* feat: Command Code support Reads the cmd CLI's session transcripts at ~/.commandcode/projects/<slug>/<id>.jsonl (CODEBURN_COMMANDCODE_DIR moves the root). Checkpoint and prompt sidecars are skipped. usage.inputTokens includes cacheReadTokens, so fresh input is inputTokens - cacheReadTokens. The recorded costUsd is kept per call (costFromBilling); a call without one is priced from tokens and marked estimated. Forks copy parent message ids into a new file, so calls dedupe by message id across sessions. Desktop: Electron sandbox read path, macOS and Windows change watchers, Windows tab colour. No quota adapter. * fix(command-code): dedupe on meta.messageId, not the 8-hex line id The top-level id is randomUUID().slice(0, 8) and only unique within one file, so calls from unrelated sessions could collide and vanish. meta.messageId is a full uuid that survives forks. Fixture ids now use the real 8-hex shape. * test(command-code): check sidecar skipping by file name, not a posix path
3.3 KiB
Command Code
Command Code (cmd), Langbase's coding agent CLI (commandcode.ai, npm command-code).
- Source:
src/providers/command-code.ts - Loading: eager (
src/providers/index.ts) - Test:
tests/providers/command-code.test.ts, fixturetests/fixtures/command-code/(redacted real transcripts)
Where it reads from
~/.commandcode/projects/<project-slug>/<session-id>.jsonl. CODEBURN_COMMANDCODE_DIR replaces ~/.commandcode; the CLI itself has no override and follows HOME.
Only <id>.jsonl files are sessions. The CLI writes sidecars next to each one (.checkpoints.jsonl, .prompts.jsonl, .meta.json, .share.json), and discovery skips any file whose name has a second dot. ~/.commandcode/history.jsonl is prompt history and is never read, nor is anything else outside projects/.
Storage format
JSONL, session format v3:
- First line:
{type: "session", version, id, timestamp, cwd, parentSession?}. - Then
{type: "message", id, parentId, timestamp, message: {role, content, meta: {messageId}}, model?, usage?}.contentis a string or an array oftext,thinking,tool_useandtool_resultblocks. - Assistant lines carry
model(e.g.moonshotai/Kimi-K3,deepseek/deepseek-v4-pro) andusage: {inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens, costUsd}.
Token model
One call per assistant message line with usage.
usage.inputTokensincludescacheReadTokens. CodeBurn's input is fresh input, so it storesinputTokens - cacheReadTokens(never below 0). TakinginputTokensas is counts every cache read twice. Checked on real data:inputTokens >= cacheReadTokenson every call, andcostUsdfits one set of per-token rates only when input is taken as cache-inclusive.cacheReadTokensandcacheWriteTokensmap to cache read and cache write.outputTokensalready includes reasoning (no separate count), soreasoningTokensis 0.
Pricing
costUsd is the dollars Command Code charged for the call (its own rates, e.g. DeepSeek at the discounted price). When it is present, including 0 for free models, it is kept as is with costFromBilling. A call without it is priced from tokens through the shared catalog and marked costIsEstimated; a model id the catalog does not know shows up under codeburn models --unpriced.
Deduplication
command-code:<message.meta.messageId>, a full uuid. The top-level id is only 8 hex characters and unique within one file, so sessions can collide on it; it is used only as a fallback and for turnId. Forking a session copies the parent's message lines verbatim into a new session file, so the key is not scoped to a session.
Quirks
- Project is the last segment of the session header's
cwd, falling back to the slug directory. - Tool names are Command Code's own (
shell_command,read_file,grep,agent, ...) and are mapped to CodeBurn's names.agentcalls with asubagent_typecount as subagents;activate_skillcounts as a skill.
When fixing a bug here
- Discovery: the
projects/<slug>/<id>.jsonlwalk and the sidecar filter. - Accounting: the input/cache split above. Recheck it against
costUsdif the CLI changes its usage block. - Add a case to
tests/providers/command-code.test.ts; do not mock the filesystem.