Skip to content

feat(opencodego): expose local history in cost command - #4629

Merged
steipete merged 3 commits into
mainfrom
triage/20260921-bugs-37b-4606
Oct 19, 2026
Merged

steipete merged 3 commits into
mainfrom
triage/20260921-bugs-37b-4606

Conversation

@steipete

Copy link
Copy Markdown
Owner

Summary

Enable codexbar cost --provider opencodego using the existing device-local SQLite reader and snapshot projection. JSON exposes the same daily/per-model recorded costs and available tokens; text --breakdown reuses the shared daily/model renderer. Unknown token totals remain unknown.

The cost command honors its passed home directory, selected cost time zone, and All history period. The existing reader checks its local auth file only to classify missing history; it makes no remote quota or cookie request. Existing app usage-source ownership and estimate provenance/disclaimer are preserved.

Verification

The main baseline failed cost fetcher exposes existing local daily history; the main CLI returned unsupported-provider JSON (exit 1). The fixed synthetic CLI returns JSON and text (both exit 0, empty stderr), with $1.25 recorded cost and unknown token totals preserved.

Local proof used a combined lane candidate; this PR is the independently split change, and exact-head PR CI is the broad gate. All data was synthetic. No running app, real account, Keychain, or browser-cookie probe was used.

  • Native macOS focused command: swift test --build-system native --jobs 2 -Xswiftc -gnone --filter 'CostUsageClaude(ArtifactWriter|CacheIsolation|Fragment|KimiAlias|MetadataParsing|Overflow|PriceRange|PricingRace|Rebuild|ReconciliationMemory|ReportContext|ReportWire|Resolver|RowCapacity|RowStorage|VertexClassifier|VertexPrecheck|WriteAmplification)Tests|CostUsageScanner(Claude.*)?Tests|PiSession.*Tests|PiBedrockPricingTests|PiNativeProjectionTests|PiInclusiveRefreshTests|PiSharedRootMergeTests|PiProviderTests|PiProjectOverflowTests|UsageStorePiHistoryScopeTests|OpenCodeGo.*Tests|CLICost.*Tests|CLICommonOptionsTests|CLIProviderSelectionTests|CostReportingPeriodTests|ProviderArchitectureGatekeeperTests|ProviderSettingsDescriptorTests|BrowserCookiePromptContractTests|SettingsStoreTokenCostSourceTests|SettingsStoreCoverageTests|SettingsStoreAdditionalTests|SpendDashboardModelTests', under the shared serial.sh lock with Scripts/test_environment.sh.
  • The combined selection ran 816 tests in 79 suites: 815 passed and one architecture-anchor check failed. The exact-line anchor was corrected, then the affected CLI/OpenCode/gate suites were rerun with --filter 'CLICost.*Tests|ProviderArchitectureGatekeeperTests|CLIProviderSelectionTests|CLICommonOptionsTests|OpenCodeGoLocalUsageReaderTests': ✔ Test run with 144 tests in 9 suites passed after 21.085 seconds..
  • After the Pi cleanup and OpenCode Go review corrections: swift test --build-system native --jobs 2 -Xswiftc -gnone --filter 'CostUsageScannerClaudeDesktopTests|CostUsageClaudeReportContextTests|CostUsageScannerClaudeMemoTests|CostUsageScannerClaudeRegressionTests|CostUsageClaudeCacheIsolationTests|PiSession.*Tests|PiBedrockPricingTests|PiNativeProjectionTests|PiInclusiveRefreshTests|PiSharedRootMergeTests|PiProviderTests|PiProjectOverflowTests|UsageStorePiHistoryScopeTests|ProviderArchitectureGatekeeperTests|CLICost.*Tests|CLIProviderSelectionTests|CLICommonOptionsTests|OpenCodeGo.*Tests|ProviderSettingsDescriptorTests|BrowserCookiePromptContractTests|CostUsageClaudeFragmentTests': ✔ Test run with 573 tests in 53 suites passed after 43.853 seconds..
  • make check: passed.
  • python3 /Users/steipete/Projects/CodexBar-triage-evidence/20260921/precheck-catalogs.py .: no findings before push.
  • Independent Codex autoreview through P2: no accepted/actionable findings in the final candidate.
  • Production delta: 5 files changed, 48 insertions(+), 24 deletions(-) (net +24); Tests: 3 files changed, 106 insertions(+), 6 deletions(-).

Fixes #4606

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-19T06:19:16.686890Z 6a4b36a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge.

What this changes

Expose existing OpenCode Go local token and cost history through the cost command’s JSON and text output.

Example: Export synthetic OpenCode Go history containing $1.25 of recorded cost without token totals.

  • Before: The cost command rejects OpenCode Go as unsupported.
  • After: JSON and text commands succeed, retain the $1.25 cost, and preserve unknown token totals.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, owner-backed integration with reported CLI verification and relevant regression coverage; the remaining finding is inaccurate help and documentation.
Proof confidence 🐚 platinum hermit (4/6) The ordinary contributor-proof gate is exempt for this maintainer-authored PR; its verification reports the shipped CLI reading synthetic SQLite history and returning successful JSON/text with $1.25 and unknown tokens on a combined candidate.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Dashboard users cannot export OpenCode Go history through the cost command even though the app already reads that history.
Reason: The maintainer-authored direction resolves the scope decision with a small integration that preserves the existing reader’s record-selection and unknown-value contract.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-authored PR provides a useful CLI export that current main lacks; one minor help and documentation correction remains.

Priority: P3
Reviewed head: f2636e49977838953670599bdf86851d1b6944ab

Before merge

  • Update cost help and the CLI guide for OpenCode Go (P3) - The PR enables OpenCode Go breakdowns, but codexbar cost --help still describes --breakdown as Claude-only. The cost section in docs/cli.md also omits OpenCode Go and explicitly claims Claude-only breakdown support. Users following these entry points receive an inaccurate description of the newly supported command. Update both descriptions to match the implemented provider support.

Findings

  • [P3] Update cost help and the CLI guide for OpenCode Go — Sources/CodexBarCLI/CLICostCommand.swift:959
Agent review details

How this fits together

Provider capabilities admit CLI cost requests, which pass the selected home, calendar, and history period to the existing SQLite reader and shared snapshot projection before JSON or text rendering.

flowchart LR
  A[Cost command] --> B[Provider capabilities]
  B --> C[Cost usage fetcher]
  C --> D[Local SQLite reader]
  D --> E[Shared cost snapshot]
  E --> F[JSON or text output]
Loading

Technical review

Best possible solution:

Keep the shared reader and renderer integration, and update CLI help and the CLI guide to describe OpenCode Go support accurately.

Do we have a high-confidence way to reproduce the issue?

Current-main capability gates establish the unsupported-provider path, and the PR reports a synthetic baseline CLI rejection; this review ran no builds or tests.

Is this the best way to solve the issue?

Reusing the provider’s existing reader, shared snapshot projection, and renderer is the smallest complete implementation and preserves existing accounting semantics.

Full review comments:

  • [P3] Update cost help and the CLI guide for OpenCode Go — Sources/CodexBarCLI/CLICostCommand.swift:959
    The PR enables OpenCode Go breakdowns, but codexbar cost --help still describes --breakdown as Claude-only. The cost section in docs/cli.md also omits OpenCode Go and explicitly claims Claude-only breakdown support. Users following these entry points receive an inaccurate description of the newly supported command. Update both descriptions to match the implemented provider support.
    Confidence: 1

Overall correctness: patch is correct
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7e31e74ea662.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • swift run CodexBarCLI cost --help
  • make check
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a2cf7fa adds Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoLocalUsageReader.swift:325 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a2cf7face10b; files: Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoLocalUsageReader.swift)
  • kentoku24: Raw commit 23eb775 adds Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoLocalUsageReader.swift:330 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 23eb7750e471; files: Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoLocalUsageReader.swift)
  • Yuxin Qiao: Raw commit 4bfbbe2 adds Sources/CodexBarCLI/CLICostCommand.swift:256 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4bfbbe20996b; files: Sources/CodexBarCLI/CLICostCommand.swift)

Review metrics

Metric Value Why it matters
Production delta +48 / -24 lines across five files A small loader branch and calendar plumbing reuse existing accounting and rendering owners.
Test delta +106 / -6 lines across three files Coverage targets export, history beyond one year, calendar selection, unknown values, and architecture registration.

Labels

Label changes:

  • add P3: This is a bounded CLI export enhancement for an advanced dashboard workflow; existing app history remains available.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is a bounded CLI export enhancement for an advanced dashboard workflow; existing app history remains available.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 19, 2026, 12:15 AM ET / 04:15 UTC.

steipete added a commit that referenced this pull request Oct 19, 2026
@steipete
steipete merged commit 9766555 into main Oct 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codexbar cost: expose existing OpenCode Go local token/cost history

1 participant