Build Guide¶
This guide covers the build system, build scripts, and packaging process for NebulaFlow.
Prerequisites¶
- Node.js ≥ 18 and npm ≥ 9 (see Node.js downloads)
- VS Code ≥ 1.90.0 (for extension development and debugging)
- Git (for cloning the repository)
Build Architecture¶
NebulaFlow is a VS Code extension with a React webview interface. The build process consists of three main components:
- TypeScript Type Checking - Validates all TypeScript code
- Webview Build - Bundles the React application (React Flow UI)
- Extension Build - Bundles the VS Code extension host code
- Electron Build - Builds the Electron application (optional)
Build Scripts¶
Full Build¶
Build everything with type checking:
This executes in order:
1. npm run typecheck - TypeScript validation for all components
2. npm run build:webview - Vite bundles React app into dist/webviews/
3. npm run build:ext - esbuild bundles extension + SDK into dist/src/extension.js
Partial Builds¶
Build specific components:
# Webview only (React UI)
npm run build:webview
# Extension only (VS Code extension host)
npm run build:ext
# Electron app (main process)
npm run build:electron
Watch Modes (Development)¶
Watch for changes and rebuild automatically:
# Webview watch (hot reload)
npm run watch:webview
# Extension watch (requires VS Code reload)
npm run watch:ext
# Combined watch (webview + extension)
npm run watch
Note: The combined watch (npm run watch) runs the webview watcher. Extension changes require a VS Code window reload.
Type Checking¶
Run TypeScript type checking for all components:
This validates:
- Extension code (src/, workflow/)
- Webview code (workflow/Web/)
- Electron code (electron/)
Linting & Formatting¶
NebulaFlow uses Biome for linting and formatting:
# Check (typecheck + lint)
npm run check
# Lint only
npm run lint
# Auto-fix (also aliased as `npm run format`)
npm run biome
Packaging¶
Create a VSIX package for distribution:
This creates a .vsix file in the dist/ directory.
Electron Packaging¶
Build and package the Electron application:
# Build Electron app
npm run pack:electron
# Build Windows installer
npm run pack:win
# Create Windows zip
npm run zip:win
Build Configuration¶
TypeScript Configuration¶
- Main tsconfig (
tsconfig.json): Extends@sourcegraph/tsconfig, targets ES2022, Node16 module system - Electron tsconfig (
electron/tsconfig.json): Extends main config, outputs todist/electron/ - Webview tsconfig (
workflow/Web/tsconfig.json): Vite-managed, React JSX support
Webview Build (Vite)¶
- Entry:
workflow/Web/workflow.html - Output:
dist/webviews/ - Bundler: Vite with React plugin
- Aliases:
@graph,@sidebar,@modals,@nodes,@shared - Development: Source maps enabled, no minification
- Production: Minified, no source maps
Extension Build (esbuild)¶
- Entry:
src/extension.ts - Output:
dist/src/extension.js - Platform: Node.js
- Format: CommonJS (CJS)
- Target: Node 20
- External: vscode (provided by VS Code runtime)
Electron Build¶
- Main process:
electron/main/ - Preload:
electron/preload/ - Output:
dist/electron/ - Packaging: electron-builder (AppImage for Linux, DMG for macOS, NSIS for Windows)
Build Output Structure¶
dist/
├── src/ # Extension bundle (extension.js)
├── webviews/ # Webview assets (HTML, JS, CSS)
├── electron/ # Electron app bundles
└── release/ # Packaged Electron apps (AppImage, DMG, NSIS)
Development Workflow¶
Initial Setup¶
-
Clone and install dependencies:
-
Set environment variables:
-
Build the project:
Development Mode¶
-
Start the watch mode:
-
Open the project in VS Code.
-
Press F5 to launch the extension in debug mode.
-
In the new VS Code window, run the command: NebulaFlow: Open Workflow Editor.
Troubleshooting Build Issues¶
| Issue | Solution |
|---|---|
| Webview assets don't load | Run npm run build or start the webview watcher (npm run watch:webview). |
| Type errors | Run npm run typecheck and fix diagnostics. |
| Lint/format issues | Run npm run check or npm run biome. |
| Extension fails to load | Check VS Code version ≥ 1.90.0; reload the window. |
| pi SDK not available | Run npm install and rebuild the extension. |
| No authenticated pi model | Configure pi /login, auth.json, or the selected provider environment variable. |
| Build hangs | Kill any hanging processes and restart the build. |
CI/CD Build Process¶
NebulaFlow uses GitHub Actions for continuous integration. The build workflow (.github/workflows/build.yml) runs:
- Type checking (
npm run typecheck) - Linting (
npm run lint) - Build and packaging (
npm run package:vsix) - Upload artifacts (VSIX file and build logs)
- Create release (when a tag is pushed)
You can run the same steps locally to verify your changes before pushing.
Build Performance Tips¶
- Incremental builds: Use watch modes (
npm run watch) for faster development iteration. - Skip type checking: For quick webview changes, use
npm run build:webviewdirectly. - Clean build: If you encounter strange issues, run
npm run buildto ensure a clean build. - Cache: TypeScript and Vite caches are stored in
node_modules/.cache/. Delete this folder if caches become corrupted.
Build Dependencies¶
Runtime Dependencies¶
@earendil-works/pi-agent-core,@earendil-works/pi-ai, and@earendil-works/pi-coding-agent: pi SDK@xyflow/react: React Flow for graph visualizationreact,react-dom: UI framework- Various UI components (Radix UI, lucide-react, etc.)
Build Dependencies¶
typescript: TypeScript compileresbuild: Extension bundlervite: Webview bundler@biomejs/biome: Linting and formattingelectron,electron-builder: Electron packaging
Next Steps¶
- Read Development Guide for setting up the development environment.
- Explore the Technical Architecture for implementation details.
- Check the Testing Guide for testing strategies.