Files
CV_Site_Nuxt/deploy/pr-agent/README.md
T
Noel Sabia 636a65dd05
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Successful in 1m10s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Successful in 8s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
docs(pr-agent): record the first successful review
The key is wired into the live server .env; glm-5.3-flash returned OK and /review on PR #28 posted a PR Reviewer Guide.
2026-10-30 21:28:05 +01:00

4.1 KiB

PR-Agent for Gitea

PR-Agent runs as a webhook server next to Gitea on server0. Gitea sends pull-request and comment events over the gitea_gitea Docker network; the endpoint is not published to the internet.

Piece Value
Image pragent/pr-agent:0.49.0-gitea_app
Container pr-agent
Webhook URL, from Gitea http://pr-agent:3000/api/v1/gitea_webhooks
Config /opt/pr-agent/.env (root, mode 600)
Logs ssh … agent@server0 logs
Deploy / restart ssh … agent@server0 deploy
Status ssh … agent@server0 status
Upgrade edit the root-owned compose file, then run deploy

The table describes the target state. The live stack is still at /home/noel/self-hosted/pr-agent and is managed with noel's SSH key until setup-agent-access.sh has been run.

Gitea side

  1. The bot user pr-agent is a collaborator on CV_Website/CV_Site_Nuxt with write permission. Its personal access token is scoped to read:repository, write:issue and read:user.
  2. The repository webhook sends push, issues, pull_request and issue_comment events, with JSON content type and the shared secret.
  3. Gitea's [webhook] ALLOWED_HOST_LIST includes private:3000. Without it, Gitea's default egress policy refuses webhook deliveries to private addresses, including the Docker network.

Operator access

The agent does not log in as noel. A dedicated agent account has one forced command and three actions:

ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 status
ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 logs
ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 deploy

The SSH key is restricted with restrict,command=…; the account has no Docker group, no general sudo, and no shell. Sudo permits only the three root-owned helper scripts in /usr/local/sbin, and those helpers operate on the fixed /opt/pr-agent/docker-compose.yml. The compose file, .env and helpers are root-owned, so the agent cannot turn “restart” into a different container or a host mount.

setup-agent-access.sh creates the account and moves the stack to /opt/pr-agent. remove-noel-access.sh then removes the inherited access from noel: the docker and sudo groups, the keys in /home/noel/.ssh/authorized_keys, and the old PR-Agent directory. Run both on the server as root, and only run the second after the restricted command works and you have another admin path.

For git, use a repository-scoped deploy key instead of the personal Gitea key: ~/.ssh/pr_agent_gitea.pub is added as a write deploy key on CV_Website/CV_Site_Nuxt. The old personal key must be removed from Gitea, or it still grants every repository the user can see.

AI model

The agent uses OpenCode Go's OpenAI-compatible endpoint:

model          openai/glm-5.3-flash
fallback       openai/glm-5.3
api base       https://opencode.ai/inference/go/openai/v1

CONFIG__CUSTOM_MODEL_MAX_TOKENS tells PR-Agent the context limit, because the model is not in its token table. The effective review budget is still capped by PR-Agent's default config.max_model_tokens of 32000.

OpenCode Go requires an x-opencode-session header; PR-Agent sends the stable id pr-agent through LITELLM__EXTRA_HEADERS.

The API key lives only in the server's .env, never in the repo. Set OPENAI__KEY in the live /home/noel/self-hosted/pr-agent/.env until the /opt migration has run; afterwards use /opt/pr-agent/.env and the deploy helper.

First check

Open a pull request in CV_Website/CV_Site_Nuxt. The server runs /describe and /review on open/reopen; comment commands such as /review, /improve and /ask are handled from the PR conversation. /improve is deliberately on demand: adding it to the auto list would make a second model call and a second comment for every PR. If nothing appears:

ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 logs

A 403 in the Gitea webhook delivery log means the secret does not match or ALLOWED_HOST_LIST is still missing; a 401 from PR-Agent means the signature header and secret disagree.