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
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool definitions and system instructions.
|
|
3
|
+
* Pure static data — no runtime dependencies.
|
|
4
|
+
*/
|
|
5
|
+
export const MCP_INSTRUCTIONS = [
|
|
6
|
+
'Token Pilot — token-efficient code reading (saves 60-80% tokens). ALWAYS prefer these tools over Read/cat/grep.',
|
|
7
|
+
'',
|
|
8
|
+
'DECISION RULES — pick the first match:',
|
|
9
|
+
'1. New codebase / unfamiliar project → project_overview',
|
|
10
|
+
'2. Starting work on a directory → explore_area (outline + imports + tests + git log in one call)',
|
|
11
|
+
'3. Need to read a code file → smart_read (NOT Read/cat — returns structure, 60-80% fewer tokens)',
|
|
12
|
+
'4. Need one function/class body → read_symbol (loads only that symbol, NOT the whole file)',
|
|
13
|
+
'5. Preparing an edit → read_for_edit (returns exact text for Edit old_string)',
|
|
14
|
+
'6. Verify edits after editing → read_diff (only changed hunks — REQUIRES smart_read BEFORE editing)',
|
|
15
|
+
'7. Multiple files at once → smart_read_many (batch up to 20 files)',
|
|
16
|
+
'8. Find where a symbol is used → find_usages (semantic: definitions + imports + usages)',
|
|
17
|
+
'9. Understand file dependencies → related_files (imports, importers, tests — ranked by relevance)',
|
|
18
|
+
'10. List all symbols in a directory → outline (classes, functions, methods in one call)',
|
|
19
|
+
'11. Review git changes → smart_diff (NOT git diff — maps changes to functions/classes)',
|
|
20
|
+
'12. Commit history → smart_log (NOT git log — structured with categories)',
|
|
21
|
+
'13. Run tests → test_summary (NOT raw test output — structured pass/fail)',
|
|
22
|
+
'14. Code quality → code_audit (TODOs, deprecated, structural patterns)',
|
|
23
|
+
'15. Dead code → find_unused (unreferenced symbols across project)',
|
|
24
|
+
'16. Module architecture → module_info (deps, dependents, public API)',
|
|
25
|
+
'',
|
|
26
|
+
'USE DEFAULT TOOLS ONLY FOR: regex text search → Grep | exact raw content → Read | non-code configs → Read',
|
|
27
|
+
'',
|
|
28
|
+
'WORKFLOWS:',
|
|
29
|
+
'• Explore: project_overview → explore_area → smart_read → read_symbol',
|
|
30
|
+
'• Edit: smart_read → read_for_edit → Edit → read_diff',
|
|
31
|
+
'• Refactor: find_usages → read_symbol → read_for_edit → Edit → test_summary',
|
|
32
|
+
'• Audit: code_audit + find_unused + Grep (for regex patterns)',
|
|
33
|
+
].join('\n');
|
|
34
|
+
export const TOOL_DEFINITIONS = [
|
|
35
|
+
// --- Core reading tools ---
|
|
36
|
+
{
|
|
37
|
+
name: 'smart_read',
|
|
38
|
+
description: 'Use INSTEAD OF Read/cat for code files. Returns code structure (classes, functions, methods with signatures and line ranges) — 60-80% fewer tokens than raw content. Use read_symbol() to drill into specific code.',
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
path: { type: 'string', description: 'File path (absolute or relative to project root)' },
|
|
43
|
+
show_imports: { type: 'boolean', description: 'Include import details (default: true)' },
|
|
44
|
+
show_docs: { type: 'boolean', description: 'Include doc comments (default: true)' },
|
|
45
|
+
depth: { type: 'number', description: 'Max depth for nested symbols (default: 2)' },
|
|
46
|
+
},
|
|
47
|
+
required: ['path'],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'read_symbol',
|
|
52
|
+
description: 'Read source code of ONE specific function/method/class — INSTEAD OF reading the whole file. Supports Class.method syntax.',
|
|
53
|
+
inputSchema: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
properties: {
|
|
56
|
+
path: { type: 'string', description: 'File path' },
|
|
57
|
+
symbol: { type: 'string', description: 'Symbol name, e.g. "UserService.updateUser"' },
|
|
58
|
+
context_before: { type: 'number', description: 'Lines of context before (default: 2)' },
|
|
59
|
+
context_after: { type: 'number', description: 'Lines of context after (default: 0)' },
|
|
60
|
+
show: { type: 'string', enum: ['full', 'head', 'tail', 'outline'], description: 'Display mode: full (all lines), head (first 50), tail (last 30), outline (head + methods + tail). Default: auto (full ≤300 lines, outline >300)' },
|
|
61
|
+
},
|
|
62
|
+
required: ['path', 'symbol'],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'read_range',
|
|
67
|
+
description: 'Read a specific line range from a file. Use when you know exact lines — lighter than reading the whole file.',
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
path: { type: 'string', description: 'File path' },
|
|
72
|
+
start_line: { type: 'number', description: 'Start line (1-indexed)' },
|
|
73
|
+
end_line: { type: 'number', description: 'End line (1-indexed, inclusive)' },
|
|
74
|
+
},
|
|
75
|
+
required: ['path', 'start_line', 'end_line'],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'read_diff',
|
|
80
|
+
description: 'Use INSTEAD OF re-reading whole file after edits. Shows only changed hunks. REQUIRES: call smart_read or read_for_edit BEFORE editing to create baseline snapshot.',
|
|
81
|
+
inputSchema: {
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: {
|
|
84
|
+
path: { type: 'string', description: 'File path' },
|
|
85
|
+
context_lines: { type: 'number', description: 'Lines of context around changes (default: 3)' },
|
|
86
|
+
},
|
|
87
|
+
required: ['path'],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'read_for_edit',
|
|
92
|
+
description: 'Use INSTEAD OF Read when preparing an edit. Returns exact raw code around a symbol or line — copy directly as old_string for Edit tool. Optional: include_callers, include_tests, include_changes for enriched context.',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
path: { type: 'string', description: 'File path' },
|
|
97
|
+
symbol: { type: 'string', description: 'Symbol name to edit (e.g. "UserService.updateUser")' },
|
|
98
|
+
line: { type: 'number', description: 'Line number to edit (alternative to symbol)' },
|
|
99
|
+
context: { type: 'number', description: 'Lines of context around target (default: 5)' },
|
|
100
|
+
include_callers: { type: 'boolean', description: 'Show top callers of this symbol (saves a separate find_usages call)' },
|
|
101
|
+
include_tests: { type: 'boolean', description: 'Show related test file and test names' },
|
|
102
|
+
include_changes: { type: 'boolean', description: 'Show recent git changes in the target region' },
|
|
103
|
+
},
|
|
104
|
+
required: ['path'],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'smart_read_many',
|
|
109
|
+
description: 'Batch smart_read for multiple files at once — INSTEAD OF calling Read on each file. Returns structure for each file. Max 20 files.',
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
properties: {
|
|
113
|
+
paths: {
|
|
114
|
+
type: 'array',
|
|
115
|
+
items: { type: 'string' },
|
|
116
|
+
description: 'Array of file paths',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
required: ['paths'],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
// --- Search & navigation ---
|
|
123
|
+
{
|
|
124
|
+
name: 'find_usages',
|
|
125
|
+
description: 'Use INSTEAD OF Grep for finding symbol references. Semantic search — groups by: definitions, imports, usages. Supports scope, kind, limit, lang filters.',
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: {
|
|
129
|
+
symbol: { type: 'string', description: 'Symbol name to find usages of' },
|
|
130
|
+
scope: { type: 'string', description: 'Filter results by path prefix (e.g., "src/Domain/")' },
|
|
131
|
+
kind: { type: 'string', enum: ['definitions', 'imports', 'usages', 'all'], description: 'Show only specific section (default: "all")' },
|
|
132
|
+
limit: { type: 'number', description: 'Max results per category (default: 50, max: 500)' },
|
|
133
|
+
lang: { type: 'string', description: 'Filter by language/extension (e.g., "php", "typescript")' },
|
|
134
|
+
},
|
|
135
|
+
required: ['symbol'],
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'project_overview',
|
|
140
|
+
description: 'START HERE for unfamiliar codebases. Shows project type, architecture, framework detection, quality tools, CI, directory map. Use include filter for specific sections.',
|
|
141
|
+
inputSchema: {
|
|
142
|
+
type: 'object',
|
|
143
|
+
properties: {
|
|
144
|
+
include: {
|
|
145
|
+
type: 'array',
|
|
146
|
+
items: { type: 'string', enum: ['stack', 'ci', 'quality', 'architecture'] },
|
|
147
|
+
description: 'Sections to include (default: all). Use ["stack"] for quick type check, ["quality","ci"] for tooling overview.',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'related_files',
|
|
154
|
+
description: 'Show ranked import graph for a file: imports, importers, and tests scored by relevance (test adjacency, import closeness, recent changes, path proximity). Files ranked into HIGH VALUE / MEDIUM / LOW to prioritize reading.',
|
|
155
|
+
inputSchema: {
|
|
156
|
+
type: 'object',
|
|
157
|
+
properties: {
|
|
158
|
+
path: { type: 'string', description: 'File path to analyze' },
|
|
159
|
+
},
|
|
160
|
+
required: ['path'],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'outline',
|
|
165
|
+
description: 'Use INSTEAD OF listing dir + reading each file. One call returns all symbols (classes, functions, methods, routes) for every code file in a directory. Supports recursive with max_depth.',
|
|
166
|
+
inputSchema: {
|
|
167
|
+
type: 'object',
|
|
168
|
+
properties: {
|
|
169
|
+
path: { type: 'string', description: 'Directory path' },
|
|
170
|
+
recursive: { type: 'boolean', description: 'Recursively outline subdirectories (default: false)' },
|
|
171
|
+
max_depth: { type: 'number', description: 'Max recursion depth when recursive=true (default: 2, max: 5)' },
|
|
172
|
+
},
|
|
173
|
+
required: ['path'],
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
// --- Analytics ---
|
|
177
|
+
{
|
|
178
|
+
name: 'session_analytics',
|
|
179
|
+
description: 'Show token savings report: calls, tokens saved, per-tool breakdown, top files, cache hits.',
|
|
180
|
+
inputSchema: {
|
|
181
|
+
type: 'object',
|
|
182
|
+
properties: {},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
// --- Analysis ---
|
|
186
|
+
{
|
|
187
|
+
name: 'find_unused',
|
|
188
|
+
description: 'Find dead code — functions, classes, and variables with no references across the project. Use for cleanup and refactoring.',
|
|
189
|
+
inputSchema: {
|
|
190
|
+
type: 'object',
|
|
191
|
+
properties: {
|
|
192
|
+
module: { type: 'string', description: 'Filter by module path (e.g., "src/services/")' },
|
|
193
|
+
export_only: { type: 'boolean', description: 'Only check exported (capitalized) symbols' },
|
|
194
|
+
limit: { type: 'number', description: 'Max results (default: 30)' },
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'code_audit',
|
|
200
|
+
description: 'Find code quality issues: TODO/FIXME comments, deprecated symbols, structural code patterns (bare except:, print() calls). Use for project-wide audits.',
|
|
201
|
+
inputSchema: {
|
|
202
|
+
type: 'object',
|
|
203
|
+
properties: {
|
|
204
|
+
check: {
|
|
205
|
+
type: 'string',
|
|
206
|
+
enum: ['pattern', 'todo', 'deprecated', 'annotations', 'all'],
|
|
207
|
+
description: 'What to check: "pattern" (structural search via ast-grep, e.g. "except:", "print($$$ARGS)"), "todo" (TODO/FIXME comments), "deprecated" (deprecated symbols), "annotations" (find by decorator name), "all" (todo + deprecated summary)',
|
|
208
|
+
},
|
|
209
|
+
pattern: { type: 'string', description: 'Code pattern for check="pattern". ast-grep syntax: "except:" finds bare excepts, "print($$$ARGS)" finds print calls.' },
|
|
210
|
+
name: { type: 'string', description: 'Decorator/annotation name for check="annotations". Example: "Deprecated", "Controller"' },
|
|
211
|
+
lang: { type: 'string', description: 'Language filter for check="pattern" (e.g., "python", "typescript")' },
|
|
212
|
+
limit: { type: 'number', description: 'Max results (default: 50)' },
|
|
213
|
+
},
|
|
214
|
+
required: ['check'],
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: 'module_info',
|
|
219
|
+
description: 'Analyze module dependencies, dependents, public API, and unused deps. Use for architecture understanding and dependency cleanup.',
|
|
220
|
+
inputSchema: {
|
|
221
|
+
type: 'object',
|
|
222
|
+
properties: {
|
|
223
|
+
module: { type: 'string', description: 'Module name or path pattern (e.g., "auth", "src/Domain/")' },
|
|
224
|
+
check: {
|
|
225
|
+
type: 'string',
|
|
226
|
+
enum: ['deps', 'dependents', 'api', 'unused-deps', 'all'],
|
|
227
|
+
description: 'What to check: "deps" (dependencies), "dependents" (who depends on this), "api" (public symbols), "unused-deps" (dead dependencies), "all" (everything). Default: "all"',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
required: ['module'],
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
// --- Diff & exploration ---
|
|
234
|
+
{
|
|
235
|
+
name: 'smart_diff',
|
|
236
|
+
description: 'Use INSTEAD OF raw git diff. Shows changed files with AST symbol mapping — which functions/classes were modified/added/removed. Small diffs include hunks, large diffs show summary.',
|
|
237
|
+
inputSchema: {
|
|
238
|
+
type: 'object',
|
|
239
|
+
properties: {
|
|
240
|
+
scope: { type: 'string', enum: ['unstaged', 'staged', 'commit', 'branch'], description: 'Diff scope (default: "unstaged")' },
|
|
241
|
+
path: { type: 'string', description: 'Filter to specific file or directory' },
|
|
242
|
+
ref: { type: 'string', description: 'Git ref — required for scope="commit" (commit hash) or scope="branch" (branch name)' },
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: 'explore_area',
|
|
248
|
+
description: 'One-call exploration of a directory: outline (all symbols), imports (external deps + who imports this area), tests (matching test files), recent git changes. Use INSTEAD OF separate outline + related_files + git log calls.',
|
|
249
|
+
inputSchema: {
|
|
250
|
+
type: 'object',
|
|
251
|
+
properties: {
|
|
252
|
+
path: { type: 'string', description: 'Directory path (or file path — will use its parent directory)' },
|
|
253
|
+
include: {
|
|
254
|
+
type: 'array',
|
|
255
|
+
items: { type: 'string', enum: ['outline', 'imports', 'tests', 'changes'] },
|
|
256
|
+
description: 'Sections to include (default: all)',
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
required: ['path'],
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: 'smart_log',
|
|
264
|
+
description: 'Use INSTEAD OF raw git log. Structured commit history with category detection (feat/fix/refactor/docs), file stats, author breakdown. Filters by path and ref.',
|
|
265
|
+
inputSchema: {
|
|
266
|
+
type: 'object',
|
|
267
|
+
properties: {
|
|
268
|
+
path: { type: 'string', description: 'Filter to specific file or directory' },
|
|
269
|
+
count: { type: 'number', description: 'Number of commits (default: 10, max: 50)' },
|
|
270
|
+
ref: { type: 'string', description: 'Git ref — branch, tag, or commit (default: HEAD)' },
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: 'test_summary',
|
|
276
|
+
description: 'Run tests and return structured summary: total/passed/failed/skipped + failure details. 200 lines of raw output → 10-15 lines. Supports vitest, jest, pytest, phpunit, go test, cargo test.',
|
|
277
|
+
inputSchema: {
|
|
278
|
+
type: 'object',
|
|
279
|
+
properties: {
|
|
280
|
+
command: { type: 'string', description: 'Test command to run (e.g., "npm test", "pytest", "go test ./...")' },
|
|
281
|
+
runner: { type: 'string', enum: ['vitest', 'jest', 'pytest', 'phpunit', 'go', 'cargo', 'rspec', 'mocha'], description: 'Force specific parser (auto-detected if omitted)' },
|
|
282
|
+
timeout: { type: 'number', description: 'Timeout in ms (default: 60000, max: 300000)' },
|
|
283
|
+
},
|
|
284
|
+
required: ['command'],
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
];
|
|
288
|
+
//# sourceMappingURL=tool-definitions.js.map
|