English | 中文
A bridge service that connects WeChat to OpenCode. Chat with OpenCode from your phone via WeChat — text, images, permission approvals, slash commands, all supported.
- Text conversation with OpenCode via WeChat
- Image recognition — send photos for OpenCode to analyze
- Permission approval — reply
y/nin WeChat to control tool execution - Slash commands —
/help,/cwd,/ls,/new,/sessions,/model,/models,/status,/skills - Cross-platform — macOS, Linux, Windows
- Session persistence — resume context across messages
- Directory-based session management — each directory has its own OpenCode session
- Node.js >= 18
- macOS, Linux or Windows
- Personal WeChat account (requires QR code binding)
- OpenCode installed and running locally (default localhost:4096)
Clone to a local directory:
git clone <repo> ~/wechat-opencode-bot
cd ~/wechat-opencode-bot
npm installThe postinstall script will automatically compile TypeScript.
Bind your WeChat account via QR code:
npm run setupA QR code will display in terminal — scan it with WeChat, then configure your working directory.
npm run daemon:startSimply send messages in WeChat to chat with OpenCode.
npm run daemon:start # Start the service (runs in background)
npm run daemon:stop # Stop the service
npm run daemon:status # Check running status| Command | Description |
|---|---|
/help |
Show help |
/clear |
Clear current session |
/new [title] |
Create new session (clear context), optional title |
/sessions |
List OpenCode sessions in current directory |
| `/session <n | ID>` |
/compact |
Compact context (start new SDK session, keep history) |
/history [n] |
View chat history (default last 20) |
/undo [n] |
Undo last n messages (default 1) |
| Command | Description |
|---|---|
/cwd [path] |
Switch working directory (supports relative/absolute paths) |
/ls |
List current directory contents |
| Command | Description |
|---|---|
/model [id] |
View or switch model |
/models |
List available models |
/permission [mode] |
View or switch permission mode |
/status |
Show current session status |
| Command | Description |
|---|---|
/skills |
List available OpenCode skills |
/version |
Show version info |
- Initial directory is set by
workingDirectoryinconfig.env /cwdsupports relative paths (a,../b) and absolute paths/cwdauto-creates directories that don't exist- Directory switching is limited to within
config.envworking directory - Each directory has its own OpenCode session
Examples:
/cwd a # Switch to subdirectory a
/cwd ../b # Switch to sibling directory b
/cwd /home/user # Switch to absolute path (must be within base directory)
When OpenCode requests to execute a tool, you receive a permission request in WeChat:
- Reply
yoryesto allow - Reply
nornoto deny - No reply within 120 seconds auto-denies
Switch permission mode with /permission <mode>:
| Mode | Description |
|---|---|
default |
Manual approval for every tool use |
acceptEdits |
Auto-approve file edits, others need approval |
plan |
Read-only mode, no tools allowed |
auto |
Auto-approve all tools (dangerous mode) |
WeChat (phone) ←→ ilink bot API ←→ Node.js daemon ←→ OpenCode service
- Daemon listens for new messages via long-polling WeChat ilink bot API
- Messages forwarded to OpenCode via HTTP API
- Replies sent back to WeChat
All data stored in ~/.wechat-opencode-bot/:
~/.wechat-opencode-bot/
├── accounts/ # WeChat account credentials (one JSON per account)
├── config.env # Global config (working directory, model, permission mode)
├── sessions/ # Session data (one JSON per account)
├── get_updates_buf # Message polling sync buffer
├── logs/ # Runtime logs (daily rotation)
└── daemon.pid # Daemon process PID
npm run dev # Watch mode — auto-compile on TypeScript changes
npm run build # Compile TypeScript