Files
Neo-ZQYY/.kiro/hooks/cwd-guard-shell.kiro.hook

17 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"enabled": true,
"name": "CWD Guard for Shell",
"description": "在 AI 执行 shell 命令前,校验 cwd、命令语法和 Python 调用安全性,防止常见 Windows/PowerShell 陷阱。",
"version": "2",
"when": {
"type": "preToolUse",
"toolTypes": [
"shell"
]
},
"then": {
"type": "askAgent",
"prompt": "请对即将执行的 shell 命令做以下检查,发现问题则修正后再执行,全部通过则直接放行:\n\n1. **cwd 校验**:如果命令涉及 scripts/ops/、.kiro/scripts/、apps/etl/connectors/feiqiu/scripts/ 下的 Python 脚本cwd 必须为仓库根 C:\\NeoZQYY。ETL 模块命令 cwd 应为 apps/etl/connectors/feiqiu/,后端命令应为 apps/backend/,前端命令应为 apps/admin-web/。\n2. **裸调 Python/Node 拦截**:如果命令包含 `python`、`node`、`ipython` 但没有跟 `-c`、`-m` 或脚本路径参数,必须修正(会导致 REPL 劫持 shell。\n3. **命令连接符**:如果使用了 `&&`,替换为 `;`PowerShell 语法)。\n4. **环境变量语法**:如果使用了 `$VAR_NAME` 读取环境变量,替换为 `$env:VAR_NAME`PowerShell 语法)。\n\n对于不涉及上述问题的命令直接放行。"
}
}