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

feat(hive): full-text search across hive files

Chaitanya Giri1a94dafb0fc5
diff --git a/src/main/index.ts b/src/main/index.ts
index b8771c77..afa462db 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -1,6 +1,6 @@
import { app, BrowserWindow, clipboard, dialog, ipcMain, shell } from 'electron';
import { spawn } from 'node:child_process';
-import { rmSync } from 'node:fs';
+import { rmSync, existsSync, readFileSync, readdirSync } from 'node:fs';
import { join } from 'node:path';
import { PtyManager, type SpawnOptions } from './pty';
import {
@@ -302,6 +302,40 @@ ipcMain.handle('app:resetAll', () => {
app.exit(0);
});
+// ─── IPC: full-text search across hive files (board, tasks, memory) ──────────
+ipcMain.handle('hive:textSearch', (_evt, query: unknown) => {
+ if (typeof query !== 'string' || !query.trim()) return { ok: false, results: [] };
+ const root = hive.root();
+ if (!root) return { ok: false, results: [] };
+ const q = query.toLowerCase();
+ const results: Array<{ source: string; excerpt: string }> = [];
+ // Each target file is (path, readable label). agents/<id>/memory.md is expanded below.
+ const targets: Array<{ path: string; source: string }> = [
+ { path: join(root, 'board.md'), source: 'board.md' },
+ { path: join(root, 'tasks.json'), source: 'tasks.json' }
+ ];
+ const agentsDir = join(root, 'agents');
+ if (existsSync(agentsDir)) {
+ for (const id of readdirSync(agentsDir)) {
+ targets.push({ path: join(agentsDir, id, 'memory.md'), source: `${id}/memory.md` });
+ }
+ }
+ for (const { path, source } of targets) {
+ if (!existsSync(path)) continue;
+ let hits = 0;
+ for (const line of readFileSync(path, 'utf8').split('\n')) {
+ if (hits >= 3) break;
+ const idx = line.toLowerCase().indexOf(q);
+ if (idx === -1) continue;
+ // ~40 chars of context on either side of the match.
+ const excerpt = line.slice(Math.max(0, idx - 40), idx + q.length + 40).trim();
+ results.push({ source, excerpt });
+ hits++;
+ }
+ }
+ return { ok: true, results };
+});
+
app.whenReady().then(() => {
// Bootstrap the hive (if harnessHome is configured) and start the message router.
if (hive.enabled()) {
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 42e5960a..6662b23c 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -219,7 +219,11 @@ const api = {
// ─── Reset ─────────────────────────────────────────────────────────────────
/** Wipe all hive data + the memory palace, reset config, and relaunch the app
* into onboarding. The process exits, so this promise never resolves. */
- resetAll: (): Promise<void> => ipcRenderer.invoke('app:resetAll')
+ resetAll: (): Promise<void> => ipcRenderer.invoke('app:resetAll'),
+
+ // ─── Full-text search across hive files (board, tasks, memory) ─────────────
+ textSearch: (q: string): Promise<{ ok: boolean; results: Array<{ source: string; excerpt: string }> }> =>
+ ipcRenderer.invoke('hive:textSearch', q)
};
contextBridge.exposeInMainWorld('cth', api);
diff --git a/src/renderer/src/components/CommandCenterPanel.tsx b/src/renderer/src/components/CommandCenterPanel.tsx
index a71ff27a..adb220dd 100644
--- a/src/renderer/src/components/CommandCenterPanel.tsx
+++ b/src/renderer/src/components/CommandCenterPanel.tsx
@@ -289,6 +289,11 @@ function MemoryTab({ godId }: { godId: string }) {
const [query, setQuery] = useState('');
const [searchOut, setSearchOut] = useState('');
const [busy, setBusy] = useState(false);
+ // Full-text search across hive files (board, tasks, memory) — additive.
+ const [textQuery, setTextQuery] = useState('');
+ const [textResults, setTextResults] = useState<Array<{ source: string; excerpt: string }>>([]);
+ const [textSearched, setTextSearched] = useState(false);
+ const [textBusy, setTextBusy] = useState(false);
useEffect(() => {
window.cth.hiveMemory(who).then(setMem).catch(() => setMem(''));
@@ -303,8 +308,44 @@ function MemoryTab({ godId }: { godId: string }) {
} finally { setBusy(false); }
};
+ const textSearch = async () => {
+ if (!textQuery.trim()) return;
+ setTextBusy(true);
+ try {
+ const res = await window.cth.textSearch(textQuery.trim());
+ setTextResults(res.ok ? res.results.slice(0, 10) : []);
+ } catch { setTextResults([]); }
+ finally { setTextBusy(false); setTextSearched(true); }
+ };
+
return (
<Scroll>
+ <Section title="TEXT SEARCH (board, tasks, memory)">
+ <div style={{ display: 'flex', gap: 6 }}>
+ <input
+ value={textQuery}
+ onChange={(e) => setTextQuery(e.target.value)}
+ onKeyDown={(e) => { if (e.key === 'Enter') textSearch(); }}
+ placeholder="Find exact text across hive files…"
+ style={{ ...textareaStyle, height: 30 }}
+ />
+ <PixelButton variant="primary" size="sm" onClick={textSearch} disabled={textBusy || !textQuery.trim()}>
+ {textBusy ? '…' : 'search'}
+ </PixelButton>
+ </div>
+ {textResults.length > 0 && (
+ <div style={{ marginTop: 6 }}>
+ {textResults.map((r, i) => (
+ <div key={i} style={{ marginBottom: 4 }}>
+ <div style={{ fontFamily: 'var(--cth-font-mono)', fontSize: 11, color: 'var(--cth-ink-500)' }}>{r.source}</div>
+ <Pre>{r.excerpt}</Pre>
+ </div>
+ ))}
+ </div>
+ )}
+ {textSearched && textResults.length === 0 && <Muted>Nothing matched.</Muted>}
+ </Section>
+
<Section title="SEMANTIC SEARCH (MemPalace)">
<div style={{ display: 'flex', gap: 6 }}>
<input