add readme, docs, fmt

This commit is contained in:
Chris Beck
2025-12-18 14:02:31 -07:00
parent d2eca44587
commit dca629d2cf
7 changed files with 38 additions and 4 deletions
+5
View File
@@ -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.
+8
View File
@@ -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.
+7 -3
View File
@@ -72,7 +72,10 @@ impl CachedFile {
pub fn line_range(&self, start: Option<u32>, end: Option<u32>) -> impl Iterator<Item = &str> {
let total_lines = self.line_count();
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 {
content: &self.content,
@@ -93,7 +96,6 @@ impl CachedFile {
Err(pos) => pos as u32 + 1, // pos is the number of newlines before idx
}
}
}
/// Iterator over a range of lines.
@@ -118,7 +120,9 @@ impl<'a> Iterator for LineRangeIter<'a> {
let start = if line == 0 {
0
} 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
+4 -1
View File
@@ -421,7 +421,10 @@ impl CodeTool {
if context == 0 {
// No context, just print 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)
.map_err(|e| format!("Format error: {e}"))?;
}
+3
View File
@@ -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};
/// 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 {
finders: Vec<Finder>,
}