Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

fix(memory): keep settings.json/cursor/messages out of mempalace index

Chaitanya Girid22435058ce1
diff --git a/src/main/hive.ts b/src/main/hive.ts
index 30842dd1..00a4646b 100644
--- a/src/main/hive.ts
+++ b/src/main/hive.ts
@@ -103,6 +103,24 @@ function shortRand(): string {
return randomBytes(3).toString('hex');
}
+/** Non-memory files `mempalace mine` must not ingest (Claude Code hooks config,
+ * cursor, raw inbox/outbox JSON). `mempalace mine` honors .gitignore, so we drop
+ * one in each agent dir; written on birth here and refreshed by the mine loop. */
+const MINE_IGNORE_LINES = ['settings.json', 'cursor.json', 'inbox/', 'outbox/'];
+
+/** Idempotently ensure `<agentDir>/.gitignore` excludes the non-memory files.
+ * Append-only: writes only the missing lines, leaving any existing entries. */
+function ensureMineIgnore(agentDir: string): void {
+ const path = join(agentDir, '.gitignore');
+ let existing = '';
+ try { if (existsSync(path)) existing = readFileSync(path, 'utf8'); } catch { return; }
+ const have = new Set(existing.split('\n').map((l) => l.trim()));
+ const missing = MINE_IGNORE_LINES.filter((l) => !have.has(l));
+ if (missing.length === 0) return;
+ const prefix = existing && !existing.endsWith('\n') ? existing + '\n' : existing;
+ try { writeFileSync(path, prefix + missing.join('\n') + '\n', 'utf8'); } catch { /* best-effort */ }
+}
+
// ─── HiveManager ────────────────────────────────────────────────────────────
export class HiveManager {
@@ -205,6 +223,7 @@ export class HiveManager {
if (!existsSync(memory)) {
writeFileSync(memory, `# Memory — ${meta.name} (${meta.id})\n\n_Append durable facts, decisions, and context below._\n`, 'utf8');
}
+ ensureMineIgnore(dir); // keep settings.json / cursor / messages out of mempalace's index
const cursor = join(dir, 'cursor.json');
if (!existsSync(cursor)) this.writeJson(cursor, { lastProcessed: null });
diff --git a/src/main/memory.ts b/src/main/memory.ts
index 7ed1478d..fef50fd7 100644
--- a/src/main/memory.ts
+++ b/src/main/memory.ts
@@ -13,10 +13,29 @@
*
* Runs in the Electron main process.
*/
-import { existsSync, statSync, readdirSync } from 'node:fs';
+import { existsSync, statSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { spawn, spawnSync } from 'node:child_process';
+/** Non-memory files `mempalace mine` must not ingest: the Claude Code hooks
+ * config (a large JSON blob that swamps the wake-up digest), the cursor, and
+ * raw inbox/outbox message JSON. `mempalace mine` honors .gitignore, so we drop
+ * one in each agent dir rather than touch the mine command. */
+const MINE_IGNORE_LINES = ['settings.json', 'cursor.json', 'inbox/', 'outbox/'];
+
+/** Idempotently ensure `<agentDir>/.gitignore` excludes the non-memory files.
+ * Writes only the missing lines (append-only) so it's safe to call every cycle. */
+function ensureMineIgnore(agentDir: string): void {
+ const path = join(agentDir, '.gitignore');
+ let existing = '';
+ try { if (existsSync(path)) existing = readFileSync(path, 'utf8'); } catch { return; }
+ const have = new Set(existing.split('\n').map((l) => l.trim()));
+ const missing = MINE_IGNORE_LINES.filter((l) => !have.has(l));
+ if (missing.length === 0) return; // already covered — don't rewrite every cycle
+ const prefix = existing && !existing.endsWith('\n') ? existing + '\n' : existing;
+ try { writeFileSync(path, prefix + missing.join('\n') + '\n', 'utf8'); } catch { /* best-effort */ }
+}
+
export type EmbeddingModel = 'minilm' | 'embeddinggemma';
export interface MemorySettings {
@@ -188,6 +207,7 @@ export class MemoryManager {
return new Promise((resolve) => {
const bin = this.bin();
if (!bin) { resolve(); return; }
+ ensureMineIgnore(agentDir); // keep settings.json / cursor / messages out of the index
// stdin closed (mempalace can prompt); mempalace dedups so re-mining is safe.
const proc = spawn(bin, ['mine', agentDir, '--wing', id, '--agent', id], {
env: this.childEnv(), stdio: ['ignore', 'ignore', 'pipe']