| 1 | # AGENTS.md |
| 2 | |
| 3 | This file provides guidance to AI coding agents when working with code in this repository. |
| 4 | |
| 5 | ## Development Commands |
| 6 | |
| 7 | - **Build**: `npm run build` - Compiles TypeScript to JavaScript in dist/ |
| 8 | - **Test**: `npm test` - Runs Vitest tests with ESM support |
| 9 | - **Type Check**: `npm run lint` - Runs TypeScript compiler without emitting files for type checking |
| 10 | - **Format**: `npm run format` - Runs Prettier with --write flag to check + fix formatting |
| 11 | - **Start**: `npm start` - Runs the built CLI from dist/index.js |
| 12 | - **Development**: After building, test locally with `node dist/index.js` |
| 13 | |
| 14 | ## Architecture Overview |
| 15 | |
| 16 | This is a CLI tool for Continue Dev that provides an interactive AI-assisted development experience. The architecture consists of: |
| 17 | |
| 18 | ### Core Components |
| 19 | |
| 20 | 1. **Entry Point** (`src/index.ts`): Main CLI logic with two modes: |
| 21 | |
| 22 | - **Headless mode**: Non-interactive mode for automation/CI |
| 23 | - **TUI mode**: Terminal User Interface using Ink/React |
| 24 | - **Standard mode**: Traditional readline-based chat interface |
| 25 | |
| 26 | 2. **Authentication** (`src/auth/`): WorkOS-based authentication system |
| 27 | |
| 28 | - `ensureAuth.ts`: Handles authentication flow |
| 29 | - `workos.ts`: WorkOS configuration and token management |
| 30 | |
| 31 | 3. **Continue SDK Integration** (`src/continueSDK.ts`): Initializes the Continue SDK client with: |
| 32 | |
| 33 | - API key authentication |
| 34 | - Assistant configuration (slug-based) |
| 35 | - Organization support |
| 36 | |
| 37 | 4. **Terminal UI** (`src/ui/`): React/Ink-based TUI components |
| 38 | |
| 39 | - `TUIChat.tsx`: Main chat interface component |
| 40 | - `UserInput.tsx`: Input handling with multi-line support |
| 41 | - `TextBuffer.ts`: Text display utilities |
| 42 | |
| 43 | 5. **Tools System** (`src/tools/`): Built-in development tools including: |
| 44 | |
| 45 | - File operations (read, write, list) |
| 46 | - Code search functionality |
| 47 | - Terminal command execution |
| 48 | - Diff viewing |
| 49 | - Exit tool (headless mode only) |
| 50 | |
| 51 | 6. **MCP Integration** (`src/mcp.ts`): Model Context Protocol service for extended tool capabilities |
| 52 | |
| 53 | ### Key Features |
| 54 | |
| 55 | - **Streaming Responses**: Real-time AI response streaming (`streamChatResponse.ts`) |
| 56 | - **Slash Commands**: Built-in commands like `/help`, `/exit` (`slashCommands.ts`) |
| 57 | - **Multi-mode Operation**: Supports TUI, headless, and standard chat modes |
| 58 | - **Tool Integration**: Extensible tool system for development tasks |
| 59 | |
| 60 | ### Testing Setup |
| 61 | |
| 62 | - Uses Vitest with TypeScript and ESM support |
| 63 | - Configuration in `vitest.config.ts` |
| 64 | - Tests should be written with `.test.ts` extension |
| 65 | - No existing test files found - tests should be added when writing new functionality |
| 66 | - Run tests using `npm run test path/or/pattern` |
| 67 | |
| 68 | ### Build System |
| 69 | |
| 70 | - TypeScript compilation with declaration files |
| 71 | - ESNext target with NodeNext module resolution |
| 72 | - Outputs to `dist/` directory |
| 73 | - Source maps and inline sources enabled |
| 74 | - JSX support for React components |
| 75 | - Relative import paths require explicit file extensions, e.g. 'from "./test.js"' instead of 'from "./test"' |
| 76 | |
| 77 | ### Important rules |
| 78 | |
| 79 | - Whenever you create / update a test, you should run the test to be certain that it passes |
| 80 | - If you ever create a PR, you should be sure to check the formatting and linting first with `npm run format` and `npm run lint` / `npm run lint:fix`. |