@almadar/skills 1.2.2 → 1.3.0

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.d.ts CHANGED
@@ -181,6 +181,12 @@ interface LeanSkillOptions {
181
181
  * the larger ~49K variant used by legacy callers.
182
182
  */
183
183
  declare function generateLeanOrbitalSkill(options?: LeanSkillOptions): string;
184
+ /**
185
+ * Get subagent system prompt for orbital generation.
186
+ * This is used by the orbital generator subagent in @almadar/agent.
187
+ * Provides focused guidance on generating complete orbitals with entities.
188
+ */
189
+ declare function getSubagentSystemPrompt(): string;
184
190
 
185
191
  /**
186
192
  * Lean Fixing Skill Generator
@@ -419,6 +425,8 @@ declare function getIconLibraryCompact(): string;
419
425
  * Get the fixing workflow section.
420
426
  */
421
427
  declare function getFixingWorkflowSection(): string;
428
+ /**
429
+
422
430
  /**
423
431
  * Get common fix patterns section.
424
432
  */
@@ -660,4 +668,4 @@ interface ProviderComparison {
660
668
  */
661
669
  declare function generateComparisonMatrix(comparisons: ProviderComparison[]): string;
662
670
 
663
- export { type CompositionMetrics, EVAL_CASES, type EvalCase, type EvalResult, type GeneratedSkill, type ProviderComparison, type ScoreBreakdown, type SkillFrontmatter, analyzeComposition, calculateTotalScore, formatFrontmatter, generateAllBuilderSkills, generateComparisonMatrix, generateDomainLanguageSkill, generateKflowOrbitalFixingSkill, generateKflowOrbitalsSkill, generateLeanFixingSkill$1 as generateLeanFixingSkill, generateLeanFixingSkill as generateLeanFixingSkillFull, generateLeanOrbitalSkill$1 as generateLeanOrbitalSkill, generateLeanOrbitalSkill as generateLeanOrbitalSkillFull, getArchitectureSection, getAssetRefSection, getBannedProps, getBindingContextRules, getBindingsCompact, getBindingsGuide, getCommonErrorsSection, getCommonFixPatternsSection, getCompletionRulesSection, getConnectivityCompact, getContextUsageCompact, getContextUsageSection, getCustomTraitCompact, getCustomTraitSection, getDecompositionChecklist, getDecompositionCompact, getDecompositionSection, getDesignErrorsCompact, getDesignErrorsSection, getEfficiencySection, getFieldTypesCompact, getFixingWorkflowSection, getFlowPatternSection, getFullOrbitalPrompt, getGameAsOrbitalsSection, getGameEntityTemplatesSection, getGamePatternsSection, getGameTraitsSection, getGameTypesSection, getIconLibraryCompact, getIconLibrarySection, getKeyBehaviorsReference, getMinimalTypeReference, getMultiFileSection, getOrbitalConnectivitySection, getOrbitalDecompositionPrompt, getOverGenerationSection, getPatternTypesCompact, getPortableOrbitalOutputSection, getRenderUIDesignGuide, getRenderUIQuickRef, getRequirementsDecomposePrompt, getRequirementsTraitPrompt, getSExprQuickRef, getSchemaUpdateCompact, getSchemaUpdateSection, getThemeGuide, getUsesImportCompact, getUsesImportSection, getValidationHintsSection, writeAllSkills, writeSkill };
671
+ export { type CompositionMetrics, EVAL_CASES, type EvalCase, type EvalResult, type GeneratedSkill, type ProviderComparison, type ScoreBreakdown, type SkillFrontmatter, analyzeComposition, calculateTotalScore, formatFrontmatter, generateAllBuilderSkills, generateComparisonMatrix, generateDomainLanguageSkill, generateKflowOrbitalFixingSkill, generateKflowOrbitalsSkill, generateLeanFixingSkill$1 as generateLeanFixingSkill, generateLeanFixingSkill as generateLeanFixingSkillFull, generateLeanOrbitalSkill$1 as generateLeanOrbitalSkill, generateLeanOrbitalSkill as generateLeanOrbitalSkillFull, getArchitectureSection, getAssetRefSection, getBannedProps, getBindingContextRules, getBindingsCompact, getBindingsGuide, getCommonErrorsSection, getCommonFixPatternsSection, getCompletionRulesSection, getConnectivityCompact, getContextUsageCompact, getContextUsageSection, getCustomTraitCompact, getCustomTraitSection, getDecompositionChecklist, getDecompositionCompact, getDecompositionSection, getDesignErrorsCompact, getDesignErrorsSection, getEfficiencySection, getFieldTypesCompact, getFixingWorkflowSection, getFlowPatternSection, getFullOrbitalPrompt, getGameAsOrbitalsSection, getGameEntityTemplatesSection, getGamePatternsSection, getGameTraitsSection, getGameTypesSection, getIconLibraryCompact, getIconLibrarySection, getKeyBehaviorsReference, getMinimalTypeReference, getMultiFileSection, getOrbitalConnectivitySection, getOrbitalDecompositionPrompt, getOverGenerationSection, getPatternTypesCompact, getPortableOrbitalOutputSection, getRenderUIDesignGuide, getRenderUIQuickRef, getRequirementsDecomposePrompt, getRequirementsTraitPrompt, getSExprQuickRef, getSchemaUpdateCompact, getSchemaUpdateSection, getSubagentSystemPrompt, getThemeGuide, getUsesImportCompact, getUsesImportSection, getValidationHintsSection, writeAllSkills, writeSkill };
package/dist/index.js CHANGED
@@ -497,7 +497,28 @@ function getDecompositionSection() {
497
497
  ### Step 1: Identify Entities (ONE Orbital Per Entity)
498
498
  - What are the core data objects?
499
499
  - persistent (DB), runtime (memory), or singleton (config)?
500
- - **CRITICAL: Create exactly ONE orbital per entity** - do NOT split CRUD operations into separate orbitals
500
+ - **CRITICAL: Create exactly ONE orbital per entity**
501
+ - **CRITICAL: If the prompt mentions N entities, create N orbitals** (e.g., "Product, Category, Order" \u2192 3 orbitals)
502
+ - **CRITICAL: EVERY orbital MUST have an entity field** - no exceptions
503
+ - **NEVER** collapse multiple entities into a single dashboard orbital
504
+
505
+ **Entity Field is REQUIRED in every orbital:**
506
+ \`\`\`json
507
+ {
508
+ "name": "Product Management",
509
+ "entity": { // \u2190 REQUIRED: Every orbital needs this
510
+ "name": "Product",
511
+ "collection": "products",
512
+ "fields": [...]
513
+ },
514
+ "traits": [...],
515
+ "pages": [...]
516
+ }
517
+ \`\`\`
518
+
519
+ **Common mistake to avoid:**
520
+ - \u274C WRONG: Creating an orbital with no entity field
521
+ - \u2705 CORRECT: Every orbital has its entity defined inline
501
522
 
502
523
  ### Step 2: Select Interaction Model
503
524
  | Domain | Create | View | Edit | Delete |
@@ -596,6 +617,9 @@ function getDecompositionCompact() {
596
617
  - What are the core data objects?
597
618
  - persistent (DB), runtime (memory), or singleton (config)?
598
619
  - **CRITICAL: Create exactly ONE orbital per entity**
620
+ - **CRITICAL: If the prompt mentions N entities, create N orbitals** (e.g., "Product, Category, Order" \u2192 3 orbitals)
621
+ - **CRITICAL: EVERY orbital MUST have an entity field**
622
+ - **NEVER** collapse multiple entities into a single dashboard orbital
599
623
 
600
624
  ### Step 2: Select Interaction Model
601
625
  | Domain | Create | View | Edit | Delete |
@@ -2061,34 +2085,113 @@ function getIconLibraryCompact() {
2061
2085
  function getFixingWorkflowSection() {
2062
2086
  return `## Fixing Workflow
2063
2087
 
2088
+ ### Understanding Validation Errors
2089
+
2090
+ Validation output format:
2091
+ \`\`\`
2092
+ \u274C [ERROR_CODE] path.to.error: Description
2093
+ \u{1F4A1} Fix hint
2094
+ \`\`\`
2095
+
2096
+ **The path tells you exactly where to edit.**
2097
+
2098
+ | Error Path | What to Edit |
2099
+ |------------|--------------|
2100
+ | \`orbitals[0].entity.fields\` | Add/modify entity fields |
2101
+ | \`orbitals[0].traits[0].stateMachine.transitions[1]\` | Add/modify transition |
2102
+ | \`orbitals[0].traits[0].stateMachine.states\` | Add state or mark isTerminal |
2103
+ | \`...effects[0][2].children[1].children[0].children[1].text\` | Fix binding in render-ui |
2104
+
2064
2105
  ### Step 1: Validate and Analyze
2065
2106
 
2066
2107
  \`\`\`
2067
2108
  validate_schema()
2068
2109
  \`\`\`
2069
2110
 
2070
- Group errors by orbital component:
2111
+ **CRITICAL: Before fixing, you MUST understand the full scope of errors.**
2112
+
2113
+ Parse and categorize all errors:
2071
2114
  - **Entity errors**: Field types, relations, collection names
2072
2115
  - **Trait errors**: State machine, events, transitions
2073
2116
  - **Page errors**: Missing traits, invalid references
2074
2117
  - **Pattern errors**: Missing required fields in render-ui
2075
2118
 
2076
- ### Step 2: Apply Batched Fixes
2119
+ **Count errors by orbital and severity.**
2120
+
2121
+ ### Step 2: Create Fix Plan
2122
+
2123
+ **BEFORE making any edits, write out your fix plan:**
2124
+
2125
+ \`\`\`
2126
+ ## Fix Plan
2127
+
2128
+ ### Summary
2129
+ - Total errors: X (Y critical, Z warnings)
2130
+ - Affected orbitals: [list]
2131
+ - Estimated complexity: simple|medium|complex
2132
+
2133
+ ### Execution Order
2134
+ 1. **Fix [ID]**: [Description] -> [Target location]
2135
+ 2. **Fix [ID]**: [Description] -> [Target location]
2136
+ 3. ...
2137
+
2138
+ ### Dependencies
2139
+ - Fix X must happen before Fix Y
2140
+ - Group A fixes can be batched
2141
+ \`\`\`
2142
+
2143
+ **Planning Rules:**
2144
+ - Group related fixes (same orbital, same component)
2145
+ - Identify dependencies (entity fields before bindings)
2146
+ - Prioritize critical errors first
2147
+ - Estimate if fix is simple (1 edit) or needs multiple steps
2148
+
2149
+ ### Step 3: Execute Fixes
2077
2150
 
2078
- Fix ALL errors of the same type in one edit. Priority order:
2151
+ **Execute your plan systematically:**
2079
2152
 
2080
- 1. **Entity fixes** (field types, enums, relations)
2081
- 2. **State machine fixes** (initial state, orphan states)
2082
- 3. **Transition fixes** (missing INIT, unreachable states)
2083
- 4. **Pattern fixes** (missing props in render-ui effects)
2153
+ For each fix in your plan:
2154
+ 1. **Apply the fix** using Edit tool
2155
+ 2. **Verify the fix** - check the specific error is resolved
2156
+ 3. **Track progress** - note which fixes are done
2084
2157
 
2085
- ### Step 3: Re-validate
2158
+ **Execution Order (Priority):**
2159
+ 1. **Entity structure fixes** (add missing entity, fields, persistence)
2160
+ 2. **Event/state fixes** (add missing events, states, transitions)
2161
+ 3. **Effect fixes** (render-ui effects, bindings)
2162
+ 4. **Pattern property fixes** (missing columns, fields, actions)
2163
+ 5. **Minor syntax fixes** (enum values, type corrections)
2164
+
2165
+ **Batching Strategy:**
2166
+ - Fix ALL errors of the same type in one orbital per edit
2167
+ - If errors span multiple orbitals, create separate edits
2168
+ - Document what each edit fixes
2169
+
2170
+ ### Step 4: Re-validate and Verify
2086
2171
 
2087
2172
  \`\`\`
2088
2173
  validate_schema()
2089
2174
  \`\`\`
2090
2175
 
2091
- **STOP when "valid": true** - do not add more tasks or re-verify.`;
2176
+ **After each batch of fixes, re-validate to confirm progress.**
2177
+
2178
+ Compare results with your plan:
2179
+ - Expected errors resolved
2180
+ - New errors appeared (unintended side effects)
2181
+ - Errors still present (fix did not work)
2182
+
2183
+ **If new errors appear:**
2184
+ 1. Analyze the new error
2185
+ 2. Update your fix plan
2186
+ 3. Continue execution
2187
+
2188
+ ### Step 5: Final Summary
2189
+
2190
+ **Call finish_task with:**
2191
+ - Summary of what was fixed
2192
+ - Number of edits made
2193
+ - Any warnings or notes
2194
+ `;
2092
2195
  }
2093
2196
  function getCommonFixPatternsSection() {
2094
2197
  return `## Common Fix Patterns
@@ -2126,7 +2229,49 @@ function getCommonFixPatternsSection() {
2126
2229
  | \`form-section\` | onSubmit | \`"onSubmit": "SAVE"\` |
2127
2230
  | \`form-section\` | fields | \`"fields": ["field1", "field2"]\` |
2128
2231
  | \`detail-panel\` | fields | \`"fields": ["field1", "field2"]\` |
2129
- | \`page-header\` | actions | \`"actions": [{ "label": "New", "event": "CREATE" }]\` |`;
2232
+ | \`page-header\` | actions | \`"actions": [{ "label": "New", "event": "CREATE" }]\` |
2233
+
2234
+ ### Binding Format Fixes (CRITICAL)
2235
+
2236
+ Validator error: \`ORB_BINDING_INVALID_FORMAT\` - "Invalid binding format: '@count:status=pending'"
2237
+ Suggestion: "Use @root.field.nested format" means \`@entity.fieldName\`, NOT literal "root".
2238
+
2239
+ **Common Invalid Patterns from Validator:**
2240
+ | Invalid Binding | Validator Message | Fix |
2241
+ |-----------------|-------------------|-----|
2242
+ | \`@count\` | Invalid binding format | Remove OR use \`@entity.count\` with computed field |
2243
+ | \`@count:status=pending\` | Invalid binding format | \`@entity.pendingCount\` + add computed field |
2244
+ | \`@count:status=active\` | Invalid binding format | \`@entity.activeCount\` + add computed field |
2245
+ | \`@count:status=done\` | Invalid binding format | \`@entity.doneCount\` + add computed field |
2246
+
2247
+ **Step-by-Step Fix Process:**
2248
+
2249
+ Given error: \`ORB_BINDING_INVALID_FORMAT\` at path \`orbitals[0].traits[0]...children[1].text\`
2250
+
2251
+ 1. **Extract orbital index** from path (e.g., \`orbitals[0]\` -> index 0)
2252
+ 2. **Find the invalid binding** (e.g., \`"@count:status=pending"\`)
2253
+ 3. **Add computed fields** to orbital's entity:
2254
+ \`\`\`json
2255
+ // In orbitals[0].entity.fields array, ADD:
2256
+ { "name": "pendingCount", "type": "number", "default": 0 },
2257
+ { "name": "activeCount", "type": "number", "default": 0 },
2258
+ { "name": "doneCount", "type": "number", "default": 0 }
2259
+ \`\`\`
2260
+ 4. **Replace ALL invalid bindings** in render-ui:
2261
+ \`\`\`json
2262
+ // BEFORE:
2263
+ { "type": "badge", "text": "@count:status=pending", "variant": "warning" }
2264
+ // AFTER:
2265
+ { "type": "badge", "text": "@entity.pendingCount", "variant": "warning" }
2266
+ \`\`\`
2267
+
2268
+ **Validator Error Code Reference:**
2269
+ | Code | Meaning | Action |
2270
+ |------|---------|--------|
2271
+ | \`ORB_BINDING_INVALID_FORMAT\` | Binding syntax wrong | Use \`@entity.field\` format |
2272
+ | \`ORB_BINDING_UNKNOWN_ROOT\` | Wrong root prefix | Use \`@entity\`, \`@payload\`, \`@state\`, \`@now\` |
2273
+ | \`ORB_BINDING_INVALID_PATH\` | Field doesn't exist | Add field to entity OR correct name |
2274
+ | \`ORB_BINDING_STATE_NO_PATH\` | \`@state\` needs no path | Use \`@state\` alone, not \`@state.field\` |`;
2130
2275
  }
2131
2276
  function getOverGenerationSection() {
2132
2277
  return `## Over-Generation Detection
@@ -2156,16 +2301,57 @@ The trait's render-ui effects handle all UI (modals for create/edit, drawers for
2156
2301
  function getEfficiencySection() {
2157
2302
  return `## Efficiency Guidelines
2158
2303
 
2159
- Target: **30-50 tool calls** for most fixes.
2304
+ Target: **3-5 tool calls** for most fixes.
2305
+
2306
+ ### For Small Schemas (< 15KB)
2307
+
2308
+ \`\`\`
2309
+ Step 1: Read schema.orb (1 call)
2310
+ Step 2: Edit to fix ALL errors at once (1 call)
2311
+ Step 3: Validate if needed (1 call)
2312
+ Total: 3 tool calls
2313
+ \`\`\`
2314
+
2315
+ ### For Large Schemas (> 15KB) - MANDATORY CHUNKING
2316
+
2317
+ **\u26A0\uFE0F WARNING: For schemas larger than 15KB, you MUST use chunking tools.**
2318
+
2319
+ Direct edit_file on large schemas will fail or consume excessive tokens. ALWAYS use this workflow:
2320
+
2321
+ \`\`\`
2322
+ MANDATORY Step 1: query_schema_structure("schema.orb")
2323
+ \u2192 Check totalSize field
2324
+
2325
+ MANDATORY Step 2: extract_chunk({
2326
+ file: "schema.orb",
2327
+ type: "orbital",
2328
+ name: "TargetOrbitalName"
2329
+ })
2330
+ \u2192 Returns: { chunkId: "abc123", chunkFile: ".chunks/chunk-abc123.json" }
2331
+
2332
+ MANDATORY Step 3: edit_file({
2333
+ path: ".chunks/chunk-abc123.json",
2334
+ old_string: ...,
2335
+ new_string: ...
2336
+ })
2337
+
2338
+ MANDATORY Step 4: apply_chunk({ chunkId: "abc123" })
2339
+ \u2192 Merges back to schema.orb
2340
+ \`\`\`
2341
+
2342
+ **NEVER** use Read/Edit directly on schema files > 15KB. **ALWAYS** use chunking.
2160
2343
 
2161
2344
  **DO:**
2162
- - Batch related changes (read once, edit all, write once)
2163
- - Fix all same-type errors together
2164
- - Run validation once after all changes
2345
+ - **Target 3 tool calls** for simple fixes (read \u2192 edit \u2192 done)
2346
+ - Fix ONLY what the user asked for (don't over-fix)
2347
+ - Batch related changes in ONE edit
2348
+ - Use chunking for schemas > 15KB
2165
2349
 
2166
2350
  **DON'T:**
2351
+ - Fix errors the user didn't ask about
2352
+ - Add missing transitions/states unless explicitly requested
2167
2353
  - Read schema multiple times without changes
2168
- - Make one small change per tool call
2354
+ - Make multiple small edits - do ONE comprehensive edit
2169
2355
  - Re-verify after validation passes
2170
2356
  - Create documentation files`;
2171
2357
  }
@@ -2678,7 +2864,46 @@ If the user specifies validation constraints, add S-expression guards on transit
2678
2864
  ### 4. ONE Orbital Per Entity
2679
2865
  Do NOT create multiple orbitals for the same entity. All CRUD operations belong in ONE orbital.
2680
2866
 
2681
- **Missing context fields = validation warnings. Missing guards = unenforced business rules!**`;
2867
+ ### 5. Entity Field is REQUIRED (CRITICAL)
2868
+ Every orbital MUST have an entity field. No exceptions.
2869
+
2870
+ \`\`\`json
2871
+ {
2872
+ "name": "Product Management",
2873
+ "entity": { // \u2190 REQUIRED
2874
+ "name": "Product",
2875
+ "collection": "products",
2876
+ "fields": [...]
2877
+ },
2878
+ "traits": [...],
2879
+ "pages": [...]
2880
+ }
2881
+ \`\`\`
2882
+
2883
+ **Verify before calling finish_task:**
2884
+ - [ ] Each orbital has an "entity" field
2885
+ - [ ] Each entity has a "name" and "collection"
2886
+ - [ ] Each entity has "fields" array
2887
+
2888
+ **Missing entity field = INVALID orbital!**
2889
+
2890
+ **Fixing Entity Errors:**
2891
+ If validation shows errors like "Missing entity" or "No fields":
2892
+ 1. Read the orbital file from .orbitals/ directory
2893
+ 2. Add the missing entity field:
2894
+ \`\`\`json
2895
+ "entity": {
2896
+ "name": "Product",
2897
+ "collection": "products",
2898
+ "fields": [
2899
+ { "name": "name", "type": "string", "required": true },
2900
+ { "name": "price", "type": "number" }
2901
+ ]
2902
+ }
2903
+ \`\`\`
2904
+ 3. Save the file and re-validate
2905
+
2906
+ **DO NOT call finish_task until ALL orbitals have entities!**`;
2682
2907
  }
2683
2908
  function getToolWorkflowSection() {
2684
2909
  return `---
@@ -2699,8 +2924,28 @@ generate_orbital({ orbital: {...}, orbitalIndex: 1, totalOrbitals: N })
2699
2924
 
2700
2925
  Each orbital is written to \`.orbitals/<name>.json\` with ALL effects (render-ui, persist, emit, set, etc.).
2701
2926
 
2702
- ### Phase 3: COMBINE
2703
- Call \`finish_task\` to auto-combine and validate:
2927
+ ### Phase 3: VALIDATE (CRITICAL)
2928
+ After generating ALL orbitals, validate BEFORE calling finish_task:
2929
+
2930
+ \`\`\`
2931
+ validate_schema()
2932
+ \`\`\`
2933
+
2934
+ **If validation shows errors:**
2935
+ 1. Read the error path (e.g., orbitals[0].entity)
2936
+ 2. Fix the issue in the orbital file
2937
+ 3. Re-run validate_schema()
2938
+
2939
+ **Common errors to fix:**
2940
+ - ORB_E_MISSING_NAME \u2192 Add entity name
2941
+ - ORB_E_NO_FIELDS \u2192 Add entity fields
2942
+ - Missing entity field \u2192 Add entity object with name and fields
2943
+
2944
+ **CRITICAL: Check EACH orbital file in .orbitals/ directory:**
2945
+ Use Read tool to check each orbital file has entity field.
2946
+
2947
+ ### Phase 4: COMBINE
2948
+ Call \`finish_task\` to auto-combine:
2704
2949
 
2705
2950
  \`\`\`
2706
2951
  finish_task({ appName: "App" })
@@ -2841,6 +3086,203 @@ This example passes \`npx @almadar/cli validate\` with zero errors:
2841
3086
  - Page traits: \`{ "ref": "TaskInteraction" }\` \u2014 NOT with linkedEntity
2842
3087
  - Props: \`submitEvent\` (not \`onSubmit\`), \`actions\` (not \`headerActions\`), \`fields\` (not \`fieldNames\`)
2843
3088
  - Theme: All visual properties use CSS variables
3089
+
3090
+ ---
3091
+
3092
+ ## Example: E-commerce with Multiple Orbitals (3 Entities)
3093
+
3094
+ For an app with Product, Category, and Order:
3095
+
3096
+ \`\`\`json
3097
+ {
3098
+ "name": "EcommerceAdmin",
3099
+ "version": "1.0.0",
3100
+ "orbitals": [
3101
+ {
3102
+ "name": "Product Management",
3103
+ "entity": {
3104
+ "name": "Product",
3105
+ "collection": "products",
3106
+ "fields": [
3107
+ { "name": "name", "type": "string", "required": true },
3108
+ { "name": "price", "type": "number", "required": true },
3109
+ { "name": "stock", "type": "number", "default": 0 }
3110
+ ]
3111
+ },
3112
+ "traits": [{ "name": "ProductInteraction", "category": "interaction", "linkedEntity": "Product" }],
3113
+ "pages": [{ "name": "ProductsPage", "path": "/products", "traits": [{ "ref": "ProductInteraction" }] }]
3114
+ },
3115
+ {
3116
+ "name": "Category Management",
3117
+ "entity": {
3118
+ "name": "Category",
3119
+ "collection": "categories",
3120
+ "fields": [
3121
+ { "name": "name", "type": "string", "required": true },
3122
+ { "name": "slug", "type": "string", "required": true }
3123
+ ]
3124
+ },
3125
+ "traits": [{ "name": "CategoryInteraction", "category": "interaction", "linkedEntity": "Category" }],
3126
+ "pages": [{ "name": "CategoriesPage", "path": "/categories", "traits": [{ "ref": "CategoryInteraction" }] }]
3127
+ },
3128
+ {
3129
+ "name": "Order Management",
3130
+ "entity": {
3131
+ "name": "Order",
3132
+ "collection": "orders",
3133
+ "fields": [
3134
+ { "name": "orderNumber", "type": "string", "required": true },
3135
+ { "name": "totalAmount", "type": "number", "required": true },
3136
+ { "name": "status", "type": "enum", "values": ["pending", "processing", "shipped", "delivered"] }
3137
+ ]
3138
+ },
3139
+ "traits": [{ "name": "OrderInteraction", "category": "interaction", "linkedEntity": "Order" }],
3140
+ "pages": [{ "name": "OrdersPage", "path": "/orders", "traits": [{ "ref": "OrderInteraction" }] }]
3141
+ }
3142
+ ]
3143
+ }
3144
+ \`\`\`
3145
+
3146
+ **Key Points for Multi-Orbital Apps:**
3147
+ - Each orbital has its own entity field (REQUIRED)
3148
+ - Each entity has its own collection name
3149
+ - Each orbital has its own page
3150
+ - Call \`generate_orbital\` 3 times (once per orbital)
3151
+ `;
3152
+ }
3153
+ function getSubagentSystemPrompt() {
3154
+ return `# Orbital Generation Subagent
3155
+
3156
+ You are a specialized subagent that generates complete FullOrbitalUnit definitions.
3157
+ Your task is to expand a lightweight orbital input into a full orbital with entity, traits, state machines, and pages.
3158
+
3159
+ ## Core Formula
3160
+ Orbital Unit = Entity \xD7 Traits \xD7 Patterns
3161
+
3162
+ ## REQUIRED Output Structure
3163
+
3164
+ Every orbital MUST have this exact structure:
3165
+
3166
+ \`\`\`json
3167
+ {
3168
+ "name": "OrbitalName",
3169
+ "entity": { // \u2190 CRITICAL: REQUIRED FIELD
3170
+ "name": "EntityName",
3171
+ "collection": "entitynames", // Plural lowercase
3172
+ "persistence": "persistent", // or "runtime" or "singleton"
3173
+ "fields": [
3174
+ { "name": "fieldName", "type": "string|number|boolean|enum|timestamp|array|object|relation", "required": true }
3175
+ ]
3176
+ },
3177
+ "traits": [
3178
+ {
3179
+ "name": "TraitName",
3180
+ "category": "interaction",
3181
+ "linkedEntity": "EntityName",
3182
+ "stateMachine": {
3183
+ "states": [
3184
+ { "name": "Browsing", "isInitial": true },
3185
+ { "name": "Creating" },
3186
+ { "name": "Editing" }
3187
+ ],
3188
+ "events": [
3189
+ { "key": "INIT", "name": "Initialize" },
3190
+ { "key": "CREATE", "name": "Create" },
3191
+ { "key": "SAVE", "name": "Save", "payload": [{ "name": "data", "type": "object" }] },
3192
+ { "key": "CANCEL", "name": "Cancel" }
3193
+ ],
3194
+ "transitions": [
3195
+ {
3196
+ "from": "Browsing",
3197
+ "to": "Browsing",
3198
+ "event": "INIT",
3199
+ "effects": [
3200
+ ["render-ui", "main", {
3201
+ "type": "stack",
3202
+ "direction": "vertical",
3203
+ "gap": "lg",
3204
+ "children": [
3205
+ // header, metrics, data table
3206
+ ]
3207
+ }]
3208
+ ]
3209
+ }
3210
+ ]
3211
+ }
3212
+ }
3213
+ ],
3214
+ "pages": [
3215
+ {
3216
+ "name": "PageName",
3217
+ "path": "/path",
3218
+ "viewType": "list",
3219
+ "traits": [{ "ref": "TraitName" }]
3220
+ }
3221
+ ],
3222
+ "domainContext": {
3223
+ "request": "...",
3224
+ "category": "business",
3225
+ "vocabulary": { "item": "...", "create": "..." }
3226
+ },
3227
+ "design": {
3228
+ "style": "modern",
3229
+ "uxHints": { "flowPattern": "crud-cycle", "listPattern": "entity-table" }
3230
+ }
3231
+ }
3232
+ \`\`\`
3233
+
3234
+ ## CRITICAL RULES
3235
+
3236
+ 1. **ENTITY FIELD IS REQUIRED**: Every orbital MUST have an "entity" field at the top level
3237
+ 2. **Entity Name**: Must match the orbital's primary entity
3238
+ 3. **Collection**: Plural lowercase version of entity name (e.g., "products" for Product)
3239
+ 4. **Fields**: At minimum, include id, name, and relevant fields from input
3240
+
3241
+ ## Common Mistakes to Avoid
3242
+
3243
+ - \u274C WRONG: Missing entity field at orbital level
3244
+ - \u274C WRONG: Only linkedEntity in trait, no orbital.entity
3245
+ - \u274C WRONG: Empty fields array
3246
+ - \u2705 CORRECT: Full entity object with name, collection, persistence, fields
3247
+
3248
+ ## Field Types
3249
+
3250
+ | Type | Use For | Example |
3251
+ |------|---------|---------|
3252
+ | string | Text, names | { "name": "title", "type": "string", "required": true } |
3253
+ | number | Prices, counts | { "name": "price", "type": "number" } |
3254
+ | enum | Status, categories | { "name": "status", "type": "enum", "values": ["pending", "active"] } |
3255
+ | timestamp | Dates, times | { "name": "createdAt", "type": "timestamp", "default": "@now" } |
3256
+ | relation | Links to other entities | { "name": "categoryId", "type": "relation", "relation": { "entity": "Category" } } |
3257
+
3258
+ ## State Machine Patterns
3259
+
3260
+ **CRUD Pattern:**
3261
+ - States: Browsing (isInitial), Creating, Editing, Viewing
3262
+ - Events: INIT, CREATE, EDIT, VIEW, SAVE, CANCEL, DELETE
3263
+ - INIT effect: render-ui with stack containing header, metrics, entity-table
3264
+
3265
+ **Transitions:**
3266
+ - Browsing \u2192 Creating: on CREATE
3267
+ - Creating \u2192 Browsing: on SAVE or CANCEL
3268
+ - Browsing \u2192 Editing: on EDIT
3269
+ - Editing \u2192 Browsing: on SAVE or CANCEL
3270
+
3271
+ ## Effects Reference
3272
+
3273
+ | Effect | Syntax | Purpose |
3274
+ |--------|--------|---------|
3275
+ | render-ui | ["render-ui", "main", { ... }] | Render UI pattern |
3276
+ | render-ui | ["render-ui", "modal", { ... }] | Render modal |
3277
+ | persist | ["persist", "create", "Entity", "@payload.data"] | Save to DB |
3278
+ | set | ["set", "@entity.field", value] | Update field |
3279
+ | emit | ["emit", "EVENT", payload] | Emit event |
3280
+ | navigate | ["navigate", "/path"] | Navigate |
3281
+
3282
+ ## Output Requirements
3283
+
3284
+ Return ONLY valid JSON. No markdown, no explanations.
3285
+ The JSON must be a complete FullOrbitalUnit with all required fields.
2844
3286
  `;
2845
3287
  }
2846
3288
 
@@ -2971,7 +3413,7 @@ function generateKflowOrbitalFixingSkill() {
2971
3413
  const frontmatter = {
2972
3414
  name: metadata.name,
2973
3415
  description: metadata.description,
2974
- allowedTools: ["Read", "Edit", "Bash"],
3416
+ allowedTools: ["Read", "Edit", "Bash", "query_schema_structure", "extract_chunk", "apply_chunk"],
2975
3417
  version: metadata.version
2976
3418
  };
2977
3419
  const content = generateLeanFixingSkill({
@@ -3980,14 +4422,34 @@ ${getCommonErrorsSection()}
3980
4422
 
3981
4423
  Return ONLY valid JSON matching the FullOrbitalUnit structure. No markdown, no explanations.
3982
4424
 
4425
+ **CRITICAL: The entity field is REQUIRED at the orbital level:**
4426
+
3983
4427
  \`\`\`json
3984
4428
  {
3985
- "name": "EntityName",
3986
- "entity": { ... },
4429
+ "name": "Product Management",
4430
+ "entity": { // \u2190 REQUIRED: Must have this field
4431
+ "name": "Product",
4432
+ "collection": "products",
4433
+ "persistence": "persistent",
4434
+ "fields": [
4435
+ { "name": "name", "type": "string", "required": true },
4436
+ { "name": "price", "type": "number" }
4437
+ ]
4438
+ },
3987
4439
  "traits": [ ... ],
3988
4440
  "pages": [ ... ]
3989
4441
  }
3990
4442
  \`\`\`
4443
+
4444
+ **Validation Rules:**
4445
+ - MUST include "entity" field at orbital level (NOT just linkedEntity in traits)
4446
+ - entity.name must match the orbital's primary entity
4447
+ - entity.collection must be plural lowercase (e.g., "products", not "Product")
4448
+ - entity.fields must have at least one field
4449
+
4450
+ **Common Mistake:**
4451
+ - \u274C WRONG: Only putting entity reference in trait.linkedEntity
4452
+ - \u2705 CORRECT: Full entity object in orbital.entity field
3991
4453
  `.trim();
3992
4454
  }
3993
4455
  function getRequirementsDecomposePrompt() {
@@ -4392,6 +4854,6 @@ function generateComparisonMatrix(comparisons) {
4392
4854
  return markdown;
4393
4855
  }
4394
4856
 
4395
- export { EVAL_CASES, analyzeComposition, calculateTotalScore, formatFrontmatter, generateAllBuilderSkills, generateComparisonMatrix, generateDomainLanguageSkill, generateKflowOrbitalFixingSkill, generateKflowOrbitalsSkill, generateLeanFixingSkill2 as generateLeanFixingSkill, generateLeanFixingSkill as generateLeanFixingSkillFull, generateLeanOrbitalSkill2 as generateLeanOrbitalSkill, generateLeanOrbitalSkill as generateLeanOrbitalSkillFull, getArchitectureSection, getAssetRefSection, getBannedProps, getBindingContextRules, getBindingsCompact, getBindingsGuide, getCommonErrorsSection, getCommonFixPatternsSection, getCompletionRulesSection, getConnectivityCompact, getContextUsageCompact, getContextUsageSection, getCustomTraitCompact, getCustomTraitSection, getDecompositionChecklist, getDecompositionCompact, getDecompositionSection, getDesignErrorsCompact, getDesignErrorsSection, getEfficiencySection, getFieldTypesCompact, getFixingWorkflowSection, getFlowPatternSection, getFullOrbitalPrompt, getGameAsOrbitalsSection, getGameEntityTemplatesSection, getGamePatternsSection, getGameTraitsSection, getGameTypesSection, getIconLibraryCompact, getIconLibrarySection, getKeyBehaviorsReference2 as getKeyBehaviorsReference, getMinimalTypeReference, getMultiFileSection, getOrbitalConnectivitySection, getOrbitalDecompositionPrompt, getOverGenerationSection, getPatternTypesCompact, getPortableOrbitalOutputSection, getRenderUIDesignGuide, getRenderUIQuickRef2 as getRenderUIQuickRef, getRequirementsDecomposePrompt, getRequirementsTraitPrompt, getSExprQuickRef2 as getSExprQuickRef, getSchemaUpdateCompact, getSchemaUpdateSection, getThemeGuide, getUsesImportCompact, getUsesImportSection, getValidationHintsSection, writeAllSkills, writeSkill };
4857
+ export { EVAL_CASES, analyzeComposition, calculateTotalScore, formatFrontmatter, generateAllBuilderSkills, generateComparisonMatrix, generateDomainLanguageSkill, generateKflowOrbitalFixingSkill, generateKflowOrbitalsSkill, generateLeanFixingSkill2 as generateLeanFixingSkill, generateLeanFixingSkill as generateLeanFixingSkillFull, generateLeanOrbitalSkill2 as generateLeanOrbitalSkill, generateLeanOrbitalSkill as generateLeanOrbitalSkillFull, getArchitectureSection, getAssetRefSection, getBannedProps, getBindingContextRules, getBindingsCompact, getBindingsGuide, getCommonErrorsSection, getCommonFixPatternsSection, getCompletionRulesSection, getConnectivityCompact, getContextUsageCompact, getContextUsageSection, getCustomTraitCompact, getCustomTraitSection, getDecompositionChecklist, getDecompositionCompact, getDecompositionSection, getDesignErrorsCompact, getDesignErrorsSection, getEfficiencySection, getFieldTypesCompact, getFixingWorkflowSection, getFlowPatternSection, getFullOrbitalPrompt, getGameAsOrbitalsSection, getGameEntityTemplatesSection, getGamePatternsSection, getGameTraitsSection, getGameTypesSection, getIconLibraryCompact, getIconLibrarySection, getKeyBehaviorsReference2 as getKeyBehaviorsReference, getMinimalTypeReference, getMultiFileSection, getOrbitalConnectivitySection, getOrbitalDecompositionPrompt, getOverGenerationSection, getPatternTypesCompact, getPortableOrbitalOutputSection, getRenderUIDesignGuide, getRenderUIQuickRef2 as getRenderUIQuickRef, getRequirementsDecomposePrompt, getRequirementsTraitPrompt, getSExprQuickRef2 as getSExprQuickRef, getSchemaUpdateCompact, getSchemaUpdateSection, getSubagentSystemPrompt, getThemeGuide, getUsesImportCompact, getUsesImportSection, getValidationHintsSection, writeAllSkills, writeSkill };
4396
4858
  //# sourceMappingURL=index.js.map
4397
4859
  //# sourceMappingURL=index.js.map