2026 03 14 Vitto Studio Live Platform Engine

Documentation for Plans

Vitto Studio Live Platform Engine — Implementation Plan

For agentic workers: REQUIRED: Use superpowers:subagent-driven-development (if subagents available) or superpowers:executing-plans to implement this plan. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Make Vitto Studio render AI-generated Angular 20 platforms in-browser via rspack WASM compilation with pre-built ESM SDK libraries.

Architecture: Pre-build 39 shared NX libraries to ESM bundles using esbuild, serve locally via dev server proxy. rspack compiles ONLY module code (feature modules), resolving libraries via browser import maps. A synthesized app shell wraps modules for preview.

Tech Stack: esbuild, rspack/browser WASM, Angular 20 JIT, browser import maps, Service Worker asset serving

Spec: docs/superpowers/specs/2026-03-14-vitto-studio-live-platform-engine-design.md


Chunk 1: Platform SDK Build Pipeline

Task 1: Create SDK build script

Files:

Description: A Node.js script that reads the platform-base-template's library source files, compiles each to an ESM bundle using esbuild, and outputs to dist/platform-sdk/. The script topologically sorts libraries by dependency order so that each library's dependencies are built first (though with all inter-library imports marked as externals, build order doesn't strictly matter for esbuild — it matters for validation).

Maps each @libs-* path alias to its source directory and declares external dependencies.

Uses esbuild to compile each library:

Manifest lists all built libraries. Import map resolves all package specifiers to local dev server URLs (/sdk/v1/{lib}/index.js).

"sdk:build": "npx tsx tools/scripts/build-platform-sdk.ts"

Expected: dist/platform-sdk/ contains 39 directories, each with index.js

[S224.2] feat: add platform SDK build pipeline for ESM library compilation

Task 2: Serve SDK locally via Angular dev server

Files:

Description: The built SDK files need to be accessible at /sdk/v1/{lib}/index.js from the browser. The simplest approach is to add a proxy rule or asset copy in the Angular dev server config.

[S224.2] feat: serve platform SDK via dev server proxy

Chunk 2: rspack Integration with SDK

Task 3: Expand ESM CDN map with SDK libraries

Files:

Description: Add all 39 SDK libraries AND third-party dependencies to the CDN map. This tells rspack to treat them as externals (not bundled) and the import map resolves them at runtime.

Each entry maps the package name to a URL:

[S224.2] feat: expand ESM CDN map with SDK libraries and third-party deps

Task 4: Enhance BundlerFilesystemService for synthesized app shell

Files:

Description: The core of Phase 3. Instead of compiling the generated platform's app files (which have bugs), we synthesize a clean app shell from the module metadata in VFS. The synthesized shell includes main.ts, app.component.ts, app.routes.ts, app.config.ts, and an index.html with the import map.

export interface SdkConfig {
  sdkBaseUrl: string;           // '/sdk/v1' for local dev
  modules: ModuleMetadata[];    // Detected modules from VFS
  spaceId: string;
  universeId: string;
}

export interface ModuleMetadata {
  slug: string;                 // 'match-center'
  routesFile: string;           // 'match-center.routes.ts'
  routesExport: string;         // 'MatchCenterRoutes' or detected export name
}

This method:

  1. Detects modules from VFS paths (/modules/{slug}/src/)
  2. Finds each module's routes file (scans for *.routes.ts)
  3. Generates main.ts, app.component.ts, app.routes.ts, app.config.ts
  4. Generates index.html with full import map
  5. Returns enriched file map
[S224.2] feat: synthesize app shell and import maps in BundlerFilesystemService

Task 5: Update rspack config for module compilation

Files:

Description: rspack needs to know where module source files are in memfs and to treat all SDK libraries as externals.

[S224.2] feat: update rspack config for SDK external resolution

Task 6: Wire up PreviewService for end-to-end preview

Files:

Description: Connect VFS hydration → rspack compilation so the preview actually works.

Add getModuleMetadata(): ModuleMetadata[] method that scans VFS for module directories and detects route files.

Include module metadata, spaceId, universeId from project context.

Load the match-center and club-members modules into VFS, trigger rspack compilation, verify preview iframe renders.

[S224.2] feat: wire up end-to-end platform preview pipeline

Chunk 3: Generation Pipeline Fixes

Task 7: Fix module generation templates

Files:

Description: Fix the template bugs that cause generated code to fail compilation.

Ensure generated modules export routes as {ModuleName}Routes from {module-slug}.routes.ts

Export from ./ not ./lib/ (there is no lib/ directory)

Use correct English plurals: matches (not matchs), coaches (not coachs)

Change templates to output .css files for component styles. Theme variables available via CSS custom properties.

[S224.2] fix: correct module generation templates for route imports and exports

Chunk 4: Visual Editing Loop

Task 8: Create VisualEditorService

Files:

Description: Bridge between click-to-select in preview and Vitto AI editing. When user clicks a component, reads its source from VFS and provides rich context to Vitto.

Signals:

Methods:

When focusContext changes with source='preview', trigger onComponentSelected.

[S224.2] feat: add VisualEditorService for click-to-edit bridge

Task 9: Create Vitto visual editing tools

Files:

Description: Add tools that Vitto can use to modify component source code.

[S224.2] feat: add Vitto visual editing tools for studio

Task 10: Wire visual editing end-to-end

Files:

Description: Connect VisualEditorService → Vitto prompt context → tool execution → VFS update → recompile.

[S224.2] feat: wire visual editing loop end-to-end

Execution Order

Task 1 (SDK build script) → Task 2 (serve locally)
  ↓
Task 3 (CDN map) → Task 4 (bundler fs) → Task 5 (rspack config)
  ↓
Task 6 (wire preview) ← MILESTONE: Preview renders!
  ↓
Task 7 (gen fixes) — can be parallel with above
  ↓
Task 8 (VisualEditorService) → Task 9 (Vitto tools) → Task 10 (wire editing)
  ↓
MILESTONE: Full editing loop works!