The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Memories: a lighter About You, and builds that read less (#1153)
Dee0702d53f94f2
diff --git a/store/agents/memories/lib/deliver.mjs b/store/agents/memories/lib/deliver.mjsindex d3967975a..c77a9e70c 100644--- a/store/agents/memories/lib/deliver.mjs+++ b/store/agents/memories/lib/deliver.mjs@@ -60,8 +60,16 @@ export function inert(text) {/** Headings become plain lines: Gemini CLI adds memories at the next `## ` after its own section. */const flatHeadings = (text) => text.replace(/^#{1,6}[ \t]+(.+?)[ \t#]*$/gm, '$1:')+/**+ * About You without its sources: the `[claude:short-answers.md, asks:98]` after each line is for the person+ * reading it in the pane, and a fifth of what every session would carry (824 tokens → 582 on one Mac,+ * 2026-10-10). Only a bracket of `name:value` sources at the very end of a line is one.+ */+export const CITATION = /[ \t]*\[[a-z][a-z-]*:[^\]\n]*\][ \t]*$/gm+export const withoutSources = (text) => String(text).replace(CITATION, '')+export function packet(text) {- let body = flatHeadings(inert(text).trim())+ let body = flatHeadings(inert(withoutSources(text)).trim())if (body.length > MAX_DELIVERED) {const cut = body.lastIndexOf('\n', MAX_DELIVERED)body = body.slice(0, cut > 0 ? cut : MAX_DELIVERED) + '\n(cut here: the full profile is in ~/.harness/memory/about-you.md)'@@ -77,7 +85,8 @@ const quote = (value) => `'${String(value).replace(/'/g, `'"'"'`)}'`*/export function hookCommand(aboutPath) {const intro = `<about-you source="Harness Memories">\n${PREAMBLE}\n`- const neutralize = `sed -e 's/harness-memories:about-you/harness-memories about-you/g' -e 's#<\\(/*\\)about-you#<\\1about_you#g'`+ // The last expression is CITATION in POSIX basic regular expressions, which BSD and GNU sed both read.+ const neutralize = `sed -e 's/harness-memories:about-you/harness-memories about-you/g' -e 's#<\\(/*\\)about-you#<\\1about_you#g' -e 's/[[:blank:]]*\\[[a-z][a-z-]*:[^]]*][[:blank:]]*$//'`return `f=${quote(aboutPath)}; if [ -f "$f" ]; then printf '%s\\n' ${quote(intro)}; head -c ${MAX_DELIVERED} "$f" | ${neutralize}; printf '\\n%s\\n' '</about-you>'; fi; true ${HOOK_TAG}`}diff --git a/store/agents/memories/test/deliver.test.mjs b/store/agents/memories/test/deliver.test.mjsindex a5a101674..47cf9d343 100644--- a/store/agents/memories/test/deliver.test.mjs+++ b/store/agents/memories/test/deliver.test.mjs@@ -122,6 +122,22 @@ test('agents that are not installed get nothing; on without an About You is refuassert.deepEqual(deliver('on', { env, home: dir }).results, [])})+// The sources after each line are for the pane; a fifth of what every session carried (824 → 582 tokens, one Mac).+test('agents get About You without its sources, by hook and by block alike; any other bracket stays', () => {+ const { dir, env } = home()+ const about = '## How you work\n- Wants short answers. [claude:short-answers.md, asks:98]\n- Keeps [1] footnotes and [a link](x).\n- Ends with [see notes]\n- From a session [session:3f2a-11] \n'+ writeAbout(env.MEMORIES_HOME, about)+ const expected = ['- Wants short answers.', '- Keeps [1] footnotes and [a link](x).', '- Ends with [see notes]', '- From a session']+ const block = packet(about)+ for (const line of expected) assert.ok(block.includes(`${line}\n`), `block: ${line}`)+ assert.doesNotMatch(block, /asks:98|session:3f2a/)+ const printed = execFileSync('sh', ['-c', hookCommand(join(env.MEMORIES_HOME, 'about-you.md'))], { encoding: 'utf8' })+ for (const line of expected) assert.ok(printed.includes(`${line}\n`), `hook: ${line}`)+ assert.doesNotMatch(printed, /asks:98|session:3f2a/)+ // What the switch says it costs is what is sent.+ assert.equal(status({ env, home: dir }).tokens, Math.round(block.length / 4))+})+test('the delivered copy says what it is and is cut to fit the agents\' limits', () => {const long = '## A\n' + Array.from({ length: 400 }, (_, i) => `- line ${i} ${'x'.repeat(30)}`).join('\n')const text = packet(long)diff --git a/store/agents/memories/test/mem.test.mjs b/store/agents/memories/test/mem.test.mjsindex 2756afdf1..7fee67f1f 100644--- a/store/agents/memories/test/mem.test.mjs+++ b/store/agents/memories/test/mem.test.mjs@@ -40,7 +40,9 @@ test('search covers memories and conversations', async () => {test('asks prints your messages with their sessions', async () => {const { out } = await mem(['asks', '--since', '7d'])assert.match(out, /tldr only/)- assert.match(out, /\[session:s1\]/)+ // A conversation's messages under one heading that names its day, agent, folder and session once.+ assert.match(out, /^\d{4}-\d{2}-\d{2} · claude · ~\/code\/my-app · session:s1\n- please keep it short, tldr only\n- no, too long again$/m)+ assert.equal(out.match(/session:s1/g).length, 1)assert.match(out, /3 messages/)assert.throws(() => since('soon'), /--since/)})diff --git a/store/agents/memories/toolchain/mem.mjs b/store/agents/memories/toolchain/mem.mjsindex 5ffdd13d0..2724602fa 100755--- a/store/agents/memories/toolchain/mem.mjs+++ b/store/agents/memories/toolchain/mem.mjs@@ -135,7 +135,15 @@ export async function run(argv, { out = (line) => process.stdout.write(line + '\if (!index.db) { err(index.error); return 1 }const found = asks(index.db, { since: since(flags.since ?? '30d'), engine: flags.agent ?? null, limit: Number(flags.limit ?? 300), maxChars: Number(flags.chars ?? 400) })if (flags.json) { print(found.map((row) => ({ ...row, cwd: tilde(row.cwd, h.home) }))); return 0 }- for (const row of found) out(`${day(row.at)} ${row.engine.padEnd(8)} ${short(tilde(row.cwd, h.home), 34).padEnd(34)} ${short(row.text, 400)} [session:${row.sessionId}]`)+ // Each conversation's run of messages under one heading: date, agent, folder and session written once.+ // Per line they were half of what a build read (600 messages: 133,679 characters, 60,000 of them+ // padding and repeated session ids; one Mac, 2026-10-10).+ let heading = ''+ for (const row of found) {+ const next = [day(row.at), row.engine, tilde(row.cwd, h.home), `session:${row.sessionId}`].filter(Boolean).join(' · ')+ if (next !== heading) { out(`${heading ? '\n' : ''}${next}`); heading = next }+ out(`- ${short(row.text, 400)}`)+ }out(`${found.length} messages`)return 0}