Conversation
|
|
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
|
@BabyKoan review |
|
|
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
|
@BabyKoan rr |
|
|
- Add src/core/usage/pricing.ts with bundled price table and settings overrides - Add src/core/usage/usageLedger.ts for date-partitioned JSONL append/read - Add unit tests for pricing arithmetic and ledger persistence
- Wire appendUsageEntry into runAgentTurn onFinish and subagent tool-result paths - Fire-and-forget ledger writes so I/O failures never crash a turn - Extend streaming tests to assert ledger append is called with provider/model
- Create costCommand.ts with session/today/week aggregation and per-model breakdown - Register /cost and /usage aliases in commands.ts - Add help entries in commandHelp.ts - Add unit tests for empty data, scope filtering, and populated ledger
- Add priceOverrides and budget fields to HazeSettings - Implement checkBudget in src/core/usage/budget.ts with session and daily thresholds - Wire budget warnings into chat.tsx recordTokenUsage callback with deduplication
- Add sessionCost state updated from recordTokenUsage - Append ~$ cost label to existing status detail label
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
a17eb8c to
97035ac
Compare
|
|
Rebase with requested adjustmentsBranch Changes applied
StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
PR Review — feat: local cost ledger, /cost command, and soft budget warningsGood foundation, but several prior-review correctness issues are still unfixed and one input-validation gap remains. The rebase fixed the session-budget repricing bug by tracking a running session cost in Still needs attention:
🟡 Important
1. Cost math ignores cache and reasoning tokens
|
Summary
Adds local, offline cost tracking: a JSONL usage ledger under
~/.haze/usage/,/costand/usageslash commands, optional soft budget warnings, and a live session-cost estimate in the status bar.Closes #28
Changes
src/core/usage/pricing.tswith bundled model-price table and user-editablepriceOverrides.src/core/usage/usageLedger.tsfor date-partitioned JSONL append/read.src/core/usage/budget.tsfor optional soft-budget threshold warnings.src/cli/commands/costCommand.tsimplementing/cost [session|today|week]and/usagealias.streaming.tsnow persists every finished turn and subagent tool-result usage to the ledger.chat.tsxshows an incremental~$session cost in the status bar and surfaces budget warnings as system messages.settings.tsextended withpriceOverridesandbudgetfields./cost,/usage, and budget configuration docs.Test plan
npm test -- tests/core/usage/pricing.test.ts tests/core/usage/usageLedger.test.ts tests/core/usage/budget.test.ts tests/cli/commands/costCommand.test.ts tests/cli/commands/streaming.test.tspasses.npm test(808 tests) passes.npm run typecheckandnpm run lintpass.Quality Report
Changes: 15 files changed, 598 insertions(+), 6 deletions(-)
Code scan: clean
Tests: passed (0 test)
Branch hygiene: clean
Generated by Kōan