Skip to content

Commit a198bde

Browse files
jgravelleclaude
andcommitted
Update docs for token savings counter (v0.2.4)
Documents _meta.tokens_saved and _meta.total_tokens_saved fields, token_tracker.py in architecture file tree, and the live counter feature in TOKEN_SAVINGS.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 68e1adf commit a198bde

3 files changed

Lines changed: 36 additions & 6 deletions

File tree

ARCHITECTURE.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ jcodemunch-mcp/
2525
│ │
2626
│ ├── storage/
2727
│ │ ├── __init__.py
28-
│ │ └── index_store.py # CodeIndex, IndexStore: save/load, incremental indexing
28+
│ │ ├── index_store.py # CodeIndex, IndexStore: save/load, incremental indexing
29+
│ │ └── token_tracker.py # Persistent token savings counter (~/.code-index/_savings.json)
2930
│ │
3031
│ ├── summarizer/
3132
│ │ ├── __init__.py
@@ -175,11 +176,15 @@ All tool responses include metadata:
175176
"timing_ms": 42,
176177
"repo": "owner/repo",
177178
"symbol_count": 387,
178-
"truncated": false
179+
"truncated": false,
180+
"tokens_saved": 2450,
181+
"total_tokens_saved": 184320
179182
}
180183
}
181184
```
182185

186+
`tokens_saved` and `total_tokens_saved` are included on all retrieval and search tools. The running total is persisted to `~/.code-index/_savings.json` across sessions.
187+
183188
---
184189

185190
## Search Algorithm

SPEC.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Recursive directory walk with the full security pipeline.
224224

225225
## Response Envelope
226226

227-
All tools return a `_meta` object with timing and context:
227+
All tools return a `_meta` object with timing, context, and token savings:
228228

229229
```json
230230
{
@@ -233,11 +233,18 @@ All tools return a `_meta` object with timing and context:
233233
"repo": "owner/repo",
234234
"symbol_count": 387,
235235
"truncated": false,
236-
"content_verified": true
236+
"content_verified": true,
237+
"tokens_saved": 2450,
238+
"total_tokens_saved": 184320
237239
}
238240
}
239241
```
240242

243+
- **`tokens_saved`**: Tokens saved by this specific call (raw file bytes vs response bytes, divided by 4)
244+
- **`total_tokens_saved`**: Cumulative tokens saved across all tool calls, persisted to `~/.code-index/_savings.json`
245+
246+
Present on: `get_file_outline`, `get_symbol`, `get_symbols`, `get_repo_outline`, `search_symbols`.
247+
241248
---
242249

243250
## Error Handling

TOKEN_SAVINGS.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,26 @@ jCodeMunch indexes a repository once and allows agents to retrieve **exact symbo
4646

4747
jCodeMunch shifts the workflow from:
4848

49-
**Read everything to find something”**
49+
**Read everything to find something”**
5050
to
51-
**“Find something, then read only that.”**
51+
**”Find something, then read only that.”**
52+
53+
---
54+
55+
## Live Token Savings Counter
56+
57+
Every tool response includes real-time savings data in the `_meta` field:
58+
59+
```json
60+
“_meta”: {
61+
“tokens_saved”: 2450,
62+
“total_tokens_saved”: 184320
63+
}
64+
```
65+
66+
- **`tokens_saved`**: Tokens saved by the current call (raw file bytes vs response bytes ÷ 4)
67+
- **`total_tokens_saved`**: Cumulative total across all calls, persisted to `~/.code-index/_savings.json`
68+
69+
No extra API calls or file reads — computed using fast `os.stat` only.
5270

5371
---

0 commit comments

Comments
 (0)