feat: rewrite the Command Code provider on pi's native provider API

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.
This commit is contained in:
2026-09-14 11:19:33 +08:00
parent 8007a6480c
commit 5947e133de
84 changed files with 6644 additions and 16083 deletions
+11 -53
View File
@@ -1,8 +1,9 @@
{
"name": "pi-commandcode-provider",
"version": "0.6.4",
"description": "pi custom provider for Command Code API (commandcode.ai)",
"version": "0.1.0",
"description": "Command Code provider for pi",
"type": "module",
"private": true,
"keywords": [
"pi-package",
"pi-extension",
@@ -10,55 +11,11 @@
"provider"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/patlux/pi-commandcode-provider.git"
},
"homepage": "https://github.com/patlux/pi-commandcode-provider#readme",
"bugs": {
"url": "https://github.com/patlux/pi-commandcode-provider/issues"
},
"files": [
"index.ts",
"src/",
"scripts/",
"README.md",
"CHANGELOG.md",
"CONTRIBUTING.md",
"RELEASE.md",
"LICENSE"
],
"scripts": {
"test": "npm run typecheck && tsx tests/test-package-manifest.ts && tsx tests/test-api-key.ts && tsx tests/test-pure-functions.ts && tsx tests/test-models.ts && tsx tests/test-model-metadata-check.ts && tsx tests/test-runtime.ts && tsx tests/test-pricing.ts && tsx tests/test-cost.ts && tsx tests/test-oauth.ts && tsx tests/test-abort.ts && tsx tests/test-overflow.ts && tsx tests/test-stream.ts && tsx tests/test-quota.ts && tsx tests/test-quota-command.ts && tsx tests/test-retry.ts && tsx tests/test-transport.ts && node tests/test-pi-isolated.mjs && node tests/test-pi-authenticated.mjs && node tests/test-pi-local.mjs && node tests/test-omp-compat.mjs",
"test": "node --import tsx --test tests/**/*.test.ts",
"test:unit": "node --import tsx --test tests/*/*.test.ts",
"typecheck": "tsc --noEmit",
"format:check": "prettier --check '**/*.{ts,mjs,json,md}'",
"format": "prettier --write '**/*.{ts,mjs,json,md}'",
"pi:isolated": "node scripts/pi-isolated.mjs",
"pi:authenticated": "node scripts/pi-authenticated.mjs",
"check:commandcode-catalog": "tsx .github/scripts/check-commandcode-model-metadata.ts command-code@latest",
"sync:commandcode-catalog": "tsx .github/scripts/check-commandcode-model-metadata.ts command-code@latest --write",
"test:quota": "tsx tests/test-quota.ts && tsx tests/test-quota-command.ts",
"test:unit": "tsx tests/test-api-key.ts && tsx tests/test-pure-functions.ts && tsx tests/test-models.ts && tsx tests/test-model-metadata-check.ts && tsx tests/test-runtime.ts && tsx tests/test-pricing.ts && tsx tests/test-cost.ts && tsx tests/test-oauth.ts && tsx tests/test-abort.ts && tsx tests/test-overflow.ts && tsx tests/test-stream.ts && tsx tests/test-quota.ts && tsx tests/test-quota-command.ts && tsx tests/test-retry.ts && tsx tests/test-transport.ts",
"test:api-key": "tsx tests/test-api-key.ts",
"test:models": "tsx tests/test-models.ts && tsx tests/test-model-metadata-check.ts",
"test:runtime": "tsx tests/test-runtime.ts",
"test:pricing": "tsx tests/test-pricing.ts",
"test:oauth": "tsx tests/test-oauth.ts",
"test:abort": "tsx tests/test-abort.ts",
"test:overflow": "tsx tests/test-overflow.ts",
"test:stream": "tsx tests/test-stream.ts",
"test:retry": "tsx tests/test-retry.ts",
"test:transport": "tsx tests/test-transport.ts",
"test:pi-isolated": "node tests/test-pi-isolated.mjs",
"test:pi-authenticated": "node tests/test-pi-authenticated.mjs",
"test:pi-local": "node tests/test-pi-local.mjs",
"test:smoke": "node tests/test-smoke.mjs",
"test:e2e:live": "node tests/test-live-e2e.mjs",
"test:e2e:live:go": "node scripts/live-e2e-profile.mjs go",
"test:e2e:live:goat": "node scripts/live-e2e-profile.mjs goat",
"test:e2e:live:provider": "node scripts/live-e2e-profile.mjs provider",
"test:e2e:live:all": "node scripts/live-e2e-profile.mjs go goat",
"test:cost": "tsx tests/test-cost.ts"
"sync:catalog": "node scripts/sync-catalog.mjs"
},
"pi": {
"extensions": [
@@ -66,10 +23,11 @@
]
},
"devDependencies": {
"@types/node": "25.6.0",
"prettier": "^3.5.0",
"tsx": "4.22.4",
"typescript": "6.0.3"
"@earendil-works/pi-ai": "0.85.1",
"@earendil-works/pi-coding-agent": "0.85.1",
"@types/node": "^22.10.0",
"tsx": "^4.19.0",
"typescript": "^5.7.0"
},
"peerDependencies": {
"@earendil-works/pi-ai": "*",