token-pilot 0.40.0 → 0.41.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +15 -0
- package/agents/tp-api-surface-tracker.md +1 -1
- package/agents/tp-audit-scanner.md +1 -1
- package/agents/tp-commit-writer.md +1 -1
- package/agents/tp-context-engineer.md +1 -1
- package/agents/tp-dead-code-finder.md +1 -1
- package/agents/tp-debugger.md +1 -1
- package/agents/tp-dep-health.md +1 -1
- package/agents/tp-doc-writer.md +1 -1
- package/agents/tp-history-explorer.md +1 -1
- package/agents/tp-impact-analyzer.md +1 -1
- package/agents/tp-incident-timeline.md +1 -1
- package/agents/tp-incremental-builder.md +1 -1
- package/agents/tp-migration-scout.md +1 -1
- package/agents/tp-onboard.md +1 -1
- package/agents/tp-performance-profiler.md +1 -1
- package/agents/tp-pr-reviewer.md +1 -1
- package/agents/tp-refactor-planner.md +1 -1
- package/agents/tp-review-impact.md +1 -1
- package/agents/tp-run.md +1 -1
- package/agents/tp-session-restorer.md +1 -1
- package/agents/tp-ship-coordinator.md +1 -1
- package/agents/tp-spec-writer.md +1 -1
- package/agents/tp-test-coverage-gapper.md +1 -1
- package/agents/tp-test-triage.md +1 -1
- package/agents/tp-test-writer.md +1 -1
- package/dist/hooks/subagent-stop.d.ts +28 -0
- package/dist/hooks/subagent-stop.js +41 -0
- package/dist/index.js +26 -1
- package/package.json +1 -1
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Token Pilot \u2014 save 60-90% tokens when AI reads code",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.41.0"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
13
13
|
"name": "token-pilot",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "Reduces token consumption by 60-90% via AST-aware lazy file reading, structural symbol navigation, and cross-session tool-usage analytics. 22 MCP tools + 19 subagents + budget watchdog hooks.",
|
|
16
|
-
"version": "0.
|
|
16
|
+
"version": "0.41.0",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Digital-Threads"
|
|
19
19
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "token-pilot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "Saves 60-90% tokens on AI code reading. AST-aware lazy reads, symbol navigation, find_usages, structural git diff/log, edit-safety guard, Task-routing matcher, cross-session telemetry (errors + diagnostics), 25 tp-* subagents tiered to haiku/sonnet/opus with budget watchdog.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Digital-Threads",
|
package/README.md
CHANGED
|
@@ -232,6 +232,21 @@ lines instead of bouncing the call. The structural summary still
|
|
|
232
232
|
rides along in `additionalContext`. Default OFF because the field
|
|
233
233
|
is undocumented and may change.
|
|
234
234
|
|
|
235
|
+
### Experimental: SubagentStop budget feedback (CC 2.1.163+)
|
|
236
|
+
|
|
237
|
+
Every subagent completion already lands a task-telemetry row via the
|
|
238
|
+
`SubagentStop` hook (that's how `stats --tasks` knows what you
|
|
239
|
+
dispatched). With `TOKEN_PILOT_SUBAGENT_FEEDBACK=1` the same hook also
|
|
240
|
+
returns `additionalContext` — when a `token-pilot workflow` fan-out is
|
|
241
|
+
at ≥90 % of its token ceiling, each completing agent gets a wind-down
|
|
242
|
+
note so a hundred-agent `/workflow` run stops before blowing the
|
|
243
|
+
budget.
|
|
244
|
+
|
|
245
|
+
**Requires Claude Code 2.1.163+.** Returning `additionalContext` from
|
|
246
|
+
`SubagentStop` is only honoured there; older Claude Code labels it a
|
|
247
|
+
hook error. Default OFF for that reason — enable only once
|
|
248
|
+
`claude --version` reports 2.1.163 or later.
|
|
249
|
+
|
|
235
250
|
## What's new for Claude Code 2.1.151+
|
|
236
251
|
|
|
237
252
|
These notes are about behaviour you'll see automatically once you
|
|
@@ -9,7 +9,7 @@ tools:
|
|
|
9
9
|
- mcp__token-pilot__read_symbol
|
|
10
10
|
- Bash
|
|
11
11
|
model: haiku
|
|
12
|
-
token_pilot_version: "0.
|
|
12
|
+
token_pilot_version: "0.41.0"
|
|
13
13
|
token_pilot_body_hash: dd184501203fa7f3c73f419c4ffbe33c4be75400cb64a7a51733a3fe23f6e085
|
|
14
14
|
requiredMcpServers:
|
|
15
15
|
- "token-pilot"
|
|
@@ -8,7 +8,7 @@ tools:
|
|
|
8
8
|
- mcp__token-pilot__test_summary
|
|
9
9
|
- mcp__token-pilot__outline
|
|
10
10
|
- Bash
|
|
11
|
-
token_pilot_version: "0.
|
|
11
|
+
token_pilot_version: "0.41.0"
|
|
12
12
|
token_pilot_body_hash: de64a406b5176de19f7422619c7de7949b1f28865f225402c9cea9255f377428
|
|
13
13
|
requiredMcpServers:
|
|
14
14
|
- "token-pilot"
|
package/agents/tp-debugger.md
CHANGED
package/agents/tp-dep-health.md
CHANGED
package/agents/tp-doc-writer.md
CHANGED
|
@@ -12,7 +12,7 @@ tools:
|
|
|
12
12
|
- mcp__token-pilot__read_symbols
|
|
13
13
|
- Read
|
|
14
14
|
model: sonnet
|
|
15
|
-
token_pilot_version: "0.
|
|
15
|
+
token_pilot_version: "0.41.0"
|
|
16
16
|
token_pilot_body_hash: 351a987e11eba63852f5431a16d8eb53104f4f689f82fdcc5a2bf4db948ba92f
|
|
17
17
|
requiredMcpServers:
|
|
18
18
|
- "token-pilot"
|
|
@@ -8,7 +8,7 @@ tools:
|
|
|
8
8
|
- mcp__token-pilot__read_symbol
|
|
9
9
|
- Bash
|
|
10
10
|
model: inherit
|
|
11
|
-
token_pilot_version: "0.
|
|
11
|
+
token_pilot_version: "0.41.0"
|
|
12
12
|
token_pilot_body_hash: de5722bfea374eaab096c1ae635c37879e7a91370ee3cd0532f4240be03c91eb
|
|
13
13
|
requiredMcpServers:
|
|
14
14
|
- "token-pilot"
|
package/agents/tp-onboard.md
CHANGED
|
@@ -10,7 +10,7 @@ tools:
|
|
|
10
10
|
- mcp__token-pilot__smart_read
|
|
11
11
|
- mcp__token-pilot__smart_read_many
|
|
12
12
|
- mcp__token-pilot__read_section
|
|
13
|
-
token_pilot_version: "0.
|
|
13
|
+
token_pilot_version: "0.41.0"
|
|
14
14
|
token_pilot_body_hash: 832e95633fbc8e9b0c10f3e540a327d4be062fb4b3f17a6cce6be13f414e2927
|
|
15
15
|
requiredMcpServers:
|
|
16
16
|
- "token-pilot"
|
package/agents/tp-pr-reviewer.md
CHANGED
|
@@ -11,7 +11,7 @@ tools:
|
|
|
11
11
|
- mcp__token-pilot__read_for_edit
|
|
12
12
|
- Read
|
|
13
13
|
model: sonnet
|
|
14
|
-
token_pilot_version: "0.
|
|
14
|
+
token_pilot_version: "0.41.0"
|
|
15
15
|
token_pilot_body_hash: f83f50d05b4f70285ae7afed2b1a406fc436df56e61a0aedbfb31edc7f2b6e66
|
|
16
16
|
requiredMcpServers:
|
|
17
17
|
- "token-pilot"
|
|
@@ -8,7 +8,7 @@ tools:
|
|
|
8
8
|
- mcp__token-pilot__outline
|
|
9
9
|
- mcp__token-pilot__read_symbol
|
|
10
10
|
model: sonnet
|
|
11
|
-
token_pilot_version: "0.
|
|
11
|
+
token_pilot_version: "0.41.0"
|
|
12
12
|
token_pilot_body_hash: c5f6fc122c89e16e5cf774045f92169ee3468555320b898171ba13eca5323550
|
|
13
13
|
requiredMcpServers:
|
|
14
14
|
- "token-pilot"
|
|
@@ -9,7 +9,7 @@ tools:
|
|
|
9
9
|
- mcp__token-pilot__module_info
|
|
10
10
|
- Bash
|
|
11
11
|
model: sonnet
|
|
12
|
-
token_pilot_version: "0.
|
|
12
|
+
token_pilot_version: "0.41.0"
|
|
13
13
|
token_pilot_body_hash: 8ef3c3341cbfed4eb8dd130126a9683edc57e378c92ff0ca764d584fd941c55c
|
|
14
14
|
requiredMcpServers:
|
|
15
15
|
- "token-pilot"
|
package/agents/tp-run.md
CHANGED
package/agents/tp-spec-writer.md
CHANGED
|
@@ -10,7 +10,7 @@ tools:
|
|
|
10
10
|
- mcp__token-pilot__test_summary
|
|
11
11
|
- Glob
|
|
12
12
|
- Grep
|
|
13
|
-
token_pilot_version: "0.
|
|
13
|
+
token_pilot_version: "0.41.0"
|
|
14
14
|
token_pilot_body_hash: be81eed53a3720d146cf89e4a14a7a56577633f7c84c234c412ab70d64c05b11
|
|
15
15
|
requiredMcpServers:
|
|
16
16
|
- "token-pilot"
|
package/agents/tp-test-triage.md
CHANGED
|
@@ -8,7 +8,7 @@ tools:
|
|
|
8
8
|
- mcp__token-pilot__find_usages
|
|
9
9
|
- mcp__token-pilot__read_symbol
|
|
10
10
|
model: sonnet
|
|
11
|
-
token_pilot_version: "0.
|
|
11
|
+
token_pilot_version: "0.41.0"
|
|
12
12
|
token_pilot_body_hash: 362ecf4cb03b059421ea26933473700900073dc38b3a7fe271208dfb1ae14f90
|
|
13
13
|
requiredMcpServers:
|
|
14
14
|
- "token-pilot"
|
package/agents/tp-test-writer.md
CHANGED
|
@@ -52,4 +52,32 @@ export declare function tokensFromTranscript(path: string | undefined): number;
|
|
|
52
52
|
* can pre-resolve for tests via `tokensOverride`.
|
|
53
53
|
*/
|
|
54
54
|
export declare function buildSubagentTaskEvent(input: SubagentStopInput, now: number, tokensOverride?: number): HookEvent | null;
|
|
55
|
+
export interface SubagentFeedbackContext {
|
|
56
|
+
/** Active workflow budget status, when a fleet workflow is running. */
|
|
57
|
+
workflow?: {
|
|
58
|
+
workflow_id: string;
|
|
59
|
+
budget_tokens: number | null;
|
|
60
|
+
used_tokens: number;
|
|
61
|
+
pct: number | null;
|
|
62
|
+
} | null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Decide the `additionalContext` feedback to hand back from a
|
|
66
|
+
* SubagentStop hook. Pure — caller resolves the workflow status.
|
|
67
|
+
*
|
|
68
|
+
* Returns a short wind-down note when an active fleet workflow is at or
|
|
69
|
+
* past 90 % of its token ceiling, so a `/workflow`-style fan-out winds
|
|
70
|
+
* down before the budget is blown. Returns null otherwise — we do NOT
|
|
71
|
+
* nag on every completion; broad adoption nudges stay in SessionStart.
|
|
72
|
+
*
|
|
73
|
+
* Emission is the caller's responsibility and is gated behind
|
|
74
|
+
* TOKEN_PILOT_SUBAGENT_FEEDBACK=1 + Claude Code 2.1.163+ (older Claude
|
|
75
|
+
* Code labels a SubagentStop hookSpecificOutput return as a hook error).
|
|
76
|
+
*/
|
|
77
|
+
export declare function decideSubagentFeedback(_input: SubagentStopInput, ctx: SubagentFeedbackContext): string | null;
|
|
78
|
+
/**
|
|
79
|
+
* Render the SubagentStop hook JSON response carrying feedback. Returns
|
|
80
|
+
* null when there is nothing to say (caller writes no stdout).
|
|
81
|
+
*/
|
|
82
|
+
export declare function renderSubagentFeedback(message: string | null): string | null;
|
|
55
83
|
//# sourceMappingURL=subagent-stop.d.ts.map
|
|
@@ -105,4 +105,45 @@ export function buildSubagentTaskEvent(input, now, tokensOverride) {
|
|
|
105
105
|
code: "subagent_stop",
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Decide the `additionalContext` feedback to hand back from a
|
|
110
|
+
* SubagentStop hook. Pure — caller resolves the workflow status.
|
|
111
|
+
*
|
|
112
|
+
* Returns a short wind-down note when an active fleet workflow is at or
|
|
113
|
+
* past 90 % of its token ceiling, so a `/workflow`-style fan-out winds
|
|
114
|
+
* down before the budget is blown. Returns null otherwise — we do NOT
|
|
115
|
+
* nag on every completion; broad adoption nudges stay in SessionStart.
|
|
116
|
+
*
|
|
117
|
+
* Emission is the caller's responsibility and is gated behind
|
|
118
|
+
* TOKEN_PILOT_SUBAGENT_FEEDBACK=1 + Claude Code 2.1.163+ (older Claude
|
|
119
|
+
* Code labels a SubagentStop hookSpecificOutput return as a hook error).
|
|
120
|
+
*/
|
|
121
|
+
export function decideSubagentFeedback(_input, ctx) {
|
|
122
|
+
const wf = ctx.workflow;
|
|
123
|
+
if (wf &&
|
|
124
|
+
wf.budget_tokens != null &&
|
|
125
|
+
wf.budget_tokens > 0 &&
|
|
126
|
+
wf.used_tokens >= wf.budget_tokens * 0.9) {
|
|
127
|
+
const pct = wf.pct != null ? `${wf.pct}%` : "~90%";
|
|
128
|
+
return (`[token-pilot] workflow ${wf.workflow_id} is at ${pct} of its ` +
|
|
129
|
+
`${wf.budget_tokens} token ceiling (${wf.used_tokens} used). ` +
|
|
130
|
+
`Wind down the fan-out: finish in-flight branches and report ` +
|
|
131
|
+
`rather than dispatching new agents.`);
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Render the SubagentStop hook JSON response carrying feedback. Returns
|
|
137
|
+
* null when there is nothing to say (caller writes no stdout).
|
|
138
|
+
*/
|
|
139
|
+
export function renderSubagentFeedback(message) {
|
|
140
|
+
if (!message)
|
|
141
|
+
return null;
|
|
142
|
+
return JSON.stringify({
|
|
143
|
+
hookSpecificOutput: {
|
|
144
|
+
hookEventName: "SubagentStop",
|
|
145
|
+
additionalContext: message,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
108
149
|
//# sourceMappingURL=subagent-stop.js.map
|
package/dist/index.js
CHANGED
|
@@ -336,12 +336,37 @@ export async function main(cliArgs = process.argv.slice(2)) {
|
|
|
336
336
|
await runHookEntryPoint({ hook: "hook-subagent-stop" }, async () => {
|
|
337
337
|
const stdin = readFileSync(0, "utf-8");
|
|
338
338
|
const input = JSON.parse(stdin);
|
|
339
|
-
const { buildSubagentTaskEvent } = await import("./hooks/subagent-stop.js");
|
|
339
|
+
const { buildSubagentTaskEvent, decideSubagentFeedback, renderSubagentFeedback, } = await import("./hooks/subagent-stop.js");
|
|
340
340
|
const ev = buildSubagentTaskEvent(input, Date.now());
|
|
341
341
|
if (ev) {
|
|
342
342
|
const { appendEvent } = await import("./core/event-log.js");
|
|
343
343
|
await appendEvent(process.cwd(), ev);
|
|
344
344
|
}
|
|
345
|
+
// v0.41.0 — optional SubagentStop feedback. Returning
|
|
346
|
+
// hookSpecificOutput.additionalContext from SubagentStop is a
|
|
347
|
+
// Claude Code 2.1.163+ feature; on older Claude Code it is
|
|
348
|
+
// labelled a hook error (noise). Gate strictly behind
|
|
349
|
+
// TOKEN_PILOT_SUBAGENT_FEEDBACK=1 so the default path (telemetry
|
|
350
|
+
// only) stays safe on every version.
|
|
351
|
+
if (process.env.TOKEN_PILOT_SUBAGENT_FEEDBACK === "1") {
|
|
352
|
+
const { activeWorkflowId, workflowStatus } = await import("./core/workflow.js");
|
|
353
|
+
let wf = null;
|
|
354
|
+
const wfId = activeWorkflowId();
|
|
355
|
+
if (wfId) {
|
|
356
|
+
const st = await workflowStatus(process.cwd(), wfId);
|
|
357
|
+
if (st) {
|
|
358
|
+
wf = {
|
|
359
|
+
workflow_id: st.workflow_id,
|
|
360
|
+
budget_tokens: st.budget_tokens,
|
|
361
|
+
used_tokens: st.used_tokens,
|
|
362
|
+
pct: st.pct,
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const rendered = renderSubagentFeedback(decideSubagentFeedback(input, { workflow: wf }));
|
|
367
|
+
if (rendered)
|
|
368
|
+
process.stdout.write(rendered);
|
|
369
|
+
}
|
|
345
370
|
});
|
|
346
371
|
return;
|
|
347
372
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "token-pilot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "Save up to 80% tokens when AI reads code — MCP server for token-efficient code navigation, AST-aware structural reading instead of dumping full files into context window",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|