CLI Internals
Blueprint Actions
Overview

Blueprint Actions

High-Level Semantic Operations

Blueprint Actions are the semantic building blocks that blueprint authors use to generate code. They are high-level operations that abstract away implementation complexity.


Philosophy: Semantic Over Primitive

The Problem with Primitives

Traditional code generators use low-level operations:

// LOW-LEVEL (bad for blueprint authors)
const ast = parseTypeScript('src/file.ts');
const importDecl = createImportDeclaration('QueryProvider', '@/lib/query');
ast.body.unshift(importDecl);
writeFile('src/file.ts', serializeAST(ast));

Problems:

  • ❌ Blueprint authors need AST knowledge
  • ❌ Brittle and error-prone
  • ❌ Hard to maintain
  • ❌ Inconsistent across blueprints

The Architech Approach: Semantic Actions

// HIGH-LEVEL (good for blueprint authors)
{
  type: 'ENHANCE_FILE',
  path: 'src/file.ts',
  modifier: 'ts-module-enhancer',
  params: {
    importsToAdd: [
      { name: 'QueryProvider', from: '@/lib/query' }
    ]
  }
}

Benefits:

  • βœ… Intent-driven (what to do, not how)
  • βœ… Simple API for blueprint authors
  • βœ… Complexity hidden in CLI
  • βœ… Consistent across all blueprints

Core Principle

Complexity must be in the CLI, never in the blueprint.

Blueprint authors focus on what to generate. The CLI handles how to safely execute it.


Action Categories

1. File Creation Actions

2. File Modification Actions

3. Dependency Actions

4. Configuration Actions

5. Command Actions


Actions β†’ Modifiers β†’ AST

The Execution Chain

Blueprint Action (semantic)
      ↓
Action Handler (routes)
      ↓
Modifier (if complex operation)
      ↓
AST Manipulation (ts-morph)
      ↓
VFS Write (in-memory)

Example: ENHANCE_FILE Flow

// 1. Blueprint author writes (semantic):
{
  type: 'ENHANCE_FILE',
  path: 'src/app/layout.tsx',
  modifier: 'jsx-children-wrapper',
  params: { wrapperComponent: 'QueryProvider' }
}
 
// 2. Action handler routes:
const modifier = modifierRegistry.get('jsx-children-wrapper');
await modifier.execute(path, params, context, vfs);
 
// 3. Modifier uses AST:
const sourceFile = project.createSourceFile(path, content);
// ... AST manipulation ...
const modified = sourceFile.getFullText();
 
// 4. VFS write:
vfs.writeFile(path, modified);

Blueprint author never touches AST!


Documentation Structure

Action Reference β†’

Complete API for all actions with examples.

Modifiers β†’

Deep dive into the modifier system and AST manipulation.

Best Practices β†’

Patterns and anti-patterns for blueprint authors.

Advanced Patterns β†’

forEach loops, conditional actions, dynamic blueprints.


For Marketplace Module Authors

If you're creating adapters, connectors, or features for a marketplace, this section is your complete reference for blueprint actions.

Start here: Action Reference β†’


Actions are the language blueprints speak. Master them to master The Architech.