Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

feat(agents): record Vibey as the first default on a fresh install (#2500)

Call Whitef903e47a9634
diff --git a/core/vibe_agents.py b/core/vibe_agents.py
index 4ff3a40e4..98ff5242e 100644
--- a/core/vibe_agents.py
+++ b/core/vibe_agents.py
@@ -1783,11 +1783,16 @@ class VibeAgentStore:
default_name = self.get_default_agent_name()
default_agent = self.get(default_name) if default_name else None
enabled_ensured = [agent for agent in ensured if agent.enabled]
- if (default_agent is None or not default_agent.enabled) and enabled_ensured:
- self.set_default_agent_name(
- _implicit_default(enabled_ensured).name,
- user_context=instance_owner_context(),
- )
+ # A new install has no default yet and starts with the built-in Agent. A default that was
+ # recorded is kept; only one that can no longer be used is replaced, by the replacement rank.
+ if default_name is None:
+ chosen = _first_default(enabled_ensured)
+ elif default_agent is None or not default_agent.enabled:
+ chosen = _implicit_default(enabled_ensured)
+ else:
+ chosen = None
+ if chosen is not None:
+ self.set_default_agent_name(chosen.name, user_context=instance_owner_context())
return ensured
def get_builtin_default_agent_for_backend(self, backend: str, *, enabled_only: bool = True) -> Optional[VibeAgent]:
@@ -1950,6 +1955,18 @@ def _implicit_default(candidates: Iterable[VibeAgent]) -> Optional[VibeAgent]:
return min(candidates, key=lambda agent: implicit_default_rank(agent.backend), default=None)
+def _first_default(candidates: list[VibeAgent]) -> Optional[VibeAgent]:
+ """A new install's first default: the built-in backend's Agent, unless this instance can never run it."""
+ from config.v2_config import hub_supply_block
+
+ # Without a Model Hub config, the answer is the instance's own Model Hub switch: a built-in
+ # backend gets every model through the Hub, so with it switched off the built-in Agent cannot run.
+ for agent in candidates:
+ if is_always_enabled_agent(agent) and hub_supply_block(agent.backend, None) is None:
+ return agent
+ return _implicit_default(candidates)
+
+
def iter_global_agent_files(source: str) -> list[tuple[Path, str]]:
source_key = str(source or "").strip().lower()
home = Path.home()
diff --git a/docs/INSTALL_FOR_AI.md b/docs/INSTALL_FOR_AI.md
index b2903e0a9..21cf9a2a6 100644
--- a/docs/INSTALL_FOR_AI.md
+++ b/docs/INSTALL_FOR_AI.md
@@ -56,9 +56,11 @@ If the installer cannot use PyPI, it falls back to GitHub. If `vibe` is installe
When the installer runs as root, it installs the launcher at `/usr/local/bin/vibe`, the one supported location for root installs. Later upgrades move every stable `vibe` launcher that selects this install together; see [Upgrading](UPGRADING.md#stable-launchers).
-## Step 3: Install at Least One Coding Agent
+## Step 3: Optional: Add a Coding CLI
-Ask the user which backend they want first. Recommended default: OpenCode for low-friction setup, Claude Code for deeper coding work, Codex for OpenAI workflows.
+New installs start with Vibey, Avibe's built-in agent. It needs no CLI and runs once setup adds a Model Hub source
+(Step 4). Install Claude Code, Codex, or OpenCode only if the user also wants one of them: Avibe runs them alongside
+Vibey, and the user can make one the default for new chats later, in Agents.
OpenCode:
@@ -112,8 +114,9 @@ setup completes, use **Add model source** to return to this step.
Subscriptions added during setup connect through Model Hub so the assistant
selection step can use them.
-In the wizard, help the user install or detect Claude Code, Codex, or OpenCode,
-then connect one assistant with a subscription or API key. Existing valid
+In the wizard, Vibey is ready once it has a model, and new chats start with it. If
+the user also wants Claude Code, Codex, or OpenCode, help install or detect it, then
+connect it with a subscription or API key. Existing valid
credentials count; starting another login preserves them until the new login
commits. Settings → Backends uses the same connection and recovery controls.
OpenCode retains its explicit **Allow tool calls** action.
diff --git a/docs/INSTALL_FOR_AI_ZH.md b/docs/INSTALL_FOR_AI_ZH.md
index 084081a68..5405cb231 100644
--- a/docs/INSTALL_FOR_AI_ZH.md
+++ b/docs/INSTALL_FOR_AI_ZH.md
@@ -56,9 +56,10 @@ vibe doctor
以 root 身份运行安装器时,启动器会安装到 `/usr/local/bin/vibe`,这是 root 安装唯一支持的位置。之后的升级会让所有选中这份安装的稳定 `vibe` 启动器一起切换版本,参见 [Upgrading](UPGRADING.md#stable-launchers)。
-## 第 3 步:至少安装一个编码 Agent
+## 第 3 步:可选:添加编码 CLI
-先问用户想用哪个后端。默认建议:OpenCode 上手最轻,Claude Code 适合复杂编码任务,Codex 适合 OpenAI 工作流。
+新安装默认使用 Avibe 内置的 Vibey。它不需要任何 CLI,设置向导添加一个模型网关来源后(第 4 步)就能用。只有用户还想用
+Claude Code、Codex 或 OpenCode 时才需要安装:Avibe 会和 Vibey 一起运行它们,之后也可以在「Agent」页把其中一个设为新会话的默认。
OpenCode:
@@ -107,7 +108,7 @@ vibe
在向导里帮用户选择:
1. 聊天平台:Slack、Discord、Telegram、微信、飞书 / Lark。
-2. Agent 后端:Claude Code、OpenCode、Codex。
+2. Agent:新会话默认使用 Vibey;Claude Code、OpenCode、Codex 可选。
3. 项目工作目录。
4. 需要启用的频道或聊天范围。
diff --git a/modules/agents/catalog.py b/modules/agents/catalog.py
index f33bee916..ae0943ff0 100644
--- a/modules/agents/catalog.py
+++ b/modules/agents/catalog.py
@@ -157,10 +157,11 @@ def is_builtin_backend(name: str) -> bool:
def implicit_default_rank(name: str) -> int:
- """The one rule for a default nobody chose, among backends or their Agents: a built-in backend comes last.
+ """The one rule for a replacement default, among backends or their Agents: a built-in backend comes last.
- Making the built-in backend the default for new chats is its own decision, so no fallback
- picks it while another candidate exists.
+ A new install's first default is the built-in backend's Agent (``ensure_builtin_default_agents``).
+ A replacement stands in for a default that can no longer be used, on an install that may never have
+ given the built-in backend a model source, so no replacement picks it while another candidate exists.
"""
return 1 if is_builtin_backend(name) else 0
diff --git a/tests/scenarios/auth_setup/catalog.yaml b/tests/scenarios/auth_setup/catalog.yaml
index 4a2c32067..fc2744f8f 100644
--- a/tests/scenarios/auth_setup/catalog.yaml
+++ b/tests/scenarios/auth_setup/catalog.yaml
@@ -527,6 +527,19 @@ scenarios:
- ui/src/components/onboarding/BuiltinAssistant.test.tsx
- ui/src/components/onboarding/entryGate.test.ts
- ui/e2e/onboarding-fidelity/lineup.spec.ts
+ - id: AUTH-SETUP-132
+ name: A new install starts on Vibey, and setup completes without writing a default
+ status: covered
+ kind: happy_path
+ layer: scenario
+ backend: vibey
+ test: tests/scenarios/auth_setup/test_auth_setup_scenarios.py::test_a_new_install_starts_on_vibey_and_setup_completes_without_choosing_a_default
+ # The scenario owns the server boundary: the first Agent read records the built-in Vibey
+ # Agent as the default with the native backends enabled, its route becomes runnable, and
+ # completion keeps it. The browser's rule of keeping a recorded default that can run, even
+ # when a CLI assistant can run too, is the supporting test below.
+ supporting_tests:
+ - ui/src/components/onboarding/entryGate.test.ts
- id: AUTH-SETUP-130
name: "Occupied vendor callback port: OAuth start succeeds and the pasted callback completes the login"
status: partial
diff --git a/tests/scenarios/auth_setup/test_auth_setup_scenarios.py b/tests/scenarios/auth_setup/test_auth_setup_scenarios.py
index 91b584b53..dbec4bec1 100644
--- a/tests/scenarios/auth_setup/test_auth_setup_scenarios.py
+++ b/tests/scenarios/auth_setup/test_auth_setup_scenarios.py
@@ -4580,6 +4580,83 @@ def test_explicit_opencode_model_recovery_preserves_agent_and_completes(monkeypa
store.close()
+def test_a_new_install_starts_on_vibey_and_setup_completes_without_choosing_a_default(monkeypatch, tmp_path):
+ """AUTH-SETUP-132: first Agent read -> Vibey default -> runnable route -> completion keeps Vibey.
+
+ A fresh install with the native backends enabled records the built-in Vibey Agent as its
+ default on the first read; setup never writes a default for it. Once Vibey can run, setup
+ completes and Vibey is still the confirmed default. Every step is the HTTP route setup
+ calls; the browser's rule of keeping a recorded default that can run is the supporting test.
+ """
+ from core.vibe_agents import VibeAgentStore
+ from tests.test_model_hub_api import _service
+
+ monkeypatch.setenv("VIBE_MODEL_HUB_ENABLED", "1")
+ V2Config.default().save()
+ assert V2Config.load().agents.opencode.enabled and V2Config.load().agents.claude.enabled
+ service, store, _adapter = _service(tmp_path / "hub")
+ agents = VibeAgentStore()
+ service.named_agents_override = lambda backend: [
+ (agent.name, agent.model)
+ for agent in agents.list_agents(include_disabled=False)
+ if agent.backend == backend
+ ]
+ monkeypatch.setattr(ui_server, "_model_hub_service", lambda: service)
+ source = ModelHubSourceConfig(
+ id="src_vibey132",
+ kind="api_key",
+ vendor="custom",
+ display_name="Mock Lab",
+ protocol="openai_chat",
+ supply_channel="hub",
+ billing="metered",
+ state=ModelHubSourceStateConfig(status="standby"),
+ models=[ModelHubModelConfig(id="mock-large", provenance="discovered")],
+ credential_ref="cred_vibey132",
+ )
+ store.config.sources = [source]
+ store.config.agents["vibey"].sources.order = [source.id]
+ client = app.test_client()
+ headers = csrf_headers(client)
+ try:
+ listed = client.get("/api/agents").get_json()
+ vibey = next(row for row in listed["agents"] if row["backend"] == "vibey")
+ assert listed["default_agent_name"] == vibey["name"]
+
+ candidate = next(
+ row for row in client.get("/api/models/agents/vibey/models/candidates").get_json()["candidates"]["providers"]
+ if row["id"] == "mock-large"
+ )
+ added = {
+ "id": candidate["id"], "display_name": candidate["display_name"], "origin": candidate["origin"],
+ "models_dev_id": None, "context_window": None, "max_output_tokens": None,
+ "input_modalities": [], "output_modalities": [], "supports_tools": None,
+ "supports_reasoning": None, "reasoning_efforts": list(candidate["reasoning_efforts"]),
+ "locked": False, "routeable": True,
+ }
+ suppliers = [{"source_id": row["source_id"], "model_id": row["model_id"]} for row in candidate["suppliers"]]
+ written = client.put(
+ "/api/models/agents/vibey/models",
+ json={"baseline": [], "models": [added], "expected_suppliers": {"mock-large": suppliers}},
+ headers=headers,
+ )
+ assert written.status_code == 200, written.get_json()
+ named = client.patch(f"/api/agents/{vibey['name']}", json={"model": "mock-large"}, headers=headers)
+ assert named.status_code == 200, named.get_json()
+ supply = next(row for row in client.get("/api/models/agents").get_json()["agents"] if row["backend"] == "vibey")
+ route = next(row for row in supply["named_agents"] if row["name"] == vibey["name"])
+ assert route["supply_status"] in {"ok", "degraded"}
+
+ # Setup writes no default: completion keeps the one the new install recorded.
+ completed = client.post("/api/config", json={"setup_completed": True}, headers=headers)
+ assert completed.status_code == 200, completed.get_json()
+ assert V2Config.load().setup_completed
+ assert client.get("/api/agents").get_json()["default_agent_name"] == vibey["name"]
+ assert agents.get_default_agent().name == vibey["name"]
+ finally:
+ agents.close()
+
+
def test_builtin_vibey_model_pick_completes_setup_without_a_cli(monkeypatch, tmp_path):
"""AUTH-SETUP-129: Vibey candidates -> catalog write -> Agent model -> runnable route -> completion.
diff --git a/tests/test_ui_api.py b/tests/test_ui_api.py
index fd3d4f3f8..02c583894 100644
--- a/tests/test_ui_api.py
+++ b/tests/test_ui_api.py
@@ -3998,30 +3998,73 @@ def test_vibe_agent_api_rejects_non_boolean_enabled(tmp_path, monkeypatch):
@pytest.mark.parametrize(
- ("backends", "expected"),
- [(list(AGENT_BACKENDS), "opencode"), (["claude", "vibey"], "claude"), ([], "vibey")],
+ ("hub_enabled", "backends", "users_vibey", "expected"),
+ [
+ (True, list(AGENT_BACKENDS), False, "vibey"),
+ (True, ["claude"], False, "vibey"),
+ (True, [], False, "vibey"),
+ # A user's own Agent keeps the name; the built-in Agent is the default under its own.
+ (True, ["claude"], True, "vibey-2"),
+ # Model Hub switched off on the instance: the built-in Agent can never run, so the
+ # replacement rank applies, and it is chosen only when it is the only enabled Agent.
+ (False, list(AGENT_BACKENDS), False, "opencode"),
+ (False, ["claude"], False, "claude"),
+ (False, [], False, "vibey"),
+ ],
)
-def test_builtin_default_agent_uses_first_enabled_backend_when_no_default_exists(
- tmp_path, monkeypatch, backends, expected
+def test_a_new_installs_first_default_is_the_built_in_vibey_agent(
+ tmp_path, monkeypatch, hub_enabled, backends, users_vibey, expected
):
- """The built-in backend leads the catalog, but becomes the default only when nothing else is enabled."""
+ """With no default recorded yet, the sync records the built-in Agent wherever the instance can run it."""
monkeypatch.setenv("AVIBE_HOME", str(tmp_path / ".vibe_remote"))
+ monkeypatch.setenv("VIBE_MODEL_HUB_ENABLED", "1" if hub_enabled else "0")
store = VibeAgentStore()
try:
+ if users_vibey:
+ store.create(name="vibey", backend="claude")
store.ensure_builtin_default_agents(backends)
assert store.get_default_agent_name() == expected
finally:
store.close()
-def test_a_default_nobody_chose_is_not_the_built_in_vibey_agent(tmp_path, monkeypatch):
- """With the chosen default disabled, new chats fall back to an enabled Agent, as before Avibe was built in."""
+ ("recorded", "disable", "expected"),
+ [
+ ("claude", False, "claude"),
+ ("reviewer", False, "reviewer"),
+ # A recorded default that can no longer be used is replaced by the rank, not by the built-in Agent.
+ ("reviewer", True, "opencode"),
+ ],
+)
+def test_a_recorded_default_survives_the_sync_while_it_can_be_used(tmp_path, monkeypatch, recorded, disable, expected):
+ """An install that recorded a default keeps it: the first-default rule never moves an existing choice."""
+ from vibe.authorization import instance_owner_context
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path / ".vibe_remote"))
+ store = VibeAgentStore()
+ try:
+ store.ensure_builtin_default_agents(["opencode", "claude"])
+ store.create(name="reviewer", backend="codex")
+ store.set_default_agent_name(recorded, user_context=instance_owner_context())
+ if disable:
+ store.set_enabled(recorded, False)
+ store.ensure_builtin_default_agents(["opencode", "claude"])
+ assert store.get_default_agent_name() == expected
+ finally:
+ store.close()
+
+
+def test_a_replacement_default_is_not_the_built_in_vibey_agent(tmp_path, monkeypatch):
+ """With the recorded default disabled, new chats fall back to an enabled native Agent before the built-in one."""
from core.vibe_agents import resolve_effective_default_agent
+ from vibe.authorization import instance_owner_context
monkeypatch.setenv("AVIBE_HOME", str(tmp_path / ".vibe_remote"))
store = VibeAgentStore()
try:
store.ensure_builtin_default_agents(["opencode", "claude"])
+ store.set_default_agent_name("opencode", user_context=instance_owner_context())
store.set_enabled("opencode", False)
with store.engine.connect() as conn:
assert resolve_effective_default_agent(conn).name == "claude"
@@ -4095,7 +4138,8 @@ def test_api_builtin_default_agents_ignore_legacy_config_default_backend(tmp_pat
api._ensure_builtin_default_agents(config)
store = VibeAgentStore()
try:
- assert store.get_default_agent_name() == "opencode"
+ # The legacy field names no default: a new install starts with the built-in Agent, not Codex.
+ assert store.get_default_agent_name() == "vibey"
finally:
store.close()