pr-shepherd 0.45.0 → 0.46.1

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.
Files changed (61) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +20 -9
  3. package/bin/api.d.mts +2 -2
  4. package/bin/checks/conclusions.d.mts +0 -16
  5. package/bin/checks/conclusions.mjs +0 -27
  6. package/bin/cli/fix-formatter.mjs +10 -4
  7. package/bin/cli/help-command-pages.d.mts +16 -5
  8. package/bin/cli/help-command-pages.mjs +16 -5
  9. package/bin/cli/help-top-page.d.mts +1 -1
  10. package/bin/cli/help-top-page.mjs +3 -1
  11. package/bin/cli/help.d.mts +17 -6
  12. package/bin/cli/help.mjs +2 -0
  13. package/bin/cli/iterate-checks-formatter.d.mts +2 -0
  14. package/bin/cli/iterate-checks-formatter.mjs +55 -0
  15. package/bin/cli/iterate-formatter.mjs +7 -2
  16. package/bin/cli/iterate-lean.mjs +4 -0
  17. package/bin/cli/journal-extract-handler.d.mts +2 -0
  18. package/bin/cli/journal-extract-handler.mjs +48 -0
  19. package/bin/cli/mark-files-as-viewed-formatter.mjs +7 -6
  20. package/bin/cli/safe-body-file.d.mts +14 -0
  21. package/bin/cli/safe-body-file.mjs +42 -0
  22. package/bin/cli-parser.mjs +7 -0
  23. package/bin/commands/check-status.mjs +4 -4
  24. package/bin/commands/check.mjs +25 -5
  25. package/bin/commands/iterate/api-usage.mjs +1 -8
  26. package/bin/commands/iterate/check-instructions.d.mts +2 -2
  27. package/bin/commands/iterate/check-instructions.mjs +8 -32
  28. package/bin/commands/iterate/classify.mjs +2 -1
  29. package/bin/commands/iterate/escalate.mjs +63 -9
  30. package/bin/commands/iterate/fix-code.mjs +83 -80
  31. package/bin/commands/iterate/index.mjs +2 -2
  32. package/bin/commands/iterate/merge-state.mjs +8 -37
  33. package/bin/commands/iterate/merge.mjs +1 -0
  34. package/bin/commands/iterate/render.d.mts +1 -1
  35. package/bin/commands/iterate/render.mjs +16 -13
  36. package/bin/commands/journal/index.d.mts +1 -0
  37. package/bin/commands/journal/index.mjs +1 -10
  38. package/bin/commands/mark-files-as-viewed.d.mts +2 -1
  39. package/bin/commands/mark-files-as-viewed.mjs +116 -4
  40. package/bin/commands/poll.mjs +1 -4
  41. package/bin/commands/resolve-mutate.mjs +17 -40
  42. package/bin/comments/resolve.d.mts +4 -0
  43. package/bin/comments/resolve.mjs +10 -4
  44. package/bin/comments/review-visibility.d.mts +1 -1
  45. package/bin/comments/review-visibility.mjs +3 -2
  46. package/bin/comments/thread-visibility.d.mts +1 -1
  47. package/bin/comments/thread-visibility.mjs +9 -3
  48. package/bin/github/client.d.mts +1 -2
  49. package/bin/github/client.mjs +1 -4
  50. package/bin/github/gql/get-pr-body.gql +0 -1
  51. package/bin/mcp/server.mjs +2 -2
  52. package/bin/pr-reference.d.mts +1 -1
  53. package/bin/pr-reference.mjs +1 -1
  54. package/bin/types/escalate.d.mts +5 -3
  55. package/bin/types/report.d.mts +1 -1
  56. package/package.json +2 -2
  57. package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
  58. package/plugins/pr-shepherd/.codex.mcp.json +1 -1
  59. package/plugins/pr-shepherd/.mcp.json +1 -1
  60. package/plugins/pr-shepherd/skills/mark-files-as-viewed/SKILL.md +2 -2
  61. package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +21 -15
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
3
  "description": "Autonomous PR CI monitor and review-comment resolver for agentic coding tools",
4
- "version": "0.45.0",
4
+ "version": "0.46.1",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com"
package/README.md CHANGED
@@ -25,14 +25,14 @@ Full reference: [docs/README.md](docs/README.md). Feature matrix: [docs/features
25
25
 
26
26
  `pr-shepherd` moves deterministic PR orchestration into a local MCP server, with a CLI for shells and CI. Both interfaces fetch the same GitHub state, emit raw-enough context, and return a numbered plan for the calling agent to follow.
27
27
 
28
- The MCP server exposes canonical `iterate`, `apply`, and `build_suggestion_patches` tools. `apply` accepts ordered review mutations, selection-only file-view diagnostics, and journal entries; the deprecated singular suggestion tool remains temporarily as an adapter. Direct MCP calls require a repository-qualified `pr`: a GitHub PR URL or `owner/repo#N`; the explicit repository is the target for GitHub I/O, even when it differs from the local checkout. The CLI and programmatic API also retain bare-number and current-branch PR discovery. The shipped skills are thin dispatchers for those tools.
28
+ The MCP server exposes canonical `iterate`, `apply`, and `build_suggestion_patches` tools. `apply` accepts ordered review mutations, file-view mutations, and journal entries; the deprecated singular suggestion tool remains temporarily as an adapter. Direct MCP calls require a repository-qualified `pr`: a GitHub PR URL or `owner/repo#N`; the explicit repository is the target for GitHub I/O, even when it differs from the local checkout. The CLI and programmatic API also retain bare-number and current-branch PR discovery. The shipped skills are thin dispatchers for those tools.
29
29
 
30
30
  Each tick returns exactly one action:
31
31
 
32
32
  - `WAIT` — no immediate action; continue with the next poll.
33
33
  - `MARK_READY` — the CLI converted an eligible draft PR to ready; continue polling.
34
- - `FIX_CODE` — agent work is required; complete it, then continue polling.
35
- - `MERGE` — run the emitted auto-merge command only when GitHub reports `viewerCanEnableAutoMerge`; queue enrollment otherwise hands off for authorization.
34
+ - `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.
35
+ - `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.
36
36
  - `CANCEL` — stop polling because the PR merged, closed, or completed its ready-delay.
37
37
  - `ESCALATE` — stop polling until a human provides direction.
38
38
 
@@ -77,19 +77,19 @@ Conversations Resolved: No [Not Required]
77
77
  9. `[FIX_CODE]` is non-terminal: if you changed code, commit and push to the PR head branch, then run review mutations using the pushed commit SHA and iterate again with the same options; without code changes, complete the authorized review mutations and iterate again.
78
78
  ```
79
79
 
80
- See [docs/actions.md](docs/actions.md) for the complete output contract. Iterate/poll PR outcomes use exit codes `0` and `10`–`15`; command and GitHub failures use `sysexits.h` codes — [docs/exit-codes.md](docs/exit-codes.md).
80
+ See [docs/actions.md](docs/actions.md) for the complete output contract and [docs/escalations.md](docs/escalations.md) for the exact finite human-handoff boundary. Iterate/poll PR outcomes use exit codes `0` and `10`–`15`; command and GitHub failures use `sysexits.h` codes — [docs/exit-codes.md](docs/exit-codes.md).
81
81
 
82
82
  ## Workflow Assumptions
83
83
 
84
84
  This system is opinionated and works best with PRs that use required status checks and conversation resolution.
85
85
 
86
86
  - A human inline thread whose original comment has `viewerDidAuthor: true` is replied to and resolved when its latest comment is unmarked. An unmarked other-human inline thread remains reply-only; a marker-ended other-human thread is already acknowledged and receives no further mutation. Human items are never minimized.
87
- - Detected bots and configured `botUsernames` review threads are returned until resolved; bot/non-human threads, PR comments, and review summaries can be resolved or minimized when eligible. Review summaries are not minimized while known inline child threads from that review remain unresolved.
87
+ - Detected bots and configured `botUsernames` review threads are returned until resolved when the required mutation is authorized and the thread has a source location. Unauthorized or unlocated items are surfaced once and then marker-gated until edited. Bot/non-human threads, PR comments, and review summaries can be resolved or minimized when eligible. Review summaries are not minimized while known inline child threads from that review remain unresolved.
88
88
  - Shepherd identifies its own latest reply only when that comment begins `<!-- pr-shepherd -->`, not from author equality. A marked viewer-authored thread can be resolved without another reply as a retry.
89
89
  - Every review thread/comment/review summary is surfaced at least once, even if already outdated, resolved, or minimized; edited items re-surface through seen markers.
90
90
  - Draft PRs can be marked ready automatically when clean; disable with `actions.autoMarkReady: false` or `--no-auto-mark-ready`.
91
- - The CLI never performs git mutations itself — it only emits commit/push instructions for the agent to run. It recommends pushing autonomously (own-repo PRs, and fork PRs where the viewer has push access to the fork) unless GitHub's viewer fields affirmatively report no head-branch push access, in which case it hands the push off to a human instead.
92
- - Every GitHub mutation is permission-aware. Shepherd uses raw viewer capability fields, omits unauthorized commands, and repeats authorization checks in direct `apply` commands. Missing capability data fails closed.
91
+ - The CLI never performs git mutations itself — it only emits commit/push instructions for the agent to run. Push access to the PR head is a usage precondition; GitHub viewer fields do not create a separate push-authorization handoff.
92
+ - Generated iterate mutations and automatic actions are capability-aware and omit unauthorized commands. Explicit `apply` operations honor the caller's intent and surface GitHub's result; semantic human-content protections still apply.
93
93
  - `build_suggestion_patches` turns one or more ordered GitHub suggestion threads into checked patches and commit metadata, but never edits the working tree or git history. Local HEAD may be ahead when the live PR head is its ancestor.
94
94
 
95
95
  ## Usage
@@ -128,7 +128,7 @@ pr-shepherd 42 --quiet-status # print only changed WAIT status snapshot
128
128
  pr-shepherd 42 --until-terminal # continue through WAIT/MARK_READY until work or terminal state
129
129
  pr-shepherd 42 --debounce 5m # wait 5m after first FIX_CODE, then return one batched tick
130
130
  pr-shepherd 42 --ready-delay 15m
131
- pr-shepherd 42 --merge # enable auto-merge when GitHub confirms viewer authorization
131
+ pr-shepherd 42 --merge # request head-pinned auto-merge/queue; GitHub reports the result
132
132
  pr-shepherd iterate 42 # single tick
133
133
  pr-shepherd owner/repo#42 # poll a PR in an explicit repository
134
134
  pr-shepherd https://github.com/owner/repo/pull/42
@@ -136,7 +136,7 @@ pr-shepherd https://github.com/owner/repo/pull/42
136
136
 
137
137
  ### Apply Review And Journal Changes, Or Select Files
138
138
 
139
- Use `apply` with ordered operations to reply/resolve/minimize/dismiss review items, select changed files for viewed-state authorization diagnostics, or append an idempotent Shepherd Journal item. File-view selection never mutates viewed state because GitHub exposes no exact viewer capability. Use `build_suggestion_patches` to turn ordered review suggestions into checked patches and commit metadata; it never changes the worktree or git history.
139
+ Use `apply` with ordered operations to reply/resolve/minimize/dismiss review items, mark selected changed files as viewed, or append an idempotent Shepherd Journal item. 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.
140
140
 
141
141
  ### Extract Shepherd Journal Entries
142
142
 
@@ -156,6 +156,17 @@ complete Markdown list item with LF line endings. It fails closed for malformed
156
156
  containers and ignores journal-shaped examples hidden in Markdown constructs. The full journal API,
157
157
  including append and reconciliation helpers, is documented in [docs/api.md](docs/api.md).
158
158
 
159
+ For shell automation that already has a PR body, use the equivalent local-only command:
160
+
161
+ ```sh
162
+ pr-shepherd journal extract --body-file pr-body.md
163
+ ```
164
+
165
+ It writes one JSON line containing the typed extraction result. It never reads GitHub credentials,
166
+ configuration, or Shepherd logs. On POSIX, its final body-file path entry must be a readable regular
167
+ file in a trusted parent directory; symlinks, FIFOs, and devices are rejected with exit code 66.
168
+ Unsupported platforms fail closed with that same exit code.
169
+
159
170
  ### Clean Local State
160
171
 
161
172
  `pr-shepherd` stores seen markers, fix-attempt counters, stall fingerprints, ready-delay markers, and logs under `$PR_SHEPHERD_STATE_DIR` (default `$TMPDIR/pr-shepherd-state`).
package/bin/api.d.mts CHANGED
@@ -22,7 +22,7 @@ export interface ReviewMutationsOperation {
22
22
  requireSha?: string;
23
23
  }
24
24
  export interface MarkFilesViewedOperation {
25
- /** Compatibility-named selection only; always skips mutation because authorization is unverifiable. */
25
+ /** Marks selected changed files as viewed. GitHub authorizes the requested mutation. */
26
26
  type: "mark_files_viewed";
27
27
  files?: string[];
28
28
  tests?: boolean;
@@ -33,7 +33,7 @@ export interface AppendJournalOperation {
33
33
  item: string;
34
34
  dryRun?: boolean;
35
35
  }
36
- /** Operations run in this exact list order after validation; file-view selection is non-mutating. */
36
+ /** Operations run in this exact list order after validation. */
37
37
  export type ApplyOperation = ReviewMutationsOperation | MarkFilesViewedOperation | AppendJournalOperation;
38
38
  export interface ApplyInput {
39
39
  /** PR shared by every operation in this ordered apply request. */
@@ -6,22 +6,6 @@ import type { CheckConclusion, ViewerAuthorization } from "../types.mts";
6
6
  * which covers fork push access — is the right field to gate on.
7
7
  */
8
8
  export declare function canRerunWorkflows(auth: ViewerAuthorization | undefined): boolean;
9
- /**
10
- * True when the viewer can push commits to the PR head branch — the fork, for a fork PR
11
- * (own-fork PRs report `headRepositoryPermission: "ADMIN"`), or the base repo otherwise.
12
- * `viewerCanEditFiles` is GitHub's direct "can the viewer commit to this PR" signal (true
13
- * for fork authors and for maintainers with "allow edits from maintainers" enabled) and
14
- * takes priority when present.
15
- *
16
- * pr-shepherd's premise is that the caller has push access to the PR it's iterating, so
17
- * this defaults to pushable: it withholds the autonomous push only when GitHub
18
- * affirmatively reports no head-branch access (`viewerCanEditFiles === false` and
19
- * `headRepositoryPermission` in `NONE`/`READ`/`TRIAGE`). An unverifiable/unknown signal —
20
- * matching the residual risk already accepted for CI reruns (see `canRerunWorkflows`) —
21
- * is treated as pushable rather than pre-emptively handed off; a push without access
22
- * simply fails when attempted.
23
- */
24
- export declare function canPushToHead(auth: ViewerAuthorization | undefined): boolean;
25
9
  /** Failing-check rows for formatter/instructions — excludes annotation-only carriers. */
26
10
  export declare function isFailingAgentCheck(check: {
27
11
  conclusion: CheckConclusion;
@@ -11,33 +11,6 @@ export function canRerunWorkflows(auth) {
11
11
  const permission = auth?.repositoryPermission;
12
12
  return permission != null && RERUN_CAPABLE_PERMISSIONS.has(permission);
13
13
  }
14
- /** Repository roles that carry push access to the head branch. */
15
- const PUSH_CAPABLE_PERMISSIONS = new Set(["WRITE", "MAINTAIN", "ADMIN"]);
16
- /**
17
- * True when the viewer can push commits to the PR head branch — the fork, for a fork PR
18
- * (own-fork PRs report `headRepositoryPermission: "ADMIN"`), or the base repo otherwise.
19
- * `viewerCanEditFiles` is GitHub's direct "can the viewer commit to this PR" signal (true
20
- * for fork authors and for maintainers with "allow edits from maintainers" enabled) and
21
- * takes priority when present.
22
- *
23
- * pr-shepherd's premise is that the caller has push access to the PR it's iterating, so
24
- * this defaults to pushable: it withholds the autonomous push only when GitHub
25
- * affirmatively reports no head-branch access (`viewerCanEditFiles === false` and
26
- * `headRepositoryPermission` in `NONE`/`READ`/`TRIAGE`). An unverifiable/unknown signal —
27
- * matching the residual risk already accepted for CI reruns (see `canRerunWorkflows`) —
28
- * is treated as pushable rather than pre-emptively handed off; a push without access
29
- * simply fails when attempted.
30
- */
31
- export function canPushToHead(auth) {
32
- if (auth === undefined)
33
- return true;
34
- if (auth.viewerCanEditFiles === true)
35
- return true;
36
- const permission = auth.headRepositoryPermission;
37
- if (permission != null && !PUSH_CAPABLE_PERMISSIONS.has(permission))
38
- return false;
39
- return true;
40
- }
41
14
  /** True for conclusions that belong under `## Failing checks` (not success/skipped/neutral). */
42
15
  function isFailingCheckConclusion(conclusion) {
43
16
  return conclusion == null || !NON_FAILING_CONCLUSIONS.has(conclusion);
@@ -9,9 +9,11 @@ import { isFailingAgentCheck } from "../checks/conclusions.mjs";
9
9
  import { renderMergeCommand } from "../commands/iterate/merge.mjs";
10
10
  export function formatFixCodeResult(header, result) {
11
11
  const sections = [header];
12
- if (result.fix.threads.length > 0) {
13
- sections.push("## Review threads");
14
- for (const t of result.fix.threads) {
12
+ const renderThreads = (heading, threads) => {
13
+ if (threads.length === 0)
14
+ return;
15
+ sections.push(heading);
16
+ for (const t of threads) {
15
17
  const lineLabel = renderLineRange(t.startLine, t.line);
16
18
  const loc = t.path ? `\`${t.path}:${lineLabel}\`` : "(no location)";
17
19
  const heading = t.url ? `[threadId=${t.id}](${t.url})` : `\`threadId=${t.id}\``;
@@ -24,7 +26,11 @@ export function formatFixCodeResult(header, result) {
24
26
  sections.push(renderSuggestionBlock(t.suggestion, ""));
25
27
  }
26
28
  }
27
- }
29
+ };
30
+ const locatedThreads = result.fix.threads.filter((thread) => thread.path !== null && thread.line !== null);
31
+ const unlocatedThreads = result.fix.threads.filter((thread) => thread.path === null || thread.line === null);
32
+ renderThreads("## Review threads", locatedThreads);
33
+ renderThreads("## Unlocated review threads (logged once — no mutation)", unlocatedThreads);
28
34
  if (result.fix.resolutionOnlyThreads.length > 0) {
29
35
  sections.push("## Review threads to resolve");
30
36
  sections.push(result.fix.resolutionOnlyThreads
@@ -2,7 +2,7 @@ export declare const COMMAND_USAGE: {
2
2
  readonly default: string;
3
3
  readonly apply: `pr-shepherd apply
4
4
 
5
- Apply a review mutation, select changed files for authorization diagnostics, or append a PR journal item.
5
+ Apply review mutations, mark selected changed files as viewed, or append a PR journal item.
6
6
 
7
7
  Usage:
8
8
  pr-shepherd apply review [PR] [review-flags]
@@ -36,8 +36,7 @@ At least one action flag is required.
36
36
  --help, -h Print this help and exit before GitHub I/O.`;
37
37
  readonly "apply files": `pr-shepherd apply files
38
38
 
39
- Select changed files and report that viewed-state authorization cannot be verified.
40
- No file viewed-state mutation is attempted.
39
+ Mark selected changed files as viewed.
41
40
 
42
41
  Usage:
43
42
  pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]
@@ -176,8 +175,7 @@ Exit codes:
176
175
  See docs/exit-codes.md for the full sysexits.h table.`;
177
176
  readonly "mark-files-as-viewed": `pr-shepherd mark-files-as-viewed
178
177
 
179
- Deprecated compatibility alias for selection-only file-view authorization diagnostics.
180
- No file viewed-state mutation is attempted.
178
+ Deprecated compatibility alias for marking selected PR files as viewed.
181
179
 
182
180
  Usage:
183
181
  pr-shepherd mark-files-as-viewed [PR] [files...] [--tests] [--match REGEX]
@@ -246,5 +244,18 @@ Flags:
246
244
  --help, -h Print this help and exit before any GitHub I/O.
247
245
 
248
246
  Exit code: 0 on success (including no-change no-op); nonzero on failure (sysexits.h — see docs/exit-codes.md).`;
247
+ readonly "journal extract": `pr-shepherd journal extract
248
+
249
+ Extract one visible, structurally valid Shepherd Journal from a local PR-body file.
250
+ This command performs no GitHub, configuration, or log I/O.
251
+
252
+ Usage:
253
+ pr-shepherd journal extract --body-file <path>
254
+
255
+ The output is exactly one JSON line: the typed result from extractShepherdJournal.
256
+ Malformed or unrecognized journal content is returned as {"ok":false,...} with exit code 0.
257
+ On POSIX, the final body-file path entry must be a readable regular file in a trusted parent directory;
258
+ symlinks, FIFOs, devices, and unreadable paths exit 66. Unsupported platforms fail closed with exit 66.
259
+ --help, -h Print this help and exit before any I/O.`;
249
260
  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.";
250
261
  };
@@ -5,7 +5,7 @@ export const COMMAND_USAGE = {
5
5
  default: DEFAULT_USAGE,
6
6
  apply: `pr-shepherd apply
7
7
 
8
- Apply a review mutation, select changed files for authorization diagnostics, or append a PR journal item.
8
+ Apply review mutations, mark selected changed files as viewed, or append a PR journal item.
9
9
 
10
10
  Usage:
11
11
  pr-shepherd apply review [PR] [review-flags]
@@ -39,8 +39,7 @@ At least one action flag is required.
39
39
  --help, -h Print this help and exit before GitHub I/O.`,
40
40
  "apply files": `pr-shepherd apply files
41
41
 
42
- Select changed files and report that viewed-state authorization cannot be verified.
43
- No file viewed-state mutation is attempted.
42
+ Mark selected changed files as viewed.
44
43
 
45
44
  Usage:
46
45
  pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]
@@ -179,8 +178,7 @@ Exit codes:
179
178
  See docs/exit-codes.md for the full sysexits.h table.`,
180
179
  "mark-files-as-viewed": `pr-shepherd mark-files-as-viewed
181
180
 
182
- Deprecated compatibility alias for selection-only file-view authorization diagnostics.
183
- No file viewed-state mutation is attempted.
181
+ Deprecated compatibility alias for marking selected PR files as viewed.
184
182
 
185
183
  Usage:
186
184
  pr-shepherd mark-files-as-viewed [PR] [files...] [--tests] [--match REGEX]
@@ -249,5 +247,18 @@ Flags:
249
247
  --help, -h Print this help and exit before any GitHub I/O.
250
248
 
251
249
  Exit code: 0 on success (including no-change no-op); nonzero on failure (sysexits.h — see docs/exit-codes.md).`,
250
+ "journal extract": `pr-shepherd journal extract
251
+
252
+ Extract one visible, structurally valid Shepherd Journal from a local PR-body file.
253
+ This command performs no GitHub, configuration, or log I/O.
254
+
255
+ Usage:
256
+ pr-shepherd journal extract --body-file <path>
257
+
258
+ The output is exactly one JSON line: the typed result from extractShepherdJournal.
259
+ Malformed or unrecognized journal content is returned as {"ok":false,...} with exit code 0.
260
+ On POSIX, the final body-file path entry must be a readable regular file in a trusted parent directory;
261
+ symlinks, FIFOs, devices, and unreadable paths exit 66. Unsupported platforms fail closed with exit 66.
262
+ --help, -h Print this help and exit before any I/O.`,
252
263
  "log-file": LOG_FILE_USAGE,
253
264
  };
@@ -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 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 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 until non-WAIT or timeout. This is the default command.\n iterate Run one iterate tick (single-tick alias).\n apply review Apply review-state mutations after fixes.\n apply files Select changed files; no viewed-state mutation is attempted.\n apply journal Append a list item to the Shepherd Journal details block of a PR body.\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 such as 42 or a GitHub pull request URL.\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\nPolling flags:\n --interval <duration> Delay between WAIT ticks. Bare number = seconds. Default: 60s.\n --timeout <duration> Poll wall-clock cap for WAIT ticks. Bare number = seconds. Default: 4.5m.\n --debounce <duration> Settle window after first FIX_CODE before returning. Bare number = seconds. Default: 60s. 0 disables.\n --quiet-status During WAIT polling, print only changed status snapshots.\n --until-terminal Continue through WAIT/MARK_READY until FIX_CODE/CANCEL/ESCALATE.\n\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\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\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 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 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 until non-WAIT or timeout. This is the default command.\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 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 such as 42 or a GitHub pull request URL.\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\nPolling flags:\n --interval <duration> Delay between WAIT ticks. Bare number = seconds. Default: 60s.\n --timeout <duration> Poll wall-clock cap for WAIT ticks. Bare number = seconds. Default: 4.5m.\n --debounce <duration> Settle window after first FIX_CODE before returning. Bare number = seconds. Default: 60s. 0 disables.\n --quiet-status During WAIT polling, print only changed status snapshots.\n --until-terminal Continue through WAIT/MARK_READY until FIX_CODE/CANCEL/ESCALATE.\n\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\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\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.";
@@ -10,6 +10,7 @@ Usage:
10
10
  pr-shepherd apply review [PR] [review-flags]
11
11
  pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]
12
12
  pr-shepherd apply journal [PR] <item> [--dry-run] [--format text|json]
13
+ pr-shepherd journal extract --body-file <path>
13
14
  pr-shepherd build-suggestion-patches [PR] --thread-id ID --message MSG [groups...]
14
15
  pr-shepherd admin clean <pr|branch|current|repo|all> [value] [flags]
15
16
  pr-shepherd admin log-file [--format text|json]
@@ -18,8 +19,9 @@ Commands:
18
19
  [PR] Poll until non-WAIT or timeout. This is the default command.
19
20
  iterate Run one iterate tick (single-tick alias).
20
21
  apply review Apply review-state mutations after fixes.
21
- apply files Select changed files; no viewed-state mutation is attempted.
22
+ apply files Mark selected changed files as viewed.
22
23
  apply journal Append a list item to the Shepherd Journal details block of a PR body.
24
+ journal extract Extract a validated Shepherd Journal from a local PR-body file as JSON.
23
25
  build-suggestion-patches
24
26
  Convert ordered GitHub suggestion threads into patches and commit instructions.
25
27
  admin clean Remove pr-shepherd state files.
@@ -2,7 +2,7 @@ export declare const USAGE: {
2
2
  readonly default: string;
3
3
  readonly apply: `pr-shepherd apply
4
4
 
5
- Apply a review mutation, select changed files for authorization diagnostics, or append a PR journal item.
5
+ Apply review mutations, mark selected changed files as viewed, or append a PR journal item.
6
6
 
7
7
  Usage:
8
8
  pr-shepherd apply review [PR] [review-flags]
@@ -36,8 +36,7 @@ At least one action flag is required.
36
36
  --help, -h Print this help and exit before GitHub I/O.`;
37
37
  readonly "apply files": `pr-shepherd apply files
38
38
 
39
- Select changed files and report that viewed-state authorization cannot be verified.
40
- No file viewed-state mutation is attempted.
39
+ Mark selected changed files as viewed.
41
40
 
42
41
  Usage:
43
42
  pr-shepherd apply files [PR] [files...] [--tests] [--match REGEX]
@@ -176,8 +175,7 @@ Exit codes:
176
175
  See docs/exit-codes.md for the full sysexits.h table.`;
177
176
  readonly "mark-files-as-viewed": `pr-shepherd mark-files-as-viewed
178
177
 
179
- Deprecated compatibility alias for selection-only file-view authorization diagnostics.
180
- No file viewed-state mutation is attempted.
178
+ Deprecated compatibility alias for marking selected PR files as viewed.
181
179
 
182
180
  Usage:
183
181
  pr-shepherd mark-files-as-viewed [PR] [files...] [--tests] [--match REGEX]
@@ -246,8 +244,21 @@ Flags:
246
244
  --help, -h Print this help and exit before any GitHub I/O.
247
245
 
248
246
  Exit code: 0 on success (including no-change no-op); nonzero on failure (sysexits.h — see docs/exit-codes.md).`;
247
+ readonly "journal extract": `pr-shepherd journal extract
248
+
249
+ Extract one visible, structurally valid Shepherd Journal from a local PR-body file.
250
+ This command performs no GitHub, configuration, or log I/O.
251
+
252
+ Usage:
253
+ pr-shepherd journal extract --body-file <path>
254
+
255
+ The output is exactly one JSON line: the typed result from extractShepherdJournal.
256
+ Malformed or unrecognized journal content is returned as {"ok":false,...} with exit code 0.
257
+ On POSIX, the final body-file path entry must be a readable regular file in a trusted parent directory;
258
+ symlinks, FIFOs, devices, and unreadable paths exit 66. Unsupported platforms fail closed with exit 66.
259
+ --help, -h Print this help and exit before any I/O.`;
249
260
  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.";
250
- 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 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 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 until non-WAIT or timeout. This is the default command.\n iterate Run one iterate tick (single-tick alias).\n apply review Apply review-state mutations after fixes.\n apply files Select changed files; no viewed-state mutation is attempted.\n apply journal Append a list item to the Shepherd Journal details block of a PR body.\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 such as 42 or a GitHub pull request URL.\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\nPolling flags:\n --interval <duration> Delay between WAIT ticks. Bare number = seconds. Default: 60s.\n --timeout <duration> Poll wall-clock cap for WAIT ticks. Bare number = seconds. Default: 4.5m.\n --debounce <duration> Settle window after first FIX_CODE before returning. Bare number = seconds. Default: 60s. 0 disables.\n --quiet-status During WAIT polling, print only changed status snapshots.\n --until-terminal Continue through WAIT/MARK_READY until FIX_CODE/CANCEL/ESCALATE.\n\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\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\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.";
261
+ 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 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 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 until non-WAIT or timeout. This is the default command.\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 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 such as 42 or a GitHub pull request URL.\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\nPolling flags:\n --interval <duration> Delay between WAIT ticks. Bare number = seconds. Default: 60s.\n --timeout <duration> Poll wall-clock cap for WAIT ticks. Bare number = seconds. Default: 4.5m.\n --debounce <duration> Settle window after first FIX_CODE before returning. Bare number = seconds. Default: 60s. 0 disables.\n --quiet-status During WAIT polling, print only changed status snapshots.\n --until-terminal Continue through WAIT/MARK_READY until FIX_CODE/CANCEL/ESCALATE.\n\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\n 11 MARK_READY\n 12 FIX_CODE\n 13 ESCALATE\n 14 CANCEL (closed without merging)\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.";
251
262
  };
252
263
  /** Resolve help keys for nested public commands before any command I/O. */
253
264
  export declare function helpKeyForArgs(args: string[]): keyof typeof USAGE;
package/bin/cli/help.mjs CHANGED
@@ -13,6 +13,8 @@ export function helpKeyForArgs(args) {
13
13
  return "apply files";
14
14
  if (args[0] === "apply" && args[1] === "journal")
15
15
  return "apply journal";
16
+ if (args[0] === "journal" && args[1] === "extract")
17
+ return "journal extract";
16
18
  if (args[0] === "admin" && args[1] === "clean")
17
19
  return "admin clean";
18
20
  if (args[0] === "admin" && args[1] === "log-file")
@@ -0,0 +1,2 @@
1
+ import type { RelevantCheck } from "../types.mts";
2
+ export declare function formatRelevantChecks(checks: RelevantCheck[]): string | null;
@@ -0,0 +1,55 @@
1
+ import { renderCheckAnnotation } from "./fix-formatter-extra.mjs";
2
+ export function formatRelevantChecks(checks) {
3
+ if (checks.length === 0)
4
+ return null;
5
+ const lines = ["## Checks", ""];
6
+ for (const check of checks) {
7
+ lines.push(...formatRelevantCheck(check));
8
+ }
9
+ return lines.join("\n");
10
+ }
11
+ function formatRelevantCheck(check) {
12
+ const workflow = check.workflowName ? `${check.workflowName} › ` : "";
13
+ const job = check.jobName ?? check.name;
14
+ const lines = [`- \`${workflow}${job}\` [conclusion: ${check.conclusion}]`];
15
+ appendCheckFields(lines, check);
16
+ appendLogExcerpt(lines, check.logExcerpt);
17
+ appendAnnotations(lines, check.annotations);
18
+ return lines;
19
+ }
20
+ function appendCheckFields(lines, check) {
21
+ const codeFields = [
22
+ ["run", check.runId],
23
+ ["URL", check.detailsUrl],
24
+ ["scope", check.scope],
25
+ ["commit", check.commitOid],
26
+ ];
27
+ for (const [label, value] of codeFields) {
28
+ if (value)
29
+ lines.push(` - ${label}: \`${value}\``);
30
+ }
31
+ const textFields = [
32
+ ["failed step", check.failedStep],
33
+ ["summary", check.summary],
34
+ ];
35
+ for (const [label, value] of textFields) {
36
+ if (value)
37
+ lines.push(` - ${label}: ${value}`);
38
+ }
39
+ }
40
+ function appendLogExcerpt(lines, logExcerpt) {
41
+ if (!logExcerpt)
42
+ return;
43
+ for (const line of logExcerpt.split("\n"))
44
+ lines.push(` > ${line}`);
45
+ }
46
+ function appendAnnotations(lines, annotations) {
47
+ if (!annotations || annotations.length === 0)
48
+ return;
49
+ lines.push(" - annotations:");
50
+ for (const annotation of annotations) {
51
+ for (const line of renderCheckAnnotation(annotation).split("\n")) {
52
+ lines.push(` ${line}`);
53
+ }
54
+ }
55
+ }
@@ -1,4 +1,5 @@
1
1
  import { formatFixCodeResult } from "./fix-formatter.mjs";
2
+ import { formatRelevantChecks } from "./iterate-checks-formatter.mjs";
2
3
  import { joinSections } from "../util/markdown.mjs";
3
4
  import { adaptIterateLog, buildSimpleIterateInstructions, numberInstructions, } from "./iterate-instructions.mjs";
4
5
  import { formatMergeRequirementLines } from "../merge-status/requirements-format.mjs";
@@ -26,7 +27,8 @@ export function formatIterateResult(result, opts) {
26
27
  const reviewDecisionSeg = result.mergeStatus === "BLOCKED" && result.reviewDecision
27
28
  ? ` · **reviewDecision** \`${result.reviewDecision}\``
28
29
  : "";
29
- const baseLine = `**status** \`${result.status}\` · **merge** \`${result.mergeStateStatus}\`${reviewDecisionSeg} · **state** \`${result.state}\` · **repo** \`${result.repo}\``;
30
+ const baseBranchSeg = verbose && result.baseBranch ? ` · **baseBranch** \`${result.baseBranch}\`` : "";
31
+ const baseLine = `**status** \`${result.status}\` · **merge** \`${result.mergeStateStatus}\`${reviewDecisionSeg} · **state** \`${result.state}\` · **repo** \`${result.repo}\`${baseBranchSeg}`;
30
32
  let summaryLine;
31
33
  if (verbose) {
32
34
  let verboseBranch = "";
@@ -110,7 +112,8 @@ export function formatIterateResult(result, opts) {
110
112
  const header = headerLines.join("\n");
111
113
  const quotaWarning = formatQuotaWarning(result.quotaWarning);
112
114
  const apiUsage = verbose ? formatApiUsage(result.apiUsage) : null;
113
- const telemetrySections = [quotaWarning, apiUsage];
115
+ const verboseChecks = verbose ? formatRelevantChecks(result.checks) : null;
116
+ const telemetrySections = [quotaWarning, apiUsage, verboseChecks];
114
117
  switch (result.action) {
115
118
  case "wait":
116
119
  return joinSections([
@@ -149,6 +152,7 @@ export function formatIterateResult(result, opts) {
149
152
  return joinSections([
150
153
  cancelHeaderLines.join("\n"),
151
154
  ...(apiUsage ? [apiUsage] : []),
155
+ ...(verboseChecks ? [verboseChecks] : []),
152
156
  adaptIterateLog(result.log),
153
157
  `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result))}`,
154
158
  ]);
@@ -157,6 +161,7 @@ export function formatIterateResult(result, opts) {
157
161
  return joinSections([
158
162
  header,
159
163
  ...(apiUsage ? [apiUsage] : []),
164
+ ...(verboseChecks ? [verboseChecks] : []),
160
165
  result.escalate.humanMessage,
161
166
  `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result))}`,
162
167
  ]);
@@ -158,6 +158,10 @@ export function projectIterateLean(result, opts) {
158
158
  ...(result.escalate.changesRequestedReviews.length > 0 && {
159
159
  changesRequestedReviews: result.escalate.changesRequestedReviews,
160
160
  }),
161
+ ...(result.escalate.checks &&
162
+ result.escalate.checks.length > 0 && {
163
+ checks: result.escalate.checks,
164
+ }),
161
165
  ...(result.escalate.stalledChecks &&
162
166
  result.escalate.stalledChecks.length > 0 && {
163
167
  stalledChecks: result.escalate.stalledChecks,
@@ -0,0 +1,2 @@
1
+ /** Extracts a checked Shepherd Journal from a local PR-body file without external I/O. */
2
+ export declare function handleJournalExtract(args: string[]): Promise<void>;
@@ -0,0 +1,48 @@
1
+ import { extractShepherdJournal } from "../journal/index.mjs";
2
+ import { EXIT, ShepherdError } from "../exit-codes.mjs";
3
+ import { USAGE, maybePrintHelp } from "./help.mjs";
4
+ import { readSafeBodyFile } from "./safe-body-file.mjs";
5
+ /** Extracts a checked Shepherd Journal from a local PR-body file without external I/O. */
6
+ export async function handleJournalExtract(args) {
7
+ if (maybePrintHelp(args, "journal extract"))
8
+ return;
9
+ const bodyFile = parseBodyFile(args);
10
+ if (bodyFile === null)
11
+ return;
12
+ try {
13
+ const body = await readSafeBodyFile(bodyFile);
14
+ process.stdout.write(`${JSON.stringify(extractShepherdJournal(body))}\n`);
15
+ }
16
+ catch (error) {
17
+ process.stderr.write(`pr-shepherd: journal extract: ${String(error)}\n`);
18
+ process.exitCode = error instanceof ShepherdError ? error.exitCode : EXIT.NOINPUT;
19
+ }
20
+ }
21
+ function parseBodyFile(args) {
22
+ let bodyFile;
23
+ for (let index = 0; index < args.length; index++) {
24
+ const arg = args[index];
25
+ if (arg === "--body-file") {
26
+ const value = args[++index];
27
+ if (value === undefined || bodyFile !== undefined) {
28
+ return printUsage();
29
+ }
30
+ bodyFile = value;
31
+ continue;
32
+ }
33
+ if (arg.startsWith("--body-file=")) {
34
+ const value = arg.slice("--body-file=".length);
35
+ if (value === "" || bodyFile !== undefined)
36
+ return printUsage();
37
+ bodyFile = value;
38
+ continue;
39
+ }
40
+ return printUsage();
41
+ }
42
+ return bodyFile ?? printUsage();
43
+ }
44
+ function printUsage() {
45
+ process.stderr.write(`${USAGE["journal extract"]}\n`);
46
+ process.exitCode = EXIT.USAGE;
47
+ return null;
48
+ }
@@ -3,12 +3,11 @@ export function formatMarkFilesAsViewedResult(result) {
3
3
  lines.push(`# PR #${result.prNumber} — File-view selection (${result.matchedPaths.length} selected)`);
4
4
  lines.push("");
5
5
  lines.push(`repo: ${result.repo}`);
6
- if (result.authorizationSkipped) {
7
- lines.push("");
8
- lines.push("## Authorization");
9
- lines.push("");
10
- lines.push("- Not marked: GitHub does not expose a capability that confirms the current viewer may mark PR files as viewed.");
11
- }
6
+ lines.push(`pullRequestId: ${result.pullRequestId}`);
7
+ appendPathSection(lines, "Requested exact paths", result.requestedPaths);
8
+ if (result.testSelector)
9
+ appendTextSection(lines, "Selectors", ["--tests"]);
10
+ appendTextSection(lines, "Match selectors", result.matchPatterns.map((pattern) => `--match ${pattern}`));
12
11
  appendPathSection(lines, "Matched files", result.matchedPaths);
13
12
  appendPathSection(lines, "Marked viewed", result.markedPaths);
14
13
  appendPathSection(lines, "Already viewed", result.alreadyViewedPaths);
@@ -22,9 +21,11 @@ export function formatMarkFilesAsViewedResult(result) {
22
21
  result.rateLimit.remaining !== undefined && result.rateLimit.limit !== undefined
23
22
  ? `remaining ${result.rateLimit.remaining}/${result.rateLimit.limit}`
24
23
  : null,
24
+ result.rateLimit.used !== undefined ? `used ${result.rateLimit.used}` : null,
25
25
  result.rateLimit.resetAt !== undefined
26
26
  ? `reset at ${new Date(result.rateLimit.resetAt * 1000).toISOString()}`
27
27
  : null,
28
+ result.rateLimit.resource !== undefined ? `resource ${result.rateLimit.resource}` : null,
28
29
  ]
29
30
  .filter(Boolean)
30
31
  .join(", ");
@@ -0,0 +1,14 @@
1
+ import { open } from "node:fs/promises";
2
+ type FileHandle = Awaited<ReturnType<typeof open>>;
3
+ export interface SafeBodyFileReaderDependencies {
4
+ platform: NodeJS.Platform;
5
+ noFollow: number | undefined;
6
+ nonBlock: number | undefined;
7
+ open: (filePath: string, flags: number) => Promise<FileHandle>;
8
+ }
9
+ /**
10
+ * Reads a regular file after rejecting unsafe final path entries without exposing its contents.
11
+ * Callers must trust parent directories: O_NOFOLLOW only protects the final path entry.
12
+ */
13
+ export declare function readSafeBodyFile(filePath: string, dependencies?: SafeBodyFileReaderDependencies): Promise<string>;
14
+ export {};