modify documents
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Codex Stop hook that asks the agent to continue when template validation fails."""
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def main() -> int:
|
||||
result = subprocess.run(
|
||||
[sys.executable, "scripts/validate_docs.py"],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
errors="replace",
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
return 0
|
||||
|
||||
details = "\n".join(part for part in [result.stdout.strip(), result.stderr.strip()] if part)
|
||||
payload = {
|
||||
"decision": "block",
|
||||
"reason": (
|
||||
"Document harness validation failed. Continue the turn, fix the listed "
|
||||
f"issues, and run `python scripts/validate_docs.py` again.\n\n{details}"
|
||||
),
|
||||
}
|
||||
print(json.dumps(payload, ensure_ascii=False))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user