{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "https://schema.hagicode.com/schemas/prompts.schema.json",
  "title": "Prompt Template",
  "type": "object",
  "description": "PCode prompt template configuration for YAML files",
  "additionalProperties": false,
  "properties": {
    "Metadata": {
      "description": "提示词元数据",
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/PromptMetadata"
        }
      ]
    },
    "SystemPrompt": {
      "type": [
        "null",
        "string"
      ],
      "description": "系统提示词"
    },
    "UserPromptTemplate": {
      "type": [
        "null",
        "string"
      ],
      "description": "用户提示词模板（可包含参数占位符）"
    },
    "EmbeddedCommand": {
      "type": [
        "null",
        "string"
      ],
      "description": "内嵌命令内容（可选）"
    }
  },
  "definitions": {
    "PromptMetadata": {
      "type": "object",
      "description": "提示词元数据 (V2 - JSON format for new Scriban templates)",
      "additionalProperties": false,
      "properties": {
        "Scenario": {
          "type": "string",
          "description": "场景名称"
        },
        "Locale": {
          "type": "string",
          "description": "语言区域设置 (BCP 47 format, e.g., \"zh-CN\", \"en-US\")"
        },
        "Version": {
          "type": "string",
          "description": "版本号 (semantic version format, e.g., \"2.0.0\")"
        },
        "TemplateRef": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional reference to a shared template file.\nIf omitted, defaults to same filename with .scriban extension."
        },
        "Appendices": {
          "description": "Optional appendix-oriented metadata extensions for non-OpenSpec prompts.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/definitions/PromptMetadataAppendices"
            }
          ]
        },
        "Syntax": {
          "type": "string",
          "description": "Template syntax type (default: \"handlebars\")"
        },
        "SyntaxVersion": {
          "type": [
            "null",
            "string"
          ],
          "description": "Syntax version for future compatibility"
        },
        "Parameters": {
          "type": "array",
          "description": "Parameter definitions for the template",
          "items": {
            "$ref": "#/definitions/PromptParameter"
          }
        },
        "LastModified": {
          "type": [
            "null",
            "string"
          ],
          "description": "最后修改日期 (ISO 8601 format)"
        },
        "Author": {
          "type": [
            "null",
            "string"
          ],
          "description": "作者"
        },
        "Description": {
          "type": [
            "null",
            "string"
          ],
          "description": "描述"
        },
        "Icon": {
          "type": [
            "null",
            "string"
          ],
          "description": "Icon identifier for visual display."
        },
        "Image": {
          "description": "Optional prompt image generation definition.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/definitions/PromptImageDefinition"
            }
          ]
        },
        "Dungeon": {
          "description": "Optional dungeon catalog configuration for prompt-backed hero routing.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/definitions/PromptDungeonConfiguration"
            }
          ]
        },
        "Tags": {
          "type": "array",
          "description": "Classification tags for the prompt",
          "items": {
            "type": "string"
          }
        },
        "EmbeddedCommand": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional embedded command content (for OpenSpec commands)"
        },
        "Source": {
          "description": "Source of the prompt (Default or Override)",
          "oneOf": [
            {
              "$ref": "#/definitions/PromptSource"
            }
          ]
        },
        "LastModifiedAt": {
          "type": [
            "null",
            "string"
          ],
          "description": "Last modified timestamp for the prompt file",
          "format": "date-time"
        }
      }
    },
    "PromptMetadataAppendices": {
      "type": "object",
      "description": "Appendix-oriented prompt metadata sections for non-OpenSpec prompts.",
      "additionalProperties": false,
      "properties": {
        "Template": {
          "description": "Template linkage appendix.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/definitions/PromptTemplateAppendix"
            }
          ]
        },
        "Visual": {
          "description": "Visual display appendix.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/definitions/PromptVisualAppendix"
            }
          ]
        },
        "Runtime": {
          "description": "Runtime behavior appendix.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/definitions/PromptRuntimeAppendix"
            }
          ]
        }
      }
    },
    "PromptTemplateAppendix": {
      "type": "object",
      "description": "Describes how a prompt metadata file associates with a template file.",
      "additionalProperties": false,
      "properties": {
        "Association": {
          "type": [
            "null",
            "string"
          ],
          "description": "Association mode, e.g. co-located or template-ref."
        },
        "TemplateRef": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional explicit shared template reference."
        }
      }
    },
    "PromptVisualAppendix": {
      "type": "object",
      "description": "Visual appendix for prompt display metadata.",
      "additionalProperties": false,
      "properties": {
        "Icon": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional icon identifier for list/detail display."
        },
        "Tags": {
          "type": "array",
          "description": "Visual categorization tags.",
          "items": {
            "type": "string"
          }
        },
        "Image": {
          "description": "Appendix-backed image definition.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/definitions/PromptImageDefinition"
            }
          ]
        }
      }
    },
    "PromptImageDefinition": {
      "type": "object",
      "description": "Represents author-time prompt image generation metadata.",
      "additionalProperties": false,
      "properties": {
        "Prompt": {
          "type": [
            "null",
            "string"
          ],
          "description": "Explicit image prompt supplement."
        },
        "Alt": {
          "type": [
            "null",
            "string"
          ],
          "description": "Accessible alternative text."
        },
        "AspectRatio": {
          "type": [
            "null",
            "string"
          ],
          "description": "Preferred aspect ratio, e.g. 16:9."
        },
        "StageStyleKey": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional stage style key. For catalogued scenarios this must match the fixed assignment."
        },
        "StageStyleLabel": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional human-readable stage style label."
        },
        "ArtStyle": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional fixed art style. For catalogued scenarios this must match the fixed assignment."
        },
        "DisplayMode": {
          "type": [
            "null",
            "string"
          ],
          "description": "Preferred presentation mode, e.g. banner or storyboard."
        },
        "PromptDirection": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional prompt direction description used by image summary surfaces."
        },
        "StyleTags": {
          "type": "array",
          "description": "Optional style tags applied on top of the fixed catalog style.",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "PromptRuntimeAppendix": {
      "type": "object",
      "description": "Runtime appendix for prompt-managed behaviors.",
      "additionalProperties": false,
      "properties": {
        "Dungeon": {
          "description": "Optional dungeon catalog configuration.",
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/definitions/PromptDungeonConfiguration"
            }
          ]
        },
        "InfoSections": {
          "type": "array",
          "description": "Optional read-only information sections rendered in prompt management.",
          "items": {
            "$ref": "#/definitions/PromptInfoSection"
          }
        }
      }
    },
    "PromptDungeonConfiguration": {
      "type": "object",
      "description": "Represents prompt-owned dungeon catalog metadata.",
      "additionalProperties": false,
      "properties": {
        "Enabled": {
          "type": "boolean",
          "description": "Whether this prompt should produce a dungeon catalog entry."
        },
        "ScriptKey": {
          "type": [
            "null",
            "string"
          ],
          "description": "Stable runtime script key for the dungeon entry."
        },
        "GroupKey": {
          "type": [
            "null",
            "string"
          ],
          "description": "Stable group key used to group the dungeon in the UI."
        },
        "SortOrder": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Sort order used when rendering the dungeon catalog.",
          "format": "int32"
        },
        "DisplayNameKey": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional localization key used to resolve the dungeon name on the frontend."
        },
        "DisplayName": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional display name override for the dungeon entry."
        },
        "DescriptionKey": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional localization key used to resolve the dungeon description on the frontend."
        },
        "Description": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional description override for the dungeon entry."
        }
      }
    },
    "PromptInfoSection": {
      "type": "object",
      "description": "Represents a read-only prompt information section such as venue metadata.",
      "additionalProperties": false,
      "properties": {
        "Kind": {
          "type": [
            "null",
            "string"
          ],
          "description": "Section kind, e.g. venue."
        },
        "Title": {
          "type": [
            "null",
            "string"
          ],
          "description": "Human-readable section title."
        },
        "Description": {
          "type": [
            "null",
            "string"
          ],
          "description": "Optional helper text displayed under the title."
        },
        "Items": {
          "type": "array",
          "description": "Read-only label/value rows for the section.",
          "items": {
            "$ref": "#/definitions/PromptInfoItem"
          }
        }
      }
    },
    "PromptInfoItem": {
      "type": "object",
      "description": "Represents a read-only prompt information row.",
      "additionalProperties": false,
      "properties": {
        "Label": {
          "type": [
            "null",
            "string"
          ],
          "description": "Human-readable field label."
        },
        "Value": {
          "type": [
            "null",
            "string"
          ],
          "description": "Field value rendered as text."
        }
      }
    },
    "PromptParameter": {
      "type": "object",
      "description": "Represents a parameter definition in prompt metadata",
      "additionalProperties": false,
      "properties": {
        "Name": {
          "type": "string",
          "description": "Parameter name"
        },
        "Type": {
          "type": "string",
          "description": "Parameter type (string, int, bool, array, object)"
        },
        "Required": {
          "type": "boolean",
          "description": "Whether the parameter is required"
        },
        "Description": {
          "type": [
            "null",
            "string"
          ],
          "description": "Parameter description"
        }
      }
    },
    "PromptSource": {
      "type": "integer",
      "description": "Defines the source location for a prompt template.",
      "x-enumNames": [
        "Default",
        "Override"
      ],
      "enum": [
        0,
        1
      ]
    }
  }
}