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
feat(opencode): default to OpenCode and refresh routing docs
cyhhao3ff382218b3c
diff --git a/.env.example b/.env.exampleindex 43063e174..a8590bd3b 100644--- a/.env.example+++ b/.env.example@@ -33,7 +33,11 @@ TELEGRAM_TARGET_CHAT_ID=[]# Claude ConfigurationCLAUDE_PERMISSION_MODE=bypassPermissions-CLAUDE_DEFAULT_CWD=./_tmp++# Default working directory for all agents (recommended)+AGENT_DEFAULT_CWD=./_tmp+# Legacy alias (still supported):+# CLAUDE_DEFAULT_CWD=./_tmp# Optional: Custom system promptCLAUDE_SYSTEM_PROMPT=diff --git a/AGENTS.md b/AGENTS.mdindex 9c5688728..5f09bded1 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -43,11 +43,11 @@ This file defines how coding agents should work in this repository.- Entry point: `main.py` wires `config.AppConfig` into `core/controller.py`.- Core orchestration and handlers: `core/` (notably `core/handlers/`).-- Agent backends: `modules/agents/` (shared base, Claude/Codex backends, registry).+- Agent backends: `modules/agents/` (shared base, OpenCode/Claude/Codex backends, registry).- IM transports: `modules/im/` (Slack/Telegram).- Config:- Defaults and validation: `config/` (see `config/settings.py`).- - Agent routing: `agent_routes.example.yaml` (template) and local `agent_routes.yaml` (gitignored).+ - Agent routing: optional local `agent_routes.yaml` (gitignored).- Runtime data:- Logs: `logs/vibe_remote.log`.- Persisted state: `user_settings.json`.@@ -78,16 +78,17 @@ This file defines how coding agents should work in this repository.- For IM integrations, stub Slack/Telegram clients and validate outbound payload schemas.- Do a manual E2E sanity check (start bot, send `/start`) until CI exists.-### Agent Routing / Codex+### Agent Routing-- Codex enablement: `CODEX_ENABLED=true` and `CODEX_CLI_PATH` points to the CLI.+- OpenCode enablement: `OPENCODE_ENABLED=true` (default: false) and `OPENCODE_CLI_PATH` points to the CLI.+- Codex enablement: `CODEX_ENABLED=true` (default: true) and `CODEX_CLI_PATH` points to the CLI.- Routing file:- - Copy `agent_routes.example.yaml` to `agent_routes.yaml` (local).+ - Create `agent_routes.yaml` (local) only if you prefer file-based routing (legacy).- Controlled by `AGENT_ROUTE_FILE` (defaults to repo-root `agent_routes.yaml`).- - Keys are Slack channel IDs / Telegram chat IDs; values are agent names (e.g., `claude`, `codex`).+ - Keys are Slack channel IDs / Telegram chat IDs; values are agent names (e.g., `opencode`, `claude`, `codex`).- Missing entries fall back to platform default, then to global default.### Safety Notes-- Keep `CLAUDE_DEFAULT_CWD` scoped to `_tmp/` (or another sanitized directory).+- Keep `AGENT_DEFAULT_CWD` scoped to `_tmp/` (or another sanitized directory).- Logs can contain sensitive context; scrub before sharing.diff --git a/CLAUDE.md b/CLAUDE.mdindex 9c5688728..5f09bded1 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -43,11 +43,11 @@ This file defines how coding agents should work in this repository.- Entry point: `main.py` wires `config.AppConfig` into `core/controller.py`.- Core orchestration and handlers: `core/` (notably `core/handlers/`).-- Agent backends: `modules/agents/` (shared base, Claude/Codex backends, registry).+- Agent backends: `modules/agents/` (shared base, OpenCode/Claude/Codex backends, registry).- IM transports: `modules/im/` (Slack/Telegram).- Config:- Defaults and validation: `config/` (see `config/settings.py`).- - Agent routing: `agent_routes.example.yaml` (template) and local `agent_routes.yaml` (gitignored).+ - Agent routing: optional local `agent_routes.yaml` (gitignored).- Runtime data:- Logs: `logs/vibe_remote.log`.- Persisted state: `user_settings.json`.@@ -78,16 +78,17 @@ This file defines how coding agents should work in this repository.- For IM integrations, stub Slack/Telegram clients and validate outbound payload schemas.- Do a manual E2E sanity check (start bot, send `/start`) until CI exists.-### Agent Routing / Codex+### Agent Routing-- Codex enablement: `CODEX_ENABLED=true` and `CODEX_CLI_PATH` points to the CLI.+- OpenCode enablement: `OPENCODE_ENABLED=true` (default: false) and `OPENCODE_CLI_PATH` points to the CLI.+- Codex enablement: `CODEX_ENABLED=true` (default: true) and `CODEX_CLI_PATH` points to the CLI.- Routing file:- - Copy `agent_routes.example.yaml` to `agent_routes.yaml` (local).+ - Create `agent_routes.yaml` (local) only if you prefer file-based routing (legacy).- Controlled by `AGENT_ROUTE_FILE` (defaults to repo-root `agent_routes.yaml`).- - Keys are Slack channel IDs / Telegram chat IDs; values are agent names (e.g., `claude`, `codex`).+ - Keys are Slack channel IDs / Telegram chat IDs; values are agent names (e.g., `opencode`, `claude`, `codex`).- Missing entries fall back to platform default, then to global default.### Safety Notes-- Keep `CLAUDE_DEFAULT_CWD` scoped to `_tmp/` (or another sanitized directory).+- Keep `AGENT_DEFAULT_CWD` scoped to `_tmp/` (or another sanitized directory).- Logs can contain sensitive context; scrub before sharing.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 1d7ca0a6b..42ab36336 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -14,7 +14,7 @@ Thanks for your interest in contributing!- Run locally: `python main.py`- Lint before PR (add your linter if used)- Write clear commit messages-- Codex-specific changes: install the Codex CLI, copy `agent_routes.example.yaml` → `agent_routes.yaml`, and route one Slack channel / Telegram chat to `codex` for manual testing (see `docs/CODEX_SETUP.md`).+- Agent-specific changes: install the relevant CLI (recommended: OpenCode `opencode`; also supported: Codex), then route one Slack channel via Slack **Agent Settings**, or (legacy) create `agent_routes.yaml`, to manually test the backend (`opencode` or `codex`).## Pull Requestsdiff --git a/README.md b/README.mdindex 8b1dae0f4..f28b89974 100644--- a/README.md+++ b/README.md@@ -17,7 +17,7 @@</div>-_Remote vibe coding over chat — control AI coding agents (Claude Code, Codex, Cursor, etc.) from Slack/Telegram._+_Remote vibe coding over chat — control AI coding agents (OpenCode, Claude Code, Codex, Cursor, etc.) from Slack/Telegram._Vibe Remote lets you operate coding agents via IM. Type in Slack or Telegram to start and steer agents; describe intent and constraints, receive streaming results, and ship without being tied to a local IDE.@@ -25,8 +25,8 @@ Vibe Remote lets you operate coding agents via IM. Type in Slack or Telegram to- **Vibe coding, not micromanaging**: Let AI drive based on your intent and constraints; focus on outcomes.- **Work from anywhere**: Control coding sessions over Slack/Telegram; no IDE tether.-- **Extensible by design**: Starts with Claude Code and Codex, built to support additional coding agents/CLIs.-- **Multi-agent routing**: Route each Slack channel / Telegram chat to Claude Code or Codex by editing `agent_routes.yaml`.+- **Extensible by design**: OpenCode-first, and also supports Claude Code + Codex; built to support additional coding agents/CLIs.+- **Multi-agent routing**: Route each Slack channel / Telegram chat to OpenCode, Claude Code, or Codex via `agent_routes.yaml` (and Slack UI when enabled).- **Session persistence by thread + path**: Each Slack thread/Telegram chat maintains its own agent session and working dir; auto‑resume via saved mappings.- **Interactive Slack UX**: `/start` menu + Settings/CWD modals; buttons over commands for faster flow.@@ -49,7 +49,32 @@ Vibe Remote lets you operate coding agents via IM. Type in Slack or Telegram to## Prerequisites-- At least one coding agent CLI installed (Claude Code CLI or Codex CLI). You can install both to mix and match per channel.+- At least one coding agent CLI installed. Recommended: OpenCode (`opencode`). Also supported: Claude Code CLI and Codex CLI.++### OpenCode (Recommended)++Install (Homebrew):++```bash+brew install opencode+```++Install (script):++```bash+curl -fsSL https://opencode.ai/install | bash+```++Verify:++```bash+opencode --help+```++Enable in Vibe Remote:++- `OPENCODE_ENABLED=true`+- Optional: `OPENCODE_CLI_PATH=opencode`, `OPENCODE_PORT=4096`### Claude Code@@ -107,7 +132,8 @@ python main.py### Claude Code-- `CLAUDE_DEFAULT_CWD` e.g. `./_tmp`+- `AGENT_DEFAULT_CWD` e.g. `./_tmp` (recommended)+- Legacy alias: `CLAUDE_DEFAULT_CWD` (still supported)- `CLAUDE_PERMISSION_MODE` e.g. `bypassPermissions`- `CLAUDE_SYSTEM_PROMPT` optional- `ANTHROPIC_API_KEY` if required by your SDK setup@@ -118,27 +144,34 @@ python main.py- `CODEX_ENABLED=true` (default) enables the agent; set to false only if the Codex CLI is unavailable. `CODEX_CLI_PATH` overrides the binary path.- `CODEX_DEFAULT_MODEL` / `CODEX_EXTRA_ARGS` customize the underlying model or flags.+### OpenCode++- OpenCode is enabled by `OPENCODE_ENABLED=true` (default: false). Ensure `opencode` is installed.+- OpenCode runs as a local HTTP server started by Vibe Remote (`opencode serve --hostname=127.0.0.1 --port=4096`).+- Default agent/model settings are read from `~/.config/opencode/opencode.json`, and can be overridden per Slack channel via the Agent Settings dialog (if you use Slack).+### Agent routing-- Copy `agent_routes.example.yaml` → `agent_routes.yaml` (repository root) to configure per-channel routing, or point `AGENT_ROUTE_FILE` to any YAML/JSON file.-- File schema:+- Slack: use the built-in **Agent Settings** dialog to select the backend per channel (recommended).+- Legacy (for backward compatibility): file-based routing via `agent_routes.yaml`.+ - Place `agent_routes.yaml` in the repo root, or point `AGENT_ROUTE_FILE` to any YAML/JSON file.+ - File schema:```yaml-default: claude+default: opencodeslack:- default: claude+ default: opencodeoverrides:C01EXAMPLE: codextelegram:- default: claude+ default: opencodeoverrides:"123456789": codex```-- Slack routes use channel IDs; Telegram routes use chat IDs. Unlisted channels fall back to the per-platform default (then to the global `default`). `agent_routes.yaml` is gitignored so each environment can customize it safely.--- See [docs/CODEX_SETUP.md](docs/CODEX_SETUP.md) for a step‑by‑step guide to installing Codex CLI and configuring routing.-- No file? Everything routes to the global default agent (Claude unless overridden).+- Slack routes use channel IDs; Telegram routes use chat IDs.+- See [docs/CODEX_SETUP.md](docs/CODEX_SETUP.md) for Codex install and routing notes.+- No routing file? If OpenCode is enabled, the bot defaults to OpenCode; otherwise it falls back to Claude.### Appdiff --git a/README_ZH.md b/README_ZH.mdindex 48ff5f2ba..0d5ac0c7d 100644--- a/README_ZH.md+++ b/README_ZH.md@@ -17,7 +17,7 @@</div>-_在 Slack/Telegram 里通过聊天远程操控 AI 代理(如 Claude Code、Codex、Cursor),进行 Vibe Coding。_+_在 Slack/Telegram 里通过聊天远程操控 AI 代理(如 OpenCode、Claude Code、Codex、Cursor),进行 Vibe Coding。_Vibe Remote 把 AI 写代码搬到聊天软件。你在 Slack/Telegram 输入意图与约束,它会驱动相应的 AI agent 执行并反馈;结果实时流式返回,无需本地 IDE,随时随地推进任务。@@ -25,8 +25,8 @@ Vibe Remote 把 AI 写代码搬到聊天软件。你在 Slack/Telegram 输入意- **专注 vibe coding**:基于你的意图与约束让 AI 自主推进,你只把控方向与结果。- **随时随地**:不被 IDE 束缚,直接在 Slack/Telegram 中远程操控编码会话。-- **为扩展而生**:目前已支持 Claude Code + Codex,并可扩展到更多 coding agents/CLIs。-- **多 Agent 路由**:为不同 Slack Channel / Telegram Chat 指定 Agent,互不干扰。+- **为扩展而生**:OpenCode 优先,同时支持 Claude Code + Codex;并可扩展到更多 coding agents/CLIs。+- **多 Agent 路由**:为不同 Slack Channel / Telegram Chat 指定 OpenCode / Claude Code / Codex,互不干扰。- **按线程 + 路径持久化**:每个 Slack 线程/Telegram 对话都维持独立 Agent 会话与工作目录,并通过持久化映射自动恢复。- **Slack 交互式体验**:`/start` 菜单 + Settings/CWD 模态,按钮优先于命令,更快上手。@@ -49,7 +49,32 @@ Vibe Remote 把 AI 写代码搬到聊天软件。你在 Slack/Telegram 输入意## 先决条件-- 至少安装一个 Agent CLI(Claude Code 或 Codex)。建议同时安装,方便在不同频道切换。+- 至少安装一个 Agent CLI。推荐优先使用 OpenCode(`opencode`),同时也支持 Claude Code 与 Codex,方便在不同频道切换。++### OpenCode(推荐)++安装(Homebrew):++```bash+brew install opencode+```++安装(脚本):++```bash+curl -fsSL https://opencode.ai/install | bash+```++验证:++```bash+opencode --help+```++在 Vibe Remote 中启用:++- `OPENCODE_ENABLED=true`+- 可选:`OPENCODE_CLI_PATH=opencode`、`OPENCODE_PORT=4096`### Claude Code@@ -107,7 +132,8 @@ python main.py### Claude Code-- `CLAUDE_DEFAULT_CWD` 例如 `./_tmp`+- `AGENT_DEFAULT_CWD` 例如 `./_tmp`(推荐)+- 兼容别名:`CLAUDE_DEFAULT_CWD`(仍支持)- `CLAUDE_PERMISSION_MODE` 例如 `bypassPermissions`- `CLAUDE_SYSTEM_PROMPT` 可选- `ANTHROPIC_API_KEY`(取决于你的 SDK 设置)@@ -118,25 +144,34 @@ python main.py- `CODEX_ENABLED=true`(默认)启用 Codex;若环境没有 CLI 才需要设为 false。`CODEX_CLI_PATH` 可重定向可执行文件。- `CODEX_DEFAULT_MODEL` / `CODEX_EXTRA_ARGS` 可强制模型或追加命令行参数。+### OpenCode++- 通过 `OPENCODE_ENABLED=true` 启用 OpenCode(默认 false),并确保已安装 `opencode`。+- Vibe Remote 会启动本地 OpenCode HTTP Server(`opencode serve --hostname=127.0.0.1 --port=4096`)。+- OpenCode 的默认 agent/model 配置读取自 `~/.config/opencode/opencode.json`;在 Slack 下也可通过 Agent Settings 对每个 channel 单独覆盖。+### Agent 路由-- 复制 `agent_routes.example.yaml` 为仓库根目录的 `agent_routes.yaml`(或设置 `AGENT_ROUTE_FILE` 指向自定义 YAML/JSON)。-- 示例:+- Slack:推荐直接使用内置的 **Agent Settings** 弹窗,为每个 channel 选择 backend。+- 兼容(为老用户保留):通过 `agent_routes.yaml` 进行文件路由。+ - 将 `agent_routes.yaml` 放在仓库根目录,或用 `AGENT_ROUTE_FILE` 指向任意 YAML/JSON 文件。+ - 示例:```yaml-default: claude+default: opencodeslack:- default: claude+ default: opencodeoverrides:C01EXAMPLE: codextelegram:- default: claude+ default: opencodeoverrides:"123456789": codex```-- Slack 使用频道 ID,Telegram 使用聊天 ID。未命中的频道会落到平台默认值,然后回退到全局 `default`。`agent_routes.yaml` 已被 `.gitignore` 排除,可在不同环境独立配置。-- 若未提供文件,则所有渠道沿用全局默认 Agent(默认是 Claude)。参见 [docs/CODEX_SETUP.md](docs/CODEX_SETUP.md) 获取更完整的 Codex 配置示例。+- Slack 使用频道 ID,Telegram 使用聊天 ID。+- 参见 [docs/CODEX_SETUP.md](docs/CODEX_SETUP.md) 获取 Codex 安装与路由说明。+- 未提供路由文件时:如果启用了 OpenCode,则默认使用 OpenCode;否则回退到 Claude。### 应用diff --git a/agent_routes.example.yaml b/agent_routes.example.yamldeleted file mode 100644index a3f6d8c46..000000000--- a/agent_routes.example.yaml+++ /dev/null@@ -1,11 +0,0 @@-default: claude-slack:- default: claude- overrides:- C01EXAMPLE: codex- C02OPENCODE: opencode-telegram:- default: claude- overrides:- "123456789": codex- "987654321": opencodediff --git a/config/settings.py b/config/settings.pyindex b64422e1a..5eedcd601 100644--- a/config/settings.py+++ b/config/settings.py@@ -75,9 +75,11 @@ class ClaudeConfig:if not permission_mode:raise ValueError("CLAUDE_PERMISSION_MODE environment variable is required")- cwd = os.getenv("CLAUDE_DEFAULT_CWD")+ cwd = os.getenv("AGENT_DEFAULT_CWD") or os.getenv("CLAUDE_DEFAULT_CWD")if not cwd:- raise ValueError("CLAUDE_DEFAULT_CWD environment variable is required")+ raise ValueError(+ "AGENT_DEFAULT_CWD (or legacy CLAUDE_DEFAULT_CWD) environment variable is required"+ )return cls(permission_mode=permission_mode,@@ -205,9 +207,9 @@ class SlackConfig(BaseIMConfig):@dataclassclass AppConfig:platform: str+ claude: ClaudeConfigtelegram: Optional[TelegramConfig] = Noneslack: Optional[SlackConfig] = None- claude: ClaudeConfig = Nonecodex: Optional[CodexConfig] = Noneopencode: Optional[OpenCodeConfig] = Nonelog_level: str = "INFO"diff --git a/core/controller.py b/core/controller.pyindex ead92c09e..6180822eb 100644--- a/core/controller.py+++ b/core/controller.py@@ -86,6 +86,15 @@ class Controller:self.config.agent_route_file, platform=self.config.platform)+ # Default backend preference:+ # If the user didn't provide an agent_routes.yaml, and OpenCode is enabled,+ # make OpenCode the implicit default backend.+ if self.config.opencode and not self.config.agent_route_file:+ self.agent_router.global_default = "opencode"+ platform_route = self.agent_router.platform_routes.get(self.config.platform)+ if platform_route:+ platform_route.default = "opencode"+# Inject settings_manager into SlackBot if it's Slack platformif self.config.platform == "slack":# Import here to avoid circular dependency@@ -243,7 +252,9 @@ class Controller:)# Fall back to static routing- return self.agent_router.resolve(self.config.platform, settings_key)+ resolved = self.agent_router.resolve(self.config.platform, settings_key)++ return resolveddef get_opencode_overrides(self, context: MessageContextdiff --git a/docs/CODEX_SETUP.md b/docs/CODEX_SETUP.mdindex d07219bbb..4beca713e 100644--- a/docs/CODEX_SETUP.md+++ b/docs/CODEX_SETUP.md@@ -1,6 +1,6 @@# Codex Agent Setup-Vibe Remote can route individual Slack channels / Telegram chats to Codex instead of Claude Code. This guide walks through enabling Codex end-to-end.+Vibe Remote can route individual Slack channels / Telegram chats to Codex instead of Claude Code. (OpenCode is also supported and recommended; see README for quick enablement.) This guide walks through enabling Codex end-to-end.## 1. Install and authenticate Codex CLI@@ -27,11 +27,11 @@ No additional flag is required to bypass approvals—the bot always adds `--dang## 3. Route channels to Codex-Copy the example routing file and edit it:+Configure routing (two options):-```bash-cp agent_routes.example.yaml agent_routes.yaml-```+1) Slack: use the **Agent Settings** dialog to switch a channel to Codex.++2) Legacy (file-based): create `agent_routes.yaml` (repo root) or set `AGENT_ROUTE_FILE`.Example contents:diff --git a/docs/TELEGRAM_SETUP.md b/docs/TELEGRAM_SETUP.mdindex f72aa33a3..35d67702d 100644--- a/docs/TELEGRAM_SETUP.md+++ b/docs/TELEGRAM_SETUP.md@@ -80,10 +80,12 @@ IM_PLATFORM=telegramTELEGRAM_BOT_TOKEN=your-bot-token-here# Optional: Whitelist specific chat IDs (null = all chats allowed)-TELEGRAM_CHAT_ID=[-1001234567890,987654321]+TELEGRAM_TARGET_CHAT_ID=[-1001234567890,987654321]# Default working directory for the coding agent-CLAUDE_CWD=/path/to/your/project+AGENT_DEFAULT_CWD=/path/to/your/project+# Legacy alias (still supported):+# CLAUDE_DEFAULT_CWD=/path/to/your/project```### Finding Chat IDs@@ -206,7 +208,7 @@ Messages from your agent are streamed in real-time:1. Ensure privacy mode is disabled (Step 4)2. Check that the bot is an admin in the group (optional but recommended)-3. Verify the group chat ID is whitelisted if using `TELEGRAM_CHAT_ID`+3. Verify the group chat ID is whitelisted if using `TELEGRAM_TARGET_CHAT_ID`### Message formatting issues@@ -234,7 +236,7 @@ If you hit rate limits, the bot will automatically retry with delays.### Chat Whitelisting-- Use `TELEGRAM_CHAT_ID` to restrict bot access to specific chats+- Use `TELEGRAM_TARGET_CHAT_ID` to restrict bot access to specific chats- This prevents unauthorized users from using your bot- Leave it as `null` only for development/testingdiff --git a/docs/TELEGRAM_SETUP_ZH.md b/docs/TELEGRAM_SETUP_ZH.mdindex 29637bdad..e46f58b1c 100644--- a/docs/TELEGRAM_SETUP_ZH.md+++ b/docs/TELEGRAM_SETUP_ZH.md@@ -80,10 +80,12 @@ IM_PLATFORM=telegramTELEGRAM_BOT_TOKEN=your-bot-token-here# 可选:白名单特定聊天 ID(null = 允许所有聊天)-TELEGRAM_CHAT_ID=[-1001234567890,987654321]+TELEGRAM_TARGET_CHAT_ID=[-1001234567890,987654321]# 编码 Agent 的默认工作目录-CLAUDE_CWD=/path/to/your/project+AGENT_DEFAULT_CWD=/path/to/your/project+# 兼容别名(仍支持):+# CLAUDE_DEFAULT_CWD=/path/to/your/project```### 查找聊天 ID@@ -206,7 +208,7 @@ python main.py1. 确保隐私模式已禁用(步骤 4)2. 检查机器人是否是群组管理员(可选但推荐)-3. 如果使用 `TELEGRAM_CHAT_ID`,验证群组聊天 ID 是否在白名单中+3. 如果使用 `TELEGRAM_TARGET_CHAT_ID`,验证群组聊天 ID 是否在白名单中### 消息格式问题@@ -234,7 +236,7 @@ Telegram 有速率限制:### 聊天白名单-- 使用 `TELEGRAM_CHAT_ID` 限制机器人访问特定聊天+- 使用 `TELEGRAM_TARGET_CHAT_ID` 限制机器人访问特定聊天- 这可以防止未授权用户使用你的机器人- 仅在开发/测试时将其设置为 `null`