Release CI ran check-stage.mjs on the packaged opencode only after
electron-builder, and on a tag `--publish always` has by then uploaded every
installer and stable*.yml to the draft release, so an opencode that signing
broke reached the draft first. An afterSign hook, scripts/opencode/after-sign.mjs,
now runs the same check once the app is signed, and on macOS notarized, and a
failure stops electron-builder before any target is built. macOS and Windows
call it on every build, signed or not; Linux signs nothing and skips it, so the
post-build CI step stays as its check.
The pinned opencode-darwin-arm64 arrives Developer ID signed by Anomaly
Innovations, with the hardened runtime, a secure timestamp and the five
entitlements Bun asks for. osx-sign force-signed it with the app's inherited
entitlements, which lack disable-executable-page-protection, and the release's
--version smoke barely runs Bun's JIT. mac.signIgnore now leaves opencode's
signature in place; rg arrives only ad-hoc signed and is still signed with the
app.
packaging.md also had Windows wrong: opencode.exe arrives Authenticode-signed
by its vendor and rg.exe unsigned, and a tag's build replaces both with
SurfSense's signature, so a dry run does not run an unsigned opencode.
With opencode on by default, any SURFSENSE_LOCAL_OPENCODE_ENABLED other than
"1" turned it off: "true", "yes", and the empty string an unset CI variable
gives all built an installer without the agent, and stage.mjs blamed "=0" as
it removed the stage. Now unset or empty keeps the default, 1 and 0 decide,
and anything else stops the build. The off message prints the value it read.
Now that every installer carries the agent, a release that ships without it,
or with an opencode that signing broke, would pass CI. Each runner now runs
check-stage.mjs on the opencode folder its build packaged: both executables and
their licences are there, and opencode and rg report their pinned versions.
On macOS that runs the copy signed under the hardened runtime, and on a tag's
Windows build the copy Azure signed. stage.mjs runs the same check before its
swap.
Every model may now choose the agent, so every build stages opencode and
ripgrep: ENABLED_BY_DEFAULT is true, and SURFSENSE_LOCAL_OPENCODE_ENABLED=0
leaves them out of one build. The docs that said installers carry no agent now
say they do, and packaging.md records the Windows stage's size (185 MB
unpacked, 44 MB as xz) and that electron-builder signs opencode and rg with the
app's inherited entitlements, whose allow-jit Bun needs.
Each stage script runs its new binary from the stage folder, then renames the folder into place. On Windows another process can still have a file in it open for a moment (on my machine, the DiagTrack service reading opencode.exe), so the rename failed with EPERM every time. The swap now retries that rename on EPERM, EACCES or EBUSY for up to 60 s, the same window graceful-fs uses.