Skip to content

Commit 88d2cfc

Browse files
author
John O'Hare
committed
docs: Update for human-readable tool summaries and LLM fallback
- README: Add summarizer feature, summarizer.rs module, LLM config options (llm_summarize_url, llm_api_key), fix config example to show snake_case (both formats accepted) - ARCHITECTURE: Add summarizer.rs to module dependency graph, update tool start flow to show summarization step - DEVELOPMENT: Add summarizer.rs to project structure, update test counts (21 total, 11 in formatting), add summarizer deep dive section with examples and LLM fallback docs, add reqwest dependency Co-Authored-By: DreamLabAI <github@thedreamlab.uk>
1 parent eeae286 commit 88d2cfc

File tree

3 files changed

+51
-10
lines changed

3 files changed

+51
-10
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ claude
3939

4040
- **CLI to Telegram**: Mirror Claude's responses, tool usage, and notifications
4141
- **Telegram to CLI**: Send prompts from Telegram directly to Claude Code
42+
- **Human-Readable Summaries**: Tool actions shown as natural language ("Running tests", "Editing config.rs") instead of raw operations, with optional LLM fallback for unknown tools
4243
- **Stop/Interrupt**: Type `stop` in Telegram to send Escape and halt Claude mid-process
4344
- **Kill**: Type `kill` to send Ctrl-C and exit Claude entirely
4445
- **Session Threading**: Each Claude session gets its own Forum Topic
@@ -130,7 +131,8 @@ When Claude requests tool permission, you'll see inline keyboard buttons:
130131
| `hook.rs` | Claude Code hook event processing |
131132
| `injector.rs` | tmux command injection (Command::arg, no shell) |
132133
| `config.rs` | Configuration: env > file > defaults, secure perms |
133-
| `formatting.rs` | Message formatting, ANSI stripping, chunking |
134+
| `formatting.rs` | Message formatting, ANSI stripping, tool summaries |
135+
| `summarizer.rs` | LLM-backed fallback summarizer (optional, for unknown tools) |
134136
| `types.rs` | Shared types: BridgeMessage, HookEvent, Session |
135137
| `error.rs` | Error types via thiserror |
136138

@@ -198,6 +200,8 @@ export TELEGRAM_MIRROR=true
198200
# export TELEGRAM_AUTO_DELETE_TOPICS=true # Delete topics on session end
199201
# export TELEGRAM_TOPIC_DELETE_DELAY=5 # Minutes before topic deletion
200202
# export TELEGRAM_BRIDGE_SOCKET=~/.config/claude-telegram-mirror/bridge.sock
203+
# export CTM_LLM_SUMMARIZE_URL=https://api.anthropic.com/v1/messages
204+
# export CTM_LLM_API_KEY=sk-ant-... # For LLM-powered tool summaries
201205
```
202206

203207
### Config File (Alternative)
@@ -206,15 +210,19 @@ export TELEGRAM_MIRROR=true
206210

207211
```json
208212
{
209-
"botToken": "your-token",
210-
"chatId": -1001234567890,
213+
"bot_token": "your-token",
214+
"chat_id": -1001234567890,
211215
"enabled": true,
212216
"verbose": true,
213-
"useThreads": true,
214-
"autoDeleteTopics": false
217+
"use_threads": true,
218+
"auto_delete_topics": false,
219+
"llm_summarize_url": "https://api.anthropic.com/v1/messages",
220+
"llm_api_key": "sk-ant-..."
215221
}
216222
```
217223

224+
Both `snake_case` and `camelCase` field names are accepted.
225+
218226
Environment variables take precedence over config file values.
219227

220228
### Claude Code Hook Installation

docs/ARCHITECTURE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ graph LR
6363
BRIDGE --> INJ
6464
BRIDGE --> CONFIG
6565
BRIDGE --> FMT[formatting.rs]
66+
BRIDGE --> SUMM[summarizer.rs]
67+
68+
SUMM --> FMT
6669
6770
HOOK --> TYPES[types.rs]
6871
HOOK --> INJ
@@ -113,7 +116,8 @@ sequenceDiagram
113116
else AgentResponse
114117
Bridge->>Bot: Send formatted response
115118
else ToolStart
116-
Bridge->>Bot: Send tool preview + Details button
119+
Bridge->>Bridge: Summarize tool action
120+
Bridge->>Bot: Send human-readable summary + Details button
117121
else TurnComplete
118122
Bridge->>Bridge: Check compaction state
119123
end

docs/DEVELOPMENT.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
│ ├── hook.rs # Claude Code hook processor
1616
│ ├── injector.rs # tmux command injection
1717
│ ├── config.rs # Configuration loading
18-
│ ├── formatting.rs # Message formatting
18+
│ ├── formatting.rs # Message formatting + tool summaries
19+
│ ├── summarizer.rs # LLM-backed fallback summarizer
1920
│ ├── types.rs # Shared type definitions
2021
│ └── error.rs # Error types
2122
├── scripts/
@@ -68,9 +69,9 @@ cargo test session::tests
6869
|--------|-------|---------------|
6970
| `session.rs` | 3 | CRUD, lifecycle, approvals |
7071
| `socket.rs` | 2 | Server lifecycle, flock double-start prevention |
71-
| `formatting.rs` | 3 | ANSI stripping, truncation, path shortening |
72-
| `injector.rs` | 1 | Key whitelist validation |
73-
| `config.rs` | 2 | Environment loading, validation |
72+
| `formatting.rs` | 11 | ANSI stripping, truncation, path shortening, tool action summaries (bash/cargo/git, file ops, search, task, unknown), tool result summaries (success, error) |
73+
| `injector.rs` | 2 | Key whitelist validation, no-target safety |
74+
| `config.rs` | 2 | Environment loading, config file defaults |
7475

7576
## Code Quality
7677

@@ -98,6 +99,7 @@ graph TB
9899
RUSQLITE[rusqlite<br/>SQLite bindings]
99100
GOVERNOR[governor<br/>rate limiting]
100101
NIX[nix<br/>Unix operations]
102+
REQWEST[reqwest<br/>HTTP client for LLM]
101103
end
102104
103105
subgraph "Serialization"
@@ -170,6 +172,33 @@ Key patterns:
170172
- Session lookup is cached in-memory with DB fallback
171173
- Tool input cache auto-expires after 5 minutes
172174
- Topic deletion is delayed and cancellable
175+
- Tool actions are summarized in natural language via `summarizer.rs` (rule-based, with optional LLM fallback)
176+
177+
### summarizer.rs - Human-Readable Tool Summaries
178+
179+
The summarizer converts raw tool operations into natural language:
180+
181+
| Tool Action | Summary |
182+
|------------|---------|
183+
| `Bash: cargo test` | "Running tests" |
184+
| `Bash: git push` | "Pushing to remote" |
185+
| `Edit: /path/to/config.rs` | "Editing config.rs" |
186+
| `Grep: pattern "auth"` | "Searching for 'auth'" |
187+
| `Task: {desc: "Explore auth"}` | "Delegating: Explore auth" |
188+
| `Unknown: CustomTool` | "Using CustomTool" (LLM fallback if configured) |
189+
190+
Two-tier architecture:
191+
1. **Rule-based** (zero latency): Covers cargo, git, npm, docker, pip, file ops, search, and 15+ system commands
192+
2. **LLM fallback** (optional): When the rule-based summary is generic ("Using X"), calls a configurable LLM endpoint (Anthropic API or Z.AI proxy) for a better summary. Results are cached (200 entries, 5s timeout)
193+
194+
Configuration:
195+
```json
196+
{
197+
"llm_summarize_url": "https://api.anthropic.com/v1/messages",
198+
"llm_api_key": "sk-ant-..."
199+
}
200+
```
201+
Or via environment: `CTM_LLM_SUMMARIZE_URL`, `CTM_LLM_API_KEY`
173202

174203
### injector.rs - Shell-Safe Command Execution
175204

0 commit comments

Comments
 (0)