mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 07:41:52 +08:00
The CLI already tracked token usage, but it did not translate that usage into model-aware cost reporting or offer a spend guardrail. This change adds a max-cost flag, integrates estimated USD totals into /status and /cost, emits near-budget warnings, and blocks new turns once the configured budget has been exhausted. The workspace verification request also surfaced stale runtime test fixtures that still referenced removed permission enum variants, so those test-only call sites were updated to current permission modes to keep full clippy and workspace test coverage green. Constraint: Reuse existing runtime usage/pricing helpers instead of adding a new billing layer Constraint: Keep the feature centered in existing CLI/status surfaces with no new dependencies Rejected: Move budget enforcement into runtime usage/session abstractions | broader refactor than needed for this CLI-scoped feature Confidence: high Scope-risk: moderate Reversibility: clean Directive: If resumed sessions later need historically accurate per-turn pricing across model switches, persist model metadata before changing the cost math Tested: cargo fmt --all --check; cargo clippy --workspace --all-targets -- -D warnings; cargo test --workspace Not-tested: Live network-backed prompt/REPL budget behavior against real Anthropic responses