token-pilot 0.23.1 → 0.23.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "token-pilot",
3
- "version": "0.23.1",
3
+ "version": "0.23.2",
4
4
  "description": "Enforcement layer for token-efficient AI coding: MCP-first hook with structural denial summaries, SessionStart reminder, bless-agents CLI, and six tp-* subagents — works for every agent including those without MCP access.",
5
5
  "author": "token-pilot",
6
6
  "license": "MIT",
package/CHANGELOG.md CHANGED
@@ -5,6 +5,37 @@ All notable changes to Token Pilot will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.23.2] - 2026-04-18
9
+
10
+ ### Changed — SessionStart reminder now carries a task→agent decision guide
11
+
12
+ The reminder used to list the installed `tp-*` agents with their descriptions. Useful, but the main agent still had to decide **when** to delegate. Now the reminder carries a compact task→agent cheat-sheet inline:
13
+
14
+ ```
15
+ WHEN DELEGATING — if the task fits a specialist, use the Task tool:
16
+ bug / stack trace → tp-debugger
17
+ PR / diff review → tp-pr-reviewer
18
+ impact before change → tp-impact-analyzer
19
+ plan refactor → tp-refactor-planner
20
+ failing tests → tp-test-triage
21
+ write new tests → tp-test-writer
22
+ migrate API / version → tp-migration-scout
23
+ "why is this like this?" → tp-history-explorer
24
+ security / quality audit → tp-audit-scanner
25
+ resume after /clear → tp-session-restorer
26
+ dead code cleanup → tp-dead-code-finder
27
+ commit message → tp-commit-writer
28
+ repo onboarding → tp-onboard
29
+ general workhorse → tp-run
30
+ ```
31
+
32
+ Lines for agents the user hasn't installed are filtered out automatically. Custom / third-party `tp-*` agents not in the core map get a fallback line with their own description. Over-budget trimming still lands `… and N more` with a total count, so nothing silently disappears.
33
+
34
+ Also added to the MANDATORY block: `Batch variants (prefer over loops): read_symbols, smart_read_many, read_section.` — the three batch tools that v0.23.1 wired into specialist agents but that the main agent also benefits from.
35
+
36
+ ### Numbers
37
+ - 906 tests green (+6 new buildReminderMessage regression tests), `tsc --noEmit` clean.
38
+
8
39
  ## [0.23.1] - 2026-04-18
9
40
 
10
41
  ### Changed — agent toolset coverage
@@ -10,7 +10,7 @@ tools:
10
10
  - mcp__token-pilot__read_section
11
11
  - Grep
12
12
  - Read
13
- token_pilot_version: "0.23.1"
13
+ token_pilot_version: "0.23.2"
14
14
  token_pilot_body_hash: a740dc6c928d11d7c2c5fbaa953c50b0e35f2abc2dd6e5ef5117bf469a2d0207
15
15
  ---
16
16
 
@@ -7,7 +7,7 @@ tools:
7
7
  - mcp__token-pilot__test_summary
8
8
  - mcp__token-pilot__outline
9
9
  - Bash
10
- token_pilot_version: "0.23.1"
10
+ token_pilot_version: "0.23.2"
11
11
  token_pilot_body_hash: 559a0b61d20974bf33e35bc4c80dcf1b41d10d4df46cf9d05d3d5620713cd46f
12
12
  ---
13
13
 
@@ -9,7 +9,7 @@ tools:
9
9
  - mcp__token-pilot__related_files
10
10
  - Grep
11
11
  - Read
12
- token_pilot_version: "0.23.1"
12
+ token_pilot_version: "0.23.2"
13
13
  token_pilot_body_hash: 482e33ba566dc75d87753d980267fb2e01763e5924612efd54ec89993b5e12fd
14
14
  ---
15
15
 
@@ -11,7 +11,7 @@ tools:
11
11
  - mcp__token-pilot__read_for_edit
12
12
  - Read
13
13
  - Bash
14
- token_pilot_version: "0.23.1"
14
+ token_pilot_version: "0.23.2"
15
15
  token_pilot_body_hash: 04864ae0bf0689863d7de9f4c0b44b293087b34098ad2771837e491d37dab953
16
16
  ---
17
17
 
@@ -9,7 +9,7 @@ tools:
9
9
  - mcp__token-pilot__outline
10
10
  - Bash
11
11
  - Read
12
- token_pilot_version: "0.23.1"
12
+ token_pilot_version: "0.23.2"
13
13
  token_pilot_body_hash: b2daca007e959eaf26bf9a4d92ba36c3aa277a51de4ca4db674833d36acbe11b
14
14
  ---
15
15
 
@@ -11,7 +11,7 @@ tools:
11
11
  - mcp__token-pilot__smart_read_many
12
12
  - mcp__token-pilot__read_symbols
13
13
  - Read
14
- token_pilot_version: "0.23.1"
14
+ token_pilot_version: "0.23.2"
15
15
  token_pilot_body_hash: 0be2620ce0303f912f6b3334f261d169f064970c0d16602fa1e76db4cb2ea441
16
16
  ---
17
17
 
@@ -10,7 +10,7 @@ tools:
10
10
  - mcp__token-pilot__smart_read_many
11
11
  - Grep
12
12
  - Glob
13
- token_pilot_version: "0.23.1"
13
+ token_pilot_version: "0.23.2"
14
14
  token_pilot_body_hash: cf32cdee777430ecc6732db32b3f883a685c8a02b6dc93379d71b15555e79b3e
15
15
  ---
16
16
 
@@ -9,7 +9,7 @@ tools:
9
9
  - mcp__token-pilot__smart_read
10
10
  - mcp__token-pilot__smart_read_many
11
11
  - mcp__token-pilot__read_section
12
- token_pilot_version: "0.23.1"
12
+ token_pilot_version: "0.23.2"
13
13
  token_pilot_body_hash: ae0b86eaffaf34bf283b94b5572481fa8c2d6a2a25193f1173b70bef0fbe1919
14
14
  ---
15
15
 
@@ -10,7 +10,7 @@ tools:
10
10
  - mcp__token-pilot__smart_read_many
11
11
  - mcp__token-pilot__read_for_edit
12
12
  - Read
13
- token_pilot_version: "0.23.1"
13
+ token_pilot_version: "0.23.2"
14
14
  token_pilot_body_hash: eb9fb7f87d9ab61c5b18248a40b283008b5d73414ddb2e3094ff0826e7e463d0
15
15
  ---
16
16
 
@@ -7,7 +7,7 @@ tools:
7
7
  - mcp__token-pilot__read_diff
8
8
  - mcp__token-pilot__outline
9
9
  - mcp__token-pilot__read_symbol
10
- token_pilot_version: "0.23.1"
10
+ token_pilot_version: "0.23.2"
11
11
  token_pilot_body_hash: a058518619fd6e2def0c9226f6c70438a5e0a80efe680c935414ecd7e1b14a4f
12
12
  ---
13
13
 
@@ -15,7 +15,7 @@ tools:
15
15
  - Grep
16
16
  - Glob
17
17
  - Bash
18
- token_pilot_version: "0.23.1"
18
+ token_pilot_version: "0.23.2"
19
19
  token_pilot_body_hash: d665d57085db38077d0eeab74bda8bdb84c9ad59688495486059af5d3fac67cf
20
20
  ---
21
21
 
@@ -8,7 +8,7 @@ tools:
8
8
  - mcp__token-pilot__session_budget
9
9
  - Bash
10
10
  - Read
11
- token_pilot_version: "0.23.1"
11
+ token_pilot_version: "0.23.2"
12
12
  token_pilot_body_hash: 35b7f333a28c94e7dc89fcc3171703c4b466225f55cd5c701b7592f4f6486440
13
13
  ---
14
14
 
@@ -7,7 +7,7 @@ tools:
7
7
  - mcp__token-pilot__read_range
8
8
  - mcp__token-pilot__find_usages
9
9
  - mcp__token-pilot__read_symbol
10
- token_pilot_version: "0.23.1"
10
+ token_pilot_version: "0.23.2"
11
11
  token_pilot_body_hash: 255912c47661d203c8f9a735237bc419f97e937f788a01811bbe126ee3dd5878
12
12
  ---
13
13
 
@@ -12,7 +12,7 @@ tools:
12
12
  - Write
13
13
  - Edit
14
14
  - Bash
15
- token_pilot_version: "0.23.1"
15
+ token_pilot_version: "0.23.2"
16
16
  token_pilot_body_hash: 533b3d2387e631a24291314b2b8ad8c3e01c19e0b9ec1d3fe08ae0011f0c73f9
17
17
  ---
18
18
 
@@ -97,7 +97,24 @@ MANDATORY — for code files, use these before raw Read:
97
97
  mcp__token-pilot__read_symbol(path, sym) — one function / class
98
98
  mcp__token-pilot__read_for_edit(path, sym)— exact text for editing
99
99
  mcp__token-pilot__outline(path) — symbol list
100
+ Batch variants (prefer over loops): read_symbols, smart_read_many, read_section.
100
101
  Raw Read allowed only with offset/limit or TOKEN_PILOT_BYPASS=1.`;
102
+ const DECISION_GUIDE = `WHEN DELEGATING — if the task fits a specialist, use the Task tool:
103
+ bug / stack trace → tp-debugger
104
+ PR / diff review → tp-pr-reviewer
105
+ impact before change → tp-impact-analyzer
106
+ plan refactor → tp-refactor-planner
107
+ failing tests → tp-test-triage
108
+ write new tests → tp-test-writer
109
+ migrate API / version → tp-migration-scout
110
+ "why is this like this?"→ tp-history-explorer
111
+ security / quality audit→ tp-audit-scanner
112
+ resume after /clear → tp-session-restorer
113
+ dead code cleanup → tp-dead-code-finder
114
+ commit message → tp-commit-writer
115
+ repo onboarding → tp-onboard
116
+ general workhorse → tp-run
117
+ Delegating keeps main-context lean; each specialist has a narrow toolset + budget.`;
101
118
  function estimateTokens(text) {
102
119
  // Fast approximation: chars / 4, adjusted for whitespace
103
120
  if (text.length === 0)
@@ -110,29 +127,51 @@ function estimateTokens(text) {
110
127
  * delegating list with "… and N more" if needed.
111
128
  */
112
129
  export function buildReminderMessage(agents, maxReminderTokens) {
113
- const agentLines = agents.length === 0
114
- ? " none installed run: npx token-pilot install-agents"
115
- : agents.map((a) => ` ${a.name} — ${a.description}`).join("\n");
116
- const delegatingSection = `WHEN DELEGATING — use the right token-pilot-native subagent:\n${agentLines}`;
117
- const full = `${MANDATORY_BLOCK}\n\n${delegatingSection}`;
130
+ // If no agents installed, give the user a clear nudge; skip the
131
+ // delegation guide since there's nothing to delegate to.
132
+ if (agents.length === 0) {
133
+ return `${MANDATORY_BLOCK}\n\nWHEN DELEGATING — none installed; run: npx token-pilot install-agents`;
134
+ }
135
+ // Filter the decision guide to the agents this user actually has
136
+ // installed. Dropping lines for missing agents keeps the reminder
137
+ // honest when the template ships an agent the user hasn't installed.
138
+ const installedNames = new Set(agents.map((a) => a.name));
139
+ const guideKnownNames = new Set();
140
+ const decisionGuideLines = DECISION_GUIDE.split("\n").filter((line) => {
141
+ const m = line.match(/→\s+(tp-[a-z-]+)/);
142
+ if (!m)
143
+ return true; // header / footer
144
+ guideKnownNames.add(m[1]);
145
+ return installedNames.has(m[1]);
146
+ });
147
+ // Fallback: custom / third-party tp-* agents we don't hard-code in the
148
+ // guide still deserve a mention so the main agent can delegate to them.
149
+ const extras = agents.filter((a) => !guideKnownNames.has(a.name));
150
+ if (extras.length > 0) {
151
+ const extraLines = extras.map((a) => ` custom: ${a.name} — ${a.description}`);
152
+ // Insert before the "Delegating keeps..." footer.
153
+ const footer = decisionGuideLines.pop() ?? "";
154
+ decisionGuideLines.push(...extraLines, footer);
155
+ }
156
+ const decisionGuide = decisionGuideLines.join("\n");
157
+ const full = `${MANDATORY_BLOCK}\n\n${decisionGuide}`;
118
158
  if (estimateTokens(full) <= maxReminderTokens) {
119
159
  return full;
120
160
  }
121
- // Trim agent list until we fit. Distinguish "all agents trimmed due to
122
- // budget" (count remained >0 in the original list) from "no agents at
123
- // all" they look the same to `trimmedAgents.length === 0` but mean
124
- // very different things to the caller (one requires install-agents; the
125
- // other just reports "N more hidden").
126
- let trimmedAgents = [...agents];
127
- while (trimmedAgents.length > 0) {
128
- trimmedAgents = trimmedAgents.slice(0, trimmedAgents.length - 1);
129
- const dropped = agents.length - trimmedAgents.length;
130
- const trimmedLines = trimmedAgents.length === 0
131
- ? ` … and ${dropped} more (reminder budget exhausted)`
132
- : trimmedAgents
133
- .map((a) => ` ${a.name} ${a.description}`)
134
- .join("\n") + `\n … and ${dropped} more`;
135
- const candidate = `${MANDATORY_BLOCK}\n\nWHEN DELEGATING — use the right token-pilot-native subagent:\n${trimmedLines}`;
161
+ // Budget overflow: trim decision-guide body lines from the end (keep
162
+ // header, footer, and as many mappings as fit). Preserves the first
163
+ // line so the agent still knows the section exists.
164
+ const header = decisionGuideLines[0];
165
+ const footer = decisionGuideLines[decisionGuideLines.length - 1];
166
+ const body = decisionGuideLines.slice(1, -1);
167
+ let kept = body.length;
168
+ while (kept > 0) {
169
+ kept--;
170
+ const dropped = body.length - kept;
171
+ const trimmedBody = kept === 0
172
+ ? [` … and ${dropped} more (reminder budget exhausted)`]
173
+ : body.slice(0, kept).concat(` … and ${dropped} more`);
174
+ const candidate = `${MANDATORY_BLOCK}\n\n${[header, ...trimmedBody, footer].join("\n")}`;
136
175
  if (estimateTokens(candidate) <= maxReminderTokens) {
137
176
  return candidate;
138
177
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "token-pilot",
3
- "version": "0.23.1",
3
+ "version": "0.23.2",
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",