Skip to content

Commit ef3d39b

Browse files
authored
artifact: add PR body generator example
Adds a deterministic Markdown example artifact for the PR body generator, a generator script, and exact regeneration parity coverage.
1 parent 6ba6299 commit ef3d39b

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Summary
2+
3+
Deterministic agent artifact bundle evidence for this change.
4+
5+
## Scope
6+
7+
- `artifacts/agent_artifact_bundle_example.json`
8+
- `scripts/generate_agent_artifact_bundle_example.py`
9+
- `tests/test_agent_artifact_bundle.py`
10+
11+
## Validation
12+
13+
- `python -m compileall -q scripts/agent_artifact_bundle.py scripts/generate_agent_artifact_bundle_example.py`: `pass`
14+
- `pytest tests/test_agent_artifact_bundle.py -q`: `pass`
15+
16+
## Safety Gate
17+
18+
- result: `PASS`
19+
- ok: `true`
20+
- allow_dirty: `false`
21+
- problems: `none`
22+
23+
## Evidence
24+
25+
- branch: `feat/agent-artifact-bundle-example`
26+
- bundle_result: `PASS`
27+
- mcp_context_output_ref: `artifacts/mcp_context_layer_example.json`
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python3
2+
"""Generate a deterministic PR body Markdown example from an agent bundle."""
3+
4+
from __future__ import annotations
5+
6+
import sys
7+
from pathlib import Path
8+
9+
REPO_ROOT = Path(__file__).resolve().parents[1]
10+
if str(REPO_ROOT) not in sys.path:
11+
sys.path.insert(0, str(REPO_ROOT))
12+
13+
from scripts.pr_body_from_agent_bundle import render_pr_body_from_file
14+
15+
INPUT_BUNDLE_PATH = REPO_ROOT / "artifacts" / "agent_artifact_bundle_example.json"
16+
OUTPUT_PATH = REPO_ROOT / "artifacts" / "pr_body_from_agent_bundle_example.md"
17+
18+
19+
def generate_pr_body_from_agent_bundle_example(output_path: Path = OUTPUT_PATH) -> Path:
20+
rendered = render_pr_body_from_file(INPUT_BUNDLE_PATH)
21+
output_path.parent.mkdir(parents=True, exist_ok=True)
22+
output_path.write_text(rendered, encoding="utf-8")
23+
return output_path
24+
25+
26+
def main() -> int:
27+
output_path = generate_pr_body_from_agent_bundle_example()
28+
print(output_path.relative_to(REPO_ROOT).as_posix())
29+
return 0
30+
31+
32+
if __name__ == "__main__":
33+
raise SystemExit(main())

tests/test_pr_body_from_agent_bundle.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
from pathlib import Path
55

66
import scripts.pr_body_from_agent_bundle as pr_body
7+
from scripts.generate_pr_body_from_agent_bundle_example import generate_pr_body_from_agent_bundle_example
78

89
ARTIFACT_PATH = Path("artifacts/agent_artifact_bundle_example.json")
10+
PR_BODY_ARTIFACT_PATH = Path("artifacts/pr_body_from_agent_bundle_example.md")
911

1012

1113
def test_render_pr_body_from_committed_bundle_is_deterministic() -> None:
@@ -111,3 +113,10 @@ def test_cli_outputs_markdown_only_for_valid_bundle(tmp_path: Path, capsys) -> N
111113
assert captured.err == ""
112114
assert captured.out.startswith("## Summary\n")
113115
assert "## Safety Gate\n" in captured.out
116+
117+
118+
def test_pr_body_example_artifact_matches_generator_output(tmp_path: Path) -> None:
119+
output_path = tmp_path / "pr_body_from_agent_bundle_example.md"
120+
generate_pr_body_from_agent_bundle_example(output_path)
121+
122+
assert output_path.read_text(encoding="utf-8") == PR_BODY_ARTIFACT_PATH.read_text(encoding="utf-8")

0 commit comments

Comments
 (0)