Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(regression): install agent backends as the service user so self-update works (#545)
Call Whitea2de4c8ce78e
diff --git a/scripts/incus_regression.py b/scripts/incus_regression.pyindex 6b8cc0d93..391491a52 100644--- a/scripts/incus_regression.py+++ b/scripts/incus_regression.py@@ -1260,23 +1260,38 @@ def cmd_build_base(args: argparse.Namespace) -> int:apt-get install -y bash ca-certificates curl git build-essential python3 python3-pip python3-venv rsync sudocurl -fsSL https://deb.nodesource.com/setup_20.x | bash -apt-get install -y nodejs- npm install -g @anthropic-ai/claude-code @openai/codex- curl -fsSL https://askill.sh | sh -s -- -b /usr/local/bin- HOME=/usr/local curl -fsSL https://opencode.ai/install | bash -s -- --no-modify-path- opencode_bin=""- for candidate in /usr/local/.opencode/bin/opencode /root/.opencode/bin/opencode; do- if [ -x "$candidate" ]; then- opencode_bin="$candidate"- break- fi- done- if [ -z "$opencode_bin" ]; then+ # Install the agent backends under the service user's home so the+ # non-root avibe service can self-update them (`claude update`, etc.).+ # Root-global installs under /usr are not writable by the avibe user,+ # which is exactly what breaks self-update in regression. These land+ # root-owned at build time and are made avibe-owned per instance by the+ # `chown -R avibe:avibe /home/avibe` in cloud-init runcmd /+ # ensure_project_and_instance; the service PATH already prefers+ # /home/avibe/.local/bin over /usr.+ avibe_home=/home/avibe+ mkdir -p "$avibe_home/.local/bin" "$avibe_home/.npm-global"+ # Persist a user-writable npm prefix so claude-code/codex install here+ # AND future npm-based self-updates by the avibe user stay writable.+ printf 'prefix=%s/.npm-global\n' "$avibe_home" > "$avibe_home/.npmrc"+ HOME="$avibe_home" npm install -g @anthropic-ai/claude-code @openai/codex+ ln -sf "$avibe_home/.npm-global/bin/claude" "$avibe_home/.local/bin/claude"+ ln -sf "$avibe_home/.npm-global/bin/codex" "$avibe_home/.local/bin/codex"+ # OpenCode installs into the service user's home via its own updater.+ # HOME must be set on the piped `bash` (the installer), not on `curl`.+ curl -fsSL https://opencode.ai/install | HOME="$avibe_home" bash -s -- --no-modify-path+ if [ ! -x "$avibe_home/.opencode/bin/opencode" ]; thenecho "OpenCode installer did not produce an opencode binary" >&2exit 1fi- install -o root -g root -m 0755 "$opencode_bin" /usr/local/bin/opencode- askill --version+ ln -sf "$avibe_home/.opencode/bin/opencode" "$avibe_home/.local/bin/opencode"+ # askill stays system-global: it is a bootstrap dependency, not a+ # self-updated agent backend.+ curl -fsSL https://askill.sh | sh -s -- -b /usr/local/bin+ export PATH="$avibe_home/.local/bin:$PATH"+ claude --version+ codex --versionopencode --version+ askill --versionnode --versionnpm --version"""diff --git a/scripts/prepare_regression.py b/scripts/prepare_regression.pyindex 185463ed0..fc7124445 100755--- a/scripts/prepare_regression.py+++ b/scripts/prepare_regression.py@@ -54,7 +54,12 @@ RESET_MODES = {"none", "config", "all"}CONTAINER_HOME = Path("/home/avibe")CONTAINER_AVIBE_HOME = CONTAINER_HOME / ".avibe"DEFAULT_CWD = str(CONTAINER_AVIBE_HOME / "workdir")-CONTAINER_OPENCODE_CLI = "/usr/local/bin/opencode"+# OpenCode is a bare PATH-resolved name (the system default; claude/codex too).+# The service PATH prefers ~/.local/bin, where build-base installs the user-owned,+# self-updatable binary; on a not-yet-rebuilt base it still resolves the old+# /usr/local/bin copy. Bare avoids pinning an absolute path that may be absent on+# a given instance (the cause of breakage across base-image generations).+CONTAINER_OPENCODE_CLI = "opencode"ENV_PREFIX = "REGRESSION_"@@ -641,8 +646,20 @@ def _normalize_config_payload(path: Path) -> None:if not isinstance(opencode, dict):returncli_path = str(opencode.get("cli_path") or "")- legacy_home_cli = str(CONTAINER_HOME / ".opencode" / "bin" / "opencode")- if cli_path not in {"", "opencode", legacy_home_cli}:+ # Migrate any recognized opencode install location to the bare PATH-resolved+ # name. Pinning an absolute path breaks across base-image generations: the+ # pre-#545 root-global /usr/local/bin/opencode and the user-owned+ # ~/.local/bin/opencode (or its ~/.opencode source) do not both exist on every+ # instance, so a preserved-state config could point at a path that is absent.+ # A custom user-set path is left untouched.+ known_opencode_paths = {+ "",+ "opencode",+ "/usr/local/bin/opencode",+ str(CONTAINER_HOME / ".opencode" / "bin" / "opencode"),+ str(CONTAINER_HOME / ".local" / "bin" / "opencode"),+ }+ if cli_path not in known_opencode_paths:returnopencode["cli_path"] = CONTAINER_OPENCODE_CLIdiff --git a/tests/test_incus_regression.py b/tests/test_incus_regression.pyindex 4606b6e15..c991b411f 100644--- a/tests/test_incus_regression.py+++ b/tests/test_incus_regression.py@@ -391,11 +391,15 @@ def test_build_base_uses_publishable_temp_instance() -> None:assert "--ephemeral" not in joinedassert "incus launch images:ubuntu/24.04/cloud avibe-regression-base-build --storage default --network incusbr0" in joinedassert "https://deb.nodesource.com/setup_20.x" in joined- assert "npm install -g @anthropic-ai/claude-code @openai/codex" in joined+ assert 'HOME="$avibe_home" npm install -g @anthropic-ai/claude-code @openai/codex' in joinedassert "https://askill.sh | sh -s -- -b /usr/local/bin" in joined- assert "HOME=/usr/local curl -fsSL https://opencode.ai/install | bash -s -- --no-modify-path" in joined- assert "/usr/local/.opencode/bin/opencode /root/.opencode/bin/opencode" in joined- assert 'install -o root -g root -m 0755 "$opencode_bin" /usr/local/bin/opencode' in joined+ assert ".npm-global" in joined+ assert 'ln -sf "$avibe_home/.npm-global/bin/claude" "$avibe_home/.local/bin/claude"' in joined+ assert 'ln -sf "$avibe_home/.npm-global/bin/codex" "$avibe_home/.local/bin/codex"' in joined+ assert 'curl -fsSL https://opencode.ai/install | HOME="$avibe_home" bash -s -- --no-modify-path' in joined+ assert 'ln -sf "$avibe_home/.opencode/bin/opencode" "$avibe_home/.local/bin/opencode"' in joined+ # Backends must not be root-global: the non-root avibe user owns them and self-updates.+ assert "/usr/local/bin/opencode" not in joinedassert "cloud-init clean --logs || true" in joinedassert "incus publish avibe-regression-base-build --alias avibe-regression-base-current" in joineddiff --git a/tests/test_prepare_regression.py b/tests/test_prepare_regression.pyindex 6f74bfbd1..53d37b69f 100644--- a/tests/test_prepare_regression.py+++ b/tests/test_prepare_regression.py@@ -84,7 +84,7 @@ def test_prepare_generates_unified_state(tmp_path: Path, monkeypatch: pytest.Monassert config["agents"]["claude"]["enabled"] is Trueassert config["agents"]["codex"]["enabled"] is Trueassert config["agents"]["default_backend"] == "opencode"- assert config["agents"]["opencode"]["cli_path"] == "/usr/local/bin/opencode"+ assert config["agents"]["opencode"]["cli_path"] == "opencode"assert config["agents"]["opencode"]["default_model"] == "gpt-5.4"assert config["agents"]["opencode"]["default_provider"] == "openai"@@ -225,7 +225,9 @@ def test_prepare_ignores_legacy_regression_layout(tmp_path: Path, monkeypatch: pjson.dumps({"runtime": {"default_cwd": "/data/vibe_remote/workdir"},- "agents": {"opencode": {"cli_path": "opencode"}},+ # Legacy root-global install baked by pre-#545 base images; must be+ # migrated to the user-owned path on a preserved-state update.+ "agents": {"opencode": {"cli_path": "/usr/local/bin/opencode"}},}),encoding="utf-8",@@ -262,7 +264,7 @@ def test_prepare_ignores_legacy_regression_layout(tmp_path: Path, monkeypatch: pconfig = json.loads((avibe_home / "config" / "config.json").read_text(encoding="utf-8"))settings = json.loads((avibe_home / "state" / "settings.json").read_text(encoding="utf-8"))assert config["runtime"]["default_cwd"] == "/home/avibe/.avibe/workdir"- assert config["agents"]["opencode"]["cli_path"] == "/usr/local/bin/opencode"+ assert config["agents"]["opencode"]["cli_path"] == "opencode"assert settings["scopes"]["channel"]["slack"]["C123SLACK"]["custom_cwd"] == "/home/avibe/.avibe/workdir"assert (tmp_path / "home" / ".claude.json").is_file()@@ -307,7 +309,9 @@ def test_prepare_repairs_stale_container_paths_inside_avibe_home(tmp_path: Path,json.dumps({"runtime": {"default_cwd": "/data/vibe_remote/workdir"},- "agents": {"opencode": {"cli_path": "opencode"}},+ # Legacy root-global install baked by pre-#545 base images; must be+ # migrated to the user-owned path on a preserved-state update.+ "agents": {"opencode": {"cli_path": "/usr/local/bin/opencode"}},}),encoding="utf-8",@@ -360,7 +364,7 @@ def test_prepare_repairs_stale_container_paths_inside_avibe_home(tmp_path: Path,sessions = json.loads((state_dir / "sessions.json").read_text(encoding="utf-8"))scheduled_tasks = json.loads((state_dir / "scheduled_tasks.json").read_text(encoding="utf-8"))assert config["runtime"]["default_cwd"] == "/home/avibe/.avibe/workdir"- assert config["agents"]["opencode"]["cli_path"] == "/usr/local/bin/opencode"+ assert config["agents"]["opencode"]["cli_path"] == "opencode"assert settings["scopes"]["channel"]["slack"]["C123"]["custom_cwd"] == "/home/avibe/.avibe/workdir"assert "slack_1774535203.606599:/home/avibe/.avibe/workdir" in sessions["thread_bindings"]assert "slack_1774535203.606599:/data/vibe_remote/workdir" not in sessions["thread_bindings"]