"""
Skill manifest base model.

Defines the top-level SkillManifestV1 that combines all manifest components.
"""

from pydantic import BaseModel, Field

from typing import Literal

from aphub_sdk.schemas.manifest.metadata import AgentMetadata
from aphub_sdk.schemas.skill_manifest.spec import SkillSpec


class SkillManifestV1(BaseModel):
    """
    Skill Manifest v1.0

    The standardized declarative format for describing AI coding assistant skill packs.

    Example:
        ```yaml
        apiVersion: aipartnerup.com/v1
        kind: Skill

        metadata:
          name: code-forge
          version: 0.11.0
          description: "Forge TDD-driven implementation plans from documentation"
          keywords: [planning, tdd, implementation]

        spec:
          skills:
            - name: plan
              description: "Use when you have a spec for a multi-step task"
            - name: impl
              description: "Use when executing implementation plans"
          commands:
            - name: plan
              description: "Analyze documentation and generate implementation plan"
              skill: plan
          platforms:
            - claude-code
            - opencode
        ```
    """

    # Schema version (required)
    api_version: Literal["aipartnerup.com/v1"] = Field(
        "aipartnerup.com/v1",
        alias="apiVersion",
        description="Schema version",
    )

    # Resource type (required)
    kind: Literal["Skill"] = Field("Skill", description="Resource type")

    # Identity (required) - reuses AgentMetadata (name, version, etc.)
    metadata: AgentMetadata = Field(..., description="Skill identity and versioning")

    # Specification (required)
    spec: SkillSpec = Field(..., description="Skill pack specification")

    # Labels for filtering (optional)
    labels: dict[str, str] = Field(
        default_factory=dict,
        description="Filterable key-value labels",
    )

    # Annotations for metadata (optional)
    annotations: dict[str, str] = Field(
        default_factory=dict,
        description="Non-filterable metadata annotations",
    )

    model_config = {"populate_by_name": True}
