pr-shepherd 0.34.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +3 -2
- package/.grok-plugin/marketplace.json +17 -0
- package/README.md +80 -43
- package/bin/api.d.mts +80 -0
- package/bin/api.mjs +236 -0
- package/bin/checks/classify.d.mts +41 -0
- package/bin/checks/startup-failures.d.mts +2 -0
- package/bin/checks/superseded.d.mts +21 -0
- package/bin/checks/triage.d.mts +4 -0
- package/bin/checks/triage.mjs +11 -3
- package/bin/classify/apply.d.mts +18 -0
- package/bin/classify/apply.mjs +4 -0
- package/bin/classify/loader.d.mts +10 -0
- package/bin/classify/types.d.mts +35 -0
- package/bin/cli/args.d.mts +18 -0
- package/bin/cli/args.mjs +1 -0
- package/bin/cli/clean-formatter.d.mts +2 -0
- package/bin/cli/default-poll.d.mts +2 -0
- package/bin/cli/default-poll.mjs +1 -0
- package/bin/cli/duration-flag.d.mts +2 -0
- package/bin/cli/duration.d.mts +13 -0
- package/bin/cli/fence.d.mts +1 -0
- package/bin/cli/fix-formatter-extra.d.mts +3 -0
- package/bin/cli/fix-formatter.d.mts +2 -0
- package/bin/cli/fix-formatter.mjs +6 -6
- package/bin/cli/formatters.d.mts +7 -0
- package/bin/cli/handlers.d.mts +4 -0
- package/bin/cli/handlers.mjs +11 -10
- package/bin/cli/help-command-pages.d.mts +231 -0
- package/bin/cli/help-command-pages.mjs +106 -1
- package/bin/cli/help-iterate-poll-pages.d.mts +4 -0
- package/bin/cli/help-iterate-poll-pages.mjs +14 -7
- package/bin/cli/help-log-file-page.d.mts +1 -0
- package/bin/cli/help-top-page.d.mts +1 -0
- package/bin/cli/help-top-page.mjs +16 -16
- package/bin/cli/help.d.mts +236 -0
- package/bin/cli/help.mjs +17 -0
- package/bin/cli/iterate-emitter.d.mts +8 -0
- package/bin/cli/iterate-flags.d.mts +11 -0
- package/bin/cli/iterate-formatter.d.mts +19 -0
- package/bin/cli/iterate-formatter.mjs +11 -2
- package/bin/cli/iterate-instructions.d.mts +6 -0
- package/bin/cli/iterate-lean.d.mts +12 -0
- package/bin/cli/iterate-lean.mjs +1 -0
- package/bin/cli/journal-formatter.d.mts +2 -0
- package/bin/cli/journal-formatter.mjs +15 -0
- package/bin/cli/journal-handler.d.mts +1 -0
- package/bin/cli/journal-handler.mjs +7 -20
- package/bin/cli/list-formatters.d.mts +76 -0
- package/bin/cli/list-formatters.mjs +9 -9
- package/bin/cli/mark-files-as-viewed-flags.d.mts +11 -0
- package/bin/cli/mark-files-as-viewed-formatter.d.mts +2 -0
- package/bin/cli/mutate-formatter.d.mts +2 -0
- package/bin/cli/poll-handler.d.mts +1 -0
- package/bin/cli/poll-handler.mjs +9 -2
- package/bin/cli/resolve-validators.d.mts +3 -0
- package/bin/cli/resolve-validators.mjs +3 -3
- package/bin/cli/runner.d.mts +7 -0
- package/bin/cli/suggestion-renderer.d.mts +3 -0
- package/bin/cli/validate-default-args.d.mts +6 -0
- package/bin/cli-parser.d.mts +2 -0
- package/bin/cli-parser.mjs +72 -16
- package/bin/commands/check-annotations.d.mts +5 -0
- package/bin/commands/check-status.d.mts +3 -0
- package/bin/commands/check-terminal-report.d.mts +5 -0
- package/bin/commands/check.d.mts +7 -0
- package/bin/commands/check.mjs +28 -23
- package/bin/commands/clean.d.mts +21 -0
- package/bin/commands/commit-suggestion-instruction.d.mts +8 -0
- package/bin/commands/commit-suggestion-instruction.mjs +3 -3
- package/bin/commands/commit-suggestion.d.mts +8 -0
- package/bin/commands/commit-suggestion.mjs +20 -13
- package/bin/commands/iterate/check-instructions.d.mts +16 -0
- package/bin/commands/iterate/check-instructions.mjs +3 -3
- package/bin/commands/iterate/classify.d.mts +18 -0
- package/bin/commands/iterate/classify.mjs +4 -4
- package/bin/commands/iterate/escalate.d.mts +31 -0
- package/bin/commands/iterate/escalate.mjs +7 -4
- package/bin/commands/iterate/fix-code.d.mts +25 -0
- package/bin/commands/iterate/fix-code.mjs +1 -1
- package/bin/commands/iterate/helpers.d.mts +14 -0
- package/bin/commands/iterate/helpers.mjs +19 -7
- package/bin/commands/iterate/index.d.mts +2 -0
- package/bin/commands/iterate/index.mjs +8 -12
- package/bin/commands/iterate/render.d.mts +5 -0
- package/bin/commands/iterate/render.mjs +8 -6
- package/bin/commands/iterate/reruns.d.mts +20 -0
- package/bin/commands/iterate/stall.d.mts +6 -0
- package/bin/commands/journal/index.d.mts +14 -0
- package/bin/commands/journal/index.mjs +1 -0
- package/bin/commands/journal/transform.d.mts +22 -0
- package/bin/commands/log-file.d.mts +5 -0
- package/bin/commands/mark-files-as-viewed.d.mts +26 -0
- package/bin/commands/mark-files-as-viewed.mjs +1 -0
- package/bin/commands/poll.d.mts +12 -0
- package/bin/commands/poll.mjs +52 -17
- package/bin/commands/ready-delay.d.mts +29 -0
- package/bin/commands/ready-delay.mjs +3 -13
- package/bin/commands/ready-mergeability.d.mts +15 -0
- package/bin/commands/resolve-mutate.d.mts +4 -0
- package/bin/commands/resolve-mutate.mjs +1 -0
- package/bin/commands/resolve.d.mts +4 -0
- package/bin/commands/shepherd-journal.d.mts +7 -0
- package/bin/commands/shepherd-journal.mjs +2 -2
- package/bin/comments/authors.d.mts +14 -0
- package/bin/comments/marker.d.mts +2 -0
- package/bin/comments/minimize-policy.d.mts +4 -0
- package/bin/comments/pending-ops.d.mts +15 -0
- package/bin/comments/rate-limit.d.mts +18 -0
- package/bin/comments/resolve.d.mts +34 -0
- package/bin/comments/resolve.mjs +1 -0
- package/bin/comments/review-thread-markers.d.mts +8 -0
- package/bin/comments/review-visibility.d.mts +28 -0
- package/bin/comments/sha-poll.d.mts +2 -0
- package/bin/comments/thread-visibility.d.mts +11 -0
- package/bin/comments/visible-comments.d.mts +11 -0
- package/bin/config/load.d.mts +60 -0
- package/bin/config/load.mjs +129 -16
- package/bin/config.json +0 -2
- package/bin/execution-context.d.mts +9 -0
- package/bin/execution-context.mjs +19 -0
- package/bin/exit-codes.d.mts +51 -0
- package/bin/github/activity.d.mts +3 -0
- package/bin/github/activity.mjs +7 -0
- package/bin/github/batch-page-helpers.d.mts +45 -0
- package/bin/github/batch-page-helpers.mjs +63 -0
- package/bin/github/batch-page.d.mts +14 -0
- package/bin/github/batch-page.mjs +62 -0
- package/bin/github/batch-parse-suites.d.mts +4 -0
- package/bin/github/batch-parse-suites.mjs +25 -0
- package/bin/github/batch-parser-helpers.d.mts +22 -0
- package/bin/github/batch-parsers-rules.d.mts +6 -0
- package/bin/github/batch-parsers-rules.mjs +122 -0
- package/bin/github/batch-parsers.d.mts +3 -0
- package/bin/github/batch-parsers.mjs +12 -0
- package/bin/github/batch-raw-rules.d.mts +59 -0
- package/bin/github/batch-raw-rules.mjs +1 -0
- package/bin/github/batch-raw-types.d.mts +216 -0
- package/bin/github/batch-response.d.mts +4 -0
- package/bin/github/batch.d.mts +24 -0
- package/bin/github/batch.mjs +14 -120
- package/bin/github/branch-protection.d.mts +3 -0
- package/bin/github/check-annotations.d.mts +2 -0
- package/bin/github/client.d.mts +46 -0
- package/bin/github/client.mjs +7 -2
- package/bin/github/errors.d.mts +25 -0
- package/bin/github/gql/batch-pr-page.gql +189 -0
- package/bin/github/gql/batch-pr.gql +79 -21
- package/bin/github/gql/commit-suggestion-thread.gql +40 -0
- package/bin/github/gql/review-thread-comments.gql +1 -0
- package/bin/github/graphql-http.d.mts +19 -0
- package/bin/github/graphql-response.d.mts +7 -0
- package/bin/github/http-auth.d.mts +4 -0
- package/bin/github/http-request.d.mts +7 -0
- package/bin/github/http-utils.d.mts +11 -0
- package/bin/github/http.d.mts +6 -0
- package/bin/github/http.mjs +2 -1
- package/bin/github/pagination.d.mts +46 -0
- package/bin/github/pagination.mjs +3 -2
- package/bin/github/queries.d.mts +28 -0
- package/bin/github/queries.mjs +4 -0
- package/bin/github/rest-http.d.mts +7 -0
- package/bin/github/rest-http.mjs +25 -86
- package/bin/github/rest-text.d.mts +1 -0
- package/bin/github/rest-text.mjs +88 -0
- package/bin/github/suggestion-thread.d.mts +9 -0
- package/bin/github/suggestion-thread.mjs +45 -0
- package/bin/github/thread-comments.d.mts +2 -0
- package/bin/github/thread-comments.mjs +12 -8
- package/bin/index.d.mts +10 -0
- package/bin/index.mjs +1 -1
- package/bin/log/log-file.d.mts +28 -0
- package/bin/log/session.d.mts +31 -0
- package/bin/log/setup.d.mts +6 -0
- package/bin/mcp/index.d.mts +5 -0
- package/bin/mcp/index.mjs +8 -0
- package/bin/mcp/server.d.mts +8 -0
- package/bin/mcp/server.mjs +157 -0
- package/bin/mcp-stdio.d.mts +2 -0
- package/bin/mcp-stdio.mjs +7 -0
- package/bin/merge-status/derive.d.mts +19 -0
- package/bin/merge-status/derive.mjs +2 -0
- package/bin/merge-status/requirements-format.d.mts +3 -0
- package/bin/merge-status/requirements-format.mjs +88 -0
- package/bin/merge-status/requirements.d.mts +2 -0
- package/bin/merge-status/requirements.mjs +51 -0
- package/bin/reporters/agent.d.mts +23 -0
- package/bin/reporters/agent.mjs +3 -0
- package/bin/state/base.d.mts +10 -0
- package/bin/state/base.mjs +23 -0
- package/bin/state/bot-cr-seen.d.mts +51 -0
- package/bin/state/bot-cr-seen.mjs +4 -14
- package/bin/state/fix-attempts.d.mts +27 -0
- package/bin/state/fix-attempts.mjs +3 -13
- package/bin/state/iterate-stall.d.mts +27 -0
- package/bin/state/iterate-stall.mjs +3 -13
- package/bin/state/seen-comments.d.mts +62 -0
- package/bin/state/seen-comments.mjs +6 -13
- package/bin/suggestions/extract.d.mts +8 -0
- package/bin/suggestions/parse.d.mts +48 -0
- package/bin/suggestions/patch.d.mts +14 -0
- package/bin/threads/transcript.d.mts +14 -0
- package/bin/threads/transcript.mjs +4 -0
- package/bin/types/activity.d.mts +30 -0
- package/bin/types/agent-thread.d.mts +9 -0
- package/bin/types/check-annotations.d.mts +14 -0
- package/bin/types/check-classification.d.mts +19 -0
- package/bin/types/github.d.mts +136 -0
- package/bin/types/iterate.d.mts +156 -0
- package/bin/types/merge-requirements.d.mts +82 -0
- package/bin/types/merge-requirements.mjs +2 -0
- package/bin/types/protected-run.d.mts +6 -0
- package/bin/types/report.d.mts +176 -0
- package/bin/types/review-thread.d.mts +12 -0
- package/bin/types.d.mts +10 -0
- package/bin/types.mjs +1 -0
- package/bin/util/markdown.d.mts +1 -0
- package/bin/util/path-segment.d.mts +4 -0
- package/bin/util/path-segment.mjs +2 -0
- package/bin/util/pool.d.mts +2 -0
- package/bin/util/pool.mjs +18 -0
- package/bin/util/sleep.d.mts +1 -0
- package/bin/util/worktree.d.mts +9 -0
- package/bin/util/worktree.mjs +4 -1
- package/package.json +51 -37
- package/plugins/pr-shepherd/.codex-plugin/plugin.json +3 -2
- package/plugins/pr-shepherd/.codex.mcp.json +8 -0
- package/plugins/pr-shepherd/.mcp.json +6 -0
- package/plugins/pr-shepherd/skills/mark-files-as-viewed/SKILL.md +5 -19
- package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +6 -15
- package/src/classify/types.mts +12 -0
package/bin/checks/triage.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
|
-
import {
|
|
2
|
+
import { restWithRateLimit, restText } from "../github/http.mjs";
|
|
3
3
|
const STARTUP_FAILURE_STATUS = "startup_failure";
|
|
4
4
|
const LOG_EXCERPT_CONTEXT_LINES = 16;
|
|
5
5
|
const LOG_EXCERPT_TAIL_LINES = 28;
|
|
@@ -43,10 +43,14 @@ async function fetchStartupFailureChecksUncached(repo, headSha, prNumber) {
|
|
|
43
43
|
const MAX_RUN_PAGES = 10;
|
|
44
44
|
const checks = [];
|
|
45
45
|
for (let page = 1; page <= MAX_RUN_PAGES; page++) {
|
|
46
|
-
const data = await
|
|
46
|
+
const { data, rateLimit } = await restWithRateLimit("GET", `/repos/${owner}/${name}/actions/runs?head_sha=${encodeURIComponent(headSha)}&status=${STARTUP_FAILURE_STATUS}&per_page=${perPage}&page=${page}`);
|
|
47
47
|
checks.push(...data.workflow_runs
|
|
48
48
|
.filter((run) => runBelongsToPr(run, prNumber, headSha))
|
|
49
49
|
.map(workflowRunToCheckRun));
|
|
50
|
+
if (rateLimit?.remaining === 0) {
|
|
51
|
+
process.stderr.write(`pr-shepherd: REST rate limit remaining is 0 while listing startup-failure runs for ${headSha} — detection may be incomplete\n`);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
50
54
|
if (data.workflow_runs.length < perPage)
|
|
51
55
|
break;
|
|
52
56
|
if (page === MAX_RUN_PAGES) {
|
|
@@ -91,8 +95,12 @@ async function fetchJobsUncached(runId, repo) {
|
|
|
91
95
|
process.stderr.write(`pr-shepherd: job pagination cap (${MAX_JOB_PAGES * 100} jobs) reached for run ${runId} — triage may be incomplete\n`);
|
|
92
96
|
break;
|
|
93
97
|
}
|
|
94
|
-
const data = await
|
|
98
|
+
const { data, rateLimit } = await restWithRateLimit("GET", `/repos/${owner}/${name}/actions/runs/${runId}/jobs?filter=latest&per_page=${perPage}&page=${page}`);
|
|
95
99
|
allJobs.push(...data.jobs);
|
|
100
|
+
if (rateLimit?.remaining === 0) {
|
|
101
|
+
process.stderr.write(`pr-shepherd: REST rate limit remaining is 0 while listing jobs for run ${runId} — triage may be incomplete\n`);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
96
104
|
if (data.jobs.length < perPage)
|
|
97
105
|
break;
|
|
98
106
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BatchPrData } from "../types.mts";
|
|
2
|
+
import type { LoadedRule } from "./loader.mts";
|
|
3
|
+
export interface ClassifyIndex {
|
|
4
|
+
suppressedIds: Set<string>;
|
|
5
|
+
autoResolveIds: Set<string>;
|
|
6
|
+
}
|
|
7
|
+
export interface BatchPartition {
|
|
8
|
+
suppressedCommentIds: Set<string>;
|
|
9
|
+
suppressedThreadIds: Set<string>;
|
|
10
|
+
suppressedReviewSummaryIds: Set<string>;
|
|
11
|
+
suppressedChangesRequestedIds: Set<string>;
|
|
12
|
+
ruleAutoResolveCommentIds: string[];
|
|
13
|
+
ruleAutoResolveThreadIds: string[];
|
|
14
|
+
/** COMMENTED review summary IDs — minimized without surfacing to the agent. */
|
|
15
|
+
ruleAutoResolveReviewSummaryIds: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare function buildClassifyIndex(rules: LoadedRule[], batch: BatchPrData): ClassifyIndex;
|
|
18
|
+
export declare function partitionBatch(index: ClassifyIndex, batch: BatchPrData): BatchPartition;
|
package/bin/classify/apply.mjs
CHANGED
|
@@ -26,6 +26,7 @@ function threadToItem(t) {
|
|
|
26
26
|
id: t.id,
|
|
27
27
|
author: t.author,
|
|
28
28
|
authorType: t.authorType,
|
|
29
|
+
...(t.authorAssociation !== undefined && { authorAssociation: t.authorAssociation }),
|
|
29
30
|
body: t.body,
|
|
30
31
|
url: t.url,
|
|
31
32
|
path: t.path,
|
|
@@ -37,6 +38,7 @@ function commentToItem(c) {
|
|
|
37
38
|
id: c.id,
|
|
38
39
|
author: c.author,
|
|
39
40
|
authorType: c.authorType,
|
|
41
|
+
...(c.authorAssociation !== undefined && { authorAssociation: c.authorAssociation }),
|
|
40
42
|
body: c.body,
|
|
41
43
|
url: c.url,
|
|
42
44
|
};
|
|
@@ -47,6 +49,7 @@ function reviewSummaryToItem(r) {
|
|
|
47
49
|
id: r.id,
|
|
48
50
|
author: r.author,
|
|
49
51
|
authorType: r.authorType,
|
|
52
|
+
...(r.authorAssociation !== undefined && { authorAssociation: r.authorAssociation }),
|
|
50
53
|
body: r.body,
|
|
51
54
|
};
|
|
52
55
|
}
|
|
@@ -56,6 +59,7 @@ function changesRequestedToItem(r) {
|
|
|
56
59
|
id: r.id,
|
|
57
60
|
author: r.author,
|
|
58
61
|
authorType: r.authorType,
|
|
62
|
+
...(r.authorAssociation !== undefined && { authorAssociation: r.authorAssociation }),
|
|
59
63
|
body: r.body,
|
|
60
64
|
};
|
|
61
65
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ClassifyRule } from "./types.mts";
|
|
2
|
+
export interface LoadedRule {
|
|
3
|
+
name: string;
|
|
4
|
+
file: string;
|
|
5
|
+
rule: ClassifyRule;
|
|
6
|
+
}
|
|
7
|
+
export declare function discoverRuleFiles(cwd: string): string[];
|
|
8
|
+
export declare function loadRules(files: string[]): Promise<LoadedRule[]>;
|
|
9
|
+
/** Reset the rule cache — for use in tests. */
|
|
10
|
+
export declare function _resetRuleCache(): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Raw relationship between a comment author and the repository, as reported by GitHub. */
|
|
2
|
+
export type CommentAuthorAssociation = "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "MEMBER" | "NONE" | "OWNER";
|
|
3
|
+
export type ClassifyItemKind = "review-thread" | "pr-comment" | "review-summary" | "changes-requested";
|
|
4
|
+
export interface ClassifyItemBase {
|
|
5
|
+
readonly kind: ClassifyItemKind;
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly author: string;
|
|
8
|
+
readonly authorType: "User" | "Bot" | "Unknown";
|
|
9
|
+
readonly authorAssociation?: CommentAuthorAssociation;
|
|
10
|
+
readonly body: string;
|
|
11
|
+
readonly url?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ClassifyReviewThread extends ClassifyItemBase {
|
|
14
|
+
readonly kind: "review-thread";
|
|
15
|
+
readonly path?: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface ClassifyPrComment extends ClassifyItemBase {
|
|
18
|
+
readonly kind: "pr-comment";
|
|
19
|
+
}
|
|
20
|
+
export interface ClassifyReviewSummary extends ClassifyItemBase {
|
|
21
|
+
readonly kind: "review-summary";
|
|
22
|
+
}
|
|
23
|
+
export interface ClassifyChangesRequested extends ClassifyItemBase {
|
|
24
|
+
readonly kind: "changes-requested";
|
|
25
|
+
}
|
|
26
|
+
export type ClassifyItem = ClassifyReviewThread | ClassifyPrComment | ClassifyReviewSummary | ClassifyChangesRequested;
|
|
27
|
+
export interface ClassifyAction {
|
|
28
|
+
/** When true, routes the item's ID to the appropriate resolve/minimize GitHub mutation. Not supported for changes-requested reviews. */
|
|
29
|
+
readonly autoResolve?: boolean;
|
|
30
|
+
/** When true, hides the item from agent output (seen marker is still written). */
|
|
31
|
+
readonly suppress?: boolean;
|
|
32
|
+
/** Optional note recorded to the debug log when this rule fires. */
|
|
33
|
+
readonly reason?: string;
|
|
34
|
+
}
|
|
35
|
+
export type ClassifyRule = (item: ClassifyItem) => ClassifyAction | null | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI argument-parsing helpers extracted from cli.mts for testability.
|
|
3
|
+
*/
|
|
4
|
+
import type { GlobalOptions } from "../types.mts";
|
|
5
|
+
export declare function parseIntStrict(value: string, flag: string): number;
|
|
6
|
+
interface ParsedArgs {
|
|
7
|
+
prNumber: number | undefined;
|
|
8
|
+
global: GlobalOptions;
|
|
9
|
+
extra: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function parseCommonArgs(args: string[]): ParsedArgs;
|
|
12
|
+
export declare function parsePrNumber(value: string): number | null;
|
|
13
|
+
/** Get the value of a flag like `--flag value` or `--flag=value`. */
|
|
14
|
+
export declare function getFlag(args: string[], name: string): string | null;
|
|
15
|
+
export declare function hasFlag(args: string[], name: string): boolean;
|
|
16
|
+
export declare function parseList(value: string | null): string[];
|
|
17
|
+
export declare function parseStatusPrNumbers(args: string[]): number[];
|
|
18
|
+
export {};
|
package/bin/cli/args.mjs
CHANGED
package/bin/cli/default-poll.mjs
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface SecondsDurationParts {
|
|
2
|
+
value: number;
|
|
3
|
+
unit: string;
|
|
4
|
+
}
|
|
5
|
+
export interface DurationParseOptions {
|
|
6
|
+
/** Unit assumed for a bare number with no suffix. Defaults to seconds. */
|
|
7
|
+
defaultUnit?: "s" | "m";
|
|
8
|
+
/** When true, 0 is accepted (used by flags where 0 means "disabled"). */
|
|
9
|
+
allowZero?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseSecondsDurationParts(s: string, opts?: DurationParseOptions): SecondsDurationParts | null;
|
|
12
|
+
export declare function parseDurationToSeconds(s: string, defaultSeconds: number, opts?: DurationParseOptions): number;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function safeFence(content: string): string;
|
|
@@ -15,7 +15,7 @@ export function formatFixCodeResult(header, result) {
|
|
|
15
15
|
const reviewMarker = t.reviewId ? ` [reviewId=${t.reviewId}]` : "";
|
|
16
16
|
const suggestionMarker = t.suggestion ? " [suggestion]" : "";
|
|
17
17
|
const editedMarker = t.edited ? " [edited since first look]" : "";
|
|
18
|
-
sections.push(`### ${heading} — ${loc} (${renderAuthor(t.author, t.authorType)})${reviewMarker}${suggestionMarker}${editedMarker}`);
|
|
18
|
+
sections.push(`### ${heading} — ${loc} (${renderAuthor(t.author, t.authorType, t.authorAssociation)})${reviewMarker}${suggestionMarker}${editedMarker}`);
|
|
19
19
|
sections.push(renderThreadConversation(t));
|
|
20
20
|
if (t.suggestion) {
|
|
21
21
|
sections.push(renderSuggestionBlock(t.suggestion, ""));
|
|
@@ -33,7 +33,7 @@ export function formatFixCodeResult(header, result) {
|
|
|
33
33
|
for (const c of result.fix.actionableComments) {
|
|
34
34
|
const heading = c.url ? `[commentId=${c.id}](${c.url})` : `\`commentId=${c.id}\``;
|
|
35
35
|
const editedMarker = c.edited ? " [edited since first look]" : "";
|
|
36
|
-
sections.push(`### ${heading} (${renderAuthor(c.author, c.authorType)})${editedMarker}`);
|
|
36
|
+
sections.push(`### ${heading} (${renderAuthor(c.author, c.authorType, c.authorAssociation)})${editedMarker}`);
|
|
37
37
|
sections.push(blockquote(c.body));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -83,14 +83,14 @@ export function formatFixCodeResult(header, result) {
|
|
|
83
83
|
if (result.fix.firstLookSummaries.length > 0) {
|
|
84
84
|
sections.push("## Review summaries (first look)");
|
|
85
85
|
for (const r of result.fix.firstLookSummaries) {
|
|
86
|
-
sections.push(`### \`reviewId=${r.id}\` (${renderAuthor(r.author, r.authorType)})`);
|
|
86
|
+
sections.push(`### \`reviewId=${r.id}\` (${renderAuthor(r.author, r.authorType, r.authorAssociation)})`);
|
|
87
87
|
sections.push(r.body.trim() === "" ? "(no review body)" : blockquote(r.body));
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
if (result.fix.editedSummaries.length > 0) {
|
|
91
91
|
sections.push("## Review summaries (edited since first look — already minimized; do not re-minimize)");
|
|
92
92
|
for (const r of result.fix.editedSummaries) {
|
|
93
|
-
sections.push(`### \`reviewId=${r.id}\` (${renderAuthor(r.author, r.authorType)})`);
|
|
93
|
+
sections.push(`### \`reviewId=${r.id}\` (${renderAuthor(r.author, r.authorType, r.authorAssociation)})`);
|
|
94
94
|
sections.push(r.body.trim() === "" ? "(no review body)" : blockquote(r.body));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -103,7 +103,7 @@ export function formatFixCodeResult(header, result) {
|
|
|
103
103
|
if (result.fix.surfacedApprovals.length > 0) {
|
|
104
104
|
sections.push("## Approvals (surfaced — not minimized)");
|
|
105
105
|
for (const r of result.fix.surfacedApprovals) {
|
|
106
|
-
sections.push(`### \`reviewId=${r.id}\` (${renderAuthor(r.author, r.authorType)})`);
|
|
106
|
+
sections.push(`### \`reviewId=${r.id}\` (${renderAuthor(r.author, r.authorType, r.authorAssociation)})`);
|
|
107
107
|
sections.push(r.body.trim() === "" ? "(no review body)" : blockquote(r.body));
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -129,7 +129,7 @@ export function formatFixCodeResult(header, result) {
|
|
|
129
129
|
if (result.fix.resolveOnlyCommand?.hasMutations)
|
|
130
130
|
postFixLines.push(`- resolve-only: \`${renderResolveCommand(result.fix.resolveOnlyCommand)}\``);
|
|
131
131
|
if (result.fix.resolveCommand.hasMutations) {
|
|
132
|
-
postFixLines.push(`-
|
|
132
|
+
postFixLines.push(`- apply review: \`${renderResolveCommand(result.fix.resolveCommand)}\``);
|
|
133
133
|
}
|
|
134
134
|
sections.push(postFixLines.join("\n"));
|
|
135
135
|
sections.push("## Instructions");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { formatIterateResult } from "./iterate-formatter.mts";
|
|
2
|
+
export { projectIterateLean, projectIterateVerbose } from "./iterate-lean.mts";
|
|
3
|
+
export { formatCleanResult } from "./clean-formatter.mts";
|
|
4
|
+
export { formatMarkFilesAsViewedResult } from "./mark-files-as-viewed-formatter.mts";
|
|
5
|
+
export { formatMutateResult } from "./mutate-formatter.mts";
|
|
6
|
+
import type { CommitSuggestionResult } from "../types.mts";
|
|
7
|
+
export declare function formatCommitSuggestionResult(result: CommitSuggestionResult): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function handleClean(args: string[], command?: "admin clean" | "clean"): Promise<void>;
|
|
2
|
+
export declare function handleCommitSuggestion(args: string[], command?: "build-suggestion-patch" | "commit-suggestion"): Promise<void>;
|
|
3
|
+
export declare function handleIterate(args: string[]): Promise<void>;
|
|
4
|
+
export declare function handleMarkFilesAsViewed(args: string[], command?: "apply files" | "mark-files-as-viewed"): Promise<void>;
|
package/bin/cli/handlers.mjs
CHANGED
|
@@ -11,10 +11,11 @@ import { parseIterateFlags } from "./iterate-flags.mjs";
|
|
|
11
11
|
import { emitIterateResult } from "./iterate-emitter.mjs";
|
|
12
12
|
import { parseMarkFilesAsViewedArgs } from "./mark-files-as-viewed-flags.mjs";
|
|
13
13
|
const CLEAN_VARIANTS = new Set(["pr", "branch", "current", "repo", "all"]);
|
|
14
|
-
export async function handleClean(args) {
|
|
14
|
+
export async function handleClean(args, command = "admin clean") {
|
|
15
|
+
const usage = command === "admin clean" ? USAGE["admin clean"] : USAGE.clean;
|
|
15
16
|
const variant = args[0];
|
|
16
17
|
if (!variant || !CLEAN_VARIANTS.has(variant)) {
|
|
17
|
-
process.stderr.write(`${
|
|
18
|
+
process.stderr.write(`${usage}\n`);
|
|
18
19
|
process.exitCode = EXIT.USAGE;
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
@@ -24,7 +25,7 @@ export async function handleClean(args) {
|
|
|
24
25
|
continue;
|
|
25
26
|
if (a === "--dry-run" || a === "--format" || a.startsWith("--format="))
|
|
26
27
|
continue;
|
|
27
|
-
process.stderr.write(`pr-shepherd:
|
|
28
|
+
process.stderr.write(`pr-shepherd: ${command}: unknown flag: "${a}"\n`);
|
|
28
29
|
process.exitCode = EXIT.USAGE;
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
@@ -38,7 +39,7 @@ export async function handleClean(args) {
|
|
|
38
39
|
formatValue = rest[fmtIdx + 1];
|
|
39
40
|
}
|
|
40
41
|
if (formatValue !== undefined && formatValue !== "text" && formatValue !== "json") {
|
|
41
|
-
process.stderr.write(`pr-shepherd:
|
|
42
|
+
process.stderr.write(`pr-shepherd: ${command}: invalid --format value: "${formatValue}". Expected "text" or "json".\n`);
|
|
42
43
|
process.exitCode = EXIT.USAGE;
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
@@ -52,24 +53,24 @@ export async function handleClean(args) {
|
|
|
52
53
|
}
|
|
53
54
|
const positionals = rest.filter((a, i) => !flagConsumedIndices.has(i) && !a.startsWith("--"));
|
|
54
55
|
if (positionals.length > 1) {
|
|
55
|
-
process.stderr.write(`pr-shepherd:
|
|
56
|
+
process.stderr.write(`pr-shepherd: ${command}: too many positional arguments (expected at most 1, got ${positionals.length})\n`);
|
|
56
57
|
process.exitCode = EXIT.USAGE;
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
59
60
|
const value = positionals[0];
|
|
60
61
|
const result = await runClean({ variant: variant, value, dryRun });
|
|
61
62
|
if (!result.ok) {
|
|
62
|
-
process.stderr.write(`pr-shepherd:
|
|
63
|
+
process.stderr.write(`pr-shepherd: ${command}: ${result.error}\n`);
|
|
63
64
|
process.exitCode = EXIT.SOFTWARE;
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
67
|
process.stdout.write(jsonOut ? `${JSON.stringify(result, null, 2)}\n` : `${formatCleanResult(result)}\n`);
|
|
67
68
|
}
|
|
68
|
-
export async function handleCommitSuggestion(args) {
|
|
69
|
+
export async function handleCommitSuggestion(args, command = "build-suggestion-patch") {
|
|
69
70
|
const { prNumber, global: globalOpts, extra } = parseCommonArgs(args);
|
|
70
71
|
const threadId = getFlag(extra, "--thread-id");
|
|
71
72
|
if (!threadId) {
|
|
72
|
-
process.stderr.write(`${USAGE[
|
|
73
|
+
process.stderr.write(`${USAGE[command]}\n`);
|
|
73
74
|
process.exitCode = EXIT.USAGE;
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
@@ -111,11 +112,11 @@ export async function handleIterate(args) {
|
|
|
111
112
|
readyDelaySuffix: flags.readyDelaySuffix ?? undefined,
|
|
112
113
|
});
|
|
113
114
|
}
|
|
114
|
-
export async function handleMarkFilesAsViewed(args) {
|
|
115
|
+
export async function handleMarkFilesAsViewed(args, command = "apply files") {
|
|
115
116
|
const { prNumber, global: globalOpts, extra } = parseCommonArgs(args);
|
|
116
117
|
const parsed = parseMarkFilesAsViewedArgs(extra);
|
|
117
118
|
if (!parsed.ok) {
|
|
118
|
-
process.stderr.write(`pr-shepherd:
|
|
119
|
+
process.stderr.write(`pr-shepherd: ${command}: ${parsed.error}\n`);
|
|
119
120
|
process.exitCode = EXIT.USAGE;
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
export declare const COMMAND_USAGE: {
|
|
2
|
+
readonly default: string;
|
|
3
|
+
readonly apply: `pr-shepherd apply
|
|
4
|
+
|
|
5
|
+
Apply a review mutation, mark changed files as viewed, or append a PR journal item.
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
pr-shepherd apply review [PR] [review-flags]
|
|
9
|
+
pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]
|
|
10
|
+
pr-shepherd apply journal [PR] <item> [--dry-run] [--format text|json]
|
|
11
|
+
pr-shepherd apply journal [PR] --file <path> [--dry-run] [--format text|json]
|
|
12
|
+
|
|
13
|
+
Run 'pr-shepherd apply <review|files|journal> --help' for command-specific details.
|
|
14
|
+
--help, -h Print this help and exit before GitHub I/O.`;
|
|
15
|
+
readonly "apply review": `pr-shepherd apply review
|
|
16
|
+
|
|
17
|
+
Apply GitHub review-state mutations after fixes.
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
pr-shepherd apply review [PR] --reply-thread-ids A,B --message MSG
|
|
21
|
+
pr-shepherd apply review [PR] --resolve-thread-ids A,B [--minimize-comment-ids X,Y]
|
|
22
|
+
[--dismiss-review-ids Q] [--message MSG]
|
|
23
|
+
[--require-sha SHA] [--format text|json]
|
|
24
|
+
|
|
25
|
+
Flags:
|
|
26
|
+
--resolve-thread-ids <ids> Comma-separated review thread IDs (PRRT_*) to resolve.
|
|
27
|
+
Human-authored thread IDs are skipped; use --reply-thread-ids.
|
|
28
|
+
--reply-thread-ids <ids> Comma-separated human review thread IDs to reply to.
|
|
29
|
+
--minimize-comment-ids <ids> Comma-separated issue/review comment IDs to minimize.
|
|
30
|
+
--dismiss-review-ids <ids> Comma-separated CHANGES_REQUESTED review IDs to dismiss.
|
|
31
|
+
--message <text> Reply/dismiss message. Required with reply or dismiss IDs.
|
|
32
|
+
--require-sha <sha> Wait for this full 40-character lowercase PR head SHA.
|
|
33
|
+
--format text|json Output format. Default: text.
|
|
34
|
+
|
|
35
|
+
At least one action flag is required.
|
|
36
|
+
--help, -h Print this help and exit before GitHub I/O.`;
|
|
37
|
+
readonly "apply files": `pr-shepherd apply files
|
|
38
|
+
|
|
39
|
+
Mark changed files as viewed in the GitHub pull request diff.
|
|
40
|
+
|
|
41
|
+
Usage:
|
|
42
|
+
pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]
|
|
43
|
+
[--format text|json]
|
|
44
|
+
|
|
45
|
+
Selectors:
|
|
46
|
+
files... Exact changed-file paths from the PR diff.
|
|
47
|
+
--tests Select changed test files.
|
|
48
|
+
--match <regex> Select changed files whose paths match a case-insensitive JavaScript regex.
|
|
49
|
+
May be repeated.
|
|
50
|
+
--help, -h Print this help and exit before GitHub I/O.`;
|
|
51
|
+
readonly "apply journal": `pr-shepherd apply journal
|
|
52
|
+
|
|
53
|
+
Append a list item to the ## Shepherd Journal section of a PR body.
|
|
54
|
+
|
|
55
|
+
Usage:
|
|
56
|
+
pr-shepherd apply journal [PR] <item> [--dry-run] [--format text|json]
|
|
57
|
+
pr-shepherd apply journal [PR] --file <path> [--dry-run] [--format text|json]
|
|
58
|
+
pr-shepherd apply journal [PR] --file - [--dry-run] [--format text|json]
|
|
59
|
+
|
|
60
|
+
PR may be a number or GitHub pull request URL. An item must start with '- ' followed by text.
|
|
61
|
+
Use --file to read an item from a file, or --file - to read it from stdin. Exactly one item source
|
|
62
|
+
is required. --dry-run previews the resulting body without writing it.
|
|
63
|
+
--help, -h Print this help and exit before GitHub I/O.`;
|
|
64
|
+
readonly "build-suggestion-patch": `pr-shepherd build-suggestion-patch
|
|
65
|
+
|
|
66
|
+
Build a patch and commit instructions for one GitHub review thread containing a suggestion block.
|
|
67
|
+
The command does not edit files or mutate git history.
|
|
68
|
+
|
|
69
|
+
Usage:
|
|
70
|
+
pr-shepherd build-suggestion-patch [PR] --thread-id ID --message MSG
|
|
71
|
+
[--description DESC] [--format text|json]
|
|
72
|
+
|
|
73
|
+
Flags:
|
|
74
|
+
--thread-id <id> Review thread containing exactly one suggestion block. Required.
|
|
75
|
+
--message <text> Suggested commit subject. Required and non-empty.
|
|
76
|
+
--description <text> Optional longer commit body.
|
|
77
|
+
--format text|json Output format. Default: text.
|
|
78
|
+
|
|
79
|
+
The current branch must match the PR head ref and local HEAD must match the PR head SHA.
|
|
80
|
+
--help, -h Print this help and exit before GitHub, git, config, or log I/O.`;
|
|
81
|
+
readonly admin: `pr-shepherd admin
|
|
82
|
+
|
|
83
|
+
Administrative state and diagnostics commands.
|
|
84
|
+
|
|
85
|
+
Usage:
|
|
86
|
+
pr-shepherd admin clean <pr|branch|current|repo|all> [value] [flags]
|
|
87
|
+
pr-shepherd admin log-file [--format text|json]
|
|
88
|
+
|
|
89
|
+
Run 'pr-shepherd admin <clean|log-file> --help' for command-specific details.
|
|
90
|
+
--help, -h Print this help and exit before any I/O.`;
|
|
91
|
+
readonly "admin clean": `pr-shepherd admin clean
|
|
92
|
+
|
|
93
|
+
Remove pr-shepherd state files from PR_SHEPHERD_STATE_DIR.
|
|
94
|
+
|
|
95
|
+
Usage:
|
|
96
|
+
pr-shepherd admin clean pr [number] [--dry-run] [--format text|json]
|
|
97
|
+
pr-shepherd admin clean branch [name] [--dry-run] [--format text|json]
|
|
98
|
+
pr-shepherd admin clean current [--dry-run] [--format text|json]
|
|
99
|
+
pr-shepherd admin clean repo [--dry-run] [--format text|json]
|
|
100
|
+
pr-shepherd admin clean all [--dry-run] [--format text|json]
|
|
101
|
+
|
|
102
|
+
Variants remove state for one PR, branch, current branch, repository, or all repositories.
|
|
103
|
+
Use --dry-run to preview paths without removing them.
|
|
104
|
+
--help, -h Print this help and exit before any cleanup.`;
|
|
105
|
+
readonly "admin log-file": string;
|
|
106
|
+
readonly resolve: `pr-shepherd resolve
|
|
107
|
+
|
|
108
|
+
Apply GitHub review-state mutations after fixes.
|
|
109
|
+
|
|
110
|
+
Usage:
|
|
111
|
+
pr-shepherd resolve [PR] --reply-thread-ids A,B --message MSG
|
|
112
|
+
pr-shepherd resolve [PR] --resolve-thread-ids A,B [--minimize-comment-ids X,Y]
|
|
113
|
+
[--dismiss-review-ids Q] [--message MSG]
|
|
114
|
+
[--require-sha SHA] [--format text|json]
|
|
115
|
+
|
|
116
|
+
Flags:
|
|
117
|
+
--resolve-thread-ids <ids> Comma-separated review thread IDs (PRRT_*) to resolve.
|
|
118
|
+
Human-authored thread IDs are skipped; use --reply-thread-ids.
|
|
119
|
+
Note: comment IDs (PRRC_*) from gh api are not thread IDs and will fail.
|
|
120
|
+
--reply-thread-ids <ids> Comma-separated human review thread IDs to reply to.
|
|
121
|
+
--minimize-comment-ids <ids> Comma-separated issue/review comment IDs to minimize.
|
|
122
|
+
--dismiss-review-ids <ids> Comma-separated CHANGES_REQUESTED review IDs to dismiss.
|
|
123
|
+
--message <text> Reply/dismiss message. Required with --reply-thread-ids
|
|
124
|
+
or --dismiss-review-ids.
|
|
125
|
+
--require-sha <sha> Wait until GitHub reports this PR head SHA before mutating.
|
|
126
|
+
Must be a full 40-character lowercase hex SHA. Use $(git rev-parse HEAD).
|
|
127
|
+
--format text|json Output format. Default: text.
|
|
128
|
+
--help, -h Print this help and exit before GitHub I/O.
|
|
129
|
+
|
|
130
|
+
At least one non-empty action flag is required:
|
|
131
|
+
--reply-thread-ids, --resolve-thread-ids, --minimize-comment-ids, or --dismiss-review-ids.
|
|
132
|
+
|
|
133
|
+
PR may be a number or GitHub pull request URL. When omitted, the current branch PR is inferred.
|
|
134
|
+
Exit code: 0 on success; nonzero on failure (sysexits.h — see docs/exit-codes.md).`;
|
|
135
|
+
readonly "commit-suggestion": `pr-shepherd commit-suggestion
|
|
136
|
+
|
|
137
|
+
Build a patch and commit instructions for one GitHub review thread containing a suggestion block.
|
|
138
|
+
The command does not edit files or mutate git history.
|
|
139
|
+
|
|
140
|
+
Usage:
|
|
141
|
+
pr-shepherd commit-suggestion [PR] --thread-id ID --message MSG
|
|
142
|
+
[--description DESC] [--format text|json]
|
|
143
|
+
|
|
144
|
+
Flags:
|
|
145
|
+
--thread-id <id> Review thread ID containing exactly one suggestion to apply. Required.
|
|
146
|
+
--message <text> Suggested commit subject. Required and must be non-empty.
|
|
147
|
+
--description <text> Optional longer commit body.
|
|
148
|
+
--format text|json Output format. Default: text.
|
|
149
|
+
--help, -h Print this help and exit before GitHub, git, config, or log I/O.
|
|
150
|
+
|
|
151
|
+
Preconditions:
|
|
152
|
+
The current branch must match the PR head ref, and local HEAD must match the PR head SHA.
|
|
153
|
+
|
|
154
|
+
Exit codes:
|
|
155
|
+
0 suggestion patch and instructions produced
|
|
156
|
+
64 usage error (missing/invalid flag)
|
|
157
|
+
69 precondition unmet (thread ineligible, branch/SHA mismatch, no open PR)
|
|
158
|
+
See docs/exit-codes.md for the full sysexits.h table.`;
|
|
159
|
+
readonly "mark-files-as-viewed": `pr-shepherd mark-files-as-viewed
|
|
160
|
+
|
|
161
|
+
Mark changed files as viewed in the GitHub pull request diff.
|
|
162
|
+
|
|
163
|
+
Usage:
|
|
164
|
+
pr-shepherd mark-files-as-viewed [PR] [files...] [--tests] [--match REGEX]
|
|
165
|
+
[--format text|json]
|
|
166
|
+
|
|
167
|
+
Selectors:
|
|
168
|
+
files... Exact changed-file paths from the PR diff.
|
|
169
|
+
--tests Select changed test files.
|
|
170
|
+
--match <regex> Select changed files whose paths match a case-insensitive JavaScript regex.
|
|
171
|
+
May be repeated.
|
|
172
|
+
|
|
173
|
+
Flags:
|
|
174
|
+
--format text|json Output format. Default: text.
|
|
175
|
+
--help, -h Print this help and exit before GitHub I/O.
|
|
176
|
+
|
|
177
|
+
PR may be a number or GitHub pull request URL. When omitted, the current branch PR is inferred.
|
|
178
|
+
Exit code: 0 on success; nonzero on failure (sysexits.h — see docs/exit-codes.md).`;
|
|
179
|
+
readonly iterate: "pr-shepherd iterate\n\nRun one iterate tick for a pull request. The no-subcommand form polls; use this subcommand for a single tick.\nThe output contains one action and an action-specific ## Instructions section.\n\nUsage:\n pr-shepherd iterate [PR] [iterate-flags]\n\nIterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Do not convert draft PRs to ready for review.\n --no-auto-cancel-actionable Do not cancel in-progress runs before actionable fixes.\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include verbose iterate fields.\n --help, -h Print this help and exit before GitHub, git, config, or log I/O.\n\nDurations accept s/m/h suffixes: 30s, 4.5m, 1h. A bare number is minutes; decimals are allowed only with an explicit unit (4.5m).\n\nActions:\n WAIT No immediate code action; run another iterate tick later.\n MARK_READY Draft PR was marked ready for review.\n FIX_CODE Apply fixes, commit, push, and run the printed apply command.\n CANCEL Terminal state: merged/closed or ready-delay elapsed.\n ESCALATE Terminal state requiring human direction.\n\nExit codes:\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
180
|
+
readonly poll: "pr-shepherd poll\n\nRun iterate repeatedly for WAIT ticks and during the FIX_CODE debounce window. Print only the\nfinal tick to stdout.\nPoll exits as soon as iterate returns MARK_READY, CANCEL, or ESCALATE, or when timeout\nreturns the last WAIT result. FIX_CODE starts a --debounce settle window (default 1m): poll keeps\niterating at --interval, then runs one more tick after the window and returns that result.\nWith --until-terminal, poll also continues through MARK_READY.\n\nUsage:\n pr-shepherd poll [PR] [poll-flags] [iterate-flags]\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: 60s.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: 4.5m.\n --debounce <duration> Settle window after first FIX_CODE before returning. Bare number = seconds. Default: 60s. 0 disables.\n --quiet-status During WAIT polling, print only changed status snapshots.\n --until-terminal Continue through WAIT/MARK_READY until FIX_CODE/CANCEL/ESCALATE.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Do not convert draft PRs to ready for review.\n --no-auto-cancel-actionable Do not cancel in-progress runs before actionable fixes.\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include verbose iterate fields and detailed per-tick lines.\n --help, -h Print this help and exit before GitHub, git, config, or log I/O.\n\nDurations accept s/m/h suffixes: 30s, 4.5m, 1h. A bare number uses each flag's default unit (seconds\nfor --interval/--timeout/--debounce, minutes for --ready-delay/--stall-timeout); decimals are allowed only with\nan explicit unit (4.5m).\nEach WAIT tick writes a single dot to stderr by default; --quiet-status prints only changed WAIT snapshots, and --verbose emits detailed per-tick lines.\nFIX_CODE debounce writes a remaining-seconds line to stderr. --timeout does not cut an in-flight debounce short.\nWith --until-terminal, --timeout is ignored for WAIT ticks and polling continues until FIX_CODE, CANCEL, or ESCALATE.\n\nExit codes: same as iterate (the final tick's action/reason decides the code).\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT (including a WAIT returned by --timeout)\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
181
|
+
readonly clean: `pr-shepherd clean
|
|
182
|
+
|
|
183
|
+
Remove pr-shepherd state files from PR_SHEPHERD_STATE_DIR.
|
|
184
|
+
|
|
185
|
+
Usage:
|
|
186
|
+
pr-shepherd clean pr [number] [--dry-run] [--format text|json]
|
|
187
|
+
pr-shepherd clean branch [name] [--dry-run] [--format text|json]
|
|
188
|
+
pr-shepherd clean current [--dry-run] [--format text|json]
|
|
189
|
+
pr-shepherd clean repo [--dry-run] [--format text|json]
|
|
190
|
+
pr-shepherd clean all [--dry-run] [--format text|json]
|
|
191
|
+
|
|
192
|
+
Variants:
|
|
193
|
+
pr [number] Remove state for one PR. Defaults to current branch PR.
|
|
194
|
+
branch [name] Resolve a branch to its open PR, then remove that PR's state.
|
|
195
|
+
Defaults to current branch.
|
|
196
|
+
current Alias for branch against the current branch.
|
|
197
|
+
repo Remove all state for the current repository, including worktree logs.
|
|
198
|
+
all Remove all pr-shepherd state.
|
|
199
|
+
|
|
200
|
+
Flags:
|
|
201
|
+
--dry-run Preview paths without removing them.
|
|
202
|
+
--format text|json Output format. Default: text.
|
|
203
|
+
--help, -h Print this help and exit before any cleanup.
|
|
204
|
+
|
|
205
|
+
Exit code: 0 on success (including a no-op --dry-run on a nonexistent target); nonzero on failure (sysexits.h — see docs/exit-codes.md).`;
|
|
206
|
+
readonly journal: `pr-shepherd journal
|
|
207
|
+
|
|
208
|
+
Append a list item to the ## Shepherd Journal section of a PR body.
|
|
209
|
+
Creates the section at the end if absent. Idempotent — duplicate items are skipped.
|
|
210
|
+
|
|
211
|
+
Usage:
|
|
212
|
+
pr-shepherd journal [PR] <item> [--dry-run] [--format text|json]
|
|
213
|
+
pr-shepherd journal [PR] --file <path> [--dry-run] [--format text|json]
|
|
214
|
+
pr-shepherd journal [PR] --file - [--dry-run] [--format text|json]
|
|
215
|
+
|
|
216
|
+
PR PR number or GitHub pull request URL. Defaults to current branch PR.
|
|
217
|
+
item Markdown list item: must start with "- " followed by non-whitespace text.
|
|
218
|
+
Example: '- Rejected suggestion: kept existing pattern for consistency.'
|
|
219
|
+
Provide it as a positional argument, or via --file to avoid shell-escaping
|
|
220
|
+
backticks and multi-line Markdown. Exactly one of the two is required.
|
|
221
|
+
|
|
222
|
+
Flags:
|
|
223
|
+
--file <path> Read the entry from a file instead of a positional argument.
|
|
224
|
+
Pass --file - to read from stdin.
|
|
225
|
+
--dry-run Preview the new PR body without writing it to GitHub.
|
|
226
|
+
--format text|json Output format. Default: text.
|
|
227
|
+
--help, -h Print this help and exit before any GitHub I/O.
|
|
228
|
+
|
|
229
|
+
Exit code: 0 on success (including no-change no-op); nonzero on failure (sysexits.h — see docs/exit-codes.md).`;
|
|
230
|
+
readonly "log-file": "pr-shepherd log-file\n\nPrint the per-worktree append-only debug log path for the current repository.\nThe log is created by the first non-help pr-shepherd command that initializes logging.\n\nUsage:\n pr-shepherd log-file [--format text|json]\n\nFlags:\n --format text|json Print a raw path or {\"path\": \"...\"} JSON. Default: text.\n --help, -h Print this help and exit before logging setup.\n\nEnvironment:\n PR_SHEPHERD_LOG_DISABLED=1 disables logging.\n PR_SHEPHERD_STATE_DIR overrides the base state directory.\n\nExit code: 0 on success; 1 if repository identity cannot be resolved.";
|
|
231
|
+
};
|