hivecode-mcp 0.14.1 → 0.14.2
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/HIVE_RULES.md +98 -98
- package/LICENSE +21 -21
- package/README.md +421 -421
- package/core.js +91 -91
- package/docs/ALWAYS_ON.md +310 -310
- package/docs/GITHUB_WORKFLOW.md +394 -394
- package/docs/HIVE_RULES.md +41 -41
- package/docs/MCP.md +157 -157
- package/docs/QUICKSTART.md +266 -266
- package/docs/SELF_HOSTING.md +256 -256
- package/docs/SLACK_SETUP.md +474 -474
- package/docs/TROUBLESHOOTING.md +105 -105
- package/hive-activity.js +336 -336
- package/hive-authors.js +46 -44
- package/hive-await.js +230 -230
- package/hive-branch.js +608 -607
- package/hive-busy.js +88 -88
- package/hive-coord.js +110 -110
- package/hive-gate.js +135 -135
- package/hive-github.js +3 -1
- package/hive-hook-install.js +179 -179
- package/hive-instructions.js +74 -74
- package/hive-land.js +695 -691
- package/hive-listen.js +81 -81
- package/hive-mailbox.js +520 -520
- package/hive-mcp-http.js +591 -591
- package/hive-mcp.js +33 -6
- package/hive-mux-proto.js +58 -58
- package/hive-mux.js +351 -351
- package/hive-notify.js +234 -233
- package/hive-obligations.js +247 -247
- package/hive-poll-proto.js +50 -50
- package/hive-pr-staleness.js +189 -189
- package/hive-pr.js +600 -512
- package/hive-privacy.js +327 -327
- package/hive-receipts.js +233 -233
- package/hive-relay-health.js +234 -234
- package/hive-repos.js +430 -430
- package/hive-room-key.js +210 -210
- package/hive-room-mode.js +1668 -1668
- package/hive-room-watcher.js +562 -561
- package/hive-secrets.js +89 -89
- package/hive-session.js +114 -114
- package/hive-setup.js +560 -560
- package/hive-slack-agent.js +408 -408
- package/hive-slack.js +2384 -2367
- package/hive-stdio.js +172 -172
- package/hive-stop-hook.js +293 -293
- package/hive-throttle.js +118 -118
- package/hive-time.js +71 -71
- package/hive-transport.js +578 -578
- package/hive-update.js +58 -58
- package/hive-version.js +110 -110
- package/hive-webhook.js +55 -54
- package/icr-merge.js +58 -58
- package/icr.js +851 -851
- package/lang-brace.js +305 -305
- package/lang-js.js +651 -651
- package/lang-json.js +211 -211
- package/lang-python.js +588 -588
- package/lang-ruby.js +230 -230
- package/lang-toml.js +136 -136
- package/lang-yaml.js +183 -183
- package/limits.js +413 -413
- package/package.json +1 -1
- package/reconcile.cjs +621 -621
- package/slack-app-manifest-agent.json +61 -61
- package/slack-app-manifest-inbound.json +36 -36
- package/slack-app-manifest.json +27 -27
- package/substrate.js +252 -252
- package/sync.js +169 -11
- package/token.js +201 -201
package/docs/HIVE_RULES.md
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
# HIVE RULES — read this first. Everyone in this room (human or AI) follows these.
|
|
2
|
-
|
|
3
|
-
You are in a Hivecode room: humans and AI agents edit ONE project together live.
|
|
4
|
-
These rules keep anyone from destroying another's work. The sync layer enforces
|
|
5
|
-
the hard parts automatically; you do the rest.
|
|
6
|
-
|
|
7
|
-
## Before you touch a file
|
|
8
|
-
1. Read HIVE_CHAT.md — what is everyone doing right now.
|
|
9
|
-
2. Read HIVE_BOARD.md — which files were just rewritten.
|
|
10
|
-
3. If a file you plan to edit appears there, RE-READ it before changing it.
|
|
11
|
-
|
|
12
|
-
## While you work
|
|
13
|
-
4. ANNOUNCE in chat what you are taking before you start.
|
|
14
|
-
5. PREFER SMALL PATCHES — grep to the spot, edit a few lines (they merge cleanly).
|
|
15
|
-
6. AVOID full-file rewrites; if you must, RE-READ first (rewrites are auto-logged).
|
|
16
|
-
7. STAY IN YOUR LANE — read others' areas, but leave edits to the owner.
|
|
17
|
-
|
|
18
|
-
## When things collide
|
|
19
|
-
8. <<<<<<< ======= >>>>>>> markers = a real conflict: keep the right code, delete
|
|
20
|
-
the markers. Never ignore or blindly overwrite.
|
|
21
|
-
9. If your edit was merged/reworked, that is normal — re-read and continue.
|
|
22
|
-
|
|
23
|
-
## Talking
|
|
24
|
-
10. Coordinate in chat. ASK before anything destructive in another's area.
|
|
25
|
-
|
|
26
|
-
## Mission control
|
|
27
|
-
- If a human PAUSES you, finish your current step and STOP — start no new work
|
|
28
|
-
until resumed. A human may reassign your focus anytime; their directive wins.
|
|
29
|
-
|
|
30
|
-
## When you get a ping mid-task (interruptions)
|
|
31
|
-
11. Another AGENT pinging or assigning you = COORDINATION: auto-accepted and
|
|
32
|
-
QUEUED. It does NOT interrupt — finish your current atomic step first (never
|
|
33
|
-
abandon half-done work), THEN handle it. If it's urgent (build broken,
|
|
34
|
-
blocking others), do it now.
|
|
35
|
-
12. ACKNOWLEDGE the moment you see a ping so the sender isn't left hanging, e.g.
|
|
36
|
-
"got it — finishing X (~2 min), then on your auth.js fix".
|
|
37
|
-
13. YOU triage: say whether you'll do it now or after your current step. Your
|
|
38
|
-
OWNER can override anytime — if they say "do it now" or "skip that" in chat,
|
|
39
|
-
that wins (owner instructions are always honored).
|
|
40
|
-
14. A ping from a HUMAN who is not your owner does NOT auto-run — it waits for
|
|
41
|
-
your owner's approval. Keep working; your owner decides.
|
|
1
|
+
# HIVE RULES — read this first. Everyone in this room (human or AI) follows these.
|
|
2
|
+
|
|
3
|
+
You are in a Hivecode room: humans and AI agents edit ONE project together live.
|
|
4
|
+
These rules keep anyone from destroying another's work. The sync layer enforces
|
|
5
|
+
the hard parts automatically; you do the rest.
|
|
6
|
+
|
|
7
|
+
## Before you touch a file
|
|
8
|
+
1. Read HIVE_CHAT.md — what is everyone doing right now.
|
|
9
|
+
2. Read HIVE_BOARD.md — which files were just rewritten.
|
|
10
|
+
3. If a file you plan to edit appears there, RE-READ it before changing it.
|
|
11
|
+
|
|
12
|
+
## While you work
|
|
13
|
+
4. ANNOUNCE in chat what you are taking before you start.
|
|
14
|
+
5. PREFER SMALL PATCHES — grep to the spot, edit a few lines (they merge cleanly).
|
|
15
|
+
6. AVOID full-file rewrites; if you must, RE-READ first (rewrites are auto-logged).
|
|
16
|
+
7. STAY IN YOUR LANE — read others' areas, but leave edits to the owner.
|
|
17
|
+
|
|
18
|
+
## When things collide
|
|
19
|
+
8. <<<<<<< ======= >>>>>>> markers = a real conflict: keep the right code, delete
|
|
20
|
+
the markers. Never ignore or blindly overwrite.
|
|
21
|
+
9. If your edit was merged/reworked, that is normal — re-read and continue.
|
|
22
|
+
|
|
23
|
+
## Talking
|
|
24
|
+
10. Coordinate in chat. ASK before anything destructive in another's area.
|
|
25
|
+
|
|
26
|
+
## Mission control
|
|
27
|
+
- If a human PAUSES you, finish your current step and STOP — start no new work
|
|
28
|
+
until resumed. A human may reassign your focus anytime; their directive wins.
|
|
29
|
+
|
|
30
|
+
## When you get a ping mid-task (interruptions)
|
|
31
|
+
11. Another AGENT pinging or assigning you = COORDINATION: auto-accepted and
|
|
32
|
+
QUEUED. It does NOT interrupt — finish your current atomic step first (never
|
|
33
|
+
abandon half-done work), THEN handle it. If it's urgent (build broken,
|
|
34
|
+
blocking others), do it now.
|
|
35
|
+
12. ACKNOWLEDGE the moment you see a ping so the sender isn't left hanging, e.g.
|
|
36
|
+
"got it — finishing X (~2 min), then on your auth.js fix".
|
|
37
|
+
13. YOU triage: say whether you'll do it now or after your current step. Your
|
|
38
|
+
OWNER can override anytime — if they say "do it now" or "skip that" in chat,
|
|
39
|
+
that wins (owner instructions are always honored).
|
|
40
|
+
14. A ping from a HUMAN who is not your owner does NOT auto-run — it waits for
|
|
41
|
+
your owner's approval. Keep working; your owner decides.
|
package/docs/MCP.md
CHANGED
|
@@ -1,157 +1,157 @@
|
|
|
1
|
-
# Hivecode MCP server
|
|
2
|
-
|
|
3
|
-
Lets any MCP-capable AI agent (Claude Code, Claude Desktop, etc.) join a Hivecode
|
|
4
|
-
room and coordinate through **native tool calls** — no scripts to run, no human
|
|
5
|
-
to set it up.
|
|
6
|
-
|
|
7
|
-
## Register it
|
|
8
|
-
|
|
9
|
-
`npx -y hivecode-mcp@latest setup` (below) writes this entry for you. Written by hand, it points at
|
|
10
|
-
the runtime copy that `setup` installs:
|
|
11
|
-
|
|
12
|
-
**Claude Code** (your user settings, so every project on this machine gets it):
|
|
13
|
-
```json
|
|
14
|
-
{
|
|
15
|
-
"mcpServers": {
|
|
16
|
-
"hivecode": {
|
|
17
|
-
"command": "node",
|
|
18
|
-
"args": ["<your home>/.hivecode/runtime/<version>/node_modules/hivecode-mcp/hive-mcp.js"],
|
|
19
|
-
"env": { "HIVE_RELAY": "wss://hivecode-relay.onrender.com" }
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
`HIVE_RELAY` is optional (defaults to the hosted relay).
|
|
26
|
-
|
|
27
|
-
Do not put this entry in a project's `.mcp.json`. That file is shared through git, but the path in
|
|
28
|
-
it exists only on the machine that wrote it. Inside that project, Claude Code ranks it above the
|
|
29
|
-
entry in a user's settings, so on everyone else's machine Hivecode fails to start ("Connection
|
|
30
|
-
closed").
|
|
31
|
-
|
|
32
|
-
### Setting it up: one command
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npx -y hivecode-mcp@latest setup
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
This writes the hivecode entry into every agent app it finds (Claude Code, Antigravity, Cursor,
|
|
39
|
-
Windsurf, Claude Desktop, Gemini CLI), then launches each entry the way that app will and checks it
|
|
40
|
-
answers an MCP handshake. It installs a runtime copy under `~/.hivecode/runtime/<version>`, so the
|
|
41
|
-
agent app starts Hivecode with no download and no network.
|
|
42
|
-
|
|
43
|
-
Do not put `{"command": "npx", ...}` in an MCP config by hand. Agent apps start servers without a
|
|
44
|
-
shell, and on Windows `npx` is `npx.cmd`, so that entry fails with `spawn npx ENOENT`. Its first
|
|
45
|
-
start also downloads the package, which can outlast an app's start-up limit (Claude Code allows
|
|
46
|
-
30 seconds). If `setup` does not know your app, it prints the exact entry to use instead.
|
|
47
|
-
|
|
48
|
-
Because agent apps now start that installed copy, nothing updates it on its own. The server asks
|
|
49
|
-
npm once per start (in the background, never blocking) and, when a newer build is out, says so in
|
|
50
|
-
`hive_join` and `hive_status`, with the command to run: `npx -y hivecode-mcp@latest setup`. Mixed
|
|
51
|
-
versions in one room can lose data, so do not ignore it. `HIVE_PRIVATE=1` or
|
|
52
|
-
`HIVE_NO_UPDATE_CHECK=1` turns the check off.
|
|
53
|
-
|
|
54
|
-
## Tools the agent gets
|
|
55
|
-
|
|
56
|
-
| Tool | What it does |
|
|
57
|
-
|------|--------------|
|
|
58
|
-
| `hive_join` | Join/host a room for a folder. Auto-joins as an **AI** participant. Returns the room info **and the HIVE_RULES to follow**. With `branch` (and `repo`), joins the room bound to that git branch by `npx -y hivecode-mcp@latest branch <name>`, in a folder of its own. |
|
|
59
|
-
| `hive_say` | Post a coordination message — announce what you're about to work on. |
|
|
60
|
-
| `hive_read_chat` | Read the room conversation (read this to coordinate). |
|
|
61
|
-
| `hive_read_board` | Read recent whole-file rewrites (read before editing a file). |
|
|
62
|
-
| `hive_members` | Who's in the room (humans + agents). |
|
|
63
|
-
| `hive_status` | Current session info. |
|
|
64
|
-
| `hive_leave` | Leave the room. |
|
|
65
|
-
|
|
66
|
-
## How an agent uses it
|
|
67
|
-
|
|
68
|
-
1. `hive_join` (with a `link`, a `branch` bound by `npx -y hivecode-mcp@latest branch`, a `dir` containing `.hive.json`, or nothing to host a new room) — pass `owner` so the right human can approve your tasks.
|
|
69
|
-
2. Read the returned **HIVE_RULES**.
|
|
70
|
-
3. `hive_read_chat` + `hive_read_board` before touching files.
|
|
71
|
-
4. `hive_say` to announce intent, then edit files in the synced folder.
|
|
72
|
-
5. Keep editing — changes merge with everyone else's safely; rewrites are auto-logged.
|
|
73
|
-
|
|
74
|
-
## Reacting to directed work (no polling)
|
|
75
|
-
|
|
76
|
-
A human can direct a task at you, but you only act once **your owner approves**.
|
|
77
|
-
Don't poll — **block** on `hive_wait`:
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
loop:
|
|
81
|
-
result = hive_wait(timeoutSeconds: 60) # returns the instant your owner approves
|
|
82
|
-
if result has APPROVED WORK:
|
|
83
|
-
do it, then hive_complete(id)
|
|
84
|
-
# else just call hive_wait again
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
`hive_wait` returns within ~1s of the approval (it reacts to the live update),
|
|
88
|
-
and also wakes on new chat so you stay responsive to teammates.
|
|
89
|
-
|
|
90
|
-
This is the lowest-friction way for AIs to adopt the protocol in `SPEC.md`:
|
|
91
|
-
the agent never runs a command, it just calls tools.
|
|
92
|
-
|
|
93
|
-
## The anti-idle gate (Claude Code)
|
|
94
|
-
|
|
95
|
-
Everything above is still an instruction, and instructions get ignored. The single
|
|
96
|
-
worst failure in a room is an agent that decides it is finished: its process is
|
|
97
|
-
alive and its socket is up, but it has stopped listening, and the agents waiting on
|
|
98
|
-
it just wait. Nothing tells them.
|
|
99
|
-
|
|
100
|
-
You cannot fix that with wording. Install the gate:
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
npx -y -p hivecode-mcp@latest hivecode-hook install # this project
|
|
104
|
-
npx -y -p hivecode-mcp@latest hivecode-hook install --global # every project
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
That writes a Claude Code **`Stop` hook**. Claude Code runs it when the agent is
|
|
108
|
-
about to end its turn; the hook checks the room and **refuses the stop** if there is
|
|
109
|
-
unread mail addressed to that agent, or an accepted task still open. The agent does
|
|
110
|
-
not get a vote — same difference as a claim the relay enforces versus a claim it
|
|
111
|
-
merely warns about.
|
|
112
|
-
|
|
113
|
-
It merges into any existing `Stop` hooks rather than replacing them, and
|
|
114
|
-
`npx -y -p hivecode-mcp@latest hivecode-hook uninstall` removes it. It reads only local mirrored files
|
|
115
|
-
(`HIVE_CHAT.md`, `HIVE_TASKS.md`), so it costs no network round trip and works with
|
|
116
|
-
the relay unreachable.
|
|
117
|
-
|
|
118
|
-
Three guards stop it becoming a trap: it never blocks a stop that is already the
|
|
119
|
-
result of a block, a given message can cause at most one block, and an open task
|
|
120
|
-
stands down after three consecutive turns so an impossible task cannot pin an agent
|
|
121
|
-
forever. Any failure at all — no room, unreadable file, bad JSON — allows the stop.
|
|
122
|
-
|
|
123
|
-
Other MCP clients get the same rules in their system prompt (the server returns them
|
|
124
|
-
in `instructions` at handshake), but only Claude Code can enforce them.
|
|
125
|
-
|
|
126
|
-
## Running two or more agents in the same app
|
|
127
|
-
|
|
128
|
-
Host apps handle MCP server processes in one of two ways:
|
|
129
|
-
|
|
130
|
-
- **Per-session (separate process per chat/terminal):**
|
|
131
|
-
- **Claude Code**: Each terminal CLI session (`claude`) spawns its own independent Node child process from `~/.claude.json`. Multiple Claude Code sessions never share an MCP server process.
|
|
132
|
-
- **Single shared process across all tabs/windows:**
|
|
133
|
-
- **Antigravity**: Spawns one singleton stdio MCP process from `mcp_config.json` managed by `language_server.exe` (`--subclient_type hub`), shared by all chats, composer tabs, and agent sessions.
|
|
134
|
-
- **Cursor**: [not checked] Centralized MCP server lifecycle.
|
|
135
|
-
- **Windsurf**: [not checked] Centralized MCP server lifecycle.
|
|
136
|
-
- **Claude Desktop**: [not checked] Centralized MCP server lifecycle.
|
|
137
|
-
|
|
138
|
-
If two agents in a shared-process app call `hive_join` with different names, the server refuses the second join with **`Q637`** to protect the first agent from being silently replaced.
|
|
139
|
-
|
|
140
|
-
To run two or more agents concurrently in a shared-process app (e.g. `frontend-bot` and `backend-bot`), register a second MCP server entry in your config pointing to the same runtime copy:
|
|
141
|
-
|
|
142
|
-
```json
|
|
143
|
-
{
|
|
144
|
-
"mcpServers": {
|
|
145
|
-
"hivecode": {
|
|
146
|
-
"command": "node",
|
|
147
|
-
"args": ["<your home>/.hivecode/runtime/<version>/node_modules/hivecode-mcp/hive-mcp.js"]
|
|
148
|
-
},
|
|
149
|
-
"hivecode-2": {
|
|
150
|
-
"command": "node",
|
|
151
|
-
"args": ["<your home>/.hivecode/runtime/<version>/node_modules/hivecode-mcp/hive-mcp.js"]
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Restart your app. A host that shares MCP servers exposes **all** configured servers to **every** chat — nothing automatically routes `hivecode-2` to Agent 2. You must explicitly prompt each agent which server to use (for example: *"You use only the hivecode-2 tools"*), or both agents will attempt to call `hive_join` on `hivecode`, where `Q637` will refuse the second agent.
|
|
1
|
+
# Hivecode MCP server
|
|
2
|
+
|
|
3
|
+
Lets any MCP-capable AI agent (Claude Code, Claude Desktop, etc.) join a Hivecode
|
|
4
|
+
room and coordinate through **native tool calls** — no scripts to run, no human
|
|
5
|
+
to set it up.
|
|
6
|
+
|
|
7
|
+
## Register it
|
|
8
|
+
|
|
9
|
+
`npx -y hivecode-mcp@latest setup` (below) writes this entry for you. Written by hand, it points at
|
|
10
|
+
the runtime copy that `setup` installs:
|
|
11
|
+
|
|
12
|
+
**Claude Code** (your user settings, so every project on this machine gets it):
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"hivecode": {
|
|
17
|
+
"command": "node",
|
|
18
|
+
"args": ["<your home>/.hivecode/runtime/<version>/node_modules/hivecode-mcp/hive-mcp.js"],
|
|
19
|
+
"env": { "HIVE_RELAY": "wss://hivecode-relay.onrender.com" }
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`HIVE_RELAY` is optional (defaults to the hosted relay).
|
|
26
|
+
|
|
27
|
+
Do not put this entry in a project's `.mcp.json`. That file is shared through git, but the path in
|
|
28
|
+
it exists only on the machine that wrote it. Inside that project, Claude Code ranks it above the
|
|
29
|
+
entry in a user's settings, so on everyone else's machine Hivecode fails to start ("Connection
|
|
30
|
+
closed").
|
|
31
|
+
|
|
32
|
+
### Setting it up: one command
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx -y hivecode-mcp@latest setup
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This writes the hivecode entry into every agent app it finds (Claude Code, Antigravity, Cursor,
|
|
39
|
+
Windsurf, Claude Desktop, Gemini CLI), then launches each entry the way that app will and checks it
|
|
40
|
+
answers an MCP handshake. It installs a runtime copy under `~/.hivecode/runtime/<version>`, so the
|
|
41
|
+
agent app starts Hivecode with no download and no network.
|
|
42
|
+
|
|
43
|
+
Do not put `{"command": "npx", ...}` in an MCP config by hand. Agent apps start servers without a
|
|
44
|
+
shell, and on Windows `npx` is `npx.cmd`, so that entry fails with `spawn npx ENOENT`. Its first
|
|
45
|
+
start also downloads the package, which can outlast an app's start-up limit (Claude Code allows
|
|
46
|
+
30 seconds). If `setup` does not know your app, it prints the exact entry to use instead.
|
|
47
|
+
|
|
48
|
+
Because agent apps now start that installed copy, nothing updates it on its own. The server asks
|
|
49
|
+
npm once per start (in the background, never blocking) and, when a newer build is out, says so in
|
|
50
|
+
`hive_join` and `hive_status`, with the command to run: `npx -y hivecode-mcp@latest setup`. Mixed
|
|
51
|
+
versions in one room can lose data, so do not ignore it. `HIVE_PRIVATE=1` or
|
|
52
|
+
`HIVE_NO_UPDATE_CHECK=1` turns the check off.
|
|
53
|
+
|
|
54
|
+
## Tools the agent gets
|
|
55
|
+
|
|
56
|
+
| Tool | What it does |
|
|
57
|
+
|------|--------------|
|
|
58
|
+
| `hive_join` | Join/host a room for a folder. Auto-joins as an **AI** participant. Returns the room info **and the HIVE_RULES to follow**. With `branch` (and `repo`), joins the room bound to that git branch by `npx -y hivecode-mcp@latest branch <name>`, in a folder of its own. |
|
|
59
|
+
| `hive_say` | Post a coordination message — announce what you're about to work on. |
|
|
60
|
+
| `hive_read_chat` | Read the room conversation (read this to coordinate). |
|
|
61
|
+
| `hive_read_board` | Read recent whole-file rewrites (read before editing a file). |
|
|
62
|
+
| `hive_members` | Who's in the room (humans + agents). |
|
|
63
|
+
| `hive_status` | Current session info. |
|
|
64
|
+
| `hive_leave` | Leave the room. |
|
|
65
|
+
|
|
66
|
+
## How an agent uses it
|
|
67
|
+
|
|
68
|
+
1. `hive_join` (with a `link`, a `branch` bound by `npx -y hivecode-mcp@latest branch`, a `dir` containing `.hive.json`, or nothing to host a new room) — pass `owner` so the right human can approve your tasks.
|
|
69
|
+
2. Read the returned **HIVE_RULES**.
|
|
70
|
+
3. `hive_read_chat` + `hive_read_board` before touching files.
|
|
71
|
+
4. `hive_say` to announce intent, then edit files in the synced folder.
|
|
72
|
+
5. Keep editing — changes merge with everyone else's safely; rewrites are auto-logged.
|
|
73
|
+
|
|
74
|
+
## Reacting to directed work (no polling)
|
|
75
|
+
|
|
76
|
+
A human can direct a task at you, but you only act once **your owner approves**.
|
|
77
|
+
Don't poll — **block** on `hive_wait`:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
loop:
|
|
81
|
+
result = hive_wait(timeoutSeconds: 60) # returns the instant your owner approves
|
|
82
|
+
if result has APPROVED WORK:
|
|
83
|
+
do it, then hive_complete(id)
|
|
84
|
+
# else just call hive_wait again
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`hive_wait` returns within ~1s of the approval (it reacts to the live update),
|
|
88
|
+
and also wakes on new chat so you stay responsive to teammates.
|
|
89
|
+
|
|
90
|
+
This is the lowest-friction way for AIs to adopt the protocol in `SPEC.md`:
|
|
91
|
+
the agent never runs a command, it just calls tools.
|
|
92
|
+
|
|
93
|
+
## The anti-idle gate (Claude Code)
|
|
94
|
+
|
|
95
|
+
Everything above is still an instruction, and instructions get ignored. The single
|
|
96
|
+
worst failure in a room is an agent that decides it is finished: its process is
|
|
97
|
+
alive and its socket is up, but it has stopped listening, and the agents waiting on
|
|
98
|
+
it just wait. Nothing tells them.
|
|
99
|
+
|
|
100
|
+
You cannot fix that with wording. Install the gate:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
npx -y -p hivecode-mcp@latest hivecode-hook install # this project
|
|
104
|
+
npx -y -p hivecode-mcp@latest hivecode-hook install --global # every project
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
That writes a Claude Code **`Stop` hook**. Claude Code runs it when the agent is
|
|
108
|
+
about to end its turn; the hook checks the room and **refuses the stop** if there is
|
|
109
|
+
unread mail addressed to that agent, or an accepted task still open. The agent does
|
|
110
|
+
not get a vote — same difference as a claim the relay enforces versus a claim it
|
|
111
|
+
merely warns about.
|
|
112
|
+
|
|
113
|
+
It merges into any existing `Stop` hooks rather than replacing them, and
|
|
114
|
+
`npx -y -p hivecode-mcp@latest hivecode-hook uninstall` removes it. It reads only local mirrored files
|
|
115
|
+
(`HIVE_CHAT.md`, `HIVE_TASKS.md`), so it costs no network round trip and works with
|
|
116
|
+
the relay unreachable.
|
|
117
|
+
|
|
118
|
+
Three guards stop it becoming a trap: it never blocks a stop that is already the
|
|
119
|
+
result of a block, a given message can cause at most one block, and an open task
|
|
120
|
+
stands down after three consecutive turns so an impossible task cannot pin an agent
|
|
121
|
+
forever. Any failure at all — no room, unreadable file, bad JSON — allows the stop.
|
|
122
|
+
|
|
123
|
+
Other MCP clients get the same rules in their system prompt (the server returns them
|
|
124
|
+
in `instructions` at handshake), but only Claude Code can enforce them.
|
|
125
|
+
|
|
126
|
+
## Running two or more agents in the same app
|
|
127
|
+
|
|
128
|
+
Host apps handle MCP server processes in one of two ways:
|
|
129
|
+
|
|
130
|
+
- **Per-session (separate process per chat/terminal):**
|
|
131
|
+
- **Claude Code**: Each terminal CLI session (`claude`) spawns its own independent Node child process from `~/.claude.json`. Multiple Claude Code sessions never share an MCP server process.
|
|
132
|
+
- **Single shared process across all tabs/windows:**
|
|
133
|
+
- **Antigravity**: Spawns one singleton stdio MCP process from `mcp_config.json` managed by `language_server.exe` (`--subclient_type hub`), shared by all chats, composer tabs, and agent sessions.
|
|
134
|
+
- **Cursor**: [not checked] Centralized MCP server lifecycle.
|
|
135
|
+
- **Windsurf**: [not checked] Centralized MCP server lifecycle.
|
|
136
|
+
- **Claude Desktop**: [not checked] Centralized MCP server lifecycle.
|
|
137
|
+
|
|
138
|
+
If two agents in a shared-process app call `hive_join` with different names, the server refuses the second join with **`Q637`** to protect the first agent from being silently replaced.
|
|
139
|
+
|
|
140
|
+
To run two or more agents concurrently in a shared-process app (e.g. `frontend-bot` and `backend-bot`), register a second MCP server entry in your config pointing to the same runtime copy:
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"mcpServers": {
|
|
145
|
+
"hivecode": {
|
|
146
|
+
"command": "node",
|
|
147
|
+
"args": ["<your home>/.hivecode/runtime/<version>/node_modules/hivecode-mcp/hive-mcp.js"]
|
|
148
|
+
},
|
|
149
|
+
"hivecode-2": {
|
|
150
|
+
"command": "node",
|
|
151
|
+
"args": ["<your home>/.hivecode/runtime/<version>/node_modules/hivecode-mcp/hive-mcp.js"]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Restart your app. A host that shares MCP servers exposes **all** configured servers to **every** chat — nothing automatically routes `hivecode-2` to Agent 2. You must explicitly prompt each agent which server to use (for example: *"You use only the hivecode-2 tools"*), or both agents will attempt to call `hive_join` on `hivecode`, where `Q637` will refuse the second agent.
|