|
| 1 | +--- |
| 2 | +name: build-extension |
| 3 | +description: Build, test, and package VSCode extensions in the dart_node repo |
| 4 | +argument-hint: "[too-many-cooks|dart-node-vsix] [build|test|package|install]" |
| 5 | +disable-model-invocation: true |
| 6 | +allowed-tools: Bash |
| 7 | +--- |
| 8 | + |
| 9 | +# Build VSCode Extensions |
| 10 | + |
| 11 | +This repo has two VSCode extension components: |
| 12 | + |
| 13 | +| Component | Location | What it is | |
| 14 | +|-----------|----------|------------| |
| 15 | +| **dart_node_vsix** | `packages/dart_node_vsix/` | The SDK package — Dart bindings for the VSCode extension API (commands, tree views, webviews, status bar, etc.) | |
| 16 | +| **too_many_cooks** | `examples/too_many_cooks_vscode_extension/` | A concrete extension built with that SDK — multi-agent coordination UI | |
| 17 | + |
| 18 | +## too-many-cooks extension |
| 19 | + |
| 20 | +**Full build** (MCP server + extension + .vsix package): |
| 21 | +```bash |
| 22 | +bash examples/too_many_cooks_vscode_extension/build.sh |
| 23 | +``` |
| 24 | + |
| 25 | +This does: |
| 26 | +1. Compiles MCP server: `dart compile js` → `add_preamble.dart` → `server_node.js` |
| 27 | +2. Compiles extension: `dart compile js` → `wrap-extension.js` bridge → `out/lib/extension.js` |
| 28 | +3. Packages: `vsce package` → `.vsix` file |
| 29 | + |
| 30 | +**Test** (runs Mocha tests under a real VSCode instance): |
| 31 | +```bash |
| 32 | +cd examples/too_many_cooks_vscode_extension && npm run pretest && npm test |
| 33 | +``` |
| 34 | +On headless Linux, prefix with `xvfb-run -a`. |
| 35 | + |
| 36 | +**Install into VSCode**: |
| 37 | +```bash |
| 38 | +code --install-extension examples/too_many_cooks_vscode_extension/*.vsix |
| 39 | +``` |
| 40 | + |
| 41 | +## dart_node_vsix SDK package |
| 42 | + |
| 43 | +**Test the SDK** (Dart tests compiled to JS, run in VSCode): |
| 44 | +```bash |
| 45 | +cd packages/dart_node_vsix && npm install && npm run compile && npm test |
| 46 | +``` |
| 47 | + |
| 48 | +**What it provides** — Dart bindings for: |
| 49 | +- `commands`, `window`, `workspace`, `statusBar` |
| 50 | +- `TreeView`, `Webview`, `OutputChannel` |
| 51 | +- `ExtensionContext`, `Disposable` |
| 52 | +- `Mocha` test API bindings |
| 53 | +- JS interop helpers (`Promise`, `EventEmitter`) |
| 54 | + |
| 55 | +## Architecture |
| 56 | + |
| 57 | +Both use the same pattern: Dart → `dart compile js` → wrapper script → VSCode-compatible JS module. |
| 58 | + |
| 59 | +The wrapper scripts (`scripts/wrap-extension.js`, `scripts/wrap-tests.js`) bridge dart2js output to VSCode's CommonJS `require`/`module.exports` system and inject polyfills (navigator, self) needed by dart2js async scheduling. |
0 commit comments