feat(pr-contract): add --body-file pre-publish mode and context-aware parser#82
Conversation
… parser Validate a drafted PR body before the PR exists (--body-file <path|->), so the same validator runs identically before and after creation — removes the push->create->amend->re-scan loop. Make placeholder/generic scans context-aware (mask HTML comments; mask fenced/inline code and quoted text in free prose) while still failing visible-prose claims and evidence-field placeholders. Add --help to pr-contract/agent-pr-ready/agent-close-preflight. Acceptance fixtures included, with the "still fails" cases. Refs #81 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Assert the --body-file reject test fails specifically with placeholder_text; it was reason-blind (any failure satisfied exit 1). - Add a blockquote-masking acceptance case so the maskCodeAndQuotes ">" branch is locked (only fenced/inline spans were covered before). Refs #81 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf64c6d8ee
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,14 @@ | |||
| ### Added | |||
There was a problem hiding this comment.
Add the required repo update log entry
This commit changes scripts and tests, so the repo-level AGENTS.md rule under “Repo update log” applies: code/config/behavior changes must append an entry to docs/repo-update-log.md before review. The diff adds a changelog fragment but no operational ledger entry, which leaves the PR failing the repo’s documented closeout/audit requirement; add the entry with issue/PR, branch, changed paths, verification, and propagation status.
Useful? React with 👍 / 👎.
Summary
--body-file <path|->(stdin) input mode toscripts/pr-contract.mjsso the same validator can run on a locally drafted body before a PR exists, not only against a remote PR viagh.--help/usage topr-contract.mjs,agent-pr-ready.mjs, andagent-close-preflight.mjs.This is the keystone slice (GW-A) of the closeout-contract repair: one validator, identical rules before and after PR creation. This PR's own body was drafted and validated locally with the new
--body-filemode before creation.Verification
vitest run scripts/pr-contract.test.mjs
node scripts/pr-contract.mjs --body-file - (drafted body, no PR)
Verification Notes
The full local suite was run with the repo's vitest binary; the only failing file is the pre-existing
doc-policy-lint.test.mjsparse error, which is independent of this change (it does not referencepr-contract). The new fixtures assert the strict cases (a leftover scaffolding marker in visible prose, an evidence-field marker, and a checkedtests passedclaim all still fail) alongside the relaxed cases (the template's own instructional HTML comment, a command cited in inline code, and a diagnostic quoted in a fenced block now pass).Docs / Changelog
.changelog/unreleased/81-pr-contract-body-file.mdrecords the added--body-filemode, the--helpoutput, and the context-aware parser change.Refs #81