# kap.toml — network and tool policy for this devcontainer

# Forward host SSH agent into the container (for git over SSH, commit signing, etc.)
# On macOS, uses Docker Desktop's built-in SSH forwarding.
# On Linux, bind-mounts $SSH_AUTH_SOCK directly.
ssh_agent = true

[proxy.network]
# Domains the container can reach. Wildcards supported (*.example.com).
# Everything else is blocked — both HTTP/HTTPS and DNS.
allow = [
  # GitHub
  "github.com",
  "*.github.com",
  "*.githubusercontent.com",

  # AI providers
  "anthropic.com",
  "*.anthropic.com",
  "claude.ai",
  "*.claude.ai",
  "claude.com",
  "*.claude.com",
  "openai.com",
  "*.openai.com",
  "generativelanguage.googleapis.com",
  "storage.googleapis.com",

  # APT
  "*.ubuntu.com",
  "*.debian.org",

  # Dev tools
  "mise.jdx.dev",

  # Ruby
  "rubygems.org",
  "*.rubygems.org",
  "bundler.io",
  "*.ruby-lang.org",
  "rubyonrails.org",
  "*.rubyonrails.org",

  # Node
  "*.npmjs.org",
  "*.npmjs.com",
  "nodejs.org",
  "*.yarnpkg.com",

  # Rust
  "crates.io",
  "*.crates.io",
  "rustup.rs",
  "*.rustup.rs",
  "*.rust-lang.org",

  # Python
  "pypi.org",
  "*.pypi.org",
  "*.pythonhosted.org",

  # Go
  "proxy.golang.org",
  "sum.golang.org",

  # Java
  "repo.maven.apache.org",
  "*.maven.org",
  "plugins.gradle.org",
  "services.gradle.org",
  "downloads.gradle-dn.com",

  # CocoaPods
  "cocoapods.org",
  "*.cocoapods.org"
]
# deny overrides allow:
# deny = ["gist.github.com"]
# Global defaults from ~/.kap/kap.toml are merged automatically.

# --- MCP servers (tool-level filtering for remote MCP) ---
# Register with `kap mcp add <url>`, then restrict tools:
# [mcp]
# [[mcp.servers]]
# name = "github"
# allow = ["get_pull_request", "list_issues"]

# --- CLI tool proxying (credentials stay on sidecar, never enter app container) ---
[cli]
[[cli.tools]]
name = "gh"
env = ["GH_TOKEN"]
allow = ["*"]
deny = ["auth token", "auth login", "auth logout", "auth refresh"]

# Build sidecar from source (dogfooding — uses local code instead of published image)
[compose]
build = { context = "..", dockerfile = ".devcontainer/Dockerfile", target = "proxy" }
