From 83d7e785d549c1cf54d153eebd9e4afc138242b6 Mon Sep 17 00:00:00 2001 From: ProfRandom92 Date: Fri, 22 May 2026 21:17:06 +0200 Subject: [PATCH] artifact: add PR body generator example --- .../pr_body_from_agent_bundle_example.md | 27 +++++++++++++++ ...erate_pr_body_from_agent_bundle_example.py | 33 +++++++++++++++++++ tests/test_pr_body_from_agent_bundle.py | 9 +++++ 3 files changed, 69 insertions(+) create mode 100644 artifacts/pr_body_from_agent_bundle_example.md create mode 100644 scripts/generate_pr_body_from_agent_bundle_example.py diff --git a/artifacts/pr_body_from_agent_bundle_example.md b/artifacts/pr_body_from_agent_bundle_example.md new file mode 100644 index 0000000..6f98afc --- /dev/null +++ b/artifacts/pr_body_from_agent_bundle_example.md @@ -0,0 +1,27 @@ +## Summary + +Deterministic agent artifact bundle evidence for this change. + +## Scope + +- `artifacts/agent_artifact_bundle_example.json` +- `scripts/generate_agent_artifact_bundle_example.py` +- `tests/test_agent_artifact_bundle.py` + +## Validation + +- `python -m compileall -q scripts/agent_artifact_bundle.py scripts/generate_agent_artifact_bundle_example.py`: `pass` +- `pytest tests/test_agent_artifact_bundle.py -q`: `pass` + +## Safety Gate + +- result: `PASS` +- ok: `true` +- allow_dirty: `false` +- problems: `none` + +## Evidence + +- branch: `feat/agent-artifact-bundle-example` +- bundle_result: `PASS` +- mcp_context_output_ref: `artifacts/mcp_context_layer_example.json` diff --git a/scripts/generate_pr_body_from_agent_bundle_example.py b/scripts/generate_pr_body_from_agent_bundle_example.py new file mode 100644 index 0000000..e484808 --- /dev/null +++ b/scripts/generate_pr_body_from_agent_bundle_example.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +"""Generate a deterministic PR body Markdown example from an agent bundle.""" + +from __future__ import annotations + +import sys +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[1] +if str(REPO_ROOT) not in sys.path: + sys.path.insert(0, str(REPO_ROOT)) + +from scripts.pr_body_from_agent_bundle import render_pr_body_from_file + +INPUT_BUNDLE_PATH = REPO_ROOT / "artifacts" / "agent_artifact_bundle_example.json" +OUTPUT_PATH = REPO_ROOT / "artifacts" / "pr_body_from_agent_bundle_example.md" + + +def generate_pr_body_from_agent_bundle_example(output_path: Path = OUTPUT_PATH) -> Path: + rendered = render_pr_body_from_file(INPUT_BUNDLE_PATH) + output_path.parent.mkdir(parents=True, exist_ok=True) + output_path.write_text(rendered, encoding="utf-8") + return output_path + + +def main() -> int: + output_path = generate_pr_body_from_agent_bundle_example() + print(output_path.relative_to(REPO_ROOT).as_posix()) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/test_pr_body_from_agent_bundle.py b/tests/test_pr_body_from_agent_bundle.py index c48d433..69dc865 100644 --- a/tests/test_pr_body_from_agent_bundle.py +++ b/tests/test_pr_body_from_agent_bundle.py @@ -4,8 +4,10 @@ from pathlib import Path import scripts.pr_body_from_agent_bundle as pr_body +from scripts.generate_pr_body_from_agent_bundle_example import generate_pr_body_from_agent_bundle_example ARTIFACT_PATH = Path("artifacts/agent_artifact_bundle_example.json") +PR_BODY_ARTIFACT_PATH = Path("artifacts/pr_body_from_agent_bundle_example.md") 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 assert captured.err == "" assert captured.out.startswith("## Summary\n") assert "## Safety Gate\n" in captured.out + + +def test_pr_body_example_artifact_matches_generator_output(tmp_path: Path) -> None: + output_path = tmp_path / "pr_body_from_agent_bundle_example.md" + generate_pr_body_from_agent_bundle_example(output_path) + + assert output_path.read_text(encoding="utf-8") == PR_BODY_ARTIFACT_PATH.read_text(encoding="utf-8")