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): guard local CI environment checks (#475)
Call White3ec1b715e87e
diff --git a/AGENTS.md b/AGENTS.mdindex 3ee215424..9094f13db 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -176,12 +176,14 @@ Source-of-truth rule:- PR descriptions must state which evidence layers were updated: unit, contract, scenario, and residual manual checks- after opening a PR, use the `background-watch-hook` skill to keep a review-fix loop running until Codex review passes- by default, create the review watch immediately after the PR is opened; do not wait for the user to remind you unless they explicitly say not to keep a watch+- keep expensive full-suite gates on GitHub CI by default, then require those CI checks to pass before merge### Pre-Push Requirements- run the smallest relevant validation first, then broader checks as needed- before `git push`, run `ruff check` on changed Python files at minimum- fix lint errors before pushing; CI runs `pre-commit run --all-files` with Ruff+- do not require a full local CI run before opening or updating a PR; prefer focused local validation and let GitHub CI run the slow gates asynchronously## 6. Coding Standards@@ -240,12 +242,14 @@ Reuse design-system primitives — do not re-roll:Important packaging caveat:- the installed `vibe` command uses packaged UI assets, not raw `ui/dist/` from the repo by default-- for local preview of UI changes, use editable install (`uv tool install --force --editable .`) or reinstall the package after building+- for local preview of packaged CLI/UI changes, build the UI and reinstall from a normal wheel; do not use `uv tool install --force --editable .` for the live local CLI+- do not run `python3 -m pip install -e .` against the system Python for validation; editable installs belong in a temporary venv or another explicitly isolated environment- do not restart local `vibe` just to verify UI changes unless the user explicitly requests a local-service workflow and the session impact is understood## 7. Testing and Validation- prefer the smallest relevant checks first: focused pytest, targeted scripts, or narrow manual validation+- keep slow full-suite gates in GitHub CI rather than running them locally for every feature PR- add tests when an existing test pattern already exists- do not introduce a brand-new test framework unless requesteddiff --git a/tests/test_vibe_cli.py b/tests/test_vibe_cli.pyindex 10fcd1abc..e8f8264f2 100644--- a/tests/test_vibe_cli.py+++ b/tests/test_vibe_cli.py@@ -3,6 +3,7 @@ import osimport pytestimport signalimport shlex+import sqlite3import sysfrom pathlib import Pathfrom types import SimpleNamespace@@ -14,6 +15,157 @@ from vibe import clifrom vibe import remote_access+def _make_fake_uv_tool(+ tmp_path: Path,+ *,+ editable: bool = False,+ revisions: list[str] | None = None,+ copied_executable: bool = False,+ windows_site_packages: bool = False,+) -> Path:+ tool_root = tmp_path / ".local" / "share" / "uv" / "tools" / "vibe-remote"+ bin_dir = tool_root / "bin"+ bin_dir.mkdir(parents=True)+ vibe_bin = bin_dir / "vibe"+ vibe_bin.write_text("#!/bin/sh\nexit 0\n", encoding="utf-8")+ vibe_bin.chmod(0o755)++ shim_dir = tmp_path / ".local" / "bin"+ shim_dir.mkdir(parents=True)+ if copied_executable:+ (shim_dir / "vibe.exe").write_text("#!/bin/sh\nexit 0\n", encoding="utf-8")+ (shim_dir / "vibe.exe").chmod(0o755)+ else:+ (shim_dir / "vibe").symlink_to(vibe_bin)++ if windows_site_packages:+ site_packages = tool_root / "Lib" / "site-packages"+ else:+ site_packages = tool_root / "lib" / "python3.13" / "site-packages"+ site_packages.mkdir(parents=True)+ if editable:+ (site_packages / "_editable_impl_vibe_remote.pth").write_text("/repo\n", encoding="utf-8")++ if revisions is not None:+ versions_dir = site_packages / "storage" / "alembic" / "versions"+ versions_dir.mkdir(parents=True)+ (versions_dir.parent / "__init__.py").write_text("", encoding="utf-8")+ (versions_dir / "__init__.py").write_text("", encoding="utf-8")+ for revision in revisions:+ (versions_dir / f"{revision}_example.py").write_text(f'revision = "{revision}"\n', encoding="utf-8")++ return site_packages+++def _write_alembic_revision(db_path: Path, revision: str) -> None:+ db_path.parent.mkdir(parents=True, exist_ok=True)+ with sqlite3.connect(db_path) as conn:+ conn.execute("create table alembic_version (version_num varchar(32) not null)")+ conn.execute("insert into alembic_version values (?)", (revision,))+++def test_local_cli_installation_items_pass_for_normal_uv_tool(monkeypatch, tmp_path):+ _make_fake_uv_tool(tmp_path, revisions=["20260606_0018"])+ db_path = tmp_path / "state" / "vibe.sqlite"+ _write_alembic_revision(db_path, "20260606_0018")++ monkeypatch.setattr(cli.Path, "home", classmethod(lambda cls: tmp_path))+ monkeypatch.setattr(cli.os, "get_exec_path", lambda: [str(tmp_path / ".local" / "bin")])+ monkeypatch.setattr(paths, "get_sqlite_state_path", lambda: db_path)++ items = cli._local_cli_installation_items()++ assert [item["status"] for item in items] == ["pass", "pass", "pass", "pass"]+ assert any("SQLite schema revision is recognized" in item["message"] for item in items)+++def test_local_cli_installation_items_pass_for_copied_uv_tool_executable(monkeypatch, tmp_path):+ _make_fake_uv_tool(+ tmp_path,+ revisions=["20260606_0018"],+ copied_executable=True,+ windows_site_packages=True,+ )+ db_path = tmp_path / "state" / "vibe.sqlite"+ _write_alembic_revision(db_path, "20260606_0018")++ monkeypatch.setattr(cli.sys, "platform", "win32")+ monkeypatch.setattr(cli.Path, "home", classmethod(lambda cls: tmp_path))+ monkeypatch.setattr(cli.os, "get_exec_path", lambda: [str(tmp_path / ".local" / "bin")])+ monkeypatch.setattr(+ cli,+ "_uv_tool_dir",+ lambda *, bin_dir: tmp_path / ".local" / "bin"+ if bin_dir+ else tmp_path / ".local" / "share" / "uv" / "tools",+ )+ monkeypatch.setattr(paths, "get_sqlite_state_path", lambda: db_path)++ items = cli._local_cli_installation_items()++ assert [item["status"] for item in items] == ["pass", "pass", "pass", "pass"]+ assert any("SQLite schema revision is recognized" in item["message"] for item in items)+++def test_local_cli_installation_items_skips_inactive_stale_uv_tool(monkeypatch, tmp_path):+ _make_fake_uv_tool(tmp_path, editable=True, revisions=None)+ active_bin = tmp_path / "venv" / "bin"+ active_bin.mkdir(parents=True)+ active_vibe = active_bin / "vibe"+ active_vibe.write_text("#!/bin/sh\nexit 0\n", encoding="utf-8")+ active_vibe.chmod(0o755)++ monkeypatch.setattr(cli.Path, "home", classmethod(lambda cls: tmp_path))+ monkeypatch.setattr(cli.os, "get_exec_path", lambda: [str(active_bin), str(tmp_path / ".local" / "bin")])+ monkeypatch.setattr(paths, "get_sqlite_state_path", lambda: tmp_path / "missing.sqlite")++ items = cli._local_cli_installation_items()++ assert not any(item["status"] == "fail" for item in items)+ assert any("Active vibe executable is not the uv tool installation" in item["message"] for item in items)+++def test_local_cli_installation_items_fails_for_editable_uv_tool(monkeypatch, tmp_path):+ _make_fake_uv_tool(tmp_path, editable=True, revisions=["20260606_0018"])++ monkeypatch.setattr(cli.Path, "home", classmethod(lambda cls: tmp_path))+ monkeypatch.setattr(cli.os, "get_exec_path", lambda: [str(tmp_path / ".local" / "bin")])+ monkeypatch.setattr(paths, "get_sqlite_state_path", lambda: tmp_path / "missing.sqlite")++ items = cli._local_cli_installation_items()++ assert any(item["status"] == "fail" and "uv tool installation is editable" in item["message"] for item in items)+++def test_local_cli_installation_items_fails_when_alembic_scripts_missing(monkeypatch, tmp_path):+ _make_fake_uv_tool(tmp_path, revisions=None)++ monkeypatch.setattr(cli.Path, "home", classmethod(lambda cls: tmp_path))+ monkeypatch.setattr(cli.os, "get_exec_path", lambda: [str(tmp_path / ".local" / "bin")])+ monkeypatch.setattr(paths, "get_sqlite_state_path", lambda: tmp_path / "missing.sqlite")++ items = cli._local_cli_installation_items()++ assert any(item["status"] == "fail" and "Packaged Alembic scripts are missing" in item["message"] for item in items)+++def test_local_cli_installation_items_fails_for_unknown_sqlite_revision(monkeypatch, tmp_path):+ _make_fake_uv_tool(tmp_path, revisions=["20260604_0017"])+ db_path = tmp_path / "state" / "vibe.sqlite"+ _write_alembic_revision(db_path, "20260606_0018")++ monkeypatch.setattr(cli.Path, "home", classmethod(lambda cls: tmp_path))+ monkeypatch.setattr(cli.os, "get_exec_path", lambda: [str(tmp_path / ".local" / "bin")])+ monkeypatch.setattr(paths, "get_sqlite_state_path", lambda: db_path)++ items = cli._local_cli_installation_items()++ assert any(+ item["status"] == "fail" and "SQLite schema revision is newer than or unknown to this CLI" in item["message"]+ for item in items+ )++def test_default_config_written(tmp_path, monkeypatch):monkeypatch.setattr(paths, "get_vibe_remote_dir", lambda: tmp_path / ".vibe_remote")runtime.ensure_dirs()diff --git a/vibe/cli.py b/vibe/cli.pyindex cb7e948c7..15959525f 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -9,6 +9,7 @@ import platformimport shleximport shutilimport signal+import sqlite3import subprocessimport sysimport time@@ -3693,6 +3694,13 @@ def _doctor():groups.append({"name": "Runtime", "items": runtime_items})+ local_cli_items = _local_cli_installation_items()+ for item in local_cli_items:+ status = item.get("status")+ if status in summary:+ summary[status] += 1+ groups.append({"name": "Local CLI Installation", "items": local_cli_items})+# Calculate overall statusok = summary["fail"] == 0@@ -3706,6 +3714,252 @@ def _doctor():return result+def _add_doctor_item(items: list[dict], status: str, message: str, action: str | None = None) -> None:+ item = {"status": status, "message": message}+ if action:+ item["action"] = action+ items.append(item)+++def _path_entries_for_executable(name: str) -> list[Path]:+ candidates: list[Path] = []+ seen: set[str] = set()+ suffixes = [""]+ if sys.platform == "win32":+ suffixes = [".exe", ".cmd", ".bat", ""]++ for directory in os.get_exec_path():+ if not directory:+ continue+ for suffix in suffixes:+ candidate = (Path(directory) / f"{name}{suffix}").expanduser()+ try:+ resolved = candidate.resolve()+ except OSError:+ resolved = candidate.absolute()+ key = str(resolved)+ if key in seen or not candidate.exists():+ continue+ seen.add(key)+ candidates.append(resolved)+ return candidates+++def _uv_tool_site_packages_for_vibe(vibe_path: Path) -> list[Path]:+ tool_roots: list[Path] = []+ seen_roots: set[str] = set()++ def add_tool_root(tool_root: Path) -> None:+ try:+ resolved = tool_root.expanduser().resolve()+ except OSError:+ resolved = tool_root.expanduser().absolute()+ key = str(resolved)+ if key not in seen_roots:+ seen_roots.add(key)+ tool_roots.append(resolved)++ parts = vibe_path.parts+ try:+ tools_index = parts.index("tools")+ except ValueError:+ pass+ else:+ if tools_index + 1 < len(parts) and parts[tools_index + 1] == "vibe-remote":+ add_tool_root(Path(*parts[: tools_index + 2]))++ uv_bin_dir = _uv_tool_dir(bin_dir=True)+ if uv_bin_dir is not None and _path_is_relative_to(vibe_path, uv_bin_dir):+ uv_tools_dir = _uv_tool_dir(bin_dir=False)+ if uv_tools_dir is not None:+ add_tool_root(uv_tools_dir / "vibe-remote")++ site_packages_dirs: list[Path] = []+ for tool_root in tool_roots:+ site_packages_dirs.extend(_site_packages_dirs_for_tool_root(tool_root))+ return site_packages_dirs+++def _site_packages_dirs_for_tool_root(tool_root: Path) -> list[Path]:+ candidates: list[Path] = []+ posix_lib_dir = tool_root / "lib"+ if posix_lib_dir.exists():+ candidates.extend(sorted(posix_lib_dir.glob("python*/site-packages")))++ windows_site_packages = tool_root / "Lib" / "site-packages"+ if windows_site_packages.exists():+ candidates.append(windows_site_packages)++ return candidates+++def _uv_tool_dir(*, bin_dir: bool) -> Path | None:+ uv_path = shutil.which("uv")+ if not uv_path:+ return None+ command = [uv_path, "tool", "dir"]+ if bin_dir:+ command.append("--bin")+ try:+ result = subprocess.run(+ command,+ check=True,+ stdout=subprocess.PIPE,+ stderr=subprocess.DEVNULL,+ text=True,+ timeout=5,+ )+ except (OSError, subprocess.SubprocessError):+ return None+ output = result.stdout.strip()+ if not output:+ return None+ return Path(output).expanduser()+++def _path_is_relative_to(path: Path, parent: Path) -> bool:+ try:+ path.resolve().relative_to(parent.expanduser().resolve())+ except (OSError, ValueError):+ try:+ path.absolute().relative_to(parent.expanduser().absolute())+ except ValueError:+ return False+ return True+++def _is_uv_tool_editable(site_packages: Path) -> bool:+ if list(site_packages.glob("_editable*_vibe_remote*.pth")):+ return True+ for direct_url in site_packages.glob("vibe_remote-*.dist-info/direct_url.json"):+ try:+ payload = json.loads(direct_url.read_text(encoding="utf-8"))+ except (OSError, json.JSONDecodeError):+ continue+ if payload.get("dir_info", {}).get("editable") is True:+ return True+ return False+++def _available_alembic_revisions(alembic_versions_dir: Path) -> set[str]:+ revisions: set[str] = set()+ if not alembic_versions_dir.exists():+ return revisions+ for migration in alembic_versions_dir.glob("*.py"):+ name = migration.name+ if name == "__init__.py":+ continue+ revision = name.split("_", 2)+ if len(revision) >= 2:+ revisions.add("_".join(revision[:2]))+ return revisions+++def _current_sqlite_revision() -> str | None:+ db_path = paths.get_sqlite_state_path().expanduser()+ if not db_path.exists():+ return None+ try:+ with sqlite3.connect(db_path) as conn:+ row = conn.execute("select version_num from alembic_version").fetchone()+ except sqlite3.Error:+ return None+ if not row or not row[0]:+ return None+ return str(row[0])+++def _local_cli_installation_items() -> list[dict]:+ items: list[dict] = []++ vibe_paths = _path_entries_for_executable("vibe")+ preferred_vibe = (Path.home() / ".local" / "bin" / "vibe").expanduser()+ active_vibe_path: Path | None = None+ if not vibe_paths:+ _add_doctor_item(+ items,+ "warn",+ "No vibe executable found on PATH",+ "Install Vibe Remote with uv tool or add the intended vibe executable to PATH.",+ )+ else:+ first_vibe = vibe_paths[0]+ active_vibe_path = first_vibe+ try:+ preferred_resolved = preferred_vibe.resolve()+ except OSError:+ preferred_resolved = preferred_vibe+ if preferred_vibe.exists() and first_vibe != preferred_resolved:+ _add_doctor_item(+ items,+ "warn",+ f"PATH resolves vibe to {first_vibe} before {preferred_resolved}",+ "Put ~/.local/bin before system Python bin directories when using the uv tool installation.",+ )+ else:+ _add_doctor_item(items, "pass", f"PATH resolves vibe to {first_vibe}")++ site_packages_dirs = _uv_tool_site_packages_for_vibe(active_vibe_path) if active_vibe_path is not None else []+ if not site_packages_dirs:+ _add_doctor_item(+ items,+ "warn",+ "Active vibe executable is not the uv tool installation",+ "uv tool package-integrity checks are skipped for this executable.",+ )+ return items++ recognized_revisions: set[str] = set()+ for site_packages in site_packages_dirs:+ if _is_uv_tool_editable(site_packages):+ _add_doctor_item(+ items,+ "fail",+ f"uv tool installation is editable: {site_packages}",+ "Reinstall Vibe Remote from a normal wheel. Do not use 'uv tool install --editable .' for the live local CLI.",+ )+ else:+ _add_doctor_item(items, "pass", f"uv tool installation is not editable: {site_packages}")++ alembic_dir = site_packages / "storage" / "alembic"+ versions_dir = alembic_dir / "versions"+ if not alembic_dir.exists() or not versions_dir.exists():+ _add_doctor_item(+ items,+ "fail",+ f"Packaged Alembic scripts are missing under {alembic_dir}",+ "Reinstall from a wheel that includes storage/alembic. Editable uv tool installs can miss this package data.",+ )+ continue++ revisions = _available_alembic_revisions(versions_dir)+ recognized_revisions.update(revisions)+ if revisions:+ _add_doctor_item(items, "pass", f"Packaged Alembic scripts found: {versions_dir}")+ else:+ _add_doctor_item(+ items,+ "fail",+ f"No Alembic revision files found under {versions_dir}",+ "Reinstall from a wheel that includes storage/alembic/versions.",+ )++ sqlite_revision = _current_sqlite_revision()+ if sqlite_revision is None:+ _add_doctor_item(items, "pass", "SQLite schema revision is not initialized yet")+ elif sqlite_revision in recognized_revisions:+ _add_doctor_item(items, "pass", f"SQLite schema revision is recognized by this CLI: {sqlite_revision}")+ else:+ _add_doctor_item(+ items,+ "fail",+ f"SQLite schema revision is newer than or unknown to this CLI: {sqlite_revision}",+ "Install a Vibe Remote wheel built from code that contains this migration revision.",+ )++ return items++def cmd_start():paths.ensure_data_dirs()config = _ensure_config()