wechat-bridge-opencode 0.1.2 → 0.1.4
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 +51 -196
- package/dist/bin/wechat-opencode.js +6 -6
- package/dist/package.json +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,243 +1,98 @@
|
|
|
1
1
|
# WeChat OpenCode
|
|
2
2
|
|
|
3
|
-
Bridge WeChat direct messages to
|
|
3
|
+
Bridge WeChat direct messages to OpenCode.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
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
|
-
##
|
|
18
|
+
## Install
|
|
28
19
|
|
|
29
20
|
```bash
|
|
30
|
-
npx
|
|
21
|
+
npx wechat-bridge-opencode --agent opencode
|
|
31
22
|
```
|
|
32
23
|
|
|
33
|
-
|
|
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
|
-
|
|
31
|
+
## Usage
|
|
51
32
|
|
|
52
33
|
```bash
|
|
53
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
##
|
|
43
|
+
## Options
|
|
146
44
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
|
164
|
-
| `/workspace switch <n\|path>` | Switch
|
|
165
|
-
| `/workspace add /path` | Add directory
|
|
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
|
|
173
|
-
| `/session switch <n\|slug>` | Switch
|
|
174
|
-
| `/session new` |
|
|
175
|
-
| `/session status` | Show current session
|
|
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
|
-
|
|
76
|
+
## Requirements
|
|
178
77
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
-
|
|
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
|
|
|
@@ -21,18 +21,18 @@ function usage() {
|
|
|
21
21
|
.map(({ id }) => id)
|
|
22
22
|
.join(", ");
|
|
23
23
|
console.log(`
|
|
24
|
-
|
|
24
|
+
wbo — Bridge WeChat to OpenCode
|
|
25
25
|
|
|
26
26
|
Usage:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
wbo --agent <preset|command> [options]
|
|
28
|
+
wbo agents List built-in agent presets
|
|
29
|
+
wbo stop Stop a running daemon
|
|
30
|
+
wbo status Check daemon status
|
|
31
31
|
|
|
32
32
|
Options:
|
|
33
33
|
--agent <value> Built-in preset name or raw agent command
|
|
34
34
|
Presets: ${presets}
|
|
35
|
-
Examples: "
|
|
35
|
+
Examples: "opencode"
|
|
36
36
|
--cwd <dir> Working directory for agent (default: current dir)
|
|
37
37
|
--login Force re-login (new QR code)
|
|
38
38
|
--daemon Run in background after login
|
package/dist/package.json
CHANGED