From cc115e23da5810c574d7419d19e066ecf69f80ef Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Wed, 11 Mar 2026 06:14:45 -0400 Subject: [PATCH 1/2] fix: use short version for integration branches When building from an integration branch (integration/YYYY-MM-DD-HH-MM), automatically extract and use the timestamp from the branch name instead of generating a long preview version string. This allows users to build integration branches without explicitly setting OPENCODE_VERSION and still get a clean version display. --- packages/script/src/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/script/src/index.ts b/packages/script/src/index.ts index ee4bc1e46502..6016441cfda2 100644 --- a/packages/script/src/index.ts +++ b/packages/script/src/index.ts @@ -32,7 +32,15 @@ const IS_PREVIEW = CHANNEL !== "latest" const VERSION = await (async () => { if (env.OPENCODE_VERSION) return env.OPENCODE_VERSION - if (IS_PREVIEW) return `0.0.0-${CHANNEL}-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` + if (IS_PREVIEW) { + // Check if we're on an integration branch and extract the timestamp + const integrationMatch = CHANNEL.match(/^integration\/(\d{4}-\d{2}-\d{2}-\d{2}-\d{2})$/) + if (integrationMatch) { + return integrationMatch[1] // Return just the timestamp (e.g., "2026-03-08-21-02") + } + // Otherwise use the old preview format for other branches + return `0.0.0-${CHANNEL}-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}` + } const version = await fetch("https://registry.npmjs.org/opencode-ai/latest") .then((res) => { if (!res.ok) throw new Error(res.statusText) From ed562248bae4d8376e243c291632bcad67e1a70e Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Tue, 24 Mar 2026 17:57:21 -0400 Subject: [PATCH 2/2] test: add regression tests for integration branch short version format These tests verify that the build script correctly extracts the short version format from integration branch names and will fail if the feature is accidentally removed during future merges. The tests check for: - Integration branch regex pattern exists - Code checks for integration match and returns short version - Fallback to old preview format for non-integration branches --- packages/opencode/test/script/version.test.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 packages/opencode/test/script/version.test.ts diff --git a/packages/opencode/test/script/version.test.ts b/packages/opencode/test/script/version.test.ts new file mode 100644 index 000000000000..ef75c3162989 --- /dev/null +++ b/packages/opencode/test/script/version.test.ts @@ -0,0 +1,27 @@ +import { describe, expect, test } from "bun:test" +import { readFileSync } from "fs" +import { join } from "path" + +describe("build script version format", () => { + const scriptPath = join( + __dirname, + "../../../script/src/index.ts", + ) + + test("script must contain integration branch regex pattern", () => { + const content = readFileSync(scriptPath, "utf-8") + expect(content).toContain('/^integration\\/(\\d{4}-\\d{2}-\\d{2}-\\d{2}-\\d{2})$/') + }) + + test("script must check for integration match and return short version", () => { + const content = readFileSync(scriptPath, "utf-8") + expect(content).toContain('const integrationMatch = CHANNEL.match') + expect(content).toContain('if (integrationMatch)') + expect(content).toContain('return integrationMatch[1]') + }) + + test("script must fall back to old preview format for non-integration branches", () => { + const content = readFileSync(scriptPath, "utf-8") + expect(content).toContain('0.0.0-${CHANNEL}') + }) +})