refactor: split opencode runtime and tests
This commit is contained in:
@@ -463,15 +463,15 @@ for permanence.
|
||||
## The opencode review engine
|
||||
|
||||
The review "brain" runs on **opencode** (the AI coding-agent CLI), not a single
|
||||
cramped model call. `pilot/opencode_review.py` is the glue:
|
||||
cramped model call. `pilot/review/opencode.py` is the compatibility seam:
|
||||
|
||||
1. `fetch_archive` — `GET .../archive/{sha}.tar.gz`, untar into a temp workdir
|
||||
1. `opencode_workspace.fetch_archive` — `GET .../archive/{sha}.tar.gz`, untar into a temp workdir
|
||||
(stripping the top dir) so the agent has the real files, not just the diff.
|
||||
2. `write_brief` — renders `.pragent/brief.md` (title, body, diff, repo
|
||||
2. `opencode_workspace.write_brief` — renders `.pragent/brief.md` (title, body, diff, repo
|
||||
`.pr-review.json`, prior reviews, sha, anchor hint).
|
||||
3. `drop_factory` — copies `opencode.json` + `.opencode/` (agents/skills/commands)
|
||||
3. `opencode_workspace.drop_factory` — copies `opencode.json` + `.opencode/` (agents/skills/commands)
|
||||
into the workdir as the project config.
|
||||
4. `run_opencode` — `opencode run --pure --format json --agent pragent
|
||||
4. `opencode.run_opencode` — `opencode run --pure --format json --agent pragent
|
||||
--dir <workdir> --model headroom/glm-5.2:cloud` headlessly. `--format json`
|
||||
emits NDJSON events: `parse_opencode_events` reconstructs the assistant text
|
||||
from `text` events and sums tokens/cost/steps from every `step_finish` event.
|
||||
@@ -514,7 +514,7 @@ opencode run --pure --agent pragent --dir <checkout> --model headroom/glm-5.2:cl
|
||||
"$(python3 -c 'import sys;sys.path.insert(0,"pilot");import opencode_review as o;print(o._PROMPT)')"
|
||||
```
|
||||
|
||||
### Gotchas baked into `opencode_review.py`
|
||||
### Gotchas baked into the opencode review modules
|
||||
|
||||
- **stdin=DEVNULL** — opencode blocks on stdin (permission prompt) when run
|
||||
headlessly via subprocess; closing stdin is required or it hangs to timeout.
|
||||
@@ -603,4 +603,3 @@ webhook service went live.
|
||||
- Gitea 1.26.1: system webhooks broken (see above) → user-level webhooks instead;
|
||||
hook delivery-history API (`.../hooks/{id}/tasks`) returns 404, so delivery is
|
||||
observed via the pragent-webhook pod logs (`kubectl -n pragent logs -f deploy/pragent-webhook`).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user