{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://synkra.dev/schemas/agent-v3-schema.json",
  "title": "AIOX Agent V3 Schema",
  "description": "Schema for AIOX agent definitions with Auto-Claude capabilities",
  "type": "object",
  "required": ["agent", "persona", "commands"],
  "properties": {
    "IDE-FILE-RESOLUTION": {
      "type": "array",
      "description": "Instructions for resolving file paths in IDE context",
      "items": { "type": "string" }
    },
    "REQUEST-RESOLUTION": {
      "type": "string",
      "description": "Instructions for matching user requests to commands"
    },
    "activation-instructions": {
      "type": "array",
      "description": "Steps to execute when agent is activated",
      "items": { "type": "string" }
    },
    "agent": {
      "type": "object",
      "description": "Core agent identification",
      "required": ["name", "id", "title", "icon"],
      "properties": {
        "name": {
          "type": "string",
          "description": "Agent persona name (e.g., 'Dex', 'Quinn')"
        },
        "id": {
          "type": "string",
          "description": "Unique agent identifier (e.g., 'dev', 'qa')",
          "pattern": "^[a-z][a-z0-9-]*$"
        },
        "title": {
          "type": "string",
          "description": "Agent role title (e.g., 'Full Stack Developer')"
        },
        "icon": {
          "type": "string",
          "description": "Emoji icon for the agent"
        },
        "whenToUse": {
          "type": "string",
          "description": "Guidance on when to use this agent"
        },
        "customization": {
          "type": ["string", "null"],
          "description": "Custom overrides for this agent"
        }
      }
    },
    "persona_profile": {
      "type": "object",
      "description": "Personality and communication style",
      "properties": {
        "archetype": {
          "type": "string",
          "description": "Persona archetype (e.g., 'Builder', 'Guardian')"
        },
        "zodiac": {
          "type": "string",
          "description": "Zodiac sign for persona flavor"
        },
        "communication": {
          "type": "object",
          "properties": {
            "tone": {
              "type": "string",
              "enum": ["pragmatic", "conceptual", "analytical", "supportive", "precise"]
            },
            "emoji_frequency": {
              "type": "string",
              "enum": ["low", "medium", "high"]
            },
            "vocabulary": {
              "type": "array",
              "items": { "type": "string" }
            },
            "greeting_levels": {
              "type": "object",
              "properties": {
                "minimal": { "type": "string" },
                "named": { "type": "string" },
                "archetypal": { "type": "string" }
              }
            },
            "signature_closing": { "type": "string" }
          }
        }
      }
    },
    "persona": {
      "type": "object",
      "description": "Core persona definition",
      "required": ["role"],
      "properties": {
        "role": { "type": "string" },
        "style": { "type": "string" },
        "identity": { "type": "string" },
        "focus": { "type": "string" },
        "core_principles": {
          "type": "array",
          "items": { "type": "string" }
        },
        "responsibility_boundaries": {
          "type": "object",
          "description": "Scope and delegation rules"
        }
      }
    },
    "core_principles": {
      "type": "array",
      "description": "Guiding principles for agent behavior",
      "items": { "type": "string" }
    },
    "commands": {
      "type": "array",
      "description": "Available commands for this agent",
      "items": {
        "type": "object",
        "required": ["name", "description"],
        "properties": {
          "name": {
            "type": "string",
            "description": "Command name without * prefix"
          },
          "visibility": {
            "type": "array",
            "description": "When to show: full (all), quick (essential), key (critical)",
            "items": {
              "type": "string",
              "enum": ["full", "quick", "key"]
            }
          },
          "args": {
            "type": "string",
            "description": "Command arguments, e.g., '{story}' or '{topic}'"
          },
          "description": {
            "type": "string",
            "description": "What this command does"
          }
        }
      }
    },
    "dependencies": {
      "type": "object",
      "description": "External resources this agent depends on",
      "properties": {
        "tasks": {
          "type": "array",
          "items": { "type": "string" }
        },
        "templates": {
          "type": "array",
          "items": { "type": "string" }
        },
        "checklists": {
          "type": "array",
          "items": { "type": "string" }
        },
        "data": {
          "type": "array",
          "items": { "type": "string" }
        },
        "tools": {
          "type": "array",
          "items": { "type": "string" }
        },
        "git_restrictions": {
          "type": "object",
          "properties": {
            "allowed_operations": {
              "type": "array",
              "items": { "type": "string" }
            },
            "blocked_operations": {
              "type": "array",
              "items": { "type": "string" }
            },
            "redirect_message": { "type": "string" }
          }
        },
        "coderabbit_integration": {
          "type": "object",
          "description": "CodeRabbit code review integration config"
        },
        "decision_logging": {
          "type": "object",
          "description": "Decision logging configuration for yolo mode"
        }
      }
    },
    "develop-story": {
      "type": "object",
      "description": "Story development workflow (for @dev agent)",
      "properties": {
        "order-of-execution": { "type": "string" },
        "story-file-updates-ONLY": {
          "type": "array",
          "items": { "type": "string" }
        },
        "blocking": { "type": "string" },
        "ready-for-review": { "type": "string" },
        "completion": { "type": "string" }
      }
    },

    "autoClaude": {
      "type": "object",
      "description": "V3: Auto-Claude autonomous development capabilities",
      "properties": {
        "version": {
          "type": "string",
          "description": "Schema version",
          "const": "3.0"
        },
        "migratedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When this agent was migrated to V3"
        },
        "specPipeline": {
          "type": "object",
          "description": "Specification pipeline capabilities",
          "properties": {
            "canGather": {
              "type": "boolean",
              "description": "Can gather requirements (typically @pm)",
              "default": false
            },
            "canAssess": {
              "type": "boolean",
              "description": "Can assess complexity (typically @architect)",
              "default": false
            },
            "canResearch": {
              "type": "boolean",
              "description": "Can research dependencies (typically @analyst)",
              "default": false
            },
            "canWrite": {
              "type": "boolean",
              "description": "Can write specifications (typically @pm)",
              "default": false
            },
            "canCritique": {
              "type": "boolean",
              "description": "Can critique specs (typically @qa)",
              "default": false
            }
          }
        },
        "execution": {
          "type": "object",
          "description": "Implementation execution capabilities",
          "properties": {
            "canCreatePlan": {
              "type": "boolean",
              "description": "Can create implementation plans (typically @architect)",
              "default": false
            },
            "canCreateContext": {
              "type": "boolean",
              "description": "Can generate project context files (typically @architect)",
              "default": false
            },
            "canExecute": {
              "type": "boolean",
              "description": "Can execute subtasks (typically @dev)",
              "default": false
            },
            "canVerify": {
              "type": "boolean",
              "description": "Can verify subtask completion (typically @dev, @qa)",
              "default": false
            },
            "selfCritique": {
              "type": "object",
              "description": "Self-critique configuration for execution",
              "properties": {
                "enabled": {
                  "type": "boolean",
                  "default": true
                },
                "checklistRef": {
                  "type": "string",
                  "description": "Reference to self-critique checklist"
                }
              }
            }
          }
        },
        "recovery": {
          "type": "object",
          "description": "Recovery and rollback capabilities",
          "properties": {
            "canTrack": {
              "type": "boolean",
              "description": "Can track implementation attempts (typically @dev)",
              "default": false
            },
            "canRollback": {
              "type": "boolean",
              "description": "Can rollback to previous state (typically @dev)",
              "default": false
            },
            "maxAttempts": {
              "type": "integer",
              "description": "Max attempts before stuck detection",
              "default": 3
            },
            "stuckDetection": {
              "type": "boolean",
              "description": "Enable stuck detection",
              "default": true
            }
          }
        },
        "qa": {
          "type": "object",
          "description": "QA review capabilities",
          "properties": {
            "canReview": {
              "type": "boolean",
              "description": "Can perform QA reviews (typically @qa)",
              "default": false
            },
            "canFixRequest": {
              "type": "boolean",
              "description": "Can create fix requests (typically @qa)",
              "default": false
            },
            "reviewPhases": {
              "type": "integer",
              "description": "Number of review phases (default 10)",
              "default": 10
            },
            "maxIterations": {
              "type": "integer",
              "description": "Max QA loop iterations",
              "default": 5
            }
          }
        },
        "memory": {
          "type": "object",
          "description": "Memory and learning capabilities",
          "properties": {
            "canCaptureInsights": {
              "type": "boolean",
              "description": "Can capture session insights",
              "default": false
            },
            "canExtractPatterns": {
              "type": "boolean",
              "description": "Can extract code patterns",
              "default": false
            },
            "canDocumentGotchas": {
              "type": "boolean",
              "description": "Can document gotchas",
              "default": false
            }
          }
        },
        "worktree": {
          "type": "object",
          "description": "Worktree management capabilities",
          "properties": {
            "canCreate": {
              "type": "boolean",
              "description": "Can create worktrees (typically @devops)",
              "default": false
            },
            "canMerge": {
              "type": "boolean",
              "description": "Can merge worktrees (typically @devops)",
              "default": false
            },
            "canCleanup": {
              "type": "boolean",
              "description": "Can cleanup stale worktrees (typically @devops)",
              "default": false
            }
          }
        }
      }
    }
  }
}
