Skip to content

feat: Budget & Token Tracker spec (Phase 4)#12

Open
zywkloo wants to merge 9 commits into
mainfrom
feat/budget-tracker
Open

feat: Budget & Token Tracker spec (Phase 4)#12
zywkloo wants to merge 9 commits into
mainfrom
feat/budget-tracker

Conversation

@zywkloo

@zywkloo zywkloo commented May 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • docs/budget.md — full spec for the upcoming wtcraft budget command: hybrid config model (planner.md frontmatter + WTCRAFT_MAX_BUDGET env var), real-time event hooks for velocity/cache/model recommendations during wtcraft new / verify / check, CLI design, and supported agent log parsers (Claude Code, Gemini CLI, Aider/Codex)
  • docs/roadmap.md — Phase 4 goal updated to include budget control with a link to the spec
  • README.md — positioning callout added to surface the budget-aware, zero-bloat angle for developers landing on the project

Why

Solo developers running multiple agents face silent cost overruns. This spec lays out how wtcraft can parse local session logs and give real-time burn-rate feedback — keeping the tool git-native and privacy-preserving (all parsing is local, no external calls).

Reviewer notes

This PR is spec/docs only — no implementation yet. The goal is to validate the design before building the wtcraft budget command and hook integrations.

Test plan

  • docs/budget.md renders correctly on GitHub
  • Roadmap Phase 4 section links to budget.md correctly
  • README callout displays as expected

🤖 Generated with Claude Code

claude and others added 6 commits May 27, 2026 21:04
…user narratives

Integrates npm/GitHub token budget tool landscape research into a new
docs/token-budget.md. Defines two primary user narratives (all-free-tier
and all-lowest-paid-tier across Claude Code / Codex / Antigravity) and
maps wtcraft's layer-2 architecture position against layer-3 observability
tools (CodeBurn, llm-token-tracker) and Anthropic's native Task Budget API.

https://claude.ai/code/session_01A5oU4c7YSGpwatMA2PK1AE
Adds a new `wtcraft cost [--all]` subcommand that reads
~/.claude/projects/**/*.jsonl and aggregates token usage (input, output,
cache_read, cache_write) and estimated USD cost by git branch. No API key
or proxy required — purely local JSONL parsing.

Default view filters to branches visible in the current repo's active
worktrees. --all shows every branch on record.

Implemented in src/wtcraft/_cost.py (Python); _cli.py intercepts the
`cost` argv before delegating to bash, so the shell script needs no JSON
parsing. Help text added to shell script for `wtcraft help cost`.

https://claude.ai/code/session_01A5oU4c7YSGpwatMA2PK1AE
- docs/budget.md: full spec for the upcoming wtcraft budget command —
  covers hybrid config model (planner.md frontmatter + env vars),
  real-time event hooks (velocity, cache, model recommendations),
  CLI design, and supported agent log parsers
- docs/roadmap.md: promote Phase 4 goal to include budget control and
  link to the new budget.md spec
- README.md: add positioning callout for budget-aware, zero-bloat
  multi-agent orchestration

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
zywkloo added 3 commits May 27, 2026 16:26
…acker

The shipped Budget & Token Tracker (budget.md + _budget.py + wtcraft cost)
covers cost observability via local CLI log parsing. This commit adds a
complementary design doc capturing the next layer that emerged from a
post-implementation design discussion:

- WTCRAFT_USAGE_REPORT contract with source-tagging (runtime / self_report /
  unavailable) as a vendor-agnostic baseline.
- Adapter degradation chain (vendor JSON stream → log parser → skill →
  wall-clock heuristic) — existing log-parsing path becomes the default
  'runtime' adapter for Claude and Codex.
- wtcraft handoff command + quota-aware routing using roles.preferred +
  roles.fallback, moving from passive cost observation to active
  orchestration.
- Activation scope strictly bounded to wtcraft worktrees (env var or
  .worktree-task.md detection).
- Default single-step handoff; --auto is opt-in with explicit stop
  conditions, preserving human-in-loop as the default.

Decisions, investigation TODO, implementation TODO, and open design
questions are all tracked as checkboxes so progress is visible from git
diffs. This doc is strictly additive — does not modify or replace the
shipped tracker behavior.

Adds a one-line link from roadmap.md Phase 4 so the doc is discoverable.
Vendor-name routing (preferred: claude) is too coarse — within one
family, Haiku / Sonnet / Opus differ by an order of magnitude in price,
reasoning depth, and throughput. Putting them in one bucket throws away
the most important routing signal.

D5 now uses model-level identifiers (claude-opus-4-7, codex-gpt-5.3,
gemini-3.5-flash, …) with a 4-role example that assigns:

- planner: Opus — strong reasoning, few calls, premium worth it
- executor: Codex (GPT-5.3) — main workhorse, JSON event stream
- verifier: Gemini Flash — long-context diff reading, cheapest tier
- finisher: Opus — commit message / PR body quality

The pattern is intentional: priciest model goes where call count is
lowest, cheapest model goes where bulk reading happens. Same-vendor
fallback (Opus → Sonnet) is also enabled — quota-aware routing matters
within a family as much as across.

Adds a new Investigation TODO item for the model identifier scheme:
who owns the mapping from CLI invocation to model string, how to
handle aliases vs pinned ids, how to detect retired names, and whether
to normalize across vendors. Routing examples in D5 remain
documentation-only until this lands.
…EADME

Three layered changes addressing the same concern — pinned model ids
(claude-opus-4-7, codex-gpt-5.3, gemini-3.5-flash) in the D5 routing
example will go stale within months as vendors ship new variants and
retire old names.

- Top-of-doc maintenance callout: warns any reader past ~90 days from
  the last commit that example values are likely stale, and points at
  the alias-resolution proposal as the long-term fix.
- After-YAML alias-resolution proposal: contracts use semantic aliases
  (claude-opus-latest, *-best-reasoning-*, *-cheapest-fast-*) that the
  runtime resolves at handoff time against an updatable mapping table
  (.wtcraft/models.yaml, refreshable via wtcraft sync-models).
  Contracts stay readable across model generations; registry is the
  single point of maintenance instead of every task file.
- README Docs section now links to handoff-and-routing.md with a
  parenthetical noting the maintenance requirement, so new users
  discover the planning doc and its caveat without having to dig
  through the roadmap.
zywkloo added a commit that referenced this pull request Jun 10, 2026
- cli is now the primary routing key; model is a hint (subscription reality)
- flat one-line-per-field schema: bash/awk parseable, no nested YAML
- fallback encoded as ordered 'cli:Model Name' comma list
- docs/model-select.md: Level 2 CLI spec + scope boundary with budget (PR #12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants