|
| 1 | +# PROJECT KNOWLEDGE BASE |
| 2 | + |
| 3 | +**Generated:** 2026-01-16 |
| 4 | +**Commit:** 3bf3876 |
| 5 | +**Branch:** main |
| 6 | + |
| 7 | +## OVERVIEW |
| 8 | + |
| 9 | +ChatGPT-powered code review bot. Multi-deployment: GitHub Action, Probot app, AWS Lambda, Vercel Edge. |
| 10 | + |
| 11 | +## STRUCTURE |
| 12 | + |
| 13 | +``` |
| 14 | +./ |
| 15 | +├── src/ # Core logic (bot.ts, chat.ts) |
| 16 | +├── action/ # GitHub Action bundle (ncc output) - DO NOT EDIT |
| 17 | +├── dist/ # Probot/Vercel build output - DO NOT EDIT |
| 18 | +├── api/ # Vercel serverless entry |
| 19 | +├── test/ # Jest test fixtures |
| 20 | +├── action.yml # GitHub Action metadata → action/index.cjs |
| 21 | +├── serverless.yml # AWS Lambda config |
| 22 | +└── rollup.config.ts # Build orchestration |
| 23 | +``` |
| 24 | + |
| 25 | +## WHERE TO LOOK |
| 26 | + |
| 27 | +| Task | Location | Notes | |
| 28 | +|------|----------|-------| |
| 29 | +| Code review logic | `src/bot.ts` | PR event handling, diff processing, file filtering | |
| 30 | +| OpenAI integration | `src/chat.ts` | Prompts, API calls, response parsing | |
| 31 | +| GitHub Action entry | `src/github-action.cjs` | Uses @probot/adapter-github-actions | |
| 32 | +| Probot standalone | `src/index.ts` | Standard Probot runner | |
| 33 | +| Vercel deployment | `api/github/webhooks/index.ts` | createNodeMiddleware wrapper | |
| 34 | +| AWS Lambda | `src/aws-lambda.cjs` | @probot/adapter-aws-lambda-serverless | |
| 35 | + |
| 36 | +## BUILD & DEPLOY |
| 37 | + |
| 38 | +```bash |
| 39 | +npm run build # rollup → dist/ + ncc → action/ |
| 40 | +npm run start # Probot standalone (requires .env) |
| 41 | +npm test # Jest |
| 42 | +``` |
| 43 | + |
| 44 | +**Build outputs:** |
| 45 | +- `action/` → GitHub Action (action.yml points here) |
| 46 | +- `dist/` → Probot app, Vercel middleware |
| 47 | +- `lambda/` → AWS Lambda (via build:lambda) |
| 48 | + |
| 49 | +## CONVENTIONS |
| 50 | + |
| 51 | +### TypeScript |
| 52 | +- ESNext target, NodeNext module resolution |
| 53 | +- Strict mode enabled |
| 54 | +- Output to `lib/` (tsc) but builds use rollup/ncc |
| 55 | + |
| 56 | +### Module System |
| 57 | +- ESM for source (`"type": "module"` in package.json) |
| 58 | +- CJS wrappers for Action/Lambda entry points (`.cjs` extension) |
| 59 | +- `.js` extension required in imports (`from "./chat.js"`) |
| 60 | + |
| 61 | +### Environment Variables |
| 62 | + |
| 63 | +| Variable | Purpose | Required | |
| 64 | +|----------|---------|----------| |
| 65 | +| `OPENAI_API_KEY` | OpenAI authentication | Yes | |
| 66 | +| `OPENAI_API_ENDPOINT` | Custom endpoint (default: api.openai.com) | No | |
| 67 | +| `AZURE_API_VERSION` | Azure OpenAI version | For Azure | |
| 68 | +| `AZURE_DEPLOYMENT` | Azure deployment name | For Azure | |
| 69 | +| `LANGUAGE` | Review output language | No | |
| 70 | +| `PROMPT` | Custom prompt prefix | No | |
| 71 | +| `MAX_PATCH_LENGTH` | Skip large diffs (default: Infinity) | No | |
| 72 | +| `MAX_CONTEXT_CHARS` | Truncate prompt context | No | |
| 73 | +| `IGNORE_PATTERNS` | Glob patterns to skip | No | |
| 74 | +| `INCLUDE_PATTERNS` | Glob patterns to include | No | |
| 75 | +| `TARGET_LABEL` | Only review labeled PRs | No | |
| 76 | + |
| 77 | +## ANTI-PATTERNS (THIS PROJECT) |
| 78 | + |
| 79 | +- **NEVER edit `action/`** - Generated by ncc, changes will be overwritten |
| 80 | +- **NEVER edit `dist/`** - Rollup output |
| 81 | +- Model hardcoded as `gpt-5-mini` in `src/chat.ts:246` - change there if needed |
| 82 | +- Response format uses `json_object` - prompts must include JSON output instructions |
| 83 | + |
| 84 | +## UNIQUE STYLES |
| 85 | + |
| 86 | +### Korean Comments |
| 87 | +- Source has Korean comments/prompts (코드 리뷰 시스템) |
| 88 | +- System prompts in `src/chat.ts` are Korean by default |
| 89 | +- `LANGUAGE` env var controls output language |
| 90 | + |
| 91 | +### Incremental Review |
| 92 | +- On `synchronize` events, only reviews files changed in latest commit |
| 93 | +- Tracks previous review comments to avoid duplicate feedback |
| 94 | + |
| 95 | +### File Relation Context |
| 96 | +- Extracts imports to provide related file context to AI |
| 97 | +- Relations: "imports", "imported-by", "same-dir" |
| 98 | + |
| 99 | +## COMMANDS |
| 100 | + |
| 101 | +```bash |
| 102 | +# Development |
| 103 | +npm install |
| 104 | +npm run build |
| 105 | +npm run start # Requires APP_ID, PRIVATE_KEY in .env |
| 106 | + |
| 107 | +# Testing |
| 108 | +npm test |
| 109 | + |
| 110 | +# Docker |
| 111 | +docker build -t cr-bot . |
| 112 | +docker run -e APP_ID=<id> -e PRIVATE_KEY=<pem> cr-bot |
| 113 | +``` |
| 114 | + |
| 115 | +## NOTES |
| 116 | + |
| 117 | +- Uses Probot framework (v12) for GitHub integration |
| 118 | +- OpenAI SDK v4 with Azure support |
| 119 | +- PR file limit: 30 files max per review |
| 120 | +- Large patches (>MAX_PATCH_LENGTH) silently skipped |
| 121 | +- 422 errors from GitHub API trigger fallback to body-only review |
0 commit comments