From f6bcc19f75759b9677383993ef8d5a3794c25358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Couralet?= Date: Thu, 26 Nov 2026 13:11:38 +0000 Subject: [PATCH] Package the config as a release tarball with an Onyxia init script - MANIFEST lists the runtime files shipped in the release (config, AGENTS.md, prompts, skills, commands, install.sh, licenses); dev scripts stay out. - scripts/build_dist.sh builds a reproducible opencode-onyxia.tar.gz + .sha256 from the git-tracked MANIFEST paths. - onyxia-init.sh, usable as the Onyxia personal init script: installs opencode v2 if missing, downloads a (pinnable) release, verifies its checksum and runs install.sh; never fails the service, logs to ~/.cache. - release workflow: checks on PRs, publishes the release on v* tags. - check_install.py covers the tarball and the init script. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 41 +++++++++++ .gitignore | 1 + INSTALL.md | 55 +++++++++++++- MANIFEST | 12 +++ README.md | 20 ++++- onyxia-init.sh | 101 ++++++++++++++++++++++++++ scripts/build_dist.sh | 45 ++++++++++++ scripts/check_install.py | 133 +++++++++++++++++++++++++++++++++- 8 files changed, 404 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 MANIFEST create mode 100755 onyxia-init.sh create mode 100755 scripts/build_dist.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b52a2d1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +# Checks the config on every pull request; on a `v*` tag, also builds the release tarball and publishes it. +# Release assets (same names in every release, so .../releases/latest/download/ always works): +# opencode-onyxia.tar.gz opencode-onyxia.tar.gz.sha256 onyxia-init.sh +name: release + +on: + pull_request: + push: + tags: ["v*"] + +permissions: + contents: read + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install opencode v2 + run: | + curl -fsSL https://opencode.ai/v2/install | bash + for d in "$HOME/.opencode/bin" "$HOME/.local/bin"; do echo "$d" >> "$GITHUB_PATH"; done + - run: opencode --version + - run: python3 -I scripts/check_permissions.py + - run: python3 -I scripts/check_install.py + + release: + if: startsWith(github.ref, 'refs/tags/v') + needs: check + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - run: bash scripts/build_dist.sh "$GITHUB_REF_NAME" dist + - name: Publish the GitHub release + env: + GH_TOKEN: ${{ github.token }} + run: | + gh release create "$GITHUB_REF_NAME" --verify-tag --generate-notes \ + dist/opencode-onyxia.tar.gz dist/opencode-onyxia.tar.gz.sha256 dist/onyxia-init.sh diff --git a/.gitignore b/.gitignore index be3fdad..51314f2 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ mlruns/ .DS_Store Thumbs.db *.swp +dist/ diff --git a/INSTALL.md b/INSTALL.md index 5d53966..3326f65 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -53,6 +53,42 @@ source ~/.bashrc ## 4. Install the config globally +### Method 0 — Onyxia init script (recommended on SSP Cloud, no manual step) + +Onyxia runs a *personal initialization script* at the start of every service. In Onyxia → **My account** → +**Services**, set: + +| Field | Value | +|---|---| +| Initialization script | `https://raw.githubusercontent.com/inseefrlab/opencode-onyxia/main/onyxia-init.sh` | +| Arguments | e.g. `--version v1.0.0` (default: latest release), `--bare` (models only), `--claude` | + +At start-up, `onyxia-init.sh`: +1. installs opencode v2 with the official installer, unless a v2 `opencode` is already on `PATH`; +2. downloads the release tarball `opencode-onyxia.tar.gz` and its `.sha256` from GitHub Releases, verifies the + checksum, and runs the bundled `install.sh` with your arguments (same result as Method A); +3. warns if `OPENAI_BASE_URL` / `OPENAI_API_KEY` are missing (on SSP Cloud the platform injects them). + +It **never makes the service fail**. Every error is logged to `~/.cache/opencode-onyxia-init.log`, and the service +starts without the config. + +Things to know: +- Onyxia fetches the script with `curl` **without `-L`**, so the URL must not redirect. Use the + `raw.githubusercontent.com` URL above. `github.com/.../releases/latest/download/onyxia-init.sh` redirects and + would run nothing. To pin the script itself, replace `main` with a tag. +- Pin `--version` for reproducible services. `latest` follows each new release. +- Onyxia accepts a single init script. If you already have one, call this script from it: + ```bash + curl -fsSL https://raw.githubusercontent.com/inseefrlab/opencode-onyxia/main/onyxia-init.sh | bash -s -- --version v1.0.0 + ``` +- Overrides: `OPENCODE_ONYXIA_REPO=/` (a fork's releases), `OPENCODE_ONYXIA_URL=` (any + location holding the two files, e.g. a MinIO bucket), `OPENCODE_ONYXIA_SKIP_OPENCODE=1`. +- The checksum guards against a corrupted or truncated download. It is fetched from the same release, so it does + not authenticate the publisher. + +The tarball contains only the runtime files listed in `MANIFEST` (config, `AGENTS.md`, prompts, skills, +commands, `install.sh`, licenses) plus a `VERSION` file. No dev scripts or tests. + ### Method A — provided script (recommended) From the unpacked repository folder: @@ -99,7 +135,7 @@ It installs **no** agents, permissions, policies, MCP servers, skills, commands, are left in place and stay active; the script says so. - Re-run `./install.sh --bare` after a `git pull` to pick up model changes. You still need `OPENAI_BASE_URL` and `OPENAI_API_KEY` (step 3 above). -- `python3 -I scripts/check_install.py` tests what the full and the bare install write. +- `python3 -I scripts/check_install.py` tests the full and bare installs, the release tarball and `onyxia-init.sh`. ### Method B — manual @@ -191,9 +227,24 @@ To update, review the upstream diff, bump the SHA in `UPSTREAM.lock`, re-run the edit no longer applies) and update `THIRD_PARTY.md`. The DuckDB skills are adapted by hand: port upstream changes manually and re-test the snippets. +## Publishing a release (maintainers) + +```bash +python3 -I scripts/check_permissions.py && python3 -I scripts/check_install.py +git tag v1.2.0 && git push origin v1.2.0 +``` + +`.github/workflows/release.yml` reruns both checks, then builds the tarball with `scripts/build_dist.sh` and +publishes a GitHub Release with `opencode-onyxia.tar.gz`, `opencode-onyxia.tar.gz.sha256` and `onyxia-init.sh`. +The same workflow runs the checks on every pull request. To ship a new file, add its path to `MANIFEST`: the build +fails on an untracked or misspelled path, and `check_install.py` compares the tarball with `MANIFEST`. Build +locally with `scripts/build_dist.sh v0.0.0-test` (output in `dist/`, git-ignored). Two builds of the same commit +produce identical bytes. + ## Updating the global config -After a `git pull` of the repository, simply rerun: +With Method 0, new services pick up the release that `--version` points to (or the newest one, with `latest`). +With a clone, after a `git pull`, rerun: ```bash ./install.sh diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..2971e2b --- /dev/null +++ b/MANIFEST @@ -0,0 +1,12 @@ +# Runtime files shipped in the release tarball (read by scripts/build_dist.sh, tested by scripts/check_install.py). +# One tracked path per line (directory = everything tracked under it). Keep the .opencode/ layout: install.sh reads it. +# Dev-only material (scripts/, UPSTREAM.lock, README.md, INSTALL.md, onyxia-init.sh) stays out. +opencode.jsonc +AGENTS.md +install.sh +LICENSE +THIRD_PARTY.md +licenses +prompts +.opencode/skills +.opencode/commands diff --git a/README.md b/README.md index 447db23..e6c8a16 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,16 @@ opencode-onyxia/ ├── opencode.jsonc # main config (native opencode v2): providers, models/variants, agents, permissions, MCP ├── AGENTS.md # Onyxia context shared by ALL agents (loaded automatically) ├── install.sh # GLOBAL install into ~/.config/opencode (all projects) +├── onyxia-init.sh # Onyxia personal init script: installs opencode + a released config at service start +├── MANIFEST # runtime files shipped in the release tarball ├── INSTALL.md # detailed install guide +├── .github/workflows/release.yml # checks on PRs; on a v* tag builds and publishes the release tarball ├── THIRD_PARTY.md UPSTREAM.lock # skills adapted from duckdb/duckdb-skills (MIT) and mlflow/skills (Apache-2.0) ├── licenses/ # upstream licenses ├── scripts/vendor_mlflow_skills.py# re-creates the vendored mlflow-* skills from the pinned upstream revision ├── scripts/check_permissions.py # model-free test of the permission rules (allow/ask/deny table) -├── scripts/check_install.py # tests what `install.sh` and `install.sh --bare` write +├── scripts/check_install.py # tests install.sh (full/--bare), the release tarball and onyxia-init.sh +├── scripts/build_dist.sh # builds dist/opencode-onyxia.tar.gz (+ .sha256) from MANIFEST ├── prompts/ # one system prompt per agent │ ├── build.md plan.md python-ds.md r-ds.md mlops.md reviewer.md dataviz-vision.md └── .opencode/ @@ -42,6 +46,20 @@ opencode-onyxia/ ``` ## Installation (summary — detailed guide in `INSTALL.md`) + +**On SSP Cloud, the shortest route is the init script.** Under Onyxia → *My account* → *Services*, set the +initialization script and (optionally) its arguments: +``` +URL https://raw.githubusercontent.com/inseefrlab/opencode-onyxia/main/onyxia-init.sh +args --version v1.0.0 # pin a release (default: latest); add --bare for the models only +``` +Every new service then installs opencode v2 (if missing) and the released config, checksum-verified. The script +never makes the service fail: errors go to `~/.cache/opencode-onyxia-init.log`. The platform already injects +`OPENAI_BASE_URL` / `OPENAI_API_KEY`. If you already use another init script, add one line to it instead: +`curl -fsSL https://raw.githubusercontent.com/inseefrlab/opencode-onyxia/main/onyxia-init.sh | bash -s -- --version v1.0.0`. + +Manual install from a clone: + 1. **Install OpenCode v2** in the service (VSCode/Jupyter). This config is in the *native v2 format* and cannot be read by OpenCode v1: ```bash diff --git a/onyxia-init.sh b/onyxia-init.sh new file mode 100755 index 0000000..5054425 --- /dev/null +++ b/onyxia-init.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash +# SSP Cloud / Onyxia init script: installs opencode v2 (if needed) and the opencode-onyxia config from a release. +# +# As your personal init script (Onyxia → My account → Services → Initialization script): +# URL https://raw.githubusercontent.com/inseefrlab/opencode-onyxia/main/onyxia-init.sh +# args e.g. --version v1.0.0 --bare +# (Onyxia runs `curl $URL | bash -s -- $ARGS` WITHOUT -L: use a raw.githubusercontent.com URL, never a +# github.com/.../releases/... one, which redirects and would run nothing.) +# From another init script (Onyxia takes only one): +# curl -fsSL https://raw.githubusercontent.com/inseefrlab/opencode-onyxia/main/onyxia-init.sh | bash -s -- --version v1.0.0 +# +# Options: --version release to install (default: latest; env OPENCODE_ONYXIA_VERSION) +# anything else passed to install.sh (--bare, --claude) +# Env: OPENCODE_ONYXIA_REPO GitHub repo to download from (default inseefrlab/opencode-onyxia) +# OPENCODE_ONYXIA_URL base URL holding opencode-onyxia.tar.gz(.sha256): overrides repo/version +# OPENCODE_ONYXIA_SKIP_OPENCODE=1 do not install opencode itself +# OPENCODE_CONFIG_DIR target config dir (default ~/.config/opencode, handled by install.sh) +# +# Never makes the service fail: any error is logged (~/.cache/opencode-onyxia-init.log) and the script exits 0. +set -uo pipefail + +LOG="${HOME}/.cache/opencode-onyxia-init.log" +mkdir -p "$(dirname "$LOG")" 2>/dev/null && exec > >(tee -a "$LOG") 2>&1 +echo "=== opencode-onyxia init — $(date -Is) ===" + +log() { echo "[opencode-onyxia] $*"; } +fail() { echo "[opencode-onyxia] ✗ $*" >&2; return 1; } + +is_v2() { command -v opencode >/dev/null 2>&1 && opencode --version 2>/dev/null | head -n1 | grep -Eq '(^|v| )2\.'; } + +ensure_path_line() { # $1 = directory to put on PATH in ~/.bashrc (idempotent) + local line="export PATH=\"$1:\$PATH\"" + grep -qxF "$line" "$HOME/.bashrc" 2>/dev/null || echo "$line" >> "$HOME/.bashrc" + case ":$PATH:" in *":$1:"*) ;; *) export PATH="$1:$PATH" ;; esac +} + +install_opencode() { + if [ "${OPENCODE_ONYXIA_SKIP_OPENCODE:-0}" = 1 ]; then log "skipping opencode install (OPENCODE_ONYXIA_SKIP_OPENCODE=1)"; return 0; fi + if is_v2; then log "opencode already installed: $(opencode --version 2>/dev/null | head -n1)"; return 0; fi + log "installing opencode v2…" + curl -fsSL https://opencode.ai/v2/install | bash || fail "opencode installer failed" || return 1 + local d + for d in "$HOME/.opencode/bin" "$HOME/.local/bin"; do + [ -x "$d/opencode" ] && ensure_path_line "$d" + done + is_v2 || fail "opencode v2 not found on PATH after install" || return 1 + log "opencode installed: $(opencode --version 2>/dev/null | head -n1)" +} + +install_config() { + local version="${OPENCODE_ONYXIA_VERSION:-latest}" repo="${OPENCODE_ONYXIA_REPO:-inseefrlab/opencode-onyxia}" + local args=() + while [ $# -gt 0 ]; do + case "$1" in + --version) [ $# -ge 2 ] || { fail "--version needs a value"; return 1; }; version="$2"; shift 2 ;; + --version=*) version="${1#*=}"; shift ;; + *) args+=("$1"); shift ;; + esac + done + + local base + if [ -n "${OPENCODE_ONYXIA_URL:-}" ]; then base="$OPENCODE_ONYXIA_URL" + elif [ "$version" = latest ]; then base="https://github.com/$repo/releases/latest/download" + else base="https://github.com/$repo/releases/download/$version" + fi + + tmp="$(mktemp -d)" || return 1 # global: removed by the EXIT trap + log "downloading $base/opencode-onyxia.tar.gz" + curl -fsSL -o "$tmp/opencode-onyxia.tar.gz" "$base/opencode-onyxia.tar.gz" \ + && curl -fsSL -o "$tmp/opencode-onyxia.tar.gz.sha256" "$base/opencode-onyxia.tar.gz.sha256" \ + || { fail "download failed (version '$version' exists? network?)"; return 1; } + (cd "$tmp" && sha256sum -c --quiet opencode-onyxia.tar.gz.sha256) || { fail "checksum mismatch: not installing"; return 1; } + + mkdir "$tmp/src" && tar -xzf "$tmp/opencode-onyxia.tar.gz" -C "$tmp/src" --strip-components=1 \ + || { fail "could not extract the tarball"; return 1; } + local installed + installed="$(cat "$tmp/src/VERSION" 2>/dev/null || echo unknown)" + log "installing config $installed ${args[*]:-}" + bash "$tmp/src/install.sh" "${args[@]}" || { fail "install.sh failed"; return 1; } + + # When Onyxia runs this as root, hand the files back to the service user + local dest="${OPENCODE_CONFIG_DIR:-$HOME/.config/opencode}" + if [ "$(id -u)" = 0 ] && [ -n "${USERNAME:-}" ] && id "$USERNAME" >/dev/null 2>&1; then + chown -R "$USERNAME:$(id -gn "$USERNAME")" "$dest" "$HOME/.claude" 2>/dev/null || true + fi + log "✓ opencode-onyxia $installed installed in $dest" +} + +check_env() { + if [ -z "${OPENAI_BASE_URL:-}" ] || [ -z "${OPENAI_API_KEY:-}" ]; then + log "⚠ OPENAI_BASE_URL / OPENAI_API_KEY not set: opencode cannot reach the models." + log " Create a key at https://llm.lab.sspcloud.fr (Settings → Account → API Keys), store it in Vault" + log " (My secrets) and inject it in your services; OPENAI_BASE_URL=https://llm.lab.sspcloud.fr/api" + fi +} + +tmp="" +trap '[ -n "$tmp" ] && rm -rf "$tmp"' EXIT +install_opencode || log "continuing without a verified opencode v2" +if install_config "$@"; then check_env; else log "config NOT installed — see $LOG"; fi +exit 0 diff --git a/scripts/build_dist.sh b/scripts/build_dist.sh new file mode 100755 index 0000000..7fd7578 --- /dev/null +++ b/scripts/build_dist.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Builds the release tarball: only the runtime files listed in MANIFEST (tracked by Git), under a versioned prefix. +# +# Usage: scripts/build_dist.sh [out_dir] e.g. scripts/build_dist.sh v1.2.0 +# Writes: /opencode-onyxia.tar.gz (asset name is the same in every release, so +# /opencode-onyxia.tar.gz.sha256 releases/latest/download/... always resolves) +# /onyxia-init.sh (attached to the release for reference) +# +# Content = the working-tree version of the files Git tracks under MANIFEST paths (untracked files, caches and +# local junk never get in). Reproducible: sorted entries, fixed mtime (last commit), root owner, gzip -n. +set -euo pipefail + +VERSION="${1:?usage: scripts/build_dist.sh [out_dir]}" +REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +OUT="${2:-$REPO/dist}" +NAME="opencode-onyxia" +PREFIX="$NAME-$VERSION" + +cd "$REPO" +mapfile -t paths < <(grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' MANIFEST) +mapfile -t files < <(git ls-files -- "${paths[@]}") +for p in "${paths[@]}"; do # a typo or a removed path in MANIFEST must not silently ship an incomplete tarball + if ! printf '%s\n' "${files[@]}" | grep -q -e "^$p\$" -e "^$p/"; then + echo "✗ MANIFEST path not tracked by Git: $p" >&2 + exit 1 + fi +done + +stage="$(mktemp -d)" +trap 'rm -rf "$stage"' EXIT +printf '%s\n' "$VERSION" > "$stage/VERSION" +mtime="@$(git log -1 --format=%ct)" +tar_opts=(--sort=name --mtime="$mtime" --owner=0 --group=0 --numeric-owner --mode='u+rw,go+r,go-w') + +mkdir -p "$OUT" +{ + tar -cf - "${tar_opts[@]}" --transform "s|^|$PREFIX/|" "${files[@]}" +} > "$stage/files.tar" +tar -rf "$stage/files.tar" "${tar_opts[@]}" -C "$stage" --transform "s|^|$PREFIX/|" VERSION +gzip -n -9 < "$stage/files.tar" > "$OUT/$NAME.tar.gz" +(cd "$OUT" && sha256sum "$NAME.tar.gz" > "$NAME.tar.gz.sha256") +cp -f "$REPO/onyxia-init.sh" "$OUT/onyxia-init.sh" + +echo "✓ $OUT/$NAME.tar.gz ($PREFIX, ${#files[@]} files)" +cat "$OUT/$NAME.tar.gz.sha256" diff --git a/scripts/check_install.py b/scripts/check_install.py index 2a123e7..855e5cd 100755 --- a/scripts/check_install.py +++ b/scripts/check_install.py @@ -14,6 +14,7 @@ import shutil import subprocess import sys +import tarfile import tempfile from pathlib import Path @@ -57,6 +58,11 @@ def tree(path: Path) -> list[str]: return sorted(str(p.relative_to(path)) for p in path.rglob("*")) if path.exists() else [] +def clean_tree(path: Path) -> list[str]: + """tree() without local bytecode caches, which a repo checkout may hold but a release never ships.""" + return [p for p in tree(path) if "__pycache__" not in p] + + results: list[tuple[str, bool, str]] = [] @@ -176,7 +182,132 @@ def main() -> int: str(tree(dest)), ) - # 6. the bare config loads in a real opencode service ------------------------------------------------- + # 6. release tarball: only the MANIFEST paths, installs like the repo --------------------------------- + dist = work / "dist" + r = subprocess.run( + ["bash", str(REPO / "scripts" / "build_dist.sh"), "v0.0.0-test", str(dist)], + capture_output=True, + text=True, + check=False, + timeout=120, + ) + check("build_dist.sh succeeds", r.returncode == 0, r.stderr.strip()[-200:]) + manifest = [ + ln.strip() for ln in (REPO / "MANIFEST").read_text().splitlines() if ln.strip() and not ln.startswith("#") + ] + tracked = subprocess.run( + ["git", "-C", str(REPO), "ls-files", "--", *manifest], + capture_output=True, + text=True, + check=True, + ).stdout.split() + with tarfile.open(dist / "opencode-onyxia.tar.gz") as tf: + names = sorted(m.name.split("/", 1)[1] for m in tf.getmembers() if m.isfile()) + src = work / "dist-src" + tf.extractall(src, filter="data") + check( + "tarball holds exactly the tracked MANIFEST files + VERSION", + names == sorted([*tracked, "VERSION"]), + str(sorted(set(names) ^ {*tracked, "VERSION"}))[:200], + ) + check( + "tarball ships no dev scripts", + not any(n.startswith("scripts/") for n in names), + ) + src = next(src.iterdir()) + check( + "VERSION file holds the version", + (src / "VERSION").read_text().strip() == "v0.0.0-test", + ) + for args, label in (((), "full"), (("--bare",), "bare")): + d_repo, d_dist, h = ( + work / f"cmp-{label}-repo", + work / f"cmp-{label}-dist", + work / f"cmp-{label}-home", + ) + h.mkdir() + install(REPO, d_repo, h, *args) + install(src, d_dist, h, *args) + check( + f"{label} install from the tarball == from the repo", + clean_tree(d_repo) == tree(d_dist) and tree(d_dist) != [], + str(sorted(set(clean_tree(d_repo)) ^ set(tree(d_dist))))[:200], + ) + r2 = subprocess.run( + [ + "bash", + str(REPO / "scripts" / "build_dist.sh"), + "v0.0.0-test", + str(work / "dist2"), + ], + capture_output=True, + text=True, + check=False, + timeout=120, + ) + check( + "the build is reproducible (same sha256 twice)", + r2.returncode == 0 + and (dist / "opencode-onyxia.tar.gz.sha256").read_text() + == (work / "dist2" / "opencode-onyxia.tar.gz.sha256").read_text(), + ) + + # 7. onyxia-init.sh: installs from a release, refuses a bad checksum, never fails the service --------- + def init(base: Path, home: Path, dest: Path, *args: str) -> subprocess.CompletedProcess: + env = { + "PATH": "/usr/bin:/bin:/usr/local/bin", + "HOME": str(home), + "OPENCODE_CONFIG_DIR": str(dest), + "OPENCODE_ONYXIA_URL": base.as_uri(), + "OPENCODE_ONYXIA_SKIP_OPENCODE": "1", + } + home.mkdir(parents=True, exist_ok=True) + return subprocess.run( + ["bash", "-s", "--", *args], + input=(REPO / "onyxia-init.sh").read_text(), + env=env, + capture_output=True, + text=True, + check=False, + timeout=120, + ) + + dest, home = work / "init" / "cfg", work / "init" / "home" + r = init(dist, home, dest) + check( + "init script (piped like Onyxia) installs the full config", + r.returncode == 0 and tree(dest) == clean_tree(work / "cmp-full-repo"), + (r.stdout + r.stderr)[-300:], + ) + check( + "init script logs to ~/.cache", + (home / ".cache" / "opencode-onyxia-init.log").exists(), + ) + dest = work / "init-bare" / "cfg" + r = init(dist, work / "init-bare" / "home", dest, "--version", "v9", "--bare") + check( + "init script passes --bare to install.sh", + tree(dest) == ["opencode.jsonc"], + str(tree(dest)), + ) + bad = work / "bad" + shutil.copytree(dist, bad) + (bad / "opencode-onyxia.tar.gz.sha256").write_text(f"{'0' * 64} opencode-onyxia.tar.gz\n") + dest = work / "init-bad" / "cfg" + r = init(bad, work / "init-bad" / "home", dest) + check( + "bad checksum: nothing installed, exit 0, error reported", + r.returncode == 0 and not dest.exists() and "checksum mismatch" in r.stdout + r.stderr, + f"rc={r.returncode} {tree(dest)}", + ) + r = init(work / "missing", work / "init-404" / "home", work / "init-404" / "cfg") + check( + "unreachable release: exit 0, error reported", + r.returncode == 0 and "download failed" in r.stdout + r.stderr, + (r.stdout + r.stderr)[-200:], + ) + + # 8. the bare config loads in a real opencode service ------------------------------------------------- if shutil.which("opencode") is None: print("skip bare config loaded by opencode (opencode not on PATH)") else: