@wemind/cli 1.0.0 → 1.1.1
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/LICENSE +22 -0
- package/README.md +114 -4
- package/dist/cli.js +561 -144
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Howardzhangdqs (mcp-wechat-server — https://github.com/Howardzhangdqs/mcp-wechat-server)
|
|
4
|
+
Copyright (c) 2026 imwangpan (WeMind — https://github.com/imwangpan/WeMind)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -10,13 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
npm i -g @wemind/cli # 安装后得到 wemind 命令
|
|
13
|
-
wemind version # → wemind 1.
|
|
13
|
+
wemind version # → wemind 1.1.0 (@wemind/cli, node …, win32-x64) # 版本以实际安装为准
|
|
14
14
|
|
|
15
15
|
# 不安装、一次性运行(注意是包名 @wemind/cli,不是 wemind)
|
|
16
16
|
npx -y @wemind/cli list
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
要求:**Node.js >= 20**;想让它真的会「思考」,需要 PATH 上有一个支持 **ACP** 的 agent CLI(`kiro-cli` / `opencode` / 桌面端 `dsh` 等;未配置时自动探测 `kiro → opencode → gemini → deepseek`)。
|
|
19
|
+
要求:**Node.js >= 20**;想让它真的会「思考」,需要 PATH 上有一个支持 **ACP** 的 agent CLI(`kiro-cli` / `opencode` / 桌面端 `dsh` / `qodercli` 等;未配置时自动探测 `kiro → opencode → gemini → deepseek → qoder`)。
|
|
20
|
+
|
|
21
|
+
## 升级
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm i -g @wemind/cli@latest
|
|
25
|
+
wemind stop <账号> && wemind start <账号> # 已在运行的 daemon 不会自动加载新代码
|
|
26
|
+
```
|
|
20
27
|
|
|
21
28
|
## 三步上手
|
|
22
29
|
|
|
@@ -46,14 +53,14 @@ wemind brain check # ③ 验证大脑能说 ACP(initialize +
|
|
|
46
53
|
|
|
47
54
|
## 常驻怎么跑
|
|
48
55
|
|
|
49
|
-
`wemind start` 默认用**自带的跨平台看门狗**(builtin):detached 拉起 `wemind _watchdog`,它循环执行 `wemind daemon`,进程退出 5 秒后自动重拉;单实例靠 `wrapper.pid` + 进程身份校验。也可以用 `--runner pm2`(或 `WEMIND_RUNNER=pm2`)交给 pm2
|
|
56
|
+
`wemind start` 默认用**自带的跨平台看门狗**(builtin):detached 拉起 `wemind _watchdog`,它循环执行 `wemind daemon`,进程退出 5 秒后自动重拉;单实例靠 `wrapper.pid` + 进程身份校验。也可以用 `--runner pm2`(或 `WEMIND_RUNNER=pm2`)交给 pm2——`wemind` 会在账号目录生成 `pm2.app.json`(5s 重拉、最多 50 次、退出码 78 停手、日志合并到 `daemon.log`,与 builtin 语义一致),再 `pm2 start` 它。
|
|
50
57
|
|
|
51
58
|
开机自启:让系统在登录时执行一次 `wemind start <账号>` 即可(Windows 计划任务/启动文件夹、Linux systemd user service、macOS launchd)。**同一账号只用一套常驻方案**——两种 runner 同时跑会抢同一个 bot token。
|
|
52
59
|
|
|
53
60
|
## 数据与安全
|
|
54
61
|
|
|
55
62
|
- 所有状态在 `~/.wemind/<账号>/`(可用 `WEMIND_HOME` 改根目录):`account.json` 登录凭证、`state.json` 游标、`allowFrom.json` 授权清单、`brain-home/` 大脑沙箱、`daemon.log` 日志。
|
|
56
|
-
- ⚠️ **daemon
|
|
63
|
+
- ⚠️ **daemon 会让大脑免确认执行工具**(kiro 预设 `--trust-all-tools`;qoder 预设 `--yolo`):能给这个 bot 发消息的人,即可让大脑在本机执行任意工具(shell / 写文件)。唯一安全闸是**发件人授权(allowFrom)**:扫码登录者自动授权,**勿清空**。
|
|
57
64
|
- `account.json` 里 bot token 是明文(POSIX 上 chmod 600;Windows 请用目录权限或磁盘加密)。
|
|
58
65
|
- 同一个 bot token **只能有一个消费者**:`wemind` daemon 与 `@wemind/wechat-mcp` 二选一,否则互相抢消息。
|
|
59
66
|
|
|
@@ -78,10 +85,113 @@ wemind brain check # ③ 验证大脑能说 ACP(initialize +
|
|
|
78
85
|
## 文档
|
|
79
86
|
|
|
80
87
|
- 完整文档:<https://github.com/imwangpan/WeMind>
|
|
88
|
+
- 新手一步步教程:[docs/新手教程.md](https://github.com/imwangpan/WeMind/blob/main/docs/新手教程.md)
|
|
89
|
+
- 发布与版本规则:[docs/发布-wemind-npm.md](https://github.com/imwangpan/WeMind/blob/main/docs/发布-wemind-npm.md)
|
|
81
90
|
- AI 协作者入口:[AGENTS.md](https://github.com/imwangpan/WeMind/blob/main/AGENTS.md)
|
|
82
91
|
- 接入其它 ACP agent:[docs/接入其它-ACP-Agent.md](https://github.com/imwangpan/WeMind/blob/main/docs/接入其它-ACP-Agent.md)
|
|
92
|
+
- Qoder 接入:[docs/接入-Qoder.md](https://github.com/imwangpan/WeMind/blob/main/docs/接入-Qoder.md)
|
|
83
93
|
- Daemon 常驻原理:[docs/repowiki/10-部署与运维.md](https://github.com/imwangpan/WeMind/blob/main/docs/repowiki/10-部署与运维.md)
|
|
84
94
|
|
|
95
|
+
## 维护者:发布新版本
|
|
96
|
+
|
|
97
|
+
本包(包名 `@wemind/cli`,命令 `wemind`)通过 GitHub Actions([`.github/workflows/wemind-publish.yml`](../../.github/workflows/wemind-publish.yml))发布到 npm。**下面的命令都在 WeMind 仓库根目录运行**,不是在 `packages/wechat-daemon` 子目录。
|
|
98
|
+
|
|
99
|
+
> ℹ️ **版本号只有一处来源**:`packages/wechat-daemon/package.json` 的 `version`。`src/version.ts` 在**运行时**读它(不再手写常量),所以改版本不会漏改源码。仓库提供 `npm run release:*` 一步到位,并自动跑一致性自检。
|
|
100
|
+
|
|
101
|
+
### 第一步:判断要不要发版
|
|
102
|
+
|
|
103
|
+
| 你改了什么 | 需要发版吗 |
|
|
104
|
+
| --- | --- |
|
|
105
|
+
| `packages/wechat-daemon/src/**` 或 `packages/wechat-ilink-core/src/**`(内核会内联进来) | ✅ 要 |
|
|
106
|
+
| 只改了 `*.md` 文档 | ❌ 不用(CI 仍跑检查,但版本没变会跳过发布) |
|
|
107
|
+
| 只改了 `packages/wechat-mcp/**` | ❌ 与本包无关,发的是另一个包 |
|
|
108
|
+
|
|
109
|
+
> 同一个版本号**不能重复发布**。所以「有没有改代码」不是关键,「有没有升版本号」才是——没升就只会跑检查、不发布。
|
|
110
|
+
|
|
111
|
+
### 第二步:选版本号
|
|
112
|
+
|
|
113
|
+
| 参数 | 示例 | 什么时候用 |
|
|
114
|
+
| --- | --- | --- |
|
|
115
|
+
| `patch` | `1.0.0` → `1.0.1` | Bug 修复、兼容性改动(**最常用**) |
|
|
116
|
+
| `minor` | `1.0.0` → `1.1.0` | 新增向后兼容的能力(如新增内置大脑预设、新增子命令) |
|
|
117
|
+
| `major` | `1.0.0` → `2.0.0` | 不兼容改动(如删子命令、改数据目录布局、改 CLI 参数) |
|
|
118
|
+
|
|
119
|
+
### 第三步:升版本号(一条命令)
|
|
120
|
+
|
|
121
|
+
```powershell
|
|
122
|
+
npm run release:patch # 1.1.0 → 1.1.1(Bug 修复)
|
|
123
|
+
npm run release:minor # 1.1.0 → 1.2.0(向后兼容的新功能)
|
|
124
|
+
npm run release:major # 1.1.0 → 2.0.0(不兼容改动)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
这三个脚本等价于:
|
|
128
|
+
|
|
129
|
+
```powershell
|
|
130
|
+
npm version <type> --workspace @wemind/cli --no-git-tag-version && npm run check:version
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- 前半句改 **`package.json` 与 `package-lock.json` 两处**;`--no-git-tag-version` 让它**不**自动创建 git commit 和 tag(我们的发布流程要求「版本号 + 源码改动」在同一个 commit 里);
|
|
134
|
+
- 后半句跑 `check-version` 自检:包名、`bin` 是否仍叫 `wemind`、lock 是否同步、**`src/version.ts` 有没有被改回硬编码版本号**。任一项不对就 `exit 1`,`&&` 会中断,不会带着错误版本继续。
|
|
135
|
+
|
|
136
|
+
> **指定具体版本**:`npm version 1.4.2 --workspace @wemind/cli --no-git-tag-version`
|
|
137
|
+
>
|
|
138
|
+
> 想完全手动也可以:改 `packages/wechat-daemon/package.json` 的 `"version"`,再 `npm install --package-lock-only --ignore-scripts` 刷新 lock。
|
|
139
|
+
> **不需要**改 `src/version.ts`——它运行时读 package.json。不要手动编辑 `package-lock.json`。
|
|
140
|
+
|
|
141
|
+
### 第四步:本地校验
|
|
142
|
+
|
|
143
|
+
```powershell
|
|
144
|
+
npm run check:version # 包名 / bin / lock / 无硬编码版本号
|
|
145
|
+
npm run lint && npm run typecheck && npm run build && npm test
|
|
146
|
+
npm pack --dry-run --workspace @wemind/cli # 应看到 4 个文件:cli.js / cli.js.map / README.md / package.json
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
> ⚠️ **`npm publish` 不会自动 build**。CI 会 build,但本地 `npm pack` 前必须先 `npm run build`,否则打出来是旧产物(`dist/` 在 `.gitignore` 里)。
|
|
150
|
+
>
|
|
151
|
+
> `prepack` 守卫(`scripts/prepack-guard.mjs`)会兜底拒绝:产物目录为空、`bin` 缺失、或声明了 sourcemap 却没把 `.map` 带进包。
|
|
152
|
+
|
|
153
|
+
### 第五步:提交并推送
|
|
154
|
+
|
|
155
|
+
```powershell
|
|
156
|
+
git add packages/wechat-daemon/package.json package-lock.json
|
|
157
|
+
git add packages/wechat-daemon/src packages/wechat-ilink-core/src # 有源码改动时
|
|
158
|
+
git commit -m "chore: release @wemind/cli 1.1.1"
|
|
159
|
+
git push origin main
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
推送到 `main` 后,工作流依次执行:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
check-version(包名 / bin / lock / 无硬编码版本号)→ npm ci → lint → format:check → typecheck → build → test
|
|
166
|
+
→ npm pack --dry-run(prepack 守卫确认包内容)
|
|
167
|
+
→ 把 tarball 真装到临时目录跑 wemind version / help(装包冒烟)
|
|
168
|
+
→ 检查 npm 上是否已存在该版本
|
|
169
|
+
→ 不存在则 npm publish(带 provenance 来源证明);已存在则跳过并输出 notice
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**看到 `Publish to npm` 显示 skipped 是正常的**:说明这个版本已发过(比如你只改了文档、没升版本)。想真正发版,回到第二步升版本号。
|
|
173
|
+
|
|
174
|
+
### 第六步:发布后验收
|
|
175
|
+
|
|
176
|
+
```powershell
|
|
177
|
+
npm view @wemind/cli version # 应显示新版本号
|
|
178
|
+
npm i -g @wemind/cli@latest && wemind version # → wemind <新版本> (@wemind/cli, node …, <platform>-<arch>)
|
|
179
|
+
wemind list # 应能正确识别在跑的账号与进程
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
已装用户升级:`npm i -g @wemind/cli@latest`,然后 `wemind stop <账号> && wemind start <账号>` ——**正在运行的 daemon 不会自动加载新代码**。
|
|
183
|
+
|
|
184
|
+
### 常见坑
|
|
185
|
+
|
|
186
|
+
| 现象 | 原因 | 处理 |
|
|
187
|
+
| --- | --- | --- |
|
|
188
|
+
| `check-version` 报「lock 版本不一致」 | 手改了 `package.json` 没刷新 lock | `npm install --package-lock-only --ignore-scripts`(或改用 `npm run release:*`) |
|
|
189
|
+
| `check-version` 报「硬编码 CLI_VERSION 字面量」 | 有人把 `src/version.ts` 改回了常量写法 | 还原为 `readOwnVersion(...)`(版本号必须只来自 package.json) |
|
|
190
|
+
| CI 绿了但 npm 上没新版本 | 版本号没升,被跳过 | `npm run release:patch` 后再推 |
|
|
191
|
+
| `npm pack` 出来是空壳 | 没先 `npm run build` | 先 build 再 pack |
|
|
192
|
+
| `prepack` 守卫拒绝发布 | 产物为空 / `bin` 缺失 / 声明了 sourcemap 但 `.map` 不在包里 | 按守卫提示补 build 或检查 `files` |
|
|
193
|
+
| `npm publish` 报 403 / EOTP | 本地直发需要交互式 2FA | **不要本地发**,走 CI(Trusted Publisher 已配好) |
|
|
194
|
+
|
|
85
195
|
## License
|
|
86
196
|
|
|
87
197
|
MIT
|