dreamd-mcp 1.3.2 → 1.4.1
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 +12 -4
- package/bin/dreamd-mcp.js +128 -15
- package/manifest.json +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# dreamd-mcp
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Shared memory across coding agents, in files you can trace and undo.** Every lesson cites the events it came from. `blame` shows which memories drove an answer. `forget` removes a bad memory and the lesson state built on it, with a receipt. `git revert` rolls back a whole learning cycle.
|
|
4
4
|
|
|
5
|
-
dreamd is local-first, long-term memory for AI agents, served over MCP to Claude Code, Cursor, Cline and other MCP-aware harnesses. Memory lives in `.agent/` in your repo as JSONL and Markdown and is committed with your code, so you review what agents learned the way you review code.
|
|
5
|
+
dreamd is local-first, long-term memory for AI agents, served over MCP to Claude Code, Cursor, Cline and other MCP-aware harnesses. Memory lives in `.agent/` in your repo as JSONL and Markdown and is committed with your code (`setup` prints the commit command), so you review what agents learned the way you review code.
|
|
6
6
|
|
|
7
7
|
Source, docs and issues: **[github.com/botzrDev/dreamd](https://github.com/botzrDev/dreamd)**
|
|
8
8
|
|
|
@@ -46,7 +46,7 @@ After a `forget`, `doctor --provenance` reports the removed event's old ledger e
|
|
|
46
46
|
|
|
47
47
|
## How agents learn
|
|
48
48
|
|
|
49
|
-
Agents write episodes (what happened, how painful it was, how important) through the MCP tool `append_node` and recall them with `search_nodes`; each hit carries an `id` (`evt_` for an event, `lsn_` for a lesson) and its source harness. A learning cycle (`dreamd dream`) clusters episodes by `skill_action`, promotes a recurring pattern into a lesson in `LESSONS.md` that cites its events, and commits the result to your project's git repo as `dreamd: cycle YYYY-MM-DD`. That commit is skipped when a file holds a change no dream cycle wrote (a hand edit, `forget`, or `archive --force-unpin`). Appends and a cycle's own rewrites do not hold it. Recall ranks episodes and lessons with BM25 × salience (age decay, pain, importance, recurrence). Preview the next cycle with `npx -y dreamd-mcp dream --dry`.
|
|
49
|
+
Agents write episodes (what happened, how painful it was, how important) through the MCP tool `append_node` and recall them with `search_nodes`; each hit carries an `id` (`evt_` for an event, `lsn_` for a lesson) and its source harness. A learning cycle (`npx -y dreamd-mcp dream`) clusters episodes by `skill_action`, promotes a recurring pattern into a lesson in `LESSONS.md` that cites its events, and commits the result to your project's git repo as `dreamd: cycle YYYY-MM-DD`. Nothing runs that cycle on a timer, and there is no MCP tool for it. That commit is skipped when a file holds a change no dream cycle wrote (a hand edit, `forget`, or `archive --force-unpin`). Appends and a cycle's own rewrites do not hold it. Recall ranks episodes and lessons with BM25 × salience (age decay, pain, importance, recurrence). Preview the next cycle with `npx -y dreamd-mcp dream --dry`.
|
|
50
50
|
|
|
51
51
|
## Install
|
|
52
52
|
|
|
@@ -58,6 +58,12 @@ npx -y dreamd-mcp watch # 2. shared daemon, recommended when several agents wr
|
|
|
58
58
|
# 3. reload the harness: it now spawns `npx -y dreamd-mcp` itself
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
+
While git has no commit of `.agent/`, `setup` prints the command that commits it, because `git clean -fd` deletes untracked memory:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
git add .agent .gitignore && git commit -m "Add dreamd memory" -- .agent .gitignore
|
|
65
|
+
```
|
|
66
|
+
|
|
61
67
|
`setup` prompts when it has a TTY; in scripts pass `--yes` with `--harness claude|cursor|both|none`. It rewrites each MCP config as 2-space pretty-printed JSON, so an existing `.mcp.json` or `.cursor/mcp.json` can come back reformatted; other MCP servers in the file are kept. `npx -y dreamd-mcp init` scaffolds the store only, same as `setup --no-write-mcp`. Adapter quickstarts: [Claude Code](https://github.com/botzrDev/dreamd/tree/main/adapters/claude-code) · [Cursor](https://github.com/botzrDev/dreamd/tree/main/adapters/cursor) · [Cline](https://github.com/botzrDev/dreamd/tree/main/adapters/cline)
|
|
62
68
|
|
|
63
69
|
**Several agents at once.** `npx -y dreamd-mcp` connects to a shared daemon if one is running, and otherwise runs a standalone in-process server. Sequential use across tools is safe. To point several agents at the same project simultaneously, start one daemon per machine with `npx -y dreamd-mcp watch` so every write goes through a single serialized writer.
|
|
@@ -66,6 +72,8 @@ npx -y dreamd-mcp watch # 2. shared daemon, recommended when several agents wr
|
|
|
66
72
|
|
|
67
73
|
**Windows.** This shim ships no Windows binary: on native Windows `npx -y dreamd-mcp` exits 1 and points you at WSL2. A `dreamd.exe` built from source runs learn, the learning cycle and the Tantivy index; start `dreamd watch` before `dreamd mcp` ([docs/windows.md](https://github.com/botzrDev/dreamd/blob/main/docs/windows.md)).
|
|
68
74
|
|
|
75
|
+
**Signals and exit status.** The shim passes SIGINT, SIGTERM and SIGHUP to `dreamd` and waits for it to exit. It exits with `dreamd`'s exit code, and if `dreamd` dies of a signal, the shim dies of the same signal. A binary that cannot start makes the shim exit 1 and print the binary's path. On Windows the shim passes nothing on: the console already sends Ctrl-C to `dreamd`, and the shim waits for it. Under `npx`, npm runs the shim through `sh -c`. Where `/bin/sh` is dash, as on Debian and Ubuntu, a SIGTERM sent to the `npm exec` process stops only that shell. The shim notices within a second that the process it started under is gone, and sends `dreamd` a SIGTERM, so `watch` stops and removes its socket. So any harness or script that kills `npm exec` also stops the server it started. npm ignores SIGINT, so to interrupt `npx … watch` press Ctrl-C in the terminal, or send SIGTERM.
|
|
76
|
+
|
|
69
77
|
> **Leave `npx dreamd-mcp` floating; don't pin.** On a fresh spawn, npx re-resolves the `latest` dist-tag, so a floating config always starts the current version. A running MCP server or `dreamd watch` daemon keeps the version it started with until you restart it, and an offline run falls back to the last-cached binary.
|
|
70
78
|
|
|
71
79
|
## Commands
|
|
@@ -86,7 +94,7 @@ Any other first argument is passed to `dreamd mcp` (so `npx -y dreamd-mcp --proj
|
|
|
86
94
|
npx -y dreamd-mcp update # or: dreamd update
|
|
87
95
|
```
|
|
88
96
|
|
|
89
|
-
`update` stops this `$HOME`'s local `dreamd mcp` / `dreamd watch` processes
|
|
97
|
+
`update` stops this `$HOME`'s local `dreamd mcp` / `dreamd watch` processes and removes the socket. In `~/.cache/dreamd-mcp` it keeps this version's binary and removes every older and newer one; the shim downloads a version again if a spawn needs it. It never contacts the network, so it cannot tell whether a newer release exists. Then reload your MCP harness so it drops the old process, and re-run `npx -y dreamd-mcp`: floating npx runs the newest published dreamd-mcp, and the shim downloads a binary only for a version it has not cached. A dreamd-mcp installed globally or in the project's `node_modules` runs instead, and an MCP config that pins a dreamd-mcp version stays on it; use the floating form to follow new releases. `update` never relaunches anything for you. `--dry-run` prints the plan and changes nothing; `--restart` makes the stop step explicit; `--quiet` / `-q` trims output. It does not touch `~/.npm/_npx`, and it does not replace a binary you built with `cargo install`.
|
|
90
98
|
|
|
91
99
|
## Uninstall / reset
|
|
92
100
|
|
package/bin/dreamd-mcp.js
CHANGED
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
|
|
4
4
|
// dreamd-mcp — npx download/verify/exec shim for the native `dreamd` binary.
|
|
5
5
|
// Flow: resolve platform → cache hit or GitHub release download → sha256 verify
|
|
6
|
-
// →
|
|
7
|
-
//
|
|
8
|
-
//
|
|
6
|
+
// → run as a child that gets the shim's signals and whose exit status the shim
|
|
7
|
+
// keeps (DRM-123). Env overrides: DREAMD_BIN (+ DREAMD_BIN_ALLOW_UNVERIFIED).
|
|
8
|
+
// The shim sets DREAMD_LAUNCHER=npx for the binary it runs. Exports below are
|
|
9
|
+
// for unit tests only; IDEs spawn this file as the MCP entrypoint.
|
|
9
10
|
|
|
10
11
|
const https = require('https');
|
|
11
12
|
const fs = require('fs');
|
|
12
13
|
const path = require('path');
|
|
13
14
|
const os = require('os');
|
|
14
15
|
const crypto = require('crypto');
|
|
15
|
-
const { execFileSync, spawnSync } = require('child_process');
|
|
16
|
+
const { execFileSync, spawn, spawnSync } = require('child_process');
|
|
16
17
|
const zlib = require('zlib');
|
|
17
18
|
|
|
18
19
|
// Derived from package.json — the single source of truth for the version. This
|
|
@@ -263,6 +264,118 @@ async function ensureBinary(target, binaryPath, expectedSha256) {
|
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
266
|
|
|
267
|
+
// Which signals the shim passes to the child, and which it only holds so it
|
|
268
|
+
// outlives the child (DRM-123). On Windows the console already delivers
|
|
269
|
+
// Ctrl-C and Ctrl-Break to the child, and child.kill() is TerminateProcess,
|
|
270
|
+
// which would skip dreamd's shutdown.
|
|
271
|
+
function signalPlan(platform) {
|
|
272
|
+
return platform === 'win32'
|
|
273
|
+
? { forward: [], hold: ['SIGINT', 'SIGBREAK'] }
|
|
274
|
+
: { forward: ['SIGINT', 'SIGTERM', 'SIGHUP'], hold: [] };
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// The status a shim that cannot die of `signal` exits with: the child's own
|
|
278
|
+
// code, else 128 + the signal's number, else 1.
|
|
279
|
+
function exitCodeFor(code, signal) {
|
|
280
|
+
if (typeof code === 'number') return code;
|
|
281
|
+
const n = signal ? os.constants.signals[signal] : undefined;
|
|
282
|
+
return typeof n === 'number' ? 128 + n : 1;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// How often the shim checks whether its parent is gone (DRM-160).
|
|
286
|
+
const ORPHAN_POLL_MS = 500;
|
|
287
|
+
|
|
288
|
+
// Run the native binary and settle when it is gone. Never rejects. The child
|
|
289
|
+
// shares the shim's stdio, so the JSON-RPC bytes of `dreamd mcp` pass straight
|
|
290
|
+
// through; the shim itself writes nothing to stdout.
|
|
291
|
+
function runChild(bin, args, env) {
|
|
292
|
+
return new Promise((resolve) => {
|
|
293
|
+
const plan = signalPlan(process.platform);
|
|
294
|
+
const listeners = [];
|
|
295
|
+
let done = false;
|
|
296
|
+
let child;
|
|
297
|
+
const removeListeners = () => {
|
|
298
|
+
for (const [sig, fn] of listeners) process.removeListener(sig, fn);
|
|
299
|
+
listeners.length = 0;
|
|
300
|
+
};
|
|
301
|
+
let orphanTimer = null;
|
|
302
|
+
const settle = () => {
|
|
303
|
+
if (done) return false;
|
|
304
|
+
done = true;
|
|
305
|
+
removeListeners();
|
|
306
|
+
if (orphanTimer) clearInterval(orphanTimer);
|
|
307
|
+
return true;
|
|
308
|
+
};
|
|
309
|
+
try {
|
|
310
|
+
child = spawn(bin, args, { stdio: 'inherit', env });
|
|
311
|
+
} catch (err) {
|
|
312
|
+
// A synchronous throw (an invalid argument) is a spawn failure too.
|
|
313
|
+
settle();
|
|
314
|
+
process.stderr.write(`[dreamd-mcp] could not start ${bin}: ${err.code}: ${err.message}\n`);
|
|
315
|
+
process.exitCode = 1;
|
|
316
|
+
resolve();
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
for (const sig of plan.forward) {
|
|
320
|
+
const fn = () => {
|
|
321
|
+
try {
|
|
322
|
+
child.kill(sig);
|
|
323
|
+
} catch {
|
|
324
|
+
// The child is already gone; its 'exit' settles.
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
process.on(sig, fn);
|
|
328
|
+
listeners.push([sig, fn]);
|
|
329
|
+
}
|
|
330
|
+
for (const sig of plan.hold) {
|
|
331
|
+
const fn = () => {};
|
|
332
|
+
process.on(sig, fn);
|
|
333
|
+
listeners.push([sig, fn]);
|
|
334
|
+
}
|
|
335
|
+
// The orphan rule (DRM-160). Under `npx`, the shim's parent is npm's
|
|
336
|
+
// `sh -c`. Where /bin/sh is dash, a SIGTERM to `npm exec` kills that
|
|
337
|
+
// shell and is never passed on, so the shim and the native `watch` kept
|
|
338
|
+
// running. When the parent the shim started under is gone, the shim is
|
|
339
|
+
// reparented: it then stops the child as if it had got SIGTERM. For
|
|
340
|
+
// `dreamd mcp` this changes nothing, since stdin EOF already ends it.
|
|
341
|
+
if (process.platform !== 'win32') {
|
|
342
|
+
const parent = process.ppid;
|
|
343
|
+
orphanTimer = setInterval(() => {
|
|
344
|
+
if (process.ppid === parent) return;
|
|
345
|
+
clearInterval(orphanTimer);
|
|
346
|
+
try {
|
|
347
|
+
child.kill('SIGTERM');
|
|
348
|
+
} catch {
|
|
349
|
+
// The child is already gone; its 'exit' settles.
|
|
350
|
+
}
|
|
351
|
+
}, ORPHAN_POLL_MS);
|
|
352
|
+
// The child keeps the shim alive; the timer must not.
|
|
353
|
+
orphanTimer.unref();
|
|
354
|
+
}
|
|
355
|
+
child.on('error', (err) => {
|
|
356
|
+
if (!settle()) return;
|
|
357
|
+
process.stderr.write(`[dreamd-mcp] could not start ${bin}: ${err.code}: ${err.message}\n`);
|
|
358
|
+
process.exitCode = 1;
|
|
359
|
+
resolve();
|
|
360
|
+
});
|
|
361
|
+
child.on('exit', (code, signal) => {
|
|
362
|
+
if (!settle()) return;
|
|
363
|
+
if (signal && process.platform !== 'win32') {
|
|
364
|
+
// Die of the same signal, so a shell or supervisor sees what the
|
|
365
|
+
// child gave the shim. The listeners are gone, so the default action
|
|
366
|
+
// runs.
|
|
367
|
+
try {
|
|
368
|
+
process.kill(process.pid, signal);
|
|
369
|
+
} catch {
|
|
370
|
+
// Fall through to the exit status below.
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
process.exitCode = exitCodeFor(code, signal);
|
|
374
|
+
resolve();
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
266
379
|
async function main() {
|
|
267
380
|
const args = process.argv.slice(2);
|
|
268
381
|
|
|
@@ -291,7 +404,7 @@ async function main() {
|
|
|
291
404
|
'[dreamd-mcp] WARNING: DREAMD_BIN set — skipping sha256 verification. ' +
|
|
292
405
|
'Use only for local development builds.\n',
|
|
293
406
|
);
|
|
294
|
-
|
|
407
|
+
await runChild(process.env.DREAMD_BIN, dreamdArgs, childEnv(process.env));
|
|
295
408
|
return;
|
|
296
409
|
}
|
|
297
410
|
|
|
@@ -300,8 +413,8 @@ async function main() {
|
|
|
300
413
|
if (process.platform === 'win32') {
|
|
301
414
|
process.stderr.write(
|
|
302
415
|
`This npm package has no Windows binary.\n` +
|
|
303
|
-
`A dreamd.exe built from source, or taken from a GitHub release windows-x86_64.tar.gz when that release has one,
|
|
304
|
-
`
|
|
416
|
+
`A dreamd.exe built from source, or taken from a GitHub release windows-x86_64.tar.gz when that release has one, runs learn, the dream cycle, and the Tantivy index over loopback. Start dreamd watch before dreamd mcp.\n` +
|
|
417
|
+
`For npx -y dreamd-mcp, use WSL2 or a Linux/macOS host.\n` +
|
|
305
418
|
`Prebuilt shim binaries ship for linux-x64, darwin-x64, and darwin-arm64 only.\n`
|
|
306
419
|
);
|
|
307
420
|
} else {
|
|
@@ -339,18 +452,15 @@ async function main() {
|
|
|
339
452
|
// Verify sha256 before every exec (not just on download)
|
|
340
453
|
verifyBinary(binaryPath, binaryEntry.sha256);
|
|
341
454
|
|
|
342
|
-
|
|
455
|
+
await runChild(binaryPath, dreamdArgs, childEnv(process.env));
|
|
343
456
|
}
|
|
344
457
|
|
|
345
458
|
if (require.main === module) {
|
|
459
|
+
// No child run throws (runChild never rejects), so a throw here is a
|
|
460
|
+
// download or verify step's, and it is fatal.
|
|
346
461
|
main().catch((err) => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
process.stderr.write(`[dreamd-mcp] command exited with code ${err.status}\n`);
|
|
350
|
-
} else {
|
|
351
|
-
process.stderr.write(`[dreamd-mcp] Fatal error: ${err.message}\n`);
|
|
352
|
-
process.exit(1);
|
|
353
|
-
}
|
|
462
|
+
process.stderr.write(`[dreamd-mcp] Fatal error: ${err.message}\n`);
|
|
463
|
+
process.exit(1);
|
|
354
464
|
});
|
|
355
465
|
}
|
|
356
466
|
|
|
@@ -362,4 +472,7 @@ module.exports = {
|
|
|
362
472
|
isAllowedRedirectHost,
|
|
363
473
|
validateRedirect,
|
|
364
474
|
isSafeTarEntry,
|
|
475
|
+
signalPlan,
|
|
476
|
+
exitCodeFor,
|
|
477
|
+
runChild,
|
|
365
478
|
};
|
package/manifest.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.4.1",
|
|
3
3
|
"binaries": {
|
|
4
4
|
"linux-x86_64": {
|
|
5
|
-
"sha256": "
|
|
5
|
+
"sha256": "a0a42ae375198a81a484df3341fea78a0f6beff9e3a910ea2bc795a871fbcae9"
|
|
6
6
|
},
|
|
7
7
|
"darwin-x86_64": {
|
|
8
|
-
"sha256": "
|
|
8
|
+
"sha256": "d7c0fe1971c439e5fe36a6bd20c48344ec98a3c5301f3698d6b84e726e0f98ba"
|
|
9
9
|
},
|
|
10
10
|
"darwin-aarch64": {
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "ca37ab40d5beda4f873980b838e7422c8f9b2c9ed47a6ac93067ce0d7578be95"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dreamd-mcp",
|
|
3
3
|
"mcpName": "io.github.botzrDev/dreamd",
|
|
4
|
-
"version": "1.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "1.4.1",
|
|
5
|
+
"description": "Shared memory for Claude Code, Cursor, and Cline, in files you can audit. Trace a bad memory and remove it with a receipt. Local-first MCP server.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mcp",
|
|
8
8
|
"mcp-server",
|