Skip to content

feat(cli): scope ccam cost to a session and surface tool surcharges#239

Merged
hoangsonww merged 1 commit into
masterfrom
feat/ccam-cost-session-surcharges
Jul 18, 2026
Merged

feat(cli): scope ccam cost to a session and surface tool surcharges#239
hoangsonww merged 1 commit into
masterfrom
feat/ccam-cost-session-surcharges

Conversation

@hoangsonww

Copy link
Copy Markdown
Owner

Summary

A single, self-contained enhancement to the ccam cost command. It was calling only the whole-database aggregate endpoint and rendering the token total + per-model chart, leaving two things the API already returns invisible from the terminal:

  • Per-session costccam cost --session <id> now hits GET /api/pricing/cost/:sessionId (the same route the dashboard uses, previously unreachable from the CLI). Same response shape, so the per-model breakdown and unpriced-model warning render exactly as they do for the aggregate. Faster than the full ccam session <id> view when cost is all you want, and scriptable.
  • Server-tool surchargesfeature_costs carries the web-search ($10/1k) and code-execution (container-time beyond the org free allowance) charges billed on top of tokens. ccam cost now prints a Server-tool surcharges line whenever either is non-zero, so the total's composition is explainable instead of reading as pure token cost. The line is omitted when nothing is surcharged, keeping the common case clean.

Testing

  • npm run test:server / npm run test:client — full suite green via the pre-commit hook (new CLI tests: cost --session scoping, web-search surcharge line)
  • bash .claude/skills/file-headers/scripts/check-headers.sh — exit 0

Docs

Synced across the surface: docs/CLI.md, README + VN/CN/KO CLI blocks, and the wiki Insights row with zh/vi/ko i18n entries and the required cache bump (wiki-v42 / i18n-content.js?v=33).

🤖 Generated with Claude Code

`ccam cost` only ever called the whole-database aggregate endpoint and
rendered the token-cost total plus the per-model chart. Two things the API
already returns were invisible from the terminal:

- Per-session cost. The route GET /api/pricing/cost/:sessionId exists and is
  what the dashboard uses, but the CLI had no way to reach it. `ccam cost
  --session <id>` now prices a single session (same response shape, so the
  breakdown/unpriced-warning rendering is shared) — quicker than the full
  `ccam session <id>` detail view when cost is all you want, and scriptable.
- Server-tool surcharges. feature_costs carries the web-search ($10/1k) and
  code-execution (container-time beyond the org free allowance) charges that
  are billed on top of tokens. `ccam cost` now prints a "Server-tool
  surcharges" line whenever either is non-zero, so the total's composition is
  explainable instead of looking like pure token cost. The line is omitted
  when nothing is surcharged, keeping the common case uncluttered.

Docs synced across the surface: docs/CLI.md, README + VN/CN/KO CLI blocks,
and the wiki Insights row (with zh/vi/ko i18n entries and the required cache
bump to wiki-v42 / i18n-content.js?v=33). Tests: `ccam cost --session`
scoping and the web-search surcharge line added to the CLI suite.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 17, 2026 18:55
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@cursor

cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested labels Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@hoangsonww
hoangsonww merged commit 250f91a into master Jul 18, 2026
20 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested

Projects

Development

Successfully merging this pull request may close these issues.

2 participants