Skip to content

Commit a7f32ba

Browse files
committed
feat(build): report version as upstream+hash (e.g. 1.17.18+6cdc4d7)
Script.version now reads packages/opencode/package.json for the upstream semver base and appends +{7-char git hash} via git rev-parse --short=7 HEAD. OPENCODE_VERSION env var still overrides when set. CLI lildax binary uses InstallationVersion instead of hardcoded 'local' for --version flag display.
1 parent 6cdc4d7 commit a7f32ba

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

packages/cli/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"
44
import * as NodeServices from "@effect/platform-node/NodeServices"
55
import * as Effect from "effect/Effect"
6+
import { InstallationVersion } from "@opencode-ai/core/installation/version"
67
import { Commands } from "./commands/commands"
78
import { Runtime } from "./framework/runtime"
89
import { Daemon } from "./services/daemon"
@@ -24,7 +25,7 @@ const Handlers = Runtime.handlers(Commands, {
2425
serve: () => import("./commands/handlers/serve"),
2526
})
2627

27-
Runtime.run(Commands, Handlers, { version: "local" }).pipe(
28+
Runtime.run(Commands, Handlers, { version: InstallationVersion }).pipe(
2829
Effect.provide(Daemon.layer),
2930
Effect.provide(NodeServices.layer),
3031
Effect.scoped,

packages/script/src/index.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,11 @@ const IS_PREVIEW = CHANNEL !== "latest"
3333

3434
const VERSION = await (async () => {
3535
if (env.OPENCODE_VERSION) return env.OPENCODE_VERSION
36-
if (IS_PREVIEW) return `0.0.0-${CHANNEL}-${new Date().toISOString().slice(0, 16).replace(/[-:T]/g, "")}`
37-
const version = await fetch("https://registry.npmjs.org/opencode-ai/latest")
38-
.then((res) => {
39-
if (!res.ok) throw new Error(res.statusText)
40-
return res.json()
41-
})
42-
.then((data: any) => data.version)
43-
const [major, minor, patch] = version.split(".").map((x: string) => Number(x) || 0)
44-
const t = env.OPENCODE_BUMP?.toLowerCase()
45-
if (t === "major") return `${major + 1}.0.0`
46-
if (t === "minor") return `${major}.${minor + 1}.0`
47-
return `${major}.${minor}.${patch + 1}`
36+
const subPkgPath = path.resolve(import.meta.dir, "../../opencode/package.json")
37+
const subPkg = await Bun.file(subPkgPath).json()
38+
const base: string = subPkg.version
39+
const hash = await $`git rev-parse --short=7 HEAD`.text().then((x) => x.trim())
40+
return `${base}+${hash}`
4841
})()
4942

5043
const bot = ["actions-user", "opencode", "opencode-agent[bot]"]

0 commit comments

Comments
 (0)