Skip to content

Commit 6c02272

Browse files
authored
v0.40.0: capture task telemetry via SubagentStop (confirmed root cause) (#38)
Resolves the multi-release "0 task events" mystery with a clean, in-session empirical proof — not another guess. The proof (run this session, fresh 0.39.3, async already reverted): 1. Captured a cutoff timestamp. 2. Dispatched a real subagent via the Agent tool (32947 tokens, returned). Result: ZERO events after cutoff. 3. In the SAME session, triggered a Read-deny on a large file. Result: exactly 1 `denied` event written after its cutoff. 4. An unbounded recursive search was blocked by hook-pre-bash (hooks demonstrably live this session). So: appendEvent + the hook runtime are healthy (Read-deny wrote), but PostToolUse:Task produces nothing on a real dispatch. That is the entire "0 task events" history explained — the parent-side PostToolUse hook simply does not fire for the dispatch tool on this Claude Code. async (v0.35.0) was never the cause; the April zeros predate it. Releases v0.33.1 / v0.39.2 chased the wrong layer. The fix — SubagentStop: Claude Code's SubagentStop is the canonical subagent-completion event (bundle schema: agent_id, agent_type, agent_transcript_path, last_assistant_message). It fires once per subagent by definition. New hook-subagent-stop writes the `event:"task"` record from it: - subagent_type = agent_type (the adoption signal v0.30 needs: was a subagent used, tp-* or not) - estTokens = best-effort sum from the transcript usage (agent_transcript_path), 0 on any failure - code:"subagent_stop" marks the source so a future revival of PostToolUse:Task can be deduped, not double-counted Routing-miss detection (general-purpose where tp-* fit) stays in the PreToolUse:Task diagnostic, which has the task description SubagentStop lacks. Wiring: - src/hooks/subagent-stop.ts — buildSubagentTaskEvent + tokensFromTranscript (both pure / injectable, fully tested). - index.ts case hook-subagent-stop (synchronous — writes telemetry). - hooks/hooks.json + installer.ts: SubagentStop section, installed + uninstalled idempotently alongside the others. - typo-guard registers hook-subagent-stop. Verified end-to-end against the built dist: a SubagentStop payload for tp-pr-reviewer writes event:"task" subagent_type=tp-pr-reviewer code=subagent_stop. PostToolUse:Task is KEPT (harmless; carries tokens if CC ever fixes it; code-marked events let stats dedup). Tests: 1328/1328 pass (+9 subagent-stop + typo-guard).
1 parent 9cbc089 commit 6c02272

35 files changed

Lines changed: 330 additions & 34 deletions

.claude-plugin/marketplace.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
},
77
"metadata": {
88
"description": "Token Pilot \u2014 save 60-90% tokens when AI reads code",
9-
"version": "0.39.3"
9+
"version": "0.40.0"
1010
},
1111
"plugins": [
1212
{
1313
"name": "token-pilot",
1414
"source": "./",
1515
"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.39.3",
16+
"version": "0.40.0",
1717
"author": {
1818
"name": "Digital-Threads"
1919
},

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "token-pilot",
3-
"version": "0.39.3",
3+
"version": "0.40.0",
44
"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.",
55
"author": {
66
"name": "Digital-Threads",

agents/tp-api-surface-tracker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tools:
99
- mcp__token-pilot__read_symbol
1010
- Bash
1111
model: haiku
12-
token_pilot_version: "0.39.3"
12+
token_pilot_version: "0.40.0"
1313
token_pilot_body_hash: dd184501203fa7f3c73f419c4ffbe33c4be75400cb64a7a51733a3fe23f6e085
1414
requiredMcpServers:
1515
- "token-pilot"

agents/tp-audit-scanner.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tools:
1111
- Grep
1212
- Read
1313
model: sonnet
14-
token_pilot_version: "0.39.3"
14+
token_pilot_version: "0.40.0"
1515
token_pilot_body_hash: d172f600bf32277ea6eb4cbbee4542ddd698a986dcd96997d33930561964569b
1616
requiredMcpServers:
1717
- "token-pilot"

agents/tp-commit-writer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tools:
88
- mcp__token-pilot__test_summary
99
- mcp__token-pilot__outline
1010
- Bash
11-
token_pilot_version: "0.39.3"
11+
token_pilot_version: "0.40.0"
1212
token_pilot_body_hash: de64a406b5176de19f7422619c7de7949b1f28865f225402c9cea9255f377428
1313
requiredMcpServers:
1414
- "token-pilot"

agents/tp-context-engineer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ tools:
1313
- Edit
1414
- Glob
1515
model: sonnet
16-
token_pilot_version: "0.39.3"
16+
token_pilot_version: "0.40.0"
1717
token_pilot_body_hash: 68b32af2dacd82ebe52c4eec93edb903d452688274c3065218270627c564d8b0
1818
requiredMcpServers:
1919
- "token-pilot"

agents/tp-dead-code-finder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tools:
1111
- Grep
1212
- Read
1313
model: sonnet
14-
token_pilot_version: "0.39.3"
14+
token_pilot_version: "0.40.0"
1515
token_pilot_body_hash: d9b7f5b7ae6f4ae21305c775361bcab097cc774370a6d976c093571d46d55021
1616
requiredMcpServers:
1717
- "token-pilot"

agents/tp-debugger.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tools:
1212
- Read
1313
- Bash
1414
model: sonnet
15-
token_pilot_version: "0.39.3"
15+
token_pilot_version: "0.40.0"
1616
token_pilot_body_hash: 052413de8d92377edcde6ae5c823f5378db304baccfa29e8866467f42553a500
1717
requiredMcpServers:
1818
- "token-pilot"

agents/tp-dep-health.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tools:
99
- Bash
1010
- Read
1111
model: haiku
12-
token_pilot_version: "0.39.3"
12+
token_pilot_version: "0.40.0"
1313
token_pilot_body_hash: e14dc57493d816f8c2e017963e2ef5f66bea50fd0b805a80e8a0d97c968427e7
1414
requiredMcpServers:
1515
- "token-pilot"

agents/tp-doc-writer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ tools:
1313
- Edit
1414
- Glob
1515
model: haiku
16-
token_pilot_version: "0.39.3"
16+
token_pilot_version: "0.40.0"
1717
token_pilot_body_hash: 57d741794ab40e31a7ac49c68ea39a9088f5827cdef866ce81bfca1b7c9180cf
1818
requiredMcpServers:
1919
- "token-pilot"

0 commit comments

Comments
 (0)