Files
Neo-ZQYY/.kiro/hooks/repl-hijack-guard.kiro.hook

16 lines
1.1 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": "REPL 劫持检测与恢复",
"description": "在 shell 命令执行后检查输出,若发现 REPL 劫持症状exit code 0 但无输出、出现 >>> 提示符),先尝试 exit 命令自救,失败则提醒用户手动终止进程。",
"version": "1",
"when": {
"type": "postToolUse",
"toolTypes": [
"shell"
]
},
"then": {
"type": "askAgent",
"prompt": "检查刚执行的 shell 命令输出,判断是否出现 REPL 劫持症状:\n1. exit code 0 但完全无输出(对于预期有输出的命令)\n2. 输出中出现 `>>>` 或 `...` 等 Python REPL 提示符\n3. 输出中出现 `>` 等 Node REPL 提示符\n\n如果检测到症状\n- 第一步:立即执行 `exit` 命令尝试退出 REPL\n- 第二步:执行一条验证命令(如 `echo \"shell_ok\"`)确认 shell 已恢复\n- 如果恢复成功:重新执行原命令\n- 如果仍未恢复:停止重试,提醒用户在外部终端执行 `Get-Process python* | Stop-Process -Force`,等用户确认后再继续\n\n如果没有症状直接放行不做任何操作。"
}
}