@almadar/skills 1.1.1 → 1.1.2

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 CHANGED
@@ -130,7 +130,7 @@ ${nonGameBehaviors.map((behavior) => {
130
130
  return `### ${behavior.name}
131
131
 
132
132
  **States**: ${sm?.states?.map((s) => s.name).join(", ") ?? "N/A"}
133
- **Events**: ${sm?.events?.join(", ") ?? "N/A"}
133
+ **Events**: ${sm?.events?.map((e) => e.key ?? e.name ?? e).join(", ") ?? "N/A"}
134
134
 
135
135
  \`\`\`json
136
136
  ${JSON.stringify(behavior, null, 2)}
@@ -476,6 +476,9 @@ function getDecompositionSection() {
476
476
  | form | wizard, onboarding | Wizard, FormSubmission |
477
477
  | dashboard | metrics, KPI | EntityManagement |
478
478
  | content | blog, CMS | none (page navigation) |
479
+ | social | chat, feed, profile, follow | EntityManagement |
480
+ | ecommerce | shop, store, cart, checkout | EntityManagement, SearchAndFilter |
481
+ | workflow | automate, process, pipeline | EntityManagement |
479
482
 
480
483
  ### Step 1: Identify Entities (ONE Orbital Per Entity)
481
484
  - What are the core data objects?
@@ -547,7 +550,7 @@ Without INIT, the page loads blank!
547
550
  function getDecompositionChecklist() {
548
551
  return `## Decomposition Checklist
549
552
 
550
- - [ ] Domain classified (business/game/form/dashboard/content)
553
+ - [ ] Domain classified (business/game/form/dashboard/content/social/ecommerce/workflow)
551
554
  - [ ] Entities identified with persistence type
552
555
  - [ ] **ONE orbital per entity** (not multiple orbitals for same entity!)
553
556
  - [ ] Traits selected (EntityManagement for CRUD, domain-specific for others)
@@ -571,6 +574,9 @@ function getDecompositionCompact() {
571
574
  | form | wizard, onboarding | Wizard, FormSubmission |
572
575
  | dashboard | metrics, KPI | EntityManagement |
573
576
  | content | blog, CMS | none (page navigation) |
577
+ | social | chat, feed, profile, follow | EntityManagement |
578
+ | ecommerce | shop, store, cart, checkout | EntityManagement, SearchAndFilter |
579
+ | workflow | automate, process, pipeline | EntityManagement |
574
580
 
575
581
  ### Step 1: Identify Entities (ONE Orbital Per Entity)
576
582
  - What are the core data objects?
@@ -872,7 +878,7 @@ Layout patterns wrap other patterns via \`children\` arrays for rich, structured
872
878
  | Domain | List Pattern | Extras |
873
879
  |--------|-------------|--------|
874
880
  | business/admin | \`entity-table\` (searchable) | \`stats\`, \`filter-group\` |
875
- | e-commerce | \`entity-cards\` | \`stats\` (revenue), \`chart\` |
881
+ | ecommerce | \`entity-cards\` | \`stats\` (revenue), \`chart\` |
876
882
  | content/CMS | \`entity-cards\` | \`tabs\`, \`media-gallery\` |
877
883
  | dashboard | \`dashboard-grid\` | \`stats\`, \`chart\`, \`meter\`, \`timeline\` |
878
884
  | workflow | \`entity-table\` | \`progress-bar\`, \`timeline\` |
@@ -2778,7 +2784,7 @@ You receive a single transition to design. Use these inputs to make UI decisions
2778
2784
  3. What DOMAIN?
2779
2785
  \u251C\u2500 business \u2192 entity-table + stats + filter-group
2780
2786
  \u251C\u2500 dashboard \u2192 dashboard-grid + chart + stats
2781
- \u251C\u2500 e-commerce \u2192 entity-cards + stats (revenue)
2787
+ \u251C\u2500 ecommerce \u2192 entity-cards + stats (revenue)
2782
2788
  \u251C\u2500 content \u2192 entity-cards + tabs + media
2783
2789
  \u2514\u2500 workflow \u2192 timeline + progress-bar
2784
2790
 
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/pattern-design-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/prompts/type-references.ts","../src/generators/kflow-design.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/generation-prompts.ts","../src/prompts/behaviors-reference.ts"],"names":["PATTERN_TYPES","getPatternActionsRef","getPatternPropsCompact","getSExprQuickRef","getRenderUIQuickRef","ODL_SYNTAX_REFERENCE","ODL_PATTERNS","ODL_TO_SCHEMA_MAPPING","generateLeanOrbitalSkill","LEAN_CORE_INSTRUCTIONS","LEAN_ERROR_HANDLING","LEAN_VALIDATION_RULES","LEAN_EFFECT_GUARD_SYNTAX","generateLeanFixingSkill","getKeyBehaviorsReference","generateBehaviorsDocs"],"mappings":";;;;;;;AAeO,SAAS,kBAAkB,EAAA,EAA8B;AAC9D,EAAA,MAAM,KAAA,GAAQ,CAAC,KAAK,CAAA;AACpB,EAAA,KAAA,CAAM,IAAA,CAAK,CAAA,MAAA,EAAS,EAAA,CAAG,IAAI,CAAA,CAAE,CAAA;AAC7B,EAAA,KAAA,CAAM,IAAA,CAAK,CAAA,aAAA,EAAgB,EAAA,CAAG,WAAW,CAAA,CAAE,CAAA;AAC3C,EAAA,IAAI,EAAA,CAAG,cAAc,MAAA,EAAQ;AAC3B,IAAA,KAAA,CAAM,KAAK,CAAA,eAAA,EAAkB,EAAA,CAAG,aAAa,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AAAA,EAC3D;AACA,EAAA,IAAI,GAAG,OAAA,EAAS;AACd,IAAA,KAAA,CAAM,IAAA,CAAK,CAAA,SAAA,EAAY,EAAA,CAAG,OAAO,CAAA,CAAE,CAAA;AAAA,EACrC;AACA,EAAA,KAAA,CAAM,KAAK,KAAK,CAAA;AAChB,EAAA,OAAO,KAAA,CAAM,KAAK,IAAI,CAA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AsB;;AAAA;;AAAA,EAItB,wBAAwB;;AAAA;;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAgBxB,IAAA,EAAK;AACP;AAMO,SAAS,8BAAA,GAAyC;AACvD,EAAA,OAAO;AAAA;;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA,EAsCP,2BAA2B;AAAA,CAAA,CAC3B,IAAA,EAAK;AACP;AAMO,SAAS,0BAAA,GAAqC;AACnD,EAAA,OAAO;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA,EAkCP,wBAAwB;AAAA,CAAA,CACxB,IAAA,EAAK;AACP;ACzLO,SAASU,yBAAAA,GAAmC;AACjD,EAAA,MAAM,gBAAgBC,qBAAAA,EAAsB;AAE5C,EAAA,OAAO,CAAA;;AAAA,EAEP,cAAc,UAAA,CAAW,GAAA,CAAI,CAAA,GAAA,KAAO,CAAA,IAAA,EAAO,IAAI,IAAI;AAAA,EACnD,GAAA,CAAI,SAAA,CAAU,GAAA,CAAI,CAAA,CAAA,KAAK,OAAO,CAAA,CAAE,IAAI,CAAA,IAAA,EAAO,CAAA,CAAE,WAAW,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC;AAAA,CACvE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC;;AAAA;AAAA,CAAA;AAIb","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?.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 onSubmit** | Connects form to trait events |\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 → entity-detail (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.\n\n\\`\\`\\`json\n{\n \"from\": \"Browsing\",\n \"to\": \"Browsing\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", { \"type\": \"page-header\", ... }],\n [\"render-ui\", \"main\", { \"type\": \"entity-table\", ... }]\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 State Machine Pattern\n\nWhen a transition opens a modal/drawer, the target state MUST have CLOSE and CANCEL transitions:\n\n\\`\\`\\`json\n{ \"from\": \"Browsing\", \"to\": \"Creating\", \"event\": \"CREATE\",\n \"effects\": [[\"render-ui\", \"modal\", { \"type\": \"form-section\", \"cancelEvent\": \"CANCEL\", ... }]] },\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"modal\", null]] },\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"CLOSE\",\n \"effects\": [[\"render-ui\", \"modal\", null]] },\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"effects\": [[\"persist\", \"create\", \"Entity\", \"@payload.data\"], [\"render-ui\", \"modal\", null], [\"emit\", \"INIT\"]] }\n\\`\\`\\`\n\n**CLOSE** = user clicks outside modal/presses Escape. **CANCEL** = form cancel button. Both needed.\n`;\n}\n\n/**\n * Edge case errors 7-16 — 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 onSubmit in form-section\n\\`\\`\\`\nWRONG: { \"type\": \"form-section\", \"entity\": \"Task\" }\nCORRECT: { \"type\": \"form-section\", \"entity\": \"Task\", \"onSubmit\": \"SAVE\" }\n\\`\\`\\`\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 onSubmit/onCancel 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 onSubmit event name 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\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** - do NOT split CRUD operations into separate orbitals\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\n- Business: EntityManagement (handles CRUD via render-ui)\n- Game: Physics2D, Health, Score, Collision\n- Form: Wizard (multi-step) or FormSubmission (single)\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)\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\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\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\n- Business: EntityManagement (handles CRUD via render-ui)\n- Game: Physics2D, Health, Score, Collision\n- Form: Wizard (multi-step) or FormSubmission (single)\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 * Pattern Design Guide Section\n *\n * Replaces the 380-char getRenderUIQuickRef() with actionable guidance\n * on pattern selection, composition recipes, and slot strategy.\n *\n * Target: ~2,500 chars — focused entirely on helping the LLM produce\n * rich, varied render-ui effects instead of defaulting to entity-table.\n *\n * @packageDocumentation\n */\n\nimport {\n getPatternPropsCompact,\n getPatternActionsRef,\n} from \"@almadar/patterns\";\n\n/**\n * Get the render-ui design guide.\n * Covers syntax, slot strategy, pattern-by-intent, and composition recipes.\n */\nexport function getRenderUIDesignGuide(): string {\n return `## Render-UI Design Guide\n\n### Syntax\n\\`[\"render-ui\", slot, { \"type\": pattern, ...props }]\\`\nClear slot: \\`[\"render-ui\", \"modal\", null]\\`\n\n### Slot Strategy\n| Slot | Use For | Composable? |\n|------|---------|-------------|\n| \\`main\\` | Primary content | **YES** — stack multiple render-ui calls |\n| \\`modal\\` | Forms (create/edit), confirmations | One at a time |\n| \\`drawer\\` | Detail views, quick edits | One at a time |\n| \\`sidebar\\` | Navigation, persistent filters | One at a time |\n| \\`overlay\\` | Confirmations, alerts | One at a time |\n\n### Pattern Selection by Intent\n| Intent | Patterns | Key Props |\n|--------|----------|-----------|\n| List/browse data | \\`entity-table\\`, \\`entity-cards\\`, \\`entity-list\\` | columns, itemActions, searchable |\n| Show metrics/KPIs | \\`stats\\` | metrics: [{label, value, icon, trend}] |\n| Filter/search | \\`filter-group\\`, \\`search-input\\` | filters (from entity enum fields) |\n| Create/edit form | \\`form-section\\` | fields, submitEvent, cancelEvent |\n| View details | \\`entity-detail\\`, \\`detail-panel\\` | fields/fieldNames, actions |\n| Organize content | \\`tabs\\` | tabs: [{label, content}] |\n| Dashboard layout | \\`dashboard-grid\\` | columns (number) |\n| Charts | \\`chart\\` | chartType, data, xAxis, yAxis |\n| Progress | \\`progress-bar\\`, \\`meter\\` | value, max, label |\n| Timeline | \\`timeline\\` | items: [{date, title, description}] |\n| Page heading | \\`page-header\\` | title, subtitle, actions |\n| Confirmation | \\`confirmation\\` | title, message, onConfirm, onCancel |\n| Master/detail | \\`master-detail\\` | Split list + detail |\n| Cards grid | \\`entity-cards\\` | columns, itemActions, layout |\n\n### Composition Recipes\n\n**CRUD Browsing INIT** (most common — compose ALL of these in main slot):\n\\`\\`\\`json\n[\"render-ui\", \"main\", { \"type\": \"page-header\", \"title\": \"Tasks\", \"subtitle\": \"Manage your tasks\", \"actions\": [{ \"label\": \"New Task\", \"event\": \"CREATE\", \"variant\": \"primary\" }] }],\n[\"render-ui\", \"main\", { \"type\": \"stats\", \"entity\": \"Task\", \"metrics\": [{ \"label\": \"Total\", \"value\": \"@count\", \"icon\": \"clipboard\" }, { \"label\": \"Active\", \"value\": \"@count:status=active\", \"icon\": \"clock\" }, { \"label\": \"Done\", \"value\": \"@count:status=done\", \"icon\": \"check-circle\" }] }],\n[\"render-ui\", \"main\", { \"type\": \"entity-table\", \"entity\": \"Task\", \"columns\": [\"title\", \"status\", \"createdAt\"], \"searchable\": true, \"itemActions\": [{ \"label\": \"View\", \"event\": \"VIEW\" }, { \"label\": \"Edit\", \"event\": \"EDIT\" }, { \"label\": \"Delete\", \"event\": \"DELETE\" }] }]\n\\`\\`\\`\n\n**Dashboard INIT**:\n\\`\\`\\`\nmain: page-header → title + date range actions\nmain: dashboard-grid → columns: 3\nmain: stats → computed KPIs from entity counts\nmain: chart → primary data visualization\nmain: entity-cards → recent items (limit: 6)\n\\`\\`\\`\n\n**Detail View (drawer)**:\n\\`\\`\\`\ndrawer: entity-detail → all fields + [Edit, Delete] actions\ndrawer: tabs → related collections (if entity has relation fields)\n\\`\\`\\`\n\n**Wizard Flow**:\n\\`\\`\\`\nmain: wizard-progress → steps array + currentStep\nmain: wizard-container → current step content\nmain: wizard-navigation → Back/Next/Submit buttons\n\\`\\`\\`\n\n### Layout Composition (stack, box, grid)\n\nLayout patterns wrap other patterns via \\`children\\` arrays for rich, structured views.\n\n**VStack** (vertical stack): \\`{ \"type\": \"stack\", \"direction\": \"vertical\", ... }\\`\n**HStack** (horizontal stack): \\`{ \"type\": \"stack\", \"direction\": \"horizontal\", ... }\\`\n**Box** (styled container): \\`{ \"type\": \"box\", ... }\\`\n\n#### Stack Props\n| Prop | Values | Default |\n|------|--------|---------|\n| \\`direction\\` | \\`\"vertical\"\\`, \\`\"horizontal\"\\` | \\`\"vertical\"\\` |\n| \\`gap\\` | \\`\"none\"\\`, \\`\"xs\"\\`, \\`\"sm\"\\`, \\`\"md\"\\`, \\`\"lg\"\\`, \\`\"xl\"\\` | \\`\"md\"\\` |\n| \\`align\\` | \\`\"start\"\\`, \\`\"center\"\\`, \\`\"end\"\\`, \\`\"stretch\"\\` | \\`\"stretch\"\\` |\n| \\`justify\\` | \\`\"start\"\\`, \\`\"center\"\\`, \\`\"end\"\\`, \\`\"between\"\\`, \\`\"around\"\\` | \\`\"start\"\\` |\n| \\`wrap\\` | \\`true\\`, \\`false\\` | \\`false\\` |\n\n#### Box Props\n| Prop | Values |\n|------|--------|\n| \\`padding\\` / \\`paddingX\\` / \\`paddingY\\` | \\`\"none\"\\`, \\`\"xs\"\\`, \\`\"sm\"\\`, \\`\"md\"\\`, \\`\"lg\"\\`, \\`\"xl\"\\` |\n| \\`bg\\` | \\`\"default\"\\`, \\`\"muted\"\\`, \\`\"card\"\\`, \\`\"primary\"\\`, \\`\"secondary\"\\`, \\`\"accent\"\\` |\n| \\`border\\` | \\`true\\`, \\`false\\` |\n| \\`rounded\\` | \\`\"none\"\\`, \\`\"sm\"\\`, \\`\"md\"\\`, \\`\"lg\"\\`, \\`\"full\"\\` |\n| \\`shadow\\` | \\`\"none\"\\`, \\`\"sm\"\\`, \\`\"md\"\\`, \\`\"lg\"\\` |\n\n#### Grid Props\n| Prop | Values |\n|------|--------|\n| \\`cols\\` | \\`1\\`–\\`12\\` or \\`{ sm: 1, md: 2, lg: 3 }\\` |\n| \\`gap\\` | \\`\"none\"\\`, \\`\"xs\"\\`, \\`\"sm\"\\`, \\`\"md\"\\`, \\`\"lg\"\\`, \\`\"xl\"\\` |\n\n#### Nesting Example — Page Header + Stats Row + Table\n\\`\\`\\`json\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\": \"Orders\" },\n { \"type\": \"button\", \"label\": \"New Order\", \"event\": \"CREATE\", \"variant\": \"primary\" }\n ]\n },\n { \"type\": \"stack\", \"direction\": \"horizontal\", \"gap\": \"md\", \"wrap\": true,\n \"children\": [\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"stats\", \"metrics\": [{ \"label\": \"Total\", \"value\": \"@count\" }] }]\n },\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"stats\", \"metrics\": [{ \"label\": \"Pending\", \"value\": \"@count:status=pending\" }] }]\n }\n ]\n },\n { \"type\": \"entity-table\", \"entity\": \"Order\", \"columns\": [\"customer\", \"total\", \"status\"], \"searchable\": true }\n ]\n}]\n\\`\\`\\`\n\n#### When to Use Layout Patterns\n- **VStack**: Default page layout — stack header, content sections, tables vertically\n- **HStack**: Side-by-side elements — stat cards, action buttons, header with controls\n- **Box**: Visual grouping — cards, panels, highlighted sections with borders/backgrounds\n- **Grid**: Equal-width columns — dashboard cards, stat grids, gallery layouts\n\n> **Tip**: A single \\`render-ui\\` call with a top-level \\`stack\\` containing nested children produces a more cohesive layout than multiple flat \\`render-ui\\` calls to the same slot.\n\n### Domain-Aware Pattern Selection\n| Domain | List Pattern | Extras |\n|--------|-------------|--------|\n| business/admin | \\`entity-table\\` (searchable) | \\`stats\\`, \\`filter-group\\` |\n| e-commerce | \\`entity-cards\\` | \\`stats\\` (revenue), \\`chart\\` |\n| content/CMS | \\`entity-cards\\` | \\`tabs\\`, \\`media-gallery\\` |\n| dashboard | \\`dashboard-grid\\` | \\`stats\\`, \\`chart\\`, \\`meter\\`, \\`timeline\\` |\n| workflow | \\`entity-table\\` | \\`progress-bar\\`, \\`timeline\\` |\n\n${getPatternPropsCompact()}\n\n${getPatternActionsRef()}\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\": \"entity-detail\",\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\": \"entity-detail\",\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| \\`entity-detail\\` | \\`headerActions: [{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 both \\`schema.json\\` and \\`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 1: Validate and Analyze\n\n\\`\\`\\`\nvalidate_schema()\n\\`\\`\\`\n\nGroup errors by orbital component:\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### Step 2: Apply Batched Fixes\n\nFix ALL errors of the same type in one edit. Priority order:\n\n1. **Entity fixes** (field types, enums, relations)\n2. **State machine fixes** (initial state, orphan states)\n3. **Transition fixes** (missing INIT, unreachable states)\n4. **Pattern fixes** (missing props in render-ui effects)\n\n### Step 3: Re-validate\n\n\\`\\`\\`\nvalidate_schema()\n\\`\\`\\`\n\n**STOP when \"valid\": true** - do not add more tasks or re-verify.`;\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| \\`entity-detail\\` | fieldNames | \\`\"fieldNames\": [\"field1\", \"field2\"]\\` |\n| \\`page-header\\` | actions | \\`\"actions\": [{ \"label\": \"New\", \"event\": \"CREATE\" }]\\` |`;\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: **30-50 tool calls** for most fixes.\n\n**DO:**\n- Batch related changes (read once, edit all, write once)\n- Fix all same-type errors together\n- Run validation once after all changes\n\n**DON'T:**\n- Read schema multiple times without changes\n- Make one small change per tool call\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.json 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 // 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${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**Missing context fields = validation warnings. Missing guards = unenforced business rules!**`;\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\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 and validate:\n\n\\`\\`\\`\nfinish_task({ appName: \"App\" })\n# Reads .orbitals/*.json → schema.json → orbital validate\n\\`\\`\\`\n\n### Phase 4: DESIGN REFINEMENT (optional but recommended)\n\nAfter \\`finish_task\\` produces \\`schema.json\\`, enhance key transitions with \\`design_transition\\`.\n\n**When to use**: INIT transitions (they benefit most from rich composition — header + stats + content), and CREATE/VIEW transitions for polished forms and detail views.\n\n**Step-by-step:**\n\n1. Call \\`design_transition\\` for the transition:\n\\`\\`\\`json\n{\n \"from\": \"Browsing\", \"to\": \"Browsing\", \"event\": \"INIT\",\n \"slot\": \"main\", \"entityName\": \"Task\",\n \"entityFields\": [{\"name\": \"title\", \"type\": \"string\"}, {\"name\": \"status\", \"type\": \"enum\", \"values\": [\"pending\", \"active\", \"done\"]}],\n \"domainCategory\": \"business\"\n}\n\\`\\`\\`\nReturns: \\`{ \"success\": true, \"effects\": [[\"render-ui\", \"main\", {...}], ...] }\\`\n\n2. Extract the orbital chunk:\n\\`\\`\\`json\n{ \"file\": \"schema.json\", \"type\": \"orbital\", \"name\": \"Task Management\" }\n\\`\\`\\`\n\n3. Edit the chunk file: replace render-ui effects in the target transition with the designed effects. **Keep all non-render-ui effects** (persist, emit, set) — only replace the render-ui tuples.\n\n4. Apply the chunk back:\n\\`\\`\\`json\n{ \"chunkId\": \"<id from extract_chunk>\" }\n\\`\\`\\`\n\n**Splicing rule**: For a transition with mixed effects like:\n\\`\\`\\`json\n[[\"persist\", \"create\", \"Task\", \"@payload.data\"], [\"render-ui\", \"modal\", null], [\"emit\", \"INIT\"]]\n\\`\\`\\`\nKeep \\`persist\\` and \\`emit\\`, replace \\`render-ui\\` with the designed effects.\nFor INIT transitions (render-ui only), replace all effects.\n\n**Skip design_transition for**: SAVE, CANCEL, CONFIRM_DELETE transitions (they have persist/emit effects with simple slot-clearing — no UI to design).\n`;\n}\n\n/**\n * Get minimal example section.\n * Enriched INIT transition: page-header + stats + searchable entity-table.\n */\nfunction getMinimalExample(): string {\n return `---\n\n## Example: Task Manager\n\n\\`\\`\\`json\n{\n \"name\": \"Taskly\",\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 \"stateMachine\": {\n \"states\": [\n { \"name\": \"Browsing\", \"isInitial\": true },\n { \"name\": \"Creating\" },\n { \"name\": \"Viewing\" },\n { \"name\": \"Editing\" },\n { \"name\": \"Deleting\" }\n ],\n \"events\": [\"INIT\", \"CREATE\", \"VIEW\", \"EDIT\", \"DELETE\", \"SAVE\", \"CANCEL\", \"CONFIRM_DELETE\"],\n \"transitions\": [\n {\n \"from\": \"Browsing\", \"to\": \"Browsing\", \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", { \"type\": \"page-header\", \"title\": \"Tasks\", \"subtitle\": \"Manage your tasks\", \"actions\": [{ \"label\": \"New Task\", \"event\": \"CREATE\", \"variant\": \"primary\" }] }],\n [\"render-ui\", \"main\", { \"type\": \"stats\", \"entity\": \"Task\", \"metrics\": [{ \"label\": \"Total\", \"value\": \"@count\", \"icon\": \"clipboard\" }, { \"label\": \"Active\", \"value\": \"@count:status=active\", \"icon\": \"clock\" }, { \"label\": \"Done\", \"value\": \"@count:status=done\", \"icon\": \"check-circle\" }] }],\n [\"render-ui\", \"main\", { \"type\": \"entity-table\", \"entity\": \"Task\", \"columns\": [\"title\", \"status\"], \"searchable\": true, \"itemActions\": [{ \"label\": \"View\", \"event\": \"VIEW\" }, { \"label\": \"Edit\", \"event\": \"EDIT\" }, { \"label\": \"Delete\", \"event\": \"DELETE\" }] }]\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\": \"Browsing\", \"to\": \"Viewing\", \"event\": \"VIEW\",\n \"effects\": [[\"render-ui\", \"drawer\", { \"type\": \"entity-detail\", \"entity\": \"Task\", \"actions\": [{ \"label\": \"Edit\", \"event\": \"EDIT\" }, { \"label\": \"Delete\", \"event\": \"DELETE\", \"variant\": \"danger\" }] }]]\n },\n {\n \"from\": \"Browsing\", \"to\": \"Editing\", \"event\": \"EDIT\",\n \"effects\": [[\"render-ui\", \"modal\", { \"type\": \"form-section\", \"entity\": \"Task\", \"fields\": [\"title\", \"status\"], \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }]]\n },\n {\n \"from\": \"Browsing\", \"to\": \"Deleting\", \"event\": \"DELETE\",\n \"effects\": [[\"render-ui\", \"overlay\", { \"type\": \"confirmation\", \"title\": \"Delete Task?\", \"message\": \"This action cannot be undone.\" }]]\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\": \"Viewing\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"drawer\", null]]\n },\n {\n \"from\": \"Editing\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"effects\": [[\"persist\", \"update\", \"Task\", \"@payload.data\"], [\"render-ui\", \"modal\", null], [\"emit\", \"INIT\"]]\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\": [{ \"name\": \"TasksPage\", \"path\": \"/tasks\", \"traits\": [{ \"ref\": \"TaskInteraction\" }] }]\n }]\n}\n\\`\\`\\`\n\n**Key points**:\n- ONE page (TasksPage) not four (list/create/edit/view)\n- INIT transition composes **multiple patterns**: page-header + stats + entity-table\n- States are OBJECTS with \\`isInitial\\` flag\n- **Actions are INSIDE patterns (use unified props)**:\n - \\`page-header\\` has \\`actions: [{label, event, variant}]\\`\n - \\`entity-table\\` has \\`itemActions: [{label, event}]\\` and \\`searchable: true\\`\n - \\`form-section\\` has \\`submitEvent\\` and \\`cancelEvent\\` (NOT onSubmit/onCancel!)\n - \\`entity-detail\\` has \\`actions\\` (NOT headerActions!)\n - \\`confirmation\\` emits action events\n - \\`stats\\` has \\`metrics: [{label, value, icon}]\\`\n- **NEVER use**: \\`onSubmit\\`, \\`onCancel\\`, \\`headerActions\\`, \\`loading\\` (use \\`isLoading\\`)\n- NO separate \"form-actions\" pattern - it doesn't exist!\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 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', 'design_transition', 'finish_task', 'query_schema_structure', 'extract_chunk', 'apply_chunk'],\n version: '4.1.0', // v4.1: design refinement workflow with design_transition\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.json │\n│ │\n│ NEVER use other file names like: │\n│ - schema_with_fixes.json ❌ │\n│ - new_schema.json ❌ │\n│ - updated_schema.json ❌ │\n│ │\n│ The persistence system ONLY reads from schema.json │\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'],\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';\n\n// Inline domain language constants (TODO: move to separate domain-language package)\nconst ODL_SYNTAX_REFERENCE = `\n## Domain Language Syntax\n\nEntity: \\`A [Name] is a [persistent] entity that: - has [field] as [type]\\`\nPage: \\`[PageName] at /[path]: - shows [Entity] using [Behavior]\\`\n`;\n\nconst ODL_EXAMPLES = `\n## Examples\n\n\\`\\`\\`\nA Task is a persistent entity that:\n - has title as text (required)\n - has status as enum [pending, active, done]\n\nTasksPage at /tasks:\n - shows Task using List behavior\n\\`\\`\\`\n`;\n\nconst ODL_PATTERNS = `\n## Patterns\n\nUse patterns like entity-table, form-section in domain language.\n`;\n\nconst ODL_TO_SCHEMA_MAPPING = `\n## Mapping\n\nDomain language converts to OrbitalSchema JSON via compiler.\n`;\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 Syntax Reference\n\n${ODL_SYNTAX_REFERENCE}\n\n## Patterns Reference\n\n${ODL_PATTERNS}\n\n## Full Examples\n\n${ODL_EXAMPLES}\n\n## Mapping to Schema\n\n${ODL_TO_SCHEMA_MAPPING}\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, detail→entity-detail, create/edit→form-section\n`.trim();\n\n return {\n name: 'domain-language',\n frontmatter,\n content,\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 * KFlow Design Skill Generator\n *\n * Generates the kflow-design skill for render-ui authoring.\n * This is a focused ~10K skill that operates at the transition level,\n * producing rich render-ui effects using the full pattern catalog.\n *\n * Unlike kflow-orbitals (which focuses on structure), this skill\n * focuses entirely on UI design decisions: pattern selection,\n * slot composition, layout nesting, and domain-aware styling.\n *\n * @packageDocumentation\n */\n\nimport type { GeneratedSkill } from './types.js';\nimport { getRenderUIDesignGuide } from '../prompts/skill-sections/pattern-design-guide.js';\nimport { getSExprQuickRef } from '../prompts/type-references.js';\nimport {\n getCommonErrorsSection,\n} from '../prompts/skill-sections/common-errors.js';\n\n// ============================================================================\n// Design Skill Content\n// ============================================================================\n\n/**\n * Get the transition context guide.\n * Teaches the LLM how to interpret the transition context it receives.\n */\nfunction getTransitionContextGuide(): string {\n return `## Transition Context\n\nYou receive a single transition to design. Use these inputs to make UI decisions:\n\n### Input Fields\n| Field | What It Tells You |\n|-------|-------------------|\n| \\`from\\` | Current state (e.g., \"Browsing\", \"Creating\") |\n| \\`to\\` | Target state (e.g., \"Browsing\", \"Viewing\") |\n| \\`event\\` | What the user did (e.g., \"INIT\", \"CREATE\", \"VIEW\") |\n| \\`currentSlot\\` | Which slot to render into (\\`main\\`, \\`modal\\`, \\`drawer\\`) |\n| \\`entity\\` | Entity name + fields (drives column/field selection) |\n| \\`designHints\\` | Style + UX hints from decomposition |\n| \\`domainContext\\` | Category + vocabulary (drives pattern choice) |\n| \\`existingEffects\\` | Current render-ui effects (if enhancing) |\n\n### Decision Flow\n\n\\`\\`\\`\n1. What EVENT is this?\n ├─ INIT → Compose full page layout (header + content + data)\n ├─ CREATE/EDIT → Form in modal or drawer\n ├─ VIEW → Detail in drawer or inline\n ├─ DELETE → Confirmation in overlay\n └─ SAVE/CANCEL → Clear slot (return null)\n\n2. What SLOT?\n ├─ main → Compose multiple patterns (stack them)\n ├─ modal → Single form or confirmation\n ├─ drawer → Detail view or quick edit form\n └─ overlay → Confirmation dialog\n\n3. What DOMAIN?\n ├─ business → entity-table + stats + filter-group\n ├─ dashboard → dashboard-grid + chart + stats\n ├─ e-commerce → entity-cards + stats (revenue)\n ├─ content → entity-cards + tabs + media\n └─ workflow → timeline + progress-bar\n\n4. What ENTITY FIELDS suggest?\n ├─ enum fields → filter-group, badge columns\n ├─ date fields → timeline, date columns\n ├─ number fields → stats, chart, meter\n ├─ relation fields → tabs for related collections\n └─ image/url fields → entity-cards (visual)\n\\`\\`\\``;\n}\n\n/**\n * Get layout composition patterns.\n * Detailed guidance on nesting patterns with stack/box/grid.\n */\nfunction getLayoutCompositionGuide(): string {\n return `## Layout Composition\n\nUse layout patterns to create structured, visually rich views.\n\n### Stack (VStack / HStack)\n\\`{ \"type\": \"stack\", \"direction\": \"vertical\"|\"horizontal\", \"gap\": \"sm\"|\"md\"|\"lg\", \"children\": [...] }\\`\n\n### Box (Styled Container)\n\\`{ \"type\": \"box\", \"padding\": \"md\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\", \"children\": [...] }\\`\n\n### Grid (Multi-Column)\n\\`{ \"type\": \"grid\", \"cols\": 3, \"gap\": \"md\", \"children\": [...] }\\`\n\n### Composition Patterns\n\n**Page Layout** — VStack wrapping all content:\n\\`\\`\\`json\n[\"render-ui\", \"main\", {\n \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\",\n \"children\": [\n { \"type\": \"page-header\", \"title\": \"...\", \"actions\": [...] },\n { \"type\": \"stack\", \"direction\": \"horizontal\", \"gap\": \"md\", \"wrap\": true,\n \"children\": [\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"stats\", \"metrics\": [...] }] },\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"stats\", \"metrics\": [...] }] }\n ]\n },\n { \"type\": \"entity-table\", \"entity\": \"...\", \"columns\": [...], \"searchable\": true }\n ]\n}]\n\\`\\`\\`\n\n**Dashboard Layout** — Grid of cards:\n\\`\\`\\`json\n[\"render-ui\", \"main\", {\n \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\",\n \"children\": [\n { \"type\": \"page-header\", \"title\": \"Dashboard\" },\n { \"type\": \"grid\", \"cols\": { \"sm\": 1, \"md\": 2, \"lg\": 3 }, \"gap\": \"md\",\n \"children\": [\n { \"type\": \"box\", \"padding\": \"lg\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"stats\", \"metrics\": [...] }] },\n { \"type\": \"box\", \"padding\": \"lg\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"chart\", \"chartType\": \"line\", \"data\": [...] }] },\n { \"type\": \"box\", \"padding\": \"lg\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"entity-cards\", \"entity\": \"...\", \"columns\": 1 }] }\n ]\n }\n ]\n}]\n\\`\\`\\`\n\n**Detail Drawer** — Stacked sections:\n\\`\\`\\`json\n[\"render-ui\", \"drawer\", {\n \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"md\",\n \"children\": [\n { \"type\": \"entity-detail\", \"entity\": \"...\", \"actions\": [{ \"label\": \"Edit\", \"event\": \"EDIT\" }] },\n { \"type\": \"tabs\", \"tabs\": [\n { \"label\": \"Related Items\", \"content\": { \"type\": \"entity-table\", \"entity\": \"...\" } },\n { \"label\": \"Activity\", \"content\": { \"type\": \"timeline\", \"items\": [...] } }\n ]}\n ]\n}]\n\\`\\`\\`\n\n### When to Use Layout vs Flat\n- **Flat** (multiple render-ui calls): Simple pages, 2-3 patterns stacked vertically\n- **Nested** (single render-ui with layout): Complex pages, side-by-side elements, cards with backgrounds, dashboard grids`;\n}\n\n/**\n * Get the output format specification.\n * Defines what the design tool returns.\n */\nfunction getOutputFormatSection(): string {\n return `## Output Format\n\nReturn ONLY a JSON array of render-ui effect tuples. No explanation, no markdown.\n\n### Simple (multiple flat effects):\n\\`\\`\\`json\n[\n [\"render-ui\", \"main\", { \"type\": \"page-header\", \"title\": \"...\", \"actions\": [...] }],\n [\"render-ui\", \"main\", { \"type\": \"stats\", \"entity\": \"...\", \"metrics\": [...] }],\n [\"render-ui\", \"main\", { \"type\": \"entity-table\", \"entity\": \"...\", \"columns\": [...] }]\n]\n\\`\\`\\`\n\n### Composed (single effect with layout nesting):\n\\`\\`\\`json\n[\n [\"render-ui\", \"main\", { \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\", \"children\": [...] }]\n]\n\\`\\`\\`\n\n### Clear slot:\n\\`\\`\\`json\n[\n [\"render-ui\", \"modal\", null]\n]\n\\`\\`\\`\n\n### Rules\n1. Return valid JSON array — nothing else\n2. Every effect must be \\`[\"render-ui\", slot, config]\\`\n3. Use entity fields from the input for columns, form fields, stats\n4. Match domain vocabulary for labels (e.g., \"Place Order\" not \"Create\")\n5. Include \\`itemActions\\` on tables/cards with appropriate events\n6. Use \\`searchable: true\\` on tables for business domains\n7. For INIT transitions, ALWAYS compose multiple patterns (never just a table)\n8. For CREATE/EDIT, always include \\`submitEvent\\` and \\`cancelEvent\\` on form-section`;\n}\n\n// ============================================================================\n// Main Generator\n// ============================================================================\n\n/**\n * Generate the kflow-design skill.\n *\n * Produces a focused ~10K skill for render-ui authoring.\n * Used by the design_transition tool to produce rich UI effects.\n */\nexport function generateKflowDesignSkill(): GeneratedSkill {\n const frontmatter = {\n name: 'kflow-design',\n description: 'Design rich render-ui effects for orbital schema transitions. Focused on pattern selection, layout composition, and domain-aware UI authoring.',\n allowedTools: ['Read', 'Write', 'Edit'],\n version: '1.0.0',\n };\n\n const content = `# Render-UI Design Skill\n\n> Design rich, polished render-ui effects for orbital schema transitions.\n\nYou are a UI design specialist for KFlow orbital schemas. Your job is to take a\ntransition context (state, event, entity, domain) and produce the best possible\nrender-ui effects using the full pattern catalog.\n\n**Your goal**: Every transition should produce UI that is visually rich, functionally\ncomplete, and domain-appropriate. Never default to just \"entity-table\" — compose\nlayouts with headers, stats, filters, and appropriate patterns.\n\n---\n\n${getTransitionContextGuide()}\n\n---\n\n${getRenderUIDesignGuide()}\n\n---\n\n${getLayoutCompositionGuide()}\n\n---\n\n${getSExprQuickRef()}\n\n---\n\n${getCommonErrorsSection('top6')}\n\n---\n\n${getOutputFormatSection()}\n`;\n\n return {\n name: 'kflow-design',\n frontmatter,\n content,\n };\n}\n\n/**\n * Get design skill metadata.\n */\nexport function getDesignSkillMetadata() {\n return {\n name: 'kflow-design',\n description: 'Design rich render-ui effects for orbital schema transitions',\n version: '1.0.0',\n };\n}\n\n/**\n * Get design skill stats for comparison.\n */\nexport function getDesignSkillStats(): { lines: number; chars: number } {\n const skill = generateKflowDesignSkill();\n return {\n lines: skill.content.split('\\n').length,\n chars: skill.content.length,\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\", \"entity-detail\"]\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\": \"entity-detail\", \"entity\": \"Task\", \"fieldNames\": [\"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 6 core skills used by the builder client:\n * 1. kflow-orbitals (standard JSON generation)\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 * 6. kflow-design (render-ui design for transitions)\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// Design skill (render-ui authoring for transitions)\nexport { generateKflowDesignSkill, getDesignSkillStats } from './kflow-design.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 { generateKflowDesignSkill } from './kflow-design.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 6 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 generateKflowDesignSkill(),\n ];\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\\`\\`\\`json\n{\n \"name\": \"EntityName\",\n \"entity\": { ... },\n \"traits\": [ ... ],\n \"pages\": [ ... ]\n}\n\\`\\`\\`\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"]}
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/pattern-design-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/prompts/type-references.ts","../src/generators/kflow-design.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/generation-prompts.ts","../src/prompts/behaviors-reference.ts"],"names":["PATTERN_TYPES","getPatternActionsRef","getPatternPropsCompact","getSExprQuickRef","getRenderUIQuickRef","ODL_SYNTAX_REFERENCE","ODL_PATTERNS","ODL_TO_SCHEMA_MAPPING","generateLeanOrbitalSkill","LEAN_CORE_INSTRUCTIONS","LEAN_ERROR_HANDLING","LEAN_VALIDATION_RULES","LEAN_EFFECT_GUARD_SYNTAX","generateLeanFixingSkill","getKeyBehaviorsReference","generateBehaviorsDocs"],"mappings":";;;;;;;AAeO,SAAS,kBAAkB,EAAA,EAA8B;AAC9D,EAAA,MAAM,KAAA,GAAQ,CAAC,KAAK,CAAA;AACpB,EAAA,KAAA,CAAM,IAAA,CAAK,CAAA,MAAA,EAAS,EAAA,CAAG,IAAI,CAAA,CAAE,CAAA;AAC7B,EAAA,KAAA,CAAM,IAAA,CAAK,CAAA,aAAA,EAAgB,EAAA,CAAG,WAAW,CAAA,CAAE,CAAA;AAC3C,EAAA,IAAI,EAAA,CAAG,cAAc,MAAA,EAAQ;AAC3B,IAAA,KAAA,CAAM,KAAK,CAAA,eAAA,EAAkB,EAAA,CAAG,aAAa,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AAAA,EAC3D;AACA,EAAA,IAAI,GAAG,OAAA,EAAS;AACd,IAAA,KAAA,CAAM,IAAA,CAAK,CAA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O,CAAA,CAAE,WAAW,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC;AAAA,CACvE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC;;AAAA;AAAA,CAAA;AAIb","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 onSubmit** | Connects form to trait events |\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 → entity-detail (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.\n\n\\`\\`\\`json\n{\n \"from\": \"Browsing\",\n \"to\": \"Browsing\",\n \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", { \"type\": \"page-header\", ... }],\n [\"render-ui\", \"main\", { \"type\": \"entity-table\", ... }]\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 State Machine Pattern\n\nWhen a transition opens a modal/drawer, the target state MUST have CLOSE and CANCEL transitions:\n\n\\`\\`\\`json\n{ \"from\": \"Browsing\", \"to\": \"Creating\", \"event\": \"CREATE\",\n \"effects\": [[\"render-ui\", \"modal\", { \"type\": \"form-section\", \"cancelEvent\": \"CANCEL\", ... }]] },\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"modal\", null]] },\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"CLOSE\",\n \"effects\": [[\"render-ui\", \"modal\", null]] },\n{ \"from\": \"Creating\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"effects\": [[\"persist\", \"create\", \"Entity\", \"@payload.data\"], [\"render-ui\", \"modal\", null], [\"emit\", \"INIT\"]] }\n\\`\\`\\`\n\n**CLOSE** = user clicks outside modal/presses Escape. **CANCEL** = form cancel button. Both needed.\n`;\n}\n\n/**\n * Edge case errors 7-16 — 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 onSubmit in form-section\n\\`\\`\\`\nWRONG: { \"type\": \"form-section\", \"entity\": \"Task\" }\nCORRECT: { \"type\": \"form-section\", \"entity\": \"Task\", \"onSubmit\": \"SAVE\" }\n\\`\\`\\`\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 onSubmit/onCancel 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 onSubmit event name 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** - do NOT split CRUD operations into separate orbitals\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\n- Business: EntityManagement (handles CRUD via render-ui)\n- Game: Physics2D, Health, Score, Collision\n- Form: Wizard (multi-step) or FormSubmission (single)\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\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\n- Business: EntityManagement (handles CRUD via render-ui)\n- Game: Physics2D, Health, Score, Collision\n- Form: Wizard (multi-step) or FormSubmission (single)\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 * Pattern Design Guide Section\n *\n * Replaces the 380-char getRenderUIQuickRef() with actionable guidance\n * on pattern selection, composition recipes, and slot strategy.\n *\n * Target: ~2,500 chars — focused entirely on helping the LLM produce\n * rich, varied render-ui effects instead of defaulting to entity-table.\n *\n * @packageDocumentation\n */\n\nimport {\n getPatternPropsCompact,\n getPatternActionsRef,\n} from \"@almadar/patterns\";\n\n/**\n * Get the render-ui design guide.\n * Covers syntax, slot strategy, pattern-by-intent, and composition recipes.\n */\nexport function getRenderUIDesignGuide(): string {\n return `## Render-UI Design Guide\n\n### Syntax\n\\`[\"render-ui\", slot, { \"type\": pattern, ...props }]\\`\nClear slot: \\`[\"render-ui\", \"modal\", null]\\`\n\n### Slot Strategy\n| Slot | Use For | Composable? |\n|------|---------|-------------|\n| \\`main\\` | Primary content | **YES** — stack multiple render-ui calls |\n| \\`modal\\` | Forms (create/edit), confirmations | One at a time |\n| \\`drawer\\` | Detail views, quick edits | One at a time |\n| \\`sidebar\\` | Navigation, persistent filters | One at a time |\n| \\`overlay\\` | Confirmations, alerts | One at a time |\n\n### Pattern Selection by Intent\n| Intent | Patterns | Key Props |\n|--------|----------|-----------|\n| List/browse data | \\`entity-table\\`, \\`entity-cards\\`, \\`entity-list\\` | columns, itemActions, searchable |\n| Show metrics/KPIs | \\`stats\\` | metrics: [{label, value, icon, trend}] |\n| Filter/search | \\`filter-group\\`, \\`search-input\\` | filters (from entity enum fields) |\n| Create/edit form | \\`form-section\\` | fields, submitEvent, cancelEvent |\n| View details | \\`entity-detail\\`, \\`detail-panel\\` | fields/fieldNames, actions |\n| Organize content | \\`tabs\\` | tabs: [{label, content}] |\n| Dashboard layout | \\`dashboard-grid\\` | columns (number) |\n| Charts | \\`chart\\` | chartType, data, xAxis, yAxis |\n| Progress | \\`progress-bar\\`, \\`meter\\` | value, max, label |\n| Timeline | \\`timeline\\` | items: [{date, title, description}] |\n| Page heading | \\`page-header\\` | title, subtitle, actions |\n| Confirmation | \\`confirmation\\` | title, message, onConfirm, onCancel |\n| Master/detail | \\`master-detail\\` | Split list + detail |\n| Cards grid | \\`entity-cards\\` | columns, itemActions, layout |\n\n### Composition Recipes\n\n**CRUD Browsing INIT** (most common — compose ALL of these in main slot):\n\\`\\`\\`json\n[\"render-ui\", \"main\", { \"type\": \"page-header\", \"title\": \"Tasks\", \"subtitle\": \"Manage your tasks\", \"actions\": [{ \"label\": \"New Task\", \"event\": \"CREATE\", \"variant\": \"primary\" }] }],\n[\"render-ui\", \"main\", { \"type\": \"stats\", \"entity\": \"Task\", \"metrics\": [{ \"label\": \"Total\", \"value\": \"@count\", \"icon\": \"clipboard\" }, { \"label\": \"Active\", \"value\": \"@count:status=active\", \"icon\": \"clock\" }, { \"label\": \"Done\", \"value\": \"@count:status=done\", \"icon\": \"check-circle\" }] }],\n[\"render-ui\", \"main\", { \"type\": \"entity-table\", \"entity\": \"Task\", \"columns\": [\"title\", \"status\", \"createdAt\"], \"searchable\": true, \"itemActions\": [{ \"label\": \"View\", \"event\": \"VIEW\" }, { \"label\": \"Edit\", \"event\": \"EDIT\" }, { \"label\": \"Delete\", \"event\": \"DELETE\" }] }]\n\\`\\`\\`\n\n**Dashboard INIT**:\n\\`\\`\\`\nmain: page-header → title + date range actions\nmain: dashboard-grid → columns: 3\nmain: stats → computed KPIs from entity counts\nmain: chart → primary data visualization\nmain: entity-cards → recent items (limit: 6)\n\\`\\`\\`\n\n**Detail View (drawer)**:\n\\`\\`\\`\ndrawer: entity-detail → all fields + [Edit, Delete] actions\ndrawer: tabs → related collections (if entity has relation fields)\n\\`\\`\\`\n\n**Wizard Flow**:\n\\`\\`\\`\nmain: wizard-progress → steps array + currentStep\nmain: wizard-container → current step content\nmain: wizard-navigation → Back/Next/Submit buttons\n\\`\\`\\`\n\n### Layout Composition (stack, box, grid)\n\nLayout patterns wrap other patterns via \\`children\\` arrays for rich, structured views.\n\n**VStack** (vertical stack): \\`{ \"type\": \"stack\", \"direction\": \"vertical\", ... }\\`\n**HStack** (horizontal stack): \\`{ \"type\": \"stack\", \"direction\": \"horizontal\", ... }\\`\n**Box** (styled container): \\`{ \"type\": \"box\", ... }\\`\n\n#### Stack Props\n| Prop | Values | Default |\n|------|--------|---------|\n| \\`direction\\` | \\`\"vertical\"\\`, \\`\"horizontal\"\\` | \\`\"vertical\"\\` |\n| \\`gap\\` | \\`\"none\"\\`, \\`\"xs\"\\`, \\`\"sm\"\\`, \\`\"md\"\\`, \\`\"lg\"\\`, \\`\"xl\"\\` | \\`\"md\"\\` |\n| \\`align\\` | \\`\"start\"\\`, \\`\"center\"\\`, \\`\"end\"\\`, \\`\"stretch\"\\` | \\`\"stretch\"\\` |\n| \\`justify\\` | \\`\"start\"\\`, \\`\"center\"\\`, \\`\"end\"\\`, \\`\"between\"\\`, \\`\"around\"\\` | \\`\"start\"\\` |\n| \\`wrap\\` | \\`true\\`, \\`false\\` | \\`false\\` |\n\n#### Box Props\n| Prop | Values |\n|------|--------|\n| \\`padding\\` / \\`paddingX\\` / \\`paddingY\\` | \\`\"none\"\\`, \\`\"xs\"\\`, \\`\"sm\"\\`, \\`\"md\"\\`, \\`\"lg\"\\`, \\`\"xl\"\\` |\n| \\`bg\\` | \\`\"default\"\\`, \\`\"muted\"\\`, \\`\"card\"\\`, \\`\"primary\"\\`, \\`\"secondary\"\\`, \\`\"accent\"\\` |\n| \\`border\\` | \\`true\\`, \\`false\\` |\n| \\`rounded\\` | \\`\"none\"\\`, \\`\"sm\"\\`, \\`\"md\"\\`, \\`\"lg\"\\`, \\`\"full\"\\` |\n| \\`shadow\\` | \\`\"none\"\\`, \\`\"sm\"\\`, \\`\"md\"\\`, \\`\"lg\"\\` |\n\n#### Grid Props\n| Prop | Values |\n|------|--------|\n| \\`cols\\` | \\`1\\`–\\`12\\` or \\`{ sm: 1, md: 2, lg: 3 }\\` |\n| \\`gap\\` | \\`\"none\"\\`, \\`\"xs\"\\`, \\`\"sm\"\\`, \\`\"md\"\\`, \\`\"lg\"\\`, \\`\"xl\"\\` |\n\n#### Nesting Example — Page Header + Stats Row + Table\n\\`\\`\\`json\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\": \"Orders\" },\n { \"type\": \"button\", \"label\": \"New Order\", \"event\": \"CREATE\", \"variant\": \"primary\" }\n ]\n },\n { \"type\": \"stack\", \"direction\": \"horizontal\", \"gap\": \"md\", \"wrap\": true,\n \"children\": [\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"stats\", \"metrics\": [{ \"label\": \"Total\", \"value\": \"@count\" }] }]\n },\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"stats\", \"metrics\": [{ \"label\": \"Pending\", \"value\": \"@count:status=pending\" }] }]\n }\n ]\n },\n { \"type\": \"entity-table\", \"entity\": \"Order\", \"columns\": [\"customer\", \"total\", \"status\"], \"searchable\": true }\n ]\n}]\n\\`\\`\\`\n\n#### When to Use Layout Patterns\n- **VStack**: Default page layout — stack header, content sections, tables vertically\n- **HStack**: Side-by-side elements — stat cards, action buttons, header with controls\n- **Box**: Visual grouping — cards, panels, highlighted sections with borders/backgrounds\n- **Grid**: Equal-width columns — dashboard cards, stat grids, gallery layouts\n\n> **Tip**: A single \\`render-ui\\` call with a top-level \\`stack\\` containing nested children produces a more cohesive layout than multiple flat \\`render-ui\\` calls to the same slot.\n\n### Domain-Aware Pattern Selection\n| Domain | List Pattern | Extras |\n|--------|-------------|--------|\n| business/admin | \\`entity-table\\` (searchable) | \\`stats\\`, \\`filter-group\\` |\n| ecommerce | \\`entity-cards\\` | \\`stats\\` (revenue), \\`chart\\` |\n| content/CMS | \\`entity-cards\\` | \\`tabs\\`, \\`media-gallery\\` |\n| dashboard | \\`dashboard-grid\\` | \\`stats\\`, \\`chart\\`, \\`meter\\`, \\`timeline\\` |\n| workflow | \\`entity-table\\` | \\`progress-bar\\`, \\`timeline\\` |\n\n${getPatternPropsCompact()}\n\n${getPatternActionsRef()}\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\": \"entity-detail\",\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\": \"entity-detail\",\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| \\`entity-detail\\` | \\`headerActions: [{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 both \\`schema.json\\` and \\`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 1: Validate and Analyze\n\n\\`\\`\\`\nvalidate_schema()\n\\`\\`\\`\n\nGroup errors by orbital component:\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### Step 2: Apply Batched Fixes\n\nFix ALL errors of the same type in one edit. Priority order:\n\n1. **Entity fixes** (field types, enums, relations)\n2. **State machine fixes** (initial state, orphan states)\n3. **Transition fixes** (missing INIT, unreachable states)\n4. **Pattern fixes** (missing props in render-ui effects)\n\n### Step 3: Re-validate\n\n\\`\\`\\`\nvalidate_schema()\n\\`\\`\\`\n\n**STOP when \"valid\": true** - do not add more tasks or re-verify.`;\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| \\`entity-detail\\` | fieldNames | \\`\"fieldNames\": [\"field1\", \"field2\"]\\` |\n| \\`page-header\\` | actions | \\`\"actions\": [{ \"label\": \"New\", \"event\": \"CREATE\" }]\\` |`;\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: **30-50 tool calls** for most fixes.\n\n**DO:**\n- Batch related changes (read once, edit all, write once)\n- Fix all same-type errors together\n- Run validation once after all changes\n\n**DON'T:**\n- Read schema multiple times without changes\n- Make one small change per tool call\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.json 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 // 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${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**Missing context fields = validation warnings. Missing guards = unenforced business rules!**`;\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\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 and validate:\n\n\\`\\`\\`\nfinish_task({ appName: \"App\" })\n# Reads .orbitals/*.json → schema.json → orbital validate\n\\`\\`\\`\n\n### Phase 4: DESIGN REFINEMENT (optional but recommended)\n\nAfter \\`finish_task\\` produces \\`schema.json\\`, enhance key transitions with \\`design_transition\\`.\n\n**When to use**: INIT transitions (they benefit most from rich composition — header + stats + content), and CREATE/VIEW transitions for polished forms and detail views.\n\n**Step-by-step:**\n\n1. Call \\`design_transition\\` for the transition:\n\\`\\`\\`json\n{\n \"from\": \"Browsing\", \"to\": \"Browsing\", \"event\": \"INIT\",\n \"slot\": \"main\", \"entityName\": \"Task\",\n \"entityFields\": [{\"name\": \"title\", \"type\": \"string\"}, {\"name\": \"status\", \"type\": \"enum\", \"values\": [\"pending\", \"active\", \"done\"]}],\n \"domainCategory\": \"business\"\n}\n\\`\\`\\`\nReturns: \\`{ \"success\": true, \"effects\": [[\"render-ui\", \"main\", {...}], ...] }\\`\n\n2. Extract the orbital chunk:\n\\`\\`\\`json\n{ \"file\": \"schema.json\", \"type\": \"orbital\", \"name\": \"Task Management\" }\n\\`\\`\\`\n\n3. Edit the chunk file: replace render-ui effects in the target transition with the designed effects. **Keep all non-render-ui effects** (persist, emit, set) — only replace the render-ui tuples.\n\n4. Apply the chunk back:\n\\`\\`\\`json\n{ \"chunkId\": \"<id from extract_chunk>\" }\n\\`\\`\\`\n\n**Splicing rule**: For a transition with mixed effects like:\n\\`\\`\\`json\n[[\"persist\", \"create\", \"Task\", \"@payload.data\"], [\"render-ui\", \"modal\", null], [\"emit\", \"INIT\"]]\n\\`\\`\\`\nKeep \\`persist\\` and \\`emit\\`, replace \\`render-ui\\` with the designed effects.\nFor INIT transitions (render-ui only), replace all effects.\n\n**Skip design_transition for**: SAVE, CANCEL, CONFIRM_DELETE transitions (they have persist/emit effects with simple slot-clearing — no UI to design).\n`;\n}\n\n/**\n * Get minimal example section.\n * Enriched INIT transition: page-header + stats + searchable entity-table.\n */\nfunction getMinimalExample(): string {\n return `---\n\n## Example: Task Manager\n\n\\`\\`\\`json\n{\n \"name\": \"Taskly\",\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 \"stateMachine\": {\n \"states\": [\n { \"name\": \"Browsing\", \"isInitial\": true },\n { \"name\": \"Creating\" },\n { \"name\": \"Viewing\" },\n { \"name\": \"Editing\" },\n { \"name\": \"Deleting\" }\n ],\n \"events\": [\"INIT\", \"CREATE\", \"VIEW\", \"EDIT\", \"DELETE\", \"SAVE\", \"CANCEL\", \"CONFIRM_DELETE\"],\n \"transitions\": [\n {\n \"from\": \"Browsing\", \"to\": \"Browsing\", \"event\": \"INIT\",\n \"effects\": [\n [\"render-ui\", \"main\", { \"type\": \"page-header\", \"title\": \"Tasks\", \"subtitle\": \"Manage your tasks\", \"actions\": [{ \"label\": \"New Task\", \"event\": \"CREATE\", \"variant\": \"primary\" }] }],\n [\"render-ui\", \"main\", { \"type\": \"stats\", \"entity\": \"Task\", \"metrics\": [{ \"label\": \"Total\", \"value\": \"@count\", \"icon\": \"clipboard\" }, { \"label\": \"Active\", \"value\": \"@count:status=active\", \"icon\": \"clock\" }, { \"label\": \"Done\", \"value\": \"@count:status=done\", \"icon\": \"check-circle\" }] }],\n [\"render-ui\", \"main\", { \"type\": \"entity-table\", \"entity\": \"Task\", \"columns\": [\"title\", \"status\"], \"searchable\": true, \"itemActions\": [{ \"label\": \"View\", \"event\": \"VIEW\" }, { \"label\": \"Edit\", \"event\": \"EDIT\" }, { \"label\": \"Delete\", \"event\": \"DELETE\" }] }]\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\": \"Browsing\", \"to\": \"Viewing\", \"event\": \"VIEW\",\n \"effects\": [[\"render-ui\", \"drawer\", { \"type\": \"entity-detail\", \"entity\": \"Task\", \"actions\": [{ \"label\": \"Edit\", \"event\": \"EDIT\" }, { \"label\": \"Delete\", \"event\": \"DELETE\", \"variant\": \"danger\" }] }]]\n },\n {\n \"from\": \"Browsing\", \"to\": \"Editing\", \"event\": \"EDIT\",\n \"effects\": [[\"render-ui\", \"modal\", { \"type\": \"form-section\", \"entity\": \"Task\", \"fields\": [\"title\", \"status\"], \"submitEvent\": \"SAVE\", \"cancelEvent\": \"CANCEL\" }]]\n },\n {\n \"from\": \"Browsing\", \"to\": \"Deleting\", \"event\": \"DELETE\",\n \"effects\": [[\"render-ui\", \"overlay\", { \"type\": \"confirmation\", \"title\": \"Delete Task?\", \"message\": \"This action cannot be undone.\" }]]\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\": \"Viewing\", \"to\": \"Browsing\", \"event\": \"CANCEL\",\n \"effects\": [[\"render-ui\", \"drawer\", null]]\n },\n {\n \"from\": \"Editing\", \"to\": \"Browsing\", \"event\": \"SAVE\",\n \"effects\": [[\"persist\", \"update\", \"Task\", \"@payload.data\"], [\"render-ui\", \"modal\", null], [\"emit\", \"INIT\"]]\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\": [{ \"name\": \"TasksPage\", \"path\": \"/tasks\", \"traits\": [{ \"ref\": \"TaskInteraction\" }] }]\n }]\n}\n\\`\\`\\`\n\n**Key points**:\n- ONE page (TasksPage) not four (list/create/edit/view)\n- INIT transition composes **multiple patterns**: page-header + stats + entity-table\n- States are OBJECTS with \\`isInitial\\` flag\n- **Actions are INSIDE patterns (use unified props)**:\n - \\`page-header\\` has \\`actions: [{label, event, variant}]\\`\n - \\`entity-table\\` has \\`itemActions: [{label, event}]\\` and \\`searchable: true\\`\n - \\`form-section\\` has \\`submitEvent\\` and \\`cancelEvent\\` (NOT onSubmit/onCancel!)\n - \\`entity-detail\\` has \\`actions\\` (NOT headerActions!)\n - \\`confirmation\\` emits action events\n - \\`stats\\` has \\`metrics: [{label, value, icon}]\\`\n- **NEVER use**: \\`onSubmit\\`, \\`onCancel\\`, \\`headerActions\\`, \\`loading\\` (use \\`isLoading\\`)\n- NO separate \"form-actions\" pattern - it doesn't exist!\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 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', 'design_transition', 'finish_task', 'query_schema_structure', 'extract_chunk', 'apply_chunk'],\n version: '4.1.0', // v4.1: design refinement workflow with design_transition\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.json │\n│ │\n│ NEVER use other file names like: │\n│ - schema_with_fixes.json ❌ │\n│ - new_schema.json ❌ │\n│ - updated_schema.json ❌ │\n│ │\n│ The persistence system ONLY reads from schema.json │\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'],\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';\n\n// Inline domain language constants (TODO: move to separate domain-language package)\nconst ODL_SYNTAX_REFERENCE = `\n## Domain Language Syntax\n\nEntity: \\`A [Name] is a [persistent] entity that: - has [field] as [type]\\`\nPage: \\`[PageName] at /[path]: - shows [Entity] using [Behavior]\\`\n`;\n\nconst ODL_EXAMPLES = `\n## Examples\n\n\\`\\`\\`\nA Task is a persistent entity that:\n - has title as text (required)\n - has status as enum [pending, active, done]\n\nTasksPage at /tasks:\n - shows Task using List behavior\n\\`\\`\\`\n`;\n\nconst ODL_PATTERNS = `\n## Patterns\n\nUse patterns like entity-table, form-section in domain language.\n`;\n\nconst ODL_TO_SCHEMA_MAPPING = `\n## Mapping\n\nDomain language converts to OrbitalSchema JSON via compiler.\n`;\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 Syntax Reference\n\n${ODL_SYNTAX_REFERENCE}\n\n## Patterns Reference\n\n${ODL_PATTERNS}\n\n## Full Examples\n\n${ODL_EXAMPLES}\n\n## Mapping to Schema\n\n${ODL_TO_SCHEMA_MAPPING}\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, detail→entity-detail, create/edit→form-section\n`.trim();\n\n return {\n name: 'domain-language',\n frontmatter,\n content,\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 * KFlow Design Skill Generator\n *\n * Generates the kflow-design skill for render-ui authoring.\n * This is a focused ~10K skill that operates at the transition level,\n * producing rich render-ui effects using the full pattern catalog.\n *\n * Unlike kflow-orbitals (which focuses on structure), this skill\n * focuses entirely on UI design decisions: pattern selection,\n * slot composition, layout nesting, and domain-aware styling.\n *\n * @packageDocumentation\n */\n\nimport type { GeneratedSkill } from './types.js';\nimport { getRenderUIDesignGuide } from '../prompts/skill-sections/pattern-design-guide.js';\nimport { getSExprQuickRef } from '../prompts/type-references.js';\nimport {\n getCommonErrorsSection,\n} from '../prompts/skill-sections/common-errors.js';\n\n// ============================================================================\n// Design Skill Content\n// ============================================================================\n\n/**\n * Get the transition context guide.\n * Teaches the LLM how to interpret the transition context it receives.\n */\nfunction getTransitionContextGuide(): string {\n return `## Transition Context\n\nYou receive a single transition to design. Use these inputs to make UI decisions:\n\n### Input Fields\n| Field | What It Tells You |\n|-------|-------------------|\n| \\`from\\` | Current state (e.g., \"Browsing\", \"Creating\") |\n| \\`to\\` | Target state (e.g., \"Browsing\", \"Viewing\") |\n| \\`event\\` | What the user did (e.g., \"INIT\", \"CREATE\", \"VIEW\") |\n| \\`currentSlot\\` | Which slot to render into (\\`main\\`, \\`modal\\`, \\`drawer\\`) |\n| \\`entity\\` | Entity name + fields (drives column/field selection) |\n| \\`designHints\\` | Style + UX hints from decomposition |\n| \\`domainContext\\` | Category + vocabulary (drives pattern choice) |\n| \\`existingEffects\\` | Current render-ui effects (if enhancing) |\n\n### Decision Flow\n\n\\`\\`\\`\n1. What EVENT is this?\n ├─ INIT → Compose full page layout (header + content + data)\n ├─ CREATE/EDIT → Form in modal or drawer\n ├─ VIEW → Detail in drawer or inline\n ├─ DELETE → Confirmation in overlay\n └─ SAVE/CANCEL → Clear slot (return null)\n\n2. What SLOT?\n ├─ main → Compose multiple patterns (stack them)\n ├─ modal → Single form or confirmation\n ├─ drawer → Detail view or quick edit form\n └─ overlay → Confirmation dialog\n\n3. What DOMAIN?\n ├─ business → entity-table + stats + filter-group\n ├─ dashboard → dashboard-grid + chart + stats\n ├─ ecommerce → entity-cards + stats (revenue)\n ├─ content → entity-cards + tabs + media\n └─ workflow → timeline + progress-bar\n\n4. What ENTITY FIELDS suggest?\n ├─ enum fields → filter-group, badge columns\n ├─ date fields → timeline, date columns\n ├─ number fields → stats, chart, meter\n ├─ relation fields → tabs for related collections\n └─ image/url fields → entity-cards (visual)\n\\`\\`\\``;\n}\n\n/**\n * Get layout composition patterns.\n * Detailed guidance on nesting patterns with stack/box/grid.\n */\nfunction getLayoutCompositionGuide(): string {\n return `## Layout Composition\n\nUse layout patterns to create structured, visually rich views.\n\n### Stack (VStack / HStack)\n\\`{ \"type\": \"stack\", \"direction\": \"vertical\"|\"horizontal\", \"gap\": \"sm\"|\"md\"|\"lg\", \"children\": [...] }\\`\n\n### Box (Styled Container)\n\\`{ \"type\": \"box\", \"padding\": \"md\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\", \"children\": [...] }\\`\n\n### Grid (Multi-Column)\n\\`{ \"type\": \"grid\", \"cols\": 3, \"gap\": \"md\", \"children\": [...] }\\`\n\n### Composition Patterns\n\n**Page Layout** — VStack wrapping all content:\n\\`\\`\\`json\n[\"render-ui\", \"main\", {\n \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\",\n \"children\": [\n { \"type\": \"page-header\", \"title\": \"...\", \"actions\": [...] },\n { \"type\": \"stack\", \"direction\": \"horizontal\", \"gap\": \"md\", \"wrap\": true,\n \"children\": [\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"stats\", \"metrics\": [...] }] },\n { \"type\": \"box\", \"padding\": \"md\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"stats\", \"metrics\": [...] }] }\n ]\n },\n { \"type\": \"entity-table\", \"entity\": \"...\", \"columns\": [...], \"searchable\": true }\n ]\n}]\n\\`\\`\\`\n\n**Dashboard Layout** — Grid of cards:\n\\`\\`\\`json\n[\"render-ui\", \"main\", {\n \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\",\n \"children\": [\n { \"type\": \"page-header\", \"title\": \"Dashboard\" },\n { \"type\": \"grid\", \"cols\": { \"sm\": 1, \"md\": 2, \"lg\": 3 }, \"gap\": \"md\",\n \"children\": [\n { \"type\": \"box\", \"padding\": \"lg\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"stats\", \"metrics\": [...] }] },\n { \"type\": \"box\", \"padding\": \"lg\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"chart\", \"chartType\": \"line\", \"data\": [...] }] },\n { \"type\": \"box\", \"padding\": \"lg\", \"bg\": \"card\", \"border\": true, \"rounded\": \"md\",\n \"children\": [{ \"type\": \"entity-cards\", \"entity\": \"...\", \"columns\": 1 }] }\n ]\n }\n ]\n}]\n\\`\\`\\`\n\n**Detail Drawer** — Stacked sections:\n\\`\\`\\`json\n[\"render-ui\", \"drawer\", {\n \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"md\",\n \"children\": [\n { \"type\": \"entity-detail\", \"entity\": \"...\", \"actions\": [{ \"label\": \"Edit\", \"event\": \"EDIT\" }] },\n { \"type\": \"tabs\", \"tabs\": [\n { \"label\": \"Related Items\", \"content\": { \"type\": \"entity-table\", \"entity\": \"...\" } },\n { \"label\": \"Activity\", \"content\": { \"type\": \"timeline\", \"items\": [...] } }\n ]}\n ]\n}]\n\\`\\`\\`\n\n### When to Use Layout vs Flat\n- **Flat** (multiple render-ui calls): Simple pages, 2-3 patterns stacked vertically\n- **Nested** (single render-ui with layout): Complex pages, side-by-side elements, cards with backgrounds, dashboard grids`;\n}\n\n/**\n * Get the output format specification.\n * Defines what the design tool returns.\n */\nfunction getOutputFormatSection(): string {\n return `## Output Format\n\nReturn ONLY a JSON array of render-ui effect tuples. No explanation, no markdown.\n\n### Simple (multiple flat effects):\n\\`\\`\\`json\n[\n [\"render-ui\", \"main\", { \"type\": \"page-header\", \"title\": \"...\", \"actions\": [...] }],\n [\"render-ui\", \"main\", { \"type\": \"stats\", \"entity\": \"...\", \"metrics\": [...] }],\n [\"render-ui\", \"main\", { \"type\": \"entity-table\", \"entity\": \"...\", \"columns\": [...] }]\n]\n\\`\\`\\`\n\n### Composed (single effect with layout nesting):\n\\`\\`\\`json\n[\n [\"render-ui\", \"main\", { \"type\": \"stack\", \"direction\": \"vertical\", \"gap\": \"lg\", \"children\": [...] }]\n]\n\\`\\`\\`\n\n### Clear slot:\n\\`\\`\\`json\n[\n [\"render-ui\", \"modal\", null]\n]\n\\`\\`\\`\n\n### Rules\n1. Return valid JSON array — nothing else\n2. Every effect must be \\`[\"render-ui\", slot, config]\\`\n3. Use entity fields from the input for columns, form fields, stats\n4. Match domain vocabulary for labels (e.g., \"Place Order\" not \"Create\")\n5. Include \\`itemActions\\` on tables/cards with appropriate events\n6. Use \\`searchable: true\\` on tables for business domains\n7. For INIT transitions, ALWAYS compose multiple patterns (never just a table)\n8. For CREATE/EDIT, always include \\`submitEvent\\` and \\`cancelEvent\\` on form-section`;\n}\n\n// ============================================================================\n// Main Generator\n// ============================================================================\n\n/**\n * Generate the kflow-design skill.\n *\n * Produces a focused ~10K skill for render-ui authoring.\n * Used by the design_transition tool to produce rich UI effects.\n */\nexport function generateKflowDesignSkill(): GeneratedSkill {\n const frontmatter = {\n name: 'kflow-design',\n description: 'Design rich render-ui effects for orbital schema transitions. Focused on pattern selection, layout composition, and domain-aware UI authoring.',\n allowedTools: ['Read', 'Write', 'Edit'],\n version: '1.0.0',\n };\n\n const content = `# Render-UI Design Skill\n\n> Design rich, polished render-ui effects for orbital schema transitions.\n\nYou are a UI design specialist for KFlow orbital schemas. Your job is to take a\ntransition context (state, event, entity, domain) and produce the best possible\nrender-ui effects using the full pattern catalog.\n\n**Your goal**: Every transition should produce UI that is visually rich, functionally\ncomplete, and domain-appropriate. Never default to just \"entity-table\" — compose\nlayouts with headers, stats, filters, and appropriate patterns.\n\n---\n\n${getTransitionContextGuide()}\n\n---\n\n${getRenderUIDesignGuide()}\n\n---\n\n${getLayoutCompositionGuide()}\n\n---\n\n${getSExprQuickRef()}\n\n---\n\n${getCommonErrorsSection('top6')}\n\n---\n\n${getOutputFormatSection()}\n`;\n\n return {\n name: 'kflow-design',\n frontmatter,\n content,\n };\n}\n\n/**\n * Get design skill metadata.\n */\nexport function getDesignSkillMetadata() {\n return {\n name: 'kflow-design',\n description: 'Design rich render-ui effects for orbital schema transitions',\n version: '1.0.0',\n };\n}\n\n/**\n * Get design skill stats for comparison.\n */\nexport function getDesignSkillStats(): { lines: number; chars: number } {\n const skill = generateKflowDesignSkill();\n return {\n lines: skill.content.split('\\n').length,\n chars: skill.content.length,\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\", \"entity-detail\"]\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\": \"entity-detail\", \"entity\": \"Task\", \"fieldNames\": [\"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 6 core skills used by the builder client:\n * 1. kflow-orbitals (standard JSON generation)\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 * 6. kflow-design (render-ui design for transitions)\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// Design skill (render-ui authoring for transitions)\nexport { generateKflowDesignSkill, getDesignSkillStats } from './kflow-design.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 { generateKflowDesignSkill } from './kflow-design.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 6 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 generateKflowDesignSkill(),\n ];\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\\`\\`\\`json\n{\n \"name\": \"EntityName\",\n \"entity\": { ... },\n \"traits\": [ ... ],\n \"pages\": [ ... ]\n}\n\\`\\`\\`\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/skills",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "AI skill generators and prompts for Orbital schema generation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "commander": "^12.0.0",
31
31
  "glob": "^10.3.10",
32
- "@almadar/core": "1.0.15",
32
+ "@almadar/core": "1.0.16",
33
33
  "@almadar/llm": "1.0.15",
34
34
  "@almadar/patterns": "1.1.0",
35
35
  "@almadar/std": "1.0.14"
@@ -57,15 +57,15 @@
57
57
  "build": "tsup",
58
58
  "build:watch": "tsup --watch",
59
59
  "typecheck": "tsc --noEmit",
60
- "generate": "tsx scripts/generate.ts",
61
- "generate:list": "tsx scripts/generate.ts list",
62
- "generate:preview": "tsx scripts/generate.ts preview",
63
- "install:skills": "tsx scripts/install.ts",
60
+ "generate": "pnpm build && tsx scripts/generate.ts",
61
+ "generate:list": "pnpm build && tsx scripts/generate.ts list",
62
+ "generate:preview": "pnpm build && tsx scripts/generate.ts preview",
63
+ "install:skills": "pnpm build && tsx scripts/install.ts",
64
64
  "install:check": "tsx scripts/install.ts --check",
65
- "install:clean": "tsx scripts/install.ts --clean",
66
- "validate": "tsx scripts/validate.ts",
67
- "sync": "tsx scripts/sync.ts",
68
- "sync:dry": "tsx scripts/sync.ts --dry-run",
65
+ "install:clean": "pnpm build && tsx scripts/install.ts --clean",
66
+ "validate": "pnpm build && tsx scripts/validate.ts",
67
+ "sync": "pnpm build && tsx scripts/sync.ts",
68
+ "sync:dry": "pnpm build && tsx scripts/sync.ts --dry-run",
69
69
  "clean": "rm -rf .skills dist",
70
70
  "eval": "tsx evals/cli.ts",
71
71
  "eval:basic": "tsx evals/cli.ts --tags basic",