Command Code (commandcode.ai) model provider plugin for OpenClaw, with three-tier model resolution: a generated static baseline for pre-credential discovery, a live catalog refreshed at runtime, and a dynamic resolver (resolveDynamicModel) for model ids missing from the per-agent registry.
- Install deps:
npm install - Start dev:
npm run build(no dev server — plugin is a runtime entry built todist/) - Build:
npm run build(tsc -p tsconfig.json) - Test:
npm test(vitest run) - Typecheck:
npm run typecheck(tsc --noEmit)
index.ts— plugin entry: registers thecommandcodeprovider, live/static catalogs, dynamic resolution, transport mappingsrc/— provider logic;baseline.models.tsis generated, never hand-editedtest/— Vitest unit tests (transport + projection + dynamic resolution)scripts/— Node.mjsutilities (generate-baseline.mjs,smoke.discovery.mjs,live-test.mjs).github/workflows/— CI (typecheck + build + tests)dist/— build output, committed: OpenClaw git/package installs require the compiled runtime (./dist/index.js); the TypeScript-source fallback only applies to local dev paths (plugins.load.paths,--link). Regenerate withnpm run buildbefore committing.openclaw.plugin.json— manifest (provider id, auth env var, onboarding choice, modelCatalog)package.json— package + openclaw extension metadata (prepackbuilds dist for npm publish)
- TypeScript strict mode (
tsconfig.json:strict: true),module/moduleResolutionNodeNext,targetES2022 - ESM (
"type": "module"); scripts are.mjs, no.d.tsis shipped intentionally - No linter/formatter configured — match surrounding code style manually
- Unit tests:
npm test(Vitest,test/modelMapping.test.ts) — covers the projection, the dynamic model resolver, and a drift guard that compares the manifestmodelCatalogagainst the baseline projection - Discovery smoke:
node scripts/smoke.discovery.mjs(hits the live public endpoint) - Live inference:
node scripts/live-test.mjs(reads the key from~/.openclaw/secrets/providers.json, never prints it) - Baseline refresh:
node scripts/generate-baseline.mjs(rewritessrc/baseline.models.tsand themodelCatalogblock ofopenclaw.plugin.jsonfrom the same projection asprojectModelinindex.ts— keep the two in sync), thennpm run buildto refreshdist/ - CI also fails when the committed
dist/does not match a fresh build — always rebuild before committing source changes - Add tests for every new behavior; all tests must pass before opening a PR
- Branch from
main; never push to it directly - Commit message: conventional commits (
feat:/fix:/docs:/refactor:) - Open PR once CI (
typecheck+build+test) is green
- Never commit secrets —
.envand.env.*are in.gitignore - The API key is read from the
COMMAND_CODE_API_KEYenv var (or the user's auth profile / provider config) only; never hardcode it