Reference implementation for the Phoenix Architecture. Work in progress. aicoding.leaflet.pub/
ai coding crazy
at main 72 lines 2.6 kB view raw
1/** 2 * Architecture & Runtime Target 3 * 4 * Architecture defines the SYSTEM SHAPE — communication patterns, data ownership, 5 * component grain, evaluation surfaces. Language/runtime agnostic. 6 * 7 * Runtime Target defines the COMPILATION TARGET — language, frameworks, templates, 8 * packages. Implements an architecture in a specific stack. 9 * 10 * Hierarchy: 11 * Spec (what users want) 12 * → Architecture (what kind of system) 13 * → Runtime Target (what language/framework) 14 * → Generated Code 15 */ 16 17// ─── Architecture (system shape, language-agnostic) ───────────────────────── 18 19export interface Architecture { 20 /** Unique name, e.g., 'web-api' */ 21 name: string; 22 /** Human description */ 23 description: string; 24 25 /** How components communicate: 'rest', 'graphql', 'grpc', 'events', 'cli' */ 26 communicationPattern: string; 27 /** How data is owned: 'per-component', 'shared-db', 'event-sourced' */ 28 dataOwnership: string; 29 /** How to verify components: 'http-endpoints', 'unit-tests', 'cli-output' */ 30 evaluationSurface: string; 31 32 /** Architecture-level prompt: describes system shape for the LLM (no language specifics) */ 33 systemPrompt: string; 34 35 /** Available runtime targets for this architecture */ 36 runtimeTargets: string[]; 37} 38 39// ─── Runtime Target (language/framework specific) ─────────────────────────── 40 41export interface RuntimeTarget { 42 /** Unique name, e.g., 'node-typescript' */ 43 name: string; 44 /** Human description */ 45 description: string; 46 /** Language: 'typescript', 'python', 'go', etc. */ 47 language: string; 48 49 /** Production dependencies: package name → version range */ 50 packages: Record<string, string>; 51 /** Dev dependencies */ 52 devPackages: Record<string, string>; 53 54 /** Module template — the LLM fills in marked sections, structure is guaranteed */ 55 moduleTemplate: string; 56 /** LLM prompt extension — language/framework-specific rules */ 57 promptExtension: string; 58 /** Few-shot code examples showing the exact patterns */ 59 codeExamples: string; 60 61 /** Shared boilerplate files: relative path → file content */ 62 sharedFiles: Record<string, string>; 63 /** Extra package.json / pyproject.toml fields */ 64 packageExtras: Record<string, unknown>; 65} 66 67// ─── Resolved target (what the pipeline actually uses) ────────────────────── 68 69export interface ResolvedTarget { 70 architecture: Architecture; 71 runtime: RuntimeTarget; 72}