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(hive): untrack Codex homes that are already in the index

Vyapak Goyal182b0bfae16f
diff --git a/src/main/hive.ts b/src/main/hive.ts
index 4e95d137..77e93b98 100644
--- a/src/main/hive.ts
+++ b/src/main/hive.ts
@@ -1870,10 +1870,43 @@ export class HiveManager {
return { ok: res.status === 0, out: res.stdout ?? '', err: res.stderr ?? '' };
}
+ /** Has the one-time Codex-home untrack pass run in this process yet? */
+ private untrackedCodexHomes = false;
+
+ /**
+ * Stop versioning Codex worker homes that are ALREADY in the index.
+ *
+ * Adding `.codex/` to each agent's .gitignore only keeps NEW paths out; git
+ * happily keeps recording a file it is already tracking, so a hive that
+ * predates that ignore line goes on committing every SQLite and transcript
+ * revision exactly as before — the .gitignore reads as a fix while the repo
+ * keeps growing. This closes that: once per process, refresh every agent's
+ * ignore file (agents that are not running never pass through spawn, and the
+ * mine loop only reaches them if mempalace is installed) and drop any tracked
+ * `.codex` path from the index. The files stay on disk, so `codex --resume`
+ * is unaffected; only their history stops.
+ */
+ private untrackCodexHomes(root: string): void {
+ if (this.untrackedCodexHomes) return;
+ this.untrackedCodexHomes = true;
+ const agentsDir = join(root, 'agents');
+ if (!existsSync(agentsDir)) return;
+ try {
+ for (const id of readdirSync(agentsDir)) ensureMineIgnore(join(agentsDir, id));
+ } catch { /* best-effort */ }
+ // Probe before mutating: `rm --cached` on a clean repo would still rewrite
+ // the index on every launch, and this runs inside the commit retry path.
+ const tracked = this.git(['ls-files', '--', 'agents/*/.codex'], root);
+ if (!tracked.ok || !tracked.out.trim()) return;
+ this.git(['rm', '-r', '--cached', '-q', '--ignore-unmatch', '--', 'agents/*/.codex'], root);
+ console.warn('[hive] untracked previously-committed Codex homes from the hive repo');
+ }
+
/** Commit all hive changes. No-op if there is nothing staged. */
commit(message: string): void {
const root = this.root();
if (!root || !existsSync(join(root, '.git'))) return;
+ this.untrackCodexHomes(root);
for (let attempt = 0; attempt < 5; attempt++) {
this.clearStaleLock(root);
const add = this.git(['add', '-A'], root);