{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tokrepo.com/schemas/agent-memory.schema.json",
  "title": "TokRepo Project Agent Memory",
  "description": "Machine-readable project memory written by tokrepo init-agent --target all so future agents know to use tokrepo_discover, tokrepo_verify, tokrepo_install_plan, and tokrepo_handoff_plan before rebuilding reusable work.",
  "type": "object",
  "required": ["schema_version", "tokrepo"],
  "properties": {
    "schema_version": { "type": "integer", "const": 1 },
    "schema": { "type": "string", "format": "uri" },
    "name": { "type": "string" },
    "updated_at": { "type": "string" },
    "tokrepo": {
      "type": "object",
      "required": ["enabled", "planning_tool", "trust_tool", "install_plan_tool", "handoff_plan_tool", "cli_fallbacks", "policy"],
      "properties": {
        "enabled": { "type": "boolean" },
        "initialized_by": { "type": "string" },
        "target": { "type": "string" },
        "machine_manifest": { "type": "string", "format": "uri" },
        "trust_manifest": { "type": "string", "format": "uri" },
        "tool_catalog": { "type": "string", "format": "uri" },
        "hosted_mcp": { "type": "string", "format": "uri" },
        "local_mcp_server": { "type": ["string", "null"] },
        "planning_tool": { "type": "string", "const": "tokrepo_discover" },
        "detail_tool": { "type": "string", "const": "tokrepo_detail" },
        "trust_tool": { "type": "string", "const": "tokrepo_verify" },
        "install_plan_tool": { "type": "string", "const": "tokrepo_install_plan" },
        "handoff_plan_tool": { "type": "string", "const": "tokrepo_handoff_plan" },
        "lifecycle_tools": {
          "type": "array",
          "items": { "type": "string" }
        },
        "cli_fallbacks": {
          "type": "object",
          "required": ["planning", "verify", "install_dry_run", "handoff"],
          "additionalProperties": { "type": "string" }
        },
        "project_surfaces": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["target", "file", "purpose"],
            "properties": {
              "target": { "type": "string" },
              "file": { "type": "string" },
              "purpose": { "type": "string" }
            }
          }
        },
        "mcp_config": { "type": ["string", "null"] },
        "policy": {
          "type": "object",
          "required": ["discover_before_build", "verify_before_activation", "dry_run_before_write", "human_confirmation_before_push"],
          "properties": {
            "discover_before_build": { "type": "boolean" },
            "verify_before_activation": { "type": "boolean" },
            "dry_run_before_write": { "type": "boolean" },
            "human_confirmation_before_push": { "type": "boolean" },
            "private_by_default": { "type": "boolean" }
          }
        }
      }
    }
  }
}
