Compare commits

..

No commits in common. "dev" and "github-v1.2.27" have entirely different histories.

12896 changed files with 492500 additions and 1581570 deletions

25
.gitattributes vendored
View file

@ -1,30 +1,5 @@
packages/core/migration/**/snapshot.json linguist-generated
packages/core/src/database/migration.gen.ts linguist-generated
packages/core/src/models-dev/snapshot.txt linguist-generated
packages/core/src/database/schema.gen.ts linguist-generated
packages/desktop/src/main/storage/migration.gen.ts linguist-generated
packages/protocol/openapi.json linguist-generated
packages/client/src/promise/generated/** linguist-generated
packages/client/src/effect/generated/** linguist-generated
packages/client/src/effect/api/** linguist-generated
# cli-rs: parity recordings and the files `script/gen` writes.
packages/cli-rs/parity/fixtures/** linguist-generated
packages/cli-rs/assets/queries/** linguist-generated
packages/cli-rs/crates/acp/src/permission/structured_patch.json linguist-generated
packages/cli-rs/crates/api-types/src/types.rs linguist-generated
packages/cli-rs/crates/api/src/generated/** linguist-generated
packages/cli-rs/crates/cli/src/run/mime.rs linguist-generated
packages/cli-rs/crates/cli/tests/fixtures/** linguist-generated
packages/cli-rs/crates/local/src/generated/** linguist-generated
packages/cli-rs/crates/mermaid/src/core/entities.rs linguist-generated
packages/cli-rs/crates/mermaid/src/core/wide.rs linguist-generated
packages/cli-rs/crates/ui/src/fuzzy/accents.rs linguist-generated
packages/cli-rs/crates/ui/src/keymap/generated.rs linguist-generated
packages/cli-rs/crates/ui/src/theme/generated/** linguist-generated
packages/cli-rs/crates/util/fixtures/time.tsv linguist-generated
packages/core/src/**/*.txt text eol=lf
# test/opencode-api-skill.test.ts compares the generated API reference byte for byte, so Windows checkouts keep LF.
packages/core/src/plugin/skill/opencode/** text eol=lf
packages/httpapi-codegen/test/generated/*.ts text eol=lf
# The site tests compare source text and humans.txt byte for byte, so Windows checkouts keep LF.
services/site/** text=auto eol=lf

6
.github/CODEOWNERS vendored
View file

@ -1,3 +1,3 @@
# CI and releases. Release jobs that hold secrets run only .github/workflows/release.yml and .github/release/,
# which makes this path the release security boundary. It is the only path that needs a code owner review.
/.github/ @thdxr
# web + desktop packages
packages/app/ @Hona @Brendonovich
packages/desktop/ @Hona @Brendonovich

View file

@ -11,6 +11,7 @@ kommander
ludvigrask
MrMushrooooom
neriousy
nexxeln
R44VC0RP
rekram1-node
thdxr
@ -18,8 +19,4 @@ simonklee
Slickstef11
usrnk1
vimtor
Tarquinen
dc85
vaprdev
hearnadam
heimoshuiyu
StarpTech

View file

@ -1,40 +0,0 @@
name: Prefetch Ghostty dependencies
description: Prepare the pinned source and Zig packages for process-daemon's native build
runs:
using: composite
steps:
- name: Check out pinned Ghostty source
id: pins
shell: bash
env:
GHOSTTY_SOURCE_DIR: ${{ runner.temp }}/ghostty
ZIG_GLOBAL_CACHE_DIR: ${{ github.workspace }}/.zig-cache
run: |
revision=$(git show HEAD:packages/process-daemon/ghostty-revision)
git init --quiet "$GHOSTTY_SOURCE_DIR"
git -C "$GHOSTTY_SOURCE_DIR" fetch --depth=1 https://github.com/ghostty-org/ghostty.git "$revision"
git -C "$GHOSTTY_SOURCE_DIR" -c core.longpaths=true checkout --detach "$revision"
echo "revision=$revision" >> "$GITHUB_OUTPUT"
echo "zig=$(zig version)" >> "$GITHUB_OUTPUT"
echo "GHOSTTY_SOURCE_DIR=$GHOSTTY_SOURCE_DIR" >> "$GITHUB_ENV"
echo "ZIG_GLOBAL_CACHE_DIR=$ZIG_GLOBAL_CACHE_DIR" >> "$GITHUB_ENV"
# Zig 0.16 stores portable, content-addressed source tarballs in p/.
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .zig-cache/p
key: ghostty-packages-${{ steps.pins.outputs.zig }}-${{ steps.pins.outputs.revision }}
enableCrossOsArchive: true
- name: Fetch Zig packages
shell: bash
working-directory: ${{ env.GHOSTTY_SOURCE_DIR }}
run: |
for attempt in 1 2 3 4; do
echo "zig build --fetch=all (attempt $attempt/4)"
if zig build --fetch=all; then exit 0; fi
if [[ $attempt == 4 ]]; then exit 1; fi
delay=$((5 * 2 ** (attempt - 1)))
echo "Retrying in ${delay}s"
sleep "$delay"
done

View file

@ -58,9 +58,6 @@ runs:
with:
path: ${{ steps.cache.outputs.dir }}
key: ${{ runner.os }}-${{ runner.arch }}-bun-${{ steps.cache.outputs.version }}-${{ hashFiles('bun.lock', 'patches/**') }}
# Each dev merge changes beta's bun.lock. Beta falls back to the newest cache for the same Bun version
# (Bun's cache stores every package version separately) instead of installing everything from npm.
restore-keys: ${{ (github.ref_name == 'beta' && format('{0}-{1}-bun-{2}-', runner.os, runner.arch, steps.cache.outputs.version)) || '' }}
- name: Install setuptools for distutils compatibility
run: python3 -m pip install setuptools || pip install setuptools || true

View file

@ -0,0 +1,43 @@
name: "Setup Git Committer"
description: "Create app token and configure git user"
inputs:
opencode-app-id:
description: "OpenCode GitHub App ID"
required: true
opencode-app-secret:
description: "OpenCode GitHub App private key"
required: true
outputs:
token:
description: "GitHub App token"
value: ${{ steps.apptoken.outputs.token }}
app-slug:
description: "GitHub App slug"
value: ${{ steps.apptoken.outputs.app-slug }}
runs:
using: "composite"
steps:
- name: Create app token
id: apptoken
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
with:
app-id: ${{ inputs.opencode-app-id }}
private-key: ${{ inputs.opencode-app-secret }}
owner: ${{ github.repository_owner }}
- name: Configure git user
run: |
slug="${{ steps.apptoken.outputs.app-slug }}"
git config --global user.name "${slug}[bot]"
git config --global user.email "${slug}[bot]@users.noreply.github.com"
shell: bash
- name: Clear checkout auth
run: |
git config --local --unset-all http.https://github.com/.extraheader || true
shell: bash
- name: Configure git remote
run: |
git remote set-url origin https://x-access-token:${{ steps.apptoken.outputs.token }}@github.com/${{ github.repository }}
shell: bash

View file

@ -1,66 +0,0 @@
#!/usr/bin/env bash
# publish.sh <hashes.json>: run from a checkout of dev. Puts <hashes.json> on bot/nix-hashes as one commit on top of dev,
# opens or updates the pull request into dev, dispatches its required checks and enables auto-merge. Closes the pull
# request instead when dev already has these hashes. Uses git, gh and jq only; never runs repository code.
set -euo pipefail
here=$(cd "$(dirname "$0")" && pwd)
new=$(realpath "$1")
branch=bot/nix-hashes
file=nix/hashes.json
title="chore: update nix node_modules hashes"
: "${GH_REPO:?}" "${GITHUB_SHA:?}"
git=(git -c core.hooksPath=/dev/null -c user.name='github-actions[bot]' -c user.email='41898282+github-actions[bot]@users.noreply.github.com')
bash "$here/validate.sh" "$new"
"${git[@]}" fetch --no-tags --depth=1 origin "+refs/heads/dev:refs/remotes/origin/dev" "$GITHUB_SHA"
# A newer push that changed the inputs has its own run, which publishes hashes for it. Mirrors on.push.paths.
if ! git diff --quiet "$GITHUB_SHA" origin/dev -- bun.lock package.json ':(glob)packages/*/package.json' \
':(glob)services/*/package.json' flake.lock nix/node_modules.nix nix/scripts patches; then
echo "::notice::dev changed the hash inputs since $GITHUB_SHA; leaving it to the newer run"
exit 0
fi
# Only a same-repository pull request is the bot's; a fork can use the same branch name.
find_pr() {
gh pr list --repo "$GH_REPO" --base dev --head "$branch" --state open --json number,isCrossRepository \
--jq 'map(select(.isCrossRepository | not)) | .[0].number // empty'
}
pr=$(find_pr)
"${git[@]}" checkout -B "$branch" origin/dev
if cmp -s "$new" "$file"; then
echo "dev already has these hashes"
if [ -n "$pr" ]; then
gh pr close "$pr" --repo "$GH_REPO" --delete-branch --comment "dev already has these hashes."
fi
exit 0
fi
cp "$new" "$file"
bash "$here/validate.sh" "$file"
"${git[@]}" add -- "$file"
"${git[@]}" commit --no-verify -m "$title"
[ "$(git diff --name-only origin/dev HEAD)" = "$file" ] || {
echo "::error::the commit changes more than $file" >&2
exit 1
}
"${git[@]}" push --no-verify --force origin "HEAD:refs/heads/$branch"
if [ -z "$pr" ]; then
gh pr create --repo "$GH_REPO" --base dev --head "$branch" --title "$title" \
--body "Updates \`$file\` to the node_modules hashes computed for $GITHUB_SHA by bot-nix-hashes. check-bot-scope keeps this branch to that file."
pr=$(find_pr)
fi
# Pushes and pull requests made with GITHUB_TOKEN start no workflows; dispatches do. These produce the checks dev
# requires on the new head.
for workflow in check.yml check-test.yml check-bot-scope.yml; do
gh workflow run "$workflow" --repo "$GH_REPO" --ref "$branch"
done
gh pr merge "$pr" --repo "$GH_REPO" --auto --squash
echo "### Nix hashes" >> "${GITHUB_STEP_SUMMARY:-/dev/null}"
echo "Updated pull request #$pr" >> "${GITHUB_STEP_SUMMARY:-/dev/null}"

View file

@ -1,27 +0,0 @@
#!/usr/bin/env bash
# validate.sh <file>: fails unless <file> has exactly the shape of nix/hashes.json, so the hashes bot can only ever publish
# three SRI hashes. Used by bot-nix-hashes.yml before it commits and by check-bot-scope.yml on the bot's pull request.
# Adding a system to the flake means adding it to SYSTEMS here.
set -euo pipefail
file=${1:?usage: validate.sh <file>}
SYSTEMS='["aarch64-darwin","aarch64-linux","x86_64-linux"]'
fail() {
echo "::error::$file: $*" >&2
exit 1
}
if [ ! -f "$file" ] || [ -L "$file" ]; then fail "not a regular file"; fi
[ "$(wc -c < "$file")" -lt 4096 ] || fail "4096 bytes or larger"
jq -se 'length == 1' "$file" > /dev/null 2>&1 || fail "not a single JSON value"
jq -e --argjson systems "$SYSTEMS" '
type == "object"
and keys == ["nodeModules"]
and (.nodeModules | type == "object")
and (.nodeModules | keys == $systems)
and (.nodeModules | all(.[]; type == "string" and test("\\Asha256-[A-Za-z0-9+/]{43}=\\z")))
' "$file" > /dev/null || fail "expected {\"nodeModules\": {<$SYSTEMS>: \"sha256-<44 base64 chars>\"}}"
# The canonical form rules out duplicate keys and anything else jq would drop on parse.
jq . "$file" | cmp -s - "$file" || fail "not formatted as jq . prints it"
echo "$file: valid"

71
.github/publish-python-sdk.yml vendored Normal file
View file

@ -0,0 +1,71 @@
#
# This file is intentionally in the wrong dir, will move and add later....
#
# name: publish-python-sdk
# on:
# release:
# types: [published]
# workflow_dispatch:
# jobs:
# publish:
# runs-on: ubuntu-latest
# permissions:
# contents: read
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Setup Bun
# uses: oven-sh/setup-bun@v1
# with:
# bun-version: 1.2.21
# - name: Install dependencies (JS/Bun)
# run: bun install
# - name: Install uv
# shell: bash
# run: curl -LsSf https://astral.sh/uv/install.sh | sh
# - name: Generate Python SDK from OpenAPI (CLI)
# shell: bash
# run: |
# ~/.local/bin/uv run --project packages/sdk/python python packages/sdk/python/scripts/generate.py --source cli
# - name: Sync Python dependencies
# shell: bash
# run: |
# ~/.local/bin/uv sync --dev --project packages/sdk/python
# - name: Set version from release tag
# shell: bash
# run: |
# TAG="${GITHUB_REF_NAME:-}"
# if [ -z "$TAG" ]; then
# TAG="$(git describe --tags --abbrev=0 || echo 0.0.0)"
# fi
# echo "Using version: $TAG"
# VERSION="$TAG" ~/.local/bin/uv run --project packages/sdk/python python - <<'PY'
# import os, re, pathlib
# root = pathlib.Path('packages/sdk/python')
# pt = (root / 'pyproject.toml').read_text()
# version = os.environ.get('VERSION','0.0.0').lstrip('v')
# pt = re.sub(r'(?m)^(version\s*=\s*")[^"]+("\s*)$', f"\\1{version}\\2", pt)
# (root / 'pyproject.toml').write_text(pt)
# # Also update generator config override for consistency
# cfgp = root / 'openapi-python-client.yaml'
# if cfgp.exists():
# cfg = cfgp.read_text()
# cfg = re.sub(r'(?m)^(package_version_override:\s*)\S+$', f"\\1{version}", cfg)
# cfgp.write_text(cfg)
# PY
# - name: Build and publish to PyPI
# env:
# PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
# shell: bash
# run: |
# ~/.local/bin/uv run --project packages/sdk/python python packages/sdk/python/scripts/publish.py

View file

@ -1,61 +0,0 @@
# Deploy boundary
The deploy workflows (`deploy.yml`, `deploy-site.yml`, `deploy-files.yml`,
`deploy-update.yml`) split every service in two:
- **build** runs repository code (`bun install`, `cf build`, `bun script/build.ts`,
`wrangler deploy --dry-run`) with no environment, no secrets, and no OIDC
token. It uploads the deploy-ready output with a `SHA256SUMS` and reports that
manifest's digest as a job output.
- **deploy** runs in the `dev` or `production` environment, assumes the stage's
AWS role, mints a short-lived Cloudflare token from the token issuer
(`cloudflare-token.sh`), and checks out only `.github/release/`. It verifies
the artifact against the digest the build job reported, installs the pinned
`cf`/`wrangler` CLI (`npm ci --ignore-scripts`), and runs only a
`deploy-*.sh` script here.
Repository code outside `.github/` does not need Dax's review, so the deploy job
must never execute it. The scripts treat the artifact as data: Worker code and
assets may change freely, but names, routes, custom domains, crons, Workflow and
export names, and every binding (including service bindings to other Workers)
come from `targets/`. An artifact whose resolved config is not byte-for-byte one
of those pinned targets is refused before the token is used.
For `cf` services the pinned target is also what `cf` reads: the script copies
the target over the artifact's config after validating it. For `wrangler`
services the artifact is only `index.js`; the complete `wrangler.json` is the
pinned target.
## Why the token can be account-wide
Cloudflare has no per-Worker permission for Workflows. The data sync Worker owns
a Workflow, and `PUT /accounts/<id>/workflows/<name>` needs account-wide
`Workers Scripts Write`, so `Individual Workers Editor` fails that deploy.
Dev and production therefore mint a token that can write any Worker on the
account. That is only safe because the code holding it is this directory: one
reviewed script per service, on a verified artifact, with every destination
pinned in `targets/`. Do not move a deploy back into a job that runs repository
code, and do not widen a script's accepted targets without review.
Production keeps this token only for a Dax-approved fast-forward of `dev`; a
`dev` merge cannot reach the production environment.
## Production promotion notes
Moving `dev` to `production` deploys the same pinned targets with the same
scripts, but production holds an account-wide token and a bad deploy is live.
Before promoting:
1. Confirm every dev deploy job is green on the commit being promoted
(`deploy`, `deploy-site`, `deploy-files`; `deploy-update` runs on production
only).
2. Diff `.github/release/targets/` against `origin/production`. Any change here
is a change to what production may deploy.
3. Rollback is a fast-forward back to the previous `production` commit, which
redeploys the previous Worker code from the same pinned targets. If a target
itself changed and must be reverted, revert it with the deploy commit.
4. The production deploy job runs only `.github/release/` at `github.sha`; it
does not run repo code. The build job still runs repo code, but with no
secrets and no OIDC token.

View file

@ -1,53 +0,0 @@
#!/usr/bin/env bash
# backfill-blockmaps.sh <version>...: builds the .blockmap for each published Windows installer and macOS zip of
# the given stable versions from the signed files on opencode.ai/files and uploads it next to them. Releases before
# publish-desktop.sh built blockmaps shipped without them, so electron-updater could not update differentially
# from them. A blockmap that already exists is left alone; a file the version never shipped is skipped.
. "$(dirname "$0")/lib.sh"
actor=${GITHUB_TRIGGERING_ACTOR:-${GITHUB_ACTOR:-}}
if ! (shopt -s nocasematch; [[ "$actor" = thdxr || "$actor" = Hona || "$actor" = rekram1-node ]]); then
die "${actor:-An unknown actor} is not allowed to backfill release files"
fi
[ $# -gt 0 ] || die "No versions given"
for version in "$@"; do
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] && [[ "$version" != 0.0.0-* ]] ||
die "Invalid release version: $version"
done
names=(opencode-desktop-win-arm64.exe opencode-desktop-win-x64.exe opencode-desktop-mac-arm64.zip opencode-desktop-mac-x64.zip)
status() {
curl -sS -o /dev/null -w '%{http_code}' --head "$1"
}
credentials=false
for version in "$@"; do
dir=$(mktemp -d)
for name in "${names[@]}"; do
url="https://opencode.ai/files/bin/$version/$name"
case "$(status "$url.blockmap")" in
200) echo "$version/$name.blockmap exists" && continue ;;
404) ;;
*) die "Could not check $url.blockmap" ;;
esac
case "$(status "$url")" in
200) ;;
404) echo "$version/$name was not published" && continue ;;
*) die "Could not check $url" ;;
esac
curl -fsSL --retry 3 -o "$dir/$name" "$url"
node "$release_dir/blockmap.mjs" "$dir/$name"
if dry_run; then
echo "dry-run upload: bin/$version/$name.blockmap ($(size "$dir/$name.blockmap") bytes)"
continue
fi
if [ "$credentials" = false ]; then
r2_credentials
credentials=true
fi
OPENCODE_VERSION=$version upload_file "$dir/$name.blockmap" "$name.blockmap" application/octet-stream ||
die "Upload failed: $version/$name.blockmap"
echo "uploaded bin/$version/$name.blockmap"
done
rm -rf "$dir"
done

View file

@ -1,179 +0,0 @@
// blockmap.mjs <file>...: writes <file>.blockmap next to each file, the gzipped block map electron-updater fetches
// for a differential download. It matches electron-builder's buildBlockMap (app-builder-lib 26): Rabin
// content-defined chunks of 8-32 KB and a 18-byte BLAKE2b checksum per chunk. electron-builder builds it at pack
// time, but signing changes the installer, so the release builds it here from the final signed files.
//
// It runs in publish jobs that hold secrets, so it uses Node's standard library only.
import { createReadStream, writeFileSync } from "node:fs"
import { gzipSync } from "node:zlib"
const MIN = 8192
const MAX = 32768
const MASK = 16384 - 1
const WINDOW = 64
// Rabin fingerprint tables for the degree-63 polynomial 0xbfe6b8a5bf378d83 (github.com/aclements/go-rabin), each
// 64-bit entry split into signed 32-bit hi and lo words.
const POLY = 0xbfe6b8a5bf378d83n
const PUSH_HI = new Int32Array(256)
const PUSH_LO = new Int32Array(256)
const POP_HI = new Int32Array(256)
const POP_LO = new Int32Array(256)
{
const mod = (a) => {
for (let d = a.toString(2).length - 1; a !== 0n && d >= 63; d = a.toString(2).length - 1)
a ^= POLY << BigInt(d - 63)
return a
}
const set = (hi, lo, i, x) => {
hi[i] = Number(BigInt.asIntN(32, x >> 32n))
lo[i] = Number(BigInt.asIntN(32, x))
}
for (let i = 0; i < 256; i++) {
const b = BigInt(i)
set(PUSH_HI, PUSH_LO, i, BigInt.asUintN(64, (b << 63n) ^ mod(b << 63n)))
set(POP_HI, POP_LO, i, mod(b << BigInt((WINDOW - 1) * 8)))
}
}
// BLAKE2b (RFC 7693) with an 18-byte digest and no key, on 32-bit word pairs. Node's crypto offers only BLAKE2b-512,
// whose digest length is part of the parameter block, so truncating it gives a different hash.
const IV = new Uint32Array([
0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372, 0x5f1d36f1, 0xa54ff53a, 0xade682d1,
0x510e527f, 0x2b3e6c1f, 0x9b05688c, 0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19,
])
const SIGMA = [
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
[14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3],
[11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4],
[7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8],
[9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13],
[2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9],
[12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11],
[13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10],
[6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5],
[10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0],
].map((row) => row.map((i) => i * 2))
const ROUNDS = [...SIGMA, SIGMA[0], SIGMA[1]]
const DIGEST = 18
const v = new Uint32Array(32)
const m = new Uint32Array(32)
const h = new Uint32Array(16)
const block = new Uint8Array(128)
const view = new DataView(block.buffer)
function add(a, b0, b1) {
const lo = v[a] + b0
v[a + 1] = v[a + 1] + b1 + (lo >= 0x100000000 ? 1 : 0)
v[a] = lo
}
function mix(a, b, c, d, x, y) {
add(a, v[b], v[b + 1])
add(a, m[x], m[x + 1])
let lo = v[d] ^ v[a]
let hi = v[d + 1] ^ v[a + 1]
v[d] = hi
v[d + 1] = lo
add(c, v[d], v[d + 1])
lo = v[b] ^ v[c]
hi = v[b + 1] ^ v[c + 1]
v[b] = (lo >>> 24) ^ (hi << 8)
v[b + 1] = (hi >>> 24) ^ (lo << 8)
add(a, v[b], v[b + 1])
add(a, m[y], m[y + 1])
lo = v[d] ^ v[a]
hi = v[d + 1] ^ v[a + 1]
v[d] = (lo >>> 16) ^ (hi << 16)
v[d + 1] = (hi >>> 16) ^ (lo << 16)
add(c, v[d], v[d + 1])
lo = v[b] ^ v[c]
hi = v[b + 1] ^ v[c + 1]
v[b] = (hi >>> 31) ^ (lo << 1)
v[b + 1] = (lo >>> 31) ^ (hi << 1)
}
function compress(count, last) {
for (let i = 0; i < 16; i++) {
v[i] = h[i]
v[i + 16] = IV[i]
}
v[24] ^= count
v[25] ^= Math.floor(count / 0x100000000)
if (last) {
v[28] = ~v[28]
v[29] = ~v[29]
}
for (let i = 0; i < 32; i++) m[i] = view.getUint32(i * 4, true)
for (const s of ROUNDS) {
mix(0, 8, 16, 24, s[0], s[1])
mix(2, 10, 18, 26, s[2], s[3])
mix(4, 12, 20, 28, s[4], s[5])
mix(6, 14, 22, 30, s[6], s[7])
mix(0, 10, 20, 30, s[8], s[9])
mix(2, 12, 22, 24, s[10], s[11])
mix(4, 14, 16, 26, s[12], s[13])
mix(6, 8, 18, 28, s[14], s[15])
}
for (let i = 0; i < 16; i++) h[i] ^= v[i] ^ v[i + 16]
}
function blake2b(data) {
h.set(IV)
h[0] ^= 0x01010000 ^ DIGEST
let offset = 0
while (data.length - offset > 128) {
block.set(data.subarray(offset, offset + 128))
offset += 128
compress(offset, false)
}
block.fill(0)
block.set(data.subarray(offset))
compress(data.length, true)
return Buffer.from(h.buffer, h.byteOffset, DIGEST).toString("base64")
}
async function blockmap(file) {
const checksums = []
const sizes = []
const chunk = Buffer.allocUnsafe(MAX)
const win = new Uint8Array(WINDOW)
let n = 0
let hi = 0
let lo = 0
let pos = 0
const emit = () => {
checksums.push(blake2b(chunk.subarray(0, n)))
sizes.push(n)
n = hi = lo = pos = 0
win.fill(0)
}
for await (const data of createReadStream(file, { highWaterMark: 256 * 1024 })) {
for (let i = 0; i < data.length; i++) {
const b = data[i]
chunk[n++] = b
if (n <= MIN - WINDOW) continue
if (n > MIN) {
const old = win[pos]
hi ^= POP_HI[old]
lo ^= POP_LO[old]
}
win[pos] = b
pos = (pos + 1) % WINDOW
const top = (hi >>> 23) & 0xff
const nhi = ((hi << 8) | (lo >>> 24)) & 0x7fffffff
const nlo = (lo << 8) | b
hi = nhi ^ PUSH_HI[top]
lo = nlo ^ PUSH_LO[top]
if (n >= MIN && ((lo & MASK) === MASK || n >= MAX)) emit()
}
}
if (n > 0) emit()
const map = { version: "2", files: [{ name: "file", offset: 0, checksums, sizes }] }
writeFileSync(`${file}.blockmap`, gzipSync(Buffer.from(JSON.stringify(map)), { level: 9 }))
}
for (const file of process.argv.slice(2)) await blockmap(file)

1138
.github/release/cf/package-lock.json generated vendored

File diff suppressed because it is too large Load diff

View file

@ -1,7 +0,0 @@
{
"private": true,
"description": "The pinned cf CLI that deploy-site.sh runs; npm ci --ignore-scripts installs exactly package-lock.json.",
"dependencies": {
"cf": "1.0.0-beta.12"
}
}

View file

@ -1,114 +0,0 @@
#!/usr/bin/env bash
# Mints a short-lived Cloudflare token for the current job from the token issuer
# (anomalyco/secrets). Run after aws-actions/configure-aws-credentials has assumed
# arn:aws:iam::604439173067:role/github/opencode-<stage> (release, dev or production): the Lambda
# identifies the role from the SigV4 signature and mints only that stage's token. No repo, stage,
# permission or TTL is sent in the request, and the token is pinned to the runner's IP.
#
# Step-scoped by default: the token goes to $GITHUB_OUTPUT and only steps that list
# `CLOUDFLARE_API_TOKEN: ${{ steps.<id>.outputs.token }}` in their env receive it.
set -euo pipefail
set +x
url=${CLOUDFLARE_TOKEN_URL:-https://kjivkui2evldapbok5fhrrl6oy0fctkp.lambda-url.us-east-1.on.aws/}
account=${CLOUDFLARE_ACCOUNT_ID:-15d29c8639fd3733b1b5486a2acfd968}
if [[ $# == 1 ]]; then
. "$(dirname "$0")/lib.sh"
account=$(stage_account "$1")
fi
# One argv value, never a line in curl's config: a newline in an override must not be able to
# inject curl options or move the AWS credentials into Basic auth.
url_pattern='^https://[a-z0-9]+\.lambda-url\.us-east-1\.on\.aws/$'
if ! [[ "$url" =~ $url_pattern ]]; then
echo "::error::CLOUDFLARE_TOKEN_URL is not the token issuer's function URL." >&2
exit 1
fi
case "$account" in
*[!0-9a-f]*|"")
echo "::error::CLOUDFLARE_ACCOUNT_ID must be a 32-character lowercase hex id." >&2
exit 1
;;
esac
if [ ${#account} -ne 32 ]; then
echo "::error::CLOUDFLARE_ACCOUNT_ID must be a 32-character lowercase hex id." >&2
exit 1
fi
for name in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN; do
if [ -z "${!name:-}" ]; then
echo "::error::$name is not set; run aws-actions/configure-aws-credentials first." >&2
exit 1
fi
done
# The response is captured, never streamed: it contains the token. AWS credentials go to curl
# through stdin, not argv, so they stay out of `ps` and any trace of this script.
response=$(
printf 'user = "%s:%s"\nheader = "x-amz-security-token: %s"\n' \
"$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY" "$AWS_SESSION_TOKEN" |
curl --config - \
--proto '=https' --proto-redir '=https' \
--aws-sigv4 "aws:amz:us-east-1:lambda" \
--request POST --url "$url" \
--fail-with-body --silent --show-error --max-time 20
)
token=$(printf '%s' "$response" | jq -er 'if (.token | type) == "string" then .token else error("token") end' 2>/dev/null)
expires=$(printf '%s' "$response" | jq -er 'if (.expires_on | type) == "string" then .expires_on else error("expires_on") end' 2>/dev/null)
# Validate before any output. No error below includes the token value.
case "$token" in
""|*[[:space:]]*)
echo "::error::The token issuer returned an invalid token." >&2
exit 1
;;
esac
if [ ${#token} -lt 8 ] || [ ${#token} -gt 512 ]; then
echo "::error::The token issuer returned an invalid token length." >&2
exit 1
fi
case "$expires" in
""|*[[:space:]]*)
echo "::error::The token issuer returned an invalid expires_on." >&2
exit 1
;;
esac
iso_pattern='^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?Z$'
if ! printf '%s' "$response" | jq -e --arg re "$iso_pattern" '(.expires_on | type) == "string" and (.expires_on | test($re))' > /dev/null; then
echo "::error::The token issuer returned an invalid expires_on." >&2
exit 1
fi
if ! [[ "$expires" =~ $iso_pattern ]]; then
echo "::error::The token issuer returned an invalid expires_on." >&2
exit 1
fi
# GitHub masks the exact string everywhere after this, including accidental traces and our own
# error messages. This is the first output that contains it.
printf '::add-mask::%s\n' "$token"
if [ -n "${GITHUB_OUTPUT:-}" ]; then
{
printf 'token=%s\n' "$token"
printf 'expires_on=%s\n' "$expires"
} >> "$GITHUB_OUTPUT"
elif [ -n "${GITHUB_ENV:-}" ]; then
printf 'CLOUDFLARE_API_TOKEN=%s\n' "$token" >> "$GITHUB_ENV"
fi
# Verify immediately, with the token on curl's stdin rather than argv. A runner whose Cloudflare
# egress address differs from the address Lambda saw (IPv4 vs IPv6, or a different NAT address)
# fails here instead of part way through an upload.
verify_url="https://api.cloudflare.com/client/v4/accounts/$account/tokens/verify"
if ! verify=$(printf 'header = "Authorization: Bearer %s"\nurl = "%s"\n' "$token" "$verify_url" |
curl --config - --proto '=https' --proto-redir '=https' --silent --show-error --fail-with-body --max-time 20); then
echo "::error::Cloudflare rejected the freshly minted token. The runner's egress IP to Cloudflare may differ from the IP Lambda saw (IPv4 vs IPv6 or a different NAT address). Use a runner with stable egress." >&2
exit 1
fi
if ! printf '%s' "$verify" | jq -e '.success == true and .result.status == "active"' > /dev/null; then
echo "::error::Cloudflare did not report the freshly minted token as active." >&2
exit 1
fi
echo "::notice::Cloudflare token ready; expires $expires"

View file

@ -1,86 +0,0 @@
#!/usr/bin/env bash
# deploy-data.sh <dev|production> <dir> <secrets.json>: deploys the data site's
# three Workers (og, sync, default) from one verified Build Output artifact
# (services/data/.cloudflare/output) with the cf CLI pinned in
# cf/package-lock.json. Order matches services/data/script/deploy.ts: the OG
# Worker first because the site binds to it, then sync, then the site.
#
# The build job has no secrets, so the Workers' code and assets are untrusted
# by design: the data site can change freely. The configs may not. All three
# must equal targets/data/<mode>/*.json exactly, and the pinned copies are what
# cf reads: another Worker name, route, cron, Workflow name, or binding
# (including the OG service binding) is refused before the token is used.
#
# The sync Worker's Workflow PUT needs account-wide Workers Scripts Write;
# Cloudflare has no per-Worker Workflows permission. That is safe only because
# this script (and the other deploy-*.sh) pin every target.
. "$(dirname "$0")/lib.sh"
mode=$1
src=$(cd "$2" && pwd)
secrets=$(posix "$3")
release=$(cd "$(dirname "$0")" && pwd)
case "$mode" in
dev | production) ;;
*) die "Unknown data mode: $mode" ;;
esac
target="$release/targets/data/$mode"
for file in root default og sync; do
[ -f "$target/$file.json" ] || die "No pinned data target $target/$file.json"
done
: "${CLOUDFLARE_API_TOKEN:?Set CLOUDFLARE_API_TOKEN}"
# Pinned in targets/ and in the token issuer's config (anomalyco/secrets).
CLOUDFLARE_ACCOUNT_ID=$(stage_account "$mode")
export CLOUDFLARE_ACCOUNT_ID
unexpected=$(cd "$src" && find . ! -type d ! -type f -o -type f ! -path ./SHA256SUMS \
! -path ./v0/config.json \
! -path ./v0/workers/default/worker.config.json \
! -path './v0/workers/default/bundle/*' \
! -path './v0/workers/default/assets/*' \
! -path ./v0/workers/og/worker.config.json \
! -path './v0/workers/og/bundle/*' \
! -path ./v0/workers/sync/worker.config.json \
! -path './v0/workers/sync/bundle/*')
[ -z "$unexpected" ] || die "Unexpected files in the data artifact: $unexpected"
for dir in default og sync; do
[ -f "$src/v0/workers/$dir/bundle/index.mjs" ] || die "The data artifact has no $dir bundle/index.mjs"
done
[ -d "$src/v0/workers/default/assets" ] || die "The data artifact has no default assets directory"
expect_json "$src/v0/config.json" "$target/root.json" "The data root config"
expect_json "$src/v0/workers/default/worker.config.json" "$target/default.json" "The data site's Worker config"
expect_json "$src/v0/workers/og/worker.config.json" "$target/og.json" "The OG Worker's config"
expect_json "$src/v0/workers/sync/worker.config.json" "$target/sync.json" "The sync Worker's config"
jq -e 'keys == ["DATA_DATABASE_HOST", "DATA_DATABASE_PASSWORD", "DATA_DATABASE_USERNAME", "DATA_HIDDEN_MODELS", "R2_SQL_AUTH_TOKEN"]
and all(.[]; type == "string" and length > 0)' "$secrets" > /dev/null ||
die "The secrets file does not hold exactly the data Workers' secrets"
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
output="$work/.cloudflare/output/v0"
mkdir -p "$output/workers/default" "$output/workers/og" "$output/workers/sync"
cp "$target/root.json" "$output/config.json"
for dir in default og sync; do
cp "$target/$dir.json" "$output/workers/$dir/worker.config.json"
cp -R "$src/v0/workers/$dir/bundle" "$output/workers/$dir/bundle"
done
cp -R "$src/v0/workers/default/assets" "$output/workers/default/assets"
# Each Worker gets only the secrets its pinned config declares (cf rejects a
# missing one). The files are 0600 in the runner's temp directory and removed
# with the work directory.
umask 077
jq '{DATA_DATABASE_HOST, DATA_DATABASE_USERNAME, DATA_DATABASE_PASSWORD}' "$secrets" > "$work/default-secrets.json"
cp "$secrets" "$work/sync-secrets.json"
cf="$release/cf/node_modules/.bin/cf"
[ -x "$cf" ] || die "Install the pinned cf CLI first: npm ci --ignore-scripts in .github/release/cf"
cd "$work"
"$cf" deploy --prebuilt --mode "$mode" --worker "$(jq -r .name "$target/og.json")"
"$cf" deploy --prebuilt --mode "$mode" --worker "$(jq -r .name "$target/sync.json")" --secrets-file "$work/sync-secrets.json"
"$cf" deploy --prebuilt --mode "$mode" --worker "$(jq -r .name "$target/default.json")" --secrets-file "$work/default-secrets.json"

View file

@ -1,43 +0,0 @@
#!/usr/bin/env bash
# deploy-files.sh <dev|production> <dir>: deploys the files Worker from a
# verified bundle artifact (index.js built by `wrangler deploy --dry-run`)
# with the wrangler CLI pinned in wrangler/package-lock.json.
#
# The build job has no secrets, so the bundle is untrusted by design: its code
# can change freely. The rest of the Worker does not come from the artifact at
# all: the name, route, R2 bucket, and STAGE var are the complete pinned
# wrangler.json in targets/files/<mode>/, which is what wrangler reads. The
# token can write every Worker on the account, so nothing in the artifact can
# name another destination.
. "$(dirname "$0")/lib.sh"
mode=$1
src=$(cd "$2" && pwd)
release=$(cd "$(dirname "$0")" && pwd)
case "$mode" in
dev | production) ;;
*) die "Unknown files mode: $mode" ;;
esac
target="$release/targets/files/$mode/wrangler.json"
[ -f "$target" ] || die "No pinned files target for $mode"
: "${CLOUDFLARE_API_TOKEN:?Set CLOUDFLARE_API_TOKEN}"
# Pinned in targets/ and in the token issuer's config (anomalyco/secrets).
CLOUDFLARE_ACCOUNT_ID=$(stage_account "$mode")
export CLOUDFLARE_ACCOUNT_ID
unexpected=$(cd "$src" && find . ! -type d ! -type f -o -type f ! -path ./SHA256SUMS ! -path ./index.js)
[ -z "$unexpected" ] || die "Unexpected files in the files artifact: $unexpected"
[ -f "$src/index.js" ] || die "The files artifact has no index.js"
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
cp "$src/index.js" "$work/index.js"
cp "$target" "$work/wrangler.json"
wrangler="$release/wrangler/node_modules/.bin/wrangler"
[ -x "$wrangler" ] || die "Install the pinned wrangler CLI first: npm ci --ignore-scripts in .github/release/wrangler"
cd "$work"
"$wrangler" deploy --config wrangler.json --no-bundle

View file

@ -1,59 +0,0 @@
#!/usr/bin/env bash
# deploy-legacy.sh <dev|production> <dir> [production-secrets.json]: deploys the legacy
# Worker from a verified Build Output artifact (services/legacy/.cloudflare/output)
# with the cf CLI pinned in cf/package-lock.json.
#
# The build job has no secrets, so the Worker's code is untrusted by design.
# Its config must equal targets/legacy/<mode>/*.json exactly, and the pinned
# copy is what cf reads: another Worker name, domain, or binding is refused
# before the token is used. The GitHub App secrets are read from AWS by the
# workflow into <secrets.json> and reach cf as a file, never argv.
. "$(dirname "$0")/lib.sh"
mode=$1
src=$(cd "$2" && pwd)
release=$(cd "$(dirname "$0")" && pwd)
case "$mode" in
dev | production) ;;
*) die "Unknown legacy mode: $mode" ;;
esac
target="$release/targets/legacy/$mode"
[ -f "$target/root.json" ] && [ -f "$target/worker.json" ] || die "No pinned legacy targets for $mode"
: "${CLOUDFLARE_API_TOKEN:?Set CLOUDFLARE_API_TOKEN}"
# Pinned in targets/ and in the token issuer's config (anomalyco/secrets).
CLOUDFLARE_ACCOUNT_ID=$(stage_account "$mode")
export CLOUDFLARE_ACCOUNT_ID
unexpected=$(cd "$src" && find . ! -type d ! -type f -o -type f ! -path ./SHA256SUMS \
! -path ./v0/config.json \
! -path ./v0/workers/default/worker.config.json \
! -path './v0/workers/default/bundle/*')
[ -z "$unexpected" ] || die "Unexpected files in the legacy artifact: $unexpected"
[ -f "$src/v0/workers/default/bundle/index.js" ] || die "The legacy artifact has no bundle/index.js"
expect_json "$src/v0/config.json" "$target/root.json" "The legacy Worker's root config"
expect_json "$src/v0/workers/default/worker.config.json" "$target/worker.json" "The legacy Worker's config"
args=()
if [[ "$mode" == production ]]; then
secrets=$(posix "$3")
jq -e 'keys == ["GITHUB_APP_ID", "GITHUB_APP_PRIVATE_KEY"] and all(.[]; type == "string" and length > 0)' \
"$secrets" > /dev/null || die "The secrets file does not hold exactly GITHUB_APP_ID and GITHUB_APP_PRIVATE_KEY"
args=(--secrets-file "$secrets")
fi
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
output="$work/.cloudflare/output/v0"
mkdir -p "$output/workers/default"
cp "$target/root.json" "$output/config.json"
cp "$target/worker.json" "$output/workers/default/worker.config.json"
cp -R "$src/v0/workers/default/bundle" "$output/workers/default/bundle"
cf="$release/cf/node_modules/.bin/cf"
[ -x "$cf" ] || die "Install the pinned cf CLI first: npm ci --ignore-scripts in .github/release/cf"
cd "$work"
"$cf" deploy --prebuilt --mode "$mode" "${args[@]}"

View file

@ -1,55 +0,0 @@
#!/usr/bin/env bash
# deploy-site.sh <dev|production> <dir>: deploys the site Worker from a verified
# Build Output artifact (services/site/.cloudflare/output) with the cf CLI
# pinned in cf/package-lock.json, which the workflow installs before the token
# is in reach.
#
# The build job has no secrets, so the Worker's code and assets are untrusted
# by design: the site can change freely. Its config may not. The artifact's
# root config and Worker config must equal targets/site/<mode>/*.json exactly,
# and those pinned copies are what cf reads: another Worker name, route,
# domain, or binding is refused before the token is used.
. "$(dirname "$0")/lib.sh"
mode=$1
src=$(cd "$2" && pwd)
release=$(cd "$(dirname "$0")" && pwd)
case "$mode" in
dev | production) ;;
*) die "Unknown site mode: $mode" ;;
esac
target="$release/targets/site/$mode"
[ -f "$target/root.json" ] && [ -f "$target/worker.json" ] || die "No pinned site targets for $mode"
: "${CLOUDFLARE_API_TOKEN:?Set CLOUDFLARE_API_TOKEN}"
# Pinned in targets/ and in the token issuer's config (anomalyco/secrets).
CLOUDFLARE_ACCOUNT_ID=$(stage_account "$mode")
export CLOUDFLARE_ACCOUNT_ID
unexpected=$(cd "$src" && find . ! -type d ! -type f -o -type f ! -path ./SHA256SUMS \
! -path ./v0/config.json \
! -path ./v0/workers/default/worker.config.json \
! -path './v0/workers/default/bundle/*' \
! -path './v0/workers/default/assets/*')
[ -z "$unexpected" ] || die "Unexpected files in the site artifact: $unexpected"
[ -f "$src/v0/workers/default/bundle/index.mjs" ] || die "The site artifact has no bundle/index.mjs"
[ -d "$src/v0/workers/default/assets" ] || die "The site artifact has no assets directory"
expect_json "$src/v0/config.json" "$target/root.json" "The site's root config"
expect_json "$src/v0/workers/default/worker.config.json" "$target/worker.json" "The site's Worker config"
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
output="$work/.cloudflare/output/v0"
mkdir -p "$output/workers/default"
cp "$target/root.json" "$output/config.json"
cp "$target/worker.json" "$output/workers/default/worker.config.json"
cp -R "$src/v0/workers/default/bundle" "$output/workers/default/bundle"
cp -R "$src/v0/workers/default/assets" "$output/workers/default/assets"
cf="$release/cf/node_modules/.bin/cf"
[ -x "$cf" ] || die "Install the pinned cf CLI first: npm ci --ignore-scripts in .github/release/cf"
cd "$work"
"$cf" deploy --prebuilt --mode "$mode"

View file

@ -1,38 +0,0 @@
#!/usr/bin/env bash
# deploy-update.sh <production> <dir>: deploys the update Worker from a verified
# bundle artifact (index.js built by `wrangler deploy --dry-run`) with the
# wrangler CLI pinned in wrangler/package-lock.json.
#
# The build job has no secrets, so the bundle is untrusted by design: its code
# can change freely. The rest of the Worker does not come from the artifact at
# all: the name, routes, custom domain, D1 database, and Pipelines stream are
# the complete pinned wrangler.json in targets/update/production/, which is what
# wrangler reads. Only production deploys this Worker.
. "$(dirname "$0")/lib.sh"
mode=$1
src=$(cd "$2" && pwd)
release=$(cd "$(dirname "$0")" && pwd)
[ "$mode" = production ] || die "The update Worker deploys only to production, not $mode"
target="$release/targets/update/production/wrangler.json"
[ -f "$target" ] || die "No pinned update target"
: "${CLOUDFLARE_API_TOKEN:?Set CLOUDFLARE_API_TOKEN}"
# Pinned in targets/ and in the token issuer's config (anomalyco/secrets).
export CLOUDFLARE_ACCOUNT_ID=15d29c8639fd3733b1b5486a2acfd968
unexpected=$(cd "$src" && find . ! -type d ! -type f -o -type f ! -path ./SHA256SUMS ! -path ./index.js)
[ -z "$unexpected" ] || die "Unexpected files in the update artifact: $unexpected"
[ -f "$src/index.js" ] || die "The update artifact has no index.js"
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
cp "$src/index.js" "$work/index.js"
cp "$target" "$work/wrangler.json"
wrangler="$release/wrangler/node_modules/.bin/wrangler"
[ -x "$wrangler" ] || die "Install the pinned wrangler CLI first: npm ci --ignore-scripts in .github/release/wrangler"
cd "$work"
"$wrangler" deploy --config wrangler.json --no-bundle

View file

@ -1,26 +0,0 @@
name: Download release artifacts
description: Downloads artifacts into $RUNNER_TEMP/in/<name> and verifies each against its SHA256SUMS.
inputs:
pattern:
description: Artifact name pattern
required: true
digests:
description: Space-separated name=digest pairs for artifacts made by sign jobs, from their job outputs
required: false
default: ""
require-digests:
description: Require every artifact to match a reported digest (deploy jobs set this)
required: false
default: "false"
runs:
using: composite
steps:
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: ${{ inputs.pattern }}
path: ${{ runner.temp }}/in
- shell: bash
run: bash "${GITHUB_ACTION_PATH//\\//}/../verify-artifacts.sh" "$RUNNER_TEMP/in"
env:
OPENCODE_DIGESTS: ${{ inputs.digests }}
OPENCODE_REQUIRE_DIGESTS: ${{ inputs.require-digests }}

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
</dict>
</plist>

View file

@ -1,14 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
umask 077
cert="$RUNNER_TEMP/cert.p12"
trap 'rm -f "$cert"' EXIT
keychain_password=$(openssl rand -base64 32)
printf '%s' "$APPLE_SIGNING_CERTIFICATE" | base64 --decode > "$cert"
unset APPLE_SIGNING_CERTIFICATE
security create-keychain -p "$keychain_password" build.keychain
security set-keychain-settings -lut 21600 build.keychain
security unlock-keychain -p "$keychain_password" build.keychain
security import "$cert" -k build.keychain -P "" -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/productsign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$keychain_password" build.keychain > /dev/null
security list-keychains -d user -s build.keychain $(security list-keychains -d user | tr -d '"')

152
.github/release/lib.sh vendored
View file

@ -1,152 +0,0 @@
# Shared helpers for the release scripts. Sourced, never executed.
#
# These scripts run in sign and publish jobs that hold secrets. They must never execute repository code
# or artifact contents: artifacts are data, and every value that names a destination comes from the
# environment the workflow sets (OPENCODE_VERSION, OPENCODE_CHANNEL, OPENCODE_DRY_RUN, ...).
set -euo pipefail
# Without this, set -e does not apply inside $(...), so a failing command in a function called as
# files=$(upload_files ...) is ignored. macOS /bin/bash is 3.2, which lacks the option.
if [ "${BASH_VERSINFO[0]}" -gt 4 ] || { [ "${BASH_VERSINFO[0]}" = 4 ] && [ "${BASH_VERSINFO[1]}" -ge 4 ]; }; then
shopt -s inherit_errexit
fi
# shellcheck disable=SC2034 # used by the scripts that source this file
release_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
die() {
echo "::error::$*" >&2
exit 1
}
dry_run() {
[ "${OPENCODE_DRY_RUN:-false}" = true ]
}
stage_account() {
case "$1" in
dev) echo d8e944f537ceef3f06a5bd3aec1d7a53 ;;
production) echo 15d29c8639fd3733b1b5486a2acfd968 ;;
*) die "Unknown Cloudflare stage: $1" ;;
esac
}
sha256() {
if command -v sha256sum > /dev/null; then sha256sum "$@"; else shasum -a 256 "$@"; fi
}
# Windows runners pass D:\a\_temp style paths; Git Bash tools want /d/a/_temp.
posix() {
if command -v cygpath > /dev/null; then cygpath -u "$1"; else printf '%s' "$1"; fi
}
size() {
wc -c < "$1" | tr -d ' '
}
# Uploads files to opencode.ai/files/bin/<version>/ and prints the update-server file map.
upload_files() {
local credentials=false
for file in "$@"; do
test -s "$file" || die "Missing release file: $file"
local name type
name=$(basename "$file")
case "$name" in
*.tar.gz) type=application/gzip ;;
*.zip) type=application/zip ;;
*) type=application/octet-stream ;;
esac
if dry_run; then
echo "dry-run upload: bin/$OPENCODE_VERSION/$name" >&2
else
if [ "$credentials" = false ]; then
r2_credentials
credentials=true
fi
upload_file "$file" "$name" "$type" || die "Upload failed: $name"
fi
jq -n --arg name "$name" --arg url "https://opencode.ai/files/bin/$OPENCODE_VERSION/$name" \
--arg sha256 "$(sha256 "$file" | cut -c1-64)" --argjson size "$(size "$file")" \
'{($name): {url: $url, sha256: $sha256, size: $size}}'
done | jq -s 'add'
}
# Uploads one file to R2 and confirms the stored object has the local size: upload_file <file> <name> <type>.
# R2 intermittently rejects CompleteMultipartUpload with InvalidPart, so failed uploads are retried.
upload_file() {
local key="bin/$OPENCODE_VERSION/$2" endpoint="https://$CLOUDFLARE_ACCOUNT_ID.r2.cloudflarestorage.com" attempt
for attempt in 1 2 3; do
if aws s3 cp "$1" "s3://opencode-production-files/$key" --only-show-errors --endpoint-url "$endpoint" \
--content-type "$3" --content-disposition "attachment; filename=\"$2\"" \
--cache-control "public, max-age=31536000, immutable" >&2 &&
[ "$(aws s3api head-object --bucket opencode-production-files --key "$key" --endpoint-url "$endpoint" \
--query ContentLength --output text)" = "$(size "$1")" ]; then
return
fi
echo "::warning::Upload attempt $attempt failed: $2" >&2
sleep $((attempt * 5))
done
return 1
}
# R2 accepts the API token ID as the access key and SHA-256(token) as the secret.
r2_credentials() {
local id
id=$(curl -fsS -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
"https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/tokens/verify" | jq -er .result.id) ||
die "Could not resolve R2 credentials"
export AWS_ACCESS_KEY_ID="$id"
AWS_SECRET_ACCESS_KEY=$(printf '%s' "$CLOUDFLARE_API_TOKEN" | sha256 | cut -c1-64)
export AWS_SECRET_ACCESS_KEY
# These are R2's own credentials, so drop the role credentials the job assumed to read Secrets Manager.
unset AWS_SESSION_TOKEN AWS_PROFILE AWS_REGION
export AWS_DEFAULT_REGION=auto AWS_REQUEST_CHECKSUM_CALCULATION=when_required AWS_RESPONSE_CHECKSUM_VALIDATION=when_required
# Larger parts mean fewer CompleteMultipartUpload parts for the 200-350 MB desktop builds.
AWS_CONFIG_FILE=$(mktemp)
export AWS_CONFIG_FILE
printf '[default]\ns3 =\n multipart_threshold = 64MB\n multipart_chunksize = 64MB\n' > "$AWS_CONFIG_FILE"
}
# Registers one artifact with the update server: publish_update <name> <distribution> <metadata json>.
publish_update() {
local body status token attempt
body=$(jq -n --arg channel "$OPENCODE_CHANNEL" --arg version "$OPENCODE_VERSION" --arg name "$1" --arg distribution "$2" \
--argjson metadata "$3" '{channel: $channel, name: $name, distribution: $distribution, version: $version, metadata: $metadata}')
echo "$body" | jq .
if dry_run; then return; fi
token=$(curl -fsS -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://update.opencode.ai" | jq -er .value)
for attempt in 1 2 3; do
status=$(curl -sS -o "$RUNNER_TEMP/update-response" -w '%{http_code}' -X POST https://opencode.ai/update/api/publish \
-H "Authorization: Bearer $token" -H "Content-Type: application/json" --data "$body")
if [ "$status" -lt 300 ]; then return; fi
cat "$RUNNER_TEMP/update-response"
# D1 can commit the upsert and still time out. Replaying the same artifact is safe.
if [ "$status" -lt 500 ] || [ "$attempt" = 3 ]; then die "Update server returned $status"; fi
sleep "$attempt"
done
}
# Clones a repository, lets a render script fill it, then commits and pushes any change:
# push_git <clone url> <commit message> <render script> [args...]. Dry runs render into an empty directory.
push_git() {
local url=$1 message=$2 dir
shift 2
dir=$(mktemp -d)
if ! dry_run; then git clone -q "$url" "$dir"; fi
"$@" "$dir"
if dry_run; then return; fi
git -C "$dir" add -A
if git -C "$dir" diff --cached --quiet; then return; fi
git -C "$dir" -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit -q -m "$message"
git -C "$dir" push -q origin HEAD:master
}
# expect_json <artifact-file> <pinned-target> <label>: the artifact's resolved
# config must equal the pinned target exactly before anything is deployed.
# Deploy scripts use this with targets/; release scripts do not.
expect_json() {
jq -e --slurp '.[0] == .[1]' "$1" "$2" > /dev/null ||
die "$3 in the artifact is not the pinned target ($2)"
}

View file

@ -1,79 +0,0 @@
#!/usr/bin/env bash
# plan-release.sh: decides version, channel and npm dist-tag from the event, ref and dispatch inputs
# (INPUT_BUMP, INPUT_VERSION) only, and writes them to $GITHUB_OUTPUT. Nothing here reads repository files.
#
# schedule or dispatch on dev -> dev 0.0.0-dev-<run> npm tag dev, desktop
# dispatch on dev with bump/version -> latest x.y.z npm tag latest, releasers only, notes required
# push or dispatch on beta -> beta 0.0.0-beta-<run> desktop only
# pull_request -> pr 0.0.0-pr-<run> everything, dry run
#
# Stable releases are limited to the GitHub logins listed below (case-insensitive).
. "$(dirname "$0")/lib.sh"
versioned=false
if [ -n "${INPUT_BUMP:-}" ] || [ -n "${INPUT_VERSION:-}" ]; then versioned=true; fi
case "$GITHUB_EVENT_NAME:$GITHUB_REF:$versioned" in
schedule:refs/heads/dev:false | workflow_dispatch:refs/heads/dev:false) channel="dev" ;;
workflow_dispatch:refs/heads/dev:true) channel="latest" ;;
push:refs/heads/beta:false | workflow_dispatch:refs/heads/beta:false) channel="beta" ;;
pull_request:*:false) channel="pr" ;;
*) die "$GITHUB_EVENT_NAME on $GITHUB_REF cannot publish (versioned: $versioned)" ;;
esac
if [ "$channel" = latest ] && [ -z "${INPUT_RELEASE_NOTES//[[:space:]]/}" ]; then
die "Stable releases need release notes; generate them with ./script/release.ts --print"
fi
if [ "$channel" = latest ]; then
actor=${GITHUB_TRIGGERING_ACTOR:-${GITHUB_ACTOR:-}}
[ -n "$actor" ] || die "Stable releases can only be started by releasers; the triggering actor is unknown"
if ! (shopt -s nocasematch; [[ "$actor" = thdxr || "$actor" = Hona || "$actor" = rekram1-node ]]); then
die "$actor is not allowed to start stable releases"
fi
fi
if [ "$channel" = latest ] && [ -n "${INPUT_VERSION:-}" ]; then
version=$INPUT_VERSION
elif [ "$channel" = latest ]; then
current=$(curl -fsS https://registry.npmjs.org/-/package/@opencode%2fcli/dist-tags | jq -r .latest)
[[ "$current" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]] || die "Unexpected latest version: $current"
major=${BASH_REMATCH[1]} minor=${BASH_REMATCH[2]} patch=${BASH_REMATCH[3]}
case "$INPUT_BUMP" in
major) version="$((major + 1)).0.0" ;;
minor) version="$major.$((minor + 1)).0" ;;
*) version="$major.$minor.$((patch + 1))" ;;
esac
if [ "$major" -lt 2 ]; then version=2.0.0; fi
else
version="0.0.0-$channel-$GITHUB_RUN_NUMBER"
if [ "$GITHUB_RUN_ATTEMPT" != 1 ]; then version="$version.$GITHUB_RUN_ATTEMPT"; fi
fi
if [ "$channel" = latest ]; then
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || [[ "$version" == 0.0.0-* ]]; then
die "Invalid release version: $version"
fi
status=$(curl -sS -o /dev/null -w '%{http_code}' "https://registry.npmjs.org/@opencode%2fcli/$version")
[ "$status" != 200 ] || die "@opencode/cli@$version is already published"
fi
# What each channel builds and publishes.
case "$channel" in
latest) npm_tag=latest cli=true desktop=true node=false release=true ;;
dev) npm_tag=dev cli=true desktop=true node=true release=false ;;
beta) npm_tag="" cli=false desktop=true node=false release=false ;;
pr) npm_tag=pr cli=true desktop=true node=true release=true ;;
esac
dry_run=false
if [ "$channel" = pr ]; then dry_run=true; fi
{
echo "version=$version"
echo "channel=$channel"
echo "npm_tag=$npm_tag"
echo "dry_run=$dry_run"
echo "cli=$cli"
echo "desktop=$desktop"
echo "node=$node"
echo "release=$release"
} | tee -a "$GITHUB_OUTPUT"

View file

@ -1,15 +0,0 @@
#!/usr/bin/env bash
# publish-aur.sh <build-npm dir>: updates opencode-beta on the AUR over SSH (AUR_KEY, pinned host key) and
# registers the aur update artifact.
. "$(dirname "$0")/lib.sh"
if ! dry_run; then
mkdir -p ~/.ssh
printf '%s\n' "$AUR_KEY" > ~/.ssh/aur
chmod 600 ~/.ssh/aur
echo "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN" > ~/.ssh/known_hosts
export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/aur -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes"
fi
push_git ssh://aur@aur.archlinux.org/opencode-beta.git "chore: update opencode-beta to ${OPENCODE_VERSION//-/.}" \
bash "$release_dir/render-aur.sh" "$1"
publish_update cli aur '{"package": "opencode-beta"}'

View file

@ -1,23 +0,0 @@
#!/usr/bin/env bash
# publish-cli.sh <build-archives dir> <sign-macos dir> <sign-windows dir>: uploads the standalone CLI
# archives to opencode.ai/files and registers the cli (and, off latest, cli-node) update artifacts.
. "$(dirname "$0")/lib.sh"
archives=$1 macos=$2 windows=$3
cli=()
for target in linux-arm64 linux-x64 linux-x64-baseline linux-arm64-musl linux-x64-musl linux-x64-baseline-musl; do cli+=("$archives/opencode-$target.tar.gz"); done
for target in darwin-arm64 darwin-x64 darwin-x64-baseline; do cli+=("$macos/opencode-$target.zip"); done
for target in windows-arm64 windows-x64 windows-x64-baseline; do cli+=("$windows/opencode-$target.zip"); done
files=$(upload_files "${cli[@]}")
publish_update cli npm '{"package": "@opencode/cli"}'
publish_update cli opencode "$(jq -n --argjson files "$files" '{files: $files}')"
if [ "$OPENCODE_CHANNEL" != latest ]; then
node=()
for target in linux-arm64 linux-x64; do node+=("$archives/opencode2-node-$target.tar.gz"); done
for target in darwin-arm64 windows-arm64 windows-x64; do node+=("$archives/opencode2-node-$target.zip"); done
files=$(upload_files "${node[@]}")
publish_update cli-node npm '{"package": "@opencode/cli-node"}'
publish_update cli-node opencode "$(jq -n --argjson files "$files" '{files: $files}')"
fi

View file

@ -1,37 +0,0 @@
#!/usr/bin/env bash
# publish-desktop.sh <sign-macos dir> <sign-desktop-windows-installer dir> <build-desktop-linux-x64 dir>
# <build-desktop-linux-arm64 dir>: uploads the desktop builds to opencode.ai/files and registers the desktop update
# artifact. The electron-updater feeds (latest*.yml) are computed here from the final signed files.
. "$(dirname "$0")/lib.sh"
macos=$1 windows=$2 linux_x64=$3 linux_arm64=$4
win=("$windows/opencode-desktop-win-arm64.exe" "$windows/opencode-desktop-win-x64.exe")
mac=("$macos/opencode-desktop-mac-arm64.zip" "$macos/opencode-desktop-mac-arm64.dmg" "$macos/opencode-desktop-mac-x64.zip" "$macos/opencode-desktop-mac-x64.dmg")
linux=("$linux_x64/opencode-desktop-linux-x86_64.AppImage" "$linux_x64/opencode-desktop-linux-amd64.deb" "$linux_x64/opencode-desktop-linux-x86_64.rpm")
linux_arm=("$linux_arm64/opencode-desktop-linux-arm64.AppImage" "$linux_arm64/opencode-desktop-linux-arm64.deb" "$linux_arm64/opencode-desktop-linux-aarch64.rpm")
# Dev and beta skip the .app.tar.gz, which only the retired Tauri updater feed read.
bundles=()
case "$OPENCODE_CHANNEL" in
dev | beta) ;;
*) bundles=("$macos/opencode-desktop-mac-arm64.app.tar.gz" "$macos/opencode-desktop-mac-x64.app.tar.gz") ;;
esac
feed() {
for file in "$@"; do
jq -n --arg url "https://opencode.ai/files/bin/$OPENCODE_VERSION/$(basename "$file")" \
--arg sha512 "$(openssl dgst -sha512 -binary "$file" | base64 | tr -d '\n')" --argjson size "$(size "$file")" \
'{url: $url, sha512: $sha512, size: $size}'
done | jq -s --arg date "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" '{files: ., releaseDate: $date}'
}
# electron-updater fetches <file>.blockmap next to the Windows installer and the macOS zip for a differential
# download. Signing changes these files, so the blockmaps electron-builder made at pack time no longer match.
differential=("${win[@]}" "$macos/opencode-desktop-mac-arm64.zip" "$macos/opencode-desktop-mac-x64.zip")
node "$release_dir/blockmap.mjs" "${differential[@]}"
blockmaps=("${differential[@]/%/.blockmap}")
files=$(upload_files "${win[@]}" "${mac[@]}" "${linux[@]}" "${linux_arm[@]}" "${bundles[@]}" "${blockmaps[@]}")
manifests=$(jq -n --argjson win "$(feed "${win[@]}")" --argjson mac "$(feed "${mac[@]}")" \
--argjson linux "$(feed "${linux[@]}")" --argjson linux_arm64 "$(feed "${linux_arm[@]}")" \
'{"desktop.yml": $win, "desktop-mac.yml": $mac, "desktop-linux.yml": $linux, "desktop-linux-arm64.yml": $linux_arm64}')
publish_update desktop opencode "$(jq -n --argjson files "$files" --argjson manifests "$manifests" '{files: $files, manifests: $manifests}')"

View file

@ -1,19 +0,0 @@
#!/usr/bin/env bash
# publish-discord.sh: announces the v<version> release in Discord with OPENCODE_RELEASE_NOTES (DISCORD_WEBHOOK).
# Discord caps an embed description at 4096 characters, so longer notes are cut and link to the GitHub release.
. "$(dirname "$0")/lib.sh"
tag="v$OPENCODE_VERSION"
payload=$(jq -n --arg tag "$tag" --arg notes "${OPENCODE_RELEASE_NOTES:-}" \
--arg url "https://github.com/$GITHUB_REPOSITORY/releases/tag/$tag" '
($notes | gsub("(?m)^#{4,6}[ \\t]+(?<heading>[^\\r\\n]+)"; "**\(.heading)**") |
if length > 4000 then .[:4000] + "\n\n[Full release notes](\($url))" else . end) as $description |
{
allowed_mentions: {parse: []},
embeds: [{title: "OpenCode V2 \($tag)", url: $url, description: $description, color: 2829099}]
}')
echo "$payload" | jq .
if dry_run; then exit 0; fi
test -n "${DISCORD_WEBHOOK:-}" || die "DISCORD_WEBHOOK is not set"
curl -fsS --retry 3 -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK"

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# publish-docker.sh <build-docker dir>: pushes the multi-arch OCI image to ghcr.io/anomalyco/opencode:<version>
# without building anything (GH_TOKEN with packages: write).
. "$(dirname "$0")/lib.sh"
image="$1/opencode-image.tar"
skopeo inspect --raw "oci-archive:$image" | jq .
if dry_run; then exit 0; fi
printf '%s' "$GH_TOKEN" | skopeo login ghcr.io --username "$GITHUB_ACTOR" --password-stdin
skopeo copy --all "oci-archive:$image" "docker://ghcr.io/anomalyco/opencode:$OPENCODE_VERSION"

View file

@ -1,21 +0,0 @@
#!/usr/bin/env bash
# publish-github-release.sh <dir>...: attaches the CLI archives and desktop builds in the given artifact dirs, plus
# a SHA256SUMS, to the v<version> GitHub release with OPENCODE_RELEASE_NOTES. Immutable releases lock assets once
# published, so they go to a draft first.
. "$(dirname "$0")/lib.sh"
assets=$(mktemp -d)
for dir in "$@"; do
find "$dir" -maxdepth 1 -type f \( -name 'opencode-*.zip' -o -name 'opencode-*.tar.gz' -o -name 'opencode-desktop-*' \) \
! -name '*.tgz' ! -name '*.app.tar' -exec cp {} "$assets/" \;
done
(cd "$assets" && sha256 -- * > SHA256SUMS && cat SHA256SUMS)
printf '%s\n' "${OPENCODE_RELEASE_NOTES:-}" > "$assets.md"
if dry_run; then exit 0; fi
tag="v$OPENCODE_VERSION"
# OpenCode 1 update paths (CLI upgrade, electron-updater, Scoop) follow GitHub's Latest release, which must stay on 1.x.
gh release view "$tag" > /dev/null 2>&1 ||
gh release create "$tag" --draft --verify-tag --latest=false --title "$tag" --notes-file "$assets.md"
gh release upload "$tag" "$assets"/* --clobber
gh release edit "$tag" --draft=false --latest=false

View file

@ -1,17 +0,0 @@
#!/usr/bin/env bash
# publish-homebrew.sh <sign-macos dir> <build-archives dir>: updates opencode-v2 in anomalyco/homebrew-tap over SSH
# with its write deploy key (HOMEBREW_TAP_DEPLOY_KEY) and registers the homebrew update artifact.
. "$(dirname "$0")/lib.sh"
if ! dry_run; then
test -n "${HOMEBREW_TAP_DEPLOY_KEY:-}" || die "Missing HOMEBREW_TAP_DEPLOY_KEY"
ssh_dir=$(mktemp -d)
printf '%s\n' "$HOMEBREW_TAP_DEPLOY_KEY" > "$ssh_dir/key"
chmod 600 "$ssh_dir/key"
echo "github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl" > "$ssh_dir/known_hosts"
export GIT_SSH_COMMAND="ssh -i $ssh_dir/key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$ssh_dir/known_hosts"
fi
push_git "git@github.com:anomalyco/homebrew-tap.git" \
"chore: update opencode-v2 to $OPENCODE_VERSION" bash "$release_dir/render-homebrew.sh" "$1" "$2"
publish_update cli homebrew '{"package": "anomalyco/tap/opencode-v2"}'

View file

@ -1,89 +0,0 @@
#!/usr/bin/env bash
# publish-npm.sh <build-npm dir> <signed dir>...: publishes every release tarball to npm with OPENCODE_NPM_TAG.
# Names, the version and the package set come from this script, never from the tarballs: each tarball's
# package.json is read as data and must match. macOS and Windows CLI packages must come from a signed dir.
. "$(dirname "$0")/lib.sh"
npm_dir=$1
shift
targets="linux-arm64 linux-x64 linux-x64-baseline linux-arm64-musl linux-x64-musl linux-x64-baseline-musl darwin-arm64 darwin-x64 darwin-x64-baseline windows-arm64 windows-x64 windows-x64-baseline"
expected="@opencode/cli"
for target in $targets; do expected="$expected @opencode/cli-$target"; done
for lib in schema codemode theme ai util protocol client plugin plugin-browser core simulation server sdk ui; do expected="$expected @opencode/$lib"; done
if [ "$OPENCODE_CHANNEL" != latest ]; then
expected="$expected @opencode/cli-node"
for target in linux-arm64 linux-x64 darwin-arm64 windows-arm64 windows-x64; do expected="$expected @opencode/cli-node-$target"; done
fi
if ! dry_run; then
for file in "$npm_dir"/*.tgz; do
gh attestation verify "$file" --repo anomalyco/opencode --signer-workflow anomalyco/opencode/.github/workflows/release.yml > /dev/null
done
fi
shopt -s nullglob
files=()
for dir in "$@"; do files+=("$dir"/*.tgz); done
files+=("$npm_dir"/*.tgz)
list=$(mktemp)
for file in "${files[@]}"; do
IFS=$'\t' read -r name version config install < <(tar -xzOf "$file" package/package.json |
jq -r '[.name, .version, ((.publishConfig // {}) | keys - ["access"] | length > 0),
((.scripts // {}) | (has("preinstall") or has("install") or has("postinstall")))] | @tsv')
# shellcheck disable=SC2086 # $expected is a word list
printf '%s\n' $expected | grep -qxF -- "$name" || die "Unexpected package $name in $file"
# The signed copy of a macOS or Windows CLI package replaces the unsigned one from the build.
if cut -f1 "$list" | grep -qxF -- "$name"; then continue; fi
case "$name:$file" in
@opencode/cli-darwin-*:"$npm_dir"/* | @opencode/cli-windows-*:"$npm_dir"/*) die "$name is not signed" ;;
esac
[ "$version" = "$OPENCODE_VERSION" ] || die "$name has version $version, expected $OPENCODE_VERSION"
[ "$config" = false ] || die "$name sets publishConfig beyond access"
[ "$install" = false ] || [ "$name" = @opencode/cli ] || [ "$name" = @opencode/cli-node ] || die "$name has an install script"
printf '%s\t%s\n' "$name" "$file" >> "$list"
done
for name in $expected; do cut -f1 "$list" | grep -qxF -- "$name" || die "Missing package $name"; done
# The CLI wrappers resolve their platform packages from postinstall, so they publish last.
packages=$(mktemp)
wrappers=$(mktemp)
grep -vP '^@opencode/cli(-node)?\t' "$list" > "$packages" || true
grep -P '^@opencode/cli(-node)?\t' "$list" > "$wrappers" || true
cat "$packages" "$wrappers"
# A clean directory and config, so nothing from an artifact can redirect the registry.
printf 'registry=https://registry.npmjs.org/\n' > "$RUNNER_TEMP/npmrc"
export NPM_CONFIG_USERCONFIG="$RUNNER_TEMP/npmrc"
cd "$(mktemp -d)"
flags=(--tag "$OPENCODE_NPM_TAG" --access public --ignore-scripts)
if dry_run; then flags+=(--dry-run); else flags+=(--provenance); fi
publish() {
while IFS=$'\t' read -r name file; do
if ! dry_run && npm view "$name@$OPENCODE_VERSION" version > /dev/null 2>&1; then
echo "already published $name@$OPENCODE_VERSION"
continue
fi
npm publish "$file" "${flags[@]}"
done < "$1"
}
# npm publish returns while the registry is still processing the version: a large platform tarball can take ten
# minutes to become available, and versions appear out of publish order. A wrapper published in that window makes
# its postinstall fail with ETARGET, and rolling the dist-tag back does not repair an install that already failed,
# so wait for every other package to resolve at this version before publishing the wrappers.
wait_for_registry() {
if dry_run; then return; fi
while IFS= read -r name; do
for attempt in $(seq 1 180); do
if npm view --prefer-online "$name@$OPENCODE_VERSION" version > /dev/null 2>&1; then break; fi
if [ "$attempt" = 180 ]; then die "$name@$OPENCODE_VERSION did not appear in the registry"; fi
echo "waiting for $name@$OPENCODE_VERSION"
sleep 10
done
done < <(cut -f1 "$1")
}
publish "$packages"
wait_for_registry "$packages"
publish "$wrappers"

View file

@ -1,19 +0,0 @@
#!/usr/bin/env bash
. "$(dirname "$0")/lib.sh"
version=${GITHUB_REF_NAME#process-daemon-v}
[[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]] || die 'Invalid daemon version'
registry=https://registry.npmjs.org
# Validate every package before the first write. Publish the dispatcher last.
packages=(pty-darwin-{arm64,x64} pty-linux-{arm64,x64}-{gnu,musl} pty-win32-{arm64,x64} pty)
for package in "${packages[@]}"; do
file="$1/opencode-$package-$version.tgz"
tar -xOzf "$file" package/package.json | jq -es --arg name "@opencode/$package" --arg version "$version" '
length == 1 and (.[0] | .name == $name and .version == $version and
((.publishConfig // {}) | del(.access) == {}))' >/dev/null || die "Unexpected manifest for $package"
done
for package in "${packages[@]}"; do
if ! npm view --registry="$registry" "@opencode/$package@$version" version >/dev/null 2>&1; then
npm publish --registry="$registry" --ignore-scripts --access public --provenance "$1/opencode-$package-$version.tgz"
fi
done

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# publish-version-pr.sh <sha>: opens the pull request that brings the release commit (versions and changelog) back to dev.
# Pushing to dev is blocked by rulesets, so this never merges.
. "$(dirname "$0")/lib.sh"
branch="release-v$OPENCODE_VERSION"
gh api "repos/$GH_REPO/git/refs" -f "ref=refs/heads/$branch" -f "sha=$1" > /dev/null ||
gh api "repos/$GH_REPO/git/refs/heads/$branch" > /dev/null
body="Brings the versions and changelog of the published \`v$OPENCODE_VERSION\` release back to \`dev\`. The \`v$OPENCODE_VERSION\` tag points at this commit."
gh pr create --base dev --head "$branch" --title "release: v$OPENCODE_VERSION" --body "$body" ||
echo "::warning::Could not open the release PR. Open it by hand: gh pr create --base dev --head $branch"

View file

@ -1,80 +0,0 @@
#!/usr/bin/env bash
# render-aur.sh <build-npm dir> <aur dir>: writes PKGBUILD, .SRCINFO and the opencode2 shim for opencode-beta.
# The package installs the published npm tarballs, so their hashes come from the build-npm artifact.
# LICENSE comes from the AUR repository itself.
. "$(dirname "$0")/lib.sh"
npm=$1 aur=$2
name=opencode-beta
pkgver="${OPENCODE_VERSION//-/.}"
if dry_run && [ ! -f "$aur/LICENSE" ]; then printf 'MIT License\n' > "$aur/LICENSE"; fi
test -s "$aur/LICENSE" || die "The AUR repository has no LICENSE"
printf '#!/bin/sh\nexec "$(dirname "$0")/opencode" "$@"\n' > "$aur/opencode2"
sum() { sha256 "$1" | cut -c1-64; }
x64=$(sum "$npm/opencode-cli-linux-x64-baseline-$OPENCODE_VERSION.tgz")
arm64=$(sum "$npm/opencode-cli-linux-arm64-$OPENCODE_VERSION.tgz")
x64_url="https://registry.npmjs.org/@opencode/cli-linux-x64-baseline/-/cli-linux-x64-baseline-$OPENCODE_VERSION.tgz"
arm64_url="https://registry.npmjs.org/@opencode/cli-linux-arm64/-/cli-linux-arm64-$OPENCODE_VERSION.tgz"
license=$(sum "$aur/LICENSE")
shim=$(sum "$aur/opencode2")
# Stripping a compiled Bun executable can damage its embedded application.
cat > "$aur/PKGBUILD" <<PKGBUILD
# Maintainer: Dax <mail@thdxr.com>
pkgname=$name
pkgver=$pkgver
pkgrel=1
pkgdesc='OpenCode beta - the AI coding agent for the terminal'
url='https://github.com/anomalyco/opencode'
arch=('x86_64' 'aarch64')
license=('MIT')
depends=('glibc' 'gcc-libs' 'ripgrep')
provides=('opencode' 'opencode2')
conflicts=('opencode' 'opencode2')
options=('!strip' '!debug')
source=('LICENSE' 'opencode2')
sha256sums=('$license' '$shim')
source_x86_64=('$name-$pkgver-x86_64.tgz::$x64_url')
sha256sums_x86_64=('$x64')
source_aarch64=('$name-$pkgver-aarch64.tgz::$arm64_url')
sha256sums_aarch64=('$arm64')
package() {
install -Dm755 "\$srcdir/package/bin/opencode" "\$pkgdir/usr/bin/opencode"
install -Dm755 "\$srcdir/opencode2" "\$pkgdir/usr/bin/opencode2"
install -Dm644 "\$srcdir/LICENSE" "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
}
PKGBUILD
# What makepkg --printsrcinfo prints for the PKGBUILD above.
t=$'\t'
cat > "$aur/.SRCINFO" <<SRCINFO
pkgbase = $name
${t}pkgdesc = OpenCode beta - the AI coding agent for the terminal
${t}pkgver = $pkgver
${t}pkgrel = 1
${t}url = https://github.com/anomalyco/opencode
${t}arch = x86_64
${t}arch = aarch64
${t}license = MIT
${t}depends = glibc
${t}depends = gcc-libs
${t}depends = ripgrep
${t}provides = opencode
${t}provides = opencode2
${t}conflicts = opencode
${t}conflicts = opencode2
${t}options = !strip
${t}options = !debug
${t}source = LICENSE
${t}source = opencode2
${t}sha256sums = $license
${t}sha256sums = $shim
${t}source_x86_64 = $name-$pkgver-x86_64.tgz::$x64_url
${t}sha256sums_x86_64 = $x64
${t}source_aarch64 = $name-$pkgver-aarch64.tgz::$arm64_url
${t}sha256sums_aarch64 = $arm64
pkgname = $name
SRCINFO
cat "$aur/PKGBUILD" "$aur/.SRCINFO"

View file

@ -1,47 +0,0 @@
#!/usr/bin/env bash
# render-homebrew.sh <sign-macos dir> <build-archives dir> <tap dir>: writes Formula opencode-v2.rb with the
# hashes of the signed macOS and the Linux archives.
. "$(dirname "$0")/lib.sh"
macos=$1 archives=$2 tap=$3
sum() { sha256 "$1" | cut -c1-64; }
base="https://opencode.ai/files/bin/$OPENCODE_VERSION"
cat > "$tap/opencode-v2.rb" <<FORMULA
# typed: false
# frozen_string_literal: true
class OpencodeV2 < Formula
desc "OpenCode V2 - the AI coding agent for the terminal"
homepage "https://github.com/anomalyco/opencode"
version "$OPENCODE_VERSION"
license "MIT"
depends_on "ripgrep"
conflicts_with "opencode", because: "both install an opencode binary"
on_macos do
if Hardware::CPU.arm?
url "$base/opencode-darwin-arm64.zip"
sha256 "$(sum "$macos/opencode-darwin-arm64.zip")"
else
url "$base/opencode-darwin-x64-baseline.zip"
sha256 "$(sum "$macos/opencode-darwin-x64-baseline.zip")"
end
end
on_linux do
if Hardware::CPU.arm?
url "$base/opencode-linux-arm64.tar.gz"
sha256 "$(sum "$archives/opencode-linux-arm64.tar.gz")"
else
url "$base/opencode-linux-x64-baseline.tar.gz"
sha256 "$(sum "$archives/opencode-linux-x64-baseline.tar.gz")"
end
end
def install
bin.install "opencode"
end
end
FORMULA
cat "$tap/opencode-v2.rb"

View file

@ -1,45 +0,0 @@
#!/usr/bin/env bash
# render-winget.sh <sign-windows dir> <sign-desktop-windows-installer dir> <out dir>: writes the WinGet manifests for
# Anomaly.OpenCode and Anomaly.OpenCode.Desktop. Submission to microsoft/winget-pkgs is paused until the packages
# are accepted, so the workflow only uploads them.
. "$(dirname "$0")/lib.sh"
cli=$1 desktop=$2 out=$3
sum() { sha256 "$1" | cut -c1-64 | tr a-f A-F; }
base="https://opencode.ai/files/bin/$OPENCODE_VERSION"
date=$(date -u +%F)
header() {
printf '# yaml-language-server: $schema=https://aka.ms/winget-manifest.%s.1.12.0.schema.json\n\nPackageIdentifier: %s\nPackageVersion: %s\n' \
"$2" "$1" "$OPENCODE_VERSION"
}
footer() { printf 'ManifestType: %s\nManifestVersion: 1.12.0\n' "$1"; }
manifests() {
local id=$1 name=$2 description=$3 moniker=$4
shift 4
mkdir -p "$out/$id"
{ header "$id" version; echo "DefaultLocale: en-US"; footer version; } > "$out/$id/$id.yaml"
{ header "$id" installer; printf '%s\n' "$@" "ReleaseDate: $date"; footer installer; } > "$out/$id/$id.installer.yaml"
{
header "$id" defaultLocale
printf '%s\n' "PackageLocale: en-US" "Publisher: OpenCode" "PublisherUrl: https://anoma.ly/" \
"PublisherSupportUrl: https://github.com/anomalyco/opencode/issues" "PrivacyUrl: https://opencode.ai/legal/privacy-policy" \
"PackageName: $name" "PackageUrl: https://opencode.ai/" "License: MIT" "LicenseUrl: https://github.com/anomalyco/opencode/blob/HEAD/LICENSE" \
"ShortDescription: $description" "Moniker: $moniker" "Tags:" "- ai" "- coding-agent" "- developer-tools" \
"Documentations:" "- DocumentLabel: Docs" " DocumentUrl: https://opencode.ai/docs"
footer defaultLocale
} > "$out/$id/$id.locale.en-US.yaml"
}
manifests Anomaly.OpenCode "OpenCode CLI" "The open source AI coding agent for the terminal." opencode \
"InstallerType: zip" "NestedInstallerType: portable" "NestedInstallerFiles:" \
"- RelativeFilePath: opencode.exe" " PortableCommandAlias: opencode" "Commands:" "- opencode" "Installers:" \
"- Architecture: x64" " InstallerUrl: $base/opencode-windows-x64-baseline.zip" " InstallerSha256: $(sum "$cli/opencode-windows-x64-baseline.zip")" \
"- Architecture: arm64" " InstallerUrl: $base/opencode-windows-arm64.zip" " InstallerSha256: $(sum "$cli/opencode-windows-arm64.zip")"
# The display name and uninstall key match what the NSIS installer registers for ai.opencode.desktop.
manifests Anomaly.OpenCode.Desktop "OpenCode" "The open source AI coding agent as a desktop app." opencode-desktop \
"InstallerType: nullsoft" "Scope: user" "UpgradeBehavior: install" "ProductCode: d074f30d-5f88-5885-b075-be1348cc7676" \
"Protocols:" "- opencode" "Installers:" \
"- Architecture: x64" " InstallerUrl: $base/opencode-desktop-win-x64.exe" " InstallerSha256: $(sum "$desktop/opencode-desktop-win-x64.exe")" \
"- Architecture: arm64" " InstallerUrl: $base/opencode-desktop-win-arm64.exe" " InstallerSha256: $(sum "$desktop/opencode-desktop-win-arm64.exe")"
tail -n +1 "$out"/*/*

View file

@ -1,13 +0,0 @@
#!/usr/bin/env bash
# repack-windows.sh <work dir> <out dir>: checks every signature in <work dir>, then writes the signed CLI back
# into npm tarballs and opencode-<target>.zip archives in <out dir>.
. "$(dirname "$0")/lib.sh"
work=$(posix "$1") out=$(posix "$2")
bash "$release_dir/verify-signatures-windows.sh" "$work"
mkdir -p "$out"
if [ ! -d "$work/cli" ]; then exit 0; fi
for target in windows-arm64 windows-x64 windows-x64-baseline; do
tar -czf "$out/opencode-cli-$target-$OPENCODE_VERSION.tgz" -C "$work/cli/$target" package
powershell -NoProfile -Command "Compress-Archive -Path '$(cygpath -w "$work/cli/$target/package/bin/opencode.exe")' -DestinationPath '$(cygpath -w "$out/opencode-$target.zip")'"
done

View file

@ -1,28 +0,0 @@
#!/usr/bin/env bash
# sign-cli-macos.sh <build-npm dir> <out dir>: signs the three macOS CLI binaries inside their npm tarballs with
# the Developer ID in build.keychain, then writes the re-packed tarballs and the opencode-<target>.zip archives.
# Dry runs sign ad-hoc.
. "$(dirname "$0")/lib.sh"
in=$1 out=$2
mkdir -p "$out"
identity=- timestamp=--timestamp=none
if ! dry_run; then
identity=$(security find-identity -v -p codesigning build.keychain | sed -n 's/.*"\(Developer ID Application:.*\)"/\1/p' | head -n 1)
[ -n "$identity" ] || die "Developer ID Application identity not found"
timestamp=--timestamp
fi
export COPYFILE_DISABLE=1
for target in darwin-arm64 darwin-x64 darwin-x64-baseline; do
work=$(mktemp -d)
tar -xzf "$in/opencode-cli-$target-$OPENCODE_VERSION.tgz" -C "$work"
bin="$work/package/bin/opencode"
file -b "$bin" | grep -q '^Mach-O' || die "$target is not a Mach-O binary"
chmod 755 "$bin"
codesign --force "$timestamp" --options runtime --entitlements "$release_dir/entitlements/cli.plist" --sign "$identity" "$bin"
codesign --verify --strict --verbose=2 "$bin"
tar --no-mac-metadata -czf "$out/opencode-cli-$target-$OPENCODE_VERSION.tgz" -C "$work" package
touch -t 198001010000 "$bin"
(cd "$work/package/bin" && zip -X -q "$out/opencode-$target.zip" opencode)
done

View file

@ -1,88 +0,0 @@
#!/usr/bin/env bash
# sign-desktop-macos.sh <out dir> <app tarball>...: signs each unsigned .app inside-out with hardened runtime,
# notarizes them in one submission, staples them, and only then builds opencode-desktop-mac-<arch>.{zip,dmg,app.tar.gz}
# from the stapled apps. Dry runs sign ad-hoc and skip notarization. Dev and beta trade larger files for faster
# packaging (zip and dmg at zlib level 1) and skip the .app.tar.gz, which only the retired Tauri updater feed read.
# Notarization reads APPLE_NOTARY_KEY (the .p8 contents), APPLE_NOTARY_KEY_ID and APPLE_NOTARY_ISSUER_ID.
. "$(dirname "$0")/lib.sh"
out=$1
shift
mkdir -p "$out"
apps=$(mktemp -d)
identity=- timestamp=--timestamp=none
zip_level=() dmg_level=() preview=false
case "$OPENCODE_CHANNEL" in dev | beta) preview=true ;; esac
if [ "$preview" = true ]; then zip_level=(--zlibCompressionLevel 1) dmg_level=(-imagekey zlib-level=1); fi
if ! dry_run; then
identity=$(security find-identity -v -p codesigning build.keychain | sed -n 's/.*"\(Developer ID Application:.*\)"/\1/p' | head -n 1)
[ -n "$identity" ] || die "Developer ID Application identity not found"
timestamp=--timestamp
fi
sign() {
codesign --force "$timestamp" --options runtime --entitlements "$2" --sign "$identity" "$1"
}
bundle() {
find "$apps/$1" -mindepth 1 -maxdepth 1 -name '*.app' -type d
}
for tarball in "$@"; do
arch=$(basename "$tarball" .app.tar)
arch=${arch#opencode-desktop-mac-}
[ "$arch" = arm64 ] || [ "$arch" = x64 ] || die "Unexpected app tarball: $tarball"
mkdir -p "$apps/$arch"
tar -xf "$tarball" -C "$apps/$arch"
if [ "$(find "$apps/$arch" -mindepth 1 -maxdepth 1 | wc -l | tr -d ' ')" != 1 ] || [ -z "$(bundle "$arch")" ]; then
die "Expected exactly one .app bundle in $tarball"
fi
app=$(bundle "$arch")
# Every nested Mach-O file and bundle, deepest first, then the app itself.
list=$(mktemp)
{
find "$app/Contents" -type f -print0 | while IFS= read -r -d '' file; do
case "$(file -b --mime-type "$file")" in application/x-mach-binary*) printf '%s\n' "$file" ;; esac
done
find "$app/Contents" -type d \( -name '*.app' -o -name '*.framework' \) -print
} | awk -F/ '{ print NF "\t" $0 }' | sort -t "$(printf '\t')" -k1,1nr | cut -f2- > "$list"
echo "Signing $(wc -l < "$list" | tr -d ' ') items in $app"
while IFS= read -r item; do
if [ "$item" = "$app/Contents/Resources/opencode-cli" ]; then
# The bundled Bun CLI loads bun-pty's native library; Electron and its helpers do not need this exception.
sign "$item" "$release_dir/entitlements/desktop-cli.plist"
else
sign "$item" "$release_dir/entitlements/desktop.plist"
fi
done < "$list"
sign "$app" "$release_dir/entitlements/desktop.plist"
codesign --verify --deep --strict --verbose=2 "$app"
done
if ! dry_run; then
key=$(mktemp)
printf '%s\n' "$APPLE_NOTARY_KEY" > "$key"
ditto -c -k --sequesterRsrc "$apps" "$apps.zip"
xcrun notarytool submit "$apps.zip" --key "$key" --key-id "$APPLE_NOTARY_KEY_ID" --issuer "$APPLE_NOTARY_ISSUER_ID" \
--wait --timeout 60m --output-format json > "$apps.json"
rm -f "$key"
cat "$apps.json"
[ "$(jq -r .status "$apps.json")" = Accepted ] || die "Notarization was not accepted"
fi
for dir in "$apps"/*; do
arch=$(basename "$dir")
app=$(bundle "$arch")
name=$(basename "$app")
if ! dry_run; then
xcrun stapler staple "$app"
xcrun stapler validate "$app"
spctl --assess --type execute --verbose=2 "$app"
fi
ditto -c -k ${zip_level[@]+"${zip_level[@]}"} --sequesterRsrc --keepParent "$app" "$out/opencode-desktop-mac-$arch.zip"
staging=$(mktemp -d)
ditto "$app" "$staging/$name"
ln -s /Applications "$staging/Applications"
hdiutil create -volname "${name%.app}" -srcfolder "$staging" -fs HFS+ -format UDZO ${dmg_level[@]+"${dmg_level[@]}"} -ov "$out/opencode-desktop-mac-$arch.dmg"
if [ "$preview" = true ]; then continue; fi
COPYFILE_DISABLE=1 tar --no-mac-metadata -czf "$out/opencode-desktop-mac-$arch.app.tar.gz" -C "$dir" "$name"
done

View file

@ -1,51 +0,0 @@
#!/usr/bin/env bash
# tag-release.sh: in a checkout of the dispatched dev commit, commits the release versions and changelog
# (OPENCODE_RELEASE_NOTES) and pushes only the v<version> tag at it. Writes sha=<commit> to $GITHUB_OUTPUT.
# Runs git only, with hooks disabled; no repository code.
. "$(dirname "$0")/lib.sh"
tag="v$OPENCODE_VERSION"
if ! dry_run; then
umask 077
ssh_dir=$(mktemp -d)
trap 'rm -rf "$ssh_dir"' EXIT
printf '%s\n' "$RELEASE_TAG_KEY" > "$ssh_dir/key"
unset RELEASE_TAG_KEY
echo 'github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl' > "$ssh_dir/known_hosts"
export GIT_SSH_COMMAND="ssh -i $ssh_dir/key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$ssh_dir/known_hosts"
git remote set-url origin git@github.com:anomalyco/opencode.git
fi
# @opencode/pty is versioned separately, by process-daemon-v<version> tags.
git ls-files -z -- '*package.json' bun.lock ':!packages/process-daemon/**' | xargs -0 sed -i -E "s/\"version\": \"[^\"]+\"/\"version\": \"$OPENCODE_VERSION\"/g"
if [ -n "${OPENCODE_RELEASE_NOTES:-}" ] && ! grep -qF -x "## $tag" CHANGELOG.md && ! grep -qF "## $tag " CHANGELOG.md; then
notes=$(mktemp)
printf '%s\n' "$OPENCODE_RELEASE_NOTES" > "$notes"
awk -v entry="## $tag — $(date -u +%F)" -v notes="$notes" '
function emit() { print entry; print ""; while ((getline line < notes) > 0) print line; print ""; done = 1 }
!done && /^## / { emit() }
{ print }
END { if (!done) { print ""; emit() } }
' CHANGELOG.md > "$notes.md"
mv "$notes.md" CHANGELOG.md
fi
if git diff --name-only | grep -vE '(^|/)package\.json$|^bun\.lock$|^CHANGELOG\.md$'; then
die "The release commit may only change versions and the changelog"
fi
git -c core.hooksPath=/dev/null \
-c user.name="github-actions[bot]" \
-c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit --no-verify -q -am "release: $tag"
# A rerun reuses the tag when it holds the same tree.
existing=$(git ls-remote origin "refs/tags/$tag" | cut -f1)
if [ -n "$existing" ]; then
git fetch -q --depth=1 origin "refs/tags/$tag"
[ "$(git rev-parse "$existing^{tree}")" = "$(git rev-parse "HEAD^{tree}")" ] || die "Tag $tag already exists with different contents"
echo "sha=$existing" >> "$GITHUB_OUTPUT"
exit 0
fi
if ! dry_run; then git push -q origin "HEAD:refs/tags/$tag"; fi
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

View file

@ -1,20 +0,0 @@
# Pinned deploy targets
These files are the allow-list for the deploy jobs that hold a Cloudflare
token. `deploy-*.sh` refuses an artifact whose resolved config is not exactly
one of these files, then deploys the pinned config (never the artifact's copy).
The deploy token can write every Worker on the account (the data sync Workflow
needs account-wide `Workers Scripts Write`; Cloudflare has no per-Worker
Workflows permission), so changing what a stage can deploy means changing these
files, which CODEOWNERS (`/.github/ @thdxr`) reviews.
- `site/`, `legacy/`, `data/`: expected `v0/config.json` and
`v0/workers/<dir>/worker.config.json` from the `cf` Build Output artifact.
- `files/`, `update/`: the complete `wrangler.json` the deploy script passes to
the pinned wrangler CLI. The artifact is only the bundled `index.js`; these
services have no config in the artifact to trust.
A Worker's own code and assets are expected to change freely. Names, routes,
custom domains, crons, Workflow/export names, and every binding (including
service bindings to other Workers) are pinned here.

View file

@ -1,39 +0,0 @@
{
"name": "opencode-data-dev",
"compatibilityDate": "2026-07-25",
"compatibilityFlags": ["nodejs_compat"],
"triggers": [
{ "type": "fetch", "pattern": "dev.opencode.ai/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/en/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/zh/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/zht/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/ko/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/de/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/es/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/fr/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/it/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/da/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/ja/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/pl/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/ru/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/uk/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/ar/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/no/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/br/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/th/data*", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/tr/data*", "zone": "dev.opencode.ai" }
],
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"env": {
"ASSETS": { "type": "assets" },
"OG_WORKER": { "type": "worker", "worker": "opencode-data-og-dev" },
"STAGE": { "type": "text", "value": "dev" },
"PUBLIC_URL": { "type": "text", "value": "https://dev.opencode.ai/data" },
"DATA_DATABASE_HOST": { "type": "secret" },
"DATA_DATABASE_USERNAME": { "type": "secret" },
"DATA_DATABASE_PASSWORD": { "type": "secret" }
},
"manifest": { "type": "partial", "mainModule": "index.mjs", "modules": {} }
}

View file

@ -1,20 +0,0 @@
{
"name": "opencode-data-og-dev",
"compatibilityDate": "2026-07-01",
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"manifest": {
"type": "partial",
"mainModule": "index.mjs",
"modules": {
"harfbuzz.wasm": { "type": "wasm" },
"satori-layout.wasm": { "type": "wasm" },
"resvg.wasm": { "type": "wasm" },
"openmono-regular-rest.bin": { "type": "data" },
"openmono-regular-latin.bin": { "type": "data" },
"openmono-bold-rest.bin": { "type": "data" },
"openmono-bold-latin.bin": { "type": "data" }
}
}
}

View file

@ -1,4 +0,0 @@
{
"accountId": "d8e944f537ceef3f06a5bd3aec1d7a53",
"buildContext": { "isPreview": false, "mode": "dev" }
}

View file

@ -1,32 +0,0 @@
{
"name": "opencode-data-sync-dev",
"compatibilityDate": "2026-07-25",
"compatibilityFlags": ["nodejs_compat"],
"triggers": [
{ "type": "scheduled", "schedule": "5 * * * *" },
{ "type": "scheduled", "schedule": "20 3 * * *" }
],
"limits": { "cpuMs": 300000 },
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"env": {
"DataSyncWorkflow": {
"type": "workflow",
"name": "opencode-data-sync-dev",
"worker": "opencode-data-sync-dev",
"exportName": "DataSyncWorkflow"
},
"STAGE": { "type": "text", "value": "dev" },
"R2_SQL_ACCOUNT_ID": { "type": "text", "value": "d8e944f537ceef3f06a5bd3aec1d7a53" },
"DATA_DATABASE_HOST": { "type": "secret" },
"DATA_DATABASE_USERNAME": { "type": "secret" },
"DATA_DATABASE_PASSWORD": { "type": "secret" },
"R2_SQL_AUTH_TOKEN": { "type": "secret" },
"DATA_HIDDEN_MODELS": { "type": "secret" }
},
"exports": {
"DataSyncWorkflow": { "type": "workflow", "name": "opencode-data-sync-dev" }
},
"manifest": { "type": "partial", "mainModule": "index.mjs", "modules": {} }
}

View file

@ -1,39 +0,0 @@
{
"name": "opencode-data-production",
"compatibilityDate": "2026-07-25",
"compatibilityFlags": ["nodejs_compat"],
"triggers": [
{ "type": "fetch", "pattern": "opencode.ai/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/en/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/zh/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/zht/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/ko/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/de/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/es/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/fr/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/it/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/da/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/ja/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/pl/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/ru/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/uk/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/ar/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/no/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/br/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/th/data*", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/tr/data*", "zone": "opencode.ai" }
],
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"env": {
"ASSETS": { "type": "assets" },
"OG_WORKER": { "type": "worker", "worker": "opencode-data-og-production" },
"STAGE": { "type": "text", "value": "production" },
"PUBLIC_URL": { "type": "text", "value": "https://opencode.ai/data" },
"DATA_DATABASE_HOST": { "type": "secret" },
"DATA_DATABASE_USERNAME": { "type": "secret" },
"DATA_DATABASE_PASSWORD": { "type": "secret" }
},
"manifest": { "type": "partial", "mainModule": "index.mjs", "modules": {} }
}

View file

@ -1,20 +0,0 @@
{
"name": "opencode-data-og-production",
"compatibilityDate": "2026-07-01",
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"manifest": {
"type": "partial",
"mainModule": "index.mjs",
"modules": {
"harfbuzz.wasm": { "type": "wasm" },
"satori-layout.wasm": { "type": "wasm" },
"resvg.wasm": { "type": "wasm" },
"openmono-regular-rest.bin": { "type": "data" },
"openmono-regular-latin.bin": { "type": "data" },
"openmono-bold-rest.bin": { "type": "data" },
"openmono-bold-latin.bin": { "type": "data" }
}
}
}

View file

@ -1,4 +0,0 @@
{
"accountId": "15d29c8639fd3733b1b5486a2acfd968",
"buildContext": { "isPreview": false, "mode": "production" }
}

View file

@ -1,31 +0,0 @@
{
"name": "opencode-data-sync-production",
"compatibilityDate": "2026-07-25",
"compatibilityFlags": ["nodejs_compat"],
"triggers": [
{ "type": "scheduled", "schedule": "5 * * * *" },
{ "type": "scheduled", "schedule": "20 3 * * *" }
],
"limits": { "cpuMs": 300000 },
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"env": {
"DataSyncWorkflow": {
"type": "workflow",
"name": "opencode-data-sync-production",
"worker": "opencode-data-sync-production",
"exportName": "DataSyncWorkflow"
},
"STAGE": { "type": "text", "value": "production" },
"DATA_DATABASE_HOST": { "type": "secret" },
"DATA_DATABASE_USERNAME": { "type": "secret" },
"DATA_DATABASE_PASSWORD": { "type": "secret" },
"R2_SQL_AUTH_TOKEN": { "type": "secret" },
"DATA_HIDDEN_MODELS": { "type": "secret" }
},
"exports": {
"DataSyncWorkflow": { "type": "workflow", "name": "opencode-data-sync-production" }
},
"manifest": { "type": "partial", "mainModule": "index.mjs", "modules": {} }
}

View file

@ -1,12 +0,0 @@
{
"name": "opencode-dev-files",
"account_id": "d8e944f537ceef3f06a5bd3aec1d7a53",
"main": "index.js",
"no_bundle": true,
"compatibility_date": "2026-08-01",
"workers_dev": false,
"preview_urls": false,
"vars": { "STAGE": "dev" },
"routes": [{ "pattern": "dev.opencode.ai/files/*", "zone_name": "dev.opencode.ai" }],
"r2_buckets": [{ "binding": "FILES", "bucket_name": "opencode-dev-files" }]
}

View file

@ -1,11 +0,0 @@
{
"name": "opencode-production-files",
"main": "index.js",
"no_bundle": true,
"compatibility_date": "2026-08-01",
"workers_dev": false,
"preview_urls": false,
"vars": { "STAGE": "production" },
"routes": [{ "pattern": "opencode.ai/files/*", "zone_name": "opencode.ai" }],
"r2_buckets": [{ "binding": "FILES", "bucket_name": "opencode-production-files" }]
}

View file

@ -1,4 +0,0 @@
{
"accountId": "d8e944f537ceef3f06a5bd3aec1d7a53",
"buildContext": { "isPreview": false, "mode": "dev" }
}

View file

@ -1,18 +0,0 @@
{
"name": "opencode-legacy-dev",
"compatibilityDate": "2026-07-25",
"compatibilityFlags": ["nodejs_compat"],
"domains": ["dev.opncd.ai", "api.dev.opencode.ai"],
"logpush": false,
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"manifest": {
"type": "complete",
"mainModule": "index.js",
"modules": {
"index.js": { "type": "esm" },
"index.js.map": { "type": "sourcemap" }
}
}
}

View file

@ -1,4 +0,0 @@
{
"accountId": "15d29c8639fd3733b1b5486a2acfd968",
"buildContext": { "isPreview": false, "mode": "production" }
}

View file

@ -1,22 +0,0 @@
{
"name": "opencode-legacy-production",
"compatibilityDate": "2026-07-25",
"compatibilityFlags": ["nodejs_compat"],
"domains": ["opncd.ai", "api.opencode.ai"],
"logpush": true,
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"env": {
"GITHUB_APP_ID": { "type": "secret" },
"GITHUB_APP_PRIVATE_KEY": { "type": "secret" }
},
"manifest": {
"type": "complete",
"mainModule": "index.js",
"modules": {
"index.js": { "type": "esm" },
"index.js.map": { "type": "sourcemap" }
}
}
}

View file

@ -1,4 +0,0 @@
{
"accountId": "d8e944f537ceef3f06a5bd3aec1d7a53",
"buildContext": { "isPreview": false, "mode": "dev" }
}

View file

@ -1,38 +0,0 @@
{
"name": "opencode-site-dev",
"compatibilityDate": "2026-07-25",
"compatibilityFlags": ["nodejs_compat"],
"assets": {
"htmlHandling": "drop-trailing-slash",
"runWorkerFirst": [
"/docs",
"/docs/*",
"!/docs/_build/*",
"!/docs/assets/*",
"!/docs/pagefind/*",
"!/docs/favicon.svg",
"!/docs/llms.txt",
"!/docs/sitemap.xml",
"!/docs/openapi.json",
"/v1/docs",
"/v1/docs/*",
"!/v1/docs/assets/*",
"!/v1/docs/pagefind/*",
"!/v1/docs/llms.txt",
"!/v1/docs/theme.json"
]
},
"domains": ["dev.opencode.ai", "docs.dev.opencode.ai"],
"triggers": [
{ "type": "fetch", "pattern": "dev.opencode.ai", "zone": "dev.opencode.ai" },
{ "type": "fetch", "pattern": "dev.opencode.ai/*", "zone": "dev.opencode.ai" }
],
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"env": {
"ASSETS": { "type": "assets" },
"STAGE": { "type": "text", "value": "dev" }
},
"manifest": { "type": "partial", "mainModule": "index.mjs", "modules": {} }
}

View file

@ -1,4 +0,0 @@
{
"accountId": "15d29c8639fd3733b1b5486a2acfd968",
"buildContext": { "isPreview": false, "mode": "production" }
}

View file

@ -1,38 +0,0 @@
{
"name": "opencode-site-production",
"compatibilityDate": "2026-07-25",
"compatibilityFlags": ["nodejs_compat"],
"assets": {
"htmlHandling": "drop-trailing-slash",
"runWorkerFirst": [
"/docs",
"/docs/*",
"!/docs/_build/*",
"!/docs/assets/*",
"!/docs/pagefind/*",
"!/docs/favicon.svg",
"!/docs/llms.txt",
"!/docs/sitemap.xml",
"!/docs/openapi.json",
"/v1/docs",
"/v1/docs/*",
"!/v1/docs/assets/*",
"!/v1/docs/pagefind/*",
"!/v1/docs/llms.txt",
"!/v1/docs/theme.json"
]
},
"domains": ["opencode.ai", "docs.opencode.ai"],
"triggers": [
{ "type": "fetch", "pattern": "opencode.ai", "zone": "opencode.ai" },
{ "type": "fetch", "pattern": "opencode.ai/*", "zone": "opencode.ai" }
],
"observability": { "enabled": true },
"workersDev": false,
"previewUrls": false,
"env": {
"ASSETS": { "type": "assets" },
"STAGE": { "type": "text", "value": "production" }
},
"manifest": { "type": "partial", "mainModule": "index.mjs", "modules": {} }
}

View file

@ -1,21 +0,0 @@
{
"name": "opencode-update",
"main": "index.js",
"no_bundle": true,
"compatibility_date": "2026-07-21",
"workers_dev": false,
"preview_urls": false,
"pipelines": [{ "binding": "EVENTS", "stream": "251a89241c3a461c9007f6b6f345ed8b" }],
"routes": [
{ "pattern": "opencode.ai/update", "zone_name": "opencode.ai" },
{ "pattern": "opencode.ai/update/*", "zone_name": "opencode.ai" }
],
"d1_databases": [
{
"binding": "DB",
"database_name": "opencode-update",
"database_id": "2c010a96-811f-43d5-804d-7188534e5858"
}
],
"observability": { "enabled": true }
}

View file

@ -1,17 +0,0 @@
#!/usr/bin/env bash
# unpack-windows.sh <download dir> <work dir>: lays out what the signing action signs in <work dir>:
# cli/<target>/package from the Windows CLI npm tarballs, and desktop-<target>/ from the unpacked desktop apps.
. "$(dirname "$0")/lib.sh"
in=$(posix "$1") work=$(posix "$2")
mkdir -p "$work"
if [ -d "$in/build-npm" ]; then
for target in windows-arm64 windows-x64 windows-x64-baseline; do
mkdir -p "$work/cli/$target"
tar -xzf "$in/build-npm/opencode-cli-$target-$OPENCODE_VERSION.tgz" -C "$work/cli/$target"
test -s "$work/cli/$target/package/bin/opencode.exe" || die "Missing opencode.exe for $target"
done
fi
for target in windows-arm64 windows-x64; do
if [ -d "$in/build-desktop-$target" ]; then mkdir -p "$work/desktop-$target" && cp -R "$in/build-desktop-$target/app" "$work/desktop-$target/app"; fi
done

View file

@ -1,36 +0,0 @@
name: Upload a release artifact
description: Writes SHA256SUMS for a directory, uploads it, and outputs the manifest digest.
inputs:
name:
description: Artifact name, <stage>-<target>
required: true
path:
description: Directory to upload
required: true
retention-days:
description: Days to keep the artifact (0 keeps the repository default)
required: false
default: "0"
include-hidden-files:
description: Include hidden files (deploy Build Output carries .vite metadata)
required: false
default: "false"
outputs:
digest:
description: SHA-256 of the artifact's SHA256SUMS
value: ${{ steps.checksum.outputs.digest }}
runs:
using: composite
steps:
- id: checksum
shell: bash
run: echo "digest=$(bash "${GITHUB_ACTION_PATH//\\//}/../write-checksums.sh" "$UPLOAD_PATH")" >> "$GITHUB_OUTPUT"
env:
UPLOAD_PATH: ${{ inputs.path }}
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}
retention-days: ${{ inputs.retention-days }}
include-hidden-files: ${{ inputs.include-hidden-files }}
if-no-files-found: error

View file

@ -1,43 +0,0 @@
#!/usr/bin/env bash
# verify-artifacts.sh <dir>: checks every artifact downloaded into <dir>/<name> against its SHA256SUMS and that it
# holds exactly the listed files. Artifacts made by sign jobs (sign-*) must also match the manifest digest their
# job reported (OPENCODE_DIGESTS="name=digest ..."), so an artifact replaced after that job finished is rejected.
# Deploy jobs set OPENCODE_REQUIRE_DIGESTS=true: every artifact must match a reported digest, because the digest
# is what ties the bytes to the build job that made them.
. "$(dirname "$0")/lib.sh"
root=$(posix "$1")
# download-artifact unpacks a lone matching artifact straight into <dir>; put it back under its name, found by
# its manifest's reported digest.
if [ -f "$root/SHA256SUMS" ]; then
lone=$(sha256 "$root/SHA256SUMS" | cut -c1-64)
name=""
for pair in ${OPENCODE_DIGESTS:-}; do
if [ "${pair#*=}" = "$lone" ]; then name=${pair%%=*}; fi
done
[ -n "$name" ] || die "The downloaded artifact's SHA256SUMS does not have a reported digest"
staging=$(mktemp -d)
find "$root" -mindepth 1 -maxdepth 1 -exec mv {} "$staging/" \;
mv "$staging" "$root/$name"
fi
shopt -s nullglob
for dir in "$root"/*/; do
name=$(basename "$dir")
digest=""
for pair in ${OPENCODE_DIGESTS:-}; do
if [ "${pair%%=*}" = "$name" ]; then digest=${pair#*=}; fi
done
if [ "${OPENCODE_REQUIRE_DIGESTS:-false}" = true ]; then
[[ "$digest" =~ ^[0-9a-f]{64}$ ]] || die "Missing digest for $name"
else
case "$name" in sign-*) [[ "$digest" =~ ^[0-9a-f]{64}$ ]] || die "Missing digest for $name" ;; esac
fi
(
cd "$dir"
if [ -n "$digest" ] && [ "$(sha256 SHA256SUMS | cut -c1-64)" != "$digest" ]; then die "SHA256SUMS digest mismatch in $name"; fi
sha256 -c SHA256SUMS > /dev/null || die "Checksum mismatch in $name"
diff <(find . -type f ! -name SHA256SUMS | sed 's|^\./||' | LC_ALL=C sort) <(cut -c67- SHA256SUMS | LC_ALL=C sort) ||
die "Unexpected files in $name"
)
echo "verified $name${digest:+ ($digest)}"
done

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# verify-signatures-windows.sh <dir>: fails unless every .exe and .node under <dir> has a valid Authenticode signature.
. "$(dirname "$0")/lib.sh"
if dry_run; then
echo "dry-run: not verifying signatures in $1"
exit 0
fi
powershell -NoProfile -Command "
\$ErrorActionPreference = 'Stop'
\$files = Get-ChildItem '$(cygpath -w "$(posix "$1")")' -Recurse -Include *.exe, *.node
if (-not \$files) { throw 'No signed files found' }
foreach (\$file in \$files) {
\$sig = Get-AuthenticodeSignature \$file.FullName
if (\$sig.Status -ne 'Valid') { throw \"Invalid signature for \$(\$file.FullName): \$(\$sig.Status)\" }
}
Write-Output \"verified \$(\$files.Count) signatures\"
"

View file

@ -1,21 +0,0 @@
#!/usr/bin/env bash
# Fetch only this command's named secrets; keep credentials out of its environment.
. "$(dirname "$0")/lib.sh"
set +x
while [[ $# -gt 0 && $1 != -- ]]; do
name=${1%%=*} id=${1#*=}
[[ $name =~ ^[A-Z][A-Z0-9_]*$ && $id != "$1" && -n $id ]] || die 'Expected NAME=secret-id'
if ! dry_run; then
value=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "$id" --query SecretString --output text)
[[ -n $value && $value != None ]] || die "Empty secret: $id"
while IFS= read -r line; do
[[ -z $line ]] || printf '::add-mask::%s\n' "${line//%/%25}"
done <<< "$value"
export "$name=$value"
fi
shift
done
[[ ${1:-} == -- && $# -gt 1 ]] || die 'Expected -- command'
shift
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN value
exec "$@"

File diff suppressed because it is too large Load diff

View file

@ -1,7 +0,0 @@
{
"private": true,
"description": "The pinned wrangler CLI deploy-files.sh and deploy-update.sh run; npm ci --ignore-scripts installs exactly package-lock.json.",
"dependencies": {
"wrangler": "4.110.0"
}
}

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
# write-checksums.sh <dir>: writes <dir>/SHA256SUMS for every file under <dir> and prints its digest.
# Every artifact carries this manifest; trusted jobs pass the digest on through job outputs.
. "$(dirname "$0")/lib.sh"
cd "$(posix "$1")"
manifest=$(mktemp)
find . -type f ! -name SHA256SUMS | sed 's|^\./||' | LC_ALL=C sort | while IFS= read -r file; do sha256 "$file"; done > "$manifest"
mv "$manifest" SHA256SUMS
cat SHA256SUMS >&2
sha256 SHA256SUMS | cut -c1-64

View file

@ -1,70 +0,0 @@
name: backfill-blockmaps
# Uploads the .blockmap files electron-updater needs for a differential update next to desktop releases that
# shipped without them (2.2.0 through 2.4.1). Like release.yml's publish jobs, it runs in the release environment,
# checks out only .github/release/ and treats the published files as data; releasers only.
on:
workflow_dispatch:
inputs:
versions:
description: "Space-separated stable versions, such as 2.4.0 2.4.1"
required: true
type: string
dry_run:
description: "Build the blockmaps without uploading them"
required: false
type: boolean
default: true
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
permissions:
contents: read
jobs:
backfill:
if: github.repository == 'anomalyco/opencode' && github.ref == 'refs/heads/dev'
runs-on: ubuntu-24.04
environment: release
permissions:
contents: read
id-token: write
env:
OPENCODE_DRY_RUN: ${{ inputs.dry_run }}
steps:
- name: Check out release scripts
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: ${{ github.sha }}
sparse-checkout: /.github/release/
sparse-checkout-cone-mode: false
persist-credentials: false
- id: aws
name: Configure AWS credentials
if: inputs.dry_run != true
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
output-env-credentials: false
output-credentials: true
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-release
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
- name: Cloudflare token
id: cloudflare-token
if: inputs.dry_run != true
run: bash .github/release/cloudflare-token.sh
env:
AWS_ACCESS_KEY_ID: ${{ steps.aws.outputs.aws-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.aws.outputs.aws-secret-access-key }}
AWS_SESSION_TOKEN: ${{ steps.aws.outputs.aws-session-token }}
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
- name: Backfill
run: |
read -ra versions <<< "$VERSIONS"
bash .github/release/backfill-blockmaps.sh "${versions[@]}"
env:
VERSIONS: ${{ inputs.versions }}
CLOUDFLARE_ACCOUNT_ID: 15d29c8639fd3733b1b5486a2acfd968
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}

View file

@ -1,203 +0,0 @@
name: bot-nix-hashes
# Keeps nix/hashes.json in step with the lockfile through a pull request, using only GITHUB_TOKEN.
# - hash and compute run repository code (nix build) with a read-only token and no secrets. compute uploads only the
# new nix/hashes.json.
# - publish holds the write token. It runs only .github/nix-hashes/ from this commit, treats the artifact as data,
# validates its exact shape and commits only that file to bot/nix-hashes. It never runs repository code.
# - check-bot-scope.yml, a required check, fails the bot's pull request unless it changes only a valid nix/hashes.json,
# so a tampered branch cannot auto-merge.
# This file, check-bot-scope.yml and .github/nix-hashes/ are the security boundary.
permissions:
contents: read
on:
workflow_dispatch:
push:
branches: [dev]
# Mirrored in .github/nix-hashes/publish.sh.
paths:
- "bun.lock"
- "package.json"
- "packages/*/package.json"
- "services/*/package.json"
- "flake.lock"
- "nix/node_modules.nix"
- "nix/scripts/**"
- "patches/**"
- ".github/workflows/bot-nix-hashes.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Native runners required: bun install cross-compilation flags (--os/--cpu)
# do not produce byte-identical node_modules as native installs.
hash:
strategy:
fail-fast: false
matrix:
include:
- system: x86_64-linux
runner: blacksmith-4vcpu-ubuntu-2404
- system: aarch64-linux
runner: blacksmith-4vcpu-ubuntu-2404-arm
- system: aarch64-darwin
runner: blacksmith-6vcpu-macos-latest
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Setup Nix
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
- name: Compute node_modules hash
id: hash
env:
SYSTEM: ${{ matrix.system }}
run: |
set -euo pipefail
BUILD_LOG=$(mktemp)
trap 'rm -f "$BUILD_LOG"' EXIT
HASH=""
MAX_ATTEMPTS=3
for ((ATTEMPT = 1; ATTEMPT <= MAX_ATTEMPTS; ATTEMPT++)); do
# Build with fakeHash to trigger hash mismatch and reveal correct hash
nix build ".#packages.${SYSTEM}.node_modules_updater" --no-link 2>&1 | tee "$BUILD_LOG" || true
HASH="$(nix run --inputs-from . nixpkgs#gnugrep -- -oP 'got:\s*\Ksha256-[A-Za-z0-9+/=]+' "$BUILD_LOG" | tail -n1 || true)"
[ -n "$HASH" ] && break
if [ "$ATTEMPT" -lt "$MAX_ATTEMPTS" ]; then
echo "::warning::Attempt ${ATTEMPT}/${MAX_ATTEMPTS} produced no hash for ${SYSTEM}; retrying in $((ATTEMPT * 10))s"
sleep $((ATTEMPT * 10))
fi
done
if [ -z "$HASH" ]; then
echo "::error::Failed to compute hash for ${SYSTEM} after ${MAX_ATTEMPTS} attempts"
cat "$BUILD_LOG"
exit 1
fi
echo "$HASH" > hash.txt
echo "Computed hash for ${SYSTEM}: $HASH"
- name: Upload hash
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: hash-${{ matrix.system }}
path: hash.txt
retention-days: 1
# Assembles nix/hashes.json from the per-system hashes and uploads it as the only input publish accepts.
compute:
needs: hash
runs-on: ubuntu-24.04
outputs:
changed: ${{ steps.update.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- name: Download hash artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: ${{ runner.temp }}/hashes
pattern: hash-*
- name: Update hashes.json
id: update
env:
HASHES: ${{ runner.temp }}/hashes
run: |
set -euo pipefail
HASH_FILE="nix/hashes.json"
[ -f "$HASH_FILE" ] || echo '{"nodeModules":{}}' > "$HASH_FILE"
for SYSTEM in x86_64-linux aarch64-linux aarch64-darwin; do
HASH="$(tr -d '[:space:]' < "$HASHES/hash-${SYSTEM}/hash.txt")"
echo "${SYSTEM}: ${HASH}"
jq --arg sys "$SYSTEM" --arg h "$HASH" '.nodeModules[$sys] = $h' "$HASH_FILE" > tmp.json
mv tmp.json "$HASH_FILE"
done
cat "$HASH_FILE"
bash .github/nix-hashes/validate.sh "$HASH_FILE"
if git diff --quiet -- "$HASH_FILE"; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "### Nix hashes" >> "$GITHUB_STEP_SUMMARY"
echo "Status: no changes" >> "$GITHUB_STEP_SUMMARY"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "### Nix hashes" >> "$GITHUB_STEP_SUMMARY"
echo "Status: changed" >> "$GITHUB_STEP_SUMMARY"
fi
- name: Upload hashes.json
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: nix-hashes
path: nix/hashes.json
if-no-files-found: error
retention-days: 1
# Runs even when compute found no change, so an open bot pull request with stale hashes is closed, not merged.
publish:
needs: compute
if: github.repository == 'anomalyco/opencode' && github.ref == 'refs/heads/dev'
runs-on: ubuntu-24.04
concurrency:
group: bot-nix-hashes-publish
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
actions: write
steps:
- name: Check out publish scripts
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: ${{ github.sha }}
path: trusted
sparse-checkout: /.github/nix-hashes/
sparse-checkout-cone-mode: false
persist-credentials: false
# Holds the push credential; only nix/hashes.json is checked out and nothing in it runs.
- name: Check out dev
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: dev
path: repo
sparse-checkout: /nix/hashes.json
sparse-checkout-cone-mode: false
- name: Download hashes.json
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: nix-hashes
path: ${{ runner.temp }}/nix-hashes
- name: Publish
working-directory: repo
run: bash ../trusted/.github/nix-hashes/publish.sh "$RUNNER_TEMP/nix-hashes/hashes.json"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}

View file

@ -1,63 +0,0 @@
name: check-bot-scope
# Required on dev. bot-nix-hashes.yml pushes bot/nix-hashes and auto-merges its pull request without review, so this
# fails that branch unless it changes nothing but a valid nix/hashes.json. Every other branch passes. The bot's own
# pushes start no workflows, so bot-nix-hashes.yml dispatches this; pull_request covers anyone else pushing the branch.
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
bot-scope:
name: bot-scope
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Check branch
id: branch
env:
HEAD_REF: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
run: |
if [ "$HEAD_REF" = bot/nix-hashes ]; then
echo "bot=true" >> "$GITHUB_OUTPUT"
else
echo "$HEAD_REF is not a bot branch; nothing to check"
fi
- name: Checkout repository
if: steps.branch.outputs.bot == 'true'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
filter: blob:none
persist-credentials: false
- name: Check changed files
if: steps.branch.outputs.bot == 'true'
env:
BASE: ${{ github.base_ref || 'dev' }}
run: |
set -euo pipefail
git fetch --no-tags --filter=blob:none origin "+refs/heads/$BASE:refs/remotes/origin/$BASE"
changed=$(git diff --name-only "origin/$BASE...HEAD")
echo "Changed files:"
echo "$changed"
if [ "$changed" != nix/hashes.json ]; then
echo "::error::bot/nix-hashes may change only nix/hashes.json"
exit 1
fi
# Runs dev's validator: the step above proved this branch leaves .github/ unchanged.
- name: Validate nix/hashes.json
if: steps.branch.outputs.bot == 'true'
run: bash .github/nix-hashes/validate.sh nix/hashes.json

View file

@ -1,42 +0,0 @@
name: check-docs
# Builds the V2 docs on their own (services/site/src/docs/script/build.ts): compiles every MDX page,
# prerenders it, builds search, checks every link and that pages load nothing from outside /docs. The
# site's deploy runs the same step, so a broken page fails here instead of blocking the deploy.
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- services/site/**
- packages/protocol/openapi.json
- packages/cli/src/config/**
- .github/workflows/check-docs.yml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
docs:
name: docs build
if: ${{ !github.event.pull_request.draft }}
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 10
defaults:
run:
working-directory: services/site
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: ./.github/actions/setup-bun
# The API reference and the config schema the pages link (/docs/openapi.json, /v2/cli.json).
- name: Generate
run: bun run generate
- name: Build docs
run: bun src/docs/script/build.ts --out "$RUNNER_TEMP/docs"

View file

@ -1,97 +0,0 @@
name: check-nix
on:
push:
branches: [dev]
pull_request:
branches: [dev]
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
nix-eval:
if: ${{ !github.event.pull_request.draft }}
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Nix
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
- name: Evaluate flake outputs (all systems)
run: |
set -euo pipefail
nix --version
echo "=== Flake metadata ==="
nix flake metadata
echo ""
echo "=== Flake structure ==="
nix flake show --all-systems
SYSTEMS="x86_64-linux aarch64-linux aarch64-darwin"
PACKAGES="opencode"
# TODO: move 'desktop' to PACKAGES when #11755 is fixed
OPTIONAL_PACKAGES="desktop"
echo ""
echo "=== Evaluating packages for all systems ==="
for system in $SYSTEMS; do
echo ""
echo "--- $system ---"
for pkg in $PACKAGES; do
printf " %s: " "$pkg"
if output=$(nix eval ".#packages.$system.$pkg.drvPath" --raw 2>&1); then
echo "✓"
else
echo "✗"
echo "::error::Evaluation failed for packages.$system.$pkg"
echo "$output"
exit 1
fi
done
done
echo ""
echo "=== Evaluating optional packages ==="
for system in $SYSTEMS; do
echo ""
echo "--- $system ---"
for pkg in $OPTIONAL_PACKAGES; do
printf " %s: " "$pkg"
if output=$(nix eval ".#packages.$system.$pkg.drvPath" --raw 2>&1); then
echo "✓"
else
echo "✗"
echo "::warning::Evaluation failed for packages.$system.$pkg"
echo "$output"
fi
done
done
echo ""
echo "=== Evaluating devShells for all systems ==="
for system in $SYSTEMS; do
printf "%s: " "$system"
if output=$(nix eval ".#devShells.$system.default.drvPath" --raw 2>&1); then
echo "✓"
else
echo "✗"
echo "::error::Evaluation failed for devShells.$system.default"
echo "$output"
exit 1
fi
done
echo ""
echo "=== All evaluations passed ==="

View file

@ -1,253 +0,0 @@
name: Process daemon
on:
pull_request:
paths:
- packages/process-daemon/**
- .github/actions/prefetch-ghostty/**
- .github/workflows/check-process-daemon.yml
push:
branches: [dev]
paths:
- packages/process-daemon/**
- .github/actions/prefetch-ghostty/**
- .github/workflows/check-process-daemon.yml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
defaults:
run:
working-directory: packages/process-daemon
jobs:
miri:
name: Miri (callback ownership)
runs-on: ubuntu-22.04
timeout-minutes: 15
env:
CARGO_TARGET_DIR: target/miri
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install Miri
run: rustup toolchain install nightly-2026-09-02 --profile minimal --component miri --component rust-src
- run: cargo +nightly-2026-09-02 miri setup
- name: Check Stacked Borrows
run: |
cargo +nightly-2026-09-02 miri test --locked --manifest-path tests/ghostty-effects/Cargo.toml
cargo +nightly-2026-09-02 miri test --locked --manifest-path tests/transport-retained/Cargo.toml
- name: Check Tree Borrows
env:
MIRIFLAGS: -Zmiri-tree-borrows
run: |
cargo +nightly-2026-09-02 miri test --locked --manifest-path tests/ghostty-effects/Cargo.toml
cargo +nightly-2026-09-02 miri test --locked --manifest-path tests/transport-retained/Cargo.toml
test:
name: Core (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, blacksmith-6vcpu-macos-15]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # v2.0.5
with:
version: 0.16.0
use-cache: false
- uses: ./.github/actions/prefetch-ghostty
- name: Install Rust
run: rustup toolchain install 1.90.0 --profile minimal --component rustfmt --component clippy
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
key: core-${{ matrix.os }}-zig-0.16.0
workspaces: packages/process-daemon -> target
cache-workspace-crates: true
- run: cargo fmt --check
- run: cargo clippy --locked --all-targets --all-features -- -D warnings
- name: Test Linux
if: runner.os == 'Linux'
run: cargo test --locked
# Match the release workflow's macOS playground exclusion.
- name: Test macOS
if: runner.os == 'macOS'
run: cargo test --locked --lib --test service --test runtime --test ownership --test pipe --test rows --test ghostty-effects
windows:
name: Windows (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
include:
- arch: x64
runner: windows-2025
target: x86_64-pc-windows-msvc
machine: "8664"
- arch: arm64
runner: windows-11-arm
target: aarch64-pc-windows-msvc
machine: "aa64"
defaults:
run:
shell: pwsh
working-directory: packages/process-daemon
env:
CARGO_TERM_COLOR: always
CARGO_BUILD_TARGET: ${{ matrix.target }}
RUSTUP_TOOLCHAIN: 1.90.0-x86_64-pc-windows-msvc
RUST_BACKTRACE: "1"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Enable long dependency paths
run: git config --global core.longpaths true
- uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # v2.0.5
if: matrix.arch == 'x64'
with:
version: 0.16.0
use-cache: false
# Zig 0.16 crashes when building Ghostty on the native ARM64 host.
# Use x64-hosted compilers on this ARM64 runner, but execute ARM64 tests natively.
- name: Install x64 Zig for ARM64 cross-compilation
if: matrix.arch == 'arm64'
run: |
$archive = Join-Path $env:RUNNER_TEMP 'zig-x64.zip'
Invoke-WebRequest 'https://ziglang.org/download/0.16.0/zig-x86_64-windows-0.16.0.zip' -OutFile $archive
if ((Get-FileHash $archive -Algorithm SHA256).Hash -ne '68659eb5f1e4eb1437a722f1dd889c5a322c9954607f5edcf337bc3684a75a7e') { throw 'Zig archive checksum mismatch' }
Expand-Archive $archive -DestinationPath $env:RUNNER_TEMP
Join-Path $env:RUNNER_TEMP 'zig-x86_64-windows-0.16.0' >> $env:GITHUB_PATH
- name: Fix Zig 0.16 ARM64 function-pointer alignment
if: matrix.arch == 'arm64'
run: |
# ARM64 function pointers require 4-byte alignment, unlike *anyopaque.
# Zig 0.16's Windows stack-trace helper omits the required alignment assertion.
$file = Join-Path $env:RUNNER_TEMP 'zig-x86_64-windows-0.16.0/lib/std/debug/SelfInfo/Windows.zig'
$source = [System.IO.File]::ReadAllText($file)
$old = '@ptrCast(try si.loadNtdllProc(@tagName(proc)))'
if (!$source.Contains($old)) { throw 'Zig alignment workaround no longer matches; re-evaluate it' }
[System.IO.File]::WriteAllText($file, $source.Replace($old, '@ptrCast(@alignCast(try si.loadNtdllProc(@tagName(proc))))'))
- name: Pin MSVC 14.51 for Zig's Clang 21
timeout-minutes: 20
run: |
$installer = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer"
$vs = & "$installer\vswhere.exe" -latest -products * -property installationPath
$tools = "$vs\VC\Tools\MSVC"
$arch = '${{ matrix.arch }}'
$hasRuntimes = {
(Test-Path "$($_.FullName)\lib\x64\vcruntime.lib") -and
(Test-Path "$($_.FullName)\lib\$arch\vcruntime.lib")
}
if (!(Get-ChildItem $tools -Directory -Filter '14.51.*' | Where-Object $hasRuntimes)) {
$components = '--add Microsoft.VisualStudio.Component.VC.14.51.x86.x64'
if ($arch -eq 'arm64') { $components += ' --add Microsoft.VisualStudio.Component.VC.14.51.ARM64' }
$setup = Start-Process "$installer\setup.exe" -ArgumentList "modify --installPath `"$vs`" $components --quiet --norestart" -Wait -PassThru
if ($setup.ExitCode -notin 0, 3010) { throw "VS installer exited with $($setup.ExitCode)" }
Write-Output "MSVC 14.51 installer exited with $($setup.ExitCode) for $arch"
}
$toolset = Get-ChildItem $tools -Directory -Filter '14.51.*' |
Where-Object $hasRuntimes |
Sort-Object { [version]$_.Name } -Descending | Select-Object -First 1
if (!$toolset) { throw "Missing MSVC 14.51 for $arch" }
# Zig reads this file for both host and target tools on the disposable runner.
Set-Content "$vs\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt" $toolset.Name -Encoding ascii
$libc = zig libc
$libc
if ($LASTEXITCODE -ne 0 -or $libc -inotcontains "sys_include_dir=$($toolset.FullName)\include") { throw 'Zig selected unexpected MSVC headers' }
- name: Install Rust toolchain and target
run: rustup toolchain install $env:RUSTUP_TOOLCHAIN --force-non-host --profile minimal --component rustfmt --component clippy --target $env:CARGO_BUILD_TARGET
- name: Verify runner and compiler architecture
env:
EXPECTED_ARCH: ${{ matrix.arch }}
run: |
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString()
Write-Output "Windows architecture: $arch"
if ($arch -ine $env:EXPECTED_ARCH) { throw "Expected native $env:EXPECTED_ARCH runner, got $arch" }
$compiler = rustc -vV
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$compiler
if ($compiler -notcontains 'host: x86_64-pc-windows-msvc') { throw 'Unexpected Rust compiler host' }
Write-Output "Executable target: $env:CARGO_BUILD_TARGET"
zig version
- uses: ./.github/actions/prefetch-ghostty
# No cache-on-failure: a timed-out run once saved a partial cache that broke re-runs.
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
key: windows-${{ matrix.target }}-zig-0.16.0
workspaces: packages/process-daemon -> target
# The native Ghostty build is now an output of the workspace crate.
cache-workspace-crates: true
- name: Check formatting
run: cargo fmt --check
- name: Check Clippy
run: cargo clippy --locked --all-targets --all-features -- -D warnings
- name: Build executable
id: build
run: cargo build --locked
- name: Run tests
id: tests
timeout-minutes: 10
run: cargo test --locked --all-targets --all-features
- name: Run standalone library tests
env:
EXPECTED_MACHINE: ${{ matrix.machine }}
run: |
$artifacts = cargo test --locked --lib --no-run --message-format=json | ForEach-Object { $_ | ConvertFrom-Json }
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$binary = ($artifacts | Where-Object { $_.reason -eq 'compiler-artifact' -and $_.profile.test -and $_.executable }).executable
# Cargo adds native library paths to PATH, which can hide accidental DLL dependencies.
# Copy only the executable so neither Cargo nor adjacent build artifacts can supply them.
$directory = Join-Path $env:RUNNER_TEMP 'pty-standalone-tests'
New-Item -ItemType Directory -Force $directory | Out-Null
$standalone = Join-Path $directory 'opencode-pty-tests.exe'
Copy-Item $binary $standalone
$bytes = [System.IO.File]::ReadAllBytes($standalone)
$header = [BitConverter]::ToInt32($bytes, 0x3c)
$machine = [BitConverter]::ToUInt16($bytes, $header + 4)
if ($machine -ne [Convert]::ToUInt16($env:EXPECTED_MACHINE, 16)) { throw 'Test executable architecture does not match the runner' }
& $standalone
- name: Diagnose failed library tests
if: failure() && steps.tests.outcome == 'failure'
timeout-minutes: 10
run: cargo test --locked --lib --all-features -- --test-threads=1 --nocapture
- name: Diagnose failed runtime tests
if: failure() && steps.tests.outcome == 'failure'
timeout-minutes: 3
run: cargo test --locked --test runtime -- --test-threads=1 --nocapture
- name: Diagnose failed daemon tests
if: failure() && steps.tests.outcome == 'failure'
timeout-minutes: 3
run: cargo test --locked --test windows-daemon -- --test-threads=1 --nocapture
- name: Smoke test executable
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: |
$metadata = cargo metadata --locked --no-deps --format-version 1 | ConvertFrom-Json
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$version = ($metadata.packages | Where-Object name -eq 'opencode-pty').version
$binary = Join-Path $metadata.target_directory "$env:CARGO_BUILD_TARGET/debug/opencode-pty.exe"
$output = & $binary --version
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Write-Output $output
if ($output -notmatch "^opencode-pty $([regex]::Escape($version)) \(protocol \d+\)$") { throw "Unexpected executable version: $output" }
- name: Document current coverage
if: always()
run: |
@"
## Windows ${{ matrix.arch }}
Target: $env:CARGO_BUILD_TARGET
This job builds the executable and runs all enabled tests natively, including libghostty parser, protocol, direct TerminalService ConPTY runtime, named-pipe transport, and daemon tests.
The runtime suite spawns real Rust console children and checks input/output, Unicode, cwd/environment/argv/PATH, OS resize, snapshots, replay, terminal replies, and independent terminals.
Daemon tests cover private atomic registration, ownership/handoff, stale registration/locking, partial requests, blocked subscribers, and live ConPTY operations over real named pipes.
The older service, ownership, playground, and rows integration suites remain Unix-only.
Basic tests do not establish exhaustive lifecycle coverage or Windows interactive CLI parity.
No packages or releases are published.
"@ >> $env:GITHUB_STEP_SUMMARY

View file

@ -1,355 +0,0 @@
name: check-test
# Pull requests run the fast tier: the affected unit tests on Linux. The full tier — unit tests on Windows, the
# compiled builds, and the Playwright suites on both OSes — runs on pushes to dev and beta and on nightly and manual
# runs. A stable release also runs it through release.yml's gate, with the browser suites on Linux only.
on:
push:
branches:
- dev
- beta
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
inputs:
quarantine:
description: Run only the quarantined browser tests (packages/app/e2e/QUARANTINE.md)
type: boolean
default: false
workflow_call:
inputs:
quarantine:
description: Run only the quarantined browser tests (packages/app/e2e/QUARANTINE.md)
type: boolean
default: false
release_gate:
description: Run the browser suites on Linux only
type: boolean
default: false
concurrency:
# A new push to a pull request cancels its stale run. Every push and manual run keeps its own group, so each
# dev and beta commit gets a verdict and a quarantine run never cancels a normal one.
group: ${{ case(github.event_name == 'pull_request', format('{0}-{1}', github.workflow, github.event.pull_request.number), format('{0}-{1}', github.workflow, github.run_id)) }}
cancel-in-progress: true
permissions:
contents: read
checks: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
# Push and pull request runs test only what changed. Manual runs and the release gate test everything: they
# have no base commit to diff against.
AFFECTED: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
# Pull requests diff against the merge's first parent; pushes diff against the previous dev head.
TURBO_SCM_BASE: ${{ github.event_name == 'pull_request' && format('{0}^1', github.sha) || github.event.before }}
TURBO_SCM_HEAD: ${{ github.sha }}
jobs:
# Only the browser suites need this, and pull requests run no browser suites.
affected:
name: affected packages
if: ${{ !github.event.pull_request.draft && github.event_name != 'pull_request' }}
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
e2e: ${{ steps.packages.outputs.app }}
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version-file: package.json
- name: Find affected packages
id: packages
run: |
if [ "$AFFECTED" != "true" ]; then
echo "app=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# packages/stories hosts the component tests, but no app package depends on it.
bun x turbo@2.10.2 ls --affected --filter=@opencode/app --filter=@opencode/stories --output=json > affected.json
bun -e 'const result = await Bun.file("affected.json").json(); console.log(`app=${result.packages.count > 0}`)' >> "$GITHUB_OUTPUT"
unit:
name: unit (${{ matrix.settings.name }})
if: ${{ !inputs.quarantine && !github.event.pull_request.draft }}
strategy:
fail-fast: false
matrix:
# Pull requests run Linux only; Windows runs the same tests on pushes, nightly runs and the release gate.
settings: ${{ fromJSON(github.event_name == 'pull_request' && '[{"name":"linux","host":"blacksmith-4vcpu-ubuntu-2404"}]' || '[{"name":"linux","host":"blacksmith-4vcpu-ubuntu-2404"},{"name":"windows","host":"blacksmith-4vcpu-windows-2025"}]') }}
runs-on: ${{ matrix.settings.host }}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Pull requests diff against the merge's first parent; pushes diff against the previous dev head.
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "24"
- name: Setup Bun
uses: ./.github/actions/setup-bun
- name: Test Effect simplification rules
if: runner.os == 'Linux'
run: bun run test:effect-simplification-rules
- name: Check Effect simplifications
if: runner.os == 'Linux'
run: bun run lint:effect-simplifications
- name: Configure git identity
run: |
git config --global user.email "bot@opencode.ai"
git config --global user.name "opencode"
- name: Run unit tests
timeout-minutes: 20
run: |
# The runners have four vCPUs, and each Bun test process performs its own concurrent work.
if [ "$AFFECTED" = "true" ]; then
GITHUB_ACTIONS=false bun turbo test --affected --concurrency=3
exit 0
fi
GITHUB_ACTIONS=false bun turbo test --concurrency=3
env:
OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER: ${{ runner.os == 'Windows' && 'true' || 'false' }}
- name: Verify packed codemode package
if: runner.os == 'Linux'
working-directory: packages/codemode
run: bun run pack
- name: Verify packed workerd SDK
if: runner.os == 'Linux'
timeout-minutes: 15
run: |
if [ "$AFFECTED" = "true" ]; then
bun turbo verify:package --affected --filter=@opencode/sdk
exit 0
fi
bun turbo verify:package --filter=@opencode/sdk
- name: Check generated client
if: runner.os == 'Linux'
working-directory: packages/client
run: bun run check:generated
- name: Check generated OpenAPI document
if: runner.os == 'Linux'
working-directory: packages/protocol
run: bun run check:generated
build:
name: build (${{ matrix.settings.name }})
# Compiling the CLI and smoke-testing its service lifecycle is part of the full tier.
if: ${{ !inputs.quarantine && github.event_name != 'pull_request' && !github.event.pull_request.draft }}
strategy:
fail-fast: false
matrix:
settings:
- name: linux
host: blacksmith-4vcpu-ubuntu-2404
- name: windows
host: blacksmith-4vcpu-windows-2025
runs-on: ${{ matrix.settings.host }}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Bun
uses: ./.github/actions/setup-bun
- name: Verify compiled service lifecycle
timeout-minutes: 10
working-directory: packages/cli
env:
NODE_OPTIONS: ${{ runner.os == 'Windows' && '--max-old-space-size=4096' || '' }}
run: |
bun run script/build.ts --single --skip-install
bun run script/service-smoke.ts
# Unit tests import workspace sources and never build the libraries they use, so this checks those builds. The
# CLI and app closures hold every library a tested package depends on. The builds are tsc and Bun.build with no
# platform-specific steps, and the libraries publish from Linux, so Windows skips them.
- name: Build workspace libraries
if: ${{ !cancelled() && runner.os == 'Linux' }}
timeout-minutes: 10
run: |
if [ "$AFFECTED" = "true" ]; then
bun turbo build --affected --concurrency=3 --filter='@opencode/cli^...' --filter='@opencode/app^...'
exit 0
fi
bun turbo build --concurrency=3 --filter='@opencode/cli^...' --filter='@opencode/app^...'
- name: Setup Node build runtime
if: ${{ !cancelled() }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "26.4.0"
- name: Verify Node build
if: ${{ !cancelled() }}
timeout-minutes: 15
working-directory: packages/cli
env:
NODE_OPTIONS: ${{ runner.os == 'Windows' && '--max-old-space-size=4096' || '' }}
run: |
bun run script/build-node.ts --single --skip-install --outdir=dist/node
bun run script/service-smoke.ts --node
e2e-suite:
name: e2e (${{ matrix.settings.name }}, ${{ matrix.suite.id }}${{ matrix.quarantine && ', quarantine' || '' }})
needs: affected
if: needs.affected.outputs.e2e == 'true'
# Quarantined tests are known red; their legs report without failing the e2e checks.
continue-on-error: ${{ matrix.quarantine }}
strategy:
fail-fast: false
matrix:
# The release gate runs the Linux browser suites only: the Windows legs still fail on dev pushes often
# enough that a stable release must not wait for them. Pushes and nightly runs cover Windows.
settings: ${{ fromJSON(inputs.release_gate && '[{"name":"linux","host":"blacksmith-4vcpu-ubuntu-2404"}]' || '[{"name":"linux","host":"blacksmith-4vcpu-ubuntu-2404"},{"name":"windows","host":"blacksmith-4vcpu-windows-2025"}]') }}
quarantine: ${{ fromJSON(inputs.quarantine && '[true]' || '[false]') }}
# Playwright splits whole spec files across shards by test count, not duration. Every app-N
# entry must use the same total, and the entries must cover 1..total. The service worker suite
# reuses shard 2's production build. Each component suite runs once per OS in its own leg, so the
# two suites' story servers and test time are not added up on one runner.
suite:
- id: app-1
shard: 1/2
- id: app-2
shard: 2/2
- id: session-ui-components
- id: app-components
runs-on: ${{ matrix.settings.host }}
env:
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.playwright-browsers
# Beta only (packages/app/e2e/QUARANTINE.md): gate legs skip quarantined tests, retry once and stop after 8
# failures; quarantine legs run only those tests, to the end. Other branches keep the config defaults.
PLAYWRIGHT_ARGS: ${{ matrix.quarantine && '--grep @quarantine --pass-with-no-tests --retries=1' || github.ref == 'refs/heads/beta' && '--grep-invert @quarantine --max-failures=8 --retries=1' || '' }}
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
# Playwright 1.59 hangs while extracting Chromium with Node 24.16.
node-version: "24.15"
- name: Setup Bun
uses: ./.github/actions/setup-bun
- name: Read Playwright version
id: playwright-version
run: |
version=$(node -e 'console.log(require("./package.json").workspaces.catalog["@playwright/test"])')
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ${{ github.workspace }}/.playwright-browsers
key: ${{ runner.os }}-${{ runner.arch }}-playwright-${{ steps.playwright-version.outputs.version }}-chromium
- name: Install Playwright system dependencies
if: runner.os == 'Linux'
working-directory: packages/app
run: bunx playwright install-deps chromium
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: packages/app
run: bunx playwright install chromium
- name: Run app e2e tests against production build
if: matrix.suite.shard
run: bun --cwd packages/app test:e2e:built --shard=${{ matrix.suite.shard }} ${{ env.PLAYWRIGHT_ARGS }}
env:
CI: true
timeout-minutes: ${{ (matrix.quarantine || github.ref == 'refs/heads/beta') && 10 || 15 }}
- name: Verify service worker precaching and upgrades
if: matrix.suite.shard == '2/2' && !matrix.quarantine
working-directory: packages/app
run: bunx playwright test --config e2e/service-worker/playwright.config.ts
timeout-minutes: 5
- name: Run session UI component tests
if: matrix.suite.id == 'session-ui-components'
run: bun --cwd packages/session-ui test:components ${{ env.PLAYWRIGHT_ARGS }}
env:
CI: true
timeout-minutes: ${{ (matrix.quarantine || github.ref == 'refs/heads/beta') && 10 || 15 }}
- name: Run app component tests
if: matrix.suite.id == 'app-components'
run: bun --cwd packages/app test:components ${{ env.PLAYWRIGHT_ARGS }}
env:
CI: true
timeout-minutes: ${{ (matrix.quarantine || github.ref == 'refs/heads/beta') && 10 || 15 }}
- name: Upload Playwright artifacts
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: playwright-${{ matrix.settings.name }}-${{ matrix.suite.id }}${{ matrix.quarantine && '-quarantine' || '' }}-${{ github.run_attempt }}
if-no-files-found: ignore
retention-days: 7
path: |
packages/app/e2e/test-results
packages/app/e2e/playwright-report
packages/session-ui/component-tests/test-results
packages/session-ui/component-tests/playwright-report
packages/app/component-tests/test-results
packages/app/component-tests/playwright-report
# One check per OS for the browser suites: it passes only when every leg above passed, or when no leg was
# needed because the changed packages have no browser tests.
e2e:
name: e2e (${{ matrix.os }})
needs: [affected, e2e-suite]
if: ${{ !cancelled() && !inputs.quarantine && github.event_name != 'pull_request' && !github.event.pull_request.draft }}
strategy:
fail-fast: false
matrix:
os: [linux, windows]
# Aggregates results only; these do not need a paid runner.
runs-on: ubuntu-24.04
steps:
- name: Check browser test results
env:
AFFECTED: ${{ needs.affected.result }}
SUITES: ${{ needs.e2e-suite.result }}
EXPECTED: ${{ needs.affected.outputs.e2e == 'true' && 'success' || 'skipped' }}
run: |
echo "affected packages: $AFFECTED, browser test legs: $SUITES (expected $EXPECTED)"
test "$AFFECTED" = success && test "$SUITES" = "$EXPECTED"

View file

@ -4,8 +4,7 @@ on:
push:
branches: [dev]
pull_request:
branches: [dev, beta]
types: [opened, synchronize, reopened, ready_for_review]
branches: [dev]
workflow_dispatch:
concurrency:
@ -15,7 +14,6 @@ concurrency:
jobs:
check:
name: typecheck
if: ${{ !github.event.pull_request.draft }}
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Checkout repository
@ -27,14 +25,10 @@ jobs:
- name: Setup Bun
uses: ./.github/actions/setup-bun
- name: Lint
run: bun run lint
- name: Run checks
run: bun run check
# Local `bun run check` uses `bun check`; CI keeps the official TypeScript compiler as the source of truth.
- name: Typecheck (TypeScript 7.1)
run: bun run typecheck:tsc
# Every GUI package file (app, desktop, gui-plugins, the plugin package's GUI SDK, ui, session-ui) a pull request adds or edits must be free of
# Every GUI package file (app, desktop, gui-extensions, ui, session-ui) a pull request adds or edits must be free of
# oxlint problems, warn-level rules (anti-slop) included. Other packages are not affected.
- name: Lint changed files
if: github.event_name == 'pull_request'

24
.github/workflows/close-issues.yml vendored Normal file
View file

@ -0,0 +1,24 @@
name: close-issues
on:
schedule:
- cron: "0 2 * * *" # Daily at 2:00 AM
workflow_dispatch:
jobs:
close:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest
- name: Close stale issues
env:
GITHUB_TOKEN: ${{ github.token }}
run: bun script/github/close-issues.ts

50
.github/workflows/close-prs.yml vendored Normal file
View file

@ -0,0 +1,50 @@
name: close-prs
on:
schedule:
- cron: "0 22 * * *" # Daily at 10:00 PM UTC
workflow_dispatch:
inputs:
dry-run:
description: "Log matching PRs without closing them"
type: boolean
default: true
max-close:
description: "Maximum matching PRs to close"
type: string
required: false
default: "50"
jobs:
close:
runs-on: ubuntu-latest
timeout-minutes: 240
permissions:
contents: read
issues: write
pull-requests: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest
- name: Close old PRs without enough positive reactions
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
max_close="${{ inputs['max-close'] }}"
if [ -z "$max_close" ]; then
max_close="50"
fi
args=("--threshold" "2" "--age-months" "1" "--sleep-ms" "20000" "--max-close" "$max_close")
if [ "${{ github.event_name }}" = "schedule" ]; then
args+=("--execute")
elif [ "${{ inputs['dry-run'] }}" = "false" ]; then
args+=("--execute")
fi
bun script/github/close-prs.ts "${args[@]}"

133
.github/workflows/compliance-close.yml vendored Normal file
View file

@ -0,0 +1,133 @@
name: compliance-close
on:
schedule:
# Run every 30 minutes to check for expired compliance windows
- cron: "*/30 * * * *"
workflow_dispatch:
permissions:
contents: read
issues: write
pull-requests: write
jobs:
close-non-compliant:
runs-on: ubuntu-latest
steps:
- name: Close non-compliant issues and PRs after 72 hours
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
with:
script: |
const { data: items } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: 'needs:compliance',
state: 'open',
per_page: 100,
});
if (items.length === 0) {
core.info('No open issues/PRs with needs:compliance label');
return;
}
const now = Date.now();
const seventyTwoHours = 72 * 60 * 60 * 1000;
const orgMemberAssociations = new Set(['OWNER', 'MEMBER']);
const agentLogin = 'opencode-agent[bot]';
const { data: file } = await github.rest.repos.getContent({
owner: context.repo.owner,
repo: context.repo.repo,
path: '.github/TEAM_MEMBERS',
ref: 'dev',
});
const teamMembers = new Set(
Buffer.from(file.content, 'base64')
.toString()
.split('\n')
.map((line) => line.trim().toLowerCase())
.filter(Boolean)
);
function isExempt(item) {
const login = item.user?.login?.toLowerCase();
return (
login === agentLogin ||
orgMemberAssociations.has(item.author_association) ||
(login && teamMembers.has(login))
);
}
for (const item of items) {
const isPR = !!item.pull_request;
const kind = isPR ? 'PR' : 'issue';
const login = item.user?.login;
if (isExempt(item)) {
core.info(`Skipping ${kind} #${item.number}; author ${login || 'unknown'} is exempt`);
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: item.number,
name: 'needs:compliance',
});
} catch (e) {}
continue;
}
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: item.number,
});
const complianceComment = comments.find(c => c.body.includes('<!-- issue-compliance -->'));
if (!complianceComment) continue;
const commentAge = now - new Date(complianceComment.created_at).getTime();
if (commentAge < seventyTwoHours) {
core.info(`${kind} #${item.number} still within 72-hour window (${Math.round(commentAge / 60000)}m elapsed)`);
continue;
}
const closeMessage = isPR
? 'This pull request has been automatically closed because it was not updated to meet our [contributing guidelines](../blob/dev/CONTRIBUTING.md) within the 72-hour window.\n\nFeel free to open a new pull request that follows our guidelines.'
: 'This issue has been automatically closed because it was not updated to meet our [contributing guidelines](../blob/dev/CONTRIBUTING.md) within the 72-hour window.\n\nFeel free to open a new issue that follows our issue templates.';
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: item.number,
body: closeMessage,
});
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: item.number,
name: 'needs:compliance',
});
} catch (e) {}
if (isPR) {
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: item.number,
state: 'closed',
});
} else {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: item.number,
state: 'closed',
state_reason: 'not_planned',
});
}
core.info(`Closed non-compliant ${kind} #${item.number} after 72-hour window`);
}

45
.github/workflows/containers.yml vendored Normal file
View file

@ -0,0 +1,45 @@
name: containers
on:
push:
branches:
- dev
paths:
- packages/containers/**
- .github/workflows/containers.yml
- package.json
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build:
runs-on: blacksmith-4vcpu-ubuntu-2404
env:
REGISTRY: ghcr.io/${{ github.repository_owner }}
TAG: "24.04"
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: ./.github/actions/setup-bun
- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Login to GHCR
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push containers
run: bun ./packages/containers/script/build.ts --push
env:
REGISTRY: ${{ env.REGISTRY }}
TAG: ${{ env.TAG }}

40
.github/workflows/deploy-changelog.yml vendored Normal file
View file

@ -0,0 +1,40 @@
name: deploy-changelog
on:
push:
branches:
- dev
paths:
- services/changelog/**
- .github/workflows/deploy-changelog.yml
workflow_dispatch:
concurrency:
group: deploy-changelog
cancel-in-progress: false
permissions:
contents: read
jobs:
deploy:
if: github.repository == 'anomalyco/opencode' && github.ref_name == 'dev'
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: ./.github/actions/setup-bun
- name: Typecheck
working-directory: services/changelog
run: bun typecheck
- name: Test
working-directory: services/changelog
run: bun test
- name: Deploy
working-directory: services/changelog
run: bun run deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

View file

@ -1,17 +1,5 @@
name: deploy-files
# Deploys the files Worker (services/files).
#
# - build runs repository code (typecheck and `wrangler deploy --dry-run`) with
# no environment and no secrets, and uploads only the bundled index.js with a
# SHA256SUMS whose digest it reports.
# - deploy runs in the dev|production environment and mints a short-lived
# Cloudflare token from the token issuer. It checks out only .github/release/,
# verifies the artifact against that digest, installs the wrangler CLI pinned
# in .github/release/wrangler, and runs only .github/release/deploy-files.sh.
# The Worker's name, route, R2 bucket and vars are the complete pinned
# wrangler.json in .github/release/targets/files/<stage>/; nothing in the
# artifact can name another destination.
on:
push:
branches:
@ -27,91 +15,20 @@ permissions:
contents: read
jobs:
files-build:
deploy:
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
digest: ${{ steps.upload.outputs.digest }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: ./.github/actions/setup-bun
- name: Typecheck
working-directory: services/files
run: bun run typecheck:tsc
- name: Build
working-directory: services/files
run: |
artifact="$RUNNER_TEMP/files-artifact"
rm -rf "$artifact"
./node_modules/.bin/wrangler deploy --dry-run \
--env ${{ github.ref_name == 'production' && 'production' || 'dev' }} \
--outdir "$artifact"
# wrangler writes a README next to the bundle; the deploy only needs index.js.
rm -f "$artifact/README.md" "$artifact/index.js.map"
- id: upload
uses: ./.github/release/upload
with:
name: files-${{ github.ref_name }}
path: ${{ runner.temp }}/files-artifact
retention-days: 7
include-hidden-files: true
files-deploy:
needs: files-build
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
runs-on: blacksmith-4vcpu-ubuntu-2404
environment: ${{ github.ref_name }}
permissions:
contents: read
id-token: write
steps:
- name: Check out the deploy scripts
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.sha }}
sparse-checkout: /.github/release/
sparse-checkout-cone-mode: false
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "24"
- name: Install the pinned wrangler CLI
working-directory: .github/release/wrangler
run: npm ci --ignore-scripts --no-audit --no-fund
- name: Download
uses: ./.github/release/download
with:
pattern: files-${{ github.ref_name }}
require-digests: true
digests: files-${{ github.ref_name }}=${{ needs.files-build.outputs.digest }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-${{ github.ref_name }}
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
# A 15-minute token for this stage, minted by the token issuer (anomalyco/secrets) from the role above.
# It is a step output, so only the Deploy step gets it.
- name: Cloudflare token
id: cloudflare-token
run: bash .github/release/cloudflare-token.sh "$GITHUB_REF_NAME"
env:
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
run: bun typecheck
- name: Deploy
working-directory: services/files
run: bun run deploy --env ${{ github.ref_name == 'production' && 'production' || 'dev' }}
env:
STAGE: ${{ github.ref_name }}
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
run: bash .github/release/deploy-files.sh "$STAGE" "$RUNNER_TEMP/in/files-$STAGE"
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

37
.github/workflows/deploy-posts.yml vendored Normal file
View file

@ -0,0 +1,37 @@
name: deploy-posts
on:
push:
branches:
- production
paths:
- packages/posts/**
- bun.lock
- .github/workflows/deploy-posts.yml
workflow_dispatch:
concurrency:
group: deploy-posts-${{ github.ref_name }}
cancel-in-progress: false
permissions:
contents: read
jobs:
deploy:
if: github.repository == 'anomalyco/opencode' && github.ref_name == 'production'
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: ./.github/actions/setup-bun
- name: Build
working-directory: packages/posts
run: bun run build
- name: Deploy
working-directory: packages/posts
run: bun run deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

View file

@ -1,110 +0,0 @@
name: deploy-site
# Deploys the opencode.ai site (services/site) to dev.opencode.ai or opencode.ai.
#
# - build runs repository code (bun install, services/site/script/build.ts) with
# no environment and no secrets. The workflow's own read-only GITHUB_TOKEN is
# available only here, for script/github-snapshot.ts. It uploads the Build
# Output with a SHA256SUMS whose digest it reports.
# - deploy runs in the dev|production environment and mints a short-lived
# Cloudflare token from the token issuer. It checks out only .github/release/,
# verifies the artifact against that digest, installs the cf CLI pinned in
# .github/release/cf, and runs only .github/release/deploy-site.sh, which
# refuses an artifact whose config is not the pinned target in
# .github/release/targets/site/<stage>/.
on:
push:
branches:
- dev
- production
workflow_dispatch:
concurrency:
group: deploy-site-${{ github.ref_name }}
cancel-in-progress: false
permissions:
contents: read
jobs:
site-build:
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
digest: ${{ steps.upload.outputs.digest }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: ./.github/actions/setup-bun
# The workflow's own token, at build time only: script/github-snapshot.ts records the repo numbers and
# releases the site falls back to. The Worker never gets a GitHub token.
- name: Build
working-directory: services/site
run: bun script/build.ts --mode ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ github.token }}
- id: upload
uses: ./.github/release/upload
with:
name: site-${{ github.ref_name }}
path: services/site/.cloudflare/output
retention-days: 7
include-hidden-files: true
site-deploy:
needs: site-build
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
runs-on: blacksmith-4vcpu-ubuntu-2404
environment: ${{ github.ref_name }}
permissions:
contents: read
id-token: write
steps:
- name: Check out the deploy scripts
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.sha }}
sparse-checkout: /.github/release/
sparse-checkout-cone-mode: false
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "24"
- name: Install the pinned cf CLI
working-directory: .github/release/cf
run: npm ci --ignore-scripts --no-audit --no-fund
- name: Download
uses: ./.github/release/download
with:
pattern: site-${{ github.ref_name }}
require-digests: true
digests: site-${{ github.ref_name }}=${{ needs.site-build.outputs.digest }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-${{ github.ref_name }}
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
# A 15-minute token for this stage, minted by the token issuer (anomalyco/secrets) from the role above.
# It is a step output, so only the Deploy step gets it.
- name: Cloudflare token
id: cloudflare-token
run: bash .github/release/cloudflare-token.sh "$GITHUB_REF_NAME"
env:
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
- name: Deploy
env:
STAGE: ${{ github.ref_name }}
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
run: bash .github/release/deploy-site.sh "$STAGE" "$RUNNER_TEMP/in/site-$STAGE"

View file

@ -1,16 +1,5 @@
name: deploy-update
# Deploys the update Worker (services/update). Production only.
#
# - build runs repository code (typecheck and `wrangler deploy --dry-run`) with
# no environment and no secrets, and uploads only the bundled index.js with a
# SHA256SUMS whose digest it reports.
# - deploy runs in the production environment and mints a short-lived Cloudflare
# token from the token issuer. It checks out only .github/release/, verifies
# the artifact against that digest, installs the wrangler CLI pinned in
# .github/release/wrangler, and runs only .github/release/deploy-update.sh.
# The Worker's name, routes, custom domain, D1 database and Pipelines stream
# are the complete pinned wrangler.json in .github/release/targets/update/.
on:
push:
branches:
@ -25,88 +14,20 @@ permissions:
contents: read
jobs:
update-build:
deploy:
if: github.repository == 'anomalyco/opencode' && github.ref_name == 'production'
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
digest: ${{ steps.upload.outputs.digest }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: ./.github/actions/setup-bun
- name: Typecheck
working-directory: services/update
run: bun run typecheck:tsc
- name: Build
working-directory: services/update
run: |
artifact="$RUNNER_TEMP/update-artifact"
rm -rf "$artifact"
./node_modules/.bin/wrangler deploy --dry-run --outdir "$artifact"
# wrangler writes a README next to the bundle; the deploy only needs index.js.
rm -f "$artifact/README.md" "$artifact/index.js.map"
- id: upload
uses: ./.github/release/upload
with:
name: update-production
path: ${{ runner.temp }}/update-artifact
retention-days: 7
include-hidden-files: true
update-deploy:
needs: update-build
if: github.repository == 'anomalyco/opencode' && github.ref_name == 'production'
runs-on: blacksmith-4vcpu-ubuntu-2404
environment: production
permissions:
contents: read
id-token: write
steps:
- name: Check out the deploy scripts
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.sha }}
sparse-checkout: /.github/release/
sparse-checkout-cone-mode: false
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "24"
- name: Install the pinned wrangler CLI
working-directory: .github/release/wrangler
run: npm ci --ignore-scripts --no-audit --no-fund
- name: Download
uses: ./.github/release/download
with:
pattern: update-production
require-digests: true
digests: update-production=${{ needs.update-build.outputs.digest }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-production
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
# A 15-minute token for production, minted by the token issuer (anomalyco/secrets) from the role above.
# It is a step output, so only the Deploy step gets it.
- name: Cloudflare token
id: cloudflare-token
run: bash .github/release/cloudflare-token.sh
env:
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
run: bun typecheck
- name: Deploy
working-directory: services/update
run: bun run deploy
env:
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
run: bash .github/release/deploy-update.sh production "$RUNNER_TEMP/in/update-production"
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

36
.github/workflows/deploy-www.yml vendored Normal file
View file

@ -0,0 +1,36 @@
name: deploy-www
on:
push:
branches:
- dev
- production
workflow_dispatch:
concurrency:
group: deploy-www-${{ github.ref_name }}
cancel-in-progress: false
permissions:
contents: read
jobs:
deploy:
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: ./.github/actions/setup-bun
- name: Build
working-directory: services/www
run: bun run build
env:
CLOUDFLARE_ENV: ${{ github.ref_name == 'production' && 'production' || 'dev' }}
- name: Deploy
working-directory: services/www
run: bun run deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

View file

@ -1,211 +1,50 @@
name: deploy
# Deploys the legacy Worker and the data site (site, OG Worker, sync Workflow).
#
# Each service is split in two:
# - build runs repository code (bun install, cf build / bun script/build.ts) with
# no environment, no secrets and no OIDC token, and uploads the resolved Build
# Output with a SHA256SUMS whose digest it reports.
# - deploy runs in the dev|production environment and mints a short-lived
# Cloudflare token from the token issuer. It checks out only .github/release/,
# verifies the artifact against the digest the build job reported, installs
# the cf CLI pinned in .github/release/cf, and runs only
# .github/release/deploy-legacy.sh or deploy-data.sh. Those treat the artifact
# as data and refuse anything but the pinned targets in
# .github/release/targets/. That is what makes an account-wide token safe: the
# data sync Workflow PUT has no per-Worker permission, so only Dax-reviewed
# .github code ever holds a token that can write another Worker.
on:
push:
branches:
- dev
- production
- beta
workflow_dispatch:
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: read
id-token: write
jobs:
legacy-build:
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
digest: ${{ steps.upload.outputs.digest }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: ./.github/actions/setup-bun
- name: Build
working-directory: services/legacy
run: ./node_modules/.bin/cf build --mode ${{ github.ref_name }}
- id: upload
uses: ./.github/release/upload
with:
name: legacy-${{ github.ref_name }}
path: services/legacy/.cloudflare/output
retention-days: 7
include-hidden-files: true
legacy-deploy:
needs: legacy-build
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
deploy:
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production' || github.ref_name == 'beta')
runs-on: blacksmith-4vcpu-ubuntu-2404
environment: ${{ github.ref_name }}
permissions:
contents: read
id-token: write
steps:
- name: Check out the deploy scripts
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.sha }}
sparse-checkout: /.github/release/
sparse-checkout-cone-mode: false
persist-credentials: false
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: ./.github/actions/setup-bun
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "24"
- name: Install the pinned cf CLI
working-directory: .github/release/cf
run: npm ci --ignore-scripts --no-audit --no-fund
- name: Download
uses: ./.github/release/download
- uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
if: github.ref_name != 'beta'
with:
pattern: legacy-${{ github.ref_name }}
require-digests: true
digests: legacy-${{ github.ref_name }}=${{ needs.legacy-build.outputs.digest }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-${{ github.ref_name }}
role-to-assume: ${{ vars.AWS_DEPLOY_ROLE_ARN }}
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
# A 15-minute token for this stage, minted by the token issuer (anomalyco/secrets) from the role above.
# It is a step output, so only the Deploy step gets it.
- name: Cloudflare token
id: cloudflare-token
run: bash .github/release/cloudflare-token.sh "$GITHUB_REF_NAME"
- run: bun sst deploy --stage=${{ github.ref_name }}
env:
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
# The GitHub App secrets are read here, so only this step ever has them. They reach cf through a file in the
# runner's temp directory, never argv, and the file is removed when the step ends.
- name: Deploy
env:
STAGE: ${{ github.ref_name }}
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
# An explicit bash runs with pipefail, so a failed secret read fails the step.
shell: bash
run: |
if [[ "$STAGE" == dev ]]; then
exec bash .github/release/deploy-legacy.sh dev "$RUNNER_TEMP/in/legacy-dev"
fi
umask 077
secrets="$RUNNER_TEMP/legacy-secrets.json"
trap 'rm -f "$secrets"' EXIT
for name in GITHUB_APP_ID GITHUB_APP_PRIVATE_KEY; do
aws secretsmanager get-secret-value --secret-id "opencode/production/$name" --output json |
jq --arg name "$name" '{($name): .SecretString}'
done | jq -s add > "$secrets"
bash .github/release/deploy-legacy.sh "$STAGE" "$RUNNER_TEMP/in/legacy-$STAGE" "$secrets"
data-build:
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
runs-on: blacksmith-4vcpu-ubuntu-2404
outputs:
digest: ${{ steps.upload.outputs.digest }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: ./.github/actions/setup-bun
- name: Build
working-directory: services/data
run: bun script/build.ts --mode ${{ github.ref_name }}
- id: upload
uses: ./.github/release/upload
with:
name: data-${{ github.ref_name }}
path: services/data/.cloudflare/output
retention-days: 7
include-hidden-files: true
# The /data site, its OG image Worker and the sync Workflow (services/data).
data-deploy:
needs: data-build
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
runs-on: blacksmith-4vcpu-ubuntu-2404
environment: ${{ github.ref_name }}
permissions:
contents: read
id-token: write
steps:
- name: Check out the deploy scripts
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.sha }}
sparse-checkout: /.github/release/
sparse-checkout-cone-mode: false
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "24"
- name: Install the pinned cf CLI
working-directory: .github/release/cf
run: npm ci --ignore-scripts --no-audit --no-fund
- name: Download
uses: ./.github/release/download
with:
pattern: data-${{ github.ref_name }}
require-digests: true
digests: data-${{ github.ref_name }}=${{ needs.data-build.outputs.digest }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-${{ github.ref_name }}
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
- name: Cloudflare token
id: cloudflare-token
run: bash .github/release/cloudflare-token.sh "$GITHUB_REF_NAME"
env:
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
# The Workers' secrets are read here, so only this step ever has them. They reach cf through files in the
# runner's temp directory, never argv, and are removed when the step ends.
- name: Deploy
env:
STAGE: ${{ github.ref_name }}
CLOUDFLARE_API_TOKEN: ${{ steps.cloudflare-token.outputs.token }}
# An explicit bash runs with pipefail, so a failed secret read fails the step.
shell: bash
run: |
umask 077
secrets="$RUNNER_TEMP/data-secrets.json"
trap 'rm -f "$secrets" "$secrets".*' EXIT
for name in DATA_DATABASE_HOST DATA_DATABASE_USERNAME DATA_DATABASE_PASSWORD R2_SQL_AUTH_TOKEN DATA_HIDDEN_MODELS; do
aws secretsmanager get-secret-value --secret-id "opencode/$STAGE/$name" --output json |
jq --arg name "$name" '{($name): .SecretString}'
done | jq -s add > "$secrets"
bash .github/release/deploy-data.sh "$STAGE" "$RUNNER_TEMP/in/data-$STAGE" "$secrets"
GITHUB_TOKEN: ${{ github.token }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
PLANETSCALE_SERVICE_TOKEN_NAME: ${{ secrets.PLANETSCALE_SERVICE_TOKEN_NAME }}
PLANETSCALE_SERVICE_TOKEN: ${{ secrets.PLANETSCALE_SERVICE_TOKEN }}
STRIPE_SECRET_KEY: ${{ github.ref_name == 'production' && secrets.STRIPE_SECRET_KEY_PROD || secrets.STRIPE_SECRET_KEY_DEV }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.WEB_SENTRY_PROJECT }}
SENTRY_RELEASE: web@${{ github.sha }}
VITE_SENTRY_DSN: ${{ vars.WEB_SENTRY_DSN }}
VITE_SENTRY_RELEASE: web@${{ github.sha }}

100
.github/workflows/docs-locale-sync.yml vendored Normal file
View file

@ -0,0 +1,100 @@
name: docs-locale-sync
on:
push:
branches:
- dev
paths:
- packages/web/src/content/docs/*.mdx
jobs:
sync-locales:
if: false
#if: github.actor != 'opencode-agent[bot]'
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Setup Bun
uses: ./.github/actions/setup-bun
- name: Setup git committer
id: committer
uses: ./.github/actions/setup-git-committer
with:
opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
- name: Compute changed English docs
id: changes
run: |
FILES=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- ':(glob)packages/web/src/content/docs/*.mdx' || true)
if [ -z "$FILES" ]; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
echo "No English docs changed in push range"
exit 0
fi
echo "has_changes=true" >> "$GITHUB_OUTPUT"
{
echo "files<<EOF"
echo "$FILES"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Install OpenCode
if: steps.changes.outputs.has_changes == 'true'
run: curl -fsSL https://opencode.ai/install | bash
- name: Sync locale docs with OpenCode
if: steps.changes.outputs.has_changes == 'true'
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
OPENCODE_CONFIG_CONTENT: |
{
"permission": {
"*": "deny",
"read": "allow",
"edit": "allow",
"glob": "allow",
"task": "allow"
}
}
run: |
opencode run --agent docs --model opencode/gpt-5.3-codex <<'EOF'
Update localized docs to match the latest English docs changes.
Changed English doc files:
<changed_english_docs>
${{ steps.changes.outputs.files }}
</changed_english_docs>
Requirements:
1. Update all relevant locale docs under packages/web/src/content/docs/<locale>/ so they reflect these English page changes.
2. You MUST use the Task tool for translation work and launch subagents with subagent_type `translator` (defined in .opencode/agent/translator.md).
3. Do not translate directly in the primary agent. Use translator subagent output as the source for locale text updates.
4. Run translator subagent Task calls in parallel whenever file/locale translation work is independent.
5. Use only the minimum tools needed for this task (read/glob, file edits, and translator Task). Do not use shell, web, search, or GitHub tools for translation work.
6. Preserve frontmatter keys, internal links, code blocks, and existing locale-specific metadata unless the English change requires an update.
7. Keep locale docs structure aligned with their corresponding English pages.
8. Do not modify English source docs in packages/web/src/content/docs/*.mdx.
9. If no locale updates are needed, make no changes.
EOF
- name: Commit and push locale docs updates
if: steps.changes.outputs.has_changes == 'true'
run: |
if [ -z "$(git status --porcelain)" ]; then
echo "No locale docs changes to commit"
exit 0
fi
git add -A
git commit -m "docs(i18n): sync locale docs from english changes"
git pull --rebase --autostash origin "$GITHUB_REF_NAME"
git push origin HEAD:"$GITHUB_REF_NAME"

72
.github/workflows/docs-update.yml vendored Normal file
View file

@ -0,0 +1,72 @@
name: docs-update
on:
schedule:
- cron: "0 */12 * * *"
workflow_dispatch:
env:
LOOKBACK_HOURS: 4
jobs:
update-docs:
if: github.repository == 'sst/opencode'
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
id-token: write
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0 # Fetch full history to access commits
- name: Setup Bun
uses: ./.github/actions/setup-bun
- name: Get recent commits
id: commits
run: |
COMMITS=$(git log --since="${{ env.LOOKBACK_HOURS }} hours ago" --pretty=format:"- %h %s" 2>/dev/null || echo "")
if [ -z "$COMMITS" ]; then
echo "No commits in the last ${{ env.LOOKBACK_HOURS }} hours"
echo "has_commits=false" >> $GITHUB_OUTPUT
else
echo "has_commits=true" >> $GITHUB_OUTPUT
{
echo "list<<EOF"
echo "$COMMITS"
echo "EOF"
} >> $GITHUB_OUTPUT
fi
- name: Run opencode
if: steps.commits.outputs.has_commits == 'true'
uses: sst/opencode/github@2c14fc5586fe0b88e5c04732d2e846769cc35671 # latest
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
with:
model: opencode/gpt-5.2
agent: docs
prompt: |
Review the following commits from the last ${{ env.LOOKBACK_HOURS }} hours and identify any new features that may need documentation.
<recent_commits>
${{ steps.commits.outputs.list }}
</recent_commits>
Steps:
1. For each commit that looks like a new feature or significant change:
- Read the changed files to understand what was added
- Check if the feature is already documented in packages/web/src/content/docs/*
2. If you find undocumented features:
- Update the relevant documentation files in packages/web/src/content/docs/*
- Follow the existing documentation style and structure
- Make sure to document the feature clearly with examples where appropriate
3. If all new features are already documented, report that no updates are needed
4. If you are creating a new documentation file be sure to update packages/web/astro.config.mjs too.
Focus on user-facing features and API changes. Skip internal refactors, bug fixes, and test updates unless they affect user-facing behavior.
Don't feel the need to document every little thing. It is perfectly okay to make 0 changes at all.
Try to keep documentation only for large features or changes that already have a good spot to be documented.

221
.github/workflows/duplicate-issues.yml vendored Normal file
View file

@ -0,0 +1,221 @@
name: duplicate-issues
on:
issues:
types: [opened, edited]
jobs:
check-duplicates:
if: github.event.action == 'opened'
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: read
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 1
- name: Check exempt issue author
id: author
run: |
LOGIN="${{ github.event.issue.user.login }}"
ASSOCIATION="${{ github.event.issue.author_association }}"
if [ "$LOGIN" = "opencode-agent[bot]" ] ||
[ "$ASSOCIATION" = "OWNER" ] ||
[ "$ASSOCIATION" = "MEMBER" ] ||
grep -qxiF "$LOGIN" .github/TEAM_MEMBERS; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Skipping issue automation for exempt author: $LOGIN ($ASSOCIATION)"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- uses: ./.github/actions/setup-bun
if: steps.author.outputs.skip != 'true'
- name: Install opencode
if: steps.author.outputs.skip != 'true'
run: curl -fsSL https://opencode.ai/install | bash
- name: Check duplicates and compliance
if: steps.author.outputs.skip != 'true'
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENCODE_PERMISSION: |
{
"bash": {
"*": "deny",
"gh issue*": "allow"
},
"webfetch": "deny"
}
run: |
opencode run -m opencode/claude-sonnet-4-6 "A new issue has been created:
Issue number: ${{ github.event.issue.number }}
Issue author association: ${{ github.event.issue.author_association }}
Lookup this issue with gh issue view ${{ github.event.issue.number }}.
You have TWO tasks. Perform both, then post a SINGLE comment (if needed).
---
TASK 1: CONTRIBUTING GUIDELINES COMPLIANCE CHECK
Check whether the issue follows our contributing guidelines and issue templates.
If the issue author association is OWNER or MEMBER, skip this compliance check. Do not add the needs:compliance label for organization-owned issues.
This project has three issue templates that every issue MUST use one of:
1. Bug Report - requires a Description field with real content
2. Feature Request - requires a verification checkbox and description, title should start with [FEATURE]:
3. Question - requires the Question field with real content
Additionally check:
- No AI-generated walls of text (long, AI-generated descriptions are not acceptable)
- The issue has real content, not just template placeholder text left unchanged
- Bug reports should include some context about how to reproduce
- Feature requests should explain the problem or need
- We want to push for having the user provide system description & information
Do NOT be nitpicky about optional fields. Only flag real problems like: no template used, required fields empty or placeholder text only, obviously AI-generated walls of text, or completely empty/nonsensical content.
---
TASK 2: DUPLICATE CHECK
Search through existing issues (excluding #${{ github.event.issue.number }}) to find potential duplicates.
Consider:
1. Similar titles or descriptions
2. Same error messages or symptoms
3. Related functionality or components
4. Similar feature requests
Additionally, if the issue mentions keybinds, keyboard shortcuts, or key bindings, note the pinned keybinds issue #4997.
---
POSTING YOUR COMMENT:
Based on your findings, post a SINGLE comment on issue #${{ github.event.issue.number }}. Build the comment as follows:
If the issue is NOT compliant and the author association is not OWNER or MEMBER, start the comment with:
<!-- issue-compliance -->
Then explain what needs to be fixed and that they have 72 hours to edit the issue before it is automatically closed. Also add the label needs:compliance to the issue using: gh issue edit ${{ github.event.issue.number }} --add-label needs:compliance
If duplicates were found, include a section about potential duplicates with links.
If the issue mentions keybinds/keyboard shortcuts, include a note about #4997.
If the issue IS compliant AND no duplicates were found AND no keybind reference, do NOT comment at all.
Use this format for the comment:
[If not compliant:]
<!-- issue-compliance -->
This issue doesn't fully meet our [contributing guidelines](../blob/dev/CONTRIBUTING.md).
**What needs to be fixed:**
- [specific reasons]
Please edit this issue to address the above within **72 hours**, or it will be automatically closed.
[If duplicates found, add:]
---
This issue might be a duplicate of existing issues. Please check:
- #[issue_number]: [brief description of similarity]
[If keybind-related, add:]
For keybind-related issues, please also check our pinned keybinds documentation: #4997
[End with if not compliant:]
If you believe this was flagged incorrectly, please let a maintainer know.
Remember: post at most ONE comment combining all findings. If everything is fine, post nothing."
recheck-compliance:
if: github.event.action == 'edited' && contains(github.event.issue.labels.*.name, 'needs:compliance')
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: read
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 1
- name: Check exempt issue author
id: author
run: |
LOGIN="${{ github.event.issue.user.login }}"
ASSOCIATION="${{ github.event.issue.author_association }}"
if [ "$LOGIN" = "opencode-agent[bot]" ] ||
[ "$ASSOCIATION" = "OWNER" ] ||
[ "$ASSOCIATION" = "MEMBER" ] ||
grep -qxiF "$LOGIN" .github/TEAM_MEMBERS; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Skipping issue automation for exempt author: $LOGIN ($ASSOCIATION)"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- uses: ./.github/actions/setup-bun
if: steps.author.outputs.skip != 'true'
- name: Install opencode
if: steps.author.outputs.skip != 'true'
run: curl -fsSL https://opencode.ai/install | bash
- name: Recheck compliance
if: steps.author.outputs.skip != 'true'
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENCODE_PERMISSION: |
{
"bash": {
"*": "deny",
"gh issue*": "allow"
},
"webfetch": "deny"
}
run: |
opencode run -m opencode/claude-sonnet-4-6 "Issue #${{ github.event.issue.number }} was previously flagged as non-compliant and has been edited.
Issue author association: ${{ github.event.issue.author_association }}
Lookup this issue with gh issue view ${{ github.event.issue.number }}.
If the issue author association is OWNER or MEMBER, remove the needs:compliance label if present, delete the previous compliance comment if present, and do not post a new comment.
Re-check whether the issue now follows our contributing guidelines and issue templates.
This project has three issue templates that every issue MUST use one of:
1. Bug Report - requires a Description field with real content
2. Feature Request - requires a verification checkbox and description, title should start with [FEATURE]:
3. Question - requires the Question field with real content
Additionally check:
- No AI-generated walls of text (long, AI-generated descriptions are not acceptable)
- The issue has real content, not just template placeholder text left unchanged
- Bug reports should include some context about how to reproduce
- Feature requests should explain the problem or need
- We want to push for having the user provide system description & information
Do NOT be nitpicky about optional fields. Only flag real problems like: no template used, required fields empty or placeholder text only, obviously AI-generated walls of text, or completely empty/nonsensical content.
If the issue is NOW compliant:
1. Remove the needs:compliance label: gh issue edit ${{ github.event.issue.number }} --remove-label needs:compliance
2. Find and delete the previous compliance comment (the one containing <!-- issue-compliance -->) using: gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments --jq '.[] | select(.body | contains(\"<!-- issue-compliance -->\")) | .id' then delete it with: gh api -X DELETE repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments/{id}
3. Post a short comment thanking them for updating the issue.
If the issue is STILL not compliant:
Post a comment explaining what still needs to be fixed. Keep the needs:compliance label."

62
.github/workflows/models-snapshot.yml vendored Normal file
View file

@ -0,0 +1,62 @@
name: models-snapshot
permissions:
contents: write
on:
workflow_dispatch:
schedule:
- cron: "0 0,12 * * *"
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
jobs:
refresh:
if: github.repository == 'anomalyco/opencode'
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
ref: dev
# The refresh script only needs `fetch`; skip the monorepo install.
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version-file: package.json
- name: Setup git committer
uses: ./.github/actions/setup-git-committer
with:
opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
- name: Refresh snapshot
run: bun packages/core/script/update-models-snapshot.ts
- name: Commit changes
run: |
set -euo pipefail
FILE="packages/core/src/models-dev/snapshot.txt"
if [ -z "$(git status --short -- "$FILE")" ]; then
echo "No changes to commit"
echo "### models.dev snapshot" >> "$GITHUB_STEP_SUMMARY"
echo "Status: no changes" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
git add "$FILE"
git commit -m "chore(core): refresh bundled models.dev snapshot"
git pull --rebase --autostash origin dev
git push origin HEAD:dev --no-verify
echo "### models.dev snapshot" >> "$GITHUB_STEP_SUMMARY"
echo "Status: committed $(git rev-parse --short HEAD)" >> "$GITHUB_STEP_SUMMARY"

View file

@ -1,23 +0,0 @@
name: nightly-beta
# GitHub runs schedules only from the default branch (dev), so this fires once this file is on dev.
# It tests beta with the full suite on both OSes, then runs beta's quarantined browser tests.
on:
schedule:
- cron: "17 9 * * *"
workflow_dispatch:
permissions:
actions: write
jobs:
dispatch:
if: github.repository == 'anomalyco/opencode'
runs-on: ubuntu-latest
steps:
- name: Dispatch beta test runs
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow run check-test.yml --repo "$GITHUB_REPOSITORY" --ref beta
gh workflow run check-test.yml --repo "$GITHUB_REPOSITORY" --ref beta -f quarantine=true

95
.github/workflows/nix-eval.yml vendored Normal file
View file

@ -0,0 +1,95 @@
name: nix-eval
on:
push:
branches: [dev]
pull_request:
branches: [dev]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
nix-eval:
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Nix
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
- name: Evaluate flake outputs (all systems)
run: |
set -euo pipefail
nix --version
echo "=== Flake metadata ==="
nix flake metadata
echo ""
echo "=== Flake structure ==="
nix flake show --all-systems
SYSTEMS="x86_64-linux aarch64-linux aarch64-darwin"
PACKAGES="opencode"
# TODO: move 'desktop' to PACKAGES when #11755 is fixed
OPTIONAL_PACKAGES="desktop"
echo ""
echo "=== Evaluating packages for all systems ==="
for system in $SYSTEMS; do
echo ""
echo "--- $system ---"
for pkg in $PACKAGES; do
printf " %s: " "$pkg"
if output=$(nix eval ".#packages.$system.$pkg.drvPath" --raw 2>&1); then
echo "✓"
else
echo "✗"
echo "::error::Evaluation failed for packages.$system.$pkg"
echo "$output"
exit 1
fi
done
done
echo ""
echo "=== Evaluating optional packages ==="
for system in $SYSTEMS; do
echo ""
echo "--- $system ---"
for pkg in $OPTIONAL_PACKAGES; do
printf " %s: " "$pkg"
if output=$(nix eval ".#packages.$system.$pkg.drvPath" --raw 2>&1); then
echo "✓"
else
echo "✗"
echo "::warning::Evaluation failed for packages.$system.$pkg"
echo "$output"
fi
done
done
echo ""
echo "=== Evaluating devShells for all systems ==="
for system in $SYSTEMS; do
printf "%s: " "$system"
if output=$(nix eval ".#devShells.$system.default.drvPath" --raw 2>&1); then
echo "✓"
else
echo "✗"
echo "::error::Evaluation failed for devShells.$system.default"
echo "$output"
exit 1
fi
done
echo ""
echo "=== All evaluations passed ==="

161
.github/workflows/nix-hashes.yml vendored Normal file
View file

@ -0,0 +1,161 @@
name: nix-hashes
permissions:
contents: write
on:
workflow_dispatch:
push:
branches: [dev]
paths:
- "bun.lock"
- "package.json"
- "packages/*/package.json"
- "services/*/package.json"
- "flake.lock"
- "nix/node_modules.nix"
- "nix/scripts/**"
- "patches/**"
- ".github/workflows/nix-hashes.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Native runners required: bun install cross-compilation flags (--os/--cpu)
# do not produce byte-identical node_modules as native installs.
compute-hash:
strategy:
fail-fast: false
matrix:
include:
- system: x86_64-linux
runner: blacksmith-4vcpu-ubuntu-2404
- system: aarch64-linux
runner: blacksmith-4vcpu-ubuntu-2404-arm
- system: aarch64-darwin
runner: macos-latest
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Nix
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
- name: Compute node_modules hash
id: hash
env:
SYSTEM: ${{ matrix.system }}
run: |
set -euo pipefail
BUILD_LOG=$(mktemp)
trap 'rm -f "$BUILD_LOG"' EXIT
HASH=""
MAX_ATTEMPTS=3
for ((ATTEMPT = 1; ATTEMPT <= MAX_ATTEMPTS; ATTEMPT++)); do
# Build with fakeHash to trigger hash mismatch and reveal correct hash
nix build ".#packages.${SYSTEM}.node_modules_updater" --no-link 2>&1 | tee "$BUILD_LOG" || true
HASH="$(nix run --inputs-from . nixpkgs#gnugrep -- -oP 'got:\s*\Ksha256-[A-Za-z0-9+/=]+' "$BUILD_LOG" | tail -n1 || true)"
[ -n "$HASH" ] && break
if [ "$ATTEMPT" -lt "$MAX_ATTEMPTS" ]; then
echo "::warning::Attempt ${ATTEMPT}/${MAX_ATTEMPTS} produced no hash for ${SYSTEM}; retrying in $((ATTEMPT * 10))s"
sleep $((ATTEMPT * 10))
fi
done
if [ -z "$HASH" ]; then
echo "::error::Failed to compute hash for ${SYSTEM} after ${MAX_ATTEMPTS} attempts"
cat "$BUILD_LOG"
exit 1
fi
echo "$HASH" > hash.txt
echo "Computed hash for ${SYSTEM}: $HASH"
- name: Upload hash
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: hash-${{ matrix.system }}
path: hash.txt
retention-days: 1
update-hashes:
needs: compute-hash
if: github.event_name != 'pull_request'
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Setup git committer
uses: ./.github/actions/setup-git-committer
with:
opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
- name: Pull latest changes
run: |
git pull --rebase --autostash origin "$GITHUB_REF_NAME"
- name: Download hash artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: hashes
pattern: hash-*
- name: Update hashes.json
run: |
set -euo pipefail
HASH_FILE="nix/hashes.json"
[ -f "$HASH_FILE" ] || echo '{"nodeModules":{}}' > "$HASH_FILE"
for SYSTEM in x86_64-linux aarch64-linux aarch64-darwin; do
FILE="hashes/hash-${SYSTEM}/hash.txt"
if [ -f "$FILE" ]; then
HASH="$(tr -d '[:space:]' < "$FILE")"
echo "${SYSTEM}: ${HASH}"
jq --arg sys "$SYSTEM" --arg h "$HASH" '.nodeModules[$sys] = $h' "$HASH_FILE" > tmp.json
mv tmp.json "$HASH_FILE"
else
echo "::warning::Missing hash for ${SYSTEM}"
fi
done
cat "$HASH_FILE"
- name: Commit changes
run: |
set -euo pipefail
HASH_FILE="nix/hashes.json"
if [ -z "$(git status --short -- "$HASH_FILE")" ]; then
echo "No changes to commit"
echo "### Nix hashes" >> "$GITHUB_STEP_SUMMARY"
echo "Status: no changes" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
git add "$HASH_FILE"
git commit -m "chore: update nix node_modules hashes"
git pull --rebase --autostash origin "$GITHUB_REF_NAME"
git push origin HEAD:"$GITHUB_REF_NAME"
echo "### Nix hashes" >> "$GITHUB_STEP_SUMMARY"
echo "Status: committed $(git rev-parse --short HEAD)" >> "$GITHUB_STEP_SUMMARY"

14
.github/workflows/notify-discord.yml vendored Normal file
View file

@ -0,0 +1,14 @@
name: notify-discord
on:
release:
types: [released] # fires when a draft release is published
jobs:
notify:
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Send nicely-formatted embed to Discord
uses: SethCohen/github-releases-to-discord@24d166886aee4646d448c8a389ff9e1ebcab3682 # v1.20.0
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}

34
.github/workflows/opencode.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: opencode
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
jobs:
opencode:
if: |
contains(github.event.comment.body, ' /oc') ||
startsWith(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, ' /opencode') ||
startsWith(github.event.comment.body, '/opencode')
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
id-token: write
contents: read
pull-requests: read
issues: read
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: ./.github/actions/setup-bun
- name: Run opencode
uses: anomalyco/opencode/github@2c14fc5586fe0b88e5c04732d2e846769cc35671 # latest
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
OPENCODE_PERMISSION: '{"bash": "deny"}'
with:
model: opencode/claude-opus-4-5

95
.github/workflows/pr-management.yml vendored Normal file
View file

@ -0,0 +1,95 @@
name: pr-management
on:
pull_request_target:
types: [opened]
jobs:
check-duplicates:
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 1
- name: Check team membership
id: team-check
run: |
LOGIN="${{ github.event.pull_request.user.login }}"
if [ "$LOGIN" = "opencode-agent[bot]" ] || grep -qxF "$LOGIN" .github/TEAM_MEMBERS; then
echo "is_team=true" >> "$GITHUB_OUTPUT"
echo "Skipping: $LOGIN is a team member or bot"
else
echo "is_team=false" >> "$GITHUB_OUTPUT"
fi
- name: Setup Bun
if: steps.team-check.outputs.is_team != 'true'
uses: ./.github/actions/setup-bun
- name: Install dependencies
if: steps.team-check.outputs.is_team != 'true'
run: bun install
- name: Install opencode
if: steps.team-check.outputs.is_team != 'true'
run: curl -fsSL https://opencode.ai/install | bash
- name: Build prompt
if: steps.team-check.outputs.is_team != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
{
echo "Check for duplicate PRs related to this new PR:"
echo ""
echo "CURRENT_PR_NUMBER: $PR_NUMBER"
echo ""
echo "Title: $(gh pr view "$PR_NUMBER" --json title --jq .title)"
echo ""
echo "Description:"
gh pr view "$PR_NUMBER" --json body --jq .body
} > pr_info.txt
- name: Check for duplicate PRs
if: steps.team-check.outputs.is_team != 'true'
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
COMMENT=$(bun script/duplicate-pr.ts -f pr_info.txt "Check the attached file for PR details and search for duplicates")
if [ "$COMMENT" != "No duplicate PRs found" ]; then
gh pr comment "$PR_NUMBER" --body "_The following comment was made by an LLM, it may be inaccurate:_
$COMMENT"
fi
add-contributor-label:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
steps:
- name: Add Contributor Label
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const isPR = !!context.payload.pull_request;
const issueNumber = isPR ? context.payload.pull_request.number : context.payload.issue.number;
const authorAssociation = isPR ? context.payload.pull_request.author_association : context.payload.issue.author_association;
if (authorAssociation === 'CONTRIBUTOR') {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: ['contributor']
});
}

360
.github/workflows/pr-standards.yml vendored Normal file
View file

@ -0,0 +1,360 @@
name: pr-standards
on:
pull_request_target:
types: [opened, edited, synchronize]
jobs:
check-standards:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check PR standards
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
with:
script: |
const pr = context.payload.pull_request;
const login = pr.user.login;
// Skip PRs older than Feb 18, 2026 at 6PM EST (Feb 19, 2026 00:00 UTC)
const cutoff = new Date('2026-02-19T00:00:00Z');
const prCreated = new Date(pr.created_at);
if (prCreated < cutoff) {
console.log(`Skipping: PR #${pr.number} was created before cutoff (${prCreated.toISOString()})`);
return;
}
// Check if author is a team member or bot
if (login === 'opencode-agent[bot]') return;
const { data: file } = await github.rest.repos.getContent({
owner: context.repo.owner,
repo: context.repo.repo,
path: '.github/TEAM_MEMBERS',
ref: 'dev'
});
const members = Buffer.from(file.content, 'base64').toString().split('\n').map(l => l.trim()).filter(Boolean);
if (members.includes(login)) {
console.log(`Skipping: ${login} is a team member`);
return;
}
const title = pr.title;
async function addLabel(label) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: [label]
});
}
async function removeLabel(label) {
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
name: label
});
} catch (e) {
// Label wasn't present, ignore
}
}
async function comment(marker, body) {
const markerText = `<!-- pr-standards:${marker} -->`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number
});
const existing = comments.find(c => c.body.includes(markerText));
if (existing) return;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: markerText + '\n' + body
});
}
// Step 1: Check title format
// Matches: feat:, feat(scope):, feat (scope):, etc.
const titlePattern = /^(feat|fix|docs|chore|refactor|test)\s*(\([a-zA-Z0-9-]+\))?\s*:/;
const hasValidTitle = titlePattern.test(title);
if (!hasValidTitle) {
await addLabel('needs:title');
await comment('title', `Hey! Your PR title \`${title}\` doesn't follow conventional commit format.
Please update it to start with one of:
- \`feat:\` or \`feat(scope):\` new feature
- \`fix:\` or \`fix(scope):\` bug fix
- \`docs:\` or \`docs(scope):\` documentation changes
- \`chore:\` or \`chore(scope):\` maintenance tasks
- \`refactor:\` or \`refactor(scope):\` code refactoring
- \`test:\` or \`test(scope):\` adding or updating tests
Where \`scope\` is the package name (e.g., \`app\`, \`desktop\`, \`opencode\`).
See [CONTRIBUTING.md](../blob/dev/CONTRIBUTING.md#pr-titles) for details.`);
return;
}
await removeLabel('needs:title');
// Step 2: Check for linked issue (skip for docs/refactor/feat PRs)
const skipIssueCheck = /^(docs|refactor|feat)\s*(\([a-zA-Z0-9-]+\))?\s*:/.test(title);
if (skipIssueCheck) {
await removeLabel('needs:issue');
console.log('Skipping issue check for docs/refactor/feat PR');
return;
}
const query = `
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
closingIssuesReferences(first: 1) {
totalCount
}
}
}
}
`;
const result = await github.graphql(query, {
owner: context.repo.owner,
repo: context.repo.repo,
number: pr.number
});
const linkedIssues = result.repository.pullRequest.closingIssuesReferences.totalCount;
// GitHub only populates closingIssuesReferences when a PR targets the repository's
// default branch (dev). PRs targeting other branches like v2 always return totalCount 0.
// Fall back to checking the PR description for closing keywords (e.g. Closes #123).
const body = pr.body || '';
const issueMatch = body.match(/### Issue for this PR\s*\n([\s\S]*?)(?=###|$)/);
const issueContent = issueMatch ? issueMatch[1].trim() : body;
const hasBodyIssueRef = /(closes|fixes|resolves)\s+#\d+/i.test(issueContent) || /#\d+/.test(issueContent);
const hasLinkedIssue = linkedIssues > 0 || hasBodyIssueRef;
if (!hasLinkedIssue) {
await addLabel('needs:issue');
await comment('issue', `Thanks for your contribution!
This PR doesn't have a linked issue. All PRs must reference an existing issue.
Please:
1. Open an issue describing the bug/feature (if one doesn't exist)
2. Add \`Fixes #<number>\` or \`Closes #<number>\` to this PR description
See [CONTRIBUTING.md](../blob/dev/CONTRIBUTING.md#issue-first-policy) for details.`);
return;
}
await removeLabel('needs:issue');
console.log('PR meets all standards');
check-compliance:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check PR template compliance
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
with:
script: |
const pr = context.payload.pull_request;
const login = pr.user.login;
// Skip PRs older than Feb 18, 2026 at 6PM EST (Feb 19, 2026 00:00 UTC)
const cutoff = new Date('2026-02-19T00:00:00Z');
const prCreated = new Date(pr.created_at);
if (prCreated < cutoff) {
console.log(`Skipping: PR #${pr.number} was created before cutoff (${prCreated.toISOString()})`);
return;
}
// Check if author is a team member or bot
if (login === 'opencode-agent[bot]') return;
const { data: file } = await github.rest.repos.getContent({
owner: context.repo.owner,
repo: context.repo.repo,
path: '.github/TEAM_MEMBERS',
ref: 'dev'
});
const members = Buffer.from(file.content, 'base64').toString().split('\n').map(l => l.trim()).filter(Boolean);
if (members.includes(login)) {
console.log(`Skipping: ${login} is a team member`);
return;
}
const body = pr.body || '';
const title = pr.title;
const isDocsRefactorOrFeat = /^(docs|refactor|feat)\s*(\([a-zA-Z0-9-]+\))?\s*:/.test(title);
const issues = [];
// Check: template sections exist
const hasWhatSection = /### What does this PR do\?/.test(body);
const hasTypeSection = /### Type of change/.test(body);
const hasVerifySection = /### How did you verify your code works\?/.test(body);
const hasChecklistSection = /### Checklist/.test(body);
const hasIssueSection = /### Issue for this PR/.test(body);
if (!hasWhatSection || !hasTypeSection || !hasVerifySection || !hasChecklistSection || !hasIssueSection) {
issues.push('PR description is missing required template sections. Please use the [PR template](../blob/dev/.github/pull_request_template.md).');
}
// Check: "What does this PR do?" has real content (not just placeholder text)
if (hasWhatSection) {
const whatMatch = body.match(/### What does this PR do\?\s*\n([\s\S]*?)(?=###|$)/);
const whatContent = whatMatch ? whatMatch[1].trim() : '';
const placeholder = 'Please provide a description of the issue';
const onlyPlaceholder = whatContent.includes(placeholder) && whatContent.replace(placeholder, '').replace(/[*\s]/g, '').length < 20;
if (!whatContent || onlyPlaceholder) {
issues.push('"What does this PR do?" section is empty or only contains placeholder text. Please describe your changes.');
}
}
// Check: at least one "Type of change" checkbox is checked
if (hasTypeSection) {
const typeMatch = body.match(/### Type of change\s*\n([\s\S]*?)(?=###|$)/);
const typeContent = typeMatch ? typeMatch[1] : '';
const hasCheckedBox = /- \[x\]/i.test(typeContent);
if (!hasCheckedBox) {
issues.push('No "Type of change" checkbox is checked. Please select at least one.');
}
}
// Check: issue reference (skip for docs/refactor/feat)
if (!isDocsRefactorOrFeat && hasIssueSection) {
const issueMatch = body.match(/### Issue for this PR\s*\n([\s\S]*?)(?=###|$)/);
const issueContent = issueMatch ? issueMatch[1].trim() : '';
const hasIssueRef = /(closes|fixes|resolves)\s+#\d+/i.test(issueContent) || /#\d+/.test(issueContent);
if (!hasIssueRef) {
issues.push('No issue referenced. Please add `Closes #<number>` linking to the relevant issue.');
}
}
// Check: "How did you verify" has content
if (hasVerifySection) {
const verifyMatch = body.match(/### How did you verify your code works\?\s*\n([\s\S]*?)(?=###|$)/);
const verifyContent = verifyMatch ? verifyMatch[1].trim() : '';
if (!verifyContent) {
issues.push('"How did you verify your code works?" section is empty. Please explain how you tested.');
}
}
// Check: checklist boxes are checked
if (hasChecklistSection) {
const checklistMatch = body.match(/### Checklist\s*\n([\s\S]*?)(?=###|$)/);
const checklistContent = checklistMatch ? checklistMatch[1] : '';
const unchecked = (checklistContent.match(/- \[ \]/g) || []).length;
const checked = (checklistContent.match(/- \[x\]/gi) || []).length;
if (checked < 2) {
issues.push('Not all checklist items are checked. Please confirm you have tested locally and have not included unrelated changes.');
}
}
// Helper functions
async function addLabel(label) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels: [label]
});
}
async function removeLabel(label) {
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
name: label
});
} catch (e) {}
}
const hasComplianceLabel = pr.labels.some(l => l.name === 'needs:compliance');
if (issues.length > 0) {
// Non-compliant
if (!hasComplianceLabel) {
await addLabel('needs:compliance');
}
const marker = '<!-- issue-compliance -->';
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number
});
const existing = comments.find(c => c.body.includes(marker));
const body_text = `${marker}
This PR doesn't fully meet our [contributing guidelines](../blob/dev/CONTRIBUTING.md) and [PR template](../blob/dev/.github/pull_request_template.md).
**What needs to be fixed:**
${issues.map(i => `- ${i}`).join('\n')}
Please edit this PR description to address the above within **72 hours**, or it will be automatically closed.
If you believe this was flagged incorrectly, please let a maintainer know.`;
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body: body_text
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: body_text
});
}
console.log(`PR #${pr.number} is non-compliant: ${issues.join(', ')}`);
} else if (hasComplianceLabel) {
// Was non-compliant, now fixed
await removeLabel('needs:compliance');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number
});
const marker = '<!-- issue-compliance -->';
const existing = comments.find(c => c.body.includes(marker));
if (existing) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id
});
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: 'Thanks for updating your PR! It now meets our contributing guidelines. :+1:'
});
console.log(`PR #${pr.number} is now compliant, label removed`);
} else {
console.log(`PR #${pr.number} is compliant`);
}

Some files were not shown because too many files have changed in this diff Show more