fix: correct hooks JSON schema type definition

The hooks array items were incorrectly typed as 'string' in the JSON
schema, causing VS Code to show type errors when users configure
HookDefinition objects. This fix adds proper schema support for complex
array item types.

- Add SettingItemDefinition interface for array item schema
- Add items schema for UserPromptSubmit and Stop hooks
- Update generate-settings-schema.ts to convert complex item types

Fixes #2246

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
xwj02155382 2026-03-11 15:09:49 +08:00
parent bf99f95602
commit 700806ce83
3 changed files with 314 additions and 3 deletions

View file

@ -600,14 +600,124 @@
"description": "Hooks that execute before agent processing. Can modify prompts or inject context.",
"type": "array",
"items": {
"type": "string"
"description": "A hook definition with an optional matcher and a list of hook configurations.",
"type": "object",
"properties": {
"matcher": {
"description": "An optional matcher pattern to filter when this hook definition applies.",
"type": "string"
},
"sequential": {
"description": "Whether the hooks should be executed sequentially instead of in parallel.",
"type": "boolean"
},
"hooks": {
"description": "The list of hook configurations to execute.",
"type": "array",
"items": {
"description": "A hook configuration entry that defines a command to execute.",
"type": "object",
"properties": {
"type": {
"description": "The type of hook.",
"type": "string",
"enum": [
"command"
]
},
"command": {
"description": "The command to execute when the hook is triggered.",
"type": "string"
},
"name": {
"description": "An optional name for the hook.",
"type": "string"
},
"description": {
"description": "An optional description of what the hook does.",
"type": "string"
},
"timeout": {
"description": "Timeout in milliseconds for the hook execution.",
"type": "number"
},
"env": {
"description": "Environment variables to set when executing the hook command.",
"type": "object"
}
},
"required": [
"type",
"command"
]
}
}
},
"required": [
"hooks"
]
}
},
"Stop": {
"description": "Hooks that execute after agent processing. Can post-process responses or log interactions.",
"type": "array",
"items": {
"type": "string"
"description": "A hook definition with an optional matcher and a list of hook configurations.",
"type": "object",
"properties": {
"matcher": {
"description": "An optional matcher pattern to filter when this hook definition applies.",
"type": "string"
},
"sequential": {
"description": "Whether the hooks should be executed sequentially instead of in parallel.",
"type": "boolean"
},
"hooks": {
"description": "The list of hook configurations to execute.",
"type": "array",
"items": {
"description": "A hook configuration entry that defines a command to execute.",
"type": "object",
"properties": {
"type": {
"description": "The type of hook.",
"type": "string",
"enum": [
"command"
]
},
"command": {
"description": "The command to execute when the hook is triggered.",
"type": "string"
},
"name": {
"description": "An optional name for the hook.",
"type": "string"
},
"description": {
"description": "An optional description of what the hook does.",
"type": "string"
},
"timeout": {
"description": "Timeout in milliseconds for the hook execution.",
"type": "number"
},
"env": {
"description": "Environment variables to set when executing the hook command.",
"type": "object"
}
},
"required": [
"type",
"command"
]
}
}
},
"required": [
"hooks"
]
}
}
}