@@ -19,6 +19,14 @@ const SOURCE_REPOSITORY = "anomalyco/opencode";
1919const SOURCE_VERSION = "1.3.13" ;
2020const SOURCE_TARBALL_URL = `https://github.com/${ SOURCE_REPOSITORY } /archive/refs/tags/v${ SOURCE_VERSION } .tar.gz` ;
2121
22+ // Upstream `packages/app/package.json` pins `ghostty-web: github:anomalyco/ghostty-web#main`,
23+ // but the bundled bun.lock snapshots the SHA below. Because `main` is a moving ref, a fresh
24+ // `bun install --frozen-lockfile` resolves to whatever `main` points at *now* and fails the
25+ // lockfile check. Rewriting the manifest to the lockfile's SHA before install keeps frozen-
26+ // lockfile guarantees intact (i.e. CI still breaks loudly if either side drifts) without
27+ // trusting arbitrary new HEADs on the ghostty-web branch.
28+ const GHOSTTY_WEB_PINNED_SHA = "4af877d" ;
29+
2230const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
2331const packageDir = resolve ( __dirname , ".." ) ;
2432const distDir = resolve ( packageDir , "dist" ) ;
@@ -47,6 +55,20 @@ function run(command, args, options = {}) {
4755 return result ;
4856}
4957
58+ function pinGhosttyWebRef ( sourceRoot ) {
59+ const manifestPath = resolve ( sourceRoot , "packages" , "app" , "package.json" ) ;
60+ const raw = readFileSync ( manifestPath , "utf-8" ) ;
61+ const movingRef = '"ghostty-web": "github:anomalyco/ghostty-web#main"' ;
62+ const pinnedRef = `"ghostty-web": "github:anomalyco/ghostty-web#${ GHOSTTY_WEB_PINNED_SHA } "` ;
63+ if ( raw . includes ( pinnedRef ) ) return ;
64+ if ( ! raw . includes ( movingRef ) ) {
65+ throw new Error (
66+ `Expected ghostty-web ref ${ movingRef } in ${ manifestPath } ; upstream layout changed — re-audit GHOSTTY_WEB_PINNED_SHA before updating.` ,
67+ ) ;
68+ }
69+ writeFileSync ( manifestPath , raw . replace ( movingRef , pinnedRef ) ) ;
70+ }
71+
5072const PATCHED_SOURCE_FILES = [
5173 "packages/opencode/src/cli/cmd/acp.ts" ,
5274 "packages/opencode/src/config/config.ts" ,
@@ -3550,6 +3572,7 @@ async function main() {
35503572 }
35513573
35523574 run ( "tar" , [ "-xzf" , tarballPath , "--strip-components=1" , "-C" , sourceRoot ] ) ;
3575+ pinGhosttyWebRef ( sourceRoot ) ;
35533576 run ( bunBin , [ "install" , "--frozen-lockfile" ] , { cwd : sourceRoot } ) ;
35543577 await ensureNodeAcpPatch ( sourceRoot , tarballPath ) ;
35553578 await applyNodeAcpRuntimeTweaks ( sourceRoot ) ;
0 commit comments