|
| 1 | +# Project Guidelines |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +VS Code extension for managing RabbitMQ connections, queues, exchanges, and bindings. Uses the Management HTTP API and AMQP protocol. Independent project — not affiliated with Broadcom. |
| 6 | + |
| 7 | +## Architecture |
| 8 | + |
| 9 | +``` |
| 10 | +src/ |
| 11 | + activation/ → Command registration (entry wiring) |
| 12 | + extension/ → Business logic, services, domain types, errors |
| 13 | + services/ → ConnectionStore, RabbitMqAdminService, etc. |
| 14 | + types/ → TypeScript interfaces (connection.ts, rabbitmq.ts) |
| 15 | + infra/rabbitmq/ → ManagementApiClient (HTTP), AmqpProbe, mappers |
| 16 | + ui/views/ → TreeDataProvider (RabbitMqExplorer) |
| 17 | + ui/webview/ → Webview panel (ResourceEditor) |
| 18 | + extension.ts → Entry point, explicit DI wiring |
| 19 | +``` |
| 20 | + |
| 21 | +- **Clean architecture**: extension → infra → UI, no reverse dependencies |
| 22 | +- **Explicit DI**: Services receive dependencies via constructor; all wiring happens in `extension.ts` `activate()` |
| 23 | +- **Error hierarchy**: All errors extend `AppError` with typed `code` field. Subtypes: `MissingConnectionError`, `ValidationError`, `ManagementApiError` |
| 24 | +- **Tree views**: `BaseProvider<T extends ExplorerNode>` with discriminated union node types |
| 25 | + |
| 26 | +## Build and Test |
| 27 | + |
| 28 | +**Package manager**: Bun (v1.3.10+). Never use npm/yarn. |
| 29 | + |
| 30 | +| Task | Command | |
| 31 | +|------|---------| |
| 32 | +| Full build | `bun run build` | |
| 33 | +| Type-check | `bun run check-types` | |
| 34 | +| Lint | `bun run lint` | |
| 35 | +| Unit tests | `bun run test:unit` | |
| 36 | +| Integration tests | `bun run test:integration` | |
| 37 | +| Package VSIX | `bun run package:vsix` | |
| 38 | + |
| 39 | +**Two bundle targets** (see `scripts/build.ts`): |
| 40 | +- Extension: `src/extension.ts` → `dist/extension.js` (CJS, Node) |
| 41 | +- Webview: `src/ui/webview/resourceEditorApp.ts` → `dist/webview/resourceEditorApp.js` (IIFE, browser) |
| 42 | + |
| 43 | +Integration tests require `dist/extension.js` to exist — always build before running them. |
| 44 | + |
| 45 | +## Code Style |
| 46 | + |
| 47 | +- **Formatter/Linter**: Biome (double quotes, tab indentation, auto-organize imports) |
| 48 | +- **TypeScript**: Strict mode, ES2022 target, Node16 modules, no implicit any |
| 49 | +- **Files**: camelCase (`connectionStore.ts`). Classes: PascalCase. Interfaces: PascalCase, no `I` prefix |
| 50 | + |
| 51 | +## Conventions |
| 52 | + |
| 53 | +- **Commands**: Named `amqp-manager.[action]`, registered centrally in `registerCommands.ts` |
| 54 | +- **Settings**: Workspace-scoped in `settings.json`. Legacy `rabbitmq.*` fallback exists — maintain backward compat |
| 55 | +- **HTTP**: Uses the native Node.js `fetch` API for the RabbitMQ Management API, with `undici` only for TLS dispatcher configuration when needed |
| 56 | +- **Testing**: Unit tests use Bun native runner (`bun:test`). Integration tests use `@vscode/test-electron` with `node:assert/strict` |
| 57 | +- **Test file naming**: `[module].test.ts` in `test/unit/` |
| 58 | +- **No external test mocks library** — stubs are inline or manual |
| 59 | +- **Runtime dependencies**: `amqplib` and `undici`. Keep dependencies minimal |
0 commit comments