pr-shepherd 0.15.0 → 0.15.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.
@@ -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.15.0",
4
+ "version": "0.15.1",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com"
package/README.md CHANGED
@@ -126,7 +126,7 @@ Some other workflow improvements:
126
126
 
127
127
  Recommendations:
128
128
 
129
- - Run `pr-shepherd` on all your PRs before you go to sleep so that you wake up to reviewable PRs. In Claude Code, `/pr-shepherd:monitor` uses `/loop` and continues working when your rate limit window is reset. In Codex, keep an active goal cycling the reusable command every `watch.interval` (default 4m) until Shepherd emits `[CANCEL]` for ready-delay completion or merged/closed, or `[ESCALATE]` (including `stall-timeout` for repeated unchanged CI failures).
129
+ - Run `pr-shepherd` on all your PRs before you go to sleep so that you wake up to reviewable PRs. In Claude Code, `/pr-shepherd:monitor` uses `/loop` and continues working when your rate limit window is reset. In Codex, keep an active goal cycling the reusable command with a fresh 1-4 minute sleep before each rerun until Shepherd emits `[CANCEL]` for ready-delay completion or merged/closed, or `[ESCALATE]` (including `stall-timeout` for repeated unchanged CI failures).
130
130
  - Instruct your agents to write comments in a single review (comment, changes requested, or approved). This allows the review's comments/threads to be minimized or resolved together, keeping your pull request history clean. If you write inline comments outside of a review, each comment would still show up in the pull request history and take up space.
131
131
  - Avoid sticky comments as they will continue to be hidden. Instead, just make a new comment, especially on reviews. If you really want sticky comments, instruct your agent to unhide/unminimize them when updating them.
132
132
  - Avoid having automation edit comments, reviews, or threads in place because updated items get minimized. Instead, always make a new review, comment, thread, etc.
@@ -279,7 +279,7 @@ Or ask Codex to use the `pr-shepherd` skill, for example: `run pr-shepherd until
279
279
  <runner> pr-shepherd 42
280
280
  ```
281
281
 
282
- For an active Codex goal, rerun that command every `watch.interval` (default 4m) until Shepherd emits `[CANCEL]` for ready-delay completion or merged/closed, or `[ESCALATE]` (including `stall-timeout` for repeated unchanged CI failures). `pr-shepherd iterate 42` remains supported for existing workflows. There is no background `/loop` scheduler in Codex.
282
+ For an active Codex goal, rerun that command after picking a fresh 1-4 minute sleep until Shepherd emits `[CANCEL]` for ready-delay completion or merged/closed, or `[ESCALATE]` (including `stall-timeout` for repeated unchanged CI failures). `pr-shepherd iterate 42` remains supported for existing workflows. There is no background `/loop` scheduler in Codex.
283
283
 
284
284
  ### Without the plugin
285
285
 
@@ -6,7 +6,6 @@ import { adaptFixCodeInstructions, numberInstructions } from "./iterate-instruct
6
6
  export function formatFixCodeResult(header, result, opts) {
7
7
  const runtime = opts?.runtime ?? "claude";
8
8
  const readyDelaySuffix = opts?.readyDelaySuffix;
9
- const retryInterval = opts?.retryInterval;
10
9
  const runner = opts?.runner;
11
10
  const sections = [header];
12
11
  if (result.fix.threads.length > 0) {
@@ -118,7 +117,7 @@ export function formatFixCodeResult(header, result, opts) {
118
117
  }
119
118
  sections.push(postFixLines.join("\n"));
120
119
  sections.push("## Instructions");
121
- sections.push(numberInstructions(adaptFixCodeInstructions(result.fix.instructions, result.pr, runtime, readyDelaySuffix, retryInterval, runner)));
120
+ sections.push(numberInstructions(adaptFixCodeInstructions(result.fix.instructions, result.pr, runtime, readyDelaySuffix, runner)));
122
121
  return joinSections(sections);
123
122
  }
124
123
  function blockquote(body) {
@@ -66,7 +66,6 @@ export async function handleIterate(args) {
66
66
  const projectionOpts = {
67
67
  runtime,
68
68
  readyDelaySuffix,
69
- retryInterval: cfg.watch.interval,
70
69
  runner: cfg.cli?.runner,
71
70
  };
72
71
  if (globalOpts.format === "json") {
@@ -20,7 +20,6 @@ export function formatIterateResult(result, opts) {
20
20
  const verbose = opts?.verbose ?? false;
21
21
  const runtime = opts?.runtime ?? "claude";
22
22
  const readyDelaySuffix = opts?.readyDelaySuffix;
23
- const retryInterval = opts?.retryInterval;
24
23
  const runner = opts?.runner;
25
24
  const heading = `# PR #${result.pr} [${result.action.toUpperCase()}]`;
26
25
  const reviewDecisionSeg = result.mergeStatus === "BLOCKED" && result.reviewDecision
@@ -57,37 +56,36 @@ export function formatIterateResult(result, opts) {
57
56
  return joinSections([
58
57
  verbose ? header : heading,
59
58
  adaptIterateLog(result.log, runtime),
60
- `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, retryInterval, runner))}`,
59
+ `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, runner))}`,
61
60
  ]);
62
61
  case "wait":
63
62
  return joinSections([
64
63
  header,
65
64
  adaptIterateLog(result.log, runtime),
66
- `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, retryInterval, runner))}`,
65
+ `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, runner))}`,
67
66
  ]);
68
67
  case "mark_ready":
69
68
  return joinSections([
70
69
  header,
71
70
  adaptIterateLog(result.log, runtime),
72
- `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, retryInterval, runner))}`,
71
+ `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, runner))}`,
73
72
  ]);
74
73
  case "cancel":
75
74
  return joinSections([
76
75
  [`${heading} — ${result.reason}`, "", baseLine, summaryLine].join("\n"),
77
76
  adaptIterateLog(result.log, runtime),
78
- `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, retryInterval, runner))}`,
77
+ `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, runner))}`,
79
78
  ]);
80
79
  case "escalate":
81
80
  return joinSections([
82
81
  header,
83
82
  result.escalate.humanMessage,
84
- `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, retryInterval, runner))}`,
83
+ `## Instructions\n\n${numberInstructions(buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, runner))}`,
85
84
  ]);
86
85
  case "fix_code":
87
86
  return formatFixCodeResult(header, result, {
88
87
  runtime,
89
88
  readyDelaySuffix,
90
- retryInterval,
91
89
  runner,
92
90
  });
93
91
  }
@@ -1,28 +1,30 @@
1
1
  import { FIX_INSTRUCTION_END_ITERATION, FIX_INSTRUCTION_STOP_AFTER_PUSH, FIX_INSTRUCTION_STOP_BEFORE_NEXT_TICK, } from "../commands/iterate/render.mjs";
2
2
  import { buildPrShepherdCommand } from "./runner.mjs";
3
- const DEFAULT_CODEX_RETRY_INTERVAL = "4m";
4
- const VALID_RETRY_INTERVAL = /^\d+[smhd]$/;
5
3
  const CLAUDE_DYNAMIC_WAKEUP = "Schedule the next dynamic wakeup with `ScheduleWakeup` using `delaySeconds` between 60 and 240 and the same loop prompt (skip if running under a fixed-interval cron loop — the next scheduled fire handles it), then end this iteration.";
6
- export function buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, retryInterval, runner) {
4
+ const CODEX_DYNAMIC_WAIT = "pick a fresh sleep/timeout between 1 and 4 minutes, wait that long";
5
+ function capitalizeFirst(value) {
6
+ return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
7
+ }
8
+ export function buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, runner) {
7
9
  const rerunCommand = buildCodexIterateCommand(result.pr, readyDelaySuffix, runner);
8
- const retryDelay = buildCodexRetryDelay(retryInterval);
10
+ const retryDelay = buildCodexRetryDelay();
9
11
  switch (result.action) {
10
12
  case "cooldown":
11
13
  return [
12
14
  runtime === "codex"
13
- ? `Continue the active Codex goal — wait about ${retryDelay}, then rerun \`${rerunCommand}\` after CI starts reporting.`
15
+ ? `Continue the active Codex goal — ${retryDelay}, then rerun \`${rerunCommand}\` after CI starts reporting.`
14
16
  : `CI still needs time to start reporting. ${CLAUDE_DYNAMIC_WAKEUP}`,
15
17
  ];
16
18
  case "wait":
17
19
  return [
18
20
  runtime === "codex"
19
- ? `Continue the active Codex goal — wait about ${retryDelay}, then rerun \`${rerunCommand}\` to recheck.`
21
+ ? `Continue the active Codex goal — ${retryDelay}, then rerun \`${rerunCommand}\` to recheck.`
20
22
  : CLAUDE_DYNAMIC_WAKEUP,
21
23
  ];
22
24
  case "mark_ready":
23
25
  return [
24
26
  runtime === "codex"
25
- ? `The CLI already marked the PR ready for review. Continue the active Codex goal until the ready-delay completes — wait about ${retryDelay}, then rerun \`${rerunCommand}\` to recheck.`
27
+ ? `The CLI already marked the PR ready for review. Continue the active Codex goal until the ready-delay completes — ${retryDelay}, then rerun \`${rerunCommand}\` to recheck.`
26
28
  : `The CLI already marked the PR ready for review. ${CLAUDE_DYNAMIC_WAKEUP}`,
27
29
  ];
28
30
  case "cancel":
@@ -41,18 +43,18 @@ export function buildSimpleIterateInstructions(result, runtime, readyDelaySuffix
41
43
  ];
42
44
  }
43
45
  }
44
- export function adaptFixCodeInstructions(instructions, pr, runtime, readyDelaySuffix, retryInterval, runner) {
46
+ export function adaptFixCodeInstructions(instructions, pr, runtime, readyDelaySuffix, runner) {
45
47
  if (runtime !== "codex")
46
48
  return instructions;
47
49
  const rerunCommand = buildCodexIterateCommand(pr, readyDelaySuffix, runner);
48
- const retryDelay = buildCodexRetryDelay(retryInterval);
50
+ const retryDelay = buildCodexRetryDelay();
49
51
  return instructions.map((instruction) => {
50
52
  if (instruction === FIX_INSTRUCTION_STOP_AFTER_PUSH) {
51
- return `Continue the active Codex goal — CI needs time to run on the new push. Wait about ${retryDelay}, then rerun \`${rerunCommand}\` to recheck.`;
53
+ return `Continue the active Codex goal — CI needs time to run on the new push. ${capitalizeFirst(retryDelay)}, then rerun \`${rerunCommand}\` to recheck.`;
52
54
  }
53
55
  if (instruction === FIX_INSTRUCTION_STOP_BEFORE_NEXT_TICK ||
54
56
  instruction === FIX_INSTRUCTION_END_ITERATION) {
55
- return `Continue the active Codex goal — wait about ${retryDelay}, then rerun \`${rerunCommand}\` to recheck.`;
57
+ return `Continue the active Codex goal — ${retryDelay}, then rerun \`${rerunCommand}\` to recheck.`;
56
58
  }
57
59
  return instruction;
58
60
  });
@@ -68,11 +70,8 @@ export function buildCodexIterateCommand(pr, readyDelaySuffix, runner) {
68
70
  runner,
69
71
  }).text;
70
72
  }
71
- export function buildCodexRetryDelay(retryInterval) {
72
- const interval = typeof retryInterval === "string" ? retryInterval.trim() : "";
73
- return VALID_RETRY_INTERVAL.test(interval)
74
- ? `the configured interval (${interval})`
75
- : `the configured interval (default ${DEFAULT_CODEX_RETRY_INTERVAL})`;
73
+ export function buildCodexRetryDelay() {
74
+ return CODEX_DYNAMIC_WAIT;
76
75
  }
77
76
  export function numberInstructions(instructions) {
78
77
  return instructions.map((instruction, i) => `${i + 1}. ${instruction}`).join("\n");
@@ -7,9 +7,8 @@ import { adaptIterateLog, adaptFixCodeInstructions, buildSimpleIterateInstructio
7
7
  export function projectIterateLean(result, opts) {
8
8
  const runtime = opts?.runtime ?? "claude";
9
9
  const readyDelaySuffix = opts?.readyDelaySuffix;
10
- const retryInterval = opts?.retryInterval;
11
10
  const runner = opts?.runner;
12
- const simpleInstructions = (r) => buildSimpleIterateInstructions(r, runtime, readyDelaySuffix, retryInterval, runner);
11
+ const simpleInstructions = (r) => buildSimpleIterateInstructions(r, runtime, readyDelaySuffix, runner);
13
12
  const base = {
14
13
  action: result.action,
15
14
  pr: result.pr,
@@ -102,7 +101,7 @@ export function projectIterateLean(result, opts) {
102
101
  }),
103
102
  resolveCommand: result.fix.resolveCommand,
104
103
  ...(result.fix.instructions.length > 0 && {
105
- instructions: adaptFixCodeInstructions(result.fix.instructions, result.pr, runtime, readyDelaySuffix, retryInterval, runner),
104
+ instructions: adaptFixCodeInstructions(result.fix.instructions, result.pr, runtime, readyDelaySuffix, runner),
106
105
  }),
107
106
  },
108
107
  };
@@ -134,14 +133,13 @@ export function projectIterateLean(result, opts) {
134
133
  export function projectIterateVerbose(result, opts) {
135
134
  const runtime = opts?.runtime ?? "claude";
136
135
  const readyDelaySuffix = opts?.readyDelaySuffix;
137
- const retryInterval = opts?.retryInterval;
138
136
  const runner = opts?.runner;
139
137
  if (result.action === "fix_code") {
140
138
  return {
141
139
  ...result,
142
140
  fix: {
143
141
  ...result.fix,
144
- instructions: adaptFixCodeInstructions(result.fix.instructions, result.pr, runtime, readyDelaySuffix, retryInterval, runner),
142
+ instructions: adaptFixCodeInstructions(result.fix.instructions, result.pr, runtime, readyDelaySuffix, runner),
145
143
  },
146
144
  };
147
145
  }
@@ -151,6 +149,6 @@ export function projectIterateVerbose(result, opts) {
151
149
  return {
152
150
  ...result,
153
151
  ...log,
154
- instructions: buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, retryInterval, runner),
152
+ instructions: buildSimpleIterateInstructions(result, runtime, readyDelaySuffix, runner),
155
153
  };
156
154
  }
@@ -20,7 +20,7 @@ export async function runMonitor(opts) {
20
20
  const loopTag = `#pr-shepherd-loop:pr=${prNumber}:`;
21
21
  const loopArgs = interval;
22
22
  const reusableCommand = buildIterateCommand(prNumber, opts.readyDelaySuffix, config.cli?.runner);
23
- const loopPrompt = buildLoopPrompt(prNumber, loopTag, reusableCommand, loopArgs, opts.runtime ?? "claude", config.cli?.runner);
23
+ const loopPrompt = buildLoopPrompt(prNumber, loopTag, reusableCommand, opts.runtime ?? "claude", config.cli?.runner);
24
24
  return {
25
25
  prNumber,
26
26
  loopTag,
@@ -40,8 +40,10 @@ export function formatMonitorResult(result, opts) {
40
40
  `# PR #${prNumber} [MONITOR]`,
41
41
  "",
42
42
  `Loop tag: \`${loopTag}\``,
43
- `Loop args: \`${loopArgs}\``,
44
- ].join("\n"),
43
+ runtime === "codex" ? null : `Loop args: \`${loopArgs}\``,
44
+ ]
45
+ .filter((line) => line !== null)
46
+ .join("\n"),
45
47
  runtime === "codex" ? `Reusable command: \`${result.reusableCommand}\`` : null,
46
48
  "## Loop prompt",
47
49
  loopPrompt,
@@ -54,10 +56,20 @@ export function formatMonitorResult(result, opts) {
54
56
  }
55
57
  export function formatMonitorJson(result, opts) {
56
58
  const runtime = opts?.runtime ?? "claude";
57
- const { reusableCommand, ...base } = result;
59
+ if (runtime === "codex") {
60
+ return {
61
+ prNumber: result.prNumber,
62
+ loopTag: result.loopTag,
63
+ loopPrompt: result.loopPrompt,
64
+ reusableCommand: result.reusableCommand,
65
+ instructions: buildMonitorInstructions(result, runtime),
66
+ };
67
+ }
58
68
  return {
59
- ...base,
60
- ...(runtime === "codex" && { reusableCommand }),
69
+ prNumber: result.prNumber,
70
+ loopTag: result.loopTag,
71
+ loopArgs: result.loopArgs,
72
+ loopPrompt: result.loopPrompt,
61
73
  instructions: buildMonitorInstructions(result, runtime),
62
74
  };
63
75
  }
@@ -77,14 +89,14 @@ function buildIterateCommand(prNumber, readyDelaySuffix, runner) {
77
89
  const validatedDelay = validateReadyDelaySuffix(readyDelaySuffix);
78
90
  return buildPrShepherdCommand([String(prNumber), ...(validatedDelay ? ["--ready-delay", validatedDelay] : [])], { runner }).text;
79
91
  }
80
- function buildLoopPrompt(prNumber, loopTag, iterateCmd, loopArgs, runtime = "claude", runner) {
92
+ function buildLoopPrompt(prNumber, loopTag, iterateCmd, runtime = "claude", runner) {
81
93
  if (runtime === "codex") {
82
94
  return [
83
95
  loopTag,
84
96
  "",
85
97
  "**IMPORTANT — Codex recurrence rules:**",
86
98
  "- Run the command below once and follow its `## Instructions` exactly.",
87
- `- If the output tells you to continue the active Codex goal, wait about the configured interval (${loopArgs}) and rerun the reusable command from the monitor output.`,
99
+ "- If the output tells you to continue the active Codex goal, pick a fresh sleep/timeout between 1 and 4 minutes, wait that long, and rerun the reusable command from the monitor output.",
88
100
  "- Stop only when Shepherd emits `[CANCEL]` because the ready-delay completed or the PR was merged/closed, or when Shepherd emits `[ESCALATE]` (including `stall-timeout` for repeated unchanged CI failures).",
89
101
  `- Do not call \`/loop\`, \`ScheduleWakeup\`, \`CronCreate\`, or \`${buildPrShepherdCommand(["monitor", String(prNumber)], { runner }).text}\`; Codex recurrence is explicit \`iterate\` command cycles.`,
90
102
  "",
@@ -117,7 +129,7 @@ function buildMonitorInstructions(result, runtime) {
117
129
  if (runtime === "codex") {
118
130
  return [
119
131
  "Run the `## Loop prompt` body once inline now.",
120
- `For an active Codex goal, keep cycling with \`${result.reusableCommand}\` about every configured interval (${result.loopArgs}) until a terminal condition is reached. Codex does not create a \`/loop\` monitor.`,
132
+ `For an active Codex goal, keep cycling with \`${result.reusableCommand}\` by picking a fresh sleep/timeout between 1 and 4 minutes before each rerun until a terminal condition is reached. Codex does not create a \`/loop\` monitor.`,
121
133
  ];
122
134
  }
123
135
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
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.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Autonomous PR CI monitor and review-comment resolver for Codex.",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",