{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tokrepo.com/schemas/tokrepo-project-state.schema.json",
  "title": "TokRepo Project Installed State",
  "description": "Machine-readable current-state snapshot generated from TokRepo.lock by tokrepo installed --project --json.",
  "type": "object",
  "required": ["schemaVersion", "generatedAt", "lockfile", "count", "summary", "assets"],
  "properties": {
    "schemaVersion": { "type": "integer", "const": 1 },
    "schema_version": { "type": "integer", "const": 1 },
    "generatedAt": { "type": "string" },
    "generated_at": { "type": "string" },
    "projectRoot": { "type": "string" },
    "lockfile": { "type": "string", "const": "TokRepo.lock" },
    "lockfilePath": { "type": "string" },
    "statePath": { "type": "string" },
    "count": { "type": "integer" },
    "summary": {
      "type": "object",
      "required": ["installed", "staged", "local_changes", "missing_files"],
      "properties": {
        "installed": { "type": "integer" },
        "staged": { "type": "integer" },
        "local_changes": { "type": "integer" },
        "missing_files": { "type": "integer" }
      }
    },
    "assets": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["uuid", "targetTool", "status", "files"],
        "properties": {
          "uuid": { "type": "string" },
          "title": { "type": "string" },
          "sourceUrl": { "type": "string" },
          "targetTool": { "type": "string" },
          "installMode": { "type": "string" },
          "installedAt": { "type": "string" },
          "contentHash": { "type": "string" },
          "installPlanHash": { "type": "string" },
          "sessionId": { "type": "string" },
          "status": { "enum": ["installed", "staged", "local-changes", "missing-files"] },
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["path", "resolvedPath", "exists", "changed"],
              "properties": {
                "path": { "type": "string" },
                "path_type": { "type": "string" },
                "resolvedPath": { "type": "string" },
                "sourceName": { "type": "string" },
                "sha256": { "type": "string" },
                "actualSha": { "type": "string" },
                "exists": { "type": "boolean" },
                "changed": { "type": "boolean" }
              }
            }
          },
          "rollback": {
            "type": "array",
            "items": { "type": "object" }
          }
        }
      }
    }
  }
}
