feat(mcp): add public-safe PR body drafting command#382
Open
web-dev0521 wants to merge 1 commit into
Open
Conversation
Adds gittensory_draft_pr_body, which turns local branch metadata into a copy/paste, maintainer-friendly PR body without leaking private scoreability. - src/services/pr-body-draft.ts: buildPublicPrBodyDraft composes the issue's sections (Summary, Changed files, Tests run, Linked issue, Duplicate/WIP check, Branch freshness, Next steps) from already-public-safe analysis slices. Missing tests produce a public-safe caveat; overlap is phrased as hygiene, not accusation. Every line passes through sanitizePublicComment plus a residual scrub of private/financial terms and local paths, and private scoring fields (score preview, scenario projections, risk signals, score-gate blockers, eligibility gate, ranked actions) are excluded by construction and documented in excludedPrivateFields. Output is metadata-only; sourceUploadDisabled is set. - src/mcp/server.ts: register gittensory_draft_pr_body; the tool returns the rendered markdown body (human-readable) and the structured draft (JSON), and reuses analyzeLocalBranch so source contents are never uploaded. - Tests: unit fixtures for clean branch, missing tests, duplicate risk, stale base, source-upload guard, private-field exclusion, and forbidden-language invariants; an integration tool-call asserts the tool stays public-safe. Global coverage stays above the gate (branches 97.04%, lines 99.66%, statements 99.08%, functions 98.42%); the new module is at 100% branch coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes: #98
gittensory_draft_pr_body, a public-safe PR body drafting command that turns local branch metadata into a copy/paste, maintainer-friendly PR description without leaking private scoreability context (feat(mcp): add public-safe PR body drafting command #98).What was added
src/services/pr-body-draft.ts—buildPublicPrBodyDraft(source)builds the sections the issue asks for: Summary, Changed files, Tests run, Linked issue, Duplicate / WIP check, Branch freshness, Next steps.sanitizePublicCommentplus a residual scrub of private/financial terms and local paths; private fields (private score preview,private scenario projections,private risk signals,private score-gate blockers,branch eligibility gate,private ranked next actions) are excluded and listed inexcludedPrivateFields.sourceUploadDisabled: trueis always set; the drafter reads metadata only.src/mcp/server.ts— registersgittensory_draft_pr_body(inputlocalBranchAnalysisShape). The tool returns the rendered markdown body as the human-readable summary and the structured draft as JSON, reusinganalyzeLocalBranchso source contents are never uploaded.test/unit/pr-body-draft.test.ts(clean branch, missing tests, duplicate risk, stale base, source-upload guard, private-field exclusion, forbidden-language invariants) plus an integration tool-call intest/integration/api.test.tsasserting the tool stays public-safe end-to-end.Scope
CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run typecheck— cleannpm run test:coveragelocally — 990 pass (1 skipped); branch 97.04%, lines 99.66%, statements 99.08%, functions 98.42% (new module at 100% branch coverage; the 3 pre-existing Windows-only spawn failuresmcp-cli,github-type-label,mcp-releasewere excluded locally and are unaffected)npm run actionlintnpm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
mcp-cli/mcp-release/type-labeltooling unrelated to this change.Safety
Notes
excludedPrivateFields, and the exclusion list itself is phrased without private/financial terms so it is safe to surface.analyzeLocalBranch, which takes structured git/GitHub metadata only (no file contents or diffs);sourceUploadDisabledis asserted and the output is checked to contain no local filesystem paths.toolResultreturns the rendered markdown PR body in the text content and the structured draft asstructuredContent, so agents can copy/paste or consume the JSON.src/services/pr-body-draft.tsis at 100% branch coverage; global coverage stays above the 97% gate on all four metrics.