@specverse/engines 5.1.0 → 6.0.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.
Files changed (92) hide show
  1. package/assets/prompts/core/standard/default/analyse.prompt.yaml +5 -5
  2. package/assets/prompts/core/standard/default/app-demo.prompt.yaml +21 -1
  3. package/assets/prompts/core/standard/default/behavior.prompt.yaml +157 -0
  4. package/assets/prompts/core/standard/default/create.prompt.yaml +3 -3
  5. package/assets/prompts/core/standard/default/materialise.prompt.yaml +804 -774
  6. package/assets/prompts/core/standard/default/realize.prompt.yaml +581 -544
  7. package/assets/prompts/core/standard/v9/analyse.prompt.yaml +5 -5
  8. package/assets/prompts/core/standard/v9/app-demo.prompt.yaml +233 -0
  9. package/assets/prompts/core/standard/v9/behavior.prompt.yaml +70 -39
  10. package/assets/prompts/core/standard/v9/create.prompt.yaml +3 -3
  11. package/assets/prompts/core/standard/v9/materialise.prompt.yaml +804 -774
  12. package/assets/prompts/core/standard/v9/realize.prompt.yaml +581 -544
  13. package/dist/ai/behavior-ai-service.d.ts +35 -28
  14. package/dist/ai/behavior-ai-service.d.ts.map +1 -1
  15. package/dist/ai/behavior-ai-service.js +95 -128
  16. package/dist/ai/behavior-ai-service.js.map +1 -1
  17. package/dist/ai/index.d.ts +26 -26
  18. package/dist/ai/index.d.ts.map +1 -1
  19. package/dist/ai/index.js +40 -29
  20. package/dist/ai/index.js.map +1 -1
  21. package/dist/ai/model-resolver.d.ts +13 -0
  22. package/dist/ai/model-resolver.d.ts.map +1 -0
  23. package/dist/ai/model-resolver.js +87 -0
  24. package/dist/ai/model-resolver.js.map +1 -0
  25. package/dist/ai/providers/claude-cli.d.ts +25 -0
  26. package/dist/ai/providers/claude-cli.d.ts.map +1 -0
  27. package/dist/ai/providers/claude-cli.js +185 -0
  28. package/dist/ai/providers/claude-cli.js.map +1 -0
  29. package/dist/ai/providers/index.d.ts +8 -5
  30. package/dist/ai/providers/index.d.ts.map +1 -1
  31. package/dist/ai/providers/index.js +7 -5
  32. package/dist/ai/providers/index.js.map +1 -1
  33. package/dist/ai/providers/stub.d.ts +15 -0
  34. package/dist/ai/providers/stub.d.ts.map +1 -0
  35. package/dist/ai/providers/stub.js +64 -0
  36. package/dist/ai/providers/stub.js.map +1 -0
  37. package/dist/ai/skill-detection.d.ts +5 -0
  38. package/dist/ai/skill-detection.d.ts.map +1 -0
  39. package/dist/ai/skill-detection.js +27 -0
  40. package/dist/ai/skill-detection.js.map +1 -0
  41. package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +184 -0
  42. package/dist/libs/instance-factories/tools/templates/mcp/mcp-server-generator.js +289 -15
  43. package/libs/instance-factories/cli/templates/commander/command-generator.ts +184 -0
  44. package/libs/instance-factories/tools/templates/mcp/mcp-server-generator.ts +322 -16
  45. package/package.json +8 -3
  46. package/assets/prompts/core/CHANGELOG.md +0 -158
  47. package/assets/prompts/core/MIGRATION-v6-to-v7.md +0 -379
  48. package/assets/prompts/core/base-terminal-prompt.md +0 -201
  49. package/assets/prompts/core/examples/example-usage.ts +0 -140
  50. package/assets/prompts/core/schemas/prompt.schema.json +0 -309
  51. package/assets/prompts/core/schemas/prompt.schema.yaml +0 -229
  52. package/assets/prompts/core/standard/archive/v1/analyse.prompt.yaml +0 -259
  53. package/assets/prompts/core/standard/archive/v1/create.prompt.yaml +0 -302
  54. package/assets/prompts/core/standard/archive/v1/materialise.prompt.yaml +0 -328
  55. package/assets/prompts/core/standard/archive/v1/realize.prompt.yaml +0 -606
  56. package/assets/prompts/core/standard/archive/v2/README.md +0 -110
  57. package/assets/prompts/core/standard/archive/v2/analyse.prompt.yaml +0 -151
  58. package/assets/prompts/core/standard/archive/v2/create.prompt.yaml +0 -151
  59. package/assets/prompts/core/standard/archive/v2/materialise.prompt.yaml +0 -132
  60. package/assets/prompts/core/standard/archive/v2/realize.prompt.yaml +0 -147
  61. package/assets/prompts/core/standard/archive/v3/README.md +0 -279
  62. package/assets/prompts/core/standard/archive/v3/analyse.prompt.yaml +0 -309
  63. package/assets/prompts/core/standard/archive/v3/create.prompt.yaml +0 -351
  64. package/assets/prompts/core/standard/archive/v3/materialise.prompt.yaml +0 -247
  65. package/assets/prompts/core/standard/archive/v3/realize.prompt.yaml +0 -344
  66. package/assets/prompts/core/standard/archive/v4/README.md +0 -79
  67. package/assets/prompts/core/standard/archive/v4/analyse.prompt.yaml +0 -204
  68. package/assets/prompts/core/standard/archive/v4/create.prompt.yaml +0 -185
  69. package/assets/prompts/core/standard/archive/v5/README.md +0 -224
  70. package/assets/prompts/core/standard/archive/v5/analyse.prompt.yaml +0 -209
  71. package/assets/prompts/core/standard/archive/v5/create.prompt.yaml +0 -225
  72. package/assets/prompts/core/standard/archive/v5/materialise.prompt.yaml +0 -242
  73. package/assets/prompts/core/standard/archive/v5/realize.prompt.yaml +0 -336
  74. package/assets/prompts/core/standard/archive/v6/README.md +0 -187
  75. package/assets/prompts/core/standard/archive/v6/analyse.prompt.yaml +0 -219
  76. package/assets/prompts/core/standard/archive/v6/create.prompt.yaml +0 -180
  77. package/assets/prompts/core/standard/archive/v6/materialise.prompt.yaml +0 -203
  78. package/assets/prompts/core/standard/archive/v6/realize.prompt.yaml +0 -215
  79. package/assets/prompts/core/standard/archive/v7/analyse.prompt.nick.yaml +0 -144
  80. package/assets/prompts/core/standard/archive/v7/analyse.prompt.old.yaml +0 -146
  81. package/assets/prompts/core/standard/archive/v7/analyse.prompt.yaml +0 -129
  82. package/assets/prompts/core/standard/archive/v7/create.prompt.yaml +0 -146
  83. package/assets/prompts/core/standard/archive/v7/materialise.prompt.yaml +0 -297
  84. package/assets/prompts/core/standard/archive/v7/realize.prompt.yaml +0 -294
  85. package/assets/prompts/core/standard/archive/v8/README.md +0 -400
  86. package/assets/prompts/core/standard/archive/v8/analyse.prompt.yaml +0 -185
  87. package/assets/prompts/core/standard/archive/v8/create.prompt.yaml +0 -203
  88. package/assets/prompts/core/standard/archive/v8/materialise.prompt.yaml +0 -297
  89. package/assets/prompts/core/standard/archive/v8/realize.prompt.yaml +0 -294
  90. package/assets/prompts/templates/api-orchestrator-template.yaml +0 -188
  91. package/assets/prompts/templates/claude-integration-template.md +0 -121
  92. package/assets/prompts/templates/terminal-prompt-template.md +0 -97
@@ -16,7 +16,7 @@ system:
16
16
  Include ALL models, controllers, services, views, events found in the implementation.
17
17
  Extract ALL deployment policies, operational configurations, and infrastructure patterns from the code.
18
18
  This is NOT for inference - capture the implementation AS IT EXISTS.
19
- The specification must be valid according to SpecVerse schema v3.5.0 and should contain:
19
+ The specification must be valid according to SpecVerse schema v5.0.0 and should contain:
20
20
  - a components section with the logical models, controllers, services, views, events
21
21
  - a deployments section showing the logical instances with operational policies
22
22
  - a manifest section with the physical details about the deployment
@@ -32,9 +32,9 @@ system:
32
32
  2. Capture ALL lifecycles, attributes, methods, behaviours and relationships as they exist
33
33
  3. Use convention syntax for all attributes
34
34
  4. Business and validation logic must be captured as steps meeting the requires and ensures clauses
35
- 5. Actions that are implementing CURED operations must be captured as controller cured operations
35
+ 5. Actions that are implementing CURVED operations must be captured as controller cured operations (Create, Update, Retrieve, Validate, Evolve, Delete)
36
36
  6. AVOID LOGIC DUPLICATION: Place validation/business logic in model behaviors, not in controllers or services
37
- 7. Controllers should focus on CURED operations, models on business behaviors, services on orchestration
37
+ 7. Controllers should focus on CURVED operations, models on business behaviors, services on orchestration
38
38
  8. Do NOT include implementation details like HTTP paths or routes in controllers
39
39
 
40
40
  DEPLOYMENT PRINCIPLES:
@@ -375,7 +375,7 @@ user:
375
375
  WORKFLOW (iterate until validation passes):
376
376
 
377
377
  Step 1: ANALYZE & GENERATE
378
- - Read schema files for current v3.5.0 syntax:
378
+ - Read schema files for current v5.0.0 syntax:
379
379
  * {{aiSchemaPath}} (AI guidance, examples, patterns)
380
380
  * {{referenceExamplePath}} (complete working example)
381
381
  - Analyze implementation at {{implementationPath}}
@@ -452,7 +452,7 @@ validation:
452
452
  required: false
453
453
 
454
454
  output:
455
- - rule: Must generate valid SpecVerse v3.5.0 specification
455
+ - rule: Must generate valid SpecVerse v5.0.0 specification
456
456
  format: yaml
457
457
  schema: schema/SPECVERSE-SCHEMA.json
458
458
  - rule: Must include at least one model
@@ -200,10 +200,30 @@ system:
200
200
 
201
201
  user:
202
202
  template: |
203
- Generate or modify the specification based on the user's request.
203
+ Generate or modify the specification based on this request:
204
+
205
+ {{userRequest}}
206
+
207
+ {{#if existingSpec}}
208
+ Existing spec to modify (replace, don't add alongside):
209
+ ```specly
210
+ {{existingSpec}}
211
+ ```
212
+ {{/if}}
213
+
204
214
  Output the specification in a ```specly code block.
205
215
  Include whichever sections the user needs. If not specified, include all relevant sections.
206
216
 
217
+ variables:
218
+ - name: userRequest
219
+ type: string
220
+ required: true
221
+ description: The user's natural-language request describing what to create or modify in the spec
222
+ - name: existingSpec
223
+ type: string
224
+ required: false
225
+ description: An existing .specly file to modify. Leave empty to create a new spec from scratch.
226
+
207
227
  metadata:
208
228
  created: "2026-03-31"
209
229
  use_case: "Interactive runtime interpreter — specs execute immediately in browser"
@@ -0,0 +1,157 @@
1
+ name: behavior
2
+ version: "9.2.0"
3
+ description: Generate pure TypeScript function bodies for SpecVerse behavior steps that don't match convention patterns
4
+ author: SpecVerse Team
5
+ tags: [behavior, code-generation, pure-function, typescript, realize]
6
+
7
+ system:
8
+ role: |
9
+ You are a SpecVerse behavior code generator. You produce PURE TypeScript
10
+ function bodies for behavior steps that couldn't be matched by the realize
11
+ engine's convention patterns.
12
+
13
+ minimalContext: |
14
+ PURE FUNCTION RULES (critical — violating these breaks the architecture):
15
+ 1. NO database access (no prisma, no queries)
16
+ 2. NO event publishing (no eventBus)
17
+ 3. NO external services (no fetch, no email providers, no payment gateways)
18
+ 4. NO imports, no require, no fs, no process
19
+ 5. All data you need comes in via the `input` object parameter (already destructured — you have the fields directly)
20
+ 6. Return a plain result value (object, number, string) — the caller uses it
21
+
22
+ OUTPUT RULES:
23
+ 1. Output ONLY the function body code (between { and })
24
+ 2. First line: short comment summarising what the function does
25
+ 3. No markdown fences, no explanation before or after
26
+ 4. Throw Error('...') for failure cases with descriptive messages
27
+ 5. If a step fundamentally requires external side effects, throw an error indicating that — do not fake it
28
+
29
+ fullContext: |
30
+ # SpecVerse context (for LLMs that don't have the SpecVerse skill loaded)
31
+
32
+ SpecVerse is a declarative specification language. You describe WHAT a
33
+ system does in a .specly file, and the engines generate HOW — backend
34
+ (Fastify/Prisma), frontend (React/Tailwind), CLI, tools, diagrams. The
35
+ behavior-generation step you're being asked to perform plugs a
36
+ specific gap: the realize engine matches most spec behavior steps
37
+ against convention patterns ("Find {Model}", "Set {field}",
38
+ "Send {event}") and emits them directly; for the rest, you fill in
39
+ the pure-function body.
40
+
41
+ Where your function fits:
42
+
43
+ ```
44
+ // Controller (convention-generated code — NOT your job)
45
+ const order = await prisma.order.findUniqueOrThrow(...);
46
+ const customer = await prisma.customer.findUniqueOrThrow(...);
47
+
48
+ // Your function — PURE calculation or transformation
49
+ const discount = await applyDiscountBasedOnLoyaltyTier({ order, customer });
50
+ // discount = { amount: 42, rate: 0.10 }
51
+
52
+ // Controller (convention-generated code — NOT your job)
53
+ await prisma.order.update({ where: { id }, data: { total: order.total - discount.amount } });
54
+ await eventBus.publish('OrderDiscounted', { orderId, discount });
55
+ ```
56
+
57
+ Convention patterns ALREADY auto-generated (don't re-implement these):
58
+ - "Find {Model} by {field}", "Create {Model}", "Update {Model}..."
59
+ - "Delete {Model}", "Transition {Model} to {state}"
60
+ - "Set/Increment/Decrement {field}", "Send {event} event"
61
+
62
+ You handle: domain-specific calculations, transformations, rules,
63
+ scoring, categorisation, validation logic. Anything where the behavior
64
+ step text doesn't match a convention pattern.
65
+
66
+ SpecVerse uses CURVED operations (Create, Update, Retrieve, Validate,
67
+ Evolve, Delete) on controllers. Validate is dry-run; Evolve handles
68
+ lifecycle state transitions. Models declare attributes, relationships,
69
+ and lifecycles. Full reference lives in the SpecVerse canonical guide
70
+ (`specverse://guide` resource, or `~/.claude/skills/specverse/reference/guide.md`
71
+ if the skill is installed).
72
+
73
+ examples:
74
+ - step: "Apply discount based on loyalty tier"
75
+ input_fields: "order, customer"
76
+ output: |
77
+ // Calculate discount rate from customer's loyalty tier and apply to order total
78
+ const tierDiscounts: Record<string, number> = {
79
+ platinum: 0.20, gold: 0.15, silver: 0.10, bronze: 0.05
80
+ };
81
+ const tier = (customer as any).loyaltyTier || 'none';
82
+ const rate = tierDiscounts[tier] || 0;
83
+ const amount = Math.round((order as any).total * rate * 100) / 100;
84
+ return { tier, rate, amount, newTotal: (order as any).total - amount };
85
+
86
+ - step: "Calculate shipping cost for destination"
87
+ input_fields: "order, destination"
88
+ output: |
89
+ // Calculate shipping cost based on destination zone and order weight
90
+ const zones: Record<string, number> = { local: 5, regional: 10, national: 15, international: 40 };
91
+ const zone = (destination as any).zone || 'national';
92
+ const weightKg = (order as any).totalWeightKg || 1;
93
+ const baseRate = zones[zone] || 15;
94
+ const cost = baseRate + (weightKg * 2);
95
+ return { zone, baseRate, weightKg, cost };
96
+
97
+ user:
98
+ template: |
99
+ Generate a PURE TypeScript function body for this SpecVerse behavior step.
100
+
101
+ Step: "{{step}}"
102
+
103
+ Context:
104
+ - Model: {{modelName}}
105
+ - Controller operation: {{modelName}}Controller.{{operationName}}()
106
+ - Function name: {{functionName}}
107
+ - Available Prisma models (for type reference only): {{availableModels}}
108
+
109
+ The function signature is already generated as:
110
+ async function {{functionName}}(input: {{inputSignature}}): Promise<{{returnType}}>
111
+
112
+ Inside the function, `input` is already destructured. You have access to
113
+ these variables directly: {{inputVars}}
114
+
115
+ The function MUST return {{returnType}}. If that's `any`, return a
116
+ reasonable result object describing what was computed. If it's a specific
117
+ type (e.g., "{ cost: number; days: number }"), return an object matching
118
+ that shape exactly — the caller depends on those field names.
119
+
120
+ Output ONLY the function body (the code that goes between { and }).
121
+ The destructure is already done — just write the logic.
122
+
123
+ Remember: PURE function, no prisma, no eventBus, no external calls.
124
+
125
+ variables:
126
+ - name: step
127
+ type: string
128
+ required: true
129
+ description: The behavior step text from the spec (e.g. "Apply discount based on loyalty tier")
130
+ - name: modelName
131
+ type: string
132
+ required: true
133
+ description: Name of the model the behavior belongs to (e.g. "Order")
134
+ - name: operationName
135
+ type: string
136
+ required: true
137
+ description: Name of the controller operation invoking the behavior (e.g. "checkout")
138
+ - name: functionName
139
+ type: string
140
+ required: true
141
+ description: Generated function name for the behavior body (e.g. "applyLoyaltyDiscount")
142
+ - name: inputSignature
143
+ type: string
144
+ required: true
145
+ description: 'TypeScript type expression for the destructured input (e.g. "{ order: Order; customer: Customer }")'
146
+ - name: inputVars
147
+ type: string
148
+ required: true
149
+ description: Comma-separated list of already-destructured input variable names (e.g. "order, customer")
150
+ - name: returnType
151
+ type: string
152
+ required: true
153
+ description: 'TypeScript return type of the function body (e.g. "{ tier: string; rate: number; amount: number }" or "any")'
154
+ - name: availableModels
155
+ type: string
156
+ required: true
157
+ description: Comma-separated list of Prisma models the behavior can reference (types only, no I/O)
@@ -303,10 +303,10 @@ user:
303
303
  WORKFLOW (iterate until validation passes):
304
304
 
305
305
  Step 1: GENERATE
306
- - Read schema files for current v3.5.0 syntax:
306
+ - Read schema files for current v5.0.0 syntax:
307
307
  * {{aiSchemaPath}} (AI guidance, examples, patterns)
308
308
  * {{referenceSchemaPath}} (complete working example)
309
- - Generate minimal spec using v3.5.0 format
309
+ - Generate minimal spec using v5.0.0 format
310
310
  - Use components: (plural) at top level
311
311
  - Use snake_case for lifecycle states (NOT kebab-case)
312
312
  - Add deployment policies appropriate for scale
@@ -376,7 +376,7 @@ validation:
376
376
  required: false
377
377
 
378
378
  output:
379
- - rule: Must generate valid SpecVerse v3.5.0 specification
379
+ - rule: Must generate valid SpecVerse v5.0.0 specification
380
380
  format: yaml
381
381
  schema: schema/SPECVERSE-SCHEMA.json
382
382
  - rule: Must include at least one model