add readme, docs, fmt
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
# signal-gateway-assistant
|
||||||
|
|
||||||
|
Trait used to represent conversational assistant in `signal-gateway`.
|
||||||
|
|
||||||
|
You can implement this trait yourself in order to customize `signal-gateway`.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# signal-gateway-assistant-claude
|
||||||
|
|
||||||
|
A stock implementation of the `signal-gateway-assitant` trait, using anthropic's claude API.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# signal-gateway-code-tool
|
||||||
|
|
||||||
|
A tool that can be provided to the `signal-gateway-assistant`, which allows it
|
||||||
|
to fetch and read code without giving it shell access.
|
||||||
|
|
||||||
|
If configured with a github read-only access token, and if you give it a route
|
||||||
|
to query the current git SHA of your deployed binary, it can transparently fetch the code
|
||||||
|
corresponding to that.
|
||||||
@@ -72,7 +72,10 @@ impl CachedFile {
|
|||||||
pub fn line_range(&self, start: Option<u32>, end: Option<u32>) -> impl Iterator<Item = &str> {
|
pub fn line_range(&self, start: Option<u32>, end: Option<u32>) -> impl Iterator<Item = &str> {
|
||||||
let total_lines = self.line_count();
|
let total_lines = self.line_count();
|
||||||
let start_line = start.unwrap_or(1).saturating_sub(1); // Convert to 0-indexed
|
let start_line = start.unwrap_or(1).saturating_sub(1); // Convert to 0-indexed
|
||||||
let end_line = end.unwrap_or(total_lines).min(total_lines).saturating_sub(1); // Convert to 0-indexed
|
let end_line = end
|
||||||
|
.unwrap_or(total_lines)
|
||||||
|
.min(total_lines)
|
||||||
|
.saturating_sub(1); // Convert to 0-indexed
|
||||||
|
|
||||||
LineRangeIter {
|
LineRangeIter {
|
||||||
content: &self.content,
|
content: &self.content,
|
||||||
@@ -93,7 +96,6 @@ impl CachedFile {
|
|||||||
Err(pos) => pos as u32 + 1, // pos is the number of newlines before idx
|
Err(pos) => pos as u32 + 1, // pos is the number of newlines before idx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterator over a range of lines.
|
/// Iterator over a range of lines.
|
||||||
@@ -118,7 +120,9 @@ impl<'a> Iterator for LineRangeIter<'a> {
|
|||||||
let start = if line == 0 {
|
let start = if line == 0 {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
self.newline_indices.get(line - 1).map(|&i| i as usize + 1)?
|
self.newline_indices
|
||||||
|
.get(line - 1)
|
||||||
|
.map(|&i| i as usize + 1)?
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get end offset: at this line's newline, or end of content for last line
|
// Get end offset: at this line's newline, or end of content for last line
|
||||||
|
|||||||
@@ -421,7 +421,10 @@ impl CodeTool {
|
|||||||
if context == 0 {
|
if context == 0 {
|
||||||
// No context, just print matches
|
// No context, just print matches
|
||||||
for &line_num in &file_matches {
|
for &line_num in &file_matches {
|
||||||
let line = file.line_range(Some(line_num), Some(line_num)).next().unwrap_or("");
|
let line = file
|
||||||
|
.line_range(Some(line_num), Some(line_num))
|
||||||
|
.next()
|
||||||
|
.unwrap_or("");
|
||||||
writeln!(&mut output, "{}:{}: {}", path, line_num, line)
|
writeln!(&mut output, "{}:{}: {}", path, line_num, line)
|
||||||
.map_err(|e| format!("Format error: {e}"))?;
|
.map_err(|e| format!("Format error: {e}"))?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# signal-gateway-log-ingest
|
||||||
|
|
||||||
|
Implementation of log ingest endpoints used in `signal-gateway-bin`.
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
use globset::{Glob, GlobMatcher};
|
use globset::{Glob, GlobMatcher};
|
||||||
|
|
||||||
|
/// Helper which removes prefixes (represented as a glob) from a file path,
|
||||||
|
/// trying each one in sequence.
|
||||||
|
///
|
||||||
|
/// For example, with the globset:
|
||||||
|
/// [ "/home/*/", ".cargo/registry/src/*/" ]
|
||||||
|
///
|
||||||
|
/// this can remove a lot of noise if you build from your home directory with
|
||||||
|
/// default cargo settings, regardless of what your username is etc.
|
||||||
pub struct StripPathPrefixes {
|
pub struct StripPathPrefixes {
|
||||||
finders: Vec<Finder>,
|
finders: Vec<Finder>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user