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
refactor(regression): consolidate 4 containers into single unified container
cyhf098f4451716
diff --git a/.env.three-regression.example b/.env.three-regression.exampleindex 57c794a8a..735c7b1c7 100644--- a/.env.three-regression.example+++ b/.env.three-regression.example@@ -38,19 +38,14 @@ THREE_REGRESSION_OPENCODE_ANTHROPIC_API_KEY=# Shared regression defaults# -----------------------------------------------------------------------------THREE_REGRESSION_UI_HOST=127.0.0.1+THREE_REGRESSION_PORT=15130THREE_REGRESSION_DEFAULT_CWD=/data/vibe_remote/workdir+THREE_REGRESSION_DEFAULT_BACKEND=opencodeTHREE_REGRESSION_LOG_LEVEL=INFOTHREE_REGRESSION_LANGUAGE=en# ------------------------------------------------------------------------------# Local UI ports-# ------------------------------------------------------------------------------THREE_REGRESSION_SLACK_PORT=15131-THREE_REGRESSION_DISCORD_PORT=15132-THREE_REGRESSION_FEISHU_PORT=15133--# ------------------------------------------------------------------------------# Slack regression environment+# Slack# -----------------------------------------------------------------------------THREE_REGRESSION_SLACK_BOT_TOKEN=THREE_REGRESSION_SLACK_APP_TOKEN=@@ -66,7 +61,7 @@ THREE_REGRESSION_SLACK_CODEX_MODEL=THREE_REGRESSION_SLACK_CODEX_REASONING_EFFORT=# ------------------------------------------------------------------------------# Discord regression environment+# Discord# -----------------------------------------------------------------------------THREE_REGRESSION_DISCORD_BOT_TOKEN=THREE_REGRESSION_DISCORD_CHANNEL=@@ -83,7 +78,7 @@ THREE_REGRESSION_DISCORD_CODEX_MODEL=THREE_REGRESSION_DISCORD_CODEX_REASONING_EFFORT=# ------------------------------------------------------------------------------# Feishu regression environment+# Feishu# -----------------------------------------------------------------------------THREE_REGRESSION_FEISHU_APP_ID=THREE_REGRESSION_FEISHU_APP_SECRET=@@ -98,3 +93,20 @@ THREE_REGRESSION_FEISHU_CLAUDE_AGENT=THREE_REGRESSION_FEISHU_CLAUDE_MODEL=THREE_REGRESSION_FEISHU_CODEX_MODEL=THREE_REGRESSION_FEISHU_CODEX_REASONING_EFFORT=++# -----------------------------------------------------------------------------+# -----------------------------------------------------------------------------+THREE_REGRESSION_WECHAT_BOT_TOKEN=+THREE_REGRESSION_WECHAT_BASE_URL=https://ilinkai.weixin.qq.com+THREE_REGRESSION_WECHAT_CDN_BASE_URL=https://novac2c.cdn.weixin.qq.com/c2c+THREE_REGRESSION_WECHAT_CHANNEL=+THREE_REGRESSION_WECHAT_BACKEND=opencode+THREE_REGRESSION_WECHAT_REQUIRE_MENTION=false+THREE_REGRESSION_WECHAT_OPENCODE_AGENT=+THREE_REGRESSION_WECHAT_OPENCODE_MODEL=+THREE_REGRESSION_WECHAT_OPENCODE_REASONING_EFFORT=+THREE_REGRESSION_WECHAT_CLAUDE_AGENT=+THREE_REGRESSION_WECHAT_CLAUDE_MODEL=+THREE_REGRESSION_WECHAT_CODEX_MODEL=+THREE_REGRESSION_WECHAT_CODEX_REASONING_EFFORT=diff --git a/AGENTS.md b/AGENTS.mdindex a835c78c4..e299169a2 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -11,7 +11,7 @@ Current product shape:- V2 config-driven service with a Web UI setup wizard and settings pages- multi-platform message transport with shared core orchestration- multi-backend agent routing across OpenCode, Claude Code, and Codex-- Docker-based three-end regression environment for real cross-platform verification+- Docker-based unified regression container for real cross-platform verificationDefault mindset:@@ -80,14 +80,16 @@ Hard rule:- The local `vibe` process may be the coding agent runtime itself; restarting it can interrupt the session.- Unless the user explicitly asks otherwise, use the Docker three-end regression environment for user-facing verification.-### Three-End Regression (Docker)+### Regression Testing (Docker)When the user says `三端回归测试`, treat it as:- update the latest code into the existing Docker-based regression environment-- let the user verify behavior on Slack, Discord, and Feishu/Lark+- let the user verify behavior on Slack, Discord, Feishu/Lark, and WeChat- preserve previously accumulated regression config/state unless the user explicitly asks for a reset+The regression environment runs a single unified container with all four IM platforms enabled simultaneously.+Standard path:- default command: `./scripts/run_three_regression.sh`@@ -96,7 +98,7 @@ Rules:- do **not** use `--reset-config` or `--reset-all` unless the user explicitly requests reset behavior- do **not** use `--no-build` when code changes must take effect; it is only for restarting with the existing image-- after running the script, verify the three services are healthy before handing back to the user+- after running the script, verify the service is healthy before handing back to the user- prefer Docker regression over local `vibe` whenever validating cross-platform behavior, setup wizard behavior, or user-facing IM flows## 4. Configuration and Routing Modeldiff --git a/docker-compose.three-regression.yml b/docker-compose.three-regression.ymlindex b7be4fefc..64722ba72 100644--- a/docker-compose.three-regression.yml+++ b/docker-compose.three-regression.yml@@ -1,66 +1,30 @@-x-vibe-regression: &vibe-regression- image: vibe-remote-three-regression:latest- build:- context: .- dockerfile: Dockerfile- target: integration- command: ["full"]- environment:- VIBE_REMOTE_HOME: /data/vibe_remote- VIBE_UI_PORT: 5123- PYTHONUNBUFFERED: "1"- ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}- ANTHROPIC_BASE_URL: ${ANTHROPIC_BASE_URL:-}- ANTHROPIC_AUTH_TOKEN: ${THREE_REGRESSION_CLAUDE_AUTH_TOKEN:-}- CLAUDE_CODE_ATTRIBUTION_HEADER: ${THREE_REGRESSION_CLAUDE_ATTRIBUTION_HEADER:-0}- OPENAI_API_KEY: ${OPENAI_API_KEY:-}- healthcheck:- test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:5123/health', timeout=3)"]- interval: 3s- timeout: 5s- retries: 20- start_period: 30s-services:- slack:- <<: *vibe-regression+ vibe:+ image: vibe-remote-three-regression:latest+ build:+ context: .+ dockerfile: Dockerfile+ target: integration+ command: ["full"]+ environment:+ VIBE_REMOTE_HOME: /data/vibe_remote+ VIBE_UI_PORT: 5123+ PYTHONUNBUFFERED: "1"+ ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}+ ANTHROPIC_BASE_URL: ${ANTHROPIC_BASE_URL:-}+ ANTHROPIC_AUTH_TOKEN: ${THREE_REGRESSION_CLAUDE_AUTH_TOKEN:-}+ CLAUDE_CODE_ATTRIBUTION_HEADER: ${THREE_REGRESSION_CLAUDE_ATTRIBUTION_HEADER:-0}+ OPENAI_API_KEY: ${OPENAI_API_KEY:-}+ healthcheck:+ test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:5123/health', timeout=3)"]+ interval: 3s+ timeout: 5s+ retries: 20+ start_period: 30sports:- - "${THREE_REGRESSION_SLACK_PORT:-15131}:5123"+ - "${THREE_REGRESSION_PORT:-15130}:5123"volumes:- - ./_tmp/three-regression/slack:/data/vibe_remote- - ./_tmp/three-regression/shared-home/.claude/settings.json:/root/.claude/settings.json:ro- - ./_tmp/three-regression/shared-home/.codex/config.toml:/root/.codex/config.toml:ro- - ./_tmp/three-regression/shared-home/.codex/auth.json:/root/.codex/auth.json:ro- - ./_tmp/three-regression/shared-home/.config/opencode/opencode.json:/root/.config/opencode/opencode.json:ro-- discord:- <<: *vibe-regression- ports:- - "${THREE_REGRESSION_DISCORD_PORT:-15132}:5123"- volumes:- - ./_tmp/three-regression/discord:/data/vibe_remote- - ./_tmp/three-regression/shared-home/.claude/settings.json:/root/.claude/settings.json:ro- - ./_tmp/three-regression/shared-home/.codex/config.toml:/root/.codex/config.toml:ro- - ./_tmp/three-regression/shared-home/.codex/auth.json:/root/.codex/auth.json:ro- - ./_tmp/three-regression/shared-home/.config/opencode/opencode.json:/root/.config/opencode/opencode.json:ro-- feishu:- <<: *vibe-regression- ports:- - "${THREE_REGRESSION_FEISHU_PORT:-15133}:5123"- volumes:- - ./_tmp/three-regression/feishu:/data/vibe_remote- - ./_tmp/three-regression/shared-home/.claude/settings.json:/root/.claude/settings.json:ro- - ./_tmp/three-regression/shared-home/.codex/config.toml:/root/.codex/config.toml:ro- - ./_tmp/three-regression/shared-home/.codex/auth.json:/root/.codex/auth.json:ro- - ./_tmp/three-regression/shared-home/.config/opencode/opencode.json:/root/.config/opencode/opencode.json:ro-- wechat:- <<: *vibe-regression- ports:- - "${THREE_REGRESSION_WECHAT_PORT:-15134}:5123"- volumes:- - ./_tmp/three-regression/wechat:/data/vibe_remote+ - ./_tmp/three-regression/vibe:/data/vibe_remote- ./_tmp/three-regression/shared-home/.claude/settings.json:/root/.claude/settings.json:ro- ./_tmp/three-regression/shared-home/.codex/config.toml:/root/.codex/config.toml:ro- ./_tmp/three-regression/shared-home/.codex/auth.json:/root/.codex/auth.json:rodiff --git a/docs/three-end-regression/README.md b/docs/three-end-regression/README.mdindex c16ed933f..efc5bf4e1 100644--- a/docs/three-end-regression/README.md+++ b/docs/three-end-regression/README.md@@ -1,13 +1,13 @@-# Three-End Regression+# Regression Testing-`三端回归测试` is the manual regression workflow for this repository. It starts three isolated containers in parallel, one for Slack, one for Discord, and one for Feishu, with each environment pre-bound to its own channel and backend agent.+`三端回归测试` is the manual regression workflow for this repository. It starts a single unified container with all four IM platforms (Slack, Discord, Feishu, WeChat) running simultaneously, each with per-channel backend routing pre-configured.The container state is persistent by default. Changes you make through the UI or inside the running service, such as channel routing and other saved settings, stay under `_tmp/three-regression/` across normal restarts.It complements the existing automated `E2E` flow instead of replacing it:- `E2E testing` keeps using scripts and pytest for automatable scenarios.-- `Three-end regression` is for human-triggered checks on real IM platforms.+- `Regression testing` is for human-triggered checks on real IM platforms.## Setup@@ -21,12 +21,12 @@ It complements the existing automated `E2E` flow instead of replacing it:- shared LLM credentials: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`- optional API base URLs: `ANTHROPIC_BASE_URL`, `OPENAI_BASE_URL`, `OPENAI_API_BASE`-- optional UI host override: `THREE_REGRESSION_UI_HOST` (useful when exposing the three UIs on a LAN host)-- platform-specific bot credentials for Slack, Discord, and Feishu+- optional UI host override: `THREE_REGRESSION_UI_HOST` (useful when exposing the UI on a LAN host)+- platform-specific bot credentials for Slack, Discord, Feishu, and WeChat- the target regression channel for each platform, if you want channel routing preseeded at startup-- the backend that each platform should pin to by default+- the backend that each platform's channel should pin to by default-Channel IDs are optional. If you leave them empty, the containers still start and you can configure channels later from the Web UI.+Channel IDs are optional. If you leave them empty, the container still starts and you can configure channels later from the Web UI.3. Keep these local-only files out of git:@@ -35,7 +35,7 @@ Channel IDs are optional. If you leave them empty, the containers still start an## Usage-The default command rebuilds the image, preserves your current regression state, and recreates all three containers:+The default command rebuilds the image, preserves your current regression state, and recreates the container:```bash./scripts/run_three_regression.sh@@ -49,7 +49,6 @@ Common commands:./scripts/run_three_regression.sh --reset-all./scripts/run_three_regression.sh --status./scripts/run_three_regression.sh --logs-./scripts/run_three_regression.sh --logs slack./scripts/run_three_regression.sh --down```@@ -62,45 +61,60 @@ DOCKER_BIN=/usr/local/bin/docker ./scripts/run_three_regression.shReset modes:- `--reset-config`: re-seed `config/`, `state/`, and `runtime/` from `.env.three-regression`, while preserving `workdir/`, `attachments/`, and `logs/`-- `--reset-all`: wipe the full per-service state directory, including `workdir/`, then re-seed from `.env.three-regression`+- `--reset-all`: wipe the full state directory, including `workdir/`, then re-seed from `.env.three-regression``--reset-state` remains available as a backward-compatible alias for `--reset-all`.## What You Get-On success, the script prints three local UI URLs together with the configured channel/backend mapping, for example:+On success, the script prints one local UI URL together with the configured per-platform channel/backend mapping:```text-Slack -> http://127.0.0.1:15131-Discord -> http://127.0.0.1:15132-Feishu -> http://127.0.0.1:15133+Unified regression environment is ready:+ URL: http://127.0.0.1:15130+ Default backend: opencode++ Platform routing:+ - Slack: channel=C123SLACK backend=opencode+ - Discord: channel=1234567890 backend=codex+ - Feishu: channel=oc_xxx backend=claude+ - WeChat: channel=(QR login) backend=opencode```-If you set `THREE_REGRESSION_UI_HOST=192.168.2.3`, the printed URLs and generated UI config will use that host instead.+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 for every service:+On first startup, or when you run with `--reset-config` / `--reset-all`, the runner seeds these files under `_tmp/three-regression/vibe/`:- `config/config.json`- `state/settings.json`- `state/sessions.json`-The generated state lives under `_tmp/three-regression/`, which keeps each regression environment isolated while preserving your later modifications by default.+The generated state lives under `_tmp/three-regression/`, which keeps the regression environment isolated while preserving your later modifications by default.Persistence rules:- `./scripts/run_three_regression.sh` preserves UI changes, sessions, and files under `workdir/`- `--reset-config` preserves `workdir/` files but resets service config/state-- `--reset-all` clears everything under each service directory+- `--reset-all` clears everything under the state directory++## Architecture++The unified container leverages the multi-platform IM support to run all four platforms in one process:++- **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 `_tmp/three-regression/vibe/` directory holds config, state, logs, and the agent workdir.+- **Shared agent home configs**: Generated under `_tmp/three-regression/shared-home/` and mounted read-only into the container.## Configuration Rules-- The Slack container always runs Slack platform config.-- The Discord container always runs Discord platform config.-- The Feishu container uses the internal `lark` platform config while keeping `feishu` naming in the regression workflow.-- All three containers receive the shared credentials needed by Claude, Codex, and OpenCode.-- Shared Claude / Codex / OpenCode home configs are generated under `_tmp/three-regression/shared-home/` and mounted into all three containers.-- Each container preloads channel routing in `settings.json`, so the target channel resolves to the expected backend immediately after startup.-- The default working directory is `/data/vibe_remote/workdir`, a writable per-container sandbox under the generated regression state.+- All four IM platforms (Slack, Discord, Feishu, WeChat) run in a single container process.+- 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 `_tmp/three-regression/shared-home/`.+- The default working directory is `/data/vibe_remote/workdir`, a writable sandbox under the generated state.## Secret Safetydiff --git a/scripts/prepare_three_regression.py b/scripts/prepare_three_regression.pyindex f64631d91..59e2e65f2 100755--- a/scripts/prepare_three_regression.py+++ b/scripts/prepare_three_regression.py@@ -1,5 +1,9 @@#!/usr/bin/env python3-"""Prepare generated config/state for three-end regression containers."""+"""Prepare generated config/state for the unified regression container.++Generates a single config.json with all four IM platforms enabled and all+three agent backends configured, plus per-channel routing in settings.json.+"""from __future__ import annotations@@ -11,10 +15,11 @@ import sysfrom pathlib import Path-SERVICE_DEFS = {+PLATFORM_DEFS = {"slack": {"platform": "slack","channel_env": "THREE_REGRESSION_SLACK_CHANNEL",+ "backend_env": "THREE_REGRESSION_SLACK_BACKEND","required_envs": ("THREE_REGRESSION_SLACK_BOT_TOKEN","THREE_REGRESSION_SLACK_APP_TOKEN",@@ -23,11 +28,13 @@ SERVICE_DEFS = {"discord": {"platform": "discord","channel_env": "THREE_REGRESSION_DISCORD_CHANNEL",+ "backend_env": "THREE_REGRESSION_DISCORD_BACKEND","required_envs": ("THREE_REGRESSION_DISCORD_BOT_TOKEN",),},"feishu": {"platform": "lark","channel_env": "THREE_REGRESSION_FEISHU_CHAT_ID",+ "backend_env": "THREE_REGRESSION_FEISHU_BACKEND","required_envs": ("THREE_REGRESSION_FEISHU_APP_ID","THREE_REGRESSION_FEISHU_APP_SECRET",@@ -36,6 +43,7 @@ SERVICE_DEFS = {"wechat": {"platform": "wechat","channel_env": "THREE_REGRESSION_WECHAT_CHANNEL",+ "backend_env": "THREE_REGRESSION_WECHAT_BACKEND","required_envs": (), # bot_token obtained via QR login, not env},}@@ -73,19 +81,19 @@ def _require_envs(keys: tuple[str, ...]) -> None:raise SystemExit(f"Missing required environment variables: {joined}")-def _service_prefix(service_name: str) -> str:- return f"THREE_REGRESSION_{service_name.upper()}"+def _platform_prefix(name: str) -> str:+ return f"THREE_REGRESSION_{name.upper()}"-def _build_routing(service_name: str) -> dict:- prefix = _service_prefix(service_name)+def _build_routing(name: str) -> dict:+ prefix = _platform_prefix(name)backend = _env(f"{prefix}_BACKEND")- if backend not in SUPPORTED_BACKENDS:+ if backend and backend not in SUPPORTED_BACKENDS:allowed = ", ".join(sorted(SUPPORTED_BACKENDS))raise SystemExit(f"{prefix}_BACKEND must be one of: {allowed}")return {- "agent_backend": backend,+ "agent_backend": backend or None,"opencode_agent": _optional(f"{prefix}_OPENCODE_AGENT"),"opencode_model": _optional(f"{prefix}_OPENCODE_MODEL"),"opencode_reasoning_effort": _optional(f"{prefix}_OPENCODE_REASONING_EFFORT"),@@ -96,100 +104,107 @@ def _build_routing(service_name: str) -> dict:}-def _service_default_cwd(service_name: str) -> str:- prefix = _service_prefix(service_name)- return _env(f"{prefix}_DEFAULT_CWD", _env("THREE_REGRESSION_DEFAULT_CWD", "/data/vibe_remote/workdir"))+def _default_cwd() -> str:+ return _env("THREE_REGRESSION_DEFAULT_CWD", "/data/vibe_remote/workdir")def _ui_host() -> str:return _env("THREE_REGRESSION_UI_HOST", "127.0.0.1")-def _base_slack_payload() -> dict:+def _build_slack_payload() -> dict:+ prefix = _platform_prefix("slack")+ require_mention = _parse_bool(_env(f"{prefix}_REQUIRE_MENTION"), default=False)return {- "bot_token": "",- "app_token": None,+ "bot_token": _env("THREE_REGRESSION_SLACK_BOT_TOKEN"),+ "app_token": _env("THREE_REGRESSION_SLACK_APP_TOKEN") or None,"signing_secret": None,"team_id": None,"team_name": None,"app_id": None,- "require_mention": False,+ "require_mention": require_mention,}-def _build_config_payload(service_name: str) -> dict:- service = SERVICE_DEFS[service_name]- prefix = _service_prefix(service_name)- routing = _build_routing(service_name)- backend = routing["agent_backend"]+def _build_discord_payload() -> dict:+ prefix = _platform_prefix("discord")require_mention = _parse_bool(_env(f"{prefix}_REQUIRE_MENTION"), default=False)+ return {+ "bot_token": _env("THREE_REGRESSION_DISCORD_BOT_TOKEN"),+ "application_id": None,+ "guild_allowlist": _parse_csv(_optional("THREE_REGRESSION_DISCORD_GUILD_ALLOWLIST")),+ "guild_denylist": _parse_csv(_optional("THREE_REGRESSION_DISCORD_GUILD_DENYLIST")),+ "require_mention": require_mention,+ }+++def _build_lark_payload() -> dict:+ prefix = _platform_prefix("feishu")+ require_mention = _parse_bool(_env(f"{prefix}_REQUIRE_MENTION"), default=False)+ return {+ "app_id": _env("THREE_REGRESSION_FEISHU_APP_ID"),+ "app_secret": _env("THREE_REGRESSION_FEISHU_APP_SECRET"),+ "require_mention": require_mention,+ "domain": _env("THREE_REGRESSION_FEISHU_DOMAIN", "feishu"),+ }+++def _build_wechat_payload() -> dict:+ prefix = _platform_prefix("wechat")+ require_mention = _parse_bool(_env(f"{prefix}_REQUIRE_MENTION"), default=False)+ return {+ "bot_token": _env("THREE_REGRESSION_WECHAT_BOT_TOKEN"),+ "base_url": _env("THREE_REGRESSION_WECHAT_BASE_URL", "https://ilinkai.weixin.qq.com"),+ "cdn_base_url": _env("THREE_REGRESSION_WECHAT_CDN_BASE_URL", "https://novac2c.cdn.weixin.qq.com/c2c"),+ "require_mention": require_mention,+ }- slack_payload = _base_slack_payload()- discord_payload = None- lark_payload = None- wechat_payload = None-- if service_name == "slack":- slack_payload = {- **slack_payload,- "bot_token": _env("THREE_REGRESSION_SLACK_BOT_TOKEN"),- "app_token": _env("THREE_REGRESSION_SLACK_APP_TOKEN"),- "require_mention": require_mention,- }- elif service_name == "discord":- discord_payload = {- "bot_token": _env("THREE_REGRESSION_DISCORD_BOT_TOKEN"),- "application_id": None,- "guild_allowlist": _parse_csv(_optional("THREE_REGRESSION_DISCORD_GUILD_ALLOWLIST")),- "guild_denylist": _parse_csv(_optional("THREE_REGRESSION_DISCORD_GUILD_DENYLIST")),- "require_mention": require_mention,- }- elif service_name == "feishu":- lark_payload = {- "app_id": _env("THREE_REGRESSION_FEISHU_APP_ID"),- "app_secret": _env("THREE_REGRESSION_FEISHU_APP_SECRET"),- "require_mention": require_mention,- "domain": _env("THREE_REGRESSION_FEISHU_DOMAIN", "feishu"),- }- elif service_name == "wechat":- wechat_payload = {- "bot_token": _env("THREE_REGRESSION_WECHAT_BOT_TOKEN"),- "base_url": _env("THREE_REGRESSION_WECHAT_BASE_URL", "https://ilinkai.weixin.qq.com"),- "cdn_base_url": _env("THREE_REGRESSION_WECHAT_CDN_BASE_URL", "https://novac2c.cdn.weixin.qq.com/c2c"),- "require_mention": require_mention,- }+def _default_backend() -> str:+ backend = _env("THREE_REGRESSION_DEFAULT_BACKEND", "opencode")+ if backend not in SUPPORTED_BACKENDS:+ allowed = ", ".join(sorted(SUPPORTED_BACKENDS))+ raise SystemExit(f"THREE_REGRESSION_DEFAULT_BACKEND must be one of: {allowed}")+ return backend+++def _build_config_payload() -> dict:+ """Build a unified config.json with all four platforms and all three backends."""return {- "platform": service["platform"],+ "platforms": {+ "enabled": ["slack", "discord", "lark", "wechat"],+ "primary": "slack",+ },+ "platform": "slack","mode": "self_host","version": "v2",- "slack": slack_payload,- "discord": discord_payload,- "lark": lark_payload,- "wechat": wechat_payload,+ "slack": _build_slack_payload(),+ "discord": _build_discord_payload(),+ "lark": _build_lark_payload(),+ "wechat": _build_wechat_payload(),"runtime": {- "default_cwd": _service_default_cwd(service_name),+ "default_cwd": _default_cwd(),"log_level": _env("THREE_REGRESSION_LOG_LEVEL", "INFO"),},"agents": {- "default_backend": backend,+ "default_backend": _default_backend(),"opencode": {"enabled": True,"cli_path": "opencode",- "default_agent": routing["opencode_agent"],- "default_model": routing["opencode_model"],- "default_reasoning_effort": routing["opencode_reasoning_effort"],+ "default_agent": _optional("THREE_REGRESSION_OPENCODE_AGENT"),+ "default_model": _optional("THREE_REGRESSION_OPENCODE_MODEL"),+ "default_reasoning_effort": _optional("THREE_REGRESSION_OPENCODE_REASONING_EFFORT"),"error_retry_limit": 1,},"claude": {"enabled": True,"cli_path": "claude",- "default_model": routing["claude_model"],+ "default_model": _optional("THREE_REGRESSION_CLAUDE_MODEL"),},"codex": {"enabled": True,"cli_path": "codex",- "default_model": routing["codex_model"],+ "default_model": _optional("THREE_REGRESSION_CODEX_MODEL"),},},"gateway": None,@@ -212,39 +227,41 @@ def _build_config_payload(service_name: str) -> dict:}-def _build_settings_payload(service_name: str) -> dict:- service = SERVICE_DEFS[service_name]- channel_id = _env(service["channel_env"])- routing = _build_routing(service_name)- channel_scope = {}-- if channel_id:- channel_scope[channel_id] = {- "enabled": True,- "show_message_types": ["assistant"],- "custom_cwd": _service_default_cwd(service_name),- "routing": routing,- "require_mention": _parse_bool(- _env(f"{_service_prefix(service_name)}_REQUIRE_MENTION"),- default=False,- ),- }+def _build_settings_payload() -> dict:+ """Build a unified settings.json with per-channel routing for every platform."""+ channel_scopes: dict[str, dict] = {}++ for name, pdef in PLATFORM_DEFS.items():+ platform_key = pdef["platform"]+ channel_id = _env(pdef["channel_env"])+ routing = _build_routing(name)+ scope: dict = {}++ if channel_id and routing["agent_backend"]:+ prefix = _platform_prefix(name)+ scope[channel_id] = {+ "enabled": True,+ "show_message_types": ["assistant"],+ "custom_cwd": _default_cwd(),+ "routing": routing,+ "require_mention": _parse_bool(+ _env(f"{prefix}_REQUIRE_MENTION"),+ default=False,+ ),+ }++ channel_scopes[platform_key] = scopereturn {"schema_version": 3,"scopes": {- "channel": {service["platform"]: channel_scope},+ "channel": channel_scopes,"user": {},},"bind_codes": [],}-def _summary_channel(service: dict) -> str:- channel = _env(service["channel_env"])- return channel or "(configure later in UI)"--def _write_json(path: Path, payload: dict) -> None:path.parent.mkdir(parents=True, exist_ok=True)path.write_text(json.dumps(payload, indent=2), encoding="utf-8")@@ -255,21 +272,21 @@ def _write_text(path: Path, content: str) -> None:path.write_text(content, encoding="utf-8")-def _ensure_service_dir(service_dir: Path, reset_mode: str = "none") -> None:+def _ensure_vibe_dir(vibe_dir: Path, reset_mode: str = "none") -> None:if reset_mode not in RESET_MODES:allowed = ", ".join(sorted(RESET_MODES))raise SystemExit(f"reset_mode must be one of: {allowed}")- if reset_mode == "all" and service_dir.exists():- shutil.rmtree(service_dir)- elif reset_mode == "config" and service_dir.exists():+ if reset_mode == "all" and vibe_dir.exists():+ shutil.rmtree(vibe_dir)+ elif reset_mode == "config" and vibe_dir.exists():for subdir in ("config", "state", "runtime"):- target = service_dir / subdir+ target = vibe_dir / subdirif target.exists():shutil.rmtree(target)for subdir in ("config", "state", "logs", "runtime", "attachments", "workdir"):- (service_dir / subdir).mkdir(parents=True, exist_ok=True)+ (vibe_dir / subdir).mkdir(parents=True, exist_ok=True)def _build_claude_settings_payload() -> dict:@@ -390,37 +407,37 @@ def _write_shared_agent_configs(output_root: Path) -> None:def prepare(output_root: Path, reset_mode: str = "none") -> None:_require_envs(("ANTHROPIC_API_KEY", "OPENAI_API_KEY"))++ # Validate platform-specific required env vars+ for name, pdef in PLATFORM_DEFS.items():+ _require_envs(pdef["required_envs"])+_write_shared_agent_configs(output_root)- summary: list[str] = []- for service_name, service in SERVICE_DEFS.items():- _require_envs(service["required_envs"])- service_dir = output_root / service_name- _ensure_service_dir(service_dir, reset_mode=reset_mode)-- config_path = service_dir / "config" / "config.json"- settings_path = service_dir / "state" / "settings.json"- sessions_path = service_dir / "state" / "sessions.json"-- if reset_mode in {"config", "all"} or not config_path.exists():- _write_json(config_path, _build_config_payload(service_name))- if reset_mode in {"config", "all"} or not settings_path.exists():- _write_json(settings_path, _build_settings_payload(service_name))- if reset_mode in {"config", "all"} or not sessions_path.exists():- _write_json(sessions_path, {})-- summary.append(- "- {service}: platform={platform} channel={channel} backend={backend} state={state}".format(- service=service_name,- platform=service["platform"],- channel=_summary_channel(service),- backend=_env(f"{_service_prefix(service_name)}_BACKEND"),- state=reset_mode if reset_mode != "none" else "preserved",- )- )-- print(f"Prepared three-end regression state under {output_root}")- print("\n".join(summary))+ vibe_dir = output_root / "vibe"+ _ensure_vibe_dir(vibe_dir, reset_mode=reset_mode)++ config_path = vibe_dir / "config" / "config.json"+ settings_path = vibe_dir / "state" / "settings.json"+ sessions_path = vibe_dir / "state" / "sessions.json"++ if reset_mode in {"config", "all"} or not config_path.exists():+ _write_json(config_path, _build_config_payload())+ if reset_mode in {"config", "all"} or not settings_path.exists():+ _write_json(settings_path, _build_settings_payload())+ if reset_mode in {"config", "all"} or not sessions_path.exists():+ _write_json(sessions_path, {})++ summary_lines: list[str] = []+ for name, pdef in PLATFORM_DEFS.items():+ channel = _env(pdef["channel_env"]) or "(configure later in UI)"+ 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("Platform routing:")+ print("\n".join(summary_lines))+ print(f"State: {reset_mode if reset_mode != 'none' else 'preserved'}")def main() -> int:@@ -428,7 +445,7 @@ def main() -> int:parser.add_argument("--output-root",default=str(Path("_tmp") / "three-regression"),- help="Directory that will hold generated per-service state",+ help="Directory that will hold generated state",)parser.add_argument("--reset-mode",diff --git a/scripts/run_three_regression.sh b/scripts/run_three_regression.shindex 424958608..2a8c2ec00 100755--- a/scripts/run_three_regression.sh+++ b/scripts/run_three_regression.sh@@ -42,7 +42,6 @@ resolve_docker_binMODE="up"BUILD_FLAG="--build"-LOGS_SERVICE=""RESET_MODE="none"usage() {@@ -54,7 +53,7 @@ Usage:./scripts/run_three_regression.sh --reset-all./scripts/run_three_regression.sh --down./scripts/run_three_regression.sh --status- ./scripts/run_three_regression.sh --logs [slack|discord|feishu|wechat]+ ./scripts/run_three_regression.sh --logs./scripts/run_three_regression.sh --env-file /path/to/.env.three-regressionEOF}@@ -80,12 +79,7 @@ while [ $# -gt 0 ]; do;;--logs)MODE="logs"- if [ $# -gt 1 ] && [[ "$2" != --* ]]; then- LOGS_SERVICE="$2"- shift 2- else- shift- fi+ shift;;--no-build)BUILD_FLAG=""@@ -136,37 +130,35 @@ elif [ "$MODE" = "up" ]; thenfiprint_summary() {+ local port="${THREE_REGRESSION_PORT:-15130}"+ local ui_host="${THREE_REGRESSION_UI_HOST:-127.0.0.1}"+ local default_backend="${THREE_REGRESSION_DEFAULT_BACKEND:-opencode}"+local slack_channel="${THREE_REGRESSION_SLACK_CHANNEL:-}"local discord_channel="${THREE_REGRESSION_DISCORD_CHANNEL:-}"local feishu_channel="${THREE_REGRESSION_FEISHU_CHAT_ID:-}"local wechat_channel="${THREE_REGRESSION_WECHAT_CHANNEL:-}"- local ui_host="${THREE_REGRESSION_UI_HOST:-127.0.0.1}"- if [ -z "$slack_channel" ]; then- slack_channel="(configure later in UI)"- fi- if [ -z "$discord_channel" ]; then- discord_channel="(configure later in UI)"- fi- if [ -z "$feishu_channel" ]; then- feishu_channel="(configure later in UI)"- fi- if [ -z "$wechat_channel" ]; then- wechat_channel="(QR login required in UI)"- fi+ [ -z "$slack_channel" ] && slack_channel="(configure later in UI)"+ [ -z "$discord_channel" ] && discord_channel="(configure later in UI)"+ [ -z "$feishu_channel" ] && feishu_channel="(configure later in UI)"+ [ -z "$wechat_channel" ] && wechat_channel="(QR login required in UI)"cat <<EOF-Four-platform regression environment is ready:-- Slack: http://${ui_host}:${THREE_REGRESSION_SLACK_PORT:-15131} channel=${slack_channel} backend=${THREE_REGRESSION_SLACK_BACKEND}-- Discord: http://${ui_host}:${THREE_REGRESSION_DISCORD_PORT:-15132} channel=${discord_channel} backend=${THREE_REGRESSION_DISCORD_BACKEND}-- Feishu: http://${ui_host}:${THREE_REGRESSION_FEISHU_PORT:-15133} channel=${feishu_channel} backend=${THREE_REGRESSION_FEISHU_BACKEND}-- WeChat: http://${ui_host}:${THREE_REGRESSION_WECHAT_PORT:-15134} channel=${wechat_channel} backend=${THREE_REGRESSION_WECHAT_BACKEND:-opencode}+Unified regression environment is ready:+ URL: http://${ui_host}:${port}+ Default backend: ${default_backend}++ Platform routing:+ - Slack: channel=${slack_channel} backend=${THREE_REGRESSION_SLACK_BACKEND:-${default_backend}}+ - Discord: channel=${discord_channel} backend=${THREE_REGRESSION_DISCORD_BACKEND:-${default_backend}}+ - Feishu: channel=${feishu_channel} backend=${THREE_REGRESSION_FEISHU_BACKEND:-${default_backend}}+ - WeChat: channel=${wechat_channel} backend=${THREE_REGRESSION_WECHAT_BACKEND:-${default_backend}}EOF}wait_for_service() {- local service="$1"- local port="$2"+ local port="$1"local url="http://127.0.0.1:${port}"for _ in $(seq 1 60); do@@ -177,8 +169,8 @@ wait_for_service() {sleep 2done- echo "Service $service did not become ready on port $port" >&2- "$DOCKER_BIN" compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" logs "$service" || true+ echo "Service did not become ready on port $port" >&2+ "$DOCKER_BIN" compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" logs vibe || truereturn 1}@@ -195,16 +187,12 @@ case "$MODE" inexit 0;;logs)- if [ -n "$LOGS_SERVICE" ]; then- "$DOCKER_BIN" compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" logs -f "$LOGS_SERVICE"- else- "$DOCKER_BIN" compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" logs -f- fi+ "$DOCKER_BIN" compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" logs -f vibeexit 0;;esac-echo "Stopping previous three-end regression containers..."+echo "Stopping previous regression container...""$DOCKER_BIN" compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" down --remove-orphans >/dev/null 2>&1 || trueecho "Preparing generated config and state..."@@ -212,17 +200,14 @@ PREPARE_ARGS=(--output-root "$OUTPUT_ROOT")PREPARE_ARGS+=(--reset-mode "$RESET_MODE")"$PYTHON_BIN" "$REPO_ROOT/scripts/prepare_three_regression.py" "${PREPARE_ARGS[@]}"-echo "Starting three-end regression containers..."+echo "Starting unified regression container..."if [ -n "$BUILD_FLAG" ]; then"$DOCKER_BIN" compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" up -d --build --force-recreate --remove-orphanselse"$DOCKER_BIN" compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" up -d --force-recreate --remove-orphansfi-echo "Waiting for services to become healthy..."-wait_for_service slack "${THREE_REGRESSION_SLACK_PORT:-15131}"-wait_for_service discord "${THREE_REGRESSION_DISCORD_PORT:-15132}"-wait_for_service feishu "${THREE_REGRESSION_FEISHU_PORT:-15133}"-wait_for_service wechat "${THREE_REGRESSION_WECHAT_PORT:-15134}"+echo "Waiting for service to become healthy..."+wait_for_service "${THREE_REGRESSION_PORT:-15130}"print_summarydiff --git a/tests/test_prepare_three_regression.py b/tests/test_prepare_three_regression.pyindex be83bb86b..5bd42100a 100644--- a/tests/test_prepare_three_regression.py+++ b/tests/test_prepare_three_regression.py@@ -25,6 +25,7 @@ def _set_required_env(monkeypatch: pytest.MonkeyPatch) -> None:"OPENAI_API_BASE": "https://openai.example/v1","THREE_REGRESSION_UI_HOST": "192.168.2.3","THREE_REGRESSION_DEFAULT_CWD": "/data/vibe_remote/workdir",+ "THREE_REGRESSION_DEFAULT_BACKEND": "opencode","THREE_REGRESSION_LOG_LEVEL": "DEBUG","THREE_REGRESSION_LANGUAGE": "en","THREE_REGRESSION_CLAUDE_BASE_URL": "https://ai-relay.example",@@ -51,30 +52,54 @@ def _set_required_env(monkeypatch: pytest.MonkeyPatch) -> None:"THREE_REGRESSION_FEISHU_APP_SECRET": "test-app-secret","THREE_REGRESSION_FEISHU_CHAT_ID": "oc_test_chat_id","THREE_REGRESSION_FEISHU_BACKEND": "claude",+ "THREE_REGRESSION_WECHAT_BACKEND": "opencode",}for key, value in values.items():monkeypatch.setenv(key, value)-def test_prepare_generates_three_isolated_states(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):+def test_prepare_generates_unified_state(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):module = _load_module()_set_required_env(monkeypatch)module.prepare(tmp_path)- slack_config = json.loads((tmp_path / "slack" / "config" / "config.json").read_text(encoding="utf-8"))- discord_config = json.loads((tmp_path / "discord" / "config" / "config.json").read_text(encoding="utf-8"))- feishu_settings = json.loads((tmp_path / "feishu" / "state" / "settings.json").read_text(encoding="utf-8"))-- assert slack_config["platform"] == "slack"- assert slack_config["agents"]["default_backend"] == "opencode"- assert slack_config["ui"]["setup_host"] == "192.168.2.3"- assert discord_config["platform"] == "discord"- assert discord_config["agents"]["default_backend"] == "codex"- assert discord_config["discord"]["guild_allowlist"] == ["754776951587340359"]- assert feishu_settings["scopes"]["channel"]["lark"]["oc_test_chat_id"]["routing"]["agent_backend"] == "claude"- assert (tmp_path / "slack" / "workdir").is_dir()- assert (tmp_path / "discord" / "state" / "sessions.json").exists()+ 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"))++ # Unified config has all four platforms enabled+ assert config["platforms"]["enabled"] == ["slack", "discord", "lark", "wechat"]+ assert config["platforms"]["primary"] == "slack"++ # All platform credentials populated+ assert config["slack"]["bot_token"] == "xoxb-test-token"+ assert config["discord"]["bot_token"] == "discord-token-1234567890"+ assert config["discord"]["guild_allowlist"] == ["754776951587340359"]+ assert config["lark"]["app_id"] == "cli_test_app_id"+ assert config["wechat"]["base_url"] == "https://ilinkai.weixin.qq.com"++ # All three backends enabled+ assert config["agents"]["opencode"]["enabled"] is True+ assert config["agents"]["claude"]["enabled"] is True+ assert config["agents"]["codex"]["enabled"] is True+ assert config["agents"]["default_backend"] == "opencode"++ # UI host propagated+ assert config["ui"]["setup_host"] == "192.168.2.3"++ # Per-channel routing in settings for each platform+ assert settings["scopes"]["channel"]["slack"]["C123SLACK"]["routing"]["agent_backend"] == "opencode"+ assert settings["scopes"]["channel"]["discord"]["123456789012345678"]["routing"]["agent_backend"] == "codex"+ assert settings["scopes"]["channel"]["lark"]["oc_test_chat_id"]["routing"]["agent_backend"] == "claude"++ # WeChat has no channel set, so scope is empty+ assert settings["scopes"]["channel"]["wechat"] == {}++ # Directory structure+ assert (tmp_path / "vibe" / "workdir").is_dir()+ assert (tmp_path / "vibe" / "state" / "sessions.json").exists()++ # Shared agent home configsassert (json.loads((tmp_path / "shared-home" / ".claude" / "settings.json").read_text(encoding="utf-8"))["env"]["ANTHROPIC_AUTH_TOKEN"@@ -95,18 +120,18 @@ def test_prepare_preserves_existing_state_without_reset(tmp_path: Path, monkeypamodule = _load_module()_set_required_env(monkeypatch)- service_dir = tmp_path / "slack"- (service_dir / "config").mkdir(parents=True)- (service_dir / "state").mkdir(parents=True)- (service_dir / "config" / "config.json").write_text('{"keep": true}', encoding="utf-8")- (service_dir / "state" / "settings.json").write_text('{"custom": true}', encoding="utf-8")- (service_dir / "state" / "sessions.json").write_text('{"session": true}', encoding="utf-8")+ vibe_dir = tmp_path / "vibe"+ (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")module.prepare(tmp_path)- assert json.loads((service_dir / "config" / "config.json").read_text(encoding="utf-8")) == {"keep": True}- assert json.loads((service_dir / "state" / "settings.json").read_text(encoding="utf-8")) == {"custom": True}- assert json.loads((service_dir / "state" / "sessions.json").read_text(encoding="utf-8")) == {"session": True}+ assert json.loads((vibe_dir / "config" / "config.json").read_text(encoding="utf-8")) == {"keep": True}+ assert json.loads((vibe_dir / "state" / "settings.json").read_text(encoding="utf-8")) == {"custom": True}+ assert json.loads((vibe_dir / "state" / "sessions.json").read_text(encoding="utf-8")) == {"session": True}def test_prepare_allows_missing_channel_ids(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):@@ -115,16 +140,15 @@ def test_prepare_allows_missing_channel_ids(tmp_path: Path, monkeypatch: pytest.monkeypatch.delenv("THREE_REGRESSION_SLACK_CHANNEL", raising=False)monkeypatch.delenv("THREE_REGRESSION_DISCORD_CHANNEL", raising=False)monkeypatch.delenv("THREE_REGRESSION_FEISHU_CHAT_ID", raising=False)+ monkeypatch.delenv("THREE_REGRESSION_WECHAT_CHANNEL", raising=False)module.prepare(tmp_path, reset_mode="config")- slack_settings = json.loads((tmp_path / "slack" / "state" / "settings.json").read_text(encoding="utf-8"))- discord_settings = json.loads((tmp_path / "discord" / "state" / "settings.json").read_text(encoding="utf-8"))- feishu_settings = json.loads((tmp_path / "feishu" / "state" / "settings.json").read_text(encoding="utf-8"))-- assert slack_settings["scopes"]["channel"]["slack"] == {}- assert discord_settings["scopes"]["channel"]["discord"] == {}- assert feishu_settings["scopes"]["channel"]["lark"] == {}+ settings = json.loads((tmp_path / "vibe" / "state" / "settings.json").read_text(encoding="utf-8"))+ assert settings["scopes"]["channel"]["slack"] == {}+ assert settings["scopes"]["channel"]["discord"] == {}+ assert settings["scopes"]["channel"]["lark"] == {}+ assert settings["scopes"]["channel"]["wechat"] == {}def test_prepare_requires_supported_backend(monkeypatch: pytest.MonkeyPatch, tmp_path: Path):@@ -140,10 +164,10 @@ def test_prepare_reset_config_preserves_workdir(tmp_path: Path, monkeypatch: pytmodule = _load_module()_set_required_env(monkeypatch)- workdir = tmp_path / "discord" / "workdir"+ workdir = tmp_path / "vibe" / "workdir"workdir.mkdir(parents=True)(workdir / "keep.txt").write_text("keep-me", encoding="utf-8")- config_dir = tmp_path / "discord" / "config"+ config_dir = tmp_path / "vibe" / "config"config_dir.mkdir(parents=True)(config_dir / "config.json").write_text('{"stale": true}', encoding="utf-8")@@ -151,17 +175,41 @@ def test_prepare_reset_config_preserves_workdir(tmp_path: Path, monkeypatch: pytassert (workdir / "keep.txt").read_text(encoding="utf-8") == "keep-me"refreshed = json.loads((config_dir / "config.json").read_text(encoding="utf-8"))- assert refreshed["agents"]["default_backend"] == "codex"+ assert refreshed["agents"]["default_backend"] == "opencode"def test_prepare_reset_all_clears_workdir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):module = _load_module()_set_required_env(monkeypatch)- workdir = tmp_path / "discord" / "workdir"+ workdir = tmp_path / "vibe" / "workdir"workdir.mkdir(parents=True)(workdir / "drop.txt").write_text("remove-me", encoding="utf-8")module.prepare(tmp_path, reset_mode="all")assert not (workdir / "drop.txt").exists()+++def test_prepare_default_backend_from_env(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):+ module = _load_module()+ _set_required_env(monkeypatch)+ monkeypatch.setenv("THREE_REGRESSION_DEFAULT_BACKEND", "claude")++ module.prepare(tmp_path, reset_mode="config")++ config = json.loads((tmp_path / "vibe" / "config" / "config.json").read_text(encoding="utf-8"))+ assert config["agents"]["default_backend"] == "claude"+++def test_prepare_all_platform_channel_routing(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):+ module = _load_module()+ _set_required_env(monkeypatch)+ monkeypatch.setenv("THREE_REGRESSION_WECHAT_CHANNEL", "wx_test_room")+ monkeypatch.setenv("THREE_REGRESSION_WECHAT_BACKEND", "codex")++ module.prepare(tmp_path, reset_mode="config")++ settings = json.loads((tmp_path / "vibe" / "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"