{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": ["schema_version", "generated_at", "repo_root", "items", "configured_dependencies", "schema_capabilities"],
  "properties": {
    "schema_version": { "const": "tool-facts.v2" },
    "generated_at": { "type": "string" },
    "repo_root": { "type": "string" },
    "host": { "type": ["string", "null"] },
    "platform": { "type": ["string", "null"] },
    "profile": { "enum": ["minimal", "recommended", "platform"] },
    "tools": { "type": "object", "additionalProperties": true },
    "helper_tools": { "type": "object", "additionalProperties": true },
    "provider_readiness": {
      "type": "array",
      "items": { "type": "object", "additionalProperties": true }
    },
    "items": {
      "type": "array",
      "items": { "$ref": "#/$defs/item" }
    },
    "configured_dependencies": {
      "type": "array",
      "items": { "$ref": "#/$defs/configuredDependency" }
    },
    "schema_capabilities": {
      "type": "array",
      "items": { "type": "string" }
    },
    "target": { "type": ["object", "null"], "additionalProperties": true },
    "source": { "type": "object", "additionalProperties": true }
  },
  "additionalProperties": true,
  "$defs": {
    "item": {
      "type": "object",
      "required": [
        "id",
        "kind",
        "profile",
        "required",
        "baseline_blocking",
        "dependency_status",
        "configured_status",
        "result",
        "reason_code",
        "installed",
        "missing_dependency_reason"
      ],
      "properties": {
        "id": { "type": "string" },
        "kind": { "type": "string" },
        "profile": { "enum": ["minimal", "recommended", "platform"] },
        "required": { "type": "boolean" },
        "baseline_blocking": { "type": "boolean" },
        "dependency_status": { "type": "string" },
        "configured_status": { "type": "string" },
        "result": { "type": "string" },
        "reason_code": { "type": "string" },
        "installed": { "type": "boolean" },
        "missing_dependency_reason": { "type": ["string", "null"] },
        "next_action": { "type": "string" }
      },
      "additionalProperties": true
    },
    "configuredDependency": {
      "type": "object",
      "required": [
        "id",
        "kind",
        "source_path",
        "command",
        "args_shape",
        "declared_tool_id",
        "declared_status",
        "dependency_status",
        "configured_status",
        "result",
        "reason_code"
      ],
      "properties": {
        "id": { "type": "string" },
        "kind": { "type": "string" },
        "source_path": { "type": "string" },
        "command": { "type": "string" },
        "args_shape": { "type": "string" },
        "declared_tool_id": { "type": ["string", "null"] },
        "declared_status": { "type": "string" },
        "dependency_status": { "type": "string" },
        "configured_status": { "type": "string" },
        "result": { "type": "string" },
        "reason_code": { "type": "string" }
      },
      "additionalProperties": true
    }
  }
}
