@almadar/skills 2.5.0 → 2.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { existsSync, mkdirSync, writeFileSync } from 'fs';
2
2
  import { join } from 'path';
3
- import { generateBehaviorsDocs, getAllBehaviors, generateModulesDocs, getAllStdOperators } from '@almadar/std';
3
+ import { getAllBehaviors, generateBehaviorsDocs, generateModulesDocs, getAllStdOperators } from '@almadar/std';
4
4
  import { OPERATORS, UI_SLOTS, PATTERN_TYPES, ViewTypeSchema, isInlineTrait as isInlineTrait$1 } from '@almadar/core/types';
5
- import { getPatternPropsCompact, getPatternActionsRef, getOrbAllowedPatternsCompact, getAllPatternTypes } from '@almadar/patterns';
5
+ import { getPatternPropsCompact, getPatternActionsRef, getOrbAllowedPatternsCompact, getOrbAllowedPatternsFiltered, getAllPatternTypes } from '@almadar/patterns';
6
6
  import { BINDING_DOCS, CORE_BINDINGS, isInlineTrait } from '@almadar/core';
7
7
  import { generateDomainLanguageReference } from '@almadar/core/domain-language';
8
8
 
@@ -1542,6 +1542,139 @@ ${patternsRef}
1542
1542
 
1543
1543
  ### BANNED Patterns
1544
1544
 
1545
+ | Wrong | Correct |
1546
+ |-------|---------|
1547
+ | \`entity-table\` | \`data-list\` or \`data-grid\` |
1548
+ | \`page-header\` | \`stack\` with \`icon\` + \`typography\` + \`button\` |
1549
+ | \`detail-panel\` | \`stack\` with field \`typography\` rows |
1550
+ | \`stats\` | \`stat-display\` atoms in a \`stack\` |
1551
+ | Multiple flat render-ui calls | Single composed render-ui |
1552
+ | Hex colors / pixels | Theme CSS variables |
1553
+ | \`onSubmit\` / \`onCancel\` | \`submitEvent\` / \`cancelEvent\` |
1554
+ `;
1555
+ }
1556
+ function getOrbRenderUIGuideFiltered(patternNames) {
1557
+ const patternsRef = getOrbAllowedPatternsFiltered(patternNames);
1558
+ return `## .orb Render-UI Composition Guide
1559
+
1560
+ ### Golden Behavior Pattern
1561
+
1562
+ Every render-ui tree in .orb follows the same structure observed across all 107 golden behaviors:
1563
+
1564
+ \`\`\`
1565
+ stack (vertical, gap: lg) \u2190 root wrapper, ALWAYS
1566
+ \u251C\u2500\u2500 stack (horizontal) \u2190 header row (icon + title + actions)
1567
+ \u2502 \u251C\u2500\u2500 icon
1568
+ \u2502 \u251C\u2500\u2500 typography (h2/h3)
1569
+ \u2502 \u2514\u2500\u2500 button (primary action)
1570
+ \u251C\u2500\u2500 divider \u2190 visual separation
1571
+ \u251C\u2500\u2500 stat-display / badge row \u2190 optional summary stats
1572
+ \u2514\u2500\u2500 data-list / data-grid \u2190 main content
1573
+ OR form-section \u2190 for create/edit states
1574
+ \`\`\`
1575
+
1576
+ ---
1577
+
1578
+ ### Composition Rules
1579
+
1580
+ | Rule | Requirement |
1581
+ |------|-------------|
1582
+ | **1** | Root element MUST be \`stack\` (vertical) or \`box\` |
1583
+ | **2** | Use ONLY the patterns listed below |
1584
+ | **3** | Single \`render-ui\` per transition (compose children, never multiple flat calls) |
1585
+ | **4** | ALL visual props use CSS theme variables (no hex colors, no pixels) |
1586
+ | **5** | Every action button's \`event\` must match a state machine event key |
1587
+
1588
+ ---
1589
+
1590
+ ### Layout Reference
1591
+
1592
+ **Stack** (use for ALL layout):
1593
+ \`\`\`json
1594
+ {
1595
+ "type": "stack",
1596
+ "direction": "vertical" | "horizontal",
1597
+ "gap": "xs" | "sm" | "md" | "lg" | "xl",
1598
+ "align": "start" | "center" | "end" | "stretch",
1599
+ "justify": "start" | "center" | "end" | "between"
1600
+ }
1601
+ \`\`\`
1602
+
1603
+ **Box** (styled container):
1604
+ \`\`\`json
1605
+ {
1606
+ "type": "box",
1607
+ "padding": "sm" | "md" | "lg",
1608
+ "bg": "var(--color-card)",
1609
+ "border": true,
1610
+ "borderColor": "var(--color-border)",
1611
+ "rounded": "var(--radius-md)",
1612
+ "shadow": "var(--shadow-sm)"
1613
+ }
1614
+ \`\`\`
1615
+
1616
+ ---
1617
+
1618
+ ### Theme Variables (MANDATORY)
1619
+
1620
+ | Property | Use | Never |
1621
+ |----------|-----|-------|
1622
+ | Colors | \`var(--color-primary)\` | \`#3b82f6\` |
1623
+ | Backgrounds | \`var(--color-card)\` | \`white\` |
1624
+ | Text | \`var(--color-foreground)\` | \`black\` |
1625
+ | Muted text | \`var(--color-muted-foreground)\` | \`gray\` |
1626
+ | Borders | \`var(--color-border)\` | \`#e5e7eb\` |
1627
+ | Radius | \`var(--radius-md)\` | \`8px\` |
1628
+ | Shadows | \`var(--shadow-sm)\` | \`0 2px 4px...\` |
1629
+
1630
+ ---
1631
+
1632
+ ### Example: Browsing State (from golden behaviors)
1633
+
1634
+ \`\`\`json
1635
+ ["render-ui", "main", {
1636
+ "type": "stack", "direction": "vertical", "gap": "lg",
1637
+ "children": [
1638
+ {
1639
+ "type": "stack", "direction": "horizontal", "gap": "md",
1640
+ "justify": "between", "align": "center",
1641
+ "children": [
1642
+ {
1643
+ "type": "stack", "direction": "horizontal", "gap": "sm", "align": "center",
1644
+ "children": [
1645
+ { "type": "icon", "name": "list", "size": "lg" },
1646
+ { "type": "typography", "variant": "h2", "content": "Items" }
1647
+ ]
1648
+ },
1649
+ { "type": "button", "label": "Create", "event": "CREATE", "variant": "primary" }
1650
+ ]
1651
+ },
1652
+ { "type": "divider" },
1653
+ {
1654
+ "type": "data-list", "entity": "Item",
1655
+ "itemActions": [
1656
+ { "label": "Edit", "event": "EDIT" },
1657
+ { "label": "Delete", "event": "DELETE", "variant": "danger" }
1658
+ ]
1659
+ }
1660
+ ]
1661
+ }]
1662
+ \`\`\`
1663
+
1664
+ ---
1665
+
1666
+ ${getBindingsGuide()}
1667
+
1668
+ ---
1669
+
1670
+ ### Available Patterns (selected for this application)
1671
+
1672
+ ${patternsRef}
1673
+
1674
+ ---
1675
+
1676
+ ### BANNED Patterns
1677
+
1545
1678
  | Wrong | Correct |
1546
1679
  |-------|---------|
1547
1680
  | \`entity-table\` | \`data-list\` or \`data-grid\` |
@@ -4256,6 +4389,91 @@ When answering:
4256
4389
  };
4257
4390
  }
4258
4391
 
4392
+ // src/generators/converter.ts
4393
+ function generateConverterSkill() {
4394
+ const frontmatter = {
4395
+ name: "converter",
4396
+ description: "Convert existing source code projects or live websites to .orb orbital schemas",
4397
+ allowedTools: [
4398
+ "extract_source",
4399
+ "extract_crawl",
4400
+ "match_behavior",
4401
+ "use_behavior",
4402
+ "build_orbital",
4403
+ "connect_behaviors",
4404
+ "compose_app",
4405
+ "verify_app"
4406
+ ],
4407
+ version: "1.0.0"
4408
+ };
4409
+ const content = `
4410
+ # Almadar Converter Agent
4411
+
4412
+ You convert existing TypeScript/JavaScript projects into .orb orbital schemas.
4413
+
4414
+ ## Workflow
4415
+
4416
+ 1. **Extract**: Call \`extract_source\` with the project path to get a SourceSnapshot
4417
+ 2. **Read**: Examine the SourceSnapshot \u2014 entities, routes, API routes, state management
4418
+ 3. **Match**: For each entity, call \`match_behavior\` with a description of the entity's usage pattern
4419
+ 4. **Instantiate**: For each matched entity:
4420
+ - If matched \u2192 call \`use_behavior\` with the behavior name, entity name, and fields JSON (FAST, 0 LLM)
4421
+ - If not matched \u2192 call \`build_orbital\` with a shell schema (SLOW, 40+ LLM calls, FALLBACK ONLY)
4422
+ 5. **Connect**: If entities have cross-entity relationships, call \`connect_behaviors\` to wire events
4423
+ 6. **Compose**: Call \`compose_app\` to combine all orbitals into the final schema
4424
+ 7. **Verify**: If requested, call \`verify_app\` to run round-trip verification
4425
+ 8. **Retry**: If verify fails, read failures, fix the specific orbital, recompose, reverify (max 2 retries)
4426
+
4427
+ ## Tools
4428
+
4429
+ - \`extract_source\`: Extract entities, routes, APIs, state from source code (deterministic for TS, agent-driven for other languages)
4430
+ - \`match_behavior\`: Find matching std behavior for an entity (1 LLM call)
4431
+ - \`use_behavior\`: Instantiate a behavior with custom entity + fields (0 LLM calls, PREFERRED)
4432
+ - \`build_orbital\`: Full gate pipeline for novel patterns (40+ LLM calls, FALLBACK)
4433
+ - \`connect_behaviors\`: Wire cross-orbital events between emitter and listener (0 LLM calls)
4434
+ - \`compose_app\`: Combine all orbitals into final multi-page app schema (0 LLM calls)
4435
+ - \`verify_app\`: Compile + serve + browser test (0 LLM calls)
4436
+
4437
+ ## Rules
4438
+
4439
+ - ALWAYS try \`use_behavior\` first via \`match_behavior\`. Only \`build_orbital\` as fallback.
4440
+ - When calling \`use_behavior\`, provide \`fieldsJson\` as a JSON string array:
4441
+ '[{"name":"title","type":"string","required":true},{"name":"status","type":"enum","values":["active","done"],"required":true}]'
4442
+ - Set \`persistence\` to "persistent" for entities with database backing, "runtime" otherwise.
4443
+ - Always call \`compose_app\` before \`verify_app\`.
4444
+ - Read verify failures carefully and fix only the broken orbital.
4445
+
4446
+ ## Behavior Matching Guidelines
4447
+
4448
+ When deciding which behavior matches an entity, consider:
4449
+
4450
+ | Pattern | Behavior | Key Indicators |
4451
+ |---------|----------|---------------|
4452
+ | List + CRUD operations | \`std-list\` | GET (list), POST, PUT, DELETE API routes; browse/create/edit states |
4453
+ | Detail view | \`std-detail\` | GET (single) route with :id param; view-only display |
4454
+ | Multi-step form / wizard | \`std-wizard\` | Sequential steps, stages, or phases in UI |
4455
+ | Shopping cart / checkout | \`std-cart\` | Add/remove items, quantity, checkout flow |
4456
+ | Static display | \`std-display\` | Read-only data presentation, no CRUD |
4457
+ | Search functionality | \`std-search\` | Search input, filter, query results |
4458
+ | Notification / alerts | \`std-notification\` | Push notifications, alerts, toasts |
4459
+ | Timer / countdown | \`std-timer\` | Time-based state, countdown, duration |
4460
+
4461
+ ## Cross-Entity Connection Patterns
4462
+
4463
+ Look for these signals in the SourceSnapshot to identify connections:
4464
+
4465
+ - Field names ending in \`Id\` (e.g., \`authorId\`, \`categoryId\`) \u2192 relation
4466
+ - Import statements between entity modules \u2192 dependency
4467
+ - Shared event names in state management \u2192 event connection
4468
+ - Foreign key patterns in Prisma/ORM \u2192 emits/listens wiring
4469
+ `.trim();
4470
+ return {
4471
+ name: "converter",
4472
+ frontmatter,
4473
+ content
4474
+ };
4475
+ }
4476
+
4259
4477
  // src/generators/orb.ts
4260
4478
  function generateOrbSkill() {
4261
4479
  const frontmatter = {
@@ -4914,6 +5132,460 @@ Uses only atoms and molecules. No organisms.
4914
5132
  `;
4915
5133
  }
4916
5134
 
5135
+ // src/prompts/behavior-sections/classify.ts
5136
+ var ATOM_NAMES = /* @__PURE__ */ new Set([
5137
+ "std-browse",
5138
+ "std-modal",
5139
+ "std-confirmation",
5140
+ "std-search",
5141
+ "std-filter",
5142
+ "std-sort",
5143
+ "std-pagination",
5144
+ "std-drawer",
5145
+ "std-notification",
5146
+ "std-timer",
5147
+ "std-tabs",
5148
+ "std-loading",
5149
+ "std-selection",
5150
+ "std-undo",
5151
+ "std-input",
5152
+ "std-wizard",
5153
+ "std-display",
5154
+ "std-async",
5155
+ "std-combat",
5156
+ "std-gameflow",
5157
+ "std-movement",
5158
+ "std-quest",
5159
+ "std-overworld",
5160
+ "std-circuit-breaker",
5161
+ "std-cache-aside",
5162
+ "std-score",
5163
+ "std-collision",
5164
+ "std-physics2d",
5165
+ "std-rate-limiter",
5166
+ "std-game-hud",
5167
+ "std-score-board",
5168
+ "std-game-menu",
5169
+ "std-game-over-screen",
5170
+ "std-dialogue-box",
5171
+ "std-inventory-panel",
5172
+ "std-combat-log",
5173
+ "std-sprite",
5174
+ "std-game-audio",
5175
+ "std-isometric-canvas",
5176
+ "std-platformer-canvas",
5177
+ "std-simulation-canvas",
5178
+ "std-game-canvas-2d",
5179
+ "std-game-canvas-3d"
5180
+ ]);
5181
+ var MOLECULE_NAMES = /* @__PURE__ */ new Set([
5182
+ "std-list",
5183
+ "std-cart",
5184
+ "std-detail",
5185
+ "std-inventory",
5186
+ "std-messaging",
5187
+ "std-geospatial",
5188
+ "std-turn-based-battle",
5189
+ "std-platformer-game",
5190
+ "std-puzzle-game",
5191
+ "std-builder-game",
5192
+ "std-classifier-game",
5193
+ "std-sequencer-game",
5194
+ "std-debugger-game",
5195
+ "std-negotiator-game",
5196
+ "std-simulator-game",
5197
+ "std-event-handler-game"
5198
+ ]);
5199
+ function classifyBehavior(name) {
5200
+ if (ATOM_NAMES.has(name)) return "atoms";
5201
+ if (MOLECULE_NAMES.has(name)) return "molecules";
5202
+ return "organisms";
5203
+ }
5204
+ function extractTraitData(schema) {
5205
+ const orbitals = schema.orbitals;
5206
+ if (!orbitals || orbitals.length === 0) {
5207
+ return { states: [], events: [], emits: [], listens: [] };
5208
+ }
5209
+ const traits = orbitals[0].traits;
5210
+ if (!traits || traits.length === 0) {
5211
+ return { states: [], events: [], emits: [], listens: [] };
5212
+ }
5213
+ const trait = traits[0];
5214
+ const sm = trait.stateMachine;
5215
+ const states = sm?.states?.map((s) => s.name) ?? [];
5216
+ const events = sm?.events?.map((e) => e.key) ?? [];
5217
+ const emits = trait.emits?.map((e) => e.event) ?? [];
5218
+ const listens = trait.listens?.map((l) => l.event) ?? [];
5219
+ return { states, events, emits, listens };
5220
+ }
5221
+
5222
+ // src/prompts/behavior-sections/behavior-catalog.ts
5223
+ function extractDescription(schema) {
5224
+ if (schema.description) return schema.description;
5225
+ const orbitals = schema.orbitals;
5226
+ if (!orbitals || orbitals.length === 0) return "No description available";
5227
+ const traits = orbitals[0].traits;
5228
+ if (traits && traits.length > 0 && typeof traits[0].name === "string") {
5229
+ return `Behavior: ${traits[0].name}`;
5230
+ }
5231
+ if (typeof orbitals[0].name === "string") {
5232
+ return `Orbital: ${orbitals[0].name}`;
5233
+ }
5234
+ return "No description available";
5235
+ }
5236
+ function getBehaviorCatalogSection() {
5237
+ const allBehaviors = getAllBehaviors();
5238
+ const atoms = [];
5239
+ const molecules = [];
5240
+ const organisms = [];
5241
+ for (const b of allBehaviors) {
5242
+ const level = classifyBehavior(b.name);
5243
+ if (level === "atoms") atoms.push(b);
5244
+ else if (level === "molecules") molecules.push(b);
5245
+ else organisms.push(b);
5246
+ }
5247
+ const formatList = (behaviors) => behaviors.map((b) => `- \`${b.name}\`: ${extractDescription(b)}`).join("\n");
5248
+ return `## Behavior Catalog (${allBehaviors.length} behaviors)
5249
+
5250
+ ### Atoms (${atoms.length})
5251
+ Self-contained, irreducible state machines. Building blocks for molecules.
5252
+
5253
+ ${formatList(atoms)}
5254
+
5255
+ ### Molecules (${molecules.length})
5256
+ Compose atoms via extractTrait + shared event bus. Mid-complexity behaviors.
5257
+
5258
+ ${formatList(molecules)}
5259
+
5260
+ ### Organisms (${organisms.length})
5261
+ Compose atoms/molecules via connect/compose/pipe. Full application patterns.
5262
+
5263
+ ${formatList(organisms)}`;
5264
+ }
5265
+ function getBehaviorAtomReference() {
5266
+ const allBehaviors = getAllBehaviors();
5267
+ const atoms = allBehaviors.filter((b) => classifyBehavior(b.name) === "atoms");
5268
+ if (atoms.length === 0) {
5269
+ return "### Atom Reference\n\nNo atoms found.";
5270
+ }
5271
+ const entries = atoms.map((schema) => {
5272
+ const { states, events } = extractTraitData(schema);
5273
+ const desc = schema.description ?? "";
5274
+ const lines = [];
5275
+ lines.push(`#### \`${schema.name}\``);
5276
+ if (desc) lines.push(desc);
5277
+ lines.push(`- **States**: ${states.length > 0 ? states.join(", ") : "none"}`);
5278
+ lines.push(`- **Events**: ${events.length > 0 ? events.join(", ") : "none"}`);
5279
+ return lines.join("\n");
5280
+ });
5281
+ return `### Atom Reference (${atoms.length})
5282
+
5283
+ Atoms are self-contained, irreducible state machines. Each atom handles a single concern.
5284
+
5285
+ ${entries.join("\n\n")}`;
5286
+ }
5287
+ function getBehaviorMoleculeReference() {
5288
+ const allBehaviors = getAllBehaviors();
5289
+ const molecules = allBehaviors.filter((b) => classifyBehavior(b.name) === "molecules");
5290
+ if (molecules.length === 0) {
5291
+ return "### Molecule Reference\n\nNo molecules found.";
5292
+ }
5293
+ const entries = molecules.map((schema) => {
5294
+ const { states, events } = extractTraitData(schema);
5295
+ const desc = schema.description ?? "";
5296
+ const lines = [];
5297
+ lines.push(`#### \`${schema.name}\``);
5298
+ if (desc) lines.push(desc);
5299
+ lines.push(`- **States**: ${states.length > 0 ? states.join(", ") : "none"}`);
5300
+ lines.push(`- **Events**: ${events.length > 0 ? events.join(", ") : "none"}`);
5301
+ return lines.join("\n");
5302
+ });
5303
+ return `### Molecule Reference (${molecules.length})
5304
+
5305
+ Molecules compose atoms via extractTrait and shared event buses. They handle mid-complexity interaction patterns.
5306
+
5307
+ ${entries.join("\n\n")}`;
5308
+ }
5309
+ function getBehaviorOrganismReference() {
5310
+ const allBehaviors = getAllBehaviors();
5311
+ const organisms = allBehaviors.filter((b) => classifyBehavior(b.name) === "organisms");
5312
+ if (organisms.length === 0) {
5313
+ return "### Organism Reference\n\nNo organisms found.";
5314
+ }
5315
+ const entries = organisms.map((schema) => {
5316
+ const { states, events } = extractTraitData(schema);
5317
+ const desc = schema.description ?? "";
5318
+ const lines = [];
5319
+ lines.push(`#### \`${schema.name}\``);
5320
+ if (desc) lines.push(desc);
5321
+ lines.push(`- **States**: ${states.length > 0 ? states.join(", ") : "none"}`);
5322
+ lines.push(`- **Events**: ${events.length > 0 ? events.join(", ") : "none"}`);
5323
+ return lines.join("\n");
5324
+ });
5325
+ return `### Organism Reference (${organisms.length})
5326
+
5327
+ Organisms compose atoms and molecules via connect/compose/pipe. They represent full application patterns.
5328
+
5329
+ ${entries.join("\n\n")}`;
5330
+ }
5331
+
5332
+ // src/prompts/behavior-sections/behavior-composition-guide.ts
5333
+ function getBehaviorCompositionGuide() {
5334
+ return `## Behavior Composition Guide
5335
+
5336
+ ### Core Rule: One Entity Per Orbital
5337
+ Every orbital has exactly ONE entity. If your app needs multiple entity types (e.g., Products and Orders),
5338
+ create multiple orbitals and wire them together with events.
5339
+
5340
+ ### How \`use_behavior\` Works
5341
+ Call \`use_behavior\` with an entity name and its fields to instantiate a standard behavior.
5342
+ The behavior function replaces generic field names with your entity-specific names and returns a complete orbital.
5343
+
5344
+ \`\`\`
5345
+ use_behavior({ behavior: "std-list", entityName: "Product", fields: ["name", "price", "category"] })
5346
+ // Returns: complete orbital with entity=Product, all states/events/UI wired for Product
5347
+ \`\`\`
5348
+
5349
+ ### How \`composeBehaviors\` Works
5350
+ After instantiating individual behaviors, compose them into a full application.
5351
+ \`composeBehaviors\` takes an array of orbitals and adds:
5352
+ - Layout: how orbitals are arranged on screen
5353
+ - Wiring: event connections between orbitals (emits/listens)
5354
+ - Pages: route configuration
5355
+
5356
+ \`\`\`
5357
+ compose_behaviors({
5358
+ orbitals: [productOrbital, orderOrbital],
5359
+ layout: "sidebar",
5360
+ wiring: [{ from: "ProductInteraction", event: "ADD_TO_CART", to: "OrderInteraction", triggers: "REFRESH" }]
5361
+ })
5362
+ \`\`\`
5363
+
5364
+ ### Layout Strategies
5365
+
5366
+ | Strategy | Description | Best For |
5367
+ |----------|-------------|----------|
5368
+ | \`sidebar\` | Navigation sidebar + main content | CRUD apps, dashboards |
5369
+ | \`tabs\` | Tabbed content sections | Multi-entity views |
5370
+ | \`dashboard\` | Grid of widgets/cards | Analytics, monitoring |
5371
+ | \`wizard-flow\` | Sequential step-by-step | Onboarding, checkout |
5372
+ | \`auto\` | Let the system choose based on orbital count | Quick prototyping |
5373
+
5374
+ ### Event Wiring
5375
+ Behaviors communicate through emits/listens. When one behavior emits an event,
5376
+ another behavior's listener triggers a transition.
5377
+
5378
+ - **emits**: Events this behavior sends out (e.g., ITEM_CREATED, ADD_TO_CART)
5379
+ - **listens**: Events this behavior responds to (e.g., REFRESH, ITEM_SELECTED)
5380
+ - **wiring**: Explicit connections between behaviors: \`{ from, event, to, triggers }\`
5381
+
5382
+ Every \`emits\` declaration must have a matching \`listens\` in another trait.`;
5383
+ }
5384
+ function extractEventContracts(schema) {
5385
+ const allEmits = [];
5386
+ const allListens = [];
5387
+ const orbitals = schema.orbitals;
5388
+ if (!orbitals) return { emits: allEmits, listens: allListens };
5389
+ for (const orbital of orbitals) {
5390
+ const traits = orbital.traits;
5391
+ if (!traits) continue;
5392
+ for (const trait of traits) {
5393
+ const emits = trait.emits;
5394
+ if (emits) {
5395
+ for (const e of emits) {
5396
+ if (e.event && !allEmits.includes(e.event)) {
5397
+ allEmits.push(e.event);
5398
+ }
5399
+ }
5400
+ }
5401
+ const listens = trait.listens;
5402
+ if (listens) {
5403
+ for (const l of listens) {
5404
+ if (l.event && !allListens.includes(l.event)) {
5405
+ allListens.push(l.event);
5406
+ }
5407
+ }
5408
+ }
5409
+ }
5410
+ }
5411
+ return { emits: allEmits, listens: allListens };
5412
+ }
5413
+ function getBehaviorEventContractsSection() {
5414
+ const behaviors = getAllBehaviors();
5415
+ const entries = [];
5416
+ for (const schema of behaviors) {
5417
+ const { emits, listens } = extractEventContracts(schema);
5418
+ if (emits.length === 0 && listens.length === 0) continue;
5419
+ const parts = [];
5420
+ if (emits.length > 0) parts.push(`emits [${emits.join(", ")}]`);
5421
+ if (listens.length > 0) parts.push(`listens [${listens.join(", ")}]`);
5422
+ entries.push(`- \`${schema.name}\`: ${parts.join(", ")}`);
5423
+ }
5424
+ if (entries.length === 0) {
5425
+ return `## Event Contracts
5426
+
5427
+ No behaviors with emits or listens found.`;
5428
+ }
5429
+ return `## Event Contracts
5430
+
5431
+ Behaviors communicate via events. Each behavior declares what it emits and what it listens to.
5432
+ Wire matching emits to listens when composing behaviors.
5433
+
5434
+ ${entries.join("\n")}`;
5435
+ }
5436
+
5437
+ // src/prompts/behavior-sections/domain-behavior-mapping.ts
5438
+ function getDomainBehaviorMapping() {
5439
+ return `## Domain to Behavior Mapping
5440
+
5441
+ Use this guide to select behaviors based on the application domain.
5442
+
5443
+ | Domain | Recommended Behaviors |
5444
+ |--------|----------------------|
5445
+ | **Business CRUD** | std-list, std-detail |
5446
+ | **E-commerce** | std-list (products), std-cart, std-wizard (checkout) |
5447
+ | **Healthcare** | std-list (patients), std-wizard (intake), std-display (vitals) |
5448
+ | **Education** | std-list (courses), std-wizard (enrollment) |
5449
+ | **Gaming** | std-gameflow, std-combat, std-inventory-panel, std-quest |
5450
+ | **Dashboard/Analytics** | std-display, std-list |
5451
+ | **Social** | std-list (posts), std-messaging, std-detail (profile) |
5452
+ | **DevOps** | std-list, std-display, std-circuit-breaker |
5453
+ | **Finance** | std-list (transactions), std-display (portfolio), std-wizard (transfers) |
5454
+ | **IoT/Monitoring** | std-display (sensors), std-list (devices), std-timer (polling) |
5455
+ | **Content Management** | std-list (articles), std-detail (editor), std-tabs (categories) |
5456
+ | **Booking/Scheduling** | std-list (slots), std-wizard (booking flow), std-confirmation |
5457
+ | **Project Management** | std-list (tasks), std-detail (task view), std-tabs (boards) |
5458
+
5459
+ ### Selection Strategy
5460
+ 1. Identify the primary entity types in the application
5461
+ 2. Match each entity to a behavior based on how users interact with it
5462
+ 3. Wire behaviors together using emits/listens for cross-entity communication
5463
+ 4. Use layout strategy (sidebar, tabs, dashboard) based on the relationship between entities`;
5464
+ }
5465
+
5466
+ // src/prompts/behavior-sections/cross-orbital-wiring-guide.ts
5467
+ function getCrossOrbitalWiringGuide() {
5468
+ return `## Cross-Orbital Wiring Guide
5469
+
5470
+ ### How Events Flow Between Orbitals
5471
+ Orbitals communicate through a shared event bus. One orbital's trait emits an event,
5472
+ and another orbital's trait listens for it. The listener triggers a local transition.
5473
+
5474
+ ### Wiring Format
5475
+ \`\`\`json
5476
+ {
5477
+ "from": "ProductInteraction",
5478
+ "event": "ADD_TO_CART",
5479
+ "to": "CartInteraction",
5480
+ "triggers": "REFRESH"
5481
+ }
5482
+ \`\`\`
5483
+
5484
+ - **from**: The trait that emits the event
5485
+ - **event**: The event name being emitted
5486
+ - **to**: The trait that listens for the event
5487
+ - **triggers**: The local event triggered in the listening trait
5488
+
5489
+ ### Common Wiring Patterns
5490
+
5491
+ #### CRUD Refresh
5492
+ When one orbital creates/updates/deletes, another orbital refreshes its list.
5493
+
5494
+ \`\`\`
5495
+ ProductInteraction emits PRODUCT_CREATED
5496
+ -> OrderInteraction listens PRODUCT_CREATED, triggers REFRESH
5497
+ \`\`\`
5498
+
5499
+ #### Navigation / Detail View
5500
+ When one orbital selects an item, another shows its details.
5501
+
5502
+ \`\`\`
5503
+ ListInteraction emits VIEW_DETAIL
5504
+ -> DetailInteraction listens VIEW_DETAIL, triggers INIT
5505
+ \`\`\`
5506
+
5507
+ #### Cart Pattern
5508
+ Add-to-cart from a product list updates the cart orbital.
5509
+
5510
+ \`\`\`
5511
+ ProductInteraction emits ADD_TO_CART
5512
+ -> CartInteraction listens ADD_TO_CART, triggers ITEM_ADDED
5513
+ \`\`\`
5514
+
5515
+ #### Wizard Completion
5516
+ A multi-step wizard emits completion, triggering a downstream action.
5517
+
5518
+ \`\`\`
5519
+ CheckoutInteraction emits ORDER_PLACED
5520
+ -> ConfirmationInteraction listens ORDER_PLACED, triggers INIT
5521
+ \`\`\`
5522
+
5523
+ ### Rules
5524
+ 1. Every \`emits\` must have a matching \`listens\` in another trait
5525
+ 2. Event names should be descriptive: ENTITY_ACTION (e.g., PRODUCT_CREATED, ORDER_PLACED)
5526
+ 3. The \`triggers\` field is a local event name in the listening trait's state machine
5527
+ 4. Multiple traits can listen to the same event
5528
+ 5. A trait can emit to multiple listeners`;
5529
+ }
5530
+
5531
+ // src/generators/behaviors.ts
5532
+ function generateBehaviorsSkill() {
5533
+ const frontmatter = {
5534
+ name: "behaviors",
5535
+ description: "Generate applications by selecting and composing behaviors from the standard library.",
5536
+ allowedTools: [
5537
+ "decompose_app",
5538
+ "match_behavior",
5539
+ "use_behavior",
5540
+ "connect_behaviors",
5541
+ "compose_behaviors",
5542
+ "verify_app",
5543
+ "finish_task"
5544
+ ],
5545
+ version: "1.0.0"
5546
+ };
5547
+ const content = `# Behaviors Composition Skill
5548
+ > Select and compose behaviors from the standard library.
5549
+
5550
+ ${getBehaviorCatalogSection()}
5551
+
5552
+ ---
5553
+
5554
+ ${getBehaviorCompositionGuide()}
5555
+
5556
+ ---
5557
+
5558
+ ${getBehaviorEventContractsSection()}
5559
+
5560
+ ---
5561
+
5562
+ ${getDomainBehaviorMapping()}
5563
+
5564
+ ---
5565
+
5566
+ ${getCrossOrbitalWiringGuide()}
5567
+
5568
+ ---
5569
+
5570
+ ## Detailed References
5571
+
5572
+ ${getBehaviorAtomReference()}
5573
+
5574
+ ---
5575
+
5576
+ ${getBehaviorMoleculeReference()}
5577
+
5578
+ ---
5579
+
5580
+ ${getBehaviorOrganismReference()}
5581
+ `;
5582
+ return {
5583
+ name: "behaviors",
5584
+ frontmatter,
5585
+ content
5586
+ };
5587
+ }
5588
+
4917
5589
  // src/orbitals-skills-generators/lean/lean-orbital-generator.ts
4918
5590
  var LEAN_CORE_INSTRUCTIONS = `
4919
5591
  ## Core Instructions
@@ -5511,7 +6183,8 @@ function generateAllBuilderSkills() {
5511
6183
  content: generateLeanFixingSkill2()
5512
6184
  },
5513
6185
  generateDomainLanguageSkill(),
5514
- generateAlmadarAssistantSkill()
6186
+ generateAlmadarAssistantSkill(),
6187
+ generateBehaviorsSkill()
5515
6188
  ];
5516
6189
  }
5517
6190
  function getMinimalTypeReference() {
@@ -6145,6 +6818,6 @@ function generateComparisonMatrix(comparisons) {
6145
6818
  return markdown;
6146
6819
  }
6147
6820
 
6148
- export { EVAL_CASES, analyzeComposition, calculateTotalScore, formatFrontmatter, generateAllBuilderSkills, generateAlmadarAssistantSkill, generateComparisonMatrix, generateDomainLanguageSkill, generateKflowOrbitalFixingSkill, generateKflowOrbitalsSkill, generateLeanFixingSkill2 as generateLeanFixingSkill, generateLeanFixingSkill as generateLeanFixingSkillFull, generateLeanOrbitalSkill2 as generateLeanOrbitalSkill, generateLeanOrbitalSkill as generateLeanOrbitalSkillFull, generateOrbSkill, 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, getOrbRenderUIGuide, getOrbitalConnectivitySection, getOrbitalDecompositionPrompt, getOverGenerationSection, getPatternTypesCompact, getPortableOrbitalOutputSection, getRenderUIDesignGuide, getRenderUIQuickRef2 as getRenderUIQuickRef, getRequirementsDecomposePrompt, getRequirementsTraitPrompt, getSExprQuickRef2 as getSExprQuickRef, getSchemaUpdateCompact, getSchemaUpdateSection, getSubagentSystemPrompt, getThemeGuide, getUsesImportCompact, getUsesImportSection, getValidationHintsSection, writeAllSkills, writeSkill };
6821
+ export { EVAL_CASES, analyzeComposition, calculateTotalScore, formatFrontmatter, generateAllBuilderSkills, generateAlmadarAssistantSkill, generateBehaviorsSkill, generateComparisonMatrix, generateConverterSkill, generateDomainLanguageSkill, generateKflowOrbitalFixingSkill, generateKflowOrbitalsSkill, generateLeanFixingSkill2 as generateLeanFixingSkill, generateLeanFixingSkill as generateLeanFixingSkillFull, generateLeanOrbitalSkill2 as generateLeanOrbitalSkill, generateLeanOrbitalSkill as generateLeanOrbitalSkillFull, generateOrbSkill, getArchitectureSection, getAssetRefSection, getBannedProps, getBehaviorAtomReference, getBehaviorCatalogSection, getBehaviorCompositionGuide, getBehaviorEventContractsSection, getBehaviorMoleculeReference, getBehaviorOrganismReference, getBindingContextRules, getBindingsCompact, getBindingsGuide, getCommonErrorsSection, getCommonFixPatternsSection, getCompletionRulesSection, getConnectivityCompact, getContextUsageCompact, getContextUsageSection, getCrossOrbitalWiringGuide, getCustomTraitCompact, getCustomTraitSection, getDecompositionChecklist, getDecompositionCompact, getDecompositionSection, getDesignErrorsCompact, getDesignErrorsSection, getDomainBehaviorMapping, getEfficiencySection, getFieldTypesCompact, getFixingWorkflowSection, getFlowPatternSection, getFullOrbitalPrompt, getGameAsOrbitalsSection, getGameEntityTemplatesSection, getGamePatternsSection, getGameTraitsSection, getGameTypesSection, getIconLibraryCompact, getIconLibrarySection, getKeyBehaviorsReference2 as getKeyBehaviorsReference, getMinimalTypeReference, getMultiFileSection, getOrbRenderUIGuide, getOrbRenderUIGuideFiltered, getOrbitalConnectivitySection, getOrbitalDecompositionPrompt, getOverGenerationSection, getPatternTypesCompact, getPortableOrbitalOutputSection, getRenderUIDesignGuide, getRenderUIQuickRef2 as getRenderUIQuickRef, getRequirementsDecomposePrompt, getRequirementsTraitPrompt, getSExprQuickRef2 as getSExprQuickRef, getSchemaUpdateCompact, getSchemaUpdateSection, getSubagentSystemPrompt, getThemeGuide, getUsesImportCompact, getUsesImportSection, getValidationHintsSection, writeAllSkills, writeSkill };
6149
6822
  //# sourceMappingURL=index.js.map
6150
6823
  //# sourceMappingURL=index.js.map