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(discord): merge legacy guild policy updates
cyh171c23d0c4bc
diff --git a/scripts/prepare_three_regression.py b/scripts/prepare_three_regression.pyindex dd9974b18..ff63229a2 100755--- a/scripts/prepare_three_regression.py+++ b/scripts/prepare_three_regression.py@@ -230,6 +230,7 @@ def _build_settings_payload() -> dict:"""Build a unified settings.json with per-channel routing for every platform."""channel_scopes: dict[str, dict] = {}guild_scopes: dict[str, dict] = {}+ guild_policy_scopes: dict[str, dict] = {}for name, pdef in PLATFORM_DEFS.items():platform_key = pdef["platform"]@@ -261,12 +262,16 @@ def _build_settings_payload() -> dict:}for guild_id in discord_denylist:guild_scopes["discord"][guild_id] = {"enabled": False}+ guild_policy_scopes["discord"] = {+ "default_enabled": not bool(discord_allowlist),+ }return {- "schema_version": 4,+ "schema_version": 5,"scopes": {"channel": channel_scopes,"guild": guild_scopes,+ "guild_policy": guild_policy_scopes,"user": {},},"bind_codes": [],diff --git a/tests/test_discord_guild_settings.py b/tests/test_discord_guild_settings.pyindex 2320f8c5a..42744c32f 100644--- a/tests/test_discord_guild_settings.py+++ b/tests/test_discord_guild_settings.py@@ -148,6 +148,41 @@ def test_partial_save_config_migrates_existing_legacy_discord_denylist(tmp_path,assert store.is_guild_enabled("discord", "guild-other") is True+def test_partial_legacy_guild_config_update_preserves_omitted_denylist(tmp_path, monkeypatch) -> None:+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ SettingsStore.reset_instance()++ paths.ensure_data_dirs()+ paths.get_config_path().write_text(+ json.dumps(+ {+ **_config_payload(),+ "discord": {+ "bot_token": "discord-token-1234567890",+ "guild_allowlist": ["guild-old"],+ "guild_denylist": ["guild-blocked"],+ "require_mention": False,+ },+ }+ ),+ encoding="utf-8",+ )++ api.save_config(+ {+ "discord": {+ "guild_allowlist": ["guild-new"],+ },+ }+ )+ store = SettingsStore.get_instance()++ assert store.get_guild_default_enabled_for_platform("discord") is False+ assert store.is_guild_enabled("discord", "guild-new") is True+ assert store.is_guild_enabled("discord", "guild-blocked") is False+ assert store.is_guild_enabled("discord", "guild-old") is False++def test_save_settings_preserves_discord_denylist_policy_when_default_omitted(tmp_path, monkeypatch) -> None:monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))SettingsStore.reset_instance()diff --git a/tests/test_prepare_three_regression.py b/tests/test_prepare_three_regression.pyindex c2c236673..3d8bee132 100644--- a/tests/test_prepare_three_regression.py+++ b/tests/test_prepare_three_regression.py@@ -90,7 +90,9 @@ def test_prepare_generates_unified_state(tmp_path: Path, monkeypatch: pytest.Mon# Per-channel routing in settings for each platformassert settings["scopes"]["channel"]["slack"]["C123SLACK"]["routing"]["agent_backend"] == "opencode"assert settings["scopes"]["channel"]["discord"]["123456789012345678"]["routing"]["agent_backend"] == "codex"+ assert settings["schema_version"] == 5assert settings["scopes"]["guild"]["discord"]["754776951587340359"]["enabled"] is True+ assert settings["scopes"]["guild_policy"]["discord"]["default_enabled"] is Falseassert settings["scopes"]["channel"]["lark"]["oc_test_chat_id"]["routing"]["agent_backend"] == "claude"# WeChat has no channel set, so scope is empty@@ -228,6 +230,19 @@ def test_prepare_allows_missing_channel_ids(tmp_path: Path, monkeypatch: pytest.assert settings["scopes"]["channel"]["wechat"] == {}+def test_prepare_preserves_discord_denylist_only_guild_policy(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):+ module = _load_module()+ _set_required_env(monkeypatch)+ monkeypatch.delenv("THREE_REGRESSION_DISCORD_GUILD_ALLOWLIST", raising=False)+ monkeypatch.setenv("THREE_REGRESSION_DISCORD_GUILD_DENYLIST", "blocked-guild")++ module.prepare(tmp_path, reset_mode="config")++ settings = json.loads((tmp_path / "vibe" / "state" / "settings.json").read_text(encoding="utf-8"))+ assert settings["scopes"]["guild"]["discord"]["blocked-guild"]["enabled"] is False+ assert settings["scopes"]["guild_policy"]["discord"]["default_enabled"] is True++def test_prepare_requires_supported_backend(monkeypatch: pytest.MonkeyPatch, tmp_path: Path):module = _load_module()_set_required_env(monkeypatch)diff --git a/vibe/api.py b/vibe/api.pyindex 6a7b4a20e..89ae324d6 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -282,8 +282,6 @@ def save_config(payload: dict) -> V2Config:if not isinstance(payload, dict):raise ValueError("Config payload must be an object")- payload, guild_scope_update = _extract_settings_scopes_from_config_payload(payload)-with CONFIG_LOCK:base_payload: dict = {}base_config: Optional[V2Config] = None@@ -294,7 +292,9 @@ def save_config(payload: dict) -> V2Config:base_payload = {}merged_payload = _deep_merge_dicts(base_payload, payload) if base_payload else payload- config = V2Config.from_payload(merged_payload)+ merged_payload = _merge_legacy_discord_guild_scope_fields(merged_payload, payload, base_config)+ sanitized_payload, guild_scope_update = _extract_settings_scopes_from_config_payload(merged_payload)+ config = V2Config.from_payload(sanitized_payload)if guild_scope_update is not None:_save_discord_guild_scope_update(*guild_scope_update)elif base_config is not None:@@ -350,6 +350,31 @@ def config_to_payload(config: V2Config) -> dict:return payload+def _merge_legacy_discord_guild_scope_fields(+ merged_payload: dict,+ request_payload: dict,+ base_config: Optional[V2Config],+) -> dict:+ """Complete partial legacy Discord guild updates before migration."""+ request_discord = request_payload.get("discord")+ if not isinstance(request_discord, dict):+ return merged_payload+ if "guild_allowlist" not in request_discord and "guild_denylist" not in request_discord:+ return merged_payload++ next_payload = dict(merged_payload)+ merged_discord = dict(next_payload.get("discord") or {})+ base_discord = getattr(base_config, "discord", None) if base_config is not None else None++ if "guild_allowlist" not in request_discord and base_discord is not None:+ merged_discord["guild_allowlist"] = getattr(base_discord, "guild_allowlist", None) or []+ if "guild_denylist" not in request_discord and base_discord is not None:+ merged_discord["guild_denylist"] = getattr(base_discord, "guild_denylist", None) or []++ next_payload["discord"] = merged_discord+ return next_payload++def get_platform_catalog() -> dict:from config.platform_registry import platform_catalog_payload