pr-shepherd 0.25.0 → 0.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.25.0",
4
+ "version": "0.25.2",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com"
@@ -10,14 +10,16 @@ Usage:
10
10
  [--require-sha SHA] [--format text|json]
11
11
 
12
12
  Flags:
13
- --resolve-thread-ids <ids> Comma-separated review thread IDs to resolve.
13
+ --resolve-thread-ids <ids> Comma-separated review thread IDs (PRRT_*) to resolve.
14
14
  Human-authored thread IDs are skipped; use --reply-thread-ids.
15
+ Note: comment IDs (PRRC_*) from gh api are not thread IDs and will fail.
15
16
  --reply-thread-ids <ids> Comma-separated human review thread IDs to reply to.
16
17
  --minimize-comment-ids <ids> Comma-separated issue/review comment IDs to minimize.
17
18
  --dismiss-review-ids <ids> Comma-separated CHANGES_REQUESTED review IDs to dismiss.
18
19
  --message <text> Reply/dismiss message. Required with --reply-thread-ids
19
20
  or --dismiss-review-ids.
20
21
  --require-sha <sha> Wait until GitHub reports this PR head SHA before mutating.
22
+ Must be a full 40-character lowercase hex SHA. Use $(git rev-parse HEAD).
21
23
  --format text|json Output format. Default: text.
22
24
  --help, -h Print this help and exit before GitHub I/O.
23
25
 
@@ -0,0 +1,16 @@
1
+ export function warnPrrcThreadIds(ids) {
2
+ const prrcIds = ids.filter((id) => id.startsWith("PRRC_"));
3
+ if (prrcIds.length > 0) {
4
+ process.stderr.write(`pr-shepherd: resolve: warning: --resolve-thread-ids contains comment IDs (PRRC_*) instead of thread IDs (PRRT_*): ${prrcIds.join(", ")}. The resolveReviewThread mutation requires PRRT_* thread IDs. Run a GraphQL query for pullRequest.reviewThreads to get the correct IDs.\n`);
5
+ }
6
+ return prrcIds;
7
+ }
8
+ export function validateRequireSha(sha) {
9
+ if (sha === undefined)
10
+ return true;
11
+ if (/^[0-9a-f]{40}$/.test(sha))
12
+ return true;
13
+ process.stderr.write(`pr-shepherd: resolve: --require-sha must be a full 40-character lowercase hex SHA, got "${sha}". Short SHAs will never match GitHub's headRefOid. Use $(git rev-parse HEAD) to get the full SHA.\n`);
14
+ process.exitCode = 1;
15
+ return false;
16
+ }
@@ -30,6 +30,7 @@ import { USAGE, maybePrintHelp } from "./cli/help.mjs";
30
30
  import { formatMutateResult } from "./cli/formatters.mjs";
31
31
  import { handleClean, handleCommitSuggestion, handleIterate, handleMarkFilesAsViewed, } from "./cli/handlers.mjs";
32
32
  import { handlePoll } from "./cli/poll-handler.mjs";
33
+ import { warnPrrcThreadIds, validateRequireSha } from "./cli/resolve-validators.mjs";
33
34
  import { setupLog } from "./log/setup.mjs";
34
35
  // ---------------------------------------------------------------------------
35
36
  // Entry
@@ -130,6 +131,9 @@ async function handleResolve(args) {
130
131
  const dismissReviewIds = parseList(getFlag(extra, "--dismiss-review-ids"));
131
132
  const dismissMessage = getFlag(extra, "--message") ?? undefined;
132
133
  const requireSha = getFlag(extra, "--require-sha") ?? undefined;
134
+ warnPrrcThreadIds(resolveThreadIds);
135
+ if (!validateRequireSha(requireSha))
136
+ return;
133
137
  if (hasFlag(extra, "--fetch")) {
134
138
  process.stderr.write("pr-shepherd: resolve: --fetch has been removed; run pr-shepherd iterate or poll to fetch the next action.\n");
135
139
  process.exitCode = 1;
@@ -5,6 +5,7 @@ import { loadConfig } from "../config/load.mjs";
5
5
  import { isConfiguredBotAuthor, isHumanAuthor, normalizeBotUsernames, } from "../comments/authors.mjs";
6
6
  import { markReplySeen } from "../state/seen-comments.mjs";
7
7
  import { threadTranscriptBody } from "../threads/transcript.mjs";
8
+ import { addPrShepherdMarker } from "../comments/marker.mjs";
8
9
  export async function runResolveMutate(opts) {
9
10
  const repo = await getRepoInfo();
10
11
  const prNumber = opts.prNumber ?? (await getCurrentPrNumber());
@@ -49,12 +50,13 @@ export async function runResolveMutate(opts) {
49
50
  if (skippedNonHumanReplies.length > 0)
50
51
  result.skippedNonHumanReplies = skippedNonHumanReplies;
51
52
  if (opts.dismissMessage) {
53
+ const markedMessage = addPrShepherdMarker(opts.dismissMessage);
52
54
  await Promise.all(result.repliedThreads.map((id) => {
53
55
  const thread = threadById.get(id);
54
56
  if (!thread)
55
57
  return Promise.resolve();
56
58
  const previousBody = threadTranscriptBody(thread);
57
- return markReplySeen({ owner: repo.owner, repo: repo.name, pr: prNumber }, id, previousBody, threadTranscriptBody(thread, [opts.dismissMessage]), opts.dismissMessage);
59
+ return markReplySeen({ owner: repo.owner, repo: repo.name, pr: prNumber }, id, previousBody, threadTranscriptBody(thread, [markedMessage]), markedMessage);
58
60
  }));
59
61
  }
60
62
  return result;
@@ -0,0 +1,7 @@
1
+ const PR_SHEPHERD_MARKER = "<!-- pr-shepherd -->";
2
+ export function hasPrShepherdMarker(body) {
3
+ return body.startsWith(PR_SHEPHERD_MARKER);
4
+ }
5
+ export function addPrShepherdMarker(body) {
6
+ return `${PR_SHEPHERD_MARKER}\n${body}`;
7
+ }
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable max-lines */
2
2
  import { graphqlWithRateLimit } from "../github/client.mjs";
3
+ import { addPrShepherdMarker } from "./marker.mjs";
3
4
  import { isRateLimitMessage, rateLimitFromError, rateLimitFromGraphQlResult, } from "./rate-limit.mjs";
4
5
  import { setPendingOps } from "./pending-ops.mjs";
5
6
  import { waitForSha } from "./sha-poll.mjs";
@@ -70,8 +71,9 @@ export async function autoResolveOutdated(threadIds) {
70
71
  const BULK_CHUNK_SIZE = 10;
71
72
  function buildBulkMutation(replyIds, resolveIds, minimizeIds, dismissIds, dismissMessage) {
72
73
  const ops = [];
74
+ const replyBody = addPrShepherdMarker(dismissMessage);
73
75
  for (let i = 0; i < replyIds.length; i++) {
74
- ops.push(` p${i}: addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: ${JSON.stringify(replyIds[i])}, body: ${JSON.stringify(dismissMessage)} }) { comment { id } }`);
76
+ ops.push(` p${i}: addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: ${JSON.stringify(replyIds[i])}, body: ${JSON.stringify(replyBody)} }) { comment { id } }`);
75
77
  }
76
78
  for (let i = 0; i < resolveIds.length; i++) {
77
79
  ops.push(` r${i}: resolveReviewThread(input: { threadId: ${JSON.stringify(resolveIds[i])} }) { thread { isResolved } }`);
@@ -1,6 +1,14 @@
1
1
  import { classifyItem } from "../state/seen-comments.mjs";
2
2
  import { threadTranscriptBody } from "../threads/transcript.mjs";
3
3
  import { isConfiguredBotAuthor } from "./authors.mjs";
4
+ import { hasPrShepherdMarker } from "./marker.mjs";
5
+ function threadEndedByShepherd(thread) {
6
+ const comments = thread.comments;
7
+ if (comments && comments.length > 0) {
8
+ return hasPrShepherdMarker(comments[comments.length - 1].body);
9
+ }
10
+ return hasPrShepherdMarker(thread.body);
11
+ }
4
12
  function withEdited(thread, edited) {
5
13
  return edited ? { ...thread, edited: true } : thread;
6
14
  }
@@ -11,6 +19,8 @@ function classifyVisibleThread(thread, seenMap) {
11
19
  return withEdited(thread, cls === "edited");
12
20
  }
13
21
  function classifyFirstLookThread(thread, seenMap, firstLookStatus) {
22
+ if (threadEndedByShepherd(thread))
23
+ return null;
14
24
  const visible = classifyVisibleThread(thread, seenMap);
15
25
  if (visible === null)
16
26
  return null;
@@ -21,6 +31,8 @@ export function classifyThreadVisibility(threads, seenMap, botUsernames = new Se
21
31
  const activeThreads = unresolvedThreads
22
32
  .filter((t) => !t.isOutdated && !t.isMinimized)
23
33
  .flatMap((t) => {
34
+ if (threadEndedByShepherd(t))
35
+ return [];
24
36
  if (isConfiguredBotAuthor(t, botUsernames))
25
37
  return [t];
26
38
  const visible = classifyVisibleThread(t, seenMap);
@@ -8,6 +8,7 @@ export function classifyVisibleComments(comments, seenMap, minimizeComments, bot
8
8
  if (shouldMinimizeAuthor(c.authorType, minimizeComments, c.author, botUsernames)) {
9
9
  actionable.push(c);
10
10
  minimizeIds.push(c.id);
11
+ toMarkSeen.push(c); // prevents re-surfacing as first-look after GitHub marks it minimized
11
12
  continue;
12
13
  }
13
14
  const cls = classifyItem(c.id, c.body, seenMap);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
4
4
  "description": "Autonomous PR CI monitor and review-comment resolver for agentic coding tools",
5
5
  "license": "MIT",
6
6
  "author": "Jonathan Ong",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
4
4
  "description": "Autonomous PR CI monitor and review-comment resolver for Codex.",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",