feat: opencode review engine + .opencode factory

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>
This commit is contained in:
Marcos
2026-08-17 23:01:59 +00:00
parent 8758b22802
commit 6e3a9eb5b0
13 changed files with 1336 additions and 48 deletions
+40
View File
@@ -0,0 +1,40 @@
{
"$schema": "https://opencode.ai/config.json",
"default_agent": "pragent",
"model": "headroom/glm-5.2:cloud",
"small_model": "headroom/glm-5.2:cloud",
"provider": {
"headroom": {
"npm": "@ai-sdk/anthropic",
"name": "Headroom GLM",
"options": {
"baseURL": "http://100.74.17.70:8789/v1",
"apiKey": "ollama"
},
"models": {
"glm-5.2:cloud": {
"name": "GLM 5.2 Cloud",
"limit": { "context": 200000, "output": 16000 }
}
}
}
},
"lsp": {},
"permission": {
"*": "allow",
"edit": "deny",
"write": "deny",
"apply_patch": "deny",
"bash": {
"*": "allow",
"rm -rf *": "deny",
"rm -fr *": "deny",
"git push *": "deny",
"git commit *": "deny",
"git reset --hard*": "deny",
"sudo *": "deny"
},
"external_directory": "allow",
"doom_loop": "deny"
}
}