Skip to content

Latest commit

Β 

History

History
121 lines (94 loc) Β· 3.87 KB

File metadata and controls

121 lines (94 loc) Β· 3.87 KB

PROJECT KNOWLEDGE BASE

Generated: 2026-01-16 Commit: 3bf3876 Branch: main

OVERVIEW

ChatGPT-powered code review bot. Multi-deployment: GitHub Action, Probot app, AWS Lambda, Vercel Edge.

STRUCTURE

./
β”œβ”€β”€ src/              # Core logic (bot.ts, chat.ts)
β”œβ”€β”€ action/           # GitHub Action bundle (ncc output) - DO NOT EDIT
β”œβ”€β”€ dist/             # Probot/Vercel build output - DO NOT EDIT
β”œβ”€β”€ api/              # Vercel serverless entry
β”œβ”€β”€ test/             # Jest test fixtures
β”œβ”€β”€ action.yml        # GitHub Action metadata β†’ action/index.cjs
β”œβ”€β”€ serverless.yml    # AWS Lambda config
└── rollup.config.ts  # Build orchestration

WHERE TO LOOK

Task Location Notes
Code review logic src/bot.ts PR event handling, diff processing, file filtering
OpenAI integration src/chat.ts Prompts, API calls, response parsing
GitHub Action entry src/github-action.cjs Uses @probot/adapter-github-actions
Probot standalone src/index.ts Standard Probot runner
Vercel deployment api/github/webhooks/index.ts createNodeMiddleware wrapper
AWS Lambda src/aws-lambda.cjs @probot/adapter-aws-lambda-serverless

BUILD & DEPLOY

npm run build      # rollup β†’ dist/ + ncc β†’ action/
npm run start      # Probot standalone (requires .env)
npm test           # Jest

Build outputs:

  • action/ β†’ GitHub Action (action.yml points here)
  • dist/ β†’ Probot app, Vercel middleware
  • lambda/ β†’ AWS Lambda (via build:lambda)

CONVENTIONS

TypeScript

  • ESNext target, NodeNext module resolution
  • Strict mode enabled
  • Output to lib/ (tsc) but builds use rollup/ncc

Module System

  • ESM for source ("type": "module" in package.json)
  • CJS wrappers for Action/Lambda entry points (.cjs extension)
  • .js extension required in imports (from "./chat.js")

Environment Variables

Variable Purpose Required
OPENAI_API_KEY OpenAI authentication Yes
OPENAI_API_ENDPOINT Custom endpoint (default: api.openai.com) No
AZURE_API_VERSION Azure OpenAI version For Azure
AZURE_DEPLOYMENT Azure deployment name For Azure
LANGUAGE Review output language No
PROMPT Custom prompt prefix No
MAX_PATCH_LENGTH Skip large diffs (default: Infinity) No
MAX_CONTEXT_CHARS Truncate prompt context No
IGNORE_PATTERNS Glob patterns to skip No
INCLUDE_PATTERNS Glob patterns to include No
TARGET_LABEL Only review labeled PRs No

ANTI-PATTERNS (THIS PROJECT)

  • NEVER edit action/ - Generated by ncc, changes will be overwritten
  • NEVER edit dist/ - Rollup output
  • Model hardcoded as gpt-5-mini in src/chat.ts:246 - change there if needed
  • Response format uses json_object - prompts must include JSON output instructions

UNIQUE STYLES

Korean Comments

  • Source has Korean comments/prompts (μ½”λ“œ 리뷰 μ‹œμŠ€ν…œ)
  • System prompts in src/chat.ts are Korean by default
  • LANGUAGE env var controls output language

Incremental Review

  • On synchronize events, only reviews files changed in latest commit
  • Tracks previous review comments to avoid duplicate feedback

File Relation Context

  • Extracts imports to provide related file context to AI
  • Relations: "imports", "imported-by", "same-dir"

COMMANDS

# Development
npm install
npm run build
npm run start       # Requires APP_ID, PRIVATE_KEY in .env

# Testing
npm test

# Docker
docker build -t cr-bot .
docker run -e APP_ID=<id> -e PRIVATE_KEY=<pem> cr-bot

NOTES

  • Uses Probot framework (v12) for GitHub integration
  • OpenAI SDK v4 with Azure support
  • PR file limit: 30 files max per review
  • Large patches (>MAX_PATCH_LENGTH) silently skipped
  • 422 errors from GitHub API trigger fallback to body-only review