@link-assistant/hive-mind 1.50.2 → 1.50.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.zh.md ADDED
@@ -0,0 +1,876 @@
1
+ [![npm](https://img.shields.io/npm/v/@link-assistant/hive-mind.svg)](https://npmjs.com/@link-assistant/hive-mind)
2
+ [![License](https://img.shields.io/badge/license-Unlicense-blue.svg)](https://github.com/link-assistant/hive-mind/blob/main/LICENSE)
3
+ [![GitHub stars](https://img.shields.io/github/stars/link-assistant/hive-mind?style=social)](https://github.com/link-assistant/hive-mind/stargazers)
4
+
5
+ [![Open in Gitpod](https://img.shields.io/badge/Gitpod-ready--to--code-f29718?logo=gitpod)](https://gitpod.io/#https://github.com/link-assistant/hive-mind)
6
+ [![Open in GitHub Codespaces](https://img.shields.io/badge/GitHub%20Codespaces-Open-181717?logo=github)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=link-assistant/hive-mind)
7
+
8
+ # Hive Mind 🧠 (languages: [en](README.md) • zh • [hi](README.hi.md) • [ru](README.ru.md))
9
+
10
+ **掌控 AI 蜂巢的核心 AI 大脑。** 这是一个统筹协调多个 AI 的编排 AI,即 HIVE MIND(蜂群思维)/ SWARM MIND(集群思维)。
11
+
12
+ 该系统还可以接入人类集体智慧,这意味着它能够与人类沟通,获取需求、专业知识和反馈。
13
+
14
+ [![通用问题解决算法](https://github.com/user-attachments/assets/1d91e911-9ba4-456e-a00a-14cdd60d9a0a)](https://github.com/konard/problem-solving)
15
+
16
+ 灵感来源于 [konard/problem-solving](https://github.com/konard/problem-solving)
17
+
18
+ ## 为什么选择 Hive Mind?
19
+
20
+ **Hive Mind 是最自主、最适合云端部署的 AI 问题解决方案,无需开发者全程盯守,同时在关键决策上保留人工监督。**
21
+
22
+ Hive Mind 是一款**通用 AI**(迷你 AGI),能够处理广泛的任务,不仅限于编程。几乎所有可以通过操作仓库文件完成的事情,都可以实现自动化。
23
+
24
+ | 特性 | 对您的意义 |
25
+ | -------------------------- | ------------------------------------------------------------------------------------------------------------- |
26
+ | **无需全程盯守** | 完全自主模式,拥有 sudo 权限。AI 享有像真实程序员一样的创造自由。 |
27
+ | **云端隔离** | 运行在专用虚拟机或 Docker 上,出现问题易于恢复。 |
28
+ | **完整互联网 + Sudo 权限** | AI 可以按需安装软件包、获取文档并配置系统。 |
29
+ | **预装工具链** | 25GB+ 开箱即用:10 种语言运行时、2 个定理证明器、构建工具,还可继续安装更多。 |
30
+ | **高效利用 Token** | 常规任务通过代码自动化完成,让 AI Token 专注于创造性问题解决。 |
31
+ | **节省时间** | 人类需要 2~8 小时的工作,AI 每个工作会话仅需 10~25 分钟完成。可批量执行仓库中的任务。"代码在你睡觉时已写好。" |
32
+ | **编排式扩展** | 并行工作进程犹如一支开发团队,每月仅需约 $200。 |
33
+ | **人工控制** | AI 创建草稿 PR——由您决定是否合并。在关键节点设置质量把关。 |
34
+ | **任意设备编程** | 通过 Telegram 机器人使用 `/solve` 和 `/hive` 命令,在任意设备上管理 AI,无需 PC、IDE 或笔记本电脑。 |
35
+ | **100% 开源** | Unlicense(公共领域)。完全透明,无供应商锁定。 |
36
+
37
+ > _"与 $200 的 Codex 相比,这个解决方案简直是神器。"_ - 用户反馈
38
+
39
+ **费用**:Claude MAX 订阅(约 $200/月,目前五折优惠 = 价值 $400)可为 Hive Mind 提供几乎无限的使用量——市场上最佳的性价比。
40
+
41
+ Hive Mind 具备与普通程序员无异的高度创造力。当需求不明确时,它会主动提问,您也可以随时通过 PR 评论进行说明补充。
42
+
43
+ 详细功能和对比信息,请参见 [docs/FEATURES.zh.md](./docs/FEATURES.zh.md) 和 [docs/COMPARISON.zh.md](./docs/COMPARISON.zh.md)。
44
+
45
+ ## ⚠️ 警告
46
+
47
+ 在您的开发机上运行此软件是**不安全的**。
48
+
49
+ 建议使用 Docker 进行安装(本地和服务器均适用)。请参阅下方的 [Docker 安装](#使用-docker) 部分。
50
+
51
+ 本软件使用 Claude Code 的完全自主模式,这意味着它可以自由执行任何它认为合适的命令。
52
+
53
+ 这可能导致意想不到的副作用。
54
+
55
+ 此外,已知存在磁盘空间泄漏问题。因此,您需要确保能够重新安装虚拟机以清理空间和/或修复虚拟机损坏。
56
+
57
+ ### ⚠️ 重要:Token 与敏感数据安全
58
+
59
+ **本软件无法保证虚拟机上 TOKEN 或其他敏感数据的任何安全性。**
60
+
61
+ 从连接互联网的虚拟机中提取 Token 的方式多种多样,包括但不限于:
62
+
63
+ - **Claude MAX Token** - AI 操作所必需
64
+ - **GitHub Token** - 仓库访问所必需
65
+ - **API 密钥和凭证** - 系统上的任何敏感数据
66
+
67
+ **重要安全注意事项:**
68
+
69
+ - 在开发者机器上运行是**绝对不安全的**
70
+ - 在虚拟机上运行**相对安全**,但仍存在风险
71
+ - 即使您的开发机数据没有直接暴露,虚拟机中仍含有敏感 Token
72
+ - 任何存储在联网系统上的 Token 都可能被攻击
73
+
74
+ **使用本软件须完全自担风险与责任。**
75
+
76
+ 我们强烈建议:
77
+
78
+ - 使用专用的、隔离的虚拟机
79
+ - 定期轮换 Token
80
+ - 监控 Token 使用情况,发现可疑活动
81
+ - 切勿使用生产环境的 Token 或凭证
82
+ - 做好随时撤销并替换本系统所用所有 Token 的准备
83
+
84
+ 运行 `hive.mjs` 的最低系统要求:
85
+
86
+ ```
87
+ 1 CPU 核心
88
+ 1 GB RAM
89
+ > 4 GB SWAP
90
+ 50 GB 磁盘空间
91
+ ```
92
+
93
+ ## 🚀 快速开始
94
+
95
+ ### 全局安装
96
+
97
+ #### 使用 Bun(推荐)
98
+
99
+ ```bash
100
+ bun install -g @link-assistant/hive-mind
101
+ ```
102
+
103
+ #### 使用 Node.js
104
+
105
+ ```bash
106
+ npm install -g @link-assistant/hive-mind
107
+ ```
108
+
109
+ ### 安装 Docker
110
+
111
+ 如果您尚未安装 Docker,请按照以下步骤在 Ubuntu 上安装 Docker Engine:
112
+
113
+ ```bash
114
+ # Install prerequisites
115
+ sudo apt update
116
+ sudo apt install ca-certificates curl
117
+
118
+ # Add Docker's official GPG key
119
+ sudo install -m 0755 -d /etc/apt/keyrings
120
+ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
121
+ sudo chmod a+r /etc/apt/keyrings/docker.asc
122
+
123
+ # Add Docker repository
124
+ sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
125
+ Types: deb
126
+ URIs: https://download.docker.com/linux/ubuntu
127
+ Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
128
+ Components: stable
129
+ Signed-By: /etc/apt/keyrings/docker.asc
130
+ EOF
131
+
132
+ # Install Docker
133
+ sudo apt update
134
+ sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
135
+
136
+ # Verify installation
137
+ sudo docker run hello-world
138
+ ```
139
+
140
+ **其他操作系统**或详细安装说明,请参阅 [Docker 官方文档](https://docs.docker.com/engine/install/)。
141
+
142
+ ### 使用 Docker
143
+
144
+ 使用 Docker 运行 Hive Mind,实现更安全的本地安装,无需手动配置:
145
+
146
+ **注意:** Docker 对本地安装更为安全,也可用于在服务器或 Kubernetes 集群上安装多个隔离实例。Kubernetes 部署请参见下方的 [Helm chart 安装](#helm-安装kubernetes实验性) 部分。
147
+
148
+ ```bash
149
+ # Pull the latest image from Docker Hub
150
+ docker pull konard/hive-mind:latest
151
+
152
+ # Start hive-mind container
153
+ docker run -dit --name hive-mind konard/hive-mind:latest
154
+
155
+ # Verify container started
156
+ docker ps -a
157
+
158
+ # Enter additional terminal process to do installation
159
+ docker exec -it hive-mind /bin/bash
160
+
161
+ # Inside the container, authenticate with GitHub
162
+ gh-setup-git-identity
163
+
164
+ # Authenticate with Claude
165
+ claude
166
+
167
+ # Optionally set configuration like this:
168
+ # Use /config command and set:
169
+ # Reduce motion true # Will save your ssh trafic, and make Claude Code more responsive (less latency)
170
+ # Thinking mode false # Anthropic models perform better and cheaper without thinking
171
+ # Model haiku # chepear for connection testing manually
172
+ # Claude in Chrome enabled by default false # No need for Chrome support on server
173
+
174
+ # Optionally test Claude connection
175
+ claude -p hi --model haiku
176
+
177
+ # You might need to update hive-mind and agent to latest versions:
178
+ bun install -g @link-assistant/hive-mind
179
+ bun install -g @link-assistant/agent
180
+
181
+ # Now you can use hive and solve commands
182
+ solve https://github.com/owner/repo/issues/123
183
+
184
+ # Or you can run telegram bot:
185
+
186
+ # Exit from additional bash session
187
+ exit
188
+
189
+ # Attach to main bash process
190
+ docker attach hive-mind
191
+
192
+ # Run bot here
193
+
194
+ # Press Ctrl + P, Ctrl + Q to detach without destroying the container (no stopping of main bash process)
195
+
196
+ # --- Persisting auth data across restarts ---
197
+
198
+ # Extract auth data from a running (or stopped) container to the host:
199
+ mkdir -p ~/.hive-mind
200
+ docker cp hive-mind:/workspace/.claude ~/.hive-mind/claude
201
+ docker cp hive-mind:/workspace/.claude.json ~/.hive-mind/claude.json
202
+ docker cp hive-mind:/workspace/.config/gh ~/.hive-mind/gh
203
+
204
+ # Fix ownership to match the sandbox user inside the container:
205
+ SANDBOX_UID=$(docker exec hive-mind id -u sandbox)
206
+ chown -R $SANDBOX_UID:$SANDBOX_UID ~/.hive-mind/claude ~/.hive-mind/gh
207
+ chown $SANDBOX_UID:$SANDBOX_UID ~/.hive-mind/claude.json
208
+
209
+ # On subsequent runs, mount the auth data to keep it between restarts:
210
+ docker run -dit \
211
+ --name hive-mind \
212
+ --restart unless-stopped \
213
+ -v /root/.hive-mind/claude:/workspace/.claude \
214
+ -v /root/.hive-mind/claude.json:/workspace/.claude.json \
215
+ -v /root/.hive-mind/gh:/workspace/.config/gh \
216
+ konard/hive-mind:latest
217
+ ```
218
+
219
+ **Docker 的优势:**
220
+
221
+ - ✅ 预配置的 Ubuntu 24.04 环境
222
+ - ✅ 所有依赖项预先安装
223
+ - ✅ 与宿主系统隔离
224
+ - ✅ 可使用不同 GitHub 账号轻松运行多个实例
225
+ - ✅ 跨不同机器保持一致的环境
226
+
227
+ 高级 Docker 用法请参见 [docs/DOCKER.zh.md](./docs/DOCKER.zh.md)。
228
+
229
+ #### 停止并删除 Docker 容器
230
+
231
+ ```
232
+ # Attach to main docker process to stop the container
233
+ docker attach hive-mind
234
+
235
+ ^C # stop the telegram bot
236
+
237
+ exit # exit/stop the container
238
+
239
+ docker ps -a # show list of docker containers
240
+ # CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
241
+ # fd0fd4470ec3 konard/hive-mind:latest "/bin/bash" 5 days ago Exited (130) 16 seconds ago hive-mind
242
+
243
+
244
+ df -h # check disk space
245
+ # Filesystem Size Used Avail Use% Mounted on
246
+ # tmpfs 1.2G 1.1M 1.2G 1% /run
247
+ # /dev/sda1 96G 87G 9.8G 90% /
248
+ # tmpfs 5.9G 0 5.9G 0% /dev/shm
249
+ # tmpfs 5.0M 0 5.0M 0% /run/lock
250
+ # /dev/sda16 881M 117M 703M 15% /boot
251
+ # /dev/sda15 105M 6.2M 99M 6% /boot/efi
252
+ # tmpfs 1.2G 12K 1.2G 1% /run/user/0
253
+
254
+ docker rm hive-mind # remove docker container frees space used by the container, does not delete image
255
+
256
+ df -h # check disk space (to confirm space is freed)
257
+ # Filesystem Size Used Avail Use% Mounted on
258
+ # tmpfs 1.2G 1.1M 1.2G 1% /run
259
+ # /dev/sda1 96G 26G 71G 27% /
260
+ # tmpfs 5.9G 0 5.9G 0% /dev/shm
261
+ # tmpfs 5.0M 0 5.0M 0% /run/lock
262
+ # /dev/sda16 881M 117M 703M 15% /boot
263
+ # /dev/sda15 105M 6.2M 99M 6% /boot/efi
264
+ # tmpfs 1.2G 12K 1.2G 1% /run/user/0
265
+ ```
266
+
267
+ ### Helm 安装(Kubernetes)(实验性)
268
+
269
+ > ⚠️ **实验性:** Helm/Kubernetes 安装方式为实验性功能,可能不完全稳定。
270
+ >
271
+ > 如需更可靠的安装,建议改用 [Docker](#使用-docker)。
272
+ >
273
+ > 完整的 Helm 安装说明和配置选项请参见 [docs/HELM.zh.md](./docs/HELM.zh.md)。
274
+
275
+ ### 在 Ubuntu 24.04 服务器上安装(已弃用)
276
+
277
+ > ⚠️ **已弃用:** 此安装方式不再推荐。
278
+ >
279
+ > **现在我们建议所有安装均使用 Docker**,无论是开发机还是服务器。
280
+ > Docker 提供更好的隔离性、更简便的管理方式和一致的环境。
281
+ >
282
+ > 请使用上方的 [Docker 安装方式](#使用-docker)。
283
+ > Kubernetes 部署请参见 [Helm 安装](#helm-安装kubernetes实验性) 部分。
284
+ >
285
+ > 旧版裸机安装说明已移至 [docs/UBUNTU-SERVER.zh.md](./docs/UBUNTU-SERVER.zh.md) 供参考。
286
+
287
+ ### 核心操作
288
+
289
+ ```bash
290
+ # Solve using maximum power
291
+ solve https://github.com/Veronika89-lang/index.html/issues/1 --attach-logs --verbose --model opus --think max
292
+
293
+ # Solve GitHub issues automatically
294
+ solve https://github.com/owner/repo/issues/123 --model sonnet
295
+
296
+ # Solve issue with PR to custom branch (manual fork mode)
297
+ solve https://github.com/owner/repo/issues/123 --base-branch develop --fork
298
+
299
+ # Continue working on existing PR
300
+ solve https://github.com/owner/repo/pull/456 --model opus
301
+
302
+ # Resume from Claude session when limit is reached
303
+ solve https://github.com/owner/repo/issues/123 --resume session-id
304
+
305
+ # Start hive orchestration (monitor and solve issues automatically)
306
+ hive https://github.com/owner/repo --monitor-tag "help wanted" --concurrency 3
307
+
308
+ # Monitor all issues in organization
309
+ hive https://github.com/microsoft --all-issues --max-issues 10
310
+
311
+ # Run collaborative review process
312
+ review --repo owner/repo --pr 456
313
+
314
+ # Multiple AI reviewers for consensus
315
+ ./reviewers-hive.mjs --agents 3 --consensus-threshold 0.8
316
+ ```
317
+
318
+ ## 📋 核心组件
319
+
320
+ | 脚本 | 用途 | 核心功能 |
321
+ | ------------------------------------ | ------------------- | ------------------------------------------------- |
322
+ | `solve.mjs`(稳定版) | GitHub Issue 解决器 | 自动 Fork、分支创建、PR 生成、会话恢复、Fork 支持 |
323
+ | `hive.mjs`(稳定版) | AI 编排与监控 | 多仓库监控、并发工作进程、Issue 队列管理 |
324
+ | `review.mjs`(Alpha 版) | 代码审查自动化 | 协作式 AI 审查、自动反馈 |
325
+ | `reviewers-hive.mjs`(Alpha/实验性) | 审查团队管理 | 多 Agent 共识、审查者分配 |
326
+ | `telegram-bot.mjs`(稳定版) | Telegram 机器人接口 | 远程命令执行、群聊支持、诊断工具 |
327
+
328
+ ## 🔧 solve 选项
329
+
330
+ ```bash
331
+ solve <issue-url> [options]
332
+ ```
333
+
334
+ **最常用选项:**
335
+
336
+ | 选项 | 简写 | 描述 | 默认值 |
337
+ | --------------- | ---- | ------------------------------------- | -------- |
338
+ | `--model` | `-m` | 使用的 AI 模型(sonnet、opus、haiku) | sonnet |
339
+ | `--think` | | 思考级别(low、medium、high、max) | - |
340
+ | `--base-branch` | `-b` | PR 的目标分支 | (默认) |
341
+
342
+ **其他常用选项:**
343
+
344
+ | 选项 | 简写 | 描述 | 默认值 |
345
+ | ------------------------ | ---- | ----------------------------------------- | ------ |
346
+ | `--tool` | | AI 工具(claude、opencode、codex、agent) | claude |
347
+ | `--verbose` | `-v` | 启用详细日志 | false |
348
+ | `--attach-logs` | | 将日志附加到 PR(⚠️ 可能暴露敏感数据) | false |
349
+ | `--auto-init-repository` | | 自动初始化空仓库(创建 README.md) | false |
350
+ | `--help` | `-h` | 显示所有可用选项 | - |
351
+
352
+ > **📖 完整选项列表**:包含 Fork、自动续行、监视模式及实验性功能在内的所有可用选项,请参见 [docs/CONFIGURATION.zh.md](./docs/CONFIGURATION.zh.md#solve-options)。
353
+
354
+ ## 🔧 hive 选项
355
+
356
+ ```bash
357
+ hive <github-url> [options]
358
+ ```
359
+
360
+ **最常用选项:**
361
+
362
+ | 选项 | 简写 | 描述 | 默认值 |
363
+ | -------------- | ---- | ------------------------------------- | ------ |
364
+ | `--model` | `-m` | 使用的 AI 模型(sonnet、opus、haiku) | sonnet |
365
+ | `--think` | | 思考级别(low、medium、high、max) | - |
366
+ | `--all-issues` | `-a` | 监控所有 Issue(忽略标签) | false |
367
+ | `--once` | | 单次运行(不持续监控) | false |
368
+
369
+ **其他常用选项:**
370
+
371
+ | 选项 | 简写 | 描述 | 默认值 |
372
+ | ------------------------ | ---- | -------------------------------------- | ------ |
373
+ | `--tool` | | AI 工具(claude、opencode、agent) | claude |
374
+ | `--concurrency` | `-c` | 并行工作进程数量 | 2 |
375
+ | `--skip-issues-with-prs` | `-s` | 跳过已有 PR 的 Issue | false |
376
+ | `--verbose` | `-v` | 启用详细日志 | false |
377
+ | `--attach-logs` | | 将日志附加到 PR(⚠️ 可能暴露敏感数据) | false |
378
+ | `--help` | `-h` | 显示所有可用选项 | - |
379
+
380
+ > **📖 完整选项列表**:包含项目监控、YouTrack 集成及实验性功能在内的所有可用选项,请参见 [docs/CONFIGURATION.zh.md](./docs/CONFIGURATION.zh.md#hive-options)。
381
+
382
+ ## 🤖 Telegram 机器人
383
+
384
+ Hive Mind 内置 Telegram 机器人接口(SwarmMindBot),支持远程命令执行。
385
+
386
+ ### 🚀 试用体验
387
+
388
+ 想亲眼看看 Hive Mind 的实际效果?欢迎直接在 Telegram 上联系开发者,申请免费演示或获得更快的支持:
389
+
390
+ **[在 Telegram 上联系 @drakonard](https://t.me/drakonard)**
391
+
392
+ ### 设置
393
+
394
+ 1. **获取 Bot Token**
395
+ - 在 Telegram 上联系 [@BotFather](https://t.me/BotFather)
396
+ - 创建一个新机器人并获取您的 Token
397
+ - 将机器人添加到您的群聊并设置为管理员
398
+
399
+ 2. **配置环境**
400
+
401
+ ```bash
402
+ # Copy the example configuration
403
+ cp .env.example .env
404
+
405
+ # Edit and add your bot token
406
+ echo "TELEGRAM_BOT_TOKEN=your_bot_token_here" >> .env
407
+
408
+ # Optional: Restrict to specific chats
409
+ # Get chat ID using /help command, then add:
410
+ echo "TELEGRAM_ALLOWED_CHATS=123456789,987654321" >> .env
411
+ ```
412
+
413
+ 3. **启动机器人**
414
+
415
+ ```bash
416
+ hive-telegram-bot
417
+ ```
418
+
419
+ **推荐:使用 tee 捕获日志**
420
+
421
+ 长时间运行机器人时,建议使用 `tee` 将日志同时输出到文件。这样即使终端缓冲区溢出,您也可以在事后查看日志:
422
+
423
+ ```bash
424
+ hive-telegram-bot 2>&1 | tee -a logs/bot-$(date +%Y%m%d).log
425
+ ```
426
+
427
+ 或创建日志目录并启用自动日志轮转:
428
+
429
+ ```bash
430
+ mkdir -p logs
431
+ hive-telegram-bot 2>&1 | tee -a "logs/bot-$(date +%Y%m%d-%H%M%S).log"
432
+ ```
433
+
434
+ ### 机器人命令
435
+
436
+ 所有命令仅在**群聊中**有效(不支持与机器人的私聊):
437
+
438
+ #### `/solve` - 解决 GitHub Issue
439
+
440
+ ```
441
+ /solve <github-url> [options]
442
+
443
+ Examples:
444
+ /solve https://github.com/owner/repo/issues/123 --model sonnet
445
+ /solve https://github.com/owner/repo/issues/123 --model opus --think max
446
+
447
+ Free Models (with --tool agent):
448
+ /solve https://github.com/owner/repo/issues/123 --tool agent --model nemotron-3-super-free
449
+ /solve https://github.com/owner/repo/issues/123 --tool agent --model opencode/nemotron-3-super-free
450
+ /solve https://github.com/owner/repo/issues/123 --tool agent --model minimax-m2.5-free
451
+ /solve https://github.com/owner/repo/issues/123 --tool agent --model gpt-5-nano
452
+
453
+ Free Models via Kilo Gateway (with --tool agent):
454
+ /solve https://github.com/owner/repo/issues/123 --tool agent --model kilo/glm-5-free
455
+ /solve https://github.com/owner/repo/issues/123 --tool agent --model kilo/glm-4.5-air-free
456
+ /solve https://github.com/owner/repo/issues/123 --tool agent --model kilo/deepseek-r1-free
457
+ ```
458
+
459
+ > **📖 免费模型指南**:有关所有免费模型(包括 OpenCode Zen 和 Kilo Gateway 提供商)的全面信息,请参见 [docs/FREE_MODELS.zh.md](./docs/FREE_MODELS.zh.md)。
460
+
461
+ #### `/hive` - 运行蜂群编排
462
+
463
+ ```
464
+ /hive <github-url> [options]
465
+
466
+ Examples:
467
+ /hive https://github.com/owner/repo
468
+ /hive https://github.com/owner/repo --all-issues --max-issues 10
469
+ /hive https://github.com/microsoft --all-issues --concurrency 3
470
+ ```
471
+
472
+ #### `/limits` - 显示用量限制
473
+
474
+ ```
475
+ /limits
476
+
477
+ Shows:
478
+ - CPU usage and load average
479
+ - RAM usage (used vs total)
480
+ - Disk space usage
481
+ - GitHub API rate limits
482
+ - Claude usage limits (session and weekly)
483
+ ```
484
+
485
+ #### `/help` - 获取帮助和诊断信息
486
+
487
+ ```
488
+ /help
489
+
490
+ Shows:
491
+ - Chat ID (needed for TELEGRAM_ALLOWED_CHATS)
492
+ - Chat type
493
+ - Available commands
494
+ - Usage examples
495
+ ```
496
+
497
+ ### 功能特性
498
+
499
+ - ✅ **仅限群聊**:命令仅在群聊中有效(不支持私聊)
500
+ - ✅ **完整选项支持**:所有命令行选项均可在 Telegram 中使用
501
+ - ✅ **Screen 会话**:命令在后台 Screen 会话中运行
502
+ - ✅ **聊天限制**:可选配置允许的聊天 ID 白名单
503
+ - ✅ **诊断工具**:获取聊天 ID 和配置信息
504
+
505
+ ### 安全注意事项
506
+
507
+ - 仅在机器人为管理员的群聊中有效
508
+ - 可通过 `TELEGRAM_ALLOWED_CHATS` 配置可选的聊天 ID 限制
509
+ - 命令以运行机器人的系统用户身份执行
510
+ - 请确保已完成正确的身份验证(`gh auth login`、`claude-profiles`)
511
+
512
+ ## 🏆 最佳实践
513
+
514
+ 当仓库拥有完善的 CI/CD 流水线和清晰的 Issue 需求时,Hive Mind 的效果更佳。请参阅:
515
+
516
+ - [BEST-PRACTICES.zh.md](./docs/BEST-PRACTICES.zh.md) — 通用提示、Issue 编写指南、架构改进和子 Agent 模式
517
+ - [CI-CD-BEST-PRACTICES.zh.md](./docs/CI-CD-BEST-PRACTICES.zh.md) — CI/CD 流水线设置、推荐模板和执行策略
518
+
519
+ 完善 CI/CD 的核心优势:
520
+
521
+ - AI 解决器持续迭代直到所有检查通过
522
+ - 无论人类/AI 团队构成如何,均保持一致的质量
523
+ - 文件大小限制确保代码对 AI 和人类均可读
524
+
525
+ 现已提供适用于 JavaScript、Rust、Python、Go、C# 和 Java 的开箱即用模板。
526
+
527
+ ## 🏗️ 架构
528
+
529
+ Hive Mind 基于三个层次运作:
530
+
531
+ 1. **编排层**(`hive.mjs`)- 协调多个 AI Agent
532
+ 2. **执行层**(`solve.mjs`、`review.mjs`)- 执行具体任务
533
+ 3. **人机交互层** - 支持人类与 AI 协作
534
+
535
+ ### 数据流
536
+
537
+ #### 模式一:Issue → Pull Request 流程
538
+
539
+ ```mermaid
540
+ sequenceDiagram
541
+ participant H as 人类
542
+ participant GH as GitHub
543
+ participant AI as AI Agent
544
+ participant HM as Hive Mind
545
+
546
+ H->>GH: 创建 Issue
547
+ Note over H,GH: 主要人工输入
548
+
549
+ GH->>HM: Issue 可用
550
+ HM->>AI: 分配 Issue
551
+ AI->>GH: 分析 Issue
552
+ AI->>AI: 开发解决方案
553
+ AI->>GH: 创建草稿 PR
554
+
555
+ Note over H,GH: 人工决策节点
556
+ GH->>H: 通知 PR 已创建
557
+ H->>GH: 审查 PR
558
+
559
+ alt 批准并合并
560
+ H->>GH: 合并 PR
561
+ GH->>HM: PR 已合并
562
+ else 请求修改
563
+ H->>GH: 添加评论
564
+ Note over H,GH: 次要人工输入
565
+ GH->>HM: 评论已添加
566
+ HM->>AI: 处理反馈
567
+ AI->>GH: 更新 PR
568
+ else 关闭 PR
569
+ H->>GH: 关闭 PR
570
+ GH->>HM: PR 已关闭
571
+ end
572
+ ```
573
+
574
+ #### 模式二:Pull Request → 评论流程
575
+
576
+ ```mermaid
577
+ sequenceDiagram
578
+ participant H as 人类
579
+ participant GH as GitHub
580
+ participant AI as AI Agent
581
+ participant HM as Hive Mind
582
+
583
+ Note over GH: 已有 PR
584
+ H->>GH: 添加评论
585
+ Note over H,GH: 主要人工输入
586
+
587
+ GH->>HM: 新评论可用
588
+ HM->>AI: 处理评论
589
+ AI->>GH: 分析反馈
590
+ AI->>AI: 更新解决方案
591
+ AI->>GH: 推送更改
592
+
593
+ Note over H,GH: 人工决策节点
594
+ GH->>H: 通知更改
595
+ H->>GH: 审查更新
596
+
597
+ alt 批准并合并
598
+ H->>GH: 合并 PR
599
+ GH->>HM: PR 已合并
600
+ else 需要更多更改
601
+ H->>GH: 添加更多评论
602
+ Note over H,GH: 继续人工输入
603
+ GH->>HM: 评论已添加
604
+ else 关闭 PR
605
+ H->>GH: 关闭 PR
606
+ GH->>HM: PR 已关闭
607
+ end
608
+ ```
609
+
610
+ 📖 **完整的数据流文档(包含人类反馈集成节点),请参见 [docs/flow.zh.md](./docs/flow.zh.md)**
611
+
612
+ ## 📊 使用示例
613
+
614
+ ### 自动化 Issue 解决
615
+
616
+ ```bash
617
+ # Solve issue (automatically forks if no write access)
618
+ solve https://github.com/owner/repo/issues/123 --model opus
619
+
620
+ # Manual fork and solve issue (works for both public and private repos)
621
+ solve https://github.com/owner/repo/issues/123 --fork --model opus
622
+
623
+ # Continue work on existing PR
624
+ solve https://github.com/owner/repo/pull/456 --verbose
625
+
626
+ # Solve with detailed logging and solution attachment
627
+ solve https://github.com/owner/repo/issues/123 --verbose --attach-logs
628
+
629
+ # Dry run to see what would happen
630
+ solve https://github.com/owner/repo/issues/123 --dry-run
631
+ ```
632
+
633
+ ### 多仓库编排
634
+
635
+ ```bash
636
+ # Monitor single repository with specific label
637
+ hive https://github.com/owner/repo --monitor-tag "bug" --concurrency 4
638
+
639
+ # Monitor all issues in an organization
640
+ hive https://github.com/microsoft --all-issues --max-issues 20 --once
641
+
642
+ # Monitor user repositories with high concurrency
643
+ hive https://github.com/username --all-issues --concurrency 8 --interval 120
644
+
645
+ # Skip issues that already have PRs
646
+ hive https://github.com/org/repo --skip-issues-with-prs --verbose
647
+
648
+ # Auto-cleanup temporary files
649
+ hive https://github.com/org/repo --auto-cleanup --concurrency 5
650
+ ```
651
+
652
+ ### 会话管理
653
+
654
+ ```bash
655
+ # Resume when Claude hits limit
656
+ solve https://github.com/owner/repo/issues/123 --resume 657e6db1-6eb3-4a8d
657
+
658
+ # Continue session interactively in Claude Code
659
+ (cd /tmp/gh-issue-solver-123456789 && claude --resume session-id)
660
+ ```
661
+
662
+ ## 🔍 监控与日志
663
+
664
+ 在日志中查找恢复命令:
665
+
666
+ ```bash
667
+ grep -E '\(cd /tmp/gh-issue-solver-[0-9]+ && claude --resume [0-9a-f-]{36}\)' hive-*.log
668
+ ```
669
+
670
+ ## 🔧 配置
671
+
672
+ **身份验证:**
673
+
674
+ - `gh auth login` - GitHub CLI 身份验证
675
+ - `claude-profiles` - 将 Claude 身份验证配置文件迁移到服务器
676
+
677
+ **OpenRouter 集成:**
678
+
679
+ 使用 OpenRouter 通过单一 API 密钥访问来自 60+ 提供商的 500+ AI 模型。设置说明(涵盖 Claude Code CLI 和 @link-assistant/agent)请参见 [docs/OPENROUTER.zh.md](./docs/OPENROUTER.zh.md)。
680
+
681
+ **环境变量与高级选项:**
682
+
683
+ 包含环境变量、超时、重试限制、Telegram 机器人设置、YouTrack 集成及所有 CLI 选项在内的全面配置,请参见 [docs/CONFIGURATION.zh.md](./docs/CONFIGURATION.zh.md)。
684
+
685
+ ## 🐛 问题反馈
686
+
687
+ ### Hive Mind 问题
688
+
689
+ 如果您遇到 **Hive Mind**(本项目)的问题,请在我们的 GitHub Issues 页面提交反馈:
690
+
691
+ - **仓库**:https://github.com/link-assistant/hive-mind
692
+ - **Issues**:https://github.com/link-assistant/hive-mind/issues
693
+
694
+ ### Claude Code CLI 问题
695
+
696
+ 如果您遇到 **Claude Code CLI** 本身的问题(例如 `claude` 命令报错、安装问题或 CLI 缺陷),请向官方 Claude Code 仓库提交反馈:
697
+
698
+ - **仓库**:https://github.com/anthropics/claude-code
699
+ - **Issues**:https://github.com/anthropics/claude-code/issues
700
+
701
+ ## 🛡️ 文件大小限制
702
+
703
+ 所有文档文件均会自动检查:
704
+
705
+ ```bash
706
+ find docs/ -name "*.md" -exec wc -l {} + | awk '$1 > 1000 {print "ERROR: " $2 " has " $1 " lines (max 1000)"}'
707
+ ```
708
+
709
+ ## 服务器诊断
710
+
711
+ 识别消耗资源的进程所属的 Screen 会话:
712
+
713
+ ```bash
714
+ TARGETS="62220 65988 63094 66606 1028071 4127023"
715
+
716
+ # build screen PID -> session name map
717
+ declare -A NAME
718
+ while read -r id; do spid=${id%%.*}; NAME[$spid]="$id"; done \
719
+ < <(screen -ls | awk '/(Detached|Attached)/{print $1}')
720
+
721
+ # check each PID's environment for STY and map back to session
722
+ for p in $TARGETS; do
723
+ sty=$(tr '\0' '\n' < /proc/$p/environ 2>/dev/null | awk -F= '$1=="STY"{print $2}')
724
+ if [ -n "$sty" ]; then
725
+ spid=${sty%%.*}
726
+ echo "$p -> ${NAME[$spid]:-$sty}"
727
+ else
728
+ echo "$p -> (no STY; not from screen or env cleared / double-forked)"
729
+ fi
730
+ done
731
+ ```
732
+
733
+ 显示进程详细信息:
734
+
735
+ ```bash
736
+ procinfo() {
737
+ local pid=$1
738
+ if [ -z "$pid" ]; then
739
+ echo "Usage: procinfo <pid>"
740
+ return 1
741
+ fi
742
+ if [ ! -d "/proc/$pid" ]; then
743
+ echo "Process $pid not found."
744
+ return 1
745
+ fi
746
+
747
+ echo "=== Process $pid ==="
748
+ # Basic process info
749
+ ps -p "$pid" -o user=,uid=,pid=,ppid=,c=,stime=,etime=,tty=,time=,cmd=
750
+
751
+ echo
752
+ # Working directory
753
+ echo "CWD: $(readlink -f /proc/$pid/cwd 2>/dev/null)"
754
+
755
+ # Executable path
756
+ echo "EXE: $(readlink -f /proc/$pid/exe 2>/dev/null)"
757
+
758
+ # Root directory of the process
759
+ echo "ROOT: $(readlink -f /proc/$pid/root 2>/dev/null)"
760
+
761
+ # Command line (full, raw)
762
+ echo "CMDLINE:"
763
+ tr '\0' ' ' < /proc/$pid/cmdline 2>/dev/null
764
+ echo
765
+
766
+ # Environment variables
767
+ echo
768
+ echo "ENVIRONMENT (key=value):"
769
+ tr '\0' '\n' < /proc/$pid/environ 2>/dev/null | head -n 20
770
+
771
+ # Open files (first few)
772
+ echo
773
+ echo "OPEN FILES:"
774
+ ls -l /proc/$pid/fd 2>/dev/null | head -n 10
775
+
776
+ # Child processes
777
+ echo
778
+ echo "CHILDREN:"
779
+ ps --ppid "$pid" -o pid=,cmd= 2>/dev/null
780
+ }
781
+ procinfo 62220
782
+ ```
783
+
784
+ ## 维护
785
+
786
+ ### 进入最新 Screen 会话
787
+
788
+ ```bash
789
+ s=$(screen -ls | awk '/Detached/ {print $1; exit}'); echo "Entering $s"; screen -r "$s"; echo "Left $s";
790
+ ```
791
+
792
+ ### 进入最旧 Screen 会话
793
+
794
+ ```bash
795
+ s=$(screen -ls | awk '/Detached/ {last=$1} END{print last}'); echo "Entering $s"; screen -r "$s"; echo "Left $s";
796
+ ```
797
+
798
+ ### 重启服务器
799
+
800
+ ```bash
801
+ sudo reboot
802
+ ```
803
+
804
+ 这将清除所有悬空的未使用进程和 Screen 会话,从而释放 RAM 并降低 CPU 负载。另外,重启可能会清除所有临时文件,因此如果已重启,下一步可能不需要执行任何操作。
805
+
806
+ ### 清理磁盘空间
807
+
808
+ ```bash
809
+ df -h
810
+
811
+ rm -rf /tmp
812
+
813
+ df -h
814
+ ```
815
+
816
+ 这些命令应在 `hive` 用户下执行。如果您不小心以 `root` 用户身份删除了 `/tmp` 目录本身,需要通过以下方式恢复:
817
+
818
+ ```bash
819
+ sudo mkdir -p /tmp
820
+ sudo chown root:root /tmp
821
+ sudo chmod 1777 /tmp
822
+ ```
823
+
824
+ ### 关闭所有 Screen 会话以释放 RAM
825
+
826
+ ```bash
827
+ # close all (Attached or Detached) sessions
828
+ screen -ls | awk '/(Detached|Attached)/{print $1}' \
829
+ | while read s; do screen -S "$s" -X quit; done
830
+
831
+ # remove any zombie sockets
832
+ screen -wipe
833
+
834
+ # verify
835
+ screen -ls
836
+ ```
837
+
838
+ ### 显示完整命令参数的 Top
839
+
840
+ ```bash
841
+ top -c
842
+ ```
843
+
844
+ ### 查看完整进程树
845
+
846
+ ```bash
847
+ ps -eo pid,ppid,user,args --forest
848
+ ```
849
+
850
+
851
+
852
+ ```bash
853
+ ps axjf
854
+ ```
855
+
856
+ ### 终止由特定任务派生的所有命令
857
+
858
+ ```bash
859
+ pkill -f gh-issue-solver-1773073065743
860
+ ```
861
+
862
+ ### 终止由 ms-playwright 派生的所有无头浏览器
863
+
864
+ ```bash
865
+ pkill -f ms-playwright/chromium_headless_shell-1200
866
+ ```
867
+
868
+ 此操作可以执行,但不推荐,因为重启服务器效果更好。
869
+
870
+ ## 📄 许可证
871
+
872
+ Unlicense 许可证 - 参见 [LICENSE](./LICENSE)
873
+
874
+ ## 🤖 贡献
875
+
876
+ 本项目采用 AI 驱动的开发模式。人机协作指南请参见 [CONTRIBUTING.zh.md](./docs/CONTRIBUTING.zh.md)。