Layer 5: Action Handler Layer
Semantic Action Routing
Action Handlers route semantic actions (CREATE_FILE, ENHANCE_FILE, etc.) to appropriate execution logic.
Purpose
Provide semantic abstractions over low-level file operations.
Blueprint authors write:
{ type: 'ENHANCE_FILE', path: 'layout.tsx', modifier: 'jsx-children-wrapper' }Not:
// Low-level operations blueprint authors DON'T write:
const ast = parseFile('layout.tsx');
const jsxElement = findJSXElement(ast);
modifyChildren(jsxElement);
writeFile('layout.tsx', serialize(ast));Action Handlers
File Location
src/core/services/execution/blueprint/action-handlers/Available Handlers
create-file-handler.ts- CREATE_FILE actionenhance-file-handler.ts- ENHANCE_FILE actioninstall-packages-handler.ts- INSTALL_PACKAGES actionadd-script-handler.ts- ADD_SCRIPT actionadd-env-var-handler.ts- ADD_ENV_VAR actionadd-dependency-handler.ts- ADD_DEPENDENCY actionrun-command-handler.ts- RUN_COMMAND action
Registry Pattern
// src/core/services/execution/blueprint/action-handlers/action-handler-registry.ts
export class ActionHandlerRegistry {
private handlers: Map<string, ActionHandler>;
constructor(modifierRegistry: ModifierRegistry) {
this.handlers = new Map();
this.registerHandlers(modifierRegistry);
}
async handleAction(
action: BlueprintAction,
context: ProjectContext,
projectRoot: string,
vfs: VirtualFileSystem
): Promise<ActionResult> {
const handler = this.handlers.get(action.type);
if (!handler) {
return { success: false, error: `Unknown action type: ${action.type}` };
}
return await handler.handle(action, context, projectRoot, vfs);
}
}