// ROBOTS ON PAYROLL / THE VAULT
// What this is: a Zed settings.json (JSONC, comments allowed) that turns Zed into an AI agent cockpit: profiles, models, and agent defaults.
// How to use it: download this file and give it to your AI (Claude, ChatGPT,
// Cursor, Lovable chat) as a reference. Say: "Use this as my playbook for
// configuring Zed as my agent cockpit."
// Latest version + full guide: https://robotsonpayroll.com/resources/zed-agent-cockpit
//
// Zed AI cockpit config, verified against Zed ~1.4.x (July 2026).
// Zed's settings.json accepts comments (JSONC). Paste into:
//   macOS/Linux: ~/.config/zed/settings.json   (or cmd-, in Zed)
// Replace every KEY_HERE / placeholder before use. Never commit real keys.
{
  // ------------------------------------------------------------------
  // 1. AGENT DEFAULTS
  // ------------------------------------------------------------------
  "agent": {
    // Which profile new threads start in. "write" (built-in) can edit
    // files and run terminal commands. Custom profiles defined below.
    "default_profile": "write",

    // Cheap-model routing for the boring jobs. Don't burn Opus tokens
    // on commit messages and thread titles.
    "inline_assistant_model": {
      "provider": "anthropic",
      "model": "claude-sonnet-4-5"
    },
    "commit_message_model": {
      "provider": "anthropic",
      "model": "claude-haiku-4-5"
    },
    "commit_message_instructions": "Conventional commits. Subject <= 72 chars, imperative mood. Body only when the diff is non-obvious.",
    "thread_summary_model": {
      "provider": "anthropic",
      "model": "claude-haiku-4-5"
    },
    // Model used for native subagents spawned by the main thread.
    "subagent_model": {
      "provider": "anthropic",
      "model": "claude-sonnet-4-5"
    },

    // Auto-compaction: summarizes the thread when context hits the
    // threshold so long sessions don't die. Manual trigger: /compact
    "auto_compact": {
      "enabled": true,
      "threshold": "90%"
    },

    // Per-model sampling overrides. Applied when provider+model match.
    "model_parameters": [
      {
        "provider": "anthropic",
        "model": "claude-opus-4-7",
        "temperature": 0.2
      },
      {
        // No provider/model = applies to everything as a fallback.
        "temperature": 0.4
      }
    ],

    // Ping me when the agent is blocked on a permission prompt or done.
    // Cures the "agent sat waiting for 20 minutes" problem.
    "notify_when_agent_waiting": "all_screens",
    "play_sound_when_agent_done": true,

    // --------------------------------------------------------------
    // TOOL PERMISSIONS
    // Default "confirm" = agent asks before every tool use.
    // Then allowlist the safe stuff and hard-deny the dangerous stuff.
    // Per-MCP granularity uses the "mcp:<server>:<tool>" key format.
    // --------------------------------------------------------------
    "tool_permissions": {
      "default": "confirm",
      "read_file": "allow",
      "grep": "allow",
      "find_path": "allow",
      "list_directory": "allow",
      "diagnostics": "allow",
      "edit_file": "allow",
      "terminal": "confirm",
      "fetch": "confirm",
      "delete_path": "deny",

      // MCP examples: reads auto-approved, writes always confirmed.
      "mcp:github:get_pull_request": "allow",
      "mcp:github:list_issues": "allow",
      "mcp:github:create_pull_request": "confirm",
      "mcp:github:merge_pull_request": "deny",
      "mcp:postgres:query": "allow",
      "mcp:postgres:execute": "deny"
    },

    // --------------------------------------------------------------
    // AGENT PROFILES (Write / Ask / Review)
    // Built-ins: write, ask, minimal. These override/extend them.
    // Switch via the profile picker in the Agent Panel.
    // --------------------------------------------------------------
    "profiles": {
      "write": {
        "name": "Write",
        "tools": {
          "read_file": true,
          "grep": true,
          "find_path": true,
          "list_directory": true,
          "diagnostics": true,
          "edit_file": true,
          "terminal": true,
          "fetch": true,
          "copy_path": true,
          "create_directory": true,
          "delete_path": false
        },
        "enable_all_context_servers": true,
        "default_model": {
          "provider": "anthropic",
          "model": "claude-opus-4-7"
        }
      },
      "ask": {
        "name": "Ask",
        "tools": {
          "read_file": true,
          "grep": true,
          "find_path": true,
          "list_directory": true,
          "diagnostics": true,
          "fetch": true,
          "edit_file": false,
          "terminal": false,
          "delete_path": false
        },
        "enable_all_context_servers": false,
        "context_servers": {},
        "default_model": {
          "provider": "anthropic",
          "model": "claude-sonnet-4-5"
        }
      },
      "review": {
        "name": "Review",
        "tools": {
          "read_file": true,
          "grep": true,
          "find_path": true,
          "list_directory": true,
          "diagnostics": true,
          "edit_file": false,
          "terminal": false,
          "fetch": false,
          "delete_path": false
        },
        "enable_all_context_servers": false,
        "context_servers": {
          "github": true
        },
        "default_model": {
          "provider": "anthropic",
          "model": "claude-opus-4-7"
        }
      }
    }
  },

  // ------------------------------------------------------------------
  // 2. BYO MODEL PROVIDERS
  // Set keys via each provider's settings UI or env vars, NOT here.
  // BYO usage is unlimited and free of Zed fees, even on the Free plan.
  // ------------------------------------------------------------------
  "language_models": {
    "anthropic": {
      // Key lives in ANTHROPIC_API_KEY or the credentials UI.
      "api_url": "https://api.anthropic.com"
    },
    "openai": {
      "api_url": "https://api.openai.com/v1"
    },
    "ollama": {
      "api_url": "http://localhost:11434"
    }
  },

  // ------------------------------------------------------------------
  // 3. EDIT PREDICTIONS (Zeta 2)
  // Zeta 2: open-weights, ~30% better acceptance than Zeta 1.
  // Providers are pluggable since Feb 2026:
  //   zeta | mercury | sweep | codestral | ollama | copilot
  // Free plan: 2,000 accepted predictions/mo on hosted Zeta.
  // ------------------------------------------------------------------
  "edit_predictions": {
    "provider": "zeta",
    "mode": "eager",
    // Keep predictions out of secrets and prose.
    "disabled_globs": [
      "**/.env*",
      "**/secrets/**",
      "**/*.pem",
      "**/*.md"
    ]

    // Local, unlimited, off-cloud alternative (swap provider to "ollama"):
    // "provider": "ollama",
    // "ollama": {
    //   "api_url": "http://localhost:11434",
    //   "model": "zeta2",
    //   "prompt_format": "infer",
    //   "max_output_tokens": 512
    // }
  },

  // ------------------------------------------------------------------
  // 4. MCP SERVERS (context_servers)
  // Local (command) or remote (url + headers / OAuth).
  // Pair every server with tool_permissions entries above.
  // ------------------------------------------------------------------
  "context_servers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "KEY_HERE"
      }
    },
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://readonly_user:KEY_HERE@localhost:5432/yourdb"
      ]
    }
  },

  // ------------------------------------------------------------------
  // 5. EXTERNAL AGENTS via ACP (agent_servers)
  // Claude Code, Codex CLI etc. install from the ACP Registry
  // ("zed: acp registry" in the command palette). This block is only
  // for CUSTOM agents not in the registry.
  // ------------------------------------------------------------------
  "agent_servers": {
    // "my-agent": {
    //   "type": "custom",
    //   "command": "node",
    //   "args": ["/Users/you/agent/index.js", "--acp"],
    //   "env": {}
    // }
  }
}
