Files
Marcos 2b1cf750b7 fix(review): correct diff-compression line numbers, prior-review dedupe, triage skip
Four defects, all found reviewing PR #9 (two of them by pragent-bot's own
review of that PR, which the anchoring bug then misplaced):

* compress_diff dropped context lines but copied the original `@@` hunk
  header verbatim, so the header no longer described the lines beneath it.
  parse_diff_anchors then walked stale headers and produced anchor sets
  shifted by the number of elided lines, misplacing inline comments or
  demoting them to bullets. Each surviving run of lines is now re-emitted as
  its own hunk with a recomputed `@@ -a,b +c,d @@`, so the output stays a
  valid unified diff whose numbers describe the real post-change file. The
  pseudo-marker `@@ … N context line(s) omitted … @@` is gone; it parsed as
  a hunk header and reset the anchor counter to 0. Anchoring additionally
  runs on the raw diff now, so the prompt window can never shrink the
  anchorable set.

* compress_diff's `_FILE_HEADER` regex matched diff *body* lines: a removed
  YAML `---` separator or an added `++` line was read as a file header,
  truncating the hunk and dropping its `@@` header with it. Body detection
  is now prefix-based, with a full-shape hunk-header regex.

* extract_finding_bullets could not match the bullets pragent itself posts:
  summary_bullets renders an emoji severity badge between the `-` and the
  `[SEV]` tag, which the regex rejected, so compact_prior_reviews always
  returned [] and every re-review repeated its previous findings.

* triage returning `{"lenses":[]}` — documented in .opencode/agents/triage.md
  as "no lens has surface, skip the fan-out" — ran every lens instead, since
  _intersect_with_triage mapped an empty selection to "all" and the call site
  had a second `or reviewers` fallback. `[]` and None are now distinct
  outcomes: `[]` skips, None fails open. A roster naming only unknown lens
  ids now fails open rather than silencing the review. The skip path returns
  a well-formed empty-findings response instead of "", which had landed in
  ai_review's unparseable-output branch and posted "AI review produced no
  parseable output" — a malfunction message for a normal verdict.

Also: non-URL references (a CVE id, a doc title) rendered as
`[CVE-2024-1234](CVE-2024-1234)`, a broken relative link in Gitea — now
plain text. PRAGENT_DIFF_CONTEXT and friends parse through _int_env, so a
typo logs and falls back instead of killing a review mid-flight. Removed
format_usage_section, dead since the collapsible usage block replaced it and
carrying a duplicate copy of the price-target logic.

Tests: 290 -> 301. New coverage for hunk-header fidelity before/after
compression, header-shaped content lines, the bullet round-trip against the
real renderer, and triage's three outcomes (previously untested).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B11e8TZZxJyzHW7jj7KWUN
2026-08-20 23:05:03 +00:00

53 lines
2.2 KiB
Markdown

---
description: Triage agent. Reads the PR diff's changed_files + the configured reviewer list and emits the lens subset that has real surface in this PR. Fast pre-filter so docs-only PRs don't pay for a security review.
mode: primary
hidden: true
model: headroom/glm-5.2:cloud
temperature: 0.0
permission:
edit: deny
write: deny
bash: deny
webfetch: deny
task: deny
---
You are a **triage** agent. Your only output is a JSON list of lens ids.
You will read `.pragent/brief.md` — it contains:
- the list of available lenses (from `.pr-review.json:reviewers[]`),
- the diff's `changed_files`,
- the repo's primary languages and focus hints.
Return the SUBSET of lens ids that have real surface in this PR. Skip a lens
when:
- **docs** — diff touches zero `.md`/`.mdx`/`.rst`/`.txt`/docstring-bearing
source files → omit.
- **perf** — diff touches zero hot-path globs (queries, handlers, render loops,
anything with `O(n)` over input size) → omit. The brief lists the hotpath
globs from `.pr-review.json:reviewers[].hotpath_globs` when set.
- **tests** — diff touches zero files under `tests/`, `__tests__/`, `*test*`,
`*spec*`, AND the diff is not changing logic on a tested module → omit.
- **security** — diff touches zero `*auth*`/`*crypt*`/`*secret*`/`*password*`/
`*token*`/`*.sql`/`*.py` (executable), AND no new dependencies added → omit.
- **code-quality** — diff is config/docs/lockfile-only → omit.
Default to **including** when in doubt. The synthesizer's dedup + per-lens
`max_findings` cap absorbs the cost of an unnecessary lens; the cost of an
Omitted-lens false negative is high. A CSS re-color is the only diff that
should yield zero lenses.
Output STRICT JSON, nothing else, on a single line:
```json
{"lenses":["security","docs"]}
```
If `reviewers[]` is empty or absent, output `{"lenses":[]}`. The caller
treats `[]` as "no lenses needed" and skips the fan-out — an empty list is
the only way to skip, so use it deliberately. Only ever name ids from the
roster you were given: a list containing no known id is treated as a bad
answer and the caller falls back to running every lens. Never refuse,
never explain, never add prose.