@telsoncc/opencode-commandcode 1.2.32 → 1.2.34
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 +6 -220
- package/_version.txt +1 -1
- package/dist/_version.txt +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +19 -0
- package/dist/manifest.json +28 -0
- package/dist/models.json +3334 -0
- package/dist/plugin-opencode2.d.ts +30 -0
- package/dist/plugin-opencode2.js +127 -0
- package/dist/plugin.d.ts +27 -0
- package/dist/plugin.js +192 -0
- package/dist/src/auth.d.ts +5 -0
- package/dist/src/auth.js +38 -0
- package/dist/src/catalog-break.d.ts +12 -0
- package/dist/src/catalog-break.js +33 -0
- package/dist/src/catalog-release-notes.d.ts +30 -0
- package/dist/src/catalog-release-notes.js +106 -0
- package/dist/src/catalog.d.ts +160 -0
- package/dist/src/catalog.js +786 -0
- package/dist/src/convert.d.ts +71 -0
- package/dist/src/convert.js +154 -0
- package/dist/src/costs-docs.d.ts +13 -0
- package/dist/src/costs-docs.js +170 -0
- package/dist/src/costs-models-dev.d.ts +68 -0
- package/dist/src/costs-models-dev.js +303 -0
- package/dist/src/cut-changelog.d.ts +1 -0
- package/dist/src/cut-changelog.js +43 -0
- package/dist/src/manifest.d.ts +72 -0
- package/dist/src/manifest.js +111 -0
- package/dist/src/model.d.ts +18 -0
- package/dist/src/model.js +138 -0
- package/dist/src/opencode2.d.ts +179 -0
- package/dist/src/opencode2.js +386 -0
- package/dist/src/pack-contract.d.ts +25 -0
- package/dist/src/pack-contract.js +42 -0
- package/dist/src/publish-policy.d.ts +18 -0
- package/dist/src/publish-policy.js +16 -0
- package/dist/src/startup.d.ts +18 -0
- package/dist/src/startup.js +31 -0
- package/dist/src/stream.d.ts +2 -0
- package/dist/src/stream.js +203 -0
- package/manifest.json +7 -7
- package/models.json +38 -66
- package/package.json +12 -7
- package/plugin.ts +14 -3
- package/src/cut-changelog.ts +6 -1
- package/src/opencode2.ts +14 -3
- package/src/pack-contract.ts +51 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
2
|
+
import { homedir } from "os";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
export function pluginStateDir() {
|
|
5
|
+
const override = process.env.COMMANDCODE_PROVIDER_STATE_DIR?.trim();
|
|
6
|
+
if (override)
|
|
7
|
+
return override;
|
|
8
|
+
return join(homedir(), ".local/state/opencode/commandcode-provider");
|
|
9
|
+
}
|
|
10
|
+
export function readCatalogCache(dir = pluginStateDir()) {
|
|
11
|
+
const path = join(dir, "catalog-cache.json");
|
|
12
|
+
if (!existsSync(path))
|
|
13
|
+
return null;
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
16
|
+
if (!Array.isArray(parsed) || parsed.length === 0)
|
|
17
|
+
return null;
|
|
18
|
+
return parsed;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function writeCatalogCache(dir, models) {
|
|
25
|
+
mkdirSync(dir, { recursive: true });
|
|
26
|
+
writeFileSync(join(dir, "catalog-cache.json"), JSON.stringify(models) + "\n", "utf-8");
|
|
27
|
+
}
|
|
28
|
+
export function writeStartupSummary(dir, summary) {
|
|
29
|
+
mkdirSync(dir, { recursive: true });
|
|
30
|
+
writeFileSync(join(dir, "startup.json"), JSON.stringify(summary) + "\n", "utf-8");
|
|
31
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
function mapFinishReason(raw) {
|
|
2
|
+
switch (raw) {
|
|
3
|
+
case "stop":
|
|
4
|
+
case "end_turn":
|
|
5
|
+
return "stop";
|
|
6
|
+
case "tool_calls":
|
|
7
|
+
case "tool-calls":
|
|
8
|
+
return "tool-calls";
|
|
9
|
+
case "length":
|
|
10
|
+
case "max_tokens":
|
|
11
|
+
case "max-tokens":
|
|
12
|
+
case "max_output_tokens":
|
|
13
|
+
return "length";
|
|
14
|
+
case "content_filter":
|
|
15
|
+
return "content-filter";
|
|
16
|
+
default:
|
|
17
|
+
return "other";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function mapUsage(raw) {
|
|
21
|
+
const inputDetails = (raw.inputTokenDetails ?? raw.input_token_details ?? {});
|
|
22
|
+
const outputDetails = (raw.outputTokenDetails ?? raw.output_token_details ?? {});
|
|
23
|
+
return {
|
|
24
|
+
inputTokens: {
|
|
25
|
+
total: typeof raw.inputTokens === "number"
|
|
26
|
+
? raw.inputTokens
|
|
27
|
+
: typeof raw.prompt_tokens === "number"
|
|
28
|
+
? raw.prompt_tokens
|
|
29
|
+
: undefined,
|
|
30
|
+
noCache: typeof inputDetails.noCacheTokens === "number" ? inputDetails.noCacheTokens : undefined,
|
|
31
|
+
cacheRead: typeof inputDetails.cacheReadTokens === "number" ? inputDetails.cacheReadTokens : undefined,
|
|
32
|
+
cacheWrite: typeof inputDetails.cacheWriteTokens === "number"
|
|
33
|
+
? inputDetails.cacheWriteTokens
|
|
34
|
+
: undefined,
|
|
35
|
+
},
|
|
36
|
+
outputTokens: {
|
|
37
|
+
total: typeof raw.outputTokens === "number"
|
|
38
|
+
? raw.outputTokens
|
|
39
|
+
: typeof raw.completion_tokens === "number"
|
|
40
|
+
? raw.completion_tokens
|
|
41
|
+
: undefined,
|
|
42
|
+
text: typeof outputDetails.textTokens === "number" ? outputDetails.textTokens : undefined,
|
|
43
|
+
reasoning: typeof outputDetails.reasoningTokens === "number"
|
|
44
|
+
? outputDetails.reasoningTokens
|
|
45
|
+
: undefined,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function toStreamPart(event) {
|
|
50
|
+
switch (event.type) {
|
|
51
|
+
case "start":
|
|
52
|
+
return { type: "stream-start", warnings: [] };
|
|
53
|
+
case "text-start":
|
|
54
|
+
return { type: "text-start", id: event.id };
|
|
55
|
+
case "text-delta":
|
|
56
|
+
return {
|
|
57
|
+
type: "text-delta",
|
|
58
|
+
id: event.id,
|
|
59
|
+
delta: (event.text ?? event.delta ?? ""),
|
|
60
|
+
};
|
|
61
|
+
case "text-end":
|
|
62
|
+
return { type: "text-end", id: event.id };
|
|
63
|
+
case "reasoning-start":
|
|
64
|
+
return { type: "reasoning-start", id: event.id };
|
|
65
|
+
case "reasoning-delta":
|
|
66
|
+
return {
|
|
67
|
+
type: "reasoning-delta",
|
|
68
|
+
id: event.id,
|
|
69
|
+
delta: (event.text ?? event.delta ?? ""),
|
|
70
|
+
};
|
|
71
|
+
case "reasoning-end":
|
|
72
|
+
return { type: "reasoning-end", id: event.id };
|
|
73
|
+
case "tool-input-start":
|
|
74
|
+
return {
|
|
75
|
+
type: "tool-input-start",
|
|
76
|
+
id: event.id,
|
|
77
|
+
toolName: event.toolName,
|
|
78
|
+
dynamic: event.dynamic,
|
|
79
|
+
};
|
|
80
|
+
case "tool-input-delta":
|
|
81
|
+
return {
|
|
82
|
+
type: "tool-input-delta",
|
|
83
|
+
id: event.id,
|
|
84
|
+
delta: (event.delta ?? ""),
|
|
85
|
+
};
|
|
86
|
+
case "tool-input-end":
|
|
87
|
+
return { type: "tool-input-end", id: event.id };
|
|
88
|
+
case "tool-call": {
|
|
89
|
+
const input = event.input ?? event.args ?? event.arguments;
|
|
90
|
+
return {
|
|
91
|
+
type: "tool-call",
|
|
92
|
+
toolCallId: (event.toolCallId ?? event.id ?? ""),
|
|
93
|
+
toolName: event.toolName,
|
|
94
|
+
input: typeof input === "string" ? input : JSON.stringify(input ?? {}),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
case "finish-step": {
|
|
98
|
+
const usage = event.usage ?? event.totalUsage ?? {};
|
|
99
|
+
const rawReason = (event.finishReason ?? event.rawFinishReason ?? "stop");
|
|
100
|
+
return {
|
|
101
|
+
type: "finish",
|
|
102
|
+
finishReason: { unified: mapFinishReason(rawReason), raw: rawReason },
|
|
103
|
+
usage: mapUsage(typeof usage === "object" && usage !== null ? usage : {}),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
case "finish":
|
|
107
|
+
return null;
|
|
108
|
+
case "response-metadata":
|
|
109
|
+
return {
|
|
110
|
+
type: "response-metadata",
|
|
111
|
+
id: event.id,
|
|
112
|
+
modelId: event.modelId,
|
|
113
|
+
};
|
|
114
|
+
case "error":
|
|
115
|
+
return { type: "error", error: event.error ?? event.message ?? "Unknown error" };
|
|
116
|
+
default:
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Assumes line-delimited JSON over SSE: one JSON object per `data:` line.
|
|
121
|
+
// Multi-line `data:` fields are not supported — the buffer splits on `\n`.
|
|
122
|
+
export function parseStreamEvents(body) {
|
|
123
|
+
const reader = body.getReader();
|
|
124
|
+
const decoder = new TextDecoder();
|
|
125
|
+
let buffer = "";
|
|
126
|
+
return new ReadableStream({
|
|
127
|
+
async pull(controller) {
|
|
128
|
+
try {
|
|
129
|
+
while (true) {
|
|
130
|
+
const lines = buffer.split("\n");
|
|
131
|
+
// Strip trailing \r from Windows-style \r\n line endings
|
|
132
|
+
for (let i = 0; i < lines.length; i++) {
|
|
133
|
+
const line = lines[i];
|
|
134
|
+
if (line !== undefined && line.endsWith("\r"))
|
|
135
|
+
lines[i] = line.slice(0, -1);
|
|
136
|
+
}
|
|
137
|
+
buffer = lines.pop() ?? "";
|
|
138
|
+
for (const line of lines) {
|
|
139
|
+
const trimmed = line.trim();
|
|
140
|
+
if (!trimmed || trimmed.startsWith(":") || trimmed === "[DONE]")
|
|
141
|
+
continue;
|
|
142
|
+
let jsonStr = trimmed;
|
|
143
|
+
if (jsonStr.startsWith("data: "))
|
|
144
|
+
jsonStr = jsonStr.slice(6);
|
|
145
|
+
if (jsonStr.startsWith("data:"))
|
|
146
|
+
jsonStr = jsonStr.slice(5);
|
|
147
|
+
if (!jsonStr || jsonStr === "[DONE]")
|
|
148
|
+
continue;
|
|
149
|
+
let parsed;
|
|
150
|
+
try {
|
|
151
|
+
parsed = JSON.parse(jsonStr);
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// intentionally silent: skip malformed SSE lines
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (typeof parsed !== "object" || parsed === null || typeof parsed.type !== "string")
|
|
158
|
+
continue;
|
|
159
|
+
const part = toStreamPart(parsed);
|
|
160
|
+
if (part)
|
|
161
|
+
controller.enqueue(part);
|
|
162
|
+
}
|
|
163
|
+
const { done, value } = await reader.read();
|
|
164
|
+
if (done) {
|
|
165
|
+
if (buffer.trim()) {
|
|
166
|
+
const trimmed = buffer.trim();
|
|
167
|
+
if (trimmed && trimmed !== "[DONE]" && !trimmed.startsWith(":")) {
|
|
168
|
+
let jsonStr = trimmed;
|
|
169
|
+
if (jsonStr.startsWith("data: "))
|
|
170
|
+
jsonStr = jsonStr.slice(6);
|
|
171
|
+
if (jsonStr.startsWith("data:"))
|
|
172
|
+
jsonStr = jsonStr.slice(5);
|
|
173
|
+
try {
|
|
174
|
+
const parsed = JSON.parse(jsonStr);
|
|
175
|
+
if (typeof parsed === "object" &&
|
|
176
|
+
parsed !== null &&
|
|
177
|
+
typeof parsed.type === "string") {
|
|
178
|
+
const part = toStreamPart(parsed);
|
|
179
|
+
if (part)
|
|
180
|
+
controller.enqueue(part);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// intentionally silent: skip malformed final buffer
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
controller.close();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
buffer += decoder.decode(value, { stream: true });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
controller.enqueue({ type: "error", error: err });
|
|
196
|
+
controller.close();
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
cancel() {
|
|
200
|
+
reader.cancel();
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
}
|
package/manifest.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
4
|
-
"pluginVersion": "1.2.
|
|
5
|
-
"commandCodeVersion": "1.88.
|
|
6
|
-
"commandCodeTarball": "https://registry.npmjs.org/command-code/-/command-code-1.88.
|
|
7
|
-
"modelCount":
|
|
8
|
-
"reasoningModelCount":
|
|
3
|
+
"generatedAt": "2026-11-09T18:34:31.627Z",
|
|
4
|
+
"pluginVersion": "1.2.34",
|
|
5
|
+
"commandCodeVersion": "1.88.5",
|
|
6
|
+
"commandCodeTarball": "https://registry.npmjs.org/command-code/-/command-code-1.88.5.tgz",
|
|
7
|
+
"modelCount": 95,
|
|
8
|
+
"reasoningModelCount": 84,
|
|
9
9
|
"extraction": {
|
|
10
10
|
"modelCatalog": "ok",
|
|
11
11
|
"costCatalog": "docs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"costSources": {
|
|
15
15
|
"cli": 0,
|
|
16
|
-
"officialDocs":
|
|
16
|
+
"officialDocs": 95,
|
|
17
17
|
"thirdParty": 0,
|
|
18
18
|
"free": 0,
|
|
19
19
|
"fallback": 0,
|
package/models.json
CHANGED
|
@@ -750,42 +750,6 @@
|
|
|
750
750
|
"/responses"
|
|
751
751
|
]
|
|
752
752
|
},
|
|
753
|
-
{
|
|
754
|
-
"id": "reflection/beam:free",
|
|
755
|
-
"name": "Beam 1.0",
|
|
756
|
-
"tier": "open-source",
|
|
757
|
-
"reasoning": true,
|
|
758
|
-
"reasoningEfforts": [
|
|
759
|
-
"low",
|
|
760
|
-
"medium",
|
|
761
|
-
"high",
|
|
762
|
-
"xhigh",
|
|
763
|
-
"max"
|
|
764
|
-
],
|
|
765
|
-
"tool_call": true,
|
|
766
|
-
"cost": {
|
|
767
|
-
"input": 0,
|
|
768
|
-
"output": 0,
|
|
769
|
-
"cache_read": 0
|
|
770
|
-
},
|
|
771
|
-
"limit": {
|
|
772
|
-
"context": 1048576,
|
|
773
|
-
"output": 131072
|
|
774
|
-
},
|
|
775
|
-
"attachment": false,
|
|
776
|
-
"modalities": {
|
|
777
|
-
"input": [
|
|
778
|
-
"text"
|
|
779
|
-
],
|
|
780
|
-
"output": [
|
|
781
|
-
"text"
|
|
782
|
-
]
|
|
783
|
-
},
|
|
784
|
-
"supportedEndpoints": [
|
|
785
|
-
"/chat/completions",
|
|
786
|
-
"/responses"
|
|
787
|
-
]
|
|
788
|
-
},
|
|
789
753
|
{
|
|
790
754
|
"id": "stealth/crouton-alpha",
|
|
791
755
|
"name": "Crouton Alpha",
|
|
@@ -1033,6 +997,42 @@
|
|
|
1033
997
|
"/responses"
|
|
1034
998
|
]
|
|
1035
999
|
},
|
|
1000
|
+
{
|
|
1001
|
+
"id": "deepseek/deepseek-v4.1-flash-ultrafast",
|
|
1002
|
+
"name": "DeepSeek V4.1 Flash Ultrafast",
|
|
1003
|
+
"tier": "open-source",
|
|
1004
|
+
"reasoning": true,
|
|
1005
|
+
"reasoningEfforts": [
|
|
1006
|
+
"off",
|
|
1007
|
+
"low",
|
|
1008
|
+
"high",
|
|
1009
|
+
"max"
|
|
1010
|
+
],
|
|
1011
|
+
"tool_call": true,
|
|
1012
|
+
"cost": {
|
|
1013
|
+
"input": 2.4,
|
|
1014
|
+
"output": 9.6,
|
|
1015
|
+
"cache_read": 0.048
|
|
1016
|
+
},
|
|
1017
|
+
"limit": {
|
|
1018
|
+
"context": 1048576,
|
|
1019
|
+
"output": 65536
|
|
1020
|
+
},
|
|
1021
|
+
"attachment": true,
|
|
1022
|
+
"modalities": {
|
|
1023
|
+
"input": [
|
|
1024
|
+
"text",
|
|
1025
|
+
"image"
|
|
1026
|
+
],
|
|
1027
|
+
"output": [
|
|
1028
|
+
"text"
|
|
1029
|
+
]
|
|
1030
|
+
},
|
|
1031
|
+
"supportedEndpoints": [
|
|
1032
|
+
"/chat/completions",
|
|
1033
|
+
"/responses"
|
|
1034
|
+
]
|
|
1035
|
+
},
|
|
1036
1036
|
{
|
|
1037
1037
|
"id": "sakana/fugu-ultra",
|
|
1038
1038
|
"name": "Fugu Ultra",
|
|
@@ -2065,36 +2065,8 @@
|
|
|
2065
2065
|
"modalities": {
|
|
2066
2066
|
"input": [
|
|
2067
2067
|
"text",
|
|
2068
|
-
"image"
|
|
2069
|
-
|
|
2070
|
-
"output": [
|
|
2071
|
-
"text"
|
|
2072
|
-
]
|
|
2073
|
-
},
|
|
2074
|
-
"supportedEndpoints": [
|
|
2075
|
-
"/chat/completions",
|
|
2076
|
-
"/responses"
|
|
2077
|
-
]
|
|
2078
|
-
},
|
|
2079
|
-
{
|
|
2080
|
-
"id": "poolside/laguna-s-2.1-free",
|
|
2081
|
-
"name": "Laguna S 2.1",
|
|
2082
|
-
"tier": "open-source",
|
|
2083
|
-
"reasoning": true,
|
|
2084
|
-
"tool_call": true,
|
|
2085
|
-
"cost": {
|
|
2086
|
-
"input": 0,
|
|
2087
|
-
"output": 0,
|
|
2088
|
-
"cache_read": 0
|
|
2089
|
-
},
|
|
2090
|
-
"limit": {
|
|
2091
|
-
"context": 256000,
|
|
2092
|
-
"output": 32768
|
|
2093
|
-
},
|
|
2094
|
-
"attachment": false,
|
|
2095
|
-
"modalities": {
|
|
2096
|
-
"input": [
|
|
2097
|
-
"text"
|
|
2068
|
+
"image",
|
|
2069
|
+
"pdf"
|
|
2098
2070
|
],
|
|
2099
2071
|
"output": [
|
|
2100
2072
|
"text"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telsoncc/opencode-commandcode",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.34",
|
|
4
4
|
"description": "Command Code API provider for opencode — use Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax, and Step models via Command Code",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"url": "git+https://github.com/telsoncc/opencode-commandcode.git"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
|
+
"dist/",
|
|
32
33
|
"index.ts",
|
|
33
34
|
"plugin.ts",
|
|
34
35
|
"plugin-opencode2.ts",
|
|
@@ -40,17 +41,20 @@
|
|
|
40
41
|
"src/"
|
|
41
42
|
],
|
|
42
43
|
"type": "module",
|
|
43
|
-
"main": "index.
|
|
44
|
-
"types": "index.ts",
|
|
44
|
+
"main": "dist/index.js",
|
|
45
|
+
"types": "dist/index.d.ts",
|
|
45
46
|
"exports": {
|
|
46
47
|
".": {
|
|
47
|
-
"
|
|
48
|
+
"types": "./dist/index.d.ts",
|
|
49
|
+
"import": "./dist/index.js"
|
|
48
50
|
},
|
|
49
51
|
"./server": {
|
|
50
|
-
"
|
|
52
|
+
"types": "./dist/plugin-opencode2.d.ts",
|
|
53
|
+
"import": "./dist/plugin-opencode2.js"
|
|
51
54
|
},
|
|
52
55
|
"./plugin/opencode2": {
|
|
53
|
-
"
|
|
56
|
+
"types": "./dist/plugin-opencode2.d.ts",
|
|
57
|
+
"import": "./dist/plugin-opencode2.js"
|
|
54
58
|
}
|
|
55
59
|
},
|
|
56
60
|
"publishConfig": {
|
|
@@ -66,7 +70,8 @@
|
|
|
66
70
|
"test:integration": "bun test tests/integration/",
|
|
67
71
|
"test:all": "bun test",
|
|
68
72
|
"typecheck": "tsc --noEmit",
|
|
69
|
-
"
|
|
73
|
+
"build": "bun run scripts/build.ts",
|
|
74
|
+
"prepack": "bun run build && bun run scripts/verify-manifest-version.ts",
|
|
70
75
|
"verify:release-candidate": "bun run scripts/verify-release-candidate.ts",
|
|
71
76
|
"generate-readme": "bun run scripts/generate-readme.ts",
|
|
72
77
|
"sync": "bun run scripts/sync-models.ts",
|
package/plugin.ts
CHANGED
|
@@ -16,9 +16,20 @@ import {
|
|
|
16
16
|
import type { CatalogManifest } from "./src/manifest.js";
|
|
17
17
|
|
|
18
18
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
// Repo layout keeps the catalog next to plugin.ts; published builds emit
|
|
21
|
+
// dist/plugin.js and ship the catalog inside dist/ (and at the package root).
|
|
22
|
+
function resolveAsset(name: string): string {
|
|
23
|
+
for (const dir of [__dirname, dirname(__dirname)]) {
|
|
24
|
+
const candidate = join(dir, name);
|
|
25
|
+
if (existsSync(candidate)) return candidate;
|
|
26
|
+
}
|
|
27
|
+
return join(__dirname, name);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const MODELS_PATH = resolveAsset("models.json");
|
|
31
|
+
const VERSION_PATH = resolveAsset("_version.txt");
|
|
32
|
+
const MANIFEST_PATH = resolveAsset("manifest.json");
|
|
22
33
|
|
|
23
34
|
interface PluginFileConfig {
|
|
24
35
|
disableModelSync?: boolean;
|
package/src/cut-changelog.ts
CHANGED
|
@@ -26,11 +26,16 @@ export function cutKeepAChangelog(markdown: string, version: string, date: strin
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const before = lines.slice(0, start + 1).join("");
|
|
30
29
|
const body = lines
|
|
31
30
|
.slice(start + 1, end)
|
|
32
31
|
.join("")
|
|
33
32
|
.replace(/^\n+/, "\n");
|
|
33
|
+
// Nothing was written under [Unreleased] since the last cut: emitting a
|
|
34
|
+
// heading here would only add an empty version section. Releases are also
|
|
35
|
+
// described on GitHub (semantic-release catalog notes), so skip the cut.
|
|
36
|
+
if (body.trim() === "") return markdown;
|
|
37
|
+
|
|
38
|
+
const before = lines.slice(0, start + 1).join("");
|
|
34
39
|
const after = lines.slice(end).join("");
|
|
35
40
|
return `${before}\n## [${version}] - ${date}\n${body}${after}`;
|
|
36
41
|
}
|
package/src/opencode2.ts
CHANGED
|
@@ -43,9 +43,20 @@ export const COMMANDCODE_ANTHROPIC_PACKAGE = "@opencode/ai/providers/anthropic-c
|
|
|
43
43
|
export const COMMANDCODE_ENV_NAMES = ["COMMANDCODE_API_KEY"];
|
|
44
44
|
|
|
45
45
|
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
|
|
47
|
+
// Repo layout: src/../ is the package root. Published builds: dist/src/../ is
|
|
48
|
+
// dist/ (catalog copied at build time) with the package root one level above.
|
|
49
|
+
function resolveAsset(name: string): string {
|
|
50
|
+
for (const dir of [join(MODULE_DIR, ".."), join(MODULE_DIR, "..", "..")]) {
|
|
51
|
+
const candidate = join(dir, name);
|
|
52
|
+
if (existsSync(candidate)) return candidate;
|
|
53
|
+
}
|
|
54
|
+
return join(MODULE_DIR, "..", name);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const MODELS_PATH = resolveAsset("models.json");
|
|
58
|
+
const VERSION_PATH = resolveAsset("_version.txt");
|
|
59
|
+
const MANIFEST_PATH = resolveAsset("manifest.json");
|
|
49
60
|
|
|
50
61
|
export type V2Cost = {
|
|
51
62
|
tier?: { type: "context"; size: number };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract between `package.json` and the files a `npm pack` tarball actually
|
|
3
|
+
* ships. The published entrypoints point at compiled output (`dist/`), so a
|
|
4
|
+
* pack that skips the build — or a `files` list that drops `dist/` — produces
|
|
5
|
+
* a package whose imports fail at runtime on hosts without a TypeScript
|
|
6
|
+
* loader (the opencode IDE server runs plain Node inside Electron).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type PackPackageJson = {
|
|
10
|
+
main?: string;
|
|
11
|
+
types?: string;
|
|
12
|
+
exports?: Record<string, string | { import?: string; types?: string }>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Normalize `tar -tzf` output, which uses CRLF on Windows and LF on Linux. */
|
|
16
|
+
export function parseTarListing(listing: string): string[] {
|
|
17
|
+
return listing
|
|
18
|
+
.split(/\r?\n/)
|
|
19
|
+
.filter(Boolean)
|
|
20
|
+
.map((entry) => entry.replace(/^package\//, ""));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Every file `package.json` promises to resolve, relative to the package root.
|
|
25
|
+
* `main` and each `exports` target are included so a build regression cannot
|
|
26
|
+
* ship silently.
|
|
27
|
+
*/
|
|
28
|
+
export function declaredEntrypoints(pkg: PackPackageJson): string[] {
|
|
29
|
+
const targets: string[] = [];
|
|
30
|
+
const push = (value: string | undefined): void => {
|
|
31
|
+
if (typeof value !== "string") return;
|
|
32
|
+
targets.push(value.replace(/^\.\//, ""));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
push(pkg.main);
|
|
36
|
+
for (const entry of Object.values(pkg.exports ?? {})) {
|
|
37
|
+
if (typeof entry === "string") {
|
|
38
|
+
push(entry);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
push(entry.import);
|
|
42
|
+
push(entry.types);
|
|
43
|
+
}
|
|
44
|
+
return [...new Set(targets)];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Entrypoints declared by `package.json` but absent from the tarball. */
|
|
48
|
+
export function missingEntrypoints(packageJson: PackPackageJson, packed: string[]): string[] {
|
|
49
|
+
const present = new Set(packed);
|
|
50
|
+
return declaredEntrypoints(packageJson).filter((entry) => !present.has(entry));
|
|
51
|
+
}
|