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
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
Merge branch 'pr-149' into integration/v0.4.5
Chaitanya Giri7c53216ad3ed
diff --cc src/main/hive.tsindex bca1fcb8,4890c9bb..9e15ceac--- a/src/main/hive.ts+++ b/src/main/hive.ts@@@ -37,8 -36,7 +37,9 @@@ importtype AgentProvider} from '../shared/agentProvider';import { MCP_CATALOG } from '../shared/mcpCatalog';+import { selectBroadcastTargets } from '../shared/broadcast';+import { preferredAgentRole } from '../shared/agentRole';+ import { mergeTaskLedger } from '../shared/taskLedger';import { expandTilde } from './fs';/** The subset of HarnessConfig the hive consumes for the default-MCP merge.@@@ -1401,44 -1332,13 +1413,47 @@@ export class HiveManagerconst root = this.root();if (!root) return;this.ensureHive();- this.writeJson(join(root, 'tasks.json'), { tasks });- this.appendLog({ kind: 'tasks', count: tasks.length });- this.commit(`hive: tasks (${tasks.length})`);+ const path = join(root, 'tasks.json');+ const current = this.readJson<{ tasks?: unknown }>(path, { tasks: [] });+ const merged = mergeTaskLedger(current?.tasks, tasks);+ this.writeJson(path, { tasks: merged });+ this.appendLog({ kind: 'tasks', count: merged.length });+ this.commit(`hive: tasks (${merged.length})`);}++ /** Append one card against the latest on-disk ledger. Renderer callers must+ * use this instead of re-writing a collection they read before another+ * source (webhook, Slack, god, voice) added work. Idempotent by task id. */+ addTask(task: HiveTask): boolean {+ const ledger = this.tasks() as { tasks?: HiveTask[] };+ const tasks = Array.isArray(ledger?.tasks) ? ledger.tasks : [];+ if (tasks.some((current) => current?.id === task.id)) return false;+ this.writeTasks([...tasks, task]);+ return true;+ }++ /** Patch one card against the latest on-disk ledger, preserving unrelated+ * cards and fields (notably webhook.tokenHash and Slack thread metadata). */+ patchTask(id: string, patch: Partial<Omit<HiveTask, 'id'>>): boolean {+ const ledger = this.tasks() as { tasks?: HiveTask[] };+ const tasks = Array.isArray(ledger?.tasks) ? ledger.tasks : [];+ const index = tasks.findIndex((task) => task?.id === id);+ if (index < 0) return false;+ const next = tasks.slice();+ next[index] = { ...tasks[index], ...patch, id };+ this.writeTasks(next);+ return true;+ }++ /** Delete only the named card from the latest on-disk ledger. */+ deleteTask(id: string): boolean {+ const ledger = this.tasks() as { tasks?: HiveTask[] };+ const tasks = Array.isArray(ledger?.tasks) ? ledger.tasks : [];+ const next = tasks.filter((task) => task?.id !== id);+ if (next.length === tasks.length) return false;+ this.writeTasks(next);+ return true;+ }memory(id: string): string {const p = join(this.agentDir(id), 'memory.md');return existsSync(p) ? readFileSync(p, 'utf8') : '';diff --cc src/main/index.tsindex 78783e03,2a8393f1..2a5a62c5--- a/src/main/index.ts+++ b/src/main/index.ts@@@ -3241,114 -3114,13 +3267,118 @@@ ipcMain.handle('hive:setArchived', (_evhive.setArchived(id, archived === true);return { ok: true };});+ipcMain.handle('hive:patchAgentRole', (_evt, id: unknown, role: unknown) => {+ if (typeof id !== 'string') return { ok: false, error: 'invalid id' };+ if (typeof role !== 'string') return { ok: false, error: 'invalid role' };+ if (!hive.enabled()) return { ok: false, error: 'hive disabled (no harnessHome)' };+ return hive.patchAgentRole(id, role);+});++// ─── IPC: Settings hero payload (remote data, cached) ───────────────────────+/** Plan copy and sponsor, fetched from the repo so they can change without a+ * release. Validated in shared/heroPayload before it reaches the renderer. */+ipcMain.handle('hero:payload', async (_evt, force: unknown) =>+ loadHero(join(app.getPath('userData'), 'hero.json'), { force: force === true }));++// ─── IPC: skills (installed locally, and the browsable catalog) ─────────────+/** Skills the CLIs on this machine can already use. Scans the registered repos+ * plus the agent's own cwd, so a project-scoped skill shows up where it applies. */+ipcMain.handle('skills:local', (_evt, cwd: unknown): LocalSkill[] => {+ const cfg = readConfig();+ const cwds = [+ ...(typeof cwd === 'string' && cwd ? [cwd] : []),+ ...(cfg.registeredRepos ?? [])+ ];+ try {+ return listLocalSkills({ cwds, bundledDir: skillsResourceDir() });+ } catch (e) {+ console.error('[skills] local scan failed:', e);+ return [];+ }+});+/** The skills catalog, parsed from its README and cached in userData.+ * `force` is the explicit refresh button; everything else is served from a+ * day-old cache so opening the tab never waits on the network. */+ipcMain.handle('skills:catalog', async (_evt, force: unknown) => {+ const cachePath = join(app.getPath('userData'), 'skill-catalog.json');+ return loadCatalog(cachePath, { force: force === true });+});++/** Install one catalog skill into ~/.claude/skills. Structured refusals, never a+ * throw: the UI distinguishes "not installable" from "install failed". */+ipcMain.handle('skills:install', async (_evt, url: unknown, name: unknown) => {+ if (typeof url !== 'string' || typeof name !== 'string') {+ return { ok: false as const, error: 'bad request' };+ }+ return installSkill(url, name);+});+/** Delete an installed skill. The guard rails live in uninstallSkill — it refuses+ * any path it cannot prove is a skill folder inside a skills root. */+ipcMain.handle('skills:uninstall', (_evt, path: unknown) => {+ if (typeof path !== 'string') return { ok: false as const, error: 'bad request' };+ const cfg = readConfig();+ return uninstallSkill(path, { cwds: cfg.registeredRepos ?? [] });+});+/** Reveal a skill on disk. `openExternal` is deliberately https-only, so a+ * file:// URL cannot (and should not) be smuggled through it. */+ipcMain.handle('skills:reveal', (_evt, path: unknown) => {+ if (typeof path !== 'string' || !path.trim()) return { ok: false, error: 'bad request' };+ const skillRoots = [join(homedir(), '.claude', 'skills'), join(homedir(), '.config', 'opencode')];+ const target = resolve(path);+ const inRoot = skillRoots.some((r) => target.startsWith(resolve(r) + sep))+ || (readConfig().registeredRepos ?? []).some((c) => target.startsWith(resolve(c) + sep));+ if (!inRoot) return { ok: false, error: 'outside a managed skills directory' };+ shell.showItemInFolder(target);+ return { ok: true };+});++// ─── IPC: setup catalog (which external tools are actually here) ────────────+/**+ * Probe every catalog row against THIS machine.+ *+ * Presence is a PATH resolution, not a spawn: running each candidate to read a+ * --version would be a dozen process launches on every panel open, and several of+ * these CLIs boot a TUI when invoked bare. `resolveCommand` returns its input+ * unchanged when it finds nothing, so "resolved to a real, existing path that is+ * not just the bare name" is the found test.+ *+ * mempalace is the one row that does NOT come from PATH: the memory subsystem+ * already resolves it (including uv/pip locations PATH may not carry for a+ * Finder-launched app) and knows whether the palace is initialised, so it is+ * authoritative and reused rather than re-probed differently here.+ */+ipcMain.handle('tools:status', (): ToolStatus[] => {+ const win = process.platform === 'win32';+ const mem = (() => { try { memory.resetBinCache(); return memory.status(); } catch { return null; } })();+ return toolCatalog().map((spec): ToolStatus => {+ const installCommand = win ? spec.install.win32 : spec.install.posix;+ if (spec.id === 'mempalace') {+ return {+ ...spec,+ installCommand,+ found: !!mem?.available,+ path: mem?.bin ?? null,+ detail: mem?.available+ ? (mem.initialized ? 'palace initialised' : 'installed — palace not built yet')+ : undefined+ };+ }+ if (!spec.bin) return { ...spec, installCommand, found: false, path: null };+ let path: string | null = null;+ try {+ const resolved = resolveCliCommand(spec.bin);+ if (resolved !== spec.bin && existsSync(resolved)) path = resolved;+ } catch { /* a probe must never take the panel down */ }+ return { ...spec, installCommand, found: !!path, path };+ });+});// ─── IPC: semantic memory (MemPalace CLI) ───────────────────────────────────- ipcMain.handle('hive:memoryStatus', () => { memory.resetBinCache(); return memory.status(); });+ // refresh() = resetBinCache + an idempotent start(). The poll is the one thing+ // that reliably notices mempalace being installed after boot, so it is what arms+ // the mine loop that boot's start() had to skip — otherwise the pill reads+ // "getting ready" until the app is restarted.+ ipcMain.handle('hive:memoryStatus', () => memory.refresh());ipcMain.handle('hive:searchMemory', (_evt, query: unknown, wing: unknown) => {if (typeof query !== 'string' || !query.trim()) return { ok: false, output: '', error: 'empty query' };return memory.search(query, { wing: typeof wing === 'string' ? wing : undefined });diff --cc src/renderer/src/components/AskMeTab.tsxindex 2b64304f,e3b737bd..db1dd86f--- a/src/renderer/src/components/AskMeTab.tsx+++ b/src/renderer/src/components/AskMeTab.tsx@@@ -2,7 -2,8 +2,7 @@@ import { useCallback, useEffect, useRefimport { PixelButton } from './PixelButton';import { PixelBadge } from './PixelBadge';import { useStore } from '@/store/store';- import { type HiveTask, openQuestion, waitsOnHuman } from './TasksKanban';+ import { type HiveTask, type HumanQA, openQuestion, waitsOnHuman } from './TasksKanban';-import { patchTaskInLedger } from '../../../shared/taskLedger';/*** ASK ME — first-class human feedback through the task system.@@@ -66,6 -67,34 +66,18 @@@ export function AskMeTab()const waiting = tasks.filter(waitsOnHuman);+ /**+ * Apply `patch` to the OPEN humanQA entry of one card, on the RAW ledger.+ * Returns whether it landed.+ *+ * Re-reads tasks.json first rather than writing this view's 5s-old snapshot,+ * because `hive:writeTasks` treats the incoming array as the card MEMBERSHIP:+ * writing our snapshot back would delete any card the god added since the last+ * poll. Re-locating the open question by its text also means an answer can+ * never land on a different question the god swapped in underneath us — in+ * that case nothing is written and the draft is kept.+ */- const patchOpenQuestion = async (- taskId: string,- question: string,- patch: Partial<HumanQA>- ): Promise<boolean> => {- const raw = (await window.cth.hiveTasks()) as { tasks?: unknown };- const list: unknown[] = Array.isArray(raw?.tasks) ? raw.tasks : [];- const card = list.find(- (t): t is HiveTask => !!t && typeof t === 'object' && (t as HiveTask).id === taskId- );- const open = card ? openQuestion(card) : undefined;- if (!card || !open || open.q !== question) return false;- const humanQA = (card.humanQA ?? []).map((e) => (e === open ? { ...e, ...patch } : e));- await window.cth.hiveWriteTasks(patchTaskInLedger(list, taskId, { humanQA }) as HiveTask[]);- return true;- };+const sendAnswer = async (task: HiveTask) => {const text = (drafts[task.id] ?? '').trim();const open = openQuestion(task);diff --cc src/renderer/src/components/TaskDetailOverlay.tsxindex 0697df8a,2eee1cc6..acf85ca7--- a/src/renderer/src/components/TaskDetailOverlay.tsx+++ b/src/renderer/src/components/TaskDetailOverlay.tsx@@@ -40,12 -41,19 +40,18 @@@ export function TaskDetailOverlay()const nameFor = (id?: string): string | undefined =>id ? (agents.find((a) => a.id === id)?.name ?? restorable.find((a) => a.id === id)?.name ?? id) : undefined;+ // Moving a card writes ONE field. Operate on the RAW ledger (the same pattern+ // as TasksKanban.dismissTask), never on the display-parsed state: parseTasks+ // NORMALIZES, so re-serializing it turns a hand-written `priority: "high"`+ // into the number 3 and grafts `dependsOn: []` onto a card that spells the key+ // `deps`. Those are real values, so they survive the merge in hive.writeTasks+ // and land on disk — a status change quietly rewriting the god's cards.const move = async (status: HiveTask['status']) => {- setTasks((prev) => prev.map((t) => (t.id === task.id ? { ...t, status } : t))); // optimistic+ const next = tasks.map((t) => (t.id === task.id ? { ...t, status } : t));+ setTasks(next); // optimistictry {- const raw = (await window.cth.hiveTasks()) as { tasks?: unknown };- await window.cth.hiveWriteTasks(- patchTaskInLedger(raw?.tasks, task.id, { status }) as HiveTask[]- );+ const result = await window.cth.hivePatchTask(task.id, { status });+ if (!result.ok) void refresh();} catch { void refresh(); }};diff --cc src/renderer/src/hooks/useHive.tsindex 380ee952,ae45fcb5..8182d36c--- a/src/renderer/src/hooks/useHive.ts+++ b/src/renderer/src/hooks/useHive.ts@@@ -16,10 -16,8 +16,10 @@@ import} from '../../../shared/providerAutomation';import { DEFAULT_CONTEXT_TRIGGER, type ContextRule } from '../../../shared/triggers';import type { AgentProvider } from '../../../shared/agentProvider';+import { bridgeOf, providerPreset } from '../../../shared/agentProvider';+import { isDurableRole, preferredAgentRole, roleForHiveSpawn } from '../../../shared/agentRole';import { acquireTerminal, resetTerminal, isTerminalAutomationSafe } from '@/components/terminalPool';- import { deliverWithAcknowledgement } from './queueDelivery';+ import { canDeliverToAgent, deliverWithAcknowledgement } from './queueDelivery';import { OFFICE_CAST, DEFAULT_CHARACTER } from '@/scene/office/cast';const GOD_ID = 'god';