hivecode-mcp 0.7.0 → 0.11.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.
- package/README.md +51 -84
- package/core.js +62 -13
- package/hive-mcp.js +515 -45
- package/icr.js +506 -34
- package/lang-brace.js +240 -0
- package/lang-js.js +642 -418
- package/lang-json.js +184 -0
- package/lang-python.js +360 -0
- package/lang-ruby.js +230 -0
- package/lang-toml.js +136 -0
- package/lang-yaml.js +151 -0
- package/package.json +97 -62
- package/substrate.js +252 -0
- package/sync.js +642 -13
- package/MCP.md +0 -77
package/README.md
CHANGED
|
@@ -7,10 +7,8 @@ live, **fence** each agent to the folders it's allowed in, **approve** the risky
|
|
|
7
7
|
moves, and **undo** any agent instantly. No git push/pull. Open source.
|
|
8
8
|
|
|
9
9
|
[**Install for VS Code**](https://marketplace.visualstudio.com/items?itemName=hivecode.hivecode)
|
|
10
|
-
· [**Website**](https://
|
|
11
|
-
· [Latest .vsix](https://github.com/
|
|
12
|
-
|
|
13
|
-
<!-- Add a demo GIF here once recorded:  -->
|
|
10
|
+
· [**Website**](https://hivecode.vercel.app)
|
|
11
|
+
· [Latest .vsix](https://github.com/Ganesh-Kute/HiveCode/releases)
|
|
14
12
|
|
|
15
13
|
---
|
|
16
14
|
|
|
@@ -34,97 +32,57 @@ git push/pull — edits sync in about a second.
|
|
|
34
32
|
|
|
35
33
|
---
|
|
36
34
|
|
|
37
|
-
##
|
|
38
|
-
|
|
39
|
-
1. Install the extension (link above). It works in **VS Code, Cursor, Windsurf,
|
|
40
|
-
and Antigravity**.
|
|
41
|
-
2. Open the folder you want to share (**File → Open Folder**).
|
|
42
|
-
3. `Ctrl/Cmd+Shift+P` → **Hivecode: Host a Secured Session**. A join link is
|
|
43
|
-
copied to your clipboard. *(No terminal, no server to run.)*
|
|
44
|
-
4. **Hivecode: Invite to folders…** → pick the folders and a role (edit /
|
|
45
|
-
read-only) for each person or agent. Send them the link.
|
|
46
|
-
5. They run **Hivecode: Join a Session** and paste the link. You're now editing
|
|
47
|
-
the same project live.
|
|
35
|
+
## Proof
|
|
48
36
|
|
|
49
|
-
|
|
37
|
+
The hard part is what happens when two agents edit the same file. Git compares lines, so
|
|
38
|
+
a rename on one side and a new call site on the other merge with no conflict — and ship a
|
|
39
|
+
crash. **ICR**, our merge engine, compares structure and intent instead.
|
|
50
40
|
|
|
51
|
-
|
|
41
|
+
Measured on [CooperBench](https://arxiv.org/abs/2601.13295) (Stanford, 2026), which gives
|
|
42
|
+
two agents independent features on one repo and scores the result by running **both**
|
|
43
|
+
features' own test suites. Of its 652 gold pairs — professional human patches, the
|
|
44
|
+
cleanest possible input — **505 conflict under git**:
|
|
52
45
|
|
|
53
|
-
|
|
46
|
+
| Merge layer | Of those 505, integrated cleanly | Passes both test suites |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| `git merge` | 0 (0%) | — |
|
|
49
|
+
| mergiraf 0.18 | 56 (11.1%) | — |
|
|
50
|
+
| **ICR** — safe default | **112 (22.2%)** | **100%** (27/27) |
|
|
51
|
+
| **ICR** — union mode | **206 (40.8%)** | **96.2%** (50/52) |
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
up once, then just hand the agent a join link; it appears in the room as an `ai`
|
|
57
|
-
member, scoped to exactly the folders you invited it to.
|
|
53
|
+
Three more independent checks:
|
|
58
54
|
|
|
59
|
-
- **
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
- **279 real conflicts humans already resolved** — compared against what the maintainer
|
|
56
|
+
actually committed: ICR matched 87, mergiraf 64, zero broken outputs, ICR ahead on all
|
|
57
|
+
five repositories.
|
|
58
|
+
- **[ConGra](https://arxiv.org/abs/2409.14121), 6,430 real Python conflicts** verified with
|
|
59
|
+
CPython's own `ast.parse`: 32.1% resolved vs mergiraf's 31.8%, with **zero crashes and
|
|
60
|
+
zero parse-guarantee violations**.
|
|
61
|
+
- **Properties, not examples** — symmetry (`M(b,x,y) = M(b,y,x)`), fixed-point, no-loss and
|
|
62
|
+
the parse guarantee, under seeded fuzz across 20+ languages: 13,000+ assertions, green.
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
Reproduce any of it: the harnesses are in [`scripts/`](scripts/) and the raw receipts in
|
|
65
|
+
[`data/`](data/).
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
anything else (relay-enforced, not trust-based).
|
|
72
|
-
- **Approval gates** — risky work waits for your OK; agent-to-agent coordination
|
|
73
|
-
flows automatically.
|
|
74
|
-
- **Instant rollback** — restore any file to an earlier point, or **revert
|
|
75
|
-
*everything* one agent did** in a click. Undo a rogue agent without touching the
|
|
76
|
-
rest of the team's work.
|
|
77
|
-
- **Mission control** — pause, resume, or reassign any agent; agents honor it
|
|
78
|
-
mid-task.
|
|
79
|
-
- **Instant revoke** — cut access mid-session, enforced server-side on every
|
|
80
|
-
reconnect (and it survives a relay restart).
|
|
81
|
-
- **Read-only roles** — reviewers see everything, change nothing.
|
|
82
|
-
|
|
83
|
-
**Coordination**
|
|
84
|
-
- **Built-in chat**, a **shared task board** (assign / complete), and **live
|
|
85
|
-
presence** so humans and agents stay in sync.
|
|
86
|
-
- **Co-editing heads-up** before two people touch the same file.
|
|
87
|
-
- **Never lose work** — overlapping edits keep both versions with conflict markers;
|
|
88
|
-
a stale rewrite can't silently delete another's lines.
|
|
89
|
-
|
|
90
|
-
**Trust**
|
|
91
|
-
- **Server-enforced auth** — signed tokens, algorithm-pinned, fail-closed.
|
|
92
|
-
Unauthorized clients never complete the WebSocket handshake.
|
|
93
|
-
- **Self-certifying secured rooms** — the room id embeds a fingerprint of your
|
|
94
|
-
public key; tokens carry the key and are signed by it; the relay trusts a token
|
|
95
|
-
only if the fingerprint matches. No account system, no shared secret. Your
|
|
96
|
-
private key stays in the editor's secure storage.
|
|
97
|
-
- **Dependency-free core** — the access-control layer uses only Node's `crypto`.
|
|
67
|
+
```bash
|
|
68
|
+
npx git-clash # see it on three real collision scenarios
|
|
69
|
+
npx git-clash --scan --base=main --head=my-branch # check one of YOUR merges before you make it
|
|
70
|
+
npm i icr-merge # the engine: library, CLI, and git merge driver (MIT)
|
|
71
|
+
npx hivecode-mcp # the live medium, as MCP tools for any agent
|
|
72
|
+
```
|
|
98
73
|
|
|
99
74
|
---
|
|
100
75
|
|
|
101
|
-
##
|
|
102
|
-
|
|
103
|
-
A secured room's id is `hs_<fp>_<rand>`, where `fp` is a base64url SHA-256
|
|
104
|
-
fingerprint of the owner's public key. Every token for the room carries the owner's
|
|
105
|
-
public key (claim `pk`) and is signed by the matching private key (RS256). The relay
|
|
106
|
-
trusts a token **iff** `fingerprint(token.pk) === fingerprint-in-room-id`, then
|
|
107
|
-
verifies the signature with that key — so trust is anchored in the room id itself
|
|
108
|
-
and the relay stores nothing.
|
|
109
|
-
|
|
110
|
-
Files use a per-file subdocument model: the room is `<base>`, each file is a
|
|
111
|
-
separate document at `<base>␁<path>`. The relay authorizes per path, so a scoped
|
|
112
|
-
client can only open the files it may load, and out-of-scope content never reaches
|
|
113
|
-
its disk. Paths are guarded against traversal, absolute paths, drive letters, and
|
|
114
|
-
control characters on both the client (before writing) and the relay.
|
|
76
|
+
## Documentation
|
|
115
77
|
|
|
116
|
-
|
|
117
|
-
is in [RBAC.md](RBAC.md).
|
|
78
|
+
To keep this README clean, we've modularized the documentation into separate files. Click below to read more about each specific topic:
|
|
118
79
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
`hivecode.relayUrl` in the extension. The relay holds no truth of its own — it just
|
|
126
|
-
passes CRDT updates between clients in the same room, and enforces access at the
|
|
127
|
-
handshake. See [DEPLOY.md](DEPLOY.md).
|
|
80
|
+
- **[🔌 Connecting & Hosting Rooms](docs/CONNECTING_ROOMS.md)** - Learn how humans join rooms, how to host your own relay server, and how the self-certifying security model works.
|
|
81
|
+
- **[🤖 AI Agent Manual](docs/AI_AGENT_MANUAL.md)** - A guide written specifically for AI agents on how to download the MCP server, join a room, and behave within the hive.
|
|
82
|
+
- **[🏛️ Hivecode Explained, end to end](HIVECODE_EXPLAINED.md)** - The full course: every mechanism motivated, explained, and shown with worked examples and runnable code — CRDT internals, the ICR pipeline, provenance, the benchmarks.
|
|
83
|
+
- **[🧠 ICR (Intent-aware Code Replication)](docs/ICR_EXPLAINED.md)** - How our semantic AST-aware merge algorithm guarantees no lines are lost during multi-agent collisions.
|
|
84
|
+
- **[🔐 DCO (Deterministic Context Override)](docs/DCO_EXPLAINED.md)** - The core breakthrough paradigm that physically locks tools based on CRDT state, structurally preventing agent hallucination and drift. Includes our End-to-End Test Report.
|
|
85
|
+
- **[🔗 The Substrate](docs/SUBSTRATE.md)** - A governed *medium* (not a channel) for multi-agent code: every change is a signed `(intent, patch, provenance)` triple, and the medium guarantees it converges, never regresses, and is provenance-verified — enforced by the relay, with no controller. Runnable + testable in one command.
|
|
128
86
|
|
|
129
87
|
---
|
|
130
88
|
|
|
@@ -132,8 +90,10 @@ handshake. See [DEPLOY.md](DEPLOY.md).
|
|
|
132
90
|
|
|
133
91
|
```bash
|
|
134
92
|
npm install
|
|
135
|
-
node test.js
|
|
93
|
+
node tests/test.js # unit tests
|
|
136
94
|
node hive-edge-test.js # adversarial / edge-case live tests
|
|
95
|
+
|
|
96
|
+
npm run test:substrate:all # the substrate: 4 suites (core + live + enforcement + content authority)
|
|
137
97
|
```
|
|
138
98
|
|
|
139
99
|
Other live suites: `hive-secure-test.js`, `hive-scope-test.js`, `hive-auth-test.js`,
|
|
@@ -144,6 +104,13 @@ The extension source is in [`extension/`](extension/).
|
|
|
144
104
|
|
|
145
105
|
---
|
|
146
106
|
|
|
107
|
+
## Support
|
|
108
|
+
|
|
109
|
+
- **Issues** — https://github.com/Ganesh-Kute/HiveCode/issues
|
|
110
|
+
- **Email** — support@getgrm.tech
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
147
114
|
## License
|
|
148
115
|
|
|
149
116
|
MIT.
|
package/core.js
CHANGED
|
@@ -89,18 +89,77 @@ export function mergeEdit(base, mine, current) {
|
|
|
89
89
|
return { conflict: true } // same lines changed two ways -> re-reason on `current`
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
// Detect REAL git-style conflict markers in a file. Line-anchored on purpose:
|
|
93
|
+
// it requires an opening `<<<<<<< ` AND a closing `>>>>>>> ` each at the start
|
|
94
|
+
// of a line. This is what merge3 emits. A naive `text.includes('<<<<<<<')`
|
|
95
|
+
// false-positives on any file that merely MENTIONS the markers (e.g. a README
|
|
96
|
+
// documenting conflict resolution), which would announce a phantom conflict on
|
|
97
|
+
// every sync. (Found by a live two-agent test, 2026-06-19.)
|
|
98
|
+
export function hasConflictMarkers(text) {
|
|
99
|
+
return /^<<<<<<< /m.test(text || '') && /^>>>>>>> /m.test(text || '')
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Strip and de-nest conflict markers to prevent exponential 2^N code ballooning
|
|
103
|
+
export function stripConflictMarkers(text, prefer = 'local') {
|
|
104
|
+
if (!text || !hasConflictMarkers(text)) return text || ''
|
|
105
|
+
const lines = text.split('\n')
|
|
106
|
+
const out = []
|
|
107
|
+
let inConflict = false
|
|
108
|
+
let inTheirs = false
|
|
109
|
+
const localBlock = []
|
|
110
|
+
const theirsBlock = []
|
|
111
|
+
|
|
112
|
+
for (let i = 0; i < lines.length; i++) {
|
|
113
|
+
const line = lines[i]
|
|
114
|
+
if (/^<<<<<<< /.test(line)) {
|
|
115
|
+
inConflict = true
|
|
116
|
+
inTheirs = false
|
|
117
|
+
localBlock.length = 0
|
|
118
|
+
theirsBlock.length = 0
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
if (/^=======$/.test(line) && inConflict) {
|
|
122
|
+
inTheirs = true
|
|
123
|
+
continue
|
|
124
|
+
}
|
|
125
|
+
if (/^>>>>>>> /.test(line) && inConflict) {
|
|
126
|
+
inConflict = false
|
|
127
|
+
out.push(...(prefer === 'theirs' ? theirsBlock : localBlock))
|
|
128
|
+
continue
|
|
129
|
+
}
|
|
130
|
+
if (inConflict) {
|
|
131
|
+
if (inTheirs) theirsBlock.push(line)
|
|
132
|
+
else localBlock.push(line)
|
|
133
|
+
} else {
|
|
134
|
+
out.push(line)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return out.join('\n')
|
|
138
|
+
}
|
|
139
|
+
|
|
92
140
|
// --- 3-way merge for the SYNC layer (disk <-> shared doc) ---
|
|
93
141
|
// Same idea as mergeEdit, but instead of bailing with { conflict } it always
|
|
94
142
|
// returns text: disjoint edits merge cleanly; overlapping edits are wrapped in
|
|
95
143
|
// git-style conflict markers so BOTH versions survive and a human/AI resolves.
|
|
144
|
+
// De-nests existing conflict blocks to prevent exponential duplication.
|
|
96
145
|
// merge3(base, mine, theirs) -> { text, conflict }
|
|
97
146
|
export function merge3(base, mine, theirs) {
|
|
98
147
|
if (mine === theirs) return { text: mine, conflict: false }
|
|
99
148
|
if (base === theirs) return { text: mine, conflict: false } // only I changed
|
|
100
149
|
if (base === mine) return { text: theirs, conflict: false } // only they changed
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const
|
|
150
|
+
|
|
151
|
+
// De-nest stale conflict markers so conflict blocks never wrap exponentially
|
|
152
|
+
const cleanBase = hasConflictMarkers(base) ? stripConflictMarkers(base, 'local') : (base || '')
|
|
153
|
+
const cleanMine = hasConflictMarkers(mine) ? stripConflictMarkers(mine, 'local') : (mine || '')
|
|
154
|
+
const cleanTheirs = hasConflictMarkers(theirs) ? stripConflictMarkers(theirs, 'theirs') : (theirs || '')
|
|
155
|
+
|
|
156
|
+
if (cleanMine === cleanTheirs) return { text: cleanMine, conflict: false }
|
|
157
|
+
if (cleanBase === cleanTheirs) return { text: cleanMine, conflict: false }
|
|
158
|
+
if (cleanBase === cleanMine) return { text: cleanTheirs, conflict: false }
|
|
159
|
+
|
|
160
|
+
const b = cleanBase.split('\n')
|
|
161
|
+
const mr = changedRange(b, cleanMine.split('\n'))
|
|
162
|
+
const tr = changedRange(b, cleanTheirs.split('\n'))
|
|
104
163
|
if (mr.endBase <= tr.startBase || tr.endBase <= mr.startBase) {
|
|
105
164
|
const out = b.slice()
|
|
106
165
|
for (const e of [mr, tr].sort((x, y) => y.startBase - x.startBase)) {
|
|
@@ -125,16 +184,6 @@ export function merge3(base, mine, theirs) {
|
|
|
125
184
|
return { text: out.join('\n'), conflict: true }
|
|
126
185
|
}
|
|
127
186
|
|
|
128
|
-
// Detect REAL git-style conflict markers in a file. Line-anchored on purpose:
|
|
129
|
-
// it requires an opening `<<<<<<< ` AND a closing `>>>>>>> ` each at the start
|
|
130
|
-
// of a line. This is what merge3 emits. A naive `text.includes('<<<<<<<')`
|
|
131
|
-
// false-positives on any file that merely MENTIONS the markers (e.g. a README
|
|
132
|
-
// documenting conflict resolution), which would announce a phantom conflict on
|
|
133
|
-
// every sync. (Found by a live two-agent test, 2026-06-19.)
|
|
134
|
-
export function hasConflictMarkers(text) {
|
|
135
|
-
return /^<<<<<<< /m.test(text) && /^>>>>>>> /m.test(text)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
187
|
// --- Rewrite detection for the auto-board ---
|
|
139
188
|
// Classify a change as a small PATCH (grep-and-edit, the common case) vs a
|
|
140
189
|
// wholesale REWRITE, and pull out the symbol names the new version defines in
|