token-pilot 0.14.1 → 0.15.0
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.
- package/CHANGELOG.md +17 -0
- package/README.md +8 -8
- package/dist/ast-index/client.d.ts +0 -89
- package/dist/ast-index/client.js +26 -743
- package/dist/ast-index/enricher.d.ts +10 -0
- package/dist/ast-index/enricher.js +202 -0
- package/dist/ast-index/parser.d.ts +31 -0
- package/dist/ast-index/parser.js +340 -0
- package/dist/ast-index/regex-parser.d.ts +8 -0
- package/dist/ast-index/regex-parser.js +118 -0
- package/dist/config/defaults.js +1 -0
- package/dist/core/session-analytics.d.ts +1 -1
- package/dist/core/session-analytics.js +33 -122
- package/dist/core/symbol-resolver.d.ts +0 -1
- package/dist/core/symbol-resolver.js +3 -12
- package/dist/handlers/code-audit.js +2 -2
- package/dist/handlers/find-unused.js +1 -1
- package/dist/handlers/find-usages.js +34 -26
- package/dist/handlers/smart-read.js +14 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -7
- package/dist/server/token-estimates.d.ts +31 -0
- package/dist/server/token-estimates.js +204 -0
- package/dist/server/tool-definitions.d.ts +958 -0
- package/dist/server/tool-definitions.js +288 -0
- package/dist/server.js +8 -477
- package/dist/types.d.ts +1 -0
- package/package.json +14 -12
- package/skills/guide/SKILL.md +64 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ All notable changes to Token Pilot will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.15.0] - 2026-03-19
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Regex fallback parser** — `smart_read` now works for TS/JS 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.
|
|
12
|
+
- **Guide skill** — `/guide` command shows a quick-reference table of all Token Pilot tools with usage examples and recommended workflow.
|
|
13
|
+
- **`hooks.denyThreshold` config** — hook deny threshold is now configurable in `.token-pilot.json` (default: 300, was hardcoded 500). Intercepts ~2x more native Read calls.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- **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.
|
|
17
|
+
- **`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).
|
|
18
|
+
- **`find_usages` output** — results grouped by file with compact rendering. Single match per file on one line, multiple matches indented under file header.
|
|
19
|
+
- **Stale references** — all `grep_search` hints updated to `Grep` (code-audit, find-unused, find-usages).
|
|
20
|
+
- **409 tests** (was 393).
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- **`npx token-pilot` CLI** — symlink path resolution in `isDirectRun` check. All CLI commands now work correctly via npx.
|
|
24
|
+
|
|
8
25
|
## [0.14.1] - 2026-03-14
|
|
9
26
|
|
|
10
27
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Token Pilot
|
|
2
2
|
|
|
3
|
-
MCP server that reduces token consumption in AI coding assistants by **
|
|
3
|
+
MCP server that reduces token consumption in AI coding assistants by **up to 80%** via AST-aware lazy file reading.
|
|
4
4
|
|
|
5
5
|
Instead of dumping entire files into the LLM context, Token Pilot returns structural overviews (classes, functions, signatures, line ranges) and lets the AI load only the specific symbols it needs.
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ Token Pilot: smart_read("user-service.ts") → 15-line outline → ~200 tok
|
|
|
13
13
|
After edit: read_diff("user-service.ts") → ~20 tokens
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
**Up to 80% reduction** on large files. Files under 200 lines are returned in full automatically (zero overhead for small files). Typical sessions with a mix of file sizes see **30-50% savings**, scaling higher with repeated reads (session cache, compact reminders) and targeted symbol loading.
|
|
17
17
|
|
|
18
18
|
## Installation
|
|
19
19
|
|
|
@@ -132,7 +132,7 @@ npx token-pilot uninstall-hook # Remove
|
|
|
132
132
|
When connected, every MCP client receives rules like:
|
|
133
133
|
|
|
134
134
|
```
|
|
135
|
-
WHEN TO USE TOKEN PILOT (saves
|
|
135
|
+
WHEN TO USE TOKEN PILOT (saves up to 80% tokens):
|
|
136
136
|
• Reading code files → smart_read (returns structure, not raw content)
|
|
137
137
|
• Need one function/class → read_symbol (loads only that symbol)
|
|
138
138
|
• Exploring a directory → outline (all symbols in one call)
|
|
@@ -158,7 +158,7 @@ For more control, you can add rules to your project:
|
|
|
158
158
|
|
|
159
159
|
| Tool | Instead of | Description |
|
|
160
160
|
|------|-----------|-------------|
|
|
161
|
-
| `smart_read` | `Read` | AST structural overview: classes, functions, methods with signatures.
|
|
161
|
+
| `smart_read` | `Read` | AST structural overview: classes, functions, methods with signatures. Up to 80% savings on large files. Framework-aware: shows HTTP routes, column types, validation rules. |
|
|
162
162
|
| `read_symbol` | `Read` + scroll | Load source of a specific symbol. Supports `Class.method`. `show` param: full/head/tail/outline. |
|
|
163
163
|
| `read_for_edit` | `Read` before `Edit` | Minimal RAW code around a symbol — copy directly as `old_string` for Edit tool. |
|
|
164
164
|
| `read_range` | `Read` offset | Read a specific line range from a file. |
|
|
@@ -280,13 +280,13 @@ When both are configured, Token Pilot automatically:
|
|
|
280
280
|
- Suggests context-mode for large non-code files
|
|
281
281
|
- Shows combined architecture info in `session_analytics`
|
|
282
282
|
|
|
283
|
-
**Combined savings:
|
|
283
|
+
**Combined savings: up to 80%** in a typical coding session.
|
|
284
284
|
|
|
285
285
|
## Supported Languages
|
|
286
286
|
|
|
287
|
-
Token Pilot supports all
|
|
287
|
+
Token Pilot supports all 29 languages that [ast-index](https://github.com/defendend/Claude-ast-index-search) supports:
|
|
288
288
|
|
|
289
|
-
TypeScript, JavaScript, Python, Rust, Go, Java, Kotlin, Swift, C#, C++, C, PHP, Ruby, Scala, Dart, Lua, Shell/Bash, SQL, R, Vue, Svelte, Perl, Groovy
|
|
289
|
+
TypeScript, JavaScript, Python, Rust, Go, Java, Kotlin, Swift, Objective-C, C#, C++, C, PHP, Ruby, Scala, Dart, Lua, Shell/Bash, SQL, R, Vue, Svelte, Perl, Groovy, Elixir, Common Lisp, Matlab, Protocol Buffers, BSL (1C:Enterprise)
|
|
290
290
|
|
|
291
291
|
Plus structural summaries for non-code files: JSON, YAML, Markdown, TOML, XML, CSV.
|
|
292
292
|
|
|
@@ -395,7 +395,7 @@ src/
|
|
|
395
395
|
|
|
396
396
|
Token Pilot is built on top of these excellent open-source projects:
|
|
397
397
|
|
|
398
|
-
- **[ast-index](https://github.com/defendend/Claude-ast-index-search)** by [@defendend](https://github.com/defendend) — Rust-based AST indexing engine with tree-sitter, SQLite FTS5, and support for
|
|
398
|
+
- **[ast-index](https://github.com/defendend/Claude-ast-index-search)** by [@defendend](https://github.com/defendend) — Rust-based AST indexing engine with tree-sitter, SQLite FTS5, and support for 29 programming languages. Token Pilot uses it as the backend for all code analysis.
|
|
399
399
|
- **[claude-context-mode](https://github.com/mksglu/claude-context-mode)** by [@mksglu](https://github.com/mksglu) — Complementary MCP plugin for shell output and data file processing via sandbox + BM25. Token Pilot integrates with it for maximum combined savings.
|
|
400
400
|
- **[Model Context Protocol](https://modelcontextprotocol.io/)** by Anthropic — The protocol that makes all of this possible.
|
|
401
401
|
|
|
@@ -20,21 +20,8 @@ export declare class AstIndexClient {
|
|
|
20
20
|
init(): Promise<void>;
|
|
21
21
|
ensureIndex(): Promise<void>;
|
|
22
22
|
private buildIndex;
|
|
23
|
-
/** Mark index as oversized — disables index-dependent tools, outline still works */
|
|
24
23
|
private handleOversizedIndex;
|
|
25
|
-
/** Extract file count from stats output (JSON or text) */
|
|
26
|
-
private parseFileCount;
|
|
27
24
|
outline(filePath: string): Promise<FileStructure | null>;
|
|
28
|
-
/**
|
|
29
|
-
* Parse text output from `ast-index outline`:
|
|
30
|
-
* Outline of src/file.ts:
|
|
31
|
-
* :10 ClassName [class]
|
|
32
|
-
* :11 propName [property]
|
|
33
|
-
* :14 methodName [function]
|
|
34
|
-
*/
|
|
35
|
-
private parseOutlineText;
|
|
36
|
-
/** Compute end_line from sequential start positions */
|
|
37
|
-
private computeEndLines;
|
|
38
25
|
symbol(name: string): Promise<AstIndexSymbolDetail | null>;
|
|
39
26
|
search(query: string, options?: {
|
|
40
27
|
inFile?: string;
|
|
@@ -44,119 +31,43 @@ export declare class AstIndexClient {
|
|
|
44
31
|
usages(symbolName: string): Promise<AstIndexUsageResult[]>;
|
|
45
32
|
implementations(name: string): Promise<AstIndexImplementation[]>;
|
|
46
33
|
hierarchy(name: string): Promise<AstIndexHierarchyNode | null>;
|
|
47
|
-
private parseImplementationsText;
|
|
48
|
-
private parseHierarchyText;
|
|
49
34
|
stats(): Promise<string | null>;
|
|
50
|
-
/**
|
|
51
|
-
* List all files known to the ast-index.
|
|
52
|
-
* Parses the `files` command output which lists one file per line.
|
|
53
|
-
*/
|
|
54
35
|
listFiles(): Promise<string[]>;
|
|
55
|
-
/**
|
|
56
|
-
* Cross-references: definitions + imports + usages in one call.
|
|
57
|
-
* Replaces separate symbol() + usages() calls.
|
|
58
|
-
*/
|
|
59
36
|
refs(symbolName: string, limit?: number): Promise<AstIndexRefsResponse>;
|
|
60
|
-
/**
|
|
61
|
-
* Project map: directory structure with file counts and symbol kinds.
|
|
62
|
-
*/
|
|
63
37
|
map(options?: {
|
|
64
38
|
module?: string;
|
|
65
39
|
limit?: number;
|
|
66
40
|
}): Promise<AstIndexMapResponse | null>;
|
|
67
|
-
/**
|
|
68
|
-
* Detect project conventions: architecture, frameworks, naming patterns.
|
|
69
|
-
*/
|
|
70
41
|
conventions(): Promise<AstIndexConventionsResponse | null>;
|
|
71
|
-
/**
|
|
72
|
-
* Find callers of a function.
|
|
73
|
-
*/
|
|
74
42
|
callers(functionName: string, limit?: number): Promise<AstIndexCallerEntry[]>;
|
|
75
|
-
/**
|
|
76
|
-
* Show call hierarchy tree (callers tree up).
|
|
77
|
-
*/
|
|
78
43
|
callTree(functionName: string, depth?: number): Promise<AstIndexCallTreeNode | null>;
|
|
79
|
-
/**
|
|
80
|
-
* Show changed symbols since base branch (git diff).
|
|
81
|
-
*/
|
|
82
44
|
changed(base?: string): Promise<AstIndexChangedEntry[]>;
|
|
83
|
-
/**
|
|
84
|
-
* Find potentially unused symbols.
|
|
85
|
-
*/
|
|
86
45
|
unusedSymbols(options?: {
|
|
87
46
|
module?: string;
|
|
88
47
|
exportOnly?: boolean;
|
|
89
48
|
limit?: number;
|
|
90
49
|
}): Promise<AstIndexUnusedSymbol[]>;
|
|
91
|
-
/**
|
|
92
|
-
* Get imports for a specific file.
|
|
93
|
-
* Parses text output: " { X, Y } from 'source';"
|
|
94
|
-
*/
|
|
95
50
|
fileImports(filePath: string): Promise<AstIndexImportEntry[]>;
|
|
96
|
-
private parseImportsText;
|
|
97
|
-
/** Check if ast-grep (sg) is available for structural pattern search */
|
|
98
51
|
private checkAstGrep;
|
|
99
|
-
/** Structural pattern search via ast-grep. Requires ast-grep (sg) installed. */
|
|
100
52
|
agrep(pattern: string, options?: {
|
|
101
53
|
lang?: string;
|
|
102
54
|
limit?: number;
|
|
103
55
|
}): Promise<AstIndexAgrepMatch[]>;
|
|
104
|
-
private parseAgrepText;
|
|
105
|
-
/** Find TODO/FIXME/HACK comments in the project */
|
|
106
56
|
todo(): Promise<AstIndexTodoEntry[]>;
|
|
107
|
-
private parseTodoText;
|
|
108
|
-
/** Find @Deprecated symbols in the project */
|
|
109
57
|
deprecated(): Promise<AstIndexDeprecatedEntry[]>;
|
|
110
|
-
private parseDeprecatedText;
|
|
111
|
-
/** Find symbols with a specific annotation/decorator */
|
|
112
58
|
annotations(name: string): Promise<AstIndexAnnotationEntry[]>;
|
|
113
|
-
private parseAnnotationsText;
|
|
114
|
-
/** Trigger incremental index update (called by file watcher after edits) */
|
|
115
59
|
incrementalUpdate(): Promise<void>;
|
|
116
|
-
/** List project modules matching optional pattern */
|
|
117
60
|
modules(pattern?: string): Promise<AstIndexModuleEntry[]>;
|
|
118
|
-
/** Get dependencies of a module */
|
|
119
61
|
moduleDeps(module: string): Promise<AstIndexModuleDep[]>;
|
|
120
|
-
/** Get modules that depend on this module */
|
|
121
62
|
moduleDependents(module: string): Promise<AstIndexModuleDep[]>;
|
|
122
|
-
/** Find unused dependencies of a module */
|
|
123
63
|
unusedDeps(module: string): Promise<AstIndexUnusedDep[]>;
|
|
124
|
-
/** Get public API of a module */
|
|
125
64
|
moduleApi(module: string): Promise<AstIndexModuleApi[]>;
|
|
126
|
-
private parseModuleListText;
|
|
127
|
-
private parseModuleDepText;
|
|
128
|
-
private parseUnusedDepsText;
|
|
129
|
-
private parseModuleApiText;
|
|
130
65
|
isAvailable(): boolean;
|
|
131
|
-
/** Returns true if the index was built but found >50k files (node_modules leak) */
|
|
132
66
|
isOversized(): boolean;
|
|
133
|
-
/** Returns true if index building is disabled (dangerous root like /) */
|
|
134
67
|
isDisabled(): boolean;
|
|
135
|
-
/** Disable index building (e.g. project root is / or home dir) */
|
|
136
68
|
disableIndex(): void;
|
|
137
|
-
/** Re-enable index building after auto-detecting a valid project root */
|
|
138
69
|
enableIndex(): void;
|
|
139
|
-
/** Update project root (e.g. after auto-detecting from file path) */
|
|
140
70
|
updateProjectRoot(newRoot: string): void;
|
|
141
71
|
private exec;
|
|
142
|
-
private buildFileStructure;
|
|
143
|
-
/**
|
|
144
|
-
* Python: ast-index doesn't return methods inside classes.
|
|
145
|
-
* Parse file content to extract `def` methods for classes without children.
|
|
146
|
-
*/
|
|
147
|
-
private enrichPythonClassMethods;
|
|
148
|
-
/**
|
|
149
|
-
* PHP: ast-index doesn't return methods inside classes.
|
|
150
|
-
* Parse file content to extract `function` methods for classes without children.
|
|
151
|
-
*/
|
|
152
|
-
private enrichPHPClassMethods;
|
|
153
|
-
/** Fix the last entry's end_line to use actual file line count */
|
|
154
|
-
private fixLastEndLine;
|
|
155
|
-
/** Read actual signature lines from file content */
|
|
156
|
-
private enrichSignatures;
|
|
157
|
-
private mapOutlineEntry;
|
|
158
|
-
private mapKind;
|
|
159
|
-
private mapVisibility;
|
|
160
|
-
private detectLanguage;
|
|
161
72
|
}
|
|
162
73
|
//# sourceMappingURL=client.d.ts.map
|