Files
Kill_LIFE/tools/ai/compose_codex_prompt.py
Clément SAILLANT 55fe558f63 fix: security hardening, CI fixes, and scope guard restrictions
- Fix dependency_update.yml syntax error (uses: after run:)
- Restrict scope_guard.py allowlist: ai:impl no longer allows all tools/,
  ai:qa no longer allows tools/gates/, ai:docs no longer allows specs/
- Fix signing key exposure in release_signing.yml and supply_chain.yml
  by using env://COSIGN_KEY instead of inline secret interpolation
- Fix specify_init.py hyphen normalization bug (multiple consecutive hyphens)
- Add explicit permissions blocks to 15 workflows for least-privilege
- Add file existence checks and encoding error handling to compose_codex_prompt.py
- Fix schops.py: backup_file() error handling, delimiter-aware lib_id matching

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 11:37:18 +01:00

41 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Compose a Codex prompt from repo context + sanitized issue."""
import sys
from pathlib import Path
BASE = Path(__file__).resolve().parents[2]
def read(p: str) -> str:
fp = BASE / p
if not fp.exists():
print(f"error: required file not found: {fp}", file=sys.stderr)
raise SystemExit(2)
return fp.read_text(encoding="utf-8", errors="replace")
def main():
if len(sys.argv) != 3:
print("usage: compose_codex_prompt.py <issue_txt> <out_prompt_md>", file=sys.stderr)
return 2
issue_path = Path(sys.argv[1])
if not issue_path.exists():
print(f"error: issue file not found: {issue_path}", file=sys.stderr)
return 2
issue = issue_path.read_text(encoding="utf-8", errors="replace")
base = read(".github/codex/prompts/issue_to_pr_base.md")
out = (
base
+ "\n\n## Repo context pointers\n"
+ "- constraints: `specs/constraints.yaml`\n"
+ "- specs flow: `specs/README.md`\n"
+ "- standards: `standards/README.md`\n"
+ "- BMAD gates: `bmad/gates/gate_s0.md`, `bmad/gates/gate_s1.md`\n"
+ "\n\n-----BEGIN_ISSUE_TEXT-----\n"
+ issue
+ "\n-----END_ISSUE_TEXT-----\n"
)
Path(sys.argv[2]).write_text(out, encoding="utf-8")
return 0
if __name__ == "__main__":
raise SystemExit(main())