Layer 1: CLI Command Layer
Entry Point & Genome Loading
The CLI Command Layer is where users interact with The Architech. It handles command parsing, TypeScript genome execution, and validation.
Commands
architech new <genome-file> # Create new project
architech add <feature> # Add to existing
architech list-genomes # List available genomes
architech analyze <repo> # Analyze repository
architech scale # Scale to monorepoThe new Command Flow
Step 1: Parse Command
// src/commands/new.ts
export function createNewCommand(): Command {
command
.argument('<genome-file>', 'Path to .genome.ts file')
.option('-d, --dry-run', 'Show what would be created')
.option('-v, --verbose', 'Enable verbose logging')
.action(async (genomeFile, options) => {
// Handle command
});
}Step 2: Execute TypeScript Genome
Critical innovation: Uses tsx to execute TypeScript files:
async function executeTypeScriptGenome(genomePath: string): Promise<Genome> {
const genomeCode = readFileSync(genomePath, 'utf-8');
// Execute with tsx runtime
const result = execSync(`tsx -e "${wrapperCode}"`, {
encoding: 'utf-8',
cwd: process.cwd()
});
const genome = JSON.parse(result.trim());
return genome;
}Why tsx?: Allows users to write real TypeScript with:
- Import statements
- Type checking
- IDE autocomplete
- Full TypeScript features
Step 3: Validate Genome
const validation = validateRecipe(genome);
if (!validation.valid) {
validation.errors.forEach(error => logger.error(error));
process.exit(1);
}Step 4: Pass to Orchestrator
const orchestrator = new OrchestratorAgent(projectManager);
const result = await orchestrator.executeRecipe(genome, verbose, logger);