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.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +51 -0
- package/dist/agents/tp-audit-scanner.md +4 -3
- package/dist/agents/tp-commit-writer.md +1 -1
- package/dist/agents/tp-dead-code-finder.md +1 -1
- package/dist/agents/tp-debugger.md +1 -1
- package/dist/agents/tp-history-explorer.md +1 -1
- package/dist/agents/tp-impact-analyzer.md +5 -3
- package/dist/agents/tp-migration-scout.md +4 -3
- package/dist/agents/tp-onboard.md +6 -4
- package/dist/agents/tp-pr-reviewer.md +5 -3
- package/dist/agents/tp-refactor-planner.md +1 -1
- package/dist/agents/tp-run.md +1 -1
- package/dist/agents/tp-session-restorer.md +11 -7
- package/dist/agents/tp-test-triage.md +1 -1
- package/dist/agents/tp-test-writer.md +1 -1
- package/dist/hooks/session-start.js +59 -20
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "token-pilot",
|
|
3
|
-
"version": "0.23.
|
|
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.
|
|
13
|
-
token_pilot_body_hash:
|
|
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`
|
|
@@ -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.
|
|
13
|
-
token_pilot_body_hash:
|
|
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.
|
|
13
|
-
token_pilot_body_hash:
|
|
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
|
|
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
|
-
|
|
11
|
-
|
|
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.
|
|
12
|
-
token_pilot_body_hash:
|
|
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
|
|
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.
|
|
10
|
+
token_pilot_version: "0.23.2"
|
|
11
11
|
token_pilot_body_hash: a058518619fd6e2def0c9226f6c70438a5e0a80efe680c935414ecd7e1b14a4f
|
|
12
12
|
---
|
|
13
13
|
|
package/dist/agents/tp-run.md
CHANGED
|
@@ -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.
|
|
10
|
-
token_pilot_body_hash:
|
|
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
|
|
28
|
-
2. Check
|
|
29
|
-
3.
|
|
30
|
-
4.
|
|
31
|
-
5.
|
|
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.
|
|
10
|
+
token_pilot_version: "0.23.2"
|
|
11
11
|
token_pilot_body_hash: 255912c47661d203c8f9a735237bc419f97e937f788a01811bbe126ee3dd5878
|
|
12
12
|
---
|
|
13
13
|
|
|
@@ -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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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.
|
|
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",
|