Support headless agentic CLI backends (Pi / OpenCode) for deep reviews #28

Closed
opened 2026-10-07 18:59:50 +01:00 by nimmo · 0 comments
Owner

Enable the reviewer to delegate code review analysis to an external, headless coding agent CLI (such as pi or opencode), replacing diff-only limitations with mature, agentic codebase exploration.

Context & Motivation

Diff-only reviews frequently suffer from false positives and shallow analysis because the model cannot inspect call sites, imported definitions, or type signatures outside the diff.

Rather than hand-rolling a custom tool-calling loop (managing read_file, grep, AST search, and context budgets) inside reviewer.py, the runner environment already has mature, full-featured coding agent CLIs available (e.g. pi with Pangolin/Strata/Nova provider discovery and MCP support).

In Forgejo Actions, the complete repository is already checked out on the runner disk before the review step runs. A headless agent CLI can be invoked directly in the checkout to investigate the changes, explore surrounding code, verify hypotheses, and emit a structured review report.

Proposed Architecture

  1. Runner Delegation:
    • Introduce an agent CLI provider option in .forgejo/ai-review.yml:
      provider:
        type: agent-cli              # or 'pi', 'opencode'
        command: pi                  # CLI binary to invoke
        model: strata                # target model provider/alias
        timeout_seconds: 900
        output_file: .forgejo/review-output.json
      
  2. Headless Execution:
    • Invoke the agent non-interactively with a review prompt and target schema:
      pi -p "Review the diff between origin/main and HEAD.
             Investigate affected callers, definitions, and tests across the codebase.
             Output valid JSON matching schema: <SCHEMA> to <OUTPUT_PATH>."
      
  3. Structured Publishing:
    • reviewer.py validates the generated JSON artifact against the review schema, formats the markdown report, and publishes the review/comment to Forgejo as clankbot.

Scope

  • Add agent-cli provider implementation in reviewer.py (or a dedicated action mode).
  • Support configurable CLI invocation templates (passing diff, guidance files, and target output path).
  • Ensure strict timeout and process group management (killing runaway agent processes).
  • Validate and parse the generated JSON review artifact, falling back gracefully if the agent exits non-zero or produces invalid output.
  • Retain standard ollama and openai-compatible single-pass providers as lightweight alternatives.

Acceptance Criteria

  • A repository can configure provider.type: agent-cli (or pi).
  • The agent runs headlessly in the checked-out tree, utilizing its built-in search and navigation capabilities.
  • The review artifact is parsed and published to Forgejo with the standard verdict and findings format.
  • Failure or timeout of the agent CLI reports a clean failure without hanging the workflow.
Enable the reviewer to delegate code review analysis to an external, headless coding agent CLI (such as `pi` or `opencode`), replacing diff-only limitations with mature, agentic codebase exploration. ### Context & Motivation Diff-only reviews frequently suffer from false positives and shallow analysis because the model cannot inspect call sites, imported definitions, or type signatures outside the diff. Rather than hand-rolling a custom tool-calling loop (managing `read_file`, `grep`, AST search, and context budgets) inside `reviewer.py`, the runner environment already has mature, full-featured coding agent CLIs available (e.g. `pi` with Pangolin/Strata/Nova provider discovery and MCP support). In Forgejo Actions, the complete repository is already checked out on the runner disk before the review step runs. A headless agent CLI can be invoked directly in the checkout to investigate the changes, explore surrounding code, verify hypotheses, and emit a structured review report. ### Proposed Architecture 1. **Runner Delegation**: - Introduce an agent CLI provider option in `.forgejo/ai-review.yml`: ```yaml provider: type: agent-cli # or 'pi', 'opencode' command: pi # CLI binary to invoke model: strata # target model provider/alias timeout_seconds: 900 output_file: .forgejo/review-output.json ``` 2. **Headless Execution**: - Invoke the agent non-interactively with a review prompt and target schema: ```bash pi -p "Review the diff between origin/main and HEAD. Investigate affected callers, definitions, and tests across the codebase. Output valid JSON matching schema: <SCHEMA> to <OUTPUT_PATH>." ``` 3. **Structured Publishing**: - `reviewer.py` validates the generated JSON artifact against the review schema, formats the markdown report, and publishes the review/comment to Forgejo as `clankbot`. ### Scope - Add `agent-cli` provider implementation in `reviewer.py` (or a dedicated action mode). - Support configurable CLI invocation templates (passing diff, guidance files, and target output path). - Ensure strict timeout and process group management (killing runaway agent processes). - Validate and parse the generated JSON review artifact, falling back gracefully if the agent exits non-zero or produces invalid output. - Retain standard `ollama` and `openai-compatible` single-pass providers as lightweight alternatives. ### Acceptance Criteria - A repository can configure `provider.type: agent-cli` (or `pi`). - The agent runs headlessly in the checked-out tree, utilizing its built-in search and navigation capabilities. - The review artifact is parsed and published to Forgejo with the standard verdict and findings format. - Failure or timeout of the agent CLI reports a clean failure without hanging the workflow.
nimmo changed title from Support agentic cross-file verification to reduce diff-only false positives to Support headless agentic CLI backends (Pi / OpenCode) for deep reviews 2026-10-07 19:05:41 +01:00
nimmo closed this issue 2026-10-07 21:14:36 +01:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
nimmo/forgejo-auto-pr-review#28
No description provided.