token-pilot 0.19.2 → 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 (89) hide show
  1. package/.claude-plugin/hooks/hooks.json +21 -0
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/CHANGELOG.md +129 -0
  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/cli/agent-frontmatter.d.ts +48 -0
  17. package/dist/cli/agent-frontmatter.js +189 -0
  18. package/dist/cli/bless-agents.d.ts +65 -0
  19. package/dist/cli/bless-agents.js +307 -0
  20. package/dist/cli/claudeignore.d.ts +33 -0
  21. package/dist/cli/claudeignore.js +88 -0
  22. package/dist/cli/claudemd-hygiene.d.ts +26 -0
  23. package/dist/cli/claudemd-hygiene.js +43 -0
  24. package/dist/cli/doctor-drift.d.ts +31 -0
  25. package/dist/cli/doctor-drift.js +130 -0
  26. package/dist/cli/doctor-env-check.d.ts +25 -0
  27. package/dist/cli/doctor-env-check.js +91 -0
  28. package/dist/cli/install-agents.d.ts +108 -0
  29. package/dist/cli/install-agents.js +402 -0
  30. package/dist/cli/save-doc.d.ts +42 -0
  31. package/dist/cli/save-doc.js +145 -0
  32. package/dist/cli/scan-agents.d.ts +46 -0
  33. package/dist/cli/scan-agents.js +227 -0
  34. package/dist/cli/stats.d.ts +36 -0
  35. package/dist/cli/stats.js +131 -0
  36. package/dist/cli/unbless-agents.d.ts +33 -0
  37. package/dist/cli/unbless-agents.js +85 -0
  38. package/dist/cli/uninstall-agents.d.ts +36 -0
  39. package/dist/cli/uninstall-agents.js +117 -0
  40. package/dist/config/defaults.d.ts +1 -1
  41. package/dist/config/defaults.js +14 -8
  42. package/dist/config/loader.d.ts +1 -1
  43. package/dist/config/loader.js +105 -11
  44. package/dist/core/context-registry.d.ts +16 -1
  45. package/dist/core/context-registry.js +60 -28
  46. package/dist/core/event-log.d.ts +79 -0
  47. package/dist/core/event-log.js +190 -0
  48. package/dist/core/session-registry.d.ts +43 -0
  49. package/dist/core/session-registry.js +113 -0
  50. package/dist/core/session-savings.d.ts +19 -0
  51. package/dist/core/session-savings.js +60 -0
  52. package/dist/handlers/session-budget.d.ts +32 -0
  53. package/dist/handlers/session-budget.js +61 -0
  54. package/dist/handlers/session-snapshot-persist.d.ts +22 -0
  55. package/dist/handlers/session-snapshot-persist.js +76 -0
  56. package/dist/hooks/adaptive-threshold.d.ts +27 -0
  57. package/dist/hooks/adaptive-threshold.js +46 -0
  58. package/dist/hooks/format-deny-message.d.ts +21 -0
  59. package/dist/hooks/format-deny-message.js +147 -0
  60. package/dist/hooks/installer.js +121 -31
  61. package/dist/hooks/path-safety.d.ts +16 -0
  62. package/dist/hooks/path-safety.js +34 -0
  63. package/dist/hooks/post-bash.d.ts +46 -0
  64. package/dist/hooks/post-bash.js +77 -0
  65. package/dist/hooks/session-start.d.ts +45 -0
  66. package/dist/hooks/session-start.js +179 -0
  67. package/dist/hooks/summary-ast-index.d.ts +28 -0
  68. package/dist/hooks/summary-ast-index.js +122 -0
  69. package/dist/hooks/summary-head-tail.d.ts +15 -0
  70. package/dist/hooks/summary-head-tail.js +78 -0
  71. package/dist/hooks/summary-pipeline.d.ts +35 -0
  72. package/dist/hooks/summary-pipeline.js +63 -0
  73. package/dist/hooks/summary-regex.d.ts +14 -0
  74. package/dist/hooks/summary-regex.js +130 -0
  75. package/dist/hooks/summary-types.d.ts +29 -0
  76. package/dist/hooks/summary-types.js +9 -0
  77. package/dist/index.d.ts +15 -3
  78. package/dist/index.js +509 -149
  79. package/dist/integration/context-mode-detector.d.ts +7 -1
  80. package/dist/integration/context-mode-detector.js +51 -15
  81. package/dist/server/tool-definitions.d.ts +149 -0
  82. package/dist/server/tool-definitions.js +424 -202
  83. package/dist/server.d.ts +1 -1
  84. package/dist/server.js +456 -179
  85. package/dist/templates/agent-builder.d.ts +49 -0
  86. package/dist/templates/agent-builder.js +104 -0
  87. package/dist/types.d.ts +38 -4
  88. package/package.json +4 -2
  89. package/skills/stats/SKILL.md +13 -2
@@ -3,372 +3,594 @@
3
3
  * Pure static data — no runtime dependencies.
4
4
  */
5
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)',
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
12
  ' - For navigation/browsing: smart_read(scope="nav") — names + lines only, 2-3x smaller',
13
13
  ' - For public API overview: smart_read(scope="exports")',
14
- '4. Need one function/class body → read_symbol (loads only that symbol, NOT the whole file)',
15
- ' - Preparing edit? Add include_edit_context=true to skip separate read_for_edit call',
16
- '5. Need MULTIPLE function/class bodies from same file → read_symbols (batch — one call instead of N)',
17
- '6. Preparing an edit → read_for_edit (returns exact text for Edit old_string)',
18
- '7. Verify edits after editing → read_diff (only changed hunks — REQUIRES smart_read BEFORE editing)',
19
- '8. Multiple files at once → smart_read_many (batch up to 20 files)',
20
- '9. Find where a symbol is used → find_usages (semantic: definitions + imports + usages)',
14
+ "4. Need one function/class body → read_symbol (loads only that symbol, NOT the whole file)",
15
+ " - Preparing edit? Add include_edit_context=true to skip separate read_for_edit call",
16
+ "5. Need MULTIPLE function/class bodies from same file → read_symbols (batch — one call instead of N)",
17
+ "6. Preparing an edit → read_for_edit (returns exact text for Edit old_string)",
18
+ "7. Verify edits after editing → read_diff (only changed hunks — REQUIRES smart_read BEFORE editing)",
19
+ "8. Multiple files at once → smart_read_many (batch up to 20 files)",
20
+ "9. Find where a symbol is used → find_usages (semantic: definitions + imports + usages)",
21
21
  ' - For initial discovery: find_usages(mode="list") — file:line only, 5-10x smaller',
22
- '10. Understand file dependencies → related_files (imports, importers, tests — ranked by relevance)',
23
- '11. List all symbols in a directory → outline (classes, functions, methods in one call)',
24
- '12. Review git changes → smart_diff (NOT git diff — maps changes to functions/classes)',
25
- '13. Commit history → smart_log (NOT git log — structured with categories)',
26
- '14. Run tests → test_summary (NOT raw test output — structured pass/fail)',
27
- '15. Code quality → code_audit (TODOs, deprecated, structural patterns)',
28
- '16. Dead code → find_unused (unreferenced symbols across project)',
29
- '17. Module architecture → module_info (deps, dependents, public API)',
30
- '18. Read markdown/yaml/json/csv section → read_section (loads one heading/key/row-range, NOT the whole file)',
22
+ "10. Understand file dependencies → related_files (imports, importers, tests — ranked by relevance)",
23
+ "11. List all symbols in a directory → outline (classes, functions, methods in one call)",
24
+ "12. Review git changes → smart_diff (NOT git diff — maps changes to functions/classes)",
25
+ "13. Commit history → smart_log (NOT git log — structured with categories)",
26
+ "14. Run tests → test_summary (NOT raw test output — structured pass/fail)",
27
+ "15. Code quality → code_audit (TODOs, deprecated, structural patterns)",
28
+ "16. Dead code → find_unused (unreferenced symbols across project)",
29
+ "17. Module architecture → module_info (deps, dependents, public API)",
30
+ "18. Read markdown/yaml/json/csv section → read_section (loads one heading/key/row-range, NOT the whole file)",
31
31
  ' - For editing sections: read_for_edit(path, section="Section Name")',
32
- '19. Long session / before compaction → session_snapshot (capture goal, decisions, confirmed facts, files, next step as <200 token block)',
33
- ' - Budget-constrained? Use smart_read(max_tokens=N) to auto-downgrade output size',
34
- '',
35
- 'USE DEFAULT TOOLS ONLY FOR: regex text search → Grep | exact raw content → Read | non-code configs → Read',
36
- '',
37
- 'WORKFLOWS:',
38
- '• Explore: project_overview → explore_area → smart_read → read_symbol',
39
- '• Edit: smart_read → read_symbol(include_edit_context=true) → Edit → read_diff',
40
- '• Docs: smart_read (outline) → read_section → read_for_edit(section=) → Edit → read_diff',
41
- '• Refactor: find_usages → read_symbols → read_for_edit → Edit → test_summary',
42
- '• Audit: code_audit + find_unused + Grep (for regex patterns)',
43
- '• Long session: session_snapshot → compact context → continue with minimal state',
44
- ].join('\n');
32
+ "19. Long session / before compaction → session_snapshot (capture goal, decisions, confirmed facts, files, next step as <200 token block)",
33
+ " - Budget-constrained? Use smart_read(max_tokens=N) to auto-downgrade output size",
34
+ "",
35
+ "USE DEFAULT TOOLS ONLY FOR: regex text search → Grep | exact raw content → Read | non-code configs → Read",
36
+ "",
37
+ "WORKFLOWS:",
38
+ "• Explore: project_overview → explore_area → smart_read → read_symbol",
39
+ "• Edit: smart_read → read_symbol(include_edit_context=true) → Edit → read_diff",
40
+ "• Docs: smart_read (outline) → read_section → read_for_edit(section=) → Edit → read_diff",
41
+ "• Refactor: find_usages → read_symbols → read_for_edit → Edit → test_summary",
42
+ "• Audit: code_audit + find_unused + Grep (for regex patterns)",
43
+ "• Long session: session_snapshot → compact context → continue with minimal state",
44
+ ].join("\n");
45
45
  export const TOOL_DEFINITIONS = [
46
46
  // --- Core reading tools ---
47
47
  {
48
- name: 'smart_read',
49
- 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.',
48
+ name: "smart_read",
49
+ 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.",
50
50
  inputSchema: {
51
- type: 'object',
51
+ type: "object",
52
52
  properties: {
53
- path: { type: 'string', description: 'File path (absolute or relative to project root)' },
54
- show_imports: { type: 'boolean', description: 'Include import details (default: true)' },
55
- show_docs: { type: 'boolean', description: 'Include doc comments (default: true)' },
56
- depth: { type: 'number', description: 'Max depth for nested symbols (default: 2)' },
53
+ path: {
54
+ type: "string",
55
+ description: "File path (absolute or relative to project root)",
56
+ },
57
+ show_imports: {
58
+ type: "boolean",
59
+ description: "Include import details (default: true)",
60
+ },
61
+ show_docs: {
62
+ type: "boolean",
63
+ description: "Include doc comments (default: true)",
64
+ },
65
+ depth: {
66
+ type: "number",
67
+ description: "Max depth for nested symbols (default: 2)",
68
+ },
57
69
  scope: {
58
- type: 'string',
59
- enum: ['full', 'nav', 'exports'],
60
- description: 'Output scope: full (default, all details), nav (names + lines only, 2-3x smaller), exports (public API only)',
70
+ type: "string",
71
+ enum: ["full", "nav", "exports"],
72
+ description: "Output scope: full (default, all details), nav (names + lines only, 2-3x smaller), exports (public API only)",
73
+ },
74
+ max_tokens: {
75
+ type: "number",
76
+ description: "Token budget. If output exceeds this, auto-downgrades: full → outline → compact. Use for context-constrained sessions.",
77
+ },
78
+ session_id: {
79
+ type: "string",
80
+ description: "Optional Claude Code session_id. When provided, dedup state (already-loaded files) persists across MCP server restarts and /clear, tied to that session. Omit to use ephemeral process-scoped dedup.",
81
+ },
82
+ force: {
83
+ type: "boolean",
84
+ description: "Bypass dedup — return full content even if the same path was already loaded earlier in this session. Use when the prior result was compacted out of context.",
61
85
  },
62
- max_tokens: { type: 'number', description: 'Token budget. If output exceeds this, auto-downgrades: full → outline → compact. Use for context-constrained sessions.' },
63
86
  },
64
- required: ['path'],
87
+ required: ["path"],
65
88
  },
66
89
  },
67
90
  {
68
- name: 'read_symbol',
69
- description: 'Read source code of ONE specific function/method/class — INSTEAD OF reading the whole file. Supports Class.method syntax.',
91
+ name: "read_symbol",
92
+ description: "Read source code of ONE specific function/method/class — INSTEAD OF reading the whole file. Supports Class.method syntax.",
70
93
  inputSchema: {
71
- type: 'object',
94
+ type: "object",
72
95
  properties: {
73
- path: { type: 'string', description: 'File path' },
74
- symbol: { type: 'string', description: 'Symbol name, e.g. "UserService.updateUser"' },
75
- context_before: { type: 'number', description: 'Lines of context before (default: 2)' },
76
- context_after: { type: 'number', description: 'Lines of context after (default: 0)' },
77
- 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)' },
96
+ path: { type: "string", description: "File path" },
97
+ symbol: {
98
+ type: "string",
99
+ description: 'Symbol name, e.g. "UserService.updateUser"',
100
+ },
101
+ context_before: {
102
+ type: "number",
103
+ description: "Lines of context before (default: 2)",
104
+ },
105
+ context_after: {
106
+ type: "number",
107
+ description: "Lines of context after (default: 0)",
108
+ },
109
+ show: {
110
+ type: "string",
111
+ enum: ["full", "head", "tail", "outline"],
112
+ description: "Display mode: full (all lines), head (first 50), tail (last 30), outline (head + methods + tail). Default: auto (full ≤300 lines, outline >300)",
113
+ },
78
114
  include_edit_context: {
79
- type: 'boolean',
80
- description: 'Append raw code block for Edit old_string (saves a read_for_edit call)',
115
+ type: "boolean",
116
+ description: "Append raw code block for Edit old_string (saves a read_for_edit call)",
117
+ },
118
+ session_id: {
119
+ type: "string",
120
+ description: "Optional Claude Code session_id for cross-restart dedup (see smart_read).",
121
+ },
122
+ force: {
123
+ type: "boolean",
124
+ description: "Bypass dedup (see smart_read.force).",
81
125
  },
82
126
  },
83
- required: ['path', 'symbol'],
127
+ required: ["path", "symbol"],
84
128
  },
85
129
  },
86
130
  {
87
- name: 'read_symbols',
88
- description: 'Batch read MULTIPLE symbols from ONE file for UNDERSTANDING code — saves N-1 round-trips vs calling read_symbol N times. Returns formatted symbol bodies with show modes (full/head/tail/outline). Use this when READING code, not editing. For edit preparation use read_for_edit instead.',
131
+ name: "read_symbols",
132
+ description: "Batch read MULTIPLE symbols from ONE file for UNDERSTANDING code — saves N-1 round-trips vs calling read_symbol N times. Returns formatted symbol bodies with show modes (full/head/tail/outline). Use this when READING code, not editing. For edit preparation use read_for_edit instead.",
89
133
  inputSchema: {
90
- type: 'object',
134
+ type: "object",
91
135
  properties: {
92
- path: { type: 'string', description: 'File path' },
136
+ path: { type: "string", description: "File path" },
93
137
  symbols: {
94
- type: 'array',
95
- items: { type: 'string' },
138
+ type: "array",
139
+ items: { type: "string" },
96
140
  description: 'Array of symbol names (max 10), e.g. ["UserService.create", "UserService.update", "UserService.delete"]',
97
141
  },
98
- context_before: { type: 'number', description: 'Lines of context before each symbol (default: 2)' },
99
- context_after: { type: 'number', description: 'Lines of context after each symbol (default: 0)' },
100
- show: { type: 'string', enum: ['full', 'head', 'tail', 'outline'], description: 'Display mode for each symbol (default: auto)' },
142
+ context_before: {
143
+ type: "number",
144
+ description: "Lines of context before each symbol (default: 2)",
145
+ },
146
+ context_after: {
147
+ type: "number",
148
+ description: "Lines of context after each symbol (default: 0)",
149
+ },
150
+ show: {
151
+ type: "string",
152
+ enum: ["full", "head", "tail", "outline"],
153
+ description: "Display mode for each symbol (default: auto)",
154
+ },
101
155
  },
102
- required: ['path', 'symbols'],
156
+ required: ["path", "symbols"],
103
157
  },
104
158
  },
105
159
  {
106
- name: 'read_range',
107
- description: 'Read a specific line range from a file. Use when you know exact lines — lighter than reading the whole file.',
160
+ name: "read_range",
161
+ description: "Read a specific line range from a file. Use when you know exact lines — lighter than reading the whole file.",
108
162
  inputSchema: {
109
- type: 'object',
163
+ type: "object",
110
164
  properties: {
111
- path: { type: 'string', description: 'File path' },
112
- start_line: { type: 'number', description: 'Start line (1-indexed)' },
113
- end_line: { type: 'number', description: 'End line (1-indexed, inclusive)' },
165
+ path: { type: "string", description: "File path" },
166
+ start_line: { type: "number", description: "Start line (1-indexed)" },
167
+ end_line: {
168
+ type: "number",
169
+ description: "End line (1-indexed, inclusive)",
170
+ },
171
+ session_id: {
172
+ type: "string",
173
+ description: "Optional Claude Code session_id for cross-restart dedup (see smart_read).",
174
+ },
175
+ force: {
176
+ type: "boolean",
177
+ description: "Bypass dedup (see smart_read.force).",
178
+ },
114
179
  },
115
- required: ['path', 'start_line', 'end_line'],
180
+ required: ["path", "start_line", "end_line"],
116
181
  },
117
182
  },
118
183
  {
119
- name: 'read_section',
120
- description: '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.',
184
+ name: "read_section",
185
+ description: "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.",
121
186
  inputSchema: {
122
- type: 'object',
187
+ type: "object",
123
188
  properties: {
124
- path: { type: 'string', description: 'Path to .md, .yaml, .yml, .json, or .csv file' },
125
- heading: { type: 'string', description: 'Section heading (Markdown), top-level key (YAML/JSON), or row range "rows:1-50" (CSV). Case-insensitive.' },
189
+ path: {
190
+ type: "string",
191
+ description: "Path to .md, .yaml, .yml, .json, or .csv file",
192
+ },
193
+ heading: {
194
+ type: "string",
195
+ description: 'Section heading (Markdown), top-level key (YAML/JSON), or row range "rows:1-50" (CSV). Case-insensitive.',
196
+ },
126
197
  },
127
- required: ['path', 'heading'],
198
+ required: ["path", "heading"],
128
199
  },
129
200
  },
130
201
  {
131
- name: 'read_diff',
132
- 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.',
202
+ name: "read_diff",
203
+ 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.",
133
204
  inputSchema: {
134
- type: 'object',
205
+ type: "object",
135
206
  properties: {
136
- path: { type: 'string', description: 'File path' },
137
- context_lines: { type: 'number', description: 'Lines of context around changes (default: 3)' },
207
+ path: { type: "string", description: "File path" },
208
+ context_lines: {
209
+ type: "number",
210
+ description: "Lines of context around changes (default: 3)",
211
+ },
138
212
  },
139
- required: ['path'],
213
+ required: ["path"],
140
214
  },
141
215
  },
142
216
  {
143
- name: 'read_for_edit',
217
+ name: "read_for_edit",
144
218
  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. Supports batch: pass "symbols" array to get multiple edit contexts in one call. Unlike read_symbols (for reading/understanding), this returns unformatted code optimized for copy-paste into Edit. Optional: include_callers, include_tests, include_changes for enriched context.',
145
219
  inputSchema: {
146
- type: 'object',
220
+ type: "object",
147
221
  properties: {
148
- path: { type: 'string', description: 'File path' },
149
- symbol: { type: 'string', description: 'Symbol name to edit (e.g. "UserService.updateUser")' },
222
+ path: { type: "string", description: "File path" },
223
+ symbol: {
224
+ type: "string",
225
+ description: 'Symbol name to edit (e.g. "UserService.updateUser")',
226
+ },
150
227
  symbols: {
151
- type: 'array',
152
- items: { type: 'string' },
228
+ type: "array",
229
+ items: { type: "string" },
153
230
  description: 'Array of symbol names for batch edit context (max 10). Alternative to single "symbol" — returns all symbols in one call.',
154
231
  },
155
- line: { type: 'number', description: 'Line number to edit (alternative to symbol)' },
156
- context: { type: 'number', description: 'Lines of context around target (default: 5)' },
157
- include_callers: { type: 'boolean', description: 'Show top callers of this symbol (saves a separate find_usages call)' },
158
- include_tests: { type: 'boolean', description: 'Show related test file and test names' },
159
- include_changes: { type: 'boolean', description: 'Show recent git changes in the target region' },
232
+ line: {
233
+ type: "number",
234
+ description: "Line number to edit (alternative to symbol)",
235
+ },
236
+ context: {
237
+ type: "number",
238
+ description: "Lines of context around target (default: 5)",
239
+ },
240
+ include_callers: {
241
+ type: "boolean",
242
+ description: "Show top callers of this symbol (saves a separate find_usages call)",
243
+ },
244
+ include_tests: {
245
+ type: "boolean",
246
+ description: "Show related test file and test names",
247
+ },
248
+ include_changes: {
249
+ type: "boolean",
250
+ description: "Show recent git changes in the target region",
251
+ },
160
252
  section: {
161
- type: 'string',
253
+ type: "string",
162
254
  description: 'Section to edit: heading (Markdown), top-level key (YAML/JSON), or "rows:1-50" (CSV). Returns raw section content for Edit old_string.',
163
255
  },
164
256
  },
165
- required: ['path'],
257
+ required: ["path"],
166
258
  },
167
259
  },
168
260
  {
169
- name: 'smart_read_many',
170
- description: 'Batch smart_read for multiple files at once — INSTEAD OF calling Read on each file. Returns structure for each file. Max 20 files.',
261
+ name: "smart_read_many",
262
+ description: "Batch smart_read for multiple files at once — INSTEAD OF calling Read on each file. Returns structure for each file. Max 20 files.",
171
263
  inputSchema: {
172
- type: 'object',
264
+ type: "object",
173
265
  properties: {
174
266
  paths: {
175
- type: 'array',
176
- items: { type: 'string' },
177
- description: 'Array of file paths',
267
+ type: "array",
268
+ items: { type: "string" },
269
+ description: "Array of file paths",
270
+ },
271
+ max_tokens: {
272
+ type: "number",
273
+ description: "Token budget per file. If a file exceeds this, auto-downgrades to compact outline.",
274
+ },
275
+ session_id: {
276
+ type: "string",
277
+ description: "Optional Claude Code session_id for cross-restart dedup (see smart_read).",
278
+ },
279
+ force: {
280
+ type: "boolean",
281
+ description: "Bypass dedup (see smart_read.force).",
178
282
  },
179
- max_tokens: { type: 'number', description: 'Token budget per file. If a file exceeds this, auto-downgrades to compact outline.' },
180
283
  },
181
- required: ['paths'],
284
+ required: ["paths"],
182
285
  },
183
286
  },
184
287
  // --- Search & navigation ---
185
288
  {
186
- name: 'find_usages',
187
- description: 'Use INSTEAD OF Grep for finding symbol references. Semantic search — groups by: definitions, imports, usages. Supports scope, kind, limit, lang filters. Use context_lines to include surrounding code.',
289
+ name: "find_usages",
290
+ description: "Use INSTEAD OF Grep for finding symbol references. Semantic search — groups by: definitions, imports, usages. Supports scope, kind, limit, lang filters. Use context_lines to include surrounding code.",
188
291
  inputSchema: {
189
- type: 'object',
292
+ type: "object",
190
293
  properties: {
191
- symbol: { type: 'string', description: 'Symbol name to find usages of' },
192
- scope: { type: 'string', description: 'Filter results by path prefix (e.g., "src/Domain/")' },
193
- kind: { type: 'string', enum: ['definitions', 'imports', 'usages', 'all'], description: 'Show only specific section (default: "all")' },
194
- limit: { type: 'number', description: 'Max results per category (default: 50, max: 500)' },
195
- lang: { type: 'string', description: 'Filter by language/extension (e.g., "php", "typescript")' },
196
- context_lines: { type: 'number', description: 'Lines of source context around each match (0-10). When set, shows surrounding code — saves follow-up read_symbol calls.' },
294
+ symbol: {
295
+ type: "string",
296
+ description: "Symbol name to find usages of",
297
+ },
298
+ scope: {
299
+ type: "string",
300
+ description: 'Filter results by path prefix (e.g., "src/Domain/")',
301
+ },
302
+ kind: {
303
+ type: "string",
304
+ enum: ["definitions", "imports", "usages", "all"],
305
+ description: 'Show only specific section (default: "all")',
306
+ },
307
+ limit: {
308
+ type: "number",
309
+ description: "Max results per category (default: 50, max: 500)",
310
+ },
311
+ lang: {
312
+ type: "string",
313
+ description: 'Filter by language/extension (e.g., "php", "typescript")',
314
+ },
315
+ context_lines: {
316
+ type: "number",
317
+ description: "Lines of source context around each match (0-10). When set, shows surrounding code — saves follow-up read_symbol calls.",
318
+ },
197
319
  mode: {
198
- type: 'string',
199
- enum: ['full', 'list'],
200
- description: 'Output mode: full (with context, default), list (file:line only, 5-10x smaller for initial discovery)',
320
+ type: "string",
321
+ enum: ["full", "list"],
322
+ description: "Output mode: full (with context, default), list (file:line only, 5-10x smaller for initial discovery)",
201
323
  },
202
324
  },
203
- required: ['symbol'],
325
+ required: ["symbol"],
204
326
  },
205
327
  },
206
328
  {
207
- name: 'project_overview',
208
- description: 'START HERE for unfamiliar codebases. Shows project type, architecture, framework detection, quality tools, CI, directory map. Use include filter for specific sections.',
329
+ name: "project_overview",
330
+ description: "START HERE for unfamiliar codebases. Shows project type, architecture, framework detection, quality tools, CI, directory map. Use include filter for specific sections.",
209
331
  inputSchema: {
210
- type: 'object',
332
+ type: "object",
211
333
  properties: {
212
334
  include: {
213
- type: 'array',
214
- items: { type: 'string', enum: ['stack', 'ci', 'quality', 'architecture'] },
335
+ type: "array",
336
+ items: {
337
+ type: "string",
338
+ enum: ["stack", "ci", "quality", "architecture"],
339
+ },
215
340
  description: 'Sections to include (default: all). Use ["stack"] for quick type check, ["quality","ci"] for tooling overview.',
216
341
  },
217
342
  },
218
343
  },
219
344
  },
220
345
  {
221
- name: 'related_files',
222
- 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.',
346
+ name: "related_files",
347
+ 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.",
223
348
  inputSchema: {
224
- type: 'object',
349
+ type: "object",
225
350
  properties: {
226
- path: { type: 'string', description: 'File path to analyze' },
351
+ path: { type: "string", description: "File path to analyze" },
227
352
  },
228
- required: ['path'],
353
+ required: ["path"],
229
354
  },
230
355
  },
231
356
  {
232
- name: 'outline',
233
- 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.',
357
+ name: "outline",
358
+ 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.",
234
359
  inputSchema: {
235
- type: 'object',
360
+ type: "object",
236
361
  properties: {
237
- path: { type: 'string', description: 'Directory path' },
238
- recursive: { type: 'boolean', description: 'Recursively outline subdirectories (default: false)' },
239
- max_depth: { type: 'number', description: 'Max recursion depth when recursive=true (default: 2, max: 5)' },
362
+ path: { type: "string", description: "Directory path" },
363
+ recursive: {
364
+ type: "boolean",
365
+ description: "Recursively outline subdirectories (default: false)",
366
+ },
367
+ max_depth: {
368
+ type: "number",
369
+ description: "Max recursion depth when recursive=true (default: 2, max: 5)",
370
+ },
240
371
  },
241
- required: ['path'],
372
+ required: ["path"],
242
373
  },
243
374
  },
244
375
  // --- Analytics ---
245
376
  {
246
- name: 'session_analytics',
247
- description: 'Show token savings report: calls, tokens saved, per-tool breakdown, top files, cache hits. Use verbose=true for full breakdown (per-intent, decision insights, savings by category).',
377
+ name: "session_analytics",
378
+ description: "Show token savings report: calls, tokens saved, per-tool breakdown, top files, cache hits. Use verbose=true for full breakdown (per-intent, decision insights, savings by category).",
248
379
  inputSchema: {
249
- type: 'object',
380
+ type: "object",
250
381
  properties: {
251
- verbose: { type: 'boolean', description: 'Show detailed breakdown: per-intent, savings by category, decision insights (default: false)' },
382
+ verbose: {
383
+ type: "boolean",
384
+ description: "Show detailed breakdown: per-intent, savings by category, decision insights (default: false)",
385
+ },
252
386
  },
253
387
  },
254
388
  },
255
389
  // --- Analysis ---
256
390
  {
257
- name: 'find_unused',
258
- description: 'Find dead code — functions, classes, and variables with no references across the project. Use for cleanup and refactoring.',
391
+ name: "find_unused",
392
+ description: "Find dead code — functions, classes, and variables with no references across the project. Use for cleanup and refactoring.",
259
393
  inputSchema: {
260
- type: 'object',
394
+ type: "object",
261
395
  properties: {
262
- module: { type: 'string', description: 'Filter by module path (e.g., "src/services/")' },
263
- export_only: { type: 'boolean', description: 'Only check exported (capitalized) symbols' },
264
- limit: { type: 'number', description: 'Max results (default: 30)' },
396
+ module: {
397
+ type: "string",
398
+ description: 'Filter by module path (e.g., "src/services/")',
399
+ },
400
+ export_only: {
401
+ type: "boolean",
402
+ description: "Only check exported (capitalized) symbols",
403
+ },
404
+ limit: { type: "number", description: "Max results (default: 30)" },
265
405
  },
266
406
  },
267
407
  },
268
408
  {
269
- name: 'code_audit',
270
- description: 'Find code quality issues: TODO/FIXME comments, deprecated symbols, structural code patterns (bare except:, print() calls). Use for project-wide audits.',
409
+ name: "code_audit",
410
+ description: "Find code quality issues: TODO/FIXME comments, deprecated symbols, structural code patterns (bare except:, print() calls). Use for project-wide audits.",
271
411
  inputSchema: {
272
- type: 'object',
412
+ type: "object",
273
413
  properties: {
274
414
  check: {
275
- type: 'string',
276
- enum: ['pattern', 'todo', 'deprecated', 'annotations', 'all'],
415
+ type: "string",
416
+ enum: ["pattern", "todo", "deprecated", "annotations", "all"],
277
417
  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)',
278
418
  },
279
- pattern: { type: 'string', description: 'Code pattern for check="pattern". ast-grep syntax: "except:" finds bare excepts, "print($$$ARGS)" finds print calls.' },
280
- name: { type: 'string', description: 'Decorator/annotation name for check="annotations". Example: "Deprecated", "Controller"' },
281
- lang: { type: 'string', description: 'Language filter for check="pattern" (e.g., "python", "typescript")' },
282
- limit: { type: 'number', description: 'Max results (default: 50)' },
419
+ pattern: {
420
+ type: "string",
421
+ description: 'Code pattern for check="pattern". ast-grep syntax: "except:" finds bare excepts, "print($$$ARGS)" finds print calls.',
422
+ },
423
+ name: {
424
+ type: "string",
425
+ description: 'Decorator/annotation name for check="annotations". Example: "Deprecated", "Controller"',
426
+ },
427
+ lang: {
428
+ type: "string",
429
+ description: 'Language filter for check="pattern" (e.g., "python", "typescript")',
430
+ },
431
+ limit: { type: "number", description: "Max results (default: 50)" },
283
432
  },
284
- required: ['check'],
433
+ required: ["check"],
285
434
  },
286
435
  },
287
436
  {
288
- name: 'module_info',
289
- description: 'Analyze module dependencies, dependents, public API, and unused deps. Use for architecture understanding and dependency cleanup.',
437
+ name: "module_info",
438
+ description: "Analyze module dependencies, dependents, public API, and unused deps. Use for architecture understanding and dependency cleanup.",
290
439
  inputSchema: {
291
- type: 'object',
440
+ type: "object",
292
441
  properties: {
293
- module: { type: 'string', description: 'Module name or path pattern (e.g., "auth", "src/Domain/")' },
442
+ module: {
443
+ type: "string",
444
+ description: 'Module name or path pattern (e.g., "auth", "src/Domain/")',
445
+ },
294
446
  check: {
295
- type: 'string',
296
- enum: ['deps', 'dependents', 'api', 'unused-deps', 'all'],
447
+ type: "string",
448
+ enum: ["deps", "dependents", "api", "unused-deps", "all"],
297
449
  description: 'What to check: "deps" (dependencies), "dependents" (who depends on this), "api" (public symbols), "unused-deps" (dead dependencies), "all" (everything). Default: "all"',
298
450
  },
299
451
  },
300
- required: ['module'],
452
+ required: ["module"],
301
453
  },
302
454
  },
303
455
  // --- Diff & exploration ---
304
456
  {
305
- name: 'smart_diff',
306
- 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.',
457
+ name: "smart_diff",
458
+ 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.",
307
459
  inputSchema: {
308
- type: 'object',
460
+ type: "object",
309
461
  properties: {
310
- scope: { type: 'string', enum: ['unstaged', 'staged', 'commit', 'branch'], description: 'Diff scope (default: "unstaged")' },
311
- path: { type: 'string', description: 'Filter to specific file or directory' },
312
- ref: { type: 'string', description: 'Git ref — required for scope="commit" (commit hash) or scope="branch" (branch name)' },
462
+ scope: {
463
+ type: "string",
464
+ enum: ["unstaged", "staged", "commit", "branch"],
465
+ description: 'Diff scope (default: "unstaged")',
466
+ },
467
+ path: {
468
+ type: "string",
469
+ description: "Filter to specific file or directory",
470
+ },
471
+ ref: {
472
+ type: "string",
473
+ description: 'Git ref — required for scope="commit" (commit hash) or scope="branch" (branch name)',
474
+ },
313
475
  },
314
476
  },
315
477
  },
316
478
  {
317
- name: 'explore_area',
318
- 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.',
479
+ name: "explore_area",
480
+ 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.",
319
481
  inputSchema: {
320
- type: 'object',
482
+ type: "object",
321
483
  properties: {
322
- path: { type: 'string', description: 'Directory path (or file path — will use its parent directory)' },
484
+ path: {
485
+ type: "string",
486
+ description: "Directory path (or file path — will use its parent directory)",
487
+ },
323
488
  include: {
324
- type: 'array',
325
- items: { type: 'string', enum: ['outline', 'imports', 'tests', 'changes'] },
326
- description: 'Sections to include (default: all)',
489
+ type: "array",
490
+ items: {
491
+ type: "string",
492
+ enum: ["outline", "imports", "tests", "changes"],
493
+ },
494
+ description: "Sections to include (default: all)",
327
495
  },
328
496
  },
329
- required: ['path'],
497
+ required: ["path"],
330
498
  },
331
499
  },
332
500
  {
333
- name: 'smart_log',
334
- 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.',
501
+ name: "smart_log",
502
+ 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.",
335
503
  inputSchema: {
336
- type: 'object',
504
+ type: "object",
337
505
  properties: {
338
- path: { type: 'string', description: 'Filter to specific file or directory' },
339
- count: { type: 'number', description: 'Number of commits (default: 10, max: 50)' },
340
- ref: { type: 'string', description: 'Git ref branch, tag, or commit (default: HEAD)' },
506
+ path: {
507
+ type: "string",
508
+ description: "Filter to specific file or directory",
509
+ },
510
+ count: {
511
+ type: "number",
512
+ description: "Number of commits (default: 10, max: 50)",
513
+ },
514
+ ref: {
515
+ type: "string",
516
+ description: "Git ref — branch, tag, or commit (default: HEAD)",
517
+ },
341
518
  },
342
519
  },
343
520
  },
344
521
  {
345
- name: 'test_summary',
346
- 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.',
522
+ name: "test_summary",
523
+ 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.",
347
524
  inputSchema: {
348
- type: 'object',
525
+ type: "object",
349
526
  properties: {
350
- command: { type: 'string', description: 'Test command to run (e.g., "npm test", "pytest", "go test ./...")' },
351
- runner: { type: 'string', enum: ['vitest', 'jest', 'pytest', 'phpunit', 'go', 'cargo', 'rspec', 'mocha'], description: 'Force specific parser (auto-detected if omitted)' },
352
- timeout: { type: 'number', description: 'Timeout in ms (default: 60000, max: 300000)' },
527
+ command: {
528
+ type: "string",
529
+ description: 'Test command to run (e.g., "npm test", "pytest", "go test ./...")',
530
+ },
531
+ runner: {
532
+ type: "string",
533
+ enum: [
534
+ "vitest",
535
+ "jest",
536
+ "pytest",
537
+ "phpunit",
538
+ "go",
539
+ "cargo",
540
+ "rspec",
541
+ "mocha",
542
+ ],
543
+ description: "Force specific parser (auto-detected if omitted)",
544
+ },
545
+ timeout: {
546
+ type: "number",
547
+ description: "Timeout in ms (default: 60000, max: 300000)",
548
+ },
353
549
  },
354
- required: ['command'],
550
+ required: ["command"],
355
551
  },
356
552
  },
357
553
  // --- Session ---
358
554
  {
359
- name: 'session_snapshot',
360
- description: 'Capture current session state as a compact markdown block (<200 tokens). Call before compaction, when switching direction, or periodically in long sessions. Model provides the facts, tool formats them.',
555
+ name: "session_snapshot",
556
+ description: "Capture current session state as a compact markdown block (<200 tokens). Call before compaction, when switching direction, or periodically in long sessions. Model provides the facts, tool formats them.",
361
557
  inputSchema: {
362
- type: 'object',
558
+ type: "object",
363
559
  properties: {
364
- goal: { type: 'string', description: 'Session goal — what and why' },
365
- decisions: { type: 'array', items: { type: 'string' }, description: 'Key decisions made and why (e.g., "removed sysfee step — caused double counting"). Prevents revisiting rejected approaches.' },
366
- confirmed: { type: 'array', items: { type: 'string' }, description: 'Established facts (what has been verified)' },
367
- files: { type: 'array', items: { type: 'string' }, description: 'Relevant file paths' },
368
- blocked: { type: 'string', description: 'Current blocker or obstacle' },
369
- next: { type: 'string', description: 'Next step to take' },
560
+ goal: { type: "string", description: "Session goal — what and why" },
561
+ decisions: {
562
+ type: "array",
563
+ items: { type: "string" },
564
+ description: 'Key decisions made and why (e.g., "removed sysfee step — caused double counting"). Prevents revisiting rejected approaches.',
565
+ },
566
+ confirmed: {
567
+ type: "array",
568
+ items: { type: "string" },
569
+ description: "Established facts (what has been verified)",
570
+ },
571
+ files: {
572
+ type: "array",
573
+ items: { type: "string" },
574
+ description: "Relevant file paths",
575
+ },
576
+ blocked: { type: "string", description: "Current blocker or obstacle" },
577
+ next: { type: "string", description: "Next step to take" },
578
+ },
579
+ required: ["goal"],
580
+ },
581
+ },
582
+ {
583
+ name: "session_budget",
584
+ description: "Report Read-hook pressure for this session: suppressed tokens so far, reference budget, burn fraction (0..1), and the effective denyThreshold the adaptive curve would apply right now. NOTE: burnFraction measures hook activity, not actual context-window occupancy. Useful to decide when to tighten further before a big read.",
585
+ inputSchema: {
586
+ type: "object",
587
+ properties: {
588
+ sessionId: {
589
+ type: "string",
590
+ description: 'Claude Code session_id (same id that appears in hook-events.jsonl). Pass "" to read with no session filter.',
591
+ },
370
592
  },
371
- required: ['goal'],
593
+ required: ["sessionId"],
372
594
  },
373
595
  },
374
596
  ];