feat: 实现 Hook 系统

参考 open-code 的实现,添加工具执行前后的 hook 功能:

- 添加 Hook 类型定义 (tool.execute.before/after, file.edited/created/deleted 等)
- 实现 HookManager 管理器,支持插件注册和事件触发
- 实现配置文件加载器,支持 .ai-assistant.json/jsonc 格式
- 支持 glob 模式匹配文件触发 shell 命令
- 集成到 Agent 工具执行流程
- 添加 minimatch 依赖用于 glob 匹配
- 编写完整测试用例 (27 个测试)

配置示例:
```json
{
  "hooks": {
    "file_edited": {
      "*.ts": [{ "command": ["npx", "tsc", "--noEmit"] }]
    }
  }
}
```
This commit is contained in:
2025-12-11 23:12:04 +08:00
parent 89673e28cb
commit 630ce9fd4b
8 changed files with 1667 additions and 1 deletions
+1
View File
@@ -35,6 +35,7 @@
"commander": "^12.1.0",
"inquirer": "^12.0.0",
"js-yaml": "^4.1.1",
"minimatch": "^10.1.1",
"ora": "^8.1.0",
"qwen-ai-provider-v5": "^1.0.2",
"tree-sitter-bash": "^0.25.1",