@brainervirus/opencode-commandcode 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +41 -26
- package/dist/index.d.ts +12 -0
- package/dist/plugin.d.ts +45 -0
- package/dist/plugin.js +21018 -0
- package/dist/src/auth.d.ts +5 -0
- package/dist/src/catalog-break.d.ts +12 -0
- package/dist/src/catalog-release-notes.d.ts +30 -0
- package/dist/src/catalog.d.ts +104 -0
- package/dist/src/convert.d.ts +71 -0
- package/dist/src/costs-docs.d.ts +13 -0
- package/dist/src/costs-models-dev.d.ts +34 -0
- package/dist/src/cut-changelog.d.ts +1 -0
- package/dist/src/entry.d.ts +3 -0
- package/dist/src/env.d.ts +13 -0
- package/dist/src/load-result.d.ts +17 -0
- package/dist/src/manifest.d.ts +54 -0
- package/dist/src/model.d.ts +18 -0
- package/dist/src/paths.d.ts +14 -0
- package/dist/src/publish-policy.d.ts +18 -0
- package/dist/src/schemas.d.ts +96 -0
- package/dist/src/startup.d.ts +22 -0
- package/dist/src/stream.d.ts +2 -0
- package/dist/src/v2models.d.ts +36 -0
- package/manifest.json +1 -1
- package/package.json +13 -10
- package/plugin.ts +142 -65
- package/src/catalog.ts +65 -73
- package/src/env.ts +25 -0
- package/src/load-result.ts +22 -0
- package/src/manifest.ts +3 -25
- package/src/schemas.ts +103 -0
- package/src/startup.ts +27 -13
- package/src/v2models.ts +3 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -17,12 +17,23 @@ This package is based on **[FanFan4204/opencode-commandcode-provider](https://gi
|
|
|
17
17
|
### What this package adds
|
|
18
18
|
|
|
19
19
|
- Bundled `models.json` is the default runtime catalog (no local CLI scrape).
|
|
20
|
-
-
|
|
21
|
-
-
|
|
20
|
+
- Dual OpenCode entry: V2 `setup` injects the provider plus models via transforms; V1 `server` fills `provider.commandcode` defaults plus models and registers API-key auth (auth stays V1-only).
|
|
21
|
+
- Validation at the boundaries via `src/schemas.ts` (zod): bundled `models.json` / `manifest.json` reads, provider availability payloads, and the plugin config file.
|
|
22
|
+
- CLI cost extraction can fail without dropping models; official docs fill missing costs, remaining paid gaps use [models.dev](https://models.dev) as a reference price at sync time. Command Code free SKUs stay `$0`.
|
|
22
23
|
- Vision vs text-only comes from the Command Code CLI catalog (`inputModalities` on every SKU). [models.dev](https://models.dev) only adds extra inputs (video/audio/pdf) when it matches.
|
|
23
24
|
- Reasoning effort **variants** on models that declare `reasoningEfforts`.
|
|
24
25
|
- Quiet OpenCode startup (diagnostics go to `startup.json`, not stdout).
|
|
25
26
|
|
|
27
|
+
## How it works
|
|
28
|
+
|
|
29
|
+
Each CI sync extracts the model catalog from the latest `command-code` npm bundle, merges costs, and commits versioned artifacts; at startup the plugin loads those artifacts and registers them with OpenCode — never the other way around.
|
|
30
|
+
|
|
31
|
+
- **Extract + filter** — model entries (ids, names, reasoning, `inputModalities`, limits) are evaluated out of the minified CLI bundle (`src/catalog.ts`), then intersected with the callable IDs reported by the provider API.
|
|
32
|
+
- **Costs merge** — per model, first hit wins: CLI bundle costs → official Command Code docs → free SKUs (`$0`) → [models.dev](https://models.dev) reference prices → unmatched placeholder. Anything still unmatched marks the catalog `degraded`. This runs at sync time only; runtime never fetches prices.
|
|
33
|
+
- **Artifacts** — `models.json` (the catalog), `_version.txt` (upstream version), `manifest.json` (counts, per-source cost stats, `healthy`/`degraded`/`broken` status).
|
|
34
|
+
- **V1 injection + V2 transform** — V1 `server()` fills `provider.commandcode` defaults and the models map; V2 `setup()` adds/updates the provider inventory (baseURL, API key binding) and sets models through `ctx.provider.transform`.
|
|
35
|
+
- **Degraded/cache fallbacks** — a `degraded`/`broken` manifest sets the degraded flag with a reason; an unreadable bundled `models.json` falls back to the last-good cache; auth/connect still registers even with an empty catalog.
|
|
36
|
+
|
|
26
37
|
## Quick Start
|
|
27
38
|
|
|
28
39
|
### 1. Install the plugin
|
|
@@ -33,33 +44,17 @@ This package is based on **[FanFan4204/opencode-commandcode-provider](https://gi
|
|
|
33
44
|
}
|
|
34
45
|
```
|
|
35
46
|
|
|
36
|
-
Pin a version instead of `@latest` if you do not want automatic catalog patches.
|
|
47
|
+
Pin a version instead of `@latest` if you do not want automatic catalog patches. The config key stays `plugin` in OpenCode V2 — there is no `plugins` key.
|
|
37
48
|
|
|
38
49
|
`file://` checkouts are **not** updated by npm; `git pull` after CI commits, or switch to the npm plugin line.
|
|
39
50
|
|
|
40
|
-
### 2.
|
|
51
|
+
### 2. No provider block needed
|
|
41
52
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```json
|
|
45
|
-
{
|
|
46
|
-
"plugin": ["@brainervirus/opencode-commandcode@latest"],
|
|
47
|
-
"provider": {
|
|
48
|
-
"commandcode": {
|
|
49
|
-
"npm": "@ai-sdk/openai-compatible",
|
|
50
|
-
"name": "Command Code GOAT",
|
|
51
|
-
"env": ["COMMANDCODE_API_KEY"],
|
|
52
|
-
"options": {
|
|
53
|
-
"baseURL": "https://api.commandcode.ai/provider/v1"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
```
|
|
53
|
+
On OpenCode V2 the plugin registers the `commandcode` provider itself (Provider API base URL plus `COMMANDCODE_API_KEY` binding) and its models. On V1 the `server` hook fills the same `provider.commandcode` defaults — `npm: "@ai-sdk/openai-compatible"` plus the Provider API `baseURL`; the plugin package itself is never the SDK `npm` field. Only add a manual `provider.commandcode` entry if you need non-default transport options.
|
|
59
54
|
|
|
60
55
|
### 3. Connect
|
|
61
56
|
|
|
62
|
-
|
|
57
|
+
Set `COMMANDCODE_API_KEY`, or on OpenCode V1 run `/connect`, search for **Command Code**, and enter your API key. V2 registers the provider with the env binding; the `/connect` API-key method is V1-only.
|
|
63
58
|
|
|
64
59
|
### 4. Select a model
|
|
65
60
|
|
|
@@ -67,6 +62,18 @@ Run `/connect` in opencode, search for **Command Code**, and enter your API key,
|
|
|
67
62
|
/models
|
|
68
63
|
```
|
|
69
64
|
|
|
65
|
+
Catalog patches arrive as plugin updates: `@latest` refreshes in the background and takes effect on the next OpenCode restart. If a new model is missing after an announced sync, restart opencode once.
|
|
66
|
+
|
|
67
|
+
## Plugin config file
|
|
68
|
+
|
|
69
|
+
Optional, `~/.config/opencode/opencode-commandcode.json` (legacy fallback name `commandcode-go-opencode-provider.json` still loads). Unknown keys are ignored; every field has a default.
|
|
70
|
+
|
|
71
|
+
| Key | Default | Effect |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `commandCodePackagePath` | `""` | Maintainer override: extract the catalog from a local `command-code` checkout instead of the bundle. Same as env `COMMANDCODE_PACKAGE_PATH`. |
|
|
74
|
+
| `debugStartupLogs` | `false` | Also mirror the startup summary to stderr. Default is quiet (`startup.json` only). |
|
|
75
|
+
| `disableModelSync` | `false` | Accepted for forward compatibility; currently has no effect. |
|
|
76
|
+
|
|
70
77
|
## Optional local CLI override
|
|
71
78
|
|
|
72
79
|
Maintainers only. OpenCode will scrape a local `command-code` install when `COMMANDCODE_PACKAGE_PATH` or `commandCodePackagePath` in `~/.config/opencode/opencode-commandcode.json` is set.
|
|
@@ -77,16 +84,24 @@ Maintainers only. OpenCode will scrape a local `command-code` install when `COMM
|
|
|
77
84
|
git clone https://github.com/BrainerVirus/opencode-commandcode.git
|
|
78
85
|
cd opencode-commandcode
|
|
79
86
|
bun install
|
|
80
|
-
bun run check # oxlint + oxfmt + bun test + tsc (
|
|
87
|
+
bun run check # oxlint + oxfmt --check + bun test tests/unit/ + tsc (the release gate)
|
|
81
88
|
```
|
|
82
89
|
|
|
83
90
|
```bash
|
|
84
|
-
bun run sync -- --remote # refresh models.json + manifest.json from command-code@latest
|
|
91
|
+
bun run sync -- --remote # refresh models.json + manifest.json + _version.txt from command-code@latest
|
|
92
|
+
bun run build # bundle src/entry.ts to dist/plugin.js
|
|
93
|
+
bun test tests/unit/ # unit suite (also via bun run test)
|
|
94
|
+
bun run test:integration # live-endpoint tests, not part of the gate
|
|
95
|
+
bun run verify:release-candidate # dry-run pack; manifest and package versions must match
|
|
96
|
+
bun run generate-readme # reports catalog counts only; README is hand-edited
|
|
97
|
+
bun run catalog:ci # entry used by the catalog-sync workflow
|
|
85
98
|
```
|
|
86
99
|
|
|
87
|
-
|
|
100
|
+
Entry points: `plugin.ts` owns all config-hook logic (dual default `{ id, setup }` plus `server`); `index.ts` re-exports the plugin plus the `createCommandCode` SDK factory; `src/entry.ts` is bundle glue for `scripts/build-plugin.ts` only — it produces `dist/plugin.js`.
|
|
101
|
+
|
|
102
|
+
CI (`.github/workflows/catalog-sync.yml`) opens a `fix(catalog)` PR every 6 hours when Command Code ships a new catalog; if extraction fails it opens a `catalog-break` issue instead. The PR auto-merges after **check (test)**, **check (typecheck)**, **check (lint)**, **check (format)**, and **check (pack)** are green. `.github/workflows/release.yml` then runs **semantic-release** (build + verified npm publish + GitHub Release + tag). Do not push to `main`.
|
|
88
103
|
|
|
89
|
-
The GitHub Actions secret name is `NPMJS
|
|
104
|
+
The GitHub Actions secret name is `NPMJS`. It is mapped to both `NPM_TOKEN` and `NODE_AUTH_TOKEN`. Use an npm **Automation** token (bypasses 2FA). A login token from `~/.npmrc` fails CI with `EOTP`. Catalog PRs get a real CI run when `RELEASE_SYNC_TOKEN` is a PAT; `GITHUB_TOKEN` can open the PR but GitHub will not start workflows from that event.
|
|
90
105
|
|
|
91
106
|
## License
|
|
92
107
|
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CommandCodeLanguageModel } from "./src/model.js";
|
|
2
|
+
export { default, server } from "./plugin.js";
|
|
3
|
+
export interface CommandCodeProviderOptions {
|
|
4
|
+
name?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
baseURL?: string;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
authPaths?: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function createCommandCode(options?: CommandCodeProviderOptions): {
|
|
11
|
+
languageModel(modelId: string): CommandCodeLanguageModel;
|
|
12
|
+
};
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ModelEntry } from "./src/catalog.js";
|
|
2
|
+
import { type EnvDeps } from "./src/env.js";
|
|
3
|
+
export type { ModelEntry };
|
|
4
|
+
export type CatalogLoad = {
|
|
5
|
+
models: ModelEntry[];
|
|
6
|
+
catalogSource: "bundled" | "cache" | "opt-in-local";
|
|
7
|
+
commandCodeVersion: string | null;
|
|
8
|
+
degraded: boolean;
|
|
9
|
+
degradedReason: string | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function loadCatalogEntries(deps?: EnvDeps): CatalogLoad;
|
|
12
|
+
/** V1 entrypoint (OpenCode 1.18.29+ also accepts it via `server`). */
|
|
13
|
+
export declare function server(): Promise<{
|
|
14
|
+
config: (config: Record<string, unknown>) => Promise<void>;
|
|
15
|
+
auth: {
|
|
16
|
+
provider: string;
|
|
17
|
+
methods: {
|
|
18
|
+
type: string;
|
|
19
|
+
label: string;
|
|
20
|
+
authorize: (inputs: Record<string, unknown> | undefined) => Promise<{
|
|
21
|
+
type: "failed";
|
|
22
|
+
key?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
type: "success";
|
|
25
|
+
key: string;
|
|
26
|
+
}>;
|
|
27
|
+
}[];
|
|
28
|
+
loader: (getAuth: () => Promise<{
|
|
29
|
+
type: string;
|
|
30
|
+
key?: string;
|
|
31
|
+
} | null>) => Promise<{
|
|
32
|
+
apiKey?: undefined;
|
|
33
|
+
} | {
|
|
34
|
+
apiKey: string;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
38
|
+
/** V2 setup: provider inventory + models through transforms. Auth stays V1-only for now. */
|
|
39
|
+
declare function setup(ctx: any): Promise<void>;
|
|
40
|
+
declare const _default: {
|
|
41
|
+
server: typeof server;
|
|
42
|
+
id: string;
|
|
43
|
+
setup: typeof setup;
|
|
44
|
+
};
|
|
45
|
+
export default _default;
|