token-pilot 0.23.0 → 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.0",
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,57 @@ 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
+
39
+ ## [0.23.1] - 2026-04-18
40
+
41
+ ### Changed — agent toolset coverage
42
+
43
+ Audit of all 14 agents vs 22 MCP tools surfaced 6 unused tools — 3 of those were genuine efficiency leaks (agents used scalar calls where batch was available). Fixed:
44
+
45
+ - **`read_symbols`** (batch read of N symbols in one file) — now in `tp-pr-reviewer` + `tp-impact-analyzer`. Previously both ran `read_symbol` in a loop for changed diffs.
46
+ - **`read_section`** (headed-section read for MD/YAML/JSON) — now in `tp-onboard` + `tp-audit-scanner` + `tp-session-restorer`. Previously `smart_read` pulled whole README / policy files when only one section was needed.
47
+ - **`smart_read_many`** (batch read of N files) — now in `tp-pr-reviewer` + `tp-migration-scout` + `tp-impact-analyzer` + `tp-onboard`. Previously loops of `smart_read` across the touched file set.
48
+ - **`session_budget`** — now in `tp-session-restorer`, included in the restored briefing so a resumed session knows its burn fraction + time-to-compact projection immediately.
49
+
50
+ Each agent's numbered steps were updated with an explicit instruction to prefer the batch tool over a loop. Preambles unchanged.
51
+
52
+ **Remaining "unused by tp-*" tools (by design):**
53
+ - `session_snapshot` — called by the main Claude Code agent at turn boundaries, not by subagents.
54
+ - `session_analytics` — user-facing summary tool invoked via `/ask token-pilot:session_analytics`, not subagent surface.
55
+
56
+ ### Numbers
57
+ - 904 tests green (+0 new — existing parity tests catch frontmatter changes automatically), `tsc --noEmit` clean.
58
+
8
59
  ## [0.23.0] - 2026-04-18
9
60
 
10
61
  ### Added — three more specialist agents (TP-02l follow-up)
@@ -7,10 +7,11 @@ tools:
7
7
  - mcp__token-pilot__smart_read
8
8
  - mcp__token-pilot__read_for_edit
9
9
  - mcp__token-pilot__outline
10
+ - mcp__token-pilot__read_section
10
11
  - Grep
11
12
  - Read
12
- token_pilot_version: "0.23.0"
13
- token_pilot_body_hash: 1850e394b726f6975177a1f4cbb9153fa49cb263355c068f1924a2f625bea4b4
13
+ token_pilot_version: "0.23.2"
14
+ token_pilot_body_hash: a740dc6c928d11d7c2c5fbaa953c50b0e35f2abc2dd6e5ef5117bf469a2d0207
14
15
  ---
15
16
 
16
17
  You are a token-pilot agent (`tp-<name>`). Your defining contract:
@@ -27,7 +28,7 @@ Response budget: ~800 tokens.
27
28
 
28
29
  When asked to audit a file / module / whole repo:
29
30
 
30
- 1. Start with `code_audit` — cheap first pass for TODO/FIXME/XXX with author + age metadata. Flag items older than 90 days or missing an owner.
31
+ 1. Start with `code_audit` — cheap first pass for TODO/FIXME/XXX with author + age metadata. Flag items older than 90 days or missing an owner. For config / policy files (`.env.example`, YAML, JSON), `read_section` by key — NOT whole-file `smart_read`.
31
32
  2. For each high-risk concern, Grep the precise pattern across scope:
32
33
  - Secrets: `(?i)(api[_-]?key|secret|password|token)\s*[:=]\s*["'][^"']{8,}` + `AKIA[0-9A-Z]{16}` + `-----BEGIN.*PRIVATE KEY-----`
33
34
  - Injection shapes: raw string concat into `exec`/`query`/`eval`/`Function(`, shell metachars in `spawn`/`system`
@@ -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.0"
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.0"
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.0"
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.0"
12
+ token_pilot_version: "0.23.2"
13
13
  token_pilot_body_hash: b2daca007e959eaf26bf9a4d92ba36c3aa277a51de4ca4db674833d36acbe11b
14
14
  ---
15
15
 
@@ -8,9 +8,11 @@ tools:
8
8
  - mcp__token-pilot__module_info
9
9
  - mcp__token-pilot__related_files
10
10
  - mcp__token-pilot__smart_read
11
+ - mcp__token-pilot__smart_read_many
12
+ - mcp__token-pilot__read_symbols
11
13
  - Read
12
- token_pilot_version: "0.23.0"
13
- token_pilot_body_hash: 3c09b7db1ae7224f5d72e88abfbfdbf1dd690c0fded261f4b6a805f8855ff877
14
+ token_pilot_version: "0.23.2"
15
+ token_pilot_body_hash: 0be2620ce0303f912f6b3334f261d169f064970c0d16602fa1e76db4cb2ea441
14
16
  ---
15
17
 
16
18
  You are a token-pilot agent (`tp-<name>`). Your defining contract:
@@ -29,7 +31,7 @@ When given a symbol, file, or change description:
29
31
 
30
32
  1. Locate the change surface via `read_symbol` or `outline` — never raw Read the whole file.
31
33
  2. Enumerate downstream dependents via `find_usages` (direct callers + one hop of transitive).
32
- 3. For each dependent, inspect only the relevant call site via `read_symbol` or bounded `Read(path, offset, limit)` to judge compatibility.
34
+ 3. For each dependent, inspect only the relevant call site via `read_symbol` or bounded `Read(path, offset, limit)` to judge compatibility. For multiple dependents in one file, `read_symbols` (batch) — NOT `read_symbol` in a loop. For structural view across many files at once, `smart_read_many`.
33
35
  4. Report the blast-radius as: one-line verdict → affected sites as `path:line` with compatibility judgment per site → any blind spots you could not resolve.
34
36
 
35
37
  Do NOT propose fixes. Do NOT paste source. Do NOT cross module boundaries beyond the second hop unless asked. Your only deliverable is the honest impact map.
@@ -7,10 +7,11 @@ tools:
7
7
  - mcp__token-pilot__related_files
8
8
  - mcp__token-pilot__outline
9
9
  - mcp__token-pilot__smart_read
10
+ - mcp__token-pilot__smart_read_many
10
11
  - Grep
11
12
  - Glob
12
- token_pilot_version: "0.23.0"
13
- token_pilot_body_hash: e687ecf7e2251c63c7a1da48316e7dc0e0acf84cc234afede2a98cef30e7e3d6
13
+ token_pilot_version: "0.23.2"
14
+ token_pilot_body_hash: cf32cdee777430ecc6732db32b3f883a685c8a02b6dc93379d71b15555e79b3e
14
15
  ---
15
16
 
16
17
  You are a token-pilot agent (`tp-<name>`). Your defining contract:
@@ -28,7 +29,7 @@ Response budget: ~800 tokens.
28
29
  When given a migration target (a symbol, API endpoint, pattern, or dependency to replace):
29
30
 
30
31
  1. Enumerate every reference via `find_usages` on the target — and on each direct alias if the symbol is re-exported.
31
- 2. For each file with ≥1 hit, `module_info` to note entrypoints/importers — migrations that break exported surface cost more.
32
+ 2. For files with ≥1 hit, batch through `smart_read_many` (up to 20 at a time) for structural view in one round-trip — NOT `smart_read` in a loop. Then `module_info` per file to note entrypoints/importers — migrations that break exported surface cost more.
32
33
  3. Group findings by effort class: **trivial** (string replace), **local** (one-symbol refactor), **cross-file** (signature change), **needs design** (semantic mismatch).
33
34
  4. Flag hidden consumers with `related_files` on high-traffic targets — tests, fixtures, docs often get missed.
34
35
  5. Deliver: file-by-file checklist as `path:line — effort — reason` sorted by effort class, then a rollout suggestion (safe order).
@@ -7,8 +7,10 @@ tools:
7
7
  - mcp__token-pilot__related_files
8
8
  - mcp__token-pilot__outline
9
9
  - mcp__token-pilot__smart_read
10
- token_pilot_version: "0.23.0"
11
- token_pilot_body_hash: 2a4747a72609cbbca9d2060e7cd892a2533eee1e3b909f7e6742c080621ded50
10
+ - mcp__token-pilot__smart_read_many
11
+ - mcp__token-pilot__read_section
12
+ token_pilot_version: "0.23.2"
13
+ token_pilot_body_hash: ae0b86eaffaf34bf283b94b5572481fa8c2d6a2a25193f1173b70bef0fbe1919
12
14
  ---
13
15
 
14
16
  You are a token-pilot agent (`tp-<name>`). Your defining contract:
@@ -25,8 +27,8 @@ Response budget: ~600 tokens.
25
27
 
26
28
  When asked to orient a caller to an unfamiliar codebase:
27
29
 
28
- 1. Start with `project_overview` to establish the top-level layout, language mix, and entry points. Do not Read individual files first.
29
- 2. For each named area of interest (or the top 2–3 by size if none named), use `explore_area` to enumerate the modules inside, then `outline` on the one or two most load-bearing files.
30
+ 1. Start with `project_overview` to establish the top-level layout, language mix, and entry points. Do not Read individual files first. For `README.md` / `CONTRIBUTING.md` / `ARCHITECTURE.md`, use `read_section` with the relevant heading — NOT `smart_read` on the whole doc.
31
+ 2. For each named area of interest (or the top 2–3 by size if none named), use `explore_area` to enumerate the modules inside, then `outline` on the one or two most load-bearing files. For multiple load-bearing files, `smart_read_many` as a batch (up to 20) instead of `smart_read` in a loop.
30
32
  3. For cross-module understanding, use `related_files` on an entry point to map its direct dependents.
31
33
  4. Report: one-line verdict on "how the repo is organised" → a short bulleted tour of the top 3–5 areas with `path:line` anchors to entry points → where a newcomer should start reading next.
32
34
 
@@ -6,10 +6,12 @@ tools:
6
6
  - mcp__token-pilot__outline
7
7
  - mcp__token-pilot__find_usages
8
8
  - mcp__token-pilot__read_symbol
9
+ - mcp__token-pilot__read_symbols
10
+ - mcp__token-pilot__smart_read_many
9
11
  - mcp__token-pilot__read_for_edit
10
12
  - Read
11
- token_pilot_version: "0.23.0"
12
- token_pilot_body_hash: 85f8212852dba3f6b34872f1694633ff6522543b2e01318f8dab36dda59e8ac6
13
+ token_pilot_version: "0.23.2"
14
+ token_pilot_body_hash: eb9fb7f87d9ab61c5b18248a40b283008b5d73414ddb2e3094ff0826e7e463d0
13
15
  ---
14
16
 
15
17
  You are a token-pilot agent (`tp-<name>`). Your defining contract:
@@ -27,7 +29,7 @@ Response budget: ~600 tokens.
27
29
  When reviewing a changeset (diff, commit range, or PR):
28
30
 
29
31
  1. Load the structural diff via `smart_diff` — never raw Read the full touched files first.
30
- 2. For each changed symbol of substance, `outline` its containing file and, if needed, `read_symbol` to inspect only the changed block.
32
+ 2. For each changed symbol of substance, `outline` its containing file. For multiple symbols in the same file, `read_symbols` (one call) NOT a loop of `read_symbol`. For multiple touched files at once, `smart_read_many` before drilling in.
31
33
  3. For changes to exported / public surface, run `find_usages` to verify no cross-file breakage.
32
34
  4. Report: one-line verdict (`approve` / `request changes` / `block`) → **Critical:** findings that must be fixed → **Important:** findings the author should address → silence on stylistic nits that pass the project's linter.
33
35
 
@@ -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.0"
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.0"
18
+ token_pilot_version: "0.23.2"
19
19
  token_pilot_body_hash: d665d57085db38077d0eeab74bda8bdb84c9ad59688495486059af5d3fac67cf
20
20
  ---
21
21
 
@@ -4,10 +4,12 @@ description: Rehydrates session state after /clear, compaction, or a fresh windo
4
4
  tools:
5
5
  - mcp__token-pilot__smart_read
6
6
  - mcp__token-pilot__read_range
7
+ - mcp__token-pilot__read_section
8
+ - mcp__token-pilot__session_budget
7
9
  - Bash
8
10
  - Read
9
- token_pilot_version: "0.23.0"
10
- token_pilot_body_hash: 88ccd78695eacf1216021d450be00873f2b7546d1603a3b03d55720ca1c7e83a
11
+ token_pilot_version: "0.23.2"
12
+ token_pilot_body_hash: 35b7f333a28c94e7dc89fcc3171703c4b466225f55cd5c701b7592f4f6486440
11
13
  ---
12
14
 
13
15
  You are a token-pilot agent (`tp-<name>`). Your defining contract:
@@ -24,13 +26,15 @@ Response budget: ~400 tokens.
24
26
 
25
27
  When invoked at the start of a continuation (post-/clear, post-compaction, fresh window on a mid-flight task):
26
28
 
27
- 1. Read `.token-pilot/snapshots/latest.md` via `smart_read`. If missing or older than 6 hours, stop and report "no fresh snapshot" — don't fabricate.
28
- 2. Check git context: `git status --short` + `git log -1 --oneline` + current branch. One-line view.
29
- 3. List saved research: `ls .token-pilot/docs/*.md` — count + newest 3 names only, do NOT read their bodies.
30
- 4. Parse the snapshot's `**Goal:**` / `**Decisions:**` / `**Next:**` sections. Cap Decisions at top 3; keep Next verbatim.
31
- 5. Deliver a compact briefing in this shape exactly:
29
+ 1. Read `.token-pilot/snapshots/latest.md` via `read_section` (section `Session State`) — NOT `smart_read` on the whole file. If missing or older than 6 hours, stop and report "no fresh snapshot" — don't fabricate.
30
+ 2. Check session budget: `session_budget` with the current Claude Code `session_id` if available. One-line view of burn fraction + time-to-compact projection — helps the main agent decide how aggressive to be from here.
31
+ 3. Check git context: `git status --short` + `git log -1 --oneline` + current branch. One-line view.
32
+ 4. List saved research: `ls .token-pilot/docs/*.md` count + newest 3 names only, do NOT read their bodies.
33
+ 5. Parse the snapshot's `**Goal:**` / `**Decisions:**` / `**Next:**` sections. Cap Decisions at top 3; keep Next verbatim.
34
+ 6. Deliver a compact briefing in this shape exactly:
32
35
  ```
33
36
  Resuming: <goal>
37
+ Budget: <burnFraction*100>% burned, ~<eventsUntilExhaustion> events left (or "unknown" if no session_id)
34
38
  Branch: <branch> (<dirty|clean>) · last commit: <sha> <msg>
35
39
  Decisions so far: <top 3 bullets>
36
40
  Next step: <verbatim from snapshot>
@@ -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.0"
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.0"
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.0",
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",