|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the **Vitest extension for Visual Studio Code** - a VSCode extension that provides test running, debugging, and coverage capabilities for Vitest tests. The extension integrates with VSCode's native TestController API to provide a unified testing experience. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +The project uses a monorepo structure with multiple packages that work together: |
| 12 | + |
| 13 | +- **packages/extension** - Main VSCode extension entry point and core logic |
| 14 | +- **packages/shared** - Shared utilities and RPC communication between extension and workers |
| 15 | +- **packages/worker** - New worker implementation for running Vitest processes |
| 16 | +- **packages/worker-legacy** - Legacy worker implementation for older Vitest versions |
| 17 | +- **samples/** - Sample projects for testing and demonstration |
| 18 | + |
| 19 | +### Key Components |
| 20 | + |
| 21 | +- **Extension Host** (packages/extension): Manages VSCode integration, test discovery, debugging, coverage |
| 22 | +- **Worker Processes** (packages/worker*): Execute Vitest in isolated processes, handle test running and reporting |
| 23 | +- **RPC Communication** (packages/shared): Bidirectional communication between extension and workers using birpc |
| 24 | +- **API Abstraction**: Supports both child_process and terminal shell types for running Vitest |
| 25 | + |
| 26 | +## Development Commands |
| 27 | + |
| 28 | +### Building |
| 29 | +```bash |
| 30 | +pnpm build # Build for production (minified) |
| 31 | +pnpm dev # Build in development mode with watch and sourcemap |
| 32 | +pnpm vscode:prepublish # Prepare for publishing (runs build) |
| 33 | +``` |
| 34 | + |
| 35 | +### Testing |
| 36 | +```bash |
| 37 | +pnpm test # Run unit tests (Mocha-based VSCode tests) |
| 38 | +pnpm test:watch # Run unit tests in watch mode |
| 39 | +pnpm test-e2e # Run end-to-end tests (Vitest-based) |
| 40 | +``` |
| 41 | + |
| 42 | +### Code Quality |
| 43 | +```bash |
| 44 | +pnpm typecheck # TypeScript type checking |
| 45 | +pnpm lint # Run ESLint |
| 46 | +pnpm lint:fix # Run ESLint with auto-fix |
| 47 | +``` |
| 48 | + |
| 49 | +### Packaging |
| 50 | +```bash |
| 51 | +pnpm package # Create .vsix package for distribution |
| 52 | +``` |
| 53 | + |
| 54 | +## Package Manager |
| 55 | + |
| 56 | +Uses **pnpm** with workspaces. The project requires pnpm@10.11.1 as specified in package.json. |
| 57 | + |
| 58 | +## Build System |
| 59 | + |
| 60 | +- **tsup** - Main build tool for bundling TypeScript |
| 61 | +- Multiple entry points: extension, workers, setup files |
| 62 | +- Supports both CJS and ESM output formats |
| 63 | +- External dependencies like 'vscode' and 'vitest' are excluded from bundles |
| 64 | + |
| 65 | +## Testing Infrastructure |
| 66 | + |
| 67 | +- **Unit Tests**: Mocha-based tests in `test/unit/` using `@vscode/test-cli` |
| 68 | +- **E2E Tests**: Vitest-based tests in `test/e2e/` |
| 69 | +- **VSCode Test Runner**: Uses `.vscode-test.mjs` configuration |
| 70 | +- **Samples**: Multiple sample projects for testing different scenarios |
| 71 | + |
| 72 | +## Worker Architecture |
| 73 | + |
| 74 | +The extension uses a multi-process architecture: |
| 75 | +- Extension runs in VSCode extension host |
| 76 | +- Worker processes execute Vitest in isolation |
| 77 | +- Communication via RPC (birpc) |
| 78 | +- Supports both legacy and modern Vitest versions |
| 79 | +- Can spawn workers via child_process or terminal |
| 80 | + |
| 81 | +## Key Configuration Files |
| 82 | + |
| 83 | +- `tsup.config.ts` - Build configuration with multiple entry points |
| 84 | +- `pnpm-workspace.yaml` - Workspace and catalog definitions |
| 85 | +- `.vscode-test.mjs` - VSCode test runner configuration |
| 86 | +- `tsconfig.base.json` - Base TypeScript configuration |
| 87 | + |
| 88 | +## Development Notes |
| 89 | + |
| 90 | +- Extension activates on workspaces containing Vitest config files |
| 91 | +- Supports both standalone configs and Vitest workspace configurations |
| 92 | +- Uses static AST analysis for test discovery (experimentalStaticAstCollect) |
| 93 | +- Integrates with VSCode's native testing UI and debugging capabilities |
| 94 | +- Supports coverage collection and display |
0 commit comments