nebulaflow

Architecture

This document provides a detailed overview of NebulaFlow’s architecture, including its component structure, execution model, and design patterns.

Overview

NebulaFlow is a VS Code extension that provides a visual workflow editor for LLM+CLI workflows. The architecture consists of two main components:

  1. VS Code Extension (src/extension.ts): Runs in VS Code, manages the webview interface, and orchestrates workflow execution
  2. Webview UI (workflow/Web/): React-based interface using React Flow for visual graph editing

The extension uses the Amp SDK and OpenRouter SDK for LLM operations and executes CLI commands through the Node.js child_process API. Execution is orchestrated in the extension with streaming output, approval system, and real-time event handling.

Vertical Slice Architecture (VSA)

NebulaFlow follows a Vertical Slice Architecture where code is organized by features (slices) rather than technical layers. This maximizes context locality and keeps all code required to understand a feature within the fewest possible files and folders.

Directory Structure

src/
  extension.ts                    # VS Code extension entry point
workflow/
  Application/                    # Orchestration and message handling
    register.ts                   # Extension activation and webview setup
    messaging/                    # Protocol converters and message handling
    workflow-session.ts           # Workflow session management
  Core/                          # Pure business logic (no side effects)
    models.ts                     # Node types and data structures
    Contracts/                    # Shared protocol contracts
      Protocol.ts                 # Message types for extension-webview communication
  DataAccess/                     # I/O operations (file system, storage)
    fs.ts                         # File system operations for workflows/subflows
  Execution/                      # Node execution logic
    Application/handlers/         # Workflow execution handler
    Core/engine/                  # Parallel scheduler
    Core/execution/               # Input evaluation, output combination
    Application/node-runners/     # Individual node executors
  LLMIntegration/                 # LLM provider integrations (Amp, OpenRouter)
  Shared/                         # Generic primitives (Host, Infrastructure)
    Host/                         # VS Code host adapter
    Infrastructure/               # Messaging, workspace management
  Web/                           # Webview UI (React + React Flow)
    components/                   # React components
      nodes/                      # Node UI components
    services/                     # Protocol communication
    WorkflowApp.tsx               # Main webview application

Flow Model (REPR)

Requests flow through these logical stages:

  1. Entry (Component/API): Receives input from VS Code command or webview UI
  2. Application (Handler/Validator): Orchestrates and validates workflow execution
  3. Core (Pure Logic): Transforms data without side effects
  4. Infra (DataAccess/External): Performs I/O (file system, network, CLI execution)

Example: Executing a workflow

Execution Model

Streaming Output

Execution events stream in real-time from the extension to the webview:

Approval System

CLI nodes require explicit user approval before execution:

  1. Node enters pending_approval state
  2. Webview displays approval prompt with command details
  3. User approves (node_approved) or rejects (node_rejected)
  4. Execution continues or aborts

Parallel Execution

NebulaFlow uses a parallel scheduler that executes nodes when their dependencies are satisfied:

Pause/Resume

Workflows can be paused and resumed from any node:

Node Types

NebulaFlow provides the following node types (defined in workflow/Core/models.ts and workflow/Web/components/nodes/Nodes.tsx):

Agent Nodes

Shell Nodes

Text Nodes

Logic Nodes

Preview Node

Subflow Nodes

Protocol

The extension and webview communicate using a custom workflow message protocol defined in workflow/Core/Contracts/Protocol.ts. All messages extend BaseWorkflowMessage with a type field.

Message Categories

Commands (Webview → Extension)

Events (Extension → Webview)

Data Transfer

Payload Types

Configuration

Environment Variables

VS Code Settings

Workflow Settings

Dependencies

Core Dependencies

Webview Dependencies

SDK Integrations

Development Dependencies

Development Workflow

Build Process

  1. Webview: npm run build:webview → Vite bundles React app into dist/webviews/
  2. Extension: npm run build:ext → Esbuild bundles extension + SDK into dist/extension.js
  3. Full Build: npm run build → Both steps, auto-syncs SDK via sync:sdk

Testing

Debugging

  1. Set AMP_API_KEY environment variable
  2. Launch VS Code extension host (F5)
  3. Open NebulaFlow panel
  4. Test workflows with LLM/CLI nodes

Performance Considerations

Parallel Execution

Streaming

Caching

Security

CLI Execution

LLM Integration

File System

Extensibility

Custom Nodes

Subflows

Protocol Extensions

References