token-pilot 0.23.2 → 0.23.4

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.2",
3
+ "version": "0.23.4",
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,36 @@ 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.4] - 2026-04-18
9
+
10
+ ### Fixed
11
+
12
+ - **`install-agents --force` now actually forces a refresh when body-hash matches.** Before this fix, `--force` was a no-op for unchanged-installed agents because the body hash (used to detect template drift) ignores the YAML frontmatter. Any frontmatter-only update (description, tools list, etc.) left `storedHash === templateHash`, so `--force` reported `unchanged` and skipped. This silently blocked v0.23.3's PROACTIVELY triggers from reaching existing installations — users had to `rm ~/.claude/agents/tp-*.md` first. Now `--force` rewrites the file regardless of body-hash match, while still refusing to touch user-owned files that carry no `token_pilot_body_hash` stamp.
13
+
14
+ ### Numbers
15
+ - 907 tests green (+1 regression test for `--force` on unchanged files), `tsc --noEmit` clean.
16
+
17
+ ## [0.23.3] - 2026-04-18
18
+
19
+ ### Changed — PROACTIVELY triggers in every agent description + wider MANDATORY block
20
+
21
+ 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.
22
+
23
+ Both fixes:
24
+
25
+ 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.
26
+
27
+ 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.
28
+
29
+ 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×.
30
+
31
+ ### Updated
32
+
33
+ - `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.
34
+
35
+ ### Numbers
36
+ - 906 tests green (+6 rewrites of contract + reminder tests; none removed), `tsc --noEmit` clean.
37
+
8
38
  ## [0.23.2] - 2026-04-18
9
39
 
10
40
  ### Changed — SessionStart reminder now carries a task→agent decision guide
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: tp-audit-scanner
3
- description: Read-only security + quality scan hardcoded secrets, SQL/command injection shapes, unsafe-cast patterns, deprecated APIs, stale TODOs with missing owners. Reports by severity, never edits. Use for audits / pre-release sweeps, not for writing the fix.
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.2"
13
+ token_pilot_version: "0.23.4"
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: Drafts one Conventional-Commit message from current staged changes. Verifies tests/lint pass first; blocks when they don't. Use BEFORE `git commit`, not to explain already-made commits.
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.2"
10
+ token_pilot_version: "0.23.4"
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: Finds truly unused symbols safe to delete. Cross-checks with git history, reflection / dynamic-import patterns, and test-only references before recommending removal. Use for codebase cleanup, NOT mid-feature.
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.2"
12
+ token_pilot_version: "0.23.4"
13
13
  token_pilot_body_hash: 482e33ba566dc75d87753d980267fb2e01763e5924612efd54ec89993b5e12fd
14
14
  ---
15
15
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: tp-debugger
3
- description: Bug diagnosis via call-tree traversal. Given a stack trace, error, or reproduction, finds the root cause path structurally before touching source. Use when debugging, not when writing new features.
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.2"
14
+ token_pilot_version: "0.23.4"
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: Answers "why is this like this?" by tracing git history for a file / symbol / regression. Returns the minimum commit chain that explains the current state, not the full log. Use when the question is about origin or intent, not about current behaviour.
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.2"
12
+ token_pilot_version: "0.23.4"
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: Impact analyst. Given a symbol, file, or change description, produces a blast-radius map of affected call sites. Use when tracing what a change will break.
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.2"
14
+ token_pilot_version: "0.23.4"
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: Pre-migration impact scout. Given a target (API, framework version, deprecated symbol), enumerates every touch-point in the repo as an actionable checklist. Use BEFORE starting a migration, not during.
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.2"
13
+ token_pilot_version: "0.23.4"
14
14
  token_pilot_body_hash: cf32cdee777430ecc6732db32b3f883a685c8a02b6dc93379d71b15555e79b3e
15
15
  ---
16
16
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: tp-onboard
3
- description: Repo onboarding guide. Orients a caller to an unfamiliar codebase structurally layout, entry points, core modules. Use when first exploring a new repo.
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.2"
12
+ token_pilot_version: "0.23.4"
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: PR diff reviewer. Reviews a changeset structurally verdict first, then Critical/Important findings as path:line. Use when reviewing a diff or pending PR.
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.2"
13
+ token_pilot_version: "0.23.4"
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: Refactor planner. Produces a step-by-step plan with exact edit context per step plan only, no edits applied. Use for planning a refactor before coding.
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.2"
10
+ token_pilot_version: "0.23.4"
11
11
  token_pilot_body_hash: a058518619fd6e2def0c9226f6c70438a5e0a80efe680c935414ecd7e1b14a4f
12
12
  ---
13
13
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: tp-run
3
- description: MCP-first workhorse for general coding work reading, editing, searching, exploring. Use PROACTIVELY when no specialised tp-* agent fits the task.
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.2"
18
+ token_pilot_version: "0.23.4"
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: Rehydrates session state after /clear, compaction, or a fresh window. Reads the latest session_snapshot + saved docs + git status, returns a ≤200-token "where we were" briefing. Use at the start of a continuation session, not mid-task.
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.2"
11
+ token_pilot_version: "0.23.4"
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: Test-failure triage. Given failing tests, identifies root cause and suggests the minimal fix — no speculation. Use when investigating why tests fail.
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.2"
10
+ token_pilot_version: "0.23.4"
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: Writes tests for a specific symbol not for whole files, not for untested suites. Mirrors project's existing test style. Use when extending coverage, not when diagnosing a failing test (use tp-test-triage for that).
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.2"
15
+ token_pilot_version: "0.23.4"
16
16
  token_pilot_body_hash: 533b3d2387e631a24291314b2b8ad8c3e01c19e0b9ec1d3fe08ae0011f0c73f9
17
17
  ---
18
18
 
@@ -144,8 +144,22 @@ export async function installAgents(opts) {
144
144
  continue;
145
145
  }
146
146
  if (storedHash === templateHash) {
147
- // unchanged-installed: silent skip (re-write would be a no-op).
148
- result.skipped.push({ name, reason: "unchanged" });
147
+ // unchanged-installed: body matches template. But body hash ignores
148
+ // frontmatter, so a description / tools update leaves the hash
149
+ // equal while the file genuinely needs refreshing. Respect --force
150
+ // by always rewriting in that case; keep silent skip otherwise.
151
+ if (opts.force) {
152
+ try {
153
+ await writeFile(targetPath, templateMd);
154
+ result.installed.push(name);
155
+ }
156
+ catch {
157
+ result.skipped.push({ name, reason: "write failed" });
158
+ }
159
+ }
160
+ else {
161
+ result.skipped.push({ name, reason: "unchanged" });
162
+ }
149
163
  continue;
150
164
  }
151
165
  // template-upgraded: user did not edit (currentBodyHash === storedHash)
@@ -68,7 +68,7 @@ export const DEFAULT_CONFIG = {
68
68
  sessionStart: {
69
69
  enabled: true,
70
70
  showStats: false,
71
- maxReminderTokens: 250,
71
+ maxReminderTokens: 500,
72
72
  },
73
73
  agents: {
74
74
  scope: null,
@@ -92,13 +92,21 @@ 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 — for code files, use these before raw Read:
96
- mcp__token-pilot__smart_read(path) — structural overview
97
- mcp__token-pilot__read_symbol(path, sym) — one function / class
98
- mcp__token-pilot__read_for_edit(path, sym)— exact text for editing
99
- mcp__token-pilot__outline(path) — symbol list
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)
100
105
  Batch variants (prefer over loops): read_symbols, smart_read_many, read_section.
101
- Raw Read allowed only with offset/limit or TOKEN_PILOT_BYPASS=1.`;
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.`;
102
110
  const DECISION_GUIDE = `WHEN DELEGATING — if the task fits a specialist, use the Task tool:
103
111
  bug / stack trace → tp-debugger
104
112
  PR / diff review → tp-pr-reviewer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "token-pilot",
3
- "version": "0.23.2",
3
+ "version": "0.23.4",
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",