From e571a33dd23b9acd8b0c9f9d9e1eb9b504ae1bbb Mon Sep 17 00:00:00 2001 From: wonder Date: Sat, 20 Jun 2026 00:06:17 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E9=87=8D=E5=86=99=20README=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=89=E8=A3=85=E9=85=8D=E7=BD=AE=E5=92=8C?= =?UTF-8?q?=20API=20=E5=8F=82=E8=80=83=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3cdf608..9c3fdbd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,135 @@ # PR-Helper -๐Ÿค— ๅธฎๅŠฉ็”Ÿๆˆ PR ไฟกๆฏ๏ผŒReview ไปฃ็  \ No newline at end of file +AI-powered PR description generator and code review tool. Self-hosted, designed for internal/local use. + +## Features + +- **PR Description Generation** โ€” Select commits from an interactive Git graph, get a structured PR description via LLM +- **AI Code Review** โ€” Per-file analysis with severity ratings, inline suggestions on the diff view +- **Interactive Git Graph** โ€” D3.js visualization with click-to-select base/head refs +- **Diff Viewer** โ€” Split/unified view powered by diff2html with syntax highlighting +- **Review Notes** โ€” Add markdown notes at overall, file, or suggestion level +- **PDF Export** โ€” Generate printable review reports +- **Repository Caching** โ€” Cloned repos are cached with configurable expiry + +## Quick Start + +### Docker (recommended) + +```bash +docker compose up --build +``` + +Open http://localhost:8080. + +### Manual Build + +Requirements: Go 1.22+, CGO enabled (for SQLite), Chromium (for PDF export) + +```bash +# Install dependencies +go mod download + +# Build +CGO_ENABLED=1 go build -o pr-helper . + +# Run +./pr-helper +``` + +Server listens on `:8080` by default. + +## Configuration + +### LLM Settings (required) + +Navigate to **Settings** (`/settings`) and configure: + +| Setting | Description | Default | +|---------|-------------|---------| +| API Endpoint | OpenAI-compatible API URL | `https://api.openai.com/v1` | +| API Key | Your API key | (empty) | +| Model | Model name | `gpt-4o` | + +Works with any OpenAI-compatible API: OpenAI, Deepseek, Ollama, vLLM, etc. + +### Review Settings + +| Setting | Description | Default | +|---------|-------------|---------| +| Top-N Files | Max files to analyze per review (0 = all) | `20` | +| Concurrency | Parallel file analyses | `5` | + +### Cache Settings + +| Setting | Description | Default | +|---------|-------------|---------| +| Max Age (days) | Auto-cleanup threshold | `7` | +| Max Size (MB) | Total cache size limit | `5000` | + +### Environment Variables + +| Variable | Description | Default | +|----------|-------------|---------| +| `PORT` | Server port | `8080` | +| `GIN_MODE` | Gin mode (`debug`/`release`) | `debug` | +| `DATA_DIR` | Data directory path | `./data` | +| `CHROME_BIN` | Chromium binary path (for PDF) | `/usr/bin/chromium-browser` | + +## Usage + +1. **Clone a repo** โ€” Paste a Git URL on the homepage, optionally provide credentials for private repos +2. **Browse the graph** โ€” View branches, tags, and commit history in the interactive D3.js graph +3. **Select refs** โ€” Click nodes in the graph or use the dropdown selectors to pick base and head +4. **Generate PR description** โ€” Navigate to Generate, select refs, click Generate +5. **Run code review** โ€” Navigate to Review, configure Top-N and concurrency, click Start Review +6. **Add notes** โ€” Click into any suggestion or the overall section to add markdown notes +7. **Export PDF** โ€” Click Export PDF to download a formatted report + +## API Routes + +### Pages + +| Method | Path | Description | +|--------|------|-------------| +| GET | `/` | Homepage โ€” clone form and cached repos | +| GET | `/repo/:id` | Repository โ€” Git graph and diff viewer | +| GET | `/repo/:id/generate` | PR description generation | +| GET | `/repo/:id/review` | AI code review | +| GET | `/settings` | Settings page | + +### API + +| Method | Path | Description | +|--------|------|-------------| +| POST | `/api/repos` | Clone repository (SSE stream) | +| GET | `/api/repos` | List cached repositories | +| DELETE | `/api/repos/:id` | Delete repository cache | +| POST | `/api/repos/:id/cleanup` | Trigger cache cleanup | +| GET | `/api/repos/:id/graph` | Git graph data (JSON) | +| GET | `/api/repos/:id/refs` | Branches and tags | +| GET | `/api/repos/:id/commits` | Commit log for a ref | +| GET | `/api/repos/:id/diff` | Diff between two refs | +| POST | `/api/repos/:id/generate` | Generate PR description (SSE) | +| POST | `/api/repos/:id/review` | AI code review (SSE) | +| GET | `/api/repos/:id/review/analyses` | List past reviews | +| GET | `/api/repos/:id/review/analyses/:aid` | Get single review | +| POST | `/api/repos/:id/review/notes` | Save a review note | +| GET | `/api/repos/:id/review/notes` | Get review notes | +| POST | `/api/repos/:id/review/pdf` | Generate PDF report | +| GET | `/api/settings` | Get settings | +| PUT | `/api/settings` | Update settings | + +## Tech Stack + +- **Backend**: Go, Gin, SQLite (go-sqlite3), go-git, chromedp +- **Frontend**: Go html/template, HTMX, D3.js, diff2html, Tailwind CSS +- **LLM**: OpenAI-compatible API with SSE streaming + +## Security + +**No authentication.** Do not expose to the public internet. Intended for internal/local use only. + +## License + +MIT