claude-codex-wechat 0.1.40 → 0.1.44
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 +62 -303
- package/dist/server/cli.js +193 -12
- package/dist/web/assets/{index-Ds7h49vj.js → index-dnbWitlp.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,158 +1,85 @@
|
|
|
1
1
|
# claude-codex-wechat
|
|
2
2
|
|
|
3
|
-
`
|
|
3
|
+
用微信,遥控你自己电脑上的 `Claude Code` 和 `Codex CLI`。
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- 本机原生 `Claude Code`
|
|
7
|
-
- 本机原生 `Codex CLI`
|
|
5
|
+
它是一个跑在你本机的小程序(bridge daemon)。启动后,你就能在**微信里直接给机器人发消息**,让它驱动本机上原生的 `Claude Code` / `Codex CLI` 会话干活——写代码、跑命令、查东西,随时随地用手机指挥你的开发机。
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
- 微信 = 你的遥控器
|
|
8
|
+
- 本机原生 CLI = 真正干活的人
|
|
9
|
+
- 两边共享同一条原生会话,随时可以恢复上次的对话
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## 你需要准备什么
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
## 当前能力
|
|
18
|
-
|
|
19
|
-
当前实现覆盖的主能力:
|
|
20
|
-
|
|
21
|
-
- WeChat direct 模式接入
|
|
22
|
-
- WeChat 轮询收消息与主动回消息
|
|
23
|
-
- 本地原生 `Claude Code` / `Codex CLI` 会话桥接
|
|
24
|
-
- 会话持久化与当前会话恢复
|
|
25
|
-
- 原生 Claude / Codex recoverable session 列表与 attach
|
|
26
|
-
- 本地管理页
|
|
27
|
-
- npm 全局安装与生产 CLI 入口
|
|
28
|
-
- 本地发布 npm 包
|
|
29
|
-
|
|
30
|
-
## 项目结构
|
|
31
|
-
|
|
32
|
-
主要目录:
|
|
33
|
-
|
|
34
|
-
- `src/`
|
|
35
|
-
- daemon、provider、session、channel、web 主实现
|
|
36
|
-
- `tests/`
|
|
37
|
-
- 单元测试、运行态测试、前端测试
|
|
38
|
-
- `scripts/`
|
|
39
|
-
- 诊断与辅助脚本
|
|
40
|
-
- `docs/`
|
|
41
|
-
- 设计说明、对齐文档、参考资料
|
|
42
|
-
|
|
43
|
-
脚本说明见 [scripts/README.md](./scripts/README.md)。
|
|
13
|
+
- 一台安装了 [Node.js](https://nodejs.org/) `20` 或更高版本的电脑(macOS 或 Linux)
|
|
14
|
+
- 本机已经装好并能正常使用 `Claude Code` 或 `Codex CLI`
|
|
15
|
+
- 一个微信号(用来扫码绑定机器人)
|
|
44
16
|
|
|
45
17
|
## 安装
|
|
46
18
|
|
|
47
|
-
### 作为 npm 包安装
|
|
48
|
-
|
|
49
19
|
```bash
|
|
50
20
|
npm install -g claude-codex-wechat --registry=https://registry.npmmirror.com/
|
|
51
21
|
# 或
|
|
52
22
|
pnpm add -g claude-codex-wechat
|
|
53
23
|
```
|
|
54
24
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- 该包依赖 `better-sqlite3`
|
|
58
|
-
- 大多数常见平台会直接下载预编译二进制
|
|
59
|
-
- 少数环境可能需要本地编译工具链
|
|
60
|
-
- Node 版本要求:`>=20`
|
|
25
|
+
> 该包依赖 `better-sqlite3`。大多数电脑会直接下载预编译好的二进制;极少数环境可能需要本地编译工具链。
|
|
61
26
|
|
|
62
|
-
##
|
|
27
|
+
## 开始使用
|
|
63
28
|
|
|
64
|
-
|
|
29
|
+
安装完,三步就能跑通:
|
|
65
30
|
|
|
66
31
|
```bash
|
|
67
|
-
# 1.
|
|
68
|
-
# 首次启动自动生成 relay 接入凭据、自动连接默认中转,无需手动配置)
|
|
32
|
+
# 1. 启动(首次会自动注册成系统后台服务,并自动配好接入公网中转,无需手动配置)
|
|
69
33
|
claude-codex-wechat start
|
|
70
34
|
|
|
71
35
|
# 2. 打开管理页,用微信扫码登录完成绑定
|
|
72
|
-
# http://127.0.0.1:8787
|
|
73
|
-
|
|
74
|
-
# 3. 查看状态 / 日志
|
|
75
|
-
claude-codex-wechat status
|
|
76
|
-
claude-codex-wechat logs
|
|
36
|
+
# 浏览器访问 http://127.0.0.1:8787
|
|
77
37
|
|
|
78
|
-
#
|
|
79
|
-
claude-codex-wechat doctor
|
|
38
|
+
# 3. 绑定成功后,直接在微信里给机器人发消息即可
|
|
80
39
|
```
|
|
81
40
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
- 管理页:`http://127.0.0.1:8787`(在此扫码登录微信)
|
|
85
|
-
- 微信侧即可直接给机器人发消息,驱动本机 `Claude Code` / `Codex CLI` 会话
|
|
86
|
-
|
|
87
|
-
停止 / 重启 / 卸载:
|
|
41
|
+
搞定。之后不管电脑锁屏还是你人在外面,只要开发机开着,就能用微信指挥它。
|
|
88
42
|
|
|
89
|
-
|
|
90
|
-
claude-codex-wechat restart
|
|
91
|
-
claude-codex-wechat stop
|
|
92
|
-
claude-codex-wechat uninstall
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### 从源码安装
|
|
43
|
+
如果启动遇到问题,跑一下体检命令看看哪里没就绪:
|
|
96
44
|
|
|
97
45
|
```bash
|
|
98
|
-
|
|
99
|
-
pnpm install
|
|
46
|
+
claude-codex-wechat doctor
|
|
100
47
|
```
|
|
101
48
|
|
|
102
|
-
##
|
|
103
|
-
|
|
104
|
-
生产态 CLI 入口在 `dist/server/cli.js`,通过 `bin` 暴露为 `claude-codex-wechat`。
|
|
105
|
-
|
|
106
|
-
可用命令:
|
|
49
|
+
## 常用命令
|
|
107
50
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
- `claude-codex-wechat uninstall`
|
|
121
|
-
- 卸载后台服务
|
|
122
|
-
- `claude-codex-wechat print-config`
|
|
123
|
-
- 打印当前配置文件
|
|
124
|
-
- `claude-codex-wechat help`
|
|
125
|
-
- 显示帮助
|
|
51
|
+
| 命令 | 作用 |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `claude-codex-wechat start` | 启动(首次自动注册后台服务),默认命令 |
|
|
54
|
+
| `claude-codex-wechat status` | 查看运行状态 |
|
|
55
|
+
| `claude-codex-wechat logs` | 查看最近日志 |
|
|
56
|
+
| `claude-codex-wechat tail` | 实时跟随日志 |
|
|
57
|
+
| `claude-codex-wechat restart` | 重启 |
|
|
58
|
+
| `claude-codex-wechat stop` | 停止 |
|
|
59
|
+
| `claude-codex-wechat doctor` | 体检:检查配置、前端产物、`claude`/`codex` 是否就绪 |
|
|
60
|
+
| `claude-codex-wechat print-config` | 打印当前配置 |
|
|
61
|
+
| `claude-codex-wechat uninstall` | 卸载后台服务 |
|
|
62
|
+
| `claude-codex-wechat help` | 显示帮助 |
|
|
126
63
|
|
|
127
|
-
|
|
64
|
+
管理页固定监听:`http://127.0.0.1:8787`
|
|
128
65
|
|
|
129
|
-
|
|
66
|
+
后台服务由系统守护(macOS 用 `launchd`,Linux 用 `systemd --user`),崩溃会自动拉起,不需要额外的进程管理器。
|
|
130
67
|
|
|
131
|
-
##
|
|
68
|
+
## 配置(一般不用管)
|
|
132
69
|
|
|
133
|
-
|
|
70
|
+
配置文件在**首次 `start` 时自动生成**,路径:
|
|
134
71
|
|
|
135
72
|
```text
|
|
136
73
|
~/.claude-codex-wechat/config.json
|
|
137
74
|
```
|
|
138
75
|
|
|
139
|
-
|
|
76
|
+
正常使用**无需手动编辑**——接入公网中转的凭据会自动生成并写入。只有想做进阶自定义时才需要动它,例如指定 `claude` / `codex` 的可执行文件路径、默认工作目录:
|
|
140
77
|
|
|
141
78
|
```json
|
|
142
79
|
{
|
|
143
|
-
"wechat": {
|
|
144
|
-
"enabled": true,
|
|
145
|
-
"baseUrl": "https://ilinkai.weixin.qq.com",
|
|
146
|
-
"token": "replace-with-weixin-bot-token",
|
|
147
|
-
"accountId": "replace-with-weixin-account-id"
|
|
148
|
-
},
|
|
149
80
|
"providers": {
|
|
150
|
-
"claude": {
|
|
151
|
-
|
|
152
|
-
},
|
|
153
|
-
"codex": {
|
|
154
|
-
"command": "/opt/homebrew/bin/codex"
|
|
155
|
-
}
|
|
81
|
+
"claude": { "command": "/opt/homebrew/bin/claude" },
|
|
82
|
+
"codex": { "command": "/opt/homebrew/bin/codex" }
|
|
156
83
|
},
|
|
157
84
|
"bridge": {
|
|
158
85
|
"defaultProvider": "claude-code",
|
|
@@ -161,7 +88,7 @@ pnpm install
|
|
|
161
88
|
}
|
|
162
89
|
```
|
|
163
90
|
|
|
164
|
-
|
|
91
|
+
如需接入自建的公网中转服务(relay-server),在同一份配置里加上:
|
|
165
92
|
|
|
166
93
|
```json
|
|
167
94
|
{
|
|
@@ -169,226 +96,58 @@ pnpm install
|
|
|
169
96
|
"provider": "relay",
|
|
170
97
|
"enabled": true,
|
|
171
98
|
"relay": {
|
|
172
|
-
"serverUrl": "wss://relay
|
|
99
|
+
"serverUrl": "wss://your-relay-host/agent",
|
|
173
100
|
"authToken": "replace-with-relay-auth-token"
|
|
174
101
|
}
|
|
175
102
|
}
|
|
176
103
|
}
|
|
177
104
|
```
|
|
178
105
|
|
|
179
|
-
|
|
106
|
+
relay-server 的独立部署说明见 [relay-server/README.md](./relay-server/README.md)。
|
|
180
107
|
|
|
181
|
-
|
|
182
|
-
- 当前 bridge 只需要配置 `serverUrl` 与 `authToken`
|
|
183
|
-
- 当前本地开发公网链路默认走 `relay-server`
|
|
184
|
-
- 启用后,bridge 连接 relay-server 时会获得一个随机公网访问路径
|
|
185
|
-
- 典型地址形如:`https://wechat.style520.com/sjdfh2xxx`
|
|
108
|
+
## 遇到问题
|
|
186
109
|
|
|
187
|
-
|
|
110
|
+
- 微信收不到消息 / 机器人没反应:先 `claude-codex-wechat status` 看服务是否在跑,再 `claude-codex-wechat logs` 看日志。
|
|
111
|
+
- 提示找不到 `claude` 或 `codex`:跑 `claude-codex-wechat doctor`,按提示在配置里指定可执行文件的绝对路径。
|
|
112
|
+
- 想彻底重来:`claude-codex-wechat uninstall` 卸载服务,删除 `~/.claude-codex-wechat/` 后重新 `start`。
|
|
188
113
|
|
|
189
|
-
|
|
190
|
-
- [src/web/activationCode.ts](./src/web/activationCode.ts) 仅保留为兼容 re-export,新的实现不要继续写入该文件
|
|
191
|
-
- 迁移剩余兼容项与对应测试证据见 [docs/2026-06-28-access-code-migration-notes.md](./docs/2026-06-28-access-code-migration-notes.md)
|
|
114
|
+
更详细的微信侧使用玩法见 [docs/wechatbot-usage-guide.md](./docs/wechatbot-usage-guide.md)。
|
|
192
115
|
|
|
193
|
-
|
|
116
|
+
---
|
|
194
117
|
|
|
195
|
-
|
|
196
|
-
- `BRIDGE_CONFIG`
|
|
197
|
-
- `BRIDGE_WECHAT_ENABLED`
|
|
198
|
-
- `BRIDGE_WECHAT_BASE_URL`
|
|
199
|
-
- `BRIDGE_WECHAT_TOKEN`
|
|
200
|
-
- `BRIDGE_WECHAT_ACCOUNT_ID`
|
|
201
|
-
- `BRIDGE_CLAUDE_COMMAND`
|
|
202
|
-
- `BRIDGE_CODEX_COMMAND`
|
|
118
|
+
## 开发与维护
|
|
203
119
|
|
|
204
|
-
|
|
120
|
+
以下面向想改代码或自行构建发布的开发者,普通使用者可以忽略。
|
|
205
121
|
|
|
206
|
-
|
|
122
|
+
### 从源码运行
|
|
207
123
|
|
|
208
124
|
```bash
|
|
209
|
-
|
|
125
|
+
git clone https://github.com/izerui/claude-codex-wechat.git
|
|
126
|
+
cd claude-codex-wechat
|
|
127
|
+
pnpm install
|
|
128
|
+
pnpm dev # 启动 daemon + Vite 前端热更新,管理页同上
|
|
210
129
|
```
|
|
211
130
|
|
|
212
|
-
这会:
|
|
213
|
-
|
|
214
|
-
- 启动 daemon
|
|
215
|
-
- 在同一进程里挂 Vite middleware
|
|
216
|
-
- 提供本地管理页与前端热更新
|
|
217
|
-
|
|
218
131
|
开发检查:
|
|
219
132
|
|
|
220
133
|
```bash
|
|
221
134
|
pnpm typecheck
|
|
222
135
|
pnpm test
|
|
223
|
-
pnpm build
|
|
136
|
+
pnpm build # 产出 dist/web/(前端)与 dist/server/cli.js(CLI/daemon 入口)
|
|
224
137
|
```
|
|
225
138
|
|
|
226
|
-
|
|
139
|
+
### 项目结构
|
|
227
140
|
|
|
228
|
-
- `
|
|
229
|
-
|
|
230
|
-
- `
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
## 生产运行
|
|
234
|
-
|
|
235
|
-
首次跑通流程见上方「快速开始」。`start` 会把当前 CLI 注册成操作系统服务并守护拉起。
|
|
236
|
-
|
|
237
|
-
常用管理命令:
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
claude-codex-wechat start # 后台启动 / 启动已安装服务
|
|
241
|
-
claude-codex-wechat restart # 重启
|
|
242
|
-
claude-codex-wechat status # 状态
|
|
243
|
-
claude-codex-wechat logs # 最近日志
|
|
244
|
-
claude-codex-wechat tail # 实时日志
|
|
245
|
-
claude-codex-wechat stop # 停止
|
|
246
|
-
claude-codex-wechat uninstall # 卸载服务
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
当前支持:
|
|
250
|
-
|
|
251
|
-
- macOS:`launchd`(`~/Library/LaunchAgents/`)
|
|
252
|
-
- Linux:`systemd --user`(`~/.config/systemd/user/`)
|
|
253
|
-
|
|
254
|
-
服务会以 `KeepAlive` / `Restart=on-failure` 守护,崩溃后自动拉起,无需额外进程管理器。
|
|
255
|
-
|
|
256
|
-
## 发布 npm 包
|
|
257
|
-
|
|
258
|
-
当前仓库只保留本地发布流,不再使用 GitHub Action 自动发布。
|
|
259
|
-
|
|
260
|
-
### 发布行为
|
|
261
|
-
|
|
262
|
-
本地执行 `npm publish` 时,会自动触发:
|
|
263
|
-
|
|
264
|
-
- `npm version patch --no-git-tag-version`
|
|
265
|
-
|
|
266
|
-
也就是说:
|
|
267
|
-
|
|
268
|
-
- 每次成功发布都会自动把版本加一位 `patch`
|
|
269
|
-
- 版本 bump 发生在真正 publish 之前
|
|
270
|
-
|
|
271
|
-
完整的发布前校验定义在 [release.sh](./release.sh),`prepublishOnly` 只负责自动递增版本,避免在 `npm publish` 阶段重复再跑一遍测试和构建。
|
|
272
|
-
|
|
273
|
-
### 直接发布
|
|
274
|
-
|
|
275
|
-
如果不需要自动提交版本变更:
|
|
276
|
-
|
|
277
|
-
```bash
|
|
278
|
-
cd /Users/liuyuhua/github/claude-codex-wechat
|
|
279
|
-
npm publish --access public --registry=https://registry.npmjs.org/
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
如果必须走代理:
|
|
283
|
-
|
|
284
|
-
```bash
|
|
285
|
-
cd /Users/liuyuhua/github/claude-codex-wechat
|
|
286
|
-
HTTPS_PROXY=http://127.0.0.1:7890 HTTP_PROXY=http://127.0.0.1:7890 npm publish --access public --registry=https://registry.npmjs.org/
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
### 使用 release.sh
|
|
290
|
-
|
|
291
|
-
如果希望:
|
|
292
|
-
|
|
293
|
-
- 发布前先提交当前工作区
|
|
294
|
-
- 发布后把自动 bump 的版本提交回当前分支
|
|
295
|
-
- 自动 `git push`
|
|
296
|
-
|
|
297
|
-
使用:
|
|
298
|
-
|
|
299
|
-
```bash
|
|
300
|
-
cd /Users/liuyuhua/github/claude-codex-wechat
|
|
301
|
-
chmod +x release.sh
|
|
302
|
-
./release.sh
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
脚本默认会使用本地代理:
|
|
306
|
-
|
|
307
|
-
```text
|
|
308
|
-
http://127.0.0.1:7890
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
如果你要覆盖默认代理:
|
|
312
|
-
|
|
313
|
-
```bash
|
|
314
|
-
cd /Users/liuyuhua/github/claude-codex-wechat
|
|
315
|
-
chmod +x release.sh
|
|
316
|
-
HTTPS_PROXY=http://127.0.0.1:7890 HTTP_PROXY=http://127.0.0.1:7890 ./release.sh
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
这个脚本会:
|
|
320
|
-
|
|
321
|
-
- 先执行 `pnpm typecheck`
|
|
322
|
-
- 再执行 `pnpm build`
|
|
323
|
-
- 提交当前改动
|
|
324
|
-
- 以默认参数执行 `npm publish --access public --registry=https://registry.npmjs.org/`
|
|
325
|
-
- 提交自动 bump 后的 `package.json`
|
|
326
|
-
- 推送到当前分支
|
|
327
|
-
|
|
328
|
-
### 发布前建议检查
|
|
329
|
-
|
|
330
|
-
```bash
|
|
331
|
-
cd /Users/liuyuhua/github/claude-codex-wechat
|
|
332
|
-
npm whoami
|
|
333
|
-
npm config get registry
|
|
334
|
-
npm pack --dry-run
|
|
335
|
-
pnpm typecheck
|
|
336
|
-
pnpm build
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
如果包名是否可用要先确认:
|
|
340
|
-
|
|
341
|
-
```bash
|
|
342
|
-
npm view claude-codex-wechat
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
## 常见问题
|
|
346
|
-
|
|
347
|
-
### `npm publish` 报 `EPERM scandir ~/.Trash`
|
|
348
|
-
|
|
349
|
-
一般是因为你不在项目目录,而是在家目录执行了 `npm publish`。
|
|
350
|
-
|
|
351
|
-
先确认:
|
|
352
|
-
|
|
353
|
-
```bash
|
|
354
|
-
pwd
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
应该在:
|
|
358
|
-
|
|
359
|
-
```bash
|
|
360
|
-
/Users/liuyuhua/github/claude-codex-wechat
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
### `Public registration is not allowed`
|
|
364
|
-
|
|
365
|
-
通常是下面几类问题:
|
|
366
|
-
|
|
367
|
-
- `registry` 不是官方 npm
|
|
368
|
-
- 正在往私有 registry 发包
|
|
369
|
-
- scoped package 没带 `--access public`
|
|
370
|
-
- 账号没有该包名或 scope 的发布权限
|
|
371
|
-
|
|
372
|
-
检查:
|
|
373
|
-
|
|
374
|
-
```bash
|
|
375
|
-
npm config get registry
|
|
376
|
-
npm whoami
|
|
377
|
-
node -p "require('./package.json').name"
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
### 本地必须走代理
|
|
381
|
-
|
|
382
|
-
临时发布可直接这样:
|
|
383
|
-
|
|
384
|
-
```bash
|
|
385
|
-
HTTPS_PROXY=http://127.0.0.1:7890 HTTP_PROXY=http://127.0.0.1:7890 npm publish --access public --registry=https://registry.npmjs.org/
|
|
386
|
-
```
|
|
141
|
+
- `src/` — daemon、provider、session、channel、web 主实现
|
|
142
|
+
- `relay-server/` — 独立的公网中转服务
|
|
143
|
+
- `tests/` — 单元 / 运行态 / 前端测试
|
|
144
|
+
- `scripts/` — 诊断与辅助脚本(见 [scripts/README.md](./scripts/README.md))
|
|
145
|
+
- `docs/` — 设计说明与参考资料(架构见 [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md))
|
|
387
146
|
|
|
388
147
|
## 相关文件
|
|
389
148
|
|
|
390
149
|
- [package.json](./package.json)
|
|
391
|
-
- [
|
|
150
|
+
- [relay-server/README.md](./relay-server/README.md)
|
|
392
151
|
- [scripts/README.md](./scripts/README.md)
|
|
393
152
|
- [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md)
|
|
394
153
|
- [docs/wechatbot-usage-guide.md](./docs/wechatbot-usage-guide.md)
|