remove files

This commit is contained in:
김경종
2026-05-08 16:31:17 +09:00
parent 7e985ae94a
commit 551ab50735
135 changed files with 0 additions and 41205 deletions
-81
View File
@@ -1,81 +0,0 @@
#!/usr/bin/env python3
"""Catch high-confidence documentation drift before a Codex turn ends."""
from __future__ import annotations
import json
import subprocess
import sys
from pathlib import Path
def changed_paths(root: Path) -> set[str]:
result = subprocess.run(
["git", "status", "--porcelain"],
cwd=root,
capture_output=True,
text=True,
timeout=20,
)
if result.returncode != 0:
return set()
paths: set[str] = set()
for line in result.stdout.splitlines():
if not line.strip():
continue
path = line[3:].replace("\\", "/")
if " -> " in path:
path = path.split(" -> ", 1)[1]
paths.add(path)
return paths
def block(reason: str) -> int:
json.dump({"decision": "block", "reason": reason}, sys.stdout)
return 0
def main() -> int:
try:
payload = json.load(sys.stdin)
except json.JSONDecodeError:
return 0
if payload.get("stop_hook_active"):
return 0
root = Path(payload.get("cwd") or ".").resolve()
paths = changed_paths(root)
if "requirements.txt" in paths and "docs/TOOLCHAIN.md" not in paths:
return block(
"requirements.txt changed without docs/TOOLCHAIN.md. "
"Update the toolchain notes with dependency compatibility rationale."
)
sample_pdf_changed = any(path.startswith("samples/") and path.lower().endswith(".pdf") for path in paths)
metadata_changed = "samples/metadata.json" in paths
if sample_pdf_changed and not metadata_changed:
return block(
"A sample PDF changed without samples/metadata.json. "
"Update the sample metadata mapping so quality tests know the corpus traits."
)
policy_docs = {
"docs/ARCHITECTURE.md",
"docs/CONVERSION_POLICY.md",
"docs/ADR.md",
}
touched_policy_docs = policy_docs.intersection(paths)
if touched_policy_docs and "PROGRESS.md" not in paths:
return block(
"Architecture or conversion policy docs changed without PROGRESS.md. "
"Record the decision and handoff context in PROGRESS.md."
)
return 0
if __name__ == "__main__":
raise SystemExit(main())
-95
View File
@@ -1,95 +0,0 @@
#!/usr/bin/env python3
"""Require PLAN/PROGRESS handoff discipline for multi-agent work."""
from __future__ import annotations
import json
import subprocess
import sys
from pathlib import Path
TRACKED_PREFIXES = (
".agents/",
".codex/",
"AGENTS.md",
"PLAN.md",
"docs/",
"phases/",
"plugins/",
"requirements.txt",
"scripts/",
"src/",
"tests/",
)
def git_status_names(root: Path) -> list[str]:
result = subprocess.run(
["git", "status", "--porcelain"],
cwd=root,
capture_output=True,
text=True,
timeout=20,
)
if result.returncode != 0:
return []
names: list[str] = []
for line in result.stdout.splitlines():
if not line.strip():
continue
path = line[3:].replace("\\", "/")
if " -> " in path:
path = path.split(" -> ", 1)[1]
names.append(path)
return names
def is_coordination_relevant(path: str) -> bool:
return any(path == prefix or path.startswith(prefix) for prefix in TRACKED_PREFIXES)
def block(reason: str) -> int:
json.dump({"decision": "block", "reason": reason}, sys.stdout)
return 0
def main() -> int:
try:
payload = json.load(sys.stdin)
except json.JSONDecodeError:
return 0
if payload.get("stop_hook_active"):
return 0
root = Path(payload.get("cwd") or ".").resolve()
plan = root / "PLAN.md"
progress = root / "PROGRESS.md"
if not plan.exists() or not progress.exists():
return block(
"Multi-agent coordination requires PLAN.md and PROGRESS.md. "
"Create or restore both files before ending the turn."
)
changed = git_status_names(root)
if not changed:
return 0
relevant = [path for path in changed if is_coordination_relevant(path)]
progress_changed = "PROGRESS.md" in changed
if relevant and not progress_changed:
return block(
"Repository planning, docs, code, tests, requirements, or .codex files changed, "
"but PROGRESS.md was not updated. Add a concise handoff note so the next agent "
"can see what changed, what was verified, and what remains next."
)
return 0
if __name__ == "__main__":
raise SystemExit(main())
-50
View File
@@ -1,50 +0,0 @@
#!/usr/bin/env python3
"""Block obviously destructive shell commands before Codex runs them."""
from __future__ import annotations
import json
import re
import sys
BLOCK_PATTERNS = (
r"\brm\s+-rf\b",
r"\bgit\s+push\s+--force(?:-with-lease)?\b",
r"\bgit\s+reset\s+--hard\b",
r"\bgit\s+clean\s+-[a-zA-Z]*f[a-zA-Z]*[dx][a-zA-Z]*\b",
r"\bgit\s+checkout\s+--\s+\.\b",
r"\bDROP\s+TABLE\b",
r"\btruncate\s+table\b",
r"\bRemove-Item\b.*\b-Recurse\b",
r"\bdel\b\s+/s\b",
r"\bconda\s+(?:env\s+)?remove\b.*\b--all\b",
)
def main() -> int:
try:
payload = json.load(sys.stdin)
except json.JSONDecodeError:
return 0
command = payload.get("tool_input", {}).get("command", "")
for pattern in BLOCK_PATTERNS:
if re.search(pattern, command, re.IGNORECASE):
json.dump(
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "deny",
"permissionDecisionReason": "Harness guardrail blocked a risky shell command.",
}
},
sys.stdout,
)
return 0
return 0
if __name__ == "__main__":
raise SystemExit(main())
-55
View File
@@ -1,55 +0,0 @@
#!/usr/bin/env python3
"""Run repository validation when a Codex turn stops and request one more pass if it fails."""
from __future__ import annotations
import json
import subprocess
import sys
from pathlib import Path
def main() -> int:
try:
payload = json.load(sys.stdin)
except json.JSONDecodeError:
return 0
if payload.get("stop_hook_active"):
return 0
root = Path(payload.get("cwd") or ".").resolve()
validator = root / "scripts" / "validate_workspace.py"
if not validator.exists():
return 0
result = subprocess.run(
[sys.executable, str(validator)],
cwd=root,
capture_output=True,
text=True,
timeout=240,
)
if result.returncode == 0:
return 0
summary = (result.stdout or result.stderr or "workspace validation failed").strip()
if len(summary) > 1200:
summary = summary[:1200].rstrip() + "..."
json.dump(
{
"decision": "block",
"reason": (
"Validation failed. Review the output, fix the repo, then continue.\n\n"
f"{summary}"
),
},
sys.stdout,
)
return 0
if __name__ == "__main__":
raise SystemExit(main())