Skip to content

feat(ui): add /tokens /context /cost commands (#224) - #281

Open
innocarpe wants to merge 1 commit into
lessweb:mainfrom
innocarpe:feat/224-token-commands
Open

feat(ui): add /tokens /context /cost commands (#224)#281
innocarpe wants to merge 1 commit into
lessweb:mainfrom
innocarpe:feat/224-token-commands

Conversation

@innocarpe

Copy link
Copy Markdown

Summary

  • New /tokens, /context, and /cost slash commands report token usage, context-window consumption, and estimated cost for the current session.

Why

Token usage was already tracked in session entries but invisible from the CLI. Users had no way to check how much context they had used, what was consuming it, or what a session cost — important for paid/reasoning models and for debugging context-limit issues.

Changes

  • packages/cli/src/ui/core/token-usage.ts (new): context estimation (chars/4 over active messages), DeepSeek pricing table, and report formatters.
  • packages/cli/src/ui/core/slash-commands.ts: register /tokens, /context, /cost.
  • packages/cli/src/ui/views/PromptInput.tsx + App.tsx: wire the commands to compute and display the report.
  • packages/cli/src/tests/token-usage.test.ts (new) + slash-commands.test.ts: unit tests.

Validation

  • npm run typecheck
  • npm test — CLI suite passes (306/306) ✅

Closes #224

New slash commands report token usage, context-window consumption, and estimated cost for the current session. Token usage comes from the session entry; context size is estimated from the active messages; cost uses a DeepSeek pricing table.

(cherry picked from commit feaf159f38a141e1888323f6131a12478d81e87e)
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.

feat: add /tokens /context /cost commands to show token usage and context size

1 participant