{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://github.com/gszj2018/pi-tools-switch/raw/refs/heads/release/v0.1.0/schemas/tools-switch.schema.json",
  "title": "pi-tools-switch configuration",
  "description": "Configuration for the pi-tools-switch extension: user-defined presets, subagent environment variables, custom gating modes, and the gating exit trigger. Loaded from <agentDir>/tools-switch.json.",
  "type": "object",
  "properties": {
    "presets": {
      "type": "object",
      "description": "User-defined tool presets. Keys are preset names matching [a-z][a-z0-9_-]*; values are lists of managed built-in tool names, including powershell. Presets with the same name override built-in presets.",
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string",
          "enum": [
            "read",
            "write",
            "edit",
            "bash",
            "powershell",
            "find",
            "grep",
            "ls"
          ]
        }
      }
    },
    "subagentEnvVars": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Additional environment variable names that mark a subagent context."
    },
    "gatingModes": {
      "type": "object",
      "description": "User-defined gating modes. Keys are mode names. Each mode defines trigger prefixes, explicitly allowed tools, and allowed write directories. Modes with the same name override built-in modes.",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "trigger": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "Input prefixes that activate the mode; any one matching the raw input (before skill/template expansion) activates it. Empty prefixes are rejected."
          },
          "allowTools": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Tools explicitly allowed while the mode is active. Tools listed here bypass all other restrictions."
          },
          "allowWriteDir": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Directories where write/edit are allowed while the mode is active. Accepts absolute paths, paths relative to cwd, and ~-prefixed home paths. Empty or undefined blocks all write/edit."
          }
        },
        "required": [
          "trigger",
          "allowTools",
          "allowWriteDir"
        ],
        "additionalProperties": false
      }
    },
    "gatingExitTrigger": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "description": "Input prefixes that exit the active gating mode. Omit or leave empty to use the built-in \"/normal-mode\" prefix; a non-empty list fully overrides it. Empty prefixes are rejected."
    }
  },
  "additionalProperties": true
}
