feat: review_only input and an enumeration check in the monthly prompt
tests / unittest (push) Successful in 23s
tests / unittest (push) Successful in 23s
review_only names listed documents the drafter may read but not edit. They stay in stage 1, are listed separately in the prompt, and a change to one fails the run like a change outside docs. Each entry must match a docs pattern. The monthly prompt now makes checking every list and count in the top-level documents against the repository the drafter's main job. Mode-specific text moves to prompts/mode-pr.md and prompts/mode-monthly.md; the pr text is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f39409e62c
commit
9dea56ce98
15 files changed
+223
-29
No files matched your search
+45
-3
@@ -9,6 +9,7 @@ from docs_review.draft import (
|
||||
build_prompt,
|
||||
claude_argv,
|
||||
diff_payload,
|
||||
load_template,
|
||||
outside_docs,
|
||||
parse_claude_output,
|
||||
parse_last_head,
|
||||
@@ -59,14 +60,55 @@ class PromptTest(unittest.TestCase):
|
||||
self.assertIn("monthly|none|", out)
|
||||
|
||||
def test_shipped_template_renders(self):
|
||||
from pathlib import Path
|
||||
t = Path(__file__).resolve().parent.parent / "prompts" / "task.md"
|
||||
out = build_prompt(t.read_text(), mode="pr", pr=7, flags_json="{}", payload="{x}",
|
||||
out = build_prompt(load_template("pr"), mode="pr", pr=7, flags_json="{}", payload="{x}",
|
||||
docs=("a.md",), top_level=("README.md",), guide_path=None)
|
||||
self.assertIn("```json", out)
|
||||
self.assertIn("{x}", out)
|
||||
self.assertNotIn("{mode}", out)
|
||||
|
||||
def test_review_only_section(self):
|
||||
t = "{docs}|{review_only}"
|
||||
none = build_prompt(t, mode="pr", pr=1, flags_json="{}", payload="",
|
||||
docs=("a.md",), top_level=(), guide_path=None)
|
||||
self.assertEqual(none, "a.md|")
|
||||
out = build_prompt(t, mode="pr", pr=1, flags_json="{}", payload="",
|
||||
docs=("a.md",), top_level=(), guide_path=None,
|
||||
review_only=("v.md", "w.md"))
|
||||
self.assertIn("Documents you may read but not edit:\n\nv.md\nw.md", out)
|
||||
self.assertIn("declined", out)
|
||||
|
||||
|
||||
class TemplateModeTest(unittest.TestCase):
|
||||
def _render(self, mode, review_only=()):
|
||||
return build_prompt(load_template(mode), mode=mode, pr=None if mode == "monthly" else 7,
|
||||
flags_json="{}", payload="p", docs=("README.md", "docs/a.md"),
|
||||
top_level=("README.md",), guide_path=None,
|
||||
review_only=review_only)
|
||||
|
||||
def test_monthly_asks_for_enumeration_check_and_lists_review_only(self):
|
||||
out = self._render("monthly", ("docs/vision.md",))
|
||||
self.assertIn("check every enumeration", out)
|
||||
self.assertIn("Glob", out)
|
||||
self.assertIn("A list presented as complete must be complete", out)
|
||||
self.assertIn("Documents you may read but not edit:\n\ndocs/vision.md", out)
|
||||
self.assertIn("README.md", out)
|
||||
for field in ("{top_level}", "{mode_text}", "{review_only}", "{docs}"):
|
||||
self.assertNotIn(field, out)
|
||||
|
||||
def test_pr_has_no_enumeration_check(self):
|
||||
out = self._render("pr", ("docs/vision.md",))
|
||||
self.assertNotIn("enumeration", out)
|
||||
self.assertIn("find what this pull request makes stale", out)
|
||||
self.assertIn("Documents you may read but not edit:\n\ndocs/vision.md", out)
|
||||
|
||||
def test_review_only_section_absent_when_empty(self):
|
||||
for mode in ("pr", "monthly"):
|
||||
self.assertNotIn("read but not edit", self._render(mode))
|
||||
|
||||
def test_unknown_mode_raises(self):
|
||||
with self.assertRaises(ValueError):
|
||||
load_template("weekly")
|
||||
|
||||
|
||||
class ArgvTest(unittest.TestCase):
|
||||
def test_argv_matches_spec(self):
|
||||
|
||||
Reference in new issue
Block a user