pr-shepherd 0.56.0 → 0.56.2
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 +1 -1
- package/README.md +7 -4
- package/bin/api.d.mts +11 -1
- package/bin/api.mjs +25 -0
- package/bin/cli/args.mjs +3 -0
- package/bin/cli/fix-formatter.mjs +3 -0
- package/bin/cli/help-command-pages.d.mts +17 -2
- package/bin/cli/help-command-pages.mjs +16 -1
- package/bin/cli/help-iterate-poll-pages.d.mts +1 -1
- package/bin/cli/help-iterate-poll-pages.mjs +1 -1
- package/bin/cli/help-top-page.d.mts +1 -1
- package/bin/cli/help-top-page.mjs +2 -0
- package/bin/cli/help.d.mts +18 -3
- package/bin/cli/help.mjs +2 -0
- package/bin/cli/iterate-instructions.mjs +4 -1
- package/bin/cli/iterate-lean.mjs +3 -0
- package/bin/cli/iterate-merge-formatter.mjs +2 -0
- package/bin/cli/queue-removal-handler.d.mts +2 -0
- package/bin/cli/queue-removal-handler.mjs +86 -0
- package/bin/cli-parser.mjs +4 -0
- package/bin/commands/apply-queue-removal.d.mts +18 -0
- package/bin/commands/apply-queue-removal.mjs +44 -0
- package/bin/commands/check-fingerprint.mjs +2 -0
- package/bin/commands/check.mjs +13 -1
- package/bin/commands/iterate/check-evidence.d.mts +4 -0
- package/bin/commands/iterate/check-evidence.mjs +8 -0
- package/bin/commands/iterate/fix-code.mjs +20 -4
- package/bin/commands/iterate/index.mjs +15 -1
- package/bin/commands/iterate/merge-state.mjs +4 -1
- package/bin/commands/iterate/merge.d.mts +7 -1
- package/bin/commands/iterate/merge.mjs +59 -1
- package/bin/github/poll-summary-fingerprint.mjs +7 -0
- package/bin/github/poll-summary-mergeability.d.mts +11 -0
- package/bin/github/poll-summary-mergeability.mjs +23 -0
- package/bin/github/poll-summary-readiness.mjs +11 -1
- package/bin/github/poll-summary.mjs +7 -2
- package/bin/mcp/server.mjs +18 -0
- package/bin/state/queue-removal-ack.d.mts +19 -0
- package/bin/state/queue-removal-ack.mjs +66 -0
- package/bin/types/iterate.d.mts +4 -0
- package/bin/types/merge-queue.d.mts +2 -0
- package/package.json +1 -1
- package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/.codex.mcp.json +1 -1
- package/plugins/pr-shepherd/.mcp.json +1 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +3 -2
- package/plugins/pr-shepherd/skills/pr-shepherd/references/ci-failure-triage.md +1 -0
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ Each tick returns exactly one action:
|
|
|
35
35
|
- `MARK_READY` — the CLI converted an eligible draft PR to ready; continue polling.
|
|
36
36
|
- `FIX_CODE` — agent work is required; complete it, push when needed, then continue polling. Push access to the PR head branch is a usage precondition.
|
|
37
37
|
- `MERGE` — run the emitted head-pinned auto-merge or queue command. Ordinary merges include a plain-merge fallback; queue merges include a GraphQL enqueue fallback. GitHub is authoritative for the result and reports any authorization failure.
|
|
38
|
-
- `CANCEL` — stop polling because
|
|
38
|
+
- `CANCEL` — stop polling this pull request because it merged, closed, or completed its ready-delay. Continue any remaining pull requests or issues from the original request.
|
|
39
39
|
- `ESCALATE` — stop polling until a human provides direction. Native stacks reach this only after their autonomous one-PR sessions are exhausted.
|
|
40
40
|
|
|
41
41
|
Native-stack summaries additionally use stack-level `SHEPHERD`: run the listed one-PR sessions,
|
|
@@ -122,7 +122,7 @@ Grok:
|
|
|
122
122
|
/pr-shepherd 42
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
MCP clients call `iterate` once per tick, then use `apply` for review/file/journal mutations and `build_suggestion_patches` for anchored suggestions. To read journal entries, call `extract_journal` with a body already in hand or `get_journal` with a repository-qualified PR reference. `iterate` returns the same structured action data as the CLI, including its review mutation arguments. The client owns recurrence, so this works consistently in Codex, Claude Code, Grok, and any other stdio MCP client.
|
|
125
|
+
MCP clients call `iterate` once per tick, then use `apply` for review/file/journal mutations and validated queue-removal acknowledgments and `build_suggestion_patches` for anchored suggestions. To read journal entries, call `extract_journal` with a body already in hand or `get_journal` with a repository-qualified PR reference. `iterate` returns the same structured action data as the CLI, including its review mutation arguments. The client owns recurrence, so this works consistently in Codex, Claude Code, Grok, and any other stdio MCP client.
|
|
126
126
|
|
|
127
127
|
The CLI remains useful for shell workflows. Its canonical polling form is:
|
|
128
128
|
|
|
@@ -141,6 +141,9 @@ pr-shepherd 42 43 44 # summarize an explicit same-repository s
|
|
|
141
141
|
pr-shepherd --stack 43 # summarize every PR in a native GitHub stack
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
+
A user-supplied `--merge` authorizes the agent to run the emitted merge/enqueue commands for the
|
|
145
|
+
selected PRs or stack without another conversational confirmation. Host permission checks still apply.
|
|
146
|
+
|
|
144
147
|
Multi-PR and `--stack` polling use compact, read-only GraphQL summaries. They return when work is
|
|
145
148
|
needed, every selected PR is complete, the bounded timeout expires, or `--until-terminal` crosses a
|
|
146
149
|
configured GraphQL quota-warning band. Explicit PR sets give each actionable row an exact single-PR
|
|
@@ -161,7 +164,7 @@ receipts, and whose bottom open layer GitHub has retargeted onto the stack base,
|
|
|
161
164
|
with `gh stack merge <that PR number> --yes` and the allowed method flag (`--squash` unless config or the repository selects another). That lands the named layer and every
|
|
162
165
|
unmerged layer below it. When the base uses a merge queue, the same command queues the prefix
|
|
163
166
|
together and GitHub evaluates each layer from the bottom; a failure ejects that layer and those
|
|
164
|
-
above it. Layers above the prefix keep their one-PR sessions. After the merge, GitHub retargets
|
|
167
|
+
above it. If the evidence shows an unrelated failure and no source changes or other blockers remain, the one-PR session emits a head-, queue-commit-, and timestamp-pinned local acknowledgment command. Fresh source checks and a new READY receipt then let the aggregate selector recover the eligible prefix. Manual or stale removals cannot use this path. Layers above the prefix keep their one-PR sessions. After the merge, GitHub retargets
|
|
165
168
|
the next layer, so the rerun continues until the stack returns `CANCEL`. API and MCP aggregate
|
|
166
169
|
calls perform one summary tick and leave recurrence to the caller.
|
|
167
170
|
|
|
@@ -169,7 +172,7 @@ Polling defaults can be set under `poll` in `.pr-shepherdrc.yml`: `intervalSecon
|
|
|
169
172
|
|
|
170
173
|
### Apply Review And Journal Changes, Or Select Files
|
|
171
174
|
|
|
172
|
-
Use `apply` with ordered operations to reply/resolve/minimize/dismiss review items, mark selected changed files as viewed,
|
|
175
|
+
Use `apply` with ordered operations to reply/resolve/minimize/dismiss review items, mark selected changed files as viewed, append an idempotent Shepherd Journal item, or record a validated native-stack CI queue-removal acknowledgment. Explicit operations are attempted and surface GitHub's per-operation results; generated iterate guidance remains capability-filtered. Use `build_suggestion_patches` to turn ordered review suggestions into checked patches and commit metadata; it never changes the worktree or git history.
|
|
173
176
|
|
|
174
177
|
### Extract Shepherd Journal Entries
|
|
175
178
|
|
package/bin/api.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type JournalResult } from "./commands/journal/index.mts";
|
|
2
2
|
import { type MarkFilesAsViewedResult } from "./commands/mark-files-as-viewed.mts";
|
|
3
|
+
import { type ApplyQueueRemovalResult } from "./commands/apply-queue-removal.mts";
|
|
3
4
|
import type { ResolveResult } from "./comments/resolve.mts";
|
|
4
5
|
import type { BuildSuggestionPatchesResult, CommitSuggestionResult, IterateCommandOptions, IterateResult, PollSummaryResult } from "./types.mts";
|
|
5
6
|
import { type ShepherdJournalExtraction } from "./journal/index.mts";
|
|
@@ -47,8 +48,14 @@ export interface AppendJournalOperation {
|
|
|
47
48
|
item: string;
|
|
48
49
|
dryRun?: boolean;
|
|
49
50
|
}
|
|
51
|
+
export interface AcknowledgeQueueRemovalOperation {
|
|
52
|
+
type: "acknowledge_queue_removal";
|
|
53
|
+
requireSha: string;
|
|
54
|
+
queueCommitOid: string;
|
|
55
|
+
removedAtUnix: number;
|
|
56
|
+
}
|
|
50
57
|
/** Operations run in this exact list order after validation. */
|
|
51
|
-
export type ApplyOperation = ReviewMutationsOperation | MarkFilesViewedOperation | AppendJournalOperation;
|
|
58
|
+
export type ApplyOperation = ReviewMutationsOperation | MarkFilesViewedOperation | AppendJournalOperation | AcknowledgeQueueRemovalOperation;
|
|
52
59
|
export interface ApplyInput {
|
|
53
60
|
/** PR shared by every operation in this ordered apply request. */
|
|
54
61
|
pr?: PrReference;
|
|
@@ -63,6 +70,9 @@ export type ApplyOperationResult = {
|
|
|
63
70
|
} | {
|
|
64
71
|
type: "append_journal";
|
|
65
72
|
result: JournalResult;
|
|
73
|
+
} | {
|
|
74
|
+
type: "acknowledge_queue_removal";
|
|
75
|
+
result: ApplyQueueRemovalResult;
|
|
66
76
|
};
|
|
67
77
|
export interface ApplyResult {
|
|
68
78
|
operations: ApplyOperationResult[];
|
package/bin/api.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { runJournal } from "./commands/journal/index.mjs";
|
|
|
8
8
|
import { validateJournalItem } from "./commands/journal/transform.mjs";
|
|
9
9
|
import { runMarkFilesAsViewed, } from "./commands/mark-files-as-viewed.mjs";
|
|
10
10
|
import { runResolveMutate } from "./commands/resolve-mutate.mjs";
|
|
11
|
+
import { applyQueueRemovalAck, } from "./commands/apply-queue-removal.mjs";
|
|
11
12
|
import { runWithExecutionCwd } from "./execution-context.mjs";
|
|
12
13
|
import { parsePrReference, normalizeRepositoryIdentity, resolveParsedPrTarget, } from "./pr-reference.mjs";
|
|
13
14
|
import { getPullRequestBody, getRepoInfo } from "./github/client.mjs";
|
|
@@ -104,6 +105,17 @@ export function createPrShepherd(options = {}) {
|
|
|
104
105
|
results.push({ type: operation.type, result });
|
|
105
106
|
break;
|
|
106
107
|
}
|
|
108
|
+
case "acknowledge_queue_removal": {
|
|
109
|
+
const result = await applyQueueRemovalAck({
|
|
110
|
+
prNumber,
|
|
111
|
+
targetRepository,
|
|
112
|
+
headSha: operation.requireSha,
|
|
113
|
+
queueCommitOid: operation.queueCommitOid,
|
|
114
|
+
removedAtUnix: operation.removedAtUnix,
|
|
115
|
+
});
|
|
116
|
+
results.push({ type: operation.type, result });
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
107
119
|
}
|
|
108
120
|
}
|
|
109
121
|
catch (error) {
|
|
@@ -206,6 +218,19 @@ function validateOperation(operation) {
|
|
|
206
218
|
throw new PrShepherdValidationError(validation.error);
|
|
207
219
|
}
|
|
208
220
|
return;
|
|
221
|
+
case "acknowledge_queue_removal":
|
|
222
|
+
if (typeof operation.requireSha !== "string" ||
|
|
223
|
+
!/^[0-9a-f]{40}$/.test(operation.requireSha)) {
|
|
224
|
+
throw new PrShepherdValidationError("acknowledge_queue_removal.requireSha must be a full 40-character lowercase hex SHA");
|
|
225
|
+
}
|
|
226
|
+
if (typeof operation.queueCommitOid !== "string" ||
|
|
227
|
+
!/^[0-9a-f]{40}$/.test(operation.queueCommitOid)) {
|
|
228
|
+
throw new PrShepherdValidationError("acknowledge_queue_removal.queueCommitOid must be a full 40-character lowercase hex SHA");
|
|
229
|
+
}
|
|
230
|
+
if (!Number.isSafeInteger(operation.removedAtUnix) || operation.removedAtUnix <= 0) {
|
|
231
|
+
throw new PrShepherdValidationError("acknowledge_queue_removal.removedAtUnix must be a positive Unix timestamp in seconds");
|
|
232
|
+
}
|
|
233
|
+
return;
|
|
209
234
|
default:
|
|
210
235
|
throw new PrShepherdValidationError(`Unsupported apply operation: ${JSON.stringify(operation.type)}`);
|
|
211
236
|
}
|
package/bin/cli/args.mjs
CHANGED
|
@@ -23,6 +23,9 @@ const FLAGS_WITH_VALUES = new Set([
|
|
|
23
23
|
"--match",
|
|
24
24
|
"--check",
|
|
25
25
|
"--blocked-by",
|
|
26
|
+
"--require-sha",
|
|
27
|
+
"--queue-commit",
|
|
28
|
+
"--removed-at",
|
|
26
29
|
]);
|
|
27
30
|
// Boolean flags that do NOT consume the next argument. Any --flag not in this
|
|
28
31
|
// set and not in FLAGS_WITH_VALUES is treated conservatively as value-taking
|
|
@@ -191,6 +191,9 @@ export function formatFixCodeResult(header, result, opts = {}) {
|
|
|
191
191
|
postFixLines.push(`- requeue API fallback: ${inlineCode(renderMergeCommand(result.fix.requeue.queueApiFallbackCommand))}`);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
+
if (result.fix.queueRemovalAcknowledgment) {
|
|
195
|
+
postFixLines.push(`- acknowledge queue removal: ${inlineCode(renderMergeCommand(result.fix.queueRemovalAcknowledgment))}`);
|
|
196
|
+
}
|
|
194
197
|
sections.push(postFixLines.join("\n"));
|
|
195
198
|
sections.push("## Instructions");
|
|
196
199
|
sections.push(numberInstructions(result.fix.instructions));
|
|
@@ -11,8 +11,9 @@ Usage:
|
|
|
11
11
|
pr-shepherd apply journal [PR] --file <path> [--dry-run] [--format text|json]
|
|
12
12
|
pr-shepherd apply check-blocker [PR] --check <name> --blocked-by <ref>
|
|
13
13
|
pr-shepherd apply check-blocker [PR] --check <name> --clear
|
|
14
|
+
pr-shepherd apply queue-removal [PR] --require-sha <head> --queue-commit <commit> --removed-at <unix>
|
|
14
15
|
|
|
15
|
-
Run 'pr-shepherd apply <review|files|journal|check-blocker> --help' for command-specific details.
|
|
16
|
+
Run 'pr-shepherd apply <review|files|journal|check-blocker|queue-removal> --help' for command-specific details.
|
|
16
17
|
--help, -h Print this help and exit before GitHub I/O.`;
|
|
17
18
|
readonly "apply review": `pr-shepherd apply review
|
|
18
19
|
|
|
@@ -80,6 +81,20 @@ Usage:
|
|
|
80
81
|
|
|
81
82
|
\`--clear\` removes that check's record and leaves other checks alone.
|
|
82
83
|
--help, -h Print this help and exit before any I/O.`;
|
|
84
|
+
readonly "apply queue-removal": `pr-shepherd apply queue-removal
|
|
85
|
+
|
|
86
|
+
Acknowledge one current CI-driven merge-queue removal for a native-stack PR.
|
|
87
|
+
This writes local state only after a fresh GitHub read confirms the supplied head,
|
|
88
|
+
queue commit, and removal timestamp still identify the current removal.
|
|
89
|
+
|
|
90
|
+
Usage:
|
|
91
|
+
pr-shepherd apply queue-removal [PR] --require-sha <head> --queue-commit <commit> --removed-at <unix>
|
|
92
|
+
|
|
93
|
+
--require-sha <sha> Full 40-character lowercase PR head SHA observed with the failure.
|
|
94
|
+
--queue-commit <sha> Full 40-character lowercase synthetic merge-group commit SHA.
|
|
95
|
+
--removed-at <unix> Removal time in Unix seconds.
|
|
96
|
+
--format text|json Output format. Default: text.
|
|
97
|
+
--help, -h Print this help and exit before any I/O.`;
|
|
83
98
|
readonly "build-suggestion-patches": `pr-shepherd build-suggestion-patches
|
|
84
99
|
|
|
85
100
|
Build an ordered list of patches and commit instructions from GitHub review suggestions.
|
|
@@ -212,7 +227,7 @@ Flags:
|
|
|
212
227
|
|
|
213
228
|
PR may be a number or GitHub pull request URL. When omitted, the current branch PR is inferred.
|
|
214
229
|
Exit code: 0 on success; nonzero on failure (sysexits.h — see docs/exit-codes.md).`;
|
|
215
|
-
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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\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 action; continue with the next poll.\n MARK_READY Draft PR was marked ready; continue with the next poll.\n READY Clean PR is inside the ready-delay. Schedule the rerun for when remainingSeconds elapses. Do not invent unrelated work. Already-owned later work may continue.\n FIX_CODE Agent action is required; follow the instructions, then continue polling.\n CANCEL Stop polling: merged/closed or ready-delay elapsed.\n ESCALATE Stop polling until a human provides direction.\n MERGE Run the emitted merge/queue command, then continue monitoring.\n\nExit codes:\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT or READY\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
230
|
+
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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\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 action; continue with the next poll.\n MARK_READY Draft PR was marked ready; continue with the next poll.\n READY Clean PR is inside the ready-delay. Schedule the rerun for when remainingSeconds elapses. Do not invent unrelated work. Already-owned later work may continue.\n FIX_CODE Agent action is required; follow the instructions, then continue polling.\n CANCEL Stop polling this pull request: merged/closed or ready-delay elapsed. Continue remaining work from the original request.\n ESCALATE Stop polling until a human provides direction.\n MERGE Run the emitted merge/queue command, then continue monitoring.\n\nExit codes:\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT or READY\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
216
231
|
readonly poll: "pr-shepherd poll\n\nRun iterate repeatedly for one PR, or read compact summaries for an explicit PR set or native\nGitHub stack. Aggregate mode returns when any row needs work, every row is terminal, or timeout.\nPoll exits as soon as iterate returns READY, MARK_READY, CANCEL, or ESCALATE, or when timeout\nreturns the last WAIT result. FIX_CODE starts a --debounce settle window (default:\npoll.debounceSeconds; built-in 1m): poll keeps\niterating at --interval, then runs one more tick after the window and returns that result.\nWith --until-terminal or --merge, poll also continues through MARK_READY.\n\nUsage:\n pr-shepherd poll [PR ...] [poll-flags] [iterate-flags]\n pr-shepherd poll --stack PR [poll-flags] [iterate-flags]\n\nPoll flags:\n --stack PR Select all entries in PR's native GitHub stack, bottom to top.\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.intervalSeconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stackIntervalFactor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeoutSeconds (built-in 4.5m).\n --debounce <duration> Settle window after first FIX_CODE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounceSeconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quietStatus.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quietStatus.\n --until-terminal Continue through WAIT/MARK_READY until READY/FIX_CODE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\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 stderr line naming what it is waiting on by default; poll.quietStatus can change that default, --quiet-status/--no-quiet-status override it, 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 READY, FIX_CODE, MERGE, CANCEL, or ESCALATE. With --merge, --timeout still bounds WAIT ticks; it only continues through MARK_READY while polling remains within that timeout.\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 or READY (including a WAIT returned by --timeout)\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n 16 SHEPHERD (--stack only: run the listed one-PR sessions, then rerun the selector)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
217
232
|
readonly clean: `pr-shepherd clean
|
|
218
233
|
|
|
@@ -14,8 +14,9 @@ Usage:
|
|
|
14
14
|
pr-shepherd apply journal [PR] --file <path> [--dry-run] [--format text|json]
|
|
15
15
|
pr-shepherd apply check-blocker [PR] --check <name> --blocked-by <ref>
|
|
16
16
|
pr-shepherd apply check-blocker [PR] --check <name> --clear
|
|
17
|
+
pr-shepherd apply queue-removal [PR] --require-sha <head> --queue-commit <commit> --removed-at <unix>
|
|
17
18
|
|
|
18
|
-
Run 'pr-shepherd apply <review|files|journal|check-blocker> --help' for command-specific details.
|
|
19
|
+
Run 'pr-shepherd apply <review|files|journal|check-blocker|queue-removal> --help' for command-specific details.
|
|
19
20
|
--help, -h Print this help and exit before GitHub I/O.`,
|
|
20
21
|
"apply review": `pr-shepherd apply review
|
|
21
22
|
|
|
@@ -83,6 +84,20 @@ Usage:
|
|
|
83
84
|
|
|
84
85
|
\`--clear\` removes that check's record and leaves other checks alone.
|
|
85
86
|
--help, -h Print this help and exit before any I/O.`,
|
|
87
|
+
"apply queue-removal": `pr-shepherd apply queue-removal
|
|
88
|
+
|
|
89
|
+
Acknowledge one current CI-driven merge-queue removal for a native-stack PR.
|
|
90
|
+
This writes local state only after a fresh GitHub read confirms the supplied head,
|
|
91
|
+
queue commit, and removal timestamp still identify the current removal.
|
|
92
|
+
|
|
93
|
+
Usage:
|
|
94
|
+
pr-shepherd apply queue-removal [PR] --require-sha <head> --queue-commit <commit> --removed-at <unix>
|
|
95
|
+
|
|
96
|
+
--require-sha <sha> Full 40-character lowercase PR head SHA observed with the failure.
|
|
97
|
+
--queue-commit <sha> Full 40-character lowercase synthetic merge-group commit SHA.
|
|
98
|
+
--removed-at <unix> Removal time in Unix seconds.
|
|
99
|
+
--format text|json Output format. Default: text.
|
|
100
|
+
--help, -h Print this help and exit before any I/O.`,
|
|
86
101
|
"build-suggestion-patches": `pr-shepherd build-suggestion-patches
|
|
87
102
|
|
|
88
103
|
Build an ordered list of patches and commit instructions from GitHub review suggestions.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const ITERATE_USAGE = "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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\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 action; continue with the next poll.\n MARK_READY Draft PR was marked ready; continue with the next poll.\n READY Clean PR is inside the ready-delay. Schedule the rerun for when remainingSeconds elapses. Do not invent unrelated work. Already-owned later work may continue.\n FIX_CODE Agent action is required; follow the instructions, then continue polling.\n CANCEL Stop polling: merged/closed or ready-delay elapsed.\n ESCALATE Stop polling until a human provides direction.\n MERGE Run the emitted merge/queue command, then continue monitoring.\n\nExit codes:\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT or READY\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
1
|
+
export declare const ITERATE_USAGE = "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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\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 action; continue with the next poll.\n MARK_READY Draft PR was marked ready; continue with the next poll.\n READY Clean PR is inside the ready-delay. Schedule the rerun for when remainingSeconds elapses. Do not invent unrelated work. Already-owned later work may continue.\n FIX_CODE Agent action is required; follow the instructions, then continue polling.\n CANCEL Stop polling this pull request: merged/closed or ready-delay elapsed. Continue remaining work from the original request.\n ESCALATE Stop polling until a human provides direction.\n MERGE Run the emitted merge/queue command, then continue monitoring.\n\nExit codes:\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT or READY\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
2
2
|
export declare const POLL_USAGE = "pr-shepherd poll\n\nRun iterate repeatedly for one PR, or read compact summaries for an explicit PR set or native\nGitHub stack. Aggregate mode returns when any row needs work, every row is terminal, or timeout.\nPoll exits as soon as iterate returns READY, MARK_READY, CANCEL, or ESCALATE, or when timeout\nreturns the last WAIT result. FIX_CODE starts a --debounce settle window (default:\npoll.debounceSeconds; built-in 1m): poll keeps\niterating at --interval, then runs one more tick after the window and returns that result.\nWith --until-terminal or --merge, poll also continues through MARK_READY.\n\nUsage:\n pr-shepherd poll [PR ...] [poll-flags] [iterate-flags]\n pr-shepherd poll --stack PR [poll-flags] [iterate-flags]\n\nPoll flags:\n --stack PR Select all entries in PR's native GitHub stack, bottom to top.\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.intervalSeconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stackIntervalFactor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeoutSeconds (built-in 4.5m).\n --debounce <duration> Settle window after first FIX_CODE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounceSeconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quietStatus.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quietStatus.\n --until-terminal Continue through WAIT/MARK_READY until READY/FIX_CODE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\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 stderr line naming what it is waiting on by default; poll.quietStatus can change that default, --quiet-status/--no-quiet-status override it, 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 READY, FIX_CODE, MERGE, CANCEL, or ESCALATE. With --merge, --timeout still bounds WAIT ticks; it only continues through MARK_READY while polling remains within that timeout.\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 or READY (including a WAIT returned by --timeout)\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n 16 SHEPHERD (--stack only: run the listed one-PR sessions, then rerun the selector)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
3
3
|
/** Public help page for the default PR polling invocation. */
|
|
4
4
|
export declare const DEFAULT_USAGE: string;
|
|
@@ -23,7 +23,7 @@ Actions:
|
|
|
23
23
|
MARK_READY Draft PR was marked ready; continue with the next poll.
|
|
24
24
|
READY Clean PR is inside the ready-delay. Schedule the rerun for when remainingSeconds elapses. Do not invent unrelated work. Already-owned later work may continue.
|
|
25
25
|
FIX_CODE Agent action is required; follow the instructions, then continue polling.
|
|
26
|
-
CANCEL Stop polling: merged/closed or ready-delay elapsed.
|
|
26
|
+
CANCEL Stop polling this pull request: merged/closed or ready-delay elapsed. Continue remaining work from the original request.
|
|
27
27
|
ESCALATE Stop polling until a human provides direction.
|
|
28
28
|
MERGE Run the emitted merge/queue command, then continue monitoring.
|
|
29
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const TOP_USAGE = "pr-shepherd\n\nAutonomous PR CI monitor and review-comment resolver for agentic coding tools.\n\nUsage:\n pr-shepherd --version | -v\n pr-shepherd --help | -h\n pr-shepherd [PR ...] [poll-flags] [iterate-flags]\n pr-shepherd --stack PR [poll-flags] [iterate-flags]\n pr-shepherd iterate [PR] [iterate-flags]\n pr-shepherd apply review [PR] [review-flags]\n pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]\n pr-shepherd apply journal [PR] <item> [--dry-run] [--format text|json]\n pr-shepherd apply check-blocker [PR] --check <name> (--blocked-by <ref>|--clear)\n pr-shepherd journal extract --body-file <path>\n pr-shepherd build-suggestion-patches [PR] --thread-id ID --message MSG [groups...]\n pr-shepherd admin clean <pr|branch|current|repo|all> [value] [flags]\n pr-shepherd admin log-file [--format text|json]\n\nCommands:\n [PR ...] Poll one PR, an explicit same-repository set, or a native stack.\n iterate Run one iterate tick (single-tick alias).\n apply review Apply review-state mutations after fixes.\n apply files Mark selected changed files as viewed.\n apply journal Append a list item to the Shepherd Journal details block of a PR body.\n apply check-blocker Record that a failing check is blocked on an external PR or issue.\n journal extract Extract a validated Shepherd Journal from a local PR-body file as JSON.\n build-suggestion-patches\n Convert ordered GitHub suggestion threads into patches and commit instructions.\n admin clean Remove pr-shepherd state files.\n admin log-file Print the per-worktree debug log path.\n\nPR argument:\n PR may be a number, owner/repo#number, or a GitHub pull request URL.\n Multiple PRs must name one repository. --stack PR selects every entry in PR's native stack.\n When omitted, pr-shepherd infers the current branch's pull request.\n\nCommon flags:\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include verbose iterate fields and detailed poll-tick lines.\n --help, -h Print help and exit before any GitHub, git, config, or log I/O.\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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n\nPolling flags:\n --interval <duration> Delay between WAIT ticks. Bare number = seconds. Default: poll.intervalSeconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stackIntervalFactor (built-in 2) unless this flag is set.\n --timeout <duration> Poll wall-clock cap for WAIT ticks. Bare number = seconds. Default: poll.timeoutSeconds (built-in 4.5m).\n --debounce <duration> Settle window after first FIX_CODE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounceSeconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quietStatus.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quietStatus.\n --until-terminal Continue through WAIT/MARK_READY until READY/FIX_CODE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\n\nClean variants:\n pr [number] Remove state for one PR. Defaults to current branch PR.\n branch [name] Remove state for a branch's PR. Defaults to current branch.\n current Alias for branch against the current branch.\n repo Remove all state for the current repository.\n all Remove all pr-shepherd state.\n\nExit codes: 0 done, 10-19 PR state, 64-78 shepherd failed (sysexits.h).\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT or READY\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n 16 SHEPHERD (--stack only: run the listed one-PR sessions, then rerun the selector)\nSee docs/exit-codes.md for the full sysexits.h error-code table.\n\nDuration examples: 30s, 4.5m, 1h. A bare number uses each flag's default unit (see above); decimals are allowed with an explicit unit (4.5m).\n\nRun 'pr-shepherd <command> --help' for command-specific details.";
|
|
1
|
+
export declare const TOP_USAGE = "pr-shepherd\n\nAutonomous PR CI monitor and review-comment resolver for agentic coding tools.\n\nUsage:\n pr-shepherd --version | -v\n pr-shepherd --help | -h\n pr-shepherd [PR ...] [poll-flags] [iterate-flags]\n pr-shepherd --stack PR [poll-flags] [iterate-flags]\n pr-shepherd iterate [PR] [iterate-flags]\n pr-shepherd apply review [PR] [review-flags]\n pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]\n pr-shepherd apply journal [PR] <item> [--dry-run] [--format text|json]\n pr-shepherd apply check-blocker [PR] --check <name> (--blocked-by <ref>|--clear)\n pr-shepherd apply queue-removal [PR] --require-sha <head> --queue-commit <commit> --removed-at <unix>\n pr-shepherd journal extract --body-file <path>\n pr-shepherd build-suggestion-patches [PR] --thread-id ID --message MSG [groups...]\n pr-shepherd admin clean <pr|branch|current|repo|all> [value] [flags]\n pr-shepherd admin log-file [--format text|json]\n\nCommands:\n [PR ...] Poll one PR, an explicit same-repository set, or a native stack.\n iterate Run one iterate tick (single-tick alias).\n apply review Apply review-state mutations after fixes.\n apply files Mark selected changed files as viewed.\n apply journal Append a list item to the Shepherd Journal details block of a PR body.\n apply check-blocker Record that a failing check is blocked on an external PR or issue.\n apply queue-removal Acknowledge one current CI-driven native-stack queue removal.\n journal extract Extract a validated Shepherd Journal from a local PR-body file as JSON.\n build-suggestion-patches\n Convert ordered GitHub suggestion threads into patches and commit instructions.\n admin clean Remove pr-shepherd state files.\n admin log-file Print the per-worktree debug log path.\n\nPR argument:\n PR may be a number, owner/repo#number, or a GitHub pull request URL.\n Multiple PRs must name one repository. --stack PR selects every entry in PR's native stack.\n When omitted, pr-shepherd infers the current branch's pull request.\n\nCommon flags:\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include verbose iterate fields and detailed poll-tick lines.\n --help, -h Print help and exit before any GitHub, git, config, or log I/O.\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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n\nPolling flags:\n --interval <duration> Delay between WAIT ticks. Bare number = seconds. Default: poll.intervalSeconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stackIntervalFactor (built-in 2) unless this flag is set.\n --timeout <duration> Poll wall-clock cap for WAIT ticks. Bare number = seconds. Default: poll.timeoutSeconds (built-in 4.5m).\n --debounce <duration> Settle window after first FIX_CODE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounceSeconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quietStatus.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quietStatus.\n --until-terminal Continue through WAIT/MARK_READY until READY/FIX_CODE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\n\nClean variants:\n pr [number] Remove state for one PR. Defaults to current branch PR.\n branch [name] Remove state for a branch's PR. Defaults to current branch.\n current Alias for branch against the current branch.\n repo Remove all state for the current repository.\n all Remove all pr-shepherd state.\n\nExit codes: 0 done, 10-19 PR state, 64-78 shepherd failed (sysexits.h).\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT or READY\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n 16 SHEPHERD (--stack only: run the listed one-PR sessions, then rerun the selector)\nSee docs/exit-codes.md for the full sysexits.h error-code table.\n\nDuration examples: 30s, 4.5m, 1h. A bare number uses each flag's default unit (see above); decimals are allowed with an explicit unit (4.5m).\n\nRun 'pr-shepherd <command> --help' for command-specific details.";
|
|
@@ -12,6 +12,7 @@ Usage:
|
|
|
12
12
|
pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]
|
|
13
13
|
pr-shepherd apply journal [PR] <item> [--dry-run] [--format text|json]
|
|
14
14
|
pr-shepherd apply check-blocker [PR] --check <name> (--blocked-by <ref>|--clear)
|
|
15
|
+
pr-shepherd apply queue-removal [PR] --require-sha <head> --queue-commit <commit> --removed-at <unix>
|
|
15
16
|
pr-shepherd journal extract --body-file <path>
|
|
16
17
|
pr-shepherd build-suggestion-patches [PR] --thread-id ID --message MSG [groups...]
|
|
17
18
|
pr-shepherd admin clean <pr|branch|current|repo|all> [value] [flags]
|
|
@@ -24,6 +25,7 @@ Commands:
|
|
|
24
25
|
apply files Mark selected changed files as viewed.
|
|
25
26
|
apply journal Append a list item to the Shepherd Journal details block of a PR body.
|
|
26
27
|
apply check-blocker Record that a failing check is blocked on an external PR or issue.
|
|
28
|
+
apply queue-removal Acknowledge one current CI-driven native-stack queue removal.
|
|
27
29
|
journal extract Extract a validated Shepherd Journal from a local PR-body file as JSON.
|
|
28
30
|
build-suggestion-patches
|
|
29
31
|
Convert ordered GitHub suggestion threads into patches and commit instructions.
|
package/bin/cli/help.d.mts
CHANGED
|
@@ -11,8 +11,9 @@ Usage:
|
|
|
11
11
|
pr-shepherd apply journal [PR] --file <path> [--dry-run] [--format text|json]
|
|
12
12
|
pr-shepherd apply check-blocker [PR] --check <name> --blocked-by <ref>
|
|
13
13
|
pr-shepherd apply check-blocker [PR] --check <name> --clear
|
|
14
|
+
pr-shepherd apply queue-removal [PR] --require-sha <head> --queue-commit <commit> --removed-at <unix>
|
|
14
15
|
|
|
15
|
-
Run 'pr-shepherd apply <review|files|journal|check-blocker> --help' for command-specific details.
|
|
16
|
+
Run 'pr-shepherd apply <review|files|journal|check-blocker|queue-removal> --help' for command-specific details.
|
|
16
17
|
--help, -h Print this help and exit before GitHub I/O.`;
|
|
17
18
|
readonly "apply review": `pr-shepherd apply review
|
|
18
19
|
|
|
@@ -80,6 +81,20 @@ Usage:
|
|
|
80
81
|
|
|
81
82
|
\`--clear\` removes that check's record and leaves other checks alone.
|
|
82
83
|
--help, -h Print this help and exit before any I/O.`;
|
|
84
|
+
readonly "apply queue-removal": `pr-shepherd apply queue-removal
|
|
85
|
+
|
|
86
|
+
Acknowledge one current CI-driven merge-queue removal for a native-stack PR.
|
|
87
|
+
This writes local state only after a fresh GitHub read confirms the supplied head,
|
|
88
|
+
queue commit, and removal timestamp still identify the current removal.
|
|
89
|
+
|
|
90
|
+
Usage:
|
|
91
|
+
pr-shepherd apply queue-removal [PR] --require-sha <head> --queue-commit <commit> --removed-at <unix>
|
|
92
|
+
|
|
93
|
+
--require-sha <sha> Full 40-character lowercase PR head SHA observed with the failure.
|
|
94
|
+
--queue-commit <sha> Full 40-character lowercase synthetic merge-group commit SHA.
|
|
95
|
+
--removed-at <unix> Removal time in Unix seconds.
|
|
96
|
+
--format text|json Output format. Default: text.
|
|
97
|
+
--help, -h Print this help and exit before any I/O.`;
|
|
83
98
|
readonly "build-suggestion-patches": `pr-shepherd build-suggestion-patches
|
|
84
99
|
|
|
85
100
|
Build an ordered list of patches and commit instructions from GitHub review suggestions.
|
|
@@ -212,7 +227,7 @@ Flags:
|
|
|
212
227
|
|
|
213
228
|
PR may be a number or GitHub pull request URL. When omitted, the current branch PR is inferred.
|
|
214
229
|
Exit code: 0 on success; nonzero on failure (sysexits.h — see docs/exit-codes.md).`;
|
|
215
|
-
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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\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 action; continue with the next poll.\n MARK_READY Draft PR was marked ready; continue with the next poll.\n READY Clean PR is inside the ready-delay. Schedule the rerun for when remainingSeconds elapses. Do not invent unrelated work. Already-owned later work may continue.\n FIX_CODE Agent action is required; follow the instructions, then continue polling.\n CANCEL Stop polling: merged/closed or ready-delay elapsed.\n ESCALATE Stop polling until a human provides direction.\n MERGE Run the emitted merge/queue command, then continue monitoring.\n\nExit codes:\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT or READY\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
230
|
+
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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\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 action; continue with the next poll.\n MARK_READY Draft PR was marked ready; continue with the next poll.\n READY Clean PR is inside the ready-delay. Schedule the rerun for when remainingSeconds elapses. Do not invent unrelated work. Already-owned later work may continue.\n FIX_CODE Agent action is required; follow the instructions, then continue polling.\n CANCEL Stop polling this pull request: merged/closed or ready-delay elapsed. Continue remaining work from the original request.\n ESCALATE Stop polling until a human provides direction.\n MERGE Run the emitted merge/queue command, then continue monitoring.\n\nExit codes:\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT or READY\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
216
231
|
readonly poll: "pr-shepherd poll\n\nRun iterate repeatedly for one PR, or read compact summaries for an explicit PR set or native\nGitHub stack. Aggregate mode returns when any row needs work, every row is terminal, or timeout.\nPoll exits as soon as iterate returns READY, MARK_READY, CANCEL, or ESCALATE, or when timeout\nreturns the last WAIT result. FIX_CODE starts a --debounce settle window (default:\npoll.debounceSeconds; built-in 1m): poll keeps\niterating at --interval, then runs one more tick after the window and returns that result.\nWith --until-terminal or --merge, poll also continues through MARK_READY.\n\nUsage:\n pr-shepherd poll [PR ...] [poll-flags] [iterate-flags]\n pr-shepherd poll --stack PR [poll-flags] [iterate-flags]\n\nPoll flags:\n --stack PR Select all entries in PR's native GitHub stack, bottom to top.\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.intervalSeconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stackIntervalFactor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeoutSeconds (built-in 4.5m).\n --debounce <duration> Settle window after first FIX_CODE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounceSeconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quietStatus.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quietStatus.\n --until-terminal Continue through WAIT/MARK_READY until READY/FIX_CODE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\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 stderr line naming what it is waiting on by default; poll.quietStatus can change that default, --quiet-status/--no-quiet-status override it, 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 READY, FIX_CODE, MERGE, CANCEL, or ESCALATE. With --merge, --timeout still bounds WAIT ticks; it only continues through MARK_READY while polling remains within that timeout.\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 or READY (including a WAIT returned by --timeout)\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n 16 SHEPHERD (--stack only: run the listed one-PR sessions, then rerun the selector)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
217
232
|
readonly clean: `pr-shepherd clean
|
|
218
233
|
|
|
@@ -277,7 +292,7 @@ On POSIX, the final body-file path entry must be a readable regular file in a tr
|
|
|
277
292
|
symlinks, FIFOs, devices, and unreadable paths exit 66. Unsupported platforms fail closed with exit 66.
|
|
278
293
|
--help, -h Print this help and exit before any I/O.`;
|
|
279
294
|
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.";
|
|
280
|
-
readonly top: "pr-shepherd\n\nAutonomous PR CI monitor and review-comment resolver for agentic coding tools.\n\nUsage:\n pr-shepherd --version | -v\n pr-shepherd --help | -h\n pr-shepherd [PR ...] [poll-flags] [iterate-flags]\n pr-shepherd --stack PR [poll-flags] [iterate-flags]\n pr-shepherd iterate [PR] [iterate-flags]\n pr-shepherd apply review [PR] [review-flags]\n pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]\n pr-shepherd apply journal [PR] <item> [--dry-run] [--format text|json]\n pr-shepherd apply check-blocker [PR] --check <name> (--blocked-by <ref>|--clear)\n pr-shepherd journal extract --body-file <path>\n pr-shepherd build-suggestion-patches [PR] --thread-id ID --message MSG [groups...]\n pr-shepherd admin clean <pr|branch|current|repo|all> [value] [flags]\n pr-shepherd admin log-file [--format text|json]\n\nCommands:\n [PR ...] Poll one PR, an explicit same-repository set, or a native stack.\n iterate Run one iterate tick (single-tick alias).\n apply review Apply review-state mutations after fixes.\n apply files Mark selected changed files as viewed.\n apply journal Append a list item to the Shepherd Journal details block of a PR body.\n apply check-blocker Record that a failing check is blocked on an external PR or issue.\n journal extract Extract a validated Shepherd Journal from a local PR-body file as JSON.\n build-suggestion-patches\n Convert ordered GitHub suggestion threads into patches and commit instructions.\n admin clean Remove pr-shepherd state files.\n admin log-file Print the per-worktree debug log path.\n\nPR argument:\n PR may be a number, owner/repo#number, or a GitHub pull request URL.\n Multiple PRs must name one repository. --stack PR selects every entry in PR's native stack.\n When omitted, pr-shepherd infers the current branch's pull request.\n\nCommon flags:\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include verbose iterate fields and detailed poll-tick lines.\n --help, -h Print help and exit before any GitHub, git, config, or log I/O.\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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n\nPolling flags:\n --interval <duration> Delay between WAIT ticks. Bare number = seconds. Default: poll.intervalSeconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stackIntervalFactor (built-in 2) unless this flag is set.\n --timeout <duration> Poll wall-clock cap for WAIT ticks. Bare number = seconds. Default: poll.timeoutSeconds (built-in 4.5m).\n --debounce <duration> Settle window after first FIX_CODE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounceSeconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quietStatus.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quietStatus.\n --until-terminal Continue through WAIT/MARK_READY until READY/FIX_CODE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\n\nClean variants:\n pr [number] Remove state for one PR. Defaults to current branch PR.\n branch [name] Remove state for a branch's PR. Defaults to current branch.\n current Alias for branch against the current branch.\n repo Remove all state for the current repository.\n all Remove all pr-shepherd state.\n\nExit codes: 0 done, 10-19 PR state, 64-78 shepherd failed (sysexits.h).\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT or READY\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n 16 SHEPHERD (--stack only: run the listed one-PR sessions, then rerun the selector)\nSee docs/exit-codes.md for the full sysexits.h error-code table.\n\nDuration examples: 30s, 4.5m, 1h. A bare number uses each flag's default unit (see above); decimals are allowed with an explicit unit (4.5m).\n\nRun 'pr-shepherd <command> --help' for command-specific details.";
|
|
295
|
+
readonly top: "pr-shepherd\n\nAutonomous PR CI monitor and review-comment resolver for agentic coding tools.\n\nUsage:\n pr-shepherd --version | -v\n pr-shepherd --help | -h\n pr-shepherd [PR ...] [poll-flags] [iterate-flags]\n pr-shepherd --stack PR [poll-flags] [iterate-flags]\n pr-shepherd iterate [PR] [iterate-flags]\n pr-shepherd apply review [PR] [review-flags]\n pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]\n pr-shepherd apply journal [PR] <item> [--dry-run] [--format text|json]\n pr-shepherd apply check-blocker [PR] --check <name> (--blocked-by <ref>|--clear)\n pr-shepherd apply queue-removal [PR] --require-sha <head> --queue-commit <commit> --removed-at <unix>\n pr-shepherd journal extract --body-file <path>\n pr-shepherd build-suggestion-patches [PR] --thread-id ID --message MSG [groups...]\n pr-shepherd admin clean <pr|branch|current|repo|all> [value] [flags]\n pr-shepherd admin log-file [--format text|json]\n\nCommands:\n [PR ...] Poll one PR, an explicit same-repository set, or a native stack.\n iterate Run one iterate tick (single-tick alias).\n apply review Apply review-state mutations after fixes.\n apply files Mark selected changed files as viewed.\n apply journal Append a list item to the Shepherd Journal details block of a PR body.\n apply check-blocker Record that a failing check is blocked on an external PR or issue.\n apply queue-removal Acknowledge one current CI-driven native-stack queue removal.\n journal extract Extract a validated Shepherd Journal from a local PR-body file as JSON.\n build-suggestion-patches\n Convert ordered GitHub suggestion threads into patches and commit instructions.\n admin clean Remove pr-shepherd state files.\n admin log-file Print the per-worktree debug log path.\n\nPR argument:\n PR may be a number, owner/repo#number, or a GitHub pull request URL.\n Multiple PRs must name one repository. --stack PR selects every entry in PR's native stack.\n When omitted, pr-shepherd infers the current branch's pull request.\n\nCommon flags:\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include verbose iterate fields and detailed poll-tick lines.\n --help, -h Print help and exit before any GitHub, git, config, or log I/O.\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 Legacy no-op; workflow runs are never cancelled.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n\nPolling flags:\n --interval <duration> Delay between WAIT ticks. Bare number = seconds. Default: poll.intervalSeconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stackIntervalFactor (built-in 2) unless this flag is set.\n --timeout <duration> Poll wall-clock cap for WAIT ticks. Bare number = seconds. Default: poll.timeoutSeconds (built-in 4.5m).\n --debounce <duration> Settle window after first FIX_CODE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounceSeconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quietStatus.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quietStatus.\n --until-terminal Continue through WAIT/MARK_READY until READY/FIX_CODE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\n\nClean variants:\n pr [number] Remove state for one PR. Defaults to current branch PR.\n branch [name] Remove state for a branch's PR. Defaults to current branch.\n current Alias for branch against the current branch.\n repo Remove all state for the current repository.\n all Remove all pr-shepherd state.\n\nExit codes: 0 done, 10-19 PR state, 64-78 shepherd failed (sysexits.h).\n 0 CANCEL (merged or ready-delay elapsed)\n 10 WAIT or READY\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\n 15 MERGE\n 16 SHEPHERD (--stack only: run the listed one-PR sessions, then rerun the selector)\nSee docs/exit-codes.md for the full sysexits.h error-code table.\n\nDuration examples: 30s, 4.5m, 1h. A bare number uses each flag's default unit (see above); decimals are allowed with an explicit unit (4.5m).\n\nRun 'pr-shepherd <command> --help' for command-specific details.";
|
|
281
296
|
};
|
|
282
297
|
/** Resolve help keys for nested public commands before any command I/O. */
|
|
283
298
|
export declare function helpKeyForArgs(args: string[]): keyof typeof USAGE;
|
package/bin/cli/help.mjs
CHANGED
|
@@ -15,6 +15,8 @@ export function helpKeyForArgs(args) {
|
|
|
15
15
|
return "apply journal";
|
|
16
16
|
if (args[0] === "apply" && args[1] === "check-blocker")
|
|
17
17
|
return "apply check-blocker";
|
|
18
|
+
if (args[0] === "apply" && args[1] === "queue-removal")
|
|
19
|
+
return "apply queue-removal";
|
|
18
20
|
if (args[0] === "journal" && args[1] === "extract")
|
|
19
21
|
return "journal extract";
|
|
20
22
|
if (args[0] === "admin" && args[1] === "clean")
|
|
@@ -48,7 +48,10 @@ export function buildSimpleIterateInstructions(result) {
|
|
|
48
48
|
return instructions;
|
|
49
49
|
}
|
|
50
50
|
case "cancel":
|
|
51
|
-
return [
|
|
51
|
+
return [
|
|
52
|
+
"Stop polling this pull request — its poll is complete.",
|
|
53
|
+
"Continue any remaining pull requests or issues from the original request.",
|
|
54
|
+
];
|
|
52
55
|
case "escalate": {
|
|
53
56
|
const pending = result.escalate.pendingReviewCommands;
|
|
54
57
|
if (!pending)
|
package/bin/cli/iterate-lean.mjs
CHANGED
|
@@ -152,6 +152,9 @@ export function projectIterateLean(result, opts) {
|
|
|
152
152
|
protectedRuns: result.fix.protectedRuns,
|
|
153
153
|
}),
|
|
154
154
|
...(result.fix.requeue && { requeue: result.fix.requeue }),
|
|
155
|
+
...(result.fix.queueRemovalAcknowledgment && {
|
|
156
|
+
queueRemovalAcknowledgment: result.fix.queueRemovalAcknowledgment,
|
|
157
|
+
}),
|
|
155
158
|
...(result.fix.checks.length > 0 && { checks: result.fix.checks }),
|
|
156
159
|
...(result.fix.changesRequestedReviews.length > 0 && {
|
|
157
160
|
changesRequestedReviews: result.fix.changesRequestedReviews,
|
|
@@ -40,6 +40,8 @@ export function appendMergeQueueHeader(lines, result) {
|
|
|
40
40
|
parts.push("checks incomplete (first 100 shown)");
|
|
41
41
|
if (queue.headUpdatedAfterRemoval)
|
|
42
42
|
parts.push("head updated after removal");
|
|
43
|
+
if (queue.removalAcknowledged)
|
|
44
|
+
parts.push("removal acknowledged");
|
|
43
45
|
lines.push(`**merge queue** ${parts.join(" · ")}`);
|
|
44
46
|
if (queue.autoMergeRequest) {
|
|
45
47
|
lines.push(`**auto-merge** method \`${queue.autoMergeRequest.mergeMethod}\` · enabledAtUnix \`${queue.autoMergeRequest.enabledAtUnix}\`${queue.autoMergeRequest.enabledBy ? ` · by \`@${queue.autoMergeRequest.enabledBy}\`` : ""}`);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { EXIT, errorToExitCode } from "../exit-codes.mjs";
|
|
2
|
+
import { applyQueueRemovalAck } from "../commands/apply-queue-removal.mjs";
|
|
3
|
+
import { getFlag, parseCommonArgs } from "./args.mjs";
|
|
4
|
+
import { maybePrintHelp, USAGE } from "./help.mjs";
|
|
5
|
+
const FLAGS = new Set(["--require-sha", "--queue-commit", "--removed-at"]);
|
|
6
|
+
/** `apply queue-removal`; help exits before argument validation and GitHub I/O. */
|
|
7
|
+
export async function handleQueueRemoval(args) {
|
|
8
|
+
if (maybePrintHelp(args, "apply queue-removal"))
|
|
9
|
+
return;
|
|
10
|
+
const { prNumber, global, extra } = parseCommonArgs(args);
|
|
11
|
+
const flagError = validateFlags(extra);
|
|
12
|
+
if (flagError) {
|
|
13
|
+
usage(flagError);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const headSha = getFlag(extra, "--require-sha");
|
|
17
|
+
const queueCommitOid = getFlag(extra, "--queue-commit");
|
|
18
|
+
const removedAtText = getFlag(extra, "--removed-at");
|
|
19
|
+
if (headSha === null || !/^[0-9a-f]{40}$/.test(headSha)) {
|
|
20
|
+
usage("--require-sha must be a full 40-character lowercase hex SHA.", EXIT.DATAERR);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (queueCommitOid === null || !/^[0-9a-f]{40}$/.test(queueCommitOid)) {
|
|
24
|
+
usage("--queue-commit must be a full 40-character lowercase hex SHA.", EXIT.DATAERR);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (removedAtText === null || !/^[1-9]\d*$/.test(removedAtText)) {
|
|
28
|
+
usage("--removed-at must be a positive Unix timestamp in seconds.", EXIT.DATAERR);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const removedAtUnix = Number(removedAtText);
|
|
32
|
+
if (!Number.isSafeInteger(removedAtUnix)) {
|
|
33
|
+
usage("--removed-at must be a positive Unix timestamp in seconds.", EXIT.DATAERR);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const result = await applyQueueRemovalAck({
|
|
38
|
+
prNumber,
|
|
39
|
+
targetRepository: global.targetRepository,
|
|
40
|
+
headSha,
|
|
41
|
+
queueCommitOid,
|
|
42
|
+
removedAtUnix,
|
|
43
|
+
});
|
|
44
|
+
const body = global.format === "json"
|
|
45
|
+
? JSON.stringify(result, null, 2)
|
|
46
|
+
: [
|
|
47
|
+
`PR: ${result.repo}#${result.pr}`,
|
|
48
|
+
`headSha: ${result.acknowledgment.headSha}`,
|
|
49
|
+
`queueCommitOid: ${result.acknowledgment.queueCommitOid}`,
|
|
50
|
+
`removedAtUnix: ${result.acknowledgment.removedAtUnix}`,
|
|
51
|
+
].join("\n");
|
|
52
|
+
process.stdout.write(`${body}\n`);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
56
|
+
process.stderr.write(`pr-shepherd: apply queue-removal: ${message}\n`);
|
|
57
|
+
process.exitCode = errorToExitCode(err);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function validateFlags(args) {
|
|
61
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
62
|
+
const arg = args[i];
|
|
63
|
+
if (!arg.startsWith("--"))
|
|
64
|
+
return `unexpected argument: "${arg}"`;
|
|
65
|
+
const eq = arg.indexOf("=");
|
|
66
|
+
const name = eq === -1 ? arg : arg.slice(0, eq);
|
|
67
|
+
if (!FLAGS.has(name))
|
|
68
|
+
return `unknown flag: "${name}"`;
|
|
69
|
+
if (eq !== -1) {
|
|
70
|
+
if (arg.slice(eq + 1) === "")
|
|
71
|
+
return `${name} requires a value.`;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const value = args[i + 1];
|
|
75
|
+
if (value === undefined || value.startsWith("--"))
|
|
76
|
+
return `${name} requires a value.`;
|
|
77
|
+
i += 1;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
function usage(message, exitCode = EXIT.USAGE) {
|
|
82
|
+
process.stderr.write(`pr-shepherd: apply queue-removal: ${message}\n`);
|
|
83
|
+
if (exitCode === EXIT.USAGE)
|
|
84
|
+
process.stderr.write(`${USAGE["apply queue-removal"]}\n`);
|
|
85
|
+
process.exitCode = exitCode;
|
|
86
|
+
}
|
package/bin/cli-parser.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { handleJournalExtract } from "./cli/journal-extract-handler.mjs";
|
|
|
14
14
|
import { handlePoll } from "./cli/poll-handler.mjs";
|
|
15
15
|
import { warnPrrcThreadIds, validateRequireSha, rejectPrrcMinimizeIds, } from "./cli/resolve-validators.mjs";
|
|
16
16
|
import { handleCheckBlocker } from "./cli/check-blocker-handler.mjs";
|
|
17
|
+
import { handleQueueRemoval } from "./cli/queue-removal-handler.mjs";
|
|
17
18
|
import { setupLog } from "./log/setup.mjs";
|
|
18
19
|
// ---------------------------------------------------------------------------
|
|
19
20
|
// Entry
|
|
@@ -135,6 +136,9 @@ async function handleApply(args) {
|
|
|
135
136
|
case "check-blocker":
|
|
136
137
|
await handleCheckBlocker(args.slice(1));
|
|
137
138
|
return;
|
|
139
|
+
case "queue-removal":
|
|
140
|
+
await handleQueueRemoval(args.slice(1));
|
|
141
|
+
return;
|
|
138
142
|
default:
|
|
139
143
|
process.stderr.write(`Unknown apply action: ${action ?? "(none)"}\n`);
|
|
140
144
|
process.stderr.write(`${USAGE.apply}\n`);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type QueueRemovalAcknowledgment } from "../state/queue-removal-ack.mts";
|
|
2
|
+
export interface ApplyQueueRemovalInput {
|
|
3
|
+
prNumber?: number;
|
|
4
|
+
targetRepository?: {
|
|
5
|
+
owner: string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
headSha: string;
|
|
9
|
+
queueCommitOid: string;
|
|
10
|
+
removedAtUnix: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ApplyQueueRemovalResult {
|
|
13
|
+
pr: number;
|
|
14
|
+
repo: string;
|
|
15
|
+
acknowledgment: QueueRemovalAcknowledgment;
|
|
16
|
+
}
|
|
17
|
+
/** Validate an observed native-stack CI queue removal before recording the caller's acknowledgment. */
|
|
18
|
+
export declare function applyQueueRemovalAck(input: ApplyQueueRemovalInput): Promise<ApplyQueueRemovalResult>;
|