hivecode-mcp 0.8.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 +116 -68
- package/core.js +62 -13
- package/hive-mcp.js +458 -48
- package/icr.js +502 -35
- package/lang-brace.js +240 -174
- package/lang-js.js +642 -418
- package/lang-json.js +184 -0
- package/lang-python.js +360 -149
- package/lang-ruby.js +230 -0
- package/lang-toml.js +136 -0
- package/lang-yaml.js +151 -0
- package/package.json +97 -70
- package/sync.js +220 -10
- package/MCP.md +0 -77
package/README.md
CHANGED
|
@@ -1,68 +1,116 @@
|
|
|
1
|
-
<h1>Hivecode</h1>
|
|
2
|
-
|
|
3
|
-
**Oversight and control for your AI coding agents.**
|
|
4
|
-
|
|
5
|
-
Run AI agents on your codebase and actually stay in control: **watch** every edit
|
|
6
|
-
live, **fence** each agent to the folders it's allowed in, **approve** the risky
|
|
7
|
-
moves, and **undo** any agent instantly. No git push/pull. Open source.
|
|
8
|
-
|
|
9
|
-
[**Install for VS Code**](https://marketplace.visualstudio.com/items?itemName=hivecode.hivecode)
|
|
10
|
-
· [**Website**](https://
|
|
11
|
-
· [Latest .vsix](https://github.com/
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## Why
|
|
16
|
-
|
|
17
|
-
You can't trust an AI agent blindly. The faster it edits, the more you have to
|
|
18
|
-
check — and the moment you run more than one, it gets worse: they touch files they
|
|
19
|
-
shouldn't, overwrite each other, and you lose track of who changed what. Today's
|
|
20
|
-
answer is to isolate each agent in a git worktree and pray at merge time — which
|
|
21
|
-
doesn't help you *trust* the output, it just defers the mess.
|
|
22
|
-
|
|
23
|
-
Hivecode adds the missing layer: **oversight and control.**
|
|
24
|
-
|
|
25
|
-
- **See everything** — a live Control Room (browser or phone) shows every agent and every file it touches, in real time.
|
|
26
|
-
- **Fence them in** — folder-scoped access the relay enforces; an out-of-scope agent never even receives the code.
|
|
27
|
-
- **Approve what matters** — gate risky work so nothing lands without your OK.
|
|
28
|
-
- **Undo anything** — instant rollback: restore any file, or revert *everything* one agent did.
|
|
29
|
-
|
|
30
|
-
It's **agent-neutral**: Claude Code, Cursor, Windsurf, or your own bot over MCP. No
|
|
31
|
-
git push/pull — edits sync in about a second.
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
##
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
`
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
1
|
+
<h1>Hivecode</h1>
|
|
2
|
+
|
|
3
|
+
**Oversight and control for your AI coding agents.**
|
|
4
|
+
|
|
5
|
+
Run AI agents on your codebase and actually stay in control: **watch** every edit
|
|
6
|
+
live, **fence** each agent to the folders it's allowed in, **approve** the risky
|
|
7
|
+
moves, and **undo** any agent instantly. No git push/pull. Open source.
|
|
8
|
+
|
|
9
|
+
[**Install for VS Code**](https://marketplace.visualstudio.com/items?itemName=hivecode.hivecode)
|
|
10
|
+
· [**Website**](https://hivecode.vercel.app)
|
|
11
|
+
· [Latest .vsix](https://github.com/Ganesh-Kute/HiveCode/releases)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Why
|
|
16
|
+
|
|
17
|
+
You can't trust an AI agent blindly. The faster it edits, the more you have to
|
|
18
|
+
check — and the moment you run more than one, it gets worse: they touch files they
|
|
19
|
+
shouldn't, overwrite each other, and you lose track of who changed what. Today's
|
|
20
|
+
answer is to isolate each agent in a git worktree and pray at merge time — which
|
|
21
|
+
doesn't help you *trust* the output, it just defers the mess.
|
|
22
|
+
|
|
23
|
+
Hivecode adds the missing layer: **oversight and control.**
|
|
24
|
+
|
|
25
|
+
- **See everything** — a live Control Room (browser or phone) shows every agent and every file it touches, in real time.
|
|
26
|
+
- **Fence them in** — folder-scoped access the relay enforces; an out-of-scope agent never even receives the code.
|
|
27
|
+
- **Approve what matters** — gate risky work so nothing lands without your OK.
|
|
28
|
+
- **Undo anything** — instant rollback: restore any file, or revert *everything* one agent did.
|
|
29
|
+
|
|
30
|
+
It's **agent-neutral**: Claude Code, Cursor, Windsurf, or your own bot over MCP. No
|
|
31
|
+
git push/pull — edits sync in about a second.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Proof
|
|
36
|
+
|
|
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.
|
|
40
|
+
|
|
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**:
|
|
45
|
+
|
|
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) |
|
|
52
|
+
|
|
53
|
+
Three more independent checks:
|
|
54
|
+
|
|
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.
|
|
63
|
+
|
|
64
|
+
Reproduce any of it: the harnesses are in [`scripts/`](scripts/) and the raw receipts in
|
|
65
|
+
[`data/`](data/).
|
|
66
|
+
|
|
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
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Documentation
|
|
77
|
+
|
|
78
|
+
To keep this README clean, we've modularized the documentation into separate files. Click below to read more about each specific topic:
|
|
79
|
+
|
|
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.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Development
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm install
|
|
93
|
+
node tests/test.js # unit tests
|
|
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)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Other live suites: `hive-secure-test.js`, `hive-scope-test.js`, `hive-auth-test.js`,
|
|
100
|
+
`hive-readonly-test.js`, `hive-resume-test.js`, `hive-control-test.js`,
|
|
101
|
+
`hive-durable-revoke-test.js`, `hive-relay-robust-test.js`.
|
|
102
|
+
|
|
103
|
+
The extension source is in [`extension/`](extension/).
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Support
|
|
108
|
+
|
|
109
|
+
- **Issues** — https://github.com/Ganesh-Kute/HiveCode/issues
|
|
110
|
+
- **Email** — support@getgrm.tech
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
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
|