modify documents
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Add validation reminders after Codex edits project coordination files."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
FORMAT_PATTERNS = (
|
||||
r"\.codex[\\/]agents[\\/].+\.toml\b",
|
||||
r"\.codex[\\/]config\.toml\b",
|
||||
r"\.codex[\\/]hooks\.json\b",
|
||||
r"\.codex[\\/]skills[\\/].+[\\/]SKILL\.md\b",
|
||||
r"\.codex[\\/]commands[\\/].+\.md\b",
|
||||
r"plugins[\\/].+[\\/]\.codex-plugin[\\/]plugin\.json\b",
|
||||
r"plugins[\\/].+[\\/]commands[\\/].+\.md\b",
|
||||
r"\.agents[\\/]plugins[\\/]marketplace\.json\b",
|
||||
)
|
||||
|
||||
SYNC_PATTERNS = (
|
||||
r"\bdocs[\\/]",
|
||||
r"\bphases[\\/]",
|
||||
r"\bPLAN\.md\b",
|
||||
r"\bPROGRESS\.md\b",
|
||||
r"\bAGENTS\.md\b",
|
||||
r"\bplugins[\\/]",
|
||||
r"\.agents[\\/]plugins[\\/]",
|
||||
)
|
||||
|
||||
|
||||
def matches(tool_input: object, patterns: tuple[str, ...]) -> bool:
|
||||
text = json.dumps(tool_input, ensure_ascii=False)
|
||||
return any(re.search(pattern, text, re.IGNORECASE) for pattern in patterns)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
try:
|
||||
payload = json.load(sys.stdin)
|
||||
except json.JSONDecodeError:
|
||||
return 0
|
||||
|
||||
tool_input = payload.get("tool_input", {})
|
||||
notes: list[str] = []
|
||||
|
||||
if matches(tool_input, FORMAT_PATTERNS):
|
||||
notes.append("parse changed .codex TOML/JSON/frontmatter files before finishing")
|
||||
|
||||
if matches(tool_input, SYNC_PATTERNS):
|
||||
notes.append("confirm PLAN.md and PROGRESS.md still reflect completed work and future work")
|
||||
|
||||
if not notes:
|
||||
return 0
|
||||
|
||||
notes.append("run python scripts/validate_workspace.py for changed repository state")
|
||||
json.dump(
|
||||
{
|
||||
"hookSpecificOutput": {
|
||||
"hookEventName": "PostToolUse",
|
||||
"additionalContext": "FESA post-edit reminder: " + "; ".join(notes) + ".",
|
||||
}
|
||||
},
|
||||
sys.stdout,
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user