token-pilot 0.23.1 → 0.23.3
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 +52 -0
- package/dist/agents/tp-audit-scanner.md +2 -2
- package/dist/agents/tp-commit-writer.md +2 -2
- package/dist/agents/tp-dead-code-finder.md +2 -2
- package/dist/agents/tp-debugger.md +2 -2
- package/dist/agents/tp-history-explorer.md +2 -2
- package/dist/agents/tp-impact-analyzer.md +2 -2
- package/dist/agents/tp-migration-scout.md +2 -2
- package/dist/agents/tp-onboard.md +2 -2
- package/dist/agents/tp-pr-reviewer.md +2 -2
- package/dist/agents/tp-refactor-planner.md +2 -2
- package/dist/agents/tp-run.md +2 -2
- package/dist/agents/tp-session-restorer.md +2 -2
- package/dist/agents/tp-test-triage.md +2 -2
- package/dist/agents/tp-test-writer.md +2 -2
- package/dist/config/defaults.js +1 -1
- package/dist/hooks/session-start.js +73 -26
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "token-pilot",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.3",
|
|
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,58 @@ 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.3] - 2026-04-18
|
|
9
|
+
|
|
10
|
+
### Changed — PROACTIVELY triggers in every agent description + wider MANDATORY block
|
|
11
|
+
|
|
12
|
+
Live-testing on a real machine surfaced a concrete gap: Claude Code's main agent read the reminder, saw tool descriptions, but **systematically skipped tp-\* subagents** — no explicit `PROACTIVELY` trigger meant they sat unused even when the task fit. Also reported: "I see only 4 token-pilot tools in MANDATORY, not 14" — the agent didn't scan tool descriptions to discover the rest unless prompted.
|
|
13
|
+
|
|
14
|
+
Both fixes:
|
|
15
|
+
|
|
16
|
+
1. **Every `tp-*` description now carries `PROACTIVELY use this when …` or `Use this when …` plus concrete user-intent signals** ("when the user reports a bug", "when the user asks to review a diff"). Claude Code's auto-invocation heuristic looks for exactly these phrases. 14 agents rewritten.
|
|
17
|
+
|
|
18
|
+
2. **MANDATORY block expanded from 4 tools → 9 core tools** (smart_read, read_symbol, read_for_edit, outline, find_usages, smart_diff, smart_log, test_summary, project_overview) with `INSTEAD of` hints against raw Read/Grep/git. Still lists batch variants (read_symbols, smart_read_many, read_section) and names the remaining 10 under "Also available:" so the main agent sees the full surface even if it doesn't crawl descriptions.
|
|
19
|
+
|
|
20
|
+
3. **Default `sessionStart.maxReminderTokens` raised 250 → 500** to fit the expanded block without aggressive trimming. Token-wise: ~500 tokens is 0.3% of a 160K context window — the round-trip savings from one prevented raw Read pay it back ~5×.
|
|
21
|
+
|
|
22
|
+
### Updated
|
|
23
|
+
|
|
24
|
+
- `prompt-contract.test.ts` relaxed: descriptions may now be up to 350 chars and every agent is **required** to carry a trigger phrase (`PROACTIVELY …` or `Use this when …`). Old contract required "only tp-run uses PROACTIVELY" and ≤160 chars — removed.
|
|
25
|
+
|
|
26
|
+
### Numbers
|
|
27
|
+
- 906 tests green (+6 rewrites of contract + reminder tests; none removed), `tsc --noEmit` clean.
|
|
28
|
+
|
|
29
|
+
## [0.23.2] - 2026-04-18
|
|
30
|
+
|
|
31
|
+
### Changed — SessionStart reminder now carries a task→agent decision guide
|
|
32
|
+
|
|
33
|
+
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:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
WHEN DELEGATING — if the task fits a specialist, use the Task tool:
|
|
37
|
+
bug / stack trace → tp-debugger
|
|
38
|
+
PR / diff review → tp-pr-reviewer
|
|
39
|
+
impact before change → tp-impact-analyzer
|
|
40
|
+
plan refactor → tp-refactor-planner
|
|
41
|
+
failing tests → tp-test-triage
|
|
42
|
+
write new tests → tp-test-writer
|
|
43
|
+
migrate API / version → tp-migration-scout
|
|
44
|
+
"why is this like this?" → tp-history-explorer
|
|
45
|
+
security / quality audit → tp-audit-scanner
|
|
46
|
+
resume after /clear → tp-session-restorer
|
|
47
|
+
dead code cleanup → tp-dead-code-finder
|
|
48
|
+
commit message → tp-commit-writer
|
|
49
|
+
repo onboarding → tp-onboard
|
|
50
|
+
general workhorse → tp-run
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
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.
|
|
54
|
+
|
|
55
|
+
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.
|
|
56
|
+
|
|
57
|
+
### Numbers
|
|
58
|
+
- 906 tests green (+6 new buildReminderMessage regression tests), `tsc --noEmit` clean.
|
|
59
|
+
|
|
8
60
|
## [0.23.1] - 2026-04-18
|
|
9
61
|
|
|
10
62
|
### Changed — agent toolset coverage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-audit-scanner
|
|
3
|
-
description:
|
|
3
|
+
description: Use this when the user asks for a security / quality audit, pre-release sweep, or "scan this for issues". Finds hardcoded secrets, injection shapes, unsafe casts, stale TODOs — classified Critical / Important / Minor. Read-only, NEVER edits, never quotes secrets in output.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__code_audit
|
|
6
6
|
- mcp__token-pilot__find_usages
|
|
@@ -10,7 +10,7 @@ tools:
|
|
|
10
10
|
- mcp__token-pilot__read_section
|
|
11
11
|
- Grep
|
|
12
12
|
- Read
|
|
13
|
-
token_pilot_version: "0.23.
|
|
13
|
+
token_pilot_version: "0.23.3"
|
|
14
14
|
token_pilot_body_hash: a740dc6c928d11d7c2c5fbaa953c50b0e35f2abc2dd6e5ef5117bf469a2d0207
|
|
15
15
|
---
|
|
16
16
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-commit-writer
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this when the user is about to commit, asks "write a commit message", or says "commit this". Reads staged diff, verifies tests pass, drafts Conventional Commit. Refuses mixed diffs (asks to split), failing tests, or empty stage. Do NOT use to explain already-made commits.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__smart_diff
|
|
6
6
|
- mcp__token-pilot__smart_log
|
|
7
7
|
- mcp__token-pilot__test_summary
|
|
8
8
|
- mcp__token-pilot__outline
|
|
9
9
|
- Bash
|
|
10
|
-
token_pilot_version: "0.23.
|
|
10
|
+
token_pilot_version: "0.23.3"
|
|
11
11
|
token_pilot_body_hash: 559a0b61d20974bf33e35bc4c80dcf1b41d10d4df46cf9d05d3d5620713cd46f
|
|
12
12
|
---
|
|
13
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-dead-code-finder
|
|
3
|
-
description:
|
|
3
|
+
description: Use this when the user asks to find or remove dead / unused code ("clean up this file", "find unused exports", "pre-release cleanup"). Cross-checks find_unused with Grep, git history, and dynamic-lookup patterns before classifying. Output-only — NEVER deletes code itself.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__find_unused
|
|
6
6
|
- mcp__token-pilot__find_usages
|
|
@@ -9,7 +9,7 @@ tools:
|
|
|
9
9
|
- mcp__token-pilot__related_files
|
|
10
10
|
- Grep
|
|
11
11
|
- Read
|
|
12
|
-
token_pilot_version: "0.23.
|
|
12
|
+
token_pilot_version: "0.23.3"
|
|
13
13
|
token_pilot_body_hash: 482e33ba566dc75d87753d980267fb2e01763e5924612efd54ec89993b5e12fd
|
|
14
14
|
---
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-debugger
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this when the user reports a bug, stack trace, error message, failing behaviour, or asks "why does X break / fail / throw". Traces root cause via call-tree without reading whole files first. Do NOT use for writing new features or planning changes.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__read_symbol
|
|
6
6
|
- mcp__token-pilot__find_usages
|
|
@@ -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.
|
|
14
|
+
token_pilot_version: "0.23.3"
|
|
15
15
|
token_pilot_body_hash: 04864ae0bf0689863d7de9f4c0b44b293087b34098ad2771837e491d37dab953
|
|
16
16
|
---
|
|
17
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-history-explorer
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this when the user asks "why is this like this", "when was X added / changed", "who added Y", "what was the reason for this code". Returns the minimum commit chain that explains current state — no theorising beyond what commit messages say.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__smart_log
|
|
6
6
|
- mcp__token-pilot__smart_diff
|
|
@@ -9,7 +9,7 @@ tools:
|
|
|
9
9
|
- mcp__token-pilot__outline
|
|
10
10
|
- Bash
|
|
11
11
|
- Read
|
|
12
|
-
token_pilot_version: "0.23.
|
|
12
|
+
token_pilot_version: "0.23.3"
|
|
13
13
|
token_pilot_body_hash: b2daca007e959eaf26bf9a4d92ba36c3aa277a51de4ca4db674833d36acbe11b
|
|
14
14
|
---
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-impact-analyzer
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this when the user asks "what will break if I change X", "who depends on this", or is about to modify a shared symbol / public API / widely-used function. Produces a blast-radius map of affected call sites. Does NOT propose fixes.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__read_symbol
|
|
6
6
|
- mcp__token-pilot__outline
|
|
@@ -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.
|
|
14
|
+
token_pilot_version: "0.23.3"
|
|
15
15
|
token_pilot_body_hash: 0be2620ce0303f912f6b3334f261d169f064970c0d16602fa1e76db4cb2ea441
|
|
16
16
|
---
|
|
17
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-migration-scout
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this BEFORE the user starts any migration — replacing an API, upgrading a framework version, removing a deprecated symbol, switching libraries. Enumerates touch-points as an effort-classified checklist. Do NOT use during the migration itself (file-by-file edits).
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__find_usages
|
|
6
6
|
- mcp__token-pilot__module_info
|
|
@@ -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.
|
|
13
|
+
token_pilot_version: "0.23.3"
|
|
14
14
|
token_pilot_body_hash: cf32cdee777430ecc6732db32b3f883a685c8a02b6dc93379d71b15555e79b3e
|
|
15
15
|
---
|
|
16
16
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-onboard
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this when the user is exploring an unfamiliar codebase — asks "how is this organised", "what does this project do", "where do I start reading", or starts any conversation in a repo the main agent doesn't know. Orientation map only (layout, entry points, modules); does NOT drill into implementation.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__project_overview
|
|
6
6
|
- mcp__token-pilot__explore_area
|
|
@@ -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.
|
|
12
|
+
token_pilot_version: "0.23.3"
|
|
13
13
|
token_pilot_body_hash: ae0b86eaffaf34bf283b94b5572481fa8c2d6a2a25193f1173b70bef0fbe1919
|
|
14
14
|
---
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-pr-reviewer
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this when the user asks to review a diff, PR, commit range, or changeset ("review these changes", "look at my PR", "is this safe to merge"). Verdict-first output with Critical / Important findings. Do NOT use for writing code or planning.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__smart_diff
|
|
6
6
|
- mcp__token-pilot__outline
|
|
@@ -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.
|
|
13
|
+
token_pilot_version: "0.23.3"
|
|
14
14
|
token_pilot_body_hash: eb9fb7f87d9ab61c5b18248a40b283008b5d73414ddb2e3094ff0826e7e463d0
|
|
15
15
|
---
|
|
16
16
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-refactor-planner
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this when the user asks to "plan", "design", or "scope" a refactor, or says "I want to refactor X but need a plan first". Produces step-by-step plan with exact edit context; never applies changes itself.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__read_for_edit
|
|
6
6
|
- mcp__token-pilot__find_usages
|
|
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.3"
|
|
11
11
|
token_pilot_body_hash: a058518619fd6e2def0c9226f6c70438a5e0a80efe680c935414ecd7e1b14a4f
|
|
12
12
|
---
|
|
13
13
|
|
package/dist/agents/tp-run.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-run
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this general-purpose token-pilot workhorse for ANY coding task (read / edit / search / explore) when no other tp-* specialist matches. Prefer token-pilot MCP tools over raw Read / Grep / git. Invoke when the user asks to touch code and no more specific specialist fits.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__smart_read
|
|
6
6
|
- mcp__token-pilot__read_symbol
|
|
@@ -15,7 +15,7 @@ tools:
|
|
|
15
15
|
- Grep
|
|
16
16
|
- Glob
|
|
17
17
|
- Bash
|
|
18
|
-
token_pilot_version: "0.23.
|
|
18
|
+
token_pilot_version: "0.23.3"
|
|
19
19
|
token_pilot_body_hash: d665d57085db38077d0eeab74bda8bdb84c9ad59688495486059af5d3fac67cf
|
|
20
20
|
---
|
|
21
21
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-session-restorer
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this as the FIRST step after /clear, compaction, or a fresh window when a recent session_snapshot exists on disk. Reads snapshot + git status + saved docs, returns a ≤200-token briefing. Do NOT use mid-task.
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__smart_read
|
|
6
6
|
- mcp__token-pilot__read_range
|
|
@@ -8,7 +8,7 @@ tools:
|
|
|
8
8
|
- mcp__token-pilot__session_budget
|
|
9
9
|
- Bash
|
|
10
10
|
- Read
|
|
11
|
-
token_pilot_version: "0.23.
|
|
11
|
+
token_pilot_version: "0.23.3"
|
|
12
12
|
token_pilot_body_hash: 35b7f333a28c94e7dc89fcc3171703c4b466225f55cd5c701b7592f4f6486440
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-test-triage
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this when the user reports failing tests, asks to investigate a red CI, or says "these tests are broken / flaky". Identifies root cause and suggests minimal fix — no speculation. Do NOT use to write new tests (that's tp-test-writer).
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__test_summary
|
|
6
6
|
- mcp__token-pilot__smart_read
|
|
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.3"
|
|
11
11
|
token_pilot_body_hash: 255912c47661d203c8f9a735237bc419f97e937f788a01811bbe126ee3dd5878
|
|
12
12
|
---
|
|
13
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: tp-test-writer
|
|
3
|
-
description:
|
|
3
|
+
description: PROACTIVELY use this when the user asks to write, add, or cover a SPECIFIC function / method / class with tests ("add test for X", "cover Y"). Mirrors project's existing test style; runs the tests before declaring done. Do NOT use for diagnosing failures (that's tp-test-triage).
|
|
4
4
|
tools:
|
|
5
5
|
- mcp__token-pilot__read_symbol
|
|
6
6
|
- mcp__token-pilot__read_for_edit
|
|
@@ -12,7 +12,7 @@ tools:
|
|
|
12
12
|
- Write
|
|
13
13
|
- Edit
|
|
14
14
|
- Bash
|
|
15
|
-
token_pilot_version: "0.23.
|
|
15
|
+
token_pilot_version: "0.23.3"
|
|
16
16
|
token_pilot_body_hash: 533b3d2387e631a24291314b2b8ad8c3e01c19e0b9ec1d3fe08ae0011f0c73f9
|
|
17
17
|
---
|
|
18
18
|
|
package/dist/config/defaults.js
CHANGED
|
@@ -92,12 +92,37 @@ export async function scanAgents(projectRoot, homeDir) {
|
|
|
92
92
|
// ─── Message builder (subtask 2.3) ───────────────────────────────────────────
|
|
93
93
|
const MANDATORY_BLOCK = `[token-pilot active]
|
|
94
94
|
|
|
95
|
-
MANDATORY —
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
MANDATORY — use these BEFORE raw Read / Grep / git:
|
|
96
|
+
smart_read(path) — structural overview of a code file
|
|
97
|
+
read_symbol(path, sym) — one function / class body
|
|
98
|
+
read_for_edit(path, sym) — exact text for Edit's old_string
|
|
99
|
+
outline(path) — symbol list
|
|
100
|
+
find_usages(symbol) — who calls / uses a symbol (INSTEAD of Grep)
|
|
101
|
+
smart_diff — git diff structurally (INSTEAD of raw git diff)
|
|
102
|
+
smart_log(path?) — git log with symbol context (INSTEAD of raw git log)
|
|
103
|
+
test_summary(command) — test runs without dumping full output
|
|
104
|
+
project_overview — unfamiliar repo top-level map (first step)
|
|
105
|
+
Batch variants (prefer over loops): read_symbols, smart_read_many, read_section.
|
|
106
|
+
Also available: read_range, read_diff, module_info, related_files, explore_area,
|
|
107
|
+
code_audit, find_unused, session_snapshot, session_budget, session_analytics.
|
|
108
|
+
Raw Read/Grep allowed only with offset/limit / narrow regex / non-code files,
|
|
109
|
+
or TOKEN_PILOT_BYPASS=1.`;
|
|
110
|
+
const DECISION_GUIDE = `WHEN DELEGATING — if the task fits a specialist, use the Task tool:
|
|
111
|
+
bug / stack trace → tp-debugger
|
|
112
|
+
PR / diff review → tp-pr-reviewer
|
|
113
|
+
impact before change → tp-impact-analyzer
|
|
114
|
+
plan refactor → tp-refactor-planner
|
|
115
|
+
failing tests → tp-test-triage
|
|
116
|
+
write new tests → tp-test-writer
|
|
117
|
+
migrate API / version → tp-migration-scout
|
|
118
|
+
"why is this like this?"→ tp-history-explorer
|
|
119
|
+
security / quality audit→ tp-audit-scanner
|
|
120
|
+
resume after /clear → tp-session-restorer
|
|
121
|
+
dead code cleanup → tp-dead-code-finder
|
|
122
|
+
commit message → tp-commit-writer
|
|
123
|
+
repo onboarding → tp-onboard
|
|
124
|
+
general workhorse → tp-run
|
|
125
|
+
Delegating keeps main-context lean; each specialist has a narrow toolset + budget.`;
|
|
101
126
|
function estimateTokens(text) {
|
|
102
127
|
// Fast approximation: chars / 4, adjusted for whitespace
|
|
103
128
|
if (text.length === 0)
|
|
@@ -110,29 +135,51 @@ function estimateTokens(text) {
|
|
|
110
135
|
* delegating list with "… and N more" if needed.
|
|
111
136
|
*/
|
|
112
137
|
export function buildReminderMessage(agents, maxReminderTokens) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
138
|
+
// If no agents installed, give the user a clear nudge; skip the
|
|
139
|
+
// delegation guide since there's nothing to delegate to.
|
|
140
|
+
if (agents.length === 0) {
|
|
141
|
+
return `${MANDATORY_BLOCK}\n\nWHEN DELEGATING — none installed; run: npx token-pilot install-agents`;
|
|
142
|
+
}
|
|
143
|
+
// Filter the decision guide to the agents this user actually has
|
|
144
|
+
// installed. Dropping lines for missing agents keeps the reminder
|
|
145
|
+
// honest when the template ships an agent the user hasn't installed.
|
|
146
|
+
const installedNames = new Set(agents.map((a) => a.name));
|
|
147
|
+
const guideKnownNames = new Set();
|
|
148
|
+
const decisionGuideLines = DECISION_GUIDE.split("\n").filter((line) => {
|
|
149
|
+
const m = line.match(/→\s+(tp-[a-z-]+)/);
|
|
150
|
+
if (!m)
|
|
151
|
+
return true; // header / footer
|
|
152
|
+
guideKnownNames.add(m[1]);
|
|
153
|
+
return installedNames.has(m[1]);
|
|
154
|
+
});
|
|
155
|
+
// Fallback: custom / third-party tp-* agents we don't hard-code in the
|
|
156
|
+
// guide still deserve a mention so the main agent can delegate to them.
|
|
157
|
+
const extras = agents.filter((a) => !guideKnownNames.has(a.name));
|
|
158
|
+
if (extras.length > 0) {
|
|
159
|
+
const extraLines = extras.map((a) => ` custom: ${a.name} — ${a.description}`);
|
|
160
|
+
// Insert before the "Delegating keeps..." footer.
|
|
161
|
+
const footer = decisionGuideLines.pop() ?? "";
|
|
162
|
+
decisionGuideLines.push(...extraLines, footer);
|
|
163
|
+
}
|
|
164
|
+
const decisionGuide = decisionGuideLines.join("\n");
|
|
165
|
+
const full = `${MANDATORY_BLOCK}\n\n${decisionGuide}`;
|
|
118
166
|
if (estimateTokens(full) <= maxReminderTokens) {
|
|
119
167
|
return full;
|
|
120
168
|
}
|
|
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}`;
|
|
169
|
+
// Budget overflow: trim decision-guide body lines from the end (keep
|
|
170
|
+
// header, footer, and as many mappings as fit). Preserves the first
|
|
171
|
+
// line so the agent still knows the section exists.
|
|
172
|
+
const header = decisionGuideLines[0];
|
|
173
|
+
const footer = decisionGuideLines[decisionGuideLines.length - 1];
|
|
174
|
+
const body = decisionGuideLines.slice(1, -1);
|
|
175
|
+
let kept = body.length;
|
|
176
|
+
while (kept > 0) {
|
|
177
|
+
kept--;
|
|
178
|
+
const dropped = body.length - kept;
|
|
179
|
+
const trimmedBody = kept === 0
|
|
180
|
+
? [` … and ${dropped} more (reminder budget exhausted)`]
|
|
181
|
+
: body.slice(0, kept).concat(` … and ${dropped} more`);
|
|
182
|
+
const candidate = `${MANDATORY_BLOCK}\n\n${[header, ...trimmedBody, footer].join("\n")}`;
|
|
136
183
|
if (estimateTokens(candidate) <= maxReminderTokens) {
|
|
137
184
|
return candidate;
|
|
138
185
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "token-pilot",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.3",
|
|
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",
|