{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/ast-grep/ast-grep-sgconfig-yml/latest.json",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/project.json",
    "sourceSha256": "83fba4e8506d3d57d994610d59bbc4192202207577425635e33a7f5df1a29245",
    "fileMatch": [
      "sgconfig.yml",
      "sgconfig.yaml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "$defs": {
    "Project": {
      "type": "object",
      "title": "ast-grep project configuration",
      "properties": {
        "ruleDirs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "title": "Rule directories",
          "description": "A list of string instructing where to discover ast-grep's YAML rules."
        },
        "testConfigs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TestConfig"
          },
          "title": "Test configurations",
          "description": "A list of object to configure ast-grep's test cases. Each object can have two fields."
        },
        "utilDirs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "title": "Utility directories",
          "description": "A list of string instructing where to discover ast-grep's global utility rules."
        },
        "languageGlobs": {
          "type": "object",
          "description": "A mapping to associate a language to files that have non-standard extensions or syntaxes.",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "customLanguages": {
          "type": "object",
          "description": "A dictionary of custom languages in the project.",
          "additionalProperties": {
            "$ref": "#/$defs/CustomLanguage"
          }
        },
        "languageInjections": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/LanguageInjection"
          },
          "description": "A list of language injections to support embedded languages in the project like JS/CSS in HTML. This is an experimental feature."
        }
      },
      "required": [
        "ruleDirs"
      ],
      "additionalProperties": false
    },
    "TestConfig": {
      "type": "object",
      "title": "Test configuration",
      "properties": {
        "testDir": {
          "type": "string",
          "description": "A string specifies where to discover test cases for ast-grep."
        },
        "snapshotDir": {
          "type": "string",
          "description": "A string path relative to testDir that specifies where to store test snapshots for ast-grep. You can think it like __snapshots___ in popular test framework like jest. If this option is not specified, ast-grep will store the snapshot under the __snapshots__ folder under the testDir."
        }
      },
      "required": [
        "testDir"
      ],
      "additionalProperties": false
    },
    "CustomLanguage": {
      "type": "object",
      "properties": {
        "libraryPath": {
          "type": [
            "string",
            "object"
          ],
          "description": "The path to the tree-sitter dynamic library of the language."
        },
        "extensions": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The file extensions for this language."
        },
        "expandoChar": {
          "type": "string",
          "description": "An optional char to replace $ in your pattern."
        },
        "languageSymbol": {
          "type": "string",
          "description": "The dylib symbol to load ts-language, default is tree_sitter_{name}"
        }
      },
      "required": [
        "libraryPath",
        "extensions"
      ]
    },
    "LanguageInjection": {
      "type": "object",
      "description": "A list of language injections to support embedded languages in the project like JS/CSS in HTML. This is an experimental feature.",
      "properties": {
        "hostLanguage": {
          "type": "string",
          "description": "The host language name, e.g. html. This is the language of documents that contains the embedded language code."
        },
        "rule": {
          "$ref": "https://catalog.lintel.tools/schemas/ast-grep/ast-grep-sgconfig-yml/_shared/latest--rule.json#/$defs/SerializableRule",
          "description": "Defines the ast-grep rule to identify the injected language region within the host language documents."
        },
        "injected": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ],
          "description": "The injected language name"
        }
      },
      "required": [
        "hostLanguage",
        "rule",
        "injected"
      ]
    }
  },
  "$ref": "#/$defs/Project"
}
