add pdftomd
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
"""Remind agents to verify and commit completed project-file changes."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PROJECT_PREFIXES = (
|
||||
".codex/",
|
||||
"AGENTS.md",
|
||||
"ARCHITECTURE.md",
|
||||
"PLAN.md",
|
||||
"PRD.md",
|
||||
"PROGRESS.md",
|
||||
"docs/",
|
||||
)
|
||||
|
||||
|
||||
def read_payload() -> dict:
|
||||
raw = sys.stdin.read()
|
||||
if not raw.strip():
|
||||
return {}
|
||||
try:
|
||||
return json.loads(raw)
|
||||
except json.JSONDecodeError:
|
||||
return {}
|
||||
|
||||
|
||||
def find_repo_root(cwd: str | None) -> Path:
|
||||
start = Path(cwd or Path.cwd()).resolve()
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["git", "rev-parse", "--show-toplevel"],
|
||||
cwd=start,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return Path(result.stdout.strip()).resolve()
|
||||
except Exception:
|
||||
return start
|
||||
|
||||
|
||||
def project_changes(root: Path) -> list[str]:
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["git", "status", "--short"],
|
||||
cwd=root,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
paths: list[str] = []
|
||||
for line in result.stdout.splitlines():
|
||||
path = line[3:].replace("\\", "/")
|
||||
if path.startswith("samples/"):
|
||||
continue
|
||||
if path.startswith(PROJECT_PREFIXES):
|
||||
paths.append(path)
|
||||
return paths
|
||||
|
||||
|
||||
def main() -> int:
|
||||
payload = read_payload()
|
||||
root = find_repo_root(payload.get("cwd"))
|
||||
changes = project_changes(root)
|
||||
if not changes:
|
||||
return 0
|
||||
|
||||
message = (
|
||||
"Project workflow/docs changed. Before finishing, run focused verification, "
|
||||
"commit the completed change, and keep samples/ out of the commit."
|
||||
)
|
||||
print(json.dumps({"continue": True, "systemMessage": message}, ensure_ascii=True))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user