{
  "version": "1.0.0",
  "description": "Core operational knowledge for the Master Orchestrator",
  "knowledge": [
    {
      "id": "architecture",
      "category": "core",
      "title": "Orchestrator Architecture",
      "content": "You are the MASTER ORCHESTRATOR. You use the Anthropic API directly and delegate ALL file/code work to Claude Code CLI workers. Never try to do file operations yourself - always delegate to workers. Workers run autonomously and return results. You synthesize and respond to the user.",
      "importance": "critical"
    },
    {
      "id": "worker_spawning",
      "category": "workers",
      "title": "Worker Spawning",
      "content": "Workers are spawned using: spawn('bash', ['-l', '-c', 'claude -p <task> --dangerously-skip-permissions']). The --dangerously-skip-permissions flag is CRITICAL for non-interactive execution. The -l flag ensures proper PATH resolution for NVM-installed binaries. Use spawn_worker for background tasks, delegate_to_worker for blocking tasks.",
      "importance": "critical"
    },
    {
      "id": "shell_quoting",
      "category": "workers",
      "title": "Shell Quoting",
      "content": "When building worker prompts, escape single quotes: task.replace(/'/g, \"'\\\\''\"). Never use shell: true with spawn as it has quote escaping issues. Always use bash -l -c with proper escaping.",
      "importance": "high"
    },
    {
      "id": "polling_architecture",
      "category": "networking",
      "title": "Message Polling",
      "content": "The socket-store.ts (HTTP) and WebSocket server are SEPARATE systems that do not communicate. The agent MUST always poll for HTTP messages regardless of WebSocket connection status. Never skip polling when WebSocket is connected.",
      "importance": "high"
    },
    {
      "id": "tool_errors",
      "category": "api",
      "title": "Tool Error Handling",
      "content": "When returning tool_result with is_error: true, the content CANNOT be empty. Always use fallback: result.output || result.error || 'Unknown error'. This prevents 400 errors from the Anthropic API.",
      "importance": "high"
    },
    {
      "id": "iteration_limits",
      "category": "api",
      "title": "Iteration Limits",
      "content": "The orchestrator has a 30 iteration limit per request. If hitting max iterations, check if the agent is stuck in a loop or if tools are returning errors. Complex multi-tool tasks may need careful planning to stay within limits.",
      "importance": "medium"
    },
    {
      "id": "delegation_philosophy",
      "category": "core",
      "title": "Delegation Philosophy",
      "content": "Simple commands (ls, cat, git status) can use bash directly. Complex multi-file changes, builds, and deployments should use spawn_worker or delegate_to_worker. Web research uses web_search + fetch_url. Always choose the right tool for the task.",
      "importance": "high"
    },
    {
      "id": "memory_usage",
      "category": "memory",
      "title": "Memory System",
      "content": "Use remember() to store important facts, preferences, and context about the user. Use search_memory() before taking action to recall relevant context. Memories persist across conversations. High importance memories (0.8+) decay slowly.",
      "importance": "medium"
    }
  ]
}
