Replace the previous implementation with one that registers the Provider API catalog through pi's own provider layer instead of shipping a custom transport, cache file, and hand-maintained pricing table. - models: derive the catalog from the published command-code CLI package (context windows, reasoning efforts, image input, output limits, rates) and keep it as the offline baseline; scripts/sync-catalog.mjs regenerates it and supports --check - refresh: use refreshModels plus context.publish so pi persists the live /provider/v1/models listing in models-store.json and restores it offline - auth: /login browser transfer through a localhost callback server with a pasted-key fallback; $COMMAND_CODE_API_KEY, --api-key and auth.json keep working - streaming: pi's native openai-completions and anthropic-messages adapters; the generate-transport fallback and Oh My Pi branches are gone - keep the context-overflow rewrite that enables pi's compaction retry and the /commandcode-quota command - tests: 51 cases under tests/<module>/ covering models, catalog sync, auth, the callback server, overflow handling, quota, and the extension factory Verified against the live API: chat, tool round trip, image input and --thinking max on deepseek/deepseek-v4.1-flash, quota output, and catalog persistence in an interactive session.
pi-commandcode-provider
Unofficial Command Code provider for pi,
written against pi's current provider API. It registers the Command Code
Provider API as the commandcode provider and lets pi own authentication,
model persistence, and streaming.
Not affiliated with, endorsed by, or supported by Command Code. You need your own account, API key, and a plan with Provider API access.
Install
pi remove npm:pi-commandcode-provider # if the community package is installed
pi install /home/cat/pi-commandcode-provider
Restart pi or run /reload, then /login → Command Code to store the API
key (or select the subscription flow for browser login). Pick a model with
/model.
What it registers
| Piece | Behaviour |
|---|---|
| Provider | commandcode, name "Command Code", base URL https://api.commandcode.ai/provider/v1 |
| API | pi's native adapters: openai-completions for most models, anthropic-messages for claude-* |
| Auth | /login (browser transfer or pasted key), $COMMAND_CODE_API_KEY, --api-key, auth.json |
| Catalog | Generated CLI catalog as the offline baseline; pi's catalog refresh replaces it with the live /provider/v1/models listing |
| Command | /commandcode-quota prints credits, plan, usage windows, and the period summary |
Because the model list is registered through pi's own catalog layer, the live
listing is cached in ~/.pi/agent/models-store.json and refreshed by pi itself
(interactive startup and the /model picker), not by a custom cache file. When
the endpoint is unreachable, the persisted catalog stays active; before the
first refresh, the generated baseline is used, so pi --list-models commandcode
works offline.
Environment variables
| Variable | Purpose |
|---|---|
COMMAND_CODE_API_KEY |
API key fallback when no credential is stored |
CMD_ZDR=1 |
Send x-cmd-zdr: 1 (zero data retention); COMMANDCODE_ZDR=1 still works |
COMMANDCODE_API_BASE |
Override the Provider API base URL |
COMMANDCODE_MODELS_URL |
Override the catalog endpoint |
COMMANDCODE_MODELS_TIMEOUT_MS |
Catalog request timeout (default 10 s) |
COMMANDCODE_AUTH_TIMEOUT_MS |
Browser login callback timeout (default 120 s) |
The provider also reads existing keys from ~/.pi/agent/auth.json and
~/.commandcode/auth.json for /commandcode-quota.
Model metadata
Reasoning support, effort levels, image input, output limits, and prices come
from the published command-code CLI package, which is the same source the
Command Code CLI uses. Regenerate the catalog after a new CLI release:
npm run sync:catalog # latest command-code
npm run sync:catalog -- --version 1.54.0
npm run sync:catalog -- --check # fail when src/catalog.ts is stale
Prices are display-only estimates; the Command Code usage page remains authoritative.
Development
npm install
npm test # unit + extension tests, no network
npm run typecheck
Tests live in tests/<module>/ next to the module they cover and call the real
production code. tests/extension/provider.test.ts drives the extension factory
with a stub ExtensionAPI and a local catalog server; no Command Code
credentials are required.