No description
  • Python 98.6%
  • Nix 1.1%
  • Dockerfile 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nimmo 4ef909afbc
All checks were successful
Build and publish container image / prepare-tags (push) Successful in 1s
Build and publish container image / build-and-push (push) Successful in 18s
fix: handle missing trusted base config with clean skip and fallback support (#36)
2026-10-10 19:44:49 +01:00
.forgejo fix: verify publishing identity and harden discussion handling 2026-10-10 15:19:06 +01:00
docs feat: add headless Pi and OpenCode review backends (#28) 2026-10-07 20:37:15 +01:00
examples/forgejo-workflow fix: handle PR markers and nullable review authors consistently 2026-10-10 15:08:16 +01:00
tests fix: handle missing trusted base config with clean skip and fallback support (#36) 2026-10-10 19:44:49 +01:00
.dockerignore feat: package and harden reviewer execution 2026-07-21 21:15:33 +01:00
.gitignore chore: ignore Python bytecode caches 2026-07-20 16:40:35 +01:00
action.yml fix: handle missing trusted base config with clean skip and fallback support (#36) 2026-10-10 19:44:49 +01:00
Dockerfile feat: package and harden reviewer execution 2026-07-21 21:15:33 +01:00
flake.lock feat: package and harden reviewer execution 2026-07-21 21:15:33 +01:00
flake.nix feat: package and harden reviewer execution 2026-07-21 21:15:33 +01:00
LICENSE Initial commit 2026-07-20 13:36:36 +01:00
README.md fix: handle missing trusted base config with clean skip and fallback support (#36) 2026-10-10 19:44:49 +01:00
reviewer.py fix: handle missing trusted base config with clean skip and fallback support (#36) 2026-10-10 19:44:49 +01:00

Forgejo AI pull-request review

forgejo-auto-pr-review is an advisory, reusable code-review action for Forgejo. It combines repository-defined deterministic checks with an Ollama review, then creates or updates one structured comment on a pull request.

It assists human reviewers and never merges or modifies code. Formal review decisions, including approval, require explicit trusted repository configuration.

Status

The project is an operational Phase 1 MVP. It has been live-tested in nixos-config with a local Nova Ollama model and nix flake check.

Implemented today:

  • Forgejo pull-request events and a manual PR-number input.
  • Pull-request metadata, changed-file list, bounded unified diff, and repository guidance.
  • Explicitly configured deterministic checks with timeouts.
  • Ollama structured review and an optional second validation pass.
  • One marker-based comment per PR, updated on later runs.
  • Prompt-injection instructions and trusted base-revision check configuration.

Container packaging and comprehensive fixtures remain planned work; see issue #1.

Requirements

  • Forgejo Actions with a runner capable of running Python 3.
  • An Ollama server reachable from that runner.
  • A Forgejo token with repository-read and issue-comment write access, stored as a repository secret. With review.comment_trigger: true, it also needs user-read access to its own /user identity for both push and comment reviews; see Requesting another review. Formal reviews additionally require PR-review write access.
  • A checked-out working tree for the pull request; repository-defined checks run in that working tree.

Set up a repository

  1. Add .forgejo/ai-review.yml to the default branch. The reviewer always reads this executable configuration from the pull request's base commit; a pull request cannot add commands by changing its own configuration.

  2. Add a Forgejo workflow modelled on examples/forgejo-workflow/ai-review.yml.

  3. Create an AI_REVIEW_FORGEJO_TOKEN repository secret. Do not expose it to workflows that execute code from untrusted forks.

  4. Reference the maintained branch using Forgejo's full URL syntax:

    - name: Run advisory review
      uses: https://git.nimmog.uk/nimmo/forgejo-auto-pr-review@main
      with:
        token: ${{ secrets.AI_REVIEW_FORGEJO_TOKEN }}
    

First-time repository setup and bootstrap

Because executable configuration and deterministic check commands are strictly loaded from the pull request's trusted base revision, a repository's initial setup PR introducing .forgejo/ai-review.yml does not yet have trusted configuration on its base branch.

When trusted configuration is absent on the base branch (HTTP 404):

  • Default behaviour (clean skip): The action skips cleanly without running model calls or checks, explaining in the action feedback and log: Skipped: no trusted review configuration found on the base branch (first-time setup). Merge .forgejo/ai-review.yml to enable reviews. Merge the configuration to the default branch to enable automated reviews for subsequent PRs.

  • Explicit fallback configuration (fallback-config): If you wish to review the setup PR itself or provide a trusted default configuration across repositories, supply a trusted fallback configuration via the fallback-config input (or FORGEJO_REVIEW_FALLBACK_CONFIG environment variable / --fallback-config CLI flag):

    - name: Run advisory review
      uses: https://git.nimmog.uk/nimmo/forgejo-auto-pr-review@main
      with:
        token: ${{ secrets.AI_REVIEW_FORGEJO_TOKEN }}
        fallback-config: |
          provider:
            type: ollama
            model: qwen3.6:35b-a3b-q8_0
    

    When using a file path for fallback-config, the path must be an absolute path to a trusted file outside the checked-out repository tree (to prevent pull-request content from shadowing trusted configuration). This outside-checkout guard is enforced during the review step when the repository is checked out. In multi-step workflows (e.g. separating the prepare: 'true' step from the review step), pass fallback-config to both steps so preparation and review resolve the fallback configuration identically.

    When running with fallback configuration:

    • All analysis commands are omitted (deterministic checks are skipped entirely).
    • The review report includes a limitation explaining that trusted repository configuration and deterministic checks were unavailable.
    • Reviews remain advisory: formal reviews under fallback configuration will never emit APPROVED.

Forgejo resolves short action references against its configured default action source, so a self-hosted action must include https://.

@main deliberately follows the latest merged reviewer code, so consuming repositories require no manual reference updates. For a controlled rollout, publish a signed release tag such as v1.0.0, change the reference to that tag, and advance it only after testing. Do not use abbreviated commit IDs: Forgejo requires a full commit SHA when a commit reference is chosen.

The workflow normally runs for opened, reopened, synchronize, and ready_for_review pull-request events. A manual run accepts a pull-request number; the example checks out that PR's head before deterministic checks run.

Configuration reference

The configuration accepts JSON or a deliberately small YAML subset: nested mappings, scalar values, and scalar lists/mappings. Use JSON if you need a more complex structure.

provider:
  type: ollama                 # Ollama is the implemented provider
  model: qwen3.6:35b-a3b-q8_0
  # This deployment uses Nova's mesh address rather than the runner's
  # localhost. Replace it with an Ollama endpoint reachable from your runner.
  base_url: http://nova.mesh:11434
  timeout_seconds: 600
  context_size: 65536

review:
  review_drafts: false
  second_pass: true
  max_diff_bytes: 200000       # per context-limited file batch
  max_batches: 20              # explicit cap; omitted files are reported
  exclude_paths:
    - vendor/**                # generated/vendor paths to omit deliberately
  max_reply_bytes: 12000       # bounded human replies after the prior AI review
  comment_trigger: false      # opt in to /ai-review PR comments
  rereview_users: []           # allowed usernames in addition to the repo owner
  bot_users: []                # other automation accounts to exclude from replies
  minimum_confidence: medium   # medium or high
  formal_review: false         # submit a formal PR review instead of an issue comment
  allow_approval: false        # grant approval authority explicitly
  allow_request_changes: false # grant blocking-review authority explicitly
  min_approval_confidence: high # medium or high; independent of minimum_confidence

guidance:
  max_bytes: 60000

analysis:
  commands:
    - name: tests
      command: nix flake check
      timeout_seconds: 900
      max_diagnostics: 50      # bounded structured output; raw tail is retained

Only commands in the trusted base-revision configuration may run. Each command has a timeout; its output is bounded before being sent to the model and is reported separately from AI findings.

Requesting another review

Push-based reviews remain the default. To enable explicit comment requests, set review.comment_trigger: true in the base branch configuration and use the updated workflow example. The workflow must be on the default branch for Forgejo to generate issue_comment events (Forgejo event reference). This repository enables the option for its owner.

Post explanatory feedback as an ordinary PR comment, then post a separate comment containing exactly /ai-review. The repository owner and usernames in review.rereview_users may request a review. For organization repositories, list the individual maintainers explicitly. Use a dedicated publishing account whose token can read its own /user identity as well as the repository and write the review/comment; it must be distinct from the humans requesting reviews. No repository-administration permission lookup is required.

Ordinary discussion, edited/deleted comments, command arguments, the publishing account, and detected bot accounts never trigger a review. List automation accounts that Forgejo represents as ordinary users in review.bot_users. Human replies after the latest automated report are bounded by max_reply_bytes and included in both review passes as untrusted evidence. Formal-review mode also uses the latest bot-authored formal report as the discussion baseline. If no previous report exists, the bounded human discussion is supplied as the initial context.

The preparation step validates comment/manual requests before checkout and resolves the PR head through the API. Comment and manual requests cannot bypass fork protections; closed/merged PRs and disabled drafts are skipped. The review step checks that the checkout and API head still match that resolved SHA before running checks. If the head changed in between, request another run. Comment-event CLI runs, including --dry-run, require a Git checkout at the resolved PR head. --prepare validates the request without requiring a checkout or running checks or models. Queued push reviews whose event head has been superseded are skipped with a clear reason before any checks or model calls; a mismatched checkout still fails.

Keep the example's per-PR concurrency group with cancel-in-progress: false: requests arriving during a review queue behind it in Actions. Completed comment requests record a fingerprint of the head commit, PR description/title, and human discussion. Repeating /ai-review with the same context skips model work; new or edited human feedback permits another review of unchanged code. Bot comments and command comments do not change the fingerprint. Failed reviews do not record completion and can be retried. Push reviews preserve the advisory report's last comment-request fingerprint, including on reopening or marking an unchanged PR ready for review. This coordination relies on Forgejo workflow concurrency; standalone CLI invocations must be serialized by their caller.

Accepted and ignored requests report their reason in the Actions log and step summary. With comment triggers enabled, both push and comment reviews update the current publishing account's single advisory comment. Changing that account starts a new report; archive the old account's report manually if necessary. Reports authored by another account are not edited or trusted for deduplication. Formal mode retains its existing behaviour of submitting a new commit-linked review. The workflow's manual dispatch remains available without enabling comment triggers and deliberately bypasses comment-request deduplication.

Formal pull-request reviews

By default, the reviewer creates or updates its advisory issue comment. Set review.formal_review: true in the base revision configuration to publish the same report through pulls/{number}/reviews, tied to the reviewed head commit. Each run submits a new formal review; previous reviews remain in the PR history. These options cannot be enabled by changing configuration in a PR.

Formal reviews use COMMENT unless decision authority is explicitly granted:

  • allow_request_changes: true submits REQUEST_CHANGES when validated blocking findings remain. Important findings and failed checks alone use COMMENT and retain the Requires further work verdict.
  • allow_approval: true permits APPROVED (Forgejo's API spelling) only for a Ready to merge verdict, passing configured checks, complete diff coverage, and no unresolved questions or reported limitations. Drafts and runs without reviewable files cannot receive approval.
  • Approval also requires no validated findings of any severity at or above min_approval_confidence (default high). This filter is independent of minimum_confidence, so hiding a finding from the report cannot grant approval. A medium-confidence suggestion can permit approval at high, but prevents it at medium.

formal_review: false takes precedence over both authority flags. Formal reviews require a token with permission to write PR reviews; use a dedicated bot account distinct from the PR author. Branch-protection rules determine whether that account's approval counts toward merge requirements.

Each command can additionally set these execution limits. The defaults are intended for ordinary checks and can be raised only where a trusted repository configuration genuinely needs it:

analysis:
  commands:
    - name: tests
      command: nix flake check
      timeout_seconds: 900
      cpu_limit_seconds: 900  # defaults to timeout_seconds
      memory_limit_mb: 16384  # defaults to 16384 (virtual address space)
      max_processes: 4096     # defaults to 4096

On POSIX runners, checks receive a minimal environment (not action secrets), run in a separate process group, and have CPU, address-space, and process limits applied. A timeout kills that process group, including child processes. RLIMIT_NPROC counts every thread owned by the runner UID, including workloads outside a job's process namespace, so the default leaves headroom for shared runners while retaining a finite ceiling. Use a lower value on isolated runners. Their bounded output is redacted for common token, password, secret, and API-key assignments before it is included in the review comment. These controls are defence in depth, not a substitute for an isolated runner: checks execute untrusted pull-request code.

Large pull requests

The reviewer never takes an arbitrary prefix of a large diff. It orders files deterministically, prioritising security-sensitive paths (such as auth, credentials, permissions, and crypto) before other manually written files, then reviews them in max_diff_bytes batches. exclude_paths uses Python fnmatch patterns for deliberately omitted generated or vendor content; as in fnmatch, * can match /, so use specific prefixes such as vendor/**.

The downloaded unified diff is spooled to temporary storage by file section, so it is not retained as one unbounded in-memory string; only the selected batch is loaded into a model prompt.

max_batches bounds total model work. exclude_paths normally uses a YAML list, but a single path string (or comma-separated path strings) is accepted for concise configurations. Any excluded file, unavailable/binary patch, batch-cap omission, or oversized single-file partial review is named in the final Diff coverage section with its reason.

Changed files for the pull request are collected across paginated API requests (up to a safety cap of 100 pages at 50 files per page). If the retrieved list falls short of Forgejo's reported changed_files count, or if pagination terminates at the safety cap, the shortfall is reported under Review limitations. As with all review limitations, this prevents an automated APPROVED event when allow_approval: true.

Discussion comments and formal-review baselines are also paginated, at 50 items per page. If 100 full pages are fetched from either endpoint, the run fails with Forgejo discussion pagination limit reached and publishes no report. This applies to push reviews as well as comment requests; an incomplete discussion cannot safely establish the reply context or deduplicate a request.

On later runs, non-automated comments posted after the preceding automated review are supplied as bounded, untrusted context (max_reply_bytes). This lets a human explain why a finding is not applicable without treating either human prose or the prior automated review as instructions or authority.

Providers

ollama is the default provider and uses base_url plus model. An OpenAI-compatible endpoint is also available when explicitly configured:

provider:
  type: openai-compatible
  model: luna
  base_url: https://provider.example/v1
  api_key_env: AI_REVIEW_PROVIDER_TOKEN
  timeout_seconds: 600

The API key is read only from the named runner environment variable; never put it in .forgejo/ai-review.yml. Supply it from a Forgejo secret in the review step or job environment:

env:
  AI_REVIEW_PROVIDER_TOKEN: ${{ secrets.AI_REVIEW_PROVIDER_TOKEN }}

base_url must include the provider's API-version prefix when it needs one (for example, /v1); the reviewer appends /chat/completions.

Headless Pi reviews

For reviews that need to investigate callers, definitions, and tests beyond the diff, install and authenticate Pi on the runner and configure:

provider:
  type: pi                    # agent-cli is also accepted
  command: pi                  # executable path/name; no shell syntax
  model: strata/strata          # default for Pi when omitted
  timeout_seconds: 900
  max_output_bytes: 1048576    # maximum accepted JSON report size
  env_vars:                   # explicitly forward provider credentials if needed
    - AI_REVIEW_PROVIDER_TOKEN

provider.type chooses the review backend (pi, opencode, agent-cli, ollama, or openai-compatible). For Pi, provider.model uses Pi's provider/model selector, so both the inference provider and model are configurable. The default strata/strata refers to this deployment's configured Strata provider; other users must select a model available in their own Pi installation. The default backend remains Ollama unless type: pi is explicitly configured. This repository's configuration selects Pi with strata/strata on the vega host runner and enables formal reviews with approval authority (allow_approval: true). Request-changes authority is enabled for validated blocking findings. Vega's runner must be registered with that label, and its service user must be able to use the system Pi wrapper and Strata credentials. Branch-protection rules determine whether this approval satisfies merge requirements. Provider and formal-review settings take effect when merged into the base branch; workflow runner changes can affect the PR's own checks. Strata was faster than Nova's Qwen 3.8 on a small live regression and clean-control sample; both produced valid reports and the same severity decisions.

Run pi --list-models as the same runner user to discover the available provider names and model IDs. Then set the selector in the trusted base-branch .forgejo/ai-review.yml. Examples:

# This deployment's Nova gateway exposes Qwen 3.8 through Pi's pangolin provider.
provider:
  type: pi
  model: pangolin/qwen3.8:27b
  timeout_seconds: 900

For another Pi installation, replace the selector with <provider-name>/<model-id> from its catalogue. Pi uses its own provider configuration and authentication; the HTTP base_url option applies to the lightweight HTTP backends, not Pi. Provider API keys can be supplied through the trusted env_vars list or Pi's existing runner-user authentication.

The default invocation uses Pi's --print --no-session --tools read,grep,find,ls and --model, with the full review prompt attached as a temporary file. The agent runs in the current checkout, receives the same diff, guidance, check results, and JSON schema as the lightweight providers, and can inspect the surrounding codebase. Findings must still identify defects in changed files. The checkout must contain the PR head. Existing diff batching and optional second-pass validation also apply to CLI agents.

The final stdout response must contain a JSON review object with summary, findings, questions, and limitations. Findings require the standard severity, title, path, line, evidence, impact, remediation, and confidence fields. The reviewer rejects incomplete reports rather than interpreting them as clean reviews. It then applies the normal confidence filtering, deduplication, verdict calculation, and publishing rules.

If a completed Pi/agent-cli response contains invalid JSON or fails the report schema, the reviewer retries once using a fresh invocation and the remaining timeout_seconds budget. It reports JSON line/column positions or the failed schema requirement without logging model output. A second invalid response fails the job without publishing. CLI failures, timeouts, missing artifacts, output-size limits, and OpenCode event errors are not retried.

Use provider.args to customise Pi's invocation or use a trusted wrapper. Each list entry is one argument; arguments are never evaluated by a shell. Templates accept {model}, {prompt}, {prompt_file}, {output_file}, and {root}. Prefer {prompt_file} for large prompts; escape literal braces as {{ and }}. For example, a wrapper which writes a JSON report can use:

provider:
  type: agent-cli
  command: review-agent-wrapper
  model: provider/model
  timeout_seconds: 900
  output_file: .forgejo/review-output.json
  args:
    - --model
    - '{model}'
    - --prompt-file
    - '{prompt_file}'
    - --output
    - '{output_file}'

Using {output_file} selects artifact mode: the agent must write literal JSON to that path, and stdout progress is ignored. output_file is a relative name inside a fresh temporary directory, not a file in the checkout; artifacts are removed after the run and cannot reuse a stale PR-provided report. Without that placeholder, the reviewer parses stdout. Pi's text print mode returns the final response; raw JSON event streams are not accepted as review reports.

OpenCode reviews

OpenCode has a bundled adapter; users do not need to supply a wrapper. Install opencode on the runner and configure its providers and authentication as the runner user. Run opencode models to discover selectors, then set the trusted base-branch .forgejo/ai-review.yml:

provider:
  type: opencode
  model: your-provider/your-model
  timeout_seconds: 900
  # command: /path/to/opencode  # optional executable override
  # env_vars: [YOUR_PROVIDER_API_KEY]  # if required by the provider

The model is required: Pi's deployment-specific default is not used for OpenCode. Provider endpoints belong in OpenCode's runner configuration; the reviewer's HTTP base_url option does not configure them. Forward OPENCODE_CONFIG through env_vars to select a custom OpenCode config file. The executable is a separate runner dependency; the adapter ships with both the Python script and the Nix package.

The default invocation is opencode run --pure --format json --agent forgejo-review --model <selector> --file <temporary-prompt> -- <message>. The adapter supplies a dedicated agent permitting read, grep, glob, and list, with other permissions denied, sharing disabled, and updates disabled. It reserves OPENCODE_CONFIG_CONTENT for these settings. OpenCode's other runner and project configuration still follows its own loading rules; use an isolated runner as described below. These controls are not an OS sandbox.

Only text from the final step completed with reason stop becomes the review. Tool output, reasoning, and earlier responses are ignored. Errors, truncated streams, token-limit endings, invalid reports, timeouts, and oversized streams fail before publication. The supported event types are step_start, text, step_finish, error, tool_use, and reasoning; unknown or missing types also fail before publication so protocol changes require adapter validation. max_output_bytes bounds the accepted whole event stream, including tool output (default 1 MiB). Custom args must preserve JSON event output and the selected agent; {output_file} is unsupported for type: opencode. Use type: agent-cli for other wrapper protocols.

OpenCode 1.18.35 was checked against a local fixture API, including a real file-read tool call and final report extraction. This checks CLI integration; the model comparison above used Pi. To repeat the optional integration check without sending code to an inference provider, use the raw OpenCode executable:

OPENCODE_TEST_COMMAND=/absolute/path/to/opencode \
  python3 -m unittest discover -s tests -p test_opencode_smoke.py

The smoke check uses an isolated temporary home and a loopback API with a dummy credential. It requires permission to open a local listening socket.

The child receives a small environment for executable lookup and agent configuration, plus explicitly listed env_vars. Publishing token variables cannot be forwarded. Agent authentication already stored in its runner home remains accessible. Run agents on an isolated runner without unrelated secrets; CLI tools, extensions, and project configuration are subject to the selected agent's own controls. Pi's default built-in tool selection permits navigation; it is not an operating-system sandbox. Custom artifact-writing wrappers must provide appropriate restrictions and keep source files unchanged.

A timeout kills the process group and reaps the agent. Startup errors, non-zero exits, missing artifacts, malformed reports, and oversized reports stop the action with a concise error. CLI logs and prompt text are not included in failure messages, and a failed agent run does not publish a clean review or silently switch providers. Ollama and OpenAI-compatible modes remain available.

Repository guidance

The reviewer reads available files in this order:

  1. .forgejo/ai-review.md
  2. AGENTS.md
  3. CONTRIBUTING.md
  4. SECURITY.md
  5. README.md

Guidance, pull-request descriptions, source code, file names, and diffs are all treated as untrusted evidence. They cannot override the reviewer’s system instructions.

Review output

The single automated comment contains:

  • reviewed commit SHA and an objective-completion summary;
  • blocking, important, and suggestion findings with evidence, impact, a suggested remediation, and confidence;
  • deterministic check results, questions, and review limitations; and
  • model and guidance metadata in a collapsible section.

The marker <!-- forgejo-ai-review:v1 --> lets a later run update the same comment, removing findings that no longer appear in the new review.

Security and privacy

  • The model never receives the Forgejo token or runner secrets.
  • The model cannot execute commands or modify the repository.
  • Review commands come only from trusted configuration, not PR content.
  • Fork-originated pull requests must not receive the comment token. The example workflow skips them by default.
  • A self-hosted Ollama endpoint is the default and keeps source context within your own infrastructure. An explicitly configured OpenAI-compatible provider receives the review prompt, repository guidance, deterministic-check output, and diff at its configured endpoint; assess that provider's privacy terms before enabling it.
  • Avoid enabling prompt/debug logging: prompts can contain proprietary source code and pull-request text.

Permissions and advisory failure behaviour

Create a dedicated token with repository-read and issue-comment write access. When review.comment_trigger: true, also grant user-read access to the token's own /user identity; push and comment reviews both require it. Formal reviews need PR-review write access as well. See Requesting another review. Keep it in a repository secret and never expose it to fork-originated pull requests; the example workflow skips forks. Repository administrators should also restrict which runners can receive the job, since deterministic checks execute pull-request code.

With the default configuration, the action remains advisory: a failed deterministic check is shown in the review comment and makes its verdict Requires further work, but does not by itself fail the action. The action fails only when it cannot complete the review (for example, Forgejo, the provider, or invalid trusted configuration). Use ordinary CI checks as merge gates.

Container image

The included Dockerfile builds a dependency-free, non-root image for runners or scheduled jobs that want to invoke the reviewer directly:

docker build -t forgejo-ai-review:dev .
docker run --rm --user 65532:65532 \
  --cap-drop=ALL --security-opt=no-new-privileges \
  -v "$PWD:/workspace" -w /workspace \
  -e GITHUB_EVENT_PATH -e GITHUB_REPOSITORY -e GITHUB_API_URL \
  -e FORGEJO_TOKEN \
  forgejo-ai-review:dev --dry-run

The image intentionally does not contain Nix, compilers, or repository-specific tools. Use a purpose-built runner image when configured deterministic checks need them; retain the non-root user, minimal privileges, and isolated runner boundary. Version published images with immutable release tags (for example v1.0.0) and optionally move a major tag (such as v1) after validation.

This repository's image workflow runs on every pushed commit. It publishes git.nimmog.uk/nimmo/forgejo-auto-pr-review:latest and :stable from main; other branches receive a normalised branch-name tag for pre-merge testing. Set the PACKAGE_TOKEN repository secret to a Forgejo token allowed to write this repository's package registry namespace before merging the workflow.

Nix

NixOS and other Nix users can run the dependency-free CLI directly:

nix run git+https://git.nimmog.uk/nimmo/forgejo-auto-pr-review

The flake exposes packages.<system>.default, apps.<system>.default, a development shell containing Python, and a unit-test check. For a checked-out copy, run nix flake check to execute the same unit suite used by CI.

This action is advisory by default. Deterministic test failures remain the responsibility of normal CI; repositories granting formal decision authority should account for automated reviewers' false positives and incomplete context.

Local development

Run the lightweight unit tests:

python3 -m unittest discover -s tests

For a local dry run, provide the Forgejo event JSON, API URL, repository slug, token, and pull-request number as necessary. The command never publishes when --dry-run is set:

python3 reviewer.py \
  --event /path/to/event.json \
  --repo owner/repository \
  --api-url https://forgejo.example/api/v1 \
  --token "$FORGEJO_TOKEN" \
  --dry-run

For an issue_comment event, run from a Git checkout at the PR's current head, including for a dry run: checks still execute and the checkout guard still applies. Add --prepare to validate the request and resolve its head without requiring a checkout, running checks, or calling a model.

Roadmap

Issue #1 is the umbrella specification. The Forgejo AI PR Review v1 milestone tracks the remaining work: provider abstraction, large-PR coverage, normalized analysis and deduplication, test fixtures, execution hardening, and expanded documentation.