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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -2
- 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/core/event-log.d.ts +10 -0
- package/dist/hooks/installer.js +37 -54
- package/dist/hooks/post-task.d.ts +6 -0
- package/dist/hooks/post-task.js +5 -0
- package/dist/index.js +26 -0
- 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.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.
|
|
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.
|
|
4
|
-
"description": "Saves 60-90% tokens
|
|
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"
|
package/agents/tp-debugger.md
CHANGED
package/agents/tp-dep-health.md
CHANGED
package/agents/tp-doc-writer.md
CHANGED
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.34.1"
|
|
14
14
|
token_pilot_body_hash: 832e95633fbc8e9b0c10f3e540a327d4be062fb4b3f17a6cce6be13f414e2927
|
|
15
15
|
---
|
|
16
16
|
|
package/agents/tp-pr-reviewer.md
CHANGED
package/agents/tp-run.md
CHANGED
package/agents/tp-spec-writer.md
CHANGED
package/agents/tp-test-triage.md
CHANGED
package/agents/tp-test-writer.md
CHANGED
package/dist/core/event-log.d.ts
CHANGED
|
@@ -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;
|
package/dist/hooks/installer.js
CHANGED
|
@@ -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
|
package/dist/hooks/post-task.js
CHANGED
|
@@ -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.
|
|
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",
|