From dca629d2cfa1313951bb4a213612555bc9da8c29 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Thu, 18 Dec 2025 14:02:31 -0700 Subject: [PATCH] add readme, docs, fmt --- signal-gateway-assistant/README.md | 5 +++++ signal-gateway-assistant/claude/README.md | 3 +++ signal-gateway-code-tool/README.md | 8 ++++++++ signal-gateway-code-tool/src/cached.rs | 10 +++++++--- signal-gateway-code-tool/src/lib.rs | 5 ++++- signal-gateway-log-ingest/README.md | 3 +++ signal-gateway-log-ingest/src/path_prefix.rs | 8 ++++++++ 7 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 signal-gateway-assistant/README.md create mode 100644 signal-gateway-assistant/claude/README.md create mode 100644 signal-gateway-code-tool/README.md create mode 100644 signal-gateway-log-ingest/README.md diff --git a/signal-gateway-assistant/README.md b/signal-gateway-assistant/README.md new file mode 100644 index 0000000..1c0b1e3 --- /dev/null +++ b/signal-gateway-assistant/README.md @@ -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`. diff --git a/signal-gateway-assistant/claude/README.md b/signal-gateway-assistant/claude/README.md new file mode 100644 index 0000000..c7c7609 --- /dev/null +++ b/signal-gateway-assistant/claude/README.md @@ -0,0 +1,3 @@ +# signal-gateway-assistant-claude + +A stock implementation of the `signal-gateway-assitant` trait, using anthropic's claude API. diff --git a/signal-gateway-code-tool/README.md b/signal-gateway-code-tool/README.md new file mode 100644 index 0000000..638e71e --- /dev/null +++ b/signal-gateway-code-tool/README.md @@ -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. diff --git a/signal-gateway-code-tool/src/cached.rs b/signal-gateway-code-tool/src/cached.rs index 23cba6e..cbc1017 100644 --- a/signal-gateway-code-tool/src/cached.rs +++ b/signal-gateway-code-tool/src/cached.rs @@ -72,7 +72,10 @@ impl CachedFile { pub fn line_range(&self, start: Option, end: Option) -> impl Iterator { 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 diff --git a/signal-gateway-code-tool/src/lib.rs b/signal-gateway-code-tool/src/lib.rs index 267fd90..1aac5b0 100644 --- a/signal-gateway-code-tool/src/lib.rs +++ b/signal-gateway-code-tool/src/lib.rs @@ -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}"))?; } diff --git a/signal-gateway-log-ingest/README.md b/signal-gateway-log-ingest/README.md new file mode 100644 index 0000000..ddcee62 --- /dev/null +++ b/signal-gateway-log-ingest/README.md @@ -0,0 +1,3 @@ +# signal-gateway-log-ingest + +Implementation of log ingest endpoints used in `signal-gateway-bin`. diff --git a/signal-gateway-log-ingest/src/path_prefix.rs b/signal-gateway-log-ingest/src/path_prefix.rs index 0bff22f..7209ed7 100644 --- a/signal-gateway-log-ingest/src/path_prefix.rs +++ b/signal-gateway-log-ingest/src/path_prefix.rs @@ -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, }