|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Commands |
| 6 | + |
| 7 | +- **Install dependencies**: `bun install` |
| 8 | +- **Build**: `bun run build` |
| 9 | +- **Dev server (watch)**: `bun run dev` |
| 10 | +- **Production start**: `bun run start` |
| 11 | +- **Lint**: `bun run lint` |
| 12 | +- **Pre-commit lint/fix**: Runs automatically via git hooks (bunx eslint --fix) |
| 13 | + |
| 14 | +## Architecture Overview |
| 15 | + |
| 16 | +- **Entry point**: `src/main.ts` defines CLI subcommands (`start` and `auth`) for the Copilot API server and authentication flow. |
| 17 | +- **Server**: `src/server.ts` sets up HTTP routes using Hono, maps OpenAI/Anthropic-compatible endpoints, and handles logging/cors. |
| 18 | +- **Routes**: Handlers for chat completions, embeddings, models, and messages are under `src/routes/`, providing API endpoints compatible with OpenAI and Anthropic APIs. |
| 19 | +- **Copilot communication**: `src/services/copilot/` contains methods for proxying requests (chat completions, model listing, embeddings) to the GitHub Copilot backend using user tokens. |
| 20 | +- **Lib utilities**: `src/lib/` contains configuration, token, model caching, and error handling helpers. |
| 21 | +- **Authentication**: `src/auth.ts` provides the CLI handler for authenticating with GitHub, managing required tokens, and persisting them locally. |
| 22 | + |
| 23 | +## API Endpoints |
| 24 | + |
| 25 | +- **OpenAI-compatible**: |
| 26 | + - `POST /v1/chat/completions` |
| 27 | + - `GET /v1/models` |
| 28 | + - `POST /v1/embeddings` |
| 29 | +- **Anthropic-compatible**: |
| 30 | + - `POST /v1/messages` |
| 31 | + - `POST /v1/messages/count_tokens` |
| 32 | + |
| 33 | +## Other Notes |
| 34 | + |
| 35 | +- Ensure Bun (>= 1.2.x) is installed for all scripts and local dev. |
| 36 | +- Tokens and cache are handled automatically; manual authentication can be forced with the `auth` subcommand. |
| 37 | +- No .cursorrules, .github/copilot-instructions.md, or .cursor/rules found, so follow typical TypeScript/Bun/ESLint conventions as seen in this codebase. |
0 commit comments