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:
- Detects framework modules from your genome
- Executes framework bootstrap in the correct app directory
- Runs framework CLI commands (e.g.,
create-next-app) - 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β./(notapps/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 bootstrapThis 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:
- Genome monorepo config (highest priority)
- Generated project's
package.json(checkspackageManagerfield) - Lock files in project root (
pnpm-lock.yaml,yarn.lock, etc.) - Default:
pnpm(supportsworkspace:*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 utilitiesTroubleshooting
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 directoryNested 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
- CLI Architecture - Overall CLI architecture
- Marketplace Adapter Interface - How marketplaces work
- Path Resolution - Path resolution strategy