CLI Internals
Framework Bootstrap

Framework Bootstrap

Framework bootstrap is the process of initializing application frameworks (Next.js, Expo, Hono, etc.) before regular module execution. This ensures the correct project structure exists before any modules try to create files.

Overview

When you create a project with a framework (e.g., Next.js for web apps), the CLI:

  1. Detects framework modules from your genome
  2. Executes framework bootstrap in the correct app directory
  3. Runs framework CLI commands (e.g., create-next-app)
  4. Filters framework modules from regular execution (they only run once)

Execution Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 1. Path Mapping Generation          β”‚
β”‚    - Generate all path keys         β”‚
β”‚    - Available even for non-existentβ”‚
β”‚      apps (using default patterns)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 2. Framework Bootstrap              β”‚
β”‚    - Identify framework modules      β”‚
β”‚    - Create VFS with app directory  β”‚
β”‚      as root (e.g., apps/web)       β”‚
β”‚    - Execute framework CLI commands β”‚
β”‚    - Framework modules execute HERE β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 3. Regular Module Execution         β”‚
β”‚    - Framework modules filtered out β”‚
β”‚    - Regular modules execute         β”‚
β”‚    - All paths correctly resolved   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Framework Module Detection

Framework modules are identified using metadata, not hardcoded patterns:

// Metadata-based detection (fully dynamic)
const isFramework = 
  metadata?.category === 'framework' || 
  metadata?.category === 'foundation' ||
  (metadata?.type && String(metadata.type).toLowerCase() === 'framework');

This means:

  • βœ… Works with any marketplace structure
  • βœ… No hardcoded paths or patterns
  • βœ… Fully marketplace-agnostic

Path Resolution During Bootstrap

Critical: During framework bootstrap, the VFS root IS the app directory (e.g., apps/web).

This means paths must resolve relative to the VFS root:

// During bootstrap
if (plan.appType && key === `apps.${plan.appType}.root`) {
  paths[key] = './'; // VFS root IS the app directory
}

Why? This prevents creating nested directories like apps/web/apps/web/.

Example

When bootstrapping Next.js for a web app:

  • VFS Root: /project/apps/web
  • Path Resolution: paths.apps.web.root β†’ ./ (not apps/web/)
  • File Creation: next.config.js β†’ /project/apps/web/next.config.js βœ…

Working Directory

Framework CLI commands (e.g., create-next-app) must run in the correct directory:

// VFS is created with app directory as root
const vfs = new VirtualFileSystem(
  `framework-${frameworkId}`,
  plan.targetPath // e.g., /project/apps/web
);
 
// Commands use VFS root as working directory
const workingDir = vfs.getProjectRoot(); // /project/apps/web
execSync('npx create-next-app@latest .', { cwd: workingDir });

Framework Modules Execute Once

Framework modules are filtered out from regular module execution:

// In orchestrator-agent.ts
const regularModules = resolvedGenome.modules.filter(
  mod => !isFrameworkModule(mod, resolvedGenome)
);
 
// Framework modules only execute during bootstrap
// Regular modules execute after bootstrap

This ensures:

  • βœ… Framework setup happens first
  • βœ… Framework modules don't execute twice
  • βœ… Correct execution order

Package Manager Detection

During dependency installation, the CLI detects the package manager from:

  1. Genome monorepo config (highest priority)
  2. Generated project's package.json (checks packageManager field)
  3. Lock files in project root (pnpm-lock.yaml, yarn.lock, etc.)
  4. Default: pnpm (supports workspace:* protocol)

Important: Corepack is bypassed to prevent checking parent directories (CLI's package.json).

Framework Blueprints

Framework blueprints should NOT create config files that framework CLIs already create:

// ❌ DON'T create these (framework CLI handles them)
// - next.config.js (create-next-app creates this)
// - tsconfig.json (create-next-app creates this)
// - app.json (create-expo-app creates this)
 
// βœ… DO create framework-specific enhancements
// - Custom middleware
// - Additional config overrides
// - Framework-specific utilities

Troubleshooting

Framework commands run in wrong directory

Symptom: create-next-app runs in project root instead of apps/web

Solution: Verify VFS is created with correct targetPath:

const vfs = new VirtualFileSystem(blueprintId, plan.targetPath);
// plan.targetPath should be absolute path to app directory

Nested app directories created

Symptom: Files created at apps/web/apps/web/ instead of apps/web/

Solution: Ensure paths resolve to ./ during bootstrap:

if (plan.appType && key === `apps.${plan.appType}.root`) {
  paths[key] = './'; // Relative to VFS root
}

Framework modules execute twice

Symptom: Framework setup runs during bootstrap AND regular execution

Solution: Verify framework modules are filtered:

const regularModules = resolvedGenome.modules.filter(
  mod => !isFrameworkModule(mod, resolvedGenome)
);

Related