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(cli): gate bare vibe restart compatibility
cyh6e101b5d334f
diff --git a/tests/test_vibe_cli.py b/tests/test_vibe_cli.pyindex 51b5dc657..d7eea52de 100644--- a/tests/test_vibe_cli.py+++ b/tests/test_vibe_cli.py@@ -176,9 +176,33 @@ def test_cmd_restart_runs_synchronously_by_default(monkeypatch):assert calls == ["stop", ("sleep", 3), "start"]-def test_cmd_vibe_uses_restart_compatibility_default(monkeypatch):+def test_cmd_vibe_starts_by_default(monkeypatch):calls = []+ config = SimpleNamespace(+ has_configured_platform_credentials=lambda: True,+ ui=SimpleNamespace(setup_host="127.0.0.1", setup_port=5123, open_browser=False),+ )++ monkeypatch.setattr(cli.paths, "ensure_data_dirs", lambda: None)+ monkeypatch.setattr(cli, "_ensure_config", lambda: config)+ monkeypatch.setattr(cli, "_should_restart_for_upgrade_compat", lambda cfg: False)+ monkeypatch.setattr(cli, "_cmd_start_with_config", lambda cfg: calls.append(("start", cfg)) or 0)++ assert cli.cmd_vibe() == 0++ assert calls == [("start", config)]+++def test_cmd_vibe_restarts_for_upgrade_compat(monkeypatch):+ calls = []+ config = SimpleNamespace(+ has_configured_platform_credentials=lambda: True,+ ui=SimpleNamespace(setup_host="127.0.0.1", setup_port=5123, open_browser=False),+ )+ monkeypatch.setattr(cli.paths, "ensure_data_dirs", lambda: None)+ monkeypatch.setattr(cli, "_ensure_config", lambda: config)+ monkeypatch.setattr(cli, "_should_restart_for_upgrade_compat", lambda cfg: True)monkeypatch.setattr(cli, "_cmd_restart_with_delay", lambda delay: calls.append(("restart", delay)) or 0)assert cli.cmd_vibe() == 0@@ -208,6 +232,40 @@ def test_cmd_start_ensures_services_without_stopping(monkeypatch):assert not any(call == "stop" for call in calls)+def test_upgrade_compat_restart_when_running_ui_version_differs(monkeypatch):+ config = SimpleNamespace(ui=SimpleNamespace(setup_host="127.0.0.1", setup_port=5123))++ monkeypatch.setattr(cli, "__version__", "2.3.2")+ monkeypatch.setattr(cli, "_running_ui_version", lambda cfg: "2.3.1")+ monkeypatch.setattr(cli, "_launched_by_legacy_delayed_restart_helper", lambda: False)++ assert cli._should_restart_for_upgrade_compat(config) is True+++def test_upgrade_compat_does_not_restart_when_running_ui_version_matches(monkeypatch):+ config = SimpleNamespace(ui=SimpleNamespace(setup_host="127.0.0.1", setup_port=5123))++ monkeypatch.setattr(cli, "__version__", "2.3.2")+ monkeypatch.setattr(cli, "_running_ui_version", lambda cfg: "2.3.2")+ monkeypatch.setattr(cli, "_launched_by_legacy_delayed_restart_helper", lambda: False)++ assert cli._should_restart_for_upgrade_compat(config) is False+++def test_upgrade_compat_restarts_for_legacy_helper(monkeypatch):+ config = SimpleNamespace(ui=SimpleNamespace(setup_host="127.0.0.1", setup_port=5123))++ monkeypatch.setattr(cli, "_running_ui_version", lambda cfg: None)+ monkeypatch.setattr(cli, "_launched_by_legacy_delayed_restart_helper", lambda: True)++ assert cli._should_restart_for_upgrade_compat(config) is True+++def test_ui_local_url_uses_loopback_for_wildcard_bind():+ assert cli._ui_local_url("0.0.0.0", 5123, "/version") == "http://127.0.0.1:5123/version"+ assert cli._ui_local_url("::", 5123, "/version") == "http://[::1]:5123/version"++def test_restart_parser_accepts_delay_seconds():parser = cli.build_parser()args = parser.parse_args(["restart", "--delay-seconds", "60"])diff --git a/vibe/cli.py b/vibe/cli.pyindex 8d246b412..5899e52da 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -10,6 +10,8 @@ import signalimport subprocessimport sysimport time+import urllib.error+import urllib.requestfrom datetime import datetime, timezonefrom pathlib import Pathfrom textwrap import dedent@@ -1809,10 +1811,7 @@ def _doctor():return result-def cmd_start():- paths.ensure_data_dirs()- config = _ensure_config()-+def _cmd_start_with_config(config) -> int:has_configured_platform_credentials = getattr(config, "has_configured_platform_credentials", None)if callable(has_configured_platform_credentials):ready = bool(has_configured_platform_credentials())@@ -1850,9 +1849,74 @@ def cmd_start():return 0+def cmd_start():+ paths.ensure_data_dirs()+ config = _ensure_config()+ return _cmd_start_with_config(config)+++def _ui_local_url(host: str, port: int, path: str) -> str:+ local_host = (host or "127.0.0.1").strip()+ if local_host in {"0.0.0.0", ""}:+ local_host = "127.0.0.1"+ elif local_host in {"::", "::0"}:+ local_host = "[::1]"+ elif local_host.startswith("[") and local_host.endswith("]"):+ pass+ elif ":" in local_host:+ local_host = f"[{local_host}]"+ normalized_path = path if path.startswith("/") else f"/{path}"+ return f"http://{local_host}:{port}{normalized_path}"+++def _running_ui_version(config, timeout: float = 0.75) -> str | None:+ url = _ui_local_url(config.ui.setup_host, config.ui.setup_port, "/version")+ try:+ with urllib.request.urlopen(url, timeout=timeout) as response:+ if response.status != 200:+ return None+ payload = json.loads(response.read().decode("utf-8"))+ except (OSError, TimeoutError, urllib.error.URLError, json.JSONDecodeError):+ return None+ current = payload.get("current") if isinstance(payload, dict) else None+ return current if isinstance(current, str) and current else None+++def _launched_by_legacy_delayed_restart_helper() -> bool:+ parent_command = runtime.get_process_command(os.getppid())+ if not parent_command:+ return False+ return (+ "subprocess.Popen" in parent_command+ and "time.sleep(" in parent_command+ and "stdout=subprocess.DEVNULL" in parent_command+ and "stderr=subprocess.DEVNULL" in parent_command+ )+++def _should_restart_for_upgrade_compat(config) -> bool:+ running_version = _running_ui_version(config)+ if running_version and running_version != __version__:+ logger.info(+ "Bare vibe detected running UI version %s differs from installed version %s; restarting",+ running_version,+ __version__,+ )+ return True+ if _launched_by_legacy_delayed_restart_helper():+ logger.info("Bare vibe launched by legacy delayed restart helper; restarting")+ return True+ return False++def cmd_vibe():- """Compatibility default: bare `vibe` restarts during the migration window."""- return _cmd_restart_with_delay(0.0)+ """Bare `vibe` starts by default, with a narrow upgrade compatibility restart."""+ paths.ensure_data_dirs()+ config = _ensure_config()+ if _should_restart_for_upgrade_compat(config):+ return _cmd_restart_with_delay(0.0)+ return _cmd_start_with_config(config)+def _stop_opencode_server():