Introduce AI review chat integration with OpenRouter

Add a Groovy script implementation of AiReviewProvider that wires the
Gerrit AI Code Review chat to OpenRouter (https://openrouter.ai/), a
unified gateway exposing 300+ LLMs from Anthropic, OpenAI, Google,
DeepSeek, Meta, Qwen, xAI and others behind a single OpenAI-compatible
API.

The provider builds the dropdown at runtime from a small static list of
OpenRouter floating aliases (`~vendor/model-latest`, always-fresh paid
options) combined with a live `/api/v1/models` query that picks the
highest-versioned DeepSeek `*-pro` slug and the top five free-tier
slugs by a code-review heuristic (id keywords, reasoning support,
big-vendor namespace, context length). The catalog result is cached
for a day via Guava's memoizeWithExpiration and invalidated when a
review call returns HTTP 404 (a previously listed slug went away
upstream). On catalog fetch failure the dropdown falls back to the
static floating aliases so it is never empty.

The script also handles a few OpenRouter-specific quirks:

* Single retry on HTTP 429 with a fixed back-off, followed by a
  user-facing rate-limit notice rendered as the assistant reply when
  the retry budget is exhausted, instead of surfacing a generic
  HTTP 500 in the chat panel.
* Strip an outer triple-backtick markdown fence when the entire reply
  is wrapped in one, since gr-formatted-text would otherwise render
  the response as a literal code block (observed with the
  openai/gpt-oss-* models).
* Prefix every non-empty reply with a newline so the response renders
  on its own line, separated from the "Gathering file contents and
  calling AI model ..." placeholder produced by the provider plugin.

Add a companion README documenting installation, the dynamic model
selection scheme, and OpenRouter API key setup.

Change-Id: Ieaae90717b5c56e053d31eda4f4b286d7c1a366c
2 files changed
tree: 756e979ca36534e7dad0685313dd76869a9eb19c
  1. admin/
  2. ai/
  3. multi-primary/
  4. replication/
  5. .gitignore
  6. README.md
README.md

Gerrit scripting plugins collection

Overview

This repository contains a collection of Gerrit scripting plugins that are intended to provide simple and useful extensions.

How to run the scripting plugins

Gerrit needs to be able to recognise the scripts syntax and being able to load them as plugins.

In order to be able to run Groovy scripts, you need to install first the Groovy scripting provider and then copy the Groovy scripts under your Gerrit /plugins directory.

Similarly for Scala scripts, you need to install the Scala scripting provider and then copy the Scala scripts under your Gerrit /plugins directory.

Administration Scripts

Gerrit multi-primary Scripts