dreamd-mcp 1.3.1 → 1.4.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 +12 -4
- package/bin/dreamd-mcp.js +103 -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, and npm ignores SIGINT; send the signal to the process group, or press Ctrl-C in the terminal.
|
|
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,93 @@ 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
|
+
// Run the native binary and settle when it is gone. Never rejects. The child
|
|
286
|
+
// shares the shim's stdio, so the JSON-RPC bytes of `dreamd mcp` pass straight
|
|
287
|
+
// through; the shim itself writes nothing to stdout.
|
|
288
|
+
function runChild(bin, args, env) {
|
|
289
|
+
return new Promise((resolve) => {
|
|
290
|
+
const plan = signalPlan(process.platform);
|
|
291
|
+
const listeners = [];
|
|
292
|
+
let done = false;
|
|
293
|
+
let child;
|
|
294
|
+
const removeListeners = () => {
|
|
295
|
+
for (const [sig, fn] of listeners) process.removeListener(sig, fn);
|
|
296
|
+
listeners.length = 0;
|
|
297
|
+
};
|
|
298
|
+
const settle = () => {
|
|
299
|
+
if (done) return false;
|
|
300
|
+
done = true;
|
|
301
|
+
removeListeners();
|
|
302
|
+
return true;
|
|
303
|
+
};
|
|
304
|
+
try {
|
|
305
|
+
child = spawn(bin, args, { stdio: 'inherit', env });
|
|
306
|
+
} catch (err) {
|
|
307
|
+
// A synchronous throw (an invalid argument) is a spawn failure too.
|
|
308
|
+
settle();
|
|
309
|
+
process.stderr.write(`[dreamd-mcp] could not start ${bin}: ${err.code}: ${err.message}\n`);
|
|
310
|
+
process.exitCode = 1;
|
|
311
|
+
resolve();
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
for (const sig of plan.forward) {
|
|
315
|
+
const fn = () => {
|
|
316
|
+
try {
|
|
317
|
+
child.kill(sig);
|
|
318
|
+
} catch {
|
|
319
|
+
// The child is already gone; its 'exit' settles.
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
process.on(sig, fn);
|
|
323
|
+
listeners.push([sig, fn]);
|
|
324
|
+
}
|
|
325
|
+
for (const sig of plan.hold) {
|
|
326
|
+
const fn = () => {};
|
|
327
|
+
process.on(sig, fn);
|
|
328
|
+
listeners.push([sig, fn]);
|
|
329
|
+
}
|
|
330
|
+
child.on('error', (err) => {
|
|
331
|
+
if (!settle()) return;
|
|
332
|
+
process.stderr.write(`[dreamd-mcp] could not start ${bin}: ${err.code}: ${err.message}\n`);
|
|
333
|
+
process.exitCode = 1;
|
|
334
|
+
resolve();
|
|
335
|
+
});
|
|
336
|
+
child.on('exit', (code, signal) => {
|
|
337
|
+
if (!settle()) return;
|
|
338
|
+
if (signal && process.platform !== 'win32') {
|
|
339
|
+
// Die of the same signal, so a shell or supervisor sees what the
|
|
340
|
+
// child gave the shim. The listeners are gone, so the default action
|
|
341
|
+
// runs.
|
|
342
|
+
try {
|
|
343
|
+
process.kill(process.pid, signal);
|
|
344
|
+
} catch {
|
|
345
|
+
// Fall through to the exit status below.
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
process.exitCode = exitCodeFor(code, signal);
|
|
349
|
+
resolve();
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
266
354
|
async function main() {
|
|
267
355
|
const args = process.argv.slice(2);
|
|
268
356
|
|
|
@@ -291,7 +379,7 @@ async function main() {
|
|
|
291
379
|
'[dreamd-mcp] WARNING: DREAMD_BIN set — skipping sha256 verification. ' +
|
|
292
380
|
'Use only for local development builds.\n',
|
|
293
381
|
);
|
|
294
|
-
|
|
382
|
+
await runChild(process.env.DREAMD_BIN, dreamdArgs, childEnv(process.env));
|
|
295
383
|
return;
|
|
296
384
|
}
|
|
297
385
|
|
|
@@ -300,8 +388,8 @@ async function main() {
|
|
|
300
388
|
if (process.platform === 'win32') {
|
|
301
389
|
process.stderr.write(
|
|
302
390
|
`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
|
-
`
|
|
391
|
+
`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` +
|
|
392
|
+
`For npx -y dreamd-mcp, use WSL2 or a Linux/macOS host.\n` +
|
|
305
393
|
`Prebuilt shim binaries ship for linux-x64, darwin-x64, and darwin-arm64 only.\n`
|
|
306
394
|
);
|
|
307
395
|
} else {
|
|
@@ -339,18 +427,15 @@ async function main() {
|
|
|
339
427
|
// Verify sha256 before every exec (not just on download)
|
|
340
428
|
verifyBinary(binaryPath, binaryEntry.sha256);
|
|
341
429
|
|
|
342
|
-
|
|
430
|
+
await runChild(binaryPath, dreamdArgs, childEnv(process.env));
|
|
343
431
|
}
|
|
344
432
|
|
|
345
433
|
if (require.main === module) {
|
|
434
|
+
// No child run throws (runChild never rejects), so a throw here is a
|
|
435
|
+
// download or verify step's, and it is fatal.
|
|
346
436
|
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
|
-
}
|
|
437
|
+
process.stderr.write(`[dreamd-mcp] Fatal error: ${err.message}\n`);
|
|
438
|
+
process.exit(1);
|
|
354
439
|
});
|
|
355
440
|
}
|
|
356
441
|
|
|
@@ -362,4 +447,7 @@ module.exports = {
|
|
|
362
447
|
isAllowedRedirectHost,
|
|
363
448
|
validateRedirect,
|
|
364
449
|
isSafeTarEntry,
|
|
450
|
+
signalPlan,
|
|
451
|
+
exitCodeFor,
|
|
452
|
+
runChild,
|
|
365
453
|
};
|
package/manifest.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.4.0",
|
|
3
3
|
"binaries": {
|
|
4
4
|
"linux-x86_64": {
|
|
5
|
-
"sha256": "
|
|
5
|
+
"sha256": "a8fc1ece8cb1e90351ed941051d78661a68fcc012a5fa1e8cab2b266bff6bca4"
|
|
6
6
|
},
|
|
7
7
|
"darwin-x86_64": {
|
|
8
|
-
"sha256": "
|
|
8
|
+
"sha256": "5775bf1712e65c7242db51e107e2fcb7b3adcf00ec8939809a43b81ba3ddd306"
|
|
9
9
|
},
|
|
10
10
|
"darwin-aarch64": {
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "34a3f17e5c548c41aa356b0973ba00f761c340e44ea11bbf755d4cc056333d82"
|
|
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.0",
|
|
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",
|