The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 01:30 UTC
fix(server): parse CLI versions with a "v" prefix (#11738)
NikodemNowak committed
Sep 14, 2026 at 18:15 UTC
955b787e6b9fb8666e84abfa6868671859d72f7e
2 files changed
+31
-1
apps/server/src/provider/providerSnapshot.test.ts
+24
@@ -11,6 +11,7 @@ import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
11
12
import {
13
isCommandMissingCause,
14
+ parseGenericCliVersion,
15
providerModelsFromSettings,
16
spawnAndCollect,
17
} from "./providerSnapshot.ts";
@@ -93,6 +94,29 @@ describe("providerModelsFromSettings", () => {
94
});
95
});
96
97
+describe("parseGenericCliVersion", () => {
98
+ it("parses a bare version", () => {
99
+ expect(parseGenericCliVersion("1.14.19")).toBe("1.14.19");
100
+ });
101
+
102
+ it("parses a v-prefixed version", () => {
103
+ expect(parseGenericCliVersion("opencode v2.0.3")).toBe("2.0.3");
104
+ expect(parseGenericCliVersion("v22.19.0")).toBe("22.19.0");
105
+ });
106
+
107
+ it("parses a version embedded in other output", () => {
108
+ expect(parseGenericCliVersion("codex-cli 0.53.0 (build abc)")).toBe("0.53.0");
109
+ });
110
+
111
+ it("returns null when no version is present", () => {
112
+ expect(parseGenericCliVersion("no version here")).toBeNull();
113
+ });
114
+
115
+ it("ignores versions glued to other word characters", () => {
116
+ expect(parseGenericCliVersion("build2.0.3artifact")).toBeNull();
117
+ });
118
+});
119
+
120
describe("ProviderCommandNotFoundError", () => {
121
it("classifies normalized platform failures without parsing messages", () => {
122
expect(
apps/server/src/provider/providerSnapshot.ts
+7
-1
@@ -107,8 +107,14 @@ export const spawnAndCollect = (binaryPath: string, command: ChildProcess.Comman
107
return result;
108
}).pipe(Effect.scoped);
109
110
+/**
111
+ * Return the first semantic version found in CLI output, or null. Accepts a
112
+ * leading "v" (for example `opencode v2.0.3`).
113
+ */
114
export function parseGenericCliVersion(output: string): string | null {
111
- const match = output.match(/\b(\d+\.\d+\.\d+)\b/);
115
+ // "opencode v2.0.3"-style output: the optional "v" has to be consumed first,
116
+ // since "v2" itself contains no word boundary.
117
+ const match = output.match(/\bv?(\d+\.\d+\.\d+)\b/);
118
return match?.[1] ?? null;
119
}
120