# pi-commandcode-provider Unofficial [Command Code](https://commandcode.ai) provider for [pi](https://github.com/earendil-works/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 ```sh 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: ```sh 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 ```sh npm install npm test # unit + extension tests, no network npm run typecheck ``` Tests live in `tests//` 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.