token-pilot 0.28.3 → 0.30.0

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.
Files changed (52) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +75 -0
  4. package/README.md +39 -390
  5. package/agents/tp-api-surface-tracker.md +4 -2
  6. package/agents/tp-audit-scanner.md +4 -2
  7. package/agents/tp-commit-writer.md +4 -2
  8. package/agents/tp-context-engineer.md +4 -2
  9. package/agents/tp-dead-code-finder.md +4 -2
  10. package/agents/tp-debugger.md +4 -2
  11. package/agents/tp-dep-health.md +4 -2
  12. package/agents/tp-doc-writer.md +4 -2
  13. package/agents/tp-history-explorer.md +4 -2
  14. package/agents/tp-impact-analyzer.md +4 -2
  15. package/agents/tp-incident-timeline.md +4 -2
  16. package/agents/tp-incremental-builder.md +4 -2
  17. package/agents/tp-migration-scout.md +4 -2
  18. package/agents/tp-onboard.md +4 -2
  19. package/agents/tp-performance-profiler.md +4 -2
  20. package/agents/tp-pr-reviewer.md +4 -2
  21. package/agents/tp-refactor-planner.md +4 -2
  22. package/agents/tp-review-impact.md +4 -2
  23. package/agents/tp-run.md +4 -2
  24. package/agents/tp-session-restorer.md +4 -2
  25. package/agents/tp-ship-coordinator.md +4 -2
  26. package/agents/tp-spec-writer.md +4 -2
  27. package/agents/tp-test-coverage-gapper.md +4 -2
  28. package/agents/tp-test-triage.md +4 -2
  29. package/agents/tp-test-writer.md +4 -2
  30. package/dist/cli/tool-audit.d.ts +5 -0
  31. package/dist/cli/tool-audit.js +9 -1
  32. package/dist/core/policy-engine.d.ts +1 -5
  33. package/dist/core/policy-engine.js +9 -24
  34. package/dist/hooks/pre-bash.d.ts +13 -1
  35. package/dist/hooks/pre-bash.js +56 -1
  36. package/dist/hooks/pre-grep.d.ts +2 -1
  37. package/dist/hooks/pre-grep.js +3 -1
  38. package/dist/index.js +4 -2
  39. package/dist/server/enforcement-mode.d.ts +47 -0
  40. package/dist/server/enforcement-mode.js +59 -0
  41. package/dist/server/tool-definitions.d.ts +20 -0
  42. package/dist/server/tool-definitions.js +113 -10
  43. package/dist/server/tool-profiles.d.ts +19 -1
  44. package/dist/server/tool-profiles.js +38 -4
  45. package/dist/server.d.ts +2 -0
  46. package/dist/server.js +68 -16
  47. package/docs/agents.md +82 -0
  48. package/docs/configuration.md +117 -0
  49. package/docs/hooks.md +99 -0
  50. package/docs/installation.md +143 -0
  51. package/docs/tools.md +61 -0
  52. package/package.json +2 -2
@@ -0,0 +1,143 @@
1
+ # Installation Guide
2
+
3
+ ## Quickest path
4
+
5
+ ```bash
6
+ npx -y token-pilot init
7
+ ```
8
+
9
+ Writes `.mcp.json` (or merges into an existing one), adds `token-pilot` + [`context-mode`](https://github.com/mksglu/claude-context-mode), then prompts to install `tp-*` subagents. Restart your AI assistant to activate.
10
+
11
+ ---
12
+
13
+ ## Claude Code
14
+
15
+ Three paths — pick one, they're mutually exclusive.
16
+
17
+ ### A. Plugin (one-step: hooks + MCP registered together)
18
+
19
+ ```bash
20
+ claude plugin marketplace add https://github.com/Digital-Threads/token-pilot
21
+ claude plugin install token-pilot@token-pilot
22
+ ```
23
+
24
+ Claude Code clones the repo into `~/.claude/plugins/cache/token-pilot/`, sets `CLAUDE_PLUGIN_ROOT`, and registers the MCP server + all hooks declared in `.claude-plugin/hooks/hooks.json`. No `install-hook` call needed. Run `install-agents` separately for the `tp-*` subagents.
25
+
26
+ ### B. MCP config (npm-based, no plugin system)
27
+
28
+ ```bash
29
+ claude mcp add token-pilot -- npx -y token-pilot
30
+ # or for a specific scope:
31
+ claude mcp add --scope user token-pilot -- npx -y token-pilot
32
+ claude mcp add --scope project token-pilot -- npx -y token-pilot
33
+ ```
34
+
35
+ Or edit `.mcp.json` (project-level) / `~/.mcp.json` (user-level) directly:
36
+
37
+ ```json
38
+ {
39
+ "mcpServers": {
40
+ "token-pilot": { "command": "npx", "args": ["-y", "token-pilot"] },
41
+ "context-mode": { "command": "npx", "args": ["-y", "claude-context-mode"] }
42
+ }
43
+ }
44
+ ```
45
+
46
+ Then:
47
+ ```bash
48
+ npx token-pilot install-hook # register PreToolUse hooks
49
+ npx token-pilot install-agents --scope=user # install tp-* subagents
50
+ ```
51
+
52
+ ### C. One-liner
53
+
54
+ ```bash
55
+ npx -y token-pilot init
56
+ ```
57
+
58
+ Writes path B config for you, then prompts about subagents.
59
+
60
+ ---
61
+
62
+ ## Cursor
63
+
64
+ Cursor reads `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
65
+
66
+ ```json
67
+ {
68
+ "mcpServers": {
69
+ "token-pilot": { "command": "npx", "args": ["-y", "token-pilot"] }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Codex CLI
77
+
78
+ Codex reads `~/.codex/config.toml`:
79
+
80
+ ```toml
81
+ [mcp_servers.token-pilot]
82
+ command = "npx"
83
+ args = ["-y", "token-pilot"]
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Cline (VS Code)
89
+
90
+ Cline reads `cline_mcp_settings.json` (accessible via Cline panel → MCP Servers → Edit):
91
+
92
+ ```json
93
+ {
94
+ "mcpServers": {
95
+ "token-pilot": { "command": "npx", "args": ["-y", "token-pilot"] }
96
+ }
97
+ }
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Gemini CLI
103
+
104
+ Add to `~/.gemini/settings.json` or follow Gemini CLI MCP documentation for your version.
105
+
106
+ ---
107
+
108
+ ## Any MCP-compatible client
109
+
110
+ The server is a plain stdio process:
111
+
112
+ ```
113
+ command: npx
114
+ args: -y token-pilot
115
+ ```
116
+
117
+ No env vars required. Common optional overrides:
118
+
119
+ | Env var | Default | Purpose |
120
+ |---------|---------|---------|
121
+ | `TOKEN_PILOT_MODE` | `deny` | `advisory` / `deny` / `strict` — enforcement level |
122
+ | `TOKEN_PILOT_PROFILE` | `full` | `nav` / `edit` / `full` — trims `tools/list` payload |
123
+ | `TOKEN_PILOT_DENY_THRESHOLD` | `300` | Line count above which the Read hook intervenes |
124
+ | `TOKEN_PILOT_ADAPTIVE_THRESHOLD` | `false` | Enable adaptive curve as session burns |
125
+ | `TOKEN_PILOT_BYPASS` | unset | Set to `1` to disable the Read hook for one session |
126
+ | `TOKEN_PILOT_SKIP_POSTINSTALL` | unset | Skip `ast-index` safety-net install at `npm install` time |
127
+
128
+ ---
129
+
130
+ ## From source (contributors / vendored installs)
131
+
132
+ ```bash
133
+ git clone https://github.com/Digital-Threads/token-pilot.git
134
+ cd token-pilot && npm install && npm run build
135
+ # Point your client's config at dist/index.js:
136
+ # "command": "node", "args": ["/abs/path/to/token-pilot/dist/index.js"]
137
+ ```
138
+
139
+ ---
140
+
141
+ ## Non-Claude clients
142
+
143
+ `install-agents` detects non-Claude clients via env vars + filesystem markers (`CURSOR_TRACE_ID`, `~/.codex/`, `~/.gemini/`, etc.) and **skips installing subagents** unless you pass `--scope=user|project` explicitly. Cursor, Codex, Gemini, and Cline users get all 22 MCP tools + PreToolUse hooks without the `tp-*` agents.
package/docs/tools.md ADDED
@@ -0,0 +1,61 @@
1
+ # MCP Tools Reference
2
+
3
+ Token Pilot exposes 22 MCP tools. All handlers remain active regardless of [tool profile](configuration.md#tool-profiles) — the profile only trims what appears in `tools/list` at session start.
4
+
5
+ ## Reading
6
+
7
+ | Tool | Instead of | Purpose |
8
+ |------|-----------|---------|
9
+ | `smart_read` | `Read` | AST outline; 90% fewer tokens on large files |
10
+ | `read_symbol` | `Read` + scroll | One class/function by name (`Class.method` supported) |
11
+ | `read_symbols` | N × `read_symbol` | Batch up to 10 symbols from one file |
12
+ | `read_for_edit` | `Read` before `Edit` | Minimal raw code around a symbol — copy directly as `old_string` |
13
+ | `read_range` | `Read` offset | Specific line range |
14
+ | `read_section` | `Read` | Section by heading (Markdown) or key (YAML/JSON/CSV) |
15
+ | `read_diff` | re-`Read` after edit | Changed hunks since last `smart_read` |
16
+ | `smart_read_many` | multiple `Read` | Batch smart_read for up to 20 files |
17
+
18
+ ## Search & Navigation
19
+
20
+ | Tool | Instead of | Purpose |
21
+ |------|-----------|---------|
22
+ | `find_usages` | `Grep` (refs) | All usages of a symbol; filters by scope/kind/lang/mode |
23
+ | `project_overview` | `ls` + explore | Project type, frameworks, architecture, directory map |
24
+ | `related_files` | manual | Import graph: imports, importers, test files |
25
+ | `outline` | multiple `smart_read` | Compact symbol overview of all code in a directory |
26
+ | `find_unused` | manual | Dead code detection — unreferenced exported symbols |
27
+ | `code_audit` | multiple `Grep` | TODOs, deprecated symbols, structural patterns |
28
+ | `module_info` | manual | Deps, dependents, public API, unused deps |
29
+ | `smart_diff` | raw `git diff` | Structural diff with symbol mapping |
30
+ | `explore_area` | 3–5 calls | Structure + imports + tests + recent changes in one call |
31
+ | `smart_log` | raw `git log` | Structured commits with category detection |
32
+ | `test_summary` | raw test output | Run tests → pass/fail summary + failure details |
33
+
34
+ ## Session
35
+
36
+ | Tool | Purpose |
37
+ |------|---------|
38
+ | `session_snapshot` | Compact markdown snapshot (<200 tokens) of goal, decisions, facts, blockers, next step. Auto-persisted to `.token-pilot/snapshots/latest.md`. |
39
+ | `session_budget` | Hook-suppression pressure for this session: saved tokens, burn fraction, effective denyThreshold, time-to-compact projection. |
40
+ | `session_analytics` | Token savings: per-tool breakdown, top files, policy advisories. |
41
+
42
+ ## `find_usages` modes
43
+
44
+ `find_usages` accepts a `mode` parameter:
45
+
46
+ | Mode | Output | Tokens |
47
+ |------|--------|--------|
48
+ | `full` | Symbol usages with surrounding code context | ~5–20× more |
49
+ | `list` *(strict default)* | File:line pairs only — 5–10× smaller | smallest |
50
+
51
+ In `TOKEN_PILOT_MODE=strict`, `mode` defaults to `"list"` when not set by the caller. Pass `mode: "full"` explicitly to override.
52
+
53
+ ## `smart_read` scopes
54
+
55
+ | Scope | Output |
56
+ |-------|--------|
57
+ | *(default)* | Full AST outline with types, signatures, docs |
58
+ | `nav` | Names + line numbers only (2–3× smaller) |
59
+ | `exports` | Public API surface only |
60
+
61
+ In `TOKEN_PILOT_MODE=strict`, `max_tokens` defaults to 2 000 when not set by the caller.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "token-pilot",
3
- "version": "0.28.3",
4
- "description": "Save up to 80% tokens when AI reads code \u2014 MCP server for token-efficient code navigation, AST-aware structural reading instead of dumping full files into context window",
3
+ "version": "0.30.0",
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",
7
7
  "bin": {