wechat-bridge-opencode 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,243 +1,98 @@
1
1
  # WeChat OpenCode
2
2
 
3
- Bridge WeChat direct messages to opencode.
3
+ Bridge WeChat direct messages to OpenCode.
4
4
 
5
- `wechat-bridge-opencode` (aka `wbo`) logs in with the WeChat iLink bot API, polls incoming 1:1 messages, forwards them to opencode over stdio, and sends the agent reply back to WeChat.
6
-
7
- <img src="./resources/screenshot.jpg" alt="wbo screenshot" width="400" />
5
+ <img src="./resources/screenshot.jpg" alt="wechat-bridge-opencode screenshot" width="400" />
8
6
 
9
7
  ## Features
10
8
 
11
- - WeChat QR login with terminal QR rendering
12
- - One ACP agent session per WeChat user
13
- - Built-in ACP agent presets for common CLIs
14
- - Custom raw agent command support
15
- - Auto-allow permission requests from the agent
16
- - Direct message only; group chats are ignored
17
- - Background daemon mode
18
- - File sending: agent can send files/images back to WeChat via the `send-wechat` tool
19
- - Automatic model config forwarding for opencode agents
20
-
21
- ## Requirements
22
-
23
- - Node.js 20+
24
- - A WeChat environment that can use the iLink bot API
25
- - [OpenCode](https://github.com/anomalyco/opencode) installed locally or via `npx`
9
+ - **Text** Send/receive messages between WeChat and OpenCode
10
+ - **Images** Send/receive images with WeChat CDN support
11
+ - **Files** Send/receive files of any type
12
+ - **Audio/Video** Full audio and video message support
13
+ - **QR Login** Terminal QR code rendering for WeChat login
14
+ - **One Session Per User** Dedicated ACP session for each WeChat user
15
+ - **Daemon Mode** — Run in background with `--daemon`
16
+ - **send-wechat Tool** Agents can send files/images back to WeChat
26
17
 
27
- ## Installation
18
+ ## Install
28
19
 
29
20
  ```bash
30
- npx wbo --agent opencode
21
+ npx wechat-bridge-opencode --agent opencode
31
22
  ```
32
23
 
33
- That's it — `wbo` will be available globally after first run, and the `send-wechat` tool is automatically installed to `~/.config/opencode/tools/send-wechat.ts`.
34
-
35
- To install globally:
24
+ Or install globally:
36
25
 
37
26
  ```bash
38
27
  npm install -g wechat-bridge-opencode
39
- ```
40
-
41
- ## Quick Start
42
-
43
- > **Important**: Run the bridge from your **working directory** (e.g. your project folder), **not** from an arbitrary install directory. Running from the install directory may cause conflicts.
44
-
45
- ```bash
46
- cd /path/to/your/workdir
47
28
  wbo --agent opencode
48
29
  ```
49
30
 
50
- Or with a custom agent command:
31
+ ## Usage
51
32
 
52
33
  ```bash
53
- wbo --agent "npx my-agent --acp"
54
- ```
55
-
56
- On first run, the bridge will:
57
-
58
- 1. Start WeChat QR login
59
- 2. Render a QR code in the terminal
60
- 3. Save the login token under `~/.wechat-bridge-opencode`
61
- 4. Begin polling direct messages
62
-
63
- ## Built-in Agent Presets
64
-
65
- List the bundled presets:
66
-
67
- ```bash
68
- wbo agents
69
- ```
70
-
71
- Current presets:
72
-
73
- - `opencode`
74
-
75
- These presets resolve to concrete `command + args` pairs internally, so users do not need to type long `npx ...` commands.
76
-
77
- ## CLI Usage
78
-
79
- ```text
80
- wbo --agent <preset|command> [options]
81
- wbo agents
82
- wbo stop
83
- wbo status
84
- ```
85
-
86
- Options:
87
-
88
- - `--agent <value>`: built-in preset name or raw agent command
89
- - `--cwd <dir>`: working directory for the agent process
90
- - `--login`: force QR re-login and replace the saved token
91
- - `--daemon`: run in background after startup
92
- - `--config <file>`: load JSON config file
93
- - `--idle-timeout <minutes>`: session idle timeout, default `1440` (use `0` for unlimited)
94
- - `--max-sessions <count>`: maximum concurrent user sessions, default `10`
95
- - `--show-thoughts`: forward agent thinking to WeChat (default: off)
96
- - `-h, --help`: show help
97
-
98
- Examples:
99
-
100
- ```bash
101
- cd /path/to/your/workdir
102
- wbo --agent opencode
103
- wbo --agent opencode --cwd D:\code\project
104
- wbo --agent "npx opencode-ai acp"
105
- wbo --agent opencode --daemon
106
- ```
107
-
108
- ## Configuration File
109
-
110
- You can provide a JSON config file with `--config`.
111
-
112
- Example:
113
-
114
- ```json
115
- {
116
- "agent": {
117
- "preset": "opencode",
118
- "cwd": "D:/code/project"
119
- },
120
- "session": {
121
- "idleTimeoutMs": 86400000,
122
- "maxConcurrentUsers": 10
123
- }
124
- }
34
+ cd /path/to/your/project
35
+ npx wechat-bridge-opencode --agent opencode
125
36
  ```
126
37
 
127
- You can also override or add agent presets:
128
-
129
- ```json
130
- {
131
- "agent": {
132
- "preset": "my-agent"
133
- },
134
- "agents": {
135
- "my-agent": {
136
- "label": "My Agent",
137
- "description": "Internal team agent",
138
- "command": "npx",
139
- "args": ["my-agent-cli", "--acp"]
140
- }
141
- }
142
- }
143
- ```
38
+ First run will:
39
+ 1. Show QR code in terminal
40
+ 2. Save login token to `~/.wechat-bridge-opencode`
41
+ 3. Start polling WeChat DMs
144
42
 
145
- ## Runtime Behavior
43
+ ## Options
146
44
 
147
- - Each WeChat user gets a dedicated ACP session and subprocess.
148
- - Messages are processed serially per user.
149
- - Replies are formatted for WeChat before sending.
150
- - Typing indicators are sent when supported by the WeChat API.
151
- - Sessions are cleaned up after inactivity (set `idleTimeoutMs` to `0` to disable idle cleanup).
152
- - Switching workspace or session kills the old agent and spawns a new one immediately.
153
- - OpenCode session history is resumed via `unstable_resumeSession()` when switching to an existing session.
45
+ | Flag | Description |
46
+ |------|-------------|
47
+ | `--agent <preset\|cmd>` | Built-in preset or raw command |
48
+ | `--cwd <dir>` | Working directory |
49
+ | `--login` | Force re-login |
50
+ | `--daemon` | Run in background |
51
+ | `--config <file>` | JSON config file |
52
+ | `--idle-timeout <min>` | Session idle timeout (default: 1440, 0 = unlimited) |
53
+ | `--max-sessions <count>` | Max concurrent sessions (default: 10) |
54
+ | `--show-thoughts` | Forward agent thinking to WeChat |
154
55
 
155
56
  ## WeChat Commands
156
57
 
157
- Users can manage workspaces and sessions directly from WeChat:
158
-
159
58
  ### Workspace (`/workspace` or `/ws`)
160
59
 
161
60
  | Command | Description |
162
61
  |---------|-------------|
163
- | `/workspace list` | List all directories from OpenCode sessions |
164
- | `/workspace switch <n\|path>` | Switch to directory by index or path |
165
- | `/workspace add /path` | Add directory (creates if not exists) |
62
+ | `/workspace list` | List all directories |
63
+ | `/workspace switch <n\|path>` | Switch directory |
64
+ | `/workspace add /path [name]` | Add directory |
166
65
  | `/workspace status` | Show current directory |
167
66
 
168
67
  ### Session (`/session` or `/s`)
169
68
 
170
69
  | Command | Description |
171
70
  |---------|-------------|
172
- | `/session list` | List recent 10 sessions with directory |
173
- | `/session switch <n\|slug>` | Switch to session by index or slug |
174
- | `/session new` | Restart session (clear context) |
175
- | `/session status` | Show current session info |
71
+ | `/session list` | List recent 10 sessions |
72
+ | `/session switch <n\|slug>` | Switch session |
73
+ | `/session new` | New session (clear context) |
74
+ | `/session status` | Show current session |
176
75
 
177
- ### Help
76
+ ## Requirements
178
77
 
179
- | Command | Description |
180
- |---------|-------------|
181
- | `/help` | Show all available commands |
78
+ - Node.js 20+
79
+ - WeChat iLink bot API access
80
+ - [OpenCode](https://github.com/anomalyco/opencode) installed locally or via npx
182
81
 
183
82
  ## Storage
184
83
 
185
- By default, runtime files are stored under:
84
+ Runtime data stored in `~/.wechat-bridge-opencode`:
85
+ - Login token
86
+ - Auth tokens
87
+ - Temp files (downloaded media)
88
+ - Daemon PID / log
89
+ - Bridge state (`.wechat-bridge-state.json`)
186
90
 
187
- ```text
188
- ~/.wechat-bridge-opencode
189
- ```
190
-
191
- This directory is used for:
192
-
193
- - saved login token
194
- - auth tokens
195
- - tempfile (downloaded media)
196
- - daemon pid file
197
- - daemon log file
198
- - sync state
199
- - bridge state (`.wechat-bridge-state.json` — tracks last active user/session for the `send-wechat` tool)
200
-
201
- ## Custom Tool: send-wechat
91
+ ## Notes
202
92
 
203
- The `send-wechat` tool is automatically installed to `~/.config/opencode/tools/send-wechat.ts`.
204
-
205
- This tool is available to opencode agents and lets them send files back to WeChat:
206
-
207
- ```
208
- send-wechat(filePath: string)
209
- ```
210
-
211
- The tool reads `~/.wechat-bridge-opencode/.wechat-bridge-state.json` to automatically determine the target user and session. The agent only needs to provide the file path.
212
-
213
- ## Current Limitations
214
-
215
- - Direct messages only; group chats are ignored
93
+ - Direct messages only (group chats ignored)
216
94
  - Permission requests are auto-approved
217
- - Some preset agents may require separate authentication before they can respond successfully
218
-
219
- ## Development
220
-
221
- Clone and build locally:
222
-
223
- ```bash
224
- git clone https://github.com/pan17/wechat-bridge-opencode.git
225
- cd wechat-bridge-opencode
226
- npm install
227
- npm run build
228
- ```
229
-
230
- Run the CLI locally:
231
-
232
- ```bash
233
- node dist/bin/wechat-opencode.js --help # or simply: wbo --help
234
- ```
235
-
236
- Watch mode:
237
-
238
- ```bash
239
- npm run dev
240
- ```
95
+ - `send-wechat` tool auto-installed to `~/.config/opencode/tools/send-wechat.ts`
241
96
 
242
97
  ## License
243
98
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wechat-bridge-opencode",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Bridge WeChat to any Opencode",
5
5
  "type": "module",
6
6
  "files": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wechat-bridge-opencode",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Bridge WeChat to any Opencode",
5
5
  "type": "module",
6
6
  "files": [