Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dfa2c8aa6 | ||
|
|
8b7d9bce81 | ||
|
|
da28885588 | ||
|
|
723c38d2e3 | ||
|
|
636a65dd05 |
No files matched your search
@@ -7,7 +7,9 @@ name: Renovate
|
||||
# Manual setup: create a bot account with its full name and email set, give
|
||||
# it write access to this repository, and store a token with
|
||||
# repository read/write, issue read/write, user read and organization read
|
||||
# as the RENOVATE_TOKEN Actions secret.
|
||||
# as the RENOVATE_TOKEN Actions secret. Release notes also need a github.com
|
||||
# token (any account, read-only, no scopes for public repositories) as the
|
||||
# RENOVATE_GITHUB_COM_TOKEN secret.
|
||||
on:
|
||||
schedule:
|
||||
# Daily at 04:00 UTC. Gitea only schedules workflows that exist on the
|
||||
@@ -35,6 +37,10 @@ jobs:
|
||||
# default branch through this endpoint.
|
||||
RENOVATE_ENDPOINT: https://git.noelsabia.dev/api/v1
|
||||
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
|
||||
# github.com is only used to fetch release notes and other public
|
||||
# metadata. Anonymous requests are rate-limited, which is why the
|
||||
# PR body warned that release notes were skipped.
|
||||
RENOVATE_GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GITHUB_COM_TOKEN }}
|
||||
# This workflow lives in the repository it updates, so scope the bot
|
||||
# to it instead of every repository its account can see.
|
||||
RENOVATE_REPOSITORIES: CV_Website/CV_Site_Nuxt
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
---
|
||||
type: Decision
|
||||
title: PR-Agent for Gitea reviews
|
||||
description: A pinned PR-Agent webhook server on server0 reviews pull requests through a scoped Gitea bot user, replacing the per-PR opencode job.
|
||||
description: A pinned PR-Agent service inside the Gitea compose stack reviews pull requests through a scoped Gitea bot user, replacing the per-PR opencode job.
|
||||
tags: [decision, ci, ai, gitea, pr-agent, security]
|
||||
status: draft
|
||||
generated: { by: opencode-go/deepseek-v4.1-flash, at: 2026-10-30T20:00:00Z }
|
||||
verified: { by: human:noel, at: not yet }
|
||||
sources:
|
||||
- id: compose
|
||||
resource: deploy/pr-agent/docker-compose.yml
|
||||
title: PR-Agent compose service
|
||||
- id: env-example
|
||||
resource: deploy/pr-agent/.env.example
|
||||
title: Environment variables, without secrets
|
||||
- id: gitea-compose
|
||||
resource: /home/noel/self-hosted/gitea/docker-compose.yml
|
||||
title: Gitea compose stack, pr-agent service
|
||||
- id: operations
|
||||
resource: OKF_Nuxt/pr-agent.md
|
||||
title: PR-Agent operations and configuration
|
||||
- id: pr-checker
|
||||
resource: .gitea/workflows/pr-checker.yml
|
||||
title: PR Check workflow, opencode job removed
|
||||
@@ -30,10 +30,13 @@ sources:
|
||||
# Decision
|
||||
|
||||
PR-Agent runs as `pragent/pr-agent:0.49.0-gitea_app` in a long-lived
|
||||
container on `server0`, attached to the existing `gitea_gitea` Docker
|
||||
network. It publishes no ports. Gitea delivers pull-request and comment
|
||||
events to `http://pr-agent:3000/api/v1/gitea_webhooks`; the bot user
|
||||
`pr-agent` posts the result with a scoped personal access token.
|
||||
container on `server0`, as the `pr-agent` service in the Gitea compose
|
||||
stack. It attaches to the existing `gitea_gitea` Docker network and
|
||||
publishes no ports. Gitea delivers pull-request and comment events to
|
||||
`http://pr-agent:3000/api/v1/gitea_webhooks`; the bot user `pr-agent`
|
||||
posts the result with a scoped personal access token. The service
|
||||
definition lives in `/home/noel/self-hosted/gitea/docker-compose.yml`; the
|
||||
operator guide is [PR-Agent operations](../pr-agent.md).
|
||||
|
||||
The opencode review job is removed from `pr-checker.yml`. PR-Agent runs
|
||||
`/describe` and `/review` on pull request open/reopen and answers slash
|
||||
@@ -85,31 +88,32 @@ provider rejects the request before it reaches the model.
|
||||
* Auto commands are `/describe` and `/review`. `/improve` stays available
|
||||
on demand; the default auto list would add a second model call and a
|
||||
second comment to every PR.
|
||||
* Secrets live only in `/home/noel/self-hosted/pr-agent/.env` (mode 600) on
|
||||
`server0`. The repository contains the compose file and an example env
|
||||
file, never the token or webhook secret.
|
||||
* Secrets live only in `/home/noel/self-hosted/gitea/pr-agent.env` (mode
|
||||
600) on `server0`. The repository contains the decision and the operator
|
||||
guide, never the token, webhook secret or model key.
|
||||
|
||||
# Evidence
|
||||
|
||||
* 2026-10-30: a direct `glm-5.3-flash` call through the handler returned
|
||||
`OK`, and `/review` on PR #28 posted a PR Reviewer Guide through the Gitea
|
||||
comment API. The key is set only in `gitea/pr-agent.env`.
|
||||
|
||||
# Not verified
|
||||
|
||||
* The OpenCode Go API key was not present when this was committed, so no
|
||||
model call has completed. A dummy-key call now reaches the provider's
|
||||
authentication check instead of failing on the missing session header,
|
||||
so the remaining blocker is the credential. The first PR after the key is
|
||||
set is the real verification.
|
||||
* Whether `glm-5.3-flash` handles PR-Agent's structured review output well
|
||||
enough. `glm-5.3` is configured as the fallback.
|
||||
* Whether the model finds the same class of issues as the opencode prompt on
|
||||
larger diffs. The first review found none; `glm-5.3` remains the fallback.
|
||||
* Whether two gunicorn workers and the 1 GB memory limit hold under
|
||||
concurrent reviews. The host has roughly 2.5 GB available with Gitea and
|
||||
its runner idle.
|
||||
* Whether the default review prompt is specific enough for this repository.
|
||||
A `.pr_agent.toml` with project instructions is deliberately absent until
|
||||
the first real review shows what it misses.
|
||||
a real review shows what it misses.
|
||||
|
||||
# Revisit when
|
||||
|
||||
* The first review fails, returns unstructured output, or misses the kind
|
||||
of finding the opencode prompt used to catch.
|
||||
* A newer `gitea_app` image tag is worth taking; bump the tag and run
|
||||
`docker compose up -d`.
|
||||
* A newer `gitea_app` image tag is worth taking; bump the tag in the Gitea
|
||||
compose file and run `docker compose up -d pr-agent` from that directory.
|
||||
* Review volume makes the container's memory limit tight, or Gitea adds a
|
||||
role that can comment without push access.
|
||||
+2
-1
@@ -11,6 +11,7 @@ config files — the configs say what, these documents say why.
|
||||
* [Open questions](open-questions.md) - What is still undecided for the Nuxt site.
|
||||
* [Backend endpoints](backend-endpoints.md) - The smallest API the frontend needs from the Go gateway: health, chapters, metrics, knockdown, events.
|
||||
* [Profile data](profile.md) - The LinkedIn export behind the terminal chapters, what is real vs mock, and how to refresh it.
|
||||
* [PR-Agent operations](pr-agent.md) - The Gitea-side review service: configuration, commands, logs and model.
|
||||
* [Future updates](future-updates.md) - Pipeline improvement backlog with effort estimates, not yet decided.
|
||||
* [Update log](log.md) - History of changes to this bundle.
|
||||
|
||||
@@ -19,7 +20,7 @@ config files — the configs say what, these documents say why.
|
||||
## CI/CD and releases (2026-10-18)
|
||||
|
||||
* [PR pipeline layering](decisions/pr-pipeline-layering.md) - Three layers: pre-commit for cheap deterministic checks, Gitea Actions for thorough ones, AI review for judgment.
|
||||
* [PR-Agent for Gitea reviews](decisions/pr-agent.md) - A pinned webhook server on server0 replaces the per-PR opencode job; internal-only, scoped bot, OpenCode Go model.
|
||||
* [PR-Agent for Gitea reviews](decisions/pr-agent.md) - A pinned review service inside the Gitea compose stack replaces the per-PR opencode job; internal-only, scoped bot, OpenCode Go model.
|
||||
* [AI review setup (opencode)](decisions/ai-review-setup.md) - Superseded 2026-10-30; kept for the env-only auth and verdict-gate reasoning.
|
||||
* [Vulnerability audit policy](decisions/vulnerability-audit-policy.md) - Blocking audit; reviewed ignore-list for unfixable advisories in pnpm-workspace.yaml.
|
||||
* [Release engineering](decisions/release-engineering.md) - release-please in manifest mode; conventional commits enforced at commit time.
|
||||
|
||||
+9
-2
@@ -1,17 +1,24 @@
|
||||
# Update Log
|
||||
|
||||
## 2026-10-30 (PR-Agent moved into the Gitea compose stack)
|
||||
|
||||
* **Refactor**: the `pr-agent` service now lives in `/home/noel/self-hosted/gitea/docker-compose.yml` with `/home/noel/self-hosted/gitea/pr-agent.env`. The separate `/home/noel/self-hosted/pr-agent` stack and the unused `/opt` operator-access scripts were removed; the service is managed with the Gitea stack.
|
||||
* **Docs**: the operator README moved to [PR-Agent operations](pr-agent.md). The decision, index and update log point at the new topology.
|
||||
* **Evidence**: after the move, the container is healthy, a signed webhook from the Gitea container returns 200, and a direct `glm-5.3-flash` call returns `OK`.
|
||||
|
||||
## 2026-10-30 (PR #28: lockfile and PR-Agent routing repaired)
|
||||
|
||||
* **Fix**: `pnpm-lock.yaml` - merging `main` left the lockfile at `@nuxt/icon` 2.6.0 while `package.json` asked for 2.6.2, so `pnpm install --frozen-lockfile` aborted in CI. The lockfile now resolves 2.6.2.
|
||||
* **Fix**: `pnpm-workspace.yaml` - `seroval` 1.6.9 was the two moderate audit findings (GHSA-f86p-h4j2-7qgj, GHSA-9wx9-5pv9-3349). The patched 1.6.11 is forced through `overrides`; the blocking audit now reports only two low-severity advisories and passes the moderate gate.
|
||||
* **Fix**: PR-Agent model routing - OpenCode Go rejects requests without `x-opencode-session`; `LITELLM__EXTRA_HEADERS` now supplies it, and the fallback keeps the `openai/` prefix. Auto commands are `/describe` and `/review`; `/improve` is on demand. A dummy-key call reaches the provider's auth check instead of failing on the missing header.
|
||||
* **State**: the OpenCode Go API key is still unset, so no real review has run. The next step is the credential, then a `/review` comment on PR #28.
|
||||
* **Evidence**: the key was wired into the live `.env`; a direct `glm-5.3-flash` call returned `OK`, and `/review` on PR #28 posted a PR Reviewer Guide (no findings). The failed-review comment was removed.
|
||||
* **State**: the key is set only in `gitea/pr-agent.env`; the first `/review` posted on PR #28 with no findings.
|
||||
|
||||
## 2026-10-30 (PR-Agent replaces the opencode review job)
|
||||
|
||||
* **Decision**: [PR-Agent for Gitea reviews](decisions/pr-agent.md) - a pinned `pragent/pr-agent:0.49.0-gitea_app` container on `server0` reviews PRs through the Gitea bot user `pr-agent`; the endpoint stays on the `gitea_gitea` Docker network.
|
||||
* **Update**: [pr-checker.yml](../.gitea/workflows/pr-checker.yml) - removed the `review` job, the opencode installer and the verdict-posting step. PR-Agent now runs `/describe` and `/review` on PR open/reopen and answers slash commands.
|
||||
* **Creation**: `deploy/pr-agent/` - compose service, example environment and operator README. The real `.env` lives only at `/home/noel/self-hosted/pr-agent/.env` (mode 600) on `server0`.
|
||||
* **Creation**: `deploy/pr-agent/` (later removed; the service now lives in the Gitea compose stack) - compose service, example environment and operator README. The real `.env` lived only at `/home/noel/self-hosted/pr-agent/.env` (mode 600) on `server0`.
|
||||
* **State**: the container is running and the webhook signature path is verified. Gitea gained `[webhook] ALLOWED_HOST_LIST = private:3000` (one restart, healthy) and the repository has a signed webhook. The OpenCode Go API key was still missing at commit time, so no model call or real review has run yet.
|
||||
|
||||
## 2026-10-27 (release-please still never tagged: the deleted head branch)
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
---
|
||||
type: Reference
|
||||
title: PR-Agent operations
|
||||
description: The Gitea-side pull-request review service, its configuration in the Gitea compose stack, and the commands it answers.
|
||||
tags: [pr-agent, gitea, operations, ci, ai]
|
||||
status: draft
|
||||
generated: { by: opencode-go/deepseek-v4.1-flash, at: 2026-10-30T20:40:00Z }
|
||||
verified: { by: human:noel, at: not yet }
|
||||
sources:
|
||||
- id: gitea-compose
|
||||
resource: /home/noel/self-hosted/gitea/docker-compose.yml
|
||||
title: Gitea compose stack, pr-agent service
|
||||
- id: install
|
||||
resource: https://docs.pr-agent.ai/installation/gitea/
|
||||
title: PR-Agent Gitea installation
|
||||
- id: gitea-egress
|
||||
resource: https://docs.gitea.com/administration/config-cheat-sheet#webhook
|
||||
title: Gitea webhook egress allowlist
|
||||
---
|
||||
|
||||
# What runs
|
||||
|
||||
PR-Agent is the `pr-agent` service inside the Gitea compose stack on
|
||||
`server0`. It listens on the internal `gitea_gitea` network at
|
||||
`http://pr-agent:3000`; no port is published. Gitea calls its signed
|
||||
webhook at `/api/v1/gitea_webhooks`, and the bot user `pr-agent` posts the
|
||||
results.
|
||||
|
||||
| Piece | Value |
|
||||
|---|---|
|
||||
| Service | `pr-agent` in `/home/noel/self-hosted/gitea/docker-compose.yml` |
|
||||
| Image | `pragent/pr-agent:0.49.0-gitea_app` |
|
||||
| Config | `/home/noel/self-hosted/gitea/pr-agent.env` (mode 600) |
|
||||
| Logs | `cd /home/noel/self-hosted/gitea && docker compose logs -f pr-agent` |
|
||||
| Restart | `cd /home/noel/self-hosted/gitea && docker compose up -d pr-agent` |
|
||||
| Upgrade | bump the image tag in the compose file, then restart the service |
|
||||
|
||||
The service is managed with the same access as the rest of the Gitea
|
||||
stack. The earlier plan for a separate `/opt/pr-agent` stack and a
|
||||
restricted `agent` account was not applied; those scripts were removed when
|
||||
the service moved into this stack. Hardening the Gitea stack's operator
|
||||
access is a separate change.
|
||||
|
||||
# Gitea side
|
||||
|
||||
1. Bot user `pr-agent` is a collaborator with write permission on
|
||||
`CV_Website/CV_Site_Nuxt`. 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 deliveries to the Docker
|
||||
network.
|
||||
|
||||
# Commands
|
||||
|
||||
| Trigger | What runs |
|
||||
|---|---|
|
||||
| PR opened or reopened | `/describe` and `/review` automatically |
|
||||
| New push to an open PR | nothing; comment `/review` or `/review -i` |
|
||||
| Comment `/review`, `/improve`, `/ask` | that command |
|
||||
|
||||
`/review -i` reviews only the commits added since the previous review.
|
||||
`/improve` stays on demand; adding it to the auto list would make a second
|
||||
model call and a second comment on every PR. Draft PRs are not skipped.
|
||||
|
||||
# Configuration
|
||||
|
||||
`pr-agent.env` holds the deployment values. The repository never contains
|
||||
the token, webhook secret, or API key:
|
||||
|
||||
```ini
|
||||
CONFIG__GIT_PROVIDER=gitea
|
||||
GITEA__URL=http://gitea:3000
|
||||
GITEA__WEB_URL=https://git.noelsabia.dev
|
||||
GITEA__PERSONAL_ACCESS_TOKEN=...
|
||||
GITEA__WEBHOOK_SECRET=...
|
||||
CONFIG__MODEL=openai/glm-5.3-flash
|
||||
CONFIG__FALLBACK_MODELS=["openai/glm-5.3"]
|
||||
CONFIG__CUSTOM_MODEL_MAX_TOKENS=128000
|
||||
OPENAI__API_BASE=https://opencode.ai/inference/go/openai/v1
|
||||
OPENAI__KEY=...
|
||||
LITELLM__EXTRA_HEADERS={"x-opencode-session":"pr-agent"}
|
||||
GITEA__PR_COMMANDS=["/describe","/review"]
|
||||
```
|
||||
|
||||
OpenCode Go requires the `x-opencode-session` header. The fallback keeps
|
||||
the `openai/` prefix; a bare `glm-5.3` is treated by LiteLLM as a
|
||||
provider-less model. `CONFIG__CUSTOM_MODEL_MAX_TOKENS` supplies the context
|
||||
limit; the effective review budget is capped by PR-Agent's default
|
||||
`max_model_tokens` of 32000.
|
||||
|
||||
The compose service:
|
||||
|
||||
```yaml
|
||||
pr-agent:
|
||||
image: pragent/pr-agent:0.49.0-gitea_app
|
||||
container_name: pr-agent
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- ./pr-agent.env
|
||||
environment:
|
||||
PORT: "3000"
|
||||
GUNICORN_WORKERS: "2"
|
||||
mem_limit: 1g
|
||||
networks:
|
||||
- gitea
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import socket; socket.create_connection(('127.0.0.1', 3000), 3).close()"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
```
|
||||
|
||||
# Checks
|
||||
|
||||
A signed webhook from the Gitea container returns 200, and a direct
|
||||
`glm-5.3-flash` call returns a completion. A `403` in the Gitea webhook
|
||||
delivery log means the secret does not match or `ALLOWED_HOST_LIST` is
|
||||
missing; a `401` from PR-Agent means the signature and secret disagree.
|
||||
On a model failure, check `docker compose logs pr-agent` and confirm
|
||||
`OPENAI__KEY` is set in `pr-agent.env`.
|
||||
@@ -1,32 +0,0 @@
|
||||
# Copy to .env on server0 and fill in; never commit .env.
|
||||
# chmod 600 .env
|
||||
|
||||
CONFIG__GIT_PROVIDER=gitea
|
||||
|
||||
# The API is reached over the Docker network; links in comments use the
|
||||
# public URL instead.
|
||||
GITEA__URL=http://gitea:3000
|
||||
GITEA__WEB_URL=https://git.noelsabia.dev
|
||||
|
||||
# Bot user pr-agent, scoped token (read:repository, write:issue, read:user).
|
||||
# Not the admin account and not a workflow secret.
|
||||
GITEA__PERSONAL_ACCESS_TOKEN=
|
||||
|
||||
# Secret configured on the Gitea webhook. Required: the server rejects
|
||||
# unsigned webhooks with HTTP 403.
|
||||
GITEA__WEBHOOK_SECRET=
|
||||
|
||||
# OpenCode Go exposes an OpenAI-compatible chat-completions endpoint, so
|
||||
# PR-Agent reaches it through its openai provider with a custom base URL.
|
||||
CONFIG__MODEL=openai/glm-5.3-flash
|
||||
CONFIG__FALLBACK_MODELS=["openai/glm-5.3"]
|
||||
CONFIG__CUSTOM_MODEL_MAX_TOKENS=128000
|
||||
OPENAI__API_BASE=https://opencode.ai/inference/go/openai/v1
|
||||
OPENAI__KEY=
|
||||
|
||||
# OpenCode Go requires a session id header; a stable id is enough here.
|
||||
LITELLM__EXTRA_HEADERS={"x-opencode-session":"pr-agent"}
|
||||
|
||||
# Auto commands on PR open. /improve remains available as a comment command;
|
||||
# leaving it in the auto list adds a second model call to every PR.
|
||||
GITEA__PR_COMMANDS=["/describe","/review"]
|
||||
@@ -1,102 +0,0 @@
|
||||
# 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:
|
||||
|
||||
```sh
|
||||
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:
|
||||
|
||||
```text
|
||||
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 transfer file used during installation was empty, so set the key as
|
||||
root and redeploy:
|
||||
|
||||
```sh
|
||||
sudoedit /opt/pr-agent/.env # set OPENAI__KEY=…
|
||||
sudo /usr/local/sbin/pr-agent-deploy
|
||||
```
|
||||
|
||||
## 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:
|
||||
|
||||
```sh
|
||||
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.
|
||||
@@ -1,38 +0,0 @@
|
||||
# PR-Agent webhook server for the self-hosted Gitea instance.
|
||||
#
|
||||
# Runs on the existing gitea_gitea network and publishes no ports. Gitea
|
||||
# reaches it as http://pr-agent:3000/api/v1/gitea_webhooks, so the webhook
|
||||
# endpoint is never internet-facing. Gitea still publishes comment links with
|
||||
# its own ROOT_URL (https://git.noelsabia.dev).
|
||||
#
|
||||
# Deployed by hand on server0 from /home/noel/self-hosted/pr-agent; see the
|
||||
# README next to this file.
|
||||
|
||||
services:
|
||||
pr-agent:
|
||||
image: pragent/pr-agent:0.49.0-gitea_app
|
||||
container_name: pr-agent
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
PORT: "3000"
|
||||
# Importing the app costs roughly 250 MB. Two workers leave headroom on
|
||||
# the 3.8 GB host that also runs Gitea, its runner and a web app.
|
||||
GUNICORN_WORKERS: "2"
|
||||
mem_limit: 1g
|
||||
networks:
|
||||
- gitea
|
||||
healthcheck:
|
||||
# The server has no HTTP health route; an open TCP socket is enough to
|
||||
# distinguish a running gunicorn master from a crashed container.
|
||||
test: ["CMD", "python", "-c", "import socket; socket.create_connection(('127.0.0.1', 3000), 3).close()"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
|
||||
networks:
|
||||
gitea:
|
||||
external: true
|
||||
name: gitea_gitea
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Final step: remove the agent's inherited noel access.
|
||||
#
|
||||
# Run on server0 only after the agent command works:
|
||||
# ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 status
|
||||
#
|
||||
# This removes noel from docker and sudo, clears noel's authorized_keys,
|
||||
# and deletes the old PR-Agent directory that held the secrets. Make sure
|
||||
# you have another admin path (provider console or a new key) first.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat <<'EOF'
|
||||
This will:
|
||||
- remove noel from the docker and sudo groups
|
||||
- clear every key in /home/noel/.ssh/authorized_keys
|
||||
- delete /home/noel/self-hosted/pr-agent (the /opt copy remains)
|
||||
Existing noel SSH sessions keep their old groups until they log out.
|
||||
Make sure you have another admin path before continuing.
|
||||
EOF
|
||||
read -r -p "Type REMOVE to continue: " answer
|
||||
[ "$answer" = "REMOVE" ] || { echo "aborted"; exit 1; }
|
||||
|
||||
if id -nG noel | tr ' ' '\n' | grep -qx docker; then
|
||||
gpasswd -d noel docker
|
||||
fi
|
||||
if id -nG noel | tr ' ' '\n' | grep -qx sudo; then
|
||||
deluser noel sudo
|
||||
fi
|
||||
|
||||
if [ -f /home/noel/.ssh/authorized_keys ]; then
|
||||
cp -a /home/noel/.ssh/authorized_keys \
|
||||
"/root/noel-authorized_keys.$(date +%Y%m%d-%H%M%S).bak"
|
||||
: > /home/noel/.ssh/authorized_keys
|
||||
chown noel:noel /home/noel/.ssh/authorized_keys
|
||||
chmod 600 /home/noel/.ssh/authorized_keys
|
||||
fi
|
||||
|
||||
rm -rf /home/noel/self-hosted/pr-agent
|
||||
|
||||
cat <<'EOF'
|
||||
|
||||
Done. Test the restricted path again:
|
||||
|
||||
ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 status
|
||||
|
||||
Still to do outside this script:
|
||||
- remove the old personal SSH key from Gitea (Settings > SSH / GPG Keys)
|
||||
- add ~/.ssh/pr_agent_gitea.pub as a write deploy key on CV_Site_Nuxt
|
||||
- put the OpenCode Go key in /opt/pr-agent/.env and run the deploy helper
|
||||
EOF
|
||||
@@ -1,135 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# One-time root setup for the least-privilege PR-Agent operator account.
|
||||
#
|
||||
# Run on server0:
|
||||
# sudo bash /home/noel/agent-access-setup.sh
|
||||
#
|
||||
# This creates the agent user and moves the PR-Agent stack to /opt/pr-agent.
|
||||
# It does NOT remove noel's current docker/sudo access. Verify the agent
|
||||
# command printed at the end first, then run remove-noel-access.sh.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
AGENT_USER=agent
|
||||
AGENT_HOME=/home/$AGENT_USER
|
||||
PR_AGENT_DIR=/opt/pr-agent
|
||||
SRC_DIR=/home/noel/self-hosted/pr-agent
|
||||
PUBKEY_FILE=/home/noel/.ssh/pr_agent_control.pub
|
||||
DOCKER=/usr/bin/docker
|
||||
|
||||
for f in "$SRC_DIR/docker-compose.yml" "$SRC_DIR/README.md" "$SRC_DIR/.env" "$PUBKEY_FILE"; do
|
||||
[ -f "$f" ] || { echo "missing $f" >&2; exit 1; }
|
||||
done
|
||||
case "$(cat "$PUBKEY_FILE")" in
|
||||
ssh-*|ecdsa-*|sk-ssh-*) ;;
|
||||
*) echo "$PUBKEY_FILE does not look like an SSH public key" >&2; exit 1 ;;
|
||||
esac
|
||||
grep -q '^Include /etc/ssh/sshd_config.d/\*.conf' /etc/ssh/sshd_config \
|
||||
|| { echo "sshd does not include sshd_config.d" >&2; exit 1; }
|
||||
|
||||
if ! id "$AGENT_USER" >/dev/null 2>&1; then
|
||||
useradd --create-home --shell /bin/bash "$AGENT_USER"
|
||||
fi
|
||||
passwd -l "$AGENT_USER" >/dev/null 2>&1 || true
|
||||
chmod 700 "$AGENT_HOME"
|
||||
install -d -m 700 -o "$AGENT_USER" -g "$AGENT_USER" "$AGENT_HOME/.ssh"
|
||||
|
||||
# The stack must not be writable by the agent: a changed compose file would
|
||||
# turn "restart the service" into arbitrary root containers.
|
||||
install -d -m 755 -o root -g root "$PR_AGENT_DIR"
|
||||
if [ ! -f "$PR_AGENT_DIR/docker-compose.yml" ]; then
|
||||
install -m 644 -o root -g root "$SRC_DIR/docker-compose.yml" "$PR_AGENT_DIR/docker-compose.yml"
|
||||
fi
|
||||
install -m 644 -o root -g root "$SRC_DIR/README.md" "$PR_AGENT_DIR/README.md"
|
||||
if [ ! -f "$PR_AGENT_DIR/.env" ]; then
|
||||
install -m 600 -o root -g root "$SRC_DIR/.env" "$PR_AGENT_DIR/.env"
|
||||
fi
|
||||
if ! grep -q '^name:' "$PR_AGENT_DIR/docker-compose.yml"; then
|
||||
sed -i '1i name: pr-agent' "$PR_AGENT_DIR/docker-compose.yml"
|
||||
fi
|
||||
|
||||
cat > /usr/local/sbin/pr-agent-deploy <<EOF
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
$DOCKER compose --project-directory $PR_AGENT_DIR -f $PR_AGENT_DIR/docker-compose.yml pull
|
||||
exec $DOCKER compose --project-directory $PR_AGENT_DIR -f $PR_AGENT_DIR/docker-compose.yml up -d
|
||||
EOF
|
||||
|
||||
cat > /usr/local/sbin/pr-agent-logs <<EOF
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
exec $DOCKER compose --project-directory $PR_AGENT_DIR -f $PR_AGENT_DIR/docker-compose.yml logs --tail=200 pr-agent
|
||||
EOF
|
||||
|
||||
cat > /usr/local/sbin/pr-agent-status <<EOF
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
exec $DOCKER compose --project-directory $PR_AGENT_DIR -f $PR_AGENT_DIR/docker-compose.yml ps
|
||||
EOF
|
||||
|
||||
cat > /usr/local/sbin/pr-agent-control <<'EOF'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
case "${SSH_ORIGINAL_COMMAND:-}" in
|
||||
deploy) exec sudo -n /usr/local/sbin/pr-agent-deploy ;;
|
||||
logs) exec sudo -n /usr/local/sbin/pr-agent-logs ;;
|
||||
status) exec sudo -n /usr/local/sbin/pr-agent-status ;;
|
||||
*) echo "allowed: deploy, logs, status" >&2; exit 1 ;;
|
||||
esac
|
||||
EOF
|
||||
|
||||
chown root:root /usr/local/sbin/pr-agent-deploy /usr/local/sbin/pr-agent-logs \
|
||||
/usr/local/sbin/pr-agent-status /usr/local/sbin/pr-agent-control
|
||||
chmod 755 /usr/local/sbin/pr-agent-deploy /usr/local/sbin/pr-agent-logs \
|
||||
/usr/local/sbin/pr-agent-status /usr/local/sbin/pr-agent-control
|
||||
|
||||
cat > /etc/sudoers.d/pr-agent-control <<'EOF'
|
||||
agent ALL=(root) NOPASSWD: /usr/local/sbin/pr-agent-deploy, /usr/local/sbin/pr-agent-logs, /usr/local/sbin/pr-agent-status
|
||||
EOF
|
||||
chmod 440 /etc/sudoers.d/pr-agent-control
|
||||
visudo -cf /etc/sudoers.d/pr-agent-control >/dev/null
|
||||
|
||||
PUB=$(cat "$PUBKEY_FILE")
|
||||
printf 'restrict,command="/usr/local/sbin/pr-agent-control" %s\n' "$PUB" \
|
||||
> "$AGENT_HOME/.ssh/authorized_keys"
|
||||
chown "$AGENT_USER:$AGENT_USER" "$AGENT_HOME/.ssh/authorized_keys"
|
||||
chmod 600 "$AGENT_HOME/.ssh/authorized_keys"
|
||||
|
||||
cat > /etc/ssh/sshd_config.d/60-pr-agent-agent.conf <<'EOF'
|
||||
Match User agent
|
||||
ForceCommand /usr/local/sbin/pr-agent-control
|
||||
PermitTTY no
|
||||
AllowTcpForwarding no
|
||||
X11Forwarding no
|
||||
PermitTunnel no
|
||||
AllowAgentForwarding no
|
||||
EOF
|
||||
chmod 644 /etc/ssh/sshd_config.d/60-pr-agent-agent.conf
|
||||
if ! sshd -t; then
|
||||
rm -f /etc/ssh/sshd_config.d/60-pr-agent-agent.conf
|
||||
echo "sshd config test failed; removed the new file" >&2
|
||||
exit 1
|
||||
fi
|
||||
systemctl reload ssh
|
||||
|
||||
cd "$PR_AGENT_DIR"
|
||||
"$DOCKER" compose pull
|
||||
"$DOCKER" compose up -d
|
||||
sleep 5
|
||||
"$DOCKER" compose ps
|
||||
|
||||
cat <<'EOF'
|
||||
|
||||
Agent access is ready. Test from the laptop:
|
||||
|
||||
ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 status
|
||||
|
||||
Old access is still in place. Only after that command works, run:
|
||||
|
||||
sudo bash /home/noel/agent-access-remove.sh
|
||||
EOF
|
||||
Reference in new issue
Block a user