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/index.js CHANGED
@@ -18198,7 +18198,7 @@ var require_summary = __commonJS({
18198
18198
  exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
18199
18199
  var os_1 = __require("os");
18200
18200
  var fs_1 = __require("fs");
18201
- var { access, appendFile, writeFile: writeFile2 } = fs_1.promises;
18201
+ var { access, appendFile, writeFile: writeFile3 } = fs_1.promises;
18202
18202
  exports.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY";
18203
18203
  exports.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary";
18204
18204
  var Summary = class {
@@ -18256,7 +18256,7 @@ var require_summary = __commonJS({
18256
18256
  return __awaiter(this, void 0, void 0, function* () {
18257
18257
  const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
18258
18258
  const filePath = yield this.filePath();
18259
- const writeFunc = overwrite ? writeFile2 : appendFile;
18259
+ const writeFunc = overwrite ? writeFile3 : appendFile;
18260
18260
  yield writeFunc(filePath, this._buffer, { encoding: "utf8" });
18261
18261
  return this.emptyBuffer();
18262
18262
  });
@@ -62662,8 +62662,8 @@ var require_snapshot_utils = __commonJS({
62662
62662
  var require_snapshot_recorder = __commonJS({
62663
62663
  "node_modules/.pnpm/undici@7.22.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
62664
62664
  "use strict";
62665
- var { writeFile: writeFile2, readFile, mkdir } = __require("node:fs/promises");
62666
- var { dirname: dirname4, resolve: resolve3 } = __require("node:path");
62665
+ var { writeFile: writeFile3, readFile: readFile4, mkdir: mkdir2 } = __require("node:fs/promises");
62666
+ var { dirname: dirname5, resolve: resolve3 } = __require("node:path");
62667
62667
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
62668
62668
  var { InvalidArgumentError, UndiciError } = require_errors4();
62669
62669
  var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
@@ -62864,7 +62864,7 @@ var require_snapshot_recorder = __commonJS({
62864
62864
  throw new InvalidArgumentError("Snapshot path is required");
62865
62865
  }
62866
62866
  try {
62867
- const data = await readFile(resolve3(path3), "utf8");
62867
+ const data = await readFile4(resolve3(path3), "utf8");
62868
62868
  const parsed2 = JSON.parse(data);
62869
62869
  if (Array.isArray(parsed2)) {
62870
62870
  this.#snapshots.clear();
@@ -62894,12 +62894,12 @@ var require_snapshot_recorder = __commonJS({
62894
62894
  throw new InvalidArgumentError("Snapshot path is required");
62895
62895
  }
62896
62896
  const resolvedPath = resolve3(path3);
62897
- await mkdir(dirname4(resolvedPath), { recursive: true });
62897
+ await mkdir2(dirname5(resolvedPath), { recursive: true });
62898
62898
  const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot2]) => ({
62899
62899
  hash: hash2,
62900
62900
  snapshot: snapshot2
62901
62901
  }));
62902
- await writeFile2(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
62902
+ await writeFile3(resolvedPath, JSON.stringify(data, null, 2), { flush: true });
62903
62903
  }
62904
62904
  /**
62905
62905
  * Clears all recorded snapshots
@@ -97475,14 +97475,14 @@ var require_turndown_cjs = __commonJS({
97475
97475
  } else if (node2.nodeType === 1) {
97476
97476
  replacement = replacementForNode.call(self2, node2);
97477
97477
  }
97478
- return join16(output, replacement);
97478
+ return join17(output, replacement);
97479
97479
  }, "");
97480
97480
  }
97481
97481
  function postProcess(output) {
97482
97482
  var self2 = this;
97483
97483
  this.rules.forEach(function(rule) {
97484
97484
  if (typeof rule.append === "function") {
97485
- output = join16(output, rule.append(self2.options));
97485
+ output = join17(output, rule.append(self2.options));
97486
97486
  }
97487
97487
  });
97488
97488
  return output.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
@@ -97494,7 +97494,7 @@ var require_turndown_cjs = __commonJS({
97494
97494
  if (whitespace.leading || whitespace.trailing) content = content.trim();
97495
97495
  return whitespace.leading + rule.replacement(content, node2, this.options) + whitespace.trailing;
97496
97496
  }
97497
- function join16(output, replacement) {
97497
+ function join17(output, replacement) {
97498
97498
  var s1 = trimTrailingNewlines(output);
97499
97499
  var s2 = trimLeadingNewlines(replacement);
97500
97500
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
@@ -98926,7 +98926,8 @@ var require_fast_content_type_parse = __commonJS({
98926
98926
  // main.ts
98927
98927
  var core6 = __toESM(require_core(), 1);
98928
98928
  import { existsSync as existsSync7, readdirSync } from "node:fs";
98929
- import { join as join15 } from "node:path";
98929
+ import { readFile as readFile3 } from "node:fs/promises";
98930
+ import { join as join16 } from "node:path";
98930
98931
 
98931
98932
  // node_modules/.pnpm/@ark+util@0.56.0/node_modules/@ark/util/out/arrays.js
98932
98933
  var liftArray = (data) => Array.isArray(data) ? data : [data];
@@ -107422,7 +107423,7 @@ function buildCommitPrompt(status) {
107422
107423
  ].join("\n");
107423
107424
  }
107424
107425
  function hasPostRunIssues(issues) {
107425
- return issues.stopHook !== void 0 || issues.dirtyTree !== void 0;
107426
+ return issues.stopHook !== void 0 || issues.dirtyTree !== void 0 || issues.summaryStale !== void 0;
107426
107427
  }
107427
107428
  var agent = (input) => {
107428
107429
  return {
@@ -108217,7 +108218,8 @@ var STRING_KEYS = [
108217
108218
  "issueNodeId",
108218
108219
  "reviewNodeId",
108219
108220
  "planCommentNodeId",
108220
- "summaryCommentNodeId"
108221
+ "summaryCommentNodeId",
108222
+ "summarySnapshot"
108221
108223
  ];
108222
108224
  var NUMBER_KEYS = [
108223
108225
  "inputTokens",
@@ -108937,43 +108939,22 @@ function addFooter(ctx, body) {
108937
108939
  var Comment = type({
108938
108940
  issueNumber: type.number.describe("the issue number to comment on"),
108939
108941
  body: type.string.describe("the comment body content"),
108940
- type: type.enumerated("Plan", "Summary", "Comment").describe(
108941
- "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)."
108942
- ).optional()
108942
+ type: type.enumerated("Plan", "Comment").describe("Plan: record as the plan for this run. Comment: regular comment (default).").optional()
108943
108943
  });
108944
108944
  function CreateCommentTool(ctx) {
108945
108945
  return tool({
108946
108946
  name: "create_issue_comment",
108947
- 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.",
108947
+ 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.",
108948
108948
  parameters: Comment,
108949
108949
  execute: execute(async ({ issueNumber, body, type: commentType }) => {
108950
108950
  const bodyWithFooter = addFooter(ctx, body);
108951
- if (commentType === "Summary" && ctx.toolState.existingSummaryCommentId) {
108952
- log.info(
108953
- `\xBB redirecting create_issue_comment(Summary) to update existing comment ${ctx.toolState.existingSummaryCommentId}`
108954
- );
108955
- const result2 = await ctx.octokit.rest.issues.updateComment({
108956
- owner: ctx.repo.owner,
108957
- repo: ctx.repo.name,
108958
- comment_id: ctx.toolState.existingSummaryCommentId,
108959
- body: bodyWithFooter
108960
- });
108961
- if (result2.data.node_id) {
108962
- await patchWorkflowRunFields(ctx, { summaryCommentNodeId: result2.data.node_id });
108963
- }
108964
- return {
108965
- success: true,
108966
- commentId: result2.data.id,
108967
- url: result2.data.html_url,
108968
- body: result2.data.body
108969
- };
108970
- }
108971
108951
  const result = await ctx.octokit.rest.issues.createComment({
108972
108952
  owner: ctx.repo.owner,
108973
108953
  repo: ctx.repo.name,
108974
108954
  issue_number: issueNumber,
108975
108955
  body: bodyWithFooter
108976
108956
  });
108957
+ ctx.toolState.wasUpdated = true;
108977
108958
  if (commentType === "Plan") {
108978
108959
  if (result.data.node_id) {
108979
108960
  await patchWorkflowRunFields(ctx, { planCommentNodeId: result.data.node_id });
@@ -108994,9 +108975,6 @@ function CreateCommentTool(ctx) {
108994
108975
  body: updateResult.data.body
108995
108976
  };
108996
108977
  }
108997
- if (commentType === "Summary" && result.data.node_id) {
108998
- await patchWorkflowRunFields(ctx, { summaryCommentNodeId: result.data.node_id });
108999
- }
109000
108978
  return {
109001
108979
  success: true,
109002
108980
  commentId: result.data.id,
@@ -109152,15 +109130,15 @@ ${collapsible}`;
109152
109130
  reportParams.target_plan_comment = params.target_plan_comment;
109153
109131
  }
109154
109132
  const result = await reportProgress(ctx, reportParams);
109155
- if (!params.target_plan_comment) {
109156
- ctx.toolState.finalSummaryWritten = true;
109157
- }
109158
109133
  if (result.action === "skipped") {
109159
109134
  return {
109160
109135
  success: true,
109161
109136
  message: "progress recorded (no GitHub comment created - this may occur for workflow_dispatch events or when there is no associated issue/PR)"
109162
109137
  };
109163
109138
  }
109139
+ if (!params.target_plan_comment) {
109140
+ ctx.toolState.finalSummaryWritten = true;
109141
+ }
109164
109142
  return {
109165
109143
  success: true,
109166
109144
  ...result
@@ -142265,7 +142243,7 @@ var import_semver = __toESM(require_semver2(), 1);
142265
142243
  // package.json
142266
142244
  var package_default = {
142267
142245
  name: "pullfrog",
142268
- version: "0.0.204",
142246
+ version: "0.0.205",
142269
142247
  type: "module",
142270
142248
  bin: {
142271
142249
  pullfrog: "dist/cli.mjs",
@@ -142462,7 +142440,7 @@ function closeBrowserDaemon(toolState) {
142462
142440
 
142463
142441
  // mcp/checkout.ts
142464
142442
  import { createHash as createHash2 } from "node:crypto";
142465
- import { writeFileSync } from "node:fs";
142443
+ import { statSync, unlinkSync as unlinkSync2, writeFileSync } from "node:fs";
142466
142444
  import { join as join3 } from "node:path";
142467
142445
 
142468
142446
  // utils/diffCoverage.ts
@@ -142491,7 +142469,10 @@ function createDiffCoverageState(params) {
142491
142469
  totalLines: params.totalLines,
142492
142470
  tocEntries: parseDiffTocEntries({ toc: params.toc }),
142493
142471
  coveredRanges: [],
142494
- coveragePreflightRan: false
142472
+ // carry forward across checkout_pr refreshes so the nudge stays "once per
142473
+ // review session". coveredRanges are intentionally not carried because
142474
+ // line numbers are tied to the previous diff's content.
142475
+ coveragePreflightRan: params.previous?.coveragePreflightRan ?? false
142495
142476
  };
142496
142477
  }
142497
142478
  function recordDiffReadFromToolUse(params) {
@@ -143295,6 +143276,11 @@ var GitFetch = type({
143295
143276
  ref: type.string.describe("Ref to fetch: branch name, tag, or 'pull/N/head' for PRs"),
143296
143277
  depth: type.number.describe("Fetch depth (for shallow clones)").optional()
143297
143278
  });
143279
+ var SHALLOW_UNREACHABLE_PATTERNS = [
143280
+ /Could not read [a-f0-9]{40,64}/,
143281
+ /remote did not send all necessary objects/
143282
+ ];
143283
+ var DEEPEN_RETRY_DEPTH = 1e3;
143298
143284
  function GitFetchTool(ctx) {
143299
143285
  return tool({
143300
143286
  name: "git_fetch",
@@ -143306,9 +143292,20 @@ function GitFetchTool(ctx) {
143306
143292
  if (params.depth !== void 0) {
143307
143293
  fetchArgs.push(`--depth=${params.depth}`);
143308
143294
  }
143309
- await $git("fetch", fetchArgs, {
143310
- token: ctx.gitToken
143311
- });
143295
+ try {
143296
+ await $git("fetch", fetchArgs, { token: ctx.gitToken });
143297
+ } catch (err) {
143298
+ const msg = err instanceof Error ? err.message : String(err);
143299
+ const isShallowUnreachable = SHALLOW_UNREACHABLE_PATTERNS.some((p) => p.test(msg));
143300
+ const isShallow = isShallowUnreachable && $("git", ["rev-parse", "--is-shallow-repository"], { log: false }).trim() === "true";
143301
+ if (!isShallow) throw err;
143302
+ log.info(
143303
+ `\xBB git_fetch hit shallow-unreachable error, retrying with --deepen=${DEEPEN_RETRY_DEPTH}`
143304
+ );
143305
+ await $git("fetch", [`--deepen=${DEEPEN_RETRY_DEPTH}`, "--no-tags", "origin", params.ref], {
143306
+ token: ctx.gitToken
143307
+ });
143308
+ }
143312
143309
  return { success: true, ref: params.ref };
143313
143310
  })
143314
143311
  });
@@ -143673,6 +143670,7 @@ function CreatePullRequestReviewTool(ctx) {
143673
143670
  nodeId: reviewNodeId,
143674
143671
  reviewedSha: actuallyReviewedSha
143675
143672
  };
143673
+ ctx.toolState.wasUpdated = true;
143676
143674
  await deleteProgressComment(ctx).catch((err) => {
143677
143675
  log.debug(`progress comment cleanup after review failed: ${err}`);
143678
143676
  });
@@ -144024,11 +144022,38 @@ async function ensureBeforeShaReachable(params) {
144024
144022
  return false;
144025
144023
  }
144026
144024
  }
144025
+ var STALE_LOCK_AGE_MS = 3e4;
144026
+ var GIT_LOCK_PATHS = [
144027
+ ".git/shallow.lock",
144028
+ ".git/index.lock",
144029
+ ".git/objects/maintenance.lock"
144030
+ ];
144031
+ function cleanupStaleGitLocks() {
144032
+ const now = Date.now();
144033
+ for (const relPath of GIT_LOCK_PATHS) {
144034
+ let mtimeMs;
144035
+ try {
144036
+ mtimeMs = statSync(relPath).mtimeMs;
144037
+ } catch {
144038
+ continue;
144039
+ }
144040
+ if (now - mtimeMs < STALE_LOCK_AGE_MS) continue;
144041
+ try {
144042
+ unlinkSync2(relPath);
144043
+ log.warning(`\xBB removed stale ${relPath} from prior run`);
144044
+ } catch (e) {
144045
+ log.debug(
144046
+ `\xBB failed to remove stale ${relPath}: ${e instanceof Error ? e.message : String(e)}`
144047
+ );
144048
+ }
144049
+ }
144050
+ }
144027
144051
  async function checkoutPrBranch(pr, params) {
144028
144052
  const { octokit, owner, name, gitToken, toolState, beforeSha } = params;
144029
144053
  log.info(`\xBB checking out PR #${pr.number}...`);
144030
144054
  rejectIfLeadingDash(pr.baseRef, "PR base ref");
144031
144055
  rejectIfLeadingDash(pr.headRef, "PR head ref");
144056
+ cleanupStaleGitLocks();
144032
144057
  const isFork = pr.headRepoFullName !== pr.baseRepoFullName;
144033
144058
  const localBranch = `pr-${pr.number}`;
144034
144059
  const isShallow = $("git", ["rev-parse", "--is-shallow-repository"], { log: false }).trim() === "true";
@@ -144198,7 +144223,8 @@ ${diffPreview}`);
144198
144223
  ctx.toolState.diffCoverage = createDiffCoverageState({
144199
144224
  diffPath,
144200
144225
  totalLines: countLines({ content: formatResult.content }),
144201
- toc: formatResult.toc
144226
+ toc: formatResult.toc,
144227
+ previous: ctx.toolState.diffCoverage
144202
144228
  });
144203
144229
  log.debug(
144204
144230
  `\xBB diff coverage initialized: diffPath=${diffPath}, totalLines=${ctx.toolState.diffCoverage.totalLines}, tocEntries=${ctx.toolState.diffCoverage.tocEntries.length}`
@@ -144828,6 +144854,7 @@ function UpdatePullRequestBodyTool(ctx) {
144828
144854
  pull_number: params.pull_number,
144829
144855
  body: bodyWithFooter
144830
144856
  });
144857
+ ctx.toolState.wasUpdated = true;
144831
144858
  return {
144832
144859
  success: true,
144833
144860
  number: result.data.number,
@@ -145428,425 +145455,10 @@ function ResolveReviewThreadTool(ctx) {
145428
145455
  });
145429
145456
  }
145430
145457
 
145431
- // agents/reviewer.ts
145432
- var REVIEWER_AGENT_NAME = "reviewfrog";
145433
- 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.
145434
-
145435
- HARD CONSTRAINTS (non-negotiable, regardless of orchestrator instructions):
145436
- - 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).
145437
- - 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.
145438
- - Do NOT spawn further subagents. You are a leaf reviewer; recursive dispatch pre-aggregates findings through an intermediate model and defeats the design.
145439
- - 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.
145440
-
145441
- 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.`;
145442
-
145443
- // modes.ts
145444
- var PR_SUMMARY_FORMAT = `### Default format
145445
-
145446
- Follow this structure exactly:
145447
-
145448
- <b>TL;DR</b> \u2014 1-3 sentences on what the PR does and why. Focus on intent, not mechanics.
145449
- NOTE: use HTML bold <b>TL;DR</b>, NOT markdown bold **TL;DR**.
145450
-
145451
- ### Key changes
145452
-
145453
- - **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.
145454
-
145455
- <sub><b>Summary</b> \uFF5C {file_count} files \uFF5C {commit_count} commits \uFF5C base: \`{base}\` \u2190 \`{head}\`</sub>
145456
- NOTE: the metadata line goes AFTER the bullet list, not before it.
145457
-
145458
- Then for each key change, a ## section with a short descriptive title that reads like a documentation heading (e.g. ## Live todo checklist tracking).
145459
-
145460
- <br/>
145461
-
145462
- ## Example readable section title
145463
-
145464
- > **Before:** [old behavior/state]<br/>**After:** [new behavior/state]
145465
- 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.
145466
-
145467
- 1-2 sentences of explanation. Break up text with tables, blockquotes, or lists \u2014 NEVER 3+ plain paragraphs in a row.
145468
-
145469
- If a change warrants deeper explanation, use a blockquoted details/summary framed as a question:
145470
- > <details><summary>How does X work?</summary>
145471
- > Extended explanation here.
145472
- > </details>
145473
-
145474
- End each section with a file links trail (3-4 key files max):
145475
- [\`file.ts\`](https://github.com/{owner}/{repo}/pull/{number}/files#diff-{sha256hex_of_filepath}) \xB7 ...
145476
-
145477
- Single-feature PRs: skip the ## sections. Fold before/after and explanation into the header after key changes.
145478
-
145479
- CRITICAL \u2014 GitHub markdown rendering rule:
145480
- 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.
145481
-
145482
- Rules:
145483
- - \`##\` 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
145484
- - ALL variable names, identifiers, and file names in body text must be in backticks
145485
- - 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.
145486
- - Add <br/> before each ## heading for visual spacing. Do NOT use horizontal rules (---)
145487
- - Do NOT include raw diff stats like '+123 / -45' or line counts
145488
- - Do NOT include code blocks or repeat diff contents
145489
- - Do NOT include a changelog section \u2014 the key changes list serves this purpose
145490
- - Focus on *intent*, not *what* \u2014 the diff already shows what changed
145491
- - Get the file count and commit count from the checkout_pr metadata, not by counting manually`;
145492
- function learningsStep(t, n) {
145493
- 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 \`${t("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.`;
145494
- }
145495
- function computeModes(agentId) {
145496
- const t = (toolName) => formatMcpToolRef(agentId, toolName);
145497
- return [
145498
- {
145499
- name: "Build",
145500
- 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",
145501
- prompt: `### Checklist
145502
-
145503
- 1. **plan** (optional, for complex tasks): analyze requirements, read AGENTS.md and relevant code, produce a step-by-step implementation plan.
145504
-
145505
- 2. **setup**: checkout or create the branch:
145506
- - **PR event, modifying the existing PR**: call \`${t("checkout_pr")}\`
145507
- - **new branch**: use \`${t("git")}\` to create a branch (\`git checkout -b pullfrog/branch-name\`)
145508
-
145509
- 3. **build**: implement changes using your native file and shell tools:
145510
- - follow the plan (if you ran a plan phase)
145511
- - 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.
145512
- - run relevant tests/lints before committing
145513
-
145514
- 4. **self-review**: judgment call \u2014 does YOUR diff warrant a fresh-eyes pass?
145515
-
145516
- Skip self-review (commit directly) when the diff is **genuinely trivial**:
145517
- - doc typos, comment-only edits, whitespace/format-only, import reordering
145518
- - 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)
145519
- - low-risk dep patch bump from a trusted source
145520
-
145521
- Run self-review when the diff has **any behavioral surface, however small**:
145522
- - 1-line changes to SQL operators / comparison logic / regexes / redirects / HTTP methods / response codes
145523
- - any change to money / tax / currency / billing / fee / refund / payout calculations or constants
145524
- - any change to auth / permissions / roles / sessions / tokens / signature verification
145525
- - any change to feature-flag defaults, retry counts, timeouts, rate limits, batch sizes
145526
- - new endpoints, new code paths, new error branches \u2014 even small ones
145527
- - mixed diffs (whitespace + a single semantic line) \u2014 the semantic line still triggers self-review
145528
- - anything you're uncertain about
145529
-
145530
- 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.
145531
-
145532
- 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.
145533
-
145534
- 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.
145535
-
145536
- Delegation + research discipline (distilled from \`/anneal\` canonical \u2014 these are codified learnings from many review rounds, not theoretical best practices):
145537
- - Do NOT summarize what you implemented \u2014 that biases the subagent toward validating the shape of your solution rather than questioning it.
145538
- - Do NOT curate a reading list of files. Let the subagent discover scope from the diff and codebase.
145539
- - Do NOT pre-shape output with a severity / category schema. That leaks your hypotheses; severity is your call during evaluation.
145540
- - 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.
145541
- - 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.
145542
-
145543
- 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 "..."\`).
145544
-
145545
- 5. **finalize**:
145546
- - confirm a clean working tree, then push via \`${t("push_branch")}\` (see *SYSTEM* Git rules if this fails \u2014 prepush errors are usually the repo's tests/lint, not infra timeouts)
145547
- - create a PR via \`${t("create_pull_request")}\`
145548
- - call \`${t("report_progress")}\` with the PR link or the exact error if push/PR failed
145549
-
145550
- ${learningsStep(t, 6)}
145551
-
145552
- ### Notes
145553
-
145554
- For simple, well-defined tasks, skip the plan phase and go straight to build.`
145555
- },
145556
- {
145557
- name: "AddressReviews",
145558
- description: "Address PR review feedback; respond to reviewer comments; make requested changes to an existing PR",
145559
- prompt: `### Checklist
145560
-
145561
- 1. Checkout the PR branch via \`${t("checkout_pr")}\`.
145562
-
145563
- 2. Fetch review comments via \`${t("get_review_comments")}\`.
145564
-
145565
- 3. For each comment:
145566
- - understand the feedback
145567
- - 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.
145568
- - if the request stands, make the code change using your native tools; otherwise reply explaining why
145569
- - record what was done (or why nothing was done)
145570
-
145571
- 4. Quality check:
145572
- - 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
145573
- - commit locally via shell (\`git add . && git commit -m "..."\`)
145574
-
145575
- 5. Finalize:
145576
- - confirm a clean working tree, then push via \`${t("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
145577
- - reply to each comment using \`${t("reply_to_review_comment")}\`
145578
- - resolve addressed threads via \`${t("resolve_review_thread")}\`
145579
- - call \`${t("report_progress")}\` with a brief summary (or the exact push error if push failed)
145580
-
145581
- ${learningsStep(t, 6)}`
145582
- },
145583
- // Review and IncrementalReview use the multi-lens orchestrator pattern
145584
- // (canonical source: .claude/commands/anneal.md). The orchestrator does
145585
- // triage → parallel read-only subagent fan-out → aggregate → draft comments
145586
- // → submit. For someone else's PR, parallel lenses (correctness, security,
145587
- // research-validated claims, user-journey, etc.) provide breadth across
145588
- // angles that a single subagent can't carry coherently. Build mode keeps
145589
- // a single fresh-eyes subagent (different problem shape — orchestrator
145590
- // wrote the code and bias-mitigation comes from delegating to one
145591
- // subagent that doesn't share the implementation context).
145592
- // Deliberate omission vs canonical /anneal: severity categorization in the
145593
- // final message (the review body has its own CAUTION/IMPORTANT framing
145594
- // instead of a severity table).
145595
- {
145596
- name: "Review",
145597
- description: "Review code, PRs, or implementations; provide feedback or suggestions; identify issues; or check code quality, style, and correctness",
145598
- prompt: `### Checklist
145599
-
145600
- 1. **checkout**: call \`${t("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.
145601
-
145602
- 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 \`${t("get_pull_request")}\` and other read-only GitHub tools for additional context if needed.
145603
-
145604
- 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.
145605
-
145606
- "Genuinely trivial" (skip):
145607
- - single-word doc typo, whitespace/format-only, comment-only across any number of files
145608
- - lockfile or generated-code regeneration (size of diff is irrelevant \u2014 read the *shape*)
145609
- - mechanical rename whose only effect is import-path updates
145610
- - low-risk dep patch bump
145611
-
145612
- "Looks trivial but isn't" (do **NOT** skip \u2014 small diff, big blast radius):
145613
- - any 1-line change to SQL / regex / auth / billing / permission / signature-verification code
145614
- - flipping a feature-flag default, default config value, or retry/timeout constant
145615
- - changing a money/tax/currency/fee constant by any amount
145616
- - changing an HTTP method, redirect URL, response code, or status enum
145617
- - tightening or loosening a comparison operator (\`<\` \u2194 \`<=\`, \`==\` \u2194 \`!=\`)
145618
- - renaming a public API surface (still trivial in shape, but needs an impact lens)
145619
- - adding a new direct dependency (supply-chain surface)
145620
- - any "typo fix" in user-facing copy that changes meaning ("approved" \u2192 "denied")
145621
- - mixed diffs where a semantic 1-liner is buried in whitespace/formatting changes
145622
-
145623
- 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.
145624
-
145625
- 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:
145626
-
145627
- - **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)
145628
- - **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)
145629
- - **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)
145630
- - **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.
145631
-
145632
- lenses come in two flavors, and you can mix them:
145633
- - **themed lenses** \u2014 a perspective applied across the whole diff (correctness, security, user-journey, performance, etc.).
145634
- - **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.
145635
-
145636
- starter menu (combine, omit, or invent your own):
145637
- - **correctness & invariants** \u2014 bugs, races, error handling, edge cases, state-machine boundaries
145638
- - **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
145639
- - **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.
145640
- - **security** \u2014 new endpoints, authZ, input validation, secrets handling, replay/CSRF/injection, cross-tenant isolation
145641
- - **user-journey** \u2014 UX-touching flows: walk through happy path and failure modes as a user
145642
- - **operational readiness** \u2014 observability, alerting, migrations (forward + rollback), feature flags, on-call burden
145643
- - **integration & cross-cutting** \u2014 API contracts between modules, backward-compat of public surfaces, multi-service ordering
145644
- - **test integrity** \u2014 meaningful coverage for the changed behavior; deterministic; no shared-state pollution
145645
- - **performance** \u2014 N+1 queries, hot-path allocation, latency budgets, index coverage
145646
- - **holistic** \u2014 does the PR make sense as a whole? symmetric flows (delete for every create, rollback for every migration)?
145647
- - **subsystem lenses** (invent as the PR demands) \u2014 auth, billing, payments, schema migration, webhooks, secrets, RBAC, multi-tenant isolation, cron/scheduling, etc.
145648
-
145649
- 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:
145650
- - the diff path / target \u2014 reading the diff and the codebase is its job
145651
- - **only one lens** \u2014 never a multi-section "review for X, Y, and Z" prompt
145652
- - **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\`.
145653
- - 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.
145654
- - 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."
145655
- - 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.
145656
-
145657
- delegation discipline:
145658
- - 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)
145659
- - do NOT summarize the PR for them (biases toward a validation frame)
145660
- - do NOT hand them a curated reading list (let them discover scope)
145661
- - do NOT pre-shape their output with a finding schema
145662
- - do NOT mention the other lenses (independence is the point \u2014 overlapping findings are a strong signal)
145663
-
145664
- 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.
145665
-
145666
- 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.
145667
-
145668
- 5. **submit**: ALWAYS submit exactly one review via \`${t("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.
145669
-
145670
- 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.
145671
-
145672
- - **critical issues** (blocks merge \u2014 bugs, security, data loss):
145673
- \`approved: false\`. Body begins with a GitHub alert blockquote, e.g.:
145674
- \`> [!CAUTION]\\n> This PR introduces a race condition in ...\`
145675
- Follow with a brief summary if needed. Include all inline comments.
145676
- - **recommended changes** (non-critical):
145677
- \`approved: false\`. Body begins with a GitHub alert blockquote, e.g.:
145678
- \`> [!IMPORTANT]\\n> Consider adding input validation for ...\`
145679
- Follow with a brief summary if needed. Include all inline comments.
145680
- - **no actionable issues**:
145681
- \`approved: true\`, body: "Reviewed \u2014 no issues found."`
145682
- },
145683
- // IncrementalReview shares Review's multi-lens orchestrator pattern but
145684
- // scopes the target to the incremental diff and adds prior-review-feedback
145685
- // tracking. The "issues must be NEW since the last Pullfrog review" filter
145686
- // lives at aggregation time (step 5), NOT in the subagent prompt — pushing
145687
- // the filter into subagents matches the canonical anneal anti-pattern of
145688
- // "list known pre-existing failures — don't flag these" and suppresses
145689
- // signal on regressions the new commits amplified. The body-format rules
145690
- // (Reviewed changes / Prior review feedback) are unchanged from the prior
145691
- // version. Same severity-table omission as Review.
145692
- {
145693
- name: "IncrementalReview",
145694
- description: "Re-review a PR after new commits are pushed; focus on new changes since the last review",
145695
- prompt: `### Checklist
145696
-
145697
- 1. **checkout**: call \`${t("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.
145698
-
145699
- 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.
145700
-
145701
- 3. **prior feedback**: fetch previous reviews via \`${t("list_pull_request_reviews")}\`. for the most recent Pullfrog review, call \`${t("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.
145702
-
145703
- 4. **triage & fan out**: orient on the *incremental* changes \u2014 domain, seams, external contracts, user-facing surfaces.
145704
-
145705
- 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).
145706
-
145707
- "Genuinely trivial" (skip): formatting/comment tweaks, import reordering, lockfile regen, mechanical rename of import paths, whitespace-only.
145708
- "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.
145709
- When unsure, treat as non-trivial.
145710
-
145711
- 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.
145712
-
145713
- 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:
145714
- - 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
145715
- - **only one lens** \u2014 never a multi-section "review for X, Y, and Z" prompt
145716
- - **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\`.
145717
- - 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.
145718
- - 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."
145719
- - ask the subagent to report findings with file paths and NEW line numbers from the full PR diff so you can anchor inline comments.
145720
-
145721
- delegation discipline:
145722
- - do NOT lens-review the diff yourself in parallel with the subagents
145723
- - do NOT summarize the changes for them (biases toward validation frame)
145724
- - do NOT hand them a curated reading list (let them discover scope)
145725
- - do NOT pre-shape their output with a finding schema
145726
- - do NOT mention the other lenses (independence is the point)
145727
-
145728
- 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 \`${t("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.
145729
-
145730
- then check: which prior review comments were addressed by the new commits? track the addressed ones for step 6b.
145731
-
145732
- 6. **build the review body** \u2014 two distinct sections:
145733
- 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.
145734
- 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.
145735
- - no headings, no tables, no prose paragraphs in either section \u2014 just bullets
145736
- - 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.
145737
-
145738
- 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:
145739
- - 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.
145740
- - 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.
145741
- - ELSE IF NEW CRITICAL ISSUES (blocks merge): call \`${t("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).
145742
- - ELSE IF NEW RECOMMENDED CHANGES (non-critical): call \`${t("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).
145743
- - ELSE IF NO NEW ISSUES, SUBSTANTIVE CHANGES (new functionality, behavior changes, or fixes to prior review feedback): call \`${t("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).`
145744
- },
145745
- {
145746
- name: "Plan",
145747
- description: "Create plans, break down tasks, outline steps, analyze requirements, understand scope of work, or provide task breakdowns",
145748
- prompt: `### Checklist
145749
-
145750
- 1. Analyze the task and gather context:
145751
- - read AGENTS.md and relevant codebase files
145752
- - understand the architecture and constraints
145753
-
145754
- 2. Produce a structured, actionable plan with clear milestones.
145755
-
145756
- 3. Call \`${t("report_progress")}\` with the plan.
145757
-
145758
- ${learningsStep(t, 4)}`
145759
- },
145760
- {
145761
- name: "Fix",
145762
- description: "Fix CI failures; debug failing tests or builds; investigate and resolve check suite failures",
145763
- prompt: `### Checklist
145764
-
145765
- 1. Checkout the PR branch via \`${t("checkout_pr")}\`.
145766
-
145767
- 2. Fetch check suite logs via \`${t("get_check_suite_logs")}\`.
145768
-
145769
- 3. **CRITICAL**: verify the failure was INTRODUCED BY THIS PR before fixing. If unrelated, abort and report.
145770
-
145771
- 4. Diagnose and fix:
145772
- - read the workflow file, reproduce locally with the EXACT same commands CI runs
145773
- - fix the issue using your native file and shell tools
145774
- - verify the fix by re-running the exact CI command
145775
- - 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.
145776
- - commit locally via shell (\`git add . && git commit -m "..."\`)
145777
-
145778
- 5. Finalize:
145779
- - confirm a clean working tree, then push via \`${t("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
145780
- - call \`${t("report_progress")}\` with the diagnosis and fix summary (or the exact push error if push failed)
145781
-
145782
- ${learningsStep(t, 6)}`
145783
- },
145784
- {
145785
- name: "ResolveConflicts",
145786
- description: "Resolve merge conflicts in a PR branch against the base branch",
145787
- prompt: `### Checklist
145788
-
145789
- 1. **Setup**:
145790
- - Call \`${t("checkout_pr")}\` to get the PR branch.
145791
- - Call \`${t("get_pull_request")}\` to identify the base branch (e.g., 'main').
145792
- - Call \`${t("git_fetch")}\` to fetch the base branch.
145793
-
145794
- 2. **Merge Attempt**:
145795
- - Run \`git merge origin/<base_branch>\` via shell.
145796
- - If it succeeds automatically, confirm a clean working tree, push via \`${t("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*), and call \`${t("report_progress")}\` with a brief success note or the exact push error if push failed \u2014 **then stop; do not run steps 3\u20134.**
145797
- - If it fails (conflicts), resolve them manually (continue to steps 3\u20134).
145798
-
145799
- 3. **Resolve Conflicts**:
145800
- - Run \`git status\` or parse the merge output to find the list of conflicting files.
145801
- - 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.
145802
- - Verify the file syntax is correct after resolution.
145803
-
145804
- 4. **Finalize**:
145805
- - Run a final verification (build/test) to ensure the resolution works.
145806
- - \`git add . && git commit -m "resolve merge conflicts"\`
145807
- - confirm a clean working tree, then push via \`${t("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
145808
- - Call \`${t("report_progress")}\` with a summary of what was resolved (or the exact push error if push failed)`
145809
- },
145810
- {
145811
- name: "Task",
145812
- description: "General-purpose tasks that don't fit other modes: answering questions, adding comments, labeling, running ad-hoc commands, or any direct request",
145813
- prompt: `### Checklist
145814
-
145815
- 1. Analyze the task. For simple operations (labeling, commenting, answering questions, running a single command), handle directly.
145816
-
145817
- 2. For substantial work \u2014 code changes across multiple files, multi-step investigations:
145818
- - plan your approach before starting
145819
- - use native file and shell tools for local operations
145820
- - use ${pullfrogMcpName} MCP tools for GitHub/git operations
145821
- - 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
145822
-
145823
- 3. Finalize:
145824
- - if code changes were made, push to a pull request (new or existing) using \`${t("push_branch")}\` and \`${t("create_pull_request")}\` as needed. \`git status\` must be clean before you finish (see *SYSTEM* Git rules if push fails).
145825
- - call \`${t("report_progress")}\` once with results \u2014 include exact tool errors if push or PR creation failed
145826
- - if the task involved labeling, commenting, or other GitHub operations, perform those directly
145827
-
145828
- ${learningsStep(t, 4)}`
145829
- },
145830
- {
145831
- name: "Summarize",
145832
- description: "Summarize a PR with a structured comment that is updated in place on subsequent pushes",
145833
- prompt: `### Checklist
145834
-
145835
- 1. Checkout the PR via \`${t("checkout_pr")}\` \u2014 this returns PR metadata and a \`diffPath\`.
145836
- 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.
145837
- 3. Call \`${t("create_issue_comment")}\` with \`type: "Summary"\` and the summary body.
145838
- 4. Call \`${t("report_progress")}\` with a brief note (e.g., "Posted PR summary.").
145839
-
145840
- ${PR_SUMMARY_FORMAT}`
145841
- }
145842
- ];
145843
- }
145844
- var modes = computeModes("opencode");
145845
-
145846
145458
  // mcp/selectMode.ts
145847
145459
  var SelectModeParams = type({
145848
145460
  mode: type.string.describe(
145849
- "the name of the mode to select (e.g., 'Build', 'Plan', 'Review', 'IncrementalReview', 'Fix', 'AddressReviews', 'Task', 'ResolveConflicts', 'Summarize')"
145461
+ "the name of the mode to select (e.g., 'Build', 'Plan', 'Review', 'IncrementalReview', 'Fix', 'AddressReviews', 'Task', 'ResolveConflicts')"
145850
145462
  ),
145851
145463
  "issue_number?": type("number").describe(
145852
145464
  "optional issue number; when provided with Plan mode, used to look up an existing plan comment for this issue (edit vs create)"
@@ -145867,18 +145479,7 @@ An existing plan comment was found for this issue. Update that comment with the
145867
145479
  - gather relevant codebase context (file paths, architecture notes from AGENTS.md)
145868
145480
  - produce a structured plan with clear milestones
145869
145481
  3. Call \`${t("report_progress")}\` with the full revised plan text and \`{ target_plan_comment: true }\` so it updates the existing plan comment (not the progress comment).
145870
- 4. Then post a short note to the progress comment (e.g. "Plan has been updated in the comment above.") via \`${t("report_progress")}\` so it is not left as "Leaping...".`,
145871
- SummaryUpdate: `### Checklist (updating existing summary)
145872
-
145873
- An existing summary comment was found for this PR. Update it rather than creating a new one.
145874
-
145875
- 1. Use \`previousSummaryBody\` from this response as the current summary to revise.
145876
- 2. Checkout the PR via \`${t("checkout_pr")}\` \u2014 this returns PR metadata and a \`diffPath\`.
145877
- 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.
145878
- 4. Call \`${t("edit_issue_comment")}\` with \`commentId: existingSummaryCommentId\` (from this response) and the updated summary body.
145879
- 5. Call \`${t("report_progress")}\` with a brief note (e.g., "Updated PR summary.").
145880
-
145881
- ${PR_SUMMARY_FORMAT}`
145482
+ 4. Then post a short note to the progress comment (e.g. "Plan has been updated in the comment above.") via \`${t("report_progress")}\` so it is not left as "Leaping...".`
145882
145483
  };
145883
145484
  }
145884
145485
  var modeInstructionParent = {
@@ -145911,30 +145512,22 @@ async function fetchExistingPlanComment(ctx, issueNumber) {
145911
145512
  return null;
145912
145513
  }
145913
145514
  }
145914
- async function fetchExistingSummaryComment(ctx, prNumber) {
145915
- if (!ctx.githubInstallationToken) {
145916
- log.warning("fetchExistingSummaryComment: no token, skipping");
145917
- return null;
145918
- }
145919
- const path3 = `/api/repo/${ctx.repo.owner}/${ctx.repo.name}/pr/${prNumber}/summary-comment`;
145920
- try {
145921
- const response = await apiFetch({
145922
- path: path3,
145923
- method: "GET",
145924
- headers: { authorization: `Bearer ${ctx.githubInstallationToken}` },
145925
- signal: AbortSignal.timeout(1e4)
145926
- });
145927
- const data = await response.json();
145928
- if (response.ok && "commentId" in data) {
145929
- return data;
145930
- }
145931
- const errMsg = "error" in data ? data.error : "(no error body)";
145932
- log.warning(`fetchExistingSummaryComment: ${response.status} ${path3} \u2014 ${errMsg}`);
145933
- return null;
145934
- } catch (error49) {
145935
- log.warning("fetchExistingSummaryComment failed:", error49);
145936
- return null;
145937
- }
145515
+ var SUMMARY_MODES = /* @__PURE__ */ new Set(["Review", "IncrementalReview", "Task"]);
145516
+ function buildSummaryAddendum(t, ctx) {
145517
+ const filePath = ctx.toolState.summaryFilePath;
145518
+ if (!filePath) return "";
145519
+ return `### PR summary snapshot \u2014 required step
145520
+
145521
+ 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 \`${t("list_pull_request_reviews")}\`.
145522
+
145523
+ How to use it:
145524
+
145525
+ - 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.
145526
+ - 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.
145527
+ - 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.
145528
+ - 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.
145529
+
145530
+ Do NOT call \`${t("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.`;
145938
145531
  }
145939
145532
  function SelectModeTool(ctx) {
145940
145533
  const t = (name) => formatMcpToolRef(ctx.agentId, name);
@@ -145976,21 +145569,18 @@ function SelectModeTool(ctx) {
145976
145569
  }
145977
145570
  }
145978
145571
  }
145979
- if (selectedMode.name === "Summarize") {
145980
- const prNumber = ctx.payload.event.issue_number;
145981
- if (prNumber !== void 0) {
145982
- const existing = await fetchExistingSummaryComment(ctx, prNumber);
145983
- if (existing !== null) {
145984
- ctx.toolState.existingSummaryCommentId = existing.commentId;
145985
- return {
145986
- ...buildOrchestratorGuidance(ctx, selectedMode, overrides.SummaryUpdate),
145987
- existingSummaryCommentId: existing.commentId,
145988
- previousSummaryBody: existing.body
145989
- };
145990
- }
145991
- }
145572
+ const summaryAddendum = SUMMARY_MODES.has(selectedMode.name) ? buildSummaryAddendum(t, ctx) : "";
145573
+ const base = buildOrchestratorGuidance(ctx, selectedMode);
145574
+ if (summaryAddendum.length > 0) {
145575
+ return {
145576
+ ...base,
145577
+ orchestratorGuidance: `${base.orchestratorGuidance}
145578
+
145579
+ ${summaryAddendum}`,
145580
+ summaryFilePath: ctx.toolState.summaryFilePath
145581
+ };
145992
145582
  }
145993
- return buildOrchestratorGuidance(ctx, selectedMode);
145583
+ return base;
145994
145584
  })
145995
145585
  });
145996
145586
  }
@@ -146504,6 +146094,405 @@ async function startMcpHttpServer(ctx, options) {
146504
146094
  };
146505
146095
  }
146506
146096
 
146097
+ // agents/reviewer.ts
146098
+ var REVIEWER_AGENT_NAME = "reviewfrog";
146099
+ 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.
146100
+
146101
+ HARD CONSTRAINTS (non-negotiable, regardless of orchestrator instructions):
146102
+ - 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).
146103
+ - 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.
146104
+ - Do NOT spawn further subagents. You are a leaf reviewer; recursive dispatch pre-aggregates findings through an intermediate model and defeats the design.
146105
+ - 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.
146106
+
146107
+ 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.`;
146108
+
146109
+ // modes.ts
146110
+ var PR_SUMMARY_FORMAT = `### Default format
146111
+
146112
+ Follow this structure exactly:
146113
+
146114
+ <b>TL;DR</b> \u2014 1-3 sentences on what the PR does and why. Focus on intent, not mechanics.
146115
+ NOTE: use HTML bold <b>TL;DR</b>, NOT markdown bold **TL;DR**.
146116
+
146117
+ ### Key changes
146118
+
146119
+ - **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.
146120
+
146121
+ <sub><b>Summary</b> \uFF5C {file_count} files \uFF5C {commit_count} commits \uFF5C base: \`{base}\` \u2190 \`{head}\`</sub>
146122
+ NOTE: the metadata line goes AFTER the bullet list, not before it.
146123
+
146124
+ Then for each key change, a ## section with a short descriptive title that reads like a documentation heading (e.g. ## Live todo checklist tracking).
146125
+
146126
+ <br/>
146127
+
146128
+ ## Example readable section title
146129
+
146130
+ > **Before:** [old behavior/state]<br/>**After:** [new behavior/state]
146131
+ 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.
146132
+
146133
+ 1-2 sentences of explanation. Break up text with tables, blockquotes, or lists \u2014 NEVER 3+ plain paragraphs in a row.
146134
+
146135
+ If a change warrants deeper explanation, use a blockquoted details/summary framed as a question:
146136
+ > <details><summary>How does X work?</summary>
146137
+ > Extended explanation here.
146138
+ > </details>
146139
+
146140
+ End each section with a file links trail (3-4 key files max):
146141
+ [\`file.ts\`](https://github.com/{owner}/{repo}/pull/{number}/files#diff-{sha256hex_of_filepath}) \xB7 ...
146142
+
146143
+ Single-feature PRs: skip the ## sections. Fold before/after and explanation into the header after key changes.
146144
+
146145
+ CRITICAL \u2014 GitHub markdown rendering rule:
146146
+ 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.
146147
+
146148
+ Rules:
146149
+ - \`##\` 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
146150
+ - ALL variable names, identifiers, and file names in body text must be in backticks
146151
+ - 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.
146152
+ - Add <br/> before each ## heading for visual spacing. Do NOT use horizontal rules (---)
146153
+ - Do NOT include raw diff stats like '+123 / -45' or line counts
146154
+ - Do NOT include code blocks or repeat diff contents
146155
+ - Do NOT include a changelog section \u2014 the key changes list serves this purpose
146156
+ - Focus on *intent*, not *what* \u2014 the diff already shows what changed
146157
+ - Get the file count and commit count from the checkout_pr metadata, not by counting manually`;
146158
+ function learningsStep(t, n) {
146159
+ 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 \`${t("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.`;
146160
+ }
146161
+ function computeModes(agentId) {
146162
+ const t = (toolName) => formatMcpToolRef(agentId, toolName);
146163
+ return [
146164
+ {
146165
+ name: "Build",
146166
+ 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",
146167
+ prompt: `### Checklist
146168
+
146169
+ 1. **plan** (optional, for complex tasks): analyze requirements, read AGENTS.md and relevant code, produce a step-by-step implementation plan.
146170
+
146171
+ 2. **setup**: checkout or create the branch:
146172
+ - **PR event, modifying the existing PR**: call \`${t("checkout_pr")}\`
146173
+ - **new branch**: use \`${t("git")}\` to create a branch (\`git checkout -b pullfrog/branch-name\`)
146174
+
146175
+ 3. **build**: implement changes using your native file and shell tools:
146176
+ - follow the plan (if you ran a plan phase)
146177
+ - 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.
146178
+ - run relevant tests/lints before committing
146179
+
146180
+ 4. **self-review**: judgment call \u2014 does YOUR diff warrant a fresh-eyes pass?
146181
+
146182
+ Skip self-review (commit directly) when the diff is **genuinely trivial**:
146183
+ - doc typos, comment-only edits, whitespace/format-only, import reordering
146184
+ - 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)
146185
+ - low-risk dep patch bump from a trusted source
146186
+
146187
+ Run self-review when the diff has **any behavioral surface, however small**:
146188
+ - 1-line changes to SQL operators / comparison logic / regexes / redirects / HTTP methods / response codes
146189
+ - any change to money / tax / currency / billing / fee / refund / payout calculations or constants
146190
+ - any change to auth / permissions / roles / sessions / tokens / signature verification
146191
+ - any change to feature-flag defaults, retry counts, timeouts, rate limits, batch sizes
146192
+ - new endpoints, new code paths, new error branches \u2014 even small ones
146193
+ - mixed diffs (whitespace + a single semantic line) \u2014 the semantic line still triggers self-review
146194
+ - anything you're uncertain about
146195
+
146196
+ 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.
146197
+
146198
+ 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.
146199
+
146200
+ 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.
146201
+
146202
+ Delegation + research discipline (distilled from \`/anneal\` canonical \u2014 these are codified learnings from many review rounds, not theoretical best practices):
146203
+ - Do NOT summarize what you implemented \u2014 that biases the subagent toward validating the shape of your solution rather than questioning it.
146204
+ - Do NOT curate a reading list of files. Let the subagent discover scope from the diff and codebase.
146205
+ - Do NOT pre-shape output with a severity / category schema. That leaks your hypotheses; severity is your call during evaluation.
146206
+ - 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.
146207
+ - 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.
146208
+
146209
+ 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 "..."\`).
146210
+
146211
+ 5. **finalize**:
146212
+ - confirm a clean working tree, then push via \`${t("push_branch")}\` (see *SYSTEM* Git rules if this fails \u2014 prepush errors are usually the repo's tests/lint, not infra timeouts)
146213
+ - create a PR via \`${t("create_pull_request")}\`
146214
+ - call \`${t("report_progress")}\` with the PR link or the exact error if push/PR failed
146215
+
146216
+ ${learningsStep(t, 6)}
146217
+
146218
+ ### Notes
146219
+
146220
+ For simple, well-defined tasks, skip the plan phase and go straight to build.`
146221
+ },
146222
+ {
146223
+ name: "AddressReviews",
146224
+ description: "Address PR review feedback; respond to reviewer comments; make requested changes to an existing PR",
146225
+ prompt: `### Checklist
146226
+
146227
+ 1. Checkout the PR branch via \`${t("checkout_pr")}\`.
146228
+
146229
+ 2. Fetch review comments via \`${t("get_review_comments")}\`.
146230
+
146231
+ 3. For each comment:
146232
+ - understand the feedback
146233
+ - 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.
146234
+ - if the request stands, make the code change using your native tools; otherwise reply explaining why
146235
+ - record what was done (or why nothing was done)
146236
+
146237
+ 4. Quality check:
146238
+ - 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
146239
+ - commit locally via shell (\`git add . && git commit -m "..."\`)
146240
+
146241
+ 5. Finalize:
146242
+ - confirm a clean working tree, then push via \`${t("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
146243
+ - reply to each comment using \`${t("reply_to_review_comment")}\`
146244
+ - resolve addressed threads via \`${t("resolve_review_thread")}\`
146245
+ - call \`${t("report_progress")}\` with a brief summary (or the exact push error if push failed)
146246
+
146247
+ ${learningsStep(t, 6)}`
146248
+ },
146249
+ // Review and IncrementalReview use the multi-lens orchestrator pattern
146250
+ // (canonical source: .claude/commands/anneal.md). The orchestrator does
146251
+ // triage → parallel read-only subagent fan-out → aggregate → draft comments
146252
+ // → submit. For someone else's PR, parallel lenses (correctness, security,
146253
+ // research-validated claims, user-journey, etc.) provide breadth across
146254
+ // angles that a single subagent can't carry coherently. Build mode keeps
146255
+ // a single fresh-eyes subagent (different problem shape — orchestrator
146256
+ // wrote the code and bias-mitigation comes from delegating to one
146257
+ // subagent that doesn't share the implementation context).
146258
+ // Deliberate omission vs canonical /anneal: severity categorization in the
146259
+ // final message (the review body has its own CAUTION/IMPORTANT framing
146260
+ // instead of a severity table).
146261
+ {
146262
+ name: "Review",
146263
+ description: "Review code, PRs, or implementations; provide feedback or suggestions; identify issues; or check code quality, style, and correctness",
146264
+ prompt: `### Checklist
146265
+
146266
+ 1. **checkout**: call \`${t("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.
146267
+
146268
+ 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 \`${t("get_pull_request")}\` and other read-only GitHub tools for additional context if needed.
146269
+
146270
+ 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.
146271
+
146272
+ "Genuinely trivial" (skip):
146273
+ - single-word doc typo, whitespace/format-only, comment-only across any number of files
146274
+ - lockfile or generated-code regeneration (size of diff is irrelevant \u2014 read the *shape*)
146275
+ - mechanical rename whose only effect is import-path updates
146276
+ - low-risk dep patch bump
146277
+
146278
+ "Looks trivial but isn't" (do **NOT** skip \u2014 small diff, big blast radius):
146279
+ - any 1-line change to SQL / regex / auth / billing / permission / signature-verification code
146280
+ - flipping a feature-flag default, default config value, or retry/timeout constant
146281
+ - changing a money/tax/currency/fee constant by any amount
146282
+ - changing an HTTP method, redirect URL, response code, or status enum
146283
+ - tightening or loosening a comparison operator (\`<\` \u2194 \`<=\`, \`==\` \u2194 \`!=\`)
146284
+ - renaming a public API surface (still trivial in shape, but needs an impact lens)
146285
+ - adding a new direct dependency (supply-chain surface)
146286
+ - any "typo fix" in user-facing copy that changes meaning ("approved" \u2192 "denied")
146287
+ - mixed diffs where a semantic 1-liner is buried in whitespace/formatting changes
146288
+
146289
+ 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.
146290
+
146291
+ 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:
146292
+
146293
+ - **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)
146294
+ - **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)
146295
+ - **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)
146296
+ - **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.
146297
+
146298
+ lenses come in two flavors, and you can mix them:
146299
+ - **themed lenses** \u2014 a perspective applied across the whole diff (correctness, security, user-journey, performance, etc.).
146300
+ - **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.
146301
+
146302
+ starter menu (combine, omit, or invent your own):
146303
+ - **correctness & invariants** \u2014 bugs, races, error handling, edge cases, state-machine boundaries
146304
+ - **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
146305
+ - **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.
146306
+ - **security** \u2014 new endpoints, authZ, input validation, secrets handling, replay/CSRF/injection, cross-tenant isolation
146307
+ - **user-journey** \u2014 UX-touching flows: walk through happy path and failure modes as a user
146308
+ - **operational readiness** \u2014 observability, alerting, migrations (forward + rollback), feature flags, on-call burden
146309
+ - **integration & cross-cutting** \u2014 API contracts between modules, backward-compat of public surfaces, multi-service ordering
146310
+ - **test integrity** \u2014 meaningful coverage for the changed behavior; deterministic; no shared-state pollution
146311
+ - **performance** \u2014 N+1 queries, hot-path allocation, latency budgets, index coverage
146312
+ - **holistic** \u2014 does the PR make sense as a whole? symmetric flows (delete for every create, rollback for every migration)?
146313
+ - **subsystem lenses** (invent as the PR demands) \u2014 auth, billing, payments, schema migration, webhooks, secrets, RBAC, multi-tenant isolation, cron/scheduling, etc.
146314
+
146315
+ 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:
146316
+ - the diff path / target \u2014 reading the diff and the codebase is its job
146317
+ - **only one lens** \u2014 never a multi-section "review for X, Y, and Z" prompt
146318
+ - **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\`.
146319
+ - 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.
146320
+ - 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."
146321
+ - 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.
146322
+
146323
+ delegation discipline:
146324
+ - 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)
146325
+ - do NOT summarize the PR for them (biases toward a validation frame)
146326
+ - do NOT hand them a curated reading list (let them discover scope)
146327
+ - do NOT pre-shape their output with a finding schema
146328
+ - do NOT mention the other lenses (independence is the point \u2014 overlapping findings are a strong signal)
146329
+
146330
+ 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.
146331
+
146332
+ 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.
146333
+
146334
+ 5. **submit**: ALWAYS submit exactly one review via \`${t("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.
146335
+
146336
+ 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.
146337
+
146338
+ 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.
146339
+
146340
+ - **critical issues** (blocks merge \u2014 bugs, security, data loss):
146341
+ \`approved: false\`. Body opens with \`> [!CAUTION]\\n> This PR introduces ...\`, followed by the PR summary. Include all inline comments via \`comments\`.
146342
+ - **recommended changes** (non-critical):
146343
+ \`approved: false\`. Body opens with \`> [!IMPORTANT]\\n> Consider ...\`, followed by the PR summary. Include all inline comments via \`comments\`.
146344
+ - **no actionable issues**:
146345
+ \`approved: true\`. Body opens with \`No new issues found.\` followed by the PR summary.
146346
+
146347
+ ${PR_SUMMARY_FORMAT}`
146348
+ },
146349
+ // IncrementalReview shares Review's multi-lens orchestrator pattern but
146350
+ // scopes the target to the incremental diff. The "issues must be NEW
146351
+ // since the last Pullfrog review" filter lives at aggregation time
146352
+ // (step 5), NOT in the subagent prompt — pushing the filter into
146353
+ // subagents matches the canonical anneal anti-pattern of "list known
146354
+ // pre-existing failures — don't flag these" and suppresses signal on
146355
+ // regressions the new commits amplified. The review body is just
146356
+ // "Reviewed changes" — a separate "Prior review feedback" checklist
146357
+ // would duplicate the rolling PR summary snapshot's record of what
146358
+ // earlier runs already addressed and add noise to the user-facing
146359
+ // body. Same severity-table omission as Review.
146360
+ {
146361
+ name: "IncrementalReview",
146362
+ description: "Re-review a PR after new commits are pushed; focus on new changes since the last review",
146363
+ prompt: `### Checklist
146364
+
146365
+ 1. **checkout**: call \`${t("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.
146366
+
146367
+ 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.
146368
+
146369
+ 3. **prior feedback**: fetch previous reviews via \`${t("list_pull_request_reviews")}\`. for the most recent Pullfrog review, call \`${t("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.
146370
+
146371
+ 4. **triage & fan out**: orient on the *incremental* changes \u2014 domain, seams, external contracts, user-facing surfaces.
146372
+
146373
+ 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).
146374
+
146375
+ "Genuinely trivial" (skip): formatting/comment tweaks, import reordering, lockfile regen, mechanical rename of import paths, whitespace-only.
146376
+ "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.
146377
+ When unsure, treat as non-trivial.
146378
+
146379
+ 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.
146380
+
146381
+ 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:
146382
+ - 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
146383
+ - **only one lens** \u2014 never a multi-section "review for X, Y, and Z" prompt
146384
+ - **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\`.
146385
+ - 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.
146386
+ - 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."
146387
+ - ask the subagent to report findings with file paths and NEW line numbers from the full PR diff so you can anchor inline comments.
146388
+
146389
+ delegation discipline:
146390
+ - do NOT lens-review the diff yourself in parallel with the subagents
146391
+ - do NOT summarize the changes for them (biases toward validation frame)
146392
+ - do NOT hand them a curated reading list (let them discover scope)
146393
+ - do NOT pre-shape their output with a finding schema
146394
+ - do NOT mention the other lenses (independence is the point)
146395
+
146396
+ 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 \`${t("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.
146397
+
146398
+ 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.
146399
+
146400
+ 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:
146401
+ - 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.
146402
+ - 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.
146403
+ - ELSE IF NEW CRITICAL ISSUES (blocks merge): call \`${t("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.
146404
+ - ELSE IF NEW RECOMMENDED CHANGES (non-critical): call \`${t("create_pull_request_review")}\` with \`approved: false\`, all comments, and the review body. body opens with \`> [!IMPORTANT]\\n> ...\` alert, then the Reviewed-changes summary.
146405
+ - ELSE IF NO NEW ISSUES, SUBSTANTIVE CHANGES (new functionality, behavior changes, or fixes to prior review feedback): call \`${t("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.`
146406
+ },
146407
+ {
146408
+ name: "Plan",
146409
+ description: "Create plans, break down tasks, outline steps, analyze requirements, understand scope of work, or provide task breakdowns",
146410
+ prompt: `### Checklist
146411
+
146412
+ 1. Analyze the task and gather context:
146413
+ - read AGENTS.md and relevant codebase files
146414
+ - understand the architecture and constraints
146415
+
146416
+ 2. Produce a structured, actionable plan with clear milestones.
146417
+
146418
+ 3. Call \`${t("report_progress")}\` with the plan.
146419
+
146420
+ ${learningsStep(t, 4)}`
146421
+ },
146422
+ {
146423
+ name: "Fix",
146424
+ description: "Fix CI failures; debug failing tests or builds; investigate and resolve check suite failures",
146425
+ prompt: `### Checklist
146426
+
146427
+ 1. Checkout the PR branch via \`${t("checkout_pr")}\`.
146428
+
146429
+ 2. Fetch check suite logs via \`${t("get_check_suite_logs")}\`.
146430
+
146431
+ 3. **CRITICAL**: verify the failure was INTRODUCED BY THIS PR before fixing. If unrelated, abort and report.
146432
+
146433
+ 4. Diagnose and fix:
146434
+ - read the workflow file, reproduce locally with the EXACT same commands CI runs
146435
+ - fix the issue using your native file and shell tools
146436
+ - verify the fix by re-running the exact CI command
146437
+ - 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.
146438
+ - commit locally via shell (\`git add . && git commit -m "..."\`)
146439
+
146440
+ 5. Finalize:
146441
+ - confirm a clean working tree, then push via \`${t("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
146442
+ - call \`${t("report_progress")}\` with the diagnosis and fix summary (or the exact push error if push failed)
146443
+
146444
+ ${learningsStep(t, 6)}`
146445
+ },
146446
+ {
146447
+ name: "ResolveConflicts",
146448
+ description: "Resolve merge conflicts in a PR branch against the base branch",
146449
+ prompt: `### Checklist
146450
+
146451
+ 1. **Setup**:
146452
+ - Call \`${t("checkout_pr")}\` to get the PR branch.
146453
+ - Call \`${t("get_pull_request")}\` to identify the base branch (e.g., 'main').
146454
+ - Call \`${t("git_fetch")}\` to fetch the base branch.
146455
+
146456
+ 2. **Merge Attempt**:
146457
+ - Run \`git merge origin/<base_branch>\` via shell.
146458
+ - If it succeeds automatically, confirm a clean working tree, push via \`${t("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*), and call \`${t("report_progress")}\` with a brief success note or the exact push error if push failed \u2014 **then stop; do not run steps 3\u20134.**
146459
+ - If it fails (conflicts), resolve them manually (continue to steps 3\u20134).
146460
+
146461
+ 3. **Resolve Conflicts**:
146462
+ - Run \`git status\` or parse the merge output to find the list of conflicting files.
146463
+ - 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.
146464
+ - Verify the file syntax is correct after resolution.
146465
+
146466
+ 4. **Finalize**:
146467
+ - Run a final verification (build/test) to ensure the resolution works.
146468
+ - \`git add . && git commit -m "resolve merge conflicts"\`
146469
+ - confirm a clean working tree, then push via \`${t("push_branch")}\` (same push/prepush guidance as Build mode in *SYSTEM*)
146470
+ - Call \`${t("report_progress")}\` with a summary of what was resolved (or the exact push error if push failed)`
146471
+ },
146472
+ {
146473
+ name: "Task",
146474
+ description: "General-purpose tasks that don't fit other modes: answering questions, adding comments, labeling, running ad-hoc commands, or any direct request",
146475
+ prompt: `### Checklist
146476
+
146477
+ 1. Analyze the task. For simple operations (labeling, commenting, answering questions, running a single command), handle directly.
146478
+
146479
+ 2. For substantial work \u2014 code changes across multiple files, multi-step investigations:
146480
+ - plan your approach before starting
146481
+ - use native file and shell tools for local operations
146482
+ - use ${pullfrogMcpName} MCP tools for GitHub/git operations
146483
+ - 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
146484
+
146485
+ 3. Finalize:
146486
+ - if code changes were made, push to a pull request (new or existing) using \`${t("push_branch")}\` and \`${t("create_pull_request")}\` as needed. \`git status\` must be clean before you finish (see *SYSTEM* Git rules if push fails).
146487
+ - call \`${t("report_progress")}\` once with results \u2014 include exact tool errors if push or PR creation failed
146488
+ - if the task involved labeling, commenting, or other GitHub operations, perform those directly
146489
+
146490
+ ${learningsStep(t, 4)}`
146491
+ }
146492
+ ];
146493
+ }
146494
+ var modes = computeModes("opencode");
146495
+
146507
146496
  // agents/claude.ts
146508
146497
  import { execFileSync as execFileSync3 } from "node:child_process";
146509
146498
  import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync7 } from "node:fs";
@@ -146596,20 +146585,34 @@ async function installFromNpmTarball(params) {
146596
146585
  }
146597
146586
 
146598
146587
  // utils/providerErrors.ts
146588
+ var statusKey = `\\b(?:status[_ ]?code|http[_ ]?status|status)["']?\\s*[:=]\\s*["']?`;
146599
146589
  var PROVIDER_ERROR_PATTERNS = [
146600
- { pattern: "429", label: "rate limited (429)" },
146601
- { pattern: "RESOURCE_EXHAUSTED", label: "quota exhausted" },
146602
- { pattern: "quota", label: "quota error" },
146603
- { pattern: "status: 500", label: "provider 500 error" },
146604
- { pattern: "INTERNAL", label: "provider internal error" },
146605
- { pattern: "status: 503", label: "provider unavailable (503)" },
146606
- { pattern: "UNAVAILABLE", label: "provider unavailable" },
146607
- { pattern: "rate limit", label: "rate limited" },
146608
- { pattern: "limit: 0", label: "zero quota" }
146590
+ { regex: new RegExp(`${statusKey}429\\b`, "i"), label: "rate limited (429)" },
146591
+ { regex: new RegExp(`${statusKey}500\\b`, "i"), label: "provider 500 error" },
146592
+ { regex: new RegExp(`${statusKey}503\\b`, "i"), label: "provider unavailable (503)" },
146593
+ // matches `rate limit`, `rate limited`, `rate limits exceeded`,
146594
+ // `rate_limit_error`, `rate_limit_exceeded`. the leading `\b` + `[_ ]`
146595
+ // separator rejects `x-ratelimit-*` / `anthropic-ratelimit-*` response
146596
+ // headers (no separator between "rate" and "limit") which routinely
146597
+ // appear in dumped 401 / 4xx error JSON.
146598
+ { regex: /\brate[_ ]limit/i, label: "rate limited" },
146599
+ { regex: /\bRESOURCE_EXHAUSTED\b/, label: "quota exhausted" },
146600
+ // Google gRPC `INTERNAL` status. word-boundary anchors reject
146601
+ // `INTERNAL_SERVER_ERROR` (HTTP 500 message that may appear in unrelated
146602
+ // log lines) and identifiers like `INTERNALS`.
146603
+ { regex: /\bINTERNAL\b/, label: "provider internal error" },
146604
+ { regex: /\bUNAVAILABLE\b/, label: "provider unavailable" },
146605
+ // matches `quota`, `insufficient_quota`, `quota_exceeded`, `quotaExceeded`.
146606
+ // word-character lookarounds would reject `_quota` / `quotaX`; `quota` is
146607
+ // specific enough that a plain substring match is safe.
146608
+ { regex: /quota/i, label: "quota error" },
146609
+ // explicit zero-quota response, e.g. `{"limit": 0}`. the `\b` anchor
146610
+ // around `limit` rejects keys like `time_limit` or `field_limit`.
146611
+ { regex: /["']?\blimit\b["']?\s*:\s*0\b/, label: "zero quota" }
146609
146612
  ];
146610
146613
  function detectProviderError(text) {
146611
146614
  for (const entry of PROVIDER_ERROR_PATTERNS) {
146612
- if (text.includes(entry.pattern)) return entry.label;
146615
+ if (entry.regex.test(text)) return entry.label;
146613
146616
  }
146614
146617
  return null;
146615
146618
  }
@@ -146719,6 +146722,7 @@ var ThinkingTimer = class {
146719
146722
  };
146720
146723
 
146721
146724
  // agents/postRun.ts
146725
+ import { readFile } from "node:fs/promises";
146722
146726
  var MAX_HOOK_OUTPUT_CHARS = 4096;
146723
146727
  function truncateHookOutput(raw2) {
146724
146728
  if (raw2.length <= MAX_HOOK_OUTPUT_CHARS) return raw2;
@@ -146763,6 +146767,23 @@ function buildStopHookPrompt(failure) {
146763
146767
  "```"
146764
146768
  ].join("\n");
146765
146769
  }
146770
+ async function isSummaryUnchanged(filePath, seed) {
146771
+ try {
146772
+ const current = await readFile(filePath, "utf8");
146773
+ return current === seed;
146774
+ } catch {
146775
+ return false;
146776
+ }
146777
+ }
146778
+ function buildSummaryStalePrompt(filePath) {
146779
+ return [
146780
+ `PR SUMMARY UNTOUCHED \u2014 the rolling PR summary file at \`${filePath}\` is byte-identical to its seed; this run did not edit it.`,
146781
+ "",
146782
+ "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.",
146783
+ "",
146784
+ "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."
146785
+ ].join("\n");
146786
+ }
146766
146787
  async function collectPostRunIssues(params) {
146767
146788
  const issues = {};
146768
146789
  if (params.stopScript) {
@@ -146771,12 +146792,17 @@ async function collectPostRunIssues(params) {
146771
146792
  }
146772
146793
  const status = getGitStatus();
146773
146794
  if (status) issues.dirtyTree = status;
146795
+ if (params.summaryFilePath && params.summarySeed !== void 0) {
146796
+ const stale = await isSummaryUnchanged(params.summaryFilePath, params.summarySeed);
146797
+ if (stale) issues.summaryStale = { filePath: params.summaryFilePath };
146798
+ }
146774
146799
  return issues;
146775
146800
  }
146776
146801
  function buildPostRunPrompt(issues) {
146777
146802
  const parts = [];
146778
146803
  if (issues.stopHook) parts.push(buildStopHookPrompt(issues.stopHook));
146779
146804
  if (issues.dirtyTree) parts.push(buildCommitPrompt(issues.dirtyTree));
146805
+ if (issues.summaryStale) parts.push(buildSummaryStalePrompt(issues.summaryStale.filePath));
146780
146806
  return parts.join("\n\n---\n\n");
146781
146807
  }
146782
146808
  function buildLearningsReflectionPrompt(agentId) {
@@ -146799,9 +146825,15 @@ async function runPostRunRetryLoop(params) {
146799
146825
  let finalIssues = {};
146800
146826
  let gateResumeCount = 0;
146801
146827
  let pendingReflection = params.reflectionPrompt;
146828
+ let summaryStaleNudged = false;
146802
146829
  while (gateResumeCount < MAX_POST_RUN_RETRIES) {
146803
146830
  if (!result.success) break;
146804
- const issues = await collectPostRunIssues({ stopScript: params.stopScript });
146831
+ const issues = await collectPostRunIssues({
146832
+ stopScript: params.stopScript,
146833
+ summaryFilePath: summaryStaleNudged ? void 0 : params.summaryFilePath,
146834
+ summarySeed: summaryStaleNudged ? void 0 : params.summarySeed
146835
+ });
146836
+ if (issues.summaryStale) summaryStaleNudged = true;
146805
146837
  finalIssues = issues;
146806
146838
  if (!hasPostRunIssues(issues)) {
146807
146839
  if (!pendingReflection) break;
@@ -146833,8 +146865,17 @@ async function runPostRunRetryLoop(params) {
146833
146865
  }
146834
146866
  log.info(`\xBB post-run retry (attempt ${gateResumeCount + 1}/${MAX_POST_RUN_RETRIES})`);
146835
146867
  const prompt = buildPostRunPrompt(issues);
146868
+ const onlySummaryStale = issues.summaryStale !== void 0 && issues.stopHook === void 0 && issues.dirtyTree === void 0;
146869
+ const preResume = result;
146836
146870
  result = await params.resume({ prompt, previousResult: result });
146837
146871
  aggregatedUsage = mergeAgentUsage(aggregatedUsage, result.usage);
146872
+ if (!result.success && onlySummaryStale) {
146873
+ log.warning(
146874
+ `\xBB summary-stale resume turn failed (${result.error ?? "unknown error"}), preserving prior successful result`
146875
+ );
146876
+ result = preResume;
146877
+ break;
146878
+ }
146838
146879
  gateResumeCount++;
146839
146880
  }
146840
146881
  if (gateResumeCount > 0 && result.success && hasPostRunIssues(finalIssues)) {
@@ -146971,6 +147012,7 @@ async function runClaude(params) {
146971
147012
  const thinkingTimer = new ThinkingTimer();
146972
147013
  let finalOutput = "";
146973
147014
  let sessionId;
147015
+ let resultErrorSubtype = null;
146974
147016
  let accumulatedTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
146975
147017
  let accumulatedCostUsd = 0;
146976
147018
  let tokensLogged = false;
@@ -147074,9 +147116,14 @@ async function runClaude(params) {
147074
147116
  tokensLogged = true;
147075
147117
  }
147076
147118
  } else if (subtype === "error_max_turns") {
147119
+ resultErrorSubtype = subtype;
147077
147120
  log.info(`\xBB ${params.label} max turns reached: ${JSON.stringify(event)}`);
147078
147121
  } else if (subtype === "error_during_execution") {
147122
+ resultErrorSubtype = subtype;
147079
147123
  log.info(`\xBB ${params.label} execution error: ${JSON.stringify(event)}`);
147124
+ } else if (subtype.startsWith("error")) {
147125
+ resultErrorSubtype = subtype;
147126
+ log.info(`\xBB ${params.label} result: subtype=${subtype}, data=${JSON.stringify(event)}`);
147080
147127
  } else {
147081
147128
  log.info(`\xBB ${params.label} result: subtype=${subtype}, data=${JSON.stringify(event)}`);
147082
147129
  }
@@ -147207,6 +147254,15 @@ ${stderrContext}`);
147207
147254
  sessionId
147208
147255
  };
147209
147256
  }
147257
+ if (resultErrorSubtype) {
147258
+ return {
147259
+ success: false,
147260
+ output: finalOutput || output,
147261
+ error: `result subtype: ${resultErrorSubtype}`,
147262
+ usage,
147263
+ sessionId
147264
+ };
147265
+ }
147210
147266
  return { success: true, output: finalOutput || output, usage, sessionId };
147211
147267
  } catch (error49) {
147212
147268
  params.todoTracker?.cancel();
@@ -147335,6 +147391,8 @@ var claude = agent({
147335
147391
  initialResult: result,
147336
147392
  initialUsage: result.usage,
147337
147393
  stopScript: ctx.stopScript,
147394
+ summaryFilePath: ctx.summaryFilePath,
147395
+ summarySeed: ctx.summarySeed,
147338
147396
  reflectionPrompt: buildLearningsReflectionPrompt("claude"),
147339
147397
  canResume: (r) => Boolean(r.sessionId),
147340
147398
  resume: async (c) => {
@@ -147668,6 +147726,12 @@ async function runOpenCode(params) {
147668
147726
  log.debug(withLabel(label, `tool output: ${outputStr}`));
147669
147727
  }
147670
147728
  },
147729
+ error: (event) => {
147730
+ agentErrorEvent = event;
147731
+ const errorName = event.error?.name || "unknown";
147732
+ const errorMessage = event.error?.data?.message || event.error?.name || JSON.stringify(event);
147733
+ log.info(`\xBB ${params.label} error event: ${errorName}: ${errorMessage}`);
147734
+ },
147671
147735
  result: async (event) => {
147672
147736
  const status = event.status || "unknown";
147673
147737
  const duration4 = event.stats?.duration_ms || 0;
@@ -147688,6 +147752,7 @@ async function runOpenCode(params) {
147688
147752
  };
147689
147753
  const recentStderr = [];
147690
147754
  let lastProviderError = null;
147755
+ let agentErrorEvent = null;
147691
147756
  let output = "";
147692
147757
  let stdoutBuffer = "";
147693
147758
  try {
@@ -147806,6 +147871,17 @@ ${stderrContext}`);
147806
147871
  usage
147807
147872
  };
147808
147873
  }
147874
+ if (agentErrorEvent) {
147875
+ const errorEvent = agentErrorEvent;
147876
+ const errorName = errorEvent.error?.name || "agent error";
147877
+ const errorMessage = errorEvent.error?.data?.message || errorEvent.error?.name || JSON.stringify(errorEvent);
147878
+ return {
147879
+ success: false,
147880
+ output: finalOutput || output,
147881
+ error: `${errorName}: ${errorMessage}`,
147882
+ usage
147883
+ };
147884
+ }
147809
147885
  return { success: true, output: finalOutput || output, usage };
147810
147886
  } catch (error49) {
147811
147887
  params.todoTracker?.cancel();
@@ -147881,6 +147957,8 @@ var opencode = agent({
147881
147957
  initialResult: result,
147882
147958
  initialUsage: result.usage,
147883
147959
  stopScript: ctx.stopScript,
147960
+ summaryFilePath: ctx.summaryFilePath,
147961
+ summarySeed: ctx.summarySeed,
147884
147962
  reflectionPrompt: buildLearningsReflectionPrompt("opencode"),
147885
147963
  resume: async (c) => runOpenCode({
147886
147964
  ...runParams,
@@ -152427,7 +152505,7 @@ When embedding images (e.g. uploaded screenshots) in comments or PR bodies, alwa
152427
152505
 
152428
152506
  **\`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.
152429
152507
 
152430
- 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).
152508
+ 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).
152431
152509
 
152432
152510
  ### If you get stuck
152433
152511
 
@@ -152591,7 +152669,8 @@ var JsonPayload = type({
152591
152669
  "progressComment?": type({
152592
152670
  id: "string",
152593
152671
  type: "'issue' | 'review'"
152594
- }).or("undefined")
152672
+ }).or("undefined"),
152673
+ "generateSummary?": "boolean | undefined"
152595
152674
  });
152596
152675
  var COLLABORATOR_PERMISSIONS = ["admin", "maintain", "write"];
152597
152676
  function isCollaborator(event) {
@@ -152674,6 +152753,7 @@ function resolvePayload(resolvedPromptInput, repoSettings) {
152674
152753
  timeout: inputs.timeout ?? jsonPayload?.timeout,
152675
152754
  cwd: resolveCwd(inputs.cwd),
152676
152755
  progressComment: jsonPayload?.progressComment,
152756
+ generateSummary: jsonPayload?.generateSummary,
152677
152757
  // permissions: inputs > repoSettings > fallbacks
152678
152758
  push: inputs.push ?? repoSettings.push ?? "restricted",
152679
152759
  shell: resolvedShell,
@@ -152682,6 +152762,40 @@ function resolvePayload(resolvedPromptInput, repoSettings) {
152682
152762
  };
152683
152763
  }
152684
152764
 
152765
+ // utils/prSummary.ts
152766
+ import { mkdir, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
152767
+ import { dirname as dirname4, join as join14 } from "node:path";
152768
+ var SUMMARY_FILE_NAME = "pullfrog-summary.md";
152769
+ var SUMMARY_SCAFFOLD = `# PR summary
152770
+
152771
+ <!-- durable cross-run context. edit in place; the next agent run reads this
152772
+ before reviewing new commits. structure however serves the PR best. -->
152773
+ `;
152774
+ var MIN_SNAPSHOT_LENGTH = 60;
152775
+ var MAX_SNAPSHOT_LENGTH = 32768;
152776
+ function summaryFilePath(tmpdir3) {
152777
+ return join14(tmpdir3, SUMMARY_FILE_NAME);
152778
+ }
152779
+ async function seedSummaryFile(params) {
152780
+ const path3 = summaryFilePath(params.tmpdir);
152781
+ await mkdir(dirname4(path3), { recursive: true });
152782
+ const seed = params.previousSnapshot && params.previousSnapshot.trim().length >= MIN_SNAPSHOT_LENGTH ? params.previousSnapshot : SUMMARY_SCAFFOLD;
152783
+ await writeFile2(path3, seed, "utf8");
152784
+ return path3;
152785
+ }
152786
+ async function readSummaryFile(path3) {
152787
+ let raw2;
152788
+ try {
152789
+ raw2 = await readFile2(path3, "utf8");
152790
+ } catch {
152791
+ return null;
152792
+ }
152793
+ const trimmed = raw2.trim();
152794
+ if (trimmed.length < MIN_SNAPSHOT_LENGTH) return null;
152795
+ if (trimmed.length > MAX_SNAPSHOT_LENGTH) return trimmed.slice(0, MAX_SNAPSHOT_LENGTH);
152796
+ return trimmed;
152797
+ }
152798
+
152685
152799
  // utils/reviewCleanup.ts
152686
152800
  var RE_REVIEW_PREAMBLE = "Incrementally re-review the new commits on this pull request. Use the IncrementalReview mode.";
152687
152801
  async function postReviewCleanup(ctx) {
@@ -152741,11 +152855,16 @@ async function dispatchFollowUpReReview(ctx, reviewedSha) {
152741
152855
  await ctx.octokit.rest.actions.createWorkflowDispatch({
152742
152856
  owner: ctx.repo.owner,
152743
152857
  repo: ctx.repo.name,
152744
- workflow_id: "pullfrog.yml",
152858
+ workflow_id: getCurrentWorkflowFilename(),
152745
152859
  ref: pr.data.base.repo.default_branch,
152746
152860
  inputs: { prompt: JSON.stringify(payload) }
152747
152861
  });
152748
152862
  }
152863
+ function getCurrentWorkflowFilename() {
152864
+ const ref = process.env.GITHUB_WORKFLOW_REF ?? "";
152865
+ const match3 = ref.match(/\/([^/]+)@/);
152866
+ return match3?.[1] ?? "pullfrog.yml";
152867
+ }
152749
152868
 
152750
152869
  // utils/run.ts
152751
152870
  async function handleAgentResult(ctx) {
@@ -152885,9 +153004,9 @@ async function resolveRunContextData(params) {
152885
153004
  import { execFileSync as execFileSync5, execSync as execSync3 } from "node:child_process";
152886
153005
  import { mkdtempSync } from "node:fs";
152887
153006
  import { tmpdir as tmpdir2 } from "node:os";
152888
- import { join as join14 } from "node:path";
153007
+ import { join as join15 } from "node:path";
152889
153008
  function createTempDirectory() {
152890
- const sharedTempDir = mkdtempSync(join14(tmpdir2(), "pullfrog-"));
153009
+ const sharedTempDir = mkdtempSync(join15(tmpdir2(), "pullfrog-"));
152891
153010
  process.env.PULLFROG_TEMP_DIR = sharedTempDir;
152892
153011
  log.info(`\xBB created temp dir at ${sharedTempDir}`);
152893
153012
  return sharedTempDir;
@@ -153220,39 +153339,53 @@ var TransientError = class extends Error {
153220
153339
  this.name = "TransientError";
153221
153340
  }
153222
153341
  };
153223
- function formatBillingErrorSummary(error49) {
153342
+ function billingConsoleUrl(owner, anchor) {
153343
+ return `https://pullfrog.com/console/${encodeURIComponent(owner)}#${anchor}`;
153344
+ }
153345
+ function formatBillingErrorSummary(error49, owner) {
153224
153346
  if (error49.code === "router_requires_card") {
153225
153347
  return [
153226
- "### \u26D4 Pullfrog Router requires a card",
153348
+ "**Add a card to start using Pullfrog Router.**",
153227
153349
  "",
153228
- "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.",
153350
+ "Router proxies OpenRouter at raw cost \u2014 no platform markup, and your first $20 of usage is on us.",
153229
153351
  "",
153230
- "[Add a card \u2192](https://pullfrog.com/console#model-access) \u2014 your first $20 of Router usage is free."
153352
+ `[Add a card \u2192](${billingConsoleUrl(owner, "model-access")})`
153231
153353
  ].join("\n");
153232
153354
  }
153233
153355
  if (error49.needsReauthentication) {
153356
+ const code = error49.declineCode ?? "authentication_required";
153234
153357
  return [
153235
- "### \u274C Pullfrog billing error \u2014 card requires 3DS on every charge",
153358
+ `**Your card issuer requires 3D Secure on every charge** (\`${code}\`).`,
153236
153359
  "",
153237
- `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.`,
153360
+ "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.",
153238
153361
  "",
153239
- "[Top up your Router credit balance \u2192](https://pullfrog.com/console)"
153362
+ `[Top up balance \u2192](${billingConsoleUrl(owner, "billing")})`
153240
153363
  ].join("\n");
153241
153364
  }
153242
- const codeSuffix = error49.declineCode ? ` (\`${error49.declineCode}\`)` : "";
153243
- return `### \u274C Pullfrog billing error
153244
-
153245
- ${error49.message}${codeSuffix}
153246
-
153247
- [Manage billing \u2192](https://pullfrog.com/console)`;
153365
+ if (error49.declineCode) {
153366
+ return [
153367
+ `**Your card was declined** (\`${error49.declineCode}\`).`,
153368
+ "",
153369
+ "Update your payment method and Pullfrog will retry on the next run.",
153370
+ "",
153371
+ `[Update payment method \u2192](${billingConsoleUrl(owner, "billing")})`
153372
+ ].join("\n");
153373
+ }
153374
+ return [
153375
+ "**Your Pullfrog balance is empty.**",
153376
+ "",
153377
+ "Top up your balance or enable auto-reload to keep runs flowing.",
153378
+ "",
153379
+ `[Manage billing \u2192](${billingConsoleUrl(owner, "billing")})`
153380
+ ].join("\n");
153248
153381
  }
153249
- function formatTransientErrorSummary(error49) {
153382
+ function formatTransientErrorSummary(error49, owner) {
153250
153383
  return [
153251
- "### \u26A0\uFE0F Pullfrog temporarily unavailable",
153384
+ "**Pullfrog billing is temporarily unavailable.**",
153252
153385
  "",
153253
153386
  error49.message,
153254
153387
  "",
153255
- "This is typically transient \u2014 the next dispatch should succeed. If it persists, check [status.pullfrog.com](https://status.pullfrog.com)."
153388
+ `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")}).`
153256
153389
  ].join("\n");
153257
153390
  }
153258
153391
  async function mintProxyKey(ctx) {
@@ -153313,6 +153446,43 @@ async function resolveProxyModel(ctx) {
153313
153446
  const label = ctx.oss ? "oss" : "router";
153314
153447
  log.info(`\xBB proxy: ${label} \u2192 ${ctx.proxyModel}`);
153315
153448
  }
153449
+ async function fetchPreviousSnapshot(ctx, prNumber) {
153450
+ if (!ctx.githubInstallationToken) return null;
153451
+ try {
153452
+ const response = await apiFetch({
153453
+ path: `/api/repo/${ctx.repo.owner}/${ctx.repo.name}/pr/${prNumber}/summary-comment`,
153454
+ method: "GET",
153455
+ headers: { authorization: `Bearer ${ctx.githubInstallationToken}` },
153456
+ signal: AbortSignal.timeout(1e4)
153457
+ });
153458
+ if (!response.ok) return null;
153459
+ const data = await response.json();
153460
+ return typeof data.snapshot === "string" && data.snapshot.length > 0 ? data.snapshot : null;
153461
+ } catch {
153462
+ return null;
153463
+ }
153464
+ }
153465
+ async function persistSummary(ctx) {
153466
+ const filePath = ctx.toolState.summaryFilePath;
153467
+ if (!filePath) return;
153468
+ if (ctx.toolState.summaryPersistAttempted) return;
153469
+ ctx.toolState.summaryPersistAttempted = true;
153470
+ const snapshot2 = await readSummaryFile(filePath);
153471
+ if (!snapshot2) {
153472
+ log.debug(`pr summary tmpfile missing or invalid at ${filePath} \u2014 skipping persist`);
153473
+ return;
153474
+ }
153475
+ const seed = ctx.toolState.summarySeed?.trim();
153476
+ if (seed !== void 0 && snapshot2 === seed) {
153477
+ log.warning(
153478
+ "\xBB pr summary tmpfile unchanged from seed \u2014 skipping persist (agent did not edit it)"
153479
+ );
153480
+ return;
153481
+ }
153482
+ await patchWorkflowRunFields(ctx, { summarySnapshot: snapshot2 }).catch((err) => {
153483
+ log.debug(`pr summary persist failed: ${err instanceof Error ? err.message : String(err)}`);
153484
+ });
153485
+ }
153316
153486
  async function writeJobSummary(toolState) {
153317
153487
  const usageSummary = formatUsageSummary(toolState.usageEntries);
153318
153488
  const summaryParts = [toolState.lastProgressBody, usageSummary].filter(Boolean);
@@ -153377,7 +153547,7 @@ async function main() {
153377
153547
  });
153378
153548
  } catch (error49) {
153379
153549
  if (error49 instanceof BillingError) {
153380
- const summary2 = formatBillingErrorSummary(error49);
153550
+ const summary2 = formatBillingErrorSummary(error49, runContext.repo.owner);
153381
153551
  await writeSummary(summary2).catch(() => {
153382
153552
  });
153383
153553
  await reportErrorToComment({ toolState, error: summary2 }).catch(() => {
@@ -153385,7 +153555,7 @@ async function main() {
153385
153555
  throw error49;
153386
153556
  }
153387
153557
  if (error49 instanceof TransientError) {
153388
- const summary2 = formatTransientErrorSummary(error49);
153558
+ const summary2 = formatTransientErrorSummary(error49, runContext.repo.owner);
153389
153559
  await writeSummary(summary2).catch(() => {
153390
153560
  });
153391
153561
  await reportErrorToComment({ toolState, error: summary2 }).catch(() => {
@@ -153475,6 +153645,20 @@ async function main() {
153475
153645
  toolContext.mcpServerUrl = mcpHttpServer.url;
153476
153646
  log.info(`\xBB MCP server started at ${mcpHttpServer.url}`);
153477
153647
  timer.checkpoint("mcpServer");
153648
+ if (payload.generateSummary && payload.event.is_pr && payload.event.issue_number) {
153649
+ const previousSnapshot = await fetchPreviousSnapshot(toolContext, payload.event.issue_number);
153650
+ const filePath = await seedSummaryFile({ tmpdir: tmpdir3, previousSnapshot });
153651
+ toolState.summaryFilePath = filePath;
153652
+ try {
153653
+ toolState.summarySeed = await readFile3(filePath, "utf8");
153654
+ } catch {
153655
+ }
153656
+ log.info(
153657
+ `\xBB summary snapshot seeded at ${filePath} (previous=${previousSnapshot ? "yes" : "no"})`
153658
+ );
153659
+ const ctxForExit = toolContext;
153660
+ onExitSignal(() => persistSummary(ctxForExit));
153661
+ }
153478
153662
  startInstallation(toolContext);
153479
153663
  const modelForLog = resolveModelForLog({ payload, resolvedModel });
153480
153664
  const agentForLog = resolveAgentForLog({ agentName: agent2.name, resolvedModel });
@@ -153506,7 +153690,7 @@ ${instructions.user}` : null,
153506
153690
  log.info(instructions.full);
153507
153691
  });
153508
153692
  if (agentId === "opencode") {
153509
- const pluginDir = join15(process.cwd(), ".opencode", "plugin");
153693
+ const pluginDir = join16(process.cwd(), ".opencode", "plugin");
153510
153694
  const hasPlugins = existsSync7(pluginDir) && readdirSync(pluginDir).some((f) => /\.[jt]sx?$/.test(f));
153511
153695
  if (hasPlugins && toolState.dependencyInstallation?.promise) {
153512
153696
  log.info(
@@ -153565,6 +153749,8 @@ ${instructions.user}` : null,
153565
153749
  instructions,
153566
153750
  todoTracker,
153567
153751
  stopScript: runContext.repoSettings.stopScript,
153752
+ summaryFilePath: toolState.summaryFilePath,
153753
+ summarySeed: toolState.summarySeed,
153568
153754
  onActivityTimeout: onInnerActivityTimeout,
153569
153755
  onToolUse: (event) => {
153570
153756
  const wasTracked = recordDiffReadFromToolUse({
@@ -153619,8 +153805,10 @@ ${instructions.user}` : null,
153619
153805
  log.debug(`post-review cleanup failed: ${error49}`);
153620
153806
  });
153621
153807
  }
153622
- const trackerWasLastWriter = todoTracker?.hasPublished && !toolState.finalSummaryWritten;
153623
- if (toolContext && toolState.progressComment && (!toolState.wasUpdated || trackerWasLastWriter)) {
153808
+ if (toolContext) {
153809
+ await persistSummary(toolContext);
153810
+ }
153811
+ if (toolContext && toolState.progressComment && !toolState.finalSummaryWritten) {
153624
153812
  await deleteProgressComment(toolContext).catch((error49) => {
153625
153813
  log.debug(`stranded progress comment cleanup failed: ${error49}`);
153626
153814
  });
@@ -153667,6 +153855,9 @@ ${errorMessage}
153667
153855
  log.debug(`post-review cleanup failed: ${error50}`);
153668
153856
  });
153669
153857
  }
153858
+ if (toolContext) {
153859
+ await persistSummary(toolContext);
153860
+ }
153670
153861
  return {
153671
153862
  success: false,
153672
153863
  error: errorMessage