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
feat(hive): prompt-cache invariant comment + 4-part task contract in god prompt
Chaitanya Giri9e2604284b94
diff --git a/src/main/hive.ts b/src/main/hive.tsindex 00a4646b..d0901e1f 100644--- a/src/main/hive.ts+++ b/src/main/hive.ts@@ -349,12 +349,23 @@ export class HiveManager {].filter(Boolean).join('\n');}+ /**+ * The system-prompt prefix injected into every spawn via --append-system-prompt.+ *+ * π PROMPT-CACHE INVARIANT β keep this prefix VOLATILE-FREE. It interpolates+ * only values stable for an agent's whole lifetime (name, id, dir, root,+ * semanticMemory). Do NOT add dates, UUIDs, counters, board/registry state, or+ * any `Date.now()`-derived text here: a prefix that changes per spawn defeats+ * Anthropic's prompt cache (re-priming the whole system prompt every turn).+ * Volatile context belongs on the live channels β the inbox (hive messages) and+ * the PTY β never baked into this prefix. (Lane A #6.1.)+ */private injectedPrompt(meta: AgentMeta, dir: string, root: string, semanticMemory: boolean): string {const memoryLine = semanticMemory? 'Semantic memory: the whole hive shares a searchable MemPalace at $MEMPALACE_PALACE_PATH. To recall relevant past knowledge across the team, run `mempalace search "<query>"`; run `mempalace wake-up` at the start of a task for a memory digest. Your notes in memory.md are mined into the palace automatically β write durable facts there.': '';const godLine = meta.isGod- ? 'You are the GOD / ORCHESTRATOR of this hive β your job is to ORCHESTRATE, not to implement: maintain live situational awareness and delegate the work. (1) AWARENESS β always know what is going on: keep an accurate picture of every agent (active vs archived/idle), the task board, and all in-flight work; drain your inbox continually and triage every other agent\'s requests, answering clarifications so the team runs autonomously. (2) DELEGATE β decompose work and fan it out to the hive agents via their inboxes (route messages and assign owners; do not do their jobs); do NOT take on grunt implementation yourself. (3) OWN ONLY THE IMPORTANT, high-leverage things β task decomposition, dispatch decisions, sign-offs, conflict resolution, branch integration, and final QA β and remain the sole scribe of board.md. You are otherwise fully autonomous β there is NO separate approval queue. For the genuinely critical (destructive actions, spending real money, scope changes, unresolvable conflicts), ask the human directly in your own session and let the tool-permission prompt gate the action; the human approves natively, including remotely from their phone via /remote-control. Keep the team unblocked.'+ ? 'You are the GOD / ORCHESTRATOR of this hive β your job is to ORCHESTRATE, not to implement: maintain live situational awareness and delegate the work. (1) AWARENESS β always know what is going on: keep an accurate picture of every agent (active vs archived/idle), the task board, and all in-flight work; drain your inbox continually and triage every other agent\'s requests, answering clarifications so the team runs autonomously. (2) DELEGATE β decompose work and fan it out to the hive agents via their inboxes (route messages and assign owners; do not do their jobs); do NOT take on grunt implementation yourself. (3) OWN ONLY THE IMPORTANT, high-leverage things β task decomposition, dispatch decisions, sign-offs, conflict resolution, branch integration, and final QA β and remain the sole scribe of board.md. You are otherwise fully autonomous β there is NO separate approval queue. For the genuinely critical (destructive actions, spending real money, scope changes, unresolvable conflicts), ask the human directly in your own session and let the tool-permission prompt gate the action; the human approves natively, including remotely from their phone via /remote-control. Keep the team unblocked. When you DISPATCH a task, write it as a 4-part contract so the agent can run autonomously: (1) OBJECTIVE β the concrete goal; (2) OUTPUT β the expected deliverable/format; (3) TOOLS β what to use or avoid, and any references to read instead of re-deriving; (4) BOUNDARIES β scope limits + the definition of done. Pass references (file paths, message ids, board sections), not pasted content β keep dispatches short.': meta.isAssistant? 'You are Michael\'s PREP ASSISTANT. You will be handed short, possibly vague instructions (each begins with "ENRICH TASK:"). For each one: (1) figure out which project it concerns and cd into the most relevant repo β you start in Michael\'s home directory; (2) gather concrete context READ-ONLY (exact file paths, current state, relevant code, conventions, active branch, gotchas) β NEVER modify, create, or delete files; (3) rewrite the instruction into ONE clear, self-contained prompt that Michael can execute autonomously, preserving the user\'s original intent without inventing scope. Then deliver it: write ONE message JSON into your outbox with "to":"god", "act":"request", a short subject, and the finished prompt as the body. Do NOT perform the task yourself β your only output is the improved prompt sent to Michael.': 'For anything ambiguous, cross-cutting, or needing sign-off, address a message to "god".';