token-pilot 0.19.1 → 0.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/.claude-plugin/hooks/hooks.json +21 -0
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/CHANGELOG.md +736 -580
  4. package/README.md +172 -315
  5. package/dist/agents/tp-commit-writer.md +41 -0
  6. package/dist/agents/tp-dead-code-finder.md +43 -0
  7. package/dist/agents/tp-debugger.md +45 -0
  8. package/dist/agents/tp-impact-analyzer.md +44 -0
  9. package/dist/agents/tp-migration-scout.md +43 -0
  10. package/dist/agents/tp-onboard.md +40 -0
  11. package/dist/agents/tp-pr-reviewer.md +41 -0
  12. package/dist/agents/tp-refactor-planner.md +42 -0
  13. package/dist/agents/tp-run.md +48 -0
  14. package/dist/agents/tp-test-triage.md +40 -0
  15. package/dist/agents/tp-test-writer.md +46 -0
  16. package/dist/ast-index/binary-manager.d.ts +3 -3
  17. package/dist/ast-index/binary-manager.js +74 -11
  18. package/dist/ast-index/client.d.ts +5 -1
  19. package/dist/ast-index/client.js +9 -2
  20. package/dist/cli/agent-frontmatter.d.ts +48 -0
  21. package/dist/cli/agent-frontmatter.js +189 -0
  22. package/dist/cli/bless-agents.d.ts +65 -0
  23. package/dist/cli/bless-agents.js +307 -0
  24. package/dist/cli/claudeignore.d.ts +33 -0
  25. package/dist/cli/claudeignore.js +88 -0
  26. package/dist/cli/claudemd-hygiene.d.ts +26 -0
  27. package/dist/cli/claudemd-hygiene.js +43 -0
  28. package/dist/cli/doctor-drift.d.ts +31 -0
  29. package/dist/cli/doctor-drift.js +130 -0
  30. package/dist/cli/doctor-env-check.d.ts +25 -0
  31. package/dist/cli/doctor-env-check.js +91 -0
  32. package/dist/cli/install-agents.d.ts +108 -0
  33. package/dist/cli/install-agents.js +402 -0
  34. package/dist/cli/save-doc.d.ts +42 -0
  35. package/dist/cli/save-doc.js +145 -0
  36. package/dist/cli/scan-agents.d.ts +46 -0
  37. package/dist/cli/scan-agents.js +227 -0
  38. package/dist/cli/stats.d.ts +36 -0
  39. package/dist/cli/stats.js +131 -0
  40. package/dist/cli/unbless-agents.d.ts +33 -0
  41. package/dist/cli/unbless-agents.js +85 -0
  42. package/dist/cli/uninstall-agents.d.ts +36 -0
  43. package/dist/cli/uninstall-agents.js +117 -0
  44. package/dist/config/defaults.d.ts +1 -1
  45. package/dist/config/defaults.js +14 -8
  46. package/dist/config/loader.d.ts +1 -1
  47. package/dist/config/loader.js +105 -11
  48. package/dist/core/context-registry.d.ts +16 -1
  49. package/dist/core/context-registry.js +60 -28
  50. package/dist/core/event-log.d.ts +79 -0
  51. package/dist/core/event-log.js +190 -0
  52. package/dist/core/session-registry.d.ts +43 -0
  53. package/dist/core/session-registry.js +113 -0
  54. package/dist/core/session-savings.d.ts +19 -0
  55. package/dist/core/session-savings.js +60 -0
  56. package/dist/handlers/session-budget.d.ts +32 -0
  57. package/dist/handlers/session-budget.js +61 -0
  58. package/dist/handlers/session-snapshot-persist.d.ts +22 -0
  59. package/dist/handlers/session-snapshot-persist.js +76 -0
  60. package/dist/hooks/adaptive-threshold.d.ts +27 -0
  61. package/dist/hooks/adaptive-threshold.js +46 -0
  62. package/dist/hooks/format-deny-message.d.ts +21 -0
  63. package/dist/hooks/format-deny-message.js +147 -0
  64. package/dist/hooks/installer.d.ts +7 -1
  65. package/dist/hooks/installer.js +175 -55
  66. package/dist/hooks/path-safety.d.ts +16 -0
  67. package/dist/hooks/path-safety.js +34 -0
  68. package/dist/hooks/post-bash.d.ts +46 -0
  69. package/dist/hooks/post-bash.js +77 -0
  70. package/dist/hooks/session-start.d.ts +45 -0
  71. package/dist/hooks/session-start.js +179 -0
  72. package/dist/hooks/summary-ast-index.d.ts +28 -0
  73. package/dist/hooks/summary-ast-index.js +122 -0
  74. package/dist/hooks/summary-head-tail.d.ts +15 -0
  75. package/dist/hooks/summary-head-tail.js +78 -0
  76. package/dist/hooks/summary-pipeline.d.ts +35 -0
  77. package/dist/hooks/summary-pipeline.js +63 -0
  78. package/dist/hooks/summary-regex.d.ts +14 -0
  79. package/dist/hooks/summary-regex.js +130 -0
  80. package/dist/hooks/summary-types.d.ts +29 -0
  81. package/dist/hooks/summary-types.js +9 -0
  82. package/dist/index.d.ts +15 -3
  83. package/dist/index.js +508 -131
  84. package/dist/integration/context-mode-detector.d.ts +7 -1
  85. package/dist/integration/context-mode-detector.js +51 -15
  86. package/dist/server/tool-definitions.d.ts +149 -0
  87. package/dist/server/tool-definitions.js +424 -202
  88. package/dist/server.d.ts +1 -1
  89. package/dist/server.js +456 -179
  90. package/dist/templates/agent-builder.d.ts +49 -0
  91. package/dist/templates/agent-builder.js +104 -0
  92. package/dist/types.d.ts +38 -4
  93. package/package.json +89 -87
  94. package/skills/stats/SKILL.md +13 -2
package/CHANGELOG.md CHANGED
@@ -1,580 +1,736 @@
1
- # Changelog
2
-
3
- All notable changes to Token Pilot will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [0.19.1] - 2026-04-15
9
-
10
- ### Added
11
- - **`decisions` field in `session_snapshot`** — stores key decisions with reasoning (e.g., "removed sysfee step — caused double counting"). Prevents the model from revisiting rejected approaches after context compaction.
12
-
13
- ## [0.19.0] - 2026-04-15
14
-
15
- ### Added
16
- - **`session_snapshot` tool** — capture current session state (goal, confirmed facts, files, blockers, next step) as a compact markdown block (<200 tokens). Call before context compaction or when switching direction in long sessions.
17
- - **`max_tokens` parameter** on `smart_read` and `smart_read_many` — token budget per read. Output auto-downgrades through three levels: full content → structural outline → compact (symbol names + line ranges only). Enables context-constrained sessions.
18
- - **Session compaction advisory** — policy engine now tracks total tool calls and tokens returned. Advises calling `session_snapshot()` when thresholds are reached (default: every 15 calls or after 8,000 tokens). Configurable via `compactionCallThreshold` and `compactionTokenThreshold`.
19
- - **"Why This Approach Works"** section in README explaining the 3-level optimization strategy.
20
-
21
- ### Changed
22
- - **21 tools** (was 20) — added `session_snapshot`.
23
- - **MCP instructions** updated with `session_snapshot` workflow and `max_tokens` guidance.
24
- - Benchmark numbers updated: 55 files, 102K raw → 9K outline tokens (91% savings).
25
-
26
- ## [0.18.0] - 2026-04-05
27
-
28
- ### Added
29
- - **`read_section` tool** — read a specific section from Markdown, YAML, JSON, or CSV files. Markdown: by heading name. YAML/JSON: by top-level key. CSV: by row range (`rows:1-50`). Much cheaper than reading the whole file.
30
- - **`read_for_edit` section parameter** — prepare edit context for non-code file sections. Works with all 4 formats.
31
- - **Markdown outline with line ranges** `smart_read` on `.md` files now shows `[L5-20]` ranges and hints for `read_section`.
32
- - **YAML/JSON section ranges** `smart_read` on `.yaml`/`.json` shows top-level key ranges.
33
- - **CSV smart_read** shows columns, row count, sample rows, and hints for row-range reading.
34
- - **4 section parsers** `markdown-sections.ts`, `yaml-sections.ts`, `json-sections.ts`, `csv-sections.ts`.
35
-
36
- ### Changed
37
- - **20 tools** (was 19) — added `read_section`.
38
- - **492 tests** (was 441).
39
-
40
- ### Fixed
41
- - `npm audit` — resolved brace-expansion, path-to-regexp, picomatch vulnerabilities.
42
-
43
- ## [0.17.0] - 2026-04-02
44
-
45
- ### Added
46
- - **`smart_read` scope parameter** `scope="nav"` returns names + line ranges only (2-3x smaller), `scope="exports"` shows only public API. Default `scope="full"` unchanged.
47
- - **`smart_read` auto-delta** — when a file changed since last load (within 120s), shows ADDED/REMOVED/UNCHANGED symbols instead of full re-read. Config: `smartRead.autoDelta.enabled`.
48
- - **`read_symbol` include_edit_context** — optional `include_edit_context=true` appends raw code block (max 60 lines) to save a separate `read_for_edit` call. Large symbols fall back to `read_for_edit`.
49
- - **`find_usages` mode=list** — compact `file:line` output for initial discovery, 5-10x smaller than full mode.
50
- - **`smart_read_many` per-file dedup** — skips files already in context and unchanged, returns compact reminder instead.
51
- - **Actionable hints** `read_for_edit` suggests `read_diff` after editing. Config: `display.actionableHints`.
52
- - **`symbol-display-constants.ts`**shared display constants for symbol rendering.
53
-
54
- ### Changed
55
- - **441 tests** (was 427) new tests for scope, list mode, include_edit_context, dedup.
56
- - **MCP instructions** updated with scope/mode/include_edit_context guidance.
57
- - **find_usages context rendering** sequential instead of concurrent to prevent shared cache race condition.
58
-
59
- ## [0.16.1] - 2026-03-21
60
-
61
- ### Added
62
- - **Hook interception tracking** — PreToolUse hook now records denied Read calls (file path, line count, estimated tokens) to `.token-pilot/hook-denied.jsonl`. Session analytics shows how many tokens the hook saved by intercepting unbounded reads on large code files.
63
- - **`session_analytics` hook savings** — compact report adds "Hook: intercepted N reads, saved ~X tokens" line. Verbose mode shows per-file breakdown of intercepted reads.
64
-
65
- ## [0.16.0] - 2026-03-21
66
-
67
- ### Added
68
- - **`read_symbols` tool** — batch read multiple symbols from one file in a single call (max 10). File is read once, AST resolved once. Saves N-1 round-trips vs calling `read_symbol` N times.
69
- - **`read_for_edit` batch mode** — new `symbols` array parameter reads multiple symbol edit contexts in one call. Each symbol returns raw code ready for Edit tool's `old_string`.
70
- - **`find_usages` context_lines** — new `context_lines` parameter (0-10) shows surrounding source code for each match. Eliminates follow-up `read_symbol` calls after finding usages.
71
- - **`smart_diff` affected symbols summary** — consolidated "AFFECTED SYMBOLS" section at the top of diff output, grouped by MODIFIED/ADDED/REMOVED. See all changed functions/classes at a glance.
72
-
73
- ### Changed
74
- - **19 tools** (was 18) — added `read_symbols`.
75
- - **MCP instructions** added batch read_symbols to decision rules and refactor workflow.
76
- - **427 tests** (unchanged — all pass with new features).
77
-
78
- ## [0.15.0] - 2026-03-19
79
-
80
- ### Added
81
- - **Regex fallback parser (TS/JS)** — `smart_read` now works for TypeScript/JavaScript files even without ast-index binary. Parses classes, functions, interfaces, types, enums, and class methods via regex. Zero dependencies, 130 lines. Covers ~80% of new users who fail to download ast-index.
82
- - **Regex fallback parser (Python)** — `smart_read` now works for Python files without ast-index. Parses classes, functions, async functions, decorators (`@dataclass`, `@app.route`), module constants (`UPPER_CASE`), methods with visibility detection (`_private`, `__dunder__`). 150 lines.
83
- - **Benchmark script** — `scripts/benchmark.ts` measures real token savings on public repos (express, fastify, flask). 92% average savings across 97 files ≥50 lines. Run: `npx tsx scripts/benchmark.ts`.
84
- - **Guide skill** `/guide` command shows a quick-reference table of all Token Pilot tools with usage examples and recommended workflow.
85
- - **`hooks.denyThreshold` config** — hook deny threshold is now configurable in `.token-pilot.json` (default: 300, was hardcoded 500). Intercepts ~2x more native Read calls.
86
-
87
- ### Changed
88
- - **Compact session analytics** — `session_analytics` report reduced from ~30 lines to ~5 lines. Shows calls, tokens saved, top 5 tools, top 3 files, cache hit rate on a single screen. Verbose mode (`verbose=true`) restores full breakdown.
89
- - **`server.ts` refactor** — extracted tool definitions to `server/tool-definitions.ts` and token estimate helpers to `server/token-estimates.ts` (−500 lines from server.ts).
90
- - **`find_usages` output** — results grouped by file with compact rendering. Single match per file on one line, multiple matches indented under file header.
91
- - **Stale references** all `grep_search` hints updated to `Grep` (code-audit, find-unused, find-usages).
92
- - **README** — benchmark table with real data from 4 public repos. Updated savings claims from 80% to 90% (backed by benchmark).
93
- - **427 tests** (was 393).
94
-
95
- ### Fixed
96
- - **`npx token-pilot` CLI** — symlink path resolution in `isDirectRun` check. All CLI commands now work correctly via npx.
97
- - **Regex fallback was dead code** — parsers existed but weren't wired into `client.ts` `outline()` method. Now properly called as fallback when ast-index unavailable.
98
-
99
- ## [0.14.1] - 2026-03-14
100
-
101
- ### Fixed
102
- - **CI: Node.js 24 runtime** — opted into `FORCE_JAVASCRIPT_ACTIONS_TO_NODE24` for GitHub Actions, resolving deprecation warnings for `actions/checkout@v4` and `actions/setup-node@v4`.
103
- - **CI: test matrix** — updated from Node 18+22 to Node 20+22 (Node 18 is EOL).
104
- - **Test: git commit in CI** — `read-for-edit` tests now pass `-c user.name` / `-c user.email` to `git commit`, fixing failures in environments without global git config.
105
-
106
- ## [0.14.0] - 2026-03-14
107
-
108
- ### Added
109
- - **R&D Track 0: Instrumentation** — per-call decision trace capturing file size, context state, estimated vs actual cost, and cheaper alternative suggestions. Integrated into all 18 tool handlers via `recordWithTrace()`.
110
- - **R&D Track 1: Budget Planner** — advisory layer suggesting cheaper tool alternatives (e.g. `smart_read` → `read_diff` when file already in context, → `read_symbol` when symbol known). Analytics-only, no blocking.
111
- - **R&D Track 2: Intent Router** — classifies tool calls into 7 intents (edit/debug/explore/review/analyze/search/read). Per-intent breakdown in session analytics.
112
- - **R&D Track 3: Edit Prep Mode** — `read_for_edit` with `include_callers`, `include_tests`, `include_changes` enrichment options.
113
- - **R&D Track 4: Session Cache** — tool-result-level caching with file/AST/git invalidation.
114
- - **R&D Track 5: Confidence-Based Escalation** — confidence metadata (high/medium/low) appended to `smart_read`, `read_symbol`, `read_for_edit`, `find_usages` responses. Shows known unknowns and suggested next steps.
115
- - **R&D Track 6: Working Set / Dedup** compact reminders for already-loaded files and symbols.
116
- - **R&D Track 7: Related Files Ranking** scored ranking with 6 signals (test +5, import +4, importer +3, same-dir +2, recently-changed +2, multi-ref +1). HIGH VALUE / MEDIUM / LOW buckets.
117
- - **R&D Track 8: Architecture Fingerprint** caches architecture in `.token-pilot-fingerprint.json` (24h TTL). Amortizes `project_overview` cost across sessions.
118
- - **R&D Track 9: Verified Savings Dashboard** savings breakdown by category (compression/cache/dedup), session cache hit rate, dedup stats.
119
- - **R&D Track 10: Team Policy Mode** configurable policies: `preferCheapReads`, `maxFullFileReads`, `warnOnLargeReads`, `requireReadForEditBeforeEdit`.
120
- - **7 new core modules** — `confidence.ts`, `intent-classifier.ts`, `budget-planner.ts`, `decision-trace.ts`, `session-cache.ts`, `architecture-fingerprint.ts`, `policy-engine.ts`.
121
- - **35 new tests** confidence (11), architecture-fingerprint (11), policy-engine (13). Total: 393 tests.
122
-
123
- ### Changed
124
- - **`session_analytics`** — per-intent breakdown, decision insights, savings by category.
125
- - **`project_overview`** — saves/loads architecture fingerprint for cross-session caching.
126
- - **Config** — added `policies` section to `TokenPilotConfig`.
127
-
128
- ## [0.13.0] - 2026-03-14
129
-
130
- ### Added
131
- - **Version check for all components** — on startup, checks token-pilot (npm), ast-index (GitHub releases), and context-mode (npm) in parallel. Non-blocking, fire-and-forget. Shows update notifications in stderr.
132
- - **`autoUpdate` config flag** — `updates.autoUpdate: true` in `.token-pilot.json` auto-downloads new ast-index binary on startup. Default: `false` (notify only). token-pilot and context-mode only notify (separate processes).
133
- - **`checkBinaryUpdate()`** — compares installed ast-index version vs latest GitHub release.
134
- - **`isNewerVersion()` utility** — semver comparison: strip `v` prefix, compare segments. Handles different lengths (`1.0` vs `1.0.1`).
135
- - **Common Lisp extensions** — `.lisp`, `.lsp`, `.cl`, `.asd` added to `CODE_EXTENSIONS` for ast-index v3.28+ compatibility.
136
- - **9 new tests** — `isNewerVersion()` covering major/minor/patch, same version, older, `v` prefix, different segment lengths, large numbers, real-world versions. Total: 217 tests.
137
-
138
- ### Changed
139
- - **`doctor` command** — now shows 3 sections: token-pilot (installed/latest), ast-index (installed/latest/auto-update status), context-mode (detected/latest npm). Previously only showed ast-index binary status.
140
- - **`install-ast-index` command** now also updates existing binary if newer version available on GitHub.
141
- - **`printHelp()`** fixed tool count: 18 (was incorrectly showing 12 since v0.8.0).
142
- - **Startup update check** — replaced single `checkLatestVersion()` with `checkAllUpdates()` covering all 3 components via `Promise.allSettled`.
143
-
144
- ### Fixed
145
- - **`test_summary` PHPUnit parser** — now counts both `Failures:` and `Errors:` (was only counting failures).
146
- - **`test_summary` cargo parser** — correctly identifies failure name-list section (no `----` markers) vs detail section.
147
- - **`test_summary` token estimation** — uses shared `estimateTokens()` instead of local duplicate.
148
- - **`smart_log` category detection** — `documentation` now matches docs pattern, `tests` (plural) matches test pattern, `optimize`/`optimization` match perf pattern.
149
- - **`explore_area` path boundary** `startsWith(path + '/')` prevents `src/auth` matching `src/authorize/`.
150
- - **Validation consistency** — `validateSmartLogArgs` and `validateTestSummaryArgs` now use `optionalString`/`optionalNumber` helpers, reject empty strings, check integers.
151
-
152
- ## [0.11.0] - 2026-03-14
153
-
154
- ### Added
155
- - **`smart_log` tool** — structured git log with commit category detection (feat/fix/refactor/docs/test/chore/style/perf). Shows author breakdown, file stats (+/-), per-commit file list. Filters by path and ref. Raw git log → compact summary.
156
- - **`test_summary` tool** — runs test command and returns structured summary: total/passed/failed/skipped + failure details. Parsers for vitest, jest, pytest, phpunit, go test, cargo test, rspec, mocha + generic fallback. 200 lines of raw output → 10-15 lines.
157
- - **38 new tests**smart_log parser (5), categorizer (4), test_summary parsers (17), runner detection (8), validation (4). Total: 208 tests (was 170).
158
-
159
- ### Changed
160
- - **18 tools** (was 16) — added `smart_log`, `test_summary`
161
- - **MCP instructions** — added smart_log and test_summary to workflow guidance
162
-
163
- ## [0.10.0] - 2026-03-14
164
-
165
- ### Added
166
- - **`smart_diff` tool** — structural git diff with AST symbol mapping. Shows which functions/classes were modified/added/removed instead of raw patch output. Supports scopes: `unstaged`, `staged`, `commit` (ref required), `branch` (ref required). Small diffs (<=30 lines) include actual hunks, large diffs show summary. Returns `rawTokens` for precise savings analytics.
167
- - **`explore_area` tool** — one-call directory exploration combining outline + imports + tests + git changes. Replaces 3-5 separate tool calls when starting work on an area. Sections: `outline` (recursive depth 2), `imports` (external deps + who imports this area), `tests` (matching test/spec files), `changes` (recent git log). All sections run in parallel via `Promise.allSettled`.
168
- - **26 new tests** — smart_diff parser (10), symbol mapping (5), validation (11). Total: 170 tests (was 144).
169
-
170
- ### Changed
171
- - **16 tools** (was 14) — added `smart_diff`, `explore_area`
172
- - **MCP instructions** — updated workflow: `project_overview → explore_area → smart_read → read_symbol → read_for_edit → edit → smart_diff`
173
- - **`outlineDir` and `CODE_EXTENSIONS` exported** from outline.ts for reuse by explore_area
174
-
175
- ## [0.9.0] - 2026-03-08
176
-
177
- ### Added
178
- - **`module_info` tool** — analyze module dependencies, dependents, public API, and unused deps. Uses ast-index v3.27.0 module commands (`modules`, `module-deps`, `module-dependents`, `module-api`, `unused-deps`). Includes degradation check when ast-index is unavailable.
179
- - **`project_overview` dual-detection** — shows BOTH ast-index type detection AND config-file detection (package.json, composer.json, Cargo.toml, pyproject.toml, go.mod) with CONFIDENCE scoring (high/medium/low/unknown). Detects frameworks, quality tools (PHPStan, ESLint, Vitest, Jest, Biome, etc.), CI pipelines (GitHub Actions, GitLab CI, Jenkins), and Docker.
180
- - **`project_overview` `include` parameter** filter sections: `["stack"]` for quick type check, `["quality","ci"]` for tooling overview. Default: all sections.
181
- - **`find_usages` post-filters** — `scope` (path prefix), `kind` (definitions/imports/usages), `lang` (14 languages by extension), `limit` (per category, 1-500). All filters optional, backward compatible.
182
- - **`outline` recursive mode** — `recursive=true` with `max_depth` (default 2, max 5) recurses into subdirectories. At max depth shows file counts only.
183
- - **`src/core/project-detector.ts`** — extracted config-based detection logic into reusable module. Framework detection maps for PHP (7), JS (10), Python (5). Quality tools scanner (13 tools). CI pipeline detector (6 platforms).
184
- - **ast-index client: 5 module methods** — `modules()`, `moduleDeps()`, `moduleDependents()`, `unusedDeps()`, `moduleApi()` with JSON-first + text fallback parsing.
185
- - **ast-index types: 4 module interfaces** `AstIndexModuleEntry`, `AstIndexModuleDep`, `AstIndexUnusedDep`, `AstIndexModuleApi`.
186
-
187
- ### Fixed
188
- - **`module_info` token savings** — `tokensWouldBe` was equal to `tokensReturned` (0% savings). Now estimates manual analysis cost correctly.
189
- - **`outline` recursive overflow** — added `MAX_OUTLINE_LINES=500` guard to prevent runaway output on large projects with `recursive=true`.
190
- - **`project_overview` "frontend" label** — removed hardcoded "frontend" suffix for secondary stacks (Node.js is not always frontend).
191
- - **Ruff detection** — no longer double-reads `pyproject.toml`. Checks `ruff.toml`/`.ruff.toml` first, falls back to `pyproject.toml [tool.ruff]` only if needed.
192
- - **44 new tests** — validators (23) + project-detector (21). Total: 144 tests (was 100).
193
-
194
- ### Changed
195
- - **14 tools** (was 13) — added `module_info`
196
- - **Tool descriptions** — updated with `(v1.1: ...)` version hints for enhanced tools
197
- - **MCP instructions**added module_info to "COMBINE BOTH" workflow section
198
- - **Version sync** — package.json, plugin.json, marketplace.json all at 0.9.0
199
-
200
- ## [0.8.3] - 2026-03-08
201
-
202
- ### Fixed
203
- - **code_audit pattern search — root cause fix** — `ast-index agrep` does not support `--limit` flag. Token Pilot was passing `--limit 50` which caused the command to fail silently, returning 0 results across v0.8.0–v0.8.2. Removed the flag; results are now limited via `.slice()` after parsing.
204
-
205
- ## [0.8.2] - 2026-03-08
206
-
207
- ### Fixed
208
- - **code_audit pattern search** — inject `node_modules/.bin` into PATH so `ast-index agrep` can find `sg` (ast-grep) when it's installed as optional dependency but not in system PATH.
209
- - **code_audit annotations** — strip `@` prefix from annotation names (`@Injectable` → `Injectable`). ast-index expects names without `@`.
210
-
211
- ## [0.8.1] - 2026-03-08
212
-
213
- ### Added
214
- - **ast-grep auto-install** — `@ast-grep/cli` added as optional dependency. `code_audit(check="pattern")` now works out-of-the-box without manual `brew install ast-grep`.
215
- - **MCP instructions: security audit guidance** — instructions now recommend Grep for security patterns (password, token, secret, credential) and `find_unused` for dead code detection.
216
-
217
- ### Changed
218
- - **ast-index stats → JSON parsing** — `--format json` for reliable file count extraction instead of regex on text output.
219
-
220
- ## [0.8.0] - 2026-03-07
221
-
222
- ### Added
223
- - **`code_audit` tool** — find code quality issues in one call: TODO/FIXME comments (`check="todo"`), deprecated symbols (`check="deprecated"`), structural code patterns via ast-grep (`check="pattern"`), decorator search (`check="annotations"`), or combined audit (`check="all"`).
224
- - **Incremental index update on file changes** file watcher now triggers `ast-index update` (debounced 2s) after edits. Keeps index fresh for find_usages, find_unused, code_audit.
225
- - **ast-index client methods** — `agrep()`, `todo()`, `deprecated()`, `annotations()`, `incrementalUpdate()`.
226
-
227
- ### Fixed
228
- - **smart_read on directories** — now returns helpful message instead of EISDIR crash.
229
- - **MCP instructions** — added "COMBINE BOTH" section for audit tasks (Token Pilot + Grep).
230
-
231
- ## [0.7.6] - 2026-03-07
232
-
233
- ### Added
234
- - **`npx token-pilot init`** — one command creates `.mcp.json` with both token-pilot and context-mode configured. Idempotent — safely updates existing configs without overwriting.
235
- - **MCP Server Instructions** — protocol-level `instructions` field tells AI agents WHEN to use Token Pilot tools instead of built-in defaults. Works universally on all MCP clients.
236
- - **Improved tool descriptions** — each tool explicitly states what built-in tool it replaces (e.g. "Use INSTEAD OF Read/cat").
237
-
238
- ### Fixed
239
- - **3 high severity vulnerabilities** — updated hono and express-rate-limit.
240
- - **npm package size** — excluded source maps from package. 505 kB 286 kB (−43%).
241
- - **Accurate thresholds** — README and instructions now correctly state smallFileThreshold=200 (was 80).
242
- - **read_diff documentation** — clarified that smart_read must be called BEFORE editing to create baseline snapshot.
243
-
244
- ### Changed
245
- - **README**honest metrics (60-80%), Quick Start with `init` command, MCP instructions section, Codex/Antigravity support.
246
- - **npm keywords** — added `codex`, `cline`, `model-context-protocol`, `token-savings`.
247
-
248
- ## [0.7.4] - 2026-03-07
249
-
250
- ### Added
251
- - **MCP Server Instructions** — protocol-level `instructions` field tells AI agents WHEN to use Token Pilot tools instead of built-in Read/cat/Grep. Works universally on Claude Code, Cursor, Codex, Antigravity, and any MCP-compatible client. Includes rules for when NOT to use Token Pilot (regex search, raw content copy-paste).
252
- - **Improved tool descriptions** — each tool now explicitly states what built-in tool it replaces (e.g. "Use INSTEAD OF Read/cat", "Use INSTEAD OF Grep/ripgrep"). Agents can make informed decisions from description alone, without needing project-level rules files.
253
-
254
- ## [0.7.3] - 2026-03-07
255
-
256
- ### Fixed
257
- - **read_diff diagnostic** — when cache miss occurs, now shows resolved absolute path and all cached file paths. This reveals path mismatches between smart_read and read_diff calls (e.g. different relative paths resolving to different absolute paths).
258
-
259
- ## [0.7.2] - 2026-03-07
260
-
261
- ### Fixed
262
- - **read_diff on small files** — `smart_read` small-file pass-through (≤150 lines) returned content without caching in fileCache. `read_diff` always showed "No previous read" for small files because the baseline was never stored. Now all files are cached regardless of size.
263
-
264
- ## [0.7.1] - 2026-03-07
265
-
266
- ### Fixed
267
- - **read_diff after read_for_edit** — `read_for_edit` now caches the full file content, so `read_diff` can use it as baseline after edits. Previously returned "No previous read" because read_for_edit didn't populate the file cache.
268
- - **outline on intermediate directories** — directories with only subdirectories (no direct code files) now show subdirectory listing with recursive code file counts instead of "No code files found". Enables progressive drill-down: `outline("module/") → outline("module/infrastructure/")`.
269
-
270
- ## [0.7.0] - 2026-03-07
271
-
272
- ### Fixed
273
- - **Project root detection** — complete rewrite of how token-pilot discovers the working project:
274
- 1. **MCP roots** (new, primary)uses MCP protocol `listRoots()` to get workspace root from Claude Code. Works for all tools including `find_usages`, `find_unused`, `project_overview` (no file path needed).
275
- 2. **INIT_CWD/PWD env vars** (new) when started via `npx`, npm sets `INIT_CWD` to the invoking directory. Catches cases where `process.cwd()` is `/` but the real project root is available in env.
276
- 3. **Git detect from file path** (improved) now triggers from any tool call args (`path`, `paths`, `file`, `module`), not just `smart_read`.
277
- - **ast-index tools always disabled** — `find_usages`, `find_unused`, `project_overview` never triggered auto-detect because they have no `path` argument. Now all tools trigger detection via MCP roots.
278
- - **Error messages** — changed "project root is too broad" to actionable "call smart_read() on any project file first" when MCP roots unavailable.
279
- - **`isDangerousRoot`** — moved to shared `core/validation.ts` (was duplicated in `index.ts`).
280
-
281
- ## [0.6.5] - 2026-03-07
282
-
283
- ### Fixed
284
- - **AST index rebuild race condition** — concurrent tool calls no longer trigger multiple simultaneous rebuilds. `ensureIndex()` now deduplicates via shared promise. If rebuild fails due to lock file (another process running), falls back to existing index if available instead of throwing.
285
- - **Rebuild timeout** — increased from 60s to 120s for large projects where indexing takes longer.
286
-
287
- ## [0.6.4] - 2026-03-07
288
-
289
- ### Fixed
290
- - **CRITICAL: Hook installer** — malformed `settings.json` no longer silently destroyed. Distinguishes ENOENT (create fresh) from JSON parse error (abort with message). Uninstall also reports specific errors.
291
- - **CRITICAL: Server startup** — `startServer()` now has `.catch()` handler. Unhandled promise rejections no longer crash the process silently.
292
- - **Non-code handler** — removed `.xml` and `.csv` from `isNonCodeStructured` (no handler existed for them, fell through to null).
293
- - **Symbol resolver** — removed dangerous basename-only fallback in `pathMatches` (`index.ts` no longer matches any `index.ts`). Fixed hardcoded `endLine = start_line + 10` → uses `end_line` from ast-index or 50-line fallback.
294
- - **Config loader** — added prototype pollution guard (`__proto__`, `constructor`, `prototype` keys skipped in deepMerge). Parse errors now logged instead of silently swallowed.
295
- - **File cache** — size tracking now uses `Buffer.byteLength()` instead of `string.length` (chars bytes for non-ASCII). Removed dead `isSmallFile()` method.
296
- - **Validation**`optionalNumber` now rejects `NaN` and `Infinity`.
297
- - **Token estimation** `smart_read_many` now uses `estimateTokens()` instead of `length/4`.
298
- - **Analytics** — `project_overview` calls now tracked in session analytics.
299
- - **read_for_edit** — raised `MAX_EDIT_LINES` from 20 to 60 (20 was too aggressive, truncated most functions).
300
- - **related_files** — raised symbol search limit from 5 to 10 for reverse import detection.
301
-
302
- ### Removed
303
- - Dead config options `cache.ttlMinutes` and `context.autoForgetMinutes` (declared but never used).
304
-
305
- ## [0.6.3] - 2026-03-03
306
-
307
- ### Changed
308
- - **Hook deny threshold** — raised from 200 to 500 lines. Files ≤500 lines pass through Read without denial roundtrip. Eliminates token overhead on medium files where hook denial costs more than outline saves.
309
- - **Adaptive fallback** — lowered from 90% to 70%. If outline ≥70% of raw file size, returns raw content. More aggressive at avoiding outlines that barely save tokens.
310
- - **Tool descriptions** — trimmed marketing language, percentages, and cross-references. ~250 fewer tokens in tool list per session.
311
- - **Outline cap** — top-level symbols capped at 40, class members at 30. Prevents outline explosion on files with 100+ methods.
312
-
313
- ## [0.6.2] - 2026-03-02
314
-
315
- ### Removed
316
- - **Dead handler files** — deleted `changed-symbols.ts` (removed in v0.5.0) and `find-callers.ts` (removed in v0.4.0). Were never registered in server but lingered as dead code.
317
-
318
- ## [0.6.1] - 2026-03-02
319
-
320
- ### Changed
321
- - **`smallFileThreshold`** — raised from 80 to 200 lines. Benchmark showed medium files (100-300 lines) had negative savings (-25%) because AST outline was larger than the raw file. Files ≤200 lines now pass through as raw content.
322
- - **`smart_read` adaptive fallback** — after generating outline, compares token count vs raw file. If outline 90% of raw size, returns raw content instead. Eliminates negative savings on any file size, regardless of language or threshold.
323
- - **`session_analytics` honest metrics** — replaced all hardcoded multipliers (`*5`, `*3`) with real full-file token counts from file cache. `tokensWouldBe` now reflects actual file size, not fabricated numbers. Non-file tools (related_files, outline, find_usages) report 1:1 (no savings claim).
324
-
325
- ## [0.6.0] - 2026-03-02
326
-
327
- ### Changed
328
- - **Read hook** — upgraded from advisory (`decision: "suggest"`) to blocking (`permissionDecision: "deny"`) for unbounded Read calls on large code files (>200 lines). Bounded Read (with offset/limit) is still allowed. Uses official `hookSpecificOutput` format per Claude Code docs.
329
- - **`read_for_edit` output** — already includes exact `Read(path, offset, limit)` command that passes through the hook, giving AI a clear path: `read_for_edit` → bounded `Read` → `Edit`.
330
-
331
- ### Added
332
- - **Edit hook** — new PreToolUse hook matching Edit tool. Adds `additionalContext` suggesting `read_for_edit` for minimal code context. Doesn't block Edit — just provides a hint.
333
- - **Hook installer** — now installs and manages both Read and Edit hooks. Uninstall removes all Token Pilot hooks.
334
-
335
- ## [0.5.3] - 2026-03-02
336
-
337
- ### Changed
338
- - **`find_unused`** completely rewritten with universal approach. Removed 60+ hardcoded framework-specific names. Now uses ast-index data: constructors filtered by name (`constructor`/`__init__`), Python dunder methods by `__*__` pattern, decorated symbols detected via `outline()` and shown separately with their decorators. No framework-specific knowledge.
339
- - **`formatFrameworkInfo`** (smart_read display) removed hardcoded TypeORM (`Column`, `PrimaryGeneratedColumn`) and class-validator (`IsEmail`, `MinLength`) parsing. Now only detects standard HTTP verbs (GET/POST/PUT/DELETE/PATCH) which are protocol-level, not framework-specific. All other decorators shown as-is (`@DecoratorName`).
340
- - **`outline`** route detection now universal. Instead of hardcoding `@Controller`, detects any class decorator with a path argument as route prefix. HTTP verb detection uses same universal pattern. Non-HTTP decorators shown as-is.
341
-
342
- ## [0.5.2] - 2026-03-02
343
-
344
- ### Fixed
345
- - **`project_overview`**HINT no longer references deleted `search_code()`, now suggests `find_usages()` and `outline()`
346
- - **`related_files` imported_by** — now searches both `imports` AND `usages` from refs (not just imports), with increased limit (30). Cross-language filtering preserves same-family matches while removing false positives.
347
- - **`find_unused`**excludes framework-implicit symbols (replaced by universal approach in 0.5.3)
348
- - **README** — updated handler file list (removed deleted handlers, added new ones)
349
-
350
- ## [0.5.1] - 2026-03-02
351
-
352
- ### Fixed
353
- - **`read_for_edit` symbol mode** — large symbols (>20 lines) now return only the first 20 lines instead of the entire method. Prevents returning 300+ lines when only a signature is needed for editing.
354
- - **`related_files` imported_by** — filter cross-language false positives. A TypeScript file no longer shows Python/Go/Rust files as importers. Refs are filtered by language family (JS/TS, Python, Go, JVM, etc.).
355
- - **`session_analytics`** — honest savings metric for `read_for_edit`. Reduced multiplier from 30x to 3x (realistic comparison vs `Read` with offset/limit, not vs full file).
356
-
357
- ## [0.5.0] - 2026-03-02
358
-
359
- ### Added
360
- - **`read_for_edit`** — killer feature for edit workflow. Returns RAW code (no line numbers) around a symbol or line, ready to copy as `old_string` for Edit. 97% fewer tokens than reading full file before editing.
361
- - **`related_files`** — import graph for any file: what it imports, what imports it, test files. Saves 3-5 Read calls per task.
362
- - **`outline`** — compact overview of all code files in a directory. One call instead of 5-6 smart_read calls. Framework-aware: shows HTTP routes for NestJS controllers.
363
- - **`read_symbol` show parameter** — `show: "full"|"head"|"tail"|"outline"` controls truncation. Default: auto (full ≤300 lines, outline >300).
364
- - **Framework-aware decorators** — smart_read/outline parse NestJS (`@Controller`+`@Get` HTTP routes), TypeORM (`@Column` types), class-validator (`@IsEmail` constraints).
365
-
366
- ### Removed
367
- - **`search_code`** worse than Grep in practice, find_usages + Grep cover all use cases
368
- - **`export_ast_index`** — never used in real work, infrastructure tool only
369
- - **`context_status`** — debugging tool, not user-facing
370
- - **`forget`**manual context management = poor design, should be automatic
371
- - **`changed_symbols`**git diff + smart_read covers this use case
372
-
373
- ### Changed
374
- - **12 focused tools** instead of 14 removed 5 low-value, added 3 high-impact
375
- - Edit-heavy sessions: 5-10% → 40-50% token savings (via read_for_edit)
376
- - Average sessions: 20-25% → 45-55% token savings
377
-
378
- ## [0.4.1] - 2026-03-02
379
-
380
- ### Added
381
- - **Auto-install PreToolUse hook**: hook installs automatically on server start (Claude Code), no manual `install-hook` needed
382
- - **AI instructions template**: README includes ready-to-copy block for `.cursorrules` / `CLAUDE.md`
383
-
384
- ### Changed
385
- - **Tool descriptions rewritten** — explicit "ALWAYS use instead of Read/cat", "use instead of Grep" for AI prioritization
386
- - README updated: PreToolUse hook section, MCP Tools table with "Instead of" column
387
-
388
- ## [0.4.0] - 2026-03-02
389
-
390
- ### Added
391
- - **Python class method parser**: smart_read/read_symbol shows all methods inside Python classes with visibility, decorators, async detection
392
- - **PHP class method parser**: same for PHP classes with public/private/protected, static
393
- - **Version display**: `project_overview` and `session_analytics` show `TOKEN PILOT v{version}`
394
-
395
- ### Changed
396
- - **Removed find_callers** — did not save tokens vs grep, ast-index limitation with `this.method()` calls
397
- - **Removed find_implementations** — did not save tokens vs grep, ast-index limitation with decorators
398
- - **Removed class_hierarchy** — did not save tokens vs grep, poor results from ast-index
399
- - **14 focused tools** instead of 17 — only tools that actually save tokens or provide unique value
400
-
401
- ### Fixed
402
- - **Mega-symbol truncation**: symbols >300 lines show head (50) + tail (30) + method outline instead of 71KB overflow
403
- - **Recursive findFlat**: unqualified method names (`run`, `_build_summary`) found inside class children
404
-
405
- ## [0.3.2] - 2026-03-01
406
-
407
- ### Fixed
408
- - **Python class methods**: smart_read now shows all methods inside Python classes (ast-index only returns class-level, token-pilot parses `def` methods with visibility, decorators, async detection)
409
- - **read_symbol Python**: `Orchestrator.run`, `Orchestrator._build_summary` — qualified and unqualified method access works (was returning entire 829-line class)
410
- - **Mega-symbol truncation**: symbols >300 lines show head (50) + tail (30) + method outline instead of 71KB overflow
411
- - **findFlat recursive**: unqualified method names (`run`, `_build_summary`) now found inside class children
412
-
413
- ## [0.3.1] - 2026-03-01
414
-
415
- ### Fixed
416
- - **find_usages**: combine `refs` + `search` with exact word boundary filtering — 0% result loss vs grep (was 40% loss with refs-only)
417
- - **read_symbol**: fix `Class.method` qualified names for flat outlines (ast-index lists methods as siblings, not children)
418
- - **read_symbol**: filter ast-index leaf name fallback by requested file (was returning symbols from wrong files)
419
- - **YAML smart_read**: 3-level nested parser with scalar values, array counts (was only showing top-level keys)
420
- - Removed all "Use Grep as fallback" hints — token-pilot gives complete results on its own
421
-
422
- ## [0.3.0] - 2026-03-01
423
-
424
- ### Added
425
- - **find_callers** tool — find all callers of a function, with optional call hierarchy tree (depth parameter)
426
- - **changed_symbols** tool — show symbol-level git changes (added/modified/removed) vs a base branch
427
- - **find_unused** tool — detect potentially unused/dead symbols in the project
428
- - 8 new ast-index client methods: `refs`, `map`, `conventions`, `callers`, `callTree`, `changed`, `unusedSymbols`, `fileImports`
429
- - Incremental index updates via `ast-index update` (fast) instead of full rebuild
430
-
431
- ### Fixed
432
- - **find_usages**: rewritten to use `ast-index refs`returns definitions + imports + usages in one call (was losing ~66% of results)
433
- - **project_overview**: rewritten to use `ast-index map` + `conventions` shows architecture, frameworks, naming patterns, directory map with symbol kinds
434
- - **search_code**: deduplication of results (removes duplicate file:line entries)
435
- - **read_symbol**: structure-first lookup for `Class.method` qualified names with ast-index leaf fallback
436
- - **export_ast_index**: `all_indexed=true` option exports all files from ast-index, not just cached ones
437
- - **YAML smart_read**: expand one level of nesting (shows nested keys under top-level sections)
438
-
439
- ### Changed
440
- - Total MCP tools: 14 17
441
- - ast-index commands used: 8 16
442
- - Index updates are now incremental by default (falls back to full rebuild only when needed)
443
-
444
- ## [0.2.4] - 2026-03-01
445
-
446
- ### Fixed
447
- - **search_code**: filter out garbage entries with empty file paths or `:undefined` lines
448
- - **read_symbol**: support `Class.method` and `Class::method` qualified names (structure-first lookup, ast-index leaf fallback)
449
- - **export_ast_index**: `all_indexed=true` option exports all files from ast-index, not just cached ones
450
- - **YAML smart_read**: expand one level of nesting (shows service names, nested keys under top-level sections)
451
- - Improved empty-cache message in export_ast_index with hint about `all_indexed`
452
-
453
- ## [0.2.3] - 2026-03-01
454
-
455
- ### Fixed
456
- - **ensureIndex**: plain rebuild first (indexes full monorepo), fallback to `--sub-projects` only if <5 files
457
- - **smart_read**: non-code files (YAML, JSON, Markdown, TOML) use structural summary instead of raw content dump
458
- - **smart_read**: unsupported files return truncated 60-line preview instead of full raw content
459
- - **class_hierarchy**: proper parser for ast-index text output (Parents/Children sections)
460
- - **project_overview**: uses directory name when package.json has no `name` field
461
-
462
- ## [0.2.2] - 2026-03-01
463
-
464
- ### Fixed
465
- - Published 0.2.1 contained stale Haiku files in dist/ (tsc doesn't clean old outputs)
466
- - Added `prebuild` script (`rm -rf dist`) to prevent stale artifacts
467
- - Added `chmod +x` in prepublishOnly to ensure bin is executable
468
-
469
- ## [0.2.1] - 2026-03-01
470
-
471
- ### Fixed
472
- - **RC3**: `search_code` now merges all ast-index result types (content_matches + symbols + files + references) previously only used content_matches which was often empty
473
- - **RC4**: `class_hierarchy` and `implementations` parse text format as fallback when JSON parse fails
474
- - **RC6**: `read_symbol` auto-fetches outline from ast-index if no cached structure — no longer requires prior smart_read
475
- - `ensureIndex` uses `--sub-projects` flag for monorepo indexing
476
-
477
- ### Removed
478
- - Reverted Haiku v0.2.1removed broken PersistentFileCache, DiffEngine, RealTokenEstimator, ContextWindowTracker, smart-read-xml, context-markup
479
- - Removed 3 heavy native dependencies: `better-sqlite3`, `js-tiktoken`, `diff`
480
-
481
- ### Added
482
- - `start.sh` — bootstrap script for Claude Code plugin system
483
-
484
- ## [0.2.0] - 2026-03-01
485
-
486
- ### Fixed
487
- - **P0**: ast-index errors no longer silently swallowed — all search/usages/implementations/hierarchy/outline/symbol log errors to stderr
488
- - **P0**: `exec()` now captures and logs ast-index subprocess stderr
489
- - **P0**: `projectRoot` detected via `git rev-parse --show-toplevel` instead of `process.cwd()` (fixes wrong index root)
490
- - **P1**: `forget(all=true)` now clears both ContextRegistry and FileCache (fixes stale export_ast_index/read_diff after forget)
491
- - **P1**: `forget(path=X)` also invalidates FileCache for that path
492
- - **P2**: `read_symbol` supports PHP `::` separator (e.g. `RefundProcessor::refund`)
493
- - **P2**: `findInStructure` recursion fixed — supports 3+ level nesting (Namespace::Class::method)
494
- - `ensureIndex()`: verify index has content after `stats` force rebuild if 0 files indexed
495
-
496
- ### Changed
497
- - `project_overview`: now shows directory listing + ast-index stats (files, symbols, references) instead of stub
498
- - `project_overview`: added PHP (`composer.json`) detection
499
-
500
- ## [0.1.6] - 2026-03-01 (unpublished)
501
-
502
- ### Fixed
503
- - `ensureIndex()`: verify index has content after `stats` force rebuild if 0 files indexed (fixes empty search results on first run)
504
-
505
- ## [0.1.5] - 2026-03-01
506
-
507
- ### Fixed
508
- - PreToolUse hook: read file path from stdin (Claude Code hook format) instead of `$FILE_PATH` env var
509
- - Hook now auto-suggests `smart_read` for large code files when Claude tries to use `Read`
510
- - `session_analytics`: now tracks all tools (read_symbol, read_range, read_diff, smart_read_many, search_code, find_usages, find_implementations, class_hierarchy) — previously only tracked smart_read
511
- - Empty search/usages/implementations results now show diagnostic hints (ast-index status, fallback suggestions)
512
- - `ensureIndex()` now logs build progress and errors to stderr
513
-
514
- ## [0.1.4] - 2026-03-01
515
-
516
- ### Fixed
517
- - Lazy file watcher: watch only loaded files instead of entire project root (fixes crash on Docker volumes, home dir, WSL)
518
-
519
- ## [0.1.3] - 2026-03-01
520
-
521
- ### Fixed
522
- - Chokidar file watcher error handler (partial fix, superseded by 0.1.4)
523
-
524
- ## [0.1.2] - 2026-03-01
525
-
526
- ### Fixed
527
- - ast-index integration: `outline` now parses text output (JSON format not supported in v3.24.0)
528
- - ast-index `symbol` response: handle array format, normalize field names (`line`→`start_line`, `path`→`file`)
529
- - ast-index `search` response: handle `{content_matches: [...]}` wrapper
530
- - ast-index `usages` response: map `context`→`text`, `path`→`file`
531
- - Server version now read dynamically from package.json
532
-
533
- ### Added
534
- - `token-pilot doctor` — diagnostics command (checks ast-index, Node.js, config, updates)
535
- - `token-pilot --version` — print current version
536
- - Update check on server startup (non-blocking, logs to stderr)
537
- - `/mcp add` installation method documented for Claude Code chat
538
- - Troubleshooting section in README
539
-
540
- ## [0.1.1] - 2026-03-01
541
-
542
- ### Added
543
- - `npx -y token-pilot` — zero-install for any MCP client (Cursor, Cline, Continue, etc.)
544
- - Claude Code plugin marketplace support (`.claude-plugin/marketplace.json`)
545
- - `start.sh` bootstrap script — auto `npm install` + `npm run build` on first run
546
- - `npm publish` ready (`files` field, `prepublishOnly` script)
547
- - Universal install instructions in README for Claude Code, Cursor, Cline
548
-
549
- ### Changed
550
- - `.mcp.json` now uses `start.sh` for reliable bootstrap
551
- - README reorganized: npx as primary install, from-source as fallback
552
-
553
- ## [0.1.0] - 2026-03-01
554
-
555
- ### Added
556
-
557
- - **Core Reading Tools**: `smart_read`, `read_symbol`, `read_range`, `read_diff`, `smart_read_many`
558
- - AST-based structural overviews saving 80-95% tokens
559
- - Small file pass-through (< 80 lines returned in full)
560
- - O(n) diff algorithm for re-reads
561
- - Advisory context registry with compact reminders
562
- - **Search & Navigation**: `search_code`, `find_usages`, `find_implementations`, `class_hierarchy`, `project_overview`
563
- - Powered by ast-index (tree-sitter + SQLite FTS5)
564
- - Cross-file symbol resolution
565
- - **Context Management**: `session_analytics`, `context_status`, `forget`
566
- - Token savings tracking per tool and per file
567
- - Advisory (non-blocking) context tracking
568
- - **Integration**: `export_ast_index`
569
- - context-mode detection and complementary architecture
570
- - AST data export for BM25 cross-indexing
571
- - **Infrastructure**
572
- - Git HEAD watcher with selective cache invalidation on branch switch
573
- - File watcher (chokidar) for automatic cache invalidation
574
- - LRU file cache with configurable size limit
575
- - Input validation for all tools (path traversal protection)
576
- - Auto-download of ast-index binary from GitHub releases
577
- - PreToolUse hook installer for Claude Code
578
- - Claude Code plugin format (.claude-plugin/)
579
- - Non-code structural summaries (JSON, YAML, Markdown, TOML)
580
- - Configurable via `.token-pilot.json`
1
+ # Changelog
2
+
3
+ All notable changes to Token Pilot will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.22.2] - 2026-04-18
9
+
10
+ ### Fixed
11
+
12
+ - **`session_snapshot` silently dropped `decisions[]`** — the tool schema exposed the field and the renderer consumed it, but the server dispatch's inline cast type omitted it, so every snapshot lost its Decisions section. Fix: added `decisions?: string[]` to the cast. Regression-guarded by new `tests/handlers/session-snapshot.test.ts` covering every schema field.
13
+ - **Help text tool count out of date** — `token-pilot --help` said `MCP Tools (20)` but the server registers 22. Corrected count + listed all 22 (including `read_section` and `read_symbols`).
14
+ - **README doc drift** — hard-coded `(21)` in the MCP Tools heading and "six subagents" throughout. Replaced with count-free phrasing; added Tier 1 / Tier 2 tables covering all 11 subagents; added `session_budget` to the Session tools row.
15
+
16
+ ### Changed
17
+
18
+ - **Session-registry flush on signal termination** — `SessionRegistryManager.flushAll()` is now wired to `SIGINT` and `SIGTERM` in addition to `beforeExit` (the latter doesn't fire on signal-based termination).
19
+ - Clarified the `shutdownFlush` comment about `process.exit()` limitations.
20
+ - Added a one-line intro to the README subagents section explaining the Tier 1 vs Tier 2 split.
21
+
22
+ ### Numbers
23
+ - 881 tests green (+2 regression tests for `session_snapshot`), `tsc --noEmit` clean.
24
+
25
+ ## [0.22.1] - 2026-04-18
26
+
27
+ ### Added — TP-02l Tier 2 subagents (5 new)
28
+
29
+ Five more `tp-*` specialists, installed alongside the existing six via `npx token-pilot install-agents`:
30
+
31
+ - **`tp-debugger`** bug diagnosis via call-tree traversal (`find_usages` + `read_symbol` + `smart_log`). Given a stack trace or error, finds the root-cause line without Reading whole files.
32
+ - **`tp-migration-scout`** pre-migration impact map. Given a target (API, symbol, dependency), emits a file-by-file checklist grouped by effort class (trivial / local / cross-file / needs-design).
33
+ - **`tp-test-writer`**writes tests for one specific symbol, mirroring the project's existing test style. Runs `test_summary` before declaring done — refuses to claim success on tests it didn't run.
34
+ - **`tp-dead-code-finder`**cross-checks `find_unused` with Grep, recent git history, and dynamic-lookup patterns before recommending deletion. Output only — never deletes.
35
+ - **`tp-commit-writer`** — drafts a Conventional-Commit message from staged diff. Refuses to write when `test_summary` reports failures, when diff mixes types (asks to split), or when staged is empty.
36
+
37
+ Total subagents now: **11** (6 Tier 1 + 5 Tier 2). Build pipeline auto-discovers `tp-*.md` files no config changes required.
38
+
39
+ ### Numbers
40
+ - 879 tests green, `tsc --noEmit` clean.
41
+
42
+ ## [0.22.0] - 2026-04-18
43
+
44
+ ### Added — TP-69m session-scoped dedup
45
+
46
+ The `ContextRegistry` that remembers "this file / symbol / range is already in your context" used to live for the MCP server process lifetime — a restart or the way Claude Code spawns short-lived server instances threw the knowledge away. Now it is per-session and persisted to disk.
47
+
48
+ Four mechanics shipped together:
49
+
50
+ 1. **`ContextRegistry` snapshot API** — new `toSnapshot()` / `loadSnapshot()` round-trip the state through plain JSON. Silent on malformed input (a broken snapshot file degrades to an empty registry, never crashes the server).
51
+ 2. **`SessionRegistryManager`** — owns a map of session_id → registry, LRU-caps the live set (default 8 sessions in memory), reads/writes `.token-pilot/context-registries/<id>.json`. Unsafe ids (empty, traversal, slashes) get an ephemeral in-memory registry that is never persisted.
52
+ 3. **Per-call `pickRegistry` in server.ts**`smart_read`, `read_symbol`, `read_range`, `smart_read_many` now pick the right registry for each tool call based on args. No `session_id` → process-default (legacy behaviour). Flushes to disk after every successful dedup-aware call.
53
+ 4. **`force: true` escape hatch** — new optional arg on the four dedup tools. When compaction has evicted an earlier result from the agent's window, `force: true` returns the full content instead of a "you already loaded this" pointer. Critical: without it, a session-scoped dedup pointing to a compacted turn would be an impossible-to-escape pit.
54
+
55
+ Schema additions on `smart_read` / `read_symbol` / `read_range` / `smart_read_many`: optional `session_id: string` and `force: boolean`. Backwards compatible — existing callers see no change.
56
+
57
+ Shutdown: `SessionRegistryManager.flushAll()` is attached to `process.beforeExit` so any registries that missed their post-call flush still land on disk.
58
+
59
+ ### Numbers
60
+ - 879 tests green, `tsc --noEmit` clean.
61
+
62
+ ## [0.21.2] - 2026-04-18
63
+
64
+ ### Added
65
+ - **`session_snapshot` auto-persist + SessionStart resume pointer (TP-340)** — calling `session_snapshot` now writes the rendered block to `.token-pilot/snapshots/<iso>.md` and `latest.md` (opt-out via `persist: false`). SessionStart hook surfaces a one-line pointer when the latest snapshot is fresh (<24h), so a new window after `/clear`, compaction, or a fresh process can pick up the thread without re-hydrating context by hand. Retention keeps the last 10 archived snapshots.
66
+ - **`session_budget` MCP tool (TP-hsz batch A)** — new tool reports the live session's saved tokens, configured budget, burn fraction (clamped 0..1), base threshold, and the effective threshold the adaptive curve would apply right now. Small payload (~80 tokens) — the agent can poll cheaply before a big read to decide whether to tighten up.
67
+ - **Context-mode auto-suggest in Bash advisor (TP-hsz batch A)** — when `.mcp.json` advertises context-mode, the large-Bash-output advisory now mentions `mcp__context-mode__execute` as an option (sandbox keeps stdout out of the window). Sync detector — no async plumbing added to the hook.
68
+ - **Time-to-compact projection in `session_budget` (TP-hsz batch B)** — payload now includes `eventCount`, `avgSavedPerEvent`, `eventsUntilExhaustion`, `firstEventMs`, `lastEventMs`. Agent can see how many more same-shape turns the adaptive budget will tolerate at the current burn rate.
69
+
70
+ ### Changed
71
+ - **Snapshot resume pointer is tighter and more informative** — SessionStart "fresh snapshot" window narrowed from 24h to 2h (an unrelated next-day task shouldn't inherit yesterday's thread) and now surfaces the snapshot's `Goal:` extract inline so the agent can eyeball relevance before reading `latest.md`.
72
+ - **Clarified adaptive-threshold / `session_budget` semantics** — `burnFraction` is Read-hook suppression pressure, NOT context-window occupancy. Token Pilot has no visibility into actual window state; the new docstrings and tool descriptions say so explicitly, and the `session_budget` payload carries a `semantics:` hint. No behaviour change; naming-only clarification before TP-69m builds on the same signal.
73
+
74
+ ### Numbers
75
+ - 873 tests green, `tsc --noEmit` clean.
76
+
77
+ ## [0.21.1] - 2026-04-18
78
+
79
+ ### Added
80
+ - **Adaptive Read-hook threshold (TP-bbo)** — opt-in `hooks.adaptiveThreshold` auto-lowers `denyThreshold` as the current session burns through `hooks.adaptiveBudgetTokens` (default 100k). Piecewise curve: unchanged below 30% burn, ×0.75 at 30–60%, ×0.5 at 60–80%, ×0.3 (floor 50 lines) beyond. Burn is read from `.token-pilot/hook-events.jsonl` `savedTokens` for the live `session_id`. Default off — zero behaviour change unless the user enables it. Env overrides: `TOKEN_PILOT_ADAPTIVE_THRESHOLD`, `TOKEN_PILOT_ADAPTIVE_BUDGET`.
81
+ - **Save-doc CLI (TP-89n)** — `token-pilot save-doc <name>` persists any stdin text (curl, WebFetch, long research notes) to `.token-pilot/docs/<name>.md` so it survives compaction and can be re-read cheaply with `smart_read` / `read_range` instead of refetching the external source. `token-pilot list-docs` enumerates saved docs. Name validation refuses traversal / path separators; overwrite is explicit (`--overwrite`).
82
+
83
+ ### Numbers
84
+ - 862 tests green, `tsc --noEmit` clean.
85
+
86
+ ## [0.21.0] - 2026-04-18
87
+
88
+ ### Added
89
+ - **`doctor` Claude Code env-var advisor (TP-c08)** — surfaces the four knobs the community guide flags as giving 60-80% session savings with zero code change (`CLAUDE_CODE_SUBAGENT_MODEL=haiku`, `MAX_THINKING_TOKENS=10000`, `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50`, `model=sonnet`). Pure advisory — never modifies user settings; reads both `process.env` and `~/.claude/settings.json` with fallback semantics.
90
+ - **`.claudeignore` generator (TP-rtg)** — `token-pilot init` now offers to create a `.claudeignore` with sensible defaults (node_modules, dist, build, __pycache__, lockfiles, source maps, …). Non-destructive: carries a magic-comment marker so re-runs refresh our own file in place but never clobber user-owned `.claudeignore`. `doctor` reports current status.
91
+ - **CLAUDE.md hygiene check in `doctor` (TP-rtg)** warns when `CLAUDE.md` exceeds 60 non-empty lines (that file loads into every Claude Code message; long rules are per-turn tax). Read-only; counts ignore blank lines and markdown horizontal rules.
92
+ - **Bash output advisor (TP-jzh)** — new `PostToolUse:Bash` hook. When Bash stdout exceeds ~8000 characters, the hook appends a single-line `additionalContext` tip pointing the agent at cheaper alternatives (`mcp__token-pilot__test_summary` for test runs, bounded commands, head/tail piping). Cannot truncate output in-flight — Claude Code's PostToolUse is observational for non-MCP tools — but steers the next turn.
93
+
94
+ ### Changed
95
+ - `.claude-plugin/hooks/hooks.json` and the installer now register the new PostToolUse:Bash hook alongside Read/Edit/SessionStart. Idempotent install adds it without touching existing hooks; uninstall removes PostToolUse too.
96
+
97
+ ### Numbers
98
+ - 843 tests green, `tsc --noEmit` clean.
99
+
100
+ ## [0.20.2] - 2026-04-18
101
+
102
+ ### Changed
103
+ - **`token-pilot init` now offers to install tp-* subagents** — after writing `.mcp.json`, if a TTY is attached the command asks `Install 6 tp-* subagents now? [Y/n]`. If yes, delegates to the full `install-agents` flow (scope prompt, idempotence, persistence). In non-TTY the next-step hint is printed instead of asking. Closes the gap where first-time users left `init` thinking everything was ready and only learned about subagents from a later stderr reminder.
104
+ - **Refreshed the init success message** — replaced the v0.13-era "AST-aware code reading (60-80% token savings)" line with a description of the v0.20 enforcement-layer scope.
105
+
106
+ ## [0.20.1] - 2026-04-18
107
+
108
+ ### Fixed
109
+ - **hook-events.jsonl not written** — the writeEvent helper in the hook dispatcher was fire-and-forget (`void appendEvent(...)`). `process.exit(0)` raced with the async fs write, so every event was silently dropped. Now awaits the write before returning. `token-pilot stats` and `stats --by-agent` finally show real data.
110
+
111
+ ## [0.20.0] - 2026-04-18
112
+
113
+ ### Added
114
+ - **Enforcement layer (TP-816)** — four-component architecture that makes token-pilot actually used, not just advertised.
115
+ - **`deny-enhanced` hook mode** (new default) — `PreToolUse:Read` on qualifying large code files returns a structural summary (imports, exports, declarations, head/tail fallback) **inside the denial reason**. Works for every agent, including subagents that lack MCP access. `advisory` and `off` modes remain available.
116
+ - **SessionStart hook** emits a one-shot reminder after every `/clear` / `/compact` / new session, listing the mandatory MCP tools and the installed `tp-*` subagents. Respects `sessionStart.enabled` independently of `hooks.mode`.
117
+ - **`bless-agents` CLI** scans installed agents, classifies by tool-allowlist shape (wildcard / exclusion / explicit), and writes project-level overrides adding `mcp__token-pilot__*` to category-C agents. `unbless-agents` + `doctor` upstream-drift detection close the loop.
118
+ - **Subagent family (`tp-*`)** — six Tier-1 agents with tight response budgets and verdict-first output contract: `tp-run` (800), `tp-onboard` (600), `tp-pr-reviewer` (600), `tp-impact-analyzer` (400), `tp-refactor-planner` (500), `tp-test-triage` (500). Installed via `npx token-pilot install-agents` (user or project scope, idempotent with body-hash).
119
+ - **`install-agents` / `uninstall-agents` CLI** scope resolution (flag > persisted > prompt > error), idempotence matrix (unchanged / template-upgraded / user-edited / no-hash), `--force` to overwrite user-edited (never touches files without our marker).
120
+ - **MCP startup reminder** — one-time stderr nudge when no `tp-*` agents are installed; silenced by `agents.reminder: false` or `TOKEN_PILOT_NO_AGENT_REMINDER=1`; suppressed inside subagents via `TOKEN_PILOT_SUBAGENT=1`.
121
+ - **`hook-events.jsonl` telemetry** new schema `{ts, session_id, agent_type, agent_id, event, file, lines, estTokens, summaryTokens, savedTokens}`; rotates at 10 MB, retains 30 days / 100 MB.
122
+ - **`stats` CLI** — `token-pilot stats` (default totals + top files), `--session[=<id>]` (filter to one session, most recent by default), `--by-agent` (group by `agent_type`, null rendered as "main").
123
+ - **`bench:hook` script** — `npm run bench:hook` reports p50/p95/p99 hook latency against a 1000-line fake file; thresholds from TP-816 §11 available as opt-in `--check=true` gate.
124
+
125
+ ### Changed
126
+ - **Config** — new fields: `hooks.mode` (`off` | `advisory` | `deny-enhanced`, replaces legacy boolean `hooks.enabled`), `sessionStart.*`, `agents.scope`, `agents.reminder`, `hooks.migratedFrom`.
127
+ - **Legacy migration** — `hooks.mode: "deny"` (v0.19) is rewritten to `"advisory"` on next load with a one-time stderr notice and `hooks.migratedFrom: "deny"` marker. Old `hooks.enabled: false` is migrated to `mode: "off"`. Both are idempotent.
128
+ - **Env vars** — `TOKEN_PILOT_DENY_THRESHOLD=<n>` overrides `hooks.denyThreshold`. Documented alongside `TOKEN_PILOT_MODE`, `TOKEN_PILOT_BYPASS`, `TOKEN_PILOT_DEBUG`, `TOKEN_PILOT_NO_AGENT_REMINDER`, `TOKEN_PILOT_SUBAGENT`.
129
+
130
+ ### Deferred
131
+ - **Live-LLM behavioural assertions** — the agent-behaviour acceptance ("uses MCP before raw Read; response within budget; no narration") requires a live Anthropic or Claude Code runner. Deterministic coverage (structure, budget ceiling, fixture compat) is in place; live dispatch moves to a v0.20.x follow-up.
132
+ - **Claude Code marketplace plugin** — planned for a future release; `install-agents` remains the supported path.
133
+
134
+ ### Numbers
135
+ - 806 tests green, `tsc --noEmit` clean.
136
+
137
+ ## [0.19.2] - 2026-04-15
138
+
139
+ ### Added
140
+ - **npm-first binary install** — `install-ast-index` now tries `npm install -g @ast-index/cli` before falling back to GitHub download. Works on all platforms including Windows (no more "ZIP extraction not supported" error).
141
+ - **npm binary discovery** — `findBinary` now checks the npm global prefix (`npm config get prefix`) as a 3rd resolution strategy: config system PATH npm global → managed install.
142
+
143
+ ### Fixed
144
+ - **Hook installer uses absolute paths** — hooks now write `<node> <script> hook-read` instead of bare `token-pilot hook-read`. Fixes `token-pilot: not found` in `/bin/sh` environments (nvm, npx, non-login shells).
145
+ - **Skip auto-install when running as plugin** — when `CLAUDE_PLUGIN_ROOT` is set, the MCP server no longer writes duplicate hooks into `.claude/settings.json`.
146
+ - **Auto-upgrade broken hooks** — old hooks with bare `token-pilot` commands are automatically replaced with absolute-path versions on next server start.
147
+
148
+ ### Changed
149
+ - **`BinaryStatus.source`** now includes `'npm'` as a value (shown in `doctor` and `session_analytics`).
150
+ - **`search()` supports `--type` filter** — filter results by symbol type (`class`, `function`, `interface`, etc.). Leverages ast-index ≥3.30.0.
151
+ - **`hierarchy()` supports `--in-file` / `--module` filters** — scope class hierarchy queries by filename or module path. Leverages ast-index ≥3.30.0.
152
+ - **498 tests** (was 492).
153
+
154
+ ## [0.19.1] - 2026-04-15
155
+
156
+ ### Added
157
+ - **`decisions` field in `session_snapshot`** stores key decisions with reasoning (e.g., "removed sysfee step caused double counting"). Prevents the model from revisiting rejected approaches after context compaction.
158
+
159
+ ## [0.19.0] - 2026-04-15
160
+
161
+ ### Added
162
+ - **`session_snapshot` tool** — capture current session state (goal, confirmed facts, files, blockers, next step) as a compact markdown block (<200 tokens). Call before context compaction or when switching direction in long sessions.
163
+ - **`max_tokens` parameter** on `smart_read` and `smart_read_many` — token budget per read. Output auto-downgrades through three levels: full content → structural outline → compact (symbol names + line ranges only). Enables context-constrained sessions.
164
+ - **Session compaction advisory** — policy engine now tracks total tool calls and tokens returned. Advises calling `session_snapshot()` when thresholds are reached (default: every 15 calls or after 8,000 tokens). Configurable via `compactionCallThreshold` and `compactionTokenThreshold`.
165
+ - **"Why This Approach Works"** section in README explaining the 3-level optimization strategy.
166
+
167
+ ### Changed
168
+ - **21 tools** (was 20) added `session_snapshot`.
169
+ - **MCP instructions** updated with `session_snapshot` workflow and `max_tokens` guidance.
170
+ - Benchmark numbers updated: 55 files, 102K raw → 9K outline tokens (91% savings).
171
+
172
+ ## [0.18.1] - 2026-04-13
173
+
174
+ ### Fixed
175
+ - **Hook installer uses absolute paths** — hooks now write `<node> <script> hook-read` instead of bare `token-pilot hook-read`. Fixes `token-pilot: not found` errors in `/bin/sh` environments (nvm, npx, non-login shells).
176
+ - **Skip auto-install when running as plugin** — when `CLAUDE_PLUGIN_ROOT` is set, the MCP server no longer writes duplicate hooks into `.claude/settings.json` (the plugin system handles this via `hooks.json`).
177
+ - **Auto-upgrade broken hooks** — old hooks with bare `token-pilot` commands are automatically replaced with absolute-path versions on next server start.
178
+
179
+ ### Changed
180
+ - **495 tests** (was 492).
181
+
182
+ ## [0.18.0] - 2026-04-05
183
+
184
+ ### Added
185
+ - **`read_section` tool** — read a specific section from Markdown, YAML, JSON, or CSV files. Markdown: by heading name. YAML/JSON: by top-level key. CSV: by row range (`rows:1-50`). Much cheaper than reading the whole file.
186
+ - **`read_for_edit` section parameter** — prepare edit context for non-code file sections. Works with all 4 formats.
187
+ - **Markdown outline with line ranges** — `smart_read` on `.md` files now shows `[L5-20]` ranges and hints for `read_section`.
188
+ - **YAML/JSON section ranges** — `smart_read` on `.yaml`/`.json` shows top-level key ranges.
189
+ - **CSV smart_read** — shows columns, row count, sample rows, and hints for row-range reading.
190
+ - **4 section parsers** — `markdown-sections.ts`, `yaml-sections.ts`, `json-sections.ts`, `csv-sections.ts`.
191
+
192
+ ### Changed
193
+ - **20 tools** (was 19) — added `read_section`.
194
+ - **492 tests** (was 441).
195
+
196
+ ### Fixed
197
+ - `npm audit`resolved brace-expansion, path-to-regexp, picomatch vulnerabilities.
198
+
199
+ ## [0.17.0] - 2026-04-02
200
+
201
+ ### Added
202
+ - **`smart_read` scope parameter** — `scope="nav"` returns names + line ranges only (2-3x smaller), `scope="exports"` shows only public API. Default `scope="full"` unchanged.
203
+ - **`smart_read` auto-delta** — when a file changed since last load (within 120s), shows ADDED/REMOVED/UNCHANGED symbols instead of full re-read. Config: `smartRead.autoDelta.enabled`.
204
+ - **`read_symbol` include_edit_context** — optional `include_edit_context=true` appends raw code block (max 60 lines) to save a separate `read_for_edit` call. Large symbols fall back to `read_for_edit`.
205
+ - **`find_usages` mode=list** — compact `file:line` output for initial discovery, 5-10x smaller than full mode.
206
+ - **`smart_read_many` per-file dedup** — skips files already in context and unchanged, returns compact reminder instead.
207
+ - **Actionable hints** — `read_for_edit` suggests `read_diff` after editing. Config: `display.actionableHints`.
208
+ - **`symbol-display-constants.ts`** shared display constants for symbol rendering.
209
+
210
+ ### Changed
211
+ - **441 tests** (was 427) — new tests for scope, list mode, include_edit_context, dedup.
212
+ - **MCP instructions** updated with scope/mode/include_edit_context guidance.
213
+ - **find_usages context rendering** — sequential instead of concurrent to prevent shared cache race condition.
214
+
215
+ ## [0.16.1] - 2026-03-21
216
+
217
+ ### Added
218
+ - **Hook interception tracking** — PreToolUse hook now records denied Read calls (file path, line count, estimated tokens) to `.token-pilot/hook-denied.jsonl`. Session analytics shows how many tokens the hook saved by intercepting unbounded reads on large code files.
219
+ - **`session_analytics` hook savings** — compact report adds "Hook: intercepted N reads, saved ~X tokens" line. Verbose mode shows per-file breakdown of intercepted reads.
220
+
221
+ ## [0.16.0] - 2026-03-21
222
+
223
+ ### Added
224
+ - **`read_symbols` tool** batch read multiple symbols from one file in a single call (max 10). File is read once, AST resolved once. Saves N-1 round-trips vs calling `read_symbol` N times.
225
+ - **`read_for_edit` batch mode** — new `symbols` array parameter reads multiple symbol edit contexts in one call. Each symbol returns raw code ready for Edit tool's `old_string`.
226
+ - **`find_usages` context_lines** — new `context_lines` parameter (0-10) shows surrounding source code for each match. Eliminates follow-up `read_symbol` calls after finding usages.
227
+ - **`smart_diff` affected symbols summary** — consolidated "AFFECTED SYMBOLS" section at the top of diff output, grouped by MODIFIED/ADDED/REMOVED. See all changed functions/classes at a glance.
228
+
229
+ ### Changed
230
+ - **19 tools** (was 18) — added `read_symbols`.
231
+ - **MCP instructions** — added batch read_symbols to decision rules and refactor workflow.
232
+ - **427 tests** (unchanged — all pass with new features).
233
+
234
+ ## [0.15.0] - 2026-03-19
235
+
236
+ ### Added
237
+ - **Regex fallback parser (TS/JS)** — `smart_read` now works for TypeScript/JavaScript files even without ast-index binary. Parses classes, functions, interfaces, types, enums, and class methods via regex. Zero dependencies, 130 lines. Covers ~80% of new users who fail to download ast-index.
238
+ - **Regex fallback parser (Python)** — `smart_read` now works for Python files without ast-index. Parses classes, functions, async functions, decorators (`@dataclass`, `@app.route`), module constants (`UPPER_CASE`), methods with visibility detection (`_private`, `__dunder__`). 150 lines.
239
+ - **Benchmark script** — `scripts/benchmark.ts` measures real token savings on public repos (express, fastify, flask). 92% average savings across 97 files ≥50 lines. Run: `npx tsx scripts/benchmark.ts`.
240
+ - **Guide skill** — `/guide` command shows a quick-reference table of all Token Pilot tools with usage examples and recommended workflow.
241
+ - **`hooks.denyThreshold` config** — hook deny threshold is now configurable in `.token-pilot.json` (default: 300, was hardcoded 500). Intercepts ~2x more native Read calls.
242
+
243
+ ### Changed
244
+ - **Compact session analytics** — `session_analytics` report reduced from ~30 lines to ~5 lines. Shows calls, tokens saved, top 5 tools, top 3 files, cache hit rate on a single screen. Verbose mode (`verbose=true`) restores full breakdown.
245
+ - **`server.ts` refactor** — extracted tool definitions to `server/tool-definitions.ts` and token estimate helpers to `server/token-estimates.ts` (−500 lines from server.ts).
246
+ - **`find_usages` output** — results grouped by file with compact rendering. Single match per file on one line, multiple matches indented under file header.
247
+ - **Stale references** — all `grep_search` hints updated to `Grep` (code-audit, find-unused, find-usages).
248
+ - **README** — benchmark table with real data from 4 public repos. Updated savings claims from 80% to 90% (backed by benchmark).
249
+ - **427 tests** (was 393).
250
+
251
+ ### Fixed
252
+ - **`npx token-pilot` CLI** — symlink path resolution in `isDirectRun` check. All CLI commands now work correctly via npx.
253
+ - **Regex fallback was dead code** — parsers existed but weren't wired into `client.ts` `outline()` method. Now properly called as fallback when ast-index unavailable.
254
+
255
+ ## [0.14.1] - 2026-03-14
256
+
257
+ ### Fixed
258
+ - **CI: Node.js 24 runtime** — opted into `FORCE_JAVASCRIPT_ACTIONS_TO_NODE24` for GitHub Actions, resolving deprecation warnings for `actions/checkout@v4` and `actions/setup-node@v4`.
259
+ - **CI: test matrix** — updated from Node 18+22 to Node 20+22 (Node 18 is EOL).
260
+ - **Test: git commit in CI** — `read-for-edit` tests now pass `-c user.name` / `-c user.email` to `git commit`, fixing failures in environments without global git config.
261
+
262
+ ## [0.14.0] - 2026-03-14
263
+
264
+ ### Added
265
+ - **R&D Track 0: Instrumentation** — per-call decision trace capturing file size, context state, estimated vs actual cost, and cheaper alternative suggestions. Integrated into all 18 tool handlers via `recordWithTrace()`.
266
+ - **R&D Track 1: Budget Planner** — advisory layer suggesting cheaper tool alternatives (e.g. `smart_read` → `read_diff` when file already in context, → `read_symbol` when symbol known). Analytics-only, no blocking.
267
+ - **R&D Track 2: Intent Router** — classifies tool calls into 7 intents (edit/debug/explore/review/analyze/search/read). Per-intent breakdown in session analytics.
268
+ - **R&D Track 3: Edit Prep Mode** — `read_for_edit` with `include_callers`, `include_tests`, `include_changes` enrichment options.
269
+ - **R&D Track 4: Session Cache** — tool-result-level caching with file/AST/git invalidation.
270
+ - **R&D Track 5: Confidence-Based Escalation** — confidence metadata (high/medium/low) appended to `smart_read`, `read_symbol`, `read_for_edit`, `find_usages` responses. Shows known unknowns and suggested next steps.
271
+ - **R&D Track 6: Working Set / Dedup** — compact reminders for already-loaded files and symbols.
272
+ - **R&D Track 7: Related Files Ranking** — scored ranking with 6 signals (test +5, import +4, importer +3, same-dir +2, recently-changed +2, multi-ref +1). HIGH VALUE / MEDIUM / LOW buckets.
273
+ - **R&D Track 8: Architecture Fingerprint** — caches architecture in `.token-pilot-fingerprint.json` (24h TTL). Amortizes `project_overview` cost across sessions.
274
+ - **R&D Track 9: Verified Savings Dashboard** savings breakdown by category (compression/cache/dedup), session cache hit rate, dedup stats.
275
+ - **R&D Track 10: Team Policy Mode** — configurable policies: `preferCheapReads`, `maxFullFileReads`, `warnOnLargeReads`, `requireReadForEditBeforeEdit`.
276
+ - **7 new core modules** — `confidence.ts`, `intent-classifier.ts`, `budget-planner.ts`, `decision-trace.ts`, `session-cache.ts`, `architecture-fingerprint.ts`, `policy-engine.ts`.
277
+ - **35 new tests** — confidence (11), architecture-fingerprint (11), policy-engine (13). Total: 393 tests.
278
+
279
+ ### Changed
280
+ - **`session_analytics`** — per-intent breakdown, decision insights, savings by category.
281
+ - **`project_overview`** — saves/loads architecture fingerprint for cross-session caching.
282
+ - **Config** — added `policies` section to `TokenPilotConfig`.
283
+
284
+ ## [0.13.0] - 2026-03-14
285
+
286
+ ### Added
287
+ - **Version check for all components** — on startup, checks token-pilot (npm), ast-index (GitHub releases), and context-mode (npm) in parallel. Non-blocking, fire-and-forget. Shows update notifications in stderr.
288
+ - **`autoUpdate` config flag** — `updates.autoUpdate: true` in `.token-pilot.json` auto-downloads new ast-index binary on startup. Default: `false` (notify only). token-pilot and context-mode only notify (separate processes).
289
+ - **`checkBinaryUpdate()`** — compares installed ast-index version vs latest GitHub release.
290
+ - **`isNewerVersion()` utility** — semver comparison: strip `v` prefix, compare segments. Handles different lengths (`1.0` vs `1.0.1`).
291
+ - **Common Lisp extensions** — `.lisp`, `.lsp`, `.cl`, `.asd` added to `CODE_EXTENSIONS` for ast-index v3.28+ compatibility.
292
+ - **9 new tests** — `isNewerVersion()` covering major/minor/patch, same version, older, `v` prefix, different segment lengths, large numbers, real-world versions. Total: 217 tests.
293
+
294
+ ### Changed
295
+ - **`doctor` command** — now shows 3 sections: token-pilot (installed/latest), ast-index (installed/latest/auto-update status), context-mode (detected/latest npm). Previously only showed ast-index binary status.
296
+ - **`install-ast-index` command** — now also updates existing binary if newer version available on GitHub.
297
+ - **`printHelp()`**fixed tool count: 18 (was incorrectly showing 12 since v0.8.0).
298
+ - **Startup update check** — replaced single `checkLatestVersion()` with `checkAllUpdates()` covering all 3 components via `Promise.allSettled`.
299
+
300
+ ### Fixed
301
+ - **`test_summary` PHPUnit parser** — now counts both `Failures:` and `Errors:` (was only counting failures).
302
+ - **`test_summary` cargo parser** — correctly identifies failure name-list section (no `----` markers) vs detail section.
303
+ - **`test_summary` token estimation** uses shared `estimateTokens()` instead of local duplicate.
304
+ - **`smart_log` category detection** — `documentation` now matches docs pattern, `tests` (plural) matches test pattern, `optimize`/`optimization` match perf pattern.
305
+ - **`explore_area` path boundary** — `startsWith(path + '/')` prevents `src/auth` matching `src/authorize/`.
306
+ - **Validation consistency** — `validateSmartLogArgs` and `validateTestSummaryArgs` now use `optionalString`/`optionalNumber` helpers, reject empty strings, check integers.
307
+
308
+ ## [0.11.0] - 2026-03-14
309
+
310
+ ### Added
311
+ - **`smart_log` tool** — structured git log with commit category detection (feat/fix/refactor/docs/test/chore/style/perf). Shows author breakdown, file stats (+/-), per-commit file list. Filters by path and ref. Raw git log → compact summary.
312
+ - **`test_summary` tool** — runs test command and returns structured summary: total/passed/failed/skipped + failure details. Parsers for vitest, jest, pytest, phpunit, go test, cargo test, rspec, mocha + generic fallback. 200 lines of raw output → 10-15 lines.
313
+ - **38 new tests** — smart_log parser (5), categorizer (4), test_summary parsers (17), runner detection (8), validation (4). Total: 208 tests (was 170).
314
+
315
+ ### Changed
316
+ - **18 tools** (was 16) added `smart_log`, `test_summary`
317
+ - **MCP instructions** — added smart_log and test_summary to workflow guidance
318
+
319
+ ## [0.10.0] - 2026-03-14
320
+
321
+ ### Added
322
+ - **`smart_diff` tool** — structural git diff with AST symbol mapping. Shows which functions/classes were modified/added/removed instead of raw patch output. Supports scopes: `unstaged`, `staged`, `commit` (ref required), `branch` (ref required). Small diffs (<=30 lines) include actual hunks, large diffs show summary. Returns `rawTokens` for precise savings analytics.
323
+ - **`explore_area` tool** — one-call directory exploration combining outline + imports + tests + git changes. Replaces 3-5 separate tool calls when starting work on an area. Sections: `outline` (recursive depth 2), `imports` (external deps + who imports this area), `tests` (matching test/spec files), `changes` (recent git log). All sections run in parallel via `Promise.allSettled`.
324
+ - **26 new tests** — smart_diff parser (10), symbol mapping (5), validation (11). Total: 170 tests (was 144).
325
+
326
+ ### Changed
327
+ - **16 tools** (was 14) — added `smart_diff`, `explore_area`
328
+ - **MCP instructions** — updated workflow: `project_overview explore_area smart_read read_symbol read_for_edit edit smart_diff`
329
+ - **`outlineDir` and `CODE_EXTENSIONS` exported** from outline.ts for reuse by explore_area
330
+
331
+ ## [0.9.0] - 2026-03-08
332
+
333
+ ### Added
334
+ - **`module_info` tool** — analyze module dependencies, dependents, public API, and unused deps. Uses ast-index v3.27.0 module commands (`modules`, `module-deps`, `module-dependents`, `module-api`, `unused-deps`). Includes degradation check when ast-index is unavailable.
335
+ - **`project_overview` dual-detection** — shows BOTH ast-index type detection AND config-file detection (package.json, composer.json, Cargo.toml, pyproject.toml, go.mod) with CONFIDENCE scoring (high/medium/low/unknown). Detects frameworks, quality tools (PHPStan, ESLint, Vitest, Jest, Biome, etc.), CI pipelines (GitHub Actions, GitLab CI, Jenkins), and Docker.
336
+ - **`project_overview` `include` parameter** — filter sections: `["stack"]` for quick type check, `["quality","ci"]` for tooling overview. Default: all sections.
337
+ - **`find_usages` post-filters** — `scope` (path prefix), `kind` (definitions/imports/usages), `lang` (14 languages by extension), `limit` (per category, 1-500). All filters optional, backward compatible.
338
+ - **`outline` recursive mode** `recursive=true` with `max_depth` (default 2, max 5) recurses into subdirectories. At max depth shows file counts only.
339
+ - **`src/core/project-detector.ts`** — extracted config-based detection logic into reusable module. Framework detection maps for PHP (7), JS (10), Python (5). Quality tools scanner (13 tools). CI pipeline detector (6 platforms).
340
+ - **ast-index client: 5 module methods** `modules()`, `moduleDeps()`, `moduleDependents()`, `unusedDeps()`, `moduleApi()` with JSON-first + text fallback parsing.
341
+ - **ast-index types: 4 module interfaces** — `AstIndexModuleEntry`, `AstIndexModuleDep`, `AstIndexUnusedDep`, `AstIndexModuleApi`.
342
+
343
+ ### Fixed
344
+ - **`module_info` token savings** — `tokensWouldBe` was equal to `tokensReturned` (0% savings). Now estimates manual analysis cost correctly.
345
+ - **`outline` recursive overflow** added `MAX_OUTLINE_LINES=500` guard to prevent runaway output on large projects with `recursive=true`.
346
+ - **`project_overview` "frontend" label** — removed hardcoded "frontend" suffix for secondary stacks (Node.js is not always frontend).
347
+ - **Ruff detection** no longer double-reads `pyproject.toml`. Checks `ruff.toml`/`.ruff.toml` first, falls back to `pyproject.toml [tool.ruff]` only if needed.
348
+ - **44 new tests** — validators (23) + project-detector (21). Total: 144 tests (was 100).
349
+
350
+ ### Changed
351
+ - **14 tools** (was 13) — added `module_info`
352
+ - **Tool descriptions** — updated with `(v1.1: ...)` version hints for enhanced tools
353
+ - **MCP instructions** — added module_info to "COMBINE BOTH" workflow section
354
+ - **Version sync** — package.json, plugin.json, marketplace.json all at 0.9.0
355
+
356
+ ## [0.8.3] - 2026-03-08
357
+
358
+ ### Fixed
359
+ - **code_audit pattern search — root cause fix** — `ast-index agrep` does not support `--limit` flag. Token Pilot was passing `--limit 50` which caused the command to fail silently, returning 0 results across v0.8.0–v0.8.2. Removed the flag; results are now limited via `.slice()` after parsing.
360
+
361
+ ## [0.8.2] - 2026-03-08
362
+
363
+ ### Fixed
364
+ - **code_audit pattern search** — inject `node_modules/.bin` into PATH so `ast-index agrep` can find `sg` (ast-grep) when it's installed as optional dependency but not in system PATH.
365
+ - **code_audit annotations** — strip `@` prefix from annotation names (`@Injectable` → `Injectable`). ast-index expects names without `@`.
366
+
367
+ ## [0.8.1] - 2026-03-08
368
+
369
+ ### Added
370
+ - **ast-grep auto-install** `@ast-grep/cli` added as optional dependency. `code_audit(check="pattern")` now works out-of-the-box without manual `brew install ast-grep`.
371
+ - **MCP instructions: security audit guidance** instructions now recommend Grep for security patterns (password, token, secret, credential) and `find_unused` for dead code detection.
372
+
373
+ ### Changed
374
+ - **ast-index stats → JSON parsing** `--format json` for reliable file count extraction instead of regex on text output.
375
+
376
+ ## [0.8.0] - 2026-03-07
377
+
378
+ ### Added
379
+ - **`code_audit` tool** — find code quality issues in one call: TODO/FIXME comments (`check="todo"`), deprecated symbols (`check="deprecated"`), structural code patterns via ast-grep (`check="pattern"`), decorator search (`check="annotations"`), or combined audit (`check="all"`).
380
+ - **Incremental index update on file changes** — file watcher now triggers `ast-index update` (debounced 2s) after edits. Keeps index fresh for find_usages, find_unused, code_audit.
381
+ - **ast-index client methods** `agrep()`, `todo()`, `deprecated()`, `annotations()`, `incrementalUpdate()`.
382
+
383
+ ### Fixed
384
+ - **smart_read on directories** — now returns helpful message instead of EISDIR crash.
385
+ - **MCP instructions** — added "COMBINE BOTH" section for audit tasks (Token Pilot + Grep).
386
+
387
+ ## [0.7.6] - 2026-03-07
388
+
389
+ ### Added
390
+ - **`npx token-pilot init`** — one command creates `.mcp.json` with both token-pilot and context-mode configured. Idempotent — safely updates existing configs without overwriting.
391
+ - **MCP Server Instructions** protocol-level `instructions` field tells AI agents WHEN to use Token Pilot tools instead of built-in defaults. Works universally on all MCP clients.
392
+ - **Improved tool descriptions** each tool explicitly states what built-in tool it replaces (e.g. "Use INSTEAD OF Read/cat").
393
+
394
+ ### Fixed
395
+ - **3 high severity vulnerabilities** — updated hono and express-rate-limit.
396
+ - **npm package size** — excluded source maps from package. 505 kB 286 kB (−43%).
397
+ - **Accurate thresholds** — README and instructions now correctly state smallFileThreshold=200 (was 80).
398
+ - **read_diff documentation** — clarified that smart_read must be called BEFORE editing to create baseline snapshot.
399
+
400
+ ### Changed
401
+ - **README** — honest metrics (60-80%), Quick Start with `init` command, MCP instructions section, Codex/Antigravity support.
402
+ - **npm keywords** added `codex`, `cline`, `model-context-protocol`, `token-savings`.
403
+
404
+ ## [0.7.4] - 2026-03-07
405
+
406
+ ### Added
407
+ - **MCP Server Instructions** — protocol-level `instructions` field tells AI agents WHEN to use Token Pilot tools instead of built-in Read/cat/Grep. Works universally on Claude Code, Cursor, Codex, Antigravity, and any MCP-compatible client. Includes rules for when NOT to use Token Pilot (regex search, raw content copy-paste).
408
+ - **Improved tool descriptions** each tool now explicitly states what built-in tool it replaces (e.g. "Use INSTEAD OF Read/cat", "Use INSTEAD OF Grep/ripgrep"). Agents can make informed decisions from description alone, without needing project-level rules files.
409
+
410
+ ## [0.7.3] - 2026-03-07
411
+
412
+ ### Fixed
413
+ - **read_diff diagnostic** — when cache miss occurs, now shows resolved absolute path and all cached file paths. This reveals path mismatches between smart_read and read_diff calls (e.g. different relative paths resolving to different absolute paths).
414
+
415
+ ## [0.7.2] - 2026-03-07
416
+
417
+ ### Fixed
418
+ - **read_diff on small files** — `smart_read` small-file pass-through (≤150 lines) returned content without caching in fileCache. `read_diff` always showed "No previous read" for small files because the baseline was never stored. Now all files are cached regardless of size.
419
+
420
+ ## [0.7.1] - 2026-03-07
421
+
422
+ ### Fixed
423
+ - **read_diff after read_for_edit** — `read_for_edit` now caches the full file content, so `read_diff` can use it as baseline after edits. Previously returned "No previous read" because read_for_edit didn't populate the file cache.
424
+ - **outline on intermediate directories** — directories with only subdirectories (no direct code files) now show subdirectory listing with recursive code file counts instead of "No code files found". Enables progressive drill-down: `outline("module/") → outline("module/infrastructure/")`.
425
+
426
+ ## [0.7.0] - 2026-03-07
427
+
428
+ ### Fixed
429
+ - **Project root detection** complete rewrite of how token-pilot discovers the working project:
430
+ 1. **MCP roots** (new, primary) — uses MCP protocol `listRoots()` to get workspace root from Claude Code. Works for all tools including `find_usages`, `find_unused`, `project_overview` (no file path needed).
431
+ 2. **INIT_CWD/PWD env vars** (new) — when started via `npx`, npm sets `INIT_CWD` to the invoking directory. Catches cases where `process.cwd()` is `/` but the real project root is available in env.
432
+ 3. **Git detect from file path** (improved)now triggers from any tool call args (`path`, `paths`, `file`, `module`), not just `smart_read`.
433
+ - **ast-index tools always disabled** `find_usages`, `find_unused`, `project_overview` never triggered auto-detect because they have no `path` argument. Now all tools trigger detection via MCP roots.
434
+ - **Error messages** changed "project root is too broad" to actionable "call smart_read() on any project file first" when MCP roots unavailable.
435
+ - **`isDangerousRoot`** moved to shared `core/validation.ts` (was duplicated in `index.ts`).
436
+
437
+ ## [0.6.5] - 2026-03-07
438
+
439
+ ### Fixed
440
+ - **AST index rebuild race condition** — concurrent tool calls no longer trigger multiple simultaneous rebuilds. `ensureIndex()` now deduplicates via shared promise. If rebuild fails due to lock file (another process running), falls back to existing index if available instead of throwing.
441
+ - **Rebuild timeout** increased from 60s to 120s for large projects where indexing takes longer.
442
+
443
+ ## [0.6.4] - 2026-03-07
444
+
445
+ ### Fixed
446
+ - **CRITICAL: Hook installer** — malformed `settings.json` no longer silently destroyed. Distinguishes ENOENT (create fresh) from JSON parse error (abort with message). Uninstall also reports specific errors.
447
+ - **CRITICAL: Server startup** `startServer()` now has `.catch()` handler. Unhandled promise rejections no longer crash the process silently.
448
+ - **Non-code handler** — removed `.xml` and `.csv` from `isNonCodeStructured` (no handler existed for them, fell through to null).
449
+ - **Symbol resolver** — removed dangerous basename-only fallback in `pathMatches` (`index.ts` no longer matches any `index.ts`). Fixed hardcoded `endLine = start_line + 10` uses `end_line` from ast-index or 50-line fallback.
450
+ - **Config loader** added prototype pollution guard (`__proto__`, `constructor`, `prototype` keys skipped in deepMerge). Parse errors now logged instead of silently swallowed.
451
+ - **File cache** size tracking now uses `Buffer.byteLength()` instead of `string.length` (chars ≠ bytes for non-ASCII). Removed dead `isSmallFile()` method.
452
+ - **Validation** — `optionalNumber` now rejects `NaN` and `Infinity`.
453
+ - **Token estimation** — `smart_read_many` now uses `estimateTokens()` instead of `length/4`.
454
+ - **Analytics** — `project_overview` calls now tracked in session analytics.
455
+ - **read_for_edit** — raised `MAX_EDIT_LINES` from 20 to 60 (20 was too aggressive, truncated most functions).
456
+ - **related_files** raised symbol search limit from 5 to 10 for reverse import detection.
457
+
458
+ ### Removed
459
+ - Dead config options `cache.ttlMinutes` and `context.autoForgetMinutes` (declared but never used).
460
+
461
+ ## [0.6.3] - 2026-03-03
462
+
463
+ ### Changed
464
+ - **Hook deny threshold** — raised from 200 to 500 lines. Files ≤500 lines pass through Read without denial roundtrip. Eliminates token overhead on medium files where hook denial costs more than outline saves.
465
+ - **Adaptive fallback** lowered from 90% to 70%. If outline ≥70% of raw file size, returns raw content. More aggressive at avoiding outlines that barely save tokens.
466
+ - **Tool descriptions** trimmed marketing language, percentages, and cross-references. ~250 fewer tokens in tool list per session.
467
+ - **Outline cap** top-level symbols capped at 40, class members at 30. Prevents outline explosion on files with 100+ methods.
468
+
469
+ ## [0.6.2] - 2026-03-02
470
+
471
+ ### Removed
472
+ - **Dead handler files** deleted `changed-symbols.ts` (removed in v0.5.0) and `find-callers.ts` (removed in v0.4.0). Were never registered in server but lingered as dead code.
473
+
474
+ ## [0.6.1] - 2026-03-02
475
+
476
+ ### Changed
477
+ - **`smallFileThreshold`** — raised from 80 to 200 lines. Benchmark showed medium files (100-300 lines) had negative savings (-25%) because AST outline was larger than the raw file. Files ≤200 lines now pass through as raw content.
478
+ - **`smart_read` adaptive fallback**after generating outline, compares token count vs raw file. If outline ≥ 90% of raw size, returns raw content instead. Eliminates negative savings on any file size, regardless of language or threshold.
479
+ - **`session_analytics` honest metrics** replaced all hardcoded multipliers (`*5`, `*3`) with real full-file token counts from file cache. `tokensWouldBe` now reflects actual file size, not fabricated numbers. Non-file tools (related_files, outline, find_usages) report 1:1 (no savings claim).
480
+
481
+ ## [0.6.0] - 2026-03-02
482
+
483
+ ### Changed
484
+ - **Read hook** — upgraded from advisory (`decision: "suggest"`) to blocking (`permissionDecision: "deny"`) for unbounded Read calls on large code files (>200 lines). Bounded Read (with offset/limit) is still allowed. Uses official `hookSpecificOutput` format per Claude Code docs.
485
+ - **`read_for_edit` output** — already includes exact `Read(path, offset, limit)` command that passes through the hook, giving AI a clear path: `read_for_edit` → bounded `Read` → `Edit`.
486
+
487
+ ### Added
488
+ - **Edit hook** — new PreToolUse hook matching Edit tool. Adds `additionalContext` suggesting `read_for_edit` for minimal code context. Doesn't block Edit — just provides a hint.
489
+ - **Hook installer** now installs and manages both Read and Edit hooks. Uninstall removes all Token Pilot hooks.
490
+
491
+ ## [0.5.3] - 2026-03-02
492
+
493
+ ### Changed
494
+ - **`find_unused`** — completely rewritten with universal approach. Removed 60+ hardcoded framework-specific names. Now uses ast-index data: constructors filtered by name (`constructor`/`__init__`), Python dunder methods by `__*__` pattern, decorated symbols detected via `outline()` and shown separately with their decorators. No framework-specific knowledge.
495
+ - **`formatFrameworkInfo`** (smart_read display) — removed hardcoded TypeORM (`Column`, `PrimaryGeneratedColumn`) and class-validator (`IsEmail`, `MinLength`) parsing. Now only detects standard HTTP verbs (GET/POST/PUT/DELETE/PATCH) which are protocol-level, not framework-specific. All other decorators shown as-is (`@DecoratorName`).
496
+ - **`outline`** — route detection now universal. Instead of hardcoding `@Controller`, detects any class decorator with a path argument as route prefix. HTTP verb detection uses same universal pattern. Non-HTTP decorators shown as-is.
497
+
498
+ ## [0.5.2] - 2026-03-02
499
+
500
+ ### Fixed
501
+ - **`project_overview`** — HINT no longer references deleted `search_code()`, now suggests `find_usages()` and `outline()`
502
+ - **`related_files` imported_by** — now searches both `imports` AND `usages` from refs (not just imports), with increased limit (30). Cross-language filtering preserves same-family matches while removing false positives.
503
+ - **`find_unused`**excludes framework-implicit symbols (replaced by universal approach in 0.5.3)
504
+ - **README** — updated handler file list (removed deleted handlers, added new ones)
505
+
506
+ ## [0.5.1] - 2026-03-02
507
+
508
+ ### Fixed
509
+ - **`read_for_edit` symbol mode** — large symbols (>20 lines) now return only the first 20 lines instead of the entire method. Prevents returning 300+ lines when only a signature is needed for editing.
510
+ - **`related_files` imported_by** filter cross-language false positives. A TypeScript file no longer shows Python/Go/Rust files as importers. Refs are filtered by language family (JS/TS, Python, Go, JVM, etc.).
511
+ - **`session_analytics`** honest savings metric for `read_for_edit`. Reduced multiplier from 30x to 3x (realistic comparison vs `Read` with offset/limit, not vs full file).
512
+
513
+ ## [0.5.0] - 2026-03-02
514
+
515
+ ### Added
516
+ - **`read_for_edit`** — killer feature for edit workflow. Returns RAW code (no line numbers) around a symbol or line, ready to copy as `old_string` for Edit. 97% fewer tokens than reading full file before editing.
517
+ - **`related_files`** import graph for any file: what it imports, what imports it, test files. Saves 3-5 Read calls per task.
518
+ - **`outline`** — compact overview of all code files in a directory. One call instead of 5-6 smart_read calls. Framework-aware: shows HTTP routes for NestJS controllers.
519
+ - **`read_symbol` show parameter** — `show: "full"|"head"|"tail"|"outline"` controls truncation. Default: auto (full ≤300 lines, outline >300).
520
+ - **Framework-aware decorators** — smart_read/outline parse NestJS (`@Controller`+`@Get` → HTTP routes), TypeORM (`@Column` → types), class-validator (`@IsEmail` → constraints).
521
+
522
+ ### Removed
523
+ - **`search_code`** — worse than Grep in practice, find_usages + Grep cover all use cases
524
+ - **`export_ast_index`** never used in real work, infrastructure tool only
525
+ - **`context_status`** — debugging tool, not user-facing
526
+ - **`forget`** — manual context management = poor design, should be automatic
527
+ - **`changed_symbols`** git diff + smart_read covers this use case
528
+
529
+ ### Changed
530
+ - **12 focused tools** instead of 14 — removed 5 low-value, added 3 high-impact
531
+ - Edit-heavy sessions: 5-10% 40-50% token savings (via read_for_edit)
532
+ - Average sessions: 20-25% → 45-55% token savings
533
+
534
+ ## [0.4.1] - 2026-03-02
535
+
536
+ ### Added
537
+ - **Auto-install PreToolUse hook**: hook installs automatically on server start (Claude Code), no manual `install-hook` needed
538
+ - **AI instructions template**: README includes ready-to-copy block for `.cursorrules` / `CLAUDE.md`
539
+
540
+ ### Changed
541
+ - **Tool descriptions rewritten** — explicit "ALWAYS use instead of Read/cat", "use instead of Grep" for AI prioritization
542
+ - README updated: PreToolUse hook section, MCP Tools table with "Instead of" column
543
+
544
+ ## [0.4.0] - 2026-03-02
545
+
546
+ ### Added
547
+ - **Python class method parser**: smart_read/read_symbol shows all methods inside Python classes with visibility, decorators, async detection
548
+ - **PHP class method parser**: same for PHP classes with public/private/protected, static
549
+ - **Version display**: `project_overview` and `session_analytics` show `TOKEN PILOT v{version}`
550
+
551
+ ### Changed
552
+ - **Removed find_callers** — did not save tokens vs grep, ast-index limitation with `this.method()` calls
553
+ - **Removed find_implementations** — did not save tokens vs grep, ast-index limitation with decorators
554
+ - **Removed class_hierarchy** — did not save tokens vs grep, poor results from ast-index
555
+ - **14 focused tools** instead of 17 — only tools that actually save tokens or provide unique value
556
+
557
+ ### Fixed
558
+ - **Mega-symbol truncation**: symbols >300 lines show head (50) + tail (30) + method outline instead of 71KB overflow
559
+ - **Recursive findFlat**: unqualified method names (`run`, `_build_summary`) found inside class children
560
+
561
+ ## [0.3.2] - 2026-03-01
562
+
563
+ ### Fixed
564
+ - **Python class methods**: smart_read now shows all methods inside Python classes (ast-index only returns class-level, token-pilot parses `def` methods with visibility, decorators, async detection)
565
+ - **read_symbol Python**: `Orchestrator.run`, `Orchestrator._build_summary` — qualified and unqualified method access works (was returning entire 829-line class)
566
+ - **Mega-symbol truncation**: symbols >300 lines show head (50) + tail (30) + method outline instead of 71KB overflow
567
+ - **findFlat recursive**: unqualified method names (`run`, `_build_summary`) now found inside class children
568
+
569
+ ## [0.3.1] - 2026-03-01
570
+
571
+ ### Fixed
572
+ - **find_usages**: combine `refs` + `search` with exact word boundary filtering 0% result loss vs grep (was 40% loss with refs-only)
573
+ - **read_symbol**: fix `Class.method` qualified names for flat outlines (ast-index lists methods as siblings, not children)
574
+ - **read_symbol**: filter ast-index leaf name fallback by requested file (was returning symbols from wrong files)
575
+ - **YAML smart_read**: 3-level nested parser with scalar values, array counts (was only showing top-level keys)
576
+ - Removed all "Use Grep as fallback" hints — token-pilot gives complete results on its own
577
+
578
+ ## [0.3.0] - 2026-03-01
579
+
580
+ ### Added
581
+ - **find_callers** tool — find all callers of a function, with optional call hierarchy tree (depth parameter)
582
+ - **changed_symbols** tool — show symbol-level git changes (added/modified/removed) vs a base branch
583
+ - **find_unused** tool — detect potentially unused/dead symbols in the project
584
+ - 8 new ast-index client methods: `refs`, `map`, `conventions`, `callers`, `callTree`, `changed`, `unusedSymbols`, `fileImports`
585
+ - Incremental index updates via `ast-index update` (fast) instead of full rebuild
586
+
587
+ ### Fixed
588
+ - **find_usages**: rewritten to use `ast-index refs` — returns definitions + imports + usages in one call (was losing ~66% of results)
589
+ - **project_overview**: rewritten to use `ast-index map` + `conventions` — shows architecture, frameworks, naming patterns, directory map with symbol kinds
590
+ - **search_code**: deduplication of results (removes duplicate file:line entries)
591
+ - **read_symbol**: structure-first lookup for `Class.method` qualified names with ast-index leaf fallback
592
+ - **export_ast_index**: `all_indexed=true` option exports all files from ast-index, not just cached ones
593
+ - **YAML smart_read**: expand one level of nesting (shows nested keys under top-level sections)
594
+
595
+ ### Changed
596
+ - Total MCP tools: 14 → 17
597
+ - ast-index commands used: 8 → 16
598
+ - Index updates are now incremental by default (falls back to full rebuild only when needed)
599
+
600
+ ## [0.2.4] - 2026-03-01
601
+
602
+ ### Fixed
603
+ - **search_code**: filter out garbage entries with empty file paths or `:undefined` lines
604
+ - **read_symbol**: support `Class.method` and `Class::method` qualified names (structure-first lookup, ast-index leaf fallback)
605
+ - **export_ast_index**: `all_indexed=true` option exports all files from ast-index, not just cached ones
606
+ - **YAML smart_read**: expand one level of nesting (shows service names, nested keys under top-level sections)
607
+ - Improved empty-cache message in export_ast_index with hint about `all_indexed`
608
+
609
+ ## [0.2.3] - 2026-03-01
610
+
611
+ ### Fixed
612
+ - **ensureIndex**: plain rebuild first (indexes full monorepo), fallback to `--sub-projects` only if <5 files
613
+ - **smart_read**: non-code files (YAML, JSON, Markdown, TOML) use structural summary instead of raw content dump
614
+ - **smart_read**: unsupported files return truncated 60-line preview instead of full raw content
615
+ - **class_hierarchy**: proper parser for ast-index text output (Parents/Children sections)
616
+ - **project_overview**: uses directory name when package.json has no `name` field
617
+
618
+ ## [0.2.2] - 2026-03-01
619
+
620
+ ### Fixed
621
+ - Published 0.2.1 contained stale Haiku files in dist/ (tsc doesn't clean old outputs)
622
+ - Added `prebuild` script (`rm -rf dist`) to prevent stale artifacts
623
+ - Added `chmod +x` in prepublishOnly to ensure bin is executable
624
+
625
+ ## [0.2.1] - 2026-03-01
626
+
627
+ ### Fixed
628
+ - **RC3**: `search_code` now merges all ast-index result types (content_matches + symbols + files + references) — previously only used content_matches which was often empty
629
+ - **RC4**: `class_hierarchy` and `implementations` parse text format as fallback when JSON parse fails
630
+ - **RC6**: `read_symbol` auto-fetches outline from ast-index if no cached structure — no longer requires prior smart_read
631
+ - `ensureIndex` uses `--sub-projects` flag for monorepo indexing
632
+
633
+ ### Removed
634
+ - Reverted Haiku v0.2.1 — removed broken PersistentFileCache, DiffEngine, RealTokenEstimator, ContextWindowTracker, smart-read-xml, context-markup
635
+ - Removed 3 heavy native dependencies: `better-sqlite3`, `js-tiktoken`, `diff`
636
+
637
+ ### Added
638
+ - `start.sh` — bootstrap script for Claude Code plugin system
639
+
640
+ ## [0.2.0] - 2026-03-01
641
+
642
+ ### Fixed
643
+ - **P0**: ast-index errors no longer silently swallowed — all search/usages/implementations/hierarchy/outline/symbol log errors to stderr
644
+ - **P0**: `exec()` now captures and logs ast-index subprocess stderr
645
+ - **P0**: `projectRoot` detected via `git rev-parse --show-toplevel` instead of `process.cwd()` (fixes wrong index root)
646
+ - **P1**: `forget(all=true)` now clears both ContextRegistry and FileCache (fixes stale export_ast_index/read_diff after forget)
647
+ - **P1**: `forget(path=X)` also invalidates FileCache for that path
648
+ - **P2**: `read_symbol` supports PHP `::` separator (e.g. `RefundProcessor::refund`)
649
+ - **P2**: `findInStructure` recursion fixed — supports 3+ level nesting (Namespace::Class::method)
650
+ - `ensureIndex()`: verify index has content after `stats` — force rebuild if 0 files indexed
651
+
652
+ ### Changed
653
+ - `project_overview`: now shows directory listing + ast-index stats (files, symbols, references) instead of stub
654
+ - `project_overview`: added PHP (`composer.json`) detection
655
+
656
+ ## [0.1.6] - 2026-03-01 (unpublished)
657
+
658
+ ### Fixed
659
+ - `ensureIndex()`: verify index has content after `stats` — force rebuild if 0 files indexed (fixes empty search results on first run)
660
+
661
+ ## [0.1.5] - 2026-03-01
662
+
663
+ ### Fixed
664
+ - PreToolUse hook: read file path from stdin (Claude Code hook format) instead of `$FILE_PATH` env var
665
+ - Hook now auto-suggests `smart_read` for large code files when Claude tries to use `Read`
666
+ - `session_analytics`: now tracks all tools (read_symbol, read_range, read_diff, smart_read_many, search_code, find_usages, find_implementations, class_hierarchy) — previously only tracked smart_read
667
+ - Empty search/usages/implementations results now show diagnostic hints (ast-index status, fallback suggestions)
668
+ - `ensureIndex()` now logs build progress and errors to stderr
669
+
670
+ ## [0.1.4] - 2026-03-01
671
+
672
+ ### Fixed
673
+ - Lazy file watcher: watch only loaded files instead of entire project root (fixes crash on Docker volumes, home dir, WSL)
674
+
675
+ ## [0.1.3] - 2026-03-01
676
+
677
+ ### Fixed
678
+ - Chokidar file watcher error handler (partial fix, superseded by 0.1.4)
679
+
680
+ ## [0.1.2] - 2026-03-01
681
+
682
+ ### Fixed
683
+ - ast-index integration: `outline` now parses text output (JSON format not supported in v3.24.0)
684
+ - ast-index `symbol` response: handle array format, normalize field names (`line`→`start_line`, `path`→`file`)
685
+ - ast-index `search` response: handle `{content_matches: [...]}` wrapper
686
+ - ast-index `usages` response: map `context`→`text`, `path`→`file`
687
+ - Server version now read dynamically from package.json
688
+
689
+ ### Added
690
+ - `token-pilot doctor` — diagnostics command (checks ast-index, Node.js, config, updates)
691
+ - `token-pilot --version` — print current version
692
+ - Update check on server startup (non-blocking, logs to stderr)
693
+ - `/mcp add` installation method documented for Claude Code chat
694
+ - Troubleshooting section in README
695
+
696
+ ## [0.1.1] - 2026-03-01
697
+
698
+ ### Added
699
+ - `npx -y token-pilot` — zero-install for any MCP client (Cursor, Cline, Continue, etc.)
700
+ - Claude Code plugin marketplace support (`.claude-plugin/marketplace.json`)
701
+ - `start.sh` bootstrap script — auto `npm install` + `npm run build` on first run
702
+ - `npm publish` ready (`files` field, `prepublishOnly` script)
703
+ - Universal install instructions in README for Claude Code, Cursor, Cline
704
+
705
+ ### Changed
706
+ - `.mcp.json` now uses `start.sh` for reliable bootstrap
707
+ - README reorganized: npx as primary install, from-source as fallback
708
+
709
+ ## [0.1.0] - 2026-03-01
710
+
711
+ ### Added
712
+
713
+ - **Core Reading Tools**: `smart_read`, `read_symbol`, `read_range`, `read_diff`, `smart_read_many`
714
+ - AST-based structural overviews saving 80-95% tokens
715
+ - Small file pass-through (< 80 lines returned in full)
716
+ - O(n) diff algorithm for re-reads
717
+ - Advisory context registry with compact reminders
718
+ - **Search & Navigation**: `search_code`, `find_usages`, `find_implementations`, `class_hierarchy`, `project_overview`
719
+ - Powered by ast-index (tree-sitter + SQLite FTS5)
720
+ - Cross-file symbol resolution
721
+ - **Context Management**: `session_analytics`, `context_status`, `forget`
722
+ - Token savings tracking per tool and per file
723
+ - Advisory (non-blocking) context tracking
724
+ - **Integration**: `export_ast_index`
725
+ - context-mode detection and complementary architecture
726
+ - AST data export for BM25 cross-indexing
727
+ - **Infrastructure**
728
+ - Git HEAD watcher with selective cache invalidation on branch switch
729
+ - File watcher (chokidar) for automatic cache invalidation
730
+ - LRU file cache with configurable size limit
731
+ - Input validation for all tools (path traversal protection)
732
+ - Auto-download of ast-index binary from GitHub releases
733
+ - PreToolUse hook installer for Claude Code
734
+ - Claude Code plugin format (.claude-plugin/)
735
+ - Non-code structural summaries (JSON, YAML, Markdown, TOML)
736
+ - Configurable via `.token-pilot.json`