|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +## Project overview |
| 4 | + |
| 5 | +Patchloom for VS Code is the official VS Code extension for [Patchloom](https://github.com/patchloom/patchloom). It detects the Patchloom CLI, generates agent rules, configures MCP servers, and provides quick actions from the command palette. The extension is a thin wrapper around the `patchloom` binary with dependency-injected helpers for testability. |
| 6 | + |
| 7 | +## Dev commands |
| 8 | + |
| 9 | +| Command | What it does | |
| 10 | +|---------|-------------| |
| 11 | +| `npm run compile` | Compile extension source (`tsc -p ./`) | |
| 12 | +| `npm run compile-tests` | Compile test source (`tsc -p ./tsconfig.test.json`) | |
| 13 | +| `npm run watch` | Watch mode for extension source | |
| 14 | +| `npm run test:unit` | Run unit tests (`node --test ./out-test/test/unit/*.test.js`) | |
| 15 | +| `npm run test:extension` | Run VS Code extension integration tests | |
| 16 | +| `npm run test` | Compile + compile-tests + unit tests + extension tests | |
| 17 | +| `npm run package` | Package the `.vsix` using `@vscode/vsce` | |
| 18 | +| `npm run check` | Full CI gate: test + package | |
| 19 | + |
| 20 | +Always run `npm run check` before committing. |
| 21 | + |
| 22 | +## Project structure |
| 23 | + |
| 24 | +``` |
| 25 | +src/ |
| 26 | + extension.ts Thin entrypoint: registers commands, status bar, config listeners |
| 27 | + binary/patchloom.ts Binary discovery, version parsing, compatibility assessment |
| 28 | + commands/ |
| 29 | + configureMcp.ts Configure MCP command: multi-target MCP config injection |
| 30 | + initializeProject.ts Initialize Project command: generate/diff AGENTS.md |
| 31 | + quickActions.ts Quick Action command: replace, tidy, doc set with diff preview |
| 32 | + setupWorkspace.ts Setup Workspace command: guided readiness walkthrough |
| 33 | + showStatus.ts Show Status command: diagnostics display |
| 34 | + install/managed.ts Managed install safety: checksum, staging, promotion, rollback, persistence |
| 35 | + mcp/config.ts MCP config file operations: inspect, configure, resolve targets |
| 36 | + status/statusBar.ts Status bar item: create, refresh, dispose |
| 37 | + workspace/readiness.ts Workspace readiness: environment detection, folder selection |
| 38 | +test/ |
| 39 | + unit/ Unit tests (node:test, dependency-injected, no VS Code API) |
| 40 | + binary.test.ts Binary discovery, managed install, compatibility (32 tests) |
| 41 | + binaryDiscovery.test.ts Real executable discovery on PATH (10 tests) |
| 42 | + initializeProject.test.ts Status display, agents file classification (14 tests) |
| 43 | + managedLifecycle.test.ts Managed install with real file I/O (10 tests) |
| 44 | + mcpConfig.test.ts MCP config with real temp directories (9 tests) |
| 45 | + quickActions.test.ts Quick action command building (6 tests) |
| 46 | + suite/ |
| 47 | + index.ts VS Code extension integration tests |
| 48 | + runExtensionTests.ts Test runner using @vscode/test-electron |
| 49 | +``` |
| 50 | + |
| 51 | +## Architecture conventions |
| 52 | + |
| 53 | +### Entrypoint |
| 54 | + |
| 55 | +`extension.ts` is thin. It registers commands, sets up the status bar listener, and delegates all logic to submodules. |
| 56 | + |
| 57 | +### Dependency injection |
| 58 | + |
| 59 | +All I/O-dependent functions accept an `inputs` object with injectable callbacks for file reads, writes, shell execution, etc. This keeps unit tests fast and deterministic. Default implementations use real `node:fs/promises` and `node:child_process`. |
| 60 | + |
| 61 | +### Testing |
| 62 | + |
| 63 | +- Unit tests use `node:test` and run without VS Code. |
| 64 | +- Extension tests use `@vscode/test-electron` and launch a real VS Code instance. |
| 65 | +- Tests compile to `out-test/` via `tsconfig.test.json`. |
| 66 | +- Use `tempfile` directories for real I/O tests. |
| 67 | + |
| 68 | +### Binary resolution order |
| 69 | + |
| 70 | +1. `patchloom.path` setting (explicit user config) |
| 71 | +2. `PATH` discovery (find executable named `patchloom`) |
| 72 | +3. Managed install (global storage directory) |
| 73 | + |
| 74 | +### MCP config targets |
| 75 | + |
| 76 | +| Target | Config file | Key | |
| 77 | +|--------|------------|-----| |
| 78 | +| VS Code workspace | `.vscode/mcp.json` | `servers` | |
| 79 | +| Cursor workspace | `.cursor/mcp.json` | `servers` | |
| 80 | +| Windsurf user | `~/.codeium/windsurf/mcp_config.json` | `mcpServers` | |
| 81 | + |
| 82 | +## Coding conventions |
| 83 | + |
| 84 | +- TypeScript strict mode. |
| 85 | +- No `any` types without justification. |
| 86 | +- Pure helpers with injected I/O for testability. |
| 87 | +- Keep `extension.ts` thin. No business logic in the entrypoint. |
| 88 | +- `npm run check` is the full gate. Nothing merges unless it passes. |
| 89 | +- All commits require a `Signed-off-by` line (DCO). Use `git commit -s`. |
0 commit comments