kitty-hive 0.1.1 → 0.2.0

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.
Files changed (60) hide show
  1. package/README.md +106 -129
  2. package/README.zh.md +136 -105
  3. package/channel.ts +194 -431
  4. package/dist/auth.d.ts +10 -6
  5. package/dist/auth.js +32 -17
  6. package/dist/auth.js.map +1 -1
  7. package/dist/db.d.ts +32 -16
  8. package/dist/db.js +210 -113
  9. package/dist/db.js.map +1 -1
  10. package/dist/federation-http.d.ts +2 -0
  11. package/dist/federation-http.js +233 -0
  12. package/dist/federation-http.js.map +1 -0
  13. package/dist/index.js +79 -76
  14. package/dist/index.js.map +1 -1
  15. package/dist/log.d.ts +3 -0
  16. package/dist/log.js +10 -0
  17. package/dist/log.js.map +1 -0
  18. package/dist/mcp/agent-tools.d.ts +2 -0
  19. package/dist/mcp/agent-tools.js +66 -0
  20. package/dist/mcp/agent-tools.js.map +1 -0
  21. package/dist/mcp/dm-tools.d.ts +2 -0
  22. package/dist/mcp/dm-tools.js +54 -0
  23. package/dist/mcp/dm-tools.js.map +1 -0
  24. package/dist/mcp/federation-tools.d.ts +2 -0
  25. package/dist/mcp/federation-tools.js +30 -0
  26. package/dist/mcp/federation-tools.js.map +1 -0
  27. package/dist/mcp/server.d.ts +2 -0
  28. package/dist/mcp/server.js +62 -0
  29. package/dist/mcp/server.js.map +1 -0
  30. package/dist/mcp/task-tools.d.ts +2 -0
  31. package/dist/mcp/task-tools.js +128 -0
  32. package/dist/mcp/task-tools.js.map +1 -0
  33. package/dist/mcp/team-tools.d.ts +2 -0
  34. package/dist/mcp/team-tools.js +95 -0
  35. package/dist/mcp/team-tools.js.map +1 -0
  36. package/dist/models.d.ts +22 -10
  37. package/dist/models.js +1 -3
  38. package/dist/models.js.map +1 -1
  39. package/dist/server.d.ts +2 -3
  40. package/dist/server.js +38 -761
  41. package/dist/server.js.map +1 -1
  42. package/dist/sessions.d.ts +15 -0
  43. package/dist/sessions.js +107 -0
  44. package/dist/sessions.js.map +1 -0
  45. package/dist/tools/dm.d.ts +3 -2
  46. package/dist/tools/dm.js +14 -29
  47. package/dist/tools/dm.js.map +1 -1
  48. package/dist/tools/start.d.ts +3 -3
  49. package/dist/tools/start.js +18 -15
  50. package/dist/tools/start.js.map +1 -1
  51. package/dist/tools/task.d.ts +1 -1
  52. package/dist/tools/task.js +6 -5
  53. package/dist/tools/task.js.map +1 -1
  54. package/dist/tools/team.d.ts +62 -13
  55. package/dist/tools/team.js +102 -30
  56. package/dist/tools/team.js.map +1 -1
  57. package/package.json +2 -2
  58. package/dist/tools/room.d.ts +0 -39
  59. package/dist/tools/room.js +0 -35
  60. package/dist/tools/room.js.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <p align="center">
2
2
  <h1 align="center">kitty-hive</h1>
3
3
  <p align="center">
4
- Room-first MCP server for multi-agent collaboration
4
+ MCP server for multi-agent collaboration
5
5
  <br />
6
6
  <a href="./README.zh.md">中文文档</a>
7
7
  </p>
@@ -13,21 +13,32 @@ A single-process HTTP server backed by SQLite that lets AI agents talk to each o
13
13
 
14
14
  ## Quick Start
15
15
 
16
- ```bash
17
- # Install globally
18
- npm install -g kitty-hive
16
+ ### Claude Code
19
17
 
20
- # 1. Start the server
21
- kitty-hive serve --port 4123
18
+ ```bash
19
+ # 1. Add marketplace & install plugin (one-time)
20
+ /plugin marketplace add seangx/kitty-hive
21
+ /plugin install kitty-hive@seangx
22
22
 
23
- # 2. In your project directory
24
- kitty-hive init myagent
23
+ # 2. Start server (in a separate terminal)
24
+ npx kitty-hive serve
25
25
 
26
- # 3. Launch Claude Code
27
- claude --dangerously-load-development-channels server:hive-channel
26
+ # 3. Launch Claude Code with channel support
27
+ claude --dangerously-load-development-channels plugin:kitty-hive@seangx
28
28
  ```
29
29
 
30
- That's it. Your agent is registered and can send/receive messages.
30
+ On first use, ask the agent to call `hive-whoami(name=<your-name>)` to register.
31
+ Set `HIVE_AGENT_NAME=<name>` (or `HIVE_AGENT_ID=<id>`) in the env to skip this and auto-register on launch.
32
+
33
+ ### Other IDEs (Antigravity, Cursor, VS Code, etc.)
34
+
35
+ ```bash
36
+ # 1. Start server
37
+ npx kitty-hive serve
38
+
39
+ # 2. Configure MCP in your project
40
+ npx kitty-hive init
41
+ ```
31
42
 
32
43
  ## How It Works
33
44
 
@@ -51,52 +62,72 @@ That's it. Your agent is registered and can send/receive messages.
51
62
  └─────────────┘ └─────────────┘
52
63
  ```
53
64
 
54
- **Channel plugin** (Claude Code) — Messages appear in your conversation automatically:
65
+ **Claude Code** — Messages appear in your conversation automatically via channel plugin.
55
66
 
56
- ```
57
- <channel source="hive-channel" from="bob" room_id="..." type="message">
58
- Hey alice, can you review this component?
59
- </channel>
60
- ```
67
+ **Other IDEs** — Use `hive.inbox` to check for messages.
61
68
 
62
- **HTTP MCP** (other IDEs) — Use `hive.inbox` to check for messages manually.
69
+ ## Identity model
63
70
 
64
- ## Connection Modes
71
+ - **`agent_id`** (ULID) — your stable cross-team handle. Returned by `hive-whoami`.
72
+ - **`display_name`** — human-readable, **not unique**.
73
+ - **team `nickname`** — per-team unique label (set via `hive-team-nickname`).
65
74
 
66
- ### Channel Plugin (Claude Code, recommended)
75
+ `to` parameter (DM, task) accepts: agent id, team-nickname (within your teams), or display_name (only if unambiguous). Cross-node: `id@node` (federation).
67
76
 
68
- Real-time push notifications into your conversation context.
77
+ ## Tools
69
78
 
70
- ```bash
71
- kitty-hive init myagent # writes .mcp.json
72
- claude --dangerously-load-development-channels server:hive-channel
73
- ```
79
+ The channel plugin auto-mirrors HTTP server tools as kebab-case (`hive.team.create` → `hive-team-create`). The lists below are the same set, with `hive-` for channel and `hive.` for HTTP.
74
80
 
75
- Or configure manually in `.mcp.json`:
81
+ ### Identity
76
82
 
77
- ```json
78
- {
79
- "mcpServers": {
80
- "hive-channel": {
81
- "command": "npx",
82
- "args": ["tsx", "node_modules/kitty-hive/channel.ts"],
83
- "env": {
84
- "HIVE_URL": "http://localhost:4123/mcp",
85
- "HIVE_AGENT_NAME": "myagent"
86
- }
87
- }
88
- }
89
- }
90
- ```
83
+ | Channel | HTTP | Description |
84
+ |---------|------|-------------|
85
+ | `hive-whoami` | `hive.whoami` | Show your agent id / register on first call |
86
+ | `hive-rename` | `hive.rename` | Change your global display_name |
87
+ | `hive-agents` | `hive.agents` | List all agents on the hive |
91
88
 
92
- ### HTTP MCP (Antigravity, Cursor, VS Code, etc.)
89
+ ### DM & Inbox
93
90
 
94
- ```bash
95
- kitty-hive init myagent --http # writes .mcp.json
96
- ```
91
+ | Channel | HTTP | Description |
92
+ |---------|------|-------------|
93
+ | `hive-dm` | `hive.dm` | Send a direct message |
94
+ | `hive-inbox` | `hive.inbox` | Check unread DMs / team / task events |
95
+
96
+ ### Teams
97
+
98
+ | Channel | HTTP | Description |
99
+ |---------|------|-------------|
100
+ | `hive-team-create` | `hive.team.create` | Create a team (optional nickname) |
101
+ | `hive-team-join` | `hive.team.join` | Join a team by name or id |
102
+ | `hive-team-list` | `hive.team.list` | List all open teams |
103
+ | `hive-teams` | `hive.teams` | List teams you are in |
104
+ | `hive-team-info` | `hive.team.info` | Members + recent events |
105
+ | `hive-team-events` | `hive.team.events` | Fetch events with `since` |
106
+ | `hive-team-message` | `hive.team.message` | Broadcast to team |
107
+ | `hive-team-nickname` | `hive.team.nickname` | Set/clear nickname in a team |
108
+
109
+ ### Tasks & Workflow
110
+
111
+ | Channel | HTTP | Description |
112
+ |---------|------|-------------|
113
+ | `hive-task` | `hive.task` | Create & delegate (`to` accepts id, nickname, `role:xxx`, `id@node`) |
114
+ | `hive-task-claim` | `hive.task.claim` | Claim an unassigned task |
115
+ | `hive-tasks` | `hive.tasks` | List your tasks |
116
+ | `hive-check` | `hive.check` | Check task status |
117
+ | `hive-workflow-propose` | `hive.workflow.propose` | Propose workflow steps |
118
+ | `hive-workflow-approve` | `hive.workflow.approve` | Approve (creator only) |
119
+ | `hive-workflow-step-complete` | `hive.workflow.step.complete` | Complete a step |
120
+ | `hive-workflow-reject` | `hive.workflow.reject` | Reject & rollback |
121
+
122
+ ### Federation
123
+
124
+ | Channel | HTTP | Description |
125
+ |---------|------|-------------|
126
+ | `hive-peers` | `hive.peers` | List federation peers |
127
+ | `hive-remote-agents` | `hive.remote.agents` | List agents on a peer |
97
128
 
98
129
  <details>
99
- <summary>Manual configuration for each IDE</summary>
130
+ <summary>Manual MCP configuration for each IDE</summary>
100
131
 
101
132
  **Antigravity** (`mcp_config.json`):
102
133
  ```json
@@ -123,62 +154,14 @@ kitty-hive init myagent --http # writes .mcp.json
123
154
 
124
155
  </details>
125
156
 
126
- ## Tools
127
-
128
- ### Channel Plugin
129
-
130
- | Tool | Description |
131
- |------|-------------|
132
- | `hive-dm` | Send a direct message |
133
- | `hive-inbox` | Check unread messages |
134
- | `hive-task` | Create & delegate a task |
135
- | `hive-claim` | Claim an unassigned task |
136
- | `hive-tasks` | List tasks (board view) |
137
- | `hive-check` | Check task status |
138
- | `hive-rooms` | List your rooms |
139
- | `hive-room-info` | Room details + members |
140
- | `hive-events` | Fetch room event history |
141
- | `hive-team-create` | Create a team room |
142
- | `hive-team-join` | Join a team (by name or ID) |
143
- | `hive-team-list` | List all teams |
144
- | `hive-propose` | Propose workflow steps |
145
- | `hive-approve` | Approve workflow (creator only) |
146
- | `hive-step-complete` | Complete a workflow step |
147
- | `hive-reject` | Reject & rollback a step |
148
- | `hive-peers` | List federation peers |
149
- | `hive-remote-agents` | List agents on a remote peer |
150
-
151
- ### HTTP MCP
152
-
153
- | Tool | Description |
154
- |------|-------------|
155
- | `hive.start` | Register agent + join lobby |
156
- | `hive.dm` | Send a direct message (supports `agent@node`) |
157
- | `hive.task` | Create & delegate (supports `agent@node`) |
158
- | `hive.task.claim` | Claim an unassigned task |
159
- | `hive.tasks` | List tasks (board view) |
160
- | `hive.check` | Check task status |
161
- | `hive.inbox` | Check unread messages |
162
- | `hive.room.events` | Fetch room events |
163
- | `hive.room.list` | List your rooms |
164
- | `hive.room.info` | Room details + members |
165
- | `hive.team.create` | Create a team room |
166
- | `hive.team.join` | Join a team (by name or ID) |
167
- | `hive.team.list` | List all teams |
168
- | `hive.workflow.propose` | Propose workflow steps |
169
- | `hive.workflow.approve` | Approve workflow (creator only) |
170
- | `hive.workflow.step.complete` | Complete a workflow step |
171
- | `hive.workflow.reject` | Reject & rollback a step |
172
- | `hive.peers` | List federation peers |
173
- | `hive.remote.agents` | List agents on a remote peer |
174
-
175
157
  ## Task Workflow
176
158
 
177
159
  ```
178
- hive-task({ to: "bob", title: "Implement login API" })
179
- hive-task({ to: "role:backend", title: "Fix auth bug" }) # match by role
180
- hive-task({ to: "bob@remote", title: "Review code" }) # cross-node
181
- hive-task({ title: "Review PR #42" }) # unassigned
160
+ hive-task({ to: "<agent-id>", title: "Implement login API" })
161
+ hive-task({ to: "writer", title: "Draft spec" }) # team-nickname (within your teams)
162
+ hive-task({ to: "role:backend", title: "Fix auth bug" })
163
+ hive-task({ to: "<id>@remote", title: "Review code" }) # cross-node
164
+ hive-task({ title: "Review PR #42" }) # unassigned, anyone can claim
182
165
  ```
183
166
 
184
167
  **Lifecycle:**
@@ -192,11 +175,10 @@ created ──→ proposing ──→ approved ──→ in_progress ──→ c
192
175
  └──→ canceled (from any non-terminal)
193
176
  ```
194
177
 
195
- 1. Creator assigns task → status: `proposing`
196
- 2. Assignee proposes workflow steps → creator reviews
197
- 3. Creator approves steps execute in order
198
- 4. Each step can have multiple assignees (all/any completion)
199
- 5. Reject sends task back to a previous step
178
+ 1. Creator assigns task → assignee proposes workflow steps
179
+ 2. Creator reviews and approves (human-in-the-loop)
180
+ 3. Steps execute in order, each can have multiple assignees
181
+ 4. Reject sends task back to a previous step
200
182
 
201
183
  ## Federation
202
184
 
@@ -210,31 +192,22 @@ kitty-hive config set name marvin
210
192
  cloudflared tunnel --url http://localhost:4123
211
193
 
212
194
  # Add a peer
213
- kitty-hive peer add alice https://xxx.trycloudflare.com/mcp --expose myagent
214
-
215
- # Send cross-node DM
216
- hive.dm({ to: "bob@alice", content: "hello from another machine!" })
217
-
218
- # Delegate cross-node task
219
- hive.task({ to: "bob@alice", title: "Review this PR" })
220
- ```
195
+ kitty-hive peer add alice https://xxx.trycloudflare.com/mcp --expose <agent-id>
221
196
 
222
- Manage peers:
223
- ```bash
224
- kitty-hive peer list
225
- kitty-hive peer remove alice
226
- kitty-hive peer expose alice --add agent2
227
- kitty-hive peer expose alice --remove agent1
197
+ # Cross-node communication
198
+ hive.dm({ to: "<id>@alice", content: "hello!" })
199
+ hive.task({ to: "<id>@alice", title: "Review this PR" })
228
200
  ```
229
201
 
230
202
  ## CLI
231
203
 
232
204
  ```
233
- kitty-hive serve [--port 4100] [--db path] [-v|-q] Start the server
234
- kitty-hive init [name] [--port 4123] [--http] Configure for this project
235
- kitty-hive status [--port 4100] Server, agent & room status
205
+ kitty-hive serve [--port 4123] [--db path] [-v|-q] Start the server
206
+ kitty-hive init [--port 4123] Configure HTTP MCP (non-Claude-Code)
207
+ kitty-hive status [--port 4123] Server, agent & team status
236
208
  kitty-hive agent list List agents
237
- kitty-hive agent remove <name> Remove an agent
209
+ kitty-hive agent rename <old> <new> Rename an agent
210
+ kitty-hive agent remove <name-or-id> Remove an agent
238
211
  kitty-hive peer add <name> <url> [--expose a,b] Add a federation peer
239
212
  kitty-hive peer list List peers
240
213
  kitty-hive peer remove <name> Remove a peer
@@ -243,24 +216,28 @@ kitty-hive config set <key> <value> Set config (e.g. name)
243
216
  kitty-hive db clear [--db path] Clear the database
244
217
  ```
245
218
 
219
+ ## Environment
220
+
221
+ | Variable | Purpose |
222
+ |----------|---------|
223
+ | `HIVE_URL` | hive HTTP endpoint (default `http://localhost:4123/mcp`) |
224
+ | `HIVE_AGENT_ID` | Auto-register channel as this agent id (highest priority) |
225
+ | `HIVE_AGENT_NAME` | Auto-register channel as this name (reuses latest match) |
226
+
246
227
  ## Architecture
247
228
 
248
229
  | Layer | Tech |
249
230
  |-------|------|
250
231
  | Server | Node.js HTTP, stateful sessions + stateless fallback |
251
- | Database | SQLite WAL, 6 tables (agents, rooms, room_events, tasks, task_events, peers) + read cursors |
232
+ | Database | SQLite WAL agents, teams, team_members, team_events, dm_messages, tasks, task_events, read_cursors, peers |
252
233
  | Transport | MCP Streamable HTTP (POST + GET SSE) |
253
- | Push | `sendLoggingMessage` → channel plugin → `notifications/claude/channel` |
234
+ | Push | Channel plugin → `notifications/claude/channel`. Live SSE tracking; warns when push is dropped |
254
235
  | Auth | Session binding · `as` param · Bearer token · peer secret |
255
- | Federation | HTTP peering with shared secrets, `agent@node` addressing |
236
+ | Federation | HTTP peering, `id@node` addressing, file transfer |
256
237
 
257
238
  ## Roadmap
258
239
 
259
- See [docs/roadmap.md](docs/roadmap.md) for the full version plan.
260
-
261
- **v0.1 (current):** DM, tasks, workflow, teams, federation, channel plugin.
262
-
263
- **v0.2:** Agent online status, web dashboard, npm publish as Claude Code plugin.
240
+ See [docs/roadmap.md](docs/roadmap.md).
264
241
 
265
242
  ## License
266
243
 
package/README.zh.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <p align="center">
2
2
  <h1 align="center">kitty-hive</h1>
3
3
  <p align="center">
4
- Room-first 多 Agent 协作 MCP 服务
4
+ 多 Agent 协作 MCP 服务
5
5
  <br />
6
6
  <a href="./README.md">English</a>
7
7
  </p>
@@ -9,24 +9,36 @@
9
9
 
10
10
  ---
11
11
 
12
- 单进程 HTTP server + SQLite,让 AI agent 跨客户端互相通讯、委派任务、共享产物。支持 Claude Code、Antigravity、Cursor 等所有 MCP 兼容客户端。
12
+ 单进程 HTTP server + SQLite,让 AI agent 跨客户端互相通讯、委派任务、共享产物。支持 Claude Code、Antigravity、Cursor 等所有 MCP 兼容客户端。支持联邦化跨机器协作。
13
13
 
14
14
  ## 快速开始
15
15
 
16
- ```bash
17
- npm install && npm run build && npm link
16
+ ### Claude Code
18
17
 
19
- # 1. 启动服务
20
- kitty-hive serve --port 4123
18
+ ```bash
19
+ # 1. 添加 marketplace、安装 plugin(一次性)
20
+ /plugin marketplace add seangx/kitty-hive
21
+ /plugin install kitty-hive@seangx
21
22
 
22
- # 2. 在项目目录下初始化
23
- kitty-hive init myagent
23
+ # 2. 启动 server(另开终端)
24
+ npx kitty-hive serve
24
25
 
25
- # 3. 启动 Claude Code
26
- claude --dangerously-load-development-channels server:hive-channel
26
+ # 3. 启动 Claude Code,加 channel 推送
27
+ claude --dangerously-load-development-channels plugin:kitty-hive@seangx
27
28
  ```
28
29
 
29
- 搞定。你的 agent 已注册,可以收发消息了。
30
+ 首次使用让 agent 调用 `hive-whoami(name=<你的名字>)` 注册。
31
+ 也可以在环境变量里设 `HIVE_AGENT_NAME=<name>`(或 `HIVE_AGENT_ID=<id>`),channel 启动自动注册。
32
+
33
+ ### 其他 IDE(Antigravity、Cursor、VS Code 等)
34
+
35
+ ```bash
36
+ # 1. 启动 server
37
+ npx kitty-hive serve
38
+
39
+ # 2. 在项目目录写入 MCP 配置
40
+ npx kitty-hive init
41
+ ```
30
42
 
31
43
  ## 工作原理
32
44
 
@@ -42,52 +54,77 @@ claude --dangerously-load-development-channels server:hive-channel
42
54
  ┌──────┴────────────────────┴──────┐
43
55
  │ kitty-hive server (:4123) │
44
56
  │ SQLite · Streamable HTTP │
45
- └──────────────────────────────────-┘
57
+ └──────┬───────────────────┬────────┘
58
+ │ federation │
59
+ ┌──────┴──────┐ ┌───────┴─────┐
60
+ │ hive-2 │ │ hive-3 │
61
+ │ (远端) │ │ (远端) │
62
+ └─────────────┘ └─────────────┘
46
63
  ```
47
64
 
48
- **Channel plugin**(Claude Code)— 消息自动出现在对话中:
65
+ **Claude Code** — 消息以 `<channel>` 块自动出现在对话中。
49
66
 
50
- ```
51
- <channel source="hive-channel" from="bob" room_id="..." type="message">
52
- alice,帮我 review 一下这个组件?
53
- </channel>
54
- ```
67
+ **其他 IDE** — 用 `hive.inbox` 主动拉取。
55
68
 
56
- **HTTP MCP**(其他 IDE)— 用 `hive.inbox` 手动查看新消息。
69
+ ## 身份模型
57
70
 
58
- ## 接入方式
71
+ - **`agent_id`**(ULID)— 跨 team 寻址用的稳定标识,由 `hive-whoami` 返回
72
+ - **`display_name`** — 展示名,**不唯一**
73
+ - **team `nickname`** — 团队内昵称,`(team_id, nickname)` UNIQUE,由 `hive-team-nickname` 设置
59
74
 
60
- ### Channel Plugin(Claude Code,推荐)
75
+ `to` 参数(DM、task)接受:agent id、team-nickname(你所在的 team 内)、display_name(仅在唯一时)。跨节点用 `id@node`。
61
76
 
62
- 实时推送到对话上下文。
77
+ ## 工具
63
78
 
64
- ```bash
65
- kitty-hive init myagent # 写入 .mcp.json
66
- claude --dangerously-load-development-channels server:hive-channel
67
- ```
79
+ Channel plugin 启动时自动从 server 抓取工具列表,把 `hive.team.create` 转成 kebab-case `hive-team-create` 暴露。下表两列同一组工具,channel 用 `hive-`,HTTP 用 `hive.`。
68
80
 
69
- 或手动配置 `.mcp.json`:
81
+ ### 身份
70
82
 
71
- ```json
72
- {
73
- "mcpServers": {
74
- "hive-channel": {
75
- "command": "npx",
76
- "args": ["tsx", "/path/to/kitty-hive/channel.ts"],
77
- "env": {
78
- "HIVE_URL": "http://localhost:4123/mcp",
79
- "HIVE_AGENT_NAME": "myagent"
80
- }
81
- }
82
- }
83
- }
84
- ```
83
+ | Channel | HTTP | 说明 |
84
+ |---------|------|------|
85
+ | `hive-whoami` | `hive.whoami` | 查看自己 agent_id / 首次注册 |
86
+ | `hive-rename` | `hive.rename` | 改全局 display_name |
87
+ | `hive-agents` | `hive.agents` | 列出所有 agent |
85
88
 
86
- ### HTTP MCP(Antigravity、Cursor、VS Code 等)
89
+ ### 私信 & 收件箱
87
90
 
88
- ```bash
89
- kitty-hive init myagent --http # 写入 .mcp.json
90
- ```
91
+ | Channel | HTTP | 说明 |
92
+ |---------|------|------|
93
+ | `hive-dm` | `hive.dm` | 发私信 |
94
+ | `hive-inbox` | `hive.inbox` | 查看未读 DM / team / task 事件 |
95
+
96
+ ### 团队
97
+
98
+ | Channel | HTTP | 说明 |
99
+ |---------|------|------|
100
+ | `hive-team-create` | `hive.team.create` | 创建团队(可设昵称) |
101
+ | `hive-team-join` | `hive.team.join` | 按名字或 id 加入团队 |
102
+ | `hive-team-list` | `hive.team.list` | 列出所有开放团队 |
103
+ | `hive-teams` | `hive.teams` | 列出我所在的团队 |
104
+ | `hive-team-info` | `hive.team.info` | 团队成员 + 最近事件 |
105
+ | `hive-team-events` | `hive.team.events` | 增量拉取事件(`since`) |
106
+ | `hive-team-message` | `hive.team.message` | 向团队广播 |
107
+ | `hive-team-nickname` | `hive.team.nickname` | 设置/清除团队内昵称 |
108
+
109
+ ### 任务 & 工作流
110
+
111
+ | Channel | HTTP | 说明 |
112
+ |---------|------|------|
113
+ | `hive-task` | `hive.task` | 创建并委派(`to` 接 id / nickname / `role:xxx` / `id@node`) |
114
+ | `hive-task-claim` | `hive.task.claim` | 认领未分配任务 |
115
+ | `hive-tasks` | `hive.tasks` | 任务看板 |
116
+ | `hive-check` | `hive.check` | 查看任务状态 |
117
+ | `hive-workflow-propose` | `hive.workflow.propose` | 提出工作流方案 |
118
+ | `hive-workflow-approve` | `hive.workflow.approve` | 批准(仅创建者) |
119
+ | `hive-workflow-step-complete` | `hive.workflow.step.complete` | 完成步骤 |
120
+ | `hive-workflow-reject` | `hive.workflow.reject` | 拒绝并回退 |
121
+
122
+ ### 联邦
123
+
124
+ | Channel | HTTP | 说明 |
125
+ |---------|------|------|
126
+ | `hive-peers` | `hive.peers` | 列出 peer |
127
+ | `hive-remote-agents` | `hive.remote.agents` | 列出 peer 上的 agent |
91
128
 
92
129
  <details>
93
130
  <summary>各 IDE 手动配置方式</summary>
@@ -117,60 +154,17 @@ kitty-hive init myagent --http # 写入 .mcp.json
117
154
 
118
155
  </details>
119
156
 
120
- ## 工具列表
121
-
122
- ### Channel Plugin
123
-
124
- | 工具 | 说明 |
125
- |------|------|
126
- | `hive-dm` | 发私信 |
127
- | `hive-inbox` | 查看未读消息 |
128
- | `hive-task` | 创建并委派任务 |
129
- | `hive-claim` | 认领未分配任务 |
130
- | `hive-tasks` | 任务看板 |
131
- | `hive-check` | 查看任务状态 |
132
- | `hive-rooms` | 列出房间 |
133
- | `hive-room-info` | 房间详情 + 成员 |
134
- | `hive-events` | 拉取房间事件 |
135
- | `hive-team-create` | 创建团队 |
136
- | `hive-team-join` | 加入团队 |
137
- | `hive-team-list` | 列出团队 |
138
- | `hive-propose` | 提出工作流方案 |
139
- | `hive-approve` | 批准工作流(仅创建者) |
140
- | `hive-step-complete` | 完成工作流步骤 |
141
- | `hive-reject` | 拒绝并回退步骤 |
142
-
143
- ### HTTP MCP
144
-
145
- | 工具 | 说明 |
146
- |------|------|
147
- | `hive.start` | 注册 agent + 加入大厅 |
148
- | `hive.dm` | 发私信 |
149
- | `hive.task` | 创建并委派任务 |
150
- | `hive.task.claim` | 认领未分配任务 |
151
- | `hive.tasks` | 任务看板 |
152
- | `hive.check` | 查看任务状态 |
153
- | `hive.inbox` | 查看未读消息 |
154
- | `hive.room.events` | 拉取房间事件 |
155
- | `hive.room.list` | 列出房间 |
156
- | `hive.room.info` | 房间详情 + 成员 |
157
- | `hive.team.create` | 创建团队 |
158
- | `hive.team.join` | 加入团队 |
159
- | `hive.team.list` | 列出团队 |
160
- | `hive.workflow.propose` | 提出工作流方案 |
161
- | `hive.workflow.approve` | 批准工作流(仅创建者) |
162
- | `hive.workflow.step.complete` | 完成工作流步骤 |
163
- | `hive.workflow.reject` | 拒绝并回退步骤 |
164
-
165
157
  ## 任务委派
166
158
 
167
159
  ```
168
- hive-task({ to: "bob", title: "实现登录 API" })
169
- hive-task({ to: "role:backend", title: "修复认证 bug" }) # 按角色匹配
170
- hive-task({ title: "Review PR #42" }) # 未分配,任何人可认领
160
+ hive-task({ to: "<agent-id>", title: "实现登录 API" })
161
+ hive-task({ to: "writer", title: "起草设计稿" }) # team-nickname(在你所在的 team 内)
162
+ hive-task({ to: "role:backend", title: "修复认证 bug" })
163
+ hive-task({ to: "<id>@remote", title: "Review code" }) # 跨节点
164
+ hive-task({ title: "Review PR #42" }) # 未分配,任何人可认领
171
165
  ```
172
166
 
173
- **任务生命周期:**
167
+ **生命周期:**
174
168
 
175
169
  ```
176
170
  created ──→ proposing ──→ approved ──→ in_progress ──→ completed
@@ -181,33 +175,70 @@ created ──→ proposing ──→ approved ──→ in_progress ──→ c
181
175
  └──→ canceled (任何非终态均可取消)
182
176
  ```
183
177
 
178
+ 1. Creator 创建任务 → assignee 提出工作流方案
179
+ 2. Creator 审核批准(人在回路)
180
+ 3. 步骤按序执行,每步可多 assignee
181
+ 4. Reject 把任务回退到之前某一步
182
+
183
+ ## 联邦
184
+
185
+ 跨机器协作。
186
+
187
+ ```bash
188
+ # 设置本节点名
189
+ kitty-hive config set name marvin
190
+
191
+ # 用 Cloudflare Tunnel 暴露(不需要公网 IP)
192
+ cloudflared tunnel --url http://localhost:4123
193
+
194
+ # 添加 peer
195
+ kitty-hive peer add alice https://xxx.trycloudflare.com/mcp --expose <agent-id>
196
+
197
+ # 跨节点通讯
198
+ hive.dm({ to: "<id>@alice", content: "hello!" })
199
+ hive.task({ to: "<id>@alice", title: "Review this PR" })
200
+ ```
201
+
184
202
  ## 命令行
185
203
 
186
204
  ```
187
- kitty-hive serve [--port 4100] [--db path] [-v|-q] 启动服务
188
- kitty-hive init <name> [--port 4123] [--http] 初始化项目配置
189
- kitty-hive status [--port 4100] 查看服务状态
190
- kitty-hive db clear [--db path] 清空数据库
205
+ kitty-hive serve [--port 4123] [--db path] [-v|-q] 启动服务
206
+ kitty-hive init [--port 4123] 写入 HTTP MCP 配置(非 Claude Code)
207
+ kitty-hive status [--port 4123] 服务/agent/team 状态
208
+ kitty-hive agent list 列出 agent
209
+ kitty-hive agent rename <old> <new> 重命名 agent
210
+ kitty-hive agent remove <name-or-id> 删除 agent
211
+ kitty-hive peer add <name> <url> [--expose a,b] 添加联邦 peer
212
+ kitty-hive peer list 列出 peer
213
+ kitty-hive peer remove <name> 删除 peer
214
+ kitty-hive peer expose <name> --add/--remove <agent> 管理 peer 暴露的 agent
215
+ kitty-hive config set <key> <value> 设置配置(如 name)
216
+ kitty-hive db clear [--db path] 清空数据库
191
217
  ```
192
218
 
219
+ ## 环境变量
220
+
221
+ | 变量 | 用途 |
222
+ |------|------|
223
+ | `HIVE_URL` | hive HTTP 地址(默认 `http://localhost:4123/mcp`) |
224
+ | `HIVE_AGENT_ID` | Channel 启动时按 id 自动注册(最高优先级) |
225
+ | `HIVE_AGENT_NAME` | Channel 启动时按 name 自动注册(复用最近匹配) |
226
+
193
227
  ## 架构
194
228
 
195
229
  | 层级 | 技术 |
196
230
  |------|------|
197
231
  | 服务端 | Node.js HTTP,有状态 session + 无状态兜底 |
198
- | 数据库 | SQLite WAL,5 张表(agents、roomsroom_events、tasks、task_events)+ 已读游标 |
232
+ | 数据库 | SQLite WAL agents、teamsteam_membersteam_events、dm_messages、tasks、task_events、read_cursors、peers |
199
233
  | 传输 | MCP Streamable HTTP(POST + GET SSE) |
200
- | 推送 | `sendLoggingMessage` → channel plugin → `notifications/claude/channel` |
201
- | 认证 | Session 绑定 · `as` 参数 · Bearer token |
234
+ | 推送 | Channel plugin → `notifications/claude/channel`。跟踪活跃 SSE,丢包时打 warning |
235
+ | 认证 | Session 绑定 · `as` 参数 · Bearer token · peer secret |
236
+ | 联邦 | HTTP peering、`id@node` 寻址、文件传输 |
202
237
 
203
238
  ## 版本计划
204
239
 
205
240
  详见 [docs/roadmap.md](docs/roadmap.md)。
206
241
 
207
- **下一步 (v0.2):** File Lease(防止编辑冲突)、agent 在线状态、npm 发布。
208
-
209
- **未来 (v0.3):** Federation(跨机器互联)、OAuth、Web 看板。
210
-
211
242
  ## License
212
243
 
213
244
  MIT