feat: add pr create and comment (task 0010)
All checks were successful
CI / test (pull_request) Successful in 30s
CI / test (push) Successful in 29s

`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.
This commit was merged in pull request #4.
This commit is contained in:
2026-07-11 21:03:40 -04:00
parent f82414a933
commit 590691fc96
13 changed files with 1151 additions and 69 deletions

View File

@@ -1,6 +1,7 @@
import { readFileSync } from "node:fs";
import { exitCodeForError, runAxiCli, AxiError } from "axi-sdk-js";
import { issueCommand } from "./commands/issue.js";
import { prCommand } from "./commands/pr.js";
import { resolveRepoContext } from "./context.js";
import type { CliDeps, GlobalFlags } from "./deps.js";
import { consumeFlagValue, splitFlag } from "./flags.js";
@@ -16,6 +17,8 @@ commands:
issue view Show a single issue's details
issue create Create an issue
issue comment Post a comment on an issue or pull request
pr create Create a pull request
pr comment Post a comment on a pull request
global flags:
-R, --repo <OWNER/NAME> Override the repository detected from the git origin remote
@@ -111,6 +114,7 @@ export async function runCli(options: RunCliOptions): Promise<number> {
topLevelHelp: TOP_LEVEL_HELP,
commands: {
issue: issueCommand(deps),
pr: prCommand(deps),
},
home: homeCommand(deps),
stdout: options.stdout,