Skip to content

feat: support Command Code (commandcode.ai) usage tracking via API sync #668

@thedavidweng

Description

@thedavidweng

Summary

Command Code is a frontier AI coding agent distributed via npm (command-code). It runs as an interactive TUI (cmd) and stores project/user configuration locally, but usage data (token counts, credits, request counts) is only available via its authenticated API — not in local session files. This makes it similar to the existing Warp and Cursor integrations in Tokscale: aggregate usage tracking via API sync rather than local transcript parsing.

What exists locally

Command Code stores configuration and skills locally, but no per-session token data:

~/.commandcode/
├── auth.json          ← user credentials / auth state
├── mcp.json           ← MCP server configurations
├── AGENTS.md          ← agent configuration
├── taste/             ← taste learning data
├── plan/              ← plan files
├── agent/             ← agent configs
└── project/           ← project metadata

~/.agents/             ← user skills
  • Project-level skills: .commandcode/skills or .agents/skills
  • User-level skills: ~/.commandcode/skills or ~/.agents/skills

No local session transcripts, JSONL files, or SQLite databases with token fields were found. The dist/index.mjs bundle only contains API-based usage retrieval (fetchUsageData()https://commandcode.ai/api/alpha).

Available API surfaces

The Command Code CLI makes authenticated calls to https://commandcode.ai/api/alpha:

BILLING.SUBSCRIPTIONS

  • planId, status, currentPeriodEnd
  • Subscription tier and renewal info

BILLING.CREDITS

  • monthlyCredits, purchasedCredits, freeCredits
  • Credit balance and consumption

Usage summary (from fetchUsageData)

  • totalCost — total cost in credits
  • totalCount — total request count
  • modelBreakdown — per-model cost breakdown
  • credits — detailed credit allocation

Proposed v1 scope

Register command-code as a new client using aggregate API sync:

  • Read auth state from ~/.commandcode/auth.json (or prompt user to authenticate)
  • Pull usage data from the authenticated API at commandcode.ai/api/alpha
  • Cache normalized results locally (e.g., ~/.config/tokscale/command-code-cache/)
  • Report:
    • Request count and cost per model
    • Credit consumption (monthly/purchased/free)
    • Subscription status and renewal date

Important constraint

Command Code does not expose per-message input/output/cache/reasoning token counts locally. The API returns aggregate request counts and credit costs. Tokscale should represent this as an aggregate-only source, similar to Warp.

Non-goals for v1

  • Per-message token accounting (no local data available)
  • Session transcript parsing
  • Taste/skill system integration
  • Local command-code configuration sync

Open questions

  • What is the exact format of ~/.commandcode/auth.json and how stable is the auth token?
  • Does the API support external tool access, or would Tokscale need to implement the same auth flow as the CLI?
  • Is historical usage beyond the current billing cycle available?
  • How should Tokscale display a client that has request/credit metrics but no true token counts?

Context

Researched by examining the command-code npm package (v0.31.2) dist/index.mjs and its local configuration paths on macOS. The API endpoints and data structures were extracted from the minified bundle — not from official API documentation.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions