Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Harness OS: bundle OpenCode in /usr on the Orange Pi 4 Pro

bubu-duduf10dec698416
diff --git a/os/platforms/orangepi-4pro/README.md b/os/platforms/orangepi-4pro/README.md
index 58516fd69..2dcaf1fe2 100644
--- a/os/platforms/orangepi-4pro/README.md
+++ b/os/platforms/orangepi-4pro/README.md
@@ -15,7 +15,7 @@ update feed is generated, and the board keeps Debian's own system updates.
| Base | Arch Linux, LTS kernel | Orange Pi Debian 12, vendor kernel 5.15 |
| Compositor | labwc 0.20.2 on Arch's wlroots 0.20 | the same labwc source and patch, built with wlroots 0.20.2 and newer Wayland libraries into `/opt/harness-wl` |
| Rendering | GPU | CPU (`WLR_RENDERER=pixman`): the PowerVR GPU has no open driver |
-| OpenCode | Arch's 2.x | the official 1.x ARM release pinned in `os/packaging/fedora/opencode.lock.json`; the skel config is restated in OpenCode 1's `permission` form |
+| OpenCode | Arch's 2.x at `/usr/bin/opencode` | the official 1.x ARM release pinned in `os/packaging/fedora/opencode.lock.json`, bundled as the Fedora package does (`opencode_payload.py`: `/usr/lib/harness-opencode`, `/usr/bin/opencode`, where first use starts it); the skel config is restated in OpenCode 1's `permission` form |
| Claude Code | installed by hn when first chosen | preinstalled with hn's recipe (`npm install -g @anthropic-ai/claude-code`); version recorded in `/etc/harness-image.json` |
| System profile | `arch` | `debian`: `hn-os` and `harness install/upgrade/rollback` refuse PC system operations, as on Fedora |
| Screen lock | gtklock | not available on Debian 12 (Super+l and the idle lock do nothing yet) |
diff --git a/os/platforms/orangepi-4pro/build-image.sh b/os/platforms/orangepi-4pro/build-image.sh
index 15babe3c7..25aa92207 100755
--- a/os/platforms/orangepi-4pro/build-image.sh
+++ b/os/platforms/orangepi-4pro/build-image.sh
@@ -21,10 +21,10 @@ attach_image "$OUT"
[[ -f $MNT/etc/harness-base.json && -x $MNT$PREFIX/bin/labwc ]] || { echo "$BASE is not a build-base.sh image." >&2; exit 1; }
HARNESS_WL_PREFIX=$PREFIX "$HERE/install-session.sh" "$MNT" "$RUNTIME" "$ACCOUNT"
-# OpenCode, the version the ARM package pins. Claude Code too, by hn's own install recipe
+# install-session.sh bundles OpenCode in /usr. Claude Code is preinstalled by hn's own recipe
# (cli/src/lib/engineInstall.ts), so the first Claude harness need not wait for a download;
# other agents install from hn when chosen.
-chroot "$MNT" su - "$ACCOUNT" -c "npm_config_prefix=\$HOME/.local npm install -g --no-audit --no-fund opencode-ai@$OPENCODE @anthropic-ai/claude-code >/dev/null 2>&1"
+chroot "$MNT" su - "$ACCOUNT" -c "npm_config_prefix=\$HOME/.local npm install -g --no-audit --no-fund @anthropic-ai/claude-code >/dev/null 2>&1"
CLAUDE=$(chroot "$MNT" su - "$ACCOUNT" -c '$HOME/.local/bin/claude --version' | cut -d' ' -f1)
python3 - "$MNT/etc/harness-image.json" "$MNT/etc/harness-base.json" "$SOURCE" "$OPENCODE" "$CLAUDE" <<'PY'
import json, subprocess, sys
@@ -42,6 +42,6 @@ for leftover in "home/$ACCOUNT/.ssh/authorized_keys" "home/$ACCOUNT/.harness" "r
[[ ! -e $MNT/$leftover ]] || { echo "Unexpected build-host state: $leftover" >&2; exit 1; }
done
chroot "$MNT" /usr/lib/harness/hn --version
-chroot "$MNT" su - "$ACCOUNT" -c '$HOME/.local/bin/opencode --version'
+chroot "$MNT" su - "$ACCOUNT" -c '/usr/bin/opencode --version'
df -h "$MNT" | tail -1
release_image
diff --git a/os/platforms/orangepi-4pro/install-session.sh b/os/platforms/orangepi-4pro/install-session.sh
index d64f57274..ca7f1db13 100755
--- a/os/platforms/orangepi-4pro/install-session.sh
+++ b/os/platforms/orangepi-4pro/install-session.sh
@@ -29,6 +29,15 @@ if info.get('architecture') != 'aarch64' or info.get('dirty') is not False:
module.validate_runtime = lambda runtime, commit: info
commit = subprocess.check_output(['git', '-c', f'safe.directory={source}', '-C', str(source), 'rev-parse', 'HEAD'], text=True).strip()
module.stage(source, runtime, destination, commit)
+# OpenCode as the Fedora package bundles it: the locked ARM release, checksum- and ELF-checked,
+# at /usr/lib/harness-opencode with /usr/bin/opencode, where first use (`hn-os try`) starts it.
+payload_spec = importlib.util.spec_from_file_location('opencode_payload', source / 'os/tools/opencode_payload.py')
+payload = importlib.util.module_from_spec(payload_spec)
+payload_spec.loader.exec_module(payload)
+lock = payload.read_lock(source / 'os/packaging/fedora/opencode.lock.json')
+prepared = destination.parent / 'opencode'
+payload.prepare(lock, destination.parent / 'archives', prepared)
+payload.stage(prepared, destination, lock)
# A non-arch profile makes hn-os and `harness install|upgrade|rollback` refuse the PC system
# operations, as the Fedora package does. Debian keeps its own system updates.
path = destination / 'usr/share/harness-os/runtime.json'