- Add CLAUDE.md (root + ETL subdirectory + db subdirectory) consolidating all Kiro steering docs - Add .mcp.json migrated from .kiro/settings/mcp.json (test DBs enabled, prod disabled) - Add .claude/commands/ (audit, doc-sync, db-docs) replacing Kiro skills - Add .claude/hooks/ (session_start, post_edit_audit, stop_audit_check) replacing Kiro hooks - Add .claude/settings.json registering all hooks - Add scripts/audit/prescan.py merging Kiro's audit_flagger + compliance_prescan - Remove .kiro/agents, hooks, scripts, settings, skills, state (migrated or obsolete) - Update .gitignore for Claude Code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
34 lines
942 B
Python
34 lines
942 B
Python
#!/usr/bin/env python3
|
|
"""PostToolUse hook: 编辑高风险文件后提醒审计"""
|
|
import json, re, sys
|
|
|
|
try:
|
|
data = json.load(sys.stdin)
|
|
except Exception:
|
|
sys.exit(0)
|
|
|
|
fp = (data.get("tool_input") or {}).get("file_path", "")
|
|
if not fp:
|
|
sys.exit(0)
|
|
|
|
# 转相对路径
|
|
rel = re.sub(r"^.*?NeoZQYY[/\\]", "", fp.replace("\\", "/"))
|
|
|
|
HIGH_RISK = [
|
|
r"^apps/etl/connectors/feiqiu/(tasks|loaders|scd|orchestration|config|database|models|quality)/",
|
|
r"^apps/backend/app/(routers|services|auth|schemas)/",
|
|
r"^db/.*/migrations/.*\.sql$",
|
|
r"^db/.*/schemas/.*\.sql$",
|
|
r"^packages/shared/",
|
|
]
|
|
|
|
for p in HIGH_RISK:
|
|
if re.search(p, rel):
|
|
print(json.dumps({
|
|
"hookSpecificOutput": {
|
|
"hookEventName": "PostToolUse",
|
|
"additionalContext": f"[audit-reminder] 已编辑高风险文件: {rel} — 完成本轮改动后请执行 /audit"
|
|
}
|
|
}))
|
|
break
|