开发机迁移

This commit is contained in:
Neo
2026-04-10 06:24:13 +08:00
parent f65c1d038b
commit 79d3c2e97e
50 changed files with 1565 additions and 318 deletions

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env python3
"""PreToolUse hook: 阻止读取 _archived/ 目录下的文件"""
import json, re, sys
try:
data = json.load(sys.stdin)
except Exception:
sys.exit(0)
tool = data.get("tool_name", "")
tool_input = data.get("tool_input") or {}
# 从不同工具中提取路径
path = ""
if tool in ("Read", "Edit", "Write"):
path = tool_input.get("file_path", "")
elif tool == "Glob":
path = tool_input.get("path", "")
path = path.replace("\\", "/")
if re.search(r"/_archived/|/_archived$|^_archived/", path) or re.search(
r"[/\\]_archived[/\\]", tool_input.get("file_path", "")
):
print(json.dumps({
"decision": "block",
"reason": "[archived-block] _archived/ 目录内容已废弃,禁止读取或参考。请使用当前版本的文件。"
}))