Type System
The Shared Contract: CLI ← Types → Marketplace
The types package (@thearchitech.xyz/types) provides shared type definitions between the CLI and Marketplace, enabling type-safe genomes and blueprints.
The Three-Way Relationship
Key Type Definitions
Genome (User-Facing)
// types-package/src/define-genome.ts
export interface Genome {
version: string;
project: {
name: string;
framework: string;
path: string;
description?: string;
};
modules: GenomeModule[];
options?: {
skipInstall?: boolean;
};
}
export interface GenomeModule {
id: string;
parameters?: Record<string, any>;
features?: Record<string, boolean>;
}Users write genomes with full TypeScript support:
import { defineGenome } from '@thearchitech.xyz/types';
export default defineGenome({
project: { ... }, // ← Autocomplete
modules: [ ... ] // ← Type-checked
});Blueprint (Marketplace-Facing)
// types-package/src/blueprint.ts
export interface Blueprint {
id: string;
name: string;
description: string;
version: string;
requires?: string[];
provides?: string[];
contextualFiles?: string[];
actions: BlueprintAction[];
}BlueprintAction (Shared)
// types-package/src/blueprint-actions.ts
export type BlueprintAction =
| CreateFileAction
| EnhanceFileAction
| InstallPackagesAction
| AddScriptAction
| RunCommandAction
// ... more action types
export interface CreateFileAction {
type: 'CREATE_FILE';
path: string;
content?: string;
template?: string;
data?: Record<string, any>;
forEach?: string;
}
export interface EnhanceFileAction {
type: 'ENHANCE_FILE';
path: string;
modifier: string;
params: Record<string, any>;
fallback?: 'create' | 'skip' | 'error';
}MergedConfiguration (Constitutional Architecture)
// types-package/src/constitutional-architecture.ts
export interface MergedConfiguration {
module: {
id: string;
version: string;
defaults: Record<string, any>;
parameters: Record<string, any>;
};
project: ProjectContext;
activeFeatures: string[];
}Used in dynamic blueprints:
export default function(config: MergedConfiguration): BlueprintAction[] {
// Access merged parameters
if (config.module.parameters.typescript) { ... }
// Check active features
if (config.activeFeatures.includes('auth')) { ... }
}Why a Separate Types Package?
1. Shared Contract
CLI and Marketplace both depend on same types:
// CLI's package.json
{
"dependencies": {
"@thearchitech.xyz/types": "file:../types-package"
}
}
// Marketplace's package.json
{
"dependencies": {
"@thearchitech.xyz/types": "file:../types-package"
}
}2. Version Synchronization
When types change:
- Update types-package
- Both CLI and Marketplace get update
- No drift between implementations
3. User-Facing Types
Users import types for genome creation:
import { defineGenome, Genome } from '@thearchitech.xyz/types';Type Safety Flow
User writes genome.ts
↓ (imports from @thearchitech.xyz/types)
TypeScript checks types
↓ (compile-time validation)
User runs architech new
↓ (runtime execution)
CLI validates against types
↓ (runtime validation)
Marketplace blueprints use same types
↓
Type-safe executionLimitations
Current: Type Sync Risk
Issue: Types package can drift from CLI implementation.
Example:
// CLI adds new action type
case 'NEW_ACTION':
return newActionHandler.handle(action);
// But types-package not updated
// TypeScript doesn't know about NEW_ACTIONMitigation: Manual synchronization (fragile)
Proposed fix: Generate types from CLI (single source of truth)
Next Steps
- Blueprint Actions → - All action types
- Limitations → - Type sync issue