opencode-agent-orchestration-kit 1.1.1 → 1.2.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.
@@ -139,6 +139,34 @@ test("OpenCode TUI changes the default model and persists on q", async () => {
139
139
  assert.match(output.writes.join(""), /Loading models/);
140
140
  });
141
141
 
142
+ test("OpenCode TUI reports a failed service restart as a saved warning on q", async () => {
143
+ const input = createTuiInput();
144
+ const output = { isTTY: true, rows: 30, writes: [], write(chunk) { this.writes.push(String(chunk)); } };
145
+ const state = {
146
+ schemaVersion: 1,
147
+ defaultModel: "nan/model-a",
148
+ smallModel: "nan/model-a",
149
+ agents: Object.fromEntries(AGENT_IDS.map((agent) => [agent, "nan/model-a"])),
150
+ };
151
+ const running = runTerminalOcSwitcher({
152
+ input,
153
+ output,
154
+ initialState: state,
155
+ initialModels: ["nan/model-a"],
156
+ refreshModels: async () => ["nan/model-a"],
157
+ saveState: async () => {
158
+ throw Object.assign(new Error("Saved. Run `opencode service restart` to apply the new models."), { saved: true });
159
+ },
160
+ });
161
+
162
+ await nextTick();
163
+ emitKey(input, "q");
164
+ const result = await running;
165
+
166
+ assert.equal(result.status, "saved");
167
+ assert.match(result.warning, /opencode service restart/);
168
+ });
169
+
142
170
  test("OpenCode TUI changes the focused agent model", async () => {
143
171
  const input = createTuiInput();
144
172
  const output = { isTTY: true, rows: 30, writes: [], write(chunk) { this.writes.push(String(chunk)); } };
@@ -224,6 +252,7 @@ test("uses the local OpenCode model cache until an explicit refresh", async () =
224
252
  await switcher.refreshModels({ forceRefresh: true });
225
253
 
226
254
  assert.deepEqual(calls, [
255
+ ["/opt/opencode/bin/opencode", "--version"],
227
256
  ["/opt/opencode/bin/opencode", "auth", "list"],
228
257
  ["/opt/opencode/bin/opencode", "models", "--pure"],
229
258
  ["/opt/opencode/bin/opencode", "auth", "list"],
@@ -231,6 +260,83 @@ test("uses the local OpenCode model cache until an explicit refresh", async () =
231
260
  ]);
232
261
  });
233
262
 
263
+ test("reads the OpenCode 2 catalog without the removed --pure and --refresh flags", async () => {
264
+ const calls = [];
265
+ const switcher = createOcSwitcher({
266
+ homeDir: "/tmp/oc-switch-test-home",
267
+ env: { OPENCODE_MODEL: "openai/model-a" },
268
+ resolve: async () => "/opt/opencode/bin/opencode",
269
+ command: async (args) => {
270
+ calls.push(args);
271
+ if (args[1] === "--version") return "opencode v2.4.1\n";
272
+ return "openai/model-a\nopencode-go/model-b\nxai/model-c\n";
273
+ },
274
+ });
275
+
276
+ assert.deepEqual(await switcher.refreshModels(), ["openai/model-a", "opencode-go/model-b", "xai/model-c"]);
277
+ await switcher.refreshModels({ forceRefresh: true });
278
+
279
+ assert.deepEqual(calls, [
280
+ ["/opt/opencode/bin/opencode", "--version"],
281
+ ["/opt/opencode/bin/opencode", "models"],
282
+ ["/opt/opencode/bin/opencode", "models"],
283
+ ]);
284
+ });
285
+
286
+ function saveWithVersion(version, { restartFails = false } = {}) {
287
+ const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), "oc-switch-save-"));
288
+ const calls = [];
289
+ const switcher = createOcSwitcher({
290
+ homeDir,
291
+ env: { OPENCODE_MODEL: "openai/model-a", PATH: "/usr/bin" },
292
+ shell: "/bin/zsh",
293
+ resolve: async () => "/opt/opencode/bin/opencode",
294
+ command: async (args, options = {}) => {
295
+ calls.push({ args, env: options.env });
296
+ if (args[1] === "--version") return `${version}\n`;
297
+ if (args[1] === "service" && restartFails) throw new Error("OpenCode command unavailable");
298
+ return "";
299
+ },
300
+ });
301
+ const state = applyModelSelection(switcher.loadState(), { target: "defaultModel", modelRef: "opencode-go/model-b" });
302
+ return { homeDir, calls, saving: switcher.saveState(state) };
303
+ }
304
+
305
+ test("restarts the OpenCode 2 background service with the saved models", async () => {
306
+ const { homeDir, calls, saving } = saveWithVersion("opencode v2.4.1");
307
+ try {
308
+ await saving;
309
+ assert.match(fs.readFileSync(path.join(homeDir, ".zshrc"), "utf8"), /OPENCODE_MODEL='opencode-go\/model-b'/);
310
+ const restart = calls.find((call) => call.args[1] === "service");
311
+ assert.deepEqual(restart.args, ["/opt/opencode/bin/opencode", "service", "restart"]);
312
+ assert.equal(restart.env.OPENCODE_MODEL, "opencode-go/model-b");
313
+ assert.equal(restart.env.OPENCODE_LEAD_MODEL, "openai/model-a");
314
+ assert.equal(restart.env.PATH, "/usr/bin");
315
+ } finally {
316
+ fs.rmSync(homeDir, { recursive: true, force: true });
317
+ }
318
+ });
319
+
320
+ test("does not restart a service on OpenCode 1", async () => {
321
+ const { homeDir, calls, saving } = saveWithVersion("1.19.6");
322
+ try {
323
+ await saving;
324
+ assert.equal(calls.some((call) => call.args[1] === "service"), false);
325
+ } finally {
326
+ fs.rmSync(homeDir, { recursive: true, force: true });
327
+ }
328
+ });
329
+
330
+ test("keeps the saved models when the OpenCode 2 service restart fails", async () => {
331
+ const { homeDir, saving } = saveWithVersion("opencode v2.4.1", { restartFails: true });
332
+ try {
333
+ await assert.rejects(saving, (error) => error.saved === true && /opencode service restart/.test(error.message));
334
+ assert.match(fs.readFileSync(path.join(homeDir, ".zshrc"), "utf8"), /OPENCODE_MODEL='opencode-go\/model-b'/);
335
+ } finally {
336
+ fs.rmSync(homeDir, { recursive: true, force: true });
337
+ }
338
+ });
339
+
234
340
  test("finds OpenCode directly on PATH without starting a login shell", () => {
235
341
  const directory = fs.mkdtempSync(path.join(os.tmpdir(), "oc-switch-path-"));
236
342
  const binary = path.join(directory, "opencode");
@@ -18,7 +18,7 @@ import {
18
18
 
19
19
  const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
20
20
  const HASH = "a".repeat(64);
21
- const BASENAME = "opencode-agent-orchestration-kit-1.1.1.tgz";
21
+ const BASENAME = "opencode-agent-orchestration-kit-1.2.1.tgz";
22
22
  const REQUIRED = [
23
23
  "package/package.json",
24
24
  "package/supply-chain.json",
@@ -228,7 +228,7 @@ test("smokeTarball checks the tracked set before extraction", async () => {
228
228
  await assert.rejects(
229
229
  smokeTarball({
230
230
  repositoryRoot: ROOT,
231
- tarball: "/public/opencode-agent-orchestration-kit-1.1.1.tgz",
231
+ tarball: "/public/opencode-agent-orchestration-kit-1.2.1.tgz",
232
232
  captureTarball(_source, destination) {
233
233
  fs.writeFileSync(destination, "fixture");
234
234
  return { size: 1 };
@@ -253,7 +253,7 @@ test("smokeTarball validates both archive listings before extraction", async ()
253
253
  await assert.rejects(
254
254
  smokeTarball({
255
255
  repositoryRoot: ROOT,
256
- tarball: "/public/opencode-agent-orchestration-kit-1.1.1.tgz",
256
+ tarball: "/public/opencode-agent-orchestration-kit-1.2.1.tgz",
257
257
  captureTarball(_source, destination) {
258
258
  fs.writeFileSync(destination, "fixture");
259
259
  return { size: 1 };
@@ -109,7 +109,7 @@ test("[V004] direct version entrypoints are exact and mutation-free", (t) => {
109
109
  for (const args of [["scripts/version.mjs"], ["scripts/manage-installation.mjs", "--version"]]) {
110
110
  const result = run(process.execPath, args, { HOME: home });
111
111
  assert.equal(result.status, 0, result.stderr);
112
- assert.equal(result.stdout, "opencode-agent-orchestration-kit 1.1.1\n");
112
+ assert.equal(result.stdout, "opencode-agent-orchestration-kit 1.2.1\n");
113
113
  assert.equal(fs.existsSync(target), false);
114
114
  }
115
115
  });
@@ -118,7 +118,7 @@ test("[V005] all lifecycle wrappers expose the canonical version", () => {
118
118
  for (const wrapper of ["install.sh", "upgrade.sh", "doctor.sh", "uninstall.sh", "rollback.sh"]) {
119
119
  const result = run(path.join(REPOSITORY_ROOT, wrapper), ["--version"]);
120
120
  assert.equal(result.status, 0, `${wrapper}: ${result.stderr}`);
121
- assert.equal(result.stdout, "opencode-agent-orchestration-kit 1.1.1\n", wrapper);
121
+ assert.equal(result.stdout, "opencode-agent-orchestration-kit 1.2.1\n", wrapper);
122
122
  }
123
123
  });
124
124
 
package/supply-chain.json CHANGED
@@ -25,7 +25,11 @@
25
25
  },
26
26
  "npm_overrides": {
27
27
  "@babel/core": "7.29.7",
28
- "brace-expansion": "5.0.9",
29
- "uuid": "14.0.0"
28
+ "brace-expansion": "5.0.12",
29
+ "effect": "4.0.7",
30
+ "glob": "14.0.2",
31
+ "seroval": "1.6.12",
32
+ "seroval-plugins": "1.6.12",
33
+ "zod": "4.6.7"
30
34
  }
31
35
  }