token-pilot 0.33.1 → 0.34.1

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.
@@ -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.33.1"
9
+ "version": "0.34.1"
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.33.1",
16
+ "version": "0.34.1",
17
17
  "author": {
18
18
  "name": "Digital-Threads"
19
19
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "token-pilot",
3
- "version": "0.33.1",
4
- "description": "Saves 60-90% tokens when AI reads code. AST-aware lazy reading, symbol navigation, cross-session tool-usage analytics, 22 subagents (haiku/sonnet/opus-tiered) with budget watchdog.",
3
+ "version": "0.34.1",
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",
7
7
  "url": "https://github.com/Digital-Threads"
@@ -9,7 +9,7 @@ tools:
9
9
  - mcp__token-pilot__read_symbol
10
10
  - Bash
11
11
  model: haiku
12
- token_pilot_version: "0.33.1"
12
+ token_pilot_version: "0.34.1"
13
13
  token_pilot_body_hash: dd184501203fa7f3c73f419c4ffbe33c4be75400cb64a7a51733a3fe23f6e085
14
14
  ---
15
15
 
@@ -11,7 +11,7 @@ tools:
11
11
  - Grep
12
12
  - Read
13
13
  model: sonnet
14
- token_pilot_version: "0.33.1"
14
+ token_pilot_version: "0.34.1"
15
15
  token_pilot_body_hash: d172f600bf32277ea6eb4cbbee4542ddd698a986dcd96997d33930561964569b
16
16
  ---
17
17
 
@@ -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.33.1"
11
+ token_pilot_version: "0.34.1"
12
12
  token_pilot_body_hash: de64a406b5176de19f7422619c7de7949b1f28865f225402c9cea9255f377428
13
13
  ---
14
14
 
@@ -13,7 +13,7 @@ tools:
13
13
  - Edit
14
14
  - Glob
15
15
  model: sonnet
16
- token_pilot_version: "0.33.1"
16
+ token_pilot_version: "0.34.1"
17
17
  token_pilot_body_hash: 68b32af2dacd82ebe52c4eec93edb903d452688274c3065218270627c564d8b0
18
18
  ---
19
19
 
@@ -11,7 +11,7 @@ tools:
11
11
  - Grep
12
12
  - Read
13
13
  model: sonnet
14
- token_pilot_version: "0.33.1"
14
+ token_pilot_version: "0.34.1"
15
15
  token_pilot_body_hash: d9b7f5b7ae6f4ae21305c775361bcab097cc774370a6d976c093571d46d55021
16
16
  ---
17
17
 
@@ -12,7 +12,7 @@ tools:
12
12
  - Read
13
13
  - Bash
14
14
  model: sonnet
15
- token_pilot_version: "0.33.1"
15
+ token_pilot_version: "0.34.1"
16
16
  token_pilot_body_hash: 052413de8d92377edcde6ae5c823f5378db304baccfa29e8866467f42553a500
17
17
  ---
18
18
 
@@ -9,7 +9,7 @@ tools:
9
9
  - Bash
10
10
  - Read
11
11
  model: haiku
12
- token_pilot_version: "0.33.1"
12
+ token_pilot_version: "0.34.1"
13
13
  token_pilot_body_hash: e14dc57493d816f8c2e017963e2ef5f66bea50fd0b805a80e8a0d97c968427e7
14
14
  ---
15
15
 
@@ -13,7 +13,7 @@ tools:
13
13
  - Edit
14
14
  - Glob
15
15
  model: haiku
16
- token_pilot_version: "0.33.1"
16
+ token_pilot_version: "0.34.1"
17
17
  token_pilot_body_hash: 57d741794ab40e31a7ac49c68ea39a9088f5827cdef866ce81bfca1b7c9180cf
18
18
  ---
19
19
 
@@ -10,7 +10,7 @@ tools:
10
10
  - Bash
11
11
  - Read
12
12
  model: haiku
13
- token_pilot_version: "0.33.1"
13
+ token_pilot_version: "0.34.1"
14
14
  token_pilot_body_hash: 7b70fa76a60e3c58a1de4f56c32c0f166424137e203a0cf1c8654e7c9235d904
15
15
  ---
16
16
 
@@ -12,7 +12,7 @@ tools:
12
12
  - mcp__token-pilot__read_symbols
13
13
  - Read
14
14
  model: sonnet
15
- token_pilot_version: "0.33.1"
15
+ token_pilot_version: "0.34.1"
16
16
  token_pilot_body_hash: 351a987e11eba63852f5431a16d8eb53104f4f689f82fdcc5a2bf4db948ba92f
17
17
  ---
18
18
 
@@ -8,7 +8,7 @@ tools:
8
8
  - mcp__token-pilot__read_symbol
9
9
  - Bash
10
10
  model: inherit
11
- token_pilot_version: "0.33.1"
11
+ token_pilot_version: "0.34.1"
12
12
  token_pilot_body_hash: de5722bfea374eaab096c1ae635c37879e7a91370ee3cd0532f4240be03c91eb
13
13
  ---
14
14
 
@@ -13,7 +13,7 @@ tools:
13
13
  - Edit
14
14
  - Bash
15
15
  model: sonnet
16
- token_pilot_version: "0.33.1"
16
+ token_pilot_version: "0.34.1"
17
17
  token_pilot_body_hash: 375a824d0d847bb5453ec594c7a62ad566ee7e4d92717b0473f771f1a0477c60
18
18
  ---
19
19
 
@@ -11,7 +11,7 @@ tools:
11
11
  - Grep
12
12
  - Glob
13
13
  model: sonnet
14
- token_pilot_version: "0.33.1"
14
+ token_pilot_version: "0.34.1"
15
15
  token_pilot_body_hash: 0334de1bf99b431b65359637d125cda7c44c6f780eb92c57cc538715b1939536
16
16
  ---
17
17
 
@@ -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.33.1"
13
+ token_pilot_version: "0.34.1"
14
14
  token_pilot_body_hash: 832e95633fbc8e9b0c10f3e540a327d4be062fb4b3f17a6cce6be13f414e2927
15
15
  ---
16
16
 
@@ -11,7 +11,7 @@ tools:
11
11
  - Bash
12
12
  - Read
13
13
  model: sonnet
14
- token_pilot_version: "0.33.1"
14
+ token_pilot_version: "0.34.1"
15
15
  token_pilot_body_hash: b61f06380d80798fa2e49d37bcba0653495bee04dd6bdbc1feff9a75607b0508
16
16
  ---
17
17
 
@@ -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.33.1"
14
+ token_pilot_version: "0.34.1"
15
15
  token_pilot_body_hash: f83f50d05b4f70285ae7afed2b1a406fc436df56e61a0aedbfb31edc7f2b6e66
16
16
  ---
17
17
 
@@ -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.33.1"
11
+ token_pilot_version: "0.34.1"
12
12
  token_pilot_body_hash: c5f6fc122c89e16e5cf774045f92169ee3468555320b898171ba13eca5323550
13
13
  ---
14
14
 
@@ -9,7 +9,7 @@ tools:
9
9
  - mcp__token-pilot__module_info
10
10
  - Bash
11
11
  model: sonnet
12
- token_pilot_version: "0.33.1"
12
+ token_pilot_version: "0.34.1"
13
13
  token_pilot_body_hash: 8ef3c3341cbfed4eb8dd130126a9683edc57e378c92ff0ca764d584fd941c55c
14
14
  ---
15
15
 
package/agents/tp-run.md CHANGED
@@ -16,7 +16,7 @@ tools:
16
16
  - Glob
17
17
  - Bash
18
18
  model: haiku
19
- token_pilot_version: "0.33.1"
19
+ token_pilot_version: "0.34.1"
20
20
  token_pilot_body_hash: 2b08618d34a61f00aafccbda9fed6d83243296dedb83440edbd2d5c28bb6dbc4
21
21
  ---
22
22
 
@@ -9,7 +9,7 @@ tools:
9
9
  - mcp__token-pilot__session_budget
10
10
  - Bash
11
11
  - Read
12
- token_pilot_version: "0.33.1"
12
+ token_pilot_version: "0.34.1"
13
13
  token_pilot_body_hash: 529374ed728f5eed5b758b3be3da65624783c0bf0c1a253d7d661a843eb5f767
14
14
  ---
15
15
 
@@ -11,7 +11,7 @@ tools:
11
11
  - Read
12
12
  - Grep
13
13
  model: sonnet
14
- token_pilot_version: "0.33.1"
14
+ token_pilot_version: "0.34.1"
15
15
  token_pilot_body_hash: a60f6ae110eb3138064bce074e8ba26fa0ce5f4659df1624a9d9d3646803391b
16
16
  ---
17
17
 
@@ -9,7 +9,7 @@ tools:
9
9
  - Read
10
10
  - Write
11
11
  model: sonnet
12
- token_pilot_version: "0.33.1"
12
+ token_pilot_version: "0.34.1"
13
13
  token_pilot_body_hash: c7a4e8b39228fd5158528f389c924c5ff2d98c4b9b05ee0106d54a26c5dc1350
14
14
  ---
15
15
 
@@ -10,7 +10,7 @@ tools:
10
10
  - mcp__token-pilot__test_summary
11
11
  - Glob
12
12
  - Grep
13
- token_pilot_version: "0.33.1"
13
+ token_pilot_version: "0.34.1"
14
14
  token_pilot_body_hash: be81eed53a3720d146cf89e4a14a7a56577633f7c84c234c412ab70d64c05b11
15
15
  ---
16
16
 
@@ -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.33.1"
11
+ token_pilot_version: "0.34.1"
12
12
  token_pilot_body_hash: 362ecf4cb03b059421ea26933473700900073dc38b3a7fe271208dfb1ae14f90
13
13
  ---
14
14
 
@@ -13,7 +13,7 @@ tools:
13
13
  - Edit
14
14
  - Bash
15
15
  model: sonnet
16
- token_pilot_version: "0.33.1"
16
+ token_pilot_version: "0.34.1"
17
17
  token_pilot_body_hash: 269f2fe22ff4517c277d3f56ca67d8a5527b93290ab21079a83ba7af22c1b5a9
18
18
  ---
19
19
 
@@ -28,6 +28,16 @@ export interface HookEvent {
28
28
  /** null for top-level session; agent_type string inside a subagent. */
29
29
  agent_type: string | null;
30
30
  agent_id: string | null;
31
+ /**
32
+ * v0.34.0 — agent_id of the parent that dispatched this subagent.
33
+ * Claude Code now ships `x-claude-code-parent-agent-id` headers
34
+ * and exposes the value in PostToolUse:Task input. Capturing it
35
+ * lets us reconstruct the full dispatch chain
36
+ * (main → general-purpose → tp-* delegate, etc.) instead of seeing
37
+ * only the leaf agent. Optional — older Claude Code versions
38
+ * never populate it; events stay shape-compatible.
39
+ */
40
+ parent_agent_id?: string | null;
31
41
  event: "denied" | "allowed" | "bypass" | "pass-through" | "task" | "diagnostic" | string;
32
42
  file: string;
33
43
  lines: number;
@@ -12,6 +12,15 @@ function buildHookCommand(action, options) {
12
12
  }
13
13
  return `token-pilot ${action}`;
14
14
  }
15
+ // v0.34.0 added a `buildHookArgs()` companion that emitted an
16
+ // `args: string[]` field alongside `command`. The intent was to take
17
+ // advantage of Claude Code's new direct-spawn schema, but real
18
+ // installs hit ENOENT because Claude Code does NOT expand
19
+ // `${CLAUDE_PLUGIN_ROOT}` inside `args` array elements. The literal
20
+ // `${CLAUDE_PLUGIN_ROOT}/dist/index.js` then went to posix_spawn as
21
+ // a real path and bounced. v0.34.1 dropped the helper entirely and
22
+ // kept `command`-only emission. Re-introduce only when Claude Code
23
+ // docs confirm the env-expansion rules for `args`.
15
24
  /**
16
25
  * Detect a stale token-pilot hook command — one that points at a
17
26
  * pinned npx-cache snapshot (`npx/_npx/<hash>/...`) or any other
@@ -46,93 +55,67 @@ export function isStaleTokenPilotHookCommand(cmd) {
46
55
  }
47
56
  return false;
48
57
  }
58
+ /**
59
+ * Helper — build the canonical `{type, command}` pair for one hook
60
+ * action so emit stays uniform across every matcher.
61
+ *
62
+ * v0.34.0 introduced an `args: string[]` field alongside `command` to
63
+ * adopt Claude Code's new direct-spawn schema, but that path caused
64
+ * ENOENT on real installs because the new spawn skips shell expansion
65
+ * and Claude Code does NOT interpolate `${CLAUDE_PLUGIN_ROOT}` inside
66
+ * `args` array elements (only inside `command` strings). v0.34.1
67
+ * reverts: shell-expanded `command` remains the safe, portable form
68
+ * for every Claude Code version we know of. When Claude Code docs
69
+ * confirm the env-expansion rules for `args`, we can revisit.
70
+ */
71
+ function hookEntry(action, options) {
72
+ return {
73
+ type: "command",
74
+ command: buildHookCommand(action, options),
75
+ };
76
+ }
49
77
  function createHookConfig(options) {
50
78
  return {
51
79
  hooks: {
52
80
  PreToolUse: [
53
81
  {
54
82
  matcher: "Read",
55
- hooks: [
56
- {
57
- type: "command",
58
- command: buildHookCommand("hook-read", options),
59
- },
60
- ],
83
+ hooks: [hookEntry("hook-read", options)],
61
84
  },
62
85
  {
63
86
  matcher: "Edit",
64
- hooks: [
65
- {
66
- type: "command",
67
- command: buildHookCommand("hook-edit", options),
68
- },
69
- ],
87
+ hooks: [hookEntry("hook-edit", options)],
70
88
  },
71
89
  {
72
90
  matcher: "MultiEdit",
73
- hooks: [
74
- {
75
- type: "command",
76
- command: buildHookCommand("hook-edit", options),
77
- },
78
- ],
91
+ hooks: [hookEntry("hook-edit", options)],
79
92
  },
80
93
  {
81
94
  matcher: "Bash",
82
- hooks: [
83
- {
84
- type: "command",
85
- command: buildHookCommand("hook-pre-bash", options),
86
- },
87
- ],
95
+ hooks: [hookEntry("hook-pre-bash", options)],
88
96
  },
89
97
  {
90
98
  matcher: "Grep",
91
- hooks: [
92
- {
93
- type: "command",
94
- command: buildHookCommand("hook-pre-grep", options),
95
- },
96
- ],
99
+ hooks: [hookEntry("hook-pre-grep", options)],
97
100
  },
98
101
  {
99
102
  matcher: "Task",
100
- hooks: [
101
- {
102
- type: "command",
103
- command: buildHookCommand("hook-pre-task", options),
104
- },
105
- ],
103
+ hooks: [hookEntry("hook-pre-task", options)],
106
104
  },
107
105
  ],
108
106
  SessionStart: [
109
107
  {
110
- hooks: [
111
- {
112
- type: "command",
113
- command: buildHookCommand("hook-session-start", options),
114
- },
115
- ],
108
+ hooks: [hookEntry("hook-session-start", options)],
116
109
  },
117
110
  ],
118
111
  PostToolUse: [
119
112
  {
120
113
  matcher: "Bash",
121
- hooks: [
122
- {
123
- type: "command",
124
- command: buildHookCommand("hook-post-bash", options),
125
- },
126
- ],
114
+ hooks: [hookEntry("hook-post-bash", options)],
127
115
  },
128
116
  {
129
117
  matcher: "Task",
130
- hooks: [
131
- {
132
- type: "command",
133
- command: buildHookCommand("hook-post-task", options),
134
- },
135
- ],
118
+ hooks: [hookEntry("hook-post-task", options)],
136
119
  },
137
120
  ],
138
121
  },
@@ -62,6 +62,12 @@ export interface PostTaskHookInput {
62
62
  session_id?: string;
63
63
  agent_type?: string;
64
64
  agent_id?: string;
65
+ /**
66
+ * v0.34.0 — Claude Code now passes the dispatching agent's id so
67
+ * we can reconstruct the full delegation chain. Older versions
68
+ * never populate it.
69
+ */
70
+ parent_agent_id?: string;
65
71
  }
66
72
  /**
67
73
  * Resolve the plugin's own `agents/` directory. The hook binary lives
@@ -198,6 +198,11 @@ export async function processPostTask(projectRoot, homeDir, input) {
198
198
  session_id: input.session_id ?? "",
199
199
  agent_type: input.agent_type ?? null,
200
200
  agent_id: input.agent_id ?? null,
201
+ // v0.34.0 — capture parent_agent_id when Claude Code provides it.
202
+ // Lets us reconstruct main → general-purpose → tp-* chains.
203
+ ...(input.parent_agent_id
204
+ ? { parent_agent_id: input.parent_agent_id }
205
+ : {}),
201
206
  event: "task",
202
207
  file: "",
203
208
  lines: 0,
package/dist/index.js CHANGED
@@ -485,6 +485,32 @@ export async function startServer(cliArgs = process.argv.slice(2)) {
485
485
  }
486
486
  }
487
487
  }
488
+ // v0.34.0 — fire-and-forget startup diagnostic so we can verify
489
+ // in real-world telemetry whether the new Claude Code (which exposes
490
+ // CLAUDE_PROJECT_DIR to MCP stdio servers since the May 2026 update)
491
+ // is what actually drove the projectRoot decision. NOT awaited — an
492
+ // extra await before createServer breaks tests that rely on a tight
493
+ // microtask flush, and the emit is purely advisory.
494
+ {
495
+ const cpd = process.env.CLAUDE_PROJECT_DIR;
496
+ appendDiagnostic(projectRoot, {
497
+ code: "mcp_startup",
498
+ level: "info",
499
+ detail: {
500
+ project_root_source: explicitRoot
501
+ ? "args"
502
+ : cpd && projectRoot === cpd
503
+ ? "CLAUDE_PROJECT_DIR"
504
+ : process.env.INIT_CWD && projectRoot === process.env.INIT_CWD
505
+ ? "INIT_CWD"
506
+ : "git-detect-or-cwd",
507
+ claude_project_dir_present: !!cpd,
508
+ platform: process.platform,
509
+ },
510
+ }).catch(() => {
511
+ /* best-effort */
512
+ });
513
+ }
488
514
  // Guard: refuse to use dangerous roots that would index the entire disk
489
515
  if (isDangerousRoot(projectRoot)) {
490
516
  console.error(`[token-pilot] WARNING: project root "${projectRoot}" is too broad (system/home directory).\n` +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "token-pilot",
3
- "version": "0.33.1",
3
+ "version": "0.34.1",
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",