feat: add pr create and comment (task 0010) #4
Reference in New Issue
Block a user
Delete Branch "task-0010-pr-create-and-comment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements
.claude/tasks/0010-pr-create-and-comment.md.What was built
pr createtakes--title(required),--body/--body-file,--base,--head,--assignee,--reviewer, repeatable name-resolved--label, and--milestone;--draftand--projectare excluded, as the spec says.An omitted
--headdefaults to the current local branch (git rev-parse --abbrev-ref HEAD), an omitted--baseto the repository's default branch.Before creating, an existing open PR for the same base/head pair short-circuits to
pull_request: { number, url, already: true }; a successful create emits the action blockcreated: { number, url }.pr comment <n>posts through the shared issue-comment endpoint and returns the created comment ascomment: { number, author, created, body }, truncated at 800 chars (ADR 0008).The comment block is now built in one place (
src/comment.ts) for bothissue commentandpr comment— ADR 0008 requires the two to stay identical, and it existed twice after the first draft.Deviations
--labelmust fail the same way whether or not the PR already exists; the other ordering saves one call but makes a typo fail on the first run and pass silently on the second.pr commentalso accepts--full— the shared truncation hint says "use--fullto see complete body", which would otherwise name a command that errors out. Same deviationissue commenttook in task 0004.pr commentisPR_NOT_FOUND, notISSUE_NOT_FOUND. PR comments go through/issues/{index}/comments, so the spec's path-based rule would report a missing PR as a missing issue; the table's own header is "HTTP status | Context | Error code", and the command knows its target.pr comment, notpr view, which does not exist until task 0009. Task 0009 should upgrade them.test/e2e/mutations.test.tsnow seeds a branch and asserts both the 404-when-absent and found-when-present cases against a live instance.Review
Overall: MEDIUM
pr.tsplus additive exports; the only existing-code edit isissue.tsmoving onto the extracted number parser, with messages unchanged.Unaddressed findings
prCreatemirrorsissueCreate's. It is a shape rather than logic, and collapsing it means a genericassignDefinedhelper; left for a third caller to justify.repoOnBranch/gitEnvintest/pr-create.test.tsoverlap withdetection.test.ts's private helpers, but deduping would drag that file's fake-teasandbox machinery intoharness.tsfor no gain here.withArticleinflags.ts. A vowel-regex article picker serving two nouns; kept because it lets call sites pass one plain noun and preserves the existing issue-side messages verbatim.findOpenPulltreats every 404 as "no such PR", including a 404 from a nonexistent repository. The subsequent POST still classifies asREPO_NOT_FOUND, so the cost is one wasted request, not a wrong error code.`pr create` takes --title (required), --body/--body-file, --base, --head, --assignee, --reviewer, repeatable name-resolved --label, and --milestone. An omitted --head defaults to the current local branch; an omitted --base to the repository's default branch. Before creating, an existing open PR for the same base/head pair short-circuits to `pull_request: { number, url, already: true }` rather than opening a duplicate; only an open PR does, since a closed one's branches are free to be proposed again. `pr comment <n>` posts through the shared issue-comment endpoint and returns the created comment as `comment: { number, author, created, body }` (ADR 0008), reporting a 404 as PR_NOT_FOUND since the caller asked about a pull request. That comment block is now built in one place (src/comment.ts) for both issue and pr comment, as ADR 0008 requires them to stay identical.