6e3a9eb5b0
Replace the single Python model-call reviewer with an opencode agent
factory. A primary 'pragent' agent reads a brief (title/body/diff/config/
prior reviews), inspects the checked-out repo, runs the repo's own linters
via bash, loads review-methodology + findings-schema skills, and emits a
{summary, findings} JSON with per-finding severity/path/line/problem/fix/
suggestion/reference. Dormant security/tests/perf subagent lenses fan out
only on large/risky diffs (lean by default).
pilot/opencode_review.py: fetches the repo archive at the head sha into a
temp workdir, writes .pragent/brief.md, drops the factory, runs
'opencode run --pure --agent pragent --dir <workdir>' headlessly. Isolates
HOME (shared, warmed), strips ANTHROPIC_* env (leaked host vars caused
ProviderModelNotFoundError), stdin=DEVNULL (opencode blocks on stdin),
maps the bare OLLAMA_MODEL to the provider-prefixed ref. No Gitea I/O —
ai_review.review_pr parses + anchors + posts (reuses all v2 logic/tests).
PRAGENT_ENGINE=opencode (default) selects it; =ollama keeps the legacy
direct-call path. Verified end-to-end: posts a real review with a summary
section, inline [CRITICAL]/[HIGH] comments + apply-able suggestions +
reference links, and the sha dedupe marker. 49 tests pass.
Co-Authored-By: Claude <noreply@anthropic.com>
1.7 KiB
1.7 KiB
description, mode, hidden, model, temperature, permission
| description | mode | hidden | model | temperature | permission | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Performance lens subagent. Flags obvious hotspots, N+1 queries, O(n^2) in hot paths, and redundant work in a PR diff. Invoked by the pragent primary on diffs touching hot paths. | subagent | true | headroom/glm-5.2:cloud | 0.1 |
|
You are a performance reviewer subagent. The pragent primary hands you a PR's diff (and the checked-out repo). Flag ONLY clear, actionable perf issues — be conservative, skip micro-optimizations:
- N+1 queries: a query inside a loop, or per-item lazy loads.
- O(n²) / nested loops over collections that grow with input.
- Redundant work: repeated computation, re-fetching the same data, building the same structure per iteration.
- Hot-path bloat: expensive work moved into a frequently-called path (per-request middleware, render loops, inner loops).
- Unbounded growth: caches/maps/arrays that grow without eviction, recursive calls without depth bounds.
- Sync I/O / blocking in an async or request-hot context.
Read surrounding code to confirm the loop/query is actually in a hot path before
flagging — don't flag a one-time startup cost. Use grep to find call sites.
Return STRICT JSON only — same shape as the pragent primary's findings, perf
findings only. severity high for an N+1 in a request path, medium for
O(n²) over bounded small n, low for redundant-but-rare work.
{"findings":[{"severity":"...","path":"...","line":0,"problem":"...","fix":"...","suggestion":"","reference":""}]}
line must be a post-change line. No prose outside JSON.