pullfrog 0.0.204 → 0.0.205

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/dist/cli.mjs CHANGED
@@ -18415,7 +18415,7 @@ var require_summary = __commonJS({
18415
18415
  exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
18416
18416
  var os_1 = __require("os");
18417
18417
  var fs_1 = __require("fs");
18418
- var { access, appendFile, writeFile: writeFile2 } = fs_1.promises;
18418
+ var { access, appendFile, writeFile: writeFile3 } = fs_1.promises;
18419
18419
  exports.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
18420
18420
  exports.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
18421
18421
  var Summary = class {
@@ -18473,7 +18473,7 @@ var require_summary = __commonJS({
18473
18473
  return __awaiter(this, void 0, void 0, function* () {
18474
18474
  const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
18475
18475
  const filePath = yield this.filePath();
18476
- const writeFunc = overwrite ? writeFile2 : appendFile;
18476
+ const writeFunc = overwrite ? writeFile3 : appendFile;
18477
18477
  yield writeFunc(filePath, this._buffer, { encoding: "utf8" });
18478
18478
  return this.emptyBuffer();
18479
18479
  });
@@ -62879,8 +62879,8 @@ var require_snapshot_utils = __commonJS({
62879
62879
  var require_snapshot_recorder = __commonJS({
62880
62880
  "node_modules/.pnpm/undici@7.22.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
62881
62881
  "use strict";
62882
- var { writeFile: writeFile2, readFile, mkdir } = __require("node:fs/promises");
62883
- var { dirname: dirname5, resolve: resolve3 } = __require("node:path");
62882
+ var { writeFile: writeFile3, readFile: readFile4, mkdir: mkdir2 } = __require("node:fs/promises");
62883
+ var { dirname: dirname6, resolve: resolve3 } = __require("node:path");
62884
62884
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
62885
62885
  var { InvalidArgumentError, UndiciError } = require_errors4();
62886
62886
  var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
@@ -63081,7 +63081,7 @@ var require_snapshot_recorder = __commonJS({
63081
63081
  throw new InvalidArgumentError("Snapshot path is required");
63082
63082
  }
63083
63083
  try {
63084
- const data = await readFile(resolve3(path3), "utf8");
63084
+ const data = await readFile4(resolve3(path3), "utf8");
63085
63085
  const parsed2 = JSON.parse(data);
63086
63086
  if (Array.isArray(parsed2)) {
63087
63087
  this.#snapshots.clear();
@@ -63111,12 +63111,12 @@ var require_snapshot_recorder = __commonJS({
63111
63111
  throw new InvalidArgumentError("Snapshot path is required");
63112
63112
  }
63113
63113
  const resolvedPath = resolve3(path3);
63114
- await mkdir(dirname5(resolvedPath), { recursive: true });
63114
+ await mkdir2(dirname6(resolvedPath), { recursive: true });
63115
63115
  const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot2]) => ({
63116
63116
  hash: hash2,
63117
63117
  snapshot: snapshot2
63118
63118
  }));
63119
- await writeFile2(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
63119
+ await writeFile3(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
63120
63120
  }
63121
63121
  /**
63122
63122
  * Clears all recorded snapshots
@@ -97692,14 +97692,14 @@ var require_turndown_cjs = __commonJS({
97692
97692
  } else if (node2.nodeType === 1) {
97693
97693
  replacement = replacementForNode.call(self2, node2);
97694
97694
  }
97695
- return join16(output, replacement);
97695
+ return join17(output, replacement);
97696
97696
  }, "");
97697
97697
  }
97698
97698
  function postProcess(output) {
97699
97699
  var self2 = this;
97700
97700
  this.rules.forEach(function(rule) {
97701
97701
  if (typeof rule.append === "function") {
97702
- output = join16(output, rule.append(self2.options));
97702
+ output = join17(output, rule.append(self2.options));
97703
97703
  }
97704
97704
  });
97705
97705
  return output.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
@@ -97711,7 +97711,7 @@ var require_turndown_cjs = __commonJS({
97711
97711
  if (whitespace.leading || whitespace.trailing) content = content.trim();
97712
97712
  return whitespace.leading + rule.replacement(content, node2, this.options) + whitespace.trailing;
97713
97713
  }
97714
- function join16(output, replacement) {
97714
+ function join17(output, replacement) {
97715
97715
  var s1 = trimTrailingNewlines(output);
97716
97716
  var s2 = trimLeadingNewlines(replacement);
97717
97717
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
@@ -99204,12 +99204,13 @@ import { basename as basename2 } from "node:path";
99204
99204
  // commands/gha.ts
99205
99205
  var core7 = __toESM(require_core(), 1);
99206
99206
  var import_arg = __toESM(require_arg(), 1);
99207
- import { dirname as dirname4 } from "node:path";
99207
+ import { dirname as dirname5 } from "node:path";
99208
99208
 
99209
99209
  // main.ts
99210
99210
  var core6 = __toESM(require_core(), 1);
99211
99211
  import { existsSync as existsSync7, readdirSync } from "node:fs";
99212
- import { join as join15 } from "node:path";
99212
+ import { readFile as readFile3 } from "node:fs/promises";
99213
+ import { join as join16 } from "node:path";
99213
99214
 
99214
99215
  // node_modules/.pnpm/@ark+util@0.56.0/node_modules/@ark/util/out/arrays.js
99215
99216
  var liftArray = (data) => Array.isArray(data) ? data : [data];
@@ -107705,7 +107706,7 @@ function buildCommitPrompt(status) {
107705
107706
  ].join("\n");
107706
107707
  }
107707
107708
  function hasPostRunIssues(issues) {
107708
- return issues.stopHook !== void 0 || issues.dirtyTree !== void 0;
107709
+ return issues.stopHook !== void 0 || issues.dirtyTree !== void 0 || issues.summaryStale !== void 0;
107709
107710
  }
107710
107711
  var agent = (input) => {
107711
107712
  return {
@@ -108500,7 +108501,8 @@ var STRING_KEYS = [
108500
108501
  "issueNodeId",
108501
108502
  "reviewNodeId",
108502
108503
  "planCommentNodeId",
108503
- "summaryCommentNodeId"
108504
+ "summaryCommentNodeId",
108505
+ "summarySnapshot"
108504
108506
  ];
108505
108507
  var NUMBER_KEYS = [
108506
108508
  "inputTokens",
@@ -108590,22 +108592,6 @@ function parseProgressComment(raw2) {
108590
108592
  if (Number.isNaN(id) || id <= 0) return void 0;
108591
108593
  return { id, type: raw2.type };
108592
108594
  }
108593
- async function getProgressComment(ctx, comment) {
108594
- const result = await (comment.type === "review" ? ctx.octokit.rest.pulls.getReviewComment({
108595
- owner: ctx.owner,
108596
- repo: ctx.repo,
108597
- comment_id: comment.id
108598
- }) : ctx.octokit.rest.issues.getComment({
108599
- owner: ctx.owner,
108600
- repo: ctx.repo,
108601
- comment_id: comment.id
108602
- }));
108603
- return {
108604
- id: result.data.id,
108605
- body: result.data.body ?? void 0,
108606
- html_url: result.data.html_url
108607
- };
108608
- }
108609
108595
  async function updateProgressComment(ctx, comment, body) {
108610
108596
  const result = await (comment.type === "review" ? ctx.octokit.rest.pulls.updateReviewComment({
108611
108597
  owner: ctx.owner,
@@ -109205,12 +109191,6 @@ var addTools = (ctx, server, tools) => {
109205
109191
  };
109206
109192
 
109207
109193
  // mcp/comment.ts
109208
- var LEAPING_INTO_ACTION_PREFIX = "Leaping into action";
109209
- function isLeapingIntoActionCommentBody(body) {
109210
- const content = stripExistingFooter(body).trimStart();
109211
- const firstLine = content.split(/\r?\n/, 1)[0]?.trimEnd() ?? "";
109212
- return new RegExp(`(^|\\s)${LEAPING_INTO_ACTION_PREFIX}(\\.\\.\\.)?$`).test(firstLine);
109213
- }
109214
109194
  function buildCommentFooter(ctx, customParts) {
109215
109195
  const runId = ctx.runId;
109216
109196
  return buildPullfrogFooter({
@@ -109242,43 +109222,22 @@ function addFooter(ctx, body) {
109242
109222
  var Comment = type({
109243
109223
  issueNumber: type.number.describe("the issue number to comment on"),
109244
109224
  body: type.string.describe("the comment body content"),
109245
- type: type.enumerated("Plan", "Summary", "Comment").describe(
109246
- "Plan: record as the plan for this run. Summary: record as the PR summary comment (one per PR, updated in place). Comment: regular comment (default)."
109247
- ).optional()
109225
+ type: type.enumerated("Plan", "Comment").describe("Plan: record as the plan for this run. Comment: regular comment (default).").optional()
109248
109226
  });
109249
109227
  function CreateCommentTool(ctx) {
109250
109228
  return tool({
109251
109229
  name: "create_issue_comment",
109252
- description: "Create a comment on a GitHub issue or PR. For progress/plan updates on the current run use report_progress instead. Use type: 'Plan' for plan comments, type: 'Summary' for PR summary comments.",
109230
+ description: "Create a comment on a GitHub issue or PR. For progress/plan updates on the current run use report_progress instead. Use type: 'Plan' for plan comments.",
109253
109231
  parameters: Comment,
109254
109232
  execute: execute(async ({ issueNumber, body, type: commentType }) => {
109255
109233
  const bodyWithFooter = addFooter(ctx, body);
109256
- if (commentType === "Summary" && ctx.toolState.existingSummaryCommentId) {
109257
- log.info(
109258
- `\xBB redirecting create_issue_comment(Summary) to update existing comment ${ctx.toolState.existingSummaryCommentId}`
109259
- );
109260
- const result2 = await ctx.octokit.rest.issues.updateComment({
109261
- owner: ctx.repo.owner,
109262
- repo: ctx.repo.name,
109263
- comment_id: ctx.toolState.existingSummaryCommentId,
109264
- body: bodyWithFooter
109265
- });
109266
- if (result2.data.node_id) {
109267
- await patchWorkflowRunFields(ctx, { summaryCommentNodeId: result2.data.node_id });
109268
- }
109269
- return {
109270
- success: true,
109271
- commentId: result2.data.id,
109272
- url: result2.data.html_url,
109273
- body: result2.data.body
109274
- };
109275
- }
109276
109234
  const result = await ctx.octokit.rest.issues.createComment({
109277
109235
  owner: ctx.repo.owner,
109278
109236
  repo: ctx.repo.name,
109279
109237
  issue_number: issueNumber,
109280
109238
  body: bodyWithFooter
109281
109239
  });
109240
+ ctx.toolState.wasUpdated = true;
109282
109241
  if (commentType === "Plan") {
109283
109242
  if (result.data.node_id) {
109284
109243
  await patchWorkflowRunFields(ctx, { planCommentNodeId: result.data.node_id });
@@ -109299,9 +109258,6 @@ function CreateCommentTool(ctx) {
109299
109258
  body: updateResult.data.body
109300
109259
  };
109301
109260
  }
109302
- if (commentType === "Summary" && result.data.node_id) {
109303
- await patchWorkflowRunFields(ctx, { summaryCommentNodeId: result.data.node_id });
109304
- }
109305
109261
  return {
109306
109262
  success: true,
109307
109263
  commentId: result.data.id,
@@ -109457,15 +109413,15 @@ ${collapsible}`;
109457
109413
  reportParams.target_plan_comment = params.target_plan_comment;
109458
109414
  }
109459
109415
  const result = await reportProgress(ctx, reportParams);
109460
- if (!params.target_plan_comment) {
109461
- ctx.toolState.finalSummaryWritten = true;
109462
- }
109463
109416
  if (result.action === "skipped") {
109464
109417
  return {
109465
109418
  success: true,
109466
109419
  message: "progress recorded (no GitHub comment created - this may occur for workflow_dispatch events or when there is no associated issue/PR)"
109467
109420
  };
109468
109421
  }
109422
+ if (!params.target_plan_comment) {
109423
+ ctx.toolState.finalSummaryWritten = true;
109424
+ }
109469
109425
  return {
109470
109426
  success: true,
109471
109427
  ...result
@@ -142570,7 +142526,7 @@ var import_semver = __toESM(require_semver2(), 1);
142570
142526
  // package.json
142571
142527
  var package_default = {
142572
142528
  name: "pullfrog",
142573
- version: "0.0.204",
142529
+ version: "0.0.205",
142574
142530
  type: "module",
142575
142531
  bin: {
142576
142532
  pullfrog: "dist/cli.mjs",
@@ -142767,7 +142723,7 @@ function closeBrowserDaemon(toolState) {
142767
142723
 
142768
142724
  // mcp/checkout.ts
142769
142725
  import { createHash as createHash2 } from "node:crypto";
142770
- import { writeFileSync } from "node:fs";
142726
+ import { statSync, unlinkSync as unlinkSync2, writeFileSync } from "node:fs";
142771
142727
  import { join as join3 } from "node:path";
142772
142728
 
142773
142729
  // utils/diffCoverage.ts
@@ -142796,7 +142752,10 @@ function createDiffCoverageState(params) {
142796
142752
  totalLines: params.totalLines,
142797
142753
  tocEntries: parseDiffTocEntries({ toc: params.toc }),
142798
142754
  coveredRanges: [],
142799
- coveragePreflightRan: false
142755
+ // carry forward across checkout_pr refreshes so the nudge stays "once per
142756
+ // review session". coveredRanges are intentionally not carried because
142757
+ // line numbers are tied to the previous diff's content.
142758
+ coveragePreflightRan: params.previous?.coveragePreflightRan ?? false
142800
142759
  };
142801
142760
  }
142802
142761
  function recordDiffReadFromToolUse(params) {
@@ -143600,6 +143559,11 @@ var GitFetch = type({
143600
143559
  ref: type.string.describe("Ref to fetch: branch name, tag, or 'pull/N/head' for PRs"),
143601
143560
  depth: type.number.describe("Fetch depth (for shallow clones)").optional()
143602
143561
  });
143562
+ var SHALLOW_UNREACHABLE_PATTERNS = [
143563
+ /Could not read [a-f0-9]{40,64}/,
143564
+ /remote did not send all necessary objects/
143565
+ ];
143566
+ var DEEPEN_RETRY_DEPTH = 1e3;
143603
143567
  function GitFetchTool(ctx) {
143604
143568
  return tool({
143605
143569
  name: "git_fetch",
@@ -143611,9 +143575,20 @@ function GitFetchTool(ctx) {
143611
143575
  if (params.depth !== void 0) {
143612
143576
  fetchArgs.push(`--depth=${params.depth}`);
143613
143577
  }
143614
- await $git("fetch", fetchArgs, {
143615
- token: ctx.gitToken
143616
- });
143578
+ try {
143579
+ await $git("fetch", fetchArgs, { token: ctx.gitToken });
143580
+ } catch (err) {
143581
+ const msg = err instanceof Error ? err.message : String(err);
143582
+ const isShallowUnreachable = SHALLOW_UNREACHABLE_PATTERNS.some((p2) => p2.test(msg));
143583
+ const isShallow = isShallowUnreachable && $("git", ["rev-parse", "--is-shallow-repository"], { log: false }).trim() === "true";
143584
+ if (!isShallow) throw err;
143585
+ log.info(
143586
+ `\xBB git_fetch hit shallow-unreachable error, retrying with --deepen=${DEEPEN_RETRY_DEPTH}`
143587
+ );
143588
+ await $git("fetch", [`--deepen=${DEEPEN_RETRY_DEPTH}`, "--no-tags", "origin", params.ref], {
143589
+ token: ctx.gitToken
143590
+ });
143591
+ }
143617
143592
  return { success: true, ref: params.ref };
143618
143593
  })
143619
143594
  });
@@ -143978,6 +143953,7 @@ function CreatePullRequestReviewTool(ctx) {
143978
143953
  nodeId: reviewNodeId,
143979
143954
  reviewedSha: actuallyReviewedSha
143980
143955
  };
143956
+ ctx.toolState.wasUpdated = true;
143981
143957
  await deleteProgressComment(ctx).catch((err) => {
143982
143958
  log.debug(`progress comment cleanup after review failed: ${err}`);
143983
143959
  });
@@ -144329,11 +144305,38 @@ async function ensureBeforeShaReachable(params) {
144329
144305
  return false;
144330
144306
  }
144331
144307
  }
144308
+ var STALE_LOCK_AGE_MS = 3e4;
144309
+ var GIT_LOCK_PATHS = [
144310
+ ".git/shallow.lock",
144311
+ ".git/index.lock",
144312
+ ".git/objects/maintenance.lock"
144313
+ ];
144314
+ function cleanupStaleGitLocks() {
144315
+ const now = Date.now();
144316
+ for (const relPath of GIT_LOCK_PATHS) {
144317
+ let mtimeMs;
144318
+ try {
144319
+ mtimeMs = statSync(relPath).mtimeMs;
144320
+ } catch {
144321
+ continue;
144322
+ }
144323
+ if (now - mtimeMs < STALE_LOCK_AGE_MS) continue;
144324
+ try {
144325
+ unlinkSync2(relPath);
144326
+ log.warning(`\xBB removed stale ${relPath} from prior run`);
144327
+ } catch (e) {
144328
+ log.debug(
144329
+ `\xBB failed to remove stale ${relPath}: ${e instanceof Error ? e.message : String(e)}`
144330
+ );
144331
+ }
144332
+ }
144333
+ }
144332
144334
  async function checkoutPrBranch(pr, params) {
144333
144335
  const { octokit, owner, name, gitToken, toolState, beforeSha } = params;
144334
144336
  log.info(`\xBB checking out PR #${pr.number}...`);
144335
144337
  rejectIfLeadingDash(pr.baseRef, "PR base ref");
144336
144338
  rejectIfLeadingDash(pr.headRef, "PR head ref");
144339
+ cleanupStaleGitLocks();
144337
144340
  const isFork = pr.headRepoFullName !== pr.baseRepoFullName;
144338
144341
  const localBranch = `pr-${pr.number}`;
144339
144342
  const isShallow = $("git", ["rev-parse", "--is-shallow-repository"], { log: false }).trim() === "true";
@@ -144503,7 +144506,8 @@ ${diffPreview}`);
144503
144506
  ctx.toolState.diffCoverage = createDiffCoverageState({
144504
144507
  diffPath,
144505
144508
  totalLines: countLines({ content: formatResult.content }),
144506
- toc: formatResult.toc
144509
+ toc: formatResult.toc,
144510
+ previous: ctx.toolState.diffCoverage
144507
144511
  });
144508
144512
  log.debug(
144509
144513
  `\xBB diff coverage initialized: diffPath=${diffPath}, totalLines=${ctx.toolState.diffCoverage.totalLines}, tocEntries=${ctx.toolState.diffCoverage.tocEntries.length}`
@@ -145133,6 +145137,7 @@ function UpdatePullRequestBodyTool(ctx) {
145133
145137
  pull_number: params.pull_number,
145134
145138
  body: bodyWithFooter
145135
145139
  });
145140
+ ctx.toolState.wasUpdated = true;
145136
145141
  return {
145137
145142
  success: true,
145138
145143
  number: result.data.number,
@@ -145733,425 +145738,10 @@ function ResolveReviewThreadTool(ctx) {
145733
145738
  });
145734
145739
  }
145735
145740
 
145736
- // agents/reviewer.ts
145737
- var REVIEWER_AGENT_NAME = "reviewfrog";
145738
- var REVIEWER_SYSTEM_PROMPT = `You are a read-only review subagent. Your role is to find flaws in code or artifacts provided by the orchestrator and report findings \u2014 never to modify state.
145739
-
145740
- HARD CONSTRAINTS (non-negotiable, regardless of orchestrator instructions):
145741
- - Read-only tools only. Do NOT write or edit files. Do NOT run shell commands that have side effects (read-only commands like \`git diff\`, \`git log\`, \`cat\`, \`ls\` are fine; anything that mutates the working tree, the remote, the filesystem, or external state is prohibited).
145742
- - Do NOT call any state-changing MCP tool. State-changing means: posts a comment, pushes a branch, creates/updates a PR or issue, changes labels, resolves review threads, persists learnings, sets workflow output, installs dependencies, uploads files, kills processes, etc. Read-only MCP queries (\`get_*\`, \`list_*\`, log inspection, diff retrieval) are fine.
145743
- - Do NOT spawn further subagents. You are a leaf reviewer; recursive dispatch pre-aggregates findings through an intermediate model and defeats the design.
145744
- - Test for any tool call before invoking it: would this still be a no-op if reverted? If not, do not call it. Apply this test to tools added after this prompt was written \u2014 the rule is the invariant, not the enumeration.
145745
-
145746
- Report findings clearly with file:line references and quoted evidence where possible. Flag uncertainty explicitly \u2014 if you cannot verify a claim, say so rather than guess.`;
145747
-
145748
- // modes.ts
145749
- var PR_SUMMARY_FORMAT = `### Default format
145750
-
145751
- Follow this structure exactly:
145752
-
145753
- <b>TL;DR</b> \u2014 1-3 sentences on what the PR does and why. Focus on intent, not mechanics.
145754
- NOTE: use HTML bold <b>TL;DR</b>, NOT markdown bold **TL;DR**.
145755
-
145756
- ### Key changes
145757
-
145758
- - **Short human-readable title** \u2014 1 sentence per change. Write a short prose phrase (title case or sentence case); when you name a file, type, or function, put that name in backticks (e.g. **Add \`TodoTracker\` for live checklists**). A reviewer should understand the full PR from this list alone.
145759
-
145760
- <sub><b>Summary</b> \uFF5C {file_count} files \uFF5C {commit_count} commits \uFF5C base: \`{base}\` \u2190 \`{head}\`</sub>
145761
- NOTE: the metadata line goes AFTER the bullet list, not before it.
145762
-
145763
- Then for each key change, a ## section with a short descriptive title that reads like a documentation heading (e.g. ## Live todo checklist tracking).
145764
-
145765
- <br/>
145766
-
145767
- ## Example readable section title
145768
-
145769
- > **Before:** [old behavior/state]<br/>**After:** [new behavior/state]
145770
- IMPORTANT: Before and After MUST be on a SINGLE blockquote line with an inline <br/> between them. Two separate \`>\` lines creates a double line break.
145771
-
145772
- 1-2 sentences of explanation. Break up text with tables, blockquotes, or lists \u2014 NEVER 3+ plain paragraphs in a row.
145773
-
145774
- If a change warrants deeper explanation, use a blockquoted details/summary framed as a question:
145775
- > <details><summary>How does X work?</summary>
145776
- > Extended explanation here.
145777
- > </details>
145778
-
145779
- End each section with a file links trail (3-4 key files max):
145780
- [\`file.ts\`](https://github.com/{owner}/{repo}/pull/{number}/files#diff-{sha256hex_of_filepath}) \xB7 ...
145781
-
145782
- Single-feature PRs: skip the ## sections. Fold before/after and explanation into the header after key changes.
145783
-
145784
- CRITICAL \u2014 GitHub markdown rendering rule:
145785
- GitHub's markdown parser requires a blank line between ALL block-level elements. This includes transitions between: HTML tags (<br/>, <sub>, <details>, <b>, etc.) and markdown syntax (headings, lists, blockquotes, paragraphs). Without a blank line, GitHub treats the following content as a continuation of the HTML block and renders markdown syntax as literal text. ALWAYS separate block-level elements with a blank line.
145786
-
145787
- Rules:
145788
- - \`##\` titles and key-change bullet lead-ins are plain-language summaries; backtick only actual code tokens (files, types, functions) where they appear in the title
145789
- - ALL variable names, identifiers, and file names in body text must be in backticks
145790
- - ALL file references MUST link to the PR Files Changed view. Use the \`diff-<hex>\` anchor precomputed next to each filename in the \`checkout_pr\` TOC \u2014 do NOT run \`sha256sum\` or any other shell command to compute anchors. NEVER fabricate hex strings. If a file is not in the TOC, omit the \`#diff-\` anchor rather than guessing.
145791
- - Add <br/> before each ## heading for visual spacing. Do NOT use horizontal rules (---)
145792
- - Do NOT include raw diff stats like '+123 / -45' or line counts
145793
- - Do NOT include code blocks or repeat diff contents
145794
- - Do NOT include a changelog section \u2014 the key changes list serves this purpose
145795
- - Focus on *intent*, not *what* \u2014 the diff already shows what changed
145796
- - Get the file count and commit count from the checkout_pr metadata, not by counting manually`;
145797
- function learningsStep(t2, n) {
145798
- return `${n}. **learnings** (only if high confidence): if you discovered something about repo setup, test commands, conventions, or patterns that you are confident is correct and would reliably help future runs, call \`${t2("update_learnings")}\` to persist it. skip this step if you are unsure or the finding is speculative/one-off. format as a flat bullet list (\`- \` per line, one fact per bullet). merge with existing learnings from the prompt \u2014 pass the FULL merged list. deduplicate, and drop bullets that are clearly wrong or no longer relevant to the current codebase.`;
145799
- }
145800
- function computeModes(agentId) {
145801
- const t2 = (toolName) => formatMcpToolRef(agentId, toolName);
145802
- return [
145803
- {
145804
- name: "Build",
145805
- description: "Implement, build, create, or develop code changes; make specific changes to files or features; execute a plan; or handle tasks with specific implementation details",
145806
- prompt: `### Checklist
145807
-
145808
- 1. **plan** (optional, for complex tasks): analyze requirements, read AGENTS.md and relevant code, produce a step-by-step implementation plan.
145809
-
145810
- 2. **setup**: checkout or create the branch:
145811
- - **PR event, modifying the existing PR**: call \`${t2("checkout_pr")}\`
145812
- - **new branch**: use \`${t2("git")}\` to create a branch (\`git checkout -b pullfrog/branch-name\`)
145813
-
145814
- 3. **build**: implement changes using your native file and shell tools:
145815
- - follow the plan (if you ran a plan phase)
145816
- - plan your approach before writing code: identify which files need to change, key design decisions, and edge cases. for non-trivial changes, consider whether there's a more elegant approach.
145817
- - run relevant tests/lints before committing
145818
-
145819
- 4. **self-review**: judgment call \u2014 does YOUR diff warrant a fresh-eyes pass?
145820
-
145821
- Skip self-review (commit directly) when the diff is **genuinely trivial**:
145822
- - doc typos, comment-only edits, whitespace/format-only, import reordering
145823
- - lockfile or generated-code regeneration, mechanical rename whose only effect is import-path updates (size of diff is irrelevant \u2014 read the *shape*, not the line count)
145824
- - low-risk dep patch bump from a trusted source
145825
-
145826
- Run self-review when the diff has **any behavioral surface, however small**:
145827
- - 1-line changes to SQL operators / comparison logic / regexes / redirects / HTTP methods / response codes
145828
- - any change to money / tax / currency / billing / fee / refund / payout calculations or constants
145829
- - any change to auth / permissions / roles / sessions / tokens / signature verification
145830
- - any change to feature-flag defaults, retry counts, timeouts, rate limits, batch sizes
145831
- - new endpoints, new code paths, new error branches \u2014 even small ones
145832
- - mixed diffs (whitespace + a single semantic line) \u2014 the semantic line still triggers self-review
145833
- - anything you're uncertain about
145834
-
145835
- Tie-breaker: when in doubt, run self-review. One false-positive subagent dispatch costs cents; one false-negative shipped bug costs much more. There's no value in dispatching for a typo, but there's also no excuse for skipping on a 1-line change to a billing path.
145836
-
145837
- Otherwise delegate the \`${REVIEWER_AGENT_NAME}\` subagent to review your diff with fresh eyes against YOUR TASK. The subagent's baked-in system prompt enforces a non-mutative + non-recursive contract: read-only file/search/web tools and read-only MCP queries only; no writes, shell side effects, state-changing MCP calls, or nested subagent dispatch. Enforcement is prose-only \u2014 restate the constraint in your dispatch instructions and do not relax it.
145838
-
145839
- Provide the subagent with YOUR TASK, the output of \`git diff\`, and a tight summary (not raw output) of any lint/typecheck/test failures you fixed during build \u2014 what broke, root cause, the fix \u2014 so it can check that fixes addressed root causes rather than suppressed symptoms; say "no build-phase failures" if the build path was clean. Instruct it to flag bugs, logic errors, missing edge cases, gaps between request and diff, and unintended changes.
145840
-
145841
- Delegation + research discipline (distilled from \`/anneal\` canonical \u2014 these are codified learnings from many review rounds, not theoretical best practices):
145842
- - Do NOT summarize what you implemented \u2014 that biases the subagent toward validating the shape of your solution rather than questioning it.
145843
- - Do NOT curate a reading list of files. Let the subagent discover scope from the diff and codebase.
145844
- - Do NOT pre-shape output with a severity / category schema. That leaks your hypotheses; severity is your call during evaluation.
145845
- - Do NOT defect-hunt the diff yourself in parallel with the subagent. Your role is dispatch + evaluation; doing the review yourself reintroduces the implementation bias the subagent is meant to mitigate.
145846
- - For diffs that rely on third-party API contracts, SDK semantics, framework directives, or DB engine specifics, instruct the subagent to verify load-bearing claims via web search and quote source URLs rather than trust training data \u2014 this is the single most common review-quality failure mode.
145847
-
145848
- Review the findings, address valid points, and discard nitpicks or false positives. The reviewer is fallible \u2014 it biases toward *recommending additions* (defensive checks for impossible cases, extra logging, new abstractions used once, comments restating code, tests asserting tautologies, "just-in-case" guards). For each finding, ask: would applying it leave the code more sound, correct, AND elegant? Two-out-of-three is not enough \u2014 a fix that improves correctness while degrading elegance still degrades the codebase. Reject bloat-shaped findings without applying them, and after applying the rest re-read your diff and be discerning about what *you just changed*: if any fix turned out to be bloat in context, revert it. The goal is code that is sound and correct *while remaining elegant*; the smallest diff that fixes the real defect almost always wins. Then verify only intended changes are present, no debug artifacts or commented-out code remain, no unrelated files were modified. Commit locally via shell (\`git add . && git commit -m "..."\`).
145849
-
145850
- 5. **finalize**:
145851
- - confirm a clean working tree, then push via \`${t2("push_branch")}\` (see *SYSTEM* Git rules if this fails \u2014 prepush errors are usually the repo's tests/lint, not infra timeouts)
145852
- - create a PR via \`${t2("create_pull_request")}\`
145853
- - call \`${t2("report_progress")}\` with the PR link or the exact error if push/PR failed
145854
-
145855
- ${learningsStep(t2, 6)}
145856
-
145857
- ### Notes
145858
-
145859
- For simple, well-defined tasks, skip the plan phase and go straight to build.`
145860
- },
145861
- {
145862
- name: "AddressReviews",
145863
- description: "Address PR review feedback; respond to reviewer comments; make requested changes to an existing PR",
145864
- prompt: `### Checklist
145865
-
145866
- 1. Checkout the PR branch via \`${t2("checkout_pr")}\`.
145867
-
145868
- 2. Fetch review comments via \`${t2("get_review_comments")}\`.
145869
-
145870
- 3. For each comment:
145871
- - understand the feedback
145872
- - evaluate whether applying it would leave the code more **sound, correct, AND elegant**. reviewers are fallible and bias toward *recommending additions* (defensive checks for impossible cases, extra abstractions, comments restating obvious code, tests asserting tautologies, "just-in-case" guards). if a request would add bloat \u2014 ceremony without commensurate correctness benefit \u2014 push back in your reply rather than mechanically applying it. two-out-of-three is not enough; improving correctness while degrading elegance still degrades the code.
145873
- - if the request stands, make the code change using your native tools; otherwise reply explaining why
145874
- - record what was done (or why nothing was done)
145875
-
145876
- 4. Quality check:
145877
- - test changes, then review the diff before committing \u2014 verify only intended changes are present, no debug artifacts remain, no fix turned out to be bloat in context (revert any that did), and the changes are clean enough that a senior engineer would approve without hesitation
145878
- - commit locally via shell (\`git add . && git commit -m "..."\`)
145879
-
145880
- 5. Finalize:
145881
- - confirm a clean working tree, then push via \`${t2("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
145882
- - reply to each comment using \`${t2("reply_to_review_comment")}\`
145883
- - resolve addressed threads via \`${t2("resolve_review_thread")}\`
145884
- - call \`${t2("report_progress")}\` with a brief summary (or the exact push error if push failed)
145885
-
145886
- ${learningsStep(t2, 6)}`
145887
- },
145888
- // Review and IncrementalReview use the multi-lens orchestrator pattern
145889
- // (canonical source: .claude/commands/anneal.md). The orchestrator does
145890
- // triage → parallel read-only subagent fan-out → aggregate → draft comments
145891
- // → submit. For someone else's PR, parallel lenses (correctness, security,
145892
- // research-validated claims, user-journey, etc.) provide breadth across
145893
- // angles that a single subagent can't carry coherently. Build mode keeps
145894
- // a single fresh-eyes subagent (different problem shape — orchestrator
145895
- // wrote the code and bias-mitigation comes from delegating to one
145896
- // subagent that doesn't share the implementation context).
145897
- // Deliberate omission vs canonical /anneal: severity categorization in the
145898
- // final message (the review body has its own CAUTION/IMPORTANT framing
145899
- // instead of a severity table).
145900
- {
145901
- name: "Review",
145902
- description: "Review code, PRs, or implementations; provide feedback or suggestions; identify issues; or check code quality, style, and correctness",
145903
- prompt: `### Checklist
145904
-
145905
- 1. **checkout**: call \`${t2("checkout_pr")}\` \u2014 this returns PR metadata and a \`diffPath\`. read the diff TOC end-to-end and treat its file line ranges as your coverage checklist.
145906
-
145907
- 2. **triage**: orient yourself on the PR \u2014 identify *what kind of thing this is* (domain it touches, seams it crosses, external contracts it depends on, user-facing surfaces it changes). orientation only \u2014 defer specific defect-hunting to the subagents; pre-reviewing biases the lenses you pick. use \`${t2("get_pull_request")}\` and other read-only GitHub tools for additional context if needed.
145908
-
145909
- if the PR is **genuinely trivial**, skip steps 3\u20134 entirely and submit \`Reviewed \u2014 no issues found.\` per step 5. there's no value in dispatching even one lens for a typo.
145910
-
145911
- "Genuinely trivial" (skip):
145912
- - single-word doc typo, whitespace/format-only, comment-only across any number of files
145913
- - lockfile or generated-code regeneration (size of diff is irrelevant \u2014 read the *shape*)
145914
- - mechanical rename whose only effect is import-path updates
145915
- - low-risk dep patch bump
145916
-
145917
- "Looks trivial but isn't" (do **NOT** skip \u2014 small diff, big blast radius):
145918
- - any 1-line change to SQL / regex / auth / billing / permission / signature-verification code
145919
- - flipping a feature-flag default, default config value, or retry/timeout constant
145920
- - changing a money/tax/currency/fee constant by any amount
145921
- - changing an HTTP method, redirect URL, response code, or status enum
145922
- - tightening or loosening a comparison operator (\`<\` \u2194 \`<=\`, \`==\` \u2194 \`!=\`)
145923
- - renaming a public API surface (still trivial in shape, but needs an impact lens)
145924
- - adding a new direct dependency (supply-chain surface)
145925
- - any "typo fix" in user-facing copy that changes meaning ("approved" \u2192 "denied")
145926
- - mixed diffs where a semantic 1-liner is buried in whitespace/formatting changes
145927
-
145928
- When unsure, treat as non-trivial. The cost of one extra subagent is cents; the cost of a missed billing/auth/data bug is much more.
145929
-
145930
- otherwise pick lenses by where the PR concentrates risk \u2014 **there's no fixed count**. lens count is judgment, not a formula. concrete shapes to anchor against:
145931
-
145932
- - **1 lens** \u2014 pure refactor / mechanical rename across many files (impact); new test file with no source change (test-integrity); small isolated bug fix (correctness); doc-only PR with non-trivial technical content (research-validated or holistic)
145933
- - **2\u20133 lenses (most PRs land here)** \u2014 new CRUD endpoint (correctness + security + test-integrity); new UI flow (user-journey + correctness); a single bug fix in a non-critical subsystem (correctness + test-integrity); design doc covering one domain (research-validated + correctness or holistic)
145934
- - **4\u20135 lenses (high-stakes subsystem touches)** \u2014 any billing/payments change (billing-subsystem + correctness + security + operational-readiness); new auth flow (auth-subsystem + correctness + security + test-integrity); schema migration (schema-migration-subsystem + correctness + operational-readiness + impact); cross-subsystem PR that touches billing AND auth AND schema (one subsystem lens per domain + correctness)
145935
- - **6+ lenses** \u2014 almost always a smell; you're either covering overlapping ground or this PR should have been split. push back via the review body rather than expanding lens count.
145936
-
145937
- lenses come in two flavors, and you can mix them:
145938
- - **themed lenses** \u2014 a perspective applied across the whole diff (correctness, security, user-journey, performance, etc.).
145939
- - **subsystem lenses** \u2014 a domain-scoped frame for high-stakes subsystems the PR touches (e.g. "the auth lens", "the billing lens", "the schema-migration lens"). a subsystem lens is "review the PR specifically for what could go wrong in this subsystem" and naturally combines theme + scope. **for high-stakes domains, lead with the subsystem lens rather than the generic themed equivalent** \u2014 "billing-subsystem" outperforms "correctness on billing code" because the framing primes the subagent to remember domain-specific failure modes (double-charges, refund races, currency rounding, dispute flows) the generic lens misses.
145940
-
145941
- starter menu (combine, omit, or invent your own):
145942
- - **correctness & invariants** \u2014 bugs, races, error handling, edge cases, state-machine boundaries
145943
- - **impact** \u2014 when the PR removes features, deletes exports, renames identifiers, or changes architectural patterns: stale references in code, tests, docs (\`docs/\`, \`wiki/\`), comments, configs, UI
145944
- - **research-validated assumptions** \u2014 third-party API contracts, SDK semantics, framework directives, version-gated behavior. the subagent must verify load-bearing claims via web search and quote source URLs.
145945
- - **security** \u2014 new endpoints, authZ, input validation, secrets handling, replay/CSRF/injection, cross-tenant isolation
145946
- - **user-journey** \u2014 UX-touching flows: walk through happy path and failure modes as a user
145947
- - **operational readiness** \u2014 observability, alerting, migrations (forward + rollback), feature flags, on-call burden
145948
- - **integration & cross-cutting** \u2014 API contracts between modules, backward-compat of public surfaces, multi-service ordering
145949
- - **test integrity** \u2014 meaningful coverage for the changed behavior; deterministic; no shared-state pollution
145950
- - **performance** \u2014 N+1 queries, hot-path allocation, latency budgets, index coverage
145951
- - **holistic** \u2014 does the PR make sense as a whole? symmetric flows (delete for every create, rollback for every migration)?
145952
- - **subsystem lenses** (invent as the PR demands) \u2014 auth, billing, payments, schema migration, webhooks, secrets, RBAC, multi-tenant isolation, cron/scheduling, etc.
145953
-
145954
- 3. **fan out**: dispatch one \`${REVIEWER_AGENT_NAME}\` subagent per lens \u2014 its baked-in system prompt enforces the non-mutative + non-recursive contract (read-only file/search/web tools and read-only MCP queries; no writes, shell side effects, state-changing MCP calls, or nested subagent dispatch). when picking 2+ lenses, dispatch them in a **single assistant turn with multiple parallel subagent calls**; issuing one and awaiting reply before the next collapses the fan-out into a serial review. if a subagent errors out, times out, or returns nothing usable, retry once with the same lens; if it still fails, proceed with partial coverage and note the missing lens in the review body \u2014 do not skip step 3 entirely on a single subagent failure. each subagent gets:
145955
- - the diff path / target \u2014 reading the diff and the codebase is its job
145956
- - **only one lens** \u2014 never a multi-section "review for X, Y, and Z" prompt
145957
- - **a Task \`description\` set to the lens name** (e.g. \`"security"\`, \`"correctness"\`, \`"billing-subsystem"\`) \u2014 the harness reads this field to label the subagent's log lines so parallel runs can be told apart in CI output. without it, every subagent shows up as \`subagent#N\`.
145958
- - the read-only contract restated in your dispatch instructions so the rule is present twice (the subagent's system prompt also enforces it). The test: would this call still be a no-op if reverted? If not (PR comments, branch pushes, issue updates, set_output, label changes, dependency installs, etc.), don't make it.
145959
- - if the lens touches external contracts, instruct the subagent to verify load-bearing claims via web search rather than trust training data, and to quote source URLs in its reasoning. action runs are non-interactive \u2014 there's no human in the loop to catch "I'm pretty sure Stripe does X."
145960
- - ask the subagent to report findings with file paths and NEW line numbers from the diff so you can anchor inline comments without re-reading the entire diff.
145961
-
145962
- delegation discipline:
145963
- - do NOT lens-review the diff yourself in parallel with the subagents (your job is dispatch + comment-drafting; doing the lens work yourself reintroduces the bias the fan-out avoids)
145964
- - do NOT summarize the PR for them (biases toward a validation frame)
145965
- - do NOT hand them a curated reading list (let them discover scope)
145966
- - do NOT pre-shape their output with a finding schema
145967
- - do NOT mention the other lenses (independence is the point \u2014 overlapping findings are a strong signal)
145968
-
145969
- 4. **aggregate & draft**: merge findings; de-dup overlaps (two lenses catching the same issue = higher-confidence signal); trace each finding yourself before accepting it. drop praise, style preferences, speculative/unverified claims, findings about pre-existing code unrelated to the PR (heuristic: if the finding's root cause lives in lines this PR added or modified, it's in scope; otherwise drop unless the PR plausibly introduced or amplified the regression), and anything not actionable. also drop **bloat-shaped findings** \u2014 proposed fixes that would add defensive checks for cases that can't happen, abstractions used once, comments restating obvious code, tests asserting tautologies, or "just-in-case" guards. subagents are fallible and bias toward recommending changes; the bar for an actionable inline comment is sound + correct + elegant. recommending a change that improves only one of the three (or worse, degrades elegance to nominally improve correctness) makes the codebase worse, not better.
145970
-
145971
- for surviving findings, draft inline comments with NEW line numbers from the diff. every comment must be actionable, 2-3 sentences max. use GitHub permalink format for code references. for impact-analysis findings (stale references after rename/remove), report them in the review body ordered by severity (runtime breakage > incorrect docs > stale comments) rather than as inline comments unless they're anchored to a specific line.
145972
-
145973
- 5. **submit**: ALWAYS submit exactly one review via \`${t2("create_pull_request_review")}\`. Do NOT call \`report_progress\` \u2014 the review is the final record and the progress comment will be cleaned up automatically.
145974
-
145975
- note: the first create_pull_request_review submission may error with a one-time diff-coverage nudge listing unread TOC regions. retry the same call to proceed \u2014 optionally after reading the listed ranges. the pre-flight will not block again this session.
145976
-
145977
- - **critical issues** (blocks merge \u2014 bugs, security, data loss):
145978
- \`approved: false\`. Body begins with a GitHub alert blockquote, e.g.:
145979
- \`> [!CAUTION]\\n> This PR introduces a race condition in ...\`
145980
- Follow with a brief summary if needed. Include all inline comments.
145981
- - **recommended changes** (non-critical):
145982
- \`approved: false\`. Body begins with a GitHub alert blockquote, e.g.:
145983
- \`> [!IMPORTANT]\\n> Consider adding input validation for ...\`
145984
- Follow with a brief summary if needed. Include all inline comments.
145985
- - **no actionable issues**:
145986
- \`approved: true\`, body: "Reviewed \u2014 no issues found."`
145987
- },
145988
- // IncrementalReview shares Review's multi-lens orchestrator pattern but
145989
- // scopes the target to the incremental diff and adds prior-review-feedback
145990
- // tracking. The "issues must be NEW since the last Pullfrog review" filter
145991
- // lives at aggregation time (step 5), NOT in the subagent prompt — pushing
145992
- // the filter into subagents matches the canonical anneal anti-pattern of
145993
- // "list known pre-existing failures — don't flag these" and suppresses
145994
- // signal on regressions the new commits amplified. The body-format rules
145995
- // (Reviewed changes / Prior review feedback) are unchanged from the prior
145996
- // version. Same severity-table omission as Review.
145997
- {
145998
- name: "IncrementalReview",
145999
- description: "Re-review a PR after new commits are pushed; focus on new changes since the last review",
146000
- prompt: `### Checklist
146001
-
146002
- 1. **checkout**: call \`${t2("checkout_pr")}\` \u2014 this returns PR metadata, \`diffPath\` (full diff), and \`incrementalDiffPath\` (changes since last reviewed version, if available). read the diff TOC first and use its line ranges as your coverage checklist.
146003
-
146004
- 2. **incremental scope**: if \`incrementalDiffPath\` is present, read it to see what changed since the last review. this is a range-diff that isolates the net changes, filtering out base branch noise. if not present, fall back to reviewing the full PR diff and determine what changed since Pullfrog's most recent review.
146005
-
146006
- 3. **prior feedback**: fetch previous reviews via \`${t2("list_pull_request_reviews")}\`. for the most recent Pullfrog review, call \`${t2("get_review_comments")}\` with the review ID to retrieve specific prior line-level feedback. you'll need this in step 6 to track which prior comments were addressed.
146007
-
146008
- 4. **triage & fan out**: orient on the *incremental* changes \u2014 domain, seams, external contracts, user-facing surfaces.
146009
-
146010
- if the incremental changes are **genuinely trivial**, skip the fan-out entirely and jump to step 7's non-substantive path (do NOT submit a review).
146011
-
146012
- "Genuinely trivial" (skip): formatting/comment tweaks, import reordering, lockfile regen, mechanical rename of import paths, whitespace-only.
146013
- "Looks trivial but isn't" (do NOT skip \u2014 same anti-patterns as Review mode): 1-line changes to SQL/regex/auth/billing/permissions/signature-verification code; flipping feature-flag defaults or retry/timeout constants; money/tax/HTTP-method/redirect changes; tightening or loosening a comparison operator; mixed diffs with a semantic line buried in formatting.
146014
- When unsure, treat as non-trivial.
146015
-
146016
- otherwise pick lenses by where the new commits concentrate risk \u2014 **there's no fixed count**, same calibration as Review mode (1 lens for pure refactor / isolated fix; 2\u20133 for typical features; 4\u20135 for high-stakes subsystem touches; 6+ is a smell). lens framing follows Review mode: themed lenses (correctness & invariants, impact when new commits remove/rename/deprecate things, research-validated assumptions, security, user-journey, operational readiness, integration & cross-cutting, test integrity, performance, holistic) and subsystem lenses (auth, billing, schema migration, etc.) \u2014 for high-stakes domains lead with the subsystem lens rather than the generic themed equivalent.
146017
-
146018
- dispatch one \`${REVIEWER_AGENT_NAME}\` subagent per lens \u2014 its baked-in system prompt enforces the non-mutative + non-recursive contract (read-only file/search/web tools and read-only MCP queries; no writes, shell side effects, state-changing MCP calls, or nested subagent dispatch). dispatch them in a **single assistant turn with multiple parallel subagent calls** (serial dispatch collapses the fan-out). if a subagent errors out, times out, or returns nothing usable, retry once with the same lens; if it still fails, proceed with partial coverage and note the missing lens in the review body \u2014 do not skip step 4 entirely on a single subagent failure. each subagent gets:
146019
- - the diff scope (incremental diff path if available, full diff otherwise). do NOT tell them to skip pre-existing issues \u2014 that suppresses regressions the new commits amplified; the "issues must be NEW" filter lives at aggregation time (step 5), not in the subagent prompt
146020
- - **only one lens** \u2014 never a multi-section "review for X, Y, and Z" prompt
146021
- - **a Task \`description\` set to the lens name** (e.g. \`"security"\`, \`"correctness"\`, \`"billing-subsystem"\`) \u2014 the harness reads this field to label the subagent's log lines so parallel runs can be told apart in CI output. without it, every subagent shows up as \`subagent#N\`.
146022
- - the read-only contract restated in your dispatch instructions so the rule is present twice (the subagent's system prompt also enforces it). The test: would this call still be a no-op if reverted? If not (PR comments, branch pushes, issue updates, set_output, label changes, dependency installs, etc.), don't make it.
146023
- - if the lens touches external contracts, instruct the subagent to verify load-bearing claims via web search and quote source URLs. action runs are non-interactive \u2014 there's no human to catch "I'm pretty sure Stripe does X."
146024
- - ask the subagent to report findings with file paths and NEW line numbers from the full PR diff so you can anchor inline comments.
146025
-
146026
- delegation discipline:
146027
- - do NOT lens-review the diff yourself in parallel with the subagents
146028
- - do NOT summarize the changes for them (biases toward validation frame)
146029
- - do NOT hand them a curated reading list (let them discover scope)
146030
- - do NOT pre-shape their output with a finding schema
146031
- - do NOT mention the other lenses (independence is the point)
146032
-
146033
- 5. **aggregate, draft, self-critique**: merge findings; de-dup overlaps; trace each finding yourself. drop praise, style preferences, speculative/unverified claims, findings about pre-existing code unrelated to the new commits, anything not actionable, and anything that re-states prior review feedback (heuristic: if the finding's root cause lives in lines the *new commits* added or modified, it's in scope; otherwise drop). also drop **bloat-shaped findings** \u2014 proposed fixes that would add defensive checks for cases that can't happen, abstractions used once, comments restating obvious code, tests asserting tautologies, or "just-in-case" guards. subagents are fallible and bias toward recommending changes; the bar for an actionable inline comment is sound + correct + elegant. recommending a change that improves only one of the three (or degrades elegance to nominally improve correctness) makes the codebase worse, not better. To compute "lines the new commits added or modified": if \`incrementalDiffPath\` from step 1 is present, use it directly. Otherwise, take the prior Pullfrog review's \`commit_id\` (returned alongside each entry from \`${t2("list_pull_request_reviews")}\` in step 3) and run \`git diff <prior-review-sha>..HEAD\` to isolate the lines added since that review. draft inline comments with NEW line numbers from the full PR diff \u2014 every comment must be actionable, 2-3 sentences max.
146034
-
146035
- then check: which prior review comments were addressed by the new commits? track the addressed ones for step 6b.
146036
-
146037
- 6. **build the review body** \u2014 two distinct sections:
146038
- a. **Reviewed changes**: summarize at the logical-change level, not per-file. each bullet starts with a past-tense verb (e.g. \`- Extracted shared CLI runtime into a single module\`, \`- Renamed package to pullfrog\`). avoid file paths unless they add clarity. if the changes can be described in one sentence, use one sentence \u2014 no bullets needed.
146039
- b. **Prior review feedback** (only if any were addressed): list only the prior review comments that WERE addressed by the new commits (\`- [x] safeParse instead of parse \u2014 addressed\`). omit unaddressed comments. omit this entire section if nothing was addressed. a change can appear in both sections.
146040
- - no headings, no tables, no prose paragraphs in either section \u2014 just bullets
146041
- - in some cases you may receive a complete diff for the whole pull request instead of an incremental one. when this happens, you will need to determine what changes have happened since Pullfrog's most recent review.
146042
-
146043
- 7. Submit \u2014 Do NOT call \`report_progress\` or \`create_issue_comment\` \u2014 the review is the final record and the progress comment will be cleaned up automatically. the review body always includes the reviewed changes from step 6a. append \`Prior review feedback:\\n\` with the checklist from step 6b only if any prior comments were addressed. Follow these rules:
146044
- - note: the first create_pull_request_review submission may error with a one-time diff-coverage nudge listing unread TOC regions. retry the same call to proceed \u2014 optionally after reading the listed ranges. the pre-flight will not block again this session.
146045
- - IF NO NEW ISSUES, NON-SUBSTANTIVE CHANGES ONLY (trivial formatting, import reordering, comment tweaks): do NOT submit a review. Do NOT call \`report_progress\`. Exit \u2014 the progress comment will be cleaned up automatically.
146046
- - ELSE IF NEW CRITICAL ISSUES (blocks merge): call \`${t2("create_pull_request_review")}\` with \`approved: false\`, all comments, and the review body. body opens with a GitHub alert blockquote (e.g. \`> [!CAUTION]\\n> This PR introduces ...\`), then the reviewed changes summary and prior feedback (if any).
146047
- - ELSE IF NEW RECOMMENDED CHANGES (non-critical): call \`${t2("create_pull_request_review")}\` with \`approved: false\`, all comments, and the review body. body opens with \`> [!IMPORTANT]\\n> ...\` alert, then the reviewed changes summary and prior feedback (if any).
146048
- - ELSE IF NO NEW ISSUES, SUBSTANTIVE CHANGES (new functionality, behavior changes, or fixes to prior review feedback): call \`${t2("create_pull_request_review")}\` to create a PR review. If all previous reviews have been properly addressed and no new issues were discovered, you can set \`approved: true\`. body opens with \`No new issues. Reviewed the following changes:\\n\`, then the reviewed changes summary and prior feedback (if any).`
146049
- },
146050
- {
146051
- name: "Plan",
146052
- description: "Create plans, break down tasks, outline steps, analyze requirements, understand scope of work, or provide task breakdowns",
146053
- prompt: `### Checklist
146054
-
146055
- 1. Analyze the task and gather context:
146056
- - read AGENTS.md and relevant codebase files
146057
- - understand the architecture and constraints
146058
-
146059
- 2. Produce a structured, actionable plan with clear milestones.
146060
-
146061
- 3. Call \`${t2("report_progress")}\` with the plan.
146062
-
146063
- ${learningsStep(t2, 4)}`
146064
- },
146065
- {
146066
- name: "Fix",
146067
- description: "Fix CI failures; debug failing tests or builds; investigate and resolve check suite failures",
146068
- prompt: `### Checklist
146069
-
146070
- 1. Checkout the PR branch via \`${t2("checkout_pr")}\`.
146071
-
146072
- 2. Fetch check suite logs via \`${t2("get_check_suite_logs")}\`.
146073
-
146074
- 3. **CRITICAL**: verify the failure was INTRODUCED BY THIS PR before fixing. If unrelated, abort and report.
146075
-
146076
- 4. Diagnose and fix:
146077
- - read the workflow file, reproduce locally with the EXACT same commands CI runs
146078
- - fix the issue using your native file and shell tools
146079
- - verify the fix by re-running the exact CI command
146080
- - review the diff before committing \u2014 verify only the fix is present, no debug artifacts, no unrelated changes. the fix should be clean enough that a senior engineer would approve without hesitation.
146081
- - commit locally via shell (\`git add . && git commit -m "..."\`)
146082
-
146083
- 5. Finalize:
146084
- - confirm a clean working tree, then push via \`${t2("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
146085
- - call \`${t2("report_progress")}\` with the diagnosis and fix summary (or the exact push error if push failed)
146086
-
146087
- ${learningsStep(t2, 6)}`
146088
- },
146089
- {
146090
- name: "ResolveConflicts",
146091
- description: "Resolve merge conflicts in a PR branch against the base branch",
146092
- prompt: `### Checklist
146093
-
146094
- 1. **Setup**:
146095
- - Call \`${t2("checkout_pr")}\` to get the PR branch.
146096
- - Call \`${t2("get_pull_request")}\` to identify the base branch (e.g., 'main').
146097
- - Call \`${t2("git_fetch")}\` to fetch the base branch.
146098
-
146099
- 2. **Merge Attempt**:
146100
- - Run \`git merge origin/<base_branch>\` via shell.
146101
- - If it succeeds automatically, confirm a clean working tree, push via \`${t2("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*), and call \`${t2("report_progress")}\` with a brief success note or the exact push error if push failed \u2014 **then stop; do not run steps 3\u20134.**
146102
- - If it fails (conflicts), resolve them manually (continue to steps 3\u20134).
146103
-
146104
- 3. **Resolve Conflicts**:
146105
- - Run \`git status\` or parse the merge output to find the list of conflicting files.
146106
- - For each conflicting file: read it, find the conflict markers (\`<<<<<<<\`, \`=======\`, \`>>>>>>>\`), understand the code context, and rewrite the file with the correct resolution. Remove all markers.
146107
- - Verify the file syntax is correct after resolution.
146108
-
146109
- 4. **Finalize**:
146110
- - Run a final verification (build/test) to ensure the resolution works.
146111
- - \`git add . && git commit -m "resolve merge conflicts"\`
146112
- - confirm a clean working tree, then push via \`${t2("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
146113
- - Call \`${t2("report_progress")}\` with a summary of what was resolved (or the exact push error if push failed)`
146114
- },
146115
- {
146116
- name: "Task",
146117
- description: "General-purpose tasks that don't fit other modes: answering questions, adding comments, labeling, running ad-hoc commands, or any direct request",
146118
- prompt: `### Checklist
146119
-
146120
- 1. Analyze the task. For simple operations (labeling, commenting, answering questions, running a single command), handle directly.
146121
-
146122
- 2. For substantial work \u2014 code changes across multiple files, multi-step investigations:
146123
- - plan your approach before starting
146124
- - use native file and shell tools for local operations
146125
- - use ${pullfrogMcpName} MCP tools for GitHub/git operations
146126
- - if code changes are needed: review your own diff before committing \u2014 verify only intended changes are present, no debug artifacts remain, and the changes are clean enough that a senior engineer would approve without hesitation
146127
-
146128
- 3. Finalize:
146129
- - if code changes were made, push to a pull request (new or existing) using \`${t2("push_branch")}\` and \`${t2("create_pull_request")}\` as needed. \`git status\` must be clean before you finish (see *SYSTEM* Git rules if push fails).
146130
- - call \`${t2("report_progress")}\` once with results \u2014 include exact tool errors if push or PR creation failed
146131
- - if the task involved labeling, commenting, or other GitHub operations, perform those directly
146132
-
146133
- ${learningsStep(t2, 4)}`
146134
- },
146135
- {
146136
- name: "Summarize",
146137
- description: "Summarize a PR with a structured comment that is updated in place on subsequent pushes",
146138
- prompt: `### Checklist
146139
-
146140
- 1. Checkout the PR via \`${t2("checkout_pr")}\` \u2014 this returns PR metadata and a \`diffPath\`.
146141
- 2. Read the diff using the TOC to selectively read relevant sections (not the entire file). Produce a structured summary. If EVENT INSTRUCTIONS specify a custom format, follow that instead of the default format below.
146142
- 3. Call \`${t2("create_issue_comment")}\` with \`type: "Summary"\` and the summary body.
146143
- 4. Call \`${t2("report_progress")}\` with a brief note (e.g., "Posted PR summary.").
146144
-
146145
- ${PR_SUMMARY_FORMAT}`
146146
- }
146147
- ];
146148
- }
146149
- var modes = computeModes("opencode");
146150
-
146151
145741
  // mcp/selectMode.ts
146152
145742
  var SelectModeParams = type({
146153
145743
  mode: type.string.describe(
146154
- "the name of the mode to select (e.g., 'Build', 'Plan', 'Review', 'IncrementalReview', 'Fix', 'AddressReviews', 'Task', 'ResolveConflicts', 'Summarize')"
145744
+ "the name of the mode to select (e.g., 'Build', 'Plan', 'Review', 'IncrementalReview', 'Fix', 'AddressReviews', 'Task', 'ResolveConflicts')"
146155
145745
  ),
146156
145746
  "issue_number?": type("number").describe(
146157
145747
  "optional issue number; when provided with Plan mode, used to look up an existing plan comment for this issue (edit vs create)"
@@ -146172,18 +145762,7 @@ An existing plan comment was found for this issue. Update that comment with the
146172
145762
  - gather relevant codebase context (file paths, architecture notes from AGENTS.md)
146173
145763
  - produce a structured plan with clear milestones
146174
145764
  3. Call \`${t2("report_progress")}\` with the full revised plan text and \`{ target_plan_comment: true }\` so it updates the existing plan comment (not the progress comment).
146175
- 4. Then post a short note to the progress comment (e.g. "Plan has been updated in the comment above.") via \`${t2("report_progress")}\` so it is not left as "Leaping...".`,
146176
- SummaryUpdate: `### Checklist (updating existing summary)
146177
-
146178
- An existing summary comment was found for this PR. Update it rather than creating a new one.
146179
-
146180
- 1. Use \`previousSummaryBody\` from this response as the current summary to revise.
146181
- 2. Checkout the PR via \`${t2("checkout_pr")}\` \u2014 this returns PR metadata and a \`diffPath\`.
146182
- 3. Read the diff using the TOC to selectively read relevant sections. Produce an updated summary reflecting the current state of the PR, using the existing summary (\`previousSummaryBody\`) as a starting point. If EVENT INSTRUCTIONS specify a custom format, follow that instead of the default format below.
146183
- 4. Call \`${t2("edit_issue_comment")}\` with \`commentId: existingSummaryCommentId\` (from this response) and the updated summary body.
146184
- 5. Call \`${t2("report_progress")}\` with a brief note (e.g., "Updated PR summary.").
146185
-
146186
- ${PR_SUMMARY_FORMAT}`
145765
+ 4. Then post a short note to the progress comment (e.g. "Plan has been updated in the comment above.") via \`${t2("report_progress")}\` so it is not left as "Leaping...".`
146187
145766
  };
146188
145767
  }
146189
145768
  var modeInstructionParent = {
@@ -146216,30 +145795,22 @@ async function fetchExistingPlanComment(ctx, issueNumber) {
146216
145795
  return null;
146217
145796
  }
146218
145797
  }
146219
- async function fetchExistingSummaryComment(ctx, prNumber) {
146220
- if (!ctx.githubInstallationToken) {
146221
- log.warning("fetchExistingSummaryComment: no token, skipping");
146222
- return null;
146223
- }
146224
- const path3 = `/api/repo/${ctx.repo.owner}/${ctx.repo.name}/pr/${prNumber}/summary-comment`;
146225
- try {
146226
- const response = await apiFetch({
146227
- path: path3,
146228
- method: "GET",
146229
- headers: { authorization: `Bearer ${ctx.githubInstallationToken}` },
146230
- signal: AbortSignal.timeout(1e4)
146231
- });
146232
- const data = await response.json();
146233
- if (response.ok && "commentId" in data) {
146234
- return data;
146235
- }
146236
- const errMsg = "error" in data ? data.error : "(no error body)";
146237
- log.warning(`fetchExistingSummaryComment: ${response.status} ${path3} \u2014 ${errMsg}`);
146238
- return null;
146239
- } catch (error49) {
146240
- log.warning("fetchExistingSummaryComment failed:", error49);
146241
- return null;
146242
- }
145798
+ var SUMMARY_MODES = /* @__PURE__ */ new Set(["Review", "IncrementalReview", "Task"]);
145799
+ function buildSummaryAddendum(t2, ctx) {
145800
+ const filePath = ctx.toolState.summaryFilePath;
145801
+ if (!filePath) return "";
145802
+ return `### PR summary snapshot \u2014 required step
145803
+
145804
+ A rolling PR summary lives at \`${filePath}\`. It is your durable cross-run agent context \u2014 a functional summary of what this PR does, the subsystems and files it touches, the material behavior of its changes, and any risks or open questions worth carrying forward. It is NOT a chronological log of past review runs; commit-level history can already be reconstructed from \`${t2("list_pull_request_reviews")}\`.
145805
+
145806
+ How to use it:
145807
+
145808
+ - read \`${filePath}\` at the START of the run, alongside the diff. it represents what previous agent runs already understood about this PR \u2014 absorb it before picking lenses or crafting subagent dispatch prompts. if it's a fresh seed (file is one or two lines), this is a first review and you'll be filling it in from the diff.
145809
+ - let the snapshot inform triage and dispatch. when it already tracks a risk, your lens prompts to subagents are stronger when they reference that context (e.g. "the JSDoc explicitly scopes to code points \u2014 do not flag grapheme-cluster issues" if the snapshot already documents that contract). when something the snapshot tracks is now resolved by new commits, note that. when new commits introduce something the snapshot doesn't yet describe, that's exactly where your fan-out should focus.
145810
+ - update the file in place to reflect the PR's CURRENT state. revise stale claims, drop resolved risks, add new behavior or risks. accuracy over breadth \u2014 every claim must be grounded in the diff. write for the next agent run, not for a human.
145811
+ - structure however serves THIS PR. there is no required section template. a refactor might organize by renamed export and call-site impact; a feature by capability; a billing change by money path. a compact note of which commit ranges have been reviewed should always be present so future runs scope correctly, but the rest is your call. when the structure works across runs, keep it stable so range-diffs are clean; when the PR's character changes (e.g. scope expands), reshape.
145812
+
145813
+ Do NOT call \`${t2("create_issue_comment")}\` for the summary \u2014 the server reads this file at end-of-run and persists it. The file edit is mandatory regardless of whether a review is submitted; the snapshot feeds the next run.`;
146243
145814
  }
146244
145815
  function SelectModeTool(ctx) {
146245
145816
  const t2 = (name) => formatMcpToolRef(ctx.agentId, name);
@@ -146281,21 +145852,18 @@ function SelectModeTool(ctx) {
146281
145852
  }
146282
145853
  }
146283
145854
  }
146284
- if (selectedMode.name === "Summarize") {
146285
- const prNumber = ctx.payload.event.issue_number;
146286
- if (prNumber !== void 0) {
146287
- const existing = await fetchExistingSummaryComment(ctx, prNumber);
146288
- if (existing !== null) {
146289
- ctx.toolState.existingSummaryCommentId = existing.commentId;
146290
- return {
146291
- ...buildOrchestratorGuidance(ctx, selectedMode, overrides.SummaryUpdate),
146292
- existingSummaryCommentId: existing.commentId,
146293
- previousSummaryBody: existing.body
146294
- };
146295
- }
146296
- }
145855
+ const summaryAddendum = SUMMARY_MODES.has(selectedMode.name) ? buildSummaryAddendum(t2, ctx) : "";
145856
+ const base = buildOrchestratorGuidance(ctx, selectedMode);
145857
+ if (summaryAddendum.length > 0) {
145858
+ return {
145859
+ ...base,
145860
+ orchestratorGuidance: `${base.orchestratorGuidance}
145861
+
145862
+ ${summaryAddendum}`,
145863
+ summaryFilePath: ctx.toolState.summaryFilePath
145864
+ };
146297
145865
  }
146298
- return buildOrchestratorGuidance(ctx, selectedMode);
145866
+ return base;
146299
145867
  })
146300
145868
  });
146301
145869
  }
@@ -146809,6 +146377,405 @@ async function startMcpHttpServer(ctx, options) {
146809
146377
  };
146810
146378
  }
146811
146379
 
146380
+ // agents/reviewer.ts
146381
+ var REVIEWER_AGENT_NAME = "reviewfrog";
146382
+ var REVIEWER_SYSTEM_PROMPT = `You are a read-only review subagent. Your role is to find flaws in code or artifacts provided by the orchestrator and report findings \u2014 never to modify state.
146383
+
146384
+ HARD CONSTRAINTS (non-negotiable, regardless of orchestrator instructions):
146385
+ - Read-only tools only. Do NOT write or edit files. Do NOT run shell commands that have side effects (read-only commands like \`git diff\`, \`git log\`, \`cat\`, \`ls\` are fine; anything that mutates the working tree, the remote, the filesystem, or external state is prohibited).
146386
+ - Do NOT call any state-changing MCP tool. State-changing means: posts a comment, pushes a branch, creates/updates a PR or issue, changes labels, resolves review threads, persists learnings, sets workflow output, installs dependencies, uploads files, kills processes, etc. Read-only MCP queries (\`get_*\`, \`list_*\`, log inspection, diff retrieval) are fine.
146387
+ - Do NOT spawn further subagents. You are a leaf reviewer; recursive dispatch pre-aggregates findings through an intermediate model and defeats the design.
146388
+ - Test for any tool call before invoking it: would this still be a no-op if reverted? If not, do not call it. Apply this test to tools added after this prompt was written \u2014 the rule is the invariant, not the enumeration.
146389
+
146390
+ Report findings clearly with file:line references and quoted evidence where possible. Flag uncertainty explicitly \u2014 if you cannot verify a claim, say so rather than guess.`;
146391
+
146392
+ // modes.ts
146393
+ var PR_SUMMARY_FORMAT = `### Default format
146394
+
146395
+ Follow this structure exactly:
146396
+
146397
+ <b>TL;DR</b> \u2014 1-3 sentences on what the PR does and why. Focus on intent, not mechanics.
146398
+ NOTE: use HTML bold <b>TL;DR</b>, NOT markdown bold **TL;DR**.
146399
+
146400
+ ### Key changes
146401
+
146402
+ - **Short human-readable title** \u2014 1 sentence per change. Write a short prose phrase (title case or sentence case); when you name a file, type, or function, put that name in backticks (e.g. **Add \`TodoTracker\` for live checklists**). A reviewer should understand the full PR from this list alone.
146403
+
146404
+ <sub><b>Summary</b> \uFF5C {file_count} files \uFF5C {commit_count} commits \uFF5C base: \`{base}\` \u2190 \`{head}\`</sub>
146405
+ NOTE: the metadata line goes AFTER the bullet list, not before it.
146406
+
146407
+ Then for each key change, a ## section with a short descriptive title that reads like a documentation heading (e.g. ## Live todo checklist tracking).
146408
+
146409
+ <br/>
146410
+
146411
+ ## Example readable section title
146412
+
146413
+ > **Before:** [old behavior/state]<br/>**After:** [new behavior/state]
146414
+ IMPORTANT: Before and After MUST be on a SINGLE blockquote line with an inline <br/> between them. Two separate \`>\` lines creates a double line break.
146415
+
146416
+ 1-2 sentences of explanation. Break up text with tables, blockquotes, or lists \u2014 NEVER 3+ plain paragraphs in a row.
146417
+
146418
+ If a change warrants deeper explanation, use a blockquoted details/summary framed as a question:
146419
+ > <details><summary>How does X work?</summary>
146420
+ > Extended explanation here.
146421
+ > </details>
146422
+
146423
+ End each section with a file links trail (3-4 key files max):
146424
+ [\`file.ts\`](https://github.com/{owner}/{repo}/pull/{number}/files#diff-{sha256hex_of_filepath}) \xB7 ...
146425
+
146426
+ Single-feature PRs: skip the ## sections. Fold before/after and explanation into the header after key changes.
146427
+
146428
+ CRITICAL \u2014 GitHub markdown rendering rule:
146429
+ GitHub's markdown parser requires a blank line between ALL block-level elements. This includes transitions between: HTML tags (<br/>, <sub>, <details>, <b>, etc.) and markdown syntax (headings, lists, blockquotes, paragraphs). Without a blank line, GitHub treats the following content as a continuation of the HTML block and renders markdown syntax as literal text. ALWAYS separate block-level elements with a blank line.
146430
+
146431
+ Rules:
146432
+ - \`##\` titles and key-change bullet lead-ins are plain-language summaries; backtick only actual code tokens (files, types, functions) where they appear in the title
146433
+ - ALL variable names, identifiers, and file names in body text must be in backticks
146434
+ - ALL file references MUST link to the PR Files Changed view. Use the \`diff-<hex>\` anchor precomputed next to each filename in the \`checkout_pr\` TOC \u2014 do NOT run \`sha256sum\` or any other shell command to compute anchors. NEVER fabricate hex strings. If a file is not in the TOC, omit the \`#diff-\` anchor rather than guessing.
146435
+ - Add <br/> before each ## heading for visual spacing. Do NOT use horizontal rules (---)
146436
+ - Do NOT include raw diff stats like '+123 / -45' or line counts
146437
+ - Do NOT include code blocks or repeat diff contents
146438
+ - Do NOT include a changelog section \u2014 the key changes list serves this purpose
146439
+ - Focus on *intent*, not *what* \u2014 the diff already shows what changed
146440
+ - Get the file count and commit count from the checkout_pr metadata, not by counting manually`;
146441
+ function learningsStep(t2, n) {
146442
+ return `${n}. **learnings** (only if high confidence): if you discovered something about repo setup, test commands, conventions, or patterns that you are confident is correct and would reliably help future runs, call \`${t2("update_learnings")}\` to persist it. skip this step if you are unsure or the finding is speculative/one-off. format as a flat bullet list (\`- \` per line, one fact per bullet). merge with existing learnings from the prompt \u2014 pass the FULL merged list. deduplicate, and drop bullets that are clearly wrong or no longer relevant to the current codebase.`;
146443
+ }
146444
+ function computeModes(agentId) {
146445
+ const t2 = (toolName) => formatMcpToolRef(agentId, toolName);
146446
+ return [
146447
+ {
146448
+ name: "Build",
146449
+ description: "Implement, build, create, or develop code changes; make specific changes to files or features; execute a plan; or handle tasks with specific implementation details",
146450
+ prompt: `### Checklist
146451
+
146452
+ 1. **plan** (optional, for complex tasks): analyze requirements, read AGENTS.md and relevant code, produce a step-by-step implementation plan.
146453
+
146454
+ 2. **setup**: checkout or create the branch:
146455
+ - **PR event, modifying the existing PR**: call \`${t2("checkout_pr")}\`
146456
+ - **new branch**: use \`${t2("git")}\` to create a branch (\`git checkout -b pullfrog/branch-name\`)
146457
+
146458
+ 3. **build**: implement changes using your native file and shell tools:
146459
+ - follow the plan (if you ran a plan phase)
146460
+ - plan your approach before writing code: identify which files need to change, key design decisions, and edge cases. for non-trivial changes, consider whether there's a more elegant approach.
146461
+ - run relevant tests/lints before committing
146462
+
146463
+ 4. **self-review**: judgment call \u2014 does YOUR diff warrant a fresh-eyes pass?
146464
+
146465
+ Skip self-review (commit directly) when the diff is **genuinely trivial**:
146466
+ - doc typos, comment-only edits, whitespace/format-only, import reordering
146467
+ - lockfile or generated-code regeneration, mechanical rename whose only effect is import-path updates (size of diff is irrelevant \u2014 read the *shape*, not the line count)
146468
+ - low-risk dep patch bump from a trusted source
146469
+
146470
+ Run self-review when the diff has **any behavioral surface, however small**:
146471
+ - 1-line changes to SQL operators / comparison logic / regexes / redirects / HTTP methods / response codes
146472
+ - any change to money / tax / currency / billing / fee / refund / payout calculations or constants
146473
+ - any change to auth / permissions / roles / sessions / tokens / signature verification
146474
+ - any change to feature-flag defaults, retry counts, timeouts, rate limits, batch sizes
146475
+ - new endpoints, new code paths, new error branches \u2014 even small ones
146476
+ - mixed diffs (whitespace + a single semantic line) \u2014 the semantic line still triggers self-review
146477
+ - anything you're uncertain about
146478
+
146479
+ Tie-breaker: when in doubt, run self-review. One false-positive subagent dispatch costs cents; one false-negative shipped bug costs much more. There's no value in dispatching for a typo, but there's also no excuse for skipping on a 1-line change to a billing path.
146480
+
146481
+ Otherwise delegate the \`${REVIEWER_AGENT_NAME}\` subagent to review your diff with fresh eyes against YOUR TASK. The subagent's baked-in system prompt enforces a non-mutative + non-recursive contract: read-only file/search/web tools and read-only MCP queries only; no writes, shell side effects, state-changing MCP calls, or nested subagent dispatch. Enforcement is prose-only \u2014 restate the constraint in your dispatch instructions and do not relax it.
146482
+
146483
+ Provide the subagent with YOUR TASK, the output of \`git diff\`, and a tight summary (not raw output) of any lint/typecheck/test failures you fixed during build \u2014 what broke, root cause, the fix \u2014 so it can check that fixes addressed root causes rather than suppressed symptoms; say "no build-phase failures" if the build path was clean. Instruct it to flag bugs, logic errors, missing edge cases, gaps between request and diff, and unintended changes.
146484
+
146485
+ Delegation + research discipline (distilled from \`/anneal\` canonical \u2014 these are codified learnings from many review rounds, not theoretical best practices):
146486
+ - Do NOT summarize what you implemented \u2014 that biases the subagent toward validating the shape of your solution rather than questioning it.
146487
+ - Do NOT curate a reading list of files. Let the subagent discover scope from the diff and codebase.
146488
+ - Do NOT pre-shape output with a severity / category schema. That leaks your hypotheses; severity is your call during evaluation.
146489
+ - Do NOT defect-hunt the diff yourself in parallel with the subagent. Your role is dispatch + evaluation; doing the review yourself reintroduces the implementation bias the subagent is meant to mitigate.
146490
+ - For diffs that rely on third-party API contracts, SDK semantics, framework directives, or DB engine specifics, instruct the subagent to verify load-bearing claims via web search and quote source URLs rather than trust training data \u2014 this is the single most common review-quality failure mode.
146491
+
146492
+ Review the findings, address valid points, and discard nitpicks or false positives. The reviewer is fallible \u2014 it biases toward *recommending additions* (defensive checks for impossible cases, extra logging, new abstractions used once, comments restating code, tests asserting tautologies, "just-in-case" guards). For each finding, ask: would applying it leave the code more sound, correct, AND elegant? Two-out-of-three is usually a signal to look harder for a fix that gets all three before settling for one that trades elegance for correctness. Reject bloat-shaped findings without applying them, and after applying the rest re-read your diff and be discerning about what *you just changed*: if any fix turned out to be bloat in context, revert it. The goal is code that is sound and correct *while remaining elegant*; the smallest diff that fixes the real defect almost always wins. Then verify only intended changes are present, no debug artifacts or commented-out code remain, no unrelated files were modified. Commit locally via shell (\`git add . && git commit -m "..."\`).
146493
+
146494
+ 5. **finalize**:
146495
+ - confirm a clean working tree, then push via \`${t2("push_branch")}\` (see *SYSTEM* Git rules if this fails \u2014 prepush errors are usually the repo's tests/lint, not infra timeouts)
146496
+ - create a PR via \`${t2("create_pull_request")}\`
146497
+ - call \`${t2("report_progress")}\` with the PR link or the exact error if push/PR failed
146498
+
146499
+ ${learningsStep(t2, 6)}
146500
+
146501
+ ### Notes
146502
+
146503
+ For simple, well-defined tasks, skip the plan phase and go straight to build.`
146504
+ },
146505
+ {
146506
+ name: "AddressReviews",
146507
+ description: "Address PR review feedback; respond to reviewer comments; make requested changes to an existing PR",
146508
+ prompt: `### Checklist
146509
+
146510
+ 1. Checkout the PR branch via \`${t2("checkout_pr")}\`.
146511
+
146512
+ 2. Fetch review comments via \`${t2("get_review_comments")}\`.
146513
+
146514
+ 3. For each comment:
146515
+ - understand the feedback
146516
+ - evaluate whether applying it would leave the code more **sound, correct, AND elegant**. reviewers are fallible and bias toward *recommending additions* (defensive checks for impossible cases, extra abstractions, comments restating obvious code, tests asserting tautologies, "just-in-case" guards). if a request would add bloat \u2014 ceremony without commensurate correctness benefit \u2014 push back in your reply rather than mechanically applying it. two-out-of-three is usually a signal to look harder for a fix that gets all three before settling.
146517
+ - if the request stands, make the code change using your native tools; otherwise reply explaining why
146518
+ - record what was done (or why nothing was done)
146519
+
146520
+ 4. Quality check:
146521
+ - test changes, then review the diff before committing \u2014 verify only intended changes are present, no debug artifacts remain, no fix turned out to be bloat in context (revert any that did), and the changes are clean enough that a senior engineer would approve without hesitation
146522
+ - commit locally via shell (\`git add . && git commit -m "..."\`)
146523
+
146524
+ 5. Finalize:
146525
+ - confirm a clean working tree, then push via \`${t2("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
146526
+ - reply to each comment using \`${t2("reply_to_review_comment")}\`
146527
+ - resolve addressed threads via \`${t2("resolve_review_thread")}\`
146528
+ - call \`${t2("report_progress")}\` with a brief summary (or the exact push error if push failed)
146529
+
146530
+ ${learningsStep(t2, 6)}`
146531
+ },
146532
+ // Review and IncrementalReview use the multi-lens orchestrator pattern
146533
+ // (canonical source: .claude/commands/anneal.md). The orchestrator does
146534
+ // triage → parallel read-only subagent fan-out → aggregate → draft comments
146535
+ // → submit. For someone else's PR, parallel lenses (correctness, security,
146536
+ // research-validated claims, user-journey, etc.) provide breadth across
146537
+ // angles that a single subagent can't carry coherently. Build mode keeps
146538
+ // a single fresh-eyes subagent (different problem shape — orchestrator
146539
+ // wrote the code and bias-mitigation comes from delegating to one
146540
+ // subagent that doesn't share the implementation context).
146541
+ // Deliberate omission vs canonical /anneal: severity categorization in the
146542
+ // final message (the review body has its own CAUTION/IMPORTANT framing
146543
+ // instead of a severity table).
146544
+ {
146545
+ name: "Review",
146546
+ description: "Review code, PRs, or implementations; provide feedback or suggestions; identify issues; or check code quality, style, and correctness",
146547
+ prompt: `### Checklist
146548
+
146549
+ 1. **checkout**: call \`${t2("checkout_pr")}\` \u2014 this returns PR metadata and a \`diffPath\`. read the diff TOC end-to-end and treat its file line ranges as your coverage checklist.
146550
+
146551
+ 2. **triage**: orient yourself on the PR \u2014 identify *what kind of thing this is* (domain it touches, seams it crosses, external contracts it depends on, user-facing surfaces it changes). orientation only \u2014 defer specific defect-hunting to the subagents; pre-reviewing biases the lenses you pick. use \`${t2("get_pull_request")}\` and other read-only GitHub tools for additional context if needed.
146552
+
146553
+ if the PR is **genuinely trivial**, skip steps 3\u20134 entirely and submit a \`No new issues found.\` review per step 5. there's no value in dispatching even one lens for a typo.
146554
+
146555
+ "Genuinely trivial" (skip):
146556
+ - single-word doc typo, whitespace/format-only, comment-only across any number of files
146557
+ - lockfile or generated-code regeneration (size of diff is irrelevant \u2014 read the *shape*)
146558
+ - mechanical rename whose only effect is import-path updates
146559
+ - low-risk dep patch bump
146560
+
146561
+ "Looks trivial but isn't" (do **NOT** skip \u2014 small diff, big blast radius):
146562
+ - any 1-line change to SQL / regex / auth / billing / permission / signature-verification code
146563
+ - flipping a feature-flag default, default config value, or retry/timeout constant
146564
+ - changing a money/tax/currency/fee constant by any amount
146565
+ - changing an HTTP method, redirect URL, response code, or status enum
146566
+ - tightening or loosening a comparison operator (\`<\` \u2194 \`<=\`, \`==\` \u2194 \`!=\`)
146567
+ - renaming a public API surface (still trivial in shape, but needs an impact lens)
146568
+ - adding a new direct dependency (supply-chain surface)
146569
+ - any "typo fix" in user-facing copy that changes meaning ("approved" \u2192 "denied")
146570
+ - mixed diffs where a semantic 1-liner is buried in whitespace/formatting changes
146571
+
146572
+ When unsure, treat as non-trivial. The cost of one extra subagent is cents; the cost of a missed billing/auth/data bug is much more.
146573
+
146574
+ otherwise pick lenses by where the PR concentrates risk \u2014 **there's no fixed count**. lens count is judgment, not a formula. concrete shapes to anchor against:
146575
+
146576
+ - **1 lens** \u2014 pure refactor / mechanical rename across many files (impact); new test file with no source change (test-integrity); small isolated bug fix (correctness); doc-only PR with non-trivial technical content (research-validated or holistic)
146577
+ - **2\u20133 lenses (most PRs land here)** \u2014 new CRUD endpoint (correctness + security + test-integrity); new UI flow (user-journey + correctness); a single bug fix in a non-critical subsystem (correctness + test-integrity); design doc covering one domain (research-validated + correctness or holistic)
146578
+ - **4\u20135 lenses (high-stakes subsystem touches)** \u2014 any billing/payments change (billing-subsystem + correctness + security + operational-readiness); new auth flow (auth-subsystem + correctness + security + test-integrity); schema migration (schema-migration-subsystem + correctness + operational-readiness + impact); cross-subsystem PR that touches billing AND auth AND schema (one subsystem lens per domain + correctness)
146579
+ - **6+ lenses** \u2014 almost always a smell; you're either covering overlapping ground or this PR should have been split. push back via the review body rather than expanding lens count.
146580
+
146581
+ lenses come in two flavors, and you can mix them:
146582
+ - **themed lenses** \u2014 a perspective applied across the whole diff (correctness, security, user-journey, performance, etc.).
146583
+ - **subsystem lenses** \u2014 a domain-scoped frame for high-stakes subsystems the PR touches (e.g. "the auth lens", "the billing lens", "the schema-migration lens"). a subsystem lens is "review the PR specifically for what could go wrong in this subsystem" and naturally combines theme + scope. **for high-stakes domains, lead with the subsystem lens rather than the generic themed equivalent** \u2014 "billing-subsystem" outperforms "correctness on billing code" because the framing primes the subagent to remember domain-specific failure modes (double-charges, refund races, currency rounding, dispute flows) the generic lens misses.
146584
+
146585
+ starter menu (combine, omit, or invent your own):
146586
+ - **correctness & invariants** \u2014 bugs, races, error handling, edge cases, state-machine boundaries
146587
+ - **impact** \u2014 when the PR removes features, deletes exports, renames identifiers, or changes architectural patterns: stale references in code, tests, docs (\`docs/\`, \`wiki/\`), comments, configs, UI
146588
+ - **research-validated assumptions** \u2014 third-party API contracts, SDK semantics, framework directives, version-gated behavior. the subagent must verify load-bearing claims via web search and quote source URLs.
146589
+ - **security** \u2014 new endpoints, authZ, input validation, secrets handling, replay/CSRF/injection, cross-tenant isolation
146590
+ - **user-journey** \u2014 UX-touching flows: walk through happy path and failure modes as a user
146591
+ - **operational readiness** \u2014 observability, alerting, migrations (forward + rollback), feature flags, on-call burden
146592
+ - **integration & cross-cutting** \u2014 API contracts between modules, backward-compat of public surfaces, multi-service ordering
146593
+ - **test integrity** \u2014 meaningful coverage for the changed behavior; deterministic; no shared-state pollution
146594
+ - **performance** \u2014 N+1 queries, hot-path allocation, latency budgets, index coverage
146595
+ - **holistic** \u2014 does the PR make sense as a whole? symmetric flows (delete for every create, rollback for every migration)?
146596
+ - **subsystem lenses** (invent as the PR demands) \u2014 auth, billing, payments, schema migration, webhooks, secrets, RBAC, multi-tenant isolation, cron/scheduling, etc.
146597
+
146598
+ 3. **fan out**: dispatch one \`${REVIEWER_AGENT_NAME}\` subagent per lens \u2014 its baked-in system prompt enforces the non-mutative + non-recursive contract (read-only file/search/web tools and read-only MCP queries; no writes, shell side effects, state-changing MCP calls, or nested subagent dispatch). when picking 2+ lenses, dispatch them in a **single assistant turn with multiple parallel subagent calls**; issuing one and awaiting reply before the next collapses the fan-out into a serial review. if a subagent errors out, times out, or returns nothing usable, retry once with the same lens; if it still fails, proceed with partial coverage and note the missing lens in the review body \u2014 do not skip step 3 entirely on a single subagent failure. each subagent gets:
146599
+ - the diff path / target \u2014 reading the diff and the codebase is its job
146600
+ - **only one lens** \u2014 never a multi-section "review for X, Y, and Z" prompt
146601
+ - **a Task \`description\` set to the lens name** (e.g. \`"security"\`, \`"correctness"\`, \`"billing-subsystem"\`) \u2014 the harness reads this field to label the subagent's log lines so parallel runs can be told apart in CI output. without it, every subagent shows up as \`subagent#N\`.
146602
+ - the read-only contract restated in your dispatch instructions so the rule is present twice (the subagent's system prompt also enforces it). The test: would this call still be a no-op if reverted? If not (PR comments, branch pushes, issue updates, set_output, label changes, dependency installs, etc.), don't make it.
146603
+ - if the lens touches external contracts, instruct the subagent to verify load-bearing claims via web search rather than trust training data, and to quote source URLs in its reasoning. action runs are non-interactive \u2014 there's no human in the loop to catch "I'm pretty sure Stripe does X."
146604
+ - ask the subagent to report findings with file paths and NEW line numbers from the diff so you can anchor inline comments without re-reading the entire diff.
146605
+
146606
+ delegation discipline:
146607
+ - do NOT lens-review the diff yourself in parallel with the subagents (your job is dispatch + comment-drafting; doing the lens work yourself reintroduces the bias the fan-out avoids)
146608
+ - do NOT summarize the PR for them (biases toward a validation frame)
146609
+ - do NOT hand them a curated reading list (let them discover scope)
146610
+ - do NOT pre-shape their output with a finding schema
146611
+ - do NOT mention the other lenses (independence is the point \u2014 overlapping findings are a strong signal)
146612
+
146613
+ 4. **aggregate & draft**: merge findings; de-dup overlaps (two lenses catching the same issue = higher-confidence signal); trace each finding yourself before accepting it. drop praise, style preferences, speculative/unverified claims, findings about pre-existing code unrelated to the PR (heuristic: if the finding's root cause lives in lines this PR added or modified, it's in scope; otherwise drop unless the PR plausibly introduced or amplified the regression), and anything not actionable. also drop **bloat-shaped findings** \u2014 proposed fixes that would add defensive checks for cases that can't happen, abstractions used once, comments restating obvious code, tests asserting tautologies, or "just-in-case" guards. subagents are fallible and bias toward recommending changes; the bar for an actionable inline comment is sound + correct + elegant. recommending a change that improves only one of the three (or worse, degrades elegance to nominally improve correctness) makes the codebase worse, not better.
146614
+
146615
+ for surviving findings, draft inline comments with NEW line numbers from the diff. every comment must be actionable, 2-3 sentences max. use GitHub permalink format for code references. for impact-analysis findings (stale references after rename/remove), report them in the review body ordered by severity (runtime breakage > incorrect docs > stale comments) rather than as inline comments unless they're anchored to a specific line.
146616
+
146617
+ 5. **submit**: ALWAYS submit exactly one review via \`${t2("create_pull_request_review")}\`. Do NOT call \`report_progress\` \u2014 the review is the final record and the progress comment will be cleaned up automatically.
146618
+
146619
+ note: the first create_pull_request_review submission may error with a one-time diff-coverage nudge listing unread TOC regions. retry the same call to proceed \u2014 optionally after reading the listed ranges. the pre-flight will not block again this session.
146620
+
146621
+ The review body is structured as: \`[optional alert blockquote]\` \u2192 \`[PR summary using the default format below]\`. Inline comments are passed via the \`comments\` parameter, not in the body.
146622
+
146623
+ - **critical issues** (blocks merge \u2014 bugs, security, data loss):
146624
+ \`approved: false\`. Body opens with \`> [!CAUTION]\\n> This PR introduces ...\`, followed by the PR summary. Include all inline comments via \`comments\`.
146625
+ - **recommended changes** (non-critical):
146626
+ \`approved: false\`. Body opens with \`> [!IMPORTANT]\\n> Consider ...\`, followed by the PR summary. Include all inline comments via \`comments\`.
146627
+ - **no actionable issues**:
146628
+ \`approved: true\`. Body opens with \`No new issues found.\` followed by the PR summary.
146629
+
146630
+ ${PR_SUMMARY_FORMAT}`
146631
+ },
146632
+ // IncrementalReview shares Review's multi-lens orchestrator pattern but
146633
+ // scopes the target to the incremental diff. The "issues must be NEW
146634
+ // since the last Pullfrog review" filter lives at aggregation time
146635
+ // (step 5), NOT in the subagent prompt — pushing the filter into
146636
+ // subagents matches the canonical anneal anti-pattern of "list known
146637
+ // pre-existing failures — don't flag these" and suppresses signal on
146638
+ // regressions the new commits amplified. The review body is just
146639
+ // "Reviewed changes" — a separate "Prior review feedback" checklist
146640
+ // would duplicate the rolling PR summary snapshot's record of what
146641
+ // earlier runs already addressed and add noise to the user-facing
146642
+ // body. Same severity-table omission as Review.
146643
+ {
146644
+ name: "IncrementalReview",
146645
+ description: "Re-review a PR after new commits are pushed; focus on new changes since the last review",
146646
+ prompt: `### Checklist
146647
+
146648
+ 1. **checkout**: call \`${t2("checkout_pr")}\` \u2014 this returns PR metadata, \`diffPath\` (full diff), and \`incrementalDiffPath\` (changes since last reviewed version, if available). read the diff TOC first and use its line ranges as your coverage checklist.
146649
+
146650
+ 2. **incremental scope**: if \`incrementalDiffPath\` is present, read it to see what changed since the last review. this is a range-diff that isolates the net changes, filtering out base branch noise. if not present, fall back to reviewing the full PR diff and determine what changed since Pullfrog's most recent review.
146651
+
146652
+ 3. **prior feedback**: fetch previous reviews via \`${t2("list_pull_request_reviews")}\`. for the most recent Pullfrog review, call \`${t2("get_review_comments")}\` with the review ID to retrieve specific prior line-level feedback. you'll use this to filter your aggregation in step 5 \u2014 anything already flagged in a prior review and not changed by the new commits should not be re-raised. you do NOT need to render this in the review body; the rolling PR summary snapshot is the durable record of what's been addressed.
146653
+
146654
+ 4. **triage & fan out**: orient on the *incremental* changes \u2014 domain, seams, external contracts, user-facing surfaces.
146655
+
146656
+ if the incremental changes are **genuinely trivial**, skip the fan-out entirely and jump to step 7's non-substantive path (do NOT submit a review).
146657
+
146658
+ "Genuinely trivial" (skip): formatting/comment tweaks, import reordering, lockfile regen, mechanical rename of import paths, whitespace-only.
146659
+ "Looks trivial but isn't" (do NOT skip \u2014 same anti-patterns as Review mode): 1-line changes to SQL/regex/auth/billing/permissions/signature-verification code; flipping feature-flag defaults or retry/timeout constants; money/tax/HTTP-method/redirect changes; tightening or loosening a comparison operator; mixed diffs with a semantic line buried in formatting.
146660
+ When unsure, treat as non-trivial.
146661
+
146662
+ otherwise pick lenses by where the new commits concentrate risk \u2014 **there's no fixed count**, same calibration as Review mode (1 lens for pure refactor / isolated fix; 2\u20133 for typical features; 4\u20135 for high-stakes subsystem touches; 6+ is a smell). lens framing follows Review mode: themed lenses (correctness & invariants, impact when new commits remove/rename/deprecate things, research-validated assumptions, security, user-journey, operational readiness, integration & cross-cutting, test integrity, performance, holistic) and subsystem lenses (auth, billing, schema migration, etc.) \u2014 for high-stakes domains lead with the subsystem lens rather than the generic themed equivalent.
146663
+
146664
+ dispatch one \`${REVIEWER_AGENT_NAME}\` subagent per lens \u2014 its baked-in system prompt enforces the non-mutative + non-recursive contract (read-only file/search/web tools and read-only MCP queries; no writes, shell side effects, state-changing MCP calls, or nested subagent dispatch). dispatch them in a **single assistant turn with multiple parallel subagent calls** (serial dispatch collapses the fan-out). if a subagent errors out, times out, or returns nothing usable, retry once with the same lens; if it still fails, proceed with partial coverage and note the missing lens in the review body \u2014 do not skip step 4 entirely on a single subagent failure. each subagent gets:
146665
+ - the diff scope (incremental diff path if available, full diff otherwise). do NOT tell them to skip pre-existing issues \u2014 that suppresses regressions the new commits amplified; the "issues must be NEW" filter lives at aggregation time (step 5), not in the subagent prompt
146666
+ - **only one lens** \u2014 never a multi-section "review for X, Y, and Z" prompt
146667
+ - **a Task \`description\` set to the lens name** (e.g. \`"security"\`, \`"correctness"\`, \`"billing-subsystem"\`) \u2014 the harness reads this field to label the subagent's log lines so parallel runs can be told apart in CI output. without it, every subagent shows up as \`subagent#N\`.
146668
+ - the read-only contract restated in your dispatch instructions so the rule is present twice (the subagent's system prompt also enforces it). The test: would this call still be a no-op if reverted? If not (PR comments, branch pushes, issue updates, set_output, label changes, dependency installs, etc.), don't make it.
146669
+ - if the lens touches external contracts, instruct the subagent to verify load-bearing claims via web search and quote source URLs. action runs are non-interactive \u2014 there's no human to catch "I'm pretty sure Stripe does X."
146670
+ - ask the subagent to report findings with file paths and NEW line numbers from the full PR diff so you can anchor inline comments.
146671
+
146672
+ delegation discipline:
146673
+ - do NOT lens-review the diff yourself in parallel with the subagents
146674
+ - do NOT summarize the changes for them (biases toward validation frame)
146675
+ - do NOT hand them a curated reading list (let them discover scope)
146676
+ - do NOT pre-shape their output with a finding schema
146677
+ - do NOT mention the other lenses (independence is the point)
146678
+
146679
+ 5. **aggregate, draft, self-critique**: merge findings; de-dup overlaps; trace each finding yourself. drop praise, style preferences, speculative/unverified claims, findings about pre-existing code unrelated to the new commits, anything not actionable, and anything that re-states prior review feedback (heuristic: if the finding's root cause lives in lines the *new commits* added or modified, it's in scope; otherwise drop). also drop **bloat-shaped findings** \u2014 proposed fixes that would add defensive checks for cases that can't happen, abstractions used once, comments restating obvious code, tests asserting tautologies, or "just-in-case" guards. subagents are fallible and bias toward recommending changes; the bar for an actionable inline comment is sound + correct + elegant. recommending a change that improves only one of the three (or degrades elegance to nominally improve correctness) makes the codebase worse, not better. To compute "lines the new commits added or modified": if \`incrementalDiffPath\` from step 1 is present, use it directly. Otherwise, take the prior Pullfrog review's \`commit_id\` (returned alongside each entry from \`${t2("list_pull_request_reviews")}\` in step 3) and run \`git diff <prior-review-sha>..HEAD\` to isolate the lines added since that review. draft inline comments with NEW line numbers from the full PR diff \u2014 every comment must be actionable, 2-3 sentences max.
146680
+
146681
+ 6. **build the review body** \u2014 a single "Reviewed changes" section: summarize at the logical-change level, not per-file. each bullet starts with a past-tense verb (e.g. \`- Extracted shared CLI runtime into a single module\`, \`- Renamed package to pullfrog\`). avoid file paths unless they add clarity. if the changes can be described in one sentence, use one sentence \u2014 no bullets needed. do NOT include a separate "Prior review feedback" checklist; that's tracked in the rolling PR summary snapshot for the next agent run, and surfacing it in the user-facing body is noise (changes that addressed prior feedback are already covered by the Reviewed-changes bullets). in some cases you may receive a complete diff for the whole pull request instead of an incremental one \u2014 when this happens, you will need to determine what changes have happened since Pullfrog's most recent review.
146682
+
146683
+ 7. Submit \u2014 Do NOT call \`report_progress\` or \`create_issue_comment\` \u2014 the review is the final record and the progress comment will be cleaned up automatically. Follow these rules:
146684
+ - note: the first create_pull_request_review submission may error with a one-time diff-coverage nudge listing unread TOC regions. retry the same call to proceed \u2014 optionally after reading the listed ranges. the pre-flight will not block again this session.
146685
+ - IF NO NEW ISSUES, NON-SUBSTANTIVE CHANGES ONLY (trivial formatting, import reordering, comment tweaks): do NOT submit a review. Do NOT call \`report_progress\`. Exit \u2014 the progress comment will be cleaned up automatically.
146686
+ - ELSE IF NEW CRITICAL ISSUES (blocks merge): call \`${t2("create_pull_request_review")}\` with \`approved: false\`, all comments, and the review body. body opens with a GitHub alert blockquote (e.g. \`> [!CAUTION]\\n> This PR introduces ...\`), then the Reviewed-changes summary.
146687
+ - ELSE IF NEW RECOMMENDED CHANGES (non-critical): call \`${t2("create_pull_request_review")}\` with \`approved: false\`, all comments, and the review body. body opens with \`> [!IMPORTANT]\\n> ...\` alert, then the Reviewed-changes summary.
146688
+ - ELSE IF NO NEW ISSUES, SUBSTANTIVE CHANGES (new functionality, behavior changes, or fixes to prior review feedback): call \`${t2("create_pull_request_review")}\` to create a PR review. If all previous reviews have been properly addressed and no new issues were discovered, you can set \`approved: true\`. body opens with \`No new issues. Reviewed the following changes:\\n\`, then the Reviewed-changes summary.`
146689
+ },
146690
+ {
146691
+ name: "Plan",
146692
+ description: "Create plans, break down tasks, outline steps, analyze requirements, understand scope of work, or provide task breakdowns",
146693
+ prompt: `### Checklist
146694
+
146695
+ 1. Analyze the task and gather context:
146696
+ - read AGENTS.md and relevant codebase files
146697
+ - understand the architecture and constraints
146698
+
146699
+ 2. Produce a structured, actionable plan with clear milestones.
146700
+
146701
+ 3. Call \`${t2("report_progress")}\` with the plan.
146702
+
146703
+ ${learningsStep(t2, 4)}`
146704
+ },
146705
+ {
146706
+ name: "Fix",
146707
+ description: "Fix CI failures; debug failing tests or builds; investigate and resolve check suite failures",
146708
+ prompt: `### Checklist
146709
+
146710
+ 1. Checkout the PR branch via \`${t2("checkout_pr")}\`.
146711
+
146712
+ 2. Fetch check suite logs via \`${t2("get_check_suite_logs")}\`.
146713
+
146714
+ 3. **CRITICAL**: verify the failure was INTRODUCED BY THIS PR before fixing. If unrelated, abort and report.
146715
+
146716
+ 4. Diagnose and fix:
146717
+ - read the workflow file, reproduce locally with the EXACT same commands CI runs
146718
+ - fix the issue using your native file and shell tools
146719
+ - verify the fix by re-running the exact CI command
146720
+ - review the diff before committing \u2014 verify only the fix is present, no debug artifacts, no unrelated changes. the fix should be clean enough that a senior engineer would approve without hesitation.
146721
+ - commit locally via shell (\`git add . && git commit -m "..."\`)
146722
+
146723
+ 5. Finalize:
146724
+ - confirm a clean working tree, then push via \`${t2("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
146725
+ - call \`${t2("report_progress")}\` with the diagnosis and fix summary (or the exact push error if push failed)
146726
+
146727
+ ${learningsStep(t2, 6)}`
146728
+ },
146729
+ {
146730
+ name: "ResolveConflicts",
146731
+ description: "Resolve merge conflicts in a PR branch against the base branch",
146732
+ prompt: `### Checklist
146733
+
146734
+ 1. **Setup**:
146735
+ - Call \`${t2("checkout_pr")}\` to get the PR branch.
146736
+ - Call \`${t2("get_pull_request")}\` to identify the base branch (e.g., 'main').
146737
+ - Call \`${t2("git_fetch")}\` to fetch the base branch.
146738
+
146739
+ 2. **Merge Attempt**:
146740
+ - Run \`git merge origin/<base_branch>\` via shell.
146741
+ - If it succeeds automatically, confirm a clean working tree, push via \`${t2("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*), and call \`${t2("report_progress")}\` with a brief success note or the exact push error if push failed \u2014 **then stop; do not run steps 3\u20134.**
146742
+ - If it fails (conflicts), resolve them manually (continue to steps 3\u20134).
146743
+
146744
+ 3. **Resolve Conflicts**:
146745
+ - Run \`git status\` or parse the merge output to find the list of conflicting files.
146746
+ - For each conflicting file: read it, find the conflict markers (\`<<<<<<<\`, \`=======\`, \`>>>>>>>\`), understand the code context, and rewrite the file with the correct resolution. Remove all markers.
146747
+ - Verify the file syntax is correct after resolution.
146748
+
146749
+ 4. **Finalize**:
146750
+ - Run a final verification (build/test) to ensure the resolution works.
146751
+ - \`git add . && git commit -m "resolve merge conflicts"\`
146752
+ - confirm a clean working tree, then push via \`${t2("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
146753
+ - Call \`${t2("report_progress")}\` with a summary of what was resolved (or the exact push error if push failed)`
146754
+ },
146755
+ {
146756
+ name: "Task",
146757
+ description: "General-purpose tasks that don't fit other modes: answering questions, adding comments, labeling, running ad-hoc commands, or any direct request",
146758
+ prompt: `### Checklist
146759
+
146760
+ 1. Analyze the task. For simple operations (labeling, commenting, answering questions, running a single command), handle directly.
146761
+
146762
+ 2. For substantial work \u2014 code changes across multiple files, multi-step investigations:
146763
+ - plan your approach before starting
146764
+ - use native file and shell tools for local operations
146765
+ - use ${pullfrogMcpName} MCP tools for GitHub/git operations
146766
+ - if code changes are needed: review your own diff before committing \u2014 verify only intended changes are present, no debug artifacts remain, and the changes are clean enough that a senior engineer would approve without hesitation
146767
+
146768
+ 3. Finalize:
146769
+ - if code changes were made, push to a pull request (new or existing) using \`${t2("push_branch")}\` and \`${t2("create_pull_request")}\` as needed. \`git status\` must be clean before you finish (see *SYSTEM* Git rules if push fails).
146770
+ - call \`${t2("report_progress")}\` once with results \u2014 include exact tool errors if push or PR creation failed
146771
+ - if the task involved labeling, commenting, or other GitHub operations, perform those directly
146772
+
146773
+ ${learningsStep(t2, 4)}`
146774
+ }
146775
+ ];
146776
+ }
146777
+ var modes = computeModes("opencode");
146778
+
146812
146779
  // agents/claude.ts
146813
146780
  import { execFileSync as execFileSync3 } from "node:child_process";
146814
146781
  import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync7 } from "node:fs";
@@ -146901,20 +146868,34 @@ async function installFromNpmTarball(params) {
146901
146868
  }
146902
146869
 
146903
146870
  // utils/providerErrors.ts
146871
+ var statusKey = `\\b(?:status[_ ]?code|http[_ ]?status|status)["']?\\s*[:=]\\s*["']?`;
146904
146872
  var PROVIDER_ERROR_PATTERNS = [
146905
- { pattern: "429", label: "rate limited (429)" },
146906
- { pattern: "RESOURCE_EXHAUSTED", label: "quota exhausted" },
146907
- { pattern: "quota", label: "quota error" },
146908
- { pattern: "status: 500", label: "provider 500 error" },
146909
- { pattern: "INTERNAL", label: "provider internal error" },
146910
- { pattern: "status: 503", label: "provider unavailable (503)" },
146911
- { pattern: "UNAVAILABLE", label: "provider unavailable" },
146912
- { pattern: "rate limit", label: "rate limited" },
146913
- { pattern: "limit: 0", label: "zero quota" }
146873
+ { regex: new RegExp(`${statusKey}429\\b`, "i"), label: "rate limited (429)" },
146874
+ { regex: new RegExp(`${statusKey}500\\b`, "i"), label: "provider 500 error" },
146875
+ { regex: new RegExp(`${statusKey}503\\b`, "i"), label: "provider unavailable (503)" },
146876
+ // matches `rate limit`, `rate limited`, `rate limits exceeded`,
146877
+ // `rate_limit_error`, `rate_limit_exceeded`. the leading `\b` + `[_ ]`
146878
+ // separator rejects `x-ratelimit-*` / `anthropic-ratelimit-*` response
146879
+ // headers (no separator between "rate" and "limit") which routinely
146880
+ // appear in dumped 401 / 4xx error JSON.
146881
+ { regex: /\brate[_ ]limit/i, label: "rate limited" },
146882
+ { regex: /\bRESOURCE_EXHAUSTED\b/, label: "quota exhausted" },
146883
+ // Google gRPC `INTERNAL` status. word-boundary anchors reject
146884
+ // `INTERNAL_SERVER_ERROR` (HTTP 500 message that may appear in unrelated
146885
+ // log lines) and identifiers like `INTERNALS`.
146886
+ { regex: /\bINTERNAL\b/, label: "provider internal error" },
146887
+ { regex: /\bUNAVAILABLE\b/, label: "provider unavailable" },
146888
+ // matches `quota`, `insufficient_quota`, `quota_exceeded`, `quotaExceeded`.
146889
+ // word-character lookarounds would reject `_quota` / `quotaX`; `quota` is
146890
+ // specific enough that a plain substring match is safe.
146891
+ { regex: /quota/i, label: "quota error" },
146892
+ // explicit zero-quota response, e.g. `{"limit": 0}`. the `\b` anchor
146893
+ // around `limit` rejects keys like `time_limit` or `field_limit`.
146894
+ { regex: /["']?\blimit\b["']?\s*:\s*0\b/, label: "zero quota" }
146914
146895
  ];
146915
146896
  function detectProviderError(text) {
146916
146897
  for (const entry of PROVIDER_ERROR_PATTERNS) {
146917
- if (text.includes(entry.pattern)) return entry.label;
146898
+ if (entry.regex.test(text)) return entry.label;
146918
146899
  }
146919
146900
  return null;
146920
146901
  }
@@ -147024,6 +147005,7 @@ var ThinkingTimer = class {
147024
147005
  };
147025
147006
 
147026
147007
  // agents/postRun.ts
147008
+ import { readFile } from "node:fs/promises";
147027
147009
  var MAX_HOOK_OUTPUT_CHARS = 4096;
147028
147010
  function truncateHookOutput(raw2) {
147029
147011
  if (raw2.length <= MAX_HOOK_OUTPUT_CHARS) return raw2;
@@ -147068,6 +147050,23 @@ function buildStopHookPrompt(failure) {
147068
147050
  "```"
147069
147051
  ].join("\n");
147070
147052
  }
147053
+ async function isSummaryUnchanged(filePath, seed) {
147054
+ try {
147055
+ const current = await readFile(filePath, "utf8");
147056
+ return current === seed;
147057
+ } catch {
147058
+ return false;
147059
+ }
147060
+ }
147061
+ function buildSummaryStalePrompt(filePath) {
147062
+ return [
147063
+ `PR SUMMARY UNTOUCHED \u2014 the rolling PR summary file at \`${filePath}\` is byte-identical to its seed; this run did not edit it.`,
147064
+ "",
147065
+ "review the diff and update the file in place to reflect what changed in the PR. update intent, key changes, and any risks worth flagging \u2014 keep the existing section headings stable so incremental runs produce clean diffs.",
147066
+ "",
147067
+ "if the diff is genuinely too small or noisy to warrant rewriting (e.g. a one-line typo fix, a comment tweak, a formatting-only change), it's fine to leave the structure as-is \u2014 but at minimum confirm you considered it by appending one line to the appropriate section noting the run. silence is not an option; the snapshot is what the next review run reads as context."
147068
+ ].join("\n");
147069
+ }
147071
147070
  async function collectPostRunIssues(params) {
147072
147071
  const issues = {};
147073
147072
  if (params.stopScript) {
@@ -147076,12 +147075,17 @@ async function collectPostRunIssues(params) {
147076
147075
  }
147077
147076
  const status = getGitStatus();
147078
147077
  if (status) issues.dirtyTree = status;
147078
+ if (params.summaryFilePath && params.summarySeed !== void 0) {
147079
+ const stale = await isSummaryUnchanged(params.summaryFilePath, params.summarySeed);
147080
+ if (stale) issues.summaryStale = { filePath: params.summaryFilePath };
147081
+ }
147079
147082
  return issues;
147080
147083
  }
147081
147084
  function buildPostRunPrompt(issues) {
147082
147085
  const parts = [];
147083
147086
  if (issues.stopHook) parts.push(buildStopHookPrompt(issues.stopHook));
147084
147087
  if (issues.dirtyTree) parts.push(buildCommitPrompt(issues.dirtyTree));
147088
+ if (issues.summaryStale) parts.push(buildSummaryStalePrompt(issues.summaryStale.filePath));
147085
147089
  return parts.join("\n\n---\n\n");
147086
147090
  }
147087
147091
  function buildLearningsReflectionPrompt(agentId) {
@@ -147104,9 +147108,15 @@ async function runPostRunRetryLoop(params) {
147104
147108
  let finalIssues = {};
147105
147109
  let gateResumeCount = 0;
147106
147110
  let pendingReflection = params.reflectionPrompt;
147111
+ let summaryStaleNudged = false;
147107
147112
  while (gateResumeCount < MAX_POST_RUN_RETRIES) {
147108
147113
  if (!result.success) break;
147109
- const issues = await collectPostRunIssues({ stopScript: params.stopScript });
147114
+ const issues = await collectPostRunIssues({
147115
+ stopScript: params.stopScript,
147116
+ summaryFilePath: summaryStaleNudged ? void 0 : params.summaryFilePath,
147117
+ summarySeed: summaryStaleNudged ? void 0 : params.summarySeed
147118
+ });
147119
+ if (issues.summaryStale) summaryStaleNudged = true;
147110
147120
  finalIssues = issues;
147111
147121
  if (!hasPostRunIssues(issues)) {
147112
147122
  if (!pendingReflection) break;
@@ -147138,8 +147148,17 @@ async function runPostRunRetryLoop(params) {
147138
147148
  }
147139
147149
  log.info(`\xBB post-run retry (attempt ${gateResumeCount + 1}/${MAX_POST_RUN_RETRIES})`);
147140
147150
  const prompt = buildPostRunPrompt(issues);
147151
+ const onlySummaryStale = issues.summaryStale !== void 0 && issues.stopHook === void 0 && issues.dirtyTree === void 0;
147152
+ const preResume = result;
147141
147153
  result = await params.resume({ prompt, previousResult: result });
147142
147154
  aggregatedUsage = mergeAgentUsage(aggregatedUsage, result.usage);
147155
+ if (!result.success && onlySummaryStale) {
147156
+ log.warning(
147157
+ `\xBB summary-stale resume turn failed (${result.error ?? "unknown error"}), preserving prior successful result`
147158
+ );
147159
+ result = preResume;
147160
+ break;
147161
+ }
147143
147162
  gateResumeCount++;
147144
147163
  }
147145
147164
  if (gateResumeCount > 0 && result.success && hasPostRunIssues(finalIssues)) {
@@ -147276,6 +147295,7 @@ async function runClaude(params) {
147276
147295
  const thinkingTimer = new ThinkingTimer();
147277
147296
  let finalOutput = "";
147278
147297
  let sessionId;
147298
+ let resultErrorSubtype = null;
147279
147299
  let accumulatedTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
147280
147300
  let accumulatedCostUsd = 0;
147281
147301
  let tokensLogged = false;
@@ -147379,9 +147399,14 @@ async function runClaude(params) {
147379
147399
  tokensLogged = true;
147380
147400
  }
147381
147401
  } else if (subtype === "error_max_turns") {
147402
+ resultErrorSubtype = subtype;
147382
147403
  log.info(`\xBB ${params.label} max turns reached: ${JSON.stringify(event)}`);
147383
147404
  } else if (subtype === "error_during_execution") {
147405
+ resultErrorSubtype = subtype;
147384
147406
  log.info(`\xBB ${params.label} execution error: ${JSON.stringify(event)}`);
147407
+ } else if (subtype.startsWith("error")) {
147408
+ resultErrorSubtype = subtype;
147409
+ log.info(`\xBB ${params.label} result: subtype=${subtype}, data=${JSON.stringify(event)}`);
147385
147410
  } else {
147386
147411
  log.info(`\xBB ${params.label} result: subtype=${subtype}, data=${JSON.stringify(event)}`);
147387
147412
  }
@@ -147512,6 +147537,15 @@ ${stderrContext}`);
147512
147537
  sessionId
147513
147538
  };
147514
147539
  }
147540
+ if (resultErrorSubtype) {
147541
+ return {
147542
+ success: false,
147543
+ output: finalOutput || output,
147544
+ error: `result subtype: ${resultErrorSubtype}`,
147545
+ usage,
147546
+ sessionId
147547
+ };
147548
+ }
147515
147549
  return { success: true, output: finalOutput || output, usage, sessionId };
147516
147550
  } catch (error49) {
147517
147551
  params.todoTracker?.cancel();
@@ -147640,6 +147674,8 @@ var claude = agent({
147640
147674
  initialResult: result,
147641
147675
  initialUsage: result.usage,
147642
147676
  stopScript: ctx.stopScript,
147677
+ summaryFilePath: ctx.summaryFilePath,
147678
+ summarySeed: ctx.summarySeed,
147643
147679
  reflectionPrompt: buildLearningsReflectionPrompt("claude"),
147644
147680
  canResume: (r) => Boolean(r.sessionId),
147645
147681
  resume: async (c2) => {
@@ -147973,6 +148009,12 @@ async function runOpenCode(params) {
147973
148009
  log.debug(withLabel(label, `tool output: ${outputStr}`));
147974
148010
  }
147975
148011
  },
148012
+ error: (event) => {
148013
+ agentErrorEvent = event;
148014
+ const errorName = event.error?.name || "unknown";
148015
+ const errorMessage = event.error?.data?.message || event.error?.name || JSON.stringify(event);
148016
+ log.info(`\xBB ${params.label} error event: ${errorName}: ${errorMessage}`);
148017
+ },
147976
148018
  result: async (event) => {
147977
148019
  const status = event.status || "unknown";
147978
148020
  const duration4 = event.stats?.duration_ms || 0;
@@ -147993,6 +148035,7 @@ async function runOpenCode(params) {
147993
148035
  };
147994
148036
  const recentStderr = [];
147995
148037
  let lastProviderError = null;
148038
+ let agentErrorEvent = null;
147996
148039
  let output = "";
147997
148040
  let stdoutBuffer = "";
147998
148041
  try {
@@ -148111,6 +148154,17 @@ ${stderrContext}`);
148111
148154
  usage
148112
148155
  };
148113
148156
  }
148157
+ if (agentErrorEvent) {
148158
+ const errorEvent = agentErrorEvent;
148159
+ const errorName = errorEvent.error?.name || "agent error";
148160
+ const errorMessage = errorEvent.error?.data?.message || errorEvent.error?.name || JSON.stringify(errorEvent);
148161
+ return {
148162
+ success: false,
148163
+ output: finalOutput || output,
148164
+ error: `${errorName}: ${errorMessage}`,
148165
+ usage
148166
+ };
148167
+ }
148114
148168
  return { success: true, output: finalOutput || output, usage };
148115
148169
  } catch (error49) {
148116
148170
  params.todoTracker?.cancel();
@@ -148186,6 +148240,8 @@ var opencode = agent({
148186
148240
  initialResult: result,
148187
148241
  initialUsage: result.usage,
148188
148242
  stopScript: ctx.stopScript,
148243
+ summaryFilePath: ctx.summaryFilePath,
148244
+ summarySeed: ctx.summarySeed,
148189
148245
  reflectionPrompt: buildLearningsReflectionPrompt("opencode"),
148190
148246
  resume: async (c2) => runOpenCode({
148191
148247
  ...runParams,
@@ -152732,7 +152788,7 @@ When embedding images (e.g. uploaded screenshots) in comments or PR bodies, alwa
152732
152788
 
152733
152789
  **\`report_progress\`**: call this exactly once at the end of every run with a brief final summary (1-3 sentences) unless the mode guidance instructs otherwise. Never call it for intermediate status updates (e.g., "Checking for changes...", "Starting review...") \u2014 the task list handles live progress automatically. Calling \`report_progress\` replaces the task list with your summary and preserves the current task list in a collapsible section. Keep the summary concise \u2014 do not repeat what the task list already shows. Focus on the outcome (what was accomplished, links to artifacts) rather than listing individual steps. If something failed, include the tool's error text even when that makes the summary longer.
152734
152790
 
152735
- Never use \`create_issue_comment\` for task progress \u2014 that creates duplicate comments and leaves the progress comment stuck in its initial state. \`create_issue_comment\` is only for standalone comments unrelated to your current task (e.g., Plan comments, PR Summary comments).
152791
+ Never use \`create_issue_comment\` for task progress \u2014 that creates duplicate comments and leaves the progress comment stuck in its initial state. \`create_issue_comment\` is only for standalone comments unrelated to your current task (e.g., Plan comments).
152736
152792
 
152737
152793
  ### If you get stuck
152738
152794
 
@@ -152896,7 +152952,8 @@ var JsonPayload = type({
152896
152952
  "progressComment?": type({
152897
152953
  id: "string",
152898
152954
  type: "'issue' | 'review'"
152899
- }).or("undefined")
152955
+ }).or("undefined"),
152956
+ "generateSummary?": "boolean | undefined"
152900
152957
  });
152901
152958
  var COLLABORATOR_PERMISSIONS = ["admin", "maintain", "write"];
152902
152959
  function isCollaborator(event) {
@@ -152979,6 +153036,7 @@ function resolvePayload(resolvedPromptInput, repoSettings) {
152979
153036
  timeout: inputs.timeout ?? jsonPayload?.timeout,
152980
153037
  cwd: resolveCwd(inputs.cwd),
152981
153038
  progressComment: jsonPayload?.progressComment,
153039
+ generateSummary: jsonPayload?.generateSummary,
152982
153040
  // permissions: inputs > repoSettings > fallbacks
152983
153041
  push: inputs.push ?? repoSettings.push ?? "restricted",
152984
153042
  shell: resolvedShell,
@@ -152987,6 +153045,40 @@ function resolvePayload(resolvedPromptInput, repoSettings) {
152987
153045
  };
152988
153046
  }
152989
153047
 
153048
+ // utils/prSummary.ts
153049
+ import { mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
153050
+ import { dirname as dirname4, join as join14 } from "node:path";
153051
+ var SUMMARY_FILE_NAME = "pullfrog-summary.md";
153052
+ var SUMMARY_SCAFFOLD = `# PR summary
153053
+
153054
+ <!-- durable cross-run context. edit in place; the next agent run reads this
153055
+ before reviewing new commits. structure however serves the PR best. -->
153056
+ `;
153057
+ var MIN_SNAPSHOT_LENGTH = 60;
153058
+ var MAX_SNAPSHOT_LENGTH = 32768;
153059
+ function summaryFilePath(tmpdir3) {
153060
+ return join14(tmpdir3, SUMMARY_FILE_NAME);
153061
+ }
153062
+ async function seedSummaryFile(params) {
153063
+ const path3 = summaryFilePath(params.tmpdir);
153064
+ await mkdir(dirname4(path3), { recursive: true });
153065
+ const seed = params.previousSnapshot && params.previousSnapshot.trim().length >= MIN_SNAPSHOT_LENGTH ? params.previousSnapshot : SUMMARY_SCAFFOLD;
153066
+ await writeFile2(path3, seed, "utf8");
153067
+ return path3;
153068
+ }
153069
+ async function readSummaryFile(path3) {
153070
+ let raw2;
153071
+ try {
153072
+ raw2 = await readFile2(path3, "utf8");
153073
+ } catch {
153074
+ return null;
153075
+ }
153076
+ const trimmed = raw2.trim();
153077
+ if (trimmed.length < MIN_SNAPSHOT_LENGTH) return null;
153078
+ if (trimmed.length > MAX_SNAPSHOT_LENGTH) return trimmed.slice(0, MAX_SNAPSHOT_LENGTH);
153079
+ return trimmed;
153080
+ }
153081
+
152990
153082
  // utils/reviewCleanup.ts
152991
153083
  var RE_REVIEW_PREAMBLE = "Incrementally re-review the new commits on this pull request. Use the IncrementalReview mode.";
152992
153084
  async function postReviewCleanup(ctx) {
@@ -153046,11 +153138,16 @@ async function dispatchFollowUpReReview(ctx, reviewedSha) {
153046
153138
  await ctx.octokit.rest.actions.createWorkflowDispatch({
153047
153139
  owner: ctx.repo.owner,
153048
153140
  repo: ctx.repo.name,
153049
- workflow_id: "pullfrog.yml",
153141
+ workflow_id: getCurrentWorkflowFilename(),
153050
153142
  ref: pr.data.base.repo.default_branch,
153051
153143
  inputs: { prompt: JSON.stringify(payload) }
153052
153144
  });
153053
153145
  }
153146
+ function getCurrentWorkflowFilename() {
153147
+ const ref = process.env.GITHUB_WORKFLOW_REF ?? "";
153148
+ const match3 = ref.match(/\/([^/]+)@/);
153149
+ return match3?.[1] ?? "pullfrog.yml";
153150
+ }
153054
153151
 
153055
153152
  // utils/run.ts
153056
153153
  async function handleAgentResult(ctx) {
@@ -153190,9 +153287,9 @@ async function resolveRunContextData(params) {
153190
153287
  import { execFileSync as execFileSync5, execSync as execSync3 } from "node:child_process";
153191
153288
  import { mkdtempSync } from "node:fs";
153192
153289
  import { tmpdir as tmpdir2 } from "node:os";
153193
- import { join as join14 } from "node:path";
153290
+ import { join as join15 } from "node:path";
153194
153291
  function createTempDirectory() {
153195
- const sharedTempDir = mkdtempSync(join14(tmpdir2(), "pullfrog-"));
153292
+ const sharedTempDir = mkdtempSync(join15(tmpdir2(), "pullfrog-"));
153196
153293
  process.env.PULLFROG_TEMP_DIR = sharedTempDir;
153197
153294
  log.info(`\xBB created temp dir at ${sharedTempDir}`);
153198
153295
  return sharedTempDir;
@@ -153525,39 +153622,53 @@ var TransientError = class extends Error {
153525
153622
  this.name = "TransientError";
153526
153623
  }
153527
153624
  };
153528
- function formatBillingErrorSummary(error49) {
153625
+ function billingConsoleUrl(owner, anchor) {
153626
+ return `https://pullfrog.com/console/${encodeURIComponent(owner)}#${anchor}`;
153627
+ }
153628
+ function formatBillingErrorSummary(error49, owner) {
153529
153629
  if (error49.code === "router_requires_card") {
153530
153630
  return [
153531
- "### \u26D4 Pullfrog Router requires a card",
153631
+ "**Add a card to start using Pullfrog Router.**",
153532
153632
  "",
153533
- "This run was going to use Pullfrog Router, which bills at raw OpenRouter cost and needs a card on file. Runs won't proceed until a card is added.",
153633
+ "Router proxies OpenRouter at raw cost \u2014 no platform markup, and your first $20 of usage is on us.",
153534
153634
  "",
153535
- "[Add a card \u2192](https://pullfrog.com/console#model-access) \u2014 your first $20 of Router usage is free."
153635
+ `[Add a card \u2192](${billingConsoleUrl(owner, "model-access")})`
153536
153636
  ].join("\n");
153537
153637
  }
153538
153638
  if (error49.needsReauthentication) {
153639
+ const code = error49.declineCode ?? "authentication_required";
153539
153640
  return [
153540
- "### \u274C Pullfrog billing error \u2014 card requires 3DS on every charge",
153641
+ `**Your card issuer requires 3D Secure on every charge** (\`${code}\`).`,
153541
153642
  "",
153542
- `Your card issuer requires a 3D Secure challenge on each off-session charge (\`${error49.declineCode ?? "authentication_required"}\`), which we can't run from the agent. Top up your Router credit balance manually \u2014 3DS runs interactively in Stripe Checkout, and subsequent runs draw from the prepaid balance without triggering another off-session charge.`,
153643
+ "Pullfrog can't complete a 3DS challenge from inside a workflow. Top up your Router balance once in Stripe Checkout \u2014 subsequent runs draw from the prepaid balance without re-triggering 3DS.",
153543
153644
  "",
153544
- "[Top up your Router credit balance \u2192](https://pullfrog.com/console)"
153645
+ `[Top up balance \u2192](${billingConsoleUrl(owner, "billing")})`
153545
153646
  ].join("\n");
153546
153647
  }
153547
- const codeSuffix = error49.declineCode ? ` (\`${error49.declineCode}\`)` : "";
153548
- return `### \u274C Pullfrog billing error
153549
-
153550
- ${error49.message}${codeSuffix}
153551
-
153552
- [Manage billing \u2192](https://pullfrog.com/console)`;
153648
+ if (error49.declineCode) {
153649
+ return [
153650
+ `**Your card was declined** (\`${error49.declineCode}\`).`,
153651
+ "",
153652
+ "Update your payment method and Pullfrog will retry on the next run.",
153653
+ "",
153654
+ `[Update payment method \u2192](${billingConsoleUrl(owner, "billing")})`
153655
+ ].join("\n");
153656
+ }
153657
+ return [
153658
+ "**Your Pullfrog balance is empty.**",
153659
+ "",
153660
+ "Top up your balance or enable auto-reload to keep runs flowing.",
153661
+ "",
153662
+ `[Manage billing \u2192](${billingConsoleUrl(owner, "billing")})`
153663
+ ].join("\n");
153553
153664
  }
153554
- function formatTransientErrorSummary(error49) {
153665
+ function formatTransientErrorSummary(error49, owner) {
153555
153666
  return [
153556
- "### \u26A0\uFE0F Pullfrog temporarily unavailable",
153667
+ "**Pullfrog billing is temporarily unavailable.**",
153557
153668
  "",
153558
153669
  error49.message,
153559
153670
  "",
153560
- "This is typically transient \u2014 the next dispatch should succeed. If it persists, check [status.pullfrog.com](https://status.pullfrog.com)."
153671
+ `Usually transient \u2014 the next dispatch should succeed. If it persists, check [status.pullfrog.com](https://status.pullfrog.com) or [your console](${billingConsoleUrl(owner, "billing")}).`
153561
153672
  ].join("\n");
153562
153673
  }
153563
153674
  async function mintProxyKey(ctx) {
@@ -153618,6 +153729,43 @@ async function resolveProxyModel(ctx) {
153618
153729
  const label = ctx.oss ? "oss" : "router";
153619
153730
  log.info(`\xBB proxy: ${label} \u2192 ${ctx.proxyModel}`);
153620
153731
  }
153732
+ async function fetchPreviousSnapshot(ctx, prNumber) {
153733
+ if (!ctx.githubInstallationToken) return null;
153734
+ try {
153735
+ const response = await apiFetch({
153736
+ path: `/api/repo/${ctx.repo.owner}/${ctx.repo.name}/pr/${prNumber}/summary-comment`,
153737
+ method: "GET",
153738
+ headers: { authorization: `Bearer ${ctx.githubInstallationToken}` },
153739
+ signal: AbortSignal.timeout(1e4)
153740
+ });
153741
+ if (!response.ok) return null;
153742
+ const data = await response.json();
153743
+ return typeof data.snapshot === "string" && data.snapshot.length > 0 ? data.snapshot : null;
153744
+ } catch {
153745
+ return null;
153746
+ }
153747
+ }
153748
+ async function persistSummary(ctx) {
153749
+ const filePath = ctx.toolState.summaryFilePath;
153750
+ if (!filePath) return;
153751
+ if (ctx.toolState.summaryPersistAttempted) return;
153752
+ ctx.toolState.summaryPersistAttempted = true;
153753
+ const snapshot2 = await readSummaryFile(filePath);
153754
+ if (!snapshot2) {
153755
+ log.debug(`pr summary tmpfile missing or invalid at ${filePath} \u2014 skipping persist`);
153756
+ return;
153757
+ }
153758
+ const seed = ctx.toolState.summarySeed?.trim();
153759
+ if (seed !== void 0 && snapshot2 === seed) {
153760
+ log.warning(
153761
+ "\xBB pr summary tmpfile unchanged from seed \u2014 skipping persist (agent did not edit it)"
153762
+ );
153763
+ return;
153764
+ }
153765
+ await patchWorkflowRunFields(ctx, { summarySnapshot: snapshot2 }).catch((err) => {
153766
+ log.debug(`pr summary persist failed: ${err instanceof Error ? err.message : String(err)}`);
153767
+ });
153768
+ }
153621
153769
  async function writeJobSummary(toolState) {
153622
153770
  const usageSummary = formatUsageSummary(toolState.usageEntries);
153623
153771
  const summaryParts = [toolState.lastProgressBody, usageSummary].filter(Boolean);
@@ -153682,7 +153830,7 @@ async function main() {
153682
153830
  });
153683
153831
  } catch (error49) {
153684
153832
  if (error49 instanceof BillingError) {
153685
- const summary2 = formatBillingErrorSummary(error49);
153833
+ const summary2 = formatBillingErrorSummary(error49, runContext.repo.owner);
153686
153834
  await writeSummary(summary2).catch(() => {
153687
153835
  });
153688
153836
  await reportErrorToComment({ toolState, error: summary2 }).catch(() => {
@@ -153690,7 +153838,7 @@ async function main() {
153690
153838
  throw error49;
153691
153839
  }
153692
153840
  if (error49 instanceof TransientError) {
153693
- const summary2 = formatTransientErrorSummary(error49);
153841
+ const summary2 = formatTransientErrorSummary(error49, runContext.repo.owner);
153694
153842
  await writeSummary(summary2).catch(() => {
153695
153843
  });
153696
153844
  await reportErrorToComment({ toolState, error: summary2 }).catch(() => {
@@ -153780,6 +153928,20 @@ async function main() {
153780
153928
  toolContext.mcpServerUrl = mcpHttpServer.url;
153781
153929
  log.info(`\xBB MCP server started at ${mcpHttpServer.url}`);
153782
153930
  timer.checkpoint("mcpServer");
153931
+ if (payload.generateSummary && payload.event.is_pr && payload.event.issue_number) {
153932
+ const previousSnapshot = await fetchPreviousSnapshot(toolContext, payload.event.issue_number);
153933
+ const filePath = await seedSummaryFile({ tmpdir: tmpdir3, previousSnapshot });
153934
+ toolState.summaryFilePath = filePath;
153935
+ try {
153936
+ toolState.summarySeed = await readFile3(filePath, "utf8");
153937
+ } catch {
153938
+ }
153939
+ log.info(
153940
+ `\xBB summary snapshot seeded at ${filePath} (previous=${previousSnapshot ? "yes" : "no"})`
153941
+ );
153942
+ const ctxForExit = toolContext;
153943
+ onExitSignal(() => persistSummary(ctxForExit));
153944
+ }
153783
153945
  startInstallation(toolContext);
153784
153946
  const modelForLog = resolveModelForLog({ payload, resolvedModel });
153785
153947
  const agentForLog = resolveAgentForLog({ agentName: agent2.name, resolvedModel });
@@ -153811,7 +153973,7 @@ ${instructions.user}` : null,
153811
153973
  log.info(instructions.full);
153812
153974
  });
153813
153975
  if (agentId === "opencode") {
153814
- const pluginDir = join15(process.cwd(), ".opencode", "plugin");
153976
+ const pluginDir = join16(process.cwd(), ".opencode", "plugin");
153815
153977
  const hasPlugins = existsSync7(pluginDir) && readdirSync(pluginDir).some((f) => /\.[jt]sx?$/.test(f));
153816
153978
  if (hasPlugins && toolState.dependencyInstallation?.promise) {
153817
153979
  log.info(
@@ -153870,6 +154032,8 @@ ${instructions.user}` : null,
153870
154032
  instructions,
153871
154033
  todoTracker,
153872
154034
  stopScript: runContext.repoSettings.stopScript,
154035
+ summaryFilePath: toolState.summaryFilePath,
154036
+ summarySeed: toolState.summarySeed,
153873
154037
  onActivityTimeout: onInnerActivityTimeout,
153874
154038
  onToolUse: (event) => {
153875
154039
  const wasTracked = recordDiffReadFromToolUse({
@@ -153924,8 +154088,10 @@ ${instructions.user}` : null,
153924
154088
  log.debug(`post-review cleanup failed: ${error49}`);
153925
154089
  });
153926
154090
  }
153927
- const trackerWasLastWriter = todoTracker?.hasPublished && !toolState.finalSummaryWritten;
153928
- if (toolContext && toolState.progressComment && (!toolState.wasUpdated || trackerWasLastWriter)) {
154091
+ if (toolContext) {
154092
+ await persistSummary(toolContext);
154093
+ }
154094
+ if (toolContext && toolState.progressComment && !toolState.finalSummaryWritten) {
153929
154095
  await deleteProgressComment(toolContext).catch((error49) => {
153930
154096
  log.debug(`stranded progress comment cleanup failed: ${error49}`);
153931
154097
  });
@@ -153972,6 +154138,9 @@ ${errorMessage}
153972
154138
  log.debug(`post-review cleanup failed: ${error50}`);
153973
154139
  });
153974
154140
  }
154141
+ if (toolContext) {
154142
+ await persistSummary(toolContext);
154143
+ }
153975
154144
  return {
153976
154145
  success: false,
153977
154146
  error: errorMessage
@@ -154003,169 +154172,8 @@ ${errorMessage}
154003
154172
  }
154004
154173
  }
154005
154174
 
154006
- // utils/postCleanup.ts
154007
- var SHOULD_CHECK_REASON = true;
154008
- function buildErrorCommentBody(ctx, isCancellation) {
154009
- let errorMessage = isCancellation ? `This run was cancelled \u{1F6D1}
154010
-
154011
- The workflow was cancelled before completion.` : `This run croaked \u{1F635}
154012
-
154013
- The workflow encountered an error before any progress could be reported.`;
154014
- if (ctx.runId) {
154015
- errorMessage += " Please check the link below for details.";
154016
- }
154017
- const customParts = [];
154018
- if (!isCancellation && ctx.runId) {
154019
- const apiUrl = getApiUrl();
154020
- customParts.push(
154021
- `[Rerun failed job \u2794](${apiUrl}/trigger/${ctx.repoContext.owner}/${ctx.repoContext.name}/${ctx.runId}?action=rerun)`
154022
- );
154023
- }
154024
- const footer = buildPullfrogFooter({
154025
- triggeredBy: true,
154026
- workflowRun: ctx.runId ? {
154027
- owner: ctx.repoContext.owner,
154028
- repo: ctx.repoContext.name,
154029
- runId: ctx.runId
154030
- } : void 0,
154031
- customParts
154032
- });
154033
- return `${errorMessage}${footer}`;
154034
- }
154035
- async function validateStuckProgressComment(ctx) {
154036
- const promptComment = ctx.promptInput?.progressComment;
154037
- if (!promptComment) {
154038
- log.info("[post] no progressComment in prompt input, skipping cleanup");
154039
- return null;
154040
- }
154041
- const comment = parseProgressComment(promptComment);
154042
- if (!comment) {
154043
- log.info(`[post] progressComment.id is not a positive integer: ${promptComment.id}`);
154044
- return null;
154045
- }
154046
- log.info(`[post] validating progressComment from prompt input: ${comment.id} (${comment.type})`);
154047
- try {
154048
- const fetched = await getProgressComment(
154049
- { octokit: ctx.octokit, owner: ctx.repoContext.owner, repo: ctx.repoContext.name },
154050
- comment
154051
- );
154052
- const body = fetched.body ?? "";
154053
- if (isLeapingIntoActionCommentBody(body)) {
154054
- log.info(`[post] comment ${comment.id} is stuck on "Leaping into action"`);
154055
- return comment;
154056
- }
154057
- if (/^- \[[ x]\] |^- \*\*→\*\* |^- ~~/.test(body)) {
154058
- log.info(`[post] comment ${comment.id} is stuck on a todo checklist`);
154059
- return comment;
154060
- }
154061
- log.info(`[post] comment ${comment.id} is not stuck (already updated or different content)`);
154062
- return null;
154063
- } catch (error49) {
154064
- const errorMessage = error49 instanceof Error ? error49.message : String(error49);
154065
- log.info(`[post] failed to get comment ${comment.id}: ${errorMessage}`);
154066
- return null;
154067
- }
154068
- }
154069
- async function getIsCancelled(ctx) {
154070
- if (!ctx.runId) return false;
154071
- try {
154072
- const jobsResult = await ctx.octokit.rest.actions.listJobsForWorkflowRun({
154073
- owner: ctx.repoContext.owner,
154074
- repo: ctx.repoContext.name,
154075
- run_id: ctx.runId
154076
- });
154077
- const currentJobName = process.env.GITHUB_JOB;
154078
- const currentJob = currentJobName ? jobsResult.data.jobs.find(
154079
- (j2) => j2.name === currentJobName || j2.name.startsWith(`${currentJobName} (`)
154080
- ) : jobsResult.data.jobs[0];
154081
- if (!currentJob) {
154082
- log.warning("[post] could not find current job");
154083
- return false;
154084
- }
154085
- log.info(`[post] job status: ${currentJob.status}, conclusion: ${currentJob.conclusion}`);
154086
- if (currentJob.conclusion === "cancelled") return true;
154087
- const cancelledStep = currentJob.steps?.find((step) => step.conclusion === "cancelled");
154088
- if (cancelledStep) {
154089
- log.info(`[post] found cancelled step: ${cancelledStep.name}`);
154090
- return true;
154091
- }
154092
- log.info("[post] no cancellation found, assuming failure");
154093
- } catch (error49) {
154094
- log.info(
154095
- `[post] failed to get job status: ${error49 instanceof Error ? error49.message : String(error49)}`
154096
- );
154097
- }
154098
- return false;
154099
- }
154100
- async function runPostCleanup() {
154101
- log.info("\xBB [post] starting post cleanup");
154102
- const runId = process.env.GITHUB_RUN_ID ? Number.parseInt(process.env.GITHUB_RUN_ID, 10) : void 0;
154103
- let promptInput = null;
154104
- try {
154105
- const resolved = resolvePromptInput();
154106
- if (typeof resolved !== "string") promptInput = resolved;
154107
- } catch (error49) {
154108
- log.info(
154109
- `[post] failed to resolve prompt input: ${error49 instanceof Error ? error49.message : String(error49)}`
154110
- );
154111
- }
154112
- const token = getJobToken();
154113
- const repoContext = parseRepoContext();
154114
- const octokit = createOctokit(token);
154115
- const ctx = { repoContext, octokit, runId, promptInput };
154116
- const stuck = await validateStuckProgressComment(ctx);
154117
- if (!stuck) return log.info("\xBB [post] no stuck progress comment to update, skipping cleanup");
154118
- log.info(
154119
- `\xBB [post] validated stuck comment: ${stuck.id} (${stuck.type}), updating with error message`
154120
- );
154121
- try {
154122
- const body = buildErrorCommentBody(
154123
- ctx,
154124
- SHOULD_CHECK_REASON ? await getIsCancelled(ctx) : false
154125
- );
154126
- await writeAndVerify(ctx, stuck, body);
154127
- } catch (error49) {
154128
- const errorMessage = error49 instanceof Error ? error49.message : String(error49);
154129
- log.info(`[post] failed to update comment: ${errorMessage}`);
154130
- }
154131
- }
154132
- var VERIFY_DELAY_MS = 3e3;
154133
- var MAX_WRITE_ATTEMPTS = 3;
154134
- async function writeAndVerify(ctx, comment, body) {
154135
- const apiCtx = {
154136
- octokit: ctx.octokit,
154137
- owner: ctx.repoContext.owner,
154138
- repo: ctx.repoContext.name
154139
- };
154140
- for (let attempt = 1; attempt <= MAX_WRITE_ATTEMPTS; attempt++) {
154141
- await updateProgressComment(apiCtx, comment, body);
154142
- await new Promise((resolve3) => setTimeout(resolve3, VERIFY_DELAY_MS));
154143
- let fetched;
154144
- try {
154145
- fetched = await getProgressComment(apiCtx, comment);
154146
- } catch (error49) {
154147
- log.warning(
154148
- `[post] verify GET failed after attempt ${attempt} \u2014 trusting our PUT landed: ${error49 instanceof Error ? error49.message : String(error49)}`
154149
- );
154150
- return;
154151
- }
154152
- if (fetched.body === body) {
154153
- log.info(
154154
- `\xBB [post] successfully updated progress comment (attempt ${attempt}/${MAX_WRITE_ATTEMPTS})`
154155
- );
154156
- return;
154157
- }
154158
- log.info(
154159
- `[post] body was overwritten after our write (attempt ${attempt}/${MAX_WRITE_ATTEMPTS}), retrying`
154160
- );
154161
- }
154162
- log.warning(
154163
- `[post] gave up after ${MAX_WRITE_ATTEMPTS} attempts \u2014 comment may be stale (in-flight writes from the cancelled run kept clobbering us)`
154164
- );
154165
- }
154166
-
154167
154175
  // commands/gha.ts
154168
- process.env.PATH = `${dirname4(process.execPath)}:${process.env.PATH}`;
154176
+ process.env.PATH = `${dirname5(process.execPath)}:${process.env.PATH}`;
154169
154177
  var STATE_TOKEN = "token";
154170
154178
  async function runMain() {
154171
154179
  try {
@@ -154178,15 +154186,6 @@ async function runMain() {
154178
154186
  core7.setFailed(`action failed: ${errorMessage}`);
154179
154187
  }
154180
154188
  }
154181
- async function runPost() {
154182
- log.debug(`[post] script started at ${(/* @__PURE__ */ new Date()).toISOString()}`);
154183
- try {
154184
- await runPostCleanup();
154185
- } catch (error49) {
154186
- const message = error49 instanceof Error ? error49.message : String(error49);
154187
- log.error(`[post] unexpected error: ${message}`);
154188
- }
154189
- }
154190
154189
  async function tokenMain() {
154191
154190
  const reposInput = core7.getInput("repos");
154192
154191
  const additionalRepos = reposInput ? reposInput.split(",").map((r) => r.trim()).filter(Boolean) : [];
@@ -154207,7 +154206,7 @@ async function tokenPost() {
154207
154206
  core7.info("\xBB installation token revoked");
154208
154207
  }
154209
154208
  function printGhaUsage(params) {
154210
- params.stream(`usage: ${params.prog} gha [token] [--post]
154209
+ params.stream(`usage: ${params.prog} gha [subcommand]
154211
154210
  `);
154212
154211
  params.stream("run the github action runtime flow.");
154213
154212
  params.stream("");
@@ -154216,9 +154215,29 @@ function printGhaUsage(params) {
154216
154215
  params.stream("");
154217
154216
  params.stream("options:");
154218
154217
  params.stream(" -h, --help show help");
154219
- params.stream(" --post run post-cleanup flow");
154218
+ }
154219
+ function printGhaTokenUsage(params) {
154220
+ params.stream(`usage: ${params.prog} gha token [--post]
154221
+ `);
154222
+ params.stream("acquire a github app installation token, or revoke it in the post step.");
154223
+ params.stream("");
154224
+ params.stream("options:");
154225
+ params.stream(" -h, --help show help");
154226
+ params.stream(" --post revoke the previously-acquired token (post-step usage only)");
154220
154227
  }
154221
154228
  function parseGhaArgs(args2) {
154229
+ return (0, import_arg.default)(
154230
+ {
154231
+ "--help": Boolean,
154232
+ "-h": "--help"
154233
+ },
154234
+ {
154235
+ argv: args2,
154236
+ stopAtPositional: true
154237
+ }
154238
+ );
154239
+ }
154240
+ function parseGhaTokenArgs(args2) {
154222
154241
  return (0, import_arg.default)(
154223
154242
  {
154224
154243
  "--help": Boolean,
@@ -154249,23 +154268,40 @@ async function runCli(params) {
154249
154268
  printGhaUsage({ stream: console.log, prog: params.prog });
154250
154269
  return;
154251
154270
  }
154252
- const normalizedArgs = ["gha"];
154253
154271
  const positional = parsed2._;
154254
- if (positional.length > 1) {
154255
- console.error(`unexpected positional arguments for gha: ${positional.slice(1).join(" ")}
154272
+ const subcommand = positional[0];
154273
+ if (!subcommand) {
154274
+ await run(["gha"]);
154275
+ return;
154276
+ }
154277
+ if (subcommand !== "token") {
154278
+ console.error(`unknown gha subcommand: ${subcommand}
154256
154279
  `);
154257
154280
  printGhaUsage({ stream: console.error, prog: params.prog });
154258
154281
  process.exit(1);
154259
154282
  }
154260
- if (positional[0] === "token") {
154261
- normalizedArgs.push("token");
154262
- } else if (positional[0]) {
154263
- console.error(`unknown gha subcommand: ${positional[0]}
154283
+ let tokenParsed;
154284
+ try {
154285
+ tokenParsed = parseGhaTokenArgs(positional.slice(1));
154286
+ } catch (error49) {
154287
+ const message = error49 instanceof Error ? error49.message : String(error49);
154288
+ console.error(`${message}
154289
+ `);
154290
+ printGhaTokenUsage({ stream: console.error, prog: params.prog });
154291
+ process.exit(1);
154292
+ }
154293
+ if (tokenParsed["--help"]) {
154294
+ printGhaTokenUsage({ stream: console.log, prog: params.prog });
154295
+ return;
154296
+ }
154297
+ if (tokenParsed._.length > 0) {
154298
+ console.error(`unexpected positional arguments for gha token: ${tokenParsed._.join(" ")}
154264
154299
  `);
154265
- printGhaUsage({ stream: console.error, prog: params.prog });
154300
+ printGhaTokenUsage({ stream: console.error, prog: params.prog });
154266
154301
  process.exit(1);
154267
154302
  }
154268
- if (parsed2["--post"]) {
154303
+ const normalizedArgs = ["gha", "token"];
154304
+ if (tokenParsed["--post"]) {
154269
154305
  normalizedArgs.push("--post");
154270
154306
  }
154271
154307
  await run(normalizedArgs);
@@ -154278,8 +154314,6 @@ async function run(args2) {
154278
154314
  } else {
154279
154315
  await tokenMain();
154280
154316
  }
154281
- } else if (args2.includes("--post")) {
154282
- await runPost();
154283
154317
  } else {
154284
154318
  await runMain();
154285
154319
  }
@@ -155949,7 +155983,7 @@ async function run2() {
155949
155983
  }
155950
155984
 
155951
155985
  // cli.ts
155952
- var VERSION10 = "0.0.204";
155986
+ var VERSION10 = "0.0.205";
155953
155987
  var bin = basename2(process.argv[1] || "");
155954
155988
  var PROG = bin === "pf" || bin === "pullfrog" ? bin : "pullfrog";
155955
155989
  var rawArgs = process.argv.slice(2);