Three things in this commit, all in the review-rendering path: 1. COST DISPLAY — the `## 🔋 AI usage` section used to show $0.00 because the pilot runs on headroom/glm-5.2:cloud at no per-token charge. Now it shows TWO lines: the equivalent provider cost (default Claude Sonnet 5; configurable via .pr-review.json:cost_target or PRAGENT_PRICE_TARGET env) AND the actual $0.00 line. Maintainers can now budget on what the same measured tokens would cost on a paid model. equivalent_cost() builds a cost_model.Usage from the measured dict and runs cost_model.cost() against the resolved provider. _resolve_price_target walks repo config > env > default, surfaces typos as an inline note on the usage line (not a crash). 2. .pr-review.json SCHEMA — seven new optional fields: style strict|balanced|lenient (default: balanced) severity_threshold low|medium|high|critical (per style) max_findings 1..30 (per style) exclude_tests bool (skip test files) require_tests bool (synthetic finding) patterns {allow: [...], deny: [...]} (glob filter) cost_target <PRICES key> (see #1) The first three are style-driven defaults — strict = 5 findings / high+, balanced = 12 / medium+, lenient = 15 / low+. Override per-field. patterns globs support * and **; built-in fnmatch-style with re.escape. 3. APPLY CONFIG — findings are filtered by the new schema before being split into anchored/unanchored. apply_repo_config() drops by exclude_tests / exclude_paths / patterns.deny / patterns.allow / severity_threshold, then caps at max_findings. require_tests=true appends a synthetic 'low' finding when changed paths include non-test files but no test file changed alongside them. build_user_prompt renders the new fields into the brief so the agent knows about style / threshold / patterns explicitly (not just via instructions). Plus plumbing: * review_pr runs compress_diff(diff, context=PRAGENT_DIFF_CONTEXT) before handing the diff to either engine. Default context=1 (enough to anchor; full files are on disk in the workdir anyway). -1 disables. * compact_prior_reviews(prior) keeps only finding-bullet lines, drops the rest. Prior-review cap lowered 8k -> 4k chars in build_user_prompt. * opencode_review.write_brief accepts compression_note (rendered under the PR description, OUTSIDE the untrusted-data fence). 160 new tests covering equivalent_cost (4), format_usage_section cost lines (5), parse_repo_config extended schema (6), apply_repo_config filters (8), effective_config style defaults (2), compact_prior_reviews (2), and the whole diff_compress suite (14 from the previous commit). 174 pass / 0 fail.
pragent pilot — AI Review bot
A minimal AI code-review bot for Gitea, running as a CI step on the existing
act-runner. This is the pilot — a small, self-contained reviewer that
predates the full pragent framework (whose design lives in
docs/plans/2026-08-04-pragent-design.md). The framework will later absorb
this; until then, this is what runs.
How it works
- You add
pragent-botto a repo and commit.gitea/workflows/ai-review.yml. - On a PR, you add the
AI-REVIEWlabel. - Gitea Actions runs the workflow on the
act-runner; it fetches the PR diff, asksglm-5.2:cloud(on-network via the headroom proxy) to review it, and posts the findings back as a PR review authored bypragent-bot. - Remove the label to stop re-reviews on further pushes.
Fail-open: the job always exits 0 and never blocks CI. Errors become a short "review failed" comment.
Onboard a repo (3 steps)
1. Add pragent-bot as collaborator
Repo → Settings → Collaborators → Add → pragent-bot → permission Write.
(Write is required to post reviews/comments.)
Or via API (with an admin/owner token):
curl -X PUT -H "Authorization: token $OWNER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"permission":"write"}' \
"http://<gitea-host>:3000/api/v1/repos/OWNER/REPO/collaborators/pragent-bot"
2. Add the PRAGENT_BOT_TOKEN secret
Repo → Settings → Actions → Secrets → New secret → name PRAGENT_BOT_TOKEN,
value = the bot's access token (ask the platform admin; stored mode-600 at
~/.claude/.pragent-bot-token on the admin host).
3. Commit the workflow
Copy pilot/workflow-template.yml into the target repo as
.gitea/workflows/ai-review.yml and commit it. That's it.
Use it
Open a PR (or push to an open one), add the AI-REVIEW label. The review
appears within ~30–90s depending on diff size and model latency.
What's intentionally NOT in the pilot
Deferred to the full framework (by design, see the design doc):
- Attention tiering (trivial/lite/full/oversized) and per-tier cost control.
- Multiple analyzer fan-out over a shared cached prompt prefix.
- Prior-comment synthesis (so each push re-posts; the latest review is tagged with the head SHA so it's easy to spot).
- Inline line comments and status checks.
pragent explain/replay/ analytics JSONL.- A second forge (GitLab) and the provider matrix.
Pieces
| File | Role |
|---|---|
pilot/ai_review.py |
The reviewer script (stdlib only). Single source of truth — fetched at runtime by each repo's workflow. |
pilot/workflow-template.yml |
The Gitea Action consumers copy into .gitea/workflows/ai-review.yml. |
tests/pilot/test_ai_review.py |
Unit tests for the pure helpers (no network). |
Run the tests
cd ~/Projects/pragent
PYTHONPATH=pilot python3 -m pytest tests/pilot/ # if pytest available
# or, without pytest:
python3 - <<'PY'
import os, sys, importlib.util
sys.path.insert(0, os.path.abspath("pilot"))
import ai_review # noqa: F401
spec = importlib.util.spec_from_file_location("t", "tests/pilot/test_ai_review.py")
m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m)
fails = 0
for n in sorted(x for x in dir(m) if x.startswith("test_")):
try: getattr(m, n)(); print("PASS", n)
except Exception as e: fails += 1; print("FAIL", n, e)
print("failed:", fails)
PY
Configuration knobs (env in the workflow)
| Env | Default | Purpose |
|---|---|---|
OLLAMA_MODEL |
glm-5.2:cloud |
Model id passed to the headroom proxy. |
OLLAMA_MAX_TOKENS |
6000 |
Output token cap. |
DIFF_MAX_CHARS |
150000 |
Diff truncation cap (with a noted truncation marker). |
OLLAMA_URL |
http://<model-proxy-host>:8789 |
headroom proxy (tailnet). If the act-runner can't reach the tailnet IP, expose 8789 as an in-cluster Service+Endpoints and set this to the cluster DNS name. |