modify gemini template

This commit is contained in:
NINI
2026-04-28 01:51:20 +09:00
parent 949e0ab13c
commit 38291723f0
32 changed files with 523 additions and 320 deletions
@@ -0,0 +1,52 @@
#!/usr/bin/env python3
"""Gemini CLI AfterAgent hook that requests a retry when validation fails."""
import json
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
def emit(payload: dict) -> None:
print(json.dumps(payload, ensure_ascii=False))
def main() -> int:
raw = sys.stdin.read()
try:
data = json.loads(raw) if raw.strip() else {}
except json.JSONDecodeError:
data = {}
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:
emit({})
return 0
details = "\n".join(part for part in [result.stdout.strip(), result.stderr.strip()] if part)
reason = (
"Document harness validation failed. Continue the turn, fix the listed "
f"issues, and run `python scripts/validate_docs.py` again.\n\n{details}"
)
if data.get("stop_hook_active"):
emit({"continue": False, "stopReason": reason, "suppressOutput": True})
else:
emit({"decision": "deny", "reason": reason, "suppressOutput": True})
return 0
if __name__ == "__main__":
sys.exit(main())