{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tokrepo.com/schemas/harvest-report.schema.json",
  "title": "TokRepo Harvest Report",
  "description": "Machine-readable post-task contract for turning reusable local agent output into private-by-default TokRepo asset package drafts.",
  "type": "object",
  "required": [
    "schema_version",
    "command",
    "status"
  ],
  "properties": {
    "schema_version": { "type": "integer", "const": 1 },
    "schema": { "type": "string", "format": "uri" },
    "hosted_mcp": { "type": "boolean" },
    "command": { "type": "string", "const": "harvest" },
    "status": {
      "type": "string",
      "enum": ["ready", "needs_review", "empty", "requires_local_agent"]
    },
    "scope": {
      "type": "object",
      "properties": {
        "base_dir": { "type": "string" },
        "paths": {
          "type": "array",
          "items": { "type": "string" }
        },
        "changed": { "type": "boolean" },
        "limit": { "type": "number" }
      },
      "additionalProperties": true
    },
    "requested_scope": {
      "type": "object",
      "additionalProperties": true
    },
    "asset_package_drafts": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "title",
          "files",
          "metadata",
          "usage_examples",
          "risk_notes",
          "target_compatibility",
          "handoff_quality_gate",
          "push_plan"
        ],
        "properties": {
          "title": { "type": "string" },
          "description": { "type": "string" },
          "asset_kind": { "type": "string" },
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["path"],
              "properties": {
                "path": { "type": "string" },
                "sha256": { "type": "string" },
                "bytes": { "type": "number" },
                "role": { "type": "string" }
              },
              "additionalProperties": true
            }
          },
          "metadata": { "type": "object", "additionalProperties": true },
          "usage_examples": {
            "type": "array",
            "items": { "type": "string" }
          },
          "risk_notes": {
            "type": "array",
            "items": { "type": "string" }
          },
          "target_compatibility": {
            "type": "array",
            "items": { "type": "string" }
          },
          "handoff_quality_gate": {
            "type": "object",
            "required": ["status", "checks"],
            "properties": {
              "status": { "type": "string", "enum": ["pass", "warn", "caution", "block", "empty"] },
              "checks": {
                "type": "array",
                "items": { "type": "object", "additionalProperties": true }
              }
            },
            "additionalProperties": true
          },
          "push_plan": {
            "type": "object",
            "required": ["visibility_default", "requires_human_confirmation"],
            "properties": {
              "visibility_default": { "type": "string", "enum": ["private", "public"] },
              "requires_human_confirmation": { "type": "boolean" },
              "command": { "type": "string" }
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      }
    },
    "handoff_quality_gate": {
      "type": "object",
      "additionalProperties": true
    },
    "local_cli_equivalent": { "type": "string" },
    "local_mcp_equivalent": {
      "type": "object",
      "additionalProperties": true
    },
    "safe_next_actions": {
      "type": "array",
      "items": { "type": "string" }
    },
    "output_contract": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
