Skip to content

Commit 50864c0

Browse files
Memory: a multi-line remember note broke NEXUS.md. The note was written as one bullet, so its later lines fell outside it, and a later line starting with # became a heading that ended the Remembered section: the next fact was inserted above it and the heading stayed in the file as real instructions. A note is now folded onto one bullet line.
1 parent 62b5562 commit 50864c0

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎lib/nexus/memory.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// a non-Latin script normalised to "" - a substring of everything.
1010
function normalize(s) { return String(s || "").normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N} ]+/gu, "").replace(/\s+/g, " ").trim(); }
1111
function mergeMemory(md, note) {
12-
const clean = String(note || "").trim();
12+
const clean = String(note || "").trim().replace(/\s*[\r\n]+\s*/g, " "); // one bullet line: a later line would fall outside it, and a "#" line would end the section
1313
if (clean.length < 3) return { md, added: false, reason: "too short" };
1414
const target = normalize(clean) || clean;
1515
const lines = String(md || "").split("\n");

‎test/run.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ group("output styles (Claude-Code idea)");
607607

608608
group("agent memory / remember — dedup");
609609
{
610+
eq("a multi-line note is kept as one bullet in the Remembered section", mergeMemory("# P\n\n## Remembered\n- a fact\n", "build with:\n## npm run build\nthen test").md, "# P\n\n## Remembered\n- a fact\n- build with: ## npm run build then test\n");
610611
let r = mergeMemory("# Nexus\n", "Use the shared Table component at src/Table.tsx");
611612
ok("adds a new fact", r.added === true && /## Remembered/.test(r.md) && /Table component/.test(r.md));
612613
const r2 = mergeMemory(r.md, "use the shared table component at src/Table.tsx");

0 commit comments

Comments
 (0)