@almadar/skills 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/generators/utils.ts","../src/orbitals-skills-generators/helpers.ts","../src/prompts/skill-sections/architecture.ts","../src/prompts/skill-sections/common-errors.ts","../src/prompts/skill-sections/decomposition.ts","../src/prompts/skill-sections/bindings-guide.ts","../src/prompts/skill-sections/pattern-design-guide.ts","../src/prompts/skill-sections/theme-guide.ts","../src/prompts/skill-sections/custom-traits.ts","../src/prompts/skill-sections/schema-updates.ts","../src/prompts/skill-sections/context-usage.ts","../src/prompts/skill-sections/design-errors.ts","../src/prompts/skill-sections/fixing-guidance.ts","../src/prompts/skill-sections/game-guidance.ts","../src/prompts/skill-sections/uses-imports.ts","../src/orbitals-skills-generators/lean-orbital-skill-generator.ts","../src/generators/kflow-orbitals.ts","../src/orbitals-skills-generators/lean-fixing-skill-generator.ts","../src/generators/kflow-orbital-fixing.ts","../src/generators/domain-language.ts","../src/orbitals-skills-generators/lean/lean-orbital-generator.ts","../src/orbitals-skills-generators/lean/lean-fixing-generator.ts","../src/generators/index.ts","../src/prompts/type-references.ts","../src/prompts/generation-prompts.ts","../src/prompts/behaviors-reference.ts","../src/evals/composition-quality.ts"],"names":["PATTERN_TYPES","getPatternActionsRef","generateLeanOrbitalSkill","LEAN_CORE_INSTRUCTIONS","LEAN_ERROR_HANDLING","LEAN_VALIDATION_RULES","ODL_SYNTAX_REFERENCE","LEAN_EFFECT_GUARD_SYNTAX","ODL_TO_SCHEMA_MAPPING","generateLeanFixingSkill","getAllPatternTypes","getPatternPropsCompact","getSExprQuickRef","getRenderUIQuickRef","getKeyBehaviorsReference","generateBehaviorsDocs"],"mappings":";;;;;;;;;AAeO,SAAS,kBAAkB,EAAA,EAA8B;AAC9D,EAAA,MAAM,KAAA,GAAQ,CAAC,KAAK,CAAA;AACpB,E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AA,GAAS,KAAK,KAAA,CAAM,IAAA,CAAK,OAAK,CAAA,CAAE,QAAA,KAAa,GAAG,IAAI,CAAA;AAC1D,MAAA,OAAO,MAAA,GAAS,GAAG,MAAA,CAAO,KAAK,GAAG,MAAA,CAAO,MAAA,GAAS,QAAA,GAAM,EAAE,CAAA,CAAA,GAAK,KAAA;AAAA,IACjE,CAAC,CAAA;AAED,IAAA,QAAA,IAAY,CAAA,EAAA,EAAK,IAAA,CAAK,QAAQ,CAAA,GAAA,EAAM,IAAA,CAAK,YAAY,CAAA,GAAA,EAAM,MAAA,CAAO,IAAA,CAAK,KAAK,CAAC,CAAA;AAAA,CAAA;AAAA,EAC/E;AAEA,EAAA,OAAO,QAAA;AACT","file":"index.js","sourcesContent":["/**\n * Skill Generator Utilities\n *\n * Shared utilities for formatting and writing skill files.\n *\n * @packageDocumentation\n */\n\nimport { writeFileSync, mkdirSync, existsSync } from 'fs';\nimport { join } from 'path';\nimport type { SkillFrontmatter, GeneratedSkill } from './types.js';\n\n/**\n * Format skill frontmatter to YAML.\n */\nexport function formatFrontmatter(fm: SkillFrontmatter): string {\n const lines = ['---'];\n lines.push(`name: ${fm.name}`);\n lines.push(`description: ${fm.description}`);\n if (fm.allowedTools?.length) {\n lines.push(`allowed-tools: ${fm.allowedTools.join(', ')}`);\n }\n if (fm.version) {\n lines.push(`version: ${fm.version}`);\n }\n lines.push('---');\n return lines.join('\\n');\n}\n\n/**\n * Write a skill to the filesystem.\n */\nexport function writeSkill(skill: GeneratedSkill, baseDir: string): void {\n const skillDir = join(baseDir, skill.name);\n\n if (!existsSync(skillDir)) {\n mkdirSync(skillDir, { recursive: true });\n }\n\n const skillMd = formatFrontmatter(skill.frontmatter) + '\\n\\n' + skill.content;\n writeFileSync(join(skillDir, 'SKILL.md'), skillMd);\n console.log(` ✓ ${skill.name}/SKILL.md`);\n\n if (skill.references) {\n const refsDir = join(skillDir, 'references');\n if (!existsSync(refsDir)) {\n mkdirSync(refsDir, { recursive: true });\n }\n\n for (const [filename, content] of Object.entries(skill.references)) {\n writeFileSync(join(refsDir, filename), content);\n console.log(` ✓ ${skill.name}/references/${filename}`);\n }\n }\n}\n\n/**\n * Write all skills to the filesystem.\n */\nexport function writeAllSkills(skills: GeneratedSkill[], baseDir: string): void {\n console.log(`\\nWriting ${skills.length} skills to ${baseDir}...`);\n\n for (const skill of skills) {\n writeSkill(skill, baseDir);\n }\n\n console.log(`\\n✓ Generated ${skills.length} skills`);\n}\n","/**\n * Helper functions for generating skill content from @almadar packages.\n * These generate markdown sections by importing from @almadar/* packages.\n * \n * @packageDocumentation\n */\n\nimport { getAllBehaviors, getAllStdOperators, generateBehaviorsDocs, generateModulesDocs } from '@almadar/std';\nimport { PATTERN_TYPES } from '@almadar/core/types';\nimport { getPatternsGroupedByCategory } from '@almadar/patterns';\n\n/**\n * Get minimal type reference (patterns, slots, operators).\n */\nexport function getMinimalTypeReference(): string {\n const patternsByCategory = getPatternsGroupedByCategory();\n const categories = Object.keys(patternsByCategory);\n \n return `## Type Reference\n\n### Pattern Types\n${categories.map(cat => `- **${cat}**: ${patternsByCategory[cat].slice(0, 5).join(', ')}...`).join('\\n')}\n\nTotal: ${PATTERN_TYPES.length} patterns\n\n### Operators\nUse S-expressions for guards and effects. See std library for full list.\n\n**Math**: \\`+\\`, \\`-\\`, \\`*\\`, \\`/\\`, \\`>\\`, \\`<\\`, \\`>=\\`, \\`<=\\`, \\`=\\`, \\`!=\\`\n**Logic**: \\`and\\`, \\`or\\`, \\`not\\`\n**Effects**: \\`set\\`, \\`++\\`, \\`--\\`, \\`persist\\`, \\`fetch\\`, \\`emit\\`, \\`render-ui\\`\n`;\n}\n\n/**\n * Get S-Expression quick reference.\n */\nexport function getSExprQuickRef(): string {\n return `## S-Expression Syntax\n\n**Bindings** (read data):\n- \\`@entity.field\\` - Entity field value\n- \\`@payload.data\\` - Event payload data\n- \\`@state\\` - Current state name\n- \\`@now\\` - Current timestamp\n\n**Guards** (boolean expressions):\n\\`\\`\\`json\n[\">\", \"@entity.count\", 0]\n[\"and\", [\"=\", \"@state\", \"Active\"], [\"<\", \"@entity.value\", 100]]\n\\`\\`\\`\n\n**Effects** (actions):\n\\`\\`\\`json\n[\"set\", \"@entity.count\", [\"+\", \"@entity.count\", 1]]\n[\"persist\", \"update\", \"Task\", \"@entity.id\", \"@payload.data\"]\n[\"emit\", \"TASK_COMPLETED\", { \"id\": \"@entity.id\" }]\n\\`\\`\\`\n`;\n}\n\n/**\n * Get render-ui quick reference.\n */\nexport function getRenderUIQuickRef(): string {\n return `## Render-UI Reference\n\n**Syntax**: \\`[\"render-ui\", slot, config]\\`\n\n**Slots**: \\`main\\`, \\`modal\\`, \\`drawer\\`, \\`sidebar\\`, \\`hud-top\\`, \\`hud-bottom\\`\n\n**Example**:\n\\`\\`\\`json\n[\"render-ui\", \"main\", {\n \"type\": \"entity-table\",\n \"entity\": \"Task\",\n \"columns\": [\"title\", \"status\"]\n}]\n\\`\\`\\`\n\nClear a slot: \\`[\"render-ui\", \"modal\", null]\\`\n`;\n}\n\n/**\n * Get std library minimal reference.\n */\nexport function getStdMinimalReference(): string {\n const operators = getAllStdOperators();\n return `## Standard Library\n\n**Operators**: ${operators.length} total\n\n**Key Categories**:\n- Math: \\`clamp\\`, \\`lerp\\`, \\`random\\`, \\`abs\\`, \\`min\\`, \\`max\\`\n- String: \\`concat\\`, \\`upper\\`, \\`lower\\`, \\`trim\\`, \\`split\\`\n- Array: \\`filter\\`, \\`map\\`, \\`find\\`, \\`contains\\`, \\`length\\`\n- Time: \\`now\\`, \\`format\\`, \\`diff\\`, \\`isPast\\`, \\`isFuture\\`\n\nImport with: \\`uses: [{ from: \"std/operators/math\", as: \"Math\" }]\\`\n`;\n}\n\n/**\n * Get std library full reference.\n */\nexport function getStdFullReference(): string {\n const modulesDocs = generateModulesDocs();\n return `## Standard Library (Full Reference)\n\n${modulesDocs.modules.map(mod => `### ${mod.name}\n${mod.description}\n\n${mod.operators.map(op => `- **${op.name}**: ${op.description}`).join('\\n')}\n`).join('\\n')}\n`;\n}\n\n/**\n * Get std behaviors with state machines.\n */\nexport function getStdBehaviorsWithStateMachines(): string {\n const behaviors = getAllBehaviors();\n const nonGameBehaviors = behaviors.filter(b => {\n const traits = b.orbitals?.[0]?.traits ?? [];\n const hasGameCategory = traits.some((t: any) => t.category?.includes('game'));\n const hasStateMachine = traits.some((t: any) => t.stateMachine);\n return !hasGameCategory && hasStateMachine;\n });\n\n return `## Standard Behaviors\n\n${nonGameBehaviors.map(behavior => {\n const trait = (behavior.orbitals?.[0]?.traits ?? []).find((t: any) => t.stateMachine) as any;\n const sm = trait?.stateMachine;\n return `### ${behavior.name}\n\n**States**: ${sm?.states?.map((s: any) => s.name).join(', ') ?? 'N/A'}\n**Events**: ${sm?.events?.map((e: any) => e.key ?? e.name ?? e).join(', ') ?? 'N/A'}\n\n\\`\\`\\`json\n${JSON.stringify(behavior, null, 2)}\n\\`\\`\\`\n`;\n }).join('\\n\\n')}\n`;\n}\n\n/**\n * Get key behaviors reference (compact).\n */\nexport function getKeyBehaviorsReference(): string {\n const behaviorsDocs = generateBehaviorsDocs();\n \n return `## Key Standard Behaviors\n\n${behaviorsDocs.categories.map(cat => `### ${cat.name}\n${cat.behaviors.map(b => `- **${b.name}**: ${b.description}`).join('\\n')}\n`).join('\\n')}\n\nUse with: \\`uses: [{ from: \"std/behaviors/crud\", as: \"CRUD\" }]\\`\n`;\n}\n","/**\n * Skill Architecture Section\n *\n * Core orbital architecture concepts - minimal, essential information only.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the core orbital architecture section.\n * This is the foundational understanding needed for orbital generation.\n */\nexport function getArchitectureSection(): string {\n return `## Orbital Architecture\n\n### Schema Format (IMPORTANT)\n\nThe correct schema format uses **orbitals** array at root:\n\n\\`\\`\\`json\n{\n \"name\": \"MyApp\",\n \"version\": \"1.0.0\",\n \"orbitals\": [ // ← CORRECT: orbitals array\n {\n \"name\": \"Task Management\",\n \"entity\": { ... },\n \"traits\": [ ... ],\n \"pages\": [ ... ]\n }\n ]\n}\n\\`\\`\\`\n\n**DO NOT** confuse with legacy format that had \\`dataEntities\\`, \\`traits\\`, \\`pages\\` at root level.\nThe \\`orbitals[]\\` format IS the standard format - do not \"fix\" it to something else.\n\n**NOTE**: There is NO schema-level \\`traits[]\\` array. All traits belong inside orbitals.\n\n### Core Formula\n\\`\\`\\`\nOrbital Unit = Entity × Traits × Patterns\nApplication = Σ(Orbital Units)\n\\`\\`\\`\n\n### The Closed Circuit Pattern\n\\`\\`\\`\nTrait State Machine → render-ui → UI Component → User Action → Event → Trait\n ↑ |\n └───────────────────────────────────────────────────────────┘\n\\`\\`\\`\n\n1. **Trait** transitions to state, fires \\`render-ui\\` effect\n2. **UI Component** renders with actions (buttons, forms)\n3. **User clicks** → Component emits event (e.g., \\`UI:CREATE\\`)\n4. **Trait receives** event, transitions, cycle repeats\n\n### Key Principles\n\n| Principle | Rule |\n|-----------|------|\n| **One trait per slot** | Each slot (main, modal, drawer) owned by ONE trait |\n| **INIT renders UI** | Every trait needs INIT self-loop to render initial UI |\n| **One page per entity** | Use trait's render-ui for create/edit/view, not separate pages |\n| **form-section has submitEvent** | Connects form to trait events (NOT onSubmit!) |\n| **std/* are templates** | Guide LLM generation, not runtime code |\n\n### Slot Ownership\n\\`\\`\\`\n┌─────────────────────────────────────────────┐\n│ Page: /tasks │\n├─────────────────────────────────────────────┤\n│ TaskManagement trait OWNS: │\n│ • main → entity-table, page-header │\n│ • modal → form-section (create/edit) │\n│ • drawer → detail-panel (view) │\n│ │\n│ NO other trait should render to these slots │\n└─────────────────────────────────────────────┘\n\\`\\`\\`\n`;\n}\n","/**\n * Common Errors Section\n *\n * Critical mistakes to avoid during orbital generation.\n * Keep this focused on the most frequent errors only.\n *\n * @packageDocumentation\n */\n\nimport { PATTERN_TYPES } from \"@almadar/core/types\";\nimport { ViewTypeSchema } from \"@almadar/core/types\";\nimport {\n getPatternPropsCompact,\n getPatternActionsRef,\n} from \"@almadar/patterns\";\n\n/**\n * Generate pattern categories from PATTERN_TYPES.\n */\nfunction getPatternCategories(): string {\n const categories: Record<string, string[]> = {\n Header: PATTERN_TYPES.filter(\n (p: any) => p.includes(\"header\") || p === \"title-only\",\n ),\n Display: PATTERN_TYPES.filter(\n (p: any) => p.startsWith(\"entity-\") || p === \"stats\",\n ),\n Form: PATTERN_TYPES.filter((p) => p.startsWith(\"form-\")),\n Filter: PATTERN_TYPES.filter(\n (p) => p.includes(\"search\") || p.includes(\"filter\"),\n ),\n State: PATTERN_TYPES.filter((p) => p.includes(\"-state\")),\n Navigation: PATTERN_TYPES.filter((p) => [\"tabs\", \"breadcrumb\"].includes(p)),\n Layout: PATTERN_TYPES.filter(\n (p) =>\n p.includes(\"layout\") || p.includes(\"grid\") || p === \"master-detail\",\n ),\n Interaction: PATTERN_TYPES.filter((p: any) => p === \"confirmation\" || (typeof p === 'string' && p.includes(\"confirmation\"))),\n Game: PATTERN_TYPES.filter(\n (p) =>\n p.startsWith(\"game-\") ||\n [\n \"tilemap-renderer\",\n \"inventory-panel\",\n \"dialogue-box\",\n \"level-select\",\n ].includes(p),\n ),\n };\n\n let table = \"| Category | Valid Patterns |\\n|----------|----------------|\\n\";\n for (const [cat, patterns] of Object.entries(categories)) {\n if (patterns.length > 0) {\n table += `| ${cat} | ${patterns.map((p) => `\\`${p}\\``).join(\", \")} |\\n`;\n }\n }\n return table;\n}\n\n/**\n * Get valid viewTypes from schema.\n */\nfunction getValidViewTypes(): string {\n const validTypes = ViewTypeSchema.options;\n return validTypes.map((t) => `\\`${t}\\``).join(\", \");\n}\n\n/**\n * Get common errors section.\n * Supports tiered output: 'top6' for generation skill, 'full' for fixing skill.\n */\nexport function getCommonErrorsSection(level: 'top6' | 'full' = 'full'): string {\n const critical = getCriticalErrors();\n if (level === 'top6') return critical;\n return critical + getEdgeCaseErrors();\n}\n\n/**\n * Top 6 critical errors — the mistakes the LLM actually makes repeatedly.\n * ~4,100 chars. Used by the generation skill.\n */\nfunction getCriticalErrors(): string {\n return `## Critical Rules\n\n### 1. INIT Transition Required (CRITICAL)\n\nEvery trait MUST have an INIT self-loop transition. The runtime fires \\`INIT\\` when page loads.\nThe INIT render-ui MUST be a **single composed stack**, not flat calls:\n\n\\`\\`\\`json\n{\n \"from\": \"Browsing\",\n \"to\": \"Browsing\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\",\n \"children\": [\n { \"type\": \"stack\", \"direction\": \"horizontal\", \"justify\": \"between\", \"align\": \"center\",\n \"children\": [\n { \"type\": \"typography\", \"variant\": \"h1\", \"text\": \"Title\" },\n { \"type\": \"button\", \"label\": \"Create\", \"event\": \"CREATE\", \"variant\": \"primary\" }\n ]\n },\n { \"type\": \"entity-table\", \"entity\": \"EntityName\", \"columns\": [\"...\"], \"searchable\": true,\n \"itemActions\": [{ \"label\": \"View\", \"event\": \"VIEW\" }] }\n ]\n }]\n ]\n}\n\\`\\`\\`\n\nWithout INIT: Page loads blank, nothing renders, no UI appears.\n\n### 2. NEVER Use @payload in set Effects\n\nThe \\`set\\` effect modifies entity state. **@payload is READ-ONLY**.\n\n\\`\\`\\`json\n// WRONG\n[\"set\", \"@payload.data.status\", \"active\"]\n\n// CORRECT\n[\"set\", \"@entity.status\", \"active\"]\n\\`\\`\\`\n\n**Rule:** \\`set\\` target MUST start with \\`@entity\\`, never \\`@payload\\`.\n\n### 3. Valid Patterns ONLY\n\n**DO NOT invent custom patterns!** Only these patterns exist:\n\n${getPatternCategories()}\n\n**NEVER use**: \\`onboarding-welcome\\`, \\`category-selector\\`, \\`assessment-question\\`, etc.\n\nValid viewType values: ${getValidViewTypes()}\n\n### 4. Page Structure Required\n\nEvery page MUST have \\`path\\` and \\`traits\\` properties:\n\n\\`\\`\\`json\n{\n \"pages\": [{\n \"name\": \"TasksPage\",\n \"path\": \"/tasks\",\n \"traits\": [{ \"ref\": \"TaskManagement\" }]\n }]\n}\n\\`\\`\\`\n\nWithout \\`path\\`: Validation error \\`ORB_P_MISSING_PATH\\`\nWithout \\`traits\\`: Validation error \\`ORB_P_MISSING_TRAITS\\`\n\n### 5. Valid Field Types ONLY\n\nField types MUST be one of: \\`string\\`, \\`number\\`, \\`boolean\\`, \\`date\\`, \\`timestamp\\`, \\`datetime\\`, \\`array\\`, \\`object\\`, \\`enum\\`, \\`relation\\`\n\n\\`\\`\\`json\n// WRONG - using entity name as type:\n{ \"name\": \"author\", \"type\": \"User\" }\n\n// CORRECT - use relation type:\n{ \"name\": \"author\", \"type\": \"relation\", \"relation\": { \"entity\": \"User\", \"cardinality\": \"one\" } }\n\\`\\`\\`\n\n### 6. Modal/Drawer Exit Transitions (CRITICAL — MOST COMMON ERROR)\n\n**EVERY state that renders to \\`\"modal\"\\` or \\`\"drawer\"\\` MUST have CANCEL and CLOSE transitions.**\nWithout these, the validator rejects the schema with \\`CIRCUIT_NO_OVERLAY_EXIT\\`.\n\n\\`\\`\\`json\n// Opening the modal: Browsing → Creating\n{ \"from\": \"Browsing\", \"to\": \"Creating\", \"event\": \"CREATE\",\n \"effects\": [[\"render-ui\", \"modal\", { \"type\": \"form-section\", \"entity\": \"Task\", \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }]] },\n\n// REQUIRED: CANCEL exit (form cancel button)\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"modal\", null]] },\n\n// REQUIRED: CLOSE exit (click outside / press Escape)\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"CLOSE\",\n \"effects\": [[\"render-ui\", \"modal\", null]] },\n\n// SAVE also dismisses modal\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"effects\": [[\"persist\", \"create\", \"Task\", \"@payload.data\"], [\"render-ui\", \"modal\", null], [\"emit\", \"INIT\"]] }\n\\`\\`\\`\n\n**Checklist for EVERY modal/drawer state:**\n- [ ] Has \\`CANCEL\\` transition → previous state with \\`[\"render-ui\", \"modal\", null]\\`\n- [ ] Has \\`CLOSE\\` transition → previous state with \\`[\"render-ui\", \"modal\", null]\\`\n- [ ] Has \\`SAVE\\` (or other action) transition that also dismisses with \\`[\"render-ui\", \"modal\", null]\\`\n\n**This applies to ALL states**: Creating, Editing, Viewing, Deleting — any state that renders to modal/drawer.\n\n### 7. Valid Slots ONLY\n\nrender-ui slots MUST be one of: \\`\"main\"\\`, \\`\"modal\"\\`, \\`\"drawer\"\\`, \\`\"sidebar\"\\`\n\n\\`\\`\\`json\n// WRONG - invented slots:\n[\"render-ui\", \"modal-close\", null]\n[\"render-ui\", \"notification\", { ... }]\n[\"render-ui\", \"confirm-modal\", { ... }]\n\n// CORRECT:\n[\"render-ui\", \"modal\", null]\n[\"render-ui\", \"main\", { ... }]\n\\`\\`\\`\n\n### 8. Every render-ui Pattern MUST Have \"type\"\n\nEvery pattern object in render-ui MUST include a \\`\"type\"\\` field. This applies to the top-level pattern AND every child in a stack.\n\n\\`\\`\\`json\n// WRONG - missing type:\n[\"render-ui\", \"main\", { \"entity\": \"Product\", \"columns\": [\"name\"] }]\n\n// CORRECT:\n[\"render-ui\", \"main\", { \"type\": \"entity-table\", \"entity\": \"Product\", \"columns\": [\"name\"] }]\n\n// WRONG - child missing type:\n{ \"type\": \"stack\", \"children\": [{ \"text\": \"Hello\" }] }\n\n// CORRECT:\n{ \"type\": \"stack\", \"children\": [{ \"type\": \"typography\", \"text\": \"Hello\" }] }\n\\`\\`\\`\n`;\n\n}\n\n/**\n * Edge case errors 9-20 — less frequent, validator catches most of these.\n * ~4,000 chars. Used by the fixing skill.\n */\nfunction getEdgeCaseErrors(): string {\n return `\n---\n\n## Additional Errors (Edge Cases)\n\n### 7. Over-Generating Pages\n\\`\\`\\`\nWRONG: TaskListPage, TaskCreatePage, TaskEditPage, TaskViewPage (4 pages!)\nCORRECT: TasksPage with EntityManagement trait (1 page)\n\\`\\`\\`\n\n### 8. Duplicate Slot Rendering\n\\`\\`\\`\nWRONG: Two traits both render to \"main\" on page load\nCORRECT: ONE trait owns each slot\n\\`\\`\\`\n\n### 9. Missing submitEvent / Wrong Action Pattern in form-section\n\\`\\`\\`\nWRONG: { \"type\": \"form-section\", \"entity\": \"Task\" }\nALSO WRONG: { \"type\": \"form-section\", \"entity\": \"Task\", \"onSubmit\": \"SAVE\" }\nALSO WRONG: { \"type\": \"form-section\", \"actions\": [{\"label\": \"Save\", \"event\": \"SAVE\"}] }\nCORRECT: { \"type\": \"form-section\", \"entity\": \"Task\", \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }\n\\`\\`\\`\n**form-section does NOT use \\`actions\\` array** — it uses \\`submitEvent\\` and \\`cancelEvent\\` strings.\nThe \\`actions\\` prop is for \\`page-header\\`, \\`entity-detail\\`, NOT for forms.\n\n### 10. Duplicate Transitions (Same from+event)\n\\`\\`\\`\nWRONG: Two transitions with same \"from\" and \"event\" without guards\nCORRECT: Use GUARDS to differentiate transitions\n\\`\\`\\`\n\n### 11. Using \"render\" Instead of \"render-ui\"\n\\`\\`\\`\nWRONG: [\"render\", \"main\", {...}]\nCORRECT: [\"render-ui\", \"main\", {...}]\n\\`\\`\\`\n\n### 12. Generating Sections Array (Legacy)\n\\`\\`\\`\nWRONG: { \"pages\": [{ \"sections\": [...] }] }\nCORRECT: { \"pages\": [{ \"traits\": [...] }] } - UI comes from render-ui effects\n\\`\\`\\`\n\n### 13. Using form-actions Pattern (DOES NOT EXIST!)\n\\`\\`\\`\nWRONG: [\"render-ui\", \"main\", { \"type\": \"form-actions\", \"actions\": [...] }]\nCORRECT: Use form-section with submitEvent/cancelEvent props\n\\`\\`\\`\nActions are INSIDE patterns, not separate patterns.\n\n### 14. Forgetting itemActions in entity-table\n\\`\\`\\`\nWRONG: { \"type\": \"entity-table\", \"entity\": \"Task\" }\nCORRECT: { \"type\": \"entity-table\", \"entity\": \"Task\", \"itemActions\": [{\"label\": \"Edit\", \"event\": \"EDIT\"}] }\n\\`\\`\\`\n\n### 15. Duplicate Trait Names Across Orbitals\n\\`\\`\\`\nWRONG: UserOrbital uses \"EntityManagement\", TaskOrbital uses \"EntityManagement\"\nCORRECT: UserOrbital uses \"UserManagement\", TaskOrbital uses \"TaskManagement\"\n\\`\\`\\`\nEach trait name MUST be unique. Pattern: \\`{Entity}{Purpose}\\`\n\n### 16. Hallucinated itemAction Properties\n\\`\\`\\`\nWRONG: { \"label\": \"View\", \"event\": \"VIEW\", \"condition\": \"...\" }\nCORRECT: { \"label\": \"View\", \"event\": \"VIEW\" }\n\\`\\`\\`\nValid itemAction props: \\`label\\`, \\`event\\`, \\`navigatesTo\\`, \\`placement\\`, \\`variant\\`, \\`showWhen\\`\n\n### 17. Event Listeners Structure\nEvent listeners go INSIDE traits, not at orbital level:\n\\`\\`\\`json\n\"traits\": [{ \"name\": \"TaskInteraction\",\n \"listens\": [{ \"event\": \"USER_UPDATED\", \"handler\": \"REFRESH_LIST\" }] }]\n\\`\\`\\`\n\n### 18. Wrong Filtering Pattern (Use Query Singleton)\nUse a singleton entity for filter state + \\`query\\` prop on entity-table:\n\\`\\`\\`json\n{ \"name\": \"TaskQuery\", \"entity\": { \"name\": \"TaskQuery\", \"singleton\": true, \"runtime\": true,\n \"fields\": [{ \"name\": \"status\", \"type\": \"string\" }, { \"name\": \"search\", \"type\": \"string\" }] } }\n\\`\\`\\`\nReference: \\`[\"render-ui\", \"main\", { \"type\": \"entity-table\", \"entity\": \"Task\", \"query\": \"@TaskQuery\" }]\\`\n`;\n}\n\n/**\n * Get validation error hints section.\n * Quick reference for common validation errors and fixes.\n */\nexport function getValidationHintsSection(): string {\n return `## Validation Error Quick Fixes\n\n| Error | Fix |\n|-------|-----|\n| ORB_P_MISSING_PATH | Add \\`path\\` property starting with \"/\" to page (e.g., \"/tasks\") |\n| ORB_P_MISSING_TRAITS | Add \\`traits\\` array to page with at least one trait ref |\n| ORB_E_INVALID_FIELD_TYPE | Use valid type: string, number, boolean, date, enum, relation. NOT entity names! |\n| ORB_INIT_MISSING | Add INIT self-loop transition with render-ui effects |\n| ORB_FORM_SUBMIT | Add submitEvent and cancelEvent to form-section pattern |\n| ORB_DUPE_TRANS | Add guards to differentiate same-event transitions |\n| ORB_SLOT_CONTENTION | Merge traits or use different slots |\n| ORB_DUPE_PAGE_TRAITS | Remove duplicate trait references from page |\n| ORB_T_DUPLICATE_NAME | Use unique trait names per entity: UserManagement, TaskManagement |\n| ORB_EFF_SET_REQUIRES_ENTITY | Change @payload.field to @entity.field in set effects |\n| ORB_RUI_UNKNOWN_ITEM_ACTION_PROP | Remove invalid props (like \\`condition\\`), use \\`showWhen\\` |\n| ORB_MODAL_NO_CLOSE | Add CLOSE/CANCEL transitions from modal states with \\`[\"render-ui\", \"modal\", null]\\` |\n`;\n}\n","/**\n * Decomposition Protocol Section\n *\n * Step-by-step protocol for breaking requirements into orbital units.\n * Keep this focused on the decision process, not verbose explanations.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the decomposition protocol section.\n */\nexport function getDecompositionSection(): string {\n return `## Orbital Decomposition Protocol\n\n### Step 0: Classify Domain\n| Domain | Keywords | Key Traits |\n|--------|----------|------------|\n| business | manage, track, workflow | EntityManagement, SearchAndFilter |\n| game | play, score, level | Physics2D, Health, GameState |\n| form | wizard, onboarding | Wizard, FormSubmission |\n| dashboard | metrics, KPI | EntityManagement |\n| content | blog, CMS | none (page navigation) |\n| social | chat, feed, profile, follow | EntityManagement |\n| ecommerce | shop, store, cart, checkout | EntityManagement, SearchAndFilter |\n| workflow | automate, process, pipeline | EntityManagement |\n\n### Step 1: Identify Entities (ONE Orbital Per Entity)\n- What are the core data objects?\n- persistent (DB), runtime (memory), or singleton (config)?\n- **CRITICAL: Create exactly ONE orbital per entity**\n- **CRITICAL: If the prompt mentions N entities, create N orbitals** (e.g., \"Product, Category, Order\" → 3 orbitals)\n- **CRITICAL: EVERY orbital MUST have an entity field** - no exceptions\n- **NEVER** collapse multiple entities into a single dashboard orbital\n\n**Entity Field is REQUIRED in every orbital:**\n\\`\\`\\`json\n{\n \"name\": \"Product Management\",\n \"entity\": { // ← REQUIRED: Every orbital needs this\n \"name\": \"Product\",\n \"collection\": \"products\",\n \"fields\": [...]\n },\n \"traits\": [...],\n \"pages\": [...]\n}\n\\`\\`\\`\n\n**Common mistake to avoid:**\n- ❌ WRONG: Creating an orbital with no entity field\n- ✅ CORRECT: Every orbital has its entity defined inline\n\n### Step 2: Select Interaction Model\n| Domain | Create | View | Edit | Delete |\n|--------|--------|------|------|--------|\n| business | modal | drawer | modal | confirm |\n| game | none | none | none | none |\n| form | wizard | drawer | page | confirm |\n\n### Step 3: Choose Traits (UNIQUE NAMES REQUIRED)\n- Business: \\`{Entity}Management\\` naming — e.g., \\`ProductManagement\\`, \\`OrderManagement\\`, \\`CustomerManagement\\`\n- Game: Physics2D, Health, Score, Collision\n- Form: Wizard (multi-step) or FormSubmission (single)\n- **NEVER reuse the same trait name across orbitals. Each trait name MUST be globally unique.**\n\n### Step 4: Define State Machine\n\\`\\`\\`\nstates: Identify user-facing modes (browsing, creating, editing, viewing)\nevents: Identify user actions (INIT, CREATE, VIEW, EDIT, SAVE, CLOSE)\ntransitions: Map (from, event) → (to, effects)\n\\`\\`\\`\n\n### Step 5: Add INIT Transition (CRITICAL)\nEvery trait MUST have:\n\\`\\`\\`json\n{ \"from\": \"initial\", \"to\": \"initial\", \"event\": \"INIT\", \"effects\": [[\"render-ui\", ...]] }\n\\`\\`\\`\nWithout INIT, the page loads blank!\n\n### Step 6: Define Pages\n- ONE page per entity (business) or workflow (form)\n- Attach traits to pages via \\`traits\\` array\n- No \\`sections\\` array - UI comes from render-ui effects\n\n### Step 7: Add Guards (CRITICAL for Business Rules)\n\n**Guards enforce business rules as S-expressions on transitions.**\n\n#### When to use guards:\n1. **Business rule validation** - Enforce constraints on SAVE transitions\n2. **Conditional routing** - Same (from, event) leads to different states\n\n#### Business Rule Guards (on SAVE):\n\\`\\`\\`json\n{\n \"from\": \"Editing\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"guard\": [\"and\",\n [\"<=\", \"@payload.data.age\", 120],\n [\">=\", \"@payload.data.balance\", 0]\n ],\n \"effects\": [[\"persist\", \"update\", \"Account\", \"@payload.data\"], ...]\n}\n\\`\\`\\`\n\n#### Conditional Routing Guards:\n\\`\\`\\`json\n{ \"from\": \"A\", \"to\": \"B\", \"event\": \"X\", \"guard\": [\">\", \"@entity.health\", 0] }\n{ \"from\": \"A\", \"to\": \"C\", \"event\": \"X\", \"guard\": [\"<=\", \"@entity.health\", 0] }\n\\`\\`\\`\n\n**IMPORTANT**:\n- Use \\`\"guard\"\\` (singular) on transitions, NOT \\`\"guards\"\\` (plural)\n- Business rules MUST be S-expression guards on the transition, NOT just UI messages!\n`;\n}\n\n/**\n * Get minimal decomposition checklist.\n */\nexport function getDecompositionChecklist(): string {\n return `## Decomposition Checklist\n\n- [ ] Domain classified (business/game/form/dashboard/content/social/ecommerce/workflow)\n- [ ] Entities identified with persistence type\n- [ ] **ONE orbital per entity** (not multiple orbitals for same entity!)\n- [ ] Traits selected (EntityManagement for CRUD, domain-specific for others)\n- [ ] State machine has states, events, transitions\n- [ ] INIT transition exists with render-ui effects\n- [ ] Pages defined (ONE per entity/workflow)\n- [ ] Traits attached to pages\n- [ ] **Business rule guards as S-expressions on SAVE transitions**\n- [ ] Entity relations defined for cross-orbital links\n- [ ] emits/listens defined for cross-orbital events\n`;\n}\n\n/**\n * Get compact decomposition protocol (~1,250 chars).\n * Steps 0-6 without verbose guard examples (guards covered in S-Expr + errors).\n */\nexport function getDecompositionCompact(): string {\n return `## Orbital Decomposition Protocol\n\n### Step 0: Classify Domain\n| Domain | Keywords | Key Traits |\n|--------|----------|------------|\n| business | manage, track, workflow | EntityManagement, SearchAndFilter |\n| game | play, score, level | Physics2D, Health, GameState |\n| form | wizard, onboarding | Wizard, FormSubmission |\n| dashboard | metrics, KPI | EntityManagement |\n| content | blog, CMS | none (page navigation) |\n| social | chat, feed, profile, follow | EntityManagement |\n| ecommerce | shop, store, cart, checkout | EntityManagement, SearchAndFilter |\n| workflow | automate, process, pipeline | EntityManagement |\n\n### Step 1: Identify Entities (ONE Orbital Per Entity)\n- What are the core data objects?\n- persistent (DB), runtime (memory), or singleton (config)?\n- **CRITICAL: Create exactly ONE orbital per entity**\n- **CRITICAL: If the prompt mentions N entities, create N orbitals** (e.g., \"Product, Category, Order\" → 3 orbitals)\n- **CRITICAL: EVERY orbital MUST have an entity field**\n- **NEVER** collapse multiple entities into a single dashboard orbital\n\n### Step 2: Select Interaction Model\n| Domain | Create | View | Edit | Delete |\n|--------|--------|------|------|--------|\n| business | modal | drawer | modal | confirm |\n| game | none | none | none | none |\n| form | wizard | drawer | page | confirm |\n\n### Step 3: Choose Traits (UNIQUE NAMES REQUIRED)\n- Business: \\`{Entity}Management\\` naming — e.g., \\`ProductManagement\\`, \\`OrderManagement\\`, \\`CustomerManagement\\`\n- Game: Physics2D, Health, Score, Collision\n- Form: Wizard (multi-step) or FormSubmission (single)\n- **NEVER reuse the same trait name across orbitals. Each trait name MUST be globally unique.**\n\n### Step 4: Define State Machine\n\\`\\`\\`\nstates: Identify user-facing modes (browsing, creating, editing, viewing)\nevents: Identify user actions (INIT, CREATE, VIEW, EDIT, SAVE, CLOSE)\ntransitions: Map (from, event) → (to, effects)\n\\`\\`\\`\n\n### Step 5: Add INIT Transition (CRITICAL)\nEvery trait MUST have an INIT self-loop with render-ui effects. Without INIT, the page loads blank!\n\n### Step 6: Define Pages\n- ONE page per entity (business) or workflow (form)\n- Attach traits to pages via \\`traits\\` array\n- Add \\`\"guard\"\\` (singular) S-expressions on SAVE transitions for business rules\n`;\n}\n\n/**\n * Get compact orbital connectivity (~750 chars).\n * One combined example instead of three separate examples.\n */\nexport function getConnectivityCompact(): string {\n return `## Orbital Connectivity\n\nFor multi-entity apps, connect orbitals:\n\n\\`\\`\\`json\n{\n \"entity\": {\n \"fields\": [\n { \"name\": \"customerId\", \"type\": \"relation\", \"relation\": { \"entity\": \"Customer\", \"cardinality\": \"one\" } }\n ]\n },\n \"emits\": [\"ORDER_COMPLETED\"],\n \"listens\": [{ \"event\": \"MENU_ITEM_UNAVAILABLE\", \"triggers\": \"DISABLE_ITEM\" }],\n \"design\": {\n \"uxHints\": {\n \"relatedLinks\": [{ \"relation\": \"customerId\", \"label\": \"View Customer\", \"targetView\": \"detail\" }]\n }\n }\n}\n\\`\\`\\`\n\n- **relation fields**: Link entities (Order → Customer)\n- **emits/listens**: Cross-orbital event communication\n- **relatedLinks**: Navigation between related records\n`;\n}\n\n// ============================================================================\n// UX Enhancement Sections\n// ============================================================================\n\n/**\n * Get flow pattern selection guidance.\n * Maps application types to appropriate user flow patterns.\n */\nexport function getFlowPatternSection(): string {\n return `## Flow Pattern Selection\n\nSelect a flow pattern based on application type:\n\n| App Type | Flow Pattern | Structure |\n|----------|--------------|-----------|\n| Dashboard/Admin | hub-spoke | Central hub → feature pages → back to hub |\n| CRM/List-focused | master-detail | List with drill-down drawer or split view |\n| CRUD App | crud-cycle | List ↔ modal forms for create/edit |\n| Onboarding/Checkout | linear | Step-by-step wizard flow |\n| Multi-role | role-based | Role guards determine visible features |\n\n**Flow → Orbital Structure:**\n- hub-spoke: Dashboard orbital + feature orbitals with navigation\n- master-detail: Entity orbital with detail drawer state\n- crud-cycle: Entity orbital with modal form states\n- linear: Step orbitals connected via navigation\n- role-based: Shared orbitals with role-based guards\n`;\n}\n\n/**\n * Get guidance for outputting orbitals with embedded context.\n */\nexport function getPortableOrbitalOutputSection(): string {\n return `## Orbital Output Format\n\nEach orbital MUST include embedded context for portability:\n\n\\`\\`\\`json\n{\n \"name\": \"Order Management\",\n \"entity\": {\n \"name\": \"Order\",\n \"persistence\": \"persistent\",\n \"fields\": [\n { \"name\": \"customerId\", \"type\": \"relation\", \"relation\": { \"entity\": \"Customer\", \"cardinality\": \"one\" } },\n { \"name\": \"items\", \"type\": \"relation\", \"relation\": { \"entity\": \"MenuItem\", \"cardinality\": \"many\" } }\n ]\n },\n \"traits\": [\"EntityManagement\"],\n \"domainContext\": {\n \"request\": \"<full user request>\",\n \"requestFragment\": \"<verbatim excerpt for THIS orbital>\",\n \"category\": \"business\",\n \"vocabulary\": { \"item\": \"Order\", \"create\": \"Place Order\", \"delete\": \"Cancel\" }\n },\n \"design\": {\n \"style\": \"modern\",\n \"uxHints\": { \"flowPattern\": \"crud-cycle\", \"listPattern\": \"entity-table\", \"formPattern\": \"modal\" }\n },\n \"emits\": [\"ORDER_READY\", \"ORDER_COMPLETED\"],\n \"listens\": [{ \"event\": \"MENU_ITEM_UNAVAILABLE\", \"triggers\": \"DISABLE_ITEM\" }],\n \"relations\": [\n { \"entity\": \"Customer\", \"cardinality\": \"one\" },\n { \"entity\": \"MenuItem\", \"cardinality\": \"many\" }\n ]\n}\n\\`\\`\\`\n\n**Required context fields:**\n- \\`domainContext.requestFragment\\` - What user said that produced this orbital\n- \\`domainContext.category\\` - Domain classification\n- \\`domainContext.vocabulary\\` - Domain-specific naming\n- \\`design.uxHints\\` - Pattern selection hints\n\n**Cross-orbital connectivity (for multi-entity apps):**\n- \\`entity.fields[].relation\\` - Link to related entities\n- \\`emits\\` - Events this orbital emits when state changes\n- \\`listens\\` - Events from other orbitals to handle\n- \\`relations\\` - Summary of entity relationships\n`;\n}\n\n/**\n * Get guidance for connecting orbitals together.\n */\nexport function getOrbitalConnectivitySection(): string {\n return `## Orbital Connectivity (CRITICAL)\n\nOrbitals must NOT be discrete islands. For multi-entity apps, connect orbitals properly:\n\n### 1. Entity Relations (REQUIRED for related entities)\nWhen Entity A references Entity B, add a relation field:\n\\`\\`\\`json\n// In Order orbital's entity.fields:\n{ \"name\": \"customerId\", \"type\": \"relation\", \"relation\": { \"entity\": \"Customer\", \"cardinality\": \"one\" } }\n{ \"name\": \"items\", \"type\": \"relation\", \"relation\": { \"entity\": \"MenuItem\", \"cardinality\": \"many\" } }\n\\`\\`\\`\n\n### 2. Navigation Links (in design.uxHints.relatedLinks)\nEnable drill-down from one orbital to another:\n\\`\\`\\`json\n{ \"relatedLinks\": [{ \"relation\": \"customerId\", \"label\": \"View Customer\", \"targetView\": \"detail\" }] }\n\\`\\`\\`\n\n### 3. Cross-Orbital Events (emits/listens)\nOrbitals communicate via events:\n\\`\\`\\`json\n// Order orbital emits when status changes:\n{ \"emits\": [\"ORDER_READY\", \"ORDER_COMPLETED\"] }\n\n// Notification orbital listens:\n{ \"listens\": [{ \"event\": \"ORDER_READY\", \"triggers\": \"NOTIFY_CUSTOMER\" }] }\n\\`\\`\\`\n\n**CRITICAL: For multi-entity apps:**\n- Add relation fields to connect entities (e.g., Order → Customer, Order → MenuItem)\n- Add emits/listens when one orbital's state change affects another\n- Add relatedLinks for navigation between related records\n`;\n}\n","/**\n * Bindings Guide\n *\n * Generates binding documentation from the source of truth in @almadar/core.\n * This ensures the skill guidance matches the actual compiler validation.\n *\n * @packageDocumentation\n */\n\nimport { BINDING_DOCS, CORE_BINDINGS } from '@almadar/core';\n\n/**\n * Generate binding documentation for skill prompts.\n * Derived from BINDING_DOCS in @almadar/core - single source of truth.\n */\nexport function getBindingsGuide(): string {\n const lines: string[] = [\n '## Valid Binding References',\n '',\n 'Bindings reference runtime values using `@root.path` syntax:',\n '',\n '| Binding | Description | Example |',\n '|---------|-------------|---------|',\n ];\n\n // Generate table from BINDING_DOCS\n for (const [bindingKey, docs] of Object.entries(BINDING_DOCS)) {\n const example = docs.examples[0] || `@${bindingKey}`;\n lines.push(`| \\`@${bindingKey}\\` | ${docs.description} | \\`${example}\\` |`);\n }\n\n lines.push(\n '',\n '### Binding Rules',\n '',\n '- `@entity.field` - Access entity fields (e.g., `@entity.status`, `@entity.count`)',\n '- `@payload.field` - Access event payload data (read-only)',\n '- `@state` - Current state name (no path)',\n '- `@now` - Current timestamp (no path)',\n '- `@config.field` - Trait configuration values',\n '',\n '### Common Mistakes',\n '',\n '| ❌ Invalid | ✅ Correct |',\n '|------------|------------|',\n '| `@count(tasks)` | Use static text `\"Total Tasks\"` or add a `taskCount` field to entity |',\n '| `@find(orders, id=@payload.id)` | Use `@payload.data` — the runtime resolves entities |',\n '| `@categories.find(c => c.id === @payload.id)` | Use `@payload.data` — no JavaScript in bindings |',\n '| `@sum(orders, totalAmount)` | Add a `totalAmount` field to the entity |',\n '| `@formatDate(@entity.createdAt, \"MMM dd\")` | Use `@entity.createdAt` — formatting is UI-side |',\n '| `@length(items)` | Use `@entity.itemCount` — add the field to entity |',\n '| `@filter(...)` | No function-call syntax exists in bindings |',\n '| `@inc(@payload.delta)` | Use `@payload.data` or `@entity.field` |',\n '| `@count` | Use static text or add a count field to entity |',\n '| `@entity.task.title` | `@entity.title` (entity type is implicit) |',\n '| `@payload.field` in `set` effect | `@entity.field` (set modifies entity only) |',\n '| `@entity` (bare, no path) | `@entity.data` or `@entity.fieldName` — path required |',\n '',\n '**ABSOLUTE RULE**: Bindings are ONLY `@root.path` (e.g., `@entity.name`). NO function calls, NO JavaScript expressions, NO query syntax. If you need computed values, add a field to the entity.',\n ''\n );\n\n return lines.join('\\n');\n}\n\n/**\n * Get compact binding reference (one-liner for tables).\n */\nexport function getBindingsCompact(): string {\n const validBindings = CORE_BINDINGS.map(b => `@${b}`).join(', ');\n return `Valid bindings: ${validBindings}`;\n}\n\n/**\n * Get binding validation rules for specific contexts.\n */\nexport function getBindingContextRules(): string {\n return `\n## Binding Context Rules\n\n| Context | Allowed Bindings | Notes |\n|---------|-----------------|-------|\n| Guards | @entity, @payload, @state, @now | Read-only conditions |\n| Effects | @entity, @payload, @state, @now | @entity can be modified via set |\n| Ticks | @entity, @state, @now | No payload (no event) |\n| Render-UI | @entity, @payload, @state, @config | Display values only |\n\n**Critical Rule:** The \".set\" effect ONLY modifies @entity fields.\n`.trim();\n}\n","/**\n * Atomic Composition Design Guide (v5.0)\n *\n * Teaches the LLM to compose sophisticated views using atomic design principles.\n * Every render-ui effect must satisfy the Five Rules of Sophisticated Composition.\n *\n * v5.0: Added mandatory composition rules, validation checklist, and theme enforcement.\n *\n * @packageDocumentation\n */\n\nimport {\n getPatternPropsCompact,\n getPatternActionsRef,\n getAllPatternTypes,\n} from \"@almadar/patterns\";\nimport { getBindingsGuide } from \"./bindings-guide.js\";\n\n/**\n * Get the render-ui atomic composition guide with mandatory rules.\n */\nexport function getRenderUIDesignGuide(): string {\n return `## Render-UI Atomic Composition Guide (v5.0)\n\n### The Five Rules of Sophisticated Composition (MANDATORY)\n\nEvery render-ui effect MUST satisfy ALL five rules:\n\n| Rule | Requirement | Validation |\n|------|-------------|------------|\n| **1** | **Single Render-UI** per transition | One render-ui effect only |\n| **2** | **Three Atomic Levels** | Atoms (2+) + Molecules (1+) + Organisms (1+) |\n| **3** | **Layout Wrapper** | Root must be stack/box/container/grid |\n| **4** | **Theme Variables** | ALL visual props use CSS vars |\n| **5** | **Template Quality** | Match CrudTemplate/ListTemplate sophistication |\n\n---\n\n### Rule 1: Single Render-UI Per Transition\n\nEach transition executes exactly ONE render-ui effect with composed children:\n\n\\`\\`\\`json\n// ✅ CORRECT: Single render-ui with composed children\n{\n \"from\": \"Browsing\",\n \"to\": \"Browsing\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"stack\",\n \"direction\": \"vertical\",\n \"gap\": \"lg\",\n \"children\": [\n { \"type\": \"page-header\", \"title\": \"...\", \"actions\": [...] },\n { \"type\": \"entity-table\", \"entity\": \"...\", ... }\n ]\n }]\n ]\n}\n\n// ❌ WRONG: Multiple flat render-ui calls\n{\n \"effects\": [\n [\"render-ui\", \"main\", { \"type\": \"page-header\", ... }],\n [\"render-ui\", \"main\", { \"type\": \"entity-table\", ... }]\n ]\n}\n\\`\\`\\`\n\n---\n\n### Rule 2: Three Atomic Levels Required\n\nEvery composition MUST contain ALL three levels:\n\n#### Level 1: Atoms (Minimum 2 distinct types)\n\n| Type | Purpose | Example Usage |\n|------|---------|---------------|\n| \\`typography\\` | All text content | Headlines, labels, body text |\n| \\`badge\\` | Status indicators | Active, Pending, Completed |\n| \\`button\\` | User actions | Create, Edit, Delete |\n| \\`avatar\\` | User/entity images | Profile pictures |\n| \\`icon\\` | Decorative icons | Plus, Edit, Trash |\n| \\`progress-bar\\` | Progress indicators | Upload progress |\n| \\`divider\\` | Visual separation | Section dividers |\n\n#### Level 2: Molecules (Minimum 1)\n\n| Type | Purpose | Example Usage |\n|------|---------|---------------|\n| \\`box\\` | Visual containers | Stat cards, panels |\n| \\`card\\` | Content grouping | Feature cards |\n| \\`modal\\` | Dialog overlays | Create/edit forms |\n| \\`drawer\\` | Side panels | Detail views |\n| \\`tabs\\` | Content organization | Filter tabs |\n| \\`alert\\` | Notifications | Success/error messages |\n| \\`accordion\\` | Collapsible sections | FAQ, settings |\n\n#### Level 3: Organisms (Minimum 1 for data views)\n\n| Type | Purpose | Example Usage |\n|------|---------|---------------|\n| \\`entity-table\\` | Data tables | List views |\n| \\`form-section\\` | Forms | Create/edit |\n| \\`detail-panel\\` | Detail views | View record |\n| \\`page-header\\` | Page headers | Title + actions |\n| \\`chart\\` | Data visualization | Analytics |\n| \\`timeline\\` | Chronological events | Activity history |\n| \\`stats\\` | KPI metrics | Dashboard stats |\n\n---\n\n### Rule 3: Layout-First Structure\n\nRoot element MUST be a layout primitive:\n\n\\`\\`\\`json\n// ✅ CORRECT: Layout wrappers\n{ \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\", \"children\": [...] }\n{ \"type\": \"stack\", \"direction\": \"horizontal\", \"gap\": \"md\", \"children\": [...] }\n{ \"type\": \"box\", \"padding\": \"lg\", \"bg\": \"var(--color-card)\", \"children\": [...] }\n{ \"type\": \"container\", \"size\": \"xl\", \"padding\": \"lg\", \"children\": [...] }\n{ \"type\": \"grid\", \"cols\": 3, \"gap\": \"md\", \"children\": [...] }\n\n// ❌ WRONG: No layout wrapper\n{ \"type\": \"page-header\", \"title\": \"...\" }\n{ \"type\": \"entity-table\", \"entity\": \"...\" }\n\\`\\`\\`\n\n#### Layout Props Reference\n\n**Stack (VStack/HStack)**\n\\`\\`\\`json\n{\n \"type\": \"stack\",\n \"direction\": \"vertical\" | \"horizontal\",\n \"gap\": \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\",\n \"align\": \"start\" | \"center\" | \"end\" | \"stretch\",\n \"justify\": \"start\" | \"center\" | \"end\" | \"between\" | \"around\",\n \"wrap\": true | false\n}\n\\`\\`\\`\n\n**Box**\n\\`\\`\\`json\n{\n \"type\": \"box\",\n \"padding\": \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\",\n \"bg\": \"var(--color-card)\" | \"var(--color-muted)\" | \"var(--color-primary)\",\n \"border\": true | false,\n \"borderColor\": \"var(--color-border)\",\n \"rounded\": \"var(--radius-none)\" | \"var(--radius-sm)\" | \"var(--radius-md)\" | \"var(--radius-lg)\" | \"var(--radius-xl)\",\n \"shadow\": \"var(--shadow-none)\" | \"var(--shadow-sm)\" | \"var(--shadow-md)\" | \"var(--shadow-lg)\"\n}\n\\`\\`\\`\n\n**Container**\n\\`\\`\\`json\n{\n \"type\": \"container\",\n \"size\": \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\",\n \"padding\": \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\"\n}\n\\`\\`\\`\n\n**Grid**\n\\`\\`\\`json\n{\n \"type\": \"grid\",\n \"cols\": 1 | 2 | 3 | 4 | 6 | 12 | { \"sm\": 1, \"md\": 2, \"lg\": 3 },\n \"gap\": \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\"\n}\n\\`\\`\\`\n\n---\n\n### Rule 4: Theme Variable Enforcement\n\nALL visual properties MUST use CSS theme variables:\n\n| Property | ✅ CORRECT | ❌ WRONG |\n|----------|-----------|----------|\n| Colors | \"var(--color-primary)\" | \"#3b82f6\", \"blue\", \"white\" |\n| Backgrounds | \"var(--color-card)\" | \"#ffffff\", \"white\" |\n| Text colors | \"var(--color-foreground)\" | \"#000000\", \"black\" |\n| Spacing | \"var(--spacing-lg)\" | \"16px\", \"1rem\" |\n| Radius | \"var(--radius-md)\" | \"8px\", \"0.5rem\" |\n| Shadows | \"var(--shadow-sm)\" | \"0 2px 4px rgba(0,0,0,0.1)\" |\n\n---\n\n### Rule 5: Template-Quality Composition\n\nMatch the sophistication of reference templates in \\`packages/almadar-ui/components/templates/\\`.\n\n#### CrudTemplate Structure\n\\`\\`\\`\nContainer (size: xl, padding: lg)\n └── VStack (gap: lg)\n ├── PageHeader (title + actions)\n ├── Alert (error state)\n ├── EntityTable (searchable, sortable, actions)\n └── Modal (form-section for create/edit)\n\\`\\`\\`\n\n#### ListTemplate Structure\n\\`\\`\\`\nContainer (size: md, padding: lg)\n └── VStack (gap: lg)\n ├── Typography (h2 title)\n ├── Input (search)\n ├── HStack (filter buttons)\n └── VStack (list items)\n\\`\\`\\`\n\n#### Dashboard Structure\n\\`\\`\\`\nContainer (size: full, padding: lg)\n └── Grid (cols: { sm: 1, md: 2, lg: 4 })\n ├── Box (stat card 1)\n ├── Box (stat card 2)\n ├── Box (stat card 3)\n └── Box (stat card 4)\n\\`\\`\\`\n\n#### Stats Cards - Static Text Only\n\nFor stats/overview sections, use **static text labels**, NOT computed bindings:\n\n\\`\\`\\`json\n// ✅ CORRECT: Static text for labels\n{\n \"type\": \"box\",\n \"padding\": \"md\",\n \"bg\": \"var(--color-card)\",\n \"children\": [\n { \"type\": \"typography\", \"variant\": \"caption\", \"text\": \"Total Tasks\" },\n { \"type\": \"typography\", \"variant\": \"h2\", \"text\": \"--\" }\n ]\n}\n\n// ✅ CORRECT: Using stats pattern with entity\n{\n \"type\": \"stats\",\n \"entity\": \"Task\",\n \"label\": \"Total Tasks\"\n}\n\n// ❌ WRONG: Invented computed bindings\n{ \"text\": \"@count\" }\n{ \"text\": \"@count:status=pending\" }\n\\`\\`\\`\n\n---\n\n### Validated Example: Task Management\n\nThis example has been validated with \\`npx @almadar/cli validate\\`:\n\n\\`\\`\\`json\n{\n \"name\": \"Taskly\",\n \"version\": \"1.0.0\",\n \"orbitals\": [{\n \"name\": \"Task Management\",\n \"entity\": {\n \"name\": \"Task\",\n \"collection\": \"tasks\",\n \"fields\": [\n { \"name\": \"title\", \"type\": \"string\", \"required\": true },\n { \"name\": \"status\", \"type\": \"enum\", \"values\": [\"pending\", \"active\", \"done\"] },\n { \"name\": \"priority\", \"type\": \"enum\", \"values\": [\"low\", \"medium\", \"high\"] }\n ]\n },\n \"traits\": [{\n \"name\": \"TaskInteraction\",\n \"category\": \"interaction\",\n \"linkedEntity\": \"Task\",\n \"emits\": [{ \"event\": \"INIT\", \"scope\": \"internal\" }],\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"Browsing\", \"isInitial\": true },\n { \"name\": \"Creating\" }\n ],\n \"events\": [\n { \"key\": \"INIT\", \"name\": \"Initialize\" },\n { \"key\": \"CREATE\", \"name\": \"Create\" },\n { \"key\": \"SAVE\", \"name\": \"Save\", \"payload\": [{ \"name\": \"data\", \"type\": \"object\" }] },\n { \"key\": \"CANCEL\", \"name\": \"Cancel\" }\n ],\n \"transitions\": [\n {\n \"from\": \"Browsing\",\n \"to\": \"Browsing\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"stack\",\n \"direction\": \"vertical\",\n \"gap\": \"lg\",\n \"children\": [\n {\n \"type\": \"page-header\",\n \"title\": \"Task Management\",\n \"actions\": [{ \"label\": \"Create Task\", \"event\": \"CREATE\", \"variant\": \"primary\" }]\n },\n {\n \"type\": \"entity-table\",\n \"entity\": \"Task\",\n \"columns\": [\"title\", \"status\", \"priority\"],\n \"searchable\": true,\n \"itemActions\": [\n { \"label\": \"Edit\", \"event\": \"EDIT\" },\n { \"label\": \"Delete\", \"event\": \"DELETE\" }\n ]\n }\n ]\n }]\n ]\n },\n {\n \"from\": \"Browsing\",\n \"to\": \"Creating\",\n \"event\": \"CREATE\",\n \"effects\": [\n [\"render-ui\", \"modal\", {\n \"type\": \"form-section\",\n \"entity\": \"Task\",\n \"fields\": [\"title\", \"status\", \"priority\"],\n \"submitEvent\": \"SAVE\",\n \"cancelEvent\": \"CANCEL\"\n }]\n ]\n },\n {\n \"from\": \"Creating\",\n \"to\": \"Browsing\",\n \"event\": \"SAVE\",\n \"effects\": [\n [\"persist\", \"create\", \"Task\", \"@payload.data\"],\n [\"render-ui\", \"modal\", null],\n [\"emit\", \"INIT\"]\n ]\n },\n {\n \"from\": \"Creating\",\n \"to\": \"Browsing\",\n \"event\": \"CANCEL\",\n \"effects\": [\n [\"render-ui\", \"modal\", null]\n ]\n }\n ]\n }\n }],\n \"pages\": [{\n \"name\": \"TasksPage\",\n \"path\": \"/tasks\",\n \"viewType\": \"list\",\n \"isInitial\": true,\n \"entity\": \"Task\",\n \"traits\": [{ \"ref\": \"TaskInteraction\" }]\n }],\n \"emits\": [],\n \"listens\": []\n }]\n}\n\\`\\`\\`\n\n---\n\n${getBindingsGuide()}\n\n---\n\n### Critical Validation Rules\n\n| Element | Correct Format | Wrong Format | Error |\n|---------|----------------|--------------|-------|\n| **Events** | \\`{ \"key\": \"INIT\", \"name\": \"Init\" }\\` | \\`\"INIT\"\\` | ORB_T_EVT_INVALID_FORMAT |\n| **Emits** | \\`[{ \"event\": \"INIT\", \"scope\": \"internal\" }}]\\` | \\`[\"INIT\"]\\` | ORB_T_UNDEFINED_TRAIT |\n| **Payload events** | \\`{ \"key\": \"SAVE\", \"payload\": [...] }\\` | No payload | ORB_BINDING_PAYLOAD_FIELD_UNDECLARED |\n| **Page traits** | \\`{ \"ref\": \"TraitName\" }\\` | With linkedEntity | ORB_P_INVALID_TRAIT_REF |\n| **Category** | \\`\"category\": \"interaction\"\\` | Missing | ORB_T_MISSING_CATEGORY |\n\n---\n\n### Composition Quality Checklist\n\nBefore calling \\`finish_task\\`, verify:\n\n\\`\\`\\`\n□ Single render-ui per transition\n□ Root element is layout (stack/box/container/grid)\n□ Contains 2+ atoms (typography, badge, button, etc.)\n□ Contains 1+ molecules (box, card, tabs, alert)\n□ Contains 1+ organisms (entity-table, form-section, page-header)\n□ Uses theme variables for ALL visual properties\n□ Has 3+ distinct sections (header, content, actions)\n□ Matches template quality from almadar-ui/components/templates/\n□ Passes npx @almadar/cli validate with zero errors\n\\`\\`\\`\n\n---\n\n### BANNED Patterns\n\n| Wrong | Correct |\n|-------|---------|\n| Multiple flat render-ui calls | Single composed render-ui |\n| Root organism without layout | Layout wrapper required |\n| Hex colors | Theme CSS variables |\n| Pixel values | Theme spacing variables |\n| Events as strings \\`\"INIT\"\\` | Event objects \\`{ \"key\": \"INIT\" }\\` |\n| Emits as strings \\`[\"INIT\"]\\` | Emit objects \\`[{ \"event\": \"INIT\" }]\\` |\n| \\`onSubmit\\` / \\`onCancel\\` | \\`submitEvent\\` / \\`cancelEvent\\` |\n| \\`headerActions\\` | \\`actions\\` |\n\n---\n\n${getPatternPropsCompact()}\n\n${getPatternActionsRef()}\n`;\n}\n","/**\n * Theme Variable System Guide\n *\n * Teaches the LLM to use CSS theme variables for all visual properties.\n * Enforces consistent theming across all generated schemas.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the theme variable system guide.\n * Covers colors, spacing, radius, and shadows with mandatory enforcement rules.\n */\nexport function getThemeGuide(): string {\n return `## Theme Variable System (MANDATORY)\n\nAll visual properties MUST use CSS theme variables. Never use hardcoded values.\n\n### ❌ BANNED: Hardcoded Values\n\n| Type | Wrong | Why |\n|------|-------|-----|\n| Hex colors | \"#3b82f6\", \"#ffffff\", \"#000000\" | Not themeable |\n| Named colors | \"white\", \"black\", \"red\", \"blue\" | Not themeable |\n| Pixel values | \"16px\", \"8px\", \"24px\" | Not scalable |\n| Rem values | \"1rem\", \"0.5rem\" | Inconsistent |\n| Arbitrary values | \"0 2px 4px rgba(0,0,0,0.1)\" | Not themeable |\n\n### ✅ REQUIRED: Theme Variables\n\n### Color Variables\n\n| Variable | Usage | Example Context |\n|----------|-------|-----------------|\n| \\`var(--color-foreground)\\` | Primary text | Headlines, body text |\n| \\`var(--color-muted-foreground)\\` | Secondary text | Captions, labels, hints |\n| \\`var(--color-background)\\` | Page background | Main container bg |\n| \\`var(--color-card)\\` | Card backgrounds | Box containers, panels |\n| \\`var(--color-muted)\\` | Subtle sections | Alternating rows, disabled states |\n| \\`var(--color-primary)\\` | Primary actions | Main buttons, active states |\n| \\`var(--color-primary-foreground)\\` | Text on primary | Button labels |\n| \\`var(--color-secondary)\\` | Secondary actions | Secondary buttons |\n| \\`var(--color-secondary-foreground)\\` | Text on secondary | Secondary button labels |\n| \\`var(--color-success)\\` | Success states | Completed badges, success alerts |\n| \\`var(--color-warning)\\` | Warnings | Warning badges, alerts |\n| \\`var(--color-destructive)\\` | Errors, delete | Danger buttons, error states |\n| \\`var(--color-border)\\` | Borders, dividers | Card outlines, separators |\n| \\`var(--color-input)\\` | Input backgrounds | Form field backgrounds |\n| \\`var(--color-ring)\\` | Focus rings | Input focus states |\n\n### Spacing Variables\n\n| Variable | Value | Usage |\n|----------|-------|-------|\n| \\`var(--spacing-xs)\\` | 4px | Tight gaps, icon spacing |\n| \\`var(--spacing-sm)\\` | 8px | Small gaps, compact layouts |\n| \\`var(--spacing-md)\\` | 12px | Standard gaps |\n| \\`var(--spacing-lg)\\` | 16px | Large gaps, section padding |\n| \\`var(--spacing-xl)\\` | 24px | Extra large gaps |\n| \\`var(--spacing-2xl)\\` | 32px | Page-level spacing |\n| \\`var(--spacing-3xl)\\` | 48px | Major section spacing |\n| \\`var(--spacing-4xl)\\` | 64px | Hero section spacing |\n\n### Radius Variables\n\n| Variable | Value | Usage |\n|----------|-------|-------|\n| \\`var(--radius-none)\\` | 0px | Sharp corners |\n| \\`var(--radius-sm)\\` | 2px | Small elements, tags |\n| \\`var(--radius-md)\\` | 6px | Buttons, inputs, small cards |\n| \\`var(--radius-lg)\\` | 8px | Cards, panels, modals |\n| \\`var(--radius-xl)\\` | 12px | Large containers |\n| \\`var(--radius-2xl)\\` | 16px | Extra large containers |\n| \\`var(--radius-full)\\` | 9999px | Pills, avatars, badges |\n\n### Shadow Variables\n\n| Variable | Usage |\n|----------|-------|\n| \\`var(--shadow-none)\\` | Flat design, no elevation |\n| \\`var(--shadow-sm)\\` | Subtle elevation, cards |\n| \\`var(--shadow-md)\\` | Cards, dropdowns, popovers |\n| \\`var(--shadow-lg)\\` | Modals, dialogs |\n| \\`var(--shadow-xl)\\` | High elevation elements |\n| \\`var(--shadow-2xl)\\` | Maximum elevation |\n\n### Pattern-Specific Examples\n\n#### Box / Card Container\n\\`\\`\\`json\n{\n \"type\": \"box\",\n \"padding\": \"lg\",\n \"bg\": \"var(--color-card)\",\n \"border\": true,\n \"borderColor\": \"var(--color-border)\",\n \"rounded\": \"var(--radius-lg)\",\n \"shadow\": \"var(--shadow-sm)\"\n}\n\\`\\`\\`\n\n#### Typography\n\\`\\`\\`json\n// Page title\n{\n \"type\": \"typography\",\n \"variant\": \"h1\",\n \"text\": \"Page Title\",\n \"color\": \"var(--color-foreground)\"\n}\n\n// Secondary text\n{\n \"type\": \"typography\",\n \"variant\": \"caption\",\n \"text\": \"Label text\",\n \"color\": \"var(--color-muted-foreground)\"\n}\n\n// Success text\n{\n \"type\": \"typography\",\n \"variant\": \"body\",\n \"text\": \"Completed\",\n \"color\": \"var(--color-success)\"\n}\n\\`\\`\\`\n\n#### Button (use variant, not manual colors)\n\\`\\`\\`json\n// Primary action\n{\n \"type\": \"button\",\n \"label\": \"Save\",\n \"event\": \"SAVE\",\n \"variant\": \"primary\"\n}\n\n// Secondary action\n{\n \"type\": \"button\",\n \"label\": \"Cancel\",\n \"event\": \"CANCEL\",\n \"variant\": \"secondary\"\n}\n\n// Danger action\n{\n \"type\": \"button\",\n \"label\": \"Delete\",\n \"event\": \"DELETE\",\n \"variant\": \"danger\"\n}\n\\`\\`\\`\n\n#### Badge (variant maps to semantic colors)\n\\`\\`\\`json\n{\n \"type\": \"badge\",\n \"text\": \"Active\",\n \"variant\": \"primary\"\n}\n\n{\n \"type\": \"badge\",\n \"text\": \"Completed\",\n \"variant\": \"success\"\n}\n\n{\n \"type\": \"badge\",\n \"text\": \"Pending\",\n \"variant\": \"warning\"\n}\n\n{\n \"type\": \"badge\",\n \"text\": \"Error\",\n \"variant\": \"danger\"\n}\n\\`\\`\\`\n\n#### Stack Layout\n\\`\\`\\`json\n{\n \"type\": \"stack\",\n \"direction\": \"vertical\",\n \"gap\": \"lg\",\n \"align\": \"stretch\",\n \"justify\": \"start\"\n}\n\\`\\`\\`\n\n### Theme Validation Checklist\n\nBefore calling \\`finish_task\\`, verify:\n\n- [ ] No hex colors (#fff, #000, #3b82f6, etc.)\n- [ ] No named colors (white, black, red, blue, etc.)\n- [ ] No pixel values (16px, 8px, 24px, etc.)\n- [ ] No rem values (1rem, 0.5rem, etc.)\n- [ ] All colors use var(--color-*)\n- [ ] All spacing uses var(--spacing-*)\n- [ ] All radius uses var(--radius-*)\n- [ ] All shadows use var(--shadow-*)\n\n### Auto-Correction Reference\n\nThe system will auto-correct these common mistakes:\n\n| Wrong | Auto-Corrected To |\n|-------|-------------------|\n| \"#fff\" or \"white\" | \"var(--color-background)\" |\n| \"#000\" or \"black\" | \"var(--color-foreground)\" |\n| \"#3b82f6\" | \"var(--color-primary)\" |\n| \"#10b981\" | \"var(--color-success)\" |\n| \"#f59e0b\" | \"var(--color-warning)\" |\n| \"#ef4444\" | \"var(--color-destructive)\" |\n| \"16px\" | \"var(--spacing-lg)\" |\n| \"8px\" | \"var(--spacing-sm)\" |\n| \"24px\" | \"var(--spacing-xl)\" |\n| \"8px\" (radius) | \"var(--radius-md)\" |\n`;\n}\n\n/**\n * Get banned properties that should never be used.\n */\nexport function getBannedProps(): string {\n return `## BANNED PROPS (NEVER USE)\n\n| Wrong Prop | Correct Prop | Pattern |\n|------------|--------------|---------|\n| \\`onSubmit\\` | \\`submitEvent\\` | form-section |\n| \\`onCancel\\` | \\`cancelEvent\\` | form-section |\n| \\`headerActions\\` | \\`actions\\` | detail-panel |\n| \\`loading\\` | \\`isLoading\\` | all patterns |\n| \\`fieldNames\\` | \\`fields\\` | detail-panel, form-section |\n| \\`onConfirm\\` | (use event transitions) | confirmation |\n| \\`placement\\` | (remove) | itemActions |\n| \\`isDestructive\\` | (use variant: \"danger\") | itemActions |\n\n### Banned Value Patterns\n\n| Wrong | Correct |\n|-------|---------|\n| Hex colors: \"#3b82f6\" | Theme vars: \"var(--color-primary)\" |\n| Named colors: \"white\", \"red\" | Theme vars: \"var(--color-background)\" |\n| Pixel values: \"16px\" | Theme vars: \"var(--spacing-lg)\" |\n| Events as strings: \"INIT\" | Event objects: { \"key\": \"INIT\", \"name\": \"Init\" } |\n| Emits as strings: [\"INIT\"] | Emit objects: [{ \"event\": \"INIT\", \"scope\": \"internal\" }] |\n`;\n}\n","/**\n * Custom Trait Guidance Section\n *\n * Comprehensive guidance for creating custom traits.\n * Part of the lean orbital skill.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the custom trait guidance section.\n */\nexport function getCustomTraitSection(): string {\n return `## Custom Trait Guide\n\n### When to Create Custom Traits\n\n| Scenario | Approach |\n|----------|----------|\n| Standard CRUD list/view/edit | Use \\`std/List\\` behavior pattern |\n| Multi-step wizard | Custom trait with states = steps |\n| Approval workflow | Custom trait (Drafting \\u2192 InReview \\u2192 Published) |\n| Payment processing | Custom \\`integration\\` trait with call-service |\n| Domain-specific workflow | Custom trait matching business states |\n\n### Trait Categories\n\n| Category | Purpose | Requires render-ui? |\n|----------|---------|---------------------|\n| \\`interaction\\` | UI state machine | **YES** - must render UI |\n| \\`integration\\` | Backend service calls | No |\n\n### Interaction Trait Requirements (CRITICAL)\n\nEvery \\`interaction\\` trait MUST have:\n1. **States as objects** with \\`isInitial\\` flag\n2. **INIT transition** (self-loop on initial state) that renders UI\n3. **render-ui effects** for every state transition\n4. **form-section with onSubmit** to connect forms to events\n\n### Example: Document Publishing Workflow\n\n\\`\\`\\`json\n{\n \"name\": \"DocumentPublishing\",\n \"category\": \"interaction\",\n \"linkedEntity\": \"Document\",\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"Drafting\", \"isInitial\": true },\n { \"name\": \"InReview\" },\n { \"name\": \"Published\" }\n ],\n \"events\": [\n { \"key\": \"INIT\" },\n { \"key\": \"SUBMIT\" },\n { \"key\": \"APPROVE\" },\n { \"key\": \"REJECT\" }\n ],\n \"transitions\": [\n {\n \"from\": \"Drafting\",\n \"to\": \"Drafting\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"page-header\",\n \"title\": \"Edit Document\",\n \"actions\": [{ \"label\": \"Submit\", \"event\": \"SUBMIT\" }]\n }],\n [\"render-ui\", \"main\", {\n \"type\": \"form-section\",\n \"entity\": \"Document\",\n \"fields\": [\"title\", \"content\"],\n \"onSubmit\": \"SUBMIT\"\n }]\n ]\n },\n {\n \"from\": \"Drafting\",\n \"to\": \"InReview\",\n \"event\": \"SUBMIT\",\n \"effects\": [\n [\"set\", \"@entity.status\", \"review\"],\n [\"persist\", \"update\"],\n [\"render-ui\", \"main\", {\n \"type\": \"page-header\",\n \"title\": \"In Review\"\n }],\n [\"render-ui\", \"main\", {\n \"type\": \"detail-panel\",\n \"entity\": \"Document\",\n \"fieldNames\": [\"title\", \"content\"]\n }],\n [\"render-ui\", \"main\", {\n \"type\": \"form-section\",\n \"submitLabel\": \"Approve\",\n \"cancelLabel\": \"Reject\",\n \"onSubmit\": \"APPROVE\",\n \"onCancel\": \"REJECT\"\n }]\n ]\n },\n {\n \"from\": \"InReview\",\n \"to\": \"Drafting\",\n \"event\": \"REJECT\",\n \"effects\": [\n [\"set\", \"@entity.status\", \"draft\"],\n [\"persist\", \"update\"],\n [\"emit\", \"INIT\"]\n ]\n },\n {\n \"from\": \"InReview\",\n \"to\": \"Published\",\n \"event\": \"APPROVE\",\n \"effects\": [\n [\"set\", \"@entity.status\", \"published\"],\n [\"set\", \"@entity.publishedAt\", \"@now\"],\n [\"persist\", \"update\"],\n [\"render-ui\", \"main\", {\n \"type\": \"page-header\",\n \"title\": \"Published!\"\n }],\n [\"render-ui\", \"main\", {\n \"type\": \"detail-panel\",\n \"entity\": \"Document\"\n }]\n ]\n }\n ]\n }\n}\n\\`\\`\\`\n\n**Key Points:**\n- INIT is a self-loop that renders the initial UI\n- Every state transition has render-ui effects\n- form-section always has onSubmit\n- REJECT emits INIT to re-render Drafting state\n\n### Example: Integration Trait (Payment)\n\n\\`\\`\\`json\n{\n \"name\": \"PaymentProcessing\",\n \"category\": \"integration\",\n \"linkedEntity\": \"Order\",\n \"emits\": [\n {\n \"event\": \"ORDER_PAID\",\n \"scope\": \"external\",\n \"description\": \"Emitted when payment succeeds\",\n \"payload\": [\n { \"name\": \"orderId\", \"type\": \"string\", \"required\": true, \"description\": \"The paid order ID\" },\n { \"name\": \"total\", \"type\": \"number\", \"required\": true, \"description\": \"Order total amount\" }\n ]\n }\n ],\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"Pending\", \"isInitial\": true },\n { \"name\": \"Processing\" },\n { \"name\": \"Completed\" },\n { \"name\": \"Failed\" }\n ],\n \"events\": [\n { \"key\": \"PROCESS\" },\n { \"key\": \"SUCCESS\" },\n { \"key\": \"FAILURE\" }\n ],\n \"transitions\": [\n {\n \"from\": \"Pending\",\n \"to\": \"Processing\",\n \"event\": \"PROCESS\",\n \"effects\": [\n [\"call-service\", \"stripe\", \"charge\", {\n \"amount\": \"@entity.total\",\n \"onSuccess\": \"SUCCESS\",\n \"onError\": \"FAILURE\"\n }]\n ]\n },\n {\n \"from\": \"Processing\",\n \"to\": \"Completed\",\n \"event\": \"SUCCESS\",\n \"effects\": [\n [\"set\", \"@entity.paidAt\", \"@now\"],\n [\"persist\", \"update\"],\n [\"emit\", \"ORDER_PAID\", { \"orderId\": \"@entity.id\", \"total\": \"@entity.total\" }]\n ]\n },\n {\n \"from\": \"Processing\",\n \"to\": \"Failed\",\n \"event\": \"FAILURE\",\n \"effects\": [\n [\"notify\", \"Payment failed\", \"error\"]\n ]\n }\n ]\n }\n}\n\\`\\`\\`\n\n**Note:** Integration traits don't need INIT or render-ui - they're triggered by events, not page load.\n\n### Cross-Orbital Communication (CRITICAL)\n\nWhen traits need to communicate across orbitals, you MUST:\n\n1. **Declare emits with payload contract:**\n\\`\\`\\`json\n\"emits\": [\n {\n \"event\": \"ORDER_PAID\",\n \"scope\": \"external\",\n \"description\": \"Emitted when payment is confirmed\",\n \"payload\": [\n { \"name\": \"orderId\", \"type\": \"string\", \"required\": true },\n { \"name\": \"total\", \"type\": \"number\", \"required\": true }\n ]\n }\n]\n\\`\\`\\`\n\n2. **Include payload data in emit effect:**\n\\`\\`\\`json\n[\"emit\", \"ORDER_PAID\", { \"orderId\": \"@entity.id\", \"total\": \"@entity.total\" }]\n\\`\\`\\`\n\n3. **Declare listeners with payloadMapping:**\n\\`\\`\\`json\n\"listens\": [\n {\n \"event\": \"PaymentProcessing.ORDER_PAID\",\n \"scope\": \"external\",\n \"triggers\": \"SEND_RECEIPT\",\n \"payloadMapping\": {\n \"orderId\": \"@payload.orderId\",\n \"amount\": \"@payload.total\"\n }\n }\n]\n\\`\\`\\`\n\n### Anti-Patterns to Avoid\n\n| Anti-Pattern | Problem | Fix |\n|--------------|---------|-----|\n| Missing INIT | Page is blank | Add self-loop with render-ui |\n| States as strings | Validation fails | Use \\`{ \"name\": \"...\", \"isInitial\": true }\\` |\n| No render-ui | UI doesn't update | Add render-ui to every transition |\n| form-section no onSubmit | Form does nothing | Add \\`onSubmit: \"EVENT\"\\` |\n| **Using form-actions** | **Pattern doesn't exist!** | **Use form-section with onSubmit/onCancel** |\n| Duplicate (from, event) | Second unreachable | Use guards or different events |\n| from: '*' | Non-deterministic | Use explicit from state |\n| **External emit no payload** | **Listeners have no data** | **Add payload array with typed fields** |\n| **emit effect no data** | **Payload is empty at runtime** | **Pass payload object: \\`[\"emit\", \"EVT\", {...}]\\`** |\n\n### Pattern Action Props Quick Reference\n\n| Pattern | Action Props | Purpose |\n|---------|--------------|---------|\n| \\`page-header\\` | \\`actions: [{label, event}]\\` | Top-right buttons (New, Export) |\n| \\`form-section\\` | \\`onSubmit\\`, \\`onCancel\\` | Form submit/cancel buttons |\n| \\`entity-table\\` | \\`itemActions: [{label, event}]\\` | Row action buttons (Edit, Delete) |\n| \\`detail-panel\\` | \\`actions: [{label, event}]\\` | Detail view header buttons |\n| \\`confirmation\\` | \\`onConfirm\\`, \\`onCancel\\` | Confirmation dialog buttons |\n`;\n}\n\n/**\n * Get a compact version of custom trait guidance.\n */\nexport function getCustomTraitCompact(): string {\n return `## Custom Traits\n\n**Interaction traits** (UI): MUST have INIT self-loop with render-ui\n**Integration traits** (backend): call-service, no render-ui needed\n\nStates = \\`{ \"name\": \"...\", \"isInitial\": true }\\` (objects, not strings)\nform-section = always include \\`onSubmit: \"EVENT\"\\`\n`;\n}\n","/**\n * Schema Update Guidance\n *\n * Provides guidance for modifying existing orbital schemas.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the full schema update section.\n */\nexport function getSchemaUpdateSection(): string {\n return `## Updating Existing Schemas\n\nWhen modifying an existing orbital schema, follow this systematic approach:\n\n### Step 1: Locate the Target\n\nUse grep/search to find the right location:\n\n\\`\\`\\`bash\n# Find entity by name\ngrep -n '\"entity\"' schema.orb -A 5 | grep \"TaskEntity\"\n\n# Find trait by name\ngrep -n '\"traits\"' schema.orb | head -10\n\n# Find specific trait definition\ngrep -n '\"TaskInteraction\"' schema.orb\n\n# Find state machine transitions\ngrep -n '\"transitions\"' schema.orb -A 30 | head -50\n\n# Find all events\ngrep -n '\"events\"' schema.orb\n\n# Find all pages\ngrep -n '\"pages\"' schema.orb -A 10\n\\`\\`\\`\n\n### Step 2: Identify What to Modify\n\n| Change Type | Location to Find | What to Modify |\n|-------------|------------------|----------------|\n| Add field | \\`\"fields\": [\\` | Add to entity.fields array |\n| Add event | \\`\"events\": [\\` | Add to stateMachine.events |\n| Add state | \\`\"states\": [\\` | Add to stateMachine.states |\n| Add transition | \\`\"transitions\": [\\` | Add to stateMachine.transitions |\n| Add action button | \\`\"page-header\"\\` or \\`\"itemActions\"\\` | Add to pattern props |\n| Add page | \\`\"pages\": [\\` | Add to orbital.pages array |\n| Modify UI | \\`\"render-ui\"\\` | Find transition with target slot |\n\n### Step 3: Common Modifications\n\n**Add a new field to entity:**\n\\`\\`\\`json\n// Find: \"fields\": [\n// Add before the closing bracket:\n{ \"name\": \"priority\", \"type\": \"enum\", \"values\": [\"low\", \"medium\", \"high\"] }\n\\`\\`\\`\n\n**Add a new action button to page-header:**\n\\`\\`\\`json\n// Find: INIT transition's page-header\n// Add to actions array:\n{ \"label\": \"Export\", \"event\": \"EXPORT\", \"variant\": \"secondary\" }\n\\`\\`\\`\n\n**Add a new event:**\n\\`\\`\\`json\n// Find: \"events\": [\n// Add the event:\n{ \"key\": \"EXPORT\", \"name\": \"Export Data\" }\n\\`\\`\\`\n\n**Add a new transition:**\n\\`\\`\\`json\n// Find: \"transitions\": [\n// Add after existing transitions:\n{\n \"from\": \"Browsing\",\n \"to\": \"Exporting\",\n \"event\": \"EXPORT\",\n \"effects\": [\n [\"render-ui\", \"modal\", { \"type\": \"confirmation\", \"title\": \"Export?\", \"onConfirm\": \"CONFIRM_EXPORT\", \"onCancel\": \"CANCEL\" }]\n ]\n}\n\\`\\`\\`\n\n**Add itemActions to entity-table:**\n\\`\\`\\`json\n// Find: \"entity-table\" in INIT transition\n// Add itemActions prop:\n\"itemActions\": [\n { \"label\": \"View\", \"event\": \"VIEW\" },\n { \"label\": \"Edit\", \"event\": \"EDIT\" },\n { \"label\": \"Delete\", \"event\": \"DELETE\", \"isDestructive\": true }\n]\n\\`\\`\\`\n\n### Step 4: Ensure Completeness\n\nAfter any modification, verify:\n\n1. **New events have matching transitions** - Every event must have at least one transition that uses it\n2. **New states are reachable** - Every state must have a transition leading to it\n3. **New states have exit transitions** - Every state (except browsing) needs a way back\n4. **UI slots are cleared** - Modals/drawers opened must be closed with \\`[\"render-ui\", \"modal\", null]\\`\n\n### Quick Reference: Finding Traits\n\nTraits are defined in two places:\n\n1. **Inline in orbital** (most common):\n\\`\\`\\`json\n\"orbitals\": [{\n \"traits\": [{\n \"name\": \"TaskInteraction\",\n \"stateMachine\": { ... } // <-- trait definition here\n }]\n}]\n\\`\\`\\`\n\n2. **Referenced from library**:\n\\`\\`\\`json\n\"orbitals\": [{\n \"traits\": [{\n \"ref\": \"std/crud\" // <-- references external trait\n }]\n}]\n\\`\\`\\`\n\nFor inline traits, grep for the trait name. For library traits, find the library file.\n\n---\n\n## Large Schema Handling (40KB+)\n\nFor schemas exceeding 40KB, use the **chunking tools** instead of direct editing:\n\n### Available Tools\n\n| Tool | Purpose |\n|------|---------|\n| \\`query_schema_structure\\` | Get lightweight map (~500 bytes): orbitals, traits, sizes |\n| \\`extract_chunk\\` | Extract orbital/trait to \\`.chunks/chunk-{id}.json\\` |\n| \\`apply_chunk\\` | Merge edited chunk back into schema |\n\n**Note**: These tools work with \\`schema.orb\\` files. Changes are auto-persisted.\n\n### Chunking Workflow\n\n\\`\\`\\`\n1. DISCOVER: query_schema_structure(\"schema.orb\")\n → Returns structure map with orbital/trait names\n\n2. EXTRACT: extract_chunk({ file: \"schema.orb\", type: \"orbital\", name: \"Task Management\" })\n → Creates .chunks/chunk-{id}.json (2-5KB, easy to edit)\n\n3. EDIT: Use edit_file on chunk file (NOT full schema)\n → Much smaller = reliable edits\n\n4. APPLY: apply_chunk({ chunkId: \"...\" })\n → Merges changes back into schema.orb, auto-persists to database\n\\`\\`\\`\n\n### Chunk Types\n\n| Type | When to Use |\n|------|-------------|\n| \\`orbital\\` | Adding fields, modifying inline traits |\n| \\`inline-trait\\` | Editing trait inside an orbital (requires \\`parentOrbital\\`) |\n\n**Note**: There is no schema-level \\`traits[]\\` array. All traits belong inside orbitals.\n\n### When to Use Chunking\n\n| Schema Size | Strategy |\n|-------------|----------|\n| < 15KB | Direct edit (works fine) |\n| 15-40KB | Targeted edit_file |\n| > 40KB | **Use chunking tools** |`;\n}\n\n/**\n * Get compact schema update guidance (shorter version).\n */\nexport function getSchemaUpdateCompact(): string {\n return `## Schema Updates Quick Reference\n\n**Find location:**\n\\`\\`\\`bash\ngrep -n '\"entity\"' schema.orb -A 5 # Find entities\ngrep -n '\"traits\"' schema.orb # Find traits\ngrep -n '\"transitions\"' schema.orb # Find transitions\n\\`\\`\\`\n\n**Common changes:**\n| Change | Find | Add to |\n|--------|------|--------|\n| Field | \\`\"fields\": [\\` | Entity fields array |\n| Event | \\`\"events\": [\\` | StateMachine events |\n| State | \\`\"states\": [\\` | StateMachine states |\n| Transition | \\`\"transitions\": [\\` | StateMachine transitions |\n| Button | \\`\"page-header\"\\` | actions array |\n| Row action | \\`\"entity-table\"\\` | itemActions array |\n\n**After changes, verify:**\n- New events have transitions using them\n- New states are reachable and have exits\n- Modals/drawers are closed on completion`;\n}\n","/**\n * Context Usage Section\n *\n * Guidance for using embedded context when generating orbitals.\n * Small, reusable section for skill generators.\n *\n * @packageDocumentation\n */\n\n/**\n * Get guidance for using embedded context during generation.\n */\nexport function getContextUsageSection(): string {\n return `## Using Embedded Context\n\nWhen generating, read context from the orbital:\n\n| Context Field | Usage |\n|---------------|-------|\n| \\`domainContext.requestFragment\\` | Understand what user asked for |\n| \\`domainContext.category\\` | Influences pattern selection |\n| \\`domainContext.vocabulary\\` | Use for button labels, titles, messages |\n| \\`design.style\\` | Influences visual density and components |\n| \\`design.uxHints.flowPattern\\` | Determines overall navigation structure |\n| \\`design.uxHints.listPattern\\` | Use for entity display (table/cards/list) |\n| \\`design.uxHints.formPattern\\` | Use for create/edit (modal/drawer/page) |\n| \\`design.uxHints.detailPattern\\` | Use for detail view (drawer/page/split) |\n| \\`design.uxHints.relatedLinks\\` | Add navigation to related orbitals |\n\n**Example usage in generation:**\n\\`\\`\\`\nIf domainContext.vocabulary.create = \"Recruit\"\n → Button label: \"Recruit\" instead of \"Create\"\n\nIf design.uxHints.listPattern = \"entity-cards\"\n → Use entity-cards pattern instead of entity-table\n\nIf design.uxHints.formPattern = \"drawer\"\n → Render create/edit forms in drawer slot\n\\`\\`\\`\n`;\n}\n\n/**\n * Get compact context usage for space-constrained prompts.\n */\nexport function getContextUsageCompact(): string {\n return `## Context Usage\n- \\`domainContext.vocabulary\\` → labels (item, create, delete)\n- \\`design.uxHints.listPattern\\` → entity-table | entity-cards | entity-list\n- \\`design.uxHints.formPattern\\` → modal | drawer | page\n- \\`design.uxHints.relatedLinks\\` → navigation to related orbitals\n`;\n}\n","/**\n * Design-Specific Errors Section\n *\n * Common errors specific to the design skill that transforms\n * wireframe schemas into polished applications.\n *\n * @packageDocumentation\n */\n\n/**\n * Get design-specific common errors section.\n * These are the most frequent mistakes when beautifying schemas.\n */\nexport function getDesignErrorsSection(): string {\n return `## ❌ Design-Specific Errors\n\n| Error | Wrong | Correct |\n|-------|-------|---------|\n| Entity binding | \\`@entity.task.title\\` | \\`@entity.title\\` |\n| Toast effect | \\`[\"toast\", \"success\", \"msg\"]\\` | \\`[\"notify\", \"in_app\", \"msg\"]\\` |\n| Select missing options | \\`{ \"type\": \"select\" }\\` | Add \\`\"options\": [{ \"value\": \"x\", \"label\": \"X\" }]\\` |\n| Undefined trait | \\`{ \"ref\": \"NewTrait\" }\\` | Define trait in \\`traits[]\\` FIRST |\n| Missing action | \\`{ \"type\": \"button\" }\\` | \\`{ \"type\": \"button\", \"action\": \"SAVE\" }\\` |\n\n### Entity Bindings (CRITICAL)\n\n\\`@entity\\` already knows the entity type. Access fields directly:\n\n\\`\\`\\`\n✅ @entity.title - Direct field access\n✅ @entity.address.city - Nested object field (address is an object)\n❌ @entity.task.title - Wrong! \"task\" is the entity type, not a field\n\\`\\`\\`\n\n### Notification Effects\n\nUse \\`notify\\` effect, NOT \\`toast\\`:\n\n\\`\\`\\`json\n[\"notify\", \"in_app\", \"Saved!\", \"success\"] // ✅ Correct\n[\"toast\", \"success\", \"Saved!\"] // ❌ Invalid effect\n\\`\\`\\`\n\nVariants: \\`success\\`, \\`error\\`, \\`warning\\`, \\`info\\`\n\n### Form Select Fields\n\nSelect fields REQUIRE options array:\n\n\\`\\`\\`json\n// ❌ Wrong - missing options\n{ \"name\": \"status\", \"type\": \"select\" }\n\n// ✅ Correct - options provided\n{\n \"name\": \"status\",\n \"type\": \"select\",\n \"options\": [\n { \"value\": \"todo\", \"label\": \"To Do\" },\n { \"value\": \"done\", \"label\": \"Done\" }\n ]\n}\n\\`\\`\\`\n`;\n}\n\n/**\n * Get compact design errors for lean skill.\n */\nexport function getDesignErrorsCompact(): string {\n return `## ❌ Design Errors\n\n| Wrong | Correct |\n|-------|---------|\n| \\`@entity.task.title\\` | \\`@entity.title\\` |\n| \\`[\"toast\", \"success\", \"msg\"]\\` | \\`[\"notify\", \"in_app\", \"msg\"]\\` |\n| \\`{ \"type\": \"select\" }\\` | Add \\`options: [{value, label}]\\` |\n| \\`{ \"ref\": \"NewTrait\" }\\` | Define in \\`traits[]\\` first |\n`;\n}\n\n/**\n * Get icon library reference.\n */\nexport function getIconLibrarySection(): string {\n return `### Icons (Lucide)\n\nUse kebab-case icon names from Lucide:\n\n| Category | Icons |\n|----------|-------|\n| Actions | \\`plus\\`, \\`pencil\\`, \\`trash\\`, \\`eye\\`, \\`check\\`, \\`x\\`, \\`save\\` |\n| Navigation | \\`chevron-left\\`, \\`chevron-right\\`, \\`arrow-left\\`, \\`home\\`, \\`menu\\` |\n| Status | \\`check-circle\\`, \\`x-circle\\`, \\`alert-circle\\`, \\`clock\\`, \\`loader\\` |\n| Content | \\`file\\`, \\`folder\\`, \\`image\\`, \\`list\\`, \\`grid\\`, \\`clipboard\\` |\n| UI | \\`search\\`, \\`filter\\`, \\`settings\\`, \\`more-horizontal\\`, \\`bell\\` |\n\n\\`\\`\\`json\n{ \"type\": \"button\", \"icon\": \"plus\", \"label\": \"Add\" }\n{ \"label\": \"Delete\", \"icon\": \"trash\", \"event\": \"DELETE\" }\n\\`\\`\\`\n`;\n}\n\n/**\n * Get compact icon reference.\n */\nexport function getIconLibraryCompact(): string {\n return `**Icons (Lucide)**: \\`plus\\`, \\`pencil\\`, \\`trash\\`, \\`check-circle\\`, \\`x-circle\\`, \\`eye\\`, \\`settings\\`, \\`search\\`, \\`filter\\``;\n}\n","/**\n * Fixing Guidance Section\n *\n * Specialized guidance for fixing validation errors in orbital schemas.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the fixing workflow section.\n */\nexport function getFixingWorkflowSection(): string {\n return `## Fixing Workflow\n\n### Step 0: Read the Existing Schema\n\n**BEFORE anything else, read schema.orb:**\n\n\\`\\`\\`\nRead(\"schema.orb\")\n\\`\\`\\`\n\nYou are FIXING an existing schema, NOT creating a new one.\n\n**Rules:**\n- The schema already exists at \\`schema.orb\\` — READ it first\n- Understand the current entities, traits, and pages before making changes\n- NEVER generate new orbitals or entities — only fix validation errors in what exists\n- NEVER overwrite schema.orb with a new schema — only apply targeted edits\n- If schema.orb does not exist, STOP and report the issue (do not create a new schema)\n\n### Understanding Validation Errors\n\nValidation output format:\n\\`\\`\\`\n❌ [ERROR_CODE] path.to.error: Description\n 💡 Fix hint\n\\`\\`\\`\n\n**The path tells you exactly where to edit.**\n\n| Error Path | What to Edit |\n|------------|--------------|\n| \\`orbitals[0].entity.fields\\` | Add/modify entity fields |\n| \\`orbitals[0].traits[0].stateMachine.transitions[1]\\` | Add/modify transition |\n| \\`orbitals[0].traits[0].stateMachine.states\\` | Add state or mark isTerminal |\n| \\`...effects[0][2].children[1].children[0].children[1].text\\` | Fix binding in render-ui |\n\n### Step 1: Validate and Analyze\n\n\\`\\`\\`\nvalidate_schema()\n\\`\\`\\`\n\n**CRITICAL: Before fixing, you MUST understand the full scope of errors.**\n\nParse and categorize all errors:\n- **Entity errors**: Field types, relations, collection names\n- **Trait errors**: State machine, events, transitions\n- **Page errors**: Missing traits, invalid references\n- **Pattern errors**: Missing required fields in render-ui\n\n**Count errors by orbital and severity.**\n\n### Step 2: Create Fix Plan\n\n**BEFORE making any edits, write out your fix plan:**\n\n\\`\\`\\`\n## Fix Plan\n\n### Summary\n- Total errors: X (Y critical, Z warnings)\n- Affected orbitals: [list]\n- Estimated complexity: simple|medium|complex\n\n### Execution Order\n1. **Fix [ID]**: [Description] -> [Target location]\n2. **Fix [ID]**: [Description] -> [Target location]\n3. ...\n\n### Dependencies\n- Fix X must happen before Fix Y\n- Group A fixes can be batched\n\\`\\`\\`\n\n**Planning Rules:**\n- Group related fixes (same orbital, same component)\n- Identify dependencies (entity fields before bindings)\n- Prioritize critical errors first\n- Estimate if fix is simple (1 edit) or needs multiple steps\n\n### Step 3: Execute Fixes\n\n**Execute your plan systematically:**\n\nFor each fix in your plan:\n1. **Apply the fix** using Edit tool\n2. **Verify the fix** - check the specific error is resolved\n3. **Track progress** - note which fixes are done\n\n**Execution Order (Priority):**\n1. **Entity structure fixes** (add missing entity, fields, persistence)\n2. **Event/state fixes** (add missing events, states, transitions)\n3. **Effect fixes** (render-ui effects, bindings)\n4. **Pattern property fixes** (missing columns, fields, actions)\n5. **Minor syntax fixes** (enum values, type corrections)\n\n**Batching Strategy:**\n- Fix ALL errors of the same type in one orbital per edit\n- If errors span multiple orbitals, create separate edits\n- Document what each edit fixes\n\n### Step 4: Re-validate and Verify\n\n\\`\\`\\`\nvalidate_schema()\n\\`\\`\\`\n\n**After each batch of fixes, re-validate to confirm progress.**\n\nCompare results with your plan:\n- Expected errors resolved\n- New errors appeared (unintended side effects)\n- Errors still present (fix did not work)\n\n**If new errors appear:**\n1. Analyze the new error\n2. Update your fix plan\n3. Continue execution\n\n### Step 5: Final Summary\n\n**Call finish_task with:**\n- Summary of what was fixed\n- Number of edits made\n- Any warnings or notes\n`;\n}\n\n/**\n\n/**\n * Get common fix patterns section.\n */\nexport function getCommonFixPatternsSection(): string {\n return `## Common Fix Patterns\n\n### Entity Fixes\n\n| Error | Before | After |\n|-------|--------|-------|\n| Wrong enum syntax | \\`\"enumValues\": [...]\\` | \\`\"values\": [...]\\` |\n| Wrong relation | \\`\"type\": \"many-to-one\"\\` | \\`\"relationType\": \"many-to-one\"\\` |\n| Missing collection | (none) | \\`\"collection\": \"tasks\"\\` |\n\n### State Machine Fixes\n\n| Error | Before | After |\n|-------|--------|-------|\n| No initial state | \\`{ \"name\": \"Idle\" }\\` | \\`{ \"name\": \"Idle\", \"isInitial\": true }\\` |\n| String states | \\`\"states\": [\"Idle\"]\\` | \\`\"states\": [{ \"name\": \"Idle\", \"isInitial\": true }]\\` |\n| Missing event | (not in events) | Add to \\`\"events\": [...]\\` |\n\n### Transition Fixes\n\n| Error | Fix |\n|-------|-----|\n| No INIT transition | Add self-loop: \\`{ \"from\": \"Browsing\", \"to\": \"Browsing\", \"event\": \"INIT\", \"effects\": [...] }\\` |\n| Orphan state | Add transition TO the state from initial |\n| No exit from state | Add transition FROM the state back to browsing |\n\n### Pattern Fixes (in render-ui effects)\n\n| Pattern | Missing | Add |\n|---------|---------|-----|\n| \\`entity-table\\` | columns | \\`\"columns\": [\"field1\", \"field2\"]\\` |\n| \\`entity-table\\` | itemActions | \\`\"itemActions\": [{ \"label\": \"Edit\", \"event\": \"EDIT\" }]\\` |\n| \\`form-section\\` | onSubmit | \\`\"onSubmit\": \"SAVE\"\\` |\n| \\`form-section\\` | fields | \\`\"fields\": [\"field1\", \"field2\"]\\` |\n| \\`detail-panel\\` | fields | \\`\"fields\": [\"field1\", \"field2\"]\\` |\n| \\`page-header\\` | actions | \\`\"actions\": [{ \"label\": \"New\", \"event\": \"CREATE\" }]\\` |\n\n### Binding Format Fixes (CRITICAL)\n\nValidator error: \\`ORB_BINDING_INVALID_FORMAT\\` - \"Invalid binding format: '@count:status=pending'\"\nSuggestion: \"Use @root.field.nested format\" means \\`@entity.fieldName\\`, NOT literal \"root\".\n\n**Common Invalid Patterns from Validator:**\n| Invalid Binding | Validator Message | Fix |\n|-----------------|-------------------|-----|\n| \\`@count\\` | Invalid binding format | Remove OR use \\`@entity.count\\` with computed field |\n| \\`@count:status=pending\\` | Invalid binding format | \\`@entity.pendingCount\\` + add computed field |\n| \\`@count:status=active\\` | Invalid binding format | \\`@entity.activeCount\\` + add computed field |\n| \\`@count:status=done\\` | Invalid binding format | \\`@entity.doneCount\\` + add computed field |\n\n**Step-by-Step Fix Process:**\n\nGiven error: \\`ORB_BINDING_INVALID_FORMAT\\` at path \\`orbitals[0].traits[0]...children[1].text\\`\n\n1. **Extract orbital index** from path (e.g., \\`orbitals[0]\\` -> index 0)\n2. **Find the invalid binding** (e.g., \\`\"@count:status=pending\"\\`)\n3. **Add computed fields** to orbital's entity:\n\\`\\`\\`json\n// In orbitals[0].entity.fields array, ADD:\n{ \"name\": \"pendingCount\", \"type\": \"number\", \"default\": 0 },\n{ \"name\": \"activeCount\", \"type\": \"number\", \"default\": 0 },\n{ \"name\": \"doneCount\", \"type\": \"number\", \"default\": 0 }\n\\`\\`\\`\n4. **Replace ALL invalid bindings** in render-ui:\n\\`\\`\\`json\n// BEFORE:\n{ \"type\": \"badge\", \"text\": \"@count:status=pending\", \"variant\": \"warning\" }\n// AFTER:\n{ \"type\": \"badge\", \"text\": \"@entity.pendingCount\", \"variant\": \"warning\" }\n\\`\\`\\`\n\n**Validator Error Code Reference:**\n| Code | Meaning | Action |\n|------|---------|--------|\n| \\`ORB_BINDING_INVALID_FORMAT\\` | Binding syntax wrong | Use \\`@entity.field\\` format |\n| \\`ORB_BINDING_UNKNOWN_ROOT\\` | Wrong root prefix | Use \\`@entity\\`, \\`@payload\\`, \\`@state\\`, \\`@now\\` |\n| \\`ORB_BINDING_INVALID_PATH\\` | Field doesn't exist | Add field to entity OR correct name |\n| \\`ORB_BINDING_STATE_NO_PATH\\` | \\`@state\\` needs no path | Use \\`@state\\` alone, not \\`@state.field\\` |`;\n}\n\n/**\n * Get over-generation detection section.\n */\nexport function getOverGenerationSection(): string {\n return `## Over-Generation Detection\n\n**Signs of over-generation:**\n- TaskListPage + TaskCreatePage + TaskEditPage + TaskViewPage (4 pages for 1 entity!)\n- Multiple pages for the same entity CRUD\n\n**Fix:** Consolidate to ONE page with trait-driven UI:\n\n\\`\\`\\`json\n// KEEP only:\n{\n \"pages\": [{\n \"name\": \"TasksPage\",\n \"path\": \"/tasks\",\n \"viewType\": \"list\",\n \"traits\": [{ \"ref\": \"TaskInteraction\" }]\n }]\n}\n\n// DELETE separate create/edit/view pages\n\\`\\`\\`\n\nThe trait's render-ui effects handle all UI (modals for create/edit, drawers for view).`;\n}\n\n/**\n * Get efficiency guidelines section.\n */\nexport function getEfficiencySection(): string {\n return `## Efficiency Guidelines\n\nTarget: **3-5 tool calls** for most fixes.\n\n### For Small Schemas (< 15KB)\n\n\\`\\`\\`\nStep 1: Read schema.orb (1 call)\nStep 2: Edit to fix ALL errors at once (1 call)\nStep 3: Validate if needed (1 call)\nTotal: 3 tool calls\n\\`\\`\\`\n\n### For Large Schemas (> 15KB) - MANDATORY CHUNKING\n\n**⚠️ WARNING: For schemas larger than 15KB, you MUST use chunking tools.**\n\nDirect edit_file on large schemas will fail or consume excessive tokens. ALWAYS use this workflow:\n\n\\`\\`\\`\nMANDATORY Step 1: query_schema_structure(\"schema.orb\")\n → Check totalSize field\n\nMANDATORY Step 2: extract_chunk({\n file: \"schema.orb\",\n type: \"orbital\", \n name: \"TargetOrbitalName\"\n })\n → Returns: { chunkId: \"abc123\", chunkFile: \".chunks/chunk-abc123.json\" }\n\nMANDATORY Step 3: edit_file({\n path: \".chunks/chunk-abc123.json\",\n old_string: ...,\n new_string: ...\n })\n\nMANDATORY Step 4: apply_chunk({ chunkId: \"abc123\" })\n → Merges back to schema.orb\n\\`\\`\\`\n\n**NEVER** use Read/Edit directly on schema files > 15KB. **ALWAYS** use chunking.\n\n**DO:**\n- **Target 3 tool calls** for simple fixes (read → edit → done)\n- Fix ONLY what the user asked for (don't over-fix)\n- Batch related changes in ONE edit\n- Use chunking for schemas > 15KB\n\n**DON'T:**\n- Fix errors the user didn't ask about\n- Add missing transitions/states unless explicitly requested\n- Read schema multiple times without changes\n- Make multiple small edits - do ONE comprehensive edit\n- Re-verify after validation passes\n- Create documentation files`;\n}\n\n/**\n * Get completion rules section.\n */\nexport function getCompletionRulesSection(): string {\n return `## Completion Rules\n\n**STOP IMMEDIATELY when:**\n- \\`validate_schema()\\` returns \\`\"valid\": true\\`\n\n**After validation passes:**\n1. Mark todos complete\n2. STOP - do not add more tasks\n3. Do NOT create documentation\n4. Do NOT \"verify\" or \"confirm\"\n5. Do NOT validate again\n\nThe validated schema.orb IS your only deliverable.`;\n}\n","/**\n * Game Guidance Section\n *\n * Specialized guidance for generating game orbital schemas.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the game as orbitals composition section.\n */\nexport function getGameAsOrbitalsSection(): string {\n return `## Games as Orbital Composition\n\nA game is a **list of orbitals**, each representing a game element:\n\n\\`\\`\\`\nGame Application = Σ(Game Orbitals)\n\n├── Player Orbital (runtime entity + input/physics traits)\n├── Enemy Orbital (runtime entity + AI/physics traits)\n├── Item Orbital (runtime entity + collectible trait)\n├── Level Orbital (singleton entity + level loader trait)\n└── GameState Orbital (singleton + score/health traits)\n\\`\\`\\`\n\n### Persistence Types for Games\n\n| Type | Use Case | Example |\n|------|----------|---------|\n| \\`runtime: true\\` | Active game objects | Player, Enemy, Bullet |\n| \\`singleton: true\\` | Global state | GameConfig, LevelState |\n| \\`collection: \"...\"\\` | Saved data | HighScores, SavedGames |`;\n}\n\n/**\n * Get game entity templates section.\n */\nexport function getGameEntityTemplatesSection(): string {\n return `## Game Entity Templates\n\n### Player Entity (runtime)\n\n\\`\\`\\`json\n{\n \"name\": \"Player\",\n \"runtime\": true,\n \"fields\": [\n { \"name\": \"x\", \"type\": \"number\", \"default\": 100 },\n { \"name\": \"y\", \"type\": \"number\", \"default\": 100 },\n { \"name\": \"velocityX\", \"type\": \"number\", \"default\": 0 },\n { \"name\": \"velocityY\", \"type\": \"number\", \"default\": 0 },\n { \"name\": \"health\", \"type\": \"number\", \"default\": 100 },\n { \"name\": \"facing\", \"type\": \"enum\", \"values\": [\"left\", \"right\"], \"default\": \"right\" }\n ]\n}\n\\`\\`\\`\n\n### GameState Entity (singleton)\n\n\\`\\`\\`json\n{\n \"name\": \"GameState\",\n \"singleton\": true,\n \"fields\": [\n { \"name\": \"score\", \"type\": \"number\", \"default\": 0 },\n { \"name\": \"level\", \"type\": \"number\", \"default\": 1 },\n { \"name\": \"lives\", \"type\": \"number\", \"default\": 3 },\n { \"name\": \"state\", \"type\": \"enum\", \"values\": [\"menu\", \"playing\", \"paused\", \"gameOver\"] }\n ]\n}\n\\`\\`\\`\n\n### Enemy Entity (runtime)\n\n\\`\\`\\`json\n{\n \"name\": \"Enemy\",\n \"runtime\": true,\n \"fields\": [\n { \"name\": \"x\", \"type\": \"number\" },\n { \"name\": \"y\", \"type\": \"number\" },\n { \"name\": \"health\", \"type\": \"number\", \"default\": 30 },\n { \"name\": \"damage\", \"type\": \"number\", \"default\": 10 },\n { \"name\": \"patrolStart\", \"type\": \"number\" },\n { \"name\": \"patrolEnd\", \"type\": \"number\" }\n ]\n}\n\\`\\`\\``;\n}\n\n/**\n * Get game traits section.\n */\nexport function getGameTraitsSection(): string {\n return `## Game Traits\n\n### Core Game Traits\n\n| Trait | Purpose | Key States |\n|-------|---------|------------|\n| \\`Physics2D\\` | Gravity, velocity | grounded, airborne, falling |\n| \\`PlatformerInput\\` | Movement controls | idle, moving, jumping |\n| \\`Health\\` | Damage, death | alive, hurt, dead |\n| \\`Score\\` | Points tracking | (stateless - just effects) |\n| \\`Collectible\\` | Pickup items | available, collected |\n| \\`Patrol\\` | Enemy AI | patrolling, reversing |\n| \\`GameState\\` | Game flow | menu, playing, paused, gameOver |\n\n### Game Trait Example\n\n\\`\\`\\`json\n{\n \"name\": \"Physics2D\",\n \"category\": \"interaction\",\n \"linkedEntity\": \"Player\",\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"grounded\", \"isInitial\": true },\n { \"name\": \"airborne\" }\n ],\n \"events\": [\n { \"key\": \"JUMP\", \"name\": \"Jump\" },\n { \"key\": \"LAND\", \"name\": \"Land\" }\n ],\n \"transitions\": [\n {\n \"from\": \"grounded\",\n \"to\": \"airborne\",\n \"event\": \"JUMP\",\n \"effects\": [\n [\"set\", \"@entity.velocityY\", -15],\n [\"emit\", \"PLAYER_JUMPED\", \"@entity\"]\n ]\n },\n {\n \"from\": \"airborne\",\n \"to\": \"grounded\",\n \"event\": \"LAND\",\n \"effects\": [\n [\"set\", \"@entity.velocityY\", 0],\n [\"set\", \"@entity.isGrounded\", true]\n ]\n }\n ]\n }\n}\n\\`\\`\\``;\n}\n\n/**\n * Get game patterns section.\n */\nexport function getGamePatternsSection(): string {\n return `## Game UI Patterns\n\n| Pattern | Slot | Purpose |\n|---------|------|---------|\n| \\`game-canvas\\` | main | Main game rendering |\n| \\`game-hud\\` | overlay | Score, health, lives |\n| \\`game-controls\\` | overlay | Touch/keyboard hints |\n| \\`game-menu\\` | modal | Pause, settings |\n\n### Game Canvas Effect\n\n\\`\\`\\`json\n[\"render-ui\", \"main\", {\n \"type\": \"game-canvas\",\n \"entities\": [\"Player\", \"Enemy\", \"Coin\", \"Platform\"],\n \"camera\": { \"follow\": \"Player\" },\n \"physics\": { \"gravity\": 980 }\n}]\n\\`\\`\\`\n\n### Game HUD Effect\n\n\\`\\`\\`json\n[\"render-ui\", \"overlay\", {\n \"type\": \"game-hud\",\n \"elements\": [\n { \"type\": \"health-bar\", \"entity\": \"Player\", \"field\": \"health\" },\n { \"type\": \"score-display\", \"entity\": \"GameState\", \"field\": \"score\" },\n { \"type\": \"lives-counter\", \"entity\": \"GameState\", \"field\": \"lives\" }\n ]\n}]\n\\`\\`\\``;\n}\n\n/**\n * Get asset reference section.\n */\nexport function getAssetRefSection(): string {\n return `## Asset References\n\n**NEVER hardcode asset paths. Use assetRef:**\n\n\\`\\`\\`json\n{\n \"entity\": {\n \"name\": \"Player\",\n \"assetRef\": {\n \"role\": \"player\",\n \"category\": \"hero\",\n \"animations\": [\"idle\", \"run\", \"jump\", \"fall\", \"hurt\"],\n \"style\": \"pixel\"\n }\n }\n}\n\\`\\`\\`\n\nThe compiler resolves \\`assetRef\\` to actual sprite paths at build time.\n\n### Animation Mapping\n\n| State | Animation |\n|-------|-----------|\n| grounded + idle | \\`idle\\` |\n| grounded + moving | \\`run\\` |\n| airborne + velocityY < 0 | \\`jump\\` |\n| airborne + velocityY > 0 | \\`fall\\` |\n| taking damage | \\`hurt\\` |\n| health <= 0 | \\`die\\` |`;\n}\n\n/**\n * Get multi-file composition section.\n */\nexport function getMultiFileSection(): string {\n return `## Multi-File Composition\n\nSplit large games into multiple .orb files:\n\n\\`\\`\\`\ngame/\n├── game.orb # Main schema with Player, GameState\n├── enemies.orb # Enemy orbital definitions\n├── items.orb # Collectibles, powerups\n└── tiles.orb # Platforms, terrain\n\\`\\`\\`\n\n### External Reference Syntax\n\n\\`\\`\\`json\n{\n \"name\": \"Level1Enemies\",\n \"ref\": \"./enemies.orb#Slime\",\n \"instances\": [\n { \"id\": \"slime-1\", \"position\": { \"x\": 300, \"y\": 400 } },\n { \"id\": \"slime-2\", \"position\": { \"x\": 600, \"y\": 400 } }\n ]\n}\n\\`\\`\\``;\n}\n\n/**\n * Get game types section.\n */\nexport function getGameTypesSection(): string {\n return `## Game Type Templates\n\n### Platformer\n- Player with Physics2D + PlatformerInput\n- Platform entities for level layout\n- Collectible coins/items\n- Enemies with Patrol trait\n\n### Puzzle (Match-3, Tetris)\n- Grid-based entity (runtime singleton)\n- Tile/Piece entities\n- Match detection logic in trait\n- Score tracking\n\n### Roguelike\n- Player with Health + Inventory\n- Dungeon/Room singleton for level gen\n- Enemy entities with AI traits\n- Turn-based or real-time movement\n\n### Endless Runner\n- Player at fixed X, jumping\n- Obstacles spawning and moving\n- Procedural difficulty scaling\n- Distance-based scoring`;\n}\n","/**\n * Uses Import System Section\n *\n * Guidance for using the `uses` declaration to import external orbitals.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the uses import system section.\n */\nexport function getUsesImportSection(): string {\n return `## Orbital Import System (\\`uses\\`)\n\nOrbitals can import other orbitals to reuse their components.\n\n### Basic Usage\n\n\\`\\`\\`json\n{\n \"name\": \"Level1\",\n \"uses\": [\n { \"from\": \"./goblin.orb\", \"as\": \"Goblin\" },\n { \"from\": \"./health.orb\", \"as\": \"Health\" }\n ],\n \"entity\": \"Goblin.entity\",\n \"traits\": [\n \"Goblin.traits.Movement\",\n \"Health.traits.Health\"\n ],\n \"pages\": []\n}\n\\`\\`\\`\n\n### Component References\n\nAfter importing with \\`uses\\`, access components via:\n\n| Component | Reference Format | Example |\n|-----------|------------------|---------|\n| Entity | \\`Alias.entity\\` | \\`\"entity\": \"Goblin.entity\"\\` |\n| Trait | \\`Alias.traits.TraitName\\` | \\`\"traits\": [\"Health.traits.Health\"]\\` |\n| Page | \\`Alias.pages.PageName\\` | \\`\"pages\": [\"User.pages.Profile\"]\\` |\n\n### Page Path Override\n\nWhen importing a page, you can override its URL path:\n\n\\`\\`\\`json\n{\n \"pages\": [\n { \"ref\": \"User.pages.Profile\", \"path\": \"/my-profile\" }\n ]\n}\n\\`\\`\\`\n\n### Entity Persistence Semantics\n\nWhen you reference an imported entity, the behavior depends on its persistence type:\n\n| Persistence | Sharing Behavior | Use Case |\n|-------------|------------------|----------|\n| \\`persistent\\` | **Shared** - Same DB collection | Users, Products, Orders |\n| \\`runtime\\` | **Isolated** - Each orbital gets own instances | Game entities, UI state |\n| \\`singleton\\` | **Shared** - Single global instance | Config, Game state |\n\n**Example**: Two orbitals importing a \\`runtime\\` entity each get separate instances:\n\\`\\`\\`json\n// level1.orb\n{ \"entity\": \"Goblin.entity\" } // Level1's goblins\n\n// level2.orb\n{ \"entity\": \"Goblin.entity\" } // Level2's goblins (separate!)\n\\`\\`\\`\n\n### Import Sources\n\n| Source Format | Description |\n|---------------|-------------|\n| \\`\"./path.orb\"\\` | Local relative path |\n| \\`\"../shared/health.orb\"\\` | Parent directory |\n| \\`\"std/behaviors/game-core\"\\` | Standard library |\n| \\`\"@game-lib/enemies.orb\"\\` | Scoped package |\n\n### Key Rules\n\n1. **Alias must be PascalCase** - e.g., \\`\"as\": \"Health\"\\`, NOT \\`\"as\": \"health\"\\`\n2. **All traits belong in orbitals** - No schema-level \\`traits[]\\` array\n3. **References must match imports** - \\`Goblin.entity\\` requires \\`{ \"as\": \"Goblin\" }\\` in \\`uses\\`\n4. **Inline OR reference** - Each component slot accepts either form\n`;\n}\n\n/**\n * Get compact uses guidance.\n */\nexport function getUsesImportCompact(): string {\n return `## Orbital Imports (\\`uses\\`)\n\nImport other orbitals and reference their components:\n\n\\`\\`\\`json\n{\n \"uses\": [{ \"from\": \"./health.orb\", \"as\": \"Health\" }],\n \"entity\": \"Health.entity\", // Reference entity\n \"traits\": [\"Health.traits.Health\"], // Reference trait\n \"pages\": [\"Health.pages.Dashboard\"] // Reference page\n}\n\\`\\`\\`\n\n**Alias must be PascalCase.** No schema-level \\`traits[]\\` array exists.\n`;\n}\n","/**\n * Lean Orbital Skill Generator\n *\n * Generates a minimal, focused orbital skill by:\n * 1. Deriving type information directly from @almadar/core\n * 2. Using focused, minimal guidance sections\n * 3. Avoiding verbose explanations and redundancy\n *\n * v4: Reduced from ~49K to ~15K by:\n * - Removing std behaviors JSON dump (21K)\n * - Removing schema-updates (moved to fixing skill)\n * - Removing custom-traits (moved to fixing skill)\n * - Trimming common-errors to top 6\n * - Replacing 380-char render-ui quickref with 2.5K design guide\n * - Using compact decomposition and connectivity variants\n *\n * @packageDocumentation\n */\n\nimport {\n getSExprQuickRef,\n getStdMinimalReference,\n getStdFullReference,\n getStdBehaviorsWithStateMachines,\n getKeyBehaviorsReference,\n} from './helpers.js';\nimport {\n getArchitectureSection,\n getCommonErrorsSection,\n getDecompositionSection,\n getDecompositionCompact,\n getCustomTraitSection,\n getSchemaUpdateSection,\n getConnectivityCompact,\n getRenderUIDesignGuide,\n getThemeGuide,\n getBannedProps,\n // UX Enhancement sections\n getFlowPatternSection,\n getPortableOrbitalOutputSection,\n getOrbitalConnectivitySection,\n getContextUsageCompact,\n} from '../prompts/skill-sections/index.js';\n\n// ============================================================================\n// Generator Options\n// ============================================================================\n\nexport interface LeanSkillOptions {\n /** Include example orbital */\n includeExample?: boolean;\n /** Include tool workflow section */\n includeToolWorkflow?: boolean;\n /** Include std/* library reference (operators + behaviors) */\n includeStdLibrary?: boolean;\n /** Use full std reference (detailed) vs minimal (compact) */\n stdLibraryFull?: boolean;\n /** Include expanded non-game behaviors with state machines for copying */\n includeStdStateMachines?: boolean;\n /** Include schema update guidance section */\n includeSchemaUpdates?: boolean;\n /** Include custom trait examples section */\n includeCustomTraits?: boolean;\n /** Error detail level: 'top6' for generation, 'full' for fixing */\n errorLevel?: 'top6' | 'full';\n /** Include render-ui design guide with pattern catalog and recipes */\n includeDesignGuide?: boolean;\n}\n\n// ============================================================================\n// Main Generator\n// ============================================================================\n\n/**\n * Generate a lean orbital skill.\n *\n * Default options produce a ~15K skill focused on generation quality.\n * Set includeStdStateMachines/includeCustomTraits/errorLevel='full' for\n * the larger ~49K variant used by legacy callers.\n */\nexport function generateLeanOrbitalSkill(options: LeanSkillOptions = {}): string {\n const {\n includeExample = true,\n includeToolWorkflow = true,\n includeStdLibrary = false,\n stdLibraryFull = false,\n includeStdStateMachines = false,\n includeSchemaUpdates = false,\n includeCustomTraits = false,\n errorLevel = 'top6',\n includeDesignGuide = true,\n } = options;\n\n // Build std section based on options\n let stdSection = '';\n if (includeStdLibrary || includeStdStateMachines) {\n if (includeStdStateMachines) {\n // Include expanded behaviors with state machines (non-game only)\n stdSection = `---\n\n${getKeyBehaviorsReference()}\n\n---\n\n${getStdBehaviorsWithStateMachines()}\n`;\n } else if (stdLibraryFull) {\n stdSection = `---\n\n${getStdFullReference()}\n`;\n } else {\n stdSection = `---\n\n${getStdMinimalReference()}\n`;\n }\n }\n\n // Use compact or full decomposition/connectivity\n const decompositionSection = (includeStdStateMachines || includeCustomTraits)\n ? getDecompositionSection()\n : getDecompositionCompact();\n\n const connectivitySection = (includeStdStateMachines || includeCustomTraits)\n ? getOrbitalConnectivitySection()\n : getConnectivityCompact();\n\n return `# Orbital Generation Skill\n\n> Generate Orbital applications using Orbital Units: Entity × Traits × Patterns\n\n${getArchitectureSection()}\n\n---\n\n${getSExprQuickRef()}\n\n---\n\n${includeDesignGuide ? getRenderUIDesignGuide() : ''}\n\n${includeDesignGuide ? `---\n\n${getThemeGuide()}\n\n---\n\n${getBannedProps()}` : ''}\n\n${stdSection}\n---\n\n${getFlowPatternSection()}\n\n---\n\n${decompositionSection}\n\n---\n\n${getPortableOrbitalOutputSection()}\n\n---\n\n${connectivitySection}\n\n---\n\n${getContextUsageCompact()}\n\n---\n\n${getCommonErrorsSection(errorLevel)}\n\n${includeCustomTraits ? `---\n\n${getCustomTraitSection()}\n` : ''}\n${includeToolWorkflow ? getToolWorkflowSection() : ''}\n\n${includeSchemaUpdates ? `---\n\n${getSchemaUpdateSection()}\n` : ''}\n${getCriticalOutputRequirements()}\n\n${includeExample ? getMinimalExample() : ''}\n`;\n}\n\n/**\n * Get critical output requirements section.\n * Placed near the end to reinforce requirements before generation.\n */\nfunction getCriticalOutputRequirements(): string {\n return `---\n\n## CRITICAL: Output Requirements\n\nEvery orbital MUST include:\n\n### 1. domainContext (REQUIRED)\n\\`\\`\\`json\n\"domainContext\": {\n \"request\": \"<original user request>\",\n \"requestFragment\": \"<what part produced THIS orbital>\",\n \"category\": \"business\",\n \"vocabulary\": { \"item\": \"Task\", \"create\": \"Add\", \"delete\": \"Remove\" }\n}\n\\`\\`\\`\n\n### 2. design (REQUIRED)\n\\`\\`\\`json\n\"design\": {\n \"style\": \"modern\",\n \"uxHints\": {\n \"flowPattern\": \"crud-cycle\",\n \"listPattern\": \"entity-table\",\n \"formPattern\": \"modal\"\n }\n}\n\\`\\`\\`\n\n### 3. Business Rule Guards on SAVE (when rules exist)\nIf the user specifies validation constraints, add S-expression guards on transitions:\n\\`\\`\\`json\n{\n \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"guard\": [\"<=\", \"@payload.data.score\", 100],\n \"effects\": [[\"persist\", \"create\", \"Entry\", \"@payload.data\"], ...]\n}\n\\`\\`\\`\n\n### 4. ONE Orbital Per Entity\nDo NOT create multiple orbitals for the same entity. All CRUD operations belong in ONE orbital.\n\n### 5. Entity Field is REQUIRED (CRITICAL)\nEvery orbital MUST have an entity field. No exceptions.\n\n\\`\\`\\`json\n{\n \"name\": \"Product Management\",\n \"entity\": { // ← REQUIRED\n \"name\": \"Product\",\n \"collection\": \"products\",\n \"fields\": [...]\n },\n \"traits\": [...],\n \"pages\": [...]\n}\n\\`\\`\\`\n\n**Verify before calling finish_task:**\n- [ ] Each orbital has an \"entity\" field\n- [ ] Each entity has a \"name\" and \"collection\"\n- [ ] Each entity has \"fields\" array\n\n**Missing entity field = INVALID orbital!**\n\n**Fixing Entity Errors:**\nIf validation shows errors like \"Missing entity\" or \"No fields\":\n1. Read the orbital file from .orbitals/ directory\n2. Add the missing entity field:\n\\`\\`\\`json\n\"entity\": {\n \"name\": \"Product\",\n \"collection\": \"products\",\n \"fields\": [\n { \"name\": \"name\", \"type\": \"string\", \"required\": true },\n { \"name\": \"price\", \"type\": \"number\" }\n ]\n}\n\\`\\`\\`\n3. Save the file and re-validate\n\n**DO NOT call finish_task until ALL orbitals have entities!**`\n}\n\n/**\n * Get minimal tool workflow section.\n */\nfunction getToolWorkflowSection(): string {\n return `---\n\n## Tool Workflow\n\n### Phase 1: DECOMPOSE\nBreak requirements into OrbitalUnits (pure reasoning, no tools).\n\n### Phase 2: GENERATE\n\n**Option A: Orchestrated Generation (RECOMMENDED for 3+ orbitals)**\nUse \\`generate_schema_orchestrated\\` for automatic complexity-based routing:\n\n\\`\\`\\`\ngenerate_schema_orchestrated({ prompt: \"Full app description with all entities and features\" })\n\\`\\`\\`\n\nThis tool automatically:\n- Decomposes your requirements\n- Routes simple/medium (1-3 orbitals) to fast single-provider\n- Routes complex (4+ orbitals) to parallel multi-provider\n- Returns a complete schema with all orbitals\n\n**Option B: Per-Orbital Generation (for simple cases or fine-grained control)**\nCall \\`generate_orbital\\` for each orbital:\n\n\\`\\`\\`\ngenerate_orbital({ orbital: {...}, orbitalIndex: 0, totalOrbitals: N })\ngenerate_orbital({ orbital: {...}, orbitalIndex: 1, totalOrbitals: N })\n...\n\\`\\`\\`\n\nEach orbital is written to \\`.orbitals/<name>.json\\` with ALL effects (render-ui, persist, emit, set, etc.).\n\n### Phase 3: COMBINE\nCall \\`finish_task\\` to auto-combine orbitals into schema.orb:\n\n\\`\\`\\`\nfinish_task({ appName: \"App\" })\n# Reads .orbitals/*.json → schema.orb → orbital validate\n\\`\\`\\`\n\n### Phase 4: VALIDATE (CRITICAL)\nAfter combining, validate the schema:\n\n\\`\\`\\`\nvalidate_schema()\n\\`\\`\\`\n\n**If validation shows errors:**\n1. Read the error path (e.g., orbitals[0].entity)\n2. Fix the issue in the orbital file\n3. Re-run validate_schema()\n\n**Common errors to fix:**\n- ORB_E_MISSING_NAME → Add entity name\n- ORB_E_NO_FIELDS → Add entity fields\n- Missing entity field → Add entity object with name and fields\n\n**CRITICAL: Check EACH orbital file in .orbitals/ directory:**\nUse Read tool to check each orbital file has entity field.\n\n### Phase 5: VERIFY COMPOSITION QUALITY\n\nBefore calling \\`finish_task\\`, verify each INIT transition:\n\n1. **Uses a single \\`render-ui\\` call** with top-level \\`stack\\` and \\`children\\` — NOT flat sequential calls\n2. **Has 3+ composed sections**: header (HStack: title + action), metrics (HStack/Grid of Box cards), data (entity-table/entity-cards)\n3. **Uses domain-appropriate atoms**: \\`badge\\` for status, \\`typography\\` for labels/values, \\`button\\` for actions\n4. **Props are correct**: \\`submitEvent\\` not \\`onSubmit\\`, \\`actions\\` not \\`headerActions\\`, \\`fields\\` not \\`fieldNames\\`\n\nIf any INIT transition is flat (just \\`page-header\\` + \\`entity-table\\`), redesign it as a composed VStack hierarchy before finishing.\n`;\n}\n\n/**\n * Get minimal example section.\n * VALIDATED example that passes npx @almadar/cli validate\n */\nfunction getMinimalExample(): string {\n return `---\n\n## Example: Task Manager (Atomic Composition - VALIDATED)\n\nThis example passes \\`npx @almadar/cli validate\\` with zero errors:\n\n\\`\\`\\`json\n{\n \"name\": \"Taskly\",\n \"version\": \"1.0.0\",\n \"orbitals\": [{\n \"name\": \"Task Management\",\n \"entity\": {\n \"name\": \"Task\",\n \"collection\": \"tasks\",\n \"fields\": [\n { \"name\": \"title\", \"type\": \"string\", \"required\": true },\n { \"name\": \"status\", \"type\": \"enum\", \"values\": [\"pending\", \"active\", \"done\"] }\n ]\n },\n \"traits\": [{\n \"name\": \"TaskInteraction\",\n \"category\": \"interaction\",\n \"linkedEntity\": \"Task\",\n \"emits\": [{ \"event\": \"INIT\", \"scope\": \"internal\" }],\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"Browsing\", \"isInitial\": true },\n { \"name\": \"Creating\" }\n ],\n \"events\": [\n { \"key\": \"INIT\", \"name\": \"Initialize\" },\n { \"key\": \"CREATE\", \"name\": \"Create\" },\n { \"key\": \"SAVE\", \"name\": \"Save\", \"payload\": [{ \"name\": \"data\", \"type\": \"object\" }] },\n { \"key\": \"CANCEL\", \"name\": \"Cancel\" }\n ],\n \"transitions\": [\n {\n \"from\": \"Browsing\", \"to\": \"Browsing\", \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\",\n \"children\": [\n { \"type\": \"stack\", \"direction\": \"horizontal\", \"justify\": \"between\", \"align\": \"center\",\n \"children\": [\n { \"type\": \"typography\", \"variant\": \"h1\", \"text\": \"Tasks\" },\n { \"type\": \"button\", \"label\": \"New Task\", \"event\": \"CREATE\", \"variant\": \"primary\" }\n ]\n },\n { \"type\": \"stack\", \"direction\": \"horizontal\", \"gap\": \"md\", \"wrap\": true,\n \"children\": [\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"var(--color-card)\", \"border\": true, \"rounded\": \"var(--radius-md)\",\n \"children\": [{ \"type\": \"typography\", \"variant\": \"caption\", \"text\": \"Total\" }, { \"type\": \"typography\", \"variant\": \"h2\", \"text\": \"@count\" }] },\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"var(--color-card)\", \"border\": true, \"rounded\": \"var(--radius-md)\",\n \"children\": [{ \"type\": \"typography\", \"variant\": \"caption\", \"text\": \"Active\" }, { \"type\": \"badge\", \"variant\": \"primary\", \"text\": \"@count:status=active\" }] },\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"var(--color-card)\", \"border\": true, \"rounded\": \"var(--radius-md)\",\n \"children\": [{ \"type\": \"typography\", \"variant\": \"caption\", \"text\": \"Done\" }, { \"type\": \"badge\", \"variant\": \"success\", \"text\": \"@count:status=done\" }] }\n ]\n },\n { \"type\": \"entity-table\", \"entity\": \"Task\", \"columns\": [\"title\", \"status\"], \"searchable\": true,\n \"itemActions\": [{ \"label\": \"View\", \"event\": \"VIEW\" }, { \"label\": \"Edit\", \"event\": \"EDIT\" }, { \"label\": \"Delete\", \"event\": \"DELETE\" }] }\n ]\n }]\n ]\n },\n {\n \"from\": \"Browsing\", \"to\": \"Creating\", \"event\": \"CREATE\",\n \"effects\": [[\"render-ui\", \"modal\", { \"type\": \"form-section\", \"entity\": \"Task\", \"fields\": [\"title\", \"status\"], \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }]]\n },\n {\n \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"effects\": [[\"persist\", \"create\", \"Task\", \"@payload.data\"], [\"render-ui\", \"modal\", null], [\"emit\", \"INIT\"]]\n },\n {\n \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"modal\", null]]\n }\n {\n \"from\": \"Editing\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"modal\", null]]\n },\n {\n \"from\": \"Deleting\", \"to\": \"Browsing\", \"event\": \"CONFIRM_DELETE\",\n \"effects\": [[\"persist\", \"delete\", \"Task\"], [\"render-ui\", \"overlay\", null], [\"emit\", \"INIT\"]]\n },\n {\n \"from\": \"Deleting\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"overlay\", null]]\n }\n ]\n }\n }],\n \"pages\": [{\n \"name\": \"TasksPage\",\n \"path\": \"/tasks\",\n \"viewType\": \"list\",\n \"isInitial\": true,\n \"entity\": \"Task\",\n \"traits\": [{ \"ref\": \"TaskInteraction\" }]\n }],\n \"emits\": [],\n \"listens\": []\n }]\n}\n\\`\\`\\`\n\n**Key points — Atomic Composition**:\n- **INIT uses a SINGLE \\`render-ui\\` call** with a top-level \\`stack\\` containing composed \\`children\\`\n- **3 sections composed**: header (HStack: title + button), metrics (HStack of Box stat cards), data (entity-table)\n- **Atoms used**: \\`typography\\` (h1, h2, caption), \\`badge\\` (status indicators), \\`button\\` (actions)\n- **Layout used**: \\`stack\\` (vertical page, horizontal rows), \\`box\\` (stat cards)\n- **Organism used**: \\`entity-table\\` with searchable + itemActions\n- **Theme variables**: All colors use \\`var(--color-*)\\`, spacing uses \\`var(--spacing-*)\\`, radius uses \\`var(--radius-*)\\`\n\n**Validation Rules** (MANDATORY):\n- Events: \\`{ \"key\": \"INIT\", \"name\": \"Initialize\" }\\` — NOT \\`\"INIT\"\\`\n- Emits: \\`[{ \"event\": \"INIT\", \"scope\": \"internal\" }]\\` — NOT \\`[\"INIT\"]\\`\n- Payload events MUST declare payload: \\`{ \"key\": \"SAVE\", \"payload\": [{ \"name\": \"data\", \"type\": \"object\" }] }\\`\n- Page traits: \\`{ \"ref\": \"TaskInteraction\" }\\` — NOT with linkedEntity\n- Props: \\`submitEvent\\` (not \\`onSubmit\\`), \\`actions\\` (not \\`headerActions\\`), \\`fields\\` (not \\`fieldNames\\`)\n- Theme: All visual properties use CSS variables\n\n---\n\n## Example: E-commerce with Multiple Orbitals (3 Entities)\n\nFor an app with Product, Category, and Order:\n\n\\`\\`\\`json\n{\n \"name\": \"EcommerceAdmin\",\n \"version\": \"1.0.0\",\n \"orbitals\": [\n {\n \"name\": \"Product Management\",\n \"entity\": {\n \"name\": \"Product\",\n \"collection\": \"products\",\n \"fields\": [\n { \"name\": \"name\", \"type\": \"string\", \"required\": true },\n { \"name\": \"price\", \"type\": \"number\", \"required\": true },\n { \"name\": \"stock\", \"type\": \"number\", \"default\": 0 }\n ]\n },\n \"traits\": [{ \"name\": \"ProductInteraction\", \"category\": \"interaction\", \"linkedEntity\": \"Product\" }],\n \"pages\": [{ \"name\": \"ProductsPage\", \"path\": \"/products\", \"traits\": [{ \"ref\": \"ProductInteraction\" }] }]\n },\n {\n \"name\": \"Category Management\",\n \"entity\": {\n \"name\": \"Category\",\n \"collection\": \"categories\",\n \"fields\": [\n { \"name\": \"name\", \"type\": \"string\", \"required\": true },\n { \"name\": \"slug\", \"type\": \"string\", \"required\": true }\n ]\n },\n \"traits\": [{ \"name\": \"CategoryInteraction\", \"category\": \"interaction\", \"linkedEntity\": \"Category\" }],\n \"pages\": [{ \"name\": \"CategoriesPage\", \"path\": \"/categories\", \"traits\": [{ \"ref\": \"CategoryInteraction\" }] }]\n },\n {\n \"name\": \"Order Management\",\n \"entity\": {\n \"name\": \"Order\",\n \"collection\": \"orders\",\n \"fields\": [\n { \"name\": \"orderNumber\", \"type\": \"string\", \"required\": true },\n { \"name\": \"totalAmount\", \"type\": \"number\", \"required\": true },\n { \"name\": \"status\", \"type\": \"enum\", \"values\": [\"pending\", \"processing\", \"shipped\", \"delivered\"] }\n ]\n },\n \"traits\": [{ \"name\": \"OrderInteraction\", \"category\": \"interaction\", \"linkedEntity\": \"Order\" }],\n \"pages\": [{ \"name\": \"OrdersPage\", \"path\": \"/orders\", \"traits\": [{ \"ref\": \"OrderInteraction\" }] }]\n }\n ]\n}\n\\`\\`\\`\n\n**Key Points for Multi-Orbital Apps:**\n- Each orbital has its own entity field (REQUIRED)\n- Each entity has its own collection name\n- Each orbital has its own page\n- Call \\`generate_orbital\\` 3 times (once per orbital)\n`;\n}\n\n// ============================================================================\n// Stat Export (for testing)\n// ============================================================================\n\n/**\n * Get skill stats for comparison.\n */\nexport function getLeanSkillStats(options: LeanSkillOptions = {}): { lines: number; chars: number } {\n const skill = generateLeanOrbitalSkill(options);\n return {\n lines: skill.split('\\n').length,\n chars: skill.length,\n };\n}\n\n/**\n * Get subagent system prompt for orbital generation.\n * This is used by the orbital generator subagent in @almadar/agent.\n * Provides focused guidance on generating complete orbitals with entities.\n */\nexport function getSubagentSystemPrompt(): string {\n return `# Orbital Generation Subagent\n\nYou are a specialized subagent that generates complete FullOrbitalUnit definitions.\nYour task is to expand a lightweight orbital input into a full orbital with entity, traits, state machines, and pages.\n\n## Core Formula\nOrbital Unit = Entity × Traits × Patterns\n\n## REQUIRED Output Structure\n\nEvery orbital MUST have this exact structure:\n\n\\`\\`\\`json\n{\n \"name\": \"OrbitalName\",\n \"entity\": { // ← CRITICAL: REQUIRED FIELD\n \"name\": \"EntityName\",\n \"collection\": \"entitynames\", // Plural lowercase\n \"persistence\": \"persistent\", // or \"runtime\" or \"singleton\"\n \"fields\": [\n { \"name\": \"fieldName\", \"type\": \"string|number|boolean|enum|timestamp|array|object|relation\", \"required\": true }\n ]\n },\n \"traits\": [\n {\n \"name\": \"TraitName\",\n \"category\": \"interaction\",\n \"linkedEntity\": \"EntityName\",\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"Browsing\", \"isInitial\": true },\n { \"name\": \"Creating\" },\n { \"name\": \"Editing\" }\n ],\n \"events\": [\n { \"key\": \"INIT\", \"name\": \"Initialize\" },\n { \"key\": \"CREATE\", \"name\": \"Create\" },\n { \"key\": \"SAVE\", \"name\": \"Save\", \"payload\": [{ \"name\": \"data\", \"type\": \"object\" }] },\n { \"key\": \"CANCEL\", \"name\": \"Cancel\" }\n ],\n \"transitions\": [\n {\n \"from\": \"Browsing\",\n \"to\": \"Browsing\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"stack\",\n \"direction\": \"vertical\",\n \"gap\": \"lg\",\n \"children\": [\n // header, metrics, data table\n ]\n }]\n ]\n }\n ]\n }\n }\n ],\n \"pages\": [\n {\n \"name\": \"PageName\",\n \"path\": \"/path\",\n \"viewType\": \"list\",\n \"traits\": [{ \"ref\": \"TraitName\" }]\n }\n ],\n \"domainContext\": {\n \"request\": \"...\",\n \"category\": \"business\",\n \"vocabulary\": { \"item\": \"...\", \"create\": \"...\" }\n },\n \"design\": {\n \"style\": \"modern\",\n \"uxHints\": { \"flowPattern\": \"crud-cycle\", \"listPattern\": \"entity-table\" }\n }\n}\n\\`\\`\\`\n\n## CRITICAL RULES\n\n1. **ENTITY FIELD IS REQUIRED**: Every orbital MUST have an \"entity\" field at the top level\n2. **Entity Name**: Must match the orbital's primary entity\n3. **Collection**: Plural lowercase version of entity name (e.g., \"products\" for Product)\n4. **Fields**: At minimum, include id, name, and relevant fields from input\n\n## Common Mistakes to Avoid\n\n- ❌ WRONG: Missing entity field at orbital level\n- ❌ WRONG: Only linkedEntity in trait, no orbital.entity\n- ❌ WRONG: Empty fields array\n- ❌ WRONG: Using \\`@count(tasks)\\`, \\`@find(...)\\`, \\`@sum(...)\\` — NO function-call bindings exist\n- ❌ WRONG: Using \\`actions\\` array on form-section — use \\`submitEvent\\`/\\`cancelEvent\\` strings\n- ❌ WRONG: Modal state without CANCEL/CLOSE transitions\n- ❌ WRONG: Bare \\`@entity\\` without a field path — use \\`@entity.fieldName\\`\n- ❌ WRONG: \\`@Product.name\\`, \\`@Order.status\\`, \\`@Customer.email\\` — NEVER use entity TYPE as binding root\n- ❌ WRONG: \\`@count(orders)\\`, \\`@sum(orders, total)\\`, \\`@avg(...)\\` — NO aggregate functions exist\n- ✅ CORRECT: Full entity object with name, collection, persistence, fields\n- ✅ CORRECT: \\`@entity.name\\`, \\`@entity.status\\`, \\`@entity.email\\` — ALWAYS use \\`@entity\\` as the root\n- ✅ CORRECT: Only valid binding roots: \\`@entity\\`, \\`@payload\\`, \\`@state\\`, \\`@now\\`, \\`@config\\`\n- ✅ CORRECT: Every state rendering to modal/drawer has CANCEL + CLOSE transitions back\n\n## Field Types\n\n| Type | Use For | Example |\n|------|---------|---------|\n| string | Text, names | { \"name\": \"title\", \"type\": \"string\", \"required\": true } |\n| number | Prices, counts | { \"name\": \"price\", \"type\": \"number\" } |\n| enum | Status, categories | { \"name\": \"status\", \"type\": \"enum\", \"values\": [\"pending\", \"active\"] } |\n| timestamp | Dates, times | { \"name\": \"createdAt\", \"type\": \"timestamp\", \"default\": \"@now\" } |\n| relation | Links to other entities | { \"name\": \"categoryId\", \"type\": \"relation\", \"relation\": { \"entity\": \"Category\" } } |\n\n## State Machine Patterns\n\n**CRUD Pattern:**\n- States: Browsing (isInitial), Creating, Editing, Viewing\n- Events: INIT, CREATE, EDIT, VIEW, SAVE, CANCEL, DELETE\n- INIT effect: render-ui with stack containing header, metrics, entity-table\n\n**Transitions:**\n- Browsing → Creating: on CREATE (render modal with form-section using submitEvent/cancelEvent)\n- Creating → Browsing: on SAVE (persist + dismiss modal + emit INIT)\n- Creating → Browsing: on CANCEL (dismiss modal: [\"render-ui\", \"modal\", null])\n- Creating → Browsing: on CLOSE (dismiss modal: [\"render-ui\", \"modal\", null])\n- Browsing → Editing: on EDIT (render modal with form-section)\n- Editing → Browsing: on SAVE, CANCEL, CLOSE (same pattern as Creating)\n\n**CRITICAL: Every state that renders to \"modal\" or \"drawer\" MUST have CANCEL and CLOSE transitions.**\n\n## form-section Props (NOT actions)\n\nform-section uses \\`submitEvent\\`/\\`cancelEvent\\`, NOT \\`actions\\` array:\n\\`\\`\\`json\n{ \"type\": \"form-section\", \"entity\": \"Task\", \"fields\": [\"title\", \"status\"], \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }\n\\`\\`\\`\n\n## Effects Reference\n\n| Effect | Syntax | Purpose |\n|--------|--------|---------|\n| render-ui | [\"render-ui\", \"main\", { ... }] | Render UI pattern |\n| render-ui | [\"render-ui\", \"modal\", { ... }] | Render modal |\n| render-ui | [\"render-ui\", \"modal\", null] | Dismiss modal |\n| persist | [\"persist\", \"create\", \"Entity\", \"@payload.data\"] | Save to DB |\n| set | [\"set\", \"@entity.field\", value] | Update field |\n| emit | [\"emit\", \"EVENT\", payload] | Emit event |\n| navigate | [\"navigate\", \"/path\"] | Navigate |\n\n## Valid Slots (ONLY these exist)\n\n\\`\"main\"\\`, \\`\"modal\"\\`, \\`\"drawer\"\\`, \\`\"sidebar\"\\`\n\nNEVER use: \\`\"modal-close\"\\`, \\`\"notification\"\\`, \\`\"confirm-modal\"\\`, \\`\"header\"\\`, \\`\"footer\"\\`\n\n## Pattern Type Required\n\nEVERY pattern object in render-ui MUST have a \\`\"type\"\\` field. This includes the top-level pattern AND every child in a stack's children array.\n\n## FINAL CHECKLIST (read before generating)\n\n1. **NO aggregate bindings**: \\`@count(...)\\`, \\`@sum(...)\\`, \\`@avg(...)\\` DO NOT EXIST. Use static text or add a count field to the entity instead.\n2. **form-section uses submitEvent/cancelEvent**: \\`{ \"type\": \"form-section\", \"entity\": \"X\", \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }\\`. NEVER put \\`\"actions\"\\` array on form-section — \\`actions\\` is for page-header and entity-detail only.\n3. **Arrays not objects**: \\`fields\\`, \\`states\\`, \\`events\\`, \\`transitions\\`, \\`children\\` MUST be arrays \\`[]\\`, NEVER objects \\`{}\\`.\n4. **Every render-ui child needs \"type\"**: \\`{ \"type\": \"typography\", \"text\": \"...\" }\\` not \\`{ \"text\": \"...\" }\\`\n5. **Valid slots only**: \\`\"main\"\\`, \\`\"modal\"\\`, \\`\"drawer\"\\`, \\`\"sidebar\"\\` — nothing else.\n6. **Binding roots**: ONLY \\`@entity.field\\`, \\`@payload.field\\`, \\`@state\\`, \\`@now\\`, \\`@config\\`. NEVER \\`@Order.field\\` or \\`@count()\\`.\n7. **Trait naming**: Name the trait \\`{Entity}Interaction\\` (e.g., \\`CustomerInteraction\\`, \\`OrderInteraction\\`). The page ref MUST match: \\`\"traits\": [{ \"ref\": \"CustomerInteraction\" }]\\`.\n\n## Output Requirements\n\nReturn ONLY valid JSON. No markdown, no explanations.\nThe JSON must be a complete FullOrbitalUnit with all required fields.\n`;\n}\n\n/**\n * Get comparison stats for different configurations.\n */\nexport function getSkillSizeComparison(): {\n minimal: { lines: number; chars: number };\n withStdMinimal: { lines: number; chars: number };\n withStdFull: { lines: number; chars: number };\n withStdStateMachines: { lines: number; chars: number };\n legacy: { lines: number; chars: number };\n} {\n return {\n minimal: getLeanSkillStats({}),\n withStdMinimal: getLeanSkillStats({ includeStdLibrary: true, stdLibraryFull: false }),\n withStdFull: getLeanSkillStats({ includeStdLibrary: true, stdLibraryFull: true }),\n withStdStateMachines: getLeanSkillStats({ includeStdStateMachines: true }),\n legacy: getLeanSkillStats({\n includeStdStateMachines: true,\n includeSchemaUpdates: true,\n includeCustomTraits: true,\n errorLevel: 'full',\n }),\n };\n}\n","/**\n * KFlow Orbitals Skill Generator\n *\n * Generates the kflow-orbitals skill for orbital-based schema generation.\n * Uses the orbital skill generator from the orbitals module and adds\n * domain classification, interaction models, and trait-driven UI guidance.\n *\n * v4.0: Reduced from ~49K to ~15K by cutting std dump, schema-updates,\n * custom-traits, and half the errors. Added render-ui design guide with\n * pattern catalog and composition recipes.\n *\n * @packageDocumentation\n */\n\nimport type { GeneratedSkill } from './types.js';\nimport { generateLeanOrbitalSkill } from '../orbitals-skills-generators/lean-orbital-skill-generator.js';\n\n/**\n * Generate the kflow-orbitals skill.\n *\n * Uses the lean orbital skill generator with minimal defaults (~15K).\n * The design guide, top-6 errors, and enriched example are always included.\n *\n * Options:\n * - compact: false (default) - Standard ~15K generation skill\n * - compact: true - Same (compact flag preserved for API compat, no-op now)\n */\nexport function generateKflowOrbitalsSkill(compact = false): GeneratedSkill {\n const frontmatter = {\n name: 'kflow-orbitals',\n description: 'Generate KFlow schemas using the Orbitals composition model. Decomposes applications into atomic Orbital Units (Entity x Traits x Patterns) with structural caching for efficiency.',\n allowedTools: ['Read', 'Write', 'Edit', 'generate_orbital', 'generate_schema_orchestrated', 'finish_task', 'query_schema_structure', 'extract_chunk', 'apply_chunk'],\n version: '5.0.0', // v5.0: atomic composition (removed design_transition, single-pass design)\n };\n\n // v4: Minimal skill with design guide (~15K).\n // - No std behaviors dump (saves 21K)\n // - No schema-updates (moved to fixing skill)\n // - No custom-traits (moved to fixing skill)\n // - Top 6 errors only (saves 4K)\n // - render-ui design guide with pattern catalog + composition recipes\n // - Enriched example with stats + searchable table\n const content = generateLeanOrbitalSkill({\n includeExample: true,\n includeToolWorkflow: true,\n includeStdStateMachines: false,\n includeSchemaUpdates: false,\n includeCustomTraits: false,\n errorLevel: 'top6',\n includeDesignGuide: true,\n });\n\n return {\n name: 'kflow-orbitals',\n frontmatter,\n content,\n };\n}\n","/**\n * Lean Fixing Skill Generator\n *\n * Generates a minimal, focused fixing skill by:\n * 1. Reusing the same sections as lean-orbital-skill-generator\n * 2. Adding fixing-specific guidance on top\n * 3. Keeping the same modular structure\n *\n * @packageDocumentation\n */\n\nimport {\n getSExprQuickRef,\n getRenderUIQuickRef,\n} from './helpers.js';\nimport { getPatternActionsRef } from '@almadar/patterns';\nimport {\n getArchitectureSection,\n getCommonErrorsSection,\n getSchemaUpdateSection,\n getCustomTraitSection,\n // Fixing-specific sections\n getFixingWorkflowSection,\n getCommonFixPatternsSection,\n getOverGenerationSection,\n getEfficiencySection,\n getCompletionRulesSection,\n} from '../prompts/skill-sections/index.js';\n\n// ============================================================================\n// Generator Options\n// ============================================================================\n\nexport interface LeanFixingSkillOptions {\n /** Include over-generation detection */\n includeOverGeneration?: boolean;\n /** Include schema update guidance */\n includeSchemaUpdates?: boolean;\n /** Include efficiency guidelines */\n includeEfficiency?: boolean;\n}\n\n// ============================================================================\n// Main Generator\n// ============================================================================\n\n/**\n * Generate a lean fixing skill.\n *\n * This produces a fixing skill that reuses the lean orbital sections\n * and adds fixing-specific guidance.\n */\nexport function generateLeanFixingSkill(options: LeanFixingSkillOptions = {}): string {\n const {\n includeOverGeneration = true,\n includeSchemaUpdates = true,\n includeEfficiency = true,\n } = options;\n\n return `# Orbital Fixing Skill\n\n> Fix validation errors using orbital understanding: Entity × Traits × Patterns\n\n## Key Principle\n\n\\`\\`\\`\n┌─────────────────────────────────────────────────────────────────────┐\n│ When fixing errors: │\n│ 1. Identify which ORBITAL the error belongs to │\n│ 2. Identify which COMPONENT (entity/trait/page/pattern) │\n│ 3. Apply targeted fix for that component │\n│ │\n│ This gives you CONTEXT that improves fix accuracy. │\n└─────────────────────────────────────────────────────────────────────┘\n\\`\\`\\`\n\n---\n\n${getFixingWorkflowSection()}\n\n${includeEfficiency ? `---\n\n${getEfficiencySection()}` : ''}\n\n---\n\n${getArchitectureSection()}\n\n---\n\n${getSExprQuickRef()}\n\n---\n\n${getRenderUIQuickRef()}\n\n---\n\n${getPatternActionsRef()}\n\n---\n\n${getCommonFixPatternsSection()}\n\n${includeOverGeneration ? `---\n\n${getOverGenerationSection()}` : ''}\n\n---\n\n${getCommonErrorsSection('full')}\n\n---\n\n${getCustomTraitSection()}\n\n${includeSchemaUpdates ? `---\n\n${getSchemaUpdateSection()}` : ''}\n\n---\n\n${getCompletionRulesSection()}\n\n---\n\n## Schema File Rule\n\n\\`\\`\\`\n┌─────────────────────────────────────────────────────────────────────┐\n│ ALWAYS write to: schema.orb │\n│ │\n│ NEVER use other file names like: │\n│ - schema_with_fixes.orb ❌ │\n│ - new_schema.orb ❌ │\n│ - updated_schema.orb ❌ │\n│ │\n│ The persistence system ONLY reads from schema.orb │\n└─────────────────────────────────────────────────────────────────────┘\n\\`\\`\\`\n`;\n}\n\n// ============================================================================\n// Stat Export (for testing)\n// ============================================================================\n\n/**\n * Get skill stats for comparison.\n */\nexport function getLeanFixingSkillStats(options: LeanFixingSkillOptions = {}): { lines: number; chars: number } {\n const skill = generateLeanFixingSkill(options);\n return {\n lines: skill.split('\\n').length,\n chars: skill.length,\n };\n}\n\n/**\n * Get fixing skill metadata.\n */\nexport function getFixingSkillMetadata() {\n return {\n name: 'kflow-orbital-fixing',\n description: 'Fix validation errors using orbital understanding (lean version)',\n version: '2.0.0',\n };\n}\n\n/**\n * Get fixing skill name.\n */\nexport function getFixingSkillName(): string {\n return 'kflow-orbital-fixing';\n}\n","/**\n * KFlow Orbital Fixing Skill Generator\n *\n * Generates the kflow-orbital-fixing skill for fixing validation errors\n * using orbital understanding. Uses the LEAN fixing skill generator from the\n * orbitals module for reduced token usage.\n *\n * @packageDocumentation\n */\n\nimport type { GeneratedSkill } from './types.js';\nimport {\n generateLeanFixingSkill,\n getFixingSkillMetadata,\n} from '../orbitals-skills-generators/lean-fixing-skill-generator.js';\n\n/**\n * Generate the kflow-orbital-fixing skill.\n *\n * Uses the lean generator which:\n * - Shares sections with lean-orbital-skill-generator\n * - Adds fixing-specific workflow and patterns\n * - ~42% smaller than the original generator\n */\nexport function generateKflowOrbitalFixingSkill(): GeneratedSkill {\n const metadata = getFixingSkillMetadata();\n\n const frontmatter = {\n name: metadata.name,\n description: metadata.description,\n allowedTools: ['Read', 'Edit', 'Bash', 'fix_schema_orchestrated', 'query_schema_structure', 'extract_chunk', 'apply_chunk'],\n version: metadata.version,\n };\n\n // Generate lean fixing skill content\n const content = generateLeanFixingSkill({\n includeOverGeneration: true,\n includeSchemaUpdates: true,\n includeEfficiency: true,\n });\n\n return {\n name: metadata.name,\n frontmatter,\n content,\n };\n}\n","/**\n * Domain Language Skill Generator\n *\n * Generates the domain-language skill for understanding, generating,\n * and summarizing KFlow domain language.\n *\n * @packageDocumentation\n */\n\nimport type { GeneratedSkill } from './types.js';\nimport { generateDomainLanguageReference } from '@almadar/core/domain-language';\n\n/**\n * Generate the domain-language skill.\n */\nexport function generateDomainLanguageSkill(): GeneratedSkill {\n const frontmatter = {\n name: 'domain-language',\n description: 'Understand, generate, and summarize KFlow domain language. Convert natural language requirements to domain language and provide human-readable summaries.',\n allowedTools: ['Read', 'Write', 'Edit'],\n version: '1.0.0',\n };\n\n const content = `\n# KFlow Domain Language Skill\n\nThis skill enables you to understand, generate, and summarize KFlow domain language - a human-readable format for defining application schemas.\n\n## What is Domain Language?\n\nDomain language is a structured text format that represents KFlow schemas in a readable way:\n- **Entities** - Data models with fields and relationships\n- **Pages** - UI views with patterns and traits\n- **Behaviors** - State machines and workflows\n\n## Capabilities\n\n### 1. Generate Domain Language from Requirements\n\nConvert natural language requirements into domain language text.\n\n### 2. Summarize Domain Language\n\nCreate human-readable summaries of existing domain language definitions.\n\n### 3. Edit Domain Language\n\nMake targeted edits to existing domain language text.\n\n## Domain Language Reference\n\n${generateDomainLanguageReference()}\n\n## Generation Workflow\n\n### Step 1: Analyze Requirements\n\nExtract key concepts:\n- **Entities** - What data objects are needed?\n- **Fields** - What properties does each entity have?\n- **Pages** - What views are required?\n- **Behaviors** - What workflows or state machines are needed?\n\n### Step 2: Generate Domain Language\n\nUse the syntax reference to create valid domain language:\n\n\\`\\`\\`\nENTITY TaskEntity:\n - title: string (required)\n - description: text\n - status: enum [pending, in_progress, done]\n - dueDate: date\n - assignee: relation -> User\n\nPAGE TaskListPage:\n path: /tasks\n entity: Task\n viewType: list\n sections:\n - header (page-header): title=\"Tasks\"\n - taskList (entity-list): entity=\"Task\", presentation=\"table\"\n traits: []\n\nPAGE TaskCreateForm:\n path: /tasks/new\n entity: Task\n viewType: create\n sections:\n - header (page-header): title=\"Create Task\"\n - form (form-section): entity=\"Task\", layout=\"vertical\"\n - actions (form-actions): submitLabel=\"Create Task\"\n traits: [FormSubmission, FormValidation]\n\\`\\`\\`\n\n### Step 3: Validate Structure\n\nEnsure:\n1. All entities have required fields\n2. Pages reference valid entities\n3. Traits are from the library or properly defined\n4. Section patterns are valid\n\n## Summarization Workflow\n\n### Step 1: Parse Domain Language\n\nIdentify:\n- Number of entities and their purposes\n- Number of pages and their types\n- Key behaviors and workflows\n\n### Step 2: Generate Summary\n\nCreate a concise summary:\n\n**Format:**\n\\`\\`\\`\n**{App Name}** - {one-line description}\n\n**Entities:**\n- {Entity1} - {brief description}\n- {Entity2} - {brief description}\n\n**Pages:**\n- {Page1} ({viewType}) - {purpose}\n- {Page2} ({viewType}) - {purpose}\n\n**Features:**\n- {Key behavior 1}\n- {Key behavior 2}\n\\`\\`\\`\n\n### Summary Requirements\n\n1. Keep it concise (200 words max)\n2. Focus on business functionality\n3. Use bullet points for clarity\n4. Include entity count and page count\n5. Highlight key workflows\n\n## Output Format\n\n### For Generation\n\nOutput ONLY the domain language text - no explanations or commentary.\n\n### For Summary\n\nOutput a structured summary following the format above.\n\n### For Edits\n\nOutput the complete updated domain language text.\n\n## Best Practices\n\n1. **Use library traits** - Prefer existing traits over custom behaviors\n2. **Follow naming conventions** - PascalCase for entities/pages, camelCase for fields\n3. **Include all required fields** - Every entity needs at least one field\n4. **Define page paths** - Use RESTful URL patterns\n5. **Match patterns to view types** - list→entity-list/entity-table, detail→detail-panel, create/edit→form-section\n`.trim();\n\n return {\n name: 'domain-language',\n frontmatter,\n content,\n };\n}\n","/**\n * Lean Orbital Skill Generator\n *\n * Generates kflow-lean-orbitals SKILL.md that:\n * 1. Outputs Domain Language text with S-Expression effects\n * 2. Uses minimal token count (~5x fewer than JSON)\n * 3. Imports from @almadar/* packages for schema knowledge\n *\n * @packageDocumentation\n */\n\n// Inline lean prompts for domain language output\nconst LEAN_CORE_INSTRUCTIONS = `\n## Core Instructions\n\nGenerate orbital schemas using **Domain Language** - a natural, readable format.\n\n**Output Format**: Domain Language text (NOT JSON)\n**Token Efficiency**: ~5x fewer tokens than JSON format\n`;\n\nconst LEAN_OUTPUT_FORMAT = `\n## Output Format\n\nOutput ONLY domain language text. No JSON, no code blocks, no explanations.\n\nExample Output:\n\\`\\`\\`\nA Task is a persistent entity that:\n - has title as text (required)\n - has status as enum [pending, active, done]\n - has dueDate as date\n\nTasksPage at /tasks:\n - shows Task using List behavior\n - view type: list\n\\`\\`\\`\n`;\n\nconst LEAN_VALIDATION_RULES = `\n## Validation\n\n- Every entity needs at least one field\n- Pages must reference valid entities\n- Use standard behaviors from std library\n- S-expressions for guards/effects\n`;\n\nconst LEAN_DECOMPOSITION_PROTOCOL = `\n## Decomposition\n\n1. Identify entities from requirements\n2. Define fields for each entity\n3. Create pages for each entity (list, create, edit)\n4. Apply std behaviors (List, Detail, Form)\n`;\n\nconst ODL_SYNTAX_REFERENCE = `\n## Domain Language Syntax\n\n**Entity**:\n\\`\\`\\`\nA [Name] is a [persistent/runtime/singleton] entity that:\n - has [field] as [type] (required)\n - belongs to [Related]\n - has many [Related]s\n\\`\\`\\`\n\n**Page**:\n\\`\\`\\`\n[PageName] at /[path]:\n - shows [Entity] using [Behavior]\n - view type: [list|detail|create|edit]\n\\`\\`\\`\n`;\n\nconst LEAN_STD_LIST_BEHAVIOR = `\n## List Behavior\n\nUse std/behaviors/crud List behavior for entity browsing.\n`;\n\nconst LEAN_EFFECT_GUARD_SYNTAX = `\n## S-Expressions\n\nUse S-expressions for guards and effects:\n- Guards: \\`[\">\", \"@entity.count\", 0]\\`\n- Effects: \\`[\"set\", \"@entity.field\", value]\\`\n`;\n\nconst LEAN_CRITICAL_RULES = `\n## Critical Rules\n\n1. Use domain language format (NOT JSON)\n2. One page per entity (list view)\n3. Use std behaviors\n`;\n\nconst LEAN_COMMON_ERRORS = `\n## Common Errors\n\n- Don't generate JSON\n- Don't create separate create/edit/view pages\n- Use std behaviors\n`;\n\nconst ODL_PATTERNS = `\n## Patterns\n\nEntity patterns: entity-table, entity-list, entity-cards\nForm patterns: form-section\n`;\n\nconst ODL_TO_SCHEMA_MAPPING = `\n## Mapping\n\nDomain language is converted to OrbitalSchema JSON by the compiler.\n`;\n\nconst LEAN_ERROR_HANDLING = `\n## Error Handling\n\nOutput corrected domain language when errors occur.\n`;\n\n/**\n * Generate the kflow-lean-orbitals SKILL.md content\n */\nexport function generateLeanOrbitalSkill(): string {\n return `---\nname: kflow-lean-orbitals\ndescription: Generate OrbitalSchema applications using Domain Language with S-Expression effects.\nallowed-tools: Read, generate_orbital_domain\nversion: 2.1.0\n---\n\n# kflow-lean-orbitals\n\n> Generate OrbitalSchema applications using Domain Language\n>\n> **Output**: Domain Language text with S-Expression effects\n> **Tools**: \\`generate_orbital_domain\\` (per-orbital generation with auto-persist)\n\n---\n\n${LEAN_CORE_INSTRUCTIONS}\n\n---\n\n${LEAN_DECOMPOSITION_PROTOCOL}\n\n---\n\n${LEAN_STD_LIST_BEHAVIOR}\n\n---\n\n${LEAN_OUTPUT_FORMAT}\n\n---\n\n${ODL_SYNTAX_REFERENCE}\n\n---\n\n${LEAN_EFFECT_GUARD_SYNTAX}\n\n---\n\n${LEAN_CRITICAL_RULES}\n\n---\n\n${LEAN_COMMON_ERRORS}\n\n---\n\n${ODL_PATTERNS}\n\n---\n\n${ODL_TO_SCHEMA_MAPPING}\n\n---\n\n${LEAN_VALIDATION_RULES}\n\n---\n\n${LEAN_ERROR_HANDLING}\n\n---\n\n## Workflow Summary (MANDATORY TOOL USAGE)\n\n⚠️ **CRITICAL: You MUST use \\`generate_orbital_domain\\` for EACH orbital.**\n⚠️ **NEVER use Write/Edit to create domain language directly - always use the tools.**\n\nThe tools handle proper prompting, caching, and S-Expression syntax. Writing directly will fail.\n\n### Phase 1: Decomposition (CRITICAL - NO tool calls yet)\n\n**You MUST decompose the application into orbitals BEFORE calling any tools.**\n\n1. **Classify domain** - business, game, form, dashboard, content\n2. **Identify entities** - List ALL data objects with:\n - Fields (name, type, required, default)\n - Relationships (belongs_to, has_many)\n - Persistence type (persistent, runtime, singleton)\n3. **Resolve cross-references** - Ensure every \"belongs to X\" has entity X planned\n4. **Plan orbitals** - Create a spec for each:\n\n\\`\\`\\`json\n{\n \"name\": \"Task Management\",\n \"entity\": {\n \"name\": \"Task\",\n \"persistence\": \"persistent\",\n \"fields\": [\n { \"name\": \"title\", \"type\": \"text\", \"required\": true },\n { \"name\": \"status\", \"type\": \"enum [todo, done]\", \"default\": \"todo\" }\n ],\n \"relations\": [\n { \"entity\": \"User\", \"type\": \"belongs_to\" }\n ]\n },\n \"pages\": [\n { \"name\": \"TasksPage\", \"path\": \"/tasks\", \"viewType\": \"list\", \"isInitial\": true }\n ],\n \"traits\": [\"TaskManager\"],\n \"patterns\": [\"page-header\", \"entity-table\", \"form-section\", \"detail-panel\"]\n}\n\\`\\`\\`\n\n### Phase 2: Chunked Generation (generate_orbital_domain)\n\nFor EACH orbital spec, call the \\`generate_orbital_domain\\` tool:\n\n\\`\\`\\`json\n{\n \"sessionId\": \"my-app-session\",\n \"orbital\": { ... orbital spec from Phase 1 ... },\n \"orbitalIndex\": 0,\n \"totalOrbitals\": 3\n}\n\\`\\`\\`\n\nThis tool:\n- Uses LLM with proper prompts (S-Expression syntax, patterns, CRUD template)\n- Caches results by fingerprint\n- **Auto-persists**: Each orbital is immediately converted to OrbitalSchema and saved\n\n### Phase 3: Finish\n\nAfter ALL orbitals are generated, call \\`finish_task\\` to complete the workflow.\n\nNo manual merging needed - the schema is built incrementally as each orbital is generated.\n\n---\n\n## Tool Reference\n\n### generate_orbital_domain\n\nGenerate domain language for ONE orbital using LLM with proper prompts.\n\n**Input:**\n- \\`sessionId\\`: Unique session ID for this batch\n- \\`orbital\\`: Orbital spec (entity, pages, traits, patterns)\n- \\`orbitalIndex\\`: Position in batch (0-based)\n- \\`totalOrbitals\\`: Total orbitals being generated\n\n**Output:**\n- \\`success\\`: Whether generation succeeded\n- \\`domainText\\`: Generated domain language\n- \\`cached\\`: Whether result was from cache\n- \\`usage\\`: Token usage\n- \\`schema\\`: The orbital converted to OrbitalSchema (auto-persisted)\n\n---\n\n## Complete Example\n\n**User**: Create a task management app\n\n**Assistant** writes domain.txt:\n\\`\\`\\`\n# Entities\n\nA Task is a persistent entity that:\n - has title as text (required)\n - has description as long text\n - has status as enum [todo, in_progress, done] with default \"todo\"\n - has priority as enum [low, medium, high] with default \"medium\"\n - has dueDate as date\n\n# Pages\n\nTasksPage at /tasks:\n - shows Task using TaskManager\n - view type: list\n - is initial page\n\n# Behaviors\n\nTaskManager behavior:\n Entity: Task\n States: Browsing, Creating, Viewing, Editing, Deleting\n Initial: Browsing\n\n Transitions:\n - From Browsing to Browsing on INIT\n then [\"render-ui\", \"main\", {\"type\": \"page-header\", \"title\": \"Tasks\", \"actions\": [{\"label\": \"New Task\", \"event\": \"CREATE\", \"variant\": \"primary\"}]}]\n then [\"render-ui\", \"center\", {\"type\": \"entity-table\", \"entity\": \"Task\", \"columns\": [\"title\", \"status\", \"priority\", \"dueDate\"], \"itemActions\": [{\"label\": \"View\", \"event\": \"VIEW\"}, {\"label\": \"Edit\", \"event\": \"EDIT\"}, {\"label\": \"Delete\", \"event\": \"DELETE\", \"variant\": \"danger\"}]}]\n\n - From Browsing to Creating on CREATE\n then [\"render-ui\", \"modal\", {\"type\": \"form-section\", \"entity\": \"Task\", \"fields\": [\"title\", \"description\", \"status\", \"priority\", \"dueDate\"], \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\"}]\n\n - From Creating to Browsing on SAVE\n then [\"persist\", \"create\", \"Task\", \"@payload.data\"]\n then [\"render-ui\", \"modal\", null]\n then [\"emit\", \"INIT\"]\n\n - From Creating to Browsing on CANCEL\n then [\"render-ui\", \"modal\", null]\n\n - From Browsing to Viewing on VIEW\n then [\"render-ui\", \"drawer\", {\"type\": \"detail-panel\", \"entity\": \"Task\", \"fields\": [\"title\", \"description\", \"status\", \"priority\", \"dueDate\"], \"actions\": [{\"label\": \"Edit\", \"event\": \"EDIT\"}, {\"label\": \"Delete\", \"event\": \"DELETE\", \"variant\": \"danger\"}]}]\n\n - From Viewing to Editing on EDIT\n then [\"render-ui\", \"drawer\", null]\n then [\"render-ui\", \"modal\", {\"type\": \"form-section\", \"entity\": \"Task\", \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\"}]\n\n - From Browsing to Editing on EDIT\n then [\"render-ui\", \"modal\", {\"type\": \"form-section\", \"entity\": \"Task\", \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\"}]\n\n - From Editing to Browsing on SAVE\n then [\"persist\", \"update\", \"Task\", \"@payload.data\"]\n then [\"render-ui\", \"modal\", null]\n then [\"emit\", \"INIT\"]\n\n - From Editing to Browsing on CANCEL\n then [\"render-ui\", \"modal\", null]\n\n - From Viewing to Browsing on CANCEL\n then [\"render-ui\", \"drawer\", null]\n\n - From Browsing to Deleting on DELETE\n then [\"render-ui\", \"overlay\", {\"type\": \"confirmation\", \"title\": \"Delete Task?\", \"message\": \"This action cannot be undone.\"}]\n\n - From Viewing to Deleting on DELETE\n then [\"render-ui\", \"drawer\", null]\n then [\"render-ui\", \"overlay\", {\"type\": \"confirmation\", \"title\": \"Delete Task?\", \"message\": \"This action cannot be undone.\"}]\n\n - From Deleting to Browsing on CONFIRM_DELETE\n then [\"persist\", \"delete\", \"Task\"]\n then [\"render-ui\", \"overlay\", null]\n then [\"emit\", \"INIT\"]\n\n - From Deleting to Browsing on CANCEL\n then [\"render-ui\", \"overlay\", null]\n\\`\\`\\`\n\n**Key points in this example:**\n- **Entity: Task** explicitly links the behavior to the Task entity (REQUIRED)\n- INIT renders BOTH page-header (with \"New Task\" action) AND entity-table (with View/Edit/Delete itemActions)\n- All effects use S-Expression format\n- Modal for create/edit, drawer for view, overlay for delete confirmation\n- Each open slot is closed with \\`null\\` when done\n- SAVE emits INIT to refresh the list\n`;\n}\n\n/**\n * Get the skill metadata\n */\nexport function getLeanOrbitalSkillMetadata() {\n return {\n name: 'kflow-lean-orbitals',\n description: 'Generate OrbitalSchema applications using Domain Language with S-Expression effects',\n category: 'orbital',\n priority: 'high',\n outputFormat: 'domain-language',\n };\n}\n","/**\n * Lean Fixing Skill Generator\n *\n * Generates kflow-lean-fixing SKILL.md for fixing validation errors\n * using Domain Language format.\n *\n * @packageDocumentation\n */\n\n// Inline lean prompts\nconst LEAN_CORE_INSTRUCTIONS = `\n## Core Instructions\n\nFix validation errors by outputting corrected Domain Language text.\n`;\n\nconst LEAN_ERROR_HANDLING = `\n## Error Handling\n\n1. Read the error message carefully\n2. Locate the problematic section\n3. Output corrected domain language\n`;\n\nconst LEAN_VALIDATION_RULES = `\n## Validation Rules\n\n- Required fields must be marked\n- Entity references must be valid\n- Page paths must be unique\n- Behaviors must be from std library\n`;\n\nconst ODL_SYNTAX_REFERENCE = `\n## Domain Language Syntax\n\nSee kflow-lean-orbitals skill for full syntax reference.\n`;\n\nconst LEAN_EFFECT_GUARD_SYNTAX = `\n## S-Expressions\n\nUse S-expressions in domain language for guards and effects.\n`;\n\nconst ODL_TO_SCHEMA_MAPPING = `\n## Schema Mapping\n\nDomain language maps to OrbitalSchema JSON structure.\n`;\n\n/**\n * Generate the kflow-lean-fixing SKILL.md content\n */\nexport function generateLeanFixingSkill(): string {\n return `---\nname: kflow-lean-fixing\ndescription: Fix OrbitalSchema validation errors using Domain Language format.\nallowed-tools: Read, Write, Edit\nversion: 1.0.0\n---\n\n# kflow-lean-fixing\n\n> Fix OrbitalSchema validation errors using Domain Language\n>\n> **Input**: Validation errors + current ODL\n> **Output**: Fixed Domain Language sections\n\n---\n\n${LEAN_CORE_INSTRUCTIONS}\n\n---\n\n## Error Fixing Protocol\n\n1. **Parse error code** - Identify the error type (ORB_E_*, ORB_T_*, etc.)\n2. **Locate section** - Find the corresponding ODL section\n3. **Apply fix** - Correct the issue in ODL format\n4. **Output fixed section only** - Don't re-output unchanged sections\n\n---\n\n${LEAN_ERROR_HANDLING}\n\n---\n\n## Common Fixes\n\n### ORB_E_MISSING_NAME\n**Error**: Entity missing name\n**Fix**: Ensure entity definition starts with \"A [Name] is...\"\n\nBefore:\n\\`\\`\\`\nis a persistent entity that:\n - has title as text\n\\`\\`\\`\n\nAfter:\n\\`\\`\\`\nA Task is a persistent entity that:\n - has title as text\n\\`\\`\\`\n\n### ORB_E_NO_FIELDS\n**Error**: Entity has no fields\n**Fix**: Add at least one field definition\n\nBefore:\n\\`\\`\\`\nA Task is a persistent entity that:\n\\`\\`\\`\n\nAfter:\n\\`\\`\\`\nA Task is a persistent entity that:\n - has title as text (required)\n\\`\\`\\`\n\n### ORB_T_NO_INITIAL_STATE\n**Error**: Behavior has no initial state\n**Fix**: Add \"Initial: [StateName]\" line\n\nBefore:\n\\`\\`\\`\nTaskManager behavior:\n States: Viewing, Editing\n\n Transitions:\n ...\n\\`\\`\\`\n\nAfter:\n\\`\\`\\`\nTaskManager behavior:\n States: Viewing, Editing\n Initial: Viewing\n\n Transitions:\n ...\n\\`\\`\\`\n\n### ORB_T_INVALID_TRANSITION\n**Error**: Transition references non-existent state\n**Fix**: Ensure From/To states exist in States list\n\nBefore:\n\\`\\`\\`\nTaskManager behavior:\n States: Viewing, Editing\n Initial: Viewing\n\n Transitions:\n - From Viewing to Creating on CREATE # 'Creating' not in States\n\\`\\`\\`\n\nAfter:\n\\`\\`\\`\nTaskManager behavior:\n States: Viewing, Editing, Creating # Added Creating\n Initial: Viewing\n\n Transitions:\n - From Viewing to Creating on CREATE\n\\`\\`\\`\n\n### ORB_P_NO_PATH\n**Error**: Page has no path\n**Fix**: Add \"at /[path]\" to page definition\n\nBefore:\n\\`\\`\\`\nTasksPage:\n - shows Task using TaskManager\n\\`\\`\\`\n\nAfter:\n\\`\\`\\`\nTasksPage at /tasks:\n - shows Task using TaskManager\n\\`\\`\\`\n\n### ORB_E_INVALID_RELATION\n**Error**: Relation references non-existent entity\n**Fix**: Ensure target entity is defined\n\nBefore:\n\\`\\`\\`\nA Task is a persistent entity that:\n - belongs to Project # Project not defined\n\\`\\`\\`\n\nAfter (add missing entity):\n\\`\\`\\`\nA Project is a persistent entity that:\n - has name as text (required)\n\nA Task is a persistent entity that:\n - belongs to Project\n\\`\\`\\`\n\n---\n\n${ODL_SYNTAX_REFERENCE}\n\n---\n\n${LEAN_EFFECT_GUARD_SYNTAX}\n\n---\n\n${LEAN_VALIDATION_RULES}\n\n---\n\n${ODL_TO_SCHEMA_MAPPING}\n\n---\n\n## Output Format\n\n**IMPORTANT**: Always write your fixes to \\`domain.txt\\` using the Write or Edit tool.\n\n1. If \\`domain.txt\\` exists, use the Edit tool to modify it\n2. If it doesn't exist, use the Write tool to create it\n3. The file must contain the COMPLETE domain language with your fixes applied\n4. Do NOT just output text to the chat - you must write to the file\n\nWhen fixing errors:\n- Read the existing domain.txt (if present)\n- Apply fixes to the affected sections\n- Write the complete fixed content to domain.txt\n- Confirm the changes were applied\n\nExample workflow:\n1. Read domain.txt to understand current structure\n2. Edit the specific section that has errors\n3. Verify the fix by reading the file again\n`;\n}\n\n/**\n * Get the skill metadata\n */\nexport function getLeanFixingSkillMetadata() {\n return {\n name: 'kflow-lean-fixing',\n description: 'Fix OrbitalSchema validation errors using Domain Language',\n category: 'orbital',\n priority: 'high',\n outputFormat: 'domain-language',\n };\n}\n","/**\n * Skill Generators for Builder Client\n *\n * Re-exports the 5 core skills used by the builder client:\n * 1. kflow-orbitals (standard JSON generation with atomic composition)\n * 2. kflow-orbital-fixing (standard fixing)\n * 3. kflow-lean-orbitals (lean domain language generation)\n * 4. kflow-lean-fixing (lean fixing)\n * 5. domain-language (ODL understanding/summarization)\n *\n * @packageDocumentation\n */\n\n// Types\nexport type { SkillFrontmatter, GeneratedSkill } from './types.js';\n\n// Utilities\nexport { formatFrontmatter, writeSkill, writeAllSkills } from './utils.js';\n\n// Core skills used by builder client\nexport { generateKflowOrbitalsSkill } from './kflow-orbitals.js';\nexport { generateKflowOrbitalFixingSkill } from './kflow-orbital-fixing.js';\nexport { generateDomainLanguageSkill } from './domain-language.js';\n\n// Lean skills (domain language output)\nexport { generateLeanOrbitalSkill } from '../orbitals-skills-generators/lean/lean-orbital-generator.js';\nexport { generateLeanFixingSkill } from '../orbitals-skills-generators/lean/lean-fixing-generator.js';\n\n// Orbital skill generators (used by kflow-orbitals and kflow-orbital-fixing)\nexport { generateLeanOrbitalSkill as generateLeanOrbitalSkillFull } from '../orbitals-skills-generators/lean-orbital-skill-generator.js';\nexport { generateLeanFixingSkill as generateLeanFixingSkillFull } from '../orbitals-skills-generators/lean-fixing-skill-generator.js';\n\n// Import generators for generateAllBuilderSkills\nimport type { GeneratedSkill } from './types.js';\nimport { generateKflowOrbitalsSkill } from './kflow-orbitals.js';\nimport { generateKflowOrbitalFixingSkill } from './kflow-orbital-fixing.js';\nimport { generateDomainLanguageSkill } from './domain-language.js';\nimport { generateLeanOrbitalSkill } from '../orbitals-skills-generators/lean/lean-orbital-generator.js';\nimport { generateLeanFixingSkill } from '../orbitals-skills-generators/lean/lean-fixing-generator.js';\n\n/**\n * Generate all builder client skills.\n * These are the 5 skills actually used by the builder UI.\n */\nexport function generateAllBuilderSkills(): GeneratedSkill[] {\n return [\n generateKflowOrbitalsSkill(),\n generateKflowOrbitalFixingSkill(),\n {\n name: 'kflow-lean-orbitals',\n frontmatter: {\n name: 'kflow-lean-orbitals',\n description: 'Generate schemas using Domain Language (~5x fewer tokens)',\n allowedTools: ['Read', 'Write', 'Edit'],\n },\n content: generateLeanOrbitalSkill(),\n },\n {\n name: 'kflow-lean-fixing',\n frontmatter: {\n name: 'kflow-lean-fixing',\n description: 'Fix validation errors using Domain Language',\n allowedTools: ['Read', 'Write', 'Edit'],\n },\n content: generateLeanFixingSkill(),\n },\n generateDomainLanguageSkill(),\n ];\n}\n","/**\n * Type References\n *\n * Auto-generated type reference sections from @almadar packages.\n * Used to compose generation prompts.\n *\n * @packageDocumentation\n */\n\nimport { getAllPatternTypes, getPatternPropsCompact } from '@almadar/patterns';\nimport { OPERATORS } from '@almadar/core/types';\nimport { UI_SLOTS } from '@almadar/core/types';\n\n/**\n * Get minimal type reference for orbital schemas.\n * Covers entities, traits, pages, and basic structure.\n */\nexport function getMinimalTypeReference(): string {\n return `\n## Orbital Schema Structure\n\n\\`\\`\\`typescript\ninterface OrbitalDefinition {\n name: string; // Entity name (PascalCase)\n entity: Entity; // Data model\n traits: TraitRef[]; // State machines (names or definitions)\n pages: Page[]; // Routes and views\n emits?: string[]; // Events this orbital emits\n listens?: EventListener[]; // Events this orbital listens to\n}\n\\`\\`\\`\n\n### Entity Fields\n\n\\`\\`\\`typescript\n{ name: \"title\", type: \"string\", required: true }\n{ name: \"count\", type: \"number\", default: 0 }\n{ name: \"status\", type: \"enum\", values: [\"pending\", \"active\", \"done\"] }\n{ name: \"dueDate\", type: \"date\" }\n\\`\\`\\`\n\n### Trait State Machine\n\n\\`\\`\\`typescript\n{\n states: [{ name: \"Idle\", isInitial: true }, { name: \"Active\" }],\n events: [\"INIT\", \"ACTIVATE\", \"COMPLETE\"],\n transitions: [\n { from: \"Idle\", to: \"Active\", event: \"ACTIVATE\",\n guards: [[\"condition\"]],\n effects: [[\"action\"]] }\n ]\n}\n\\`\\`\\`\n`.trim();\n}\n\n/**\n * Get compact pattern types listing.\n */\nexport function getPatternTypesCompact(): string {\n const patterns = getAllPatternTypes();\n return `\n## Available Pattern Types\n\n${patterns.map(p => `- \\`${p}\\``).join('\\n')}\n\n${getPatternPropsCompact()}\n`.trim();\n}\n\n/**\n * Get S-Expression quick reference.\n */\nexport function getSExprQuickRef(): string {\n const operators = Object.keys(OPERATORS).slice(0, 15); // First 15 operators\n\n return `\n## S-Expression Quick Reference\n\n### Guard Expressions (Conditions)\n\n\\`\\`\\`typescript\n[\"=\", \"@entity.status\", \"active\"] // Equality\n[\">\", \"@entity.count\", 0] // Greater than\n[\"and\", [\"cond1\"], [\"cond2\"]] // Logical AND\n[\"or\", [\"cond1\"], [\"cond2\"]] // Logical OR\n[\"not\", [\"condition\"]] // Logical NOT\n\\`\\`\\`\n\n### Effect Expressions (Actions)\n\n\\`\\`\\`typescript\n[\"set\", \"@entity.field\", value] // Update field\n[\"emit\", \"EVENT_NAME\", payload] // Emit event\n[\"navigate\", \"/path\"] // Navigate to route\n[\"render-ui\", \"main\", { type, props }] // Render pattern\n[\"persist\", \"create\", \"Entity\", data] // Database operation\n\\`\\`\\`\n\n### Available Operators\n\n${operators.map(op => `- \\`${op}\\``).join('\\n')}\n`.trim();\n}\n\n/**\n * Get render-ui quick reference.\n */\nexport function getRenderUIQuickRef(): string {\n const slots = UI_SLOTS;\n\n return `\n## Render-UI Effect Reference\n\n### Syntax\n\n\\`\\`\\`typescript\n[\"render-ui\", slot, patternConfig | null]\n\\`\\`\\`\n\n### UI Slots\n\n${slots.map(slot => `- \\`${slot}\\``).join('\\n')}\n\n### Example\n\n\\`\\`\\`typescript\n[\"render-ui\", \"main\", {\n type: \"entity-table\",\n entity: \"Task\",\n columns: [\"title\", \"status\"],\n itemActions: [{ label: \"Edit\", event: \"EDIT\" }]\n}]\n\\`\\`\\`\n\nClear slot: \\`[\"render-ui\", \"modal\", null]\\`\n`.trim();\n}\n\n/**\n * Get field types compact reference.\n */\nexport function getFieldTypesCompact(): string {\n return `\n## Field Types\n\n| Type | Example | Notes |\n|------|---------|-------|\n| \\`string\\` | \\`{ name: \"title\", type: \"string\" }\\` | Text |\n| \\`number\\` | \\`{ name: \"count\", type: \"number\" }\\` | Integer or float |\n| \\`boolean\\` | \\`{ name: \"active\", type: \"boolean\" }\\` | true/false |\n| \\`date\\` | \\`{ name: \"birthday\", type: \"date\" }\\` | Date only |\n| \\`timestamp\\` | \\`{ name: \"createdAt\", type: \"timestamp\" }\\` | Date + time |\n| \\`enum\\` | \\`{ name: \"status\", type: \"enum\", values: [\"a\", \"b\"] }\\` | Fixed options |\n| \\`array\\` | \\`{ name: \"tags\", type: \"array\", items: \"string\" }\\` | List |\n| \\`relation\\` | \\`{ name: \"user\", type: \"relation\", relation: { entity: \"User\", cardinality: \"one\" } }\\` | Foreign key |\n\n### Field Properties\n\n- \\`required: true\\` - Must have value\n- \\`default: value\\` - Default value\n- \\`unique: true\\` - Must be unique\n`.trim();\n}\n","/**\n * Generation Prompts\n *\n * Prompts for the generateFullOrbital() function composed from reusable skill sections.\n * These are used by @almadar/agent for programmatic orbital generation.\n *\n * @packageDocumentation\n */\n\nimport { getArchitectureSection } from './skill-sections/architecture.js';\nimport { getDecompositionSection, getDecompositionChecklist } from './skill-sections/decomposition.js';\nimport { getCommonErrorsSection, getValidationHintsSection } from './skill-sections/common-errors.js';\nimport { getCustomTraitSection } from './skill-sections/custom-traits.js';\nimport { getUsesImportSection } from './skill-sections/uses-imports.js';\nimport {\n getMinimalTypeReference,\n getPatternTypesCompact,\n getSExprQuickRef,\n getRenderUIQuickRef,\n getFieldTypesCompact,\n} from './type-references.js';\n\n/**\n * Get prompt for decomposing a request into orbital units.\n * Used by the main agent before calling generateFullOrbital on each unit.\n */\nexport function getOrbitalDecompositionPrompt(): string {\n return `\n## Orbital Unit Decomposition Protocol\n\n${getArchitectureSection()}\n\n---\n\n${getDecompositionSection()}\n\n---\n\n${getDecompositionChecklist()}\n\n---\n\n## Pattern Selection\n\n${getPatternTypesCompact()}\n\n---\n\n${getValidationHintsSection()}\n`.trim();\n}\n\n/**\n * Get prompt for expanding a lightweight orbital into a full orbital.\n * This is the main prompt used by generateFullOrbital().\n */\nexport function getFullOrbitalPrompt(): string {\n return `\n# Subagent: Expand Lightweight Orbital to Full Orbital\n\nYou receive a lightweight OrbitalDefinition and must expand it into a complete FullOrbitalUnit with traits, state machines, and UI.\n\n---\n\n${getArchitectureSection()}\n\n---\n\n${getMinimalTypeReference()}\n\n---\n\n${getSExprQuickRef()}\n\n---\n\n${getRenderUIQuickRef()}\n\n---\n\n${getFieldTypesCompact()}\n\n---\n\n${getCustomTraitSection()}\n\n---\n\n${getUsesImportSection()}\n\n---\n\n${getCommonErrorsSection()}\n\n---\n\n## Output Format\n\nReturn ONLY valid JSON matching the FullOrbitalUnit structure. No markdown, no explanations.\n\n**CRITICAL: The entity field is REQUIRED at the orbital level:**\n\n\\`\\`\\`json\n{\n \"name\": \"Product Management\",\n \"entity\": { // ← REQUIRED: Must have this field\n \"name\": \"Product\",\n \"collection\": \"products\",\n \"persistence\": \"persistent\",\n \"fields\": [\n { \"name\": \"name\", \"type\": \"string\", \"required\": true },\n { \"name\": \"price\", \"type\": \"number\" }\n ]\n },\n \"traits\": [ ... ],\n \"pages\": [ ... ]\n}\n\\`\\`\\`\n\n**Validation Rules:**\n- MUST include \"entity\" field at orbital level (NOT just linkedEntity in traits)\n- entity.name must match the orbital's primary entity\n- entity.collection must be plural lowercase (e.g., \"products\", not \"Product\")\n- entity.fields must have at least one field\n\n**Common Mistake:**\n- ❌ WRONG: Only putting entity reference in trait.linkedEntity\n- ✅ CORRECT: Full entity object in orbital.entity field\n`.trim();\n}\n\n/**\n * Get prompt for requirements-aware decomposition.\n * Used when extracted requirements are available from analysis phase.\n */\nexport function getRequirementsDecomposePrompt(): string {\n return `\n## Requirements-Aware Decomposition\n\nWhen decomposing with extracted requirements, use them to improve orbital identification:\n\n### Using Entity Requirements\n\nFor each entity in \\`requirements.entities\\`:\n- Create one OrbitalUnit per **primary** entity\n- Group related entities (e.g., Order + OrderItem in same orbital)\n- Consider entity relationships when grouping\n\n### Using State Requirements\n\nFor each state in \\`requirements.states\\`:\n- Identify which entity lifecycle it belongs to\n- Create states in that entity's trait state machine\n\n### Using Event Requirements\n\nFor each event in \\`requirements.events\\`:\n- Map to trait events (UPPERCASE)\n- Connect to appropriate transitions\n\n### Using Guard Requirements\n\nFor each guard in \\`requirements.guards\\`:\n- Identify which entity the guard applies to\n- Include guard description in that entity's orbital\n- The subagent will convert to guard expression\n\n### Using Effect Requirements\n\nFor each effect in \\`requirements.effects\\`:\n- Identify the trigger (e.g., \"on confirmation\")\n- Identify the action (e.g., \"send email\")\n- Include in relevant orbital's effects list\n\n${getValidationHintsSection()}\n`.trim();\n}\n\n/**\n * Get prompt for generating traits from requirements.\n * Used when requirements need to be converted to trait state machines.\n */\nexport function getRequirementsTraitPrompt(): string {\n return `\n## Generating Traits from Requirements\n\nWhen generating a FullOrbitalUnit, convert requirements to schema elements:\n\n### Guard Patterns\n\nCommon guard patterns to recognize:\n\n| Requirement | Guard Expression |\n|-------------|-----------------|\n| \"only managers can approve\" | \\`[\"=\", \"@context.user.role\", \"manager\"]\\` |\n| \"amount must be positive\" | \\`[\">\", \"@entity.amount\", 0]\\` |\n| \"if status is pending\" | \\`[\"=\", \"@entity.status\", \"pending\"]\\` |\n| \"user is authenticated\" | \\`[\"=\", \"@context.user.authenticated\", true]\\` |\n\n### Effect Patterns\n\nCommon effect patterns to recognize:\n\n| Requirement | Effect Type | Template |\n|-------------|------------|----------|\n| \"send email\" | \\`emit\\` | \\`[\"emit\", \"EMAIL_SEND\", { \"to\": \"...\", \"subject\": \"...\" }]\\` |\n| \"update status\" | \\`set\\` | \\`[\"set\", \"@entity.status\", \"newValue\"]\\` |\n| \"navigate to page\" | \\`navigate\\` | \\`[\"navigate\", \"/page\"]\\` |\n| \"show notification\" | \\`emit\\` | \\`[\"emit\", \"NOTIFY\", { \"message\": \"...\" }]\\` |\n\n### State Machine Construction\n\n1. Extract states from requirements.states\n2. Create events for state transitions (UPPERCASE)\n3. Add transitions with appropriate guards\n4. Include render-ui effects for each state\n\n${getCommonErrorsSection()}\n`.trim();\n}\n","/**\n * Behaviors Reference\n *\n * Helper for generating standard behaviors documentation from @almadar/std.\n *\n * @packageDocumentation\n */\n\nimport { generateBehaviorsDocs } from '@almadar/std';\n\n/**\n * Get key behaviors reference (compact).\n * Uses @almadar/std to generate the behaviors documentation.\n */\nexport function getKeyBehaviorsReference(): string {\n const behaviorsDocs = generateBehaviorsDocs();\n\n return `## Key Standard Behaviors\n\n${behaviorsDocs.categories.map(cat => `### ${cat.name}\n${cat.behaviors.map(b => `- **${b.name}**: ${b.description}`).join('\\n')}\n`).join('\\n')}\n\nUse with: \\`uses: [{ from: \"std/behaviors/crud\", as: \"CRUD\" }]\\`\n`;\n}\n","/**\n * Composition Quality Evaluation Framework\n *\n * Evaluates LLM providers' ability to generate sophisticated render-ui effects\n * that meet the Five Rules of Sophisticated Composition.\n *\n * @packageDocumentation\n */\n\nimport type { OrbitalSchema } from '@almadar/core';\n\nexport interface EvalCase {\n name: string;\n description: string;\n prompt: string;\n expectedPatterns: string[];\n minScore: number;\n domain: 'general' | 'healthcare' | 'ecommerce' | 'project-management';\n rubric?: {\n structure: Record<string, number>;\n composition: Record<string, number>;\n theme: Record<string, number>;\n quality: Record<string, number>;\n };\n}\n\nexport interface EvalResult {\n caseName: string;\n provider: string;\n score: number;\n passed: boolean;\n breakdown: ScoreBreakdown;\n validationErrors: string[];\n validationWarnings: string[];\n schema?: OrbitalSchema;\n}\n\nexport interface ScoreBreakdown {\n structure: number; // 25 points max\n composition: number; // 25 points max\n theme: number; // 25 points max\n quality: number; // 25 points max\n}\n\nexport interface CompositionMetrics {\n renderUICount: number;\n atomTypes: string[];\n moleculeTypes: string[];\n organismTypes: string[];\n layoutRoot: string | null;\n nestingDepth: number;\n sectionCount: number;\n themeVariableUsage: number; // percentage\n hardcodedValues: string[];\n}\n\n// ============================================================================\n// Test Cases\n// ============================================================================\n\nexport const EVAL_CASES: EvalCase[] = [\n {\n name: \"task-management-basic\",\n description: \"Generate a basic task management view with CRUD\",\n prompt: `Generate an Orbital schema for a task management app.\n \nEntity: Task with fields: title (string, required), status (enum: pending/active/done), priority (enum: low/medium/high)\n\nRequirements:\n- List view with search and actions (view, edit, delete)\n- Modal form for creating tasks\n- Use atomic composition with stack layouts\n- Include stats/overview section showing counts`,\n expectedPatterns: ['stack', 'page-header', 'entity-table', 'form-section', 'box', 'typography', 'badge', 'button'],\n minScore: 70,\n domain: 'general'\n },\n {\n name: \"patient-portal-dashboard\",\n description: \"Generate a healthcare patient portal dashboard\",\n prompt: `Generate an Orbital schema for a healthcare patient portal.\n\nEntities:\n- Patient: name, dateOfBirth, medicalRecordNumber, insuranceStatus\n- Appointment: date, time, doctor, status, notes\n\nRequirements:\n- Dashboard with patient statistics (total, active, critical)\n- Patient list with filters by status\n- Appointment scheduling view\n- Use healthcare-appropriate layouts (calm, organized)\n- Include tabs for different views`,\n expectedPatterns: ['stack', 'grid', 'page-header', 'entity-table', 'tabs', 'badge', 'card', 'stats'],\n minScore: 75,\n domain: 'healthcare'\n },\n {\n name: \"ecommerce-product-catalog\",\n description: \"Generate an e-commerce product catalog\",\n prompt: `Generate an Orbital schema for an e-commerce product catalog.\n\nEntities:\n- Product: name, price, category, stockLevel, rating, imageUrl\n- Category: name, description\n\nRequirements:\n- Product grid with cards (use grid layout)\n- Filters by category and price range\n- Product detail view with image\n- Shopping cart indicator\n- Use product-appropriate layouts (visual, appealing)`,\n expectedPatterns: ['stack', 'grid', 'entity-cards', 'filter-group', 'badge', 'card', 'image'],\n minScore: 75,\n domain: 'ecommerce'\n },\n {\n name: \"project-management-kanban\",\n description: \"Generate a project management kanban board\",\n prompt: `Generate an Orbital schema for a project management kanban board.\n\nEntities:\n- Project: name, status, deadline, progress, owner\n- Task: title, status (todo/in-progress/done), assignee, priority, dueDate\n\nRequirements:\n- Kanban board with columns for each status\n- Task cards with drag-drop feel (visual design)\n- Project overview with progress bars\n- Team member avatars\n- Due date indicators`,\n expectedPatterns: ['stack', 'grid', 'card', 'progress-bar', 'avatar', 'badge', 'page-header'],\n minScore: 80,\n domain: 'project-management'\n },\n {\n name: \"analytics-dashboard\",\n description: \"Generate an analytics dashboard with charts\",\n prompt: `Generate an Orbital schema for an analytics dashboard.\n\nEntities:\n- Metric: name, value, change, trend\n- Report: title, date, type, status\n\nRequirements:\n- Stats cards with trend indicators (up/down)\n- Chart visualization area\n- Recent reports list\n- Date range selector\n- Professional, data-dense layout`,\n expectedPatterns: ['stack', 'grid', 'stats', 'chart', 'entity-table', 'badge', 'card'],\n minScore: 75,\n domain: 'general'\n }\n];\n\n// ============================================================================\n// Scoring Functions\n// ============================================================================\n\n/**\n * Analyze the composition metrics of a schema.\n */\nexport function analyzeComposition(schema: OrbitalSchema): CompositionMetrics {\n const metrics: CompositionMetrics = {\n renderUICount: 0,\n atomTypes: [],\n moleculeTypes: [],\n organismTypes: [],\n layoutRoot: null,\n nestingDepth: 0,\n sectionCount: 0,\n themeVariableUsage: 0,\n hardcodedValues: []\n };\n\n // Traverse all transitions\n for (const orbital of schema.orbitals) {\n for (const trait of orbital.traits) {\n // Skip trait refs - we need full trait definitions with stateMachine\n const t = trait as any;\n if (!t.stateMachine?.transitions) continue;\n \n for (const transition of t.stateMachine.transitions) {\n if (!transition.effects) continue;\n \n for (const effect of transition.effects) {\n if (!Array.isArray(effect)) continue;\n if (effect[0] !== 'render-ui') continue;\n \n metrics.renderUICount++;\n const pattern = effect[2];\n \n if (pattern && typeof pattern === 'object') {\n analyzePattern(pattern, metrics, 0);\n }\n }\n }\n }\n }\n\n // Calculate theme variable usage\n const totalValues = metrics.atomTypes.length + metrics.moleculeTypes.length + metrics.organismTypes.length;\n if (totalValues > 0) {\n // This is a simplified calculation - in practice, we'd check all props\n metrics.themeVariableUsage = 100 - (metrics.hardcodedValues.length / totalValues * 100);\n }\n\n return metrics;\n}\n\nfunction analyzePattern(pattern: any, metrics: CompositionMetrics, depth: number): void {\n if (!pattern || typeof pattern !== 'object') return;\n\n // Track nesting depth\n metrics.nestingDepth = Math.max(metrics.nestingDepth, depth);\n\n // Check if this is the root layout\n if (depth === 0 && ['stack', 'box', 'container', 'grid'].includes(pattern.type)) {\n metrics.layoutRoot = pattern.type;\n }\n\n // Categorize pattern types\n const atomTypes = ['typography', 'badge', 'button', 'avatar', 'icon', 'progress-bar', 'divider'];\n const moleculeTypes = ['card', 'modal', 'drawer', 'tabs', 'alert', 'accordion', 'box'];\n const organismTypes = ['entity-table', 'form-section', 'detail-panel', 'page-header', 'chart', 'timeline', 'stats'];\n\n if (atomTypes.includes(pattern.type) && !metrics.atomTypes.includes(pattern.type)) {\n metrics.atomTypes.push(pattern.type);\n }\n if (moleculeTypes.includes(pattern.type) && !metrics.moleculeTypes.includes(pattern.type)) {\n metrics.moleculeTypes.push(pattern.type);\n }\n if (organismTypes.includes(pattern.type) && !metrics.organismTypes.includes(pattern.type)) {\n metrics.organismTypes.push(pattern.type);\n }\n\n // Check for hardcoded values\n for (const [key, value] of Object.entries(pattern)) {\n if (typeof value === 'string') {\n if (value.startsWith('#') || /^\\d+px$/.test(value) || ['white', 'black', 'red', 'blue'].includes(value.toLowerCase())) {\n metrics.hardcodedValues.push(`${key}: ${value}`);\n }\n }\n }\n\n // Count sections (children at depth 1)\n if (depth === 1 && pattern.type) {\n metrics.sectionCount++;\n }\n\n // Recurse into children\n if (pattern.children && Array.isArray(pattern.children)) {\n for (const child of pattern.children) {\n analyzePattern(child, metrics, depth + 1);\n }\n }\n}\n\n/**\n * Score the structure category (25 points max)\n */\nexport function scoreStructure(metrics: CompositionMetrics, schema: OrbitalSchema): number {\n let score = 0;\n\n // Single render-ui per transition (5 points)\n // This is checked by counting render-ui effects per transition\n const transitions = countTransitions(schema);\n if (metrics.renderUICount <= transitions) {\n score += 5;\n }\n\n // Layout root present (5 points)\n if (metrics.layoutRoot) {\n score += 5;\n }\n\n // Proper nesting depth (5 points)\n if (metrics.nestingDepth >= 3) {\n score += 5;\n } else if (metrics.nestingDepth >= 2) {\n score += 3;\n }\n\n // Validation passed (5 points)\n // This is checked separately and added after validation\n score += 5;\n\n // Closed circuit pattern (5 points)\n // All states have entry/exit transitions\n if (hasClosedCircuit(schema)) {\n score += 5;\n }\n\n return Math.min(25, score);\n}\n\n/**\n * Score the composition category (25 points max)\n */\nexport function scoreComposition(metrics: CompositionMetrics): number {\n let score = 0;\n\n // Atom count (10 points)\n if (metrics.atomTypes.length >= 4) {\n score += 10;\n } else if (metrics.atomTypes.length === 3) {\n score += 7;\n } else if (metrics.atomTypes.length === 2) {\n score += 5;\n }\n\n // Molecule count (7 points)\n if (metrics.moleculeTypes.length >= 3) {\n score += 7;\n } else if (metrics.moleculeTypes.length === 2) {\n score += 5;\n } else if (metrics.moleculeTypes.length === 1) {\n score += 3;\n }\n\n // Organism count (8 points)\n if (metrics.organismTypes.length >= 2) {\n score += 8;\n } else if (metrics.organismTypes.length === 1) {\n score += 5;\n }\n\n return Math.min(25, score);\n}\n\n/**\n * Score the theme category (25 points max)\n */\nexport function scoreTheme(metrics: CompositionMetrics): number {\n let score = 0;\n\n // Theme variable usage (15 points)\n if (metrics.themeVariableUsage >= 95) {\n score += 15;\n } else if (metrics.themeVariableUsage >= 85) {\n score += 10;\n } else if (metrics.themeVariableUsage >= 75) {\n score += 5;\n }\n\n // No hardcoded colors (5 points)\n const hasNoHardcodedColors = !metrics.hardcodedValues.some(v => v.includes('#') || ['white', 'black'].some(c => v.toLowerCase().includes(c)));\n if (hasNoHardcodedColors) {\n score += 5;\n }\n\n // No hardcoded spacing (5 points)\n const hasNoHardcodedSpacing = !metrics.hardcodedValues.some(v => /\\d+px/.test(v));\n if (hasNoHardcodedSpacing) {\n score += 5;\n }\n\n return Math.min(25, score);\n}\n\n/**\n * Score the quality category (25 points max)\n */\nexport function scoreQuality(metrics: CompositionMetrics, testCase: EvalCase): number {\n let score = 0;\n\n // Section count (8 points)\n if (metrics.sectionCount >= 4) {\n score += 8;\n } else if (metrics.sectionCount === 3) {\n score += 6;\n } else if (metrics.sectionCount === 2) {\n score += 4;\n }\n\n // Expected patterns present (8 points)\n const expectedPresent = testCase.expectedPatterns.filter(p => \n metrics.atomTypes.includes(p) || \n metrics.moleculeTypes.includes(p) || \n metrics.organismTypes.includes(p)\n ).length;\n score += (expectedPresent / testCase.expectedPatterns.length) * 8;\n\n // Domain appropriateness (5 points)\n // This would require domain-specific checks\n score += 5;\n\n // Action completeness (4 points)\n // CRUD actions present\n score += 4;\n\n return Math.min(25, score);\n}\n\n/**\n * Calculate total score (0-100)\n */\nexport function calculateTotalScore(\n schema: OrbitalSchema, \n testCase: EvalCase,\n validationErrors: string[]\n): { score: number; breakdown: ScoreBreakdown } {\n const metrics = analyzeComposition(schema);\n\n const breakdown: ScoreBreakdown = {\n structure: scoreStructure(metrics, schema),\n composition: scoreComposition(metrics),\n theme: scoreTheme(metrics),\n quality: scoreQuality(metrics, testCase)\n };\n\n // Deduct points for validation errors\n if (validationErrors.length > 0) {\n breakdown.structure = Math.max(0, breakdown.structure - (validationErrors.length * 2));\n }\n\n const total = breakdown.structure + breakdown.composition + breakdown.theme + breakdown.quality;\n\n return {\n score: Math.min(100, Math.round(total)),\n breakdown\n };\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nfunction countTransitions(schema: OrbitalSchema): number {\n let count = 0;\n for (const orbital of schema.orbitals) {\n for (const trait of orbital.traits) {\n const t = trait as any;\n if (t.stateMachine?.transitions) {\n count += t.stateMachine.transitions.length;\n }\n }\n }\n return count;\n}\n\nfunction hasClosedCircuit(schema: OrbitalSchema): boolean {\n // Check that all states have entry and exit transitions\n for (const orbital of schema.orbitals) {\n for (const trait of orbital.traits) {\n const t = trait as any;\n if (!t.stateMachine) continue;\n \n const states = new Set<string>((t.stateMachine.states || []).map((s: { name: string }) => s.name));\n const incomingStates = new Set<string>();\n const outgoingStates = new Set<string>();\n\n for (const transition of t.stateMachine.transitions || []) {\n incomingStates.add(transition.to);\n outgoingStates.add(transition.from);\n }\n\n // All states except initial should have incoming\n // All states should have outgoing (or be terminal)\n for (const state of states) {\n const stateObj = (t.stateMachine.states || []).find((s: { name: string }) => s.name === state);\n if (!stateObj?.isInitial && !incomingStates.has(state)) {\n return false;\n }\n }\n }\n }\n return true;\n}\n\n// ============================================================================\n// Provider Comparison\n// ============================================================================\n\nexport interface ProviderComparison {\n provider: string;\n averageScore: number;\n cases: { caseName: string; score: number; passed: boolean }[];\n strengths: string[];\n weaknesses: string[];\n}\n\n/**\n * Run all eval cases for a provider.\n */\nexport async function runProviderEval(\n provider: string,\n generateFn: (prompt: string) => Promise<OrbitalSchema>\n): Promise<ProviderComparison> {\n const results: { caseName: string; score: number; passed: boolean }[] = [];\n let totalScore = 0;\n\n for (const testCase of EVAL_CASES) {\n try {\n const schema = await generateFn(testCase.prompt);\n const { score } = calculateTotalScore(schema, testCase, []);\n \n results.push({\n caseName: testCase.name,\n score,\n passed: score >= testCase.minScore\n });\n totalScore += score;\n } catch (error) {\n results.push({\n caseName: testCase.name,\n score: 0,\n passed: false\n });\n }\n }\n\n return {\n provider,\n averageScore: Math.round(totalScore / EVAL_CASES.length),\n cases: results,\n strengths: [], // Would be populated by analysis\n weaknesses: [] // Would be populated by analysis\n };\n}\n\n/**\n * Generate comparison matrix for all providers.\n */\nexport function generateComparisonMatrix(comparisons: ProviderComparison[]): string {\n let markdown = '# Composition Quality Provider Comparison\\n\\n';\n markdown += '| Provider | Average Score | task-mgmt | patient | ecommerce | kanban | analytics |\\n';\n markdown += '|----------|---------------|-----------|---------|-----------|--------|-----------|\\n';\n\n for (const comp of comparisons) {\n const scores = EVAL_CASES.map(tc => {\n const result = comp.cases.find(c => c.caseName === tc.name);\n return result ? `${result.score}${result.passed ? '✓' : ''}` : 'N/A';\n });\n \n markdown += `| ${comp.provider} | ${comp.averageScore} | ${scores.join(' | ')} |\\n`;\n }\n\n return markdown;\n}\n"]}
1
+ {"version":3,"sources":["../src/generators/utils.ts","../src/orbitals-skills-generators/helpers.ts","../src/prompts/skill-sections/architecture.ts","../src/prompts/skill-sections/common-errors.ts","../src/prompts/skill-sections/decomposition.ts","../src/prompts/skill-sections/bindings-guide.ts","../src/prompts/skill-sections/pattern-design-guide.ts","../src/prompts/skill-sections/theme-guide.ts","../src/prompts/skill-sections/custom-traits.ts","../src/prompts/skill-sections/schema-updates.ts","../src/prompts/skill-sections/context-usage.ts","../src/prompts/skill-sections/design-errors.ts","../src/prompts/skill-sections/fixing-guidance.ts","../src/prompts/skill-sections/game-guidance.ts","../src/prompts/skill-sections/uses-imports.ts","../src/orbitals-skills-generators/lean-orbital-skill-generator.ts","../src/generators/kflow-orbitals.ts","../src/orbitals-skills-generators/lean-fixing-skill-generator.ts","../src/generators/kflow-orbital-fixing.ts","../src/generators/domain-language.ts","../src/orbitals-skills-generators/lean/lean-orbital-generator.ts","../src/orbitals-skills-generators/lean/lean-fixing-generator.ts","../src/generators/index.ts","../src/prompts/type-references.ts","../src/prompts/generation-prompts.ts","../src/prompts/behaviors-reference.ts","../src/evals/composition-quality.ts"],"names":["isInlineTrait","PATTERN_TYPES","getPatternActionsRef","generateLeanOrbitalSkill","LEAN_CORE_INSTRUCTIONS","LEAN_ERROR_HANDLING","LEAN_VALIDATION_RULES","ODL_SYNTAX_REFERENCE","LEAN_EFFECT_GUARD_SYNTAX","ODL_TO_SCHEMA_MAPPING","generateLeanFixingSkill","getAllPatternTypes","getPatternPropsCompact","getSExprQuickRef","getRenderUIQuickRef","getKeyBehaviorsReference","generateBehaviorsDocs"],"mappings":";;;;;;;;;AAeO,SAAS,kBAAkB,E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ClF,EAAA,IAAI,QAAA,GAAW,+CAAA;AACf,EAAA,QAAA,IAAY,uFAAA;AACZ,EAAA,QAAA,IAAY,uFAAA;AAEZ,EAAA,KAAA,MAAW,QAAQ,WAAA,EAAa;AAC9B,IAAA,MAAM,MAAA,GAAS,UAAA,CAAW,GAAA,CAAI,CAAA,EAAA,KAAM;AAClC,MAAA,MAAM,MAAA,GAAS,KAAK,KAAA,CAAM,IAAA,CAAK,OAAK,CAAA,CAAE,QAAA,KAAa,GAAG,IAAI,CAAA;AAC1D,MAAA,OAAO,MAAA,GAAS,GAAG,MAAA,CAAO,KAAK,GAAG,MAAA,CAAO,MAAA,GAAS,QAAA,GAAM,EAAE,CAAA,CAAA,GAAK,KAAA;AAAA,IACjE,CAAC,CAAA;AAED,IAAA,QAAA,IAAY,CAAA,EAAA,EAAK,IAAA,CAAK,QAAQ,CAAA,GAAA,EAAM,IAAA,CAAK,YAAY,CAAA,GAAA,EAAM,MAAA,CAAO,IAAA,CAAK,KAAK,CAAC,CAAA;AAAA,CAAA;AAAA,EAC/E;AAEA,EAAA,OAAO,QAAA;AACT","file":"index.js","sourcesContent":["/**\n * Skill Generator Utilities\n *\n * Shared utilities for formatting and writing skill files.\n *\n * @packageDocumentation\n */\n\nimport { writeFileSync, mkdirSync, existsSync } from 'fs';\nimport { join } from 'path';\nimport type { SkillFrontmatter, GeneratedSkill } from './types.js';\n\n/**\n * Format skill frontmatter to YAML.\n */\nexport function formatFrontmatter(fm: SkillFrontmatter): string {\n const lines = ['---'];\n lines.push(`name: ${fm.name}`);\n lines.push(`description: ${fm.description}`);\n if (fm.allowedTools?.length) {\n lines.push(`allowed-tools: ${fm.allowedTools.join(', ')}`);\n }\n if (fm.version) {\n lines.push(`version: ${fm.version}`);\n }\n lines.push('---');\n return lines.join('\\n');\n}\n\n/**\n * Write a skill to the filesystem.\n */\nexport function writeSkill(skill: GeneratedSkill, baseDir: string): void {\n const skillDir = join(baseDir, skill.name);\n\n if (!existsSync(skillDir)) {\n mkdirSync(skillDir, { recursive: true });\n }\n\n const skillMd = formatFrontmatter(skill.frontmatter) + '\\n\\n' + skill.content;\n writeFileSync(join(skillDir, 'SKILL.md'), skillMd);\n console.log(` ✓ ${skill.name}/SKILL.md`);\n\n if (skill.references) {\n const refsDir = join(skillDir, 'references');\n if (!existsSync(refsDir)) {\n mkdirSync(refsDir, { recursive: true });\n }\n\n for (const [filename, content] of Object.entries(skill.references)) {\n writeFileSync(join(refsDir, filename), content);\n console.log(` ✓ ${skill.name}/references/${filename}`);\n }\n }\n}\n\n/**\n * Write all skills to the filesystem.\n */\nexport function writeAllSkills(skills: GeneratedSkill[], baseDir: string): void {\n console.log(`\\nWriting ${skills.length} skills to ${baseDir}...`);\n\n for (const skill of skills) {\n writeSkill(skill, baseDir);\n }\n\n console.log(`\\n✓ Generated ${skills.length} skills`);\n}\n","/**\n * Helper functions for generating skill content from @almadar packages.\n * These generate markdown sections by importing from @almadar/* packages.\n * \n * @packageDocumentation\n */\n\nimport { getAllBehaviors, getAllStdOperators, generateBehaviorsDocs, generateModulesDocs } from '@almadar/std';\nimport { PATTERN_TYPES, isInlineTrait } from '@almadar/core/types';\nimport type { Trait, State, Event as OrbitalEvent } from '@almadar/core';\nimport { getPatternsGroupedByCategory } from '@almadar/patterns';\n\n/**\n * Get minimal type reference (patterns, slots, operators).\n */\nexport function getMinimalTypeReference(): string {\n const patternsByCategory = getPatternsGroupedByCategory();\n const categories = Object.keys(patternsByCategory);\n \n return `## Type Reference\n\n### Pattern Types\n${categories.map(cat => `- **${cat}**: ${patternsByCategory[cat].slice(0, 5).join(', ')}...`).join('\\n')}\n\nTotal: ${PATTERN_TYPES.length} patterns\n\n### Operators\nUse S-expressions for guards and effects. See std library for full list.\n\n**Math**: \\`+\\`, \\`-\\`, \\`*\\`, \\`/\\`, \\`>\\`, \\`<\\`, \\`>=\\`, \\`<=\\`, \\`=\\`, \\`!=\\`\n**Logic**: \\`and\\`, \\`or\\`, \\`not\\`\n**Effects**: \\`set\\`, \\`++\\`, \\`--\\`, \\`persist\\`, \\`fetch\\`, \\`emit\\`, \\`render-ui\\`\n`;\n}\n\n/**\n * Get S-Expression quick reference.\n */\nexport function getSExprQuickRef(): string {\n return `## S-Expression Syntax\n\n**Bindings** (read data):\n- \\`@entity.field\\` - Entity field value\n- \\`@payload.data\\` - Event payload data\n- \\`@state\\` - Current state name\n- \\`@now\\` - Current timestamp\n\n**Guards** (boolean expressions):\n\\`\\`\\`json\n[\">\", \"@entity.count\", 0]\n[\"and\", [\"=\", \"@state\", \"Active\"], [\"<\", \"@entity.value\", 100]]\n\\`\\`\\`\n\n**Effects** (actions):\n\\`\\`\\`json\n[\"set\", \"@entity.count\", [\"+\", \"@entity.count\", 1]]\n[\"persist\", \"update\", \"Task\", \"@entity.id\", \"@payload.data\"]\n[\"emit\", \"TASK_COMPLETED\", { \"id\": \"@entity.id\" }]\n\\`\\`\\`\n`;\n}\n\n/**\n * Get render-ui quick reference.\n */\nexport function getRenderUIQuickRef(): string {\n return `## Render-UI Reference\n\n**Syntax**: \\`[\"render-ui\", slot, config]\\`\n\n**Slots**: \\`main\\`, \\`modal\\`, \\`drawer\\`, \\`sidebar\\`, \\`hud-top\\`, \\`hud-bottom\\`\n\n**Example**:\n\\`\\`\\`json\n[\"render-ui\", \"main\", {\n \"type\": \"entity-table\",\n \"entity\": \"Task\",\n \"columns\": [\"title\", \"status\"]\n}]\n\\`\\`\\`\n\nClear a slot: \\`[\"render-ui\", \"modal\", null]\\`\n`;\n}\n\n/**\n * Get std library minimal reference.\n */\nexport function getStdMinimalReference(): string {\n const operators = getAllStdOperators();\n return `## Standard Library\n\n**Operators**: ${operators.length} total\n\n**Key Categories**:\n- Math: \\`clamp\\`, \\`lerp\\`, \\`random\\`, \\`abs\\`, \\`min\\`, \\`max\\`\n- String: \\`concat\\`, \\`upper\\`, \\`lower\\`, \\`trim\\`, \\`split\\`\n- Array: \\`filter\\`, \\`map\\`, \\`find\\`, \\`contains\\`, \\`length\\`\n- Time: \\`now\\`, \\`format\\`, \\`diff\\`, \\`isPast\\`, \\`isFuture\\`\n\nImport with: \\`uses: [{ from: \"std/operators/math\", as: \"Math\" }]\\`\n`;\n}\n\n/**\n * Get std library full reference.\n */\nexport function getStdFullReference(): string {\n const modulesDocs = generateModulesDocs();\n return `## Standard Library (Full Reference)\n\n${modulesDocs.modules.map(mod => `### ${mod.name}\n${mod.description}\n\n${mod.operators.map(op => `- **${op.name}**: ${op.description}`).join('\\n')}\n`).join('\\n')}\n`;\n}\n\n/**\n * Get std behaviors with state machines.\n */\nexport function getStdBehaviorsWithStateMachines(): string {\n const behaviors = getAllBehaviors();\n const nonGameBehaviors = behaviors.filter(b => {\n const traits = b.orbitals?.[0]?.traits ?? [];\n const inlineTraits = traits.filter(isInlineTrait);\n const hasGameCategory = inlineTraits.some((t: Trait) => t.category?.includes('game'));\n const hasStateMachine = inlineTraits.some((t: Trait) => t.stateMachine);\n return !hasGameCategory && hasStateMachine;\n });\n\n return `## Standard Behaviors\n\n${nonGameBehaviors.map(behavior => {\n const inlineTraits = (behavior.orbitals?.[0]?.traits ?? []).filter(isInlineTrait);\n const trait: Trait | undefined = inlineTraits.find((t: Trait) => t.stateMachine);\n const sm = trait?.stateMachine;\n return `### ${behavior.name}\n\n**States**: ${sm?.states?.map((s: State) => s.name).join(', ') ?? 'N/A'}\n**Events**: ${sm?.events?.map((e: OrbitalEvent) => e.key ?? e.name).join(', ') ?? 'N/A'}\n\n\\`\\`\\`json\n${JSON.stringify(behavior, null, 2)}\n\\`\\`\\`\n`;\n }).join('\\n\\n')}\n`;\n}\n\n/**\n * Get key behaviors reference (compact).\n */\nexport function getKeyBehaviorsReference(): string {\n const behaviorsDocs = generateBehaviorsDocs();\n \n return `## Key Standard Behaviors\n\n${behaviorsDocs.categories.map(cat => `### ${cat.name}\n${cat.behaviors.map(b => `- **${b.name}**: ${b.description}`).join('\\n')}\n`).join('\\n')}\n\nUse with: \\`uses: [{ from: \"std/behaviors/crud\", as: \"CRUD\" }]\\`\n`;\n}\n","/**\n * Skill Architecture Section\n *\n * Core orbital architecture concepts - minimal, essential information only.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the core orbital architecture section.\n * This is the foundational understanding needed for orbital generation.\n */\nexport function getArchitectureSection(): string {\n return `## Orbital Architecture\n\n### Schema Format (IMPORTANT)\n\nThe correct schema format uses **orbitals** array at root:\n\n\\`\\`\\`json\n{\n \"name\": \"MyApp\",\n \"version\": \"1.0.0\",\n \"orbitals\": [ // ← CORRECT: orbitals array\n {\n \"name\": \"Task Management\",\n \"entity\": { ... },\n \"traits\": [ ... ],\n \"pages\": [ ... ]\n }\n ]\n}\n\\`\\`\\`\n\n**DO NOT** confuse with legacy format that had \\`dataEntities\\`, \\`traits\\`, \\`pages\\` at root level.\nThe \\`orbitals[]\\` format IS the standard format - do not \"fix\" it to something else.\n\n**NOTE**: There is NO schema-level \\`traits[]\\` array. All traits belong inside orbitals.\n\n### Core Formula\n\\`\\`\\`\nOrbital Unit = Entity × Traits × Patterns\nApplication = Σ(Orbital Units)\n\\`\\`\\`\n\n### The Closed Circuit Pattern\n\\`\\`\\`\nTrait State Machine → render-ui → UI Component → User Action → Event → Trait\n ↑ |\n └───────────────────────────────────────────────────────────┘\n\\`\\`\\`\n\n1. **Trait** transitions to state, fires \\`render-ui\\` effect\n2. **UI Component** renders with actions (buttons, forms)\n3. **User clicks** → Component emits event (e.g., \\`UI:CREATE\\`)\n4. **Trait receives** event, transitions, cycle repeats\n\n### Key Principles\n\n| Principle | Rule |\n|-----------|------|\n| **One trait per slot** | Each slot (main, modal, drawer) owned by ONE trait |\n| **INIT renders UI** | Every trait needs INIT self-loop to render initial UI |\n| **One page per entity** | Use trait's render-ui for create/edit/view, not separate pages |\n| **form-section has submitEvent** | Connects form to trait events (NOT onSubmit!) |\n| **std/* are templates** | Guide LLM generation, not runtime code |\n\n### Slot Ownership\n\\`\\`\\`\n┌─────────────────────────────────────────────┐\n│ Page: /tasks │\n├─────────────────────────────────────────────┤\n│ TaskManagement trait OWNS: │\n│ • main → entity-table, page-header │\n│ • modal → form-section (create/edit) │\n│ • drawer → detail-panel (view) │\n│ │\n│ NO other trait should render to these slots │\n└─────────────────────────────────────────────┘\n\\`\\`\\`\n`;\n}\n","/**\n * Common Errors Section\n *\n * Critical mistakes to avoid during orbital generation.\n * Keep this focused on the most frequent errors only.\n *\n * @packageDocumentation\n */\n\nimport { PATTERN_TYPES } from \"@almadar/core/types\";\nimport { ViewTypeSchema } from \"@almadar/core/types\";\nimport {\n getPatternPropsCompact,\n getPatternActionsRef,\n} from \"@almadar/patterns\";\n\n/**\n * Generate pattern categories from PATTERN_TYPES.\n */\nfunction getPatternCategories(): string {\n const categories: Record<string, string[]> = {\n Header: PATTERN_TYPES.filter(\n (p: any) => p.includes(\"header\") || p === \"title-only\",\n ),\n Display: PATTERN_TYPES.filter(\n (p: any) => p.startsWith(\"entity-\") || p === \"stats\",\n ),\n Form: PATTERN_TYPES.filter((p) => p.startsWith(\"form-\")),\n Filter: PATTERN_TYPES.filter(\n (p) => p.includes(\"search\") || p.includes(\"filter\"),\n ),\n State: PATTERN_TYPES.filter((p) => p.includes(\"-state\")),\n Navigation: PATTERN_TYPES.filter((p) => [\"tabs\", \"breadcrumb\"].includes(p)),\n Layout: PATTERN_TYPES.filter(\n (p) =>\n p.includes(\"layout\") || p.includes(\"grid\") || p === \"master-detail\",\n ),\n Interaction: PATTERN_TYPES.filter((p: any) => p === \"confirmation\" || (typeof p === 'string' && p.includes(\"confirmation\"))),\n Game: PATTERN_TYPES.filter(\n (p) =>\n p.startsWith(\"game-\") ||\n [\n \"tilemap-renderer\",\n \"inventory-panel\",\n \"dialogue-box\",\n \"level-select\",\n ].includes(p),\n ),\n };\n\n let table = \"| Category | Valid Patterns |\\n|----------|----------------|\\n\";\n for (const [cat, patterns] of Object.entries(categories)) {\n if (patterns.length > 0) {\n table += `| ${cat} | ${patterns.map((p) => `\\`${p}\\``).join(\", \")} |\\n`;\n }\n }\n return table;\n}\n\n/**\n * Get valid viewTypes from schema.\n */\nfunction getValidViewTypes(): string {\n const validTypes = ViewTypeSchema.options;\n return validTypes.map((t) => `\\`${t}\\``).join(\", \");\n}\n\n/**\n * Get common errors section.\n * Supports tiered output: 'top6' for generation skill, 'full' for fixing skill.\n */\nexport function getCommonErrorsSection(level: 'top6' | 'full' = 'full'): string {\n const critical = getCriticalErrors();\n if (level === 'top6') return critical;\n return critical + getEdgeCaseErrors();\n}\n\n/**\n * Top 6 critical errors — the mistakes the LLM actually makes repeatedly.\n * ~4,100 chars. Used by the generation skill.\n */\nfunction getCriticalErrors(): string {\n return `## Critical Rules\n\n### 1. INIT Transition Required (CRITICAL)\n\nEvery trait MUST have an INIT self-loop transition. The runtime fires \\`INIT\\` when page loads.\nThe INIT render-ui MUST be a **single composed stack**, not flat calls:\n\n\\`\\`\\`json\n{\n \"from\": \"Browsing\",\n \"to\": \"Browsing\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\",\n \"children\": [\n { \"type\": \"stack\", \"direction\": \"horizontal\", \"justify\": \"between\", \"align\": \"center\",\n \"children\": [\n { \"type\": \"typography\", \"variant\": \"h1\", \"text\": \"Title\" },\n { \"type\": \"button\", \"label\": \"Create\", \"event\": \"CREATE\", \"variant\": \"primary\" }\n ]\n },\n { \"type\": \"entity-table\", \"entity\": \"EntityName\", \"columns\": [\"...\"], \"searchable\": true,\n \"itemActions\": [{ \"label\": \"View\", \"event\": \"VIEW\" }] }\n ]\n }]\n ]\n}\n\\`\\`\\`\n\nWithout INIT: Page loads blank, nothing renders, no UI appears.\n\n### 2. NEVER Use @payload in set Effects\n\nThe \\`set\\` effect modifies entity state. **@payload is READ-ONLY**.\n\n\\`\\`\\`json\n// WRONG\n[\"set\", \"@payload.data.status\", \"active\"]\n\n// CORRECT\n[\"set\", \"@entity.status\", \"active\"]\n\\`\\`\\`\n\n**Rule:** \\`set\\` target MUST start with \\`@entity\\`, never \\`@payload\\`.\n\n### 3. Valid Patterns ONLY\n\n**DO NOT invent custom patterns!** Only these patterns exist:\n\n${getPatternCategories()}\n\n**NEVER use**: \\`onboarding-welcome\\`, \\`category-selector\\`, \\`assessment-question\\`, etc.\n\nValid viewType values: ${getValidViewTypes()}\n\n### 4. Page Structure Required\n\nEvery page MUST have \\`path\\` and \\`traits\\` properties:\n\n\\`\\`\\`json\n{\n \"pages\": [{\n \"name\": \"TasksPage\",\n \"path\": \"/tasks\",\n \"traits\": [{ \"ref\": \"TaskManagement\" }]\n }]\n}\n\\`\\`\\`\n\nWithout \\`path\\`: Validation error \\`ORB_P_MISSING_PATH\\`\nWithout \\`traits\\`: Validation error \\`ORB_P_MISSING_TRAITS\\`\n\n### 5. Valid Field Types ONLY\n\nField types MUST be one of: \\`string\\`, \\`number\\`, \\`boolean\\`, \\`date\\`, \\`timestamp\\`, \\`datetime\\`, \\`array\\`, \\`object\\`, \\`enum\\`, \\`relation\\`\n\n\\`\\`\\`json\n// WRONG - using entity name as type:\n{ \"name\": \"author\", \"type\": \"User\" }\n\n// CORRECT - use relation type:\n{ \"name\": \"author\", \"type\": \"relation\", \"relation\": { \"entity\": \"User\", \"cardinality\": \"one\" } }\n\\`\\`\\`\n\n### 6. Modal/Drawer Exit Transitions (CRITICAL — MOST COMMON ERROR)\n\n**EVERY state that renders to \\`\"modal\"\\` or \\`\"drawer\"\\` MUST have CANCEL and CLOSE transitions.**\nWithout these, the validator rejects the schema with \\`CIRCUIT_NO_OVERLAY_EXIT\\`.\n\n\\`\\`\\`json\n// Opening the modal: Browsing → Creating\n{ \"from\": \"Browsing\", \"to\": \"Creating\", \"event\": \"CREATE\",\n \"effects\": [[\"render-ui\", \"modal\", { \"type\": \"form-section\", \"entity\": \"Task\", \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }]] },\n\n// REQUIRED: CANCEL exit (form cancel button)\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"modal\", null]] },\n\n// REQUIRED: CLOSE exit (click outside / press Escape)\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"CLOSE\",\n \"effects\": [[\"render-ui\", \"modal\", null]] },\n\n// SAVE also dismisses modal\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"effects\": [[\"persist\", \"create\", \"Task\", \"@payload.data\"], [\"render-ui\", \"modal\", null], [\"emit\", \"INIT\"]] }\n\\`\\`\\`\n\n**Checklist for EVERY modal/drawer state:**\n- [ ] Has \\`CANCEL\\` transition → previous state with \\`[\"render-ui\", \"modal\", null]\\`\n- [ ] Has \\`CLOSE\\` transition → previous state with \\`[\"render-ui\", \"modal\", null]\\`\n- [ ] Has \\`SAVE\\` (or other action) transition that also dismisses with \\`[\"render-ui\", \"modal\", null]\\`\n\n**This applies to ALL states**: Creating, Editing, Viewing, Deleting — any state that renders to modal/drawer.\n\n### 7. Valid Slots ONLY\n\nrender-ui slots MUST be one of: \\`\"main\"\\`, \\`\"modal\"\\`, \\`\"drawer\"\\`, \\`\"sidebar\"\\`\n\n\\`\\`\\`json\n// WRONG - invented slots:\n[\"render-ui\", \"modal-close\", null]\n[\"render-ui\", \"notification\", { ... }]\n[\"render-ui\", \"confirm-modal\", { ... }]\n\n// CORRECT:\n[\"render-ui\", \"modal\", null]\n[\"render-ui\", \"main\", { ... }]\n\\`\\`\\`\n\n### 8. Every render-ui Pattern MUST Have \"type\"\n\nEvery pattern object in render-ui MUST include a \\`\"type\"\\` field. This applies to the top-level pattern AND every child in a stack.\n\n\\`\\`\\`json\n// WRONG - missing type:\n[\"render-ui\", \"main\", { \"entity\": \"Product\", \"columns\": [\"name\"] }]\n\n// CORRECT:\n[\"render-ui\", \"main\", { \"type\": \"entity-table\", \"entity\": \"Product\", \"columns\": [\"name\"] }]\n\n// WRONG - child missing type:\n{ \"type\": \"stack\", \"children\": [{ \"text\": \"Hello\" }] }\n\n// CORRECT:\n{ \"type\": \"stack\", \"children\": [{ \"type\": \"typography\", \"text\": \"Hello\" }] }\n\\`\\`\\`\n`;\n\n}\n\n/**\n * Edge case errors 9-20 — less frequent, validator catches most of these.\n * ~4,000 chars. Used by the fixing skill.\n */\nfunction getEdgeCaseErrors(): string {\n return `\n---\n\n## Additional Errors (Edge Cases)\n\n### 7. Over-Generating Pages\n\\`\\`\\`\nWRONG: TaskListPage, TaskCreatePage, TaskEditPage, TaskViewPage (4 pages!)\nCORRECT: TasksPage with EntityManagement trait (1 page)\n\\`\\`\\`\n\n### 8. Duplicate Slot Rendering\n\\`\\`\\`\nWRONG: Two traits both render to \"main\" on page load\nCORRECT: ONE trait owns each slot\n\\`\\`\\`\n\n### 9. Missing submitEvent / Wrong Action Pattern in form-section\n\\`\\`\\`\nWRONG: { \"type\": \"form-section\", \"entity\": \"Task\" }\nALSO WRONG: { \"type\": \"form-section\", \"entity\": \"Task\", \"onSubmit\": \"SAVE\" }\nALSO WRONG: { \"type\": \"form-section\", \"actions\": [{\"label\": \"Save\", \"event\": \"SAVE\"}] }\nCORRECT: { \"type\": \"form-section\", \"entity\": \"Task\", \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }\n\\`\\`\\`\n**form-section does NOT use \\`actions\\` array** — it uses \\`submitEvent\\` and \\`cancelEvent\\` strings.\nThe \\`actions\\` prop is for \\`page-header\\`, \\`entity-detail\\`, NOT for forms.\n\n### 10. Duplicate Transitions (Same from+event)\n\\`\\`\\`\nWRONG: Two transitions with same \"from\" and \"event\" without guards\nCORRECT: Use GUARDS to differentiate transitions\n\\`\\`\\`\n\n### 11. Using \"render\" Instead of \"render-ui\"\n\\`\\`\\`\nWRONG: [\"render\", \"main\", {...}]\nCORRECT: [\"render-ui\", \"main\", {...}]\n\\`\\`\\`\n\n### 12. Generating Sections Array (Legacy)\n\\`\\`\\`\nWRONG: { \"pages\": [{ \"sections\": [...] }] }\nCORRECT: { \"pages\": [{ \"traits\": [...] }] } - UI comes from render-ui effects\n\\`\\`\\`\n\n### 13. Using form-actions Pattern (DOES NOT EXIST!)\n\\`\\`\\`\nWRONG: [\"render-ui\", \"main\", { \"type\": \"form-actions\", \"actions\": [...] }]\nCORRECT: Use form-section with submitEvent/cancelEvent props\n\\`\\`\\`\nActions are INSIDE patterns, not separate patterns.\n\n### 14. Forgetting itemActions in entity-table\n\\`\\`\\`\nWRONG: { \"type\": \"entity-table\", \"entity\": \"Task\" }\nCORRECT: { \"type\": \"entity-table\", \"entity\": \"Task\", \"itemActions\": [{\"label\": \"Edit\", \"event\": \"EDIT\"}] }\n\\`\\`\\`\n\n### 15. Duplicate Trait Names Across Orbitals\n\\`\\`\\`\nWRONG: UserOrbital uses \"EntityManagement\", TaskOrbital uses \"EntityManagement\"\nCORRECT: UserOrbital uses \"UserManagement\", TaskOrbital uses \"TaskManagement\"\n\\`\\`\\`\nEach trait name MUST be unique. Pattern: \\`{Entity}{Purpose}\\`\n\n### 16. Hallucinated itemAction Properties\n\\`\\`\\`\nWRONG: { \"label\": \"View\", \"event\": \"VIEW\", \"condition\": \"...\" }\nCORRECT: { \"label\": \"View\", \"event\": \"VIEW\" }\n\\`\\`\\`\nValid itemAction props: \\`label\\`, \\`event\\`, \\`navigatesTo\\`, \\`placement\\`, \\`variant\\`, \\`showWhen\\`\n\n### 17. Event Listeners Structure\nEvent listeners go INSIDE traits, not at orbital level:\n\\`\\`\\`json\n\"traits\": [{ \"name\": \"TaskInteraction\",\n \"listens\": [{ \"event\": \"USER_UPDATED\", \"handler\": \"REFRESH_LIST\" }] }]\n\\`\\`\\`\n\n### 18. Wrong Filtering Pattern (Use Query Singleton)\nUse a singleton entity for filter state + \\`query\\` prop on entity-table:\n\\`\\`\\`json\n{ \"name\": \"TaskQuery\", \"entity\": { \"name\": \"TaskQuery\", \"singleton\": true, \"runtime\": true,\n \"fields\": [{ \"name\": \"status\", \"type\": \"string\" }, { \"name\": \"search\", \"type\": \"string\" }] } }\n\\`\\`\\`\nReference: \\`[\"render-ui\", \"main\", { \"type\": \"entity-table\", \"entity\": \"Task\", \"query\": \"@TaskQuery\" }]\\`\n`;\n}\n\n/**\n * Get validation error hints section.\n * Quick reference for common validation errors and fixes.\n */\nexport function getValidationHintsSection(): string {\n return `## Validation Error Quick Fixes\n\n| Error | Fix |\n|-------|-----|\n| ORB_P_MISSING_PATH | Add \\`path\\` property starting with \"/\" to page (e.g., \"/tasks\") |\n| ORB_P_MISSING_TRAITS | Add \\`traits\\` array to page with at least one trait ref |\n| ORB_E_INVALID_FIELD_TYPE | Use valid type: string, number, boolean, date, enum, relation. NOT entity names! |\n| ORB_INIT_MISSING | Add INIT self-loop transition with render-ui effects |\n| ORB_FORM_SUBMIT | Add submitEvent and cancelEvent to form-section pattern |\n| ORB_DUPE_TRANS | Add guards to differentiate same-event transitions |\n| ORB_SLOT_CONTENTION | Merge traits or use different slots |\n| ORB_DUPE_PAGE_TRAITS | Remove duplicate trait references from page |\n| ORB_T_DUPLICATE_NAME | Use unique trait names per entity: UserManagement, TaskManagement |\n| ORB_EFF_SET_REQUIRES_ENTITY | Change @payload.field to @entity.field in set effects |\n| ORB_RUI_UNKNOWN_ITEM_ACTION_PROP | Remove invalid props (like \\`condition\\`), use \\`showWhen\\` |\n| ORB_MODAL_NO_CLOSE | Add CLOSE/CANCEL transitions from modal states with \\`[\"render-ui\", \"modal\", null]\\` |\n`;\n}\n","/**\n * Decomposition Protocol Section\n *\n * Step-by-step protocol for breaking requirements into orbital units.\n * Keep this focused on the decision process, not verbose explanations.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the decomposition protocol section.\n */\nexport function getDecompositionSection(): string {\n return `## Orbital Decomposition Protocol\n\n### Step 0: Classify Domain\n| Domain | Keywords | Key Traits |\n|--------|----------|------------|\n| business | manage, track, workflow | EntityManagement, SearchAndFilter |\n| game | play, score, level | Physics2D, Health, GameState |\n| form | wizard, onboarding | Wizard, FormSubmission |\n| dashboard | metrics, KPI | EntityManagement |\n| content | blog, CMS | none (page navigation) |\n| social | chat, feed, profile, follow | EntityManagement |\n| ecommerce | shop, store, cart, checkout | EntityManagement, SearchAndFilter |\n| workflow | automate, process, pipeline | EntityManagement |\n\n### Step 1: Identify Entities (ONE Orbital Per Entity)\n- What are the core data objects?\n- persistent (DB), runtime (memory), or singleton (config)?\n- **CRITICAL: Create exactly ONE orbital per entity**\n- **CRITICAL: If the prompt mentions N entities, create N orbitals** (e.g., \"Product, Category, Order\" → 3 orbitals)\n- **CRITICAL: EVERY orbital MUST have an entity field** - no exceptions\n- **NEVER** collapse multiple entities into a single dashboard orbital\n\n**Entity Field is REQUIRED in every orbital:**\n\\`\\`\\`json\n{\n \"name\": \"Product Management\",\n \"entity\": { // ← REQUIRED: Every orbital needs this\n \"name\": \"Product\",\n \"collection\": \"products\",\n \"fields\": [...]\n },\n \"traits\": [...],\n \"pages\": [...]\n}\n\\`\\`\\`\n\n**Common mistake to avoid:**\n- ❌ WRONG: Creating an orbital with no entity field\n- ✅ CORRECT: Every orbital has its entity defined inline\n\n### Step 2: Select Interaction Model\n| Domain | Create | View | Edit | Delete |\n|--------|--------|------|------|--------|\n| business | modal | drawer | modal | confirm |\n| game | none | none | none | none |\n| form | wizard | drawer | page | confirm |\n\n### Step 3: Choose Traits (UNIQUE NAMES REQUIRED)\n- Business: \\`{Entity}Management\\` naming — e.g., \\`ProductManagement\\`, \\`OrderManagement\\`, \\`CustomerManagement\\`\n- Game: Physics2D, Health, Score, Collision\n- Form: Wizard (multi-step) or FormSubmission (single)\n- **NEVER reuse the same trait name across orbitals. Each trait name MUST be globally unique.**\n\n### Step 4: Define State Machine\n\\`\\`\\`\nstates: Identify user-facing modes (browsing, creating, editing, viewing)\nevents: Identify user actions (INIT, CREATE, VIEW, EDIT, SAVE, CLOSE)\ntransitions: Map (from, event) → (to, effects)\n\\`\\`\\`\n\n### Step 5: Add INIT Transition (CRITICAL)\nEvery trait MUST have:\n\\`\\`\\`json\n{ \"from\": \"initial\", \"to\": \"initial\", \"event\": \"INIT\", \"effects\": [[\"render-ui\", ...]] }\n\\`\\`\\`\nWithout INIT, the page loads blank!\n\n### Step 6: Define Pages\n- ONE page per entity (business) or workflow (form)\n- Attach traits to pages via \\`traits\\` array\n- No \\`sections\\` array - UI comes from render-ui effects\n\n### Step 7: Add Guards (CRITICAL for Business Rules)\n\n**Guards enforce business rules as S-expressions on transitions.**\n\n#### When to use guards:\n1. **Business rule validation** - Enforce constraints on SAVE transitions\n2. **Conditional routing** - Same (from, event) leads to different states\n\n#### Business Rule Guards (on SAVE):\n\\`\\`\\`json\n{\n \"from\": \"Editing\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"guard\": [\"and\",\n [\"<=\", \"@payload.data.age\", 120],\n [\">=\", \"@payload.data.balance\", 0]\n ],\n \"effects\": [[\"persist\", \"update\", \"Account\", \"@payload.data\"], ...]\n}\n\\`\\`\\`\n\n#### Conditional Routing Guards:\n\\`\\`\\`json\n{ \"from\": \"A\", \"to\": \"B\", \"event\": \"X\", \"guard\": [\">\", \"@entity.health\", 0] }\n{ \"from\": \"A\", \"to\": \"C\", \"event\": \"X\", \"guard\": [\"<=\", \"@entity.health\", 0] }\n\\`\\`\\`\n\n**IMPORTANT**:\n- Use \\`\"guard\"\\` (singular) on transitions, NOT \\`\"guards\"\\` (plural)\n- Business rules MUST be S-expression guards on the transition, NOT just UI messages!\n`;\n}\n\n/**\n * Get minimal decomposition checklist.\n */\nexport function getDecompositionChecklist(): string {\n return `## Decomposition Checklist\n\n- [ ] Domain classified (business/game/form/dashboard/content/social/ecommerce/workflow)\n- [ ] Entities identified with persistence type\n- [ ] **ONE orbital per entity** (not multiple orbitals for same entity!)\n- [ ] Traits selected (EntityManagement for CRUD, domain-specific for others)\n- [ ] State machine has states, events, transitions\n- [ ] INIT transition exists with render-ui effects\n- [ ] Pages defined (ONE per entity/workflow)\n- [ ] Traits attached to pages\n- [ ] **Business rule guards as S-expressions on SAVE transitions**\n- [ ] Entity relations defined for cross-orbital links\n- [ ] emits/listens defined for cross-orbital events\n`;\n}\n\n/**\n * Get compact decomposition protocol (~1,250 chars).\n * Steps 0-6 without verbose guard examples (guards covered in S-Expr + errors).\n */\nexport function getDecompositionCompact(): string {\n return `## Orbital Decomposition Protocol\n\n### Step 0: Classify Domain\n| Domain | Keywords | Key Traits |\n|--------|----------|------------|\n| business | manage, track, workflow | EntityManagement, SearchAndFilter |\n| game | play, score, level | Physics2D, Health, GameState |\n| form | wizard, onboarding | Wizard, FormSubmission |\n| dashboard | metrics, KPI | EntityManagement |\n| content | blog, CMS | none (page navigation) |\n| social | chat, feed, profile, follow | EntityManagement |\n| ecommerce | shop, store, cart, checkout | EntityManagement, SearchAndFilter |\n| workflow | automate, process, pipeline | EntityManagement |\n\n### Step 1: Identify Entities (ONE Orbital Per Entity)\n- What are the core data objects?\n- persistent (DB), runtime (memory), or singleton (config)?\n- **CRITICAL: Create exactly ONE orbital per entity**\n- **CRITICAL: If the prompt mentions N entities, create N orbitals** (e.g., \"Product, Category, Order\" → 3 orbitals)\n- **CRITICAL: EVERY orbital MUST have an entity field**\n- **NEVER** collapse multiple entities into a single dashboard orbital\n\n### Step 2: Select Interaction Model\n| Domain | Create | View | Edit | Delete |\n|--------|--------|------|------|--------|\n| business | modal | drawer | modal | confirm |\n| game | none | none | none | none |\n| form | wizard | drawer | page | confirm |\n\n### Step 3: Choose Traits (UNIQUE NAMES REQUIRED)\n- Business: \\`{Entity}Management\\` naming — e.g., \\`ProductManagement\\`, \\`OrderManagement\\`, \\`CustomerManagement\\`\n- Game: Physics2D, Health, Score, Collision\n- Form: Wizard (multi-step) or FormSubmission (single)\n- **NEVER reuse the same trait name across orbitals. Each trait name MUST be globally unique.**\n\n### Step 4: Define State Machine\n\\`\\`\\`\nstates: Identify user-facing modes (browsing, creating, editing, viewing)\nevents: Identify user actions (INIT, CREATE, VIEW, EDIT, SAVE, CLOSE)\ntransitions: Map (from, event) → (to, effects)\n\\`\\`\\`\n\n### Step 5: Add INIT Transition (CRITICAL)\nEvery trait MUST have an INIT self-loop with render-ui effects. Without INIT, the page loads blank!\n\n### Step 6: Define Pages\n- ONE page per entity (business) or workflow (form)\n- Attach traits to pages via \\`traits\\` array\n- Add \\`\"guard\"\\` (singular) S-expressions on SAVE transitions for business rules\n`;\n}\n\n/**\n * Get compact orbital connectivity (~750 chars).\n * One combined example instead of three separate examples.\n */\nexport function getConnectivityCompact(): string {\n return `## Orbital Connectivity\n\nFor multi-entity apps, connect orbitals:\n\n\\`\\`\\`json\n{\n \"entity\": {\n \"fields\": [\n { \"name\": \"customerId\", \"type\": \"relation\", \"relation\": { \"entity\": \"Customer\", \"cardinality\": \"one\" } }\n ]\n },\n \"emits\": [\"ORDER_COMPLETED\"],\n \"listens\": [{ \"event\": \"MENU_ITEM_UNAVAILABLE\", \"triggers\": \"DISABLE_ITEM\" }],\n \"design\": {\n \"uxHints\": {\n \"relatedLinks\": [{ \"relation\": \"customerId\", \"label\": \"View Customer\", \"targetView\": \"detail\" }]\n }\n }\n}\n\\`\\`\\`\n\n- **relation fields**: Link entities (Order → Customer)\n- **emits/listens**: Cross-orbital event communication\n- **relatedLinks**: Navigation between related records\n`;\n}\n\n// ============================================================================\n// UX Enhancement Sections\n// ============================================================================\n\n/**\n * Get flow pattern selection guidance.\n * Maps application types to appropriate user flow patterns.\n */\nexport function getFlowPatternSection(): string {\n return `## Flow Pattern Selection\n\nSelect a flow pattern based on application type:\n\n| App Type | Flow Pattern | Structure |\n|----------|--------------|-----------|\n| Dashboard/Admin | hub-spoke | Central hub → feature pages → back to hub |\n| CRM/List-focused | master-detail | List with drill-down drawer or split view |\n| CRUD App | crud-cycle | List ↔ modal forms for create/edit |\n| Onboarding/Checkout | linear | Step-by-step wizard flow |\n| Multi-role | role-based | Role guards determine visible features |\n\n**Flow → Orbital Structure:**\n- hub-spoke: Dashboard orbital + feature orbitals with navigation\n- master-detail: Entity orbital with detail drawer state\n- crud-cycle: Entity orbital with modal form states\n- linear: Step orbitals connected via navigation\n- role-based: Shared orbitals with role-based guards\n`;\n}\n\n/**\n * Get guidance for outputting orbitals with embedded context.\n */\nexport function getPortableOrbitalOutputSection(): string {\n return `## Orbital Output Format\n\nEach orbital MUST include embedded context for portability:\n\n\\`\\`\\`json\n{\n \"name\": \"Order Management\",\n \"entity\": {\n \"name\": \"Order\",\n \"persistence\": \"persistent\",\n \"fields\": [\n { \"name\": \"customerId\", \"type\": \"relation\", \"relation\": { \"entity\": \"Customer\", \"cardinality\": \"one\" } },\n { \"name\": \"items\", \"type\": \"relation\", \"relation\": { \"entity\": \"MenuItem\", \"cardinality\": \"many\" } }\n ]\n },\n \"traits\": [\"EntityManagement\"],\n \"domainContext\": {\n \"request\": \"<full user request>\",\n \"requestFragment\": \"<verbatim excerpt for THIS orbital>\",\n \"category\": \"business\",\n \"vocabulary\": { \"item\": \"Order\", \"create\": \"Place Order\", \"delete\": \"Cancel\" }\n },\n \"design\": {\n \"style\": \"modern\",\n \"uxHints\": { \"flowPattern\": \"crud-cycle\", \"listPattern\": \"entity-table\", \"formPattern\": \"modal\" }\n },\n \"emits\": [\"ORDER_READY\", \"ORDER_COMPLETED\"],\n \"listens\": [{ \"event\": \"MENU_ITEM_UNAVAILABLE\", \"triggers\": \"DISABLE_ITEM\" }],\n \"relations\": [\n { \"entity\": \"Customer\", \"cardinality\": \"one\" },\n { \"entity\": \"MenuItem\", \"cardinality\": \"many\" }\n ]\n}\n\\`\\`\\`\n\n**Required context fields:**\n- \\`domainContext.requestFragment\\` - What user said that produced this orbital\n- \\`domainContext.category\\` - Domain classification\n- \\`domainContext.vocabulary\\` - Domain-specific naming\n- \\`design.uxHints\\` - Pattern selection hints\n\n**Cross-orbital connectivity (for multi-entity apps):**\n- \\`entity.fields[].relation\\` - Link to related entities\n- \\`emits\\` - Events this orbital emits when state changes\n- \\`listens\\` - Events from other orbitals to handle\n- \\`relations\\` - Summary of entity relationships\n`;\n}\n\n/**\n * Get guidance for connecting orbitals together.\n */\nexport function getOrbitalConnectivitySection(): string {\n return `## Orbital Connectivity (CRITICAL)\n\nOrbitals must NOT be discrete islands. For multi-entity apps, connect orbitals properly:\n\n### 1. Entity Relations (REQUIRED for related entities)\nWhen Entity A references Entity B, add a relation field:\n\\`\\`\\`json\n// In Order orbital's entity.fields:\n{ \"name\": \"customerId\", \"type\": \"relation\", \"relation\": { \"entity\": \"Customer\", \"cardinality\": \"one\" } }\n{ \"name\": \"items\", \"type\": \"relation\", \"relation\": { \"entity\": \"MenuItem\", \"cardinality\": \"many\" } }\n\\`\\`\\`\n\n### 2. Navigation Links (in design.uxHints.relatedLinks)\nEnable drill-down from one orbital to another:\n\\`\\`\\`json\n{ \"relatedLinks\": [{ \"relation\": \"customerId\", \"label\": \"View Customer\", \"targetView\": \"detail\" }] }\n\\`\\`\\`\n\n### 3. Cross-Orbital Events (emits/listens)\nOrbitals communicate via events:\n\\`\\`\\`json\n// Order orbital emits when status changes:\n{ \"emits\": [\"ORDER_READY\", \"ORDER_COMPLETED\"] }\n\n// Notification orbital listens:\n{ \"listens\": [{ \"event\": \"ORDER_READY\", \"triggers\": \"NOTIFY_CUSTOMER\" }] }\n\\`\\`\\`\n\n**CRITICAL: For multi-entity apps:**\n- Add relation fields to connect entities (e.g., Order → Customer, Order → MenuItem)\n- Add emits/listens when one orbital's state change affects another\n- Add relatedLinks for navigation between related records\n`;\n}\n","/**\n * Bindings Guide\n *\n * Generates binding documentation from the source of truth in @almadar/core.\n * This ensures the skill guidance matches the actual compiler validation.\n *\n * @packageDocumentation\n */\n\nimport { BINDING_DOCS, CORE_BINDINGS } from '@almadar/core';\n\n/**\n * Generate binding documentation for skill prompts.\n * Derived from BINDING_DOCS in @almadar/core - single source of truth.\n */\nexport function getBindingsGuide(): string {\n const lines: string[] = [\n '## Valid Binding References',\n '',\n 'Bindings reference runtime values using `@root.path` syntax:',\n '',\n '| Binding | Description | Example |',\n '|---------|-------------|---------|',\n ];\n\n // Generate table from BINDING_DOCS\n for (const [bindingKey, docs] of Object.entries(BINDING_DOCS)) {\n const example = docs.examples[0] || `@${bindingKey}`;\n lines.push(`| \\`@${bindingKey}\\` | ${docs.description} | \\`${example}\\` |`);\n }\n\n lines.push(\n '',\n '### Binding Rules',\n '',\n '- `@entity.field` - Access entity fields (e.g., `@entity.status`, `@entity.count`)',\n '- `@payload.field` - Access event payload data (read-only)',\n '- `@state` - Current state name (no path)',\n '- `@now` - Current timestamp (no path)',\n '- `@config.field` - Trait configuration values',\n '',\n '### Common Mistakes',\n '',\n '| ❌ Invalid | ✅ Correct |',\n '|------------|------------|',\n '| `@count(tasks)` | Use static text `\"Total Tasks\"` or add a `taskCount` field to entity |',\n '| `@find(orders, id=@payload.id)` | Use `@payload.data` — the runtime resolves entities |',\n '| `@categories.find(c => c.id === @payload.id)` | Use `@payload.data` — no JavaScript in bindings |',\n '| `@sum(orders, totalAmount)` | Add a `totalAmount` field to the entity |',\n '| `@formatDate(@entity.createdAt, \"MMM dd\")` | Use `@entity.createdAt` — formatting is UI-side |',\n '| `@length(items)` | Use `@entity.itemCount` — add the field to entity |',\n '| `@filter(...)` | No function-call syntax exists in bindings |',\n '| `@inc(@payload.delta)` | Use `@payload.data` or `@entity.field` |',\n '| `@count` | Use static text or add a count field to entity |',\n '| `@entity.task.title` | `@entity.title` (entity type is implicit) |',\n '| `@payload.field` in `set` effect | `@entity.field` (set modifies entity only) |',\n '| `@entity` (bare, no path) | `@entity.data` or `@entity.fieldName` — path required |',\n '',\n '**ABSOLUTE RULE**: Bindings are ONLY `@root.path` (e.g., `@entity.name`). NO function calls, NO JavaScript expressions, NO query syntax. If you need computed values, add a field to the entity.',\n ''\n );\n\n return lines.join('\\n');\n}\n\n/**\n * Get compact binding reference (one-liner for tables).\n */\nexport function getBindingsCompact(): string {\n const validBindings = CORE_BINDINGS.map(b => `@${b}`).join(', ');\n return `Valid bindings: ${validBindings}`;\n}\n\n/**\n * Get binding validation rules for specific contexts.\n */\nexport function getBindingContextRules(): string {\n return `\n## Binding Context Rules\n\n| Context | Allowed Bindings | Notes |\n|---------|-----------------|-------|\n| Guards | @entity, @payload, @state, @now | Read-only conditions |\n| Effects | @entity, @payload, @state, @now | @entity can be modified via set |\n| Ticks | @entity, @state, @now | No payload (no event) |\n| Render-UI | @entity, @payload, @state, @config | Display values only |\n\n**Critical Rule:** The \".set\" effect ONLY modifies @entity fields.\n`.trim();\n}\n","/**\n * Atomic Composition Design Guide (v5.0)\n *\n * Teaches the LLM to compose sophisticated views using atomic design principles.\n * Every render-ui effect must satisfy the Five Rules of Sophisticated Composition.\n *\n * v5.0: Added mandatory composition rules, validation checklist, and theme enforcement.\n *\n * @packageDocumentation\n */\n\nimport {\n getPatternPropsCompact,\n getPatternActionsRef,\n getAllPatternTypes,\n} from \"@almadar/patterns\";\nimport { getBindingsGuide } from \"./bindings-guide.js\";\n\n/**\n * Get the render-ui atomic composition guide with mandatory rules.\n */\nexport function getRenderUIDesignGuide(): string {\n return `## Render-UI Atomic Composition Guide (v5.0)\n\n### The Five Rules of Sophisticated Composition (MANDATORY)\n\nEvery render-ui effect MUST satisfy ALL five rules:\n\n| Rule | Requirement | Validation |\n|------|-------------|------------|\n| **1** | **Single Render-UI** per transition | One render-ui effect only |\n| **2** | **Three Atomic Levels** | Atoms (2+) + Molecules (1+) + Organisms (1+) |\n| **3** | **Layout Wrapper** | Root must be stack/box/container/grid |\n| **4** | **Theme Variables** | ALL visual props use CSS vars |\n| **5** | **Template Quality** | Match CrudTemplate/ListTemplate sophistication |\n\n---\n\n### Rule 1: Single Render-UI Per Transition\n\nEach transition executes exactly ONE render-ui effect with composed children:\n\n\\`\\`\\`json\n// ✅ CORRECT: Single render-ui with composed children\n{\n \"from\": \"Browsing\",\n \"to\": \"Browsing\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"stack\",\n \"direction\": \"vertical\",\n \"gap\": \"lg\",\n \"children\": [\n { \"type\": \"page-header\", \"title\": \"...\", \"actions\": [...] },\n { \"type\": \"entity-table\", \"entity\": \"...\", ... }\n ]\n }]\n ]\n}\n\n// ❌ WRONG: Multiple flat render-ui calls\n{\n \"effects\": [\n [\"render-ui\", \"main\", { \"type\": \"page-header\", ... }],\n [\"render-ui\", \"main\", { \"type\": \"entity-table\", ... }]\n ]\n}\n\\`\\`\\`\n\n---\n\n### Rule 2: Three Atomic Levels Required\n\nEvery composition MUST contain ALL three levels:\n\n#### Level 1: Atoms (Minimum 2 distinct types)\n\n| Type | Purpose | Example Usage |\n|------|---------|---------------|\n| \\`typography\\` | All text content | Headlines, labels, body text |\n| \\`badge\\` | Status indicators | Active, Pending, Completed |\n| \\`button\\` | User actions | Create, Edit, Delete |\n| \\`avatar\\` | User/entity images | Profile pictures |\n| \\`icon\\` | Decorative icons | Plus, Edit, Trash |\n| \\`progress-bar\\` | Progress indicators | Upload progress |\n| \\`divider\\` | Visual separation | Section dividers |\n\n#### Level 2: Molecules (Minimum 1)\n\n| Type | Purpose | Example Usage |\n|------|---------|---------------|\n| \\`box\\` | Visual containers | Stat cards, panels |\n| \\`card\\` | Content grouping | Feature cards |\n| \\`modal\\` | Dialog overlays | Create/edit forms |\n| \\`drawer\\` | Side panels | Detail views |\n| \\`tabs\\` | Content organization | Filter tabs |\n| \\`alert\\` | Notifications | Success/error messages |\n| \\`accordion\\` | Collapsible sections | FAQ, settings |\n\n#### Level 3: Organisms (Minimum 1 for data views)\n\n| Type | Purpose | Example Usage |\n|------|---------|---------------|\n| \\`entity-table\\` | Data tables | List views |\n| \\`form-section\\` | Forms | Create/edit |\n| \\`detail-panel\\` | Detail views | View record |\n| \\`page-header\\` | Page headers | Title + actions |\n| \\`chart\\` | Data visualization | Analytics |\n| \\`timeline\\` | Chronological events | Activity history |\n| \\`stats\\` | KPI metrics | Dashboard stats |\n\n---\n\n### Rule 3: Layout-First Structure\n\nRoot element MUST be a layout primitive:\n\n\\`\\`\\`json\n// ✅ CORRECT: Layout wrappers\n{ \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\", \"children\": [...] }\n{ \"type\": \"stack\", \"direction\": \"horizontal\", \"gap\": \"md\", \"children\": [...] }\n{ \"type\": \"box\", \"padding\": \"lg\", \"bg\": \"var(--color-card)\", \"children\": [...] }\n{ \"type\": \"container\", \"size\": \"xl\", \"padding\": \"lg\", \"children\": [...] }\n{ \"type\": \"grid\", \"cols\": 3, \"gap\": \"md\", \"children\": [...] }\n\n// ❌ WRONG: No layout wrapper\n{ \"type\": \"page-header\", \"title\": \"...\" }\n{ \"type\": \"entity-table\", \"entity\": \"...\" }\n\\`\\`\\`\n\n#### Layout Props Reference\n\n**Stack (VStack/HStack)**\n\\`\\`\\`json\n{\n \"type\": \"stack\",\n \"direction\": \"vertical\" | \"horizontal\",\n \"gap\": \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\",\n \"align\": \"start\" | \"center\" | \"end\" | \"stretch\",\n \"justify\": \"start\" | \"center\" | \"end\" | \"between\" | \"around\",\n \"wrap\": true | false\n}\n\\`\\`\\`\n\n**Box**\n\\`\\`\\`json\n{\n \"type\": \"box\",\n \"padding\": \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\",\n \"bg\": \"var(--color-card)\" | \"var(--color-muted)\" | \"var(--color-primary)\",\n \"border\": true | false,\n \"borderColor\": \"var(--color-border)\",\n \"rounded\": \"var(--radius-none)\" | \"var(--radius-sm)\" | \"var(--radius-md)\" | \"var(--radius-lg)\" | \"var(--radius-xl)\",\n \"shadow\": \"var(--shadow-none)\" | \"var(--shadow-sm)\" | \"var(--shadow-md)\" | \"var(--shadow-lg)\"\n}\n\\`\\`\\`\n\n**Container**\n\\`\\`\\`json\n{\n \"type\": \"container\",\n \"size\": \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\",\n \"padding\": \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\"\n}\n\\`\\`\\`\n\n**Grid**\n\\`\\`\\`json\n{\n \"type\": \"grid\",\n \"cols\": 1 | 2 | 3 | 4 | 6 | 12 | { \"sm\": 1, \"md\": 2, \"lg\": 3 },\n \"gap\": \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\"\n}\n\\`\\`\\`\n\n---\n\n### Rule 4: Theme Variable Enforcement\n\nALL visual properties MUST use CSS theme variables:\n\n| Property | ✅ CORRECT | ❌ WRONG |\n|----------|-----------|----------|\n| Colors | \"var(--color-primary)\" | \"#3b82f6\", \"blue\", \"white\" |\n| Backgrounds | \"var(--color-card)\" | \"#ffffff\", \"white\" |\n| Text colors | \"var(--color-foreground)\" | \"#000000\", \"black\" |\n| Spacing | \"var(--spacing-lg)\" | \"16px\", \"1rem\" |\n| Radius | \"var(--radius-md)\" | \"8px\", \"0.5rem\" |\n| Shadows | \"var(--shadow-sm)\" | \"0 2px 4px rgba(0,0,0,0.1)\" |\n\n---\n\n### Rule 5: Template-Quality Composition\n\nMatch the sophistication of reference templates in \\`packages/almadar-ui/components/templates/\\`.\n\n#### CrudTemplate Structure\n\\`\\`\\`\nContainer (size: xl, padding: lg)\n └── VStack (gap: lg)\n ├── PageHeader (title + actions)\n ├── Alert (error state)\n ├── EntityTable (searchable, sortable, actions)\n └── Modal (form-section for create/edit)\n\\`\\`\\`\n\n#### ListTemplate Structure\n\\`\\`\\`\nContainer (size: md, padding: lg)\n └── VStack (gap: lg)\n ├── Typography (h2 title)\n ├── Input (search)\n ├── HStack (filter buttons)\n └── VStack (list items)\n\\`\\`\\`\n\n#### Dashboard Structure\n\\`\\`\\`\nContainer (size: full, padding: lg)\n └── Grid (cols: { sm: 1, md: 2, lg: 4 })\n ├── Box (stat card 1)\n ├── Box (stat card 2)\n ├── Box (stat card 3)\n └── Box (stat card 4)\n\\`\\`\\`\n\n#### Stats Cards - Static Text Only\n\nFor stats/overview sections, use **static text labels**, NOT computed bindings:\n\n\\`\\`\\`json\n// ✅ CORRECT: Static text for labels\n{\n \"type\": \"box\",\n \"padding\": \"md\",\n \"bg\": \"var(--color-card)\",\n \"children\": [\n { \"type\": \"typography\", \"variant\": \"caption\", \"text\": \"Total Tasks\" },\n { \"type\": \"typography\", \"variant\": \"h2\", \"text\": \"--\" }\n ]\n}\n\n// ✅ CORRECT: Using stats pattern with entity\n{\n \"type\": \"stats\",\n \"entity\": \"Task\",\n \"label\": \"Total Tasks\"\n}\n\n// ❌ WRONG: Invented computed bindings\n{ \"text\": \"@count\" }\n{ \"text\": \"@count:status=pending\" }\n\\`\\`\\`\n\n---\n\n### Validated Example: Task Management\n\nThis example has been validated with \\`npx @almadar/cli validate\\`:\n\n\\`\\`\\`json\n{\n \"name\": \"Taskly\",\n \"version\": \"1.0.0\",\n \"orbitals\": [{\n \"name\": \"Task Management\",\n \"entity\": {\n \"name\": \"Task\",\n \"collection\": \"tasks\",\n \"fields\": [\n { \"name\": \"title\", \"type\": \"string\", \"required\": true },\n { \"name\": \"status\", \"type\": \"enum\", \"values\": [\"pending\", \"active\", \"done\"] },\n { \"name\": \"priority\", \"type\": \"enum\", \"values\": [\"low\", \"medium\", \"high\"] }\n ]\n },\n \"traits\": [{\n \"name\": \"TaskInteraction\",\n \"category\": \"interaction\",\n \"linkedEntity\": \"Task\",\n \"emits\": [{ \"event\": \"INIT\", \"scope\": \"internal\" }],\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"Browsing\", \"isInitial\": true },\n { \"name\": \"Creating\" }\n ],\n \"events\": [\n { \"key\": \"INIT\", \"name\": \"Initialize\" },\n { \"key\": \"CREATE\", \"name\": \"Create\" },\n { \"key\": \"SAVE\", \"name\": \"Save\", \"payload\": [{ \"name\": \"data\", \"type\": \"object\" }] },\n { \"key\": \"CANCEL\", \"name\": \"Cancel\" }\n ],\n \"transitions\": [\n {\n \"from\": \"Browsing\",\n \"to\": \"Browsing\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"stack\",\n \"direction\": \"vertical\",\n \"gap\": \"lg\",\n \"children\": [\n {\n \"type\": \"page-header\",\n \"title\": \"Task Management\",\n \"actions\": [{ \"label\": \"Create Task\", \"event\": \"CREATE\", \"variant\": \"primary\" }]\n },\n {\n \"type\": \"entity-table\",\n \"entity\": \"Task\",\n \"columns\": [\"title\", \"status\", \"priority\"],\n \"searchable\": true,\n \"itemActions\": [\n { \"label\": \"Edit\", \"event\": \"EDIT\" },\n { \"label\": \"Delete\", \"event\": \"DELETE\" }\n ]\n }\n ]\n }]\n ]\n },\n {\n \"from\": \"Browsing\",\n \"to\": \"Creating\",\n \"event\": \"CREATE\",\n \"effects\": [\n [\"render-ui\", \"modal\", {\n \"type\": \"form-section\",\n \"entity\": \"Task\",\n \"fields\": [\"title\", \"status\", \"priority\"],\n \"submitEvent\": \"SAVE\",\n \"cancelEvent\": \"CANCEL\"\n }]\n ]\n },\n {\n \"from\": \"Creating\",\n \"to\": \"Browsing\",\n \"event\": \"SAVE\",\n \"effects\": [\n [\"persist\", \"create\", \"Task\", \"@payload.data\"],\n [\"render-ui\", \"modal\", null],\n [\"emit\", \"INIT\"]\n ]\n },\n {\n \"from\": \"Creating\",\n \"to\": \"Browsing\",\n \"event\": \"CANCEL\",\n \"effects\": [\n [\"render-ui\", \"modal\", null]\n ]\n }\n ]\n }\n }],\n \"pages\": [{\n \"name\": \"TasksPage\",\n \"path\": \"/tasks\",\n \"viewType\": \"list\",\n \"isInitial\": true,\n \"entity\": \"Task\",\n \"traits\": [{ \"ref\": \"TaskInteraction\" }]\n }],\n \"emits\": [],\n \"listens\": []\n }]\n}\n\\`\\`\\`\n\n---\n\n${getBindingsGuide()}\n\n---\n\n### Critical Validation Rules\n\n| Element | Correct Format | Wrong Format | Error |\n|---------|----------------|--------------|-------|\n| **Events** | \\`{ \"key\": \"INIT\", \"name\": \"Init\" }\\` | \\`\"INIT\"\\` | ORB_T_EVT_INVALID_FORMAT |\n| **Emits** | \\`[{ \"event\": \"INIT\", \"scope\": \"internal\" }}]\\` | \\`[\"INIT\"]\\` | ORB_T_UNDEFINED_TRAIT |\n| **Payload events** | \\`{ \"key\": \"SAVE\", \"payload\": [...] }\\` | No payload | ORB_BINDING_PAYLOAD_FIELD_UNDECLARED |\n| **Page traits** | \\`{ \"ref\": \"TraitName\" }\\` | With linkedEntity | ORB_P_INVALID_TRAIT_REF |\n| **Category** | \\`\"category\": \"interaction\"\\` | Missing | ORB_T_MISSING_CATEGORY |\n\n---\n\n### Composition Quality Checklist\n\nBefore calling \\`finish_task\\`, verify:\n\n\\`\\`\\`\n□ Single render-ui per transition\n□ Root element is layout (stack/box/container/grid)\n□ Contains 2+ atoms (typography, badge, button, etc.)\n□ Contains 1+ molecules (box, card, tabs, alert)\n□ Contains 1+ organisms (entity-table, form-section, page-header)\n□ Uses theme variables for ALL visual properties\n□ Has 3+ distinct sections (header, content, actions)\n□ Matches template quality from almadar-ui/components/templates/\n□ Passes npx @almadar/cli validate with zero errors\n\\`\\`\\`\n\n---\n\n### BANNED Patterns\n\n| Wrong | Correct |\n|-------|---------|\n| Multiple flat render-ui calls | Single composed render-ui |\n| Root organism without layout | Layout wrapper required |\n| Hex colors | Theme CSS variables |\n| Pixel values | Theme spacing variables |\n| Events as strings \\`\"INIT\"\\` | Event objects \\`{ \"key\": \"INIT\" }\\` |\n| Emits as strings \\`[\"INIT\"]\\` | Emit objects \\`[{ \"event\": \"INIT\" }]\\` |\n| \\`onSubmit\\` / \\`onCancel\\` | \\`submitEvent\\` / \\`cancelEvent\\` |\n| \\`headerActions\\` | \\`actions\\` |\n\n---\n\n${getPatternPropsCompact()}\n\n${getPatternActionsRef()}\n`;\n}\n","/**\n * Theme Variable System Guide\n *\n * Teaches the LLM to use CSS theme variables for all visual properties.\n * Enforces consistent theming across all generated schemas.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the theme variable system guide.\n * Covers colors, spacing, radius, and shadows with mandatory enforcement rules.\n */\nexport function getThemeGuide(): string {\n return `## Theme Variable System (MANDATORY)\n\nAll visual properties MUST use CSS theme variables. Never use hardcoded values.\n\n### ❌ BANNED: Hardcoded Values\n\n| Type | Wrong | Why |\n|------|-------|-----|\n| Hex colors | \"#3b82f6\", \"#ffffff\", \"#000000\" | Not themeable |\n| Named colors | \"white\", \"black\", \"red\", \"blue\" | Not themeable |\n| Pixel values | \"16px\", \"8px\", \"24px\" | Not scalable |\n| Rem values | \"1rem\", \"0.5rem\" | Inconsistent |\n| Arbitrary values | \"0 2px 4px rgba(0,0,0,0.1)\" | Not themeable |\n\n### ✅ REQUIRED: Theme Variables\n\n### Color Variables\n\n| Variable | Usage | Example Context |\n|----------|-------|-----------------|\n| \\`var(--color-foreground)\\` | Primary text | Headlines, body text |\n| \\`var(--color-muted-foreground)\\` | Secondary text | Captions, labels, hints |\n| \\`var(--color-background)\\` | Page background | Main container bg |\n| \\`var(--color-card)\\` | Card backgrounds | Box containers, panels |\n| \\`var(--color-muted)\\` | Subtle sections | Alternating rows, disabled states |\n| \\`var(--color-primary)\\` | Primary actions | Main buttons, active states |\n| \\`var(--color-primary-foreground)\\` | Text on primary | Button labels |\n| \\`var(--color-secondary)\\` | Secondary actions | Secondary buttons |\n| \\`var(--color-secondary-foreground)\\` | Text on secondary | Secondary button labels |\n| \\`var(--color-success)\\` | Success states | Completed badges, success alerts |\n| \\`var(--color-warning)\\` | Warnings | Warning badges, alerts |\n| \\`var(--color-destructive)\\` | Errors, delete | Danger buttons, error states |\n| \\`var(--color-border)\\` | Borders, dividers | Card outlines, separators |\n| \\`var(--color-input)\\` | Input backgrounds | Form field backgrounds |\n| \\`var(--color-ring)\\` | Focus rings | Input focus states |\n\n### Spacing Variables\n\n| Variable | Value | Usage |\n|----------|-------|-------|\n| \\`var(--spacing-xs)\\` | 4px | Tight gaps, icon spacing |\n| \\`var(--spacing-sm)\\` | 8px | Small gaps, compact layouts |\n| \\`var(--spacing-md)\\` | 12px | Standard gaps |\n| \\`var(--spacing-lg)\\` | 16px | Large gaps, section padding |\n| \\`var(--spacing-xl)\\` | 24px | Extra large gaps |\n| \\`var(--spacing-2xl)\\` | 32px | Page-level spacing |\n| \\`var(--spacing-3xl)\\` | 48px | Major section spacing |\n| \\`var(--spacing-4xl)\\` | 64px | Hero section spacing |\n\n### Radius Variables\n\n| Variable | Value | Usage |\n|----------|-------|-------|\n| \\`var(--radius-none)\\` | 0px | Sharp corners |\n| \\`var(--radius-sm)\\` | 2px | Small elements, tags |\n| \\`var(--radius-md)\\` | 6px | Buttons, inputs, small cards |\n| \\`var(--radius-lg)\\` | 8px | Cards, panels, modals |\n| \\`var(--radius-xl)\\` | 12px | Large containers |\n| \\`var(--radius-2xl)\\` | 16px | Extra large containers |\n| \\`var(--radius-full)\\` | 9999px | Pills, avatars, badges |\n\n### Shadow Variables\n\n| Variable | Usage |\n|----------|-------|\n| \\`var(--shadow-none)\\` | Flat design, no elevation |\n| \\`var(--shadow-sm)\\` | Subtle elevation, cards |\n| \\`var(--shadow-md)\\` | Cards, dropdowns, popovers |\n| \\`var(--shadow-lg)\\` | Modals, dialogs |\n| \\`var(--shadow-xl)\\` | High elevation elements |\n| \\`var(--shadow-2xl)\\` | Maximum elevation |\n\n### Pattern-Specific Examples\n\n#### Box / Card Container\n\\`\\`\\`json\n{\n \"type\": \"box\",\n \"padding\": \"lg\",\n \"bg\": \"var(--color-card)\",\n \"border\": true,\n \"borderColor\": \"var(--color-border)\",\n \"rounded\": \"var(--radius-lg)\",\n \"shadow\": \"var(--shadow-sm)\"\n}\n\\`\\`\\`\n\n#### Typography\n\\`\\`\\`json\n// Page title\n{\n \"type\": \"typography\",\n \"variant\": \"h1\",\n \"text\": \"Page Title\",\n \"color\": \"var(--color-foreground)\"\n}\n\n// Secondary text\n{\n \"type\": \"typography\",\n \"variant\": \"caption\",\n \"text\": \"Label text\",\n \"color\": \"var(--color-muted-foreground)\"\n}\n\n// Success text\n{\n \"type\": \"typography\",\n \"variant\": \"body\",\n \"text\": \"Completed\",\n \"color\": \"var(--color-success)\"\n}\n\\`\\`\\`\n\n#### Button (use variant, not manual colors)\n\\`\\`\\`json\n// Primary action\n{\n \"type\": \"button\",\n \"label\": \"Save\",\n \"event\": \"SAVE\",\n \"variant\": \"primary\"\n}\n\n// Secondary action\n{\n \"type\": \"button\",\n \"label\": \"Cancel\",\n \"event\": \"CANCEL\",\n \"variant\": \"secondary\"\n}\n\n// Danger action\n{\n \"type\": \"button\",\n \"label\": \"Delete\",\n \"event\": \"DELETE\",\n \"variant\": \"danger\"\n}\n\\`\\`\\`\n\n#### Badge (variant maps to semantic colors)\n\\`\\`\\`json\n{\n \"type\": \"badge\",\n \"text\": \"Active\",\n \"variant\": \"primary\"\n}\n\n{\n \"type\": \"badge\",\n \"text\": \"Completed\",\n \"variant\": \"success\"\n}\n\n{\n \"type\": \"badge\",\n \"text\": \"Pending\",\n \"variant\": \"warning\"\n}\n\n{\n \"type\": \"badge\",\n \"text\": \"Error\",\n \"variant\": \"danger\"\n}\n\\`\\`\\`\n\n#### Stack Layout\n\\`\\`\\`json\n{\n \"type\": \"stack\",\n \"direction\": \"vertical\",\n \"gap\": \"lg\",\n \"align\": \"stretch\",\n \"justify\": \"start\"\n}\n\\`\\`\\`\n\n### Theme Validation Checklist\n\nBefore calling \\`finish_task\\`, verify:\n\n- [ ] No hex colors (#fff, #000, #3b82f6, etc.)\n- [ ] No named colors (white, black, red, blue, etc.)\n- [ ] No pixel values (16px, 8px, 24px, etc.)\n- [ ] No rem values (1rem, 0.5rem, etc.)\n- [ ] All colors use var(--color-*)\n- [ ] All spacing uses var(--spacing-*)\n- [ ] All radius uses var(--radius-*)\n- [ ] All shadows use var(--shadow-*)\n\n### Auto-Correction Reference\n\nThe system will auto-correct these common mistakes:\n\n| Wrong | Auto-Corrected To |\n|-------|-------------------|\n| \"#fff\" or \"white\" | \"var(--color-background)\" |\n| \"#000\" or \"black\" | \"var(--color-foreground)\" |\n| \"#3b82f6\" | \"var(--color-primary)\" |\n| \"#10b981\" | \"var(--color-success)\" |\n| \"#f59e0b\" | \"var(--color-warning)\" |\n| \"#ef4444\" | \"var(--color-destructive)\" |\n| \"16px\" | \"var(--spacing-lg)\" |\n| \"8px\" | \"var(--spacing-sm)\" |\n| \"24px\" | \"var(--spacing-xl)\" |\n| \"8px\" (radius) | \"var(--radius-md)\" |\n`;\n}\n\n/**\n * Get banned properties that should never be used.\n */\nexport function getBannedProps(): string {\n return `## BANNED PROPS (NEVER USE)\n\n| Wrong Prop | Correct Prop | Pattern |\n|------------|--------------|---------|\n| \\`onSubmit\\` | \\`submitEvent\\` | form-section |\n| \\`onCancel\\` | \\`cancelEvent\\` | form-section |\n| \\`headerActions\\` | \\`actions\\` | detail-panel |\n| \\`loading\\` | \\`isLoading\\` | all patterns |\n| \\`fieldNames\\` | \\`fields\\` | detail-panel, form-section |\n| \\`onConfirm\\` | (use event transitions) | confirmation |\n| \\`placement\\` | (remove) | itemActions |\n| \\`isDestructive\\` | (use variant: \"danger\") | itemActions |\n\n### Banned Value Patterns\n\n| Wrong | Correct |\n|-------|---------|\n| Hex colors: \"#3b82f6\" | Theme vars: \"var(--color-primary)\" |\n| Named colors: \"white\", \"red\" | Theme vars: \"var(--color-background)\" |\n| Pixel values: \"16px\" | Theme vars: \"var(--spacing-lg)\" |\n| Events as strings: \"INIT\" | Event objects: { \"key\": \"INIT\", \"name\": \"Init\" } |\n| Emits as strings: [\"INIT\"] | Emit objects: [{ \"event\": \"INIT\", \"scope\": \"internal\" }] |\n`;\n}\n","/**\n * Custom Trait Guidance Section\n *\n * Comprehensive guidance for creating custom traits.\n * Part of the lean orbital skill.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the custom trait guidance section.\n */\nexport function getCustomTraitSection(): string {\n return `## Custom Trait Guide\n\n### When to Create Custom Traits\n\n| Scenario | Approach |\n|----------|----------|\n| Standard CRUD list/view/edit | Use \\`std/List\\` behavior pattern |\n| Multi-step wizard | Custom trait with states = steps |\n| Approval workflow | Custom trait (Drafting \\u2192 InReview \\u2192 Published) |\n| Payment processing | Custom \\`integration\\` trait with call-service |\n| Domain-specific workflow | Custom trait matching business states |\n\n### Trait Categories\n\n| Category | Purpose | Requires render-ui? |\n|----------|---------|---------------------|\n| \\`interaction\\` | UI state machine | **YES** - must render UI |\n| \\`integration\\` | Backend service calls | No |\n\n### Interaction Trait Requirements (CRITICAL)\n\nEvery \\`interaction\\` trait MUST have:\n1. **States as objects** with \\`isInitial\\` flag\n2. **INIT transition** (self-loop on initial state) that renders UI\n3. **render-ui effects** for every state transition\n4. **form-section with onSubmit** to connect forms to events\n\n### Example: Document Publishing Workflow\n\n\\`\\`\\`json\n{\n \"name\": \"DocumentPublishing\",\n \"category\": \"interaction\",\n \"linkedEntity\": \"Document\",\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"Drafting\", \"isInitial\": true },\n { \"name\": \"InReview\" },\n { \"name\": \"Published\" }\n ],\n \"events\": [\n { \"key\": \"INIT\" },\n { \"key\": \"SUBMIT\" },\n { \"key\": \"APPROVE\" },\n { \"key\": \"REJECT\" }\n ],\n \"transitions\": [\n {\n \"from\": \"Drafting\",\n \"to\": \"Drafting\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"page-header\",\n \"title\": \"Edit Document\",\n \"actions\": [{ \"label\": \"Submit\", \"event\": \"SUBMIT\" }]\n }],\n [\"render-ui\", \"main\", {\n \"type\": \"form-section\",\n \"entity\": \"Document\",\n \"fields\": [\"title\", \"content\"],\n \"onSubmit\": \"SUBMIT\"\n }]\n ]\n },\n {\n \"from\": \"Drafting\",\n \"to\": \"InReview\",\n \"event\": \"SUBMIT\",\n \"effects\": [\n [\"set\", \"@entity.status\", \"review\"],\n [\"persist\", \"update\"],\n [\"render-ui\", \"main\", {\n \"type\": \"page-header\",\n \"title\": \"In Review\"\n }],\n [\"render-ui\", \"main\", {\n \"type\": \"detail-panel\",\n \"entity\": \"Document\",\n \"fieldNames\": [\"title\", \"content\"]\n }],\n [\"render-ui\", \"main\", {\n \"type\": \"form-section\",\n \"submitLabel\": \"Approve\",\n \"cancelLabel\": \"Reject\",\n \"onSubmit\": \"APPROVE\",\n \"onCancel\": \"REJECT\"\n }]\n ]\n },\n {\n \"from\": \"InReview\",\n \"to\": \"Drafting\",\n \"event\": \"REJECT\",\n \"effects\": [\n [\"set\", \"@entity.status\", \"draft\"],\n [\"persist\", \"update\"],\n [\"emit\", \"INIT\"]\n ]\n },\n {\n \"from\": \"InReview\",\n \"to\": \"Published\",\n \"event\": \"APPROVE\",\n \"effects\": [\n [\"set\", \"@entity.status\", \"published\"],\n [\"set\", \"@entity.publishedAt\", \"@now\"],\n [\"persist\", \"update\"],\n [\"render-ui\", \"main\", {\n \"type\": \"page-header\",\n \"title\": \"Published!\"\n }],\n [\"render-ui\", \"main\", {\n \"type\": \"detail-panel\",\n \"entity\": \"Document\"\n }]\n ]\n }\n ]\n }\n}\n\\`\\`\\`\n\n**Key Points:**\n- INIT is a self-loop that renders the initial UI\n- Every state transition has render-ui effects\n- form-section always has onSubmit\n- REJECT emits INIT to re-render Drafting state\n\n### Example: Integration Trait (Payment)\n\n\\`\\`\\`json\n{\n \"name\": \"PaymentProcessing\",\n \"category\": \"integration\",\n \"linkedEntity\": \"Order\",\n \"emits\": [\n {\n \"event\": \"ORDER_PAID\",\n \"scope\": \"external\",\n \"description\": \"Emitted when payment succeeds\",\n \"payload\": [\n { \"name\": \"orderId\", \"type\": \"string\", \"required\": true, \"description\": \"The paid order ID\" },\n { \"name\": \"total\", \"type\": \"number\", \"required\": true, \"description\": \"Order total amount\" }\n ]\n }\n ],\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"Pending\", \"isInitial\": true },\n { \"name\": \"Processing\" },\n { \"name\": \"Completed\" },\n { \"name\": \"Failed\" }\n ],\n \"events\": [\n { \"key\": \"PROCESS\" },\n { \"key\": \"SUCCESS\" },\n { \"key\": \"FAILURE\" }\n ],\n \"transitions\": [\n {\n \"from\": \"Pending\",\n \"to\": \"Processing\",\n \"event\": \"PROCESS\",\n \"effects\": [\n [\"call-service\", \"stripe\", \"charge\", {\n \"amount\": \"@entity.total\",\n \"onSuccess\": \"SUCCESS\",\n \"onError\": \"FAILURE\"\n }]\n ]\n },\n {\n \"from\": \"Processing\",\n \"to\": \"Completed\",\n \"event\": \"SUCCESS\",\n \"effects\": [\n [\"set\", \"@entity.paidAt\", \"@now\"],\n [\"persist\", \"update\"],\n [\"emit\", \"ORDER_PAID\", { \"orderId\": \"@entity.id\", \"total\": \"@entity.total\" }]\n ]\n },\n {\n \"from\": \"Processing\",\n \"to\": \"Failed\",\n \"event\": \"FAILURE\",\n \"effects\": [\n [\"notify\", \"Payment failed\", \"error\"]\n ]\n }\n ]\n }\n}\n\\`\\`\\`\n\n**Note:** Integration traits don't need INIT or render-ui - they're triggered by events, not page load.\n\n### Cross-Orbital Communication (CRITICAL)\n\nWhen traits need to communicate across orbitals, you MUST:\n\n1. **Declare emits with payload contract:**\n\\`\\`\\`json\n\"emits\": [\n {\n \"event\": \"ORDER_PAID\",\n \"scope\": \"external\",\n \"description\": \"Emitted when payment is confirmed\",\n \"payload\": [\n { \"name\": \"orderId\", \"type\": \"string\", \"required\": true },\n { \"name\": \"total\", \"type\": \"number\", \"required\": true }\n ]\n }\n]\n\\`\\`\\`\n\n2. **Include payload data in emit effect:**\n\\`\\`\\`json\n[\"emit\", \"ORDER_PAID\", { \"orderId\": \"@entity.id\", \"total\": \"@entity.total\" }]\n\\`\\`\\`\n\n3. **Declare listeners with payloadMapping:**\n\\`\\`\\`json\n\"listens\": [\n {\n \"event\": \"PaymentProcessing.ORDER_PAID\",\n \"scope\": \"external\",\n \"triggers\": \"SEND_RECEIPT\",\n \"payloadMapping\": {\n \"orderId\": \"@payload.orderId\",\n \"amount\": \"@payload.total\"\n }\n }\n]\n\\`\\`\\`\n\n### Anti-Patterns to Avoid\n\n| Anti-Pattern | Problem | Fix |\n|--------------|---------|-----|\n| Missing INIT | Page is blank | Add self-loop with render-ui |\n| States as strings | Validation fails | Use \\`{ \"name\": \"...\", \"isInitial\": true }\\` |\n| No render-ui | UI doesn't update | Add render-ui to every transition |\n| form-section no onSubmit | Form does nothing | Add \\`onSubmit: \"EVENT\"\\` |\n| **Using form-actions** | **Pattern doesn't exist!** | **Use form-section with onSubmit/onCancel** |\n| Duplicate (from, event) | Second unreachable | Use guards or different events |\n| from: '*' | Non-deterministic | Use explicit from state |\n| **External emit no payload** | **Listeners have no data** | **Add payload array with typed fields** |\n| **emit effect no data** | **Payload is empty at runtime** | **Pass payload object: \\`[\"emit\", \"EVT\", {...}]\\`** |\n\n### Pattern Action Props Quick Reference\n\n| Pattern | Action Props | Purpose |\n|---------|--------------|---------|\n| \\`page-header\\` | \\`actions: [{label, event}]\\` | Top-right buttons (New, Export) |\n| \\`form-section\\` | \\`onSubmit\\`, \\`onCancel\\` | Form submit/cancel buttons |\n| \\`entity-table\\` | \\`itemActions: [{label, event}]\\` | Row action buttons (Edit, Delete) |\n| \\`detail-panel\\` | \\`actions: [{label, event}]\\` | Detail view header buttons |\n| \\`confirmation\\` | \\`onConfirm\\`, \\`onCancel\\` | Confirmation dialog buttons |\n`;\n}\n\n/**\n * Get a compact version of custom trait guidance.\n */\nexport function getCustomTraitCompact(): string {\n return `## Custom Traits\n\n**Interaction traits** (UI): MUST have INIT self-loop with render-ui\n**Integration traits** (backend): call-service, no render-ui needed\n\nStates = \\`{ \"name\": \"...\", \"isInitial\": true }\\` (objects, not strings)\nform-section = always include \\`onSubmit: \"EVENT\"\\`\n`;\n}\n","/**\n * Schema Update Guidance\n *\n * Provides guidance for modifying existing orbital schemas.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the full schema update section.\n */\nexport function getSchemaUpdateSection(): string {\n return `## Updating Existing Schemas\n\nWhen modifying an existing orbital schema, follow this systematic approach:\n\n### Step 1: Locate the Target\n\nUse grep/search to find the right location:\n\n\\`\\`\\`bash\n# Find entity by name\ngrep -n '\"entity\"' schema.orb -A 5 | grep \"TaskEntity\"\n\n# Find trait by name\ngrep -n '\"traits\"' schema.orb | head -10\n\n# Find specific trait definition\ngrep -n '\"TaskInteraction\"' schema.orb\n\n# Find state machine transitions\ngrep -n '\"transitions\"' schema.orb -A 30 | head -50\n\n# Find all events\ngrep -n '\"events\"' schema.orb\n\n# Find all pages\ngrep -n '\"pages\"' schema.orb -A 10\n\\`\\`\\`\n\n### Step 2: Identify What to Modify\n\n| Change Type | Location to Find | What to Modify |\n|-------------|------------------|----------------|\n| Add field | \\`\"fields\": [\\` | Add to entity.fields array |\n| Add event | \\`\"events\": [\\` | Add to stateMachine.events |\n| Add state | \\`\"states\": [\\` | Add to stateMachine.states |\n| Add transition | \\`\"transitions\": [\\` | Add to stateMachine.transitions |\n| Add action button | \\`\"page-header\"\\` or \\`\"itemActions\"\\` | Add to pattern props |\n| Add page | \\`\"pages\": [\\` | Add to orbital.pages array |\n| Modify UI | \\`\"render-ui\"\\` | Find transition with target slot |\n\n### Step 3: Common Modifications\n\n**Add a new field to entity:**\n\\`\\`\\`json\n// Find: \"fields\": [\n// Add before the closing bracket:\n{ \"name\": \"priority\", \"type\": \"enum\", \"values\": [\"low\", \"medium\", \"high\"] }\n\\`\\`\\`\n\n**Add a new action button to page-header:**\n\\`\\`\\`json\n// Find: INIT transition's page-header\n// Add to actions array:\n{ \"label\": \"Export\", \"event\": \"EXPORT\", \"variant\": \"secondary\" }\n\\`\\`\\`\n\n**Add a new event:**\n\\`\\`\\`json\n// Find: \"events\": [\n// Add the event:\n{ \"key\": \"EXPORT\", \"name\": \"Export Data\" }\n\\`\\`\\`\n\n**Add a new transition:**\n\\`\\`\\`json\n// Find: \"transitions\": [\n// Add after existing transitions:\n{\n \"from\": \"Browsing\",\n \"to\": \"Exporting\",\n \"event\": \"EXPORT\",\n \"effects\": [\n [\"render-ui\", \"modal\", { \"type\": \"confirmation\", \"title\": \"Export?\", \"onConfirm\": \"CONFIRM_EXPORT\", \"onCancel\": \"CANCEL\" }]\n ]\n}\n\\`\\`\\`\n\n**Add itemActions to entity-table:**\n\\`\\`\\`json\n// Find: \"entity-table\" in INIT transition\n// Add itemActions prop:\n\"itemActions\": [\n { \"label\": \"View\", \"event\": \"VIEW\" },\n { \"label\": \"Edit\", \"event\": \"EDIT\" },\n { \"label\": \"Delete\", \"event\": \"DELETE\", \"isDestructive\": true }\n]\n\\`\\`\\`\n\n### Step 4: Ensure Completeness\n\nAfter any modification, verify:\n\n1. **New events have matching transitions** - Every event must have at least one transition that uses it\n2. **New states are reachable** - Every state must have a transition leading to it\n3. **New states have exit transitions** - Every state (except browsing) needs a way back\n4. **UI slots are cleared** - Modals/drawers opened must be closed with \\`[\"render-ui\", \"modal\", null]\\`\n\n### Quick Reference: Finding Traits\n\nTraits are defined in two places:\n\n1. **Inline in orbital** (most common):\n\\`\\`\\`json\n\"orbitals\": [{\n \"traits\": [{\n \"name\": \"TaskInteraction\",\n \"stateMachine\": { ... } // <-- trait definition here\n }]\n}]\n\\`\\`\\`\n\n2. **Referenced from library**:\n\\`\\`\\`json\n\"orbitals\": [{\n \"traits\": [{\n \"ref\": \"std/crud\" // <-- references external trait\n }]\n}]\n\\`\\`\\`\n\nFor inline traits, grep for the trait name. For library traits, find the library file.\n\n---\n\n## Large Schema Handling (40KB+)\n\nFor schemas exceeding 40KB, use the **chunking tools** instead of direct editing:\n\n### Available Tools\n\n| Tool | Purpose |\n|------|---------|\n| \\`query_schema_structure\\` | Get lightweight map (~500 bytes): orbitals, traits, sizes |\n| \\`extract_chunk\\` | Extract orbital/trait to \\`.chunks/chunk-{id}.json\\` |\n| \\`apply_chunk\\` | Merge edited chunk back into schema |\n\n**Note**: These tools work with \\`schema.orb\\` files. Changes are auto-persisted.\n\n### Chunking Workflow\n\n\\`\\`\\`\n1. DISCOVER: query_schema_structure(\"schema.orb\")\n → Returns structure map with orbital/trait names\n\n2. EXTRACT: extract_chunk({ file: \"schema.orb\", type: \"orbital\", name: \"Task Management\" })\n → Creates .chunks/chunk-{id}.json (2-5KB, easy to edit)\n\n3. EDIT: Use edit_file on chunk file (NOT full schema)\n → Much smaller = reliable edits\n\n4. APPLY: apply_chunk({ chunkId: \"...\" })\n → Merges changes back into schema.orb, auto-persists to database\n\\`\\`\\`\n\n### Chunk Types\n\n| Type | When to Use |\n|------|-------------|\n| \\`orbital\\` | Adding fields, modifying inline traits |\n| \\`inline-trait\\` | Editing trait inside an orbital (requires \\`parentOrbital\\`) |\n\n**Note**: There is no schema-level \\`traits[]\\` array. All traits belong inside orbitals.\n\n### When to Use Chunking\n\n| Schema Size | Strategy |\n|-------------|----------|\n| < 15KB | Direct edit (works fine) |\n| 15-40KB | Targeted edit_file |\n| > 40KB | **Use chunking tools** |`;\n}\n\n/**\n * Get compact schema update guidance (shorter version).\n */\nexport function getSchemaUpdateCompact(): string {\n return `## Schema Updates Quick Reference\n\n**Find location:**\n\\`\\`\\`bash\ngrep -n '\"entity\"' schema.orb -A 5 # Find entities\ngrep -n '\"traits\"' schema.orb # Find traits\ngrep -n '\"transitions\"' schema.orb # Find transitions\n\\`\\`\\`\n\n**Common changes:**\n| Change | Find | Add to |\n|--------|------|--------|\n| Field | \\`\"fields\": [\\` | Entity fields array |\n| Event | \\`\"events\": [\\` | StateMachine events |\n| State | \\`\"states\": [\\` | StateMachine states |\n| Transition | \\`\"transitions\": [\\` | StateMachine transitions |\n| Button | \\`\"page-header\"\\` | actions array |\n| Row action | \\`\"entity-table\"\\` | itemActions array |\n\n**After changes, verify:**\n- New events have transitions using them\n- New states are reachable and have exits\n- Modals/drawers are closed on completion`;\n}\n","/**\n * Context Usage Section\n *\n * Guidance for using embedded context when generating orbitals.\n * Small, reusable section for skill generators.\n *\n * @packageDocumentation\n */\n\n/**\n * Get guidance for using embedded context during generation.\n */\nexport function getContextUsageSection(): string {\n return `## Using Embedded Context\n\nWhen generating, read context from the orbital:\n\n| Context Field | Usage |\n|---------------|-------|\n| \\`domainContext.requestFragment\\` | Understand what user asked for |\n| \\`domainContext.category\\` | Influences pattern selection |\n| \\`domainContext.vocabulary\\` | Use for button labels, titles, messages |\n| \\`design.style\\` | Influences visual density and components |\n| \\`design.uxHints.flowPattern\\` | Determines overall navigation structure |\n| \\`design.uxHints.listPattern\\` | Use for entity display (table/cards/list) |\n| \\`design.uxHints.formPattern\\` | Use for create/edit (modal/drawer/page) |\n| \\`design.uxHints.detailPattern\\` | Use for detail view (drawer/page/split) |\n| \\`design.uxHints.relatedLinks\\` | Add navigation to related orbitals |\n\n**Example usage in generation:**\n\\`\\`\\`\nIf domainContext.vocabulary.create = \"Recruit\"\n → Button label: \"Recruit\" instead of \"Create\"\n\nIf design.uxHints.listPattern = \"entity-cards\"\n → Use entity-cards pattern instead of entity-table\n\nIf design.uxHints.formPattern = \"drawer\"\n → Render create/edit forms in drawer slot\n\\`\\`\\`\n`;\n}\n\n/**\n * Get compact context usage for space-constrained prompts.\n */\nexport function getContextUsageCompact(): string {\n return `## Context Usage\n- \\`domainContext.vocabulary\\` → labels (item, create, delete)\n- \\`design.uxHints.listPattern\\` → entity-table | entity-cards | entity-list\n- \\`design.uxHints.formPattern\\` → modal | drawer | page\n- \\`design.uxHints.relatedLinks\\` → navigation to related orbitals\n`;\n}\n","/**\n * Design-Specific Errors Section\n *\n * Common errors specific to the design skill that transforms\n * wireframe schemas into polished applications.\n *\n * @packageDocumentation\n */\n\n/**\n * Get design-specific common errors section.\n * These are the most frequent mistakes when beautifying schemas.\n */\nexport function getDesignErrorsSection(): string {\n return `## ❌ Design-Specific Errors\n\n| Error | Wrong | Correct |\n|-------|-------|---------|\n| Entity binding | \\`@entity.task.title\\` | \\`@entity.title\\` |\n| Toast effect | \\`[\"toast\", \"success\", \"msg\"]\\` | \\`[\"notify\", \"in_app\", \"msg\"]\\` |\n| Select missing options | \\`{ \"type\": \"select\" }\\` | Add \\`\"options\": [{ \"value\": \"x\", \"label\": \"X\" }]\\` |\n| Undefined trait | \\`{ \"ref\": \"NewTrait\" }\\` | Define trait in \\`traits[]\\` FIRST |\n| Missing action | \\`{ \"type\": \"button\" }\\` | \\`{ \"type\": \"button\", \"action\": \"SAVE\" }\\` |\n\n### Entity Bindings (CRITICAL)\n\n\\`@entity\\` already knows the entity type. Access fields directly:\n\n\\`\\`\\`\n✅ @entity.title - Direct field access\n✅ @entity.address.city - Nested object field (address is an object)\n❌ @entity.task.title - Wrong! \"task\" is the entity type, not a field\n\\`\\`\\`\n\n### Notification Effects\n\nUse \\`notify\\` effect, NOT \\`toast\\`:\n\n\\`\\`\\`json\n[\"notify\", \"in_app\", \"Saved!\", \"success\"] // ✅ Correct\n[\"toast\", \"success\", \"Saved!\"] // ❌ Invalid effect\n\\`\\`\\`\n\nVariants: \\`success\\`, \\`error\\`, \\`warning\\`, \\`info\\`\n\n### Form Select Fields\n\nSelect fields REQUIRE options array:\n\n\\`\\`\\`json\n// ❌ Wrong - missing options\n{ \"name\": \"status\", \"type\": \"select\" }\n\n// ✅ Correct - options provided\n{\n \"name\": \"status\",\n \"type\": \"select\",\n \"options\": [\n { \"value\": \"todo\", \"label\": \"To Do\" },\n { \"value\": \"done\", \"label\": \"Done\" }\n ]\n}\n\\`\\`\\`\n`;\n}\n\n/**\n * Get compact design errors for lean skill.\n */\nexport function getDesignErrorsCompact(): string {\n return `## ❌ Design Errors\n\n| Wrong | Correct |\n|-------|---------|\n| \\`@entity.task.title\\` | \\`@entity.title\\` |\n| \\`[\"toast\", \"success\", \"msg\"]\\` | \\`[\"notify\", \"in_app\", \"msg\"]\\` |\n| \\`{ \"type\": \"select\" }\\` | Add \\`options: [{value, label}]\\` |\n| \\`{ \"ref\": \"NewTrait\" }\\` | Define in \\`traits[]\\` first |\n`;\n}\n\n/**\n * Get icon library reference.\n */\nexport function getIconLibrarySection(): string {\n return `### Icons (Lucide)\n\nUse kebab-case icon names from Lucide:\n\n| Category | Icons |\n|----------|-------|\n| Actions | \\`plus\\`, \\`pencil\\`, \\`trash\\`, \\`eye\\`, \\`check\\`, \\`x\\`, \\`save\\` |\n| Navigation | \\`chevron-left\\`, \\`chevron-right\\`, \\`arrow-left\\`, \\`home\\`, \\`menu\\` |\n| Status | \\`check-circle\\`, \\`x-circle\\`, \\`alert-circle\\`, \\`clock\\`, \\`loader\\` |\n| Content | \\`file\\`, \\`folder\\`, \\`image\\`, \\`list\\`, \\`grid\\`, \\`clipboard\\` |\n| UI | \\`search\\`, \\`filter\\`, \\`settings\\`, \\`more-horizontal\\`, \\`bell\\` |\n\n\\`\\`\\`json\n{ \"type\": \"button\", \"icon\": \"plus\", \"label\": \"Add\" }\n{ \"label\": \"Delete\", \"icon\": \"trash\", \"event\": \"DELETE\" }\n\\`\\`\\`\n`;\n}\n\n/**\n * Get compact icon reference.\n */\nexport function getIconLibraryCompact(): string {\n return `**Icons (Lucide)**: \\`plus\\`, \\`pencil\\`, \\`trash\\`, \\`check-circle\\`, \\`x-circle\\`, \\`eye\\`, \\`settings\\`, \\`search\\`, \\`filter\\``;\n}\n","/**\n * Fixing Guidance Section\n *\n * Specialized guidance for fixing validation errors in orbital schemas.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the fixing workflow section.\n */\nexport function getFixingWorkflowSection(): string {\n return `## Fixing Workflow\n\n### Step 0: Read the Existing Schema\n\n**BEFORE anything else, read schema.orb:**\n\n\\`\\`\\`\nRead(\"schema.orb\")\n\\`\\`\\`\n\nYou are FIXING an existing schema, NOT creating a new one.\n\n**Rules:**\n- The schema already exists at \\`schema.orb\\` — READ it first\n- Understand the current entities, traits, and pages before making changes\n- NEVER generate new orbitals or entities — only fix validation errors in what exists\n- NEVER overwrite schema.orb with a new schema — only apply targeted edits\n- If schema.orb does not exist, STOP and report the issue (do not create a new schema)\n\n### Understanding Validation Errors\n\nValidation output format:\n\\`\\`\\`\n❌ [ERROR_CODE] path.to.error: Description\n 💡 Fix hint\n\\`\\`\\`\n\n**The path tells you exactly where to edit.**\n\n| Error Path | What to Edit |\n|------------|--------------|\n| \\`orbitals[0].entity.fields\\` | Add/modify entity fields |\n| \\`orbitals[0].traits[0].stateMachine.transitions[1]\\` | Add/modify transition |\n| \\`orbitals[0].traits[0].stateMachine.states\\` | Add state or mark isTerminal |\n| \\`...effects[0][2].children[1].children[0].children[1].text\\` | Fix binding in render-ui |\n\n### Step 1: Validate and Analyze\n\n\\`\\`\\`\nvalidate_schema()\n\\`\\`\\`\n\n**CRITICAL: Before fixing, you MUST understand the full scope of errors.**\n\nParse and categorize all errors:\n- **Entity errors**: Field types, relations, collection names\n- **Trait errors**: State machine, events, transitions\n- **Page errors**: Missing traits, invalid references\n- **Pattern errors**: Missing required fields in render-ui\n\n**Count errors by orbital and severity.**\n\n### Step 2: Create Fix Plan\n\n**BEFORE making any edits, write out your fix plan:**\n\n\\`\\`\\`\n## Fix Plan\n\n### Summary\n- Total errors: X (Y critical, Z warnings)\n- Affected orbitals: [list]\n- Estimated complexity: simple|medium|complex\n\n### Execution Order\n1. **Fix [ID]**: [Description] -> [Target location]\n2. **Fix [ID]**: [Description] -> [Target location]\n3. ...\n\n### Dependencies\n- Fix X must happen before Fix Y\n- Group A fixes can be batched\n\\`\\`\\`\n\n**Planning Rules:**\n- Group related fixes (same orbital, same component)\n- Identify dependencies (entity fields before bindings)\n- Prioritize critical errors first\n- Estimate if fix is simple (1 edit) or needs multiple steps\n\n### Step 3: Execute Fixes\n\n**Execute your plan systematically:**\n\nFor each fix in your plan:\n1. **Apply the fix** using Edit tool\n2. **Verify the fix** - check the specific error is resolved\n3. **Track progress** - note which fixes are done\n\n**Execution Order (Priority):**\n1. **Entity structure fixes** (add missing entity, fields, persistence)\n2. **Event/state fixes** (add missing events, states, transitions)\n3. **Effect fixes** (render-ui effects, bindings)\n4. **Pattern property fixes** (missing columns, fields, actions)\n5. **Minor syntax fixes** (enum values, type corrections)\n\n**Batching Strategy:**\n- Fix ALL errors of the same type in one orbital per edit\n- If errors span multiple orbitals, create separate edits\n- Document what each edit fixes\n\n### Step 4: Re-validate and Verify\n\n\\`\\`\\`\nvalidate_schema()\n\\`\\`\\`\n\n**After each batch of fixes, re-validate to confirm progress.**\n\nCompare results with your plan:\n- Expected errors resolved\n- New errors appeared (unintended side effects)\n- Errors still present (fix did not work)\n\n**If new errors appear:**\n1. Analyze the new error\n2. Update your fix plan\n3. Continue execution\n\n### Step 5: Final Summary\n\n**Call finish_task with:**\n- Summary of what was fixed\n- Number of edits made\n- Any warnings or notes\n`;\n}\n\n/**\n\n/**\n * Get common fix patterns section.\n */\nexport function getCommonFixPatternsSection(): string {\n return `## Common Fix Patterns\n\n### Entity Fixes\n\n| Error | Before | After |\n|-------|--------|-------|\n| Wrong enum syntax | \\`\"enumValues\": [...]\\` | \\`\"values\": [...]\\` |\n| Wrong relation | \\`\"type\": \"many-to-one\"\\` | \\`\"relationType\": \"many-to-one\"\\` |\n| Missing collection | (none) | \\`\"collection\": \"tasks\"\\` |\n\n### State Machine Fixes\n\n| Error | Before | After |\n|-------|--------|-------|\n| No initial state | \\`{ \"name\": \"Idle\" }\\` | \\`{ \"name\": \"Idle\", \"isInitial\": true }\\` |\n| String states | \\`\"states\": [\"Idle\"]\\` | \\`\"states\": [{ \"name\": \"Idle\", \"isInitial\": true }]\\` |\n| Missing event | (not in events) | Add to \\`\"events\": [...]\\` |\n\n### Transition Fixes\n\n| Error | Fix |\n|-------|-----|\n| No INIT transition | Add self-loop: \\`{ \"from\": \"Browsing\", \"to\": \"Browsing\", \"event\": \"INIT\", \"effects\": [...] }\\` |\n| Orphan state | Add transition TO the state from initial |\n| No exit from state | Add transition FROM the state back to browsing |\n\n### Pattern Fixes (in render-ui effects)\n\n| Pattern | Missing | Add |\n|---------|---------|-----|\n| \\`entity-table\\` | columns | \\`\"columns\": [\"field1\", \"field2\"]\\` |\n| \\`entity-table\\` | itemActions | \\`\"itemActions\": [{ \"label\": \"Edit\", \"event\": \"EDIT\" }]\\` |\n| \\`form-section\\` | onSubmit | \\`\"onSubmit\": \"SAVE\"\\` |\n| \\`form-section\\` | fields | \\`\"fields\": [\"field1\", \"field2\"]\\` |\n| \\`detail-panel\\` | fields | \\`\"fields\": [\"field1\", \"field2\"]\\` |\n| \\`page-header\\` | actions | \\`\"actions\": [{ \"label\": \"New\", \"event\": \"CREATE\" }]\\` |\n\n### Binding Format Fixes (CRITICAL)\n\nValidator error: \\`ORB_BINDING_INVALID_FORMAT\\` - \"Invalid binding format: '@count:status=pending'\"\nSuggestion: \"Use @root.field.nested format\" means \\`@entity.fieldName\\`, NOT literal \"root\".\n\n**Common Invalid Patterns from Validator:**\n| Invalid Binding | Validator Message | Fix |\n|-----------------|-------------------|-----|\n| \\`@count\\` | Invalid binding format | Remove OR use \\`@entity.count\\` with computed field |\n| \\`@count:status=pending\\` | Invalid binding format | \\`@entity.pendingCount\\` + add computed field |\n| \\`@count:status=active\\` | Invalid binding format | \\`@entity.activeCount\\` + add computed field |\n| \\`@count:status=done\\` | Invalid binding format | \\`@entity.doneCount\\` + add computed field |\n\n**Step-by-Step Fix Process:**\n\nGiven error: \\`ORB_BINDING_INVALID_FORMAT\\` at path \\`orbitals[0].traits[0]...children[1].text\\`\n\n1. **Extract orbital index** from path (e.g., \\`orbitals[0]\\` -> index 0)\n2. **Find the invalid binding** (e.g., \\`\"@count:status=pending\"\\`)\n3. **Add computed fields** to orbital's entity:\n\\`\\`\\`json\n// In orbitals[0].entity.fields array, ADD:\n{ \"name\": \"pendingCount\", \"type\": \"number\", \"default\": 0 },\n{ \"name\": \"activeCount\", \"type\": \"number\", \"default\": 0 },\n{ \"name\": \"doneCount\", \"type\": \"number\", \"default\": 0 }\n\\`\\`\\`\n4. **Replace ALL invalid bindings** in render-ui:\n\\`\\`\\`json\n// BEFORE:\n{ \"type\": \"badge\", \"text\": \"@count:status=pending\", \"variant\": \"warning\" }\n// AFTER:\n{ \"type\": \"badge\", \"text\": \"@entity.pendingCount\", \"variant\": \"warning\" }\n\\`\\`\\`\n\n**Validator Error Code Reference:**\n| Code | Meaning | Action |\n|------|---------|--------|\n| \\`ORB_BINDING_INVALID_FORMAT\\` | Binding syntax wrong | Use \\`@entity.field\\` format |\n| \\`ORB_BINDING_UNKNOWN_ROOT\\` | Wrong root prefix | Use \\`@entity\\`, \\`@payload\\`, \\`@state\\`, \\`@now\\` |\n| \\`ORB_BINDING_INVALID_PATH\\` | Field doesn't exist | Add field to entity OR correct name |\n| \\`ORB_BINDING_STATE_NO_PATH\\` | \\`@state\\` needs no path | Use \\`@state\\` alone, not \\`@state.field\\` |`;\n}\n\n/**\n * Get over-generation detection section.\n */\nexport function getOverGenerationSection(): string {\n return `## Over-Generation Detection\n\n**Signs of over-generation:**\n- TaskListPage + TaskCreatePage + TaskEditPage + TaskViewPage (4 pages for 1 entity!)\n- Multiple pages for the same entity CRUD\n\n**Fix:** Consolidate to ONE page with trait-driven UI:\n\n\\`\\`\\`json\n// KEEP only:\n{\n \"pages\": [{\n \"name\": \"TasksPage\",\n \"path\": \"/tasks\",\n \"viewType\": \"list\",\n \"traits\": [{ \"ref\": \"TaskInteraction\" }]\n }]\n}\n\n// DELETE separate create/edit/view pages\n\\`\\`\\`\n\nThe trait's render-ui effects handle all UI (modals for create/edit, drawers for view).`;\n}\n\n/**\n * Get efficiency guidelines section.\n */\nexport function getEfficiencySection(): string {\n return `## Efficiency Guidelines\n\nTarget: **3-5 tool calls** for most fixes.\n\n### For Small Schemas (< 15KB)\n\n\\`\\`\\`\nStep 1: Read schema.orb (1 call)\nStep 2: Edit to fix ALL errors at once (1 call)\nStep 3: Validate if needed (1 call)\nTotal: 3 tool calls\n\\`\\`\\`\n\n### For Large Schemas (> 15KB) - MANDATORY CHUNKING\n\n**⚠️ WARNING: For schemas larger than 15KB, you MUST use chunking tools.**\n\nDirect edit_file on large schemas will fail or consume excessive tokens. ALWAYS use this workflow:\n\n\\`\\`\\`\nMANDATORY Step 1: query_schema_structure(\"schema.orb\")\n → Check totalSize field\n\nMANDATORY Step 2: extract_chunk({\n file: \"schema.orb\",\n type: \"orbital\", \n name: \"TargetOrbitalName\"\n })\n → Returns: { chunkId: \"abc123\", chunkFile: \".chunks/chunk-abc123.json\" }\n\nMANDATORY Step 3: edit_file({\n path: \".chunks/chunk-abc123.json\",\n old_string: ...,\n new_string: ...\n })\n\nMANDATORY Step 4: apply_chunk({ chunkId: \"abc123\" })\n → Merges back to schema.orb\n\\`\\`\\`\n\n**NEVER** use Read/Edit directly on schema files > 15KB. **ALWAYS** use chunking.\n\n**DO:**\n- **Target 3 tool calls** for simple fixes (read → edit → done)\n- Fix ONLY what the user asked for (don't over-fix)\n- Batch related changes in ONE edit\n- Use chunking for schemas > 15KB\n\n**DON'T:**\n- Fix errors the user didn't ask about\n- Add missing transitions/states unless explicitly requested\n- Read schema multiple times without changes\n- Make multiple small edits - do ONE comprehensive edit\n- Re-verify after validation passes\n- Create documentation files`;\n}\n\n/**\n * Get completion rules section.\n */\nexport function getCompletionRulesSection(): string {\n return `## Completion Rules\n\n**STOP IMMEDIATELY when:**\n- \\`validate_schema()\\` returns \\`\"valid\": true\\`\n\n**After validation passes:**\n1. Mark todos complete\n2. STOP - do not add more tasks\n3. Do NOT create documentation\n4. Do NOT \"verify\" or \"confirm\"\n5. Do NOT validate again\n\nThe validated schema.orb IS your only deliverable.`;\n}\n","/**\n * Game Guidance Section\n *\n * Specialized guidance for generating game orbital schemas.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the game as orbitals composition section.\n */\nexport function getGameAsOrbitalsSection(): string {\n return `## Games as Orbital Composition\n\nA game is a **list of orbitals**, each representing a game element:\n\n\\`\\`\\`\nGame Application = Σ(Game Orbitals)\n\n├── Player Orbital (runtime entity + input/physics traits)\n├── Enemy Orbital (runtime entity + AI/physics traits)\n├── Item Orbital (runtime entity + collectible trait)\n├── Level Orbital (singleton entity + level loader trait)\n└── GameState Orbital (singleton + score/health traits)\n\\`\\`\\`\n\n### Persistence Types for Games\n\n| Type | Use Case | Example |\n|------|----------|---------|\n| \\`runtime: true\\` | Active game objects | Player, Enemy, Bullet |\n| \\`singleton: true\\` | Global state | GameConfig, LevelState |\n| \\`collection: \"...\"\\` | Saved data | HighScores, SavedGames |`;\n}\n\n/**\n * Get game entity templates section.\n */\nexport function getGameEntityTemplatesSection(): string {\n return `## Game Entity Templates\n\n### Player Entity (runtime)\n\n\\`\\`\\`json\n{\n \"name\": \"Player\",\n \"runtime\": true,\n \"fields\": [\n { \"name\": \"x\", \"type\": \"number\", \"default\": 100 },\n { \"name\": \"y\", \"type\": \"number\", \"default\": 100 },\n { \"name\": \"velocityX\", \"type\": \"number\", \"default\": 0 },\n { \"name\": \"velocityY\", \"type\": \"number\", \"default\": 0 },\n { \"name\": \"health\", \"type\": \"number\", \"default\": 100 },\n { \"name\": \"facing\", \"type\": \"enum\", \"values\": [\"left\", \"right\"], \"default\": \"right\" }\n ]\n}\n\\`\\`\\`\n\n### GameState Entity (singleton)\n\n\\`\\`\\`json\n{\n \"name\": \"GameState\",\n \"singleton\": true,\n \"fields\": [\n { \"name\": \"score\", \"type\": \"number\", \"default\": 0 },\n { \"name\": \"level\", \"type\": \"number\", \"default\": 1 },\n { \"name\": \"lives\", \"type\": \"number\", \"default\": 3 },\n { \"name\": \"state\", \"type\": \"enum\", \"values\": [\"menu\", \"playing\", \"paused\", \"gameOver\"] }\n ]\n}\n\\`\\`\\`\n\n### Enemy Entity (runtime)\n\n\\`\\`\\`json\n{\n \"name\": \"Enemy\",\n \"runtime\": true,\n \"fields\": [\n { \"name\": \"x\", \"type\": \"number\" },\n { \"name\": \"y\", \"type\": \"number\" },\n { \"name\": \"health\", \"type\": \"number\", \"default\": 30 },\n { \"name\": \"damage\", \"type\": \"number\", \"default\": 10 },\n { \"name\": \"patrolStart\", \"type\": \"number\" },\n { \"name\": \"patrolEnd\", \"type\": \"number\" }\n ]\n}\n\\`\\`\\``;\n}\n\n/**\n * Get game traits section.\n */\nexport function getGameTraitsSection(): string {\n return `## Game Traits\n\n### Core Game Traits\n\n| Trait | Purpose | Key States |\n|-------|---------|------------|\n| \\`Physics2D\\` | Gravity, velocity | grounded, airborne, falling |\n| \\`PlatformerInput\\` | Movement controls | idle, moving, jumping |\n| \\`Health\\` | Damage, death | alive, hurt, dead |\n| \\`Score\\` | Points tracking | (stateless - just effects) |\n| \\`Collectible\\` | Pickup items | available, collected |\n| \\`Patrol\\` | Enemy AI | patrolling, reversing |\n| \\`GameState\\` | Game flow | menu, playing, paused, gameOver |\n\n### Game Trait Example\n\n\\`\\`\\`json\n{\n \"name\": \"Physics2D\",\n \"category\": \"interaction\",\n \"linkedEntity\": \"Player\",\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"grounded\", \"isInitial\": true },\n { \"name\": \"airborne\" }\n ],\n \"events\": [\n { \"key\": \"JUMP\", \"name\": \"Jump\" },\n { \"key\": \"LAND\", \"name\": \"Land\" }\n ],\n \"transitions\": [\n {\n \"from\": \"grounded\",\n \"to\": \"airborne\",\n \"event\": \"JUMP\",\n \"effects\": [\n [\"set\", \"@entity.velocityY\", -15],\n [\"emit\", \"PLAYER_JUMPED\", \"@entity\"]\n ]\n },\n {\n \"from\": \"airborne\",\n \"to\": \"grounded\",\n \"event\": \"LAND\",\n \"effects\": [\n [\"set\", \"@entity.velocityY\", 0],\n [\"set\", \"@entity.isGrounded\", true]\n ]\n }\n ]\n }\n}\n\\`\\`\\``;\n}\n\n/**\n * Get game patterns section.\n */\nexport function getGamePatternsSection(): string {\n return `## Game UI Patterns\n\n| Pattern | Slot | Purpose |\n|---------|------|---------|\n| \\`game-canvas\\` | main | Main game rendering |\n| \\`game-hud\\` | overlay | Score, health, lives |\n| \\`game-controls\\` | overlay | Touch/keyboard hints |\n| \\`game-menu\\` | modal | Pause, settings |\n\n### Game Canvas Effect\n\n\\`\\`\\`json\n[\"render-ui\", \"main\", {\n \"type\": \"game-canvas\",\n \"entities\": [\"Player\", \"Enemy\", \"Coin\", \"Platform\"],\n \"camera\": { \"follow\": \"Player\" },\n \"physics\": { \"gravity\": 980 }\n}]\n\\`\\`\\`\n\n### Game HUD Effect\n\n\\`\\`\\`json\n[\"render-ui\", \"overlay\", {\n \"type\": \"game-hud\",\n \"elements\": [\n { \"type\": \"health-bar\", \"entity\": \"Player\", \"field\": \"health\" },\n { \"type\": \"score-display\", \"entity\": \"GameState\", \"field\": \"score\" },\n { \"type\": \"lives-counter\", \"entity\": \"GameState\", \"field\": \"lives\" }\n ]\n}]\n\\`\\`\\``;\n}\n\n/**\n * Get asset reference section.\n */\nexport function getAssetRefSection(): string {\n return `## Asset References\n\n**NEVER hardcode asset paths. Use assetRef:**\n\n\\`\\`\\`json\n{\n \"entity\": {\n \"name\": \"Player\",\n \"assetRef\": {\n \"role\": \"player\",\n \"category\": \"hero\",\n \"animations\": [\"idle\", \"run\", \"jump\", \"fall\", \"hurt\"],\n \"style\": \"pixel\"\n }\n }\n}\n\\`\\`\\`\n\nThe compiler resolves \\`assetRef\\` to actual sprite paths at build time.\n\n### Animation Mapping\n\n| State | Animation |\n|-------|-----------|\n| grounded + idle | \\`idle\\` |\n| grounded + moving | \\`run\\` |\n| airborne + velocityY < 0 | \\`jump\\` |\n| airborne + velocityY > 0 | \\`fall\\` |\n| taking damage | \\`hurt\\` |\n| health <= 0 | \\`die\\` |`;\n}\n\n/**\n * Get multi-file composition section.\n */\nexport function getMultiFileSection(): string {\n return `## Multi-File Composition\n\nSplit large games into multiple .orb files:\n\n\\`\\`\\`\ngame/\n├── game.orb # Main schema with Player, GameState\n├── enemies.orb # Enemy orbital definitions\n├── items.orb # Collectibles, powerups\n└── tiles.orb # Platforms, terrain\n\\`\\`\\`\n\n### External Reference Syntax\n\n\\`\\`\\`json\n{\n \"name\": \"Level1Enemies\",\n \"ref\": \"./enemies.orb#Slime\",\n \"instances\": [\n { \"id\": \"slime-1\", \"position\": { \"x\": 300, \"y\": 400 } },\n { \"id\": \"slime-2\", \"position\": { \"x\": 600, \"y\": 400 } }\n ]\n}\n\\`\\`\\``;\n}\n\n/**\n * Get game types section.\n */\nexport function getGameTypesSection(): string {\n return `## Game Type Templates\n\n### Platformer\n- Player with Physics2D + PlatformerInput\n- Platform entities for level layout\n- Collectible coins/items\n- Enemies with Patrol trait\n\n### Puzzle (Match-3, Tetris)\n- Grid-based entity (runtime singleton)\n- Tile/Piece entities\n- Match detection logic in trait\n- Score tracking\n\n### Roguelike\n- Player with Health + Inventory\n- Dungeon/Room singleton for level gen\n- Enemy entities with AI traits\n- Turn-based or real-time movement\n\n### Endless Runner\n- Player at fixed X, jumping\n- Obstacles spawning and moving\n- Procedural difficulty scaling\n- Distance-based scoring`;\n}\n","/**\n * Uses Import System Section\n *\n * Guidance for using the `uses` declaration to import external orbitals.\n *\n * @packageDocumentation\n */\n\n/**\n * Get the uses import system section.\n */\nexport function getUsesImportSection(): string {\n return `## Orbital Import System (\\`uses\\`)\n\nOrbitals can import other orbitals to reuse their components.\n\n### Basic Usage\n\n\\`\\`\\`json\n{\n \"name\": \"Level1\",\n \"uses\": [\n { \"from\": \"./goblin.orb\", \"as\": \"Goblin\" },\n { \"from\": \"./health.orb\", \"as\": \"Health\" }\n ],\n \"entity\": \"Goblin.entity\",\n \"traits\": [\n \"Goblin.traits.Movement\",\n \"Health.traits.Health\"\n ],\n \"pages\": []\n}\n\\`\\`\\`\n\n### Component References\n\nAfter importing with \\`uses\\`, access components via:\n\n| Component | Reference Format | Example |\n|-----------|------------------|---------|\n| Entity | \\`Alias.entity\\` | \\`\"entity\": \"Goblin.entity\"\\` |\n| Trait | \\`Alias.traits.TraitName\\` | \\`\"traits\": [\"Health.traits.Health\"]\\` |\n| Page | \\`Alias.pages.PageName\\` | \\`\"pages\": [\"User.pages.Profile\"]\\` |\n\n### Page Path Override\n\nWhen importing a page, you can override its URL path:\n\n\\`\\`\\`json\n{\n \"pages\": [\n { \"ref\": \"User.pages.Profile\", \"path\": \"/my-profile\" }\n ]\n}\n\\`\\`\\`\n\n### Entity Persistence Semantics\n\nWhen you reference an imported entity, the behavior depends on its persistence type:\n\n| Persistence | Sharing Behavior | Use Case |\n|-------------|------------------|----------|\n| \\`persistent\\` | **Shared** - Same DB collection | Users, Products, Orders |\n| \\`runtime\\` | **Isolated** - Each orbital gets own instances | Game entities, UI state |\n| \\`singleton\\` | **Shared** - Single global instance | Config, Game state |\n\n**Example**: Two orbitals importing a \\`runtime\\` entity each get separate instances:\n\\`\\`\\`json\n// level1.orb\n{ \"entity\": \"Goblin.entity\" } // Level1's goblins\n\n// level2.orb\n{ \"entity\": \"Goblin.entity\" } // Level2's goblins (separate!)\n\\`\\`\\`\n\n### Import Sources\n\n| Source Format | Description |\n|---------------|-------------|\n| \\`\"./path.orb\"\\` | Local relative path |\n| \\`\"../shared/health.orb\"\\` | Parent directory |\n| \\`\"std/behaviors/game-core\"\\` | Standard library |\n| \\`\"@game-lib/enemies.orb\"\\` | Scoped package |\n\n### Key Rules\n\n1. **Alias must be PascalCase** - e.g., \\`\"as\": \"Health\"\\`, NOT \\`\"as\": \"health\"\\`\n2. **All traits belong in orbitals** - No schema-level \\`traits[]\\` array\n3. **References must match imports** - \\`Goblin.entity\\` requires \\`{ \"as\": \"Goblin\" }\\` in \\`uses\\`\n4. **Inline OR reference** - Each component slot accepts either form\n`;\n}\n\n/**\n * Get compact uses guidance.\n */\nexport function getUsesImportCompact(): string {\n return `## Orbital Imports (\\`uses\\`)\n\nImport other orbitals and reference their components:\n\n\\`\\`\\`json\n{\n \"uses\": [{ \"from\": \"./health.orb\", \"as\": \"Health\" }],\n \"entity\": \"Health.entity\", // Reference entity\n \"traits\": [\"Health.traits.Health\"], // Reference trait\n \"pages\": [\"Health.pages.Dashboard\"] // Reference page\n}\n\\`\\`\\`\n\n**Alias must be PascalCase.** No schema-level \\`traits[]\\` array exists.\n`;\n}\n","/**\n * Lean Orbital Skill Generator\n *\n * Generates a minimal, focused orbital skill by:\n * 1. Deriving type information directly from @almadar/core\n * 2. Using focused, minimal guidance sections\n * 3. Avoiding verbose explanations and redundancy\n *\n * v4: Reduced from ~49K to ~15K by:\n * - Removing std behaviors JSON dump (21K)\n * - Removing schema-updates (moved to fixing skill)\n * - Removing custom-traits (moved to fixing skill)\n * - Trimming common-errors to top 6\n * - Replacing 380-char render-ui quickref with 2.5K design guide\n * - Using compact decomposition and connectivity variants\n *\n * @packageDocumentation\n */\n\nimport {\n getSExprQuickRef,\n getStdMinimalReference,\n getStdFullReference,\n getStdBehaviorsWithStateMachines,\n getKeyBehaviorsReference,\n} from './helpers.js';\nimport {\n getArchitectureSection,\n getCommonErrorsSection,\n getDecompositionSection,\n getDecompositionCompact,\n getCustomTraitSection,\n getSchemaUpdateSection,\n getConnectivityCompact,\n getRenderUIDesignGuide,\n getThemeGuide,\n getBannedProps,\n // UX Enhancement sections\n getFlowPatternSection,\n getPortableOrbitalOutputSection,\n getOrbitalConnectivitySection,\n getContextUsageCompact,\n} from '../prompts/skill-sections/index.js';\n\n// ============================================================================\n// Generator Options\n// ============================================================================\n\nexport interface LeanSkillOptions {\n /** Include example orbital */\n includeExample?: boolean;\n /** Include tool workflow section */\n includeToolWorkflow?: boolean;\n /** Include std/* library reference (operators + behaviors) */\n includeStdLibrary?: boolean;\n /** Use full std reference (detailed) vs minimal (compact) */\n stdLibraryFull?: boolean;\n /** Include expanded non-game behaviors with state machines for copying */\n includeStdStateMachines?: boolean;\n /** Include schema update guidance section */\n includeSchemaUpdates?: boolean;\n /** Include custom trait examples section */\n includeCustomTraits?: boolean;\n /** Error detail level: 'top6' for generation, 'full' for fixing */\n errorLevel?: 'top6' | 'full';\n /** Include render-ui design guide with pattern catalog and recipes */\n includeDesignGuide?: boolean;\n}\n\n// ============================================================================\n// Main Generator\n// ============================================================================\n\n/**\n * Generate a lean orbital skill.\n *\n * Default options produce a ~15K skill focused on generation quality.\n * Set includeStdStateMachines/includeCustomTraits/errorLevel='full' for\n * the larger ~49K variant used by legacy callers.\n */\nexport function generateLeanOrbitalSkill(options: LeanSkillOptions = {}): string {\n const {\n includeExample = true,\n includeToolWorkflow = true,\n includeStdLibrary = false,\n stdLibraryFull = false,\n includeStdStateMachines = false,\n includeSchemaUpdates = false,\n includeCustomTraits = false,\n errorLevel = 'top6',\n includeDesignGuide = true,\n } = options;\n\n // Build std section based on options\n let stdSection = '';\n if (includeStdLibrary || includeStdStateMachines) {\n if (includeStdStateMachines) {\n // Include expanded behaviors with state machines (non-game only)\n stdSection = `---\n\n${getKeyBehaviorsReference()}\n\n---\n\n${getStdBehaviorsWithStateMachines()}\n`;\n } else if (stdLibraryFull) {\n stdSection = `---\n\n${getStdFullReference()}\n`;\n } else {\n stdSection = `---\n\n${getStdMinimalReference()}\n`;\n }\n }\n\n // Use compact or full decomposition/connectivity\n const decompositionSection = (includeStdStateMachines || includeCustomTraits)\n ? getDecompositionSection()\n : getDecompositionCompact();\n\n const connectivitySection = (includeStdStateMachines || includeCustomTraits)\n ? getOrbitalConnectivitySection()\n : getConnectivityCompact();\n\n return `# Orbital Generation Skill\n\n> Generate Orbital applications using Orbital Units: Entity × Traits × Patterns\n\n${getArchitectureSection()}\n\n---\n\n${getSExprQuickRef()}\n\n---\n\n${includeDesignGuide ? getRenderUIDesignGuide() : ''}\n\n${includeDesignGuide ? `---\n\n${getThemeGuide()}\n\n---\n\n${getBannedProps()}` : ''}\n\n${stdSection}\n---\n\n${getFlowPatternSection()}\n\n---\n\n${decompositionSection}\n\n---\n\n${getPortableOrbitalOutputSection()}\n\n---\n\n${connectivitySection}\n\n---\n\n${getContextUsageCompact()}\n\n---\n\n${getCommonErrorsSection(errorLevel)}\n\n${includeCustomTraits ? `---\n\n${getCustomTraitSection()}\n` : ''}\n${includeToolWorkflow ? getToolWorkflowSection() : ''}\n\n${includeSchemaUpdates ? `---\n\n${getSchemaUpdateSection()}\n` : ''}\n${getCriticalOutputRequirements()}\n\n${includeExample ? getMinimalExample() : ''}\n`;\n}\n\n/**\n * Get critical output requirements section.\n * Placed near the end to reinforce requirements before generation.\n */\nfunction getCriticalOutputRequirements(): string {\n return `---\n\n## CRITICAL: Output Requirements\n\nEvery orbital MUST include:\n\n### 1. domainContext (REQUIRED)\n\\`\\`\\`json\n\"domainContext\": {\n \"request\": \"<original user request>\",\n \"requestFragment\": \"<what part produced THIS orbital>\",\n \"category\": \"business\",\n \"vocabulary\": { \"item\": \"Task\", \"create\": \"Add\", \"delete\": \"Remove\" }\n}\n\\`\\`\\`\n\n### 2. design (REQUIRED)\n\\`\\`\\`json\n\"design\": {\n \"style\": \"modern\",\n \"uxHints\": {\n \"flowPattern\": \"crud-cycle\",\n \"listPattern\": \"entity-table\",\n \"formPattern\": \"modal\"\n }\n}\n\\`\\`\\`\n\n### 3. Business Rule Guards on SAVE (when rules exist)\nIf the user specifies validation constraints, add S-expression guards on transitions:\n\\`\\`\\`json\n{\n \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"guard\": [\"<=\", \"@payload.data.score\", 100],\n \"effects\": [[\"persist\", \"create\", \"Entry\", \"@payload.data\"], ...]\n}\n\\`\\`\\`\n\n### 4. ONE Orbital Per Entity\nDo NOT create multiple orbitals for the same entity. All CRUD operations belong in ONE orbital.\n\n### 5. Entity Field is REQUIRED (CRITICAL)\nEvery orbital MUST have an entity field. No exceptions.\n\n\\`\\`\\`json\n{\n \"name\": \"Product Management\",\n \"entity\": { // ← REQUIRED\n \"name\": \"Product\",\n \"collection\": \"products\",\n \"fields\": [...]\n },\n \"traits\": [...],\n \"pages\": [...]\n}\n\\`\\`\\`\n\n**Verify before calling finish_task:**\n- [ ] Each orbital has an \"entity\" field\n- [ ] Each entity has a \"name\" and \"collection\"\n- [ ] Each entity has \"fields\" array\n\n**Missing entity field = INVALID orbital!**\n\n**Fixing Entity Errors:**\nIf validation shows errors like \"Missing entity\" or \"No fields\":\n1. Read the orbital file from .orbitals/ directory\n2. Add the missing entity field:\n\\`\\`\\`json\n\"entity\": {\n \"name\": \"Product\",\n \"collection\": \"products\",\n \"fields\": [\n { \"name\": \"name\", \"type\": \"string\", \"required\": true },\n { \"name\": \"price\", \"type\": \"number\" }\n ]\n}\n\\`\\`\\`\n3. Save the file and re-validate\n\n**DO NOT call finish_task until ALL orbitals have entities!**`\n}\n\n/**\n * Get minimal tool workflow section.\n */\nfunction getToolWorkflowSection(): string {\n return `---\n\n## Tool Workflow\n\n### Phase 1: DECOMPOSE\nBreak requirements into OrbitalUnits (pure reasoning, no tools).\n\n### Phase 2: GENERATE\n\n**Option A: Orchestrated Generation (RECOMMENDED for 3+ orbitals)**\nUse \\`generate_schema_orchestrated\\` for automatic complexity-based routing:\n\n\\`\\`\\`\ngenerate_schema_orchestrated({ prompt: \"Full app description with all entities and features\" })\n\\`\\`\\`\n\nThis tool automatically:\n- Decomposes your requirements\n- Routes simple/medium (1-3 orbitals) to fast single-provider\n- Routes complex (4+ orbitals) to parallel multi-provider\n- Returns a complete schema with all orbitals\n\n**Option B: Per-Orbital Generation (for simple cases or fine-grained control)**\nCall \\`generate_orbital\\` for each orbital:\n\n\\`\\`\\`\ngenerate_orbital({ orbital: {...}, orbitalIndex: 0, totalOrbitals: N })\ngenerate_orbital({ orbital: {...}, orbitalIndex: 1, totalOrbitals: N })\n...\n\\`\\`\\`\n\nEach orbital is written to \\`.orbitals/<name>.json\\` with ALL effects (render-ui, persist, emit, set, etc.).\n\n### Phase 3: COMBINE\nCall \\`finish_task\\` to auto-combine orbitals into schema.orb:\n\n\\`\\`\\`\nfinish_task({ appName: \"App\" })\n# Reads .orbitals/*.json → schema.orb → orbital validate\n\\`\\`\\`\n\n### Phase 4: VALIDATE (CRITICAL)\nAfter combining, validate the schema:\n\n\\`\\`\\`\nvalidate_schema()\n\\`\\`\\`\n\n**If validation shows errors:**\n1. Read the error path (e.g., orbitals[0].entity)\n2. Fix the issue in the orbital file\n3. Re-run validate_schema()\n\n**Common errors to fix:**\n- ORB_E_MISSING_NAME → Add entity name\n- ORB_E_NO_FIELDS → Add entity fields\n- Missing entity field → Add entity object with name and fields\n\n**CRITICAL: Check EACH orbital file in .orbitals/ directory:**\nUse Read tool to check each orbital file has entity field.\n\n### Phase 5: VERIFY COMPOSITION QUALITY\n\nBefore calling \\`finish_task\\`, verify each INIT transition:\n\n1. **Uses a single \\`render-ui\\` call** with top-level \\`stack\\` and \\`children\\` — NOT flat sequential calls\n2. **Has 3+ composed sections**: header (HStack: title + action), metrics (HStack/Grid of Box cards), data (entity-table/entity-cards)\n3. **Uses domain-appropriate atoms**: \\`badge\\` for status, \\`typography\\` for labels/values, \\`button\\` for actions\n4. **Props are correct**: \\`submitEvent\\` not \\`onSubmit\\`, \\`actions\\` not \\`headerActions\\`, \\`fields\\` not \\`fieldNames\\`\n\nIf any INIT transition is flat (just \\`page-header\\` + \\`entity-table\\`), redesign it as a composed VStack hierarchy before finishing.\n`;\n}\n\n/**\n * Get minimal example section.\n * VALIDATED example that passes npx @almadar/cli validate\n */\nfunction getMinimalExample(): string {\n return `---\n\n## Example: Task Manager (Atomic Composition - VALIDATED)\n\nThis example passes \\`npx @almadar/cli validate\\` with zero errors:\n\n\\`\\`\\`json\n{\n \"name\": \"Taskly\",\n \"version\": \"1.0.0\",\n \"orbitals\": [{\n \"name\": \"Task Management\",\n \"entity\": {\n \"name\": \"Task\",\n \"collection\": \"tasks\",\n \"fields\": [\n { \"name\": \"title\", \"type\": \"string\", \"required\": true },\n { \"name\": \"status\", \"type\": \"enum\", \"values\": [\"pending\", \"active\", \"done\"] }\n ]\n },\n \"traits\": [{\n \"name\": \"TaskInteraction\",\n \"category\": \"interaction\",\n \"linkedEntity\": \"Task\",\n \"emits\": [{ \"event\": \"INIT\", \"scope\": \"internal\" }],\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"Browsing\", \"isInitial\": true },\n { \"name\": \"Creating\" }\n ],\n \"events\": [\n { \"key\": \"INIT\", \"name\": \"Initialize\" },\n { \"key\": \"CREATE\", \"name\": \"Create\" },\n { \"key\": \"SAVE\", \"name\": \"Save\", \"payload\": [{ \"name\": \"data\", \"type\": \"object\" }] },\n { \"key\": \"CANCEL\", \"name\": \"Cancel\" }\n ],\n \"transitions\": [\n {\n \"from\": \"Browsing\", \"to\": \"Browsing\", \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\",\n \"children\": [\n { \"type\": \"stack\", \"direction\": \"horizontal\", \"justify\": \"between\", \"align\": \"center\",\n \"children\": [\n { \"type\": \"typography\", \"variant\": \"h1\", \"text\": \"Tasks\" },\n { \"type\": \"button\", \"label\": \"New Task\", \"event\": \"CREATE\", \"variant\": \"primary\" }\n ]\n },\n { \"type\": \"stack\", \"direction\": \"horizontal\", \"gap\": \"md\", \"wrap\": true,\n \"children\": [\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"var(--color-card)\", \"border\": true, \"rounded\": \"var(--radius-md)\",\n \"children\": [{ \"type\": \"typography\", \"variant\": \"caption\", \"text\": \"Total\" }, { \"type\": \"typography\", \"variant\": \"h2\", \"text\": \"@count\" }] },\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"var(--color-card)\", \"border\": true, \"rounded\": \"var(--radius-md)\",\n \"children\": [{ \"type\": \"typography\", \"variant\": \"caption\", \"text\": \"Active\" }, { \"type\": \"badge\", \"variant\": \"primary\", \"text\": \"@count:status=active\" }] },\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"var(--color-card)\", \"border\": true, \"rounded\": \"var(--radius-md)\",\n \"children\": [{ \"type\": \"typography\", \"variant\": \"caption\", \"text\": \"Done\" }, { \"type\": \"badge\", \"variant\": \"success\", \"text\": \"@count:status=done\" }] }\n ]\n },\n { \"type\": \"entity-table\", \"entity\": \"Task\", \"columns\": [\"title\", \"status\"], \"searchable\": true,\n \"itemActions\": [{ \"label\": \"View\", \"event\": \"VIEW\" }, { \"label\": \"Edit\", \"event\": \"EDIT\" }, { \"label\": \"Delete\", \"event\": \"DELETE\" }] }\n ]\n }]\n ]\n },\n {\n \"from\": \"Browsing\", \"to\": \"Creating\", \"event\": \"CREATE\",\n \"effects\": [[\"render-ui\", \"modal\", { \"type\": \"form-section\", \"entity\": \"Task\", \"fields\": [\"title\", \"status\"], \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }]]\n },\n {\n \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"effects\": [[\"persist\", \"create\", \"Task\", \"@payload.data\"], [\"render-ui\", \"modal\", null], [\"emit\", \"INIT\"]]\n },\n {\n \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"modal\", null]]\n }\n {\n \"from\": \"Editing\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"modal\", null]]\n },\n {\n \"from\": \"Deleting\", \"to\": \"Browsing\", \"event\": \"CONFIRM_DELETE\",\n \"effects\": [[\"persist\", \"delete\", \"Task\"], [\"render-ui\", \"overlay\", null], [\"emit\", \"INIT\"]]\n },\n {\n \"from\": \"Deleting\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"overlay\", null]]\n }\n ]\n }\n }],\n \"pages\": [{\n \"name\": \"TasksPage\",\n \"path\": \"/tasks\",\n \"viewType\": \"list\",\n \"isInitial\": true,\n \"entity\": \"Task\",\n \"traits\": [{ \"ref\": \"TaskInteraction\" }]\n }],\n \"emits\": [],\n \"listens\": []\n }]\n}\n\\`\\`\\`\n\n**Key points — Atomic Composition**:\n- **INIT uses a SINGLE \\`render-ui\\` call** with a top-level \\`stack\\` containing composed \\`children\\`\n- **3 sections composed**: header (HStack: title + button), metrics (HStack of Box stat cards), data (entity-table)\n- **Atoms used**: \\`typography\\` (h1, h2, caption), \\`badge\\` (status indicators), \\`button\\` (actions)\n- **Layout used**: \\`stack\\` (vertical page, horizontal rows), \\`box\\` (stat cards)\n- **Organism used**: \\`entity-table\\` with searchable + itemActions\n- **Theme variables**: All colors use \\`var(--color-*)\\`, spacing uses \\`var(--spacing-*)\\`, radius uses \\`var(--radius-*)\\`\n\n**Validation Rules** (MANDATORY):\n- Events: \\`{ \"key\": \"INIT\", \"name\": \"Initialize\" }\\` — NOT \\`\"INIT\"\\`\n- Emits: \\`[{ \"event\": \"INIT\", \"scope\": \"internal\" }]\\` — NOT \\`[\"INIT\"]\\`\n- Payload events MUST declare payload: \\`{ \"key\": \"SAVE\", \"payload\": [{ \"name\": \"data\", \"type\": \"object\" }] }\\`\n- Page traits: \\`{ \"ref\": \"TaskInteraction\" }\\` — NOT with linkedEntity\n- Props: \\`submitEvent\\` (not \\`onSubmit\\`), \\`actions\\` (not \\`headerActions\\`), \\`fields\\` (not \\`fieldNames\\`)\n- Theme: All visual properties use CSS variables\n\n---\n\n## Example: E-commerce with Multiple Orbitals (3 Entities)\n\nFor an app with Product, Category, and Order:\n\n\\`\\`\\`json\n{\n \"name\": \"EcommerceAdmin\",\n \"version\": \"1.0.0\",\n \"orbitals\": [\n {\n \"name\": \"Product Management\",\n \"entity\": {\n \"name\": \"Product\",\n \"collection\": \"products\",\n \"fields\": [\n { \"name\": \"name\", \"type\": \"string\", \"required\": true },\n { \"name\": \"price\", \"type\": \"number\", \"required\": true },\n { \"name\": \"stock\", \"type\": \"number\", \"default\": 0 }\n ]\n },\n \"traits\": [{ \"name\": \"ProductInteraction\", \"category\": \"interaction\", \"linkedEntity\": \"Product\" }],\n \"pages\": [{ \"name\": \"ProductsPage\", \"path\": \"/products\", \"traits\": [{ \"ref\": \"ProductInteraction\" }] }]\n },\n {\n \"name\": \"Category Management\",\n \"entity\": {\n \"name\": \"Category\",\n \"collection\": \"categories\",\n \"fields\": [\n { \"name\": \"name\", \"type\": \"string\", \"required\": true },\n { \"name\": \"slug\", \"type\": \"string\", \"required\": true }\n ]\n },\n \"traits\": [{ \"name\": \"CategoryInteraction\", \"category\": \"interaction\", \"linkedEntity\": \"Category\" }],\n \"pages\": [{ \"name\": \"CategoriesPage\", \"path\": \"/categories\", \"traits\": [{ \"ref\": \"CategoryInteraction\" }] }]\n },\n {\n \"name\": \"Order Management\",\n \"entity\": {\n \"name\": \"Order\",\n \"collection\": \"orders\",\n \"fields\": [\n { \"name\": \"orderNumber\", \"type\": \"string\", \"required\": true },\n { \"name\": \"totalAmount\", \"type\": \"number\", \"required\": true },\n { \"name\": \"status\", \"type\": \"enum\", \"values\": [\"pending\", \"processing\", \"shipped\", \"delivered\"] }\n ]\n },\n \"traits\": [{ \"name\": \"OrderInteraction\", \"category\": \"interaction\", \"linkedEntity\": \"Order\" }],\n \"pages\": [{ \"name\": \"OrdersPage\", \"path\": \"/orders\", \"traits\": [{ \"ref\": \"OrderInteraction\" }] }]\n }\n ]\n}\n\\`\\`\\`\n\n**Key Points for Multi-Orbital Apps:**\n- Each orbital has its own entity field (REQUIRED)\n- Each entity has its own collection name\n- Each orbital has its own page\n- Call \\`generate_orbital\\` 3 times (once per orbital)\n`;\n}\n\n// ============================================================================\n// Stat Export (for testing)\n// ============================================================================\n\n/**\n * Get skill stats for comparison.\n */\nexport function getLeanSkillStats(options: LeanSkillOptions = {}): { lines: number; chars: number } {\n const skill = generateLeanOrbitalSkill(options);\n return {\n lines: skill.split('\\n').length,\n chars: skill.length,\n };\n}\n\n/**\n * Get subagent system prompt for orbital generation.\n * This is used by the orbital generator subagent in @almadar/agent.\n * Provides focused guidance on generating complete orbitals with entities.\n */\nexport function getSubagentSystemPrompt(): string {\n return `# Orbital Generation Subagent\n\nYou are a specialized subagent that generates complete FullOrbitalUnit definitions.\nYour task is to expand a lightweight orbital input into a full orbital with entity, traits, state machines, and pages.\n\n## Core Formula\nOrbital Unit = Entity × Traits × Patterns\n\n## REQUIRED Output Structure\n\nEvery orbital MUST have this exact structure:\n\n\\`\\`\\`json\n{\n \"name\": \"OrbitalName\",\n \"entity\": { // ← CRITICAL: REQUIRED FIELD\n \"name\": \"EntityName\",\n \"collection\": \"entitynames\", // Plural lowercase\n \"persistence\": \"persistent\", // or \"runtime\" or \"singleton\"\n \"fields\": [\n { \"name\": \"fieldName\", \"type\": \"string|number|boolean|enum|timestamp|array|object|relation\", \"required\": true }\n ]\n },\n \"traits\": [\n {\n \"name\": \"TraitName\",\n \"category\": \"interaction\",\n \"linkedEntity\": \"EntityName\",\n \"stateMachine\": {\n \"states\": [\n { \"name\": \"Browsing\", \"isInitial\": true },\n { \"name\": \"Creating\" },\n { \"name\": \"Editing\" }\n ],\n \"events\": [\n { \"key\": \"INIT\", \"name\": \"Initialize\" },\n { \"key\": \"CREATE\", \"name\": \"Create\" },\n { \"key\": \"SAVE\", \"name\": \"Save\", \"payload\": [{ \"name\": \"data\", \"type\": \"object\" }] },\n { \"key\": \"CANCEL\", \"name\": \"Cancel\" }\n ],\n \"transitions\": [\n {\n \"from\": \"Browsing\",\n \"to\": \"Browsing\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", {\n \"type\": \"stack\",\n \"direction\": \"vertical\",\n \"gap\": \"lg\",\n \"children\": [\n // header, metrics, data table\n ]\n }]\n ]\n }\n ]\n }\n }\n ],\n \"pages\": [\n {\n \"name\": \"PageName\",\n \"path\": \"/path\",\n \"viewType\": \"list\",\n \"traits\": [{ \"ref\": \"TraitName\" }]\n }\n ],\n \"domainContext\": {\n \"request\": \"...\",\n \"category\": \"business\",\n \"vocabulary\": { \"item\": \"...\", \"create\": \"...\" }\n },\n \"design\": {\n \"style\": \"modern\",\n \"uxHints\": { \"flowPattern\": \"crud-cycle\", \"listPattern\": \"entity-table\" }\n }\n}\n\\`\\`\\`\n\n## CRITICAL RULES\n\n1. **ENTITY FIELD IS REQUIRED**: Every orbital MUST have an \"entity\" field at the top level\n2. **Entity Name**: Must match the orbital's primary entity\n3. **Collection**: Plural lowercase version of entity name (e.g., \"products\" for Product)\n4. **Fields**: At minimum, include id, name, and relevant fields from input\n\n## Common Mistakes to Avoid\n\n- ❌ WRONG: Missing entity field at orbital level\n- ❌ WRONG: Only linkedEntity in trait, no orbital.entity\n- ❌ WRONG: Empty fields array\n- ❌ WRONG: Using \\`@count(tasks)\\`, \\`@find(...)\\`, \\`@sum(...)\\` — NO function-call bindings exist\n- ❌ WRONG: Using \\`actions\\` array on form-section — use \\`submitEvent\\`/\\`cancelEvent\\` strings\n- ❌ WRONG: Modal state without CANCEL/CLOSE transitions\n- ❌ WRONG: Bare \\`@entity\\` without a field path — use \\`@entity.fieldName\\`\n- ❌ WRONG: \\`@Product.name\\`, \\`@Order.status\\`, \\`@Customer.email\\` — NEVER use entity TYPE as binding root\n- ❌ WRONG: \\`@count(orders)\\`, \\`@sum(orders, total)\\`, \\`@avg(...)\\` — NO aggregate functions exist\n- ✅ CORRECT: Full entity object with name, collection, persistence, fields\n- ✅ CORRECT: \\`@entity.name\\`, \\`@entity.status\\`, \\`@entity.email\\` — ALWAYS use \\`@entity\\` as the root\n- ✅ CORRECT: Only valid binding roots: \\`@entity\\`, \\`@payload\\`, \\`@state\\`, \\`@now\\`, \\`@config\\`\n- ✅ CORRECT: Every state rendering to modal/drawer has CANCEL + CLOSE transitions back\n\n## Field Types\n\n| Type | Use For | Example |\n|------|---------|---------|\n| string | Text, names | { \"name\": \"title\", \"type\": \"string\", \"required\": true } |\n| number | Prices, counts | { \"name\": \"price\", \"type\": \"number\" } |\n| enum | Status, categories | { \"name\": \"status\", \"type\": \"enum\", \"values\": [\"pending\", \"active\"] } |\n| timestamp | Dates, times | { \"name\": \"createdAt\", \"type\": \"timestamp\", \"default\": \"@now\" } |\n| relation | Links to other entities | { \"name\": \"categoryId\", \"type\": \"relation\", \"relation\": { \"entity\": \"Category\" } } |\n\n## State Machine Patterns\n\n**CRUD Pattern:**\n- States: Browsing (isInitial), Creating, Editing, Viewing\n- Events: INIT, CREATE, EDIT, VIEW, SAVE, CANCEL, DELETE\n- INIT effect: render-ui with stack containing header, metrics, entity-table\n\n**Transitions:**\n- Browsing → Creating: on CREATE (render modal with form-section using submitEvent/cancelEvent)\n- Creating → Browsing: on SAVE (persist + dismiss modal + emit INIT)\n- Creating → Browsing: on CANCEL (dismiss modal: [\"render-ui\", \"modal\", null])\n- Creating → Browsing: on CLOSE (dismiss modal: [\"render-ui\", \"modal\", null])\n- Browsing → Editing: on EDIT (render modal with form-section)\n- Editing → Browsing: on SAVE, CANCEL, CLOSE (same pattern as Creating)\n\n**CRITICAL: Every state that renders to \"modal\" or \"drawer\" MUST have CANCEL and CLOSE transitions.**\n\n## form-section Props (NOT actions)\n\nform-section uses \\`submitEvent\\`/\\`cancelEvent\\`, NOT \\`actions\\` array:\n\\`\\`\\`json\n{ \"type\": \"form-section\", \"entity\": \"Task\", \"fields\": [\"title\", \"status\"], \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }\n\\`\\`\\`\n\n## Effects Reference\n\n| Effect | Syntax | Purpose |\n|--------|--------|---------|\n| render-ui | [\"render-ui\", \"main\", { ... }] | Render UI pattern |\n| render-ui | [\"render-ui\", \"modal\", { ... }] | Render modal |\n| render-ui | [\"render-ui\", \"modal\", null] | Dismiss modal |\n| persist | [\"persist\", \"create\", \"Entity\", \"@payload.data\"] | Save to DB |\n| set | [\"set\", \"@entity.field\", value] | Update field |\n| emit | [\"emit\", \"EVENT\", payload] | Emit event |\n| navigate | [\"navigate\", \"/path\"] | Navigate |\n\n## Valid Slots (ONLY these exist)\n\n\\`\"main\"\\`, \\`\"modal\"\\`, \\`\"drawer\"\\`, \\`\"sidebar\"\\`\n\nNEVER use: \\`\"modal-close\"\\`, \\`\"notification\"\\`, \\`\"confirm-modal\"\\`, \\`\"header\"\\`, \\`\"footer\"\\`\n\n## Pattern Type Required\n\nEVERY pattern object in render-ui MUST have a \\`\"type\"\\` field. This includes the top-level pattern AND every child in a stack's children array.\n\n## FINAL CHECKLIST (read before generating)\n\n1. **NO aggregate bindings**: \\`@count(...)\\`, \\`@sum(...)\\`, \\`@avg(...)\\` DO NOT EXIST. Use static text or add a count field to the entity instead.\n2. **form-section uses submitEvent/cancelEvent**: \\`{ \"type\": \"form-section\", \"entity\": \"X\", \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }\\`. NEVER put \\`\"actions\"\\` array on form-section — \\`actions\\` is for page-header and entity-detail only.\n3. **Arrays not objects**: \\`fields\\`, \\`states\\`, \\`events\\`, \\`transitions\\`, \\`children\\` MUST be arrays \\`[]\\`, NEVER objects \\`{}\\`.\n4. **Every render-ui child needs \"type\"**: \\`{ \"type\": \"typography\", \"text\": \"...\" }\\` not \\`{ \"text\": \"...\" }\\`\n5. **Valid slots only**: \\`\"main\"\\`, \\`\"modal\"\\`, \\`\"drawer\"\\`, \\`\"sidebar\"\\` — nothing else.\n6. **Binding roots**: ONLY \\`@entity.field\\`, \\`@payload.field\\`, \\`@state\\`, \\`@now\\`, \\`@config\\`. NEVER \\`@Order.field\\` or \\`@count()\\`.\n7. **Trait naming**: Name the trait \\`{Entity}Interaction\\` (e.g., \\`CustomerInteraction\\`, \\`OrderInteraction\\`). The page ref MUST match: \\`\"traits\": [{ \"ref\": \"CustomerInteraction\" }]\\`.\n\n## Output Requirements\n\nReturn ONLY valid JSON. No markdown, no explanations.\nThe JSON must be a complete FullOrbitalUnit with all required fields.\n`;\n}\n\n/**\n * Get comparison stats for different configurations.\n */\nexport function getSkillSizeComparison(): {\n minimal: { lines: number; chars: number };\n withStdMinimal: { lines: number; chars: number };\n withStdFull: { lines: number; chars: number };\n withStdStateMachines: { lines: number; chars: number };\n legacy: { lines: number; chars: number };\n} {\n return {\n minimal: getLeanSkillStats({}),\n withStdMinimal: getLeanSkillStats({ includeStdLibrary: true, stdLibraryFull: false }),\n withStdFull: getLeanSkillStats({ includeStdLibrary: true, stdLibraryFull: true }),\n withStdStateMachines: getLeanSkillStats({ includeStdStateMachines: true }),\n legacy: getLeanSkillStats({\n includeStdStateMachines: true,\n includeSchemaUpdates: true,\n includeCustomTraits: true,\n errorLevel: 'full',\n }),\n };\n}\n","/**\n * KFlow Orbitals Skill Generator\n *\n * Generates the kflow-orbitals skill for orbital-based schema generation.\n * Uses the orbital skill generator from the orbitals module and adds\n * domain classification, interaction models, and trait-driven UI guidance.\n *\n * v4.0: Reduced from ~49K to ~15K by cutting std dump, schema-updates,\n * custom-traits, and half the errors. Added render-ui design guide with\n * pattern catalog and composition recipes.\n *\n * @packageDocumentation\n */\n\nimport type { GeneratedSkill } from './types.js';\nimport { generateLeanOrbitalSkill } from '../orbitals-skills-generators/lean-orbital-skill-generator.js';\n\n/**\n * Generate the kflow-orbitals skill.\n *\n * Uses the lean orbital skill generator with minimal defaults (~15K).\n * The design guide, top-6 errors, and enriched example are always included.\n *\n * Options:\n * - compact: false (default) - Standard ~15K generation skill\n * - compact: true - Same (compact flag preserved for API compat, no-op now)\n */\nexport function generateKflowOrbitalsSkill(compact = false): GeneratedSkill {\n const frontmatter = {\n name: 'kflow-orbitals',\n description: 'Generate KFlow schemas using the Orbitals composition model. Decomposes applications into atomic Orbital Units (Entity x Traits x Patterns) with structural caching for efficiency.',\n allowedTools: ['Read', 'Write', 'Edit', 'generate_orbital', 'generate_schema_orchestrated', 'finish_task', 'query_schema_structure', 'extract_chunk', 'apply_chunk'],\n version: '5.0.0', // v5.0: atomic composition (removed design_transition, single-pass design)\n };\n\n // v4: Minimal skill with design guide (~15K).\n // - No std behaviors dump (saves 21K)\n // - No schema-updates (moved to fixing skill)\n // - No custom-traits (moved to fixing skill)\n // - Top 6 errors only (saves 4K)\n // - render-ui design guide with pattern catalog + composition recipes\n // - Enriched example with stats + searchable table\n const content = generateLeanOrbitalSkill({\n includeExample: true,\n includeToolWorkflow: true,\n includeStdStateMachines: false,\n includeSchemaUpdates: false,\n includeCustomTraits: false,\n errorLevel: 'top6',\n includeDesignGuide: true,\n });\n\n return {\n name: 'kflow-orbitals',\n frontmatter,\n content,\n };\n}\n","/**\n * Lean Fixing Skill Generator\n *\n * Generates a minimal, focused fixing skill by:\n * 1. Reusing the same sections as lean-orbital-skill-generator\n * 2. Adding fixing-specific guidance on top\n * 3. Keeping the same modular structure\n *\n * @packageDocumentation\n */\n\nimport {\n getSExprQuickRef,\n getRenderUIQuickRef,\n} from './helpers.js';\nimport { getPatternActionsRef } from '@almadar/patterns';\nimport {\n getArchitectureSection,\n getCommonErrorsSection,\n getSchemaUpdateSection,\n getCustomTraitSection,\n // Fixing-specific sections\n getFixingWorkflowSection,\n getCommonFixPatternsSection,\n getOverGenerationSection,\n getEfficiencySection,\n getCompletionRulesSection,\n} from '../prompts/skill-sections/index.js';\n\n// ============================================================================\n// Generator Options\n// ============================================================================\n\nexport interface LeanFixingSkillOptions {\n /** Include over-generation detection */\n includeOverGeneration?: boolean;\n /** Include schema update guidance */\n includeSchemaUpdates?: boolean;\n /** Include efficiency guidelines */\n includeEfficiency?: boolean;\n}\n\n// ============================================================================\n// Main Generator\n// ============================================================================\n\n/**\n * Generate a lean fixing skill.\n *\n * This produces a fixing skill that reuses the lean orbital sections\n * and adds fixing-specific guidance.\n */\nexport function generateLeanFixingSkill(options: LeanFixingSkillOptions = {}): string {\n const {\n includeOverGeneration = true,\n includeSchemaUpdates = true,\n includeEfficiency = true,\n } = options;\n\n return `# Orbital Fixing Skill\n\n> Fix validation errors using orbital understanding: Entity × Traits × Patterns\n\n## Key Principle\n\n\\`\\`\\`\n┌─────────────────────────────────────────────────────────────────────┐\n│ When fixing errors: │\n│ 1. Identify which ORBITAL the error belongs to │\n│ 2. Identify which COMPONENT (entity/trait/page/pattern) │\n│ 3. Apply targeted fix for that component │\n│ │\n│ This gives you CONTEXT that improves fix accuracy. │\n└─────────────────────────────────────────────────────────────────────┘\n\\`\\`\\`\n\n---\n\n${getFixingWorkflowSection()}\n\n${includeEfficiency ? `---\n\n${getEfficiencySection()}` : ''}\n\n---\n\n${getArchitectureSection()}\n\n---\n\n${getSExprQuickRef()}\n\n---\n\n${getRenderUIQuickRef()}\n\n---\n\n${getPatternActionsRef()}\n\n---\n\n${getCommonFixPatternsSection()}\n\n${includeOverGeneration ? `---\n\n${getOverGenerationSection()}` : ''}\n\n---\n\n${getCommonErrorsSection('full')}\n\n---\n\n${getCustomTraitSection()}\n\n${includeSchemaUpdates ? `---\n\n${getSchemaUpdateSection()}` : ''}\n\n---\n\n${getCompletionRulesSection()}\n\n---\n\n## Schema File Rule\n\n\\`\\`\\`\n┌─────────────────────────────────────────────────────────────────────┐\n│ ALWAYS write to: schema.orb │\n│ │\n│ NEVER use other file names like: │\n│ - schema_with_fixes.orb ❌ │\n│ - new_schema.orb ❌ │\n│ - updated_schema.orb ❌ │\n│ │\n│ The persistence system ONLY reads from schema.orb │\n└─────────────────────────────────────────────────────────────────────┘\n\\`\\`\\`\n`;\n}\n\n// ============================================================================\n// Stat Export (for testing)\n// ============================================================================\n\n/**\n * Get skill stats for comparison.\n */\nexport function getLeanFixingSkillStats(options: LeanFixingSkillOptions = {}): { lines: number; chars: number } {\n const skill = generateLeanFixingSkill(options);\n return {\n lines: skill.split('\\n').length,\n chars: skill.length,\n };\n}\n\n/**\n * Get fixing skill metadata.\n */\nexport function getFixingSkillMetadata() {\n return {\n name: 'kflow-orbital-fixing',\n description: 'Fix validation errors using orbital understanding (lean version)',\n version: '2.0.0',\n };\n}\n\n/**\n * Get fixing skill name.\n */\nexport function getFixingSkillName(): string {\n return 'kflow-orbital-fixing';\n}\n","/**\n * KFlow Orbital Fixing Skill Generator\n *\n * Generates the kflow-orbital-fixing skill for fixing validation errors\n * using orbital understanding. Uses the LEAN fixing skill generator from the\n * orbitals module for reduced token usage.\n *\n * @packageDocumentation\n */\n\nimport type { GeneratedSkill } from './types.js';\nimport {\n generateLeanFixingSkill,\n getFixingSkillMetadata,\n} from '../orbitals-skills-generators/lean-fixing-skill-generator.js';\n\n/**\n * Generate the kflow-orbital-fixing skill.\n *\n * Uses the lean generator which:\n * - Shares sections with lean-orbital-skill-generator\n * - Adds fixing-specific workflow and patterns\n * - ~42% smaller than the original generator\n */\nexport function generateKflowOrbitalFixingSkill(): GeneratedSkill {\n const metadata = getFixingSkillMetadata();\n\n const frontmatter = {\n name: metadata.name,\n description: metadata.description,\n allowedTools: ['Read', 'Edit', 'Bash', 'fix_schema_orchestrated', 'query_schema_structure', 'extract_chunk', 'apply_chunk'],\n version: metadata.version,\n };\n\n // Generate lean fixing skill content\n const content = generateLeanFixingSkill({\n includeOverGeneration: true,\n includeSchemaUpdates: true,\n includeEfficiency: true,\n });\n\n return {\n name: metadata.name,\n frontmatter,\n content,\n };\n}\n","/**\n * Domain Language Skill Generator\n *\n * Generates the domain-language skill for understanding, generating,\n * and summarizing KFlow domain language.\n *\n * @packageDocumentation\n */\n\nimport type { GeneratedSkill } from './types.js';\nimport { generateDomainLanguageReference } from '@almadar/core/domain-language';\n\n/**\n * Generate the domain-language skill.\n */\nexport function generateDomainLanguageSkill(): GeneratedSkill {\n const frontmatter = {\n name: 'domain-language',\n description: 'Understand, generate, and summarize KFlow domain language. Convert natural language requirements to domain language and provide human-readable summaries.',\n allowedTools: ['Read', 'Write', 'Edit'],\n version: '1.0.0',\n };\n\n const content = `\n# KFlow Domain Language Skill\n\nThis skill enables you to understand, generate, and summarize KFlow domain language - a human-readable format for defining application schemas.\n\n## What is Domain Language?\n\nDomain language is a structured text format that represents KFlow schemas in a readable way:\n- **Entities** - Data models with fields and relationships\n- **Pages** - UI views with patterns and traits\n- **Behaviors** - State machines and workflows\n\n## Capabilities\n\n### 1. Generate Domain Language from Requirements\n\nConvert natural language requirements into domain language text.\n\n### 2. Summarize Domain Language\n\nCreate human-readable summaries of existing domain language definitions.\n\n### 3. Edit Domain Language\n\nMake targeted edits to existing domain language text.\n\n## Domain Language Reference\n\n${generateDomainLanguageReference()}\n\n## Generation Workflow\n\n### Step 1: Analyze Requirements\n\nExtract key concepts:\n- **Entities** - What data objects are needed?\n- **Fields** - What properties does each entity have?\n- **Pages** - What views are required?\n- **Behaviors** - What workflows or state machines are needed?\n\n### Step 2: Generate Domain Language\n\nUse the syntax reference to create valid domain language:\n\n\\`\\`\\`\nENTITY TaskEntity:\n - title: string (required)\n - description: text\n - status: enum [pending, in_progress, done]\n - dueDate: date\n - assignee: relation -> User\n\nPAGE TaskListPage:\n path: /tasks\n entity: Task\n viewType: list\n sections:\n - header (page-header): title=\"Tasks\"\n - taskList (entity-list): entity=\"Task\", presentation=\"table\"\n traits: []\n\nPAGE TaskCreateForm:\n path: /tasks/new\n entity: Task\n viewType: create\n sections:\n - header (page-header): title=\"Create Task\"\n - form (form-section): entity=\"Task\", layout=\"vertical\"\n - actions (form-actions): submitLabel=\"Create Task\"\n traits: [FormSubmission, FormValidation]\n\\`\\`\\`\n\n### Step 3: Validate Structure\n\nEnsure:\n1. All entities have required fields\n2. Pages reference valid entities\n3. Traits are from the library or properly defined\n4. Section patterns are valid\n\n## Summarization Workflow\n\n### Step 1: Parse Domain Language\n\nIdentify:\n- Number of entities and their purposes\n- Number of pages and their types\n- Key behaviors and workflows\n\n### Step 2: Generate Summary\n\nCreate a concise summary:\n\n**Format:**\n\\`\\`\\`\n**{App Name}** - {one-line description}\n\n**Entities:**\n- {Entity1} - {brief description}\n- {Entity2} - {brief description}\n\n**Pages:**\n- {Page1} ({viewType}) - {purpose}\n- {Page2} ({viewType}) - {purpose}\n\n**Features:**\n- {Key behavior 1}\n- {Key behavior 2}\n\\`\\`\\`\n\n### Summary Requirements\n\n1. Keep it concise (200 words max)\n2. Focus on business functionality\n3. Use bullet points for clarity\n4. Include entity count and page count\n5. Highlight key workflows\n\n## Output Format\n\n### For Generation\n\nOutput ONLY the domain language text - no explanations or commentary.\n\n### For Summary\n\nOutput a structured summary following the format above.\n\n### For Edits\n\nOutput the complete updated domain language text.\n\n## Best Practices\n\n1. **Use library traits** - Prefer existing traits over custom behaviors\n2. **Follow naming conventions** - PascalCase for entities/pages, camelCase for fields\n3. **Include all required fields** - Every entity needs at least one field\n4. **Define page paths** - Use RESTful URL patterns\n5. **Match patterns to view types** - list→entity-list/entity-table, detail→detail-panel, create/edit→form-section\n`.trim();\n\n return {\n name: 'domain-language',\n frontmatter,\n content,\n };\n}\n","/**\n * Lean Orbital Skill Generator\n *\n * Generates kflow-lean-orbitals SKILL.md that:\n * 1. Outputs Domain Language text with S-Expression effects\n * 2. Uses minimal token count (~5x fewer than JSON)\n * 3. Imports from @almadar/* packages for schema knowledge\n *\n * @packageDocumentation\n */\n\n// Inline lean prompts for domain language output\nconst LEAN_CORE_INSTRUCTIONS = `\n## Core Instructions\n\nGenerate orbital schemas using **Domain Language** - a natural, readable format.\n\n**Output Format**: Domain Language text (NOT JSON)\n**Token Efficiency**: ~5x fewer tokens than JSON format\n`;\n\nconst LEAN_OUTPUT_FORMAT = `\n## Output Format\n\nOutput ONLY domain language text. No JSON, no code blocks, no explanations.\n\nExample Output:\n\\`\\`\\`\nA Task is a persistent entity that:\n - has title as text (required)\n - has status as enum [pending, active, done]\n - has dueDate as date\n\nTasksPage at /tasks:\n - shows Task using List behavior\n - view type: list\n\\`\\`\\`\n`;\n\nconst LEAN_VALIDATION_RULES = `\n## Validation\n\n- Every entity needs at least one field\n- Pages must reference valid entities\n- Use standard behaviors from std library\n- S-expressions for guards/effects\n`;\n\nconst LEAN_DECOMPOSITION_PROTOCOL = `\n## Decomposition\n\n1. Identify entities from requirements\n2. Define fields for each entity\n3. Create pages for each entity (list, create, edit)\n4. Apply std behaviors (List, Detail, Form)\n`;\n\nconst ODL_SYNTAX_REFERENCE = `\n## Domain Language Syntax\n\n**Entity**:\n\\`\\`\\`\nA [Name] is a [persistent/runtime/singleton] entity that:\n - has [field] as [type] (required)\n - belongs to [Related]\n - has many [Related]s\n\\`\\`\\`\n\n**Page**:\n\\`\\`\\`\n[PageName] at /[path]:\n - shows [Entity] using [Behavior]\n - view type: [list|detail|create|edit]\n\\`\\`\\`\n`;\n\nconst LEAN_STD_LIST_BEHAVIOR = `\n## List Behavior\n\nUse std/behaviors/crud List behavior for entity browsing.\n`;\n\nconst LEAN_EFFECT_GUARD_SYNTAX = `\n## S-Expressions\n\nUse S-expressions for guards and effects:\n- Guards: \\`[\">\", \"@entity.count\", 0]\\`\n- Effects: \\`[\"set\", \"@entity.field\", value]\\`\n`;\n\nconst LEAN_CRITICAL_RULES = `\n## Critical Rules\n\n1. Use domain language format (NOT JSON)\n2. One page per entity (list view)\n3. Use std behaviors\n`;\n\nconst LEAN_COMMON_ERRORS = `\n## Common Errors\n\n- Don't generate JSON\n- Don't create separate create/edit/view pages\n- Use std behaviors\n`;\n\nconst ODL_PATTERNS = `\n## Patterns\n\nEntity patterns: entity-table, entity-list, entity-cards\nForm patterns: form-section\n`;\n\nconst ODL_TO_SCHEMA_MAPPING = `\n## Mapping\n\nDomain language is converted to OrbitalSchema JSON by the compiler.\n`;\n\nconst LEAN_ERROR_HANDLING = `\n## Error Handling\n\nOutput corrected domain language when errors occur.\n`;\n\n/**\n * Generate the kflow-lean-orbitals SKILL.md content\n */\nexport function generateLeanOrbitalSkill(): string {\n return `---\nname: kflow-lean-orbitals\ndescription: Generate OrbitalSchema applications using Domain Language with S-Expression effects.\nallowed-tools: Read, generate_orbital_domain\nversion: 2.1.0\n---\n\n# kflow-lean-orbitals\n\n> Generate OrbitalSchema applications using Domain Language\n>\n> **Output**: Domain Language text with S-Expression effects\n> **Tools**: \\`generate_orbital_domain\\` (per-orbital generation with auto-persist)\n\n---\n\n${LEAN_CORE_INSTRUCTIONS}\n\n---\n\n${LEAN_DECOMPOSITION_PROTOCOL}\n\n---\n\n${LEAN_STD_LIST_BEHAVIOR}\n\n---\n\n${LEAN_OUTPUT_FORMAT}\n\n---\n\n${ODL_SYNTAX_REFERENCE}\n\n---\n\n${LEAN_EFFECT_GUARD_SYNTAX}\n\n---\n\n${LEAN_CRITICAL_RULES}\n\n---\n\n${LEAN_COMMON_ERRORS}\n\n---\n\n${ODL_PATTERNS}\n\n---\n\n${ODL_TO_SCHEMA_MAPPING}\n\n---\n\n${LEAN_VALIDATION_RULES}\n\n---\n\n${LEAN_ERROR_HANDLING}\n\n---\n\n## Workflow Summary (MANDATORY TOOL USAGE)\n\n⚠️ **CRITICAL: You MUST use \\`generate_orbital_domain\\` for EACH orbital.**\n⚠️ **NEVER use Write/Edit to create domain language directly - always use the tools.**\n\nThe tools handle proper prompting, caching, and S-Expression syntax. Writing directly will fail.\n\n### Phase 1: Decomposition (CRITICAL - NO tool calls yet)\n\n**You MUST decompose the application into orbitals BEFORE calling any tools.**\n\n1. **Classify domain** - business, game, form, dashboard, content\n2. **Identify entities** - List ALL data objects with:\n - Fields (name, type, required, default)\n - Relationships (belongs_to, has_many)\n - Persistence type (persistent, runtime, singleton)\n3. **Resolve cross-references** - Ensure every \"belongs to X\" has entity X planned\n4. **Plan orbitals** - Create a spec for each:\n\n\\`\\`\\`json\n{\n \"name\": \"Task Management\",\n \"entity\": {\n \"name\": \"Task\",\n \"persistence\": \"persistent\",\n \"fields\": [\n { \"name\": \"title\", \"type\": \"text\", \"required\": true },\n { \"name\": \"status\", \"type\": \"enum [todo, done]\", \"default\": \"todo\" }\n ],\n \"relations\": [\n { \"entity\": \"User\", \"type\": \"belongs_to\" }\n ]\n },\n \"pages\": [\n { \"name\": \"TasksPage\", \"path\": \"/tasks\", \"viewType\": \"list\", \"isInitial\": true }\n ],\n \"traits\": [\"TaskManager\"],\n \"patterns\": [\"page-header\", \"entity-table\", \"form-section\", \"detail-panel\"]\n}\n\\`\\`\\`\n\n### Phase 2: Chunked Generation (generate_orbital_domain)\n\nFor EACH orbital spec, call the \\`generate_orbital_domain\\` tool:\n\n\\`\\`\\`json\n{\n \"sessionId\": \"my-app-session\",\n \"orbital\": { ... orbital spec from Phase 1 ... },\n \"orbitalIndex\": 0,\n \"totalOrbitals\": 3\n}\n\\`\\`\\`\n\nThis tool:\n- Uses LLM with proper prompts (S-Expression syntax, patterns, CRUD template)\n- Caches results by fingerprint\n- **Auto-persists**: Each orbital is immediately converted to OrbitalSchema and saved\n\n### Phase 3: Finish\n\nAfter ALL orbitals are generated, call \\`finish_task\\` to complete the workflow.\n\nNo manual merging needed - the schema is built incrementally as each orbital is generated.\n\n---\n\n## Tool Reference\n\n### generate_orbital_domain\n\nGenerate domain language for ONE orbital using LLM with proper prompts.\n\n**Input:**\n- \\`sessionId\\`: Unique session ID for this batch\n- \\`orbital\\`: Orbital spec (entity, pages, traits, patterns)\n- \\`orbitalIndex\\`: Position in batch (0-based)\n- \\`totalOrbitals\\`: Total orbitals being generated\n\n**Output:**\n- \\`success\\`: Whether generation succeeded\n- \\`domainText\\`: Generated domain language\n- \\`cached\\`: Whether result was from cache\n- \\`usage\\`: Token usage\n- \\`schema\\`: The orbital converted to OrbitalSchema (auto-persisted)\n\n---\n\n## Complete Example\n\n**User**: Create a task management app\n\n**Assistant** writes domain.txt:\n\\`\\`\\`\n# Entities\n\nA Task is a persistent entity that:\n - has title as text (required)\n - has description as long text\n - has status as enum [todo, in_progress, done] with default \"todo\"\n - has priority as enum [low, medium, high] with default \"medium\"\n - has dueDate as date\n\n# Pages\n\nTasksPage at /tasks:\n - shows Task using TaskManager\n - view type: list\n - is initial page\n\n# Behaviors\n\nTaskManager behavior:\n Entity: Task\n States: Browsing, Creating, Viewing, Editing, Deleting\n Initial: Browsing\n\n Transitions:\n - From Browsing to Browsing on INIT\n then [\"render-ui\", \"main\", {\"type\": \"page-header\", \"title\": \"Tasks\", \"actions\": [{\"label\": \"New Task\", \"event\": \"CREATE\", \"variant\": \"primary\"}]}]\n then [\"render-ui\", \"center\", {\"type\": \"entity-table\", \"entity\": \"Task\", \"columns\": [\"title\", \"status\", \"priority\", \"dueDate\"], \"itemActions\": [{\"label\": \"View\", \"event\": \"VIEW\"}, {\"label\": \"Edit\", \"event\": \"EDIT\"}, {\"label\": \"Delete\", \"event\": \"DELETE\", \"variant\": \"danger\"}]}]\n\n - From Browsing to Creating on CREATE\n then [\"render-ui\", \"modal\", {\"type\": \"form-section\", \"entity\": \"Task\", \"fields\": [\"title\", \"description\", \"status\", \"priority\", \"dueDate\"], \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\"}]\n\n - From Creating to Browsing on SAVE\n then [\"persist\", \"create\", \"Task\", \"@payload.data\"]\n then [\"render-ui\", \"modal\", null]\n then [\"emit\", \"INIT\"]\n\n - From Creating to Browsing on CANCEL\n then [\"render-ui\", \"modal\", null]\n\n - From Browsing to Viewing on VIEW\n then [\"render-ui\", \"drawer\", {\"type\": \"detail-panel\", \"entity\": \"Task\", \"fields\": [\"title\", \"description\", \"status\", \"priority\", \"dueDate\"], \"actions\": [{\"label\": \"Edit\", \"event\": \"EDIT\"}, {\"label\": \"Delete\", \"event\": \"DELETE\", \"variant\": \"danger\"}]}]\n\n - From Viewing to Editing on EDIT\n then [\"render-ui\", \"drawer\", null]\n then [\"render-ui\", \"modal\", {\"type\": \"form-section\", \"entity\": \"Task\", \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\"}]\n\n - From Browsing to Editing on EDIT\n then [\"render-ui\", \"modal\", {\"type\": \"form-section\", \"entity\": \"Task\", \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\"}]\n\n - From Editing to Browsing on SAVE\n then [\"persist\", \"update\", \"Task\", \"@payload.data\"]\n then [\"render-ui\", \"modal\", null]\n then [\"emit\", \"INIT\"]\n\n - From Editing to Browsing on CANCEL\n then [\"render-ui\", \"modal\", null]\n\n - From Viewing to Browsing on CANCEL\n then [\"render-ui\", \"drawer\", null]\n\n - From Browsing to Deleting on DELETE\n then [\"render-ui\", \"overlay\", {\"type\": \"confirmation\", \"title\": \"Delete Task?\", \"message\": \"This action cannot be undone.\"}]\n\n - From Viewing to Deleting on DELETE\n then [\"render-ui\", \"drawer\", null]\n then [\"render-ui\", \"overlay\", {\"type\": \"confirmation\", \"title\": \"Delete Task?\", \"message\": \"This action cannot be undone.\"}]\n\n - From Deleting to Browsing on CONFIRM_DELETE\n then [\"persist\", \"delete\", \"Task\"]\n then [\"render-ui\", \"overlay\", null]\n then [\"emit\", \"INIT\"]\n\n - From Deleting to Browsing on CANCEL\n then [\"render-ui\", \"overlay\", null]\n\\`\\`\\`\n\n**Key points in this example:**\n- **Entity: Task** explicitly links the behavior to the Task entity (REQUIRED)\n- INIT renders BOTH page-header (with \"New Task\" action) AND entity-table (with View/Edit/Delete itemActions)\n- All effects use S-Expression format\n- Modal for create/edit, drawer for view, overlay for delete confirmation\n- Each open slot is closed with \\`null\\` when done\n- SAVE emits INIT to refresh the list\n`;\n}\n\n/**\n * Get the skill metadata\n */\nexport function getLeanOrbitalSkillMetadata() {\n return {\n name: 'kflow-lean-orbitals',\n description: 'Generate OrbitalSchema applications using Domain Language with S-Expression effects',\n category: 'orbital',\n priority: 'high',\n outputFormat: 'domain-language',\n };\n}\n","/**\n * Lean Fixing Skill Generator\n *\n * Generates kflow-lean-fixing SKILL.md for fixing validation errors\n * using Domain Language format.\n *\n * @packageDocumentation\n */\n\n// Inline lean prompts\nconst LEAN_CORE_INSTRUCTIONS = `\n## Core Instructions\n\nFix validation errors by outputting corrected Domain Language text.\n`;\n\nconst LEAN_ERROR_HANDLING = `\n## Error Handling\n\n1. Read the error message carefully\n2. Locate the problematic section\n3. Output corrected domain language\n`;\n\nconst LEAN_VALIDATION_RULES = `\n## Validation Rules\n\n- Required fields must be marked\n- Entity references must be valid\n- Page paths must be unique\n- Behaviors must be from std library\n`;\n\nconst ODL_SYNTAX_REFERENCE = `\n## Domain Language Syntax\n\nSee kflow-lean-orbitals skill for full syntax reference.\n`;\n\nconst LEAN_EFFECT_GUARD_SYNTAX = `\n## S-Expressions\n\nUse S-expressions in domain language for guards and effects.\n`;\n\nconst ODL_TO_SCHEMA_MAPPING = `\n## Schema Mapping\n\nDomain language maps to OrbitalSchema JSON structure.\n`;\n\n/**\n * Generate the kflow-lean-fixing SKILL.md content\n */\nexport function generateLeanFixingSkill(): string {\n return `---\nname: kflow-lean-fixing\ndescription: Fix OrbitalSchema validation errors using Domain Language format.\nallowed-tools: Read, Write, Edit\nversion: 1.0.0\n---\n\n# kflow-lean-fixing\n\n> Fix OrbitalSchema validation errors using Domain Language\n>\n> **Input**: Validation errors + current ODL\n> **Output**: Fixed Domain Language sections\n\n---\n\n${LEAN_CORE_INSTRUCTIONS}\n\n---\n\n## Error Fixing Protocol\n\n1. **Parse error code** - Identify the error type (ORB_E_*, ORB_T_*, etc.)\n2. **Locate section** - Find the corresponding ODL section\n3. **Apply fix** - Correct the issue in ODL format\n4. **Output fixed section only** - Don't re-output unchanged sections\n\n---\n\n${LEAN_ERROR_HANDLING}\n\n---\n\n## Common Fixes\n\n### ORB_E_MISSING_NAME\n**Error**: Entity missing name\n**Fix**: Ensure entity definition starts with \"A [Name] is...\"\n\nBefore:\n\\`\\`\\`\nis a persistent entity that:\n - has title as text\n\\`\\`\\`\n\nAfter:\n\\`\\`\\`\nA Task is a persistent entity that:\n - has title as text\n\\`\\`\\`\n\n### ORB_E_NO_FIELDS\n**Error**: Entity has no fields\n**Fix**: Add at least one field definition\n\nBefore:\n\\`\\`\\`\nA Task is a persistent entity that:\n\\`\\`\\`\n\nAfter:\n\\`\\`\\`\nA Task is a persistent entity that:\n - has title as text (required)\n\\`\\`\\`\n\n### ORB_T_NO_INITIAL_STATE\n**Error**: Behavior has no initial state\n**Fix**: Add \"Initial: [StateName]\" line\n\nBefore:\n\\`\\`\\`\nTaskManager behavior:\n States: Viewing, Editing\n\n Transitions:\n ...\n\\`\\`\\`\n\nAfter:\n\\`\\`\\`\nTaskManager behavior:\n States: Viewing, Editing\n Initial: Viewing\n\n Transitions:\n ...\n\\`\\`\\`\n\n### ORB_T_INVALID_TRANSITION\n**Error**: Transition references non-existent state\n**Fix**: Ensure From/To states exist in States list\n\nBefore:\n\\`\\`\\`\nTaskManager behavior:\n States: Viewing, Editing\n Initial: Viewing\n\n Transitions:\n - From Viewing to Creating on CREATE # 'Creating' not in States\n\\`\\`\\`\n\nAfter:\n\\`\\`\\`\nTaskManager behavior:\n States: Viewing, Editing, Creating # Added Creating\n Initial: Viewing\n\n Transitions:\n - From Viewing to Creating on CREATE\n\\`\\`\\`\n\n### ORB_P_NO_PATH\n**Error**: Page has no path\n**Fix**: Add \"at /[path]\" to page definition\n\nBefore:\n\\`\\`\\`\nTasksPage:\n - shows Task using TaskManager\n\\`\\`\\`\n\nAfter:\n\\`\\`\\`\nTasksPage at /tasks:\n - shows Task using TaskManager\n\\`\\`\\`\n\n### ORB_E_INVALID_RELATION\n**Error**: Relation references non-existent entity\n**Fix**: Ensure target entity is defined\n\nBefore:\n\\`\\`\\`\nA Task is a persistent entity that:\n - belongs to Project # Project not defined\n\\`\\`\\`\n\nAfter (add missing entity):\n\\`\\`\\`\nA Project is a persistent entity that:\n - has name as text (required)\n\nA Task is a persistent entity that:\n - belongs to Project\n\\`\\`\\`\n\n---\n\n${ODL_SYNTAX_REFERENCE}\n\n---\n\n${LEAN_EFFECT_GUARD_SYNTAX}\n\n---\n\n${LEAN_VALIDATION_RULES}\n\n---\n\n${ODL_TO_SCHEMA_MAPPING}\n\n---\n\n## Output Format\n\n**IMPORTANT**: Always write your fixes to \\`domain.txt\\` using the Write or Edit tool.\n\n1. If \\`domain.txt\\` exists, use the Edit tool to modify it\n2. If it doesn't exist, use the Write tool to create it\n3. The file must contain the COMPLETE domain language with your fixes applied\n4. Do NOT just output text to the chat - you must write to the file\n\nWhen fixing errors:\n- Read the existing domain.txt (if present)\n- Apply fixes to the affected sections\n- Write the complete fixed content to domain.txt\n- Confirm the changes were applied\n\nExample workflow:\n1. Read domain.txt to understand current structure\n2. Edit the specific section that has errors\n3. Verify the fix by reading the file again\n`;\n}\n\n/**\n * Get the skill metadata\n */\nexport function getLeanFixingSkillMetadata() {\n return {\n name: 'kflow-lean-fixing',\n description: 'Fix OrbitalSchema validation errors using Domain Language',\n category: 'orbital',\n priority: 'high',\n outputFormat: 'domain-language',\n };\n}\n","/**\n * Skill Generators for Builder Client\n *\n * Re-exports the 5 core skills used by the builder client:\n * 1. kflow-orbitals (standard JSON generation with atomic composition)\n * 2. kflow-orbital-fixing (standard fixing)\n * 3. kflow-lean-orbitals (lean domain language generation)\n * 4. kflow-lean-fixing (lean fixing)\n * 5. domain-language (ODL understanding/summarization)\n *\n * @packageDocumentation\n */\n\n// Types\nexport type { SkillFrontmatter, GeneratedSkill } from './types.js';\n\n// Utilities\nexport { formatFrontmatter, writeSkill, writeAllSkills } from './utils.js';\n\n// Core skills used by builder client\nexport { generateKflowOrbitalsSkill } from './kflow-orbitals.js';\nexport { generateKflowOrbitalFixingSkill } from './kflow-orbital-fixing.js';\nexport { generateDomainLanguageSkill } from './domain-language.js';\n\n// Lean skills (domain language output)\nexport { generateLeanOrbitalSkill } from '../orbitals-skills-generators/lean/lean-orbital-generator.js';\nexport { generateLeanFixingSkill } from '../orbitals-skills-generators/lean/lean-fixing-generator.js';\n\n// Orbital skill generators (used by kflow-orbitals and kflow-orbital-fixing)\nexport { generateLeanOrbitalSkill as generateLeanOrbitalSkillFull } from '../orbitals-skills-generators/lean-orbital-skill-generator.js';\nexport { generateLeanFixingSkill as generateLeanFixingSkillFull } from '../orbitals-skills-generators/lean-fixing-skill-generator.js';\n\n// Import generators for generateAllBuilderSkills\nimport type { GeneratedSkill } from './types.js';\nimport { generateKflowOrbitalsSkill } from './kflow-orbitals.js';\nimport { generateKflowOrbitalFixingSkill } from './kflow-orbital-fixing.js';\nimport { generateDomainLanguageSkill } from './domain-language.js';\nimport { generateLeanOrbitalSkill } from '../orbitals-skills-generators/lean/lean-orbital-generator.js';\nimport { generateLeanFixingSkill } from '../orbitals-skills-generators/lean/lean-fixing-generator.js';\n\n/**\n * Generate all builder client skills.\n * These are the 5 skills actually used by the builder UI.\n */\nexport function generateAllBuilderSkills(): GeneratedSkill[] {\n return [\n generateKflowOrbitalsSkill(),\n generateKflowOrbitalFixingSkill(),\n {\n name: 'kflow-lean-orbitals',\n frontmatter: {\n name: 'kflow-lean-orbitals',\n description: 'Generate schemas using Domain Language (~5x fewer tokens)',\n allowedTools: ['Read', 'Write', 'Edit'],\n },\n content: generateLeanOrbitalSkill(),\n },\n {\n name: 'kflow-lean-fixing',\n frontmatter: {\n name: 'kflow-lean-fixing',\n description: 'Fix validation errors using Domain Language',\n allowedTools: ['Read', 'Write', 'Edit'],\n },\n content: generateLeanFixingSkill(),\n },\n generateDomainLanguageSkill(),\n ];\n}\n","/**\n * Type References\n *\n * Auto-generated type reference sections from @almadar packages.\n * Used to compose generation prompts.\n *\n * @packageDocumentation\n */\n\nimport { getAllPatternTypes, getPatternPropsCompact } from '@almadar/patterns';\nimport { OPERATORS } from '@almadar/core/types';\nimport { UI_SLOTS } from '@almadar/core/types';\n\n/**\n * Get minimal type reference for orbital schemas.\n * Covers entities, traits, pages, and basic structure.\n */\nexport function getMinimalTypeReference(): string {\n return `\n## Orbital Schema Structure\n\n\\`\\`\\`typescript\ninterface OrbitalDefinition {\n name: string; // Entity name (PascalCase)\n entity: Entity; // Data model\n traits: TraitRef[]; // State machines (names or definitions)\n pages: Page[]; // Routes and views\n emits?: string[]; // Events this orbital emits\n listens?: EventListener[]; // Events this orbital listens to\n}\n\\`\\`\\`\n\n### Entity Fields\n\n\\`\\`\\`typescript\n{ name: \"title\", type: \"string\", required: true }\n{ name: \"count\", type: \"number\", default: 0 }\n{ name: \"status\", type: \"enum\", values: [\"pending\", \"active\", \"done\"] }\n{ name: \"dueDate\", type: \"date\" }\n\\`\\`\\`\n\n### Trait State Machine\n\n\\`\\`\\`typescript\n{\n states: [{ name: \"Idle\", isInitial: true }, { name: \"Active\" }],\n events: [\"INIT\", \"ACTIVATE\", \"COMPLETE\"],\n transitions: [\n { from: \"Idle\", to: \"Active\", event: \"ACTIVATE\",\n guards: [[\"condition\"]],\n effects: [[\"action\"]] }\n ]\n}\n\\`\\`\\`\n`.trim();\n}\n\n/**\n * Get compact pattern types listing.\n */\nexport function getPatternTypesCompact(): string {\n const patterns = getAllPatternTypes();\n return `\n## Available Pattern Types\n\n${patterns.map(p => `- \\`${p}\\``).join('\\n')}\n\n${getPatternPropsCompact()}\n`.trim();\n}\n\n/**\n * Get S-Expression quick reference.\n */\nexport function getSExprQuickRef(): string {\n const operators = Object.keys(OPERATORS).slice(0, 15); // First 15 operators\n\n return `\n## S-Expression Quick Reference\n\n### Guard Expressions (Conditions)\n\n\\`\\`\\`typescript\n[\"=\", \"@entity.status\", \"active\"] // Equality\n[\">\", \"@entity.count\", 0] // Greater than\n[\"and\", [\"cond1\"], [\"cond2\"]] // Logical AND\n[\"or\", [\"cond1\"], [\"cond2\"]] // Logical OR\n[\"not\", [\"condition\"]] // Logical NOT\n\\`\\`\\`\n\n### Effect Expressions (Actions)\n\n\\`\\`\\`typescript\n[\"set\", \"@entity.field\", value] // Update field\n[\"emit\", \"EVENT_NAME\", payload] // Emit event\n[\"navigate\", \"/path\"] // Navigate to route\n[\"render-ui\", \"main\", { type, props }] // Render pattern\n[\"persist\", \"create\", \"Entity\", data] // Database operation\n\\`\\`\\`\n\n### Available Operators\n\n${operators.map(op => `- \\`${op}\\``).join('\\n')}\n`.trim();\n}\n\n/**\n * Get render-ui quick reference.\n */\nexport function getRenderUIQuickRef(): string {\n const slots = UI_SLOTS;\n\n return `\n## Render-UI Effect Reference\n\n### Syntax\n\n\\`\\`\\`typescript\n[\"render-ui\", slot, patternConfig | null]\n\\`\\`\\`\n\n### UI Slots\n\n${slots.map(slot => `- \\`${slot}\\``).join('\\n')}\n\n### Example\n\n\\`\\`\\`typescript\n[\"render-ui\", \"main\", {\n type: \"entity-table\",\n entity: \"Task\",\n columns: [\"title\", \"status\"],\n itemActions: [{ label: \"Edit\", event: \"EDIT\" }]\n}]\n\\`\\`\\`\n\nClear slot: \\`[\"render-ui\", \"modal\", null]\\`\n`.trim();\n}\n\n/**\n * Get field types compact reference.\n */\nexport function getFieldTypesCompact(): string {\n return `\n## Field Types\n\n| Type | Example | Notes |\n|------|---------|-------|\n| \\`string\\` | \\`{ name: \"title\", type: \"string\" }\\` | Text |\n| \\`number\\` | \\`{ name: \"count\", type: \"number\" }\\` | Integer or float |\n| \\`boolean\\` | \\`{ name: \"active\", type: \"boolean\" }\\` | true/false |\n| \\`date\\` | \\`{ name: \"birthday\", type: \"date\" }\\` | Date only |\n| \\`timestamp\\` | \\`{ name: \"createdAt\", type: \"timestamp\" }\\` | Date + time |\n| \\`enum\\` | \\`{ name: \"status\", type: \"enum\", values: [\"a\", \"b\"] }\\` | Fixed options |\n| \\`array\\` | \\`{ name: \"tags\", type: \"array\", items: \"string\" }\\` | List |\n| \\`relation\\` | \\`{ name: \"user\", type: \"relation\", relation: { entity: \"User\", cardinality: \"one\" } }\\` | Foreign key |\n\n### Field Properties\n\n- \\`required: true\\` - Must have value\n- \\`default: value\\` - Default value\n- \\`unique: true\\` - Must be unique\n`.trim();\n}\n","/**\n * Generation Prompts\n *\n * Prompts for the generateFullOrbital() function composed from reusable skill sections.\n * These are used by @almadar/agent for programmatic orbital generation.\n *\n * @packageDocumentation\n */\n\nimport { getArchitectureSection } from './skill-sections/architecture.js';\nimport { getDecompositionSection, getDecompositionChecklist } from './skill-sections/decomposition.js';\nimport { getCommonErrorsSection, getValidationHintsSection } from './skill-sections/common-errors.js';\nimport { getCustomTraitSection } from './skill-sections/custom-traits.js';\nimport { getUsesImportSection } from './skill-sections/uses-imports.js';\nimport {\n getMinimalTypeReference,\n getPatternTypesCompact,\n getSExprQuickRef,\n getRenderUIQuickRef,\n getFieldTypesCompact,\n} from './type-references.js';\n\n/**\n * Get prompt for decomposing a request into orbital units.\n * Used by the main agent before calling generateFullOrbital on each unit.\n */\nexport function getOrbitalDecompositionPrompt(): string {\n return `\n## Orbital Unit Decomposition Protocol\n\n${getArchitectureSection()}\n\n---\n\n${getDecompositionSection()}\n\n---\n\n${getDecompositionChecklist()}\n\n---\n\n## Pattern Selection\n\n${getPatternTypesCompact()}\n\n---\n\n${getValidationHintsSection()}\n`.trim();\n}\n\n/**\n * Get prompt for expanding a lightweight orbital into a full orbital.\n * This is the main prompt used by generateFullOrbital().\n */\nexport function getFullOrbitalPrompt(): string {\n return `\n# Subagent: Expand Lightweight Orbital to Full Orbital\n\nYou receive a lightweight OrbitalDefinition and must expand it into a complete FullOrbitalUnit with traits, state machines, and UI.\n\n---\n\n${getArchitectureSection()}\n\n---\n\n${getMinimalTypeReference()}\n\n---\n\n${getSExprQuickRef()}\n\n---\n\n${getRenderUIQuickRef()}\n\n---\n\n${getFieldTypesCompact()}\n\n---\n\n${getCustomTraitSection()}\n\n---\n\n${getUsesImportSection()}\n\n---\n\n${getCommonErrorsSection()}\n\n---\n\n## Output Format\n\nReturn ONLY valid JSON matching the FullOrbitalUnit structure. No markdown, no explanations.\n\n**CRITICAL: The entity field is REQUIRED at the orbital level:**\n\n\\`\\`\\`json\n{\n \"name\": \"Product Management\",\n \"entity\": { // ← REQUIRED: Must have this field\n \"name\": \"Product\",\n \"collection\": \"products\",\n \"persistence\": \"persistent\",\n \"fields\": [\n { \"name\": \"name\", \"type\": \"string\", \"required\": true },\n { \"name\": \"price\", \"type\": \"number\" }\n ]\n },\n \"traits\": [ ... ],\n \"pages\": [ ... ]\n}\n\\`\\`\\`\n\n**Validation Rules:**\n- MUST include \"entity\" field at orbital level (NOT just linkedEntity in traits)\n- entity.name must match the orbital's primary entity\n- entity.collection must be plural lowercase (e.g., \"products\", not \"Product\")\n- entity.fields must have at least one field\n\n**Common Mistake:**\n- ❌ WRONG: Only putting entity reference in trait.linkedEntity\n- ✅ CORRECT: Full entity object in orbital.entity field\n`.trim();\n}\n\n/**\n * Get prompt for requirements-aware decomposition.\n * Used when extracted requirements are available from analysis phase.\n */\nexport function getRequirementsDecomposePrompt(): string {\n return `\n## Requirements-Aware Decomposition\n\nWhen decomposing with extracted requirements, use them to improve orbital identification:\n\n### Using Entity Requirements\n\nFor each entity in \\`requirements.entities\\`:\n- Create one OrbitalUnit per **primary** entity\n- Group related entities (e.g., Order + OrderItem in same orbital)\n- Consider entity relationships when grouping\n\n### Using State Requirements\n\nFor each state in \\`requirements.states\\`:\n- Identify which entity lifecycle it belongs to\n- Create states in that entity's trait state machine\n\n### Using Event Requirements\n\nFor each event in \\`requirements.events\\`:\n- Map to trait events (UPPERCASE)\n- Connect to appropriate transitions\n\n### Using Guard Requirements\n\nFor each guard in \\`requirements.guards\\`:\n- Identify which entity the guard applies to\n- Include guard description in that entity's orbital\n- The subagent will convert to guard expression\n\n### Using Effect Requirements\n\nFor each effect in \\`requirements.effects\\`:\n- Identify the trigger (e.g., \"on confirmation\")\n- Identify the action (e.g., \"send email\")\n- Include in relevant orbital's effects list\n\n${getValidationHintsSection()}\n`.trim();\n}\n\n/**\n * Get prompt for generating traits from requirements.\n * Used when requirements need to be converted to trait state machines.\n */\nexport function getRequirementsTraitPrompt(): string {\n return `\n## Generating Traits from Requirements\n\nWhen generating a FullOrbitalUnit, convert requirements to schema elements:\n\n### Guard Patterns\n\nCommon guard patterns to recognize:\n\n| Requirement | Guard Expression |\n|-------------|-----------------|\n| \"only managers can approve\" | \\`[\"=\", \"@context.user.role\", \"manager\"]\\` |\n| \"amount must be positive\" | \\`[\">\", \"@entity.amount\", 0]\\` |\n| \"if status is pending\" | \\`[\"=\", \"@entity.status\", \"pending\"]\\` |\n| \"user is authenticated\" | \\`[\"=\", \"@context.user.authenticated\", true]\\` |\n\n### Effect Patterns\n\nCommon effect patterns to recognize:\n\n| Requirement | Effect Type | Template |\n|-------------|------------|----------|\n| \"send email\" | \\`emit\\` | \\`[\"emit\", \"EMAIL_SEND\", { \"to\": \"...\", \"subject\": \"...\" }]\\` |\n| \"update status\" | \\`set\\` | \\`[\"set\", \"@entity.status\", \"newValue\"]\\` |\n| \"navigate to page\" | \\`navigate\\` | \\`[\"navigate\", \"/page\"]\\` |\n| \"show notification\" | \\`emit\\` | \\`[\"emit\", \"NOTIFY\", { \"message\": \"...\" }]\\` |\n\n### State Machine Construction\n\n1. Extract states from requirements.states\n2. Create events for state transitions (UPPERCASE)\n3. Add transitions with appropriate guards\n4. Include render-ui effects for each state\n\n${getCommonErrorsSection()}\n`.trim();\n}\n","/**\n * Behaviors Reference\n *\n * Helper for generating standard behaviors documentation from @almadar/std.\n *\n * @packageDocumentation\n */\n\nimport { generateBehaviorsDocs } from '@almadar/std';\n\n/**\n * Get key behaviors reference (compact).\n * Uses @almadar/std to generate the behaviors documentation.\n */\nexport function getKeyBehaviorsReference(): string {\n const behaviorsDocs = generateBehaviorsDocs();\n\n return `## Key Standard Behaviors\n\n${behaviorsDocs.categories.map(cat => `### ${cat.name}\n${cat.behaviors.map(b => `- **${b.name}**: ${b.description}`).join('\\n')}\n`).join('\\n')}\n\nUse with: \\`uses: [{ from: \"std/behaviors/crud\", as: \"CRUD\" }]\\`\n`;\n}\n","/**\n * Composition Quality Evaluation Framework\n *\n * Evaluates LLM providers' ability to generate sophisticated render-ui effects\n * that meet the Five Rules of Sophisticated Composition.\n *\n * @packageDocumentation\n */\n\nimport type { OrbitalSchema } from '@almadar/core';\nimport { isInlineTrait } from '@almadar/core';\n\nexport interface EvalCase {\n name: string;\n description: string;\n prompt: string;\n expectedPatterns: string[];\n minScore: number;\n domain: 'general' | 'healthcare' | 'ecommerce' | 'project-management';\n rubric?: {\n structure: Record<string, number>;\n composition: Record<string, number>;\n theme: Record<string, number>;\n quality: Record<string, number>;\n };\n}\n\nexport interface EvalResult {\n caseName: string;\n provider: string;\n score: number;\n passed: boolean;\n breakdown: ScoreBreakdown;\n validationErrors: string[];\n validationWarnings: string[];\n schema?: OrbitalSchema;\n}\n\nexport interface ScoreBreakdown {\n structure: number; // 25 points max\n composition: number; // 25 points max\n theme: number; // 25 points max\n quality: number; // 25 points max\n}\n\nexport interface CompositionMetrics {\n renderUICount: number;\n atomTypes: string[];\n moleculeTypes: string[];\n organismTypes: string[];\n layoutRoot: string | null;\n nestingDepth: number;\n sectionCount: number;\n themeVariableUsage: number; // percentage\n hardcodedValues: string[];\n}\n\n// ============================================================================\n// Test Cases\n// ============================================================================\n\nexport const EVAL_CASES: EvalCase[] = [\n {\n name: \"task-management-basic\",\n description: \"Generate a basic task management view with CRUD\",\n prompt: `Generate an Orbital schema for a task management app.\n \nEntity: Task with fields: title (string, required), status (enum: pending/active/done), priority (enum: low/medium/high)\n\nRequirements:\n- List view with search and actions (view, edit, delete)\n- Modal form for creating tasks\n- Use atomic composition with stack layouts\n- Include stats/overview section showing counts`,\n expectedPatterns: ['stack', 'page-header', 'entity-table', 'form-section', 'box', 'typography', 'badge', 'button'],\n minScore: 70,\n domain: 'general'\n },\n {\n name: \"patient-portal-dashboard\",\n description: \"Generate a healthcare patient portal dashboard\",\n prompt: `Generate an Orbital schema for a healthcare patient portal.\n\nEntities:\n- Patient: name, dateOfBirth, medicalRecordNumber, insuranceStatus\n- Appointment: date, time, doctor, status, notes\n\nRequirements:\n- Dashboard with patient statistics (total, active, critical)\n- Patient list with filters by status\n- Appointment scheduling view\n- Use healthcare-appropriate layouts (calm, organized)\n- Include tabs for different views`,\n expectedPatterns: ['stack', 'grid', 'page-header', 'entity-table', 'tabs', 'badge', 'card', 'stats'],\n minScore: 75,\n domain: 'healthcare'\n },\n {\n name: \"ecommerce-product-catalog\",\n description: \"Generate an e-commerce product catalog\",\n prompt: `Generate an Orbital schema for an e-commerce product catalog.\n\nEntities:\n- Product: name, price, category, stockLevel, rating, imageUrl\n- Category: name, description\n\nRequirements:\n- Product grid with cards (use grid layout)\n- Filters by category and price range\n- Product detail view with image\n- Shopping cart indicator\n- Use product-appropriate layouts (visual, appealing)`,\n expectedPatterns: ['stack', 'grid', 'entity-cards', 'filter-group', 'badge', 'card', 'image'],\n minScore: 75,\n domain: 'ecommerce'\n },\n {\n name: \"project-management-kanban\",\n description: \"Generate a project management kanban board\",\n prompt: `Generate an Orbital schema for a project management kanban board.\n\nEntities:\n- Project: name, status, deadline, progress, owner\n- Task: title, status (todo/in-progress/done), assignee, priority, dueDate\n\nRequirements:\n- Kanban board with columns for each status\n- Task cards with drag-drop feel (visual design)\n- Project overview with progress bars\n- Team member avatars\n- Due date indicators`,\n expectedPatterns: ['stack', 'grid', 'card', 'progress-bar', 'avatar', 'badge', 'page-header'],\n minScore: 80,\n domain: 'project-management'\n },\n {\n name: \"analytics-dashboard\",\n description: \"Generate an analytics dashboard with charts\",\n prompt: `Generate an Orbital schema for an analytics dashboard.\n\nEntities:\n- Metric: name, value, change, trend\n- Report: title, date, type, status\n\nRequirements:\n- Stats cards with trend indicators (up/down)\n- Chart visualization area\n- Recent reports list\n- Date range selector\n- Professional, data-dense layout`,\n expectedPatterns: ['stack', 'grid', 'stats', 'chart', 'entity-table', 'badge', 'card'],\n minScore: 75,\n domain: 'general'\n }\n];\n\n// ============================================================================\n// Scoring Functions\n// ============================================================================\n\n/**\n * Analyze the composition metrics of a schema.\n */\nexport function analyzeComposition(schema: OrbitalSchema): CompositionMetrics {\n const metrics: CompositionMetrics = {\n renderUICount: 0,\n atomTypes: [],\n moleculeTypes: [],\n organismTypes: [],\n layoutRoot: null,\n nestingDepth: 0,\n sectionCount: 0,\n themeVariableUsage: 0,\n hardcodedValues: []\n };\n\n // Traverse all transitions\n for (const orbital of schema.orbitals) {\n for (const trait of orbital.traits) {\n // Skip trait refs - we need full trait definitions with stateMachine\n if (!isInlineTrait(trait)) continue;\n if (!trait.stateMachine?.transitions) continue;\n\n for (const transition of trait.stateMachine.transitions) {\n if (!transition.effects) continue;\n \n for (const effect of transition.effects) {\n if (!Array.isArray(effect)) continue;\n if (effect[0] !== 'render-ui') continue;\n \n metrics.renderUICount++;\n const pattern = effect[2];\n \n if (pattern && typeof pattern === 'object') {\n analyzePattern(pattern, metrics, 0);\n }\n }\n }\n }\n }\n\n // Calculate theme variable usage\n const totalValues = metrics.atomTypes.length + metrics.moleculeTypes.length + metrics.organismTypes.length;\n if (totalValues > 0) {\n // This is a simplified calculation - in practice, we'd check all props\n metrics.themeVariableUsage = 100 - (metrics.hardcodedValues.length / totalValues * 100);\n }\n\n return metrics;\n}\n\nfunction analyzePattern(pattern: any, metrics: CompositionMetrics, depth: number): void {\n if (!pattern || typeof pattern !== 'object') return;\n\n // Track nesting depth\n metrics.nestingDepth = Math.max(metrics.nestingDepth, depth);\n\n // Check if this is the root layout\n if (depth === 0 && ['stack', 'box', 'container', 'grid'].includes(pattern.type)) {\n metrics.layoutRoot = pattern.type;\n }\n\n // Categorize pattern types\n const atomTypes = ['typography', 'badge', 'button', 'avatar', 'icon', 'progress-bar', 'divider'];\n const moleculeTypes = ['card', 'modal', 'drawer', 'tabs', 'alert', 'accordion', 'box'];\n const organismTypes = ['entity-table', 'form-section', 'detail-panel', 'page-header', 'chart', 'timeline', 'stats'];\n\n if (atomTypes.includes(pattern.type) && !metrics.atomTypes.includes(pattern.type)) {\n metrics.atomTypes.push(pattern.type);\n }\n if (moleculeTypes.includes(pattern.type) && !metrics.moleculeTypes.includes(pattern.type)) {\n metrics.moleculeTypes.push(pattern.type);\n }\n if (organismTypes.includes(pattern.type) && !metrics.organismTypes.includes(pattern.type)) {\n metrics.organismTypes.push(pattern.type);\n }\n\n // Check for hardcoded values\n for (const [key, value] of Object.entries(pattern)) {\n if (typeof value === 'string') {\n if (value.startsWith('#') || /^\\d+px$/.test(value) || ['white', 'black', 'red', 'blue'].includes(value.toLowerCase())) {\n metrics.hardcodedValues.push(`${key}: ${value}`);\n }\n }\n }\n\n // Count sections (children at depth 1)\n if (depth === 1 && pattern.type) {\n metrics.sectionCount++;\n }\n\n // Recurse into children\n if (pattern.children && Array.isArray(pattern.children)) {\n for (const child of pattern.children) {\n analyzePattern(child, metrics, depth + 1);\n }\n }\n}\n\n/**\n * Score the structure category (25 points max)\n */\nexport function scoreStructure(metrics: CompositionMetrics, schema: OrbitalSchema): number {\n let score = 0;\n\n // Single render-ui per transition (5 points)\n // This is checked by counting render-ui effects per transition\n const transitions = countTransitions(schema);\n if (metrics.renderUICount <= transitions) {\n score += 5;\n }\n\n // Layout root present (5 points)\n if (metrics.layoutRoot) {\n score += 5;\n }\n\n // Proper nesting depth (5 points)\n if (metrics.nestingDepth >= 3) {\n score += 5;\n } else if (metrics.nestingDepth >= 2) {\n score += 3;\n }\n\n // Validation passed (5 points)\n // This is checked separately and added after validation\n score += 5;\n\n // Closed circuit pattern (5 points)\n // All states have entry/exit transitions\n if (hasClosedCircuit(schema)) {\n score += 5;\n }\n\n return Math.min(25, score);\n}\n\n/**\n * Score the composition category (25 points max)\n */\nexport function scoreComposition(metrics: CompositionMetrics): number {\n let score = 0;\n\n // Atom count (10 points)\n if (metrics.atomTypes.length >= 4) {\n score += 10;\n } else if (metrics.atomTypes.length === 3) {\n score += 7;\n } else if (metrics.atomTypes.length === 2) {\n score += 5;\n }\n\n // Molecule count (7 points)\n if (metrics.moleculeTypes.length >= 3) {\n score += 7;\n } else if (metrics.moleculeTypes.length === 2) {\n score += 5;\n } else if (metrics.moleculeTypes.length === 1) {\n score += 3;\n }\n\n // Organism count (8 points)\n if (metrics.organismTypes.length >= 2) {\n score += 8;\n } else if (metrics.organismTypes.length === 1) {\n score += 5;\n }\n\n return Math.min(25, score);\n}\n\n/**\n * Score the theme category (25 points max)\n */\nexport function scoreTheme(metrics: CompositionMetrics): number {\n let score = 0;\n\n // Theme variable usage (15 points)\n if (metrics.themeVariableUsage >= 95) {\n score += 15;\n } else if (metrics.themeVariableUsage >= 85) {\n score += 10;\n } else if (metrics.themeVariableUsage >= 75) {\n score += 5;\n }\n\n // No hardcoded colors (5 points)\n const hasNoHardcodedColors = !metrics.hardcodedValues.some(v => v.includes('#') || ['white', 'black'].some(c => v.toLowerCase().includes(c)));\n if (hasNoHardcodedColors) {\n score += 5;\n }\n\n // No hardcoded spacing (5 points)\n const hasNoHardcodedSpacing = !metrics.hardcodedValues.some(v => /\\d+px/.test(v));\n if (hasNoHardcodedSpacing) {\n score += 5;\n }\n\n return Math.min(25, score);\n}\n\n/**\n * Score the quality category (25 points max)\n */\nexport function scoreQuality(metrics: CompositionMetrics, testCase: EvalCase): number {\n let score = 0;\n\n // Section count (8 points)\n if (metrics.sectionCount >= 4) {\n score += 8;\n } else if (metrics.sectionCount === 3) {\n score += 6;\n } else if (metrics.sectionCount === 2) {\n score += 4;\n }\n\n // Expected patterns present (8 points)\n const expectedPresent = testCase.expectedPatterns.filter(p => \n metrics.atomTypes.includes(p) || \n metrics.moleculeTypes.includes(p) || \n metrics.organismTypes.includes(p)\n ).length;\n score += (expectedPresent / testCase.expectedPatterns.length) * 8;\n\n // Domain appropriateness (5 points)\n // This would require domain-specific checks\n score += 5;\n\n // Action completeness (4 points)\n // CRUD actions present\n score += 4;\n\n return Math.min(25, score);\n}\n\n/**\n * Calculate total score (0-100)\n */\nexport function calculateTotalScore(\n schema: OrbitalSchema, \n testCase: EvalCase,\n validationErrors: string[]\n): { score: number; breakdown: ScoreBreakdown } {\n const metrics = analyzeComposition(schema);\n\n const breakdown: ScoreBreakdown = {\n structure: scoreStructure(metrics, schema),\n composition: scoreComposition(metrics),\n theme: scoreTheme(metrics),\n quality: scoreQuality(metrics, testCase)\n };\n\n // Deduct points for validation errors\n if (validationErrors.length > 0) {\n breakdown.structure = Math.max(0, breakdown.structure - (validationErrors.length * 2));\n }\n\n const total = breakdown.structure + breakdown.composition + breakdown.theme + breakdown.quality;\n\n return {\n score: Math.min(100, Math.round(total)),\n breakdown\n };\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nfunction countTransitions(schema: OrbitalSchema): number {\n let count = 0;\n for (const orbital of schema.orbitals) {\n for (const trait of orbital.traits) {\n if (!isInlineTrait(trait)) continue;\n if (trait.stateMachine?.transitions) {\n count += trait.stateMachine.transitions.length;\n }\n }\n }\n return count;\n}\n\nfunction hasClosedCircuit(schema: OrbitalSchema): boolean {\n // Check that all states have entry and exit transitions\n for (const orbital of schema.orbitals) {\n for (const trait of orbital.traits) {\n if (!isInlineTrait(trait)) continue;\n if (!trait.stateMachine) continue;\n\n const states = new Set<string>((trait.stateMachine.states || []).map(s => s.name));\n const incomingStates = new Set<string>();\n const outgoingStates = new Set<string>();\n\n for (const transition of trait.stateMachine.transitions || []) {\n incomingStates.add(transition.to);\n outgoingStates.add(transition.from);\n }\n\n // All states except initial should have incoming\n // All states should have outgoing (or be terminal)\n for (const state of states) {\n const stateObj = (trait.stateMachine.states || []).find(s => s.name === state);\n if (!stateObj?.isInitial && !incomingStates.has(state)) {\n return false;\n }\n }\n }\n }\n return true;\n}\n\n// ============================================================================\n// Provider Comparison\n// ============================================================================\n\nexport interface ProviderComparison {\n provider: string;\n averageScore: number;\n cases: { caseName: string; score: number; passed: boolean }[];\n strengths: string[];\n weaknesses: string[];\n}\n\n/**\n * Run all eval cases for a provider.\n */\nexport async function runProviderEval(\n provider: string,\n generateFn: (prompt: string) => Promise<OrbitalSchema>\n): Promise<ProviderComparison> {\n const results: { caseName: string; score: number; passed: boolean }[] = [];\n let totalScore = 0;\n\n for (const testCase of EVAL_CASES) {\n try {\n const schema = await generateFn(testCase.prompt);\n const { score } = calculateTotalScore(schema, testCase, []);\n \n results.push({\n caseName: testCase.name,\n score,\n passed: score >= testCase.minScore\n });\n totalScore += score;\n } catch (error) {\n results.push({\n caseName: testCase.name,\n score: 0,\n passed: false\n });\n }\n }\n\n return {\n provider,\n averageScore: Math.round(totalScore / EVAL_CASES.length),\n cases: results,\n strengths: [], // Would be populated by analysis\n weaknesses: [] // Would be populated by analysis\n };\n}\n\n/**\n * Generate comparison matrix for all providers.\n */\nexport function generateComparisonMatrix(comparisons: ProviderComparison[]): string {\n let markdown = '# Composition Quality Provider Comparison\\n\\n';\n markdown += '| Provider | Average Score | task-mgmt | patient | ecommerce | kanban | analytics |\\n';\n markdown += '|----------|---------------|-----------|---------|-----------|--------|-----------|\\n';\n\n for (const comp of comparisons) {\n const scores = EVAL_CASES.map(tc => {\n const result = comp.cases.find(c => c.caseName === tc.name);\n return result ? `${result.score}${result.passed ? '✓' : ''}` : 'N/A';\n });\n \n markdown += `| ${comp.provider} | ${comp.averageScore} | ${scores.join(' | ')} |\\n`;\n }\n\n return markdown;\n}\n"]}