Skip to content

Commit fcc678e

Browse files
only21milclaude
andcommitted
fix(opencode): unrecognized OpenCode installs no longer get a one-click update that can't run
T3 offered `opencode upgrade` for any OpenCode path outside node_modules, including shell launchers, distro packages and launchers in front of an `npm --prefix` install. OpenCode cannot detect how those were installed, so 1.x waits on an "Install anyways?" prompt until T3 times out and 2.x exits with "Could not detect the installation method". OpenCode's native update now requires its own installer's path (`~/.opencode/bin/opencode`), as Codex already does, so other installs show manual update guidance instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 15fe283 commit fcc678e

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎packages/provider-opencode/src/server/driver.test.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ const resolveUpdate = (generation: "v1" | "v2", binaryPath: string) =>
290290
);
291291

292292
it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
293-
"updates an npm-global OpenCode 2 install as @opencode/cli and a 1.x one as opencode-ai",
293+
"updates npm-global OpenCode by generation and runs upgrade only for its own installer's path",
294294
() =>
295295
Effect.gen(function* () {
296296
const root = NodeFS.realpathSync(
@@ -321,6 +321,21 @@ it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
321321
assert.isNull(
322322
(yield* resolveUpdate("v1", NodePath.join(v2Prefix, "bin", "opencode"))).update,
323323
);
324+
const executable = (...segments: ReadonlyArray<string>) => {
325+
const path = NodePath.join(root, ...segments);
326+
NodeFS.mkdirSync(NodePath.dirname(path), { recursive: true });
327+
NodeFS.writeFileSync(path, "#!/bin/sh\n");
328+
NodeFS.chmodSync(path, 0o755);
329+
return path;
330+
};
331+
const launcher = executable("launcher", "opencode");
332+
const native = executable(".opencode", "bin", "opencode");
333+
for (const generation of ["v1", "v2"] as const) {
334+
assert.isNull((yield* resolveUpdate(generation, launcher)).update);
335+
assert.deepStrictEqual((yield* resolveUpdate(generation, native)).update?.args, [
336+
"upgrade",
337+
]);
338+
}
324339
}),
325340
);
326341

‎packages/provider-opencode/src/server/driver.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const openCodeUpdateFor = (generation: ProbedOpenCode["generation"]) =>
8383
nativeUpdate: {
8484
args: ["upgrade"],
8585
isCommandPath: isOpenCodeNativeCommandPath,
86+
requiresCommandPath: true,
8687
},
8788
});
8889

0 commit comments

Comments
 (0)