Skip to content

Commit d916e64

Browse files
authored
Fix formatting and improve clarity in SPEC.md
1 parent f7b4e9f commit d916e64

1 file changed

Lines changed: 48 additions & 40 deletions

File tree

SPEC.md

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
### Token Savings
88

9-
| Scenario | Raw dump | codemunch | Savings |
10-
|----------|----------|-----------|---------|
11-
| Explore 500-file repo structure | ~200,000 tokens | ~2,000 tokens | **99%** |
12-
| Find a specific function | ~40,000 tokens | ~200 tokens | **99.5%** |
13-
| Read one function body | ~40,000 tokens | ~500 tokens | **98.7%** |
14-
| Understand module API | ~15,000 tokens | ~800 tokens | **94.7%** |
9+
| Scenario | Raw dump | codemunch | Savings |
10+
| ------------------------------- | --------------- | ------------- | --------- |
11+
| Explore 500-file repo structure | ~200,000 tokens | ~2,000 tokens | **99%** |
12+
| Find a specific function | ~40,000 tokens | ~200 tokens | **99.5%** |
13+
| Read one function body | ~40,000 tokens | ~500 tokens | **98.7%** |
14+
| Understand module API | ~15,000 tokens | ~800 tokens | **94.7%** |
1515

1616
---
1717

@@ -28,7 +28,7 @@
2828
}
2929
```
3030

31-
Fetches source via `git/trees?recursive=1` (single API call), filters through security pipeline, parses with tree-sitter, summarizes, saves index + raw files.
31+
Fetches source via `git/trees?recursive=1` (single API call), filters through the security pipeline, parses with tree-sitter, summarizes, and saves the index plus raw files.
3232

3333
#### `index_folder` — Index a local folder
3434

@@ -40,7 +40,7 @@ Fetches source via `git/trees?recursive=1` (single API call), filters through se
4040
}
4141
```
4242

43-
Walks local directory with full security controls: path traversal prevention, symlink escape protection, secret detection, binary filtering, .gitignore respect.
43+
Walks the local directory with full security controls: path traversal prevention, symlink escape protection, secret detection, binary filtering, and `.gitignore` respect.
4444

4545
#### `invalidate_cache` — Delete index for a repository
4646

@@ -52,11 +52,13 @@ Walks local directory with full security controls: path traversal prevention, sy
5252

5353
Deletes both the index JSON and raw content directory.
5454

55+
---
56+
5557
### Discovery Tools
5658

5759
#### `list_repos` — List indexed repositories
5860

59-
No input required. Returns all indexed repos with symbol counts, file counts, languages, and index version.
61+
No input required. Returns all indexed repositories with symbol counts, file counts, languages, and index version.
6062

6163
#### `get_file_tree` — Get file structure
6264

@@ -67,7 +69,7 @@ No input required. Returns all indexed repos with symbol counts, file counts, la
6769
}
6870
```
6971

70-
Returns nested directory tree with per-file language and symbol count annotations.
72+
Returns a nested directory tree with per-file language and symbol count annotations.
7173

7274
#### `get_file_outline` — Get symbols in a file
7375

@@ -78,9 +80,9 @@ Returns nested directory tree with per-file language and symbol count annotation
7880
}
7981
```
8082

81-
Returns hierarchical symbol tree (classes contain methods) with signatures and summaries. No source code use `get_symbol` for that.
83+
Returns a hierarchical symbol tree (classes contain methods) with signatures and summaries. Source code is not included; use `get_symbol` for that.
8284

83-
#### `get_repo_outline` — High-level repo overview
85+
#### `get_repo_outline` — High-level repository overview
8486

8587
```json
8688
{
@@ -90,6 +92,8 @@ Returns hierarchical symbol tree (classes contain methods) with signatures and s
9092

9193
Returns directory file counts, language breakdown, and symbol kind distribution. Lighter than `get_file_tree`.
9294

95+
---
96+
9397
### Retrieval Tools
9498

9599
#### `get_symbol` — Get full source of a symbol
@@ -103,7 +107,7 @@ Returns directory file counts, language breakdown, and symbol kind distribution.
103107
}
104108
```
105109

106-
Retrieves source via byte-offset seeking (O(1)). Optional `verify` re-hashes source and compares to stored `content_hash`. Optional `context_lines` includes surrounding lines.
110+
Retrieves source via byte-offset seeking (O(1)). Optional `verify` re-hashes the source and compares it to the stored `content_hash`. Optional `context_lines` includes surrounding lines.
107111

108112
#### `get_symbols` — Batch retrieve multiple symbols
109113

@@ -114,7 +118,9 @@ Retrieves source via byte-offset seeking (O(1)). Optional `verify` re-hashes sou
114118
}
115119
```
116120

117-
Returns symbols list + errors list for any IDs not found.
121+
Returns a list of symbols plus an error list for any IDs not found.
122+
123+
---
118124

119125
### Search Tools
120126

@@ -144,7 +150,7 @@ Weighted scoring search across name, signature, summary, keywords, and docstring
144150
}
145151
```
146152

147-
Case-insensitive substring search across indexed file contents. Returns matching lines with file, line number, and context. Use when symbol search misses (string literals, comments, config values).
153+
Case-insensitive substring search across indexed file contents. Returns matching lines with file, line number, and surrounding context. Use when symbol search misses (string literals, comments, config values).
148154

149155
---
150156

@@ -188,30 +194,31 @@ class CodeIndex:
188194
languages: dict[str, int] # language → file count
189195
symbols: list[dict] # Serialized symbols (no source)
190196
file_hashes: dict[str, str] # file_path → SHA-256 (for incremental)
191-
git_head: str # HEAD commit hash (for git repos)
197+
git_head: str # HEAD commit hash (for git repos, empty if unavailable)
192198
```
193199

194200
---
195201

196202
## File Discovery
197203

198-
### GitHub Repos
204+
### GitHub Repositories
199205

200-
Single API call: `GET /repos/{owner}/{repo}/git/trees/HEAD?recursive=1`
206+
Single API call:
207+
`GET /repos/{owner}/{repo}/git/trees/HEAD?recursive=1`
201208

202209
### Local Folders
203210

204-
Recursive directory walk with full security pipeline.
211+
Recursive directory walk with the full security pipeline.
205212

206-
### Filtering Pipeline (both paths)
213+
### Filtering Pipeline (Both Paths)
207214

208215
1. **Extension filter** — must be in `LANGUAGE_EXTENSIONS` (.py, .js, .jsx, .ts, .tsx, .go, .rs, .java)
209216
2. **Skip patterns**`node_modules/`, `vendor/`, `.git/`, `build/`, `dist/`, lock files, minified files, etc.
210-
3. **.gitignore** — respected via `pathspec` library
211-
4. **Secret detection**`.env`, `*.pem`, `*.key`, `*.p12`, credentials files blocked
217+
3. **`.gitignore`** — respected via the `pathspec` library
218+
4. **Secret detection**`.env`, `*.pem`, `*.key`, `*.p12`, credentials files excluded
212219
5. **Binary detection** — extension-based + null-byte content sniffing
213-
6. **Size limit**500KB per file (configurable)
214-
7. **File count limit** — 500 files max, prioritized: `src/` > `lib/` > `pkg/` > `cmd/` > `internal/` > rest
220+
6. **Size limit**500 KB per file (configurable)
221+
7. **File count limit** — 500 files max, prioritized: `src/` `lib/` `pkg/` `cmd/` `internal/` → remainder
215222

216223
---
217224

@@ -236,31 +243,32 @@ All tools return a `_meta` object with timing and context:
236243
## Error Handling
237244

238245
All errors return:
246+
239247
```json
240248
{
241249
"error": "Human-readable message",
242250
"_meta": { "timing_ms": 1 }
243251
}
244252
```
245253

246-
| Scenario | Behavior |
247-
|----------|----------|
248-
| Repo not found (GitHub 404) | Error with message |
249-
| Rate limited (GitHub 403) | Error with reset time, suggest `GITHUB_TOKEN` |
250-
| File fetch fails | Skip file, continue indexing |
251-
| Parse fails (single file) | Skip file, continue |
252-
| No source files found | Error message |
253-
| Symbol ID not found | Error in response |
254-
| Repo not indexed | Error, suggest running index tool |
255-
| AI summarization fails | Fall back to docstring/signature |
256-
| Index version mismatch | Old index ignored, full reindex needed |
254+
| Scenario | Behavior |
255+
| --------------------------------- | ----------------------------------------------------- |
256+
| Repository not found (GitHub 404) | Error with message |
257+
| Rate limited (GitHub 403) | Error with reset time; suggest setting `GITHUB_TOKEN` |
258+
| File fetch fails | File skipped; indexing continues |
259+
| Parse fails (single file) | File skipped; indexing continues |
260+
| No source files found | Error message returned |
261+
| Symbol ID not found | Error in response |
262+
| Repository not indexed | Error suggesting indexing first |
263+
| AI summarization fails | Falls back to docstring or signature |
264+
| Index version mismatch | Old index ignored; full reindex required |
257265

258266
---
259267

260268
## Environment Variables
261269

262-
| Variable | Purpose | Required |
263-
|----------|---------|----------|
264-
| `GITHUB_TOKEN` | GitHub API auth (higher limits, private repos) | No |
265-
| `ANTHROPIC_API_KEY` | AI summarization via Claude Haiku | No |
266-
| `CODE_INDEX_PATH` | Custom storage path (default: `~/.code-index/`) | No |
270+
| Variable | Purpose | Required |
271+
| ------------------- | -------------------------------------------------------- | -------- |
272+
| `GITHUB_TOKEN` | GitHub API authentication (higher limits, private repos) | No |
273+
| `ANTHROPIC_API_KEY` | AI summarization via Claude Haiku | No |
274+
| `CODE_INDEX_PATH` | Custom storage path (default: `~/.code-index/`) | No |

0 commit comments

Comments
 (0)