improve: add README, .editorconfig, fix fallback models in setup_all.py, update .gitignore

This commit is contained in:
asepharyana
2026-08-20 11:26:03 +07:00
parent 2293428421
commit 54cec6bf0c
4 changed files with 88 additions and 2 deletions
+26
View File
@@ -0,0 +1,26 @@
# EditorConfig helps maintain consistent coding styles across editors and IDEs
# https://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 100
[*.{py,pyi}]
indent_style = space
indent_size = 4
[Makefile]
indent_style = tab
[*.{nix}]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false
max_line_length = 0
+5
View File
@@ -10,3 +10,8 @@ whsec*.txt
__pycache__/
*.pyc
result
*.egg-info/
.eggs/
dist/
build/
.venv/
+55
View File
@@ -0,0 +1,55 @@
# PR-Agent Server
Nix-deployed GitHub App server for automated PR review + auto-merge, using a custom LLM endpoint (9router/Omniroute).
## Architecture
```
GitHub webhook → Cloudflare DNS → Caddy (reverse proxy, :4002)
→ pr-agent-server (Nix profile, uvicorn)
→ PR-Agent github_app.py (FastAPI)
→ 9router API (custom OpenAI-compatible endpoint)
```
## Components
| File | Purpose |
|------|---------|
| `run_server.py` | Main FastAPI server — GitHub App webhook handler + analytics/metrics + Discord notifications |
| `auto_merge_bot.py` | Periodic bot that finds reviewed PRs and merges them |
| `trivial_merge.py` | Trivial PR fast-path (docs-only, dependabot, <100 lines) |
| `health-check.py` | Model health watchdog — tests primary + fallback models against 9router |
| `sync-key.py` | Auto-syncs the BWS router key to disk on every service start |
| `generate_manifest.py` | Creates GitHub App manifest URL |
| `callback_server.py` | Dev callback server for receiving GitHub App credentials |
| `flake.nix` | Nix build definition — produces the deployable package |
## Development
```bash
# Syntax check all Python files
python3 -m py_compile run_server.py auto_merge_bot.py health-check.py sync-key.py trivial_merge.py callback_server.py generate_manifest.py setup_all.py setup_app.py start_server.py
# Build with Nix
nix build .#default
# Deploy (CI does this automatically on push to main)
nix copy --to ssh://user@vps $STORE_PATH
ssh user@vps "sudo /nix/var/nix/profiles/default/bin/nix-env --profile /nix/var/nix/profiles/pr-agent-server --set '$STORE_PATH'"
ssh user@vps "sudo systemctl restart pr-agent-server"
```
## Ops
- **Health watchdog**: cron `pr-agent-health-watchdog` (every 10m) → `~/.hermes/scripts/pr-agent-health-check.sh`
- **Key sync**: systemd `ExecStartPre``pr-agent-sync-key` (BWS → disk)
- **Prometheus**: `GET /api/metrics``pr_agent_requests_total`, `pr_agent_requests_by_command`, `pr_agent_model_failures`
- **Analytics**: `GET /api/analytics` → JSON summary of recent events + failures
- **Discord**: `POST /api/v1/notify_review` → webhook delivery for review complete/failed
## Nix Profile Integrity
After deploy, run `nix-gc-vps.sh` to clean up old generations. The GC script now includes
a repair step that fixes broken profile symlinks before running `nix store gc`, preventing
the issue where profile `-link` dirs get deleted and store paths become unreferenced (see
`devops/pr-agent-deployment` skill for full troubleshooting).
+2 -2
View File
@@ -78,8 +78,8 @@ with open(BASE_DIR / ".secrets.toml", "w") as f:
# ── 4. Create PR-Agent config ──
config_toml = """[config]
model = "claude-opus-4-8"
fallback_models = ["auto/best-coding", "auto/claude-sonnet"]
model = "openai/claude-opus-4-8"
fallback_models = ["openai/ATLAS", "openai/gemini", "openai/text", "openai/deepseek-v4-free"]
custom_model_max_tokens = 128000
git_provider = "github"
publish_output = true