Skip to content

Commit a6dd306

Browse files
authored
v0.38.0: fleet workflows — token-pilot owns the workflow boundary (#33)
Implements the fleet design note (Phase 1+2) with the dependency inverted. The original blocker was "does Claude Code's /workflow propagate a workflow-id env var?" — inspecting the installed 2.1.131 bundle confirmed it does NOT. Rather than build against an interface that may never exist (the v0.34.0-args trap), token-pilot OWNS the workflow boundary: `workflow start/end` sets TOKEN_PILOT_WORKFLOW_ID itself, so the feature works under any orchestration and composes with CC's /workflow if it ever sets CLAUDE_CODE_WORKFLOW_ID. New: src/core/workflow.ts - WorkflowEnvelope persisted to .token-pilot/workflows/<id>.json - startWorkflow / endWorkflow / loadWorkflow / listWorkflows - computeWorkflowStatus (pure) + workflowStatus (I/O) - isWorkflowNearBudget, activeWorkflowId, makeWorkflowId, formatters Event tagging - HookEvent gains optional workflow_id - appendEvent auto-tags from TOKEN_PILOT_WORKFLOW_ID / CLAUDE_CODE_WORKFLOW_ID, so every existing call site (task, denied, diagnostic) participates with zero change CLI: `token-pilot workflow <start|end|status|list>` - start "<goal>" [--budget=N] [--max-parallel=N] → prints an `export TOKEN_PILOT_WORKFLOW_ID=<id>` line for eval - status/end default to the active env id - registered in typo-guard KNOWN_COMMANDS Budget guard (advisory, never hard-blocks) - PreToolUse:Task appends a wind-down note + logs a workflow_near_budget diagnostic at >=90% of ceiling - renderPreTaskOutput gains an optional trailing append arg Workflow-aware sessionTitle - SessionStart title switches to `[TP] wf · N tasks · X%` when a workflow is active Verified end-to-end against the built dist: start → tagged Task event → status (4k used / 40% of 10k ceiling, also confirming the v0.37.0 totalTokens extraction) → list → end. Deliberately NOT built (still gated on real data): fleet memory rendezvous + ast-index cross-worker cache (SessionCache already dedups within a process; no data yet on cross-worker duplication), and a WorkflowComplete polyfill. Docs: README "Fleet workflows" section; design note Decision updated to "implemented, dependency inverted". Tests: 1316/1316 pass (+17 workflow + typo-guard). Build: clean (25 agents under 0.38.0).
1 parent 81489c4 commit a6dd306

38 files changed

Lines changed: 841 additions & 50 deletions

.claude-plugin/marketplace.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
},
77
"metadata": {
88
"description": "Token Pilot \u2014 save 60-90% tokens when AI reads code",
9-
"version": "0.37.0"
9+
"version": "0.38.0"
1010
},
1111
"plugins": [
1212
{
1313
"name": "token-pilot",
1414
"source": "./",
1515
"description": "Reduces token consumption by 60-90% via AST-aware lazy file reading, structural symbol navigation, and cross-session tool-usage analytics. 22 MCP tools + 19 subagents + budget watchdog hooks.",
16-
"version": "0.37.0",
16+
"version": "0.38.0",
1717
"author": {
1818
"name": "Digital-Threads"
1919
},

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "token-pilot",
3-
"version": "0.37.0",
3+
"version": "0.38.0",
44
"description": "Saves 60-90% tokens on AI code reading. AST-aware lazy reads, symbol navigation, find_usages, structural git diff/log, edit-safety guard, Task-routing matcher, cross-session telemetry (errors + diagnostics), 25 tp-* subagents tiered to haiku/sonnet/opus with budget watchdog.",
55
"author": {
66
"name": "Digital-Threads",

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,45 @@ tp-* agents that already declared `model: haiku` keep their cheaper
269269
tier (90 %+ of the agent roster); the few sonnet/opus-tier ones
270270
ride the upgrade automatically.
271271

272+
## Fleet workflows (v0.38.0)
273+
274+
When you fan a task across many subagents — via Claude Code's
275+
`/workflow`, the Agent tool, or your own orchestration — token-pilot
276+
can treat the whole run as one budgeted, telemetry-tagged unit.
277+
278+
token-pilot **owns** the workflow boundary, so this works regardless
279+
of whether Claude Code propagates a workflow id. You wrap the batch:
280+
281+
```bash
282+
# Start a workflow — prints an export line you eval into your shell
283+
eval "$(token-pilot workflow start "review every PR from last sprint" --budget=2000000)"
284+
285+
# ...now run your fan-out work. Every hook event is tagged with the
286+
# workflow id automatically (TOKEN_PILOT_WORKFLOW_ID is set).
287+
288+
token-pilot workflow status # live budget + task counts
289+
token-pilot workflow list # all recorded workflows
290+
token-pilot workflow end # stamp it finished + print summary
291+
```
292+
293+
While a workflow is active:
294+
295+
- Every `event:"task"` / `denied` / `diagnostic` row in
296+
`hook-events.jsonl` carries `workflow_id`, so you can slice one
297+
fan-out run out of the global log.
298+
- The PreToolUse:Task hook watches the token ceiling. At ≥90 % it
299+
appends a wind-down note to its routing advice ("finish in-flight
300+
work rather than starting new branches") and logs a
301+
`workflow_near_budget` diagnostic — visible in `workflow status`.
302+
Dispatch is never hard-blocked on budget (a half-finished fan-out
303+
is worse than a small overrun).
304+
- The window title switches to `[TP] wf · N tasks · X%` so a long run
305+
shows live progress.
306+
307+
If Claude Code ever sets its own workflow-id env var
308+
(`CLAUDE_CODE_WORKFLOW_ID`), token-pilot reads that too — no config
309+
change needed.
310+
272311
## Troubleshooting
273312

274313
```bash

agents/tp-api-surface-tracker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tools:
99
- mcp__token-pilot__read_symbol
1010
- Bash
1111
model: haiku
12-
token_pilot_version: "0.37.0"
12+
token_pilot_version: "0.38.0"
1313
token_pilot_body_hash: dd184501203fa7f3c73f419c4ffbe33c4be75400cb64a7a51733a3fe23f6e085
1414
requiredMcpServers:
1515
- "token-pilot"

agents/tp-audit-scanner.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tools:
1111
- Grep
1212
- Read
1313
model: sonnet
14-
token_pilot_version: "0.37.0"
14+
token_pilot_version: "0.38.0"
1515
token_pilot_body_hash: d172f600bf32277ea6eb4cbbee4542ddd698a986dcd96997d33930561964569b
1616
requiredMcpServers:
1717
- "token-pilot"

agents/tp-commit-writer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tools:
88
- mcp__token-pilot__test_summary
99
- mcp__token-pilot__outline
1010
- Bash
11-
token_pilot_version: "0.37.0"
11+
token_pilot_version: "0.38.0"
1212
token_pilot_body_hash: de64a406b5176de19f7422619c7de7949b1f28865f225402c9cea9255f377428
1313
requiredMcpServers:
1414
- "token-pilot"

agents/tp-context-engineer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ tools:
1313
- Edit
1414
- Glob
1515
model: sonnet
16-
token_pilot_version: "0.37.0"
16+
token_pilot_version: "0.38.0"
1717
token_pilot_body_hash: 68b32af2dacd82ebe52c4eec93edb903d452688274c3065218270627c564d8b0
1818
requiredMcpServers:
1919
- "token-pilot"

agents/tp-dead-code-finder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tools:
1111
- Grep
1212
- Read
1313
model: sonnet
14-
token_pilot_version: "0.37.0"
14+
token_pilot_version: "0.38.0"
1515
token_pilot_body_hash: d9b7f5b7ae6f4ae21305c775361bcab097cc774370a6d976c093571d46d55021
1616
requiredMcpServers:
1717
- "token-pilot"

agents/tp-debugger.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tools:
1212
- Read
1313
- Bash
1414
model: sonnet
15-
token_pilot_version: "0.37.0"
15+
token_pilot_version: "0.38.0"
1616
token_pilot_body_hash: 052413de8d92377edcde6ae5c823f5378db304baccfa29e8866467f42553a500
1717
requiredMcpServers:
1818
- "token-pilot"

agents/tp-dep-health.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tools:
99
- Bash
1010
- Read
1111
model: haiku
12-
token_pilot_version: "0.37.0"
12+
token_pilot_version: "0.38.0"
1313
token_pilot_body_hash: e14dc57493d816f8c2e017963e2ef5f66bea50fd0b805a80e8a0d97c968427e7
1414
requiredMcpServers:
1515
- "token-pilot"

0 commit comments

Comments
 (0)