diff --git a/apps/claude-code/pr-review/CONTEXT.md b/apps/claude-code/pr-review/CONTEXT.md index ca2c8f8..35266a2 100644 --- a/apps/claude-code/pr-review/CONTEXT.md +++ b/apps/claude-code/pr-review/CONTEXT.md @@ -77,6 +77,34 @@ _Avoid_: merger, aggregator, deduplicator A self-contained plugin agent that orchestrates the entire Doc Context gathering phase — fetching work item details, running the Confluence credential check once, spawning Work Item Summarizer and Confluence Fetcher agents in parallel, and delegating final synthesis to the Doc Context Synthesizer. Returns the Synthesizer's output verbatim as a plain markdown string. _Avoid_: context orchestrator, doc orchestrator, gathering agent +### Operating modes + +**Pre-PR mode**: +A Review run without a PR URL, targeting a local branch diff. No ADO write-back occurs; findings are presented in the Claude interface only. +_Avoid_: local review, offline review, draft review + +**First-review mode**: +A Review run against an ADO PR where no prior Bot Signature is found. Produces a full set of Inline Comments and a Review Summary posted to ADO. +_Avoid_: initial review, fresh review + +**Re-review mode**: +A Review run against an ADO PR where a prior **Bot Signature** is found in the PR's threads. Focuses on commits since the last Review, performs Thread Classification, and replies to or resolves existing Review Threads rather than duplicating them. +_Avoid_: incremental review, follow-up review, second pass + +### Orchestration agents + +**ADO Fetcher**: +A plugin agent that retrieves PR metadata, iterations, changed files, and the raw diff from Azure DevOps. Used by first-review and re-review modes; not invoked in pre-PR mode. +_Avoid_: fetcher, data agent, ADO client + +**Re-review Coordinator**: +A plugin agent that owns the full re-review state machine — prior thread detection, partial-run check, Thread Classification, finding matching, and reply posting to classified threads. Invoked only in re-review mode. +_Avoid_: re-review agent, rereview handler + +**ADO Writer**: +A plugin agent responsible for all ADO write-back operations — posting Inline Comments, patching thread status, and posting the Review Summary or delta reply. Used by first-review and re-review modes. +_Avoid_: writer agent, comment poster, ADO publisher + ### Re-review classification **Thread Classification**: @@ -106,6 +134,9 @@ A Thread Classification state. The relevant code was deleted or moved; the comme - A **Doc Context** is assembled via a three-tier pipeline: the **Doc Context Orchestrator** spawns **Work Item Summarizer** and **Confluence Fetcher** agents (Doc Context Sub-agents) in parallel, then delegates their outputs to the **Doc Context Synthesizer**, which produces the final `DOC_CONTEXT` narrative injected into every Review Aspect agent - A **Doc Context Sub-agent** operates on a single source (work item or Confluence page) and receives the changed files list and the local diff when available - The **Doc Context Orchestrator** returns the **Doc Context Synthesizer**'s output verbatim; it does not rewrite or reformat the narrative +- The **ADO Fetcher** is invoked by first-review and re-review modes; **Pre-PR mode** skips it entirely and goes directly to Review Aspect agents +- The **Re-review Coordinator** is invoked only when the mode is re-review; first-review and pre-PR modes never load it +- The **ADO Writer** is invoked by first-review and re-review modes; **Pre-PR mode** does not write back to ADO ## Example dialogue diff --git a/apps/claude-code/pr-review/docs/adr/0013-orchestrator-split-for-review-pr.md b/apps/claude-code/pr-review/docs/adr/0013-orchestrator-split-for-review-pr.md new file mode 100644 index 0000000..1a8ebd8 --- /dev/null +++ b/apps/claude-code/pr-review/docs/adr/0013-orchestrator-split-for-review-pr.md @@ -0,0 +1,57 @@ +# 0013. Split review-pr.md into a thin orchestrator and focused agents + +**Status:** Accepted (2026-05) + +## Context + +`review-pr.md` has grown to ~1000 lines as the re-review state machine, ADO write-back logic, and doc-context orchestration were added. This creates two compounding problems: + +1. **Token budget pressure.** The full command file is loaded into the parent context on every invocation. Combined with tool-call results flowing back from parallel review agents, average PR reviews reach +100 K tokens — unsustainable as the command grows further. + +2. **Growth risk.** A pre-PR mode (review without opening a PR) is an emerging user request. Adding a third operating mode to the current monolith would push the file toward ~1300 lines and worsen the token problem. + +The root cause is architectural: `review-pr.md` conflates orchestration (which mode are we in? what agents to launch?) with platform integration (fetch ADO threads, post inline comments) and re-review state management (classify threads, match findings, reply). + +The GitHub PR review workflow (`.claude/prompts/pr-review-workflow.prompt.md`) solves the same orchestration problem in ~80 lines by staying a thin coordinator and delegating everything else to focused agents. That pattern is the right model for `review-pr.md`. + +## Decision + +Refactor `review-pr.md` into a **thin orchestrator** of ~200 lines that: + +1. Validates prerequisites and parses the PR URL (or detects absence of URL for pre-PR mode). +2. Detects the operating mode: **pre-PR**, **first-review**, or **re-review**. +3. Delegates immediately to a focused agent per mode. + +Three focused agents live in the plugin's `.agents/` directory (not in `pr-review-toolkit`, which is a read-only dependency): + +- **`pr-review:ado-fetcher`** — fetches PR metadata, iterations, changed files, and raw diff from ADO. Used by first-review and re-review modes. +- **`pr-review:re-review-coordinator`** — owns Steps 3.5–10-Path-B: prior thread detection, partial-run check, thread classification, finding matching, and reply posting to classified threads. Used only in re-review mode. +- **`pr-review:ado-writer`** — owns the ADO write-back pipeline: posting inline threads, patching thread status, and posting the summary comment. Used by first-review and re-review modes. + +Pre-PR mode skips the ADO fetcher and writer entirely; it goes straight from the orchestrator to the `pr-review-toolkit` review agents and presents findings locally. + +**Compact sub-agent output.** Review agents (`pr-review-toolkit:code-reviewer`, etc.) are asked via the Step 8 prompt in `review-pr.md` to return structured findings (`severity`, `filePath`, `startLine`, `endLine`, `title`, `body`) rather than prose with embedded code quotes. This keeps what flows back into the parent context small. This guidance stays in `review-pr.md`'s prompt, not in the toolkit agent definitions, because `pr-review-toolkit` is not owned by this plugin. + +**Re-review logic ownership.** The four Node.js modules in `scripts/re-review/` are already algorithmically platform-agnostic; only their input shapes are ADO-specific. When a second write-back platform (GitHub) is built, normalising to a canonical thread shape and lifting these modules to `pr-review-toolkit` is the correct move. That work is deferred until a second platform consumer exists. + +**Alternatives considered:** + +_Keep the monolith_ — continue adding to `review-pr.md`. Rejected because the token budget problem compounds with each new feature, and the pre-PR mode would require significant branching inside an already large file. + +_Lift re-review modules to pr-review-toolkit now_ — move the four Node.js modules to the toolkit as shared library code. Rejected because there is no second platform consumer yet; any canonical thread schema designed now would be speculative and likely wrong. + +_Option B: re-review coordinator as a procedural agent_ — keep re-review logic in a dedicated agent that reasons about edge cases rather than pure procedural code. Accepted in part: the `pr-review:re-review-coordinator` agent replaces the procedural inline steps, but the four Node.js modules remain as pure functions called from it. + +## Consequences + +- The parent context for a first-review or pre-PR run no longer loads re-review logic. +- Each focused agent only receives the context it needs; intermediate state (prior threads JSON, classification results, diff hunks) does not accumulate in the orchestrator context. +- Adding a fourth operating mode (e.g. post-merge audit) requires only a new agent plus a new branch in the ~200-line orchestrator. +- The three new agents must be documented in the plugin's `CONTEXT.md` under the appropriate relationship entries. + +**See also:** + +- `docs/issues/pr-review-orchestrator-split/PRD.md` for the feature PRD and implementation issues that deliver this split +- ADR 0008 (soft dependency on `pr-review-toolkit`) +- `.claude/prompts/pr-review-workflow.prompt.md` (the GitHub orchestrator pattern this + mirrors) diff --git a/docs/issues/pr-review-orchestrator-split/01-create-ado-fetcher-agent.md b/docs/issues/pr-review-orchestrator-split/01-create-ado-fetcher-agent.md new file mode 100644 index 0000000..ec854cf --- /dev/null +++ b/docs/issues/pr-review-orchestrator-split/01-create-ado-fetcher-agent.md @@ -0,0 +1,65 @@ +# Create ADO Fetcher agent + +**Status:** ready-for-agent +**Category:** enhancement + +## Parent + +`docs/issues/pr-review-orchestrator-split/PRD.md` + +## What to build + +Create a new plugin agent (`pr-review:ado-fetcher`) that encapsulates all Azure DevOps read operations required for a PR review. The agent receives a PR URL (org, project, PR ID) and returns a structured context block containing: PR metadata (title, description, source/target branches, repo ID), latest iteration ID and its commit SHA, prior commit SHA (passed in for re-review, empty for first-review), changed files list, raw diff, and work-item IDs linked to the PR. + +This agent replaces the inline ADO shell commands currently scattered across Steps 2–5 of the `review-pr` command. It is invoked by first-review and re-review modes; pre-PR mode never calls it. + +The ADO Fetcher and the Doc Context Orchestrator agent must be invocable concurrently — the ADO Fetcher provides the work-item IDs that the Doc Context Orchestrator needs, so the Fetcher runs first, but the Fetcher and Doc Context Orchestrator may overlap in wall-clock time. + +## Acceptance criteria + +- [ ] The agent accepts PR URL components (org URL, project, PR ID) and returns a structured context block +- [ ] The context block includes PR metadata, latest iteration ID, latest commit SHA, changed files list, and raw diff +- [ ] The context block includes the work-item IDs linked to the PR (empty list if none) +- [ ] The agent handles the case where no iterations are returned (defaults gracefully) +- [ ] The agent handles PRs that are already merged (continues without error) +- [ ] The agent contains no write operations — it is purely a read agent + +## Blocked by + +None — can start immediately. + +--- + +## Agent Brief + +> _This was generated by AI during triage._ + +**Category:** enhancement +**Summary:** Create the `pr-review:ado-fetcher` agent that encapsulates all ADO read operations for a PR review. + +**Current behavior:** +ADO read operations (PR metadata, iterations, changed files, diff, work-item IDs) are scattered as inline `az devops invoke` shell commands across multiple steps of the `review-pr` command. There is no dedicated agent for this concern. + +**Desired behavior:** +A new plugin agent (`pr-review:ado-fetcher`) accepts PR URL components and returns a single structured context block. All other agents and the orchestrator consume this block rather than making their own ADO calls. The agent is purely read-only — it performs no write operations. + +**Key interfaces:** + +- Input: org URL, project, PR ID, optional prior commit SHA (passed in for re-review) +- Output: structured context block — PR metadata, latest iteration ID, latest commit SHA, changed files list, raw diff, work-item IDs list +- The agent must handle zero-iteration PRs and already-merged PRs gracefully + +**Acceptance criteria:** + +- [ ] The agent accepts PR URL components and returns a structured context block +- [ ] The context block includes PR metadata, latest iteration ID, latest commit SHA, changed files list, and raw diff +- [ ] The context block includes the work-item IDs linked to the PR (empty list if none) +- [ ] The agent handles the case where no iterations are returned (defaults gracefully) +- [ ] The agent handles PRs that are already merged (continues without error) +- [ ] The agent contains no write operations — it is purely a read agent + +**Out of scope:** + +- Any ADO write operations +- Doc Context fetching (that stays with the Doc Context Orchestrator) +- GitHub or GitLab platform support diff --git a/docs/issues/pr-review-orchestrator-split/02-create-ado-writer-agent.md b/docs/issues/pr-review-orchestrator-split/02-create-ado-writer-agent.md new file mode 100644 index 0000000..813ecab --- /dev/null +++ b/docs/issues/pr-review-orchestrator-split/02-create-ado-writer-agent.md @@ -0,0 +1,72 @@ +# Create ADO Writer agent + +**Status:** ready-for-agent +**Category:** enhancement + +## Parent + +`docs/issues/pr-review-orchestrator-split/PRD.md` + +## What to build + +Create a new plugin agent (`pr-review:ado-writer`) that encapsulates all Azure DevOps write-back operations for a PR review. The agent receives: PR context (org URL, project, repo ID, PR ID, latest iteration ID, summary thread ID), a list of compact findings, and a mode flag (first-review or re-review). + +For each finding it posts a new Inline Comment thread to ADO. After all findings are posted it posts the Review Summary on first-review, or a delta reply to the existing summary thread on re-review. As its final action it posts the completion marker reply to the summary thread. + +The compact finding schema the agent accepts: `{ severity, filePath, startLine, endLine, title, body }`. Every comment posted must end with the canonical Bot Signature trailer `---\n🤖 *Reviewed by Claude Code* — Iteration N`. + +This agent is used by both first-review and re-review modes. It is not invoked in pre-PR mode. + +## Acceptance criteria + +- [ ] The agent posts one Inline Comment thread per finding at the correct file path and line range +- [ ] Each posted comment ends with the canonical Bot Signature including the iteration number +- [ ] On first-review, the agent posts a full Review Summary as a new general thread +- [ ] On re-review with at least one new finding, the agent posts a delta reply to the existing summary thread +- [ ] On re-review with zero new findings, the agent skips the summary reply +- [ ] The agent posts a completion marker reply (`✅ Review complete — Iteration N`) to the summary thread as its final action +- [ ] If `threadContext` is rejected by ADO (file not in diff), the agent retries without `threadContext` (general comment fallback) +- [ ] The agent returns the final `SUMMARY_THREAD_ID` and `FINDINGS_POSTED` count to the caller + +## Blocked by + +None — can start immediately. + +--- + +## Agent Brief + +> _This was generated by AI during triage._ + +**Category:** enhancement +**Summary:** Create the `pr-review:ado-writer` agent that encapsulates all ADO write-back operations for a PR review. + +**Current behavior:** +ADO write operations (posting Inline Comment threads, patching thread status, posting the Review Summary, posting the completion marker) are inline shell commands in `review-pr.md`. There is no dedicated agent for write-back. + +**Desired behavior:** +A new plugin agent (`pr-review:ado-writer`) receives a PR context block, a compact findings list, a mode flag, and an optional existing summary thread ID. It posts all Inline Comments, the Review Summary (or delta reply on re-review), and the completion marker. Every comment ends with the canonical Bot Signature. + +**Key interfaces:** + +- Input: PR context (org URL, project, repo ID, PR ID, latest iteration ID, summary thread ID), findings list as `{ severity, filePath, startLine, endLine, title, body }[]`, mode (`first-review` | `re-review`) +- Output: `{ summaryThreadId, findingsPosted }` returned to the caller +- Bot Signature constant: `🤖 *Reviewed by Claude Code*` prefix — must not change +- On `threadContext` rejection by ADO, retries without `threadContext` (general comment fallback) + +**Acceptance criteria:** + +- [ ] The agent posts one Inline Comment thread per finding at the correct file path and line range +- [ ] Each posted comment ends with the canonical Bot Signature including the iteration number +- [ ] On first-review, the agent posts a full Review Summary as a new general thread +- [ ] On re-review with at least one new finding, the agent posts a delta reply to the existing summary thread +- [ ] On re-review with zero new findings, the agent skips the summary reply +- [ ] The agent posts a completion marker reply to the summary thread as its final action +- [ ] If `threadContext` is rejected by ADO, the agent retries without `threadContext` +- [ ] The agent returns the final `summaryThreadId` and `findingsPosted` count + +**Out of scope:** + +- Reply posting for re-review classified threads (that is the Re-review Coordinator's responsibility) +- Pre-PR mode (no ADO calls in that mode) +- Reading or fetching any ADO data diff --git a/docs/issues/pr-review-orchestrator-split/03-create-re-review-coordinator-agent.md b/docs/issues/pr-review-orchestrator-split/03-create-re-review-coordinator-agent.md new file mode 100644 index 0000000..cda8ab6 --- /dev/null +++ b/docs/issues/pr-review-orchestrator-split/03-create-re-review-coordinator-agent.md @@ -0,0 +1,80 @@ +# Create Re-review Coordinator agent + +**Status:** ready-for-agent +**Category:** enhancement + +## Parent + +`docs/issues/pr-review-orchestrator-split/PRD.md` + +## What to build + +Create a new plugin agent (`pr-review:re-review-coordinator`) that owns the full re-review state machine. The agent receives the ADO Fetcher context block, the raw prior-threads JSON, and the diff hunks file path. + +It performs in order: + +1. Calls the `detect-prior-review` Node.js module to identify prior bot threads and locate the summary thread. +2. Runs the partial-run check (looks for the completion marker for the prior iteration in the summary thread). Falls back to first-review mode if the marker is absent. +3. If no new commits exist since the prior review (prior commit SHA equals latest commit SHA), prints outstanding pending threads to the console and exits early — no ADO writes. +4. Calls `classify-thread` on each prior thread against the diff hunks. +5. For each new finding passed in, calls `match-finding` to look for a matching prior thread. +6. Based on classification, posts replies to prior threads: acknowledges disputes, confirms resolutions (and PATCHes thread status to fixed), adds new evidence to pending threads with new information, skips pending threads with no new evidence, ignores obsolete threads. +7. Returns the classification counts (new, addressed, disputed, pending) and the updated findings list (unmatched findings pass through as fresh; matched findings are consumed). + +The four Node.js modules (`detect-prior-review`, `classify-thread`, `match-finding`, `parse-signature`) remain in `scripts/re-review/` unchanged. This agent calls them via `node --input-type=module` inline scripts, exactly as the current `review-pr.md` does. + +## Acceptance criteria + +- [ ] The agent correctly detects prior bot threads using the `detect-prior-review` module +- [ ] The agent falls back to first-review mode when no completion marker is found for the prior iteration +- [ ] The agent exits early (console output only, no ADO writes) when prior and latest commit SHAs are identical +- [ ] The agent classifies all prior threads using the `classify-thread` module +- [ ] The agent matches new findings to prior threads using the `match-finding` module with ±3-line drift tolerance +- [ ] The agent posts a dispute acknowledgement reply to disputed threads including the ADO nudge +- [ ] The agent posts a resolution confirmation reply and PATCHes status to fixed for addressed threads +- [ ] The agent posts a new-evidence reply to pending threads that have new analysis; skips pending threads with no new evidence +- [ ] The agent returns classification counts and the unmatched (fresh) findings list +- [ ] The existing re-review module unit tests (`detect-prior-review`, `classify-thread`, `match-finding`, `parse-signature`) pass unchanged + +## Blocked by + +None — can start immediately. + +--- + +## Agent Brief + +> _This was generated by AI during triage._ + +**Category:** enhancement +**Summary:** Create the `pr-review:re-review-coordinator` agent that owns the full re-review state machine. + +**Current behavior:** +The re-review state machine (prior thread detection, partial-run check, Thread Classification, finding matching, reply/resolution posting) lives inline in `review-pr.md` across Steps 3.5–10-Path-B. It is loaded on every invocation regardless of mode. + +**Desired behavior:** +A new plugin agent (`pr-review:re-review-coordinator`) receives the ADO Fetcher context block, raw prior-threads JSON, and diff hunks. It runs the full re-review state machine, posts classified replies directly to ADO, and returns classification counts plus the list of unmatched (fresh) findings for the ADO Writer to post as new threads. The four existing Node.js modules (`detect-prior-review`, `classify-thread`, `match-finding`, `parse-signature`) are called from this agent unchanged. + +**Key interfaces:** + +- Input: ADO Fetcher context block, prior-threads JSON (from `detect-prior-review`), diff hunks JSON, new findings list, Bot Signature prefix constant +- Output: `{ addressed, disputed, pending, freshFindings[] }` — fresh findings are those with no matching prior thread +- The agent calls the four Node.js modules via `node --input-type=module` inline scripts (same pattern as current `review-pr.md`) +- Early-exit path: when prior commit SHA equals latest commit SHA, prints pending threads to console and returns with empty fresh findings — no ADO writes + +**Acceptance criteria:** + +- [ ] The agent correctly detects prior bot threads using the `detect-prior-review` module +- [ ] The agent falls back to first-review mode when no completion marker is found for the prior iteration +- [ ] The agent exits early when prior and latest commit SHAs are identical (console output only, no ADO writes) +- [ ] The agent classifies all prior threads using the `classify-thread` module +- [ ] The agent matches new findings to prior threads using `match-finding` with ±3-line drift tolerance +- [ ] The agent posts dispute acknowledgement, resolution confirmation, and new-evidence replies appropriately +- [ ] The agent returns classification counts and unmatched fresh findings +- [ ] The four re-review module unit tests pass unchanged after this issue is implemented + +**Out of scope:** + +- Posting new Inline Comment threads for fresh findings (ADO Writer's responsibility) +- Posting the Review Summary or completion marker (ADO Writer's responsibility) +- First-review or pre-PR mode logic diff --git a/docs/issues/pr-review-orchestrator-split/04-refactor-orchestrator.md b/docs/issues/pr-review-orchestrator-split/04-refactor-orchestrator.md new file mode 100644 index 0000000..9345505 --- /dev/null +++ b/docs/issues/pr-review-orchestrator-split/04-refactor-orchestrator.md @@ -0,0 +1,83 @@ +# Refactor review-pr.md to thin orchestrator + +**Status:** ready-for-agent +**Category:** enhancement + +## Parent + +`docs/issues/pr-review-orchestrator-split/PRD.md` + +## What to build + +Refactor `review-pr.md` into a thin orchestrator of approximately 200 lines. The orchestrator: + +1. Validates prerequisites in a mode-aware way: always checks `git` availability and `pr-review-toolkit`; checks Azure CLI and `azure-devops` extension only when a PR URL is present (Pre-PR mode requires no ADO credentials). +2. Parses `$ARGUMENTS` for a PR URL. If absent, sets mode to Pre-PR; if present, proceeds to detection. +3. For PR URL cases: makes a lightweight ADO thread-list call directly (not via the ADO Fetcher) to check for a prior Bot Signature, determining mode and extracting the prior commit SHA if found; then invokes the ADO Fetcher agent (passing the prior commit SHA for re-review runs). +4. Logs the detected mode clearly before delegating. +5. For First-review: runs Doc Context Orchestrator + review aspect agents in parallel, collects compact findings, delegates write-back to the ADO Writer agent. +6. For Re-review: runs Doc Context Orchestrator + review aspect agents in parallel, passes findings and prior-thread data to the Re-review Coordinator agent (which handles replies), then passes remaining fresh findings to the ADO Writer agent. +7. Pre-PR mode is a stub at this slice — it detects the mode and prints a "Pre-PR mode not yet implemented" message. Full Pre-PR behaviour is delivered in issue 05. + +The `review-pr.md` file must contain no `az devops invoke` shell commands after this refactor — all ADO operations live in the three focused agents. The Bot Signature constants and detection prefix are unchanged. All existing re-review module unit tests must pass. + +## Acceptance criteria + +- [ ] `review-pr.md` is ≤ 200 lines and contains no `az devops invoke` calls +- [ ] Prerequisite checks are mode-aware: Azure CLI and `azure-devops` extension are not required in Pre-PR mode (no PR URL provided) +- [ ] The orchestrator logs the detected mode (Pre-PR / First-review / Re-review) before delegating +- [ ] First-review mode produces the same ADO comment output as the pre-refactor command (full Review Summary + Inline Comments + completion marker) +- [ ] Re-review mode produces the same ADO comment output as the pre-refactor command (classified replies + fresh findings + delta summary + completion marker) +- [ ] Pre-PR mode prints a clear "not yet implemented" message and exits cleanly +- [ ] The ADO Fetcher and Doc Context Orchestrator still run in the correct order (Fetcher first, then both Doc Context and review agents can overlap) +- [ ] The Bot Signature format and detection prefix are unchanged +- [ ] `pnpm test` passes (all re-review module unit tests green) +- [ ] `pnpm format` produces no diff + +## Blocked by + +- `docs/issues/pr-review-orchestrator-split/01-create-ado-fetcher-agent.md` +- `docs/issues/pr-review-orchestrator-split/02-create-ado-writer-agent.md` +- `docs/issues/pr-review-orchestrator-split/03-create-re-review-coordinator-agent.md` + +--- + +## Agent Brief + +> _This was generated by AI during triage._ + +**Category:** enhancement +**Summary:** Refactor `review-pr.md` into a thin orchestrator (~200 lines) that delegates to the three focused agents. + +**Current behavior:** +`review-pr.md` is ~1000 lines, mixing orchestration logic, ADO shell commands, re-review state machine, and write-back in a single file. Every invocation loads the entire file into context. + +**Desired behavior:** +`review-pr.md` shrinks to ~200 lines containing: mode-aware prerequisite validation (ADO tooling skipped for Pre-PR), argument parsing, mode detection (Pre-PR / First-review / Re-review), and delegation calls to the ADO Fetcher, Re-review Coordinator, and ADO Writer agents. The file contains no `az devops invoke` calls. Pre-PR mode is a stub that prints "not yet implemented" — full implementation is in issue 05. + +**Key interfaces:** + +- Mode detection sequence: no URL → Pre-PR; URL → orchestrator makes a lightweight ADO thread-list call → no Bot Signature → First-review; Bot Signature found → extract prior commit SHA → Re-review +- Bot Signature detection prefix: `🤖 *Reviewed by Claude Code*` — must not change +- ADO Fetcher agent invocation: passes org URL, project, PR ID +- Re-review Coordinator agent invocation (re-review only): passes ADO Fetcher context + new findings list +- ADO Writer agent invocation: passes PR context + fresh findings list + mode flag +- The GitHub prompt (`.claude/prompts/pr-review-workflow.prompt.md`) is the structural reference for what the orchestrator should look like + +**Acceptance criteria:** + +- [ ] `review-pr.md` is ≤ 200 lines and contains no `az devops invoke` calls +- [ ] Prerequisite checks are mode-aware: Azure CLI and `azure-devops` extension are not required in Pre-PR mode +- [ ] The orchestrator logs the detected mode before delegating +- [ ] First-review produces the same ADO output as pre-refactor +- [ ] Re-review produces the same ADO output as pre-refactor +- [ ] Pre-PR mode prints "not yet implemented" and exits cleanly +- [ ] ADO Fetcher runs before Doc Context Orchestrator (Fetcher provides work-item IDs); Doc Context and review agents may overlap +- [ ] Bot Signature format and detection prefix unchanged +- [ ] `pnpm test` passes; `pnpm format` produces no diff + +**Out of scope:** + +- Full Pre-PR mode implementation (issue 05) +- Compact sub-agent output guidance (issue 06) +- Version bump (issue 07) diff --git a/docs/issues/pr-review-orchestrator-split/05-add-pre-pr-mode.md b/docs/issues/pr-review-orchestrator-split/05-add-pre-pr-mode.md new file mode 100644 index 0000000..edcf484 --- /dev/null +++ b/docs/issues/pr-review-orchestrator-split/05-add-pre-pr-mode.md @@ -0,0 +1,73 @@ +# Add Pre-PR mode + +**Status:** ready-for-agent +**Category:** enhancement + +## Parent + +`docs/issues/pr-review-orchestrator-split/PRD.md` + +## What to build + +Implement the Pre-PR operating mode in the orchestrator. When `/pr-review:review-pr` is invoked without a PR URL, the command: + +1. Diffs the current local branch against its upstream target (e.g. `git diff origin/...HEAD`). +2. Reads key changed files (same skip-list as today: generated files, serialization YAMLs, etc.). +3. Launches the same `pr-review-toolkit` review aspect agents as the ADO modes, passing the local diff and file contents. Doc Context is skipped (no work items or Confluence pages to fetch without a PR). +4. Aggregates findings and presents them in the Claude interface as a structured list (severity, file, line, title, body) — no ADO calls are made. +5. Prints a clear completion message when done. + +No ADO credentials are required and no ADO calls are made in this mode. The pre-PR Review uses the same review aspect agent selection logic as ADO modes (aspect filter from `$ARGUMENTS` applies). + +## Acceptance criteria + +- [ ] Running the command without a URL enters Pre-PR mode with a console message confirming the mode +- [ ] The diff used is the local branch diff against its upstream target +- [ ] Review aspect agents receive the local diff and changed file contents +- [ ] Findings are presented in the Claude interface with severity, file path, line range, title, and body +- [ ] No ADO API calls are made in this mode +- [ ] The aspect filter argument (e.g. `code`, `errors`, `all`) is respected in pre-PR mode +- [ ] `pnpm test` passes; `pnpm format` produces no diff + +## Blocked by + +- `docs/issues/pr-review-orchestrator-split/04-refactor-orchestrator.md` + +--- + +## Agent Brief + +> _This was generated by AI during triage._ + +**Category:** enhancement +**Summary:** Implement Pre-PR mode — review local branch diff without a PR URL, no ADO write-back. + +**Current behavior:** +The orchestrator stub from issue 04 prints "Pre-PR mode not yet implemented" and exits. No review occurs without a PR URL. + +**Desired behavior:** +When the command is invoked without a URL, it diffs the local branch against its upstream target, runs the same `pr-review-toolkit` review aspect agents as ADO modes, and presents compact structured findings in the Claude interface. No ADO credentials are required or used. Doc Context gathering is skipped (no work items to fetch). The aspect filter argument applies. + +**Key interfaces:** + +- Diff source: `git diff origin/...HEAD` +- File skip-list: same as current (generated files, serialization YAMLs, `*.g.cs`, `swagger.md`) +- Review aspect agents: same selection logic as ADO modes; aspect filter from `$ARGUMENTS` applies +- Finding presentation: compact structured list — severity, file path, line range, title, body — in the Claude interface +- No ADO Fetcher, Re-review Coordinator, or ADO Writer agents are invoked + +**Acceptance criteria:** + +- [ ] Running the command without a URL enters Pre-PR mode with a console message confirming the mode +- [ ] The diff used is the local branch diff against its upstream target +- [ ] Review aspect agents receive the local diff and changed file contents +- [ ] Findings are presented in the Claude interface with severity, file path, line range, title, and body +- [ ] No ADO API calls are made in this mode +- [ ] The aspect filter argument is respected +- [ ] `pnpm test` passes; `pnpm format` produces no diff + +**Out of scope:** + +- Posting findings to ADO +- Doc Context gathering in pre-PR mode +- Any change to first-review or re-review behaviour diff --git a/docs/issues/pr-review-orchestrator-split/06-compact-subagent-output.md b/docs/issues/pr-review-orchestrator-split/06-compact-subagent-output.md new file mode 100644 index 0000000..1b81bef --- /dev/null +++ b/docs/issues/pr-review-orchestrator-split/06-compact-subagent-output.md @@ -0,0 +1,65 @@ +# Add compact sub-agent output guidance to Step 8 prompt + +**Status:** ready-for-agent +**Category:** enhancement + +## Parent + +`docs/issues/pr-review-orchestrator-split/PRD.md` + +## What to build + +Update the Step 8 prompt in the thin orchestrator to instruct `pr-review-toolkit` review aspect agents to return compact structured findings rather than prose with embedded code quotes. + +The prompt addition instructs each agent to return a JSON array where each element has: `severity` (critical / important / minor), `filePath` (leading `/`, forward slashes), `startLine` (integer), `endLine` (integer), `title` (one line, ≤ 80 chars), `body` (one paragraph — the exact text to post as the ADO or local-interface comment, no code quotes, no repeated context). The reasoning and supporting analysis should stay inside the agent's own context, not appear in the return value. + +No changes are made to `pr-review-toolkit` agent definitions — this guidance lives only in the orchestrator's prompt to the agents. + +## Acceptance criteria + +- [ ] The Step 8 prompt explicitly requests structured JSON findings with the six required fields +- [ ] The prompt instructs agents to omit code quotes and prose reasoning from the return value +- [ ] The ADO Writer agent correctly receives and processes the structured finding schema +- [ ] Pre-PR mode findings are also presented using the same structured schema +- [ ] No `pr-review-toolkit` agent definition files are modified +- [ ] `pnpm format` produces no diff + +## Blocked by + +- `docs/issues/pr-review-orchestrator-split/04-refactor-orchestrator.md` + +--- + +## Agent Brief + +> _This was generated by AI during triage._ + +**Category:** enhancement +**Summary:** Update the orchestrator's Step 8 prompt to request compact structured findings from review aspect agents. + +**Current behavior:** +Review aspect agents return prose findings with embedded code quotes and explanatory text. The full prose flows back into the parent context as tool call results, contributing to token budget pressure. + +**Desired behavior:** +The Step 8 prompt in the thin orchestrator explicitly instructs each review aspect agent to return a JSON array of findings. Each element: `severity` (critical / important / minor), `filePath`, `startLine`, `endLine`, `title` (≤ 80 chars), `body` (one paragraph, no code quotes). Reasoning stays inside the agent's own context. No `pr-review-toolkit` agent definition files are modified. + +**Key interfaces:** + +- The structured finding schema: `{ severity, filePath, startLine, endLine, title, body }` +- Guidance location: orchestrator Step 8 prompt only — not in toolkit agent definitions +- Both ADO modes and Pre-PR mode use this schema + +**Acceptance criteria:** + +- [ ] The Step 8 prompt requests structured JSON findings with all six required fields +- [ ] The prompt instructs agents to omit code quotes and prose reasoning from the return value +- [ ] The ADO Writer agent correctly receives and processes the structured schema +- [ ] Pre-PR mode findings are presented using the same schema +- [ ] No `pr-review-toolkit` agent definition files are modified +- [ ] `pnpm format` produces no diff + +**Out of scope:** + +- Enforcing schema validation on agent output +- Changing the toolkit agent definitions +- Token-budget monitoring or benchmarking diff --git a/docs/issues/pr-review-orchestrator-split/07-version-bump-and-release.md b/docs/issues/pr-review-orchestrator-split/07-version-bump-and-release.md new file mode 100644 index 0000000..016e545 --- /dev/null +++ b/docs/issues/pr-review-orchestrator-split/07-version-bump-and-release.md @@ -0,0 +1,59 @@ +# Version bump and CHANGELOG + +**Status:** ready-for-agent +**Category:** enhancement + +## Parent + +`docs/issues/pr-review-orchestrator-split/PRD.md` + +## What to build + +Bump the `pr-review` plugin version (minor bump — new features added) and add a dated CHANGELOG entry covering the orchestrator split, the three new agents, pre-PR mode, and compact sub-agent output. + +Run `pnpm --filter pr-review bump minor` to update both `plugin.json` and `marketplace.json`. Add a `[Unreleased]` → versioned entry to `CHANGELOG.md` following the existing format. Run `pnpm --filter pr-review verify:changelog` to confirm the entry passes validation. + +## Acceptance criteria + +- [ ] `plugin.json` and `marketplace.json` both reflect the new minor version +- [ ] `CHANGELOG.md` has a dated entry for the new version describing the orchestrator split, three new agents, pre-PR mode, and compact output guidance +- [ ] `pnpm --filter pr-review verify:changelog` passes +- [ ] `pnpm format` produces no diff + +## Blocked by + +- `docs/issues/pr-review-orchestrator-split/05-add-pre-pr-mode.md` +- `docs/issues/pr-review-orchestrator-split/06-compact-subagent-output.md` + +--- + +## Agent Brief + +> _This was generated by AI during triage._ + +**Category:** enhancement +**Summary:** Bump `pr-review` to the next minor version and add a CHANGELOG entry for the orchestrator split. + +**Current behavior:** +`plugin.json` and `marketplace.json` carry the current version. `CHANGELOG.md` has no entry for this feature set. + +**Desired behavior:** +Run `pnpm --filter pr-review bump minor` to update both version files atomically. Add a dated entry to `CHANGELOG.md` under the new version number describing: orchestrator split, three new focused agents (ADO Fetcher, Re-review Coordinator, ADO Writer), pre-PR mode, and compact sub-agent output guidance. Verify with `pnpm --filter pr-review verify:changelog`. + +**Key interfaces:** + +- `pnpm --filter pr-review bump minor` — updates `plugin.json` and `marketplace.json` +- `CHANGELOG.md` entry format — must match the existing dated em-dash format enforced by `verify:changelog` +- `pnpm --filter pr-review verify:changelog` — must pass + +**Acceptance criteria:** + +- [ ] `plugin.json` and `marketplace.json` both reflect the new minor version +- [ ] `CHANGELOG.md` has a dated entry for the new version covering all four feature areas +- [ ] `pnpm --filter pr-review verify:changelog` passes +- [ ] `pnpm format` produces no diff + +**Out of scope:** + +- Publishing to the marketplace (manual step) +- Creating the git tag (handled by the release workflow on `main`) diff --git a/docs/issues/pr-review-orchestrator-split/PRD.md b/docs/issues/pr-review-orchestrator-split/PRD.md new file mode 100644 index 0000000..b21024d --- /dev/null +++ b/docs/issues/pr-review-orchestrator-split/PRD.md @@ -0,0 +1,181 @@ +# PRD: pr-review — Orchestrator Split + +**Status:** ready-for-agent +**Category:** enhancement +**Plugin:** `apps/claude-code/pr-review` + +--- + +## Problem Statement + +The `review-pr` command has grown into a ~1000-line monolith that conflates three distinct concerns: orchestration (which operating mode?), ADO platform integration (fetch metadata, post comments), and re-review state management (classify threads, match findings, reply). As a result, every invocation loads the full command file into context, combined with parallel review-agent results flowing back, pushing average PR reviews past 100 K parent-context tokens. Adding the pre-PR mode that developers are requesting would push the file to ~1300 lines and compound the problem further. + +## Solution + +Refactor `review-pr.md` into a thin orchestrator of ~200 lines that detects the operating mode and immediately delegates to focused agents. The three focused agents — ADO Fetcher, Re-review Coordinator, and ADO Writer — live in the plugin's own agent directory and only load when their mode is active. Pre-PR runs never touch ADO at all. Review aspect agents are also asked to return compact structured findings rather than prose, keeping what flows back into the parent context small. + +## User Stories + +1. As a developer running `/pr-review:review-pr` on a first-review PR, I want the command to execute without loading re-review state-machine logic, so that the parent context is not burdened by code paths that do not apply. + +2. As a developer running `/pr-review:review-pr` on a re-review PR, I want the Re-review Coordinator to own all prior-thread detection and classification, so that the orchestrator stays short and readable. + +3. As a developer who wants to review code before opening a PR, I want to run `/pr-review:review-pr` without a PR URL and receive findings in the Claude interface, so that I can catch issues before the PR is even created. + +4. As a developer running a pre-PR Review, I want no comments posted to ADO, so that draft feedback does not pollute the eventual PR conversation. + +5. As a developer, I want the orchestrator to tell me clearly which mode it is entering (Pre-PR, First-review, or Re-review), so that I can understand what will happen before it starts. + +6. As a developer on a large PR, I want review-agent findings returned as compact structured records rather than prose with embedded code quotes, so that the parent context stays within budget. + +7. As a developer, I want the structured finding to include severity, file path, line range, a short title, and one-paragraph comment body, so that the ADO Writer has everything it needs to post the Inline Comment without re-querying the agent. + +8. As a developer, I want the ADO Fetcher to encapsulate all ADO API calls needed to retrieve PR metadata, iterations, changed files, and the raw diff, so that the orchestrator does not contain any platform-specific shell commands. + +9. As a developer, I want the ADO Writer to encapsulate all ADO write-back operations — posting Inline Comments, patching Thread status, and posting the Review Summary or delta reply — so that those operations are not scattered across the orchestrator. + +10. As a developer, I want the Re-review Coordinator to own the partial-run check, so that the orchestrator does not need to know about completion markers or fallback logic. + +11. As a developer on a re-review PR with no new commits, I want the Re-review Coordinator to exit early and list outstanding pending threads in the console, so that no ADO comments are posted unnecessarily. + +12. As a developer, I want adding a future operating mode (e.g. post-merge audit) to require only a new agent and a small branch in the orchestrator, so that the monolith problem does not recur. + +13. As a plugin operator, I want all four re-review Node.js modules (detect-prior-review, classify-thread, match-finding, parse-signature) to remain in the plugin's scripts directory unchanged, so that the split does not alter tested behaviour. + +14. As a plugin operator, I want the orchestrator to validate prerequisites (Azure CLI, `azure-devops` extension, `pr-review-toolkit` availability) before entering any mode, so that failures are surfaced early and consistently. + +15. As a plugin operator, I want the Bot Signature format and detection prefix to remain unchanged after the split, so that existing Review Threads on live PRs are still recognised correctly. + +16. As a developer reading the codebase, I want each agent to have a single clearly named responsibility, so that I know exactly which file to open when debugging an ADO write error versus a thread-classification error. + +17. As a developer running a first-review, I want the ADO Fetcher and the Doc Context Orchestrator to run concurrently as before, so that the split does not increase wall-clock time. + +18. As a developer, I want the guidance for compact review-agent output to live in the orchestrator's Step 8 prompt rather than in the `pr-review-toolkit` agent definitions, so that the toolkit remains an unmodified read-only dependency. + +19. As a plugin operator, I want the existing test suite for the four re-review modules to continue passing after the split with no changes, so that I have confidence the refactor is behaviour-preserving. + +20. As a developer, I want the pre-PR mode to use the same `pr-review-toolkit` review aspect agents as the ADO modes, so that review quality is consistent regardless of whether a PR URL is provided. + +## Implementation Decisions + +### Operating modes + +The orchestrator detects one of three modes on startup: + +- **Pre-PR mode** — no PR URL provided; targets the local branch diff; no ADO write-back. +- **First-review mode** — PR URL provided; no prior Bot Signature found in the PR's threads. +- **Re-review mode** — PR URL provided; prior Bot Signature detected. + +Mode detection happens within the first ~50 lines of the orchestrator. Once detected, the orchestrator delegates entirely. + +### Focused agents + +Three new agents live in the plugin's `.agents/` directory: + +**ADO Fetcher** — encapsulates all ADO read operations: PR metadata, iterations, changed files list, and raw diff. Returns a structured context block consumed by the orchestrator for passing to review agents and the writer. Used by first-review and re-review modes only. + +**Re-review Coordinator** — owns everything in the current re-review path: prior thread detection (calling `detect-prior-review`), partial-run check, early exit for no new commits, Thread Classification (calling `classify-thread`), finding matching (calling `match-finding`), and reply posting to classified threads. The four Node.js modules remain in `scripts/re-review/` and are called from this agent, not inlined. Used only in re-review mode. + +**ADO Writer** — owns all ADO write-back: posting new Inline Comment threads for fresh findings, patching Thread status to fixed for addressed findings, posting reply comments for disputed and pending findings with new evidence, posting the Review Summary on first-review, posting the delta reply on re-review, and posting the completion marker. Used by first-review and re-review modes. + +### Compact sub-agent output contract + +Review aspect agents (`pr-review-toolkit:code-reviewer`, `silent-failure-hunter`, etc.) are instructed via the orchestrator's prompt to return findings as a structured list. Each finding carries: severity, file path, start line, end line, title (one line), and body (one paragraph — the text posted as the ADO comment). No prose reasoning, no code quotes in the return value. This guidance is in the orchestrator's prompt only; the toolkit agent definitions are not modified. + +### pr-review-toolkit as read-only dependency + +No files in `pr-review-toolkit` are created or modified. All new agents live in the `pr-review` plugin's own `.agents/` directory. + +### Re-review module ownership + +The four Node.js modules in `scripts/re-review/` remain in the plugin. Lifting them to `pr-review-toolkit` as a shared library is deferred until a second write-back platform (GitHub) is built, at which point a canonical thread shape can be defined from real constraints. This is documented in ADR 0013 (`apps/claude-code/pr-review/docs/adr/0013-orchestrator-split-for-review-pr.md`). + +### Doc Context integration + +The Doc Context Orchestrator agent and its pipeline (ADO Fetcher fetches work-item IDs, Orchestrator spawns sub-agents, Synthesizer produces `DOC_CONTEXT`) are unchanged. The ADO Fetcher agent absorbs the work-item ID fetch that currently lives inline in Step 4a. + +## Testing Decisions + +### What makes a good test + +Tests assert the external behaviour of each module given controlled inputs — no implementation detail inspection, no internal branching tests. Inputs are plain JavaScript objects or JSON fixtures. A test reads as a sentence: "given a findings list with two items, the writer posts two inline threads." + +### Modules under test + +The four existing re-review modules (`detect-prior-review`, `classify-thread`, `match-finding`, `parse-signature`) already have a test suite and must continue passing unchanged. No new unit tests are required for the three new agents — their behaviour is best verified by integration against a real ADO PR (smoke test). If a new pure function is extracted during the refactor (e.g. mode detection logic), a unit test for that function is appropriate. + +### Prior art + +The existing test structure mirrors `packages/release-tools/scripts/verify-changelog.test.mjs` and `bump-version.test.mjs` — `node:test` built-in, no external deps, fixtures as imported JSON, assertions via `node:assert/strict`. + +## Out of Scope + +- GitHub write-back support (separate future feature). +- Normalising re-review modules to a canonical cross-platform thread shape (deferred + until GitHub write-back is built — see ADR 0013). +- Changes to `pr-review-toolkit` agent definitions. +- Token-budget monitoring or automatic truncation of large diffs. +- Any change to the Bot Signature format or detection prefix. +- Changes to the four re-review Node.js module interfaces. +- Automated performance benchmarking of parent context token usage. + +## Further Notes + +**ADR 0013** (`apps/claude-code/pr-review/docs/adr/0013-orchestrator-split-for-review-pr.md`) records the full rationale and alternatives considered for this decision. + +**CONTEXT.md** has already been updated with the three operating modes, three orchestration agent terms, and their relationships. + +**GitHub prompt as reference.** The `.claude/prompts/pr-review-workflow.prompt.md` file is the model for what the thin orchestrator should look like — it coordinates review activities in ~80 lines by staying a pure coordinator. The refactored `review-pr.md` should be structurally similar. + +--- + +## Agent Brief + +> _This was generated by AI during triage._ + +**Category:** enhancement +**Summary:** Refactor the `review-pr` command into a thin orchestrator that delegates to three focused agents — ADO Fetcher, Re-review Coordinator, and ADO Writer — and add a pre-PR operating mode. + +**Current behavior:** +`review-pr.md` is a ~1000-line monolith that handles orchestration, ADO platform integration, and re-review state management in a single command file. Every invocation loads the full file into context, and parallel review-agent results flowing back push average PR reviews past 100 K parent-context tokens. There is no mode for reviewing code before a PR exists. + +**Desired behavior:** +`review-pr.md` becomes a thin orchestrator of approximately 200 lines. On startup it detects one of three operating modes: + +- **Pre-PR mode** (no PR URL): diffs the local branch, runs review aspect agents from `pr-review-toolkit`, and presents findings in the Claude interface. No ADO calls are made. +- **First-review mode** (PR URL, no prior Bot Signature detected): delegates ADO reads to the ADO Fetcher agent, runs review aspect agents, delegates all ADO writes to the ADO Writer agent. +- **Re-review mode** (PR URL, prior Bot Signature detected): same as first-review, but additionally invokes the Re-review Coordinator agent to handle prior-thread classification, finding matching, and reply posting to classified threads before the ADO Writer runs. + +Each of the three new agents lives in the plugin's own `.agents/` directory. `pr-review-toolkit` is not modified (it is a read-only dependency). The four existing re-review Node.js modules (`detect-prior-review`, `classify-thread`, `match-finding`, `parse-signature`) remain in the plugin's `scripts/re-review/` directory and are called from the Re-review Coordinator agent. + +Review aspect agents are instructed via the orchestrator's Step 8 prompt to return compact structured findings (severity, file path, start line, end line, one-line title, one-paragraph body) rather than prose with embedded code quotes. This guidance lives in the orchestrator prompt only. + +**Key interfaces:** + +- `review-pr` command orchestrator — validates prerequisites, detects mode within first ~50 lines, delegates entirely; carries no ADO shell commands +- ADO Fetcher agent — returns a structured context block: PR metadata, latest iteration ID, prior commit ID (re-review only), changed files list, raw diff, and work-item IDs for Doc Context +- Re-review Coordinator agent — receives the ADO Fetcher context and prior-threads data; produces classified thread list and executes reply/resolution actions; delegates to `detect-prior-review`, `classify-thread`, and `match-finding` modules +- ADO Writer agent — receives the findings list and PR context; posts all Inline Comment threads, patches thread statuses, posts the Review Summary or delta reply, posts the completion marker +- Compact finding schema: `{ severity, filePath, startLine, endLine, title, body }` +- Bot Signature constant: `🤖 *Reviewed by Claude Code*` prefix — must remain unchanged + +**Acceptance criteria:** + +- [ ] The `review-pr` command file is ≤ 200 lines and contains no `az devops invoke` calls +- [ ] Running the command without a URL enters Pre-PR mode; findings appear in the Claude interface; no ADO threads are posted +- [ ] Running with a URL where no prior Bot Signature exists enters First-review mode and posts a full Review Summary and Inline Comments to ADO +- [ ] Running with a URL where prior Bot Signature exists enters Re-review mode; the Re-review Coordinator correctly classifies threads and posts replies +- [ ] The orchestrator logs the detected mode (Pre-PR / First-review / Re-review) before delegating +- [ ] The four existing re-review module unit tests pass unchanged after the refactor +- [ ] The ADO Fetcher and Doc Context Orchestrator still run concurrently (no wall-clock regression for first-review) +- [ ] The Bot Signature format and detection prefix are unchanged +- [ ] `pnpm test` passes; `pnpm format` produces no diff + +**Out of scope:** + +- GitHub write-back support +- Normalising re-review modules to a canonical cross-platform shape (deferred per ADR 0013) +- Any changes to `pr-review-toolkit` agent definitions +- Token-budget monitoring or automatic diff truncation +- Changing the Bot Signature format or detection prefix +- Changing the four re-review Node.js module interfaces