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

Merge branch 'feature/hive-text-search' into integration/roadmap

Chaitanya Girib71887a4c8ca
diff --cc src/main/index.ts
index 1e3d6f00,afa462db..c5068d96
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@@ -381,18 -302,40 +381,52 @@@ ipcMain.handle('app:resetAll', () =>
app.exit(0);
});
+// ─── IPC: token telemetry (real usage + est. cost from CC transcripts) ───────
+ipcMain.handle('hive:agentUsage', (_evt, cwd: unknown) =>
+ typeof cwd === 'string' ? readAgentUsage(cwd) : null);
+
+// ─── IPC: scheduled missions (recurring auto-dispatch) ──────────────────────
+ipcMain.handle('missions:list', () => readConfig().missions ?? []);
+ipcMain.handle('missions:save', (_evt, missions) => {
+ writeConfig({ missions: missions as ScheduledMission[] });
+ syncMissions();
+ return { ok: true };
+});
+
+ // ─── 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 --cc src/preload/index.ts
index f7dcc5a4,6662b23c..f74e8545
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@@ -257,21 -221,9 +257,25 @@@ const api =
* into onboarding. The process exits, so this promise never resolves. */
resetAll: (): Promise<void> => ipcRenderer.invoke('app:resetAll'),
+ // ─── Token telemetry (real usage + est. cost from CC transcripts) ──────────
+ /** Sum input/output/cache tokens + estimated USD cost for an agent from its
+ * Claude Code transcripts. Returns null for an invalid cwd. */
+ agentUsage: (cwd: string): Promise<AgentUsage | null> =>
+ ipcRenderer.invoke('hive:agentUsage', cwd),
+
+ // ─── Task kanban (hive/tasks.json) ───────────────────────────────────────
+ /** Overwrite the hive task ledger with the full task list and commit it. */
+ hiveWriteTasks: (tasks: HiveTask[]): Promise<{ ok: boolean; error?: string }> =>
+ ipcRenderer.invoke('hive:writeTasks', tasks),
+
+ // ─── Scheduled missions (recurring auto-dispatch) ──────────────────────────
+ listMissions: (): Promise<ScheduledMission[]> => ipcRenderer.invoke('missions:list'),
+ saveMissions: (missions: ScheduledMission[]): Promise<{ ok: boolean }> =>
- ipcRenderer.invoke('missions:save', missions)
++ ipcRenderer.invoke('missions:save', missions),
++
+ // ─── 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);