pr-shepherd 1.4.0 → 1.6.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 +1 -1
- package/README.md +1 -0
- package/bin/api.d.mts +1 -1
- package/bin/cli/help-command-pages.d.mts +2 -2
- package/bin/cli/help-iterate-poll-pages.d.mts +2 -2
- package/bin/cli/help-iterate-poll-pages.mjs +3 -2
- package/bin/cli/help.d.mts +2 -2
- package/bin/commands/iterate/index.mjs +4 -0
- package/bin/commands/poll-events.d.mts +44 -0
- package/bin/commands/poll-events.mjs +123 -0
- package/bin/commands/poll-options.d.mts +9 -0
- package/bin/commands/poll-options.mjs +1 -0
- package/bin/commands/poll-progress.d.mts +2 -0
- package/bin/commands/poll-progress.mjs +6 -4
- package/bin/commands/poll-quota.d.mts +2 -0
- package/bin/commands/poll-quota.mjs +4 -0
- package/bin/commands/poll-summary-explicit-instructions.mjs +1 -1
- package/bin/commands/poll-summary.d.mts +1 -0
- package/bin/commands/poll-summary.mjs +30 -18
- package/bin/commands/poll-tick.d.mts +17 -0
- package/bin/commands/poll-tick.mjs +24 -0
- package/bin/commands/poll.d.mts +3 -9
- package/bin/commands/poll.mjs +64 -60
- package/bin/commands/stall-deadline.d.mts +20 -0
- package/bin/commands/stall-deadline.mjs +42 -0
- package/bin/commands/tick.mjs +2 -16
- package/bin/config/schema.d.mts +14 -0
- package/bin/config/schema.mjs +6 -0
- package/bin/events/config.d.mts +7 -0
- package/bin/events/config.mjs +66 -0
- package/bin/events/envelope.d.mts +4 -0
- package/bin/events/envelope.mjs +27 -0
- package/bin/events/filters.d.mts +8 -0
- package/bin/events/filters.mjs +27 -0
- package/bin/events/health.d.mts +14 -0
- package/bin/events/health.mjs +27 -0
- package/bin/events/matcher.d.mts +2 -0
- package/bin/events/matcher.mjs +32 -0
- package/bin/events/relay.d.mts +11 -0
- package/bin/events/relay.mjs +86 -0
- package/bin/events/serve.d.mts +10 -0
- package/bin/events/serve.mjs +137 -0
- package/bin/events/sse.d.mts +10 -0
- package/bin/events/sse.mjs +50 -0
- package/bin/events/types.d.mts +69 -0
- package/bin/events/types.mjs +1 -0
- package/bin/events/waiter.d.mts +47 -0
- package/bin/events/waiter.mjs +80 -0
- package/bin/github/batch-first-page.d.mts +17 -0
- package/bin/github/batch-first-page.mjs +48 -0
- package/bin/github/batch-page.d.mts +2 -0
- package/bin/github/batch-page.mjs +2 -2
- package/bin/github/batch-stack-evidence.d.mts +3 -1
- package/bin/github/batch-stack-evidence.mjs +4 -2
- package/bin/github/batch-viewer.d.mts +24 -0
- package/bin/github/batch-viewer.mjs +66 -0
- package/bin/github/batch.d.mts +1 -1
- package/bin/github/batch.mjs +30 -35
- package/bin/github/check-annotations-batch.mjs +1 -7
- package/bin/github/gql/batch-pr-viewer.gql +46 -0
- package/bin/github/gql-strip-viewer.d.mts +7 -0
- package/bin/github/gql-strip-viewer.mjs +14 -0
- package/bin/github/queries.d.mts +8 -0
- package/bin/github/queries.mjs +9 -0
- package/bin/github/thread-comments.d.mts +1 -1
- package/bin/github/thread-comments.mjs +7 -7
- package/bin/types/iterate.d.mts +9 -0
- package/bin/util/chunks.d.mts +2 -0
- package/bin/util/chunks.mjs +8 -0
- package/package.json +1 -1
- package/plugins/pr-shepherd/.claude-plugin/plugin.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/package-lock.json +4 -4
- package/plugins/pr-shepherd/package.json +1 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +2 -2
- package/plugins/pr-shepherd/skills/pr-shepherd/references/waiting.md +8 -0
- package/pr-shepherd.schema.json +21 -0
package/README.md
CHANGED
|
@@ -140,6 +140,7 @@ See [docs/graphql-usage.md](docs/graphql-usage.md) and [docs/rest-usage.md](docs
|
|
|
140
140
|
- Cursor and other stdio clients use the [MCP server](docs/mcp.md).
|
|
141
141
|
- Shell and CI use the [CLI](docs/cli-usage.md).
|
|
142
142
|
- In Claude Code cloud sessions, Shepherd switches to the [REST transport](docs/rest.md) and [single ticks](docs/cloud.md).
|
|
143
|
+
- Optional [event-driven waiting](docs/hook-harness.md) wakes a poll on GitHub webhook events instead of a fixed sleep.
|
|
143
144
|
- `stack` reports every layer of a native GitHub stacked PR and shepherds the layers you own.
|
|
144
145
|
|
|
145
146
|
## Use cases
|
package/bin/api.d.mts
CHANGED
|
@@ -27,7 +27,7 @@ export interface CreatePrShepherdOptions {
|
|
|
27
27
|
}
|
|
28
28
|
/** A positive PR number, GitHub pull-request URL, or owner/repo#number reference. */
|
|
29
29
|
export type PrReference = number | string;
|
|
30
|
-
type IterateOptions = Omit<IterateCommandOptions, "format" | "prNumber" | "targetRepository" | "persistSeen" | "deferEditedCommentMarkers" | "fingerprintCache" | "stallDeadlineSink" | "deferQuotaWarning" | "quotaWarningMinimumPollIntervalMinutes">;
|
|
30
|
+
type IterateOptions = Omit<IterateCommandOptions, "format" | "prNumber" | "targetRepository" | "persistSeen" | "deferEditedCommentMarkers" | "fingerprintCache" | "stallDeadlineSink" | "eventTargetSink" | "deferQuotaWarning" | "quotaWarningMinimumPollIntervalMinutes">;
|
|
31
31
|
export type SingleIterateInput = IterateOptions & {
|
|
32
32
|
pr?: PrReference;
|
|
33
33
|
prs?: never;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const COMMAND_USAGE: {
|
|
2
|
-
readonly default: "pr-shepherd [PR]\n\nRun iterate repeatedly for one PR, or read compact summaries for an explicit same-repository PR set.\nAggregate mode returns when any row needs work, every row is terminal, or timeout.\nWhen CLAUDE_CODE_REMOTE=true, the command runs one tick like iterate and prints nextCheck instead.\nPoll exits as soon as iterate returns READY, MARK_READY, CANCEL, or ESCALATE, or when timeout\nreturns the last WAIT result. TRIAGE starts a --debounce settle window (default:\npoll.debounce-seconds; 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 [PR ...] [poll-flags] [iterate-flags]\n\nUse 'pr-shepherd stack PR' for a native GitHub stack.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m).\n --debounce <duration> Settle window after first TRIAGE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT/MARK_READY until READY/TRIAGE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Leave draft PRs in draft; stop when otherwise ready.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\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.quiet-status can change that default, --quiet-status/--no-quiet-status override it, and --verbose emits detailed per-tick lines.\nTRIAGE 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, TRIAGE, 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, ready-delay elapsed, or clean draft left in draft by disabled auto mark-ready)\n 10 WAIT or READY (including a WAIT returned by --timeout)\n 11 MARK_READY\n 12 TRIAGE\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
|
+
readonly default: "pr-shepherd [PR]\n\nRun iterate repeatedly for one PR, or read compact summaries for an explicit same-repository PR set.\nAggregate mode returns when any row needs work, every row is terminal, or timeout.\nWhen CLAUDE_CODE_REMOTE=true, the command runs one tick like iterate and prints nextCheck instead.\nPoll exits as soon as iterate returns READY, MARK_READY, CANCEL, or ESCALATE, or when timeout\nreturns the last WAIT result. TRIAGE starts a --debounce settle window (default:\npoll.debounce-seconds; 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 [PR ...] [poll-flags] [iterate-flags]\n\nUse 'pr-shepherd stack PR' for a native GitHub stack.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m, for foreground waits).\n --debounce <duration> Settle window after first TRIAGE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT/MARK_READY until READY/TRIAGE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\n For background runs that wake the caller on exit; foreground waits use the bounded default.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Leave draft PRs in draft; stop when otherwise ready.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\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.quiet-status can change that default, --quiet-status/--no-quiet-status override it, and --verbose emits detailed per-tick lines.\nTRIAGE 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, TRIAGE, 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, ready-delay elapsed, or clean draft left in draft by disabled auto mark-ready)\n 10 WAIT or READY (including a WAIT returned by --timeout)\n 11 MARK_READY\n 12 TRIAGE\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).";
|
|
3
3
|
readonly "apply merge": `pr-shepherd apply merge
|
|
4
4
|
|
|
5
5
|
Submit one SHA-guarded asynchronous merge or enqueue request with REST.
|
|
@@ -162,7 +162,7 @@ When CLAUDE_CODE_REMOTE=true, state is the durable copy under the git common dir
|
|
|
162
162
|
--help, -h Print this help and exit before any cleanup.`;
|
|
163
163
|
readonly "admin log-file": "pr-shepherd admin 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 admin 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 CLAUDE_CODE_REMOTE=true reports the durable log under the git common directory.\n\nExit code: 0 on success; 1 if repository identity cannot be resolved.";
|
|
164
164
|
readonly iterate: "pr-shepherd iterate\n\nRun one tick and return without sleeping. The no-subcommand form polls; use this subcommand when the\ncaller owns the next wake-up. One PR prints one action and an action-specific ## Instructions section.\nSeveral same-repository PRs print one aggregate summary. Unless nothing remains to wait for, the output\ncarries nextCheck: when to rerun if no GitHub event arrives first.\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. Default: iterate.ready-delay-minutes (built-in 0). Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Leave draft PRs in draft; stop when otherwise ready.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\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 TRIAGE Agent action is required; follow the instructions, then continue polling.\n CANCEL Stop polling this pull request: merged/closed, ready-delay elapsed, or a clean draft left in draft because auto mark-ready is disabled. 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, ready-delay elapsed, or clean draft left in draft by disabled auto mark-ready)\n 10 WAIT or READY\n 11 MARK_READY\n 12 TRIAGE\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).";
|
|
165
|
-
readonly stack: "pr-shepherd stack\n\nShepherd every open PR in one PR's native GitHub stack, bottom to top. Each poll reads compact\nper-layer summaries and returns when a layer needs work, every layer is terminal, or timeout.\nSHEPHERD lists one-PR sessions to run before rerunning this command.\n--once, or CLAUDE_CODE_REMOTE=true, runs one aggregate tick and prints nextCheck instead of sleeping.\n\nUsage:\n pr-shepherd stack PR [--once] [poll-flags] [iterate-flags]\n\nStack flags:\n --once Run one aggregate tick without sleeping; poll flags are ignored.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s) multiplied by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m).\n --debounce <duration> Settle window after the first SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT until SHEPHERD, MERGE, CANCEL, or ESCALATE.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). 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 --merge Shepherd through readiness, then emit the stack merge commands.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include 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).\n\nExit codes:\n 0 CANCEL (every layer merged)\n 10 WAIT\n 13 ESCALATE\n 14 CANCEL (a layer closed without merging)\n 15 MERGE\n 16 SHEPHERD (run the listed one-PR sessions, then rerun this stack command)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
165
|
+
readonly stack: "pr-shepherd stack\n\nShepherd every open PR in one PR's native GitHub stack, bottom to top. Each poll reads compact\nper-layer summaries and returns when a layer needs work, every layer is terminal, or timeout.\nSHEPHERD lists one-PR sessions to run before rerunning this command.\n--once, or CLAUDE_CODE_REMOTE=true, runs one aggregate tick and prints nextCheck instead of sleeping.\n\nUsage:\n pr-shepherd stack PR [--once] [poll-flags] [iterate-flags]\n\nStack flags:\n --once Run one aggregate tick without sleeping; poll flags are ignored.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s) multiplied by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m, for foreground waits).\n --debounce <duration> Settle window after the first SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT until SHEPHERD, MERGE, CANCEL, or ESCALATE.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). 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 --merge Shepherd through readiness, then emit the stack merge commands.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include 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).\n\nExit codes:\n 0 CANCEL (every layer merged)\n 10 WAIT\n 13 ESCALATE\n 14 CANCEL (a layer closed without merging)\n 15 MERGE\n 16 SHEPHERD (run the listed one-PR sessions, then rerun this stack command)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
166
166
|
readonly "journal extract": `pr-shepherd journal extract
|
|
167
167
|
|
|
168
168
|
Extract one visible, structurally valid Shepherd Journal from a local PR-body file.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const ITERATE_USAGE = "pr-shepherd iterate\n\nRun one tick and return without sleeping. The no-subcommand form polls; use this subcommand when the\ncaller owns the next wake-up. One PR prints one action and an action-specific ## Instructions section.\nSeveral same-repository PRs print one aggregate summary. Unless nothing remains to wait for, the output\ncarries nextCheck: when to rerun if no GitHub event arrives first.\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. Default: iterate.ready-delay-minutes (built-in 0). Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Leave draft PRs in draft; stop when otherwise ready.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\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 TRIAGE Agent action is required; follow the instructions, then continue polling.\n CANCEL Stop polling this pull request: merged/closed, ready-delay elapsed, or a clean draft left in draft because auto mark-ready is disabled. 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, ready-delay elapsed, or clean draft left in draft by disabled auto mark-ready)\n 10 WAIT or READY\n 11 MARK_READY\n 12 TRIAGE\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
|
/** Public help page for the default PR polling invocation. */
|
|
3
|
-
export declare const DEFAULT_USAGE = "pr-shepherd [PR]\n\nRun iterate repeatedly for one PR, or read compact summaries for an explicit same-repository PR set.\nAggregate mode returns when any row needs work, every row is terminal, or timeout.\nWhen CLAUDE_CODE_REMOTE=true, the command runs one tick like iterate and prints nextCheck instead.\nPoll exits as soon as iterate returns READY, MARK_READY, CANCEL, or ESCALATE, or when timeout\nreturns the last WAIT result. TRIAGE starts a --debounce settle window (default:\npoll.debounce-seconds; 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 [PR ...] [poll-flags] [iterate-flags]\n\nUse 'pr-shepherd stack PR' for a native GitHub stack.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m).\n --debounce <duration> Settle window after first TRIAGE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT/MARK_READY until READY/TRIAGE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Leave draft PRs in draft; stop when otherwise ready.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\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.quiet-status can change that default, --quiet-status/--no-quiet-status override it, and --verbose emits detailed per-tick lines.\nTRIAGE 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, TRIAGE, 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, ready-delay elapsed, or clean draft left in draft by disabled auto mark-ready)\n 10 WAIT or READY (including a WAIT returned by --timeout)\n 11 MARK_READY\n 12 TRIAGE\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).";
|
|
3
|
+
export declare const DEFAULT_USAGE = "pr-shepherd [PR]\n\nRun iterate repeatedly for one PR, or read compact summaries for an explicit same-repository PR set.\nAggregate mode returns when any row needs work, every row is terminal, or timeout.\nWhen CLAUDE_CODE_REMOTE=true, the command runs one tick like iterate and prints nextCheck instead.\nPoll exits as soon as iterate returns READY, MARK_READY, CANCEL, or ESCALATE, or when timeout\nreturns the last WAIT result. TRIAGE starts a --debounce settle window (default:\npoll.debounce-seconds; 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 [PR ...] [poll-flags] [iterate-flags]\n\nUse 'pr-shepherd stack PR' for a native GitHub stack.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m, for foreground waits).\n --debounce <duration> Settle window after first TRIAGE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT/MARK_READY until READY/TRIAGE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\n For background runs that wake the caller on exit; foreground waits use the bounded default.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Leave draft PRs in draft; stop when otherwise ready.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\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.quiet-status can change that default, --quiet-status/--no-quiet-status override it, and --verbose emits detailed per-tick lines.\nTRIAGE 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, TRIAGE, 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, ready-delay elapsed, or clean draft left in draft by disabled auto mark-ready)\n 10 WAIT or READY (including a WAIT returned by --timeout)\n 11 MARK_READY\n 12 TRIAGE\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).";
|
|
4
4
|
/** Public help page for `pr-shepherd stack`. */
|
|
5
|
-
export declare const STACK_USAGE = "pr-shepherd stack\n\nShepherd every open PR in one PR's native GitHub stack, bottom to top. Each poll reads compact\nper-layer summaries and returns when a layer needs work, every layer is terminal, or timeout.\nSHEPHERD lists one-PR sessions to run before rerunning this command.\n--once, or CLAUDE_CODE_REMOTE=true, runs one aggregate tick and prints nextCheck instead of sleeping.\n\nUsage:\n pr-shepherd stack PR [--once] [poll-flags] [iterate-flags]\n\nStack flags:\n --once Run one aggregate tick without sleeping; poll flags are ignored.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s) multiplied by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m).\n --debounce <duration> Settle window after the first SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT until SHEPHERD, MERGE, CANCEL, or ESCALATE.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). 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 --merge Shepherd through readiness, then emit the stack merge commands.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include 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).\n\nExit codes:\n 0 CANCEL (every layer merged)\n 10 WAIT\n 13 ESCALATE\n 14 CANCEL (a layer closed without merging)\n 15 MERGE\n 16 SHEPHERD (run the listed one-PR sessions, then rerun this stack command)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
5
|
+
export declare const STACK_USAGE = "pr-shepherd stack\n\nShepherd every open PR in one PR's native GitHub stack, bottom to top. Each poll reads compact\nper-layer summaries and returns when a layer needs work, every layer is terminal, or timeout.\nSHEPHERD lists one-PR sessions to run before rerunning this command.\n--once, or CLAUDE_CODE_REMOTE=true, runs one aggregate tick and prints nextCheck instead of sleeping.\n\nUsage:\n pr-shepherd stack PR [--once] [poll-flags] [iterate-flags]\n\nStack flags:\n --once Run one aggregate tick without sleeping; poll flags are ignored.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s) multiplied by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m, for foreground waits).\n --debounce <duration> Settle window after the first SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT until SHEPHERD, MERGE, CANCEL, or ESCALATE.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). 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 --merge Shepherd through readiness, then emit the stack merge commands.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include 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).\n\nExit codes:\n 0 CANCEL (every layer merged)\n 10 WAIT\n 13 ESCALATE\n 14 CANCEL (a layer closed without merging)\n 15 MERGE\n 16 SHEPHERD (run the listed one-PR sessions, then rerun this stack command)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
@@ -58,11 +58,12 @@ Use 'pr-shepherd stack PR' for a native GitHub stack.
|
|
|
58
58
|
|
|
59
59
|
Poll flags:
|
|
60
60
|
--interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stack-interval-factor (built-in 2) unless this flag is set.
|
|
61
|
-
--timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m).
|
|
61
|
+
--timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m, for foreground waits).
|
|
62
62
|
--debounce <duration> Settle window after first TRIAGE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.
|
|
63
63
|
--quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.
|
|
64
64
|
--no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.
|
|
65
65
|
--until-terminal Continue through WAIT/MARK_READY until READY/TRIAGE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.
|
|
66
|
+
For background runs that wake the caller on exit; foreground waits use the bounded default.
|
|
66
67
|
|
|
67
68
|
Forwarded iterate flags:
|
|
68
69
|
--ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). Example: 15m.
|
|
@@ -107,7 +108,7 @@ Stack flags:
|
|
|
107
108
|
|
|
108
109
|
Poll flags:
|
|
109
110
|
--interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s) multiplied by poll.stack-interval-factor (built-in 2) unless this flag is set.
|
|
110
|
-
--timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m).
|
|
111
|
+
--timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m, for foreground waits).
|
|
111
112
|
--debounce <duration> Settle window after the first SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.
|
|
112
113
|
--quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.
|
|
113
114
|
--no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.
|
package/bin/cli/help.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const USAGE: {
|
|
2
|
-
readonly default: "pr-shepherd [PR]\n\nRun iterate repeatedly for one PR, or read compact summaries for an explicit same-repository PR set.\nAggregate mode returns when any row needs work, every row is terminal, or timeout.\nWhen CLAUDE_CODE_REMOTE=true, the command runs one tick like iterate and prints nextCheck instead.\nPoll exits as soon as iterate returns READY, MARK_READY, CANCEL, or ESCALATE, or when timeout\nreturns the last WAIT result. TRIAGE starts a --debounce settle window (default:\npoll.debounce-seconds; 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 [PR ...] [poll-flags] [iterate-flags]\n\nUse 'pr-shepherd stack PR' for a native GitHub stack.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m).\n --debounce <duration> Settle window after first TRIAGE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT/MARK_READY until READY/TRIAGE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Leave draft PRs in draft; stop when otherwise ready.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\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.quiet-status can change that default, --quiet-status/--no-quiet-status override it, and --verbose emits detailed per-tick lines.\nTRIAGE 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, TRIAGE, 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, ready-delay elapsed, or clean draft left in draft by disabled auto mark-ready)\n 10 WAIT or READY (including a WAIT returned by --timeout)\n 11 MARK_READY\n 12 TRIAGE\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
|
+
readonly default: "pr-shepherd [PR]\n\nRun iterate repeatedly for one PR, or read compact summaries for an explicit same-repository PR set.\nAggregate mode returns when any row needs work, every row is terminal, or timeout.\nWhen CLAUDE_CODE_REMOTE=true, the command runs one tick like iterate and prints nextCheck instead.\nPoll exits as soon as iterate returns READY, MARK_READY, CANCEL, or ESCALATE, or when timeout\nreturns the last WAIT result. TRIAGE starts a --debounce settle window (default:\npoll.debounce-seconds; 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 [PR ...] [poll-flags] [iterate-flags]\n\nUse 'pr-shepherd stack PR' for a native GitHub stack.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s). Stack and multi-PR polls multiply that by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m, for foreground waits).\n --debounce <duration> Settle window after first TRIAGE or stack SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT/MARK_READY until READY/TRIAGE/MERGE/CANCEL/ESCALATE or stack SHEPHERD.\n For background runs that wake the caller on exit; foreground waits use the bounded default.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Leave draft PRs in draft; stop when otherwise ready.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\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.quiet-status can change that default, --quiet-status/--no-quiet-status override it, and --verbose emits detailed per-tick lines.\nTRIAGE 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, TRIAGE, 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, ready-delay elapsed, or clean draft left in draft by disabled auto mark-ready)\n 10 WAIT or READY (including a WAIT returned by --timeout)\n 11 MARK_READY\n 12 TRIAGE\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).";
|
|
3
3
|
readonly "apply merge": `pr-shepherd apply merge
|
|
4
4
|
|
|
5
5
|
Submit one SHA-guarded asynchronous merge or enqueue request with REST.
|
|
@@ -162,7 +162,7 @@ When CLAUDE_CODE_REMOTE=true, state is the durable copy under the git common dir
|
|
|
162
162
|
--help, -h Print this help and exit before any cleanup.`;
|
|
163
163
|
readonly "admin log-file": "pr-shepherd admin 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 admin 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 CLAUDE_CODE_REMOTE=true reports the durable log under the git common directory.\n\nExit code: 0 on success; 1 if repository identity cannot be resolved.";
|
|
164
164
|
readonly iterate: "pr-shepherd iterate\n\nRun one tick and return without sleeping. The no-subcommand form polls; use this subcommand when the\ncaller owns the next wake-up. One PR prints one action and an action-specific ## Instructions section.\nSeveral same-repository PRs print one aggregate summary. Unless nothing remains to wait for, the output\ncarries nextCheck: when to rerun if no GitHub event arrives first.\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. Default: iterate.ready-delay-minutes (built-in 0). Example: 15m.\n --stall-timeout <duration> Escalate repeated unchanged failures after this duration. Bare number = minutes. 0 disables.\n --no-auto-mark-ready Leave draft PRs in draft; stop when otherwise ready.\n --merge Shepherd through readiness, then emit a merge or merge-queue command.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\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 TRIAGE Agent action is required; follow the instructions, then continue polling.\n CANCEL Stop polling this pull request: merged/closed, ready-delay elapsed, or a clean draft left in draft because auto mark-ready is disabled. 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, ready-delay elapsed, or clean draft left in draft by disabled auto mark-ready)\n 10 WAIT or READY\n 11 MARK_READY\n 12 TRIAGE\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).";
|
|
165
|
-
readonly stack: "pr-shepherd stack\n\nShepherd every open PR in one PR's native GitHub stack, bottom to top. Each poll reads compact\nper-layer summaries and returns when a layer needs work, every layer is terminal, or timeout.\nSHEPHERD lists one-PR sessions to run before rerunning this command.\n--once, or CLAUDE_CODE_REMOTE=true, runs one aggregate tick and prints nextCheck instead of sleeping.\n\nUsage:\n pr-shepherd stack PR [--once] [poll-flags] [iterate-flags]\n\nStack flags:\n --once Run one aggregate tick without sleeping; poll flags are ignored.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s) multiplied by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m).\n --debounce <duration> Settle window after the first SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT until SHEPHERD, MERGE, CANCEL, or ESCALATE.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). 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 --merge Shepherd through readiness, then emit the stack merge commands.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include 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).\n\nExit codes:\n 0 CANCEL (every layer merged)\n 10 WAIT\n 13 ESCALATE\n 14 CANCEL (a layer closed without merging)\n 15 MERGE\n 16 SHEPHERD (run the listed one-PR sessions, then rerun this stack command)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
165
|
+
readonly stack: "pr-shepherd stack\n\nShepherd every open PR in one PR's native GitHub stack, bottom to top. Each poll reads compact\nper-layer summaries and returns when a layer needs work, every layer is terminal, or timeout.\nSHEPHERD lists one-PR sessions to run before rerunning this command.\n--once, or CLAUDE_CODE_REMOTE=true, runs one aggregate tick and prints nextCheck instead of sleeping.\n\nUsage:\n pr-shepherd stack PR [--once] [poll-flags] [iterate-flags]\n\nStack flags:\n --once Run one aggregate tick without sleeping; poll flags are ignored.\n\nPoll flags:\n --interval <duration> Sleep between WAIT ticks. Bare number = seconds. Default: poll.interval-seconds (built-in 60s) multiplied by poll.stack-interval-factor (built-in 2) unless this flag is set.\n --timeout <duration> Maximum wall-clock wait for WAIT ticks. Bare number = seconds. Default: poll.timeout-seconds (built-in 4.5m, for foreground waits).\n --debounce <duration> Settle window after the first SHEPHERD before returning. Bare number = seconds. Default: poll.debounce-seconds (built-in 60s). 0 disables.\n --quiet-status Print only changed WAIT snapshots. Overrides poll.quiet-status.\n --no-quiet-status Print every WAIT snapshot. Overrides poll.quiet-status.\n --until-terminal Continue through WAIT until SHEPHERD, MERGE, CANCEL, or ESCALATE.\n\nForwarded iterate flags:\n --ready-delay <duration> Settle window before a clean PR cancels. Bare number = minutes. Default: iterate.ready-delay-minutes (built-in 0). 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 --merge Shepherd through readiness, then emit the stack merge commands.\n --instructions playbook|inline Render triage steps inline every tick (default) or fold the invariant ones into a playbook pointer. Default: iterate.instructions (inline).\n --transport auto|graphql|rest Select GitHub transport. Default: github.transport (auto).\n --format text|json Output Markdown text or JSON. Default: text.\n --verbose Include 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).\n\nExit codes:\n 0 CANCEL (every layer merged)\n 10 WAIT\n 13 ESCALATE\n 14 CANCEL (a layer closed without merging)\n 15 MERGE\n 16 SHEPHERD (run the listed one-PR sessions, then rerun this stack command)\n A command/validation/GitHub failure exits with a sysexits.h code instead (see docs/exit-codes.md).";
|
|
166
166
|
readonly "journal extract": `pr-shepherd journal extract
|
|
167
167
|
|
|
168
168
|
Extract one visible, structurally valid Shepherd Journal from a local PR-body file.
|
|
@@ -78,6 +78,10 @@ async function runIterateCore(opts, tick) {
|
|
|
78
78
|
reviewOutputMaxChars: config.iterate["review-output-max-chars"],
|
|
79
79
|
}, checkContext);
|
|
80
80
|
tick.report = report;
|
|
81
|
+
if (opts.eventTargetSink) {
|
|
82
|
+
opts.eventTargetSink.headSha = report.headSha;
|
|
83
|
+
opts.eventTargetSink.headRef = report.headRefName;
|
|
84
|
+
}
|
|
81
85
|
const [repoOwner, repoName] = report.repo.split("/");
|
|
82
86
|
if (!repoOwner || !repoName) {
|
|
83
87
|
throw new ShepherdError(`Unexpected repo format: "${report.repo}" (expected "owner/name")`, EXIT.DATAERR);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IterateResult, PollSummaryResult } from "../types.mts";
|
|
2
|
+
import type { WatchTarget } from "../events/types.mts";
|
|
3
|
+
interface WaitTickInput {
|
|
4
|
+
/** Progress prefix, e.g. `poll tick 3 / +45s`. */
|
|
5
|
+
label: string;
|
|
6
|
+
targets: readonly WatchTarget[];
|
|
7
|
+
sleepMs: number;
|
|
8
|
+
intervalMs: number;
|
|
9
|
+
tickStartedAt: number;
|
|
10
|
+
/** Time left in the poll window; `Infinity` for `--until-terminal`. */
|
|
11
|
+
remainingMs: number;
|
|
12
|
+
recheck: boolean;
|
|
13
|
+
/** Epoch ms of a time-based deadline that caps the healthy event wait. */
|
|
14
|
+
deadlineAt?: number;
|
|
15
|
+
/** Which timer `deadlineAt` belongs to: `stall-timeout`, `ready-delay`, or `CI-start`. */
|
|
16
|
+
deadlineReason?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface PollEvents {
|
|
19
|
+
engaged(targets: readonly WatchTarget[]): boolean;
|
|
20
|
+
/** Wait for the next tick. Returns true when the poll window elapsed with no event. */
|
|
21
|
+
waitTick(input: WaitTickInput): Promise<boolean>;
|
|
22
|
+
close(): void;
|
|
23
|
+
}
|
|
24
|
+
/** Run a poll with its event wait (if configured), always closing the source afterwards. */
|
|
25
|
+
export declare function withPollEvents<T>(verbose: boolean, run: (events: PollEvents | undefined) => Promise<T>): Promise<T>;
|
|
26
|
+
export interface PauseInput extends WaitTickInput {
|
|
27
|
+
events: PollEvents | undefined;
|
|
28
|
+
/** `viaEvents` is true when the pause waits for an event rather than sleeping. */
|
|
29
|
+
announce: (viaEvents: boolean) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Pause until the next tick, by event wait when engaged and by plain sleep otherwise. Returns
|
|
33
|
+
* true when the poll should stop: the window is over, or (without events) the next sleep would
|
|
34
|
+
* not fit in what is left. `announce` runs once the pause is certain, before it starts.
|
|
35
|
+
*/
|
|
36
|
+
export declare function pauseBeforeNextTick(input: PauseInput): Promise<boolean>;
|
|
37
|
+
/** The one PR a single-PR tick watched; head SHA and ref come from that tick's batch data. */
|
|
38
|
+
export declare function onePrTargets(result: Pick<IterateResult, "repo" | "pr" | "baseBranch">, head: {
|
|
39
|
+
headSha?: string;
|
|
40
|
+
headRef?: string;
|
|
41
|
+
}): WatchTarget[];
|
|
42
|
+
/** Every open PR of an aggregate tick. */
|
|
43
|
+
export declare function aggregateTargets(result: PollSummaryResult): WatchTarget[];
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { loadConfig } from "../config/load.mjs";
|
|
2
|
+
import { resolveEventsSource } from "../events/config.mjs";
|
|
3
|
+
import { createRelayTransport, RELAY_REQUEST_TIMEOUT_MS } from "../events/relay.mjs";
|
|
4
|
+
import { createServeTransport } from "../events/serve.mjs";
|
|
5
|
+
import { createEventWaiter } from "../events/waiter.mjs";
|
|
6
|
+
import { githubFetch } from "../github/github-fetch.mjs";
|
|
7
|
+
import { appendEntry } from "../log/log-file.mjs";
|
|
8
|
+
import { sleep } from "../util/sleep.mjs";
|
|
9
|
+
const TIMER_DRIFT_TOLERANCE_MS = 500;
|
|
10
|
+
function describe(wake, degraded) {
|
|
11
|
+
if (wake.kind === "timer")
|
|
12
|
+
return degraded ? "timer (events unavailable)" : "fallback timer";
|
|
13
|
+
const { event, action, repo } = wake.event;
|
|
14
|
+
return `${action ? `${event}.${action}` : event} ${repo ?? ""}`.trim();
|
|
15
|
+
}
|
|
16
|
+
function createTransport(startMs) {
|
|
17
|
+
const source = resolveEventsSource();
|
|
18
|
+
return source.kind === "serve"
|
|
19
|
+
? createServeTransport(source, startMs, {
|
|
20
|
+
fetch: (input, init) => globalThis.fetch(input, init),
|
|
21
|
+
})
|
|
22
|
+
: createRelayTransport(source, startMs, {
|
|
23
|
+
fetch: (input, init) => githubFetch(input, init, RELAY_REQUEST_TIMEOUT_MS),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The event-driven wait for a poll loop, or `undefined` when `events.source` is `none`. Captures
|
|
28
|
+
* the start time now, before the first tick snapshots GitHub, so no event in between is missed.
|
|
29
|
+
* Throws a config error when hook-harness is selected but no source resolves.
|
|
30
|
+
*/
|
|
31
|
+
function createPollEvents(verbose) {
|
|
32
|
+
const config = loadConfig().events;
|
|
33
|
+
if (config.source === "none")
|
|
34
|
+
return undefined;
|
|
35
|
+
const note = (message) => {
|
|
36
|
+
if (verbose)
|
|
37
|
+
process.stderr.write(`${message}\n`);
|
|
38
|
+
appendEntry(`- ${message}\n`);
|
|
39
|
+
};
|
|
40
|
+
const waiter = createEventWaiter({
|
|
41
|
+
transport: createTransport(Date.now()),
|
|
42
|
+
fallbackMs: config["fallback-interval-seconds"] * 1000,
|
|
43
|
+
deps: { now: () => Date.now(), sleep },
|
|
44
|
+
note,
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
engaged: (targets) => waiter.engaged(targets),
|
|
48
|
+
close: () => waiter.close(),
|
|
49
|
+
async waitTick(input) {
|
|
50
|
+
const waitStart = Date.now();
|
|
51
|
+
const { wake, degraded } = await waiter.wait({
|
|
52
|
+
targets: input.targets,
|
|
53
|
+
sleepMs: input.sleepMs,
|
|
54
|
+
windowMs: input.remainingMs,
|
|
55
|
+
recheck: input.recheck,
|
|
56
|
+
// Events never make ticks more frequent than plain polling would.
|
|
57
|
+
minGapMs: input.sleepMs,
|
|
58
|
+
tickStartedAt: input.tickStartedAt,
|
|
59
|
+
...(input.deadlineAt !== undefined && { deadlineAt: input.deadlineAt }),
|
|
60
|
+
});
|
|
61
|
+
const atDeadline = wake.kind === "timer" &&
|
|
62
|
+
!degraded &&
|
|
63
|
+
input.deadlineAt !== undefined &&
|
|
64
|
+
Date.now() + TIMER_DRIFT_TOLERANCE_MS >= input.deadlineAt;
|
|
65
|
+
note(`[${input.label}] woke on ${atDeadline ? `${input.deadlineReason ?? "time-based"} deadline` : describe(wake, degraded)}`);
|
|
66
|
+
return (wake.kind === "timer" &&
|
|
67
|
+
Date.now() - waitStart + TIMER_DRIFT_TOLERANCE_MS >= input.remainingMs);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Run a poll with its event wait (if configured), always closing the source afterwards. */
|
|
72
|
+
export async function withPollEvents(verbose, run) {
|
|
73
|
+
const events = createPollEvents(verbose);
|
|
74
|
+
try {
|
|
75
|
+
return await run(events);
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
events?.close();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Pause until the next tick, by event wait when engaged and by plain sleep otherwise. Returns
|
|
83
|
+
* true when the poll should stop: the window is over, or (without events) the next sleep would
|
|
84
|
+
* not fit in what is left. `announce` runs once the pause is certain, before it starts.
|
|
85
|
+
*/
|
|
86
|
+
export async function pauseBeforeNextTick(input) {
|
|
87
|
+
const { events, announce, ...wait } = input;
|
|
88
|
+
const viaEvents = events?.engaged(wait.targets) === true;
|
|
89
|
+
const { remainingMs, sleepMs } = wait;
|
|
90
|
+
if (remainingMs <= 0 || (!viaEvents && remainingMs + TIMER_DRIFT_TOLERANCE_MS < sleepMs)) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
announce(viaEvents);
|
|
94
|
+
if (!events || !viaEvents) {
|
|
95
|
+
await sleep(sleepMs);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return events.waitTick(wait);
|
|
99
|
+
}
|
|
100
|
+
/** The one PR a single-PR tick watched; head SHA and ref come from that tick's batch data. */
|
|
101
|
+
export function onePrTargets(result, head) {
|
|
102
|
+
return [
|
|
103
|
+
{
|
|
104
|
+
repo: result.repo,
|
|
105
|
+
pr: result.pr,
|
|
106
|
+
baseRef: result.baseBranch,
|
|
107
|
+
...(head.headSha && { headSha: head.headSha }),
|
|
108
|
+
...(head.headRef && { headRef: head.headRef }),
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
/** Every open PR of an aggregate tick. */
|
|
113
|
+
export function aggregateTargets(result) {
|
|
114
|
+
return result.prs
|
|
115
|
+
.filter((item) => item.state === "OPEN")
|
|
116
|
+
.map((item) => ({
|
|
117
|
+
repo: item.repo,
|
|
118
|
+
pr: item.pr,
|
|
119
|
+
headSha: item.headRefOid,
|
|
120
|
+
headRef: item.headRefName,
|
|
121
|
+
baseRef: item.baseRefName,
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IterateCommandOptions } from "../types.mts";
|
|
2
|
+
export interface PollCommandOptions extends IterateCommandOptions {
|
|
3
|
+
intervalSeconds: number;
|
|
4
|
+
timeoutSeconds: number;
|
|
5
|
+
/** Settle window after first TRIAGE before returning. Default 60. 0 disables. */
|
|
6
|
+
debounceSeconds?: number;
|
|
7
|
+
quietStatus?: boolean;
|
|
8
|
+
untilTerminal?: boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,6 +6,8 @@ export declare function writeWaitProgress(opts: {
|
|
|
6
6
|
tick: number;
|
|
7
7
|
elapsedMs: number;
|
|
8
8
|
sleepMs: number;
|
|
9
|
+
/** The pause waits for a hook-harness event, so `sleepMs` is not its length. */
|
|
10
|
+
viaEvents?: boolean;
|
|
9
11
|
result: WaitResult;
|
|
10
12
|
quietStatus: boolean;
|
|
11
13
|
verbose: boolean;
|
|
@@ -23,7 +23,7 @@ function waitSignature(result) {
|
|
|
23
23
|
reviewItemsSinceLatestCommit: activity.reviewItemsSinceLatestCommit.length,
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function writeQuietStatus(tick, elapsedSeconds, sleepSeconds, result) {
|
|
26
|
+
function writeQuietStatus(tick, elapsedSeconds, sleepSeconds, result, viaEvents) {
|
|
27
27
|
const activeChecks = result.inProgressChecks ?? [];
|
|
28
28
|
const activeCheckText = activeChecks.map((c) => `${c.name} (${c.status})`).join(", ");
|
|
29
29
|
const active = activeChecks.length > 0 ? ` · active: ${activeCheckText}` : "";
|
|
@@ -33,7 +33,7 @@ function writeQuietStatus(tick, elapsedSeconds, sleepSeconds, result) {
|
|
|
33
33
|
const commitSeg = commitCount > 0 ? ` · ${commitCount} commits` : "";
|
|
34
34
|
const reviewRoundSeg = reviewRounds > 0 ? ` · ${reviewRounds} review rounds` : "";
|
|
35
35
|
const reviewSeg = reviewItems > 0 ? ` · ${reviewItems} review items since latest commit` : "";
|
|
36
|
-
process.stderr.write(`[poll tick ${tick} / +${elapsedSeconds}s] WAIT ${result.status}/${result.mergeStateStatus}/${result.reviewDecision ?? "NO_REVIEW_DECISION"}${active}${commitSeg}${reviewRoundSeg}${reviewSeg} — sleeping ${sleepSeconds}s\n`);
|
|
36
|
+
process.stderr.write(`[poll tick ${tick} / +${elapsedSeconds}s] WAIT ${result.status}/${result.mergeStateStatus}/${result.reviewDecision ?? "NO_REVIEW_DECISION"}${active}${commitSeg}${reviewRoundSeg}${reviewSeg} — ${viaEvents ? "waiting for an event" : `sleeping ${sleepSeconds}s`}\n`);
|
|
37
37
|
}
|
|
38
38
|
export function writeWaitProgress(opts) {
|
|
39
39
|
const elapsedSeconds = Math.round(opts.elapsedMs / 1000);
|
|
@@ -41,12 +41,14 @@ export function writeWaitProgress(opts) {
|
|
|
41
41
|
if (!opts.quietStatus) {
|
|
42
42
|
const reason = waitReason(opts.result);
|
|
43
43
|
// The tick interval is the caller's own `--interval`; only verbose mode repeats it.
|
|
44
|
-
writeTickProgress(opts.tick, elapsedSeconds, opts.verbose
|
|
44
|
+
writeTickProgress(opts.tick, elapsedSeconds, opts.verbose
|
|
45
|
+
? `${reason} — ${opts.viaEvents ? "waiting for an event" : `sleeping ${sleepSeconds}s`}`
|
|
46
|
+
: reason);
|
|
45
47
|
return opts.lastWaitSignature;
|
|
46
48
|
}
|
|
47
49
|
const signature = waitSignature(opts.result);
|
|
48
50
|
if (signature !== opts.lastWaitSignature) {
|
|
49
|
-
writeQuietStatus(opts.tick, elapsedSeconds, sleepSeconds, opts.result);
|
|
51
|
+
writeQuietStatus(opts.tick, elapsedSeconds, sleepSeconds, opts.result, opts.viaEvents === true);
|
|
50
52
|
}
|
|
51
53
|
return signature;
|
|
52
54
|
}
|
|
@@ -7,6 +7,8 @@ export declare function quotaPollIntervalMs(bands: GraphqlQuotaWarningBand[], us
|
|
|
7
7
|
graphql?: Pick<GraphqlApiUsage, "remaining" | "limit">;
|
|
8
8
|
rest?: Pick<ApiResourceUsage, "resource" | "remaining" | "limit">[];
|
|
9
9
|
} | undefined, fallbackMs: number, maxMs: number, transport?: "graphql" | "rest"): number;
|
|
10
|
+
/** The plain poll sleep for a single-PR tick: the interval raised by any quota band. */
|
|
11
|
+
export declare function onePrSleepMs(bands: GraphqlQuotaWarningBand[], usage: Parameters<typeof quotaPollIntervalMs>[1], intervalMs: number, maxMs: number): number;
|
|
10
12
|
export interface RateLimitRetry {
|
|
11
13
|
ms: number;
|
|
12
14
|
resource: string;
|
|
@@ -25,6 +25,10 @@ export function quotaPollIntervalMs(bands, usage, fallbackMs, maxMs, transport)
|
|
|
25
25
|
const core = usage?.rest?.find((item) => item.resource === "core");
|
|
26
26
|
return Math.max(graphqlQuotaPollIntervalMs(bands, transport === "rest" ? undefined : usage?.graphql, fallbackMs, maxMs), graphqlQuotaPollIntervalMs(bands, core, fallbackMs, maxMs));
|
|
27
27
|
}
|
|
28
|
+
/** The plain poll sleep for a single-PR tick: the interval raised by any quota band. */
|
|
29
|
+
export function onePrSleepMs(bands, usage, intervalMs, maxMs) {
|
|
30
|
+
return quotaPollIntervalMs(bands, usage, intervalMs, maxMs, getGithubTransport());
|
|
31
|
+
}
|
|
28
32
|
/**
|
|
29
33
|
* Retry delay for `--until-terminal` when GitHub exhausts a primary quota or
|
|
30
34
|
* returns a secondary limit. `null` means the error is not a retryable rate limit.
|
|
@@ -13,7 +13,7 @@ export function onlyDraftVerificationSelection(result) {
|
|
|
13
13
|
isDraftReadinessVerification(item)));
|
|
14
14
|
}
|
|
15
15
|
/** Rerunning is mandatory while any selected row is non-terminal; a finished one-PR poll is not the end. */
|
|
16
|
-
const KEEP_WATCHING = "Do not end the turn while any selected row is non-terminal: a one-PR poll returning `CANCEL` or `ESCALATE` finishes only that row, and rows that are `CANCEL`, `ESCALATE`, or handed off do not count.";
|
|
16
|
+
const KEEP_WATCHING = "Do not end the turn while any selected row is non-terminal: a one-PR poll returning `CANCEL` or `ESCALATE` finishes only that row, and rows that are `CANCEL`, `ESCALATE`, or handed off do not count. If a background exit wakes you, end the turn and continue then.";
|
|
17
17
|
export function explicitInstructions(result, rerunCommand) {
|
|
18
18
|
const again = rerunCommand ? `\`${rerunCommand}\`` : "this aggregate command";
|
|
19
19
|
if (result.reason === "all_terminal")
|
|
@@ -5,6 +5,7 @@ export interface AggregatePollCommandOptions extends PollSummaryCommandOptions {
|
|
|
5
5
|
debounceSeconds?: number;
|
|
6
6
|
quietStatus?: boolean;
|
|
7
7
|
untilTerminal?: boolean;
|
|
8
|
+
verbose?: boolean;
|
|
8
9
|
}
|
|
9
10
|
export declare function runPollSummary(opts: PollSummaryCommandOptions): Promise<PollSummaryResult>;
|
|
10
11
|
export declare function runAggregatePoll(opts: AggregatePollCommandOptions): Promise<PollSummaryResult>;
|
|
@@ -7,15 +7,15 @@ import { withApiTelemetryScope, summarizeApiTelemetry } from "../github/api-tele
|
|
|
7
7
|
import { aggregateRerunCommand } from "../github/poll-summary-command.mjs";
|
|
8
8
|
import { fetchPollSummary } from "../github/poll-summary.mjs";
|
|
9
9
|
import { writeStackHandoffs } from "../github/stack-handoff.mjs";
|
|
10
|
-
import { sleep } from "../util/sleep.mjs";
|
|
11
10
|
import { aggregateQuotaWarning, carryQuotaWarning, quotaPollIntervalMs } from "./poll-quota.mjs";
|
|
12
11
|
import { aggregateCancelFromPulls, aggregateRateLimitTargets } from "./poll-rate-limit-cancel.mjs";
|
|
13
12
|
import { createUntilTerminalRateLimitRetry } from "./poll-rate-limit-wait.mjs";
|
|
14
13
|
import { planPollSummary, withPollSummaryInstructions } from "./poll-summary-instructions.mjs";
|
|
15
14
|
import { summaryStatusSignature } from "./poll-summary-signature.mjs";
|
|
16
15
|
import { applyStackStallGuard } from "./stack-stall.mjs";
|
|
16
|
+
import { aggregateDeadline } from "./stall-deadline.mjs";
|
|
17
|
+
import { aggregateTargets, pauseBeforeNextTick, withPollEvents, } from "./poll-events.mjs";
|
|
17
18
|
const MAX_TIMER_MS = 2 ** 31 - 1;
|
|
18
|
-
const TIMER_DRIFT_TOLERANCE_MS = 500;
|
|
19
19
|
export function runPollSummary(opts) {
|
|
20
20
|
return withApiTelemetryScope(async () => {
|
|
21
21
|
const tick = await readPollSummaryTick(opts);
|
|
@@ -24,7 +24,7 @@ export function runPollSummary(opts) {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
export function runAggregatePoll(opts) {
|
|
27
|
-
return withApiTelemetryScope(() => runAggregatePollCore(opts));
|
|
27
|
+
return withPollEvents(opts.verbose === true, (events) => withApiTelemetryScope(() => runAggregatePollCore(opts, events)));
|
|
28
28
|
}
|
|
29
29
|
async function runPollSummaryCore(opts) {
|
|
30
30
|
return (await readPollSummaryTick(opts)).result;
|
|
@@ -65,7 +65,7 @@ async function readPollSummaryTick(opts) {
|
|
|
65
65
|
const result = await applyStackStallGuard(planned, repo, opts.stallTimeoutSeconds ?? loadConfig().iterate["stall-timeout-minutes"] * 60);
|
|
66
66
|
return { result, repo, ...(fetched.handoffSource && { handoffSource: fetched.handoffSource }) };
|
|
67
67
|
}
|
|
68
|
-
async function runAggregatePollCore(opts) {
|
|
68
|
+
async function runAggregatePollCore(opts, events) {
|
|
69
69
|
const intervalMs = Math.min(opts.intervalSeconds * 1000, MAX_TIMER_MS);
|
|
70
70
|
const timeoutMs = Math.min(opts.timeoutSeconds * 1000, MAX_TIMER_MS);
|
|
71
71
|
const debounceMs = Math.min((opts.debounceSeconds ?? 60) * 1000, MAX_TIMER_MS);
|
|
@@ -80,6 +80,7 @@ async function runAggregatePollCore(opts) {
|
|
|
80
80
|
let pendingQuotaWarning;
|
|
81
81
|
while (true) {
|
|
82
82
|
tick += 1;
|
|
83
|
+
const tickStartedAt = Date.now();
|
|
83
84
|
try {
|
|
84
85
|
lastTick = await readPollSummaryTick(opts);
|
|
85
86
|
last = lastTick.result;
|
|
@@ -178,20 +179,31 @@ async function runAggregatePollCore(opts) {
|
|
|
178
179
|
const sleepMs = debounceUntil
|
|
179
180
|
? Math.min(intervalMs, Math.max(debounceUntil - Date.now(), 0))
|
|
180
181
|
: quotaPollIntervalMs(quotaBands, summarizeApiTelemetry(), intervalMs, MAX_TIMER_MS, getGithubTransport());
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
182
|
+
const useEvents = debounceUntil ? undefined : events;
|
|
183
|
+
const deadline = useEvents && (await aggregateDeadline(last, opts.stallTimeoutSeconds));
|
|
184
|
+
const stop = await pauseBeforeNextTick({
|
|
185
|
+
// The settle window after a first TRIAGE is a plain timer, never an event wait.
|
|
186
|
+
events: useEvents,
|
|
187
|
+
...deadline,
|
|
188
|
+
targets: aggregateTargets(last),
|
|
189
|
+
recheck: last.prs.some((item) => item.mergeStateStatus === "UNKNOWN"),
|
|
190
|
+
sleepMs,
|
|
191
|
+
intervalMs,
|
|
192
|
+
label: `aggregate poll tick ${tick} / +${Math.round(elapsedMs / 1000)}s`,
|
|
193
|
+
tickStartedAt,
|
|
194
|
+
remainingMs: opts.untilTerminal || debounceUntil !== null ? Infinity : timeoutMs - elapsedMs,
|
|
195
|
+
announce: () => {
|
|
196
|
+
const statusSignature = summaryStatusSignature(last);
|
|
197
|
+
if (!opts.quietStatus || hasFix || statusSignature !== lastStatusSignature) {
|
|
198
|
+
process.stderr.write(`[aggregate poll tick ${tick} / +${Math.round(elapsedMs / 1000)}s] ${last.prs
|
|
199
|
+
.map((item) => `#${item.pr} ${item.action.toUpperCase()}`)
|
|
200
|
+
.join(", ")}\n`);
|
|
201
|
+
}
|
|
202
|
+
lastStatusSignature = statusSignature;
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
if (stop)
|
|
206
|
+
return attachUsage({ ...last, reason: "timeout" }, opts);
|
|
195
207
|
}
|
|
196
208
|
}
|
|
197
209
|
/** An auto-resolve is a one-tick event; forward it so a swallowed tick still records it. */
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IterateResult } from "../types.mts";
|
|
2
|
+
import type { RateLimitProbePull, RateLimitPullTarget } from "./poll-rate-limit-cancel.mts";
|
|
3
|
+
import type { createUntilTerminalRateLimitRetry } from "./poll-rate-limit-wait.mts";
|
|
4
|
+
export interface TickRunnerInput {
|
|
5
|
+
/** One iterate read; `fingerprintCache` allows reuse of a previous WAIT-shaped report. */
|
|
6
|
+
run: (fingerprintCache: boolean) => Promise<IterateResult>;
|
|
7
|
+
retry: ReturnType<typeof createUntilTerminalRateLimitRetry>;
|
|
8
|
+
untilTerminal: boolean;
|
|
9
|
+
intervalMs: number;
|
|
10
|
+
tickLabel: string;
|
|
11
|
+
startedAt: number;
|
|
12
|
+
/** Read lazily: the last result can change between a tick and its retry. */
|
|
13
|
+
targets: () => RateLimitPullTarget[];
|
|
14
|
+
onAllTerminal: (pulls: RateLimitProbePull[]) => IterateResult | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** One poll tick that waits out GitHub rate limits instead of failing. */
|
|
17
|
+
export declare function createTickRunner(input: TickRunnerInput): (fingerprintCache: boolean) => Promise<IterateResult>;
|