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): run three-regression from avibe home
cyh4c9ac08db86a
diff --git a/.env.three-regression.example b/.env.three-regression.exampleindex fc8eb133a..573363a77 100644--- a/.env.three-regression.example+++ b/.env.three-regression.example@@ -43,7 +43,7 @@ THREE_REGRESSION_OPENCODE_ANTHROPIC_API_KEY=THREE_REGRESSION_STATE_ROOT=THREE_REGRESSION_UI_HOST=127.0.0.1THREE_REGRESSION_PORT=15130-THREE_REGRESSION_DEFAULT_CWD=/data/vibe_remote/workdir+THREE_REGRESSION_DEFAULT_CWD=/home/avibe/.avibe/workdirTHREE_REGRESSION_DEFAULT_BACKEND=opencodeTHREE_REGRESSION_LOG_LEVEL=INFOTHREE_REGRESSION_LANGUAGE=endiff --git a/AGENTS.md b/AGENTS.mdindex 3d009ae46..20b5a307c 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -115,6 +115,7 @@ Rules:- the script stores persistent regression state under the primary checkout's `.runtime/three-regression/` by default, even when invoked from a task worktree- the script reads `.env.three-regression` from the current worktree first, then falls back to the primary checkout- override `THREE_REGRESSION_STATE_ROOT` only when intentionally creating an isolated regression state+- the regression container uses `/home/avibe` as a persistent real home; product state should live under `/home/avibe/.avibe`, with `/home/avibe/.vibe_remote` as the compatibility symlink after migration- the script must prepare and verify Show Runtime before reporting success; if Show Runtime cannot be installed or executed, treat the regression update as failed- for branch/master regression, `THREE_REGRESSION_SHOW_RUNTIME_SOURCE` defaults to `github-source` because source checkouts do not necessarily include a packaged release manifest; release/pre-release installs should use the packaged manifest path- the script serializes `up` and `down` operations with `.runtime/three-regression/.run.lock`; do not remove the lock unless the recorded PID is gone and the run is clearly stale@@ -124,7 +125,7 @@ Worktree behavior:- code is built from the worktree where the script is invoked- runtime state is shared from the primary checkout's `.runtime/three-regression/`- this keeps pairing (`remote_access` config), agent CLI homes, sessions, Show Page workspaces, and Show Runtime cache stable while still allowing any worktree to update the regression image-- if an older container was started with per-worktree `_tmp/three-regression/` state, the script imports `/data/vibe_remote` from the running container before recreating it+- if an older container was started with per-worktree `_tmp/three-regression/` state or the old `/data/vibe_remote` home, the script imports that state before recreating it## 4. Configuration and Routing Modeldiff --git a/docker-compose.three-regression.yml b/docker-compose.three-regression.ymlindex 87dfeb949..bc89a5aea 100644--- a/docker-compose.three-regression.yml+++ b/docker-compose.three-regression.yml@@ -7,7 +7,8 @@ services:target: integrationcommand: ["full"]environment:- VIBE_REMOTE_HOME: /data/vibe_remote+ HOME: /home/avibe+ VIBE_REMOTE_HOME: ""VIBE_DEPLOYMENT_ENV: regressionVIBE_INTERNAL_DISPATCH_SOCKET: /tmp/vibe_remote/dispatch.sockVIBE_UI_PORT: 5123@@ -31,9 +32,4 @@ services:ports:- "${THREE_REGRESSION_PORT_BIND_HOST:-127.0.0.1}:${THREE_REGRESSION_PORT:-15130}:5123"volumes:- - ${THREE_REGRESSION_STATE_ROOT:?set by scripts/run_three_regression.sh}/vibe:/data/vibe_remote- - ${THREE_REGRESSION_STATE_ROOT:?set by scripts/run_three_regression.sh}/shared-home/.claude:/root/.claude- - ${THREE_REGRESSION_STATE_ROOT:?set by scripts/run_three_regression.sh}/shared-home/.claude.json:/root/.claude.json- - ${THREE_REGRESSION_STATE_ROOT:?set by scripts/run_three_regression.sh}/shared-home/.codex:/root/.codex- - ${THREE_REGRESSION_STATE_ROOT:?set by scripts/run_three_regression.sh}/shared-home/.config/opencode:/root/.config/opencode- - ${THREE_REGRESSION_STATE_ROOT:?set by scripts/run_three_regression.sh}/shared-home/.local/share/opencode:/root/.local/share/opencode+ - ${THREE_REGRESSION_STATE_ROOT:?set by scripts/run_three_regression.sh}/home:/home/avibediff --git a/docs/regression/README.md b/docs/regression/README.mdindex 8ceada127..df0b730c6 100644--- a/docs/regression/README.md+++ b/docs/regression/README.md@@ -97,7 +97,7 @@ Unified regression environment is ready:If you set `THREE_REGRESSION_UI_HOST=192.168.2.3`, the printed URL and generated UI config will use that host instead.-On first startup, or when you run with `--reset-config` / `--reset-all`, the runner seeds these files under `.runtime/three-regression/vibe/` in the primary checkout:+On first startup, or when you run with `--reset-config` / `--reset-all`, the runner seeds these files under `.runtime/three-regression/home/.avibe/` in the primary checkout:- `config/config.json`- `state/settings.json`@@ -105,11 +105,19 @@ On first startup, or when you run with `--reset-config` / `--reset-all`, the runThe generated state lives under `.runtime/three-regression/`, which keeps the regression environment isolated while preserving your later modifications by default. Task worktrees share this primary-checkout state root unless `THREE_REGRESSION_STATE_ROOT` is explicitly set for an isolated run.+The container uses a real persistent home directory mounted at `/home/avibe`.+That means Avibe's default-home behavior is exercised in regression:+`/home/avibe/.avibe` is the active runtime home, and a legacy+`/home/avibe/.vibe_remote` path is left as the product-managed compatibility+symlink after migration. Older regression state under `.runtime/three-regression/vibe/`+is imported as `home/.vibe_remote/` so the first 3.0 startup covers the same+home migration path old users hit.+Persistence rules:-- `./scripts/run_three_regression.sh` preserves UI changes, sessions, and files under `workdir/`+- `./scripts/run_three_regression.sh` preserves UI changes, sessions, and files under `home/.avibe/workdir/`- `--reset-config` preserves `workdir/` files but resets service config/state-- `--reset-all` clears everything under the state directory+- `--reset-all` clears everything under the regression home## Architecture@@ -118,8 +126,8 @@ The unified container leverages the multi-platform IM support to run all four pl- **Config**: A single `config.json` with `platforms.enabled: ["slack", "discord", "lark", "wechat"]` and all four platform credential blocks populated.- **Routing**: Per-channel backend routing via `settings.json` scoped by platform, so each platform's test channel resolves to its designated backend.- **Agents**: All three backend agents (OpenCode, Claude, Codex) are enabled and installed in the container image.-- **State**: A single `.runtime/three-regression/vibe/` directory holds config, state, logs, and the agent workdir.-- **Shared agent home configs**: Generated under `.runtime/three-regression/shared-home/` and mounted read-only into the container.+- **State**: A single `.runtime/three-regression/home/.avibe/` directory holds config, state, logs, and the agent workdir.+- **Agent home configs**: Generated under `.runtime/three-regression/home/` and mounted as the container's real `$HOME`.## Configuration Rules@@ -127,8 +135,8 @@ The unified container leverages the multi-platform IM support to run all four pl- The `platforms.primary` is set to `slack` by default (controls fallback behavior).- `THREE_REGRESSION_DEFAULT_BACKEND` sets the global default backend (default: `opencode`).- Per-platform backend vars (`THREE_REGRESSION_SLACK_BACKEND`, etc.) control per-channel routing in `settings.json`.-- All three agent CLIs receive shared credentials via `.runtime/three-regression/shared-home/`.-- The default working directory is `/data/vibe_remote/workdir`, a writable sandbox under the generated state.+- All three agent CLIs receive shared credentials via `.runtime/three-regression/home/`.+- The default working directory is `/home/avibe/.avibe/workdir`, a writable sandbox under the generated state.## Secret Safetydiff --git a/scripts/prepare_three_regression.py b/scripts/prepare_three_regression.pyindex 6632569e2..45b98182e 100755--- a/scripts/prepare_three_regression.py+++ b/scripts/prepare_three_regression.py@@ -11,6 +11,7 @@ import argparseimport jsonimport osimport shutil+import sqlite3import sysfrom pathlib import Path@@ -50,6 +51,15 @@ PLATFORM_DEFS = {SUPPORTED_BACKENDS = {"opencode", "claude", "codex"}RESET_MODES = {"none", "config", "all"}+CONTAINER_HOME = Path("/home/avibe")+CONTAINER_AVIBE_HOME = CONTAINER_HOME / ".avibe"+CONTAINER_LEGACY_HOME = CONTAINER_HOME / ".vibe_remote"+LEGACY_CONTAINER_HOME = Path("/root")+LEGACY_CONTAINER_VIBE_HOME = Path("/data/vibe_remote")+LEGACY_CONTAINER_AVIBE_HOME = LEGACY_CONTAINER_HOME / ".avibe"+LEGACY_CONTAINER_VIBE_REMOTE_HOME = LEGACY_CONTAINER_HOME / ".vibe_remote"+DEFAULT_CWD = str(CONTAINER_AVIBE_HOME / "workdir")+CONTAINER_OPENCODE_CLI = "/usr/local/bin/opencode"def _env(key: str, default: str = "") -> str:@@ -106,7 +116,7 @@ def _build_routing(name: str) -> dict:def _default_cwd() -> str:- return _env("THREE_REGRESSION_DEFAULT_CWD", "/data/vibe_remote/workdir")+ return _normalize_container_path(_env("THREE_REGRESSION_DEFAULT_CWD", DEFAULT_CWD))def _ui_host() -> str:@@ -189,7 +199,7 @@ def _build_config_payload() -> dict:"default_backend": _default_backend(),"opencode": {"enabled": True,- "cli_path": "opencode",+ "cli_path": CONTAINER_OPENCODE_CLI,"default_agent": _optional("THREE_REGRESSION_OPENCODE_AGENT"),"default_model": _optional("THREE_REGRESSION_OPENCODE_MODEL"),"default_reasoning_effort": _optional("THREE_REGRESSION_OPENCODE_REASONING_EFFORT"),@@ -297,13 +307,228 @@ def _ensure_file_path(path: Path, default_content: str) -> None:_write_text(path, default_content)-def _ensure_shared_home(output_root: Path, reset_mode: str = "none") -> Path:+def _home_root(output_root: Path) -> Path:+ return output_root / "home"+++def _avibe_home(output_root: Path) -> Path:+ return _home_root(output_root) / ".avibe"+++def _legacy_vibe_remote_home(output_root: Path) -> Path:+ return _home_root(output_root) / ".vibe_remote"+++def _active_vibe_dir(output_root: Path) -> Path:+ avibe_home = _avibe_home(output_root)+ legacy_home = _legacy_vibe_remote_home(output_root)+ if avibe_home.exists() or avibe_home.is_symlink():+ return avibe_home+ if legacy_home.exists() or legacy_home.is_symlink():+ return legacy_home+ return avibe_home+++def _has_vibe_home_state(path: Path) -> bool:+ if not path.exists() and not path.is_symlink():+ return False+ if path.is_symlink():+ return True+ if any(+ marker.exists()+ for marker in (+ path / "config" / "config.json",+ path / "state" / "settings.json",+ path / "state" / "sessions.json",+ path / "state" / "vibe.sqlite",+ )+ ):+ return True+ workdir = path / "workdir"+ if workdir.exists() and workdir.is_dir():+ return any(workdir.iterdir())+ return False+++def _agent_home(output_root: Path) -> Path:+ return _home_root(output_root)+++def _legacy_shared_home(output_root: Path) -> Path:+ return output_root / "shared-home"+++def _legacy_vibe_dir(output_root: Path) -> Path:+ return output_root / "vibe"+++def _normalize_container_path(value: str | None) -> str:+ if not value:+ return value or ""+ replacements = (+ (str(LEGACY_CONTAINER_VIBE_HOME), str(CONTAINER_AVIBE_HOME)),+ (str(LEGACY_CONTAINER_AVIBE_HOME), str(CONTAINER_AVIBE_HOME)),+ (str(LEGACY_CONTAINER_VIBE_REMOTE_HOME), str(CONTAINER_LEGACY_HOME)),+ (str(LEGACY_CONTAINER_HOME), str(CONTAINER_HOME)),+ )+ normalized = value+ for old, new in replacements:+ if normalized == old:+ return new+ if normalized.startswith(old + "/"):+ return new + normalized[len(old):]+ return normalized+++def _rewrite_json_paths(value):+ if isinstance(value, dict):+ return {key: _rewrite_json_paths(item) for key, item in value.items()}+ if isinstance(value, list):+ return [_rewrite_json_paths(item) for item in value]+ if isinstance(value, str):+ return _normalize_container_path(value)+ return value+++def _rewrite_json_file_paths(path: Path) -> None:+ if not path.exists() or not path.is_file():+ return+ try:+ payload = json.loads(path.read_text(encoding="utf-8"))+ except json.JSONDecodeError:+ return+ _write_json(path, _rewrite_json_paths(payload))+++def _rewrite_sqlite_paths(db_path: Path) -> None:+ if not db_path.exists() or not db_path.is_file():+ return+ with sqlite3.connect(str(db_path)) as conn:+ table_columns = {+ "agent_sessions": ("workdir",),+ "scope_settings": ("workdir", "settings_json"),+ "runtime_records": ("workdir", "payload_json"),+ "run_definitions": ("cwd", "command_json", "metadata_json"),+ "agent_runs": ("message_payload_json", "result_payload_json", "metadata_json"),+ "media_objects": ("local_path",),+ }+ for table, columns in table_columns.items():+ existing = {+ row[1]+ for row in conn.execute(f'pragma table_info("{table}")').fetchall()+ }+ for column in columns:+ if column not in existing:+ continue+ rows = conn.execute(+ f'select rowid, "{column}" from "{table}" where "{column}" is not null'+ ).fetchall()+ for rowid, value in rows:+ if not isinstance(value, str):+ continue+ next_value = _normalize_container_path(value)+ if column.endswith("_json"):+ try:+ next_value = json.dumps(+ _rewrite_json_paths(json.loads(value)),+ separators=(",", ":"),+ )+ except json.JSONDecodeError:+ next_value = _normalize_container_path(value)+ if next_value != value:+ conn.execute(+ f'update "{table}" set "{column}" = ? where rowid = ?',+ (next_value, rowid),+ )+ conn.commit()+++def _move_path(src: Path, dst: Path) -> None:+ if not src.exists() and not src.is_symlink():+ return+ if dst.exists() or dst.is_symlink():+ return+ dst.parent.mkdir(parents=True, exist_ok=True)+ shutil.move(str(src), str(dst))+++def _remove_empty_dirs(root: Path) -> None:+ if not root.exists() or not root.is_dir():+ return+ for current, dirs, _files in os.walk(root, topdown=False):+ for dirname in dirs:+ target = Path(current) / dirname+ try:+ target.rmdir()+ except OSError:+ pass+ try:+ root.rmdir()+ except OSError:+ pass+++def _migrate_legacy_layout(output_root: Path, *, reset_mode: str) -> None:+ home_root = _home_root(output_root)+ if reset_mode == "all" and home_root.exists():+ shutil.rmtree(home_root)if reset_mode == "all":- shared_root = output_root / "shared-home"- if shared_root.exists():- shutil.rmtree(shared_root)+ for stale in (_legacy_vibe_dir(output_root), _legacy_shared_home(output_root)):+ if stale.exists() or stale.is_symlink():+ if stale.is_dir() and not stale.is_symlink():+ shutil.rmtree(stale)+ else:+ stale.unlink()+ home_root.mkdir(parents=True, exist_ok=True)++ legacy_vibe = _legacy_vibe_dir(output_root)+ legacy_shared = _legacy_shared_home(output_root)+ avibe_home = _avibe_home(output_root)+ legacy_home = _legacy_vibe_remote_home(output_root)++ if legacy_vibe.exists() and not legacy_home.exists() and not _has_vibe_home_state(avibe_home):+ _remove_empty_dirs(avibe_home)++ if legacy_vibe.exists() and not avibe_home.exists() and not legacy_home.exists():+ # Seed the old default home so first 3.0 startup exercises the product+ # migration from ~/.vibe_remote to ~/.avibe.+ _move_path(legacy_vibe, legacy_home)+ elif legacy_vibe.exists() and (avibe_home.exists() or legacy_home.exists()):+ # A prior mixed layout can happen during local harness development. Keep+ # existing real-home state authoritative and leave the old directory+ # untouched rather than merging possibly stale data.+ pass++ if legacy_shared.exists():+ for relative in (+ ".claude",+ ".claude.json",+ ".codex",+ ".config/opencode",+ ".local/share/opencode",+ ):+ _move_path(legacy_shared / relative, home_root / relative)+ _remove_empty_dirs(legacy_shared)+- shared_root = output_root / "shared-home"+def _ensure_shared_home(output_root: Path, reset_mode: str = "none") -> Path:+ if reset_mode == "all":+ home_root = _home_root(output_root)+ for relative in (+ ".claude",+ ".claude.json",+ ".codex",+ ".config/opencode",+ ".local/share/opencode",+ ):+ target = home_root / relative+ if target.exists() or target.is_symlink():+ if target.is_dir() and not target.is_symlink():+ shutil.rmtree(target)+ else:+ target.unlink()++ shared_root = _agent_home(output_root)for subdir in (".claude",".codex",@@ -445,7 +670,7 @@ def _build_opencode_payload() -> dict:def _shared_agent_config_paths(output_root: Path) -> tuple[Path, ...]:- shared_root = output_root / "shared-home"+ shared_root = _agent_home(output_root)return (shared_root / ".claude" / "settings.json",shared_root / ".claude.json",@@ -476,9 +701,44 @@ def _write_shared_agent_configs(output_root: Path, *, reset_mode: str) -> None:_write_json(shared_root / ".config" / "opencode" / "opencode.json", _build_opencode_payload())+def _normalize_config_payload(path: Path) -> None:+ if not path.is_file():+ return+ try:+ payload = json.loads(path.read_text(encoding="utf-8"))+ except (OSError, json.JSONDecodeError):+ return+ if not isinstance(payload, dict):+ return++ agents = payload.get("agents")+ if not isinstance(agents, dict):+ return+ opencode = agents.get("opencode")+ if not isinstance(opencode, dict):+ return+ cli_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}:+ return++ opencode["cli_path"] = CONTAINER_OPENCODE_CLI+ _write_json(path, payload)+++def _normalize_existing_state(vibe_dir: Path) -> None:+ config_path = vibe_dir / "config" / "config.json"+ _rewrite_json_file_paths(config_path)+ _normalize_config_payload(config_path)+ _rewrite_json_file_paths(vibe_dir / "state" / "settings.json")+ _rewrite_json_file_paths(vibe_dir / "state" / "sessions.json")+ _rewrite_sqlite_paths(vibe_dir / "state" / "vibe.sqlite")++def prepare(output_root: Path, reset_mode: str = "none") -> None:_validate_reset_mode(reset_mode)- vibe_dir = output_root / "vibe"+ _migrate_legacy_layout(output_root, reset_mode=reset_mode)+ vibe_dir = _active_vibe_dir(output_root)config_path = vibe_dir / "config" / "config.json"settings_path = vibe_dir / "state" / "settings.json"sessions_path = vibe_dir / "state" / "sessions.json"@@ -506,6 +766,8 @@ def prepare(output_root: Path, reset_mode: str = "none") -> None:_write_json(settings_path, _build_settings_payload())if needs_sessions:_write_json(sessions_path, {})+ if not needs_config or not needs_settings:+ _normalize_existing_state(vibe_dir)summary_lines: list[str] = []for name, pdef in PLATFORM_DEFS.items():@@ -513,7 +775,7 @@ def prepare(output_root: Path, reset_mode: str = "none") -> None:backend = _env(pdef["backend_env"]) or _default_backend()summary_lines.append(f" {name}: platform={pdef['platform']} channel={channel} backend={backend}")- print(f"Prepared unified regression state under {output_root / 'vibe'}")+ print(f"Prepared unified regression state under {vibe_dir}")print("Platform routing:")print("\n".join(summary_lines))print(f"State: {reset_mode if reset_mode != 'none' else 'preserved'}")diff --git a/scripts/run_three_regression.sh b/scripts/run_three_regression.shindex d1215ee8c..eb55acb44 100755--- a/scripts/run_three_regression.sh+++ b/scripts/run_three_regression.sh@@ -8,6 +8,11 @@ COMPOSE_FILE="$REPO_ROOT/docker-compose.three-regression.yml"PROJECT_NAME="vibe-three-regression"PYTHON_BIN="${PYTHON_BIN:-python3}"DOCKER_BIN="${DOCKER_BIN:-}"+CONTAINER_HOME="/home/avibe"+CONTAINER_AVIBE_HOME="$CONTAINER_HOME/.avibe"+CONTAINER_LEGACY_HOME="$CONTAINER_HOME/.vibe_remote"+LEGACY_CONTAINER_HOME="/root"+LEGACY_CONTAINER_VIBE_HOME="/data/vibe_remote"resolve_git_common_repo_root() {local common_dir@@ -229,7 +234,13 @@ print_summary() {local bind_host="${THREE_REGRESSION_PORT_BIND_HOST:-127.0.0.1}"local ui_host="${THREE_REGRESSION_ACCESS_HOST:-${THREE_REGRESSION_UI_HOST:-$bind_host}}"local default_backend="${THREE_REGRESSION_DEFAULT_BACKEND:-opencode}"- local config_path="$OUTPUT_ROOT/vibe/config/config.json"+ local config_path="$OUTPUT_ROOT/home/.avibe/config/config.json"+ if [ ! -f "$config_path" ]; then+ config_path="$OUTPUT_ROOT/home/.vibe_remote/config/config.json"+ fi+ if [ ! -f "$config_path" ]; then+ config_path="$OUTPUT_ROOT/vibe/config/config.json"+ filocal display_rootdisplay_root="$OUTPUT_ROOT"case "$display_root" in@@ -307,15 +318,20 @@ snapshot_agent_runtime_state() {return 0fi- local shared_root="$OUTPUT_ROOT/shared-home"- mkdir -p "$shared_root"+ local home_root="$OUTPUT_ROOT/home"+ mkdir -p "$home_root"echo "Snapshotting agent runtime state from existing regression container..."- snapshot_container_path "/root/.claude" "$shared_root" ".claude"- snapshot_container_path "/root/.claude.json" "$shared_root" ".claude.json"- snapshot_container_path "/root/.codex" "$shared_root" ".codex"- snapshot_container_path "/root/.config/opencode" "$shared_root/.config" "opencode"- snapshot_container_path "/root/.local/share/opencode" "$shared_root/.local/share" "opencode"+ snapshot_container_path "$CONTAINER_HOME/.claude" "$home_root" ".claude"+ snapshot_container_path "$CONTAINER_HOME/.claude.json" "$home_root" ".claude.json"+ snapshot_container_path "$CONTAINER_HOME/.codex" "$home_root" ".codex"+ snapshot_container_path "$CONTAINER_HOME/.config/opencode" "$home_root/.config" "opencode"+ snapshot_container_path "$CONTAINER_HOME/.local/share/opencode" "$home_root/.local/share" "opencode"+ snapshot_container_path "$LEGACY_CONTAINER_HOME/.claude" "$home_root" ".claude"+ snapshot_container_path "$LEGACY_CONTAINER_HOME/.claude.json" "$home_root" ".claude.json"+ snapshot_container_path "$LEGACY_CONTAINER_HOME/.codex" "$home_root" ".codex"+ snapshot_container_path "$LEGACY_CONTAINER_HOME/.config/opencode" "$home_root/.config" "opencode"+ snapshot_container_path "$LEGACY_CONTAINER_HOME/.local/share/opencode" "$home_root/.local/share" "opencode"}snapshot_vibe_remote_state() {@@ -333,14 +349,21 @@ snapshot_vibe_remote_state() {return 0fi- local target="$OUTPUT_ROOT/vibe"- if [ -f "$target/config/config.json" ]; then+ local avibe_target="$OUTPUT_ROOT/home/.avibe"+ local legacy_target="$OUTPUT_ROOT/home/.vibe_remote"+ local old_layout_target="$OUTPUT_ROOT/vibe"+ if [ -f "$avibe_target/config/config.json" ] || [ -f "$legacy_target/config/config.json" ] || [ -f "$old_layout_target/config/config.json" ]; thenreturn 0fi- mkdir -p "$target"+ mkdir -p "$OUTPUT_ROOT/home"echo "Importing Vibe Remote state from the existing regression container..."- "$DOCKER_BIN" cp "$cid:/data/vibe_remote/." "$target" >/dev/null 2>&1 || true+ if "$DOCKER_BIN" cp "$cid:$CONTAINER_AVIBE_HOME/." "$avibe_target" >/dev/null 2>&1; then+ return 0+ fi+ mkdir -p "$legacy_target"+ "$DOCKER_BIN" cp "$cid:$CONTAINER_LEGACY_HOME/." "$legacy_target" >/dev/null 2>&1 || \+ "$DOCKER_BIN" cp "$cid:$LEGACY_CONTAINER_VIBE_HOME/." "$legacy_target" >/dev/null 2>&1 || true}write_regression_metadata() {diff --git a/tests/test_prepare_three_regression.py b/tests/test_prepare_three_regression.pyindex a80ed27ad..25080c896 100644--- a/tests/test_prepare_three_regression.py+++ b/tests/test_prepare_three_regression.py@@ -2,6 +2,7 @@ from __future__ import annotationsimport importlib.utilimport json+import sqlite3from pathlib import Pathimport pytest@@ -64,8 +65,8 @@ def test_prepare_generates_unified_state(tmp_path: Path, monkeypatch: pytest.Monmodule.prepare(tmp_path)- config = json.loads((tmp_path / "vibe" / "config" / "config.json").read_text(encoding="utf-8"))- settings = json.loads((tmp_path / "vibe" / "state" / "settings.json").read_text(encoding="utf-8"))+ config = json.loads((tmp_path / "home" / ".avibe" / "config" / "config.json").read_text(encoding="utf-8"))+ settings = json.loads((tmp_path / "home" / ".avibe" / "state" / "settings.json").read_text(encoding="utf-8"))# Unified config has all four platforms enabledassert config["platforms"]["enabled"] == ["slack", "discord", "lark", "wechat"]@@ -83,12 +84,15 @@ 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"# UI host propagatedassert config["ui"]["setup_host"] == "192.168.2.3"+ assert config["runtime"]["default_cwd"] == "/home/avibe/.avibe/workdir"# Per-channel routing in settings for each platformassert settings["scopes"]["channel"]["slack"]["C123SLACK"]["routing"]["agent_backend"] == "opencode"+ assert settings["scopes"]["channel"]["slack"]["C123SLACK"]["custom_cwd"] == "/home/avibe/.avibe/workdir"assert settings["scopes"]["channel"]["discord"]["123456789012345678"]["routing"]["agent_backend"] == "codex"assert settings["schema_version"] == 5assert settings["scopes"]["guild"]["discord"]["754776951587340359"]["enabled"] is True@@ -99,22 +103,22 @@ def test_prepare_generates_unified_state(tmp_path: Path, monkeypatch: pytest.Monassert settings["scopes"]["channel"]["wechat"] == {}# Directory structure- assert (tmp_path / "vibe" / "workdir").is_dir()- assert (tmp_path / "vibe" / "state" / "sessions.json").exists()+ assert (tmp_path / "home" / ".avibe" / "workdir").is_dir()+ assert (tmp_path / "home" / ".avibe" / "state" / "sessions.json").exists()# Shared agent home configsassert (- json.loads((tmp_path / "shared-home" / ".claude" / "settings.json").read_text(encoding="utf-8"))["env"][+ json.loads((tmp_path / "home" / ".claude" / "settings.json").read_text(encoding="utf-8"))["env"]["ANTHROPIC_AUTH_TOKEN"]== "sk-claude-auth-token")- codex_config = (tmp_path / "shared-home" / ".codex" / "config.toml").read_text(encoding="utf-8")+ codex_config = (tmp_path / "home" / ".codex" / "config.toml").read_text(encoding="utf-8")assert 'model = "gpt-5.4"' in codex_configassert "responses_websockets_v2 = false" in codex_configassert "suppress_unstable_features_warning = true" in codex_configopencode_config = json.loads(- (tmp_path / "shared-home" / ".config" / "opencode" / "opencode.json").read_text(encoding="utf-8")+ (tmp_path / "home" / ".config" / "opencode" / "opencode.json").read_text(encoding="utf-8"))assert opencode_config["permission"] == "allow"assert opencode_config["provider"]["openai"]["options"]["baseURL"] == "https://ai-relay.example/v1"@@ -124,13 +128,13 @@ def test_prepare_preserves_existing_state_without_reset(tmp_path: Path, monkeypamodule = _load_module()_set_required_env(monkeypatch)- vibe_dir = tmp_path / "vibe"+ vibe_dir = tmp_path / "home" / ".avibe"(vibe_dir / "config").mkdir(parents=True)(vibe_dir / "state").mkdir(parents=True)(vibe_dir / "config" / "config.json").write_text('{"keep": true}', encoding="utf-8")(vibe_dir / "state" / "settings.json").write_text('{"custom": true}', encoding="utf-8")(vibe_dir / "state" / "sessions.json").write_text('{"session": true}', encoding="utf-8")- shared_home = tmp_path / "shared-home"+ shared_home = tmp_path / "home"(shared_home / ".claude").mkdir(parents=True)(shared_home / ".codex").mkdir(parents=True)(shared_home / ".config" / "opencode").mkdir(parents=True)@@ -167,13 +171,173 @@ def test_prepare_preserves_existing_state_without_reset(tmp_path: Path, monkeypa}+def test_prepare_migrates_legacy_state_layout_to_default_home(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):+ module = _load_module()+ _set_required_env(monkeypatch)++ old_vibe = tmp_path / "vibe"+ old_shared = tmp_path / "shared-home"+ (old_vibe / "config").mkdir(parents=True)+ (old_vibe / "state").mkdir(parents=True)+ (old_vibe / "workdir").mkdir(parents=True)+ (old_vibe / "config" / "config.json").write_text(+ json.dumps(+ {+ "runtime": {"default_cwd": "/data/vibe_remote/workdir"},+ "agents": {"opencode": {"cli_path": "opencode"}},+ }+ ),+ encoding="utf-8",+ )+ (old_vibe / "state" / "settings.json").write_text(+ json.dumps(+ {+ "scopes": {+ "channel": {+ "slack": {+ "C123": {+ "custom_cwd": "/data/vibe_remote/workdir",+ }+ }+ }+ }+ }+ ),+ encoding="utf-8",+ )+ (old_vibe / "state" / "sessions.json").write_text("{}", encoding="utf-8")+ (old_vibe / "workdir" / "keep.txt").write_text("keep-me", encoding="utf-8")+ (old_shared / ".claude").mkdir(parents=True)+ (old_shared / ".claude" / "settings.json").write_text("{}", encoding="utf-8")+ (old_shared / ".claude.json").write_text("{}", encoding="utf-8")+ (old_shared / ".codex").mkdir(parents=True)+ (old_shared / ".codex" / "config.toml").write_text("", encoding="utf-8")+ (old_shared / ".codex" / "auth.json").write_text("{}", encoding="utf-8")+ (old_shared / ".config" / "opencode").mkdir(parents=True)+ (old_shared / ".config" / "opencode" / "opencode.json").write_text("{}", encoding="utf-8")++ module.prepare(tmp_path)++ legacy_home = tmp_path / "home" / ".vibe_remote"+ assert not old_vibe.exists()+ assert not old_shared.exists()+ assert legacy_home.is_dir()+ assert not (tmp_path / "home" / ".avibe").exists()+ assert (legacy_home / "workdir" / "keep.txt").read_text(encoding="utf-8") == "keep-me"+ config = json.loads((legacy_home / "config" / "config.json").read_text(encoding="utf-8"))+ settings = json.loads((legacy_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 settings["scopes"]["channel"]["slack"]["C123"]["custom_cwd"] == "/home/avibe/.avibe/workdir"+ assert (tmp_path / "home" / ".claude.json").is_file()+++def test_prepare_migrates_legacy_layout_when_new_home_is_empty(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):+ module = _load_module()+ _set_required_env(monkeypatch)++ old_vibe = tmp_path / "vibe"+ (old_vibe / "config").mkdir(parents=True)+ (old_vibe / "state").mkdir(parents=True)+ (old_vibe / "workdir").mkdir(parents=True)+ (old_vibe / "config" / "config.json").write_text(+ json.dumps(+ {+ "runtime": {"default_cwd": "/data/vibe_remote/workdir"},+ "agents": {"opencode": {"cli_path": "opencode"}},+ }+ ),+ encoding="utf-8",+ )+ (old_vibe / "state" / "settings.json").write_text("{}", encoding="utf-8")+ (old_vibe / "state" / "sessions.json").write_text("{}", encoding="utf-8")+ (old_vibe / "workdir" / "keep.txt").write_text("keep-me", encoding="utf-8")+ (tmp_path / "home" / ".avibe").mkdir(parents=True)++ module.prepare(tmp_path)++ legacy_home = tmp_path / "home" / ".vibe_remote"+ assert not old_vibe.exists()+ assert legacy_home.is_dir()+ assert not (tmp_path / "home" / ".avibe").exists()+ assert (legacy_home / "workdir" / "keep.txt").read_text(encoding="utf-8") == "keep-me"+++def test_prepare_keeps_new_home_authoritative_when_it_has_state(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch+):+ module = _load_module()+ _set_required_env(monkeypatch)++ old_vibe = tmp_path / "vibe"+ (old_vibe / "config").mkdir(parents=True)+ (old_vibe / "state").mkdir(parents=True)+ (old_vibe / "workdir").mkdir(parents=True)+ (old_vibe / "config" / "config.json").write_text('{"old": true}', encoding="utf-8")+ (old_vibe / "state" / "settings.json").write_text("{}", encoding="utf-8")+ (old_vibe / "state" / "sessions.json").write_text("{}", encoding="utf-8")+ (old_vibe / "workdir" / "old.txt").write_text("old", encoding="utf-8")+ avibe_home = tmp_path / "home" / ".avibe"+ (avibe_home / "config").mkdir(parents=True)+ (avibe_home / "state").mkdir(parents=True)+ (avibe_home / "config" / "config.json").write_text('{"new": true}', encoding="utf-8")+ (avibe_home / "state" / "settings.json").write_text("{}", encoding="utf-8")+ (avibe_home / "state" / "sessions.json").write_text("{}", encoding="utf-8")++ module.prepare(tmp_path)++ assert old_vibe.exists()+ assert not (tmp_path / "home" / ".vibe_remote").exists()+ assert json.loads((avibe_home / "config" / "config.json").read_text(encoding="utf-8")) == {"new": True}+++def test_prepare_rewrites_legacy_sqlite_workdirs(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):+ module = _load_module()+ _set_required_env(monkeypatch)++ vibe_dir = tmp_path / "home" / ".avibe"+ state_dir = vibe_dir / "state"+ (vibe_dir / "config").mkdir(parents=True)+ state_dir.mkdir(parents=True)+ (vibe_dir / "config" / "config.json").write_text("{}", encoding="utf-8")+ (state_dir / "settings.json").write_text("{}", encoding="utf-8")+ (state_dir / "sessions.json").write_text("{}", encoding="utf-8")+ db_path = state_dir / "vibe.sqlite"+ with sqlite3.connect(db_path) as conn:+ conn.execute("create table agent_sessions (id text primary key, workdir text)")+ conn.execute("create table scope_settings (scope_id text primary key, workdir text, settings_json text)")+ conn.execute(+ "insert into agent_sessions (id, workdir) values (?, ?)",+ ("ses-old", "/data/vibe_remote/workdir"),+ )+ conn.execute(+ "insert into scope_settings (scope_id, workdir, settings_json) values (?, ?, ?)",+ (+ "scope-old",+ "/data/vibe_remote/workdir",+ json.dumps({"custom_cwd": "/data/vibe_remote/workdir"}),+ ),+ )++ module.prepare(tmp_path)++ with sqlite3.connect(db_path) as conn:+ session_workdir = conn.execute("select workdir from agent_sessions where id = 'ses-old'").fetchone()[0]+ scope_workdir, settings_json = conn.execute(+ "select workdir, settings_json from scope_settings where scope_id = 'scope-old'"+ ).fetchone()+ assert session_workdir == "/home/avibe/.avibe/workdir"+ assert scope_workdir == "/home/avibe/.avibe/workdir"+ assert json.loads(settings_json)["custom_cwd"] == "/home/avibe/.avibe/workdir"++def test_prepare_without_reset_still_requires_llm_keys_when_shared_configs_missing(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):module = _load_module()_set_required_env(monkeypatch)- vibe_dir = tmp_path / "vibe"+ vibe_dir = tmp_path / "home" / ".avibe"(vibe_dir / "config").mkdir(parents=True)(vibe_dir / "state").mkdir(parents=True)(vibe_dir / "config" / "config.json").write_text('{"keep": true}', encoding="utf-8")@@ -193,10 +357,10 @@ def test_prepare_without_reset_still_requires_platform_envs_when_config_missing(module = _load_module()_set_required_env(monkeypatch)- vibe_dir = tmp_path / "vibe"+ vibe_dir = tmp_path / "home" / ".avibe"(vibe_dir / "state").mkdir(parents=True)(vibe_dir / "state" / "sessions.json").write_text('{"session": true}', encoding="utf-8")- shared_home = tmp_path / "shared-home"+ shared_home = tmp_path / "home"(shared_home / ".claude").mkdir(parents=True)(shared_home / ".codex").mkdir(parents=True)(shared_home / ".config" / "opencode").mkdir(parents=True)@@ -223,7 +387,7 @@ def test_prepare_allows_missing_channel_ids(tmp_path: Path, monkeypatch: pytest.module.prepare(tmp_path, reset_mode="config")- settings = json.loads((tmp_path / "vibe" / "state" / "settings.json").read_text(encoding="utf-8"))+ settings = json.loads((tmp_path / "home" / ".avibe" / "state" / "settings.json").read_text(encoding="utf-8"))assert settings["scopes"]["channel"]["slack"] == {}assert settings["scopes"]["channel"]["discord"] == {}assert settings["scopes"]["channel"]["lark"] == {}@@ -238,7 +402,7 @@ def test_prepare_preserves_discord_denylist_only_guild_policy(tmp_path: Path, momodule.prepare(tmp_path, reset_mode="config")- settings = json.loads((tmp_path / "vibe" / "state" / "settings.json").read_text(encoding="utf-8"))+ settings = json.loads((tmp_path / "home" / ".avibe" / "state" / "settings.json").read_text(encoding="utf-8"))assert settings["scopes"]["guild"]["discord"]["blocked-guild"]["enabled"] is Falseassert settings["scopes"]["guild_policy"]["discord"]["default_enabled"] is True@@ -256,10 +420,10 @@ def test_prepare_reset_config_preserves_workdir(tmp_path: Path, monkeypatch: pytmodule = _load_module()_set_required_env(monkeypatch)- workdir = tmp_path / "vibe" / "workdir"+ workdir = tmp_path / "home" / ".avibe" / "workdir"workdir.mkdir(parents=True)(workdir / "keep.txt").write_text("keep-me", encoding="utf-8")- config_dir = tmp_path / "vibe" / "config"+ config_dir = tmp_path / "home" / ".avibe" / "config"config_dir.mkdir(parents=True)(config_dir / "config.json").write_text('{"stale": true}', encoding="utf-8")@@ -274,7 +438,7 @@ def test_prepare_reset_config_rewrites_shared_agent_configs(tmp_path: Path, monkmodule = _load_module()_set_required_env(monkeypatch)- shared_home = tmp_path / "shared-home"+ shared_home = tmp_path / "home"(shared_home / ".claude").mkdir(parents=True)(shared_home / ".codex").mkdir(parents=True)(shared_home / ".config" / "opencode").mkdir(parents=True)@@ -326,7 +490,7 @@ def test_prepare_replaces_docker_created_claude_json_directory(tmp_path: Path, mmodule = _load_module()_set_required_env(monkeypatch)- shared_home = tmp_path / "shared-home"+ shared_home = tmp_path / "home"(shared_home / ".claude").mkdir(parents=True)(shared_home / ".codex").mkdir(parents=True)(shared_home / ".config" / "opencode").mkdir(parents=True)@@ -347,7 +511,7 @@ def test_prepare_reset_all_clears_workdir(tmp_path: Path, monkeypatch: pytest.Momodule = _load_module()_set_required_env(monkeypatch)- workdir = tmp_path / "vibe" / "workdir"+ workdir = tmp_path / "home" / ".avibe" / "workdir"workdir.mkdir(parents=True)(workdir / "drop.txt").write_text("remove-me", encoding="utf-8")@@ -363,7 +527,7 @@ def test_prepare_default_backend_from_env(tmp_path: Path, monkeypatch: pytest.Momodule.prepare(tmp_path, reset_mode="config")- config = json.loads((tmp_path / "vibe" / "config" / "config.json").read_text(encoding="utf-8"))+ config = json.loads((tmp_path / "home" / ".avibe" / "config" / "config.json").read_text(encoding="utf-8"))assert config["agents"]["default_backend"] == "claude"@@ -375,6 +539,6 @@ def test_prepare_all_platform_channel_routing(tmp_path: Path, monkeypatch: pytesmodule.prepare(tmp_path, reset_mode="config")- settings = json.loads((tmp_path / "vibe" / "state" / "settings.json").read_text(encoding="utf-8"))+ settings = json.loads((tmp_path / "home" / ".avibe" / "state" / "settings.json").read_text(encoding="utf-8"))assert settings["scopes"]["channel"]["wechat"]["wx_test_room"]["routing"]["agent_backend"] == "codex"assert settings["scopes"]["channel"]["slack"]["C123SLACK"]["routing"]["agent_backend"] == "opencode"