@brainervirus/opencode-commandcode 0.9.1 → 0.10.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 +23 -9
- package/_version.txt +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +117 -19
- package/dist/src/catalog.d.ts +14 -2
- package/dist/src/costs-models-dev.d.ts +25 -6
- package/dist/src/publish-policy.d.ts +0 -1
- package/dist/src/schemas.d.ts +27 -0
- package/dist/src/v2models.d.ts +8 -1
- package/manifest.json +7 -7
- package/models.json +1058 -130
- package/package.json +1 -1
- package/plugin.ts +18 -4
- package/src/catalog.ts +82 -7
- package/src/costs-models-dev.ts +161 -14
- package/src/publish-policy.ts +3 -4
- package/src/schemas.ts +33 -1
- package/src/v2models.ts +42 -8
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
[Command Code](https://commandcode.ai) API provider for [opencode](https://opencode.ai). Use Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax, Step, and other models through a single API key.
|
|
8
8
|
|
|
9
|
+
This plugin is for Command Code accounts with Provider API access. GOAT is the live-tested baseline; other API-enabled plans can use models their account is entitled to. The $1 Go plan has no Provider API access. The catalog follows the provider-wide model list, so a model appearing in OpenCode does not imply that every account can call it. See [GOAT plan details](https://commandcode.ai/docs/plans/goat) and [Provider API docs](https://commandcode.ai/docs/provider).
|
|
10
|
+
|
|
9
11
|
This package keeps a **bundled** model catalog current via CI. You do **not** need a local `command-code` CLI. Catalog patches publish automatically after a green PR merges to `main`.
|
|
10
12
|
|
|
11
13
|
Previously published as `@brainervirus/commandcode-go-opencode-provider`. Use this name instead.
|
|
@@ -17,44 +19,56 @@ This package is based on **[FanFan4204/opencode-commandcode-provider](https://gi
|
|
|
17
19
|
### What this package adds
|
|
18
20
|
|
|
19
21
|
- Bundled `models.json` is the default runtime catalog (no local CLI scrape).
|
|
20
|
-
-
|
|
22
|
+
- V1 and V2 use their native plugin and provider surfaces. V1 `server()` fills `provider.commandcode` and registers API-key auth; V2 `setup()` registers provider/model transforms and a key/env integration for `/connect` and `opencode auth login`.
|
|
21
23
|
- Validation at the boundaries via `src/schemas.ts` (zod): bundled `models.json` / `manifest.json` reads, provider availability payloads, and the plugin config file.
|
|
22
24
|
- 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`.
|
|
23
25
|
- 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.
|
|
24
26
|
- Reasoning effort **variants** on models that declare `reasoningEfforts`.
|
|
27
|
+
- Release date, family, input limits, model status, vendor context limits, and matched context-price tiers flow through the bundled catalog. V2 gets native release, family, input, status, and tier fields; V1 keeps its supported fields and base prices, with `context_over_200k` where representable.
|
|
28
|
+
- The provider's `supported_endpoints` metadata chooses each model's API route. Responses-capable models use `@ai-sdk/openai` on V1 and `aisdk:@ai-sdk/openai` on V2; Claude falls back to Anthropic Messages when endpoint metadata is absent. The V1 and V2 Responses mappings passed official Docker checks against a local mock stream, and a GOAT-key DeepSeek control request succeeded in OpenCode V2. Claude Sonnet 4.6 returned `MODEL_NOT_IN_PLAN` with the message “available in Pro and above plans or extra on-demand usage”; this confirms the account restriction, not successful Anthropic routing. Entitled Claude access has not been live-verified. If a model fails on an account entitled to use it, please [open an issue](https://github.com/BrainerVirus/opencode-commandcode/issues) with the model ID and OpenCode version, or submit a PR with a reproducible fix.
|
|
25
29
|
- Quiet OpenCode startup (diagnostics go to `startup.json`, not stdout).
|
|
26
30
|
|
|
27
31
|
## How it works
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
For published plugin versions, the six-hour CI schedule extracts the latest `command-code` npm bundle and refreshes callable models plus endpoint metadata, even when the CLI version is unchanged. It opens a catalog PR only when generated artifacts change; at startup the plugin loads those artifacts and registers them with OpenCode — never the other way around.
|
|
30
34
|
|
|
31
35
|
- **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
|
-
- **
|
|
36
|
+
- **Metadata + costs merge** — vendor context length tightens only a fallback context limit, while `supported_endpoints` selects Chat Completions, Responses, or Messages per model; missing endpoint metadata preserves the last known route data. models.dev contributes release date, family, input limit, status, modalities, and cost tiers when present. Tier rows are accepted only when their base prices match this Command Code catalog. Base costs use CLI bundle → 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 metadata or prices.
|
|
33
37
|
- **Artifacts** — `models.json` (the catalog), `_version.txt` (upstream version), `manifest.json` (counts, per-source cost stats, `healthy`/`degraded`/`broken` status).
|
|
34
|
-
- **
|
|
38
|
+
- **Version-specific registration** — V1 uses the `plugin` config key, `server()` provider map, and V1 auth callback. V2 uses `plugins`, provider/model transforms, and a `commandcode` integration with key and `COMMANDCODE_API_KEY` environment methods. Both retain the Command Code wire model ID. V2 exposes tiered context pricing; V1 emits its supported `context_over_200k` field and keeps flat pricing for other tiers.
|
|
35
39
|
- **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
40
|
|
|
37
41
|
## Quick Start
|
|
38
42
|
|
|
39
43
|
### 1. Install the plugin
|
|
40
44
|
|
|
45
|
+
OpenCode V2:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"plugins": ["@brainervirus/opencode-commandcode@latest"]
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
OpenCode V1:
|
|
54
|
+
|
|
41
55
|
```json
|
|
42
56
|
{
|
|
43
57
|
"plugin": ["@brainervirus/opencode-commandcode@latest"]
|
|
44
58
|
}
|
|
45
59
|
```
|
|
46
60
|
|
|
47
|
-
Pin a version instead of `@latest` if you do not want automatic catalog patches.
|
|
61
|
+
Pin a version instead of `@latest` if you do not want automatic catalog patches.
|
|
48
62
|
|
|
49
63
|
`file://` checkouts are **not** updated by npm; `git pull` after CI commits, or switch to the npm plugin line.
|
|
50
64
|
|
|
51
65
|
### 2. No provider block needed
|
|
52
66
|
|
|
53
|
-
On OpenCode V2 the plugin registers the `commandcode` provider
|
|
67
|
+
On OpenCode V2 the plugin registers the `commandcode` provider, its models, and its API base URL through the V2 provider API. On V1 the `server` hook fills `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 entry if you need non-default transport options.
|
|
54
68
|
|
|
55
69
|
### 3. Connect
|
|
56
70
|
|
|
57
|
-
Set `COMMANDCODE_API_KEY`, or
|
|
71
|
+
Set `COMMANDCODE_API_KEY`, or connect interactively. OpenCode V1 provides **Command Code** through `/connect`; OpenCode V2 registers key and environment methods for `/connect` and `opencode auth login commandcode`. V2 uses OpenCode's automatic provider activation and preserves an explicit activation setting. Connect before running a model; an explicit run while disconnected still returns an authorization error from the API.
|
|
58
72
|
|
|
59
73
|
### 4. Select a model
|
|
60
74
|
|
|
@@ -97,9 +111,9 @@ bun run generate-readme # reports catalog counts only; README is hand-edited
|
|
|
97
111
|
bun run catalog:ci # entry used by the catalog-sync workflow
|
|
98
112
|
```
|
|
99
113
|
|
|
100
|
-
Entry points: `plugin.ts` owns
|
|
114
|
+
Entry points: `plugin.ts` owns both config surfaces (V2 `id`/`setup` plus V1 `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
115
|
|
|
102
|
-
CI (`.github/workflows/catalog-sync.yml`) opens a `fix(catalog)` PR
|
|
116
|
+
CI (`.github/workflows/catalog-sync.yml`) checks every 6 hours for CLI catalog changes and provider availability/endpoint metadata changes; it opens a `fix(catalog)` PR only when generated files change. If extraction fails or the model-count safety floor is breached, it opens a `catalog-break` issue and leaves the last-good files intact. 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`.
|
|
103
117
|
|
|
104
118
|
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.
|
|
105
119
|
|
package/_version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.68.0
|
package/dist/plugin.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare function server(): Promise<{
|
|
|
35
35
|
}>;
|
|
36
36
|
};
|
|
37
37
|
}>;
|
|
38
|
-
/** V2 setup: provider inventory
|
|
38
|
+
/** V2 setup: provider inventory, models, and API-key integration through transforms. */
|
|
39
39
|
declare function setup(ctx: any): Promise<void>;
|
|
40
40
|
declare const _default: {
|
|
41
41
|
server: typeof server;
|
package/dist/plugin.js
CHANGED
|
@@ -19405,12 +19405,30 @@ var ModelEntrySchema = exports_external.strictObject({
|
|
|
19405
19405
|
input: exports_external.number(),
|
|
19406
19406
|
output: exports_external.number(),
|
|
19407
19407
|
cache_read: exports_external.number().optional(),
|
|
19408
|
-
cache_write: exports_external.number().optional()
|
|
19408
|
+
cache_write: exports_external.number().optional(),
|
|
19409
|
+
context_over_200k: exports_external.strictObject({
|
|
19410
|
+
input: exports_external.number(),
|
|
19411
|
+
output: exports_external.number(),
|
|
19412
|
+
cache_read: exports_external.number().optional(),
|
|
19413
|
+
cache_write: exports_external.number().optional()
|
|
19414
|
+
}).optional(),
|
|
19415
|
+
tiers: exports_external.array(exports_external.strictObject({
|
|
19416
|
+
input: exports_external.number(),
|
|
19417
|
+
output: exports_external.number(),
|
|
19418
|
+
cache_read: exports_external.number().optional(),
|
|
19419
|
+
cache_write: exports_external.number().optional(),
|
|
19420
|
+
tier: exports_external.strictObject({ type: exports_external.literal("context"), size: exports_external.number().int().positive() })
|
|
19421
|
+
})).optional()
|
|
19409
19422
|
}),
|
|
19410
19423
|
limit: exports_external.strictObject({
|
|
19411
19424
|
context: exports_external.number().int(),
|
|
19425
|
+
input: exports_external.number().int().optional(),
|
|
19412
19426
|
output: exports_external.number().int()
|
|
19413
19427
|
}),
|
|
19428
|
+
family: exports_external.string().min(1).optional(),
|
|
19429
|
+
supported_endpoints: exports_external.array(exports_external.string().min(1)).optional(),
|
|
19430
|
+
release_date: exports_external.iso.date().optional(),
|
|
19431
|
+
status: exports_external.enum(["active", "beta", "deprecated"]).optional(),
|
|
19414
19432
|
attachment: exports_external.boolean().optional(),
|
|
19415
19433
|
modalities: exports_external.strictObject({
|
|
19416
19434
|
input: exports_external.array(exports_external.string()),
|
|
@@ -19451,7 +19469,11 @@ var ManifestSchema = exports_external.strictObject({
|
|
|
19451
19469
|
});
|
|
19452
19470
|
var AvailabilityPayloadSchema = exports_external.object({
|
|
19453
19471
|
object: exports_external.literal("list"),
|
|
19454
|
-
data: exports_external.array(exports_external.object({
|
|
19472
|
+
data: exports_external.array(exports_external.object({
|
|
19473
|
+
id: exports_external.string().min(1),
|
|
19474
|
+
context_length: exports_external.number().int().positive().optional().catch(undefined),
|
|
19475
|
+
supported_endpoints: exports_external.array(exports_external.string().min(1)).optional().catch(undefined)
|
|
19476
|
+
})).min(1)
|
|
19455
19477
|
}).superRefine((payload, ctx) => {
|
|
19456
19478
|
const seen = new Set;
|
|
19457
19479
|
for (const item of payload.data) {
|
|
@@ -19837,7 +19859,7 @@ function buildCostMap(costs) {
|
|
|
19837
19859
|
}
|
|
19838
19860
|
return map2;
|
|
19839
19861
|
}
|
|
19840
|
-
function buildModelEntry(entry, costMap) {
|
|
19862
|
+
function buildModelEntry(entry, costMap, vendorContextLength) {
|
|
19841
19863
|
const provider = entry.provider || "unknown";
|
|
19842
19864
|
const tier = TIER_MAP[provider] ?? "open-source";
|
|
19843
19865
|
const costEntry = costMap.get(entry.id);
|
|
@@ -19855,8 +19877,9 @@ function buildModelEntry(entry, costMap) {
|
|
|
19855
19877
|
cost = { input: 0.5, output: 2 };
|
|
19856
19878
|
}
|
|
19857
19879
|
const fallback = FALLBACK_LIMITS[entry.id];
|
|
19880
|
+
const context = entry.contextWindow ?? fallback?.context ?? 200000;
|
|
19858
19881
|
const limit = {
|
|
19859
|
-
context: entry.contextWindow
|
|
19882
|
+
context: entry.contextWindow === undefined && vendorContextLength !== undefined ? Math.min(context, vendorContextLength) : context,
|
|
19860
19883
|
output: entry.maxOutputTokens ?? fallback?.output ?? 65536
|
|
19861
19884
|
};
|
|
19862
19885
|
const efforts = entry.reasoningEfforts?.length ? [...entry.reasoningEfforts] : undefined;
|
|
@@ -19907,7 +19930,7 @@ function sortModelEntries(entries) {
|
|
|
19907
19930
|
return a.name.localeCompare(b.name);
|
|
19908
19931
|
});
|
|
19909
19932
|
}
|
|
19910
|
-
function loadCatalogFromBundle(source) {
|
|
19933
|
+
function loadCatalogFromBundle(source, vendorContextLengths) {
|
|
19911
19934
|
const models = extractModelCatalog(source);
|
|
19912
19935
|
let costMap = new Map;
|
|
19913
19936
|
try {
|
|
@@ -19917,13 +19940,13 @@ function loadCatalogFromBundle(source) {
|
|
|
19917
19940
|
for (const model of Object.values(models)) {
|
|
19918
19941
|
if (!model || typeof model !== "object" || typeof model.id !== "string")
|
|
19919
19942
|
continue;
|
|
19920
|
-
const entry = buildModelEntry(model, costMap);
|
|
19943
|
+
const entry = buildModelEntry(model, costMap, vendorContextLengths?.get(model.id.toLowerCase()));
|
|
19921
19944
|
if (entry)
|
|
19922
19945
|
entries.push(entry);
|
|
19923
19946
|
}
|
|
19924
19947
|
for (const extra of HARDCODED_EXTRAS) {
|
|
19925
19948
|
if (!entries.some((e) => e.id === extra.id)) {
|
|
19926
|
-
const entry = buildModelEntry(extra, costMap);
|
|
19949
|
+
const entry = buildModelEntry(extra, costMap, vendorContextLengths?.get(extra.id.toLowerCase()));
|
|
19927
19950
|
if (entry)
|
|
19928
19951
|
entries.push(entry);
|
|
19929
19952
|
}
|
|
@@ -20065,7 +20088,7 @@ function loadCatalogFromLocalCommandCodeResult(options, deps = liveEnv) {
|
|
|
20065
20088
|
}
|
|
20066
20089
|
let models;
|
|
20067
20090
|
try {
|
|
20068
|
-
models = loadCatalogFromBundle(source);
|
|
20091
|
+
models = loadCatalogFromBundle(source, options?.vendorContextLengths);
|
|
20069
20092
|
} catch (error62) {
|
|
20070
20093
|
return errResult(`local command-code catalog failed to evaluate: ${causeMessage(error62)}`);
|
|
20071
20094
|
}
|
|
@@ -20086,6 +20109,23 @@ function toConfigKey(id) {
|
|
|
20086
20109
|
const short = slashIdx >= 0 ? id.slice(slashIdx + 1) : id;
|
|
20087
20110
|
return short.toLowerCase();
|
|
20088
20111
|
}
|
|
20112
|
+
function usesAnthropicMessagesApi(id) {
|
|
20113
|
+
return /(?:^|[/:])claude-/i.test(id);
|
|
20114
|
+
}
|
|
20115
|
+
function modelApi(entry) {
|
|
20116
|
+
const endpoints = entry.supported_endpoints;
|
|
20117
|
+
const supports = (route) => endpoints?.some((endpoint) => {
|
|
20118
|
+
const path = (endpoint.split(/[?#]/, 1)[0] ?? "").replace(/\/+$/, "");
|
|
20119
|
+
return path === route || path.endsWith(`/${route}`);
|
|
20120
|
+
}) ?? false;
|
|
20121
|
+
if (supports("responses"))
|
|
20122
|
+
return "responses";
|
|
20123
|
+
if (supports("messages"))
|
|
20124
|
+
return "messages";
|
|
20125
|
+
if (supports("chat/completions"))
|
|
20126
|
+
return "chat";
|
|
20127
|
+
return usesAnthropicMessagesApi(entry.id) ? "messages" : "chat";
|
|
20128
|
+
}
|
|
20089
20129
|
function generateOpencodeModels(entries) {
|
|
20090
20130
|
const models = {};
|
|
20091
20131
|
for (const entry of entries) {
|
|
@@ -20095,6 +20135,15 @@ function generateOpencodeModels(entries) {
|
|
|
20095
20135
|
costObj.cache_read = entry.cost.cache_read;
|
|
20096
20136
|
if (entry.cost.cache_write !== undefined)
|
|
20097
20137
|
costObj.cache_write = entry.cost.cache_write;
|
|
20138
|
+
const contextOver200k = entry.cost.context_over_200k ?? entry.cost.tiers?.find((tier) => tier.tier.type === "context" && tier.tier.size === 200000);
|
|
20139
|
+
if (contextOver200k) {
|
|
20140
|
+
costObj.context_over_200k = {
|
|
20141
|
+
input: contextOver200k.input,
|
|
20142
|
+
output: contextOver200k.output,
|
|
20143
|
+
...contextOver200k.cache_read !== undefined ? { cache_read: contextOver200k.cache_read } : {},
|
|
20144
|
+
...contextOver200k.cache_write !== undefined ? { cache_write: contextOver200k.cache_write } : {}
|
|
20145
|
+
};
|
|
20146
|
+
}
|
|
20098
20147
|
const model = {
|
|
20099
20148
|
id: entry.id,
|
|
20100
20149
|
name: entry.name,
|
|
@@ -20103,8 +20152,19 @@ function generateOpencodeModels(entries) {
|
|
|
20103
20152
|
attachment: entry.attachment ?? false,
|
|
20104
20153
|
modalities: entry.modalities ?? { input: ["text"], output: ["text"] },
|
|
20105
20154
|
cost: costObj,
|
|
20106
|
-
limit: entry.limit
|
|
20155
|
+
limit: entry.limit,
|
|
20156
|
+
status: entry.status ?? "active"
|
|
20107
20157
|
};
|
|
20158
|
+
if (entry.family !== undefined)
|
|
20159
|
+
model.family = entry.family;
|
|
20160
|
+
if (entry.release_date !== undefined)
|
|
20161
|
+
model.release_date = entry.release_date;
|
|
20162
|
+
const api2 = modelApi(entry);
|
|
20163
|
+
if (api2 === "responses") {
|
|
20164
|
+
model.provider = { npm: "@ai-sdk/openai" };
|
|
20165
|
+
} else if (api2 === "messages") {
|
|
20166
|
+
model.provider = { npm: "@ai-sdk/anthropic" };
|
|
20167
|
+
}
|
|
20108
20168
|
if (entry.reasoningEfforts && entry.reasoningEfforts.length > 0) {
|
|
20109
20169
|
model.reasoningEfforts = entry.reasoningEfforts;
|
|
20110
20170
|
const variants = {};
|
|
@@ -20162,11 +20222,19 @@ function v2Output(entry) {
|
|
|
20162
20222
|
}
|
|
20163
20223
|
function toV2Model(entry) {
|
|
20164
20224
|
const id = toConfigKey(entry.id);
|
|
20165
|
-
|
|
20225
|
+
const costTiers = [...entry.cost.tiers ?? []];
|
|
20226
|
+
if (entry.cost.context_over_200k && !costTiers.some((tier) => tier.tier.type === "context" && tier.tier.size === 200000)) {
|
|
20227
|
+
costTiers.push({
|
|
20228
|
+
...entry.cost.context_over_200k,
|
|
20229
|
+
tier: { type: "context", size: 200000 }
|
|
20230
|
+
});
|
|
20231
|
+
}
|
|
20232
|
+
const model = {
|
|
20166
20233
|
id,
|
|
20167
20234
|
modelID: entry.id,
|
|
20168
20235
|
providerID: "commandcode",
|
|
20169
20236
|
name: entry.name,
|
|
20237
|
+
...entry.family !== undefined ? { family: entry.family } : {},
|
|
20170
20238
|
capabilities: {
|
|
20171
20239
|
tools: entry.tool_call,
|
|
20172
20240
|
input: v2Input(entry),
|
|
@@ -20180,17 +20248,35 @@ function toV2Model(entry) {
|
|
|
20180
20248
|
read: entry.cost.cache_read ?? 0,
|
|
20181
20249
|
write: entry.cost.cache_write ?? 0
|
|
20182
20250
|
}
|
|
20183
|
-
}
|
|
20251
|
+
},
|
|
20252
|
+
...costTiers.map((tier) => ({
|
|
20253
|
+
input: tier.input,
|
|
20254
|
+
output: tier.output,
|
|
20255
|
+
cache: { read: tier.cache_read ?? 0, write: tier.cache_write ?? 0 },
|
|
20256
|
+
tier: { ...tier.tier }
|
|
20257
|
+
}))
|
|
20184
20258
|
],
|
|
20185
|
-
limit: {
|
|
20259
|
+
limit: {
|
|
20260
|
+
context: entry.limit.context,
|
|
20261
|
+
...entry.limit.input !== undefined ? { input: entry.limit.input } : {},
|
|
20262
|
+
output: entry.limit.output
|
|
20263
|
+
},
|
|
20186
20264
|
variants: (entry.reasoningEfforts ?? []).map((effort) => ({
|
|
20187
20265
|
id: effort,
|
|
20188
20266
|
settings: { reasoningEffort: effort }
|
|
20189
20267
|
})),
|
|
20190
|
-
status: "active",
|
|
20268
|
+
status: entry.status ?? "active",
|
|
20191
20269
|
enabled: true,
|
|
20192
|
-
time: {
|
|
20270
|
+
time: {
|
|
20271
|
+
released: entry.release_date ? Date.parse(`${entry.release_date}T00:00:00.000Z`) : 0
|
|
20272
|
+
}
|
|
20193
20273
|
};
|
|
20274
|
+
const api2 = modelApi(entry);
|
|
20275
|
+
if (api2 === "responses")
|
|
20276
|
+
model.package = "aisdk:@ai-sdk/openai";
|
|
20277
|
+
else if (api2 === "messages")
|
|
20278
|
+
model.package = "aisdk:@ai-sdk/anthropic";
|
|
20279
|
+
return model;
|
|
20194
20280
|
}
|
|
20195
20281
|
function generateV2Models(entries) {
|
|
20196
20282
|
return entries.map(toV2Model);
|
|
@@ -20466,11 +20552,12 @@ async function setup(ctx) {
|
|
|
20466
20552
|
info: {
|
|
20467
20553
|
id: "commandcode",
|
|
20468
20554
|
name: "Command Code",
|
|
20469
|
-
activation: "
|
|
20555
|
+
activation: "auto",
|
|
20556
|
+
integrationID: "commandcode",
|
|
20557
|
+
env: ["COMMANDCODE_API_KEY"],
|
|
20470
20558
|
package: `aisdk:${PROVIDER_SDK_NPM}`,
|
|
20471
20559
|
settings: {
|
|
20472
|
-
baseURL: PROVIDER_API_BASE_URL
|
|
20473
|
-
apiKey: "{env:COMMANDCODE_API_KEY}"
|
|
20560
|
+
baseURL: PROVIDER_API_BASE_URL
|
|
20474
20561
|
}
|
|
20475
20562
|
},
|
|
20476
20563
|
models: v2models
|
|
@@ -20479,16 +20566,27 @@ async function setup(ctx) {
|
|
|
20479
20566
|
}
|
|
20480
20567
|
editor.update("commandcode", (provider) => {
|
|
20481
20568
|
provider.name = provider.name ?? "Command Code";
|
|
20569
|
+
provider.activation = provider.activation ?? "auto";
|
|
20570
|
+
provider.integrationID = provider.integrationID ?? "commandcode";
|
|
20571
|
+
provider.env = provider.env ?? ["COMMANDCODE_API_KEY"];
|
|
20482
20572
|
provider.settings = provider.settings ?? {};
|
|
20483
20573
|
if (typeof provider.settings === "object") {
|
|
20484
20574
|
if (!provider.settings.baseURL)
|
|
20485
20575
|
provider.settings.baseURL = PROVIDER_API_BASE_URL;
|
|
20486
|
-
if (!provider.settings.apiKey)
|
|
20487
|
-
provider.settings.apiKey = "{env:COMMANDCODE_API_KEY}";
|
|
20488
20576
|
}
|
|
20489
20577
|
});
|
|
20490
20578
|
editor.models.set("commandcode", v2models);
|
|
20491
20579
|
});
|
|
20580
|
+
await ctx.integration.transform((editor) => {
|
|
20581
|
+
editor.method.update({
|
|
20582
|
+
integrationID: "commandcode",
|
|
20583
|
+
method: { type: "key", label: "API Key" }
|
|
20584
|
+
});
|
|
20585
|
+
editor.method.update({
|
|
20586
|
+
integrationID: "commandcode",
|
|
20587
|
+
method: { type: "env", names: ["COMMANDCODE_API_KEY"] }
|
|
20588
|
+
});
|
|
20589
|
+
});
|
|
20492
20590
|
}
|
|
20493
20591
|
var definition = { id: "commandcode", setup };
|
|
20494
20592
|
var plugin_default = { ...definition, server };
|
package/dist/src/catalog.d.ts
CHANGED
|
@@ -67,10 +67,10 @@ export declare function extractSpecConstants(source: string): {
|
|
|
67
67
|
export declare function extractModelCatalog(source: string, wt?: Record<string, string>, wtName?: string, spec?: ReturnType<typeof extractSpecConstants>): Record<string, SnEntry>;
|
|
68
68
|
export declare function extractCostData(source: string, wt?: Record<string, string>, wtName?: string): Record<string, CostEntry[]>;
|
|
69
69
|
export declare function buildCostMap(costs: Record<string, CostEntry[]>): Map<string, CostEntry>;
|
|
70
|
-
export declare function buildModelEntry(entry: SnEntry, costMap: Map<string, CostEntry
|
|
70
|
+
export declare function buildModelEntry(entry: SnEntry, costMap: Map<string, CostEntry>, vendorContextLength?: number): ModelEntry | null;
|
|
71
71
|
export declare function disambiguateModelNames(entries: ModelEntry[]): ModelEntry[];
|
|
72
72
|
export declare function sortModelEntries(entries: ModelEntry[]): ModelEntry[];
|
|
73
|
-
export declare function loadCatalogFromBundle(source: string): ModelEntry[];
|
|
73
|
+
export declare function loadCatalogFromBundle(source: string, vendorContextLengths?: ReadonlyMap<string, number>): ModelEntry[];
|
|
74
74
|
export declare function resolveCommandCodePackage(options?: {
|
|
75
75
|
packagePath?: string;
|
|
76
76
|
}, deps?: EnvDeps): ResolvedCommandCodePackage | null;
|
|
@@ -81,15 +81,25 @@ export declare function resolveCommandCodePackage(options?: {
|
|
|
81
81
|
*/
|
|
82
82
|
export declare function loadCatalogFromLocalCommandCodeResult(options?: {
|
|
83
83
|
packagePath?: string;
|
|
84
|
+
vendorContextLengths?: ReadonlyMap<string, number>;
|
|
84
85
|
}, deps?: EnvDeps): LoadResult<LocalCatalogResult | null>;
|
|
85
86
|
/** Compat wrapper: value-or-null for callers that only need fail-open. */
|
|
86
87
|
export declare function loadCatalogFromLocalCommandCode(options?: {
|
|
87
88
|
packagePath?: string;
|
|
89
|
+
vendorContextLengths?: ReadonlyMap<string, number>;
|
|
88
90
|
}): LocalCatalogResult | null;
|
|
89
91
|
/** Short OpenCode map / UI key. Wire id stays the catalog `entry.id` (vendor/…). */
|
|
90
92
|
export declare function toConfigKey(id: string): string;
|
|
93
|
+
export declare function usesAnthropicMessagesApi(id: string): boolean;
|
|
94
|
+
export type ModelApi = "chat" | "responses" | "messages";
|
|
95
|
+
export declare function modelApi(entry: Pick<ModelEntry, "id" | "supported_endpoints">): ModelApi;
|
|
91
96
|
export declare function generateOpencodeModels(entries: ModelEntry[]): Record<string, unknown>;
|
|
92
97
|
export declare const MODELS_API_URL = "https://api.commandcode.ai/provider/v1/models";
|
|
98
|
+
export type ProviderModelMetadata = {
|
|
99
|
+
id: string;
|
|
100
|
+
context_length?: number;
|
|
101
|
+
supported_endpoints?: string[];
|
|
102
|
+
};
|
|
93
103
|
export interface FilteredCatalog<T extends {
|
|
94
104
|
id: string;
|
|
95
105
|
}> {
|
|
@@ -98,6 +108,8 @@ export interface FilteredCatalog<T extends {
|
|
|
98
108
|
}
|
|
99
109
|
/** Validate the OpenAI-style `{ object: "list", data: [{ id }] }` availability payload. */
|
|
100
110
|
export declare function parseAvailabilityIds(payload: unknown): string[];
|
|
111
|
+
/** Parse the vendor model inventory, retaining its context limit when present. */
|
|
112
|
+
export declare function parseAvailabilityModels(payload: unknown): ProviderModelMetadata[];
|
|
101
113
|
/** Retain only candidates whose exact ID is callable; collect sorted excluded IDs. */
|
|
102
114
|
export declare function filterCatalogByAvailability<T extends {
|
|
103
115
|
id: string;
|
|
@@ -8,20 +8,37 @@ export declare const TEXT_ONLY_MODALITIES: {
|
|
|
8
8
|
readonly input: readonly ["text"];
|
|
9
9
|
readonly output: readonly ["text"];
|
|
10
10
|
};
|
|
11
|
+
export type ModelsDevPrice = {
|
|
12
|
+
input: number;
|
|
13
|
+
output: number;
|
|
14
|
+
cache_read?: number;
|
|
15
|
+
cache_write?: number;
|
|
16
|
+
};
|
|
17
|
+
export type ModelsDevContextTier = ModelsDevPrice & {
|
|
18
|
+
tier: {
|
|
19
|
+
type: "context";
|
|
20
|
+
size: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type ModelsDevCost = ModelsDevPrice & {
|
|
24
|
+
context_over_200k?: ModelsDevPrice;
|
|
25
|
+
tiers?: ModelsDevContextTier[];
|
|
26
|
+
};
|
|
11
27
|
export type ModelsDevRow = {
|
|
12
28
|
id: string;
|
|
13
29
|
name: string;
|
|
14
|
-
cost
|
|
15
|
-
input: number;
|
|
16
|
-
output: number;
|
|
17
|
-
cache_read?: number;
|
|
18
|
-
cache_write?: number;
|
|
19
|
-
};
|
|
30
|
+
cost?: ModelsDevCost;
|
|
20
31
|
attachment?: boolean;
|
|
21
32
|
modalities?: {
|
|
22
33
|
input: string[];
|
|
23
34
|
output: string[];
|
|
24
35
|
};
|
|
36
|
+
family?: string;
|
|
37
|
+
release_date?: string;
|
|
38
|
+
status?: "beta" | "deprecated";
|
|
39
|
+
limit?: {
|
|
40
|
+
input?: number;
|
|
41
|
+
};
|
|
25
42
|
};
|
|
26
43
|
export declare function isFreeSku(model: {
|
|
27
44
|
id: string;
|
|
@@ -30,5 +47,7 @@ export declare function isFreeSku(model: {
|
|
|
30
47
|
export declare function parseModelsDev(json: string): ModelsDevRow[];
|
|
31
48
|
export declare function applyFreeCosts(models: ModelEntry[], skipIds: Set<string>, filledIds?: Set<string>): number;
|
|
32
49
|
export declare function applyModelsDevModalities(models: ModelEntry[], rows: ModelsDevRow[]): number;
|
|
50
|
+
export declare function applyModelsDevMetadata(models: ModelEntry[], rows: ModelsDevRow[]): number;
|
|
51
|
+
export declare function applyModelsDevCostTiers(models: ModelEntry[], rows: ModelsDevRow[]): number;
|
|
33
52
|
export declare function applyModelsDevCosts(models: ModelEntry[], rows: ModelsDevRow[], skipIds: Set<string>, filledIds?: Set<string>): number;
|
|
34
53
|
export declare function fetchModelsDevJson(): Promise<string>;
|
package/dist/src/schemas.d.ts
CHANGED
|
@@ -15,11 +15,36 @@ export declare const ModelEntrySchema: z.ZodObject<{
|
|
|
15
15
|
output: z.ZodNumber;
|
|
16
16
|
cache_read: z.ZodOptional<z.ZodNumber>;
|
|
17
17
|
cache_write: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
context_over_200k: z.ZodOptional<z.ZodObject<{
|
|
19
|
+
input: z.ZodNumber;
|
|
20
|
+
output: z.ZodNumber;
|
|
21
|
+
cache_read: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
cache_write: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
}, z.core.$strict>>;
|
|
24
|
+
tiers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
25
|
+
input: z.ZodNumber;
|
|
26
|
+
output: z.ZodNumber;
|
|
27
|
+
cache_read: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
cache_write: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
tier: z.ZodObject<{
|
|
30
|
+
type: z.ZodLiteral<"context">;
|
|
31
|
+
size: z.ZodNumber;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
}, z.core.$strict>>>;
|
|
18
34
|
}, z.core.$strict>;
|
|
19
35
|
limit: z.ZodObject<{
|
|
20
36
|
context: z.ZodNumber;
|
|
37
|
+
input: z.ZodOptional<z.ZodNumber>;
|
|
21
38
|
output: z.ZodNumber;
|
|
22
39
|
}, z.core.$strict>;
|
|
40
|
+
family: z.ZodOptional<z.ZodString>;
|
|
41
|
+
supported_endpoints: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
release_date: z.ZodOptional<z.ZodISODate>;
|
|
43
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
44
|
+
active: "active";
|
|
45
|
+
beta: "beta";
|
|
46
|
+
deprecated: "deprecated";
|
|
47
|
+
}>>;
|
|
23
48
|
attachment: z.ZodOptional<z.ZodBoolean>;
|
|
24
49
|
modalities: z.ZodOptional<z.ZodObject<{
|
|
25
50
|
input: z.ZodArray<z.ZodString>;
|
|
@@ -82,6 +107,8 @@ export declare const AvailabilityPayloadSchema: z.ZodObject<{
|
|
|
82
107
|
object: z.ZodLiteral<"list">;
|
|
83
108
|
data: z.ZodArray<z.ZodObject<{
|
|
84
109
|
id: z.ZodString;
|
|
110
|
+
context_length: z.ZodCatch<z.ZodOptional<z.ZodNumber>>;
|
|
111
|
+
supported_endpoints: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
85
112
|
}, z.core.$strip>>;
|
|
86
113
|
}, z.core.$strip>;
|
|
87
114
|
/**
|
package/dist/src/v2models.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ export interface V2Model {
|
|
|
4
4
|
id: string;
|
|
5
5
|
modelID: string;
|
|
6
6
|
providerID: string;
|
|
7
|
+
package?: string;
|
|
7
8
|
name: string;
|
|
9
|
+
family?: string;
|
|
8
10
|
capabilities: {
|
|
9
11
|
tools: boolean;
|
|
10
12
|
input: string[];
|
|
@@ -17,16 +19,21 @@ export interface V2Model {
|
|
|
17
19
|
read: number;
|
|
18
20
|
write: number;
|
|
19
21
|
};
|
|
22
|
+
tier?: {
|
|
23
|
+
type: "context";
|
|
24
|
+
size: number;
|
|
25
|
+
};
|
|
20
26
|
}>;
|
|
21
27
|
limit: {
|
|
22
28
|
context: number;
|
|
29
|
+
input?: number;
|
|
23
30
|
output: number;
|
|
24
31
|
};
|
|
25
32
|
variants: Array<{
|
|
26
33
|
id: string;
|
|
27
34
|
settings: Record<string, unknown>;
|
|
28
35
|
}>;
|
|
29
|
-
status: "active";
|
|
36
|
+
status: "active" | "beta" | "deprecated";
|
|
30
37
|
enabled: boolean;
|
|
31
38
|
time: {
|
|
32
39
|
released: number;
|
package/manifest.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-09-
|
|
4
|
-
"pluginVersion": "0.
|
|
5
|
-
"commandCodeVersion": "1.
|
|
6
|
-
"commandCodeTarball": "https://registry.npmjs.org/command-code/-/command-code-1.
|
|
7
|
-
"modelCount":
|
|
8
|
-
"reasoningModelCount":
|
|
3
|
+
"generatedAt": "2026-09-29T00:01:39.017Z",
|
|
4
|
+
"pluginVersion": "0.10.1",
|
|
5
|
+
"commandCodeVersion": "1.68.0",
|
|
6
|
+
"commandCodeTarball": "https://registry.npmjs.org/command-code/-/command-code-1.68.0.tgz",
|
|
7
|
+
"modelCount": 84,
|
|
8
|
+
"reasoningModelCount": 71,
|
|
9
9
|
"extraction": {
|
|
10
10
|
"modelCatalog": "ok",
|
|
11
11
|
"costCatalog": "cli",
|
|
12
12
|
"costCatalogError": null
|
|
13
13
|
},
|
|
14
14
|
"costSources": {
|
|
15
|
-
"cli":
|
|
15
|
+
"cli": 29,
|
|
16
16
|
"officialDocs": 55,
|
|
17
17
|
"thirdParty": 0,
|
|
18
18
|
"free": 0,
|