@specverse/engines 5.1.0 → 5.2.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/assets/prompts/core/standard/default/analyse.prompt.yaml +5 -5
- package/assets/prompts/core/standard/default/app-demo.prompt.yaml +21 -1
- package/assets/prompts/core/standard/default/behavior.prompt.yaml +150 -0
- package/assets/prompts/core/standard/default/create.prompt.yaml +3 -3
- package/assets/prompts/core/standard/default/materialise.prompt.yaml +804 -774
- package/assets/prompts/core/standard/default/realize.prompt.yaml +581 -544
- package/assets/prompts/core/standard/v9/analyse.prompt.yaml +5 -5
- package/assets/prompts/core/standard/v9/app-demo.prompt.yaml +233 -0
- package/assets/prompts/core/standard/v9/behavior.prompt.yaml +33 -9
- package/assets/prompts/core/standard/v9/create.prompt.yaml +3 -3
- package/assets/prompts/core/standard/v9/materialise.prompt.yaml +804 -774
- package/assets/prompts/core/standard/v9/realize.prompt.yaml +581 -544
- package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +184 -0
- package/dist/libs/instance-factories/tools/templates/mcp/mcp-server-generator.js +289 -15
- package/libs/instance-factories/cli/templates/commander/command-generator.ts +184 -0
- package/libs/instance-factories/tools/templates/mcp/mcp-server-generator.ts +322 -16
- package/package.json +1 -1
- package/assets/prompts/core/CHANGELOG.md +0 -158
- package/assets/prompts/core/MIGRATION-v6-to-v7.md +0 -379
- package/assets/prompts/core/base-terminal-prompt.md +0 -201
- package/assets/prompts/core/examples/example-usage.ts +0 -140
- package/assets/prompts/core/schemas/prompt.schema.json +0 -309
- package/assets/prompts/core/schemas/prompt.schema.yaml +0 -229
- package/assets/prompts/core/standard/archive/v1/analyse.prompt.yaml +0 -259
- package/assets/prompts/core/standard/archive/v1/create.prompt.yaml +0 -302
- package/assets/prompts/core/standard/archive/v1/materialise.prompt.yaml +0 -328
- package/assets/prompts/core/standard/archive/v1/realize.prompt.yaml +0 -606
- package/assets/prompts/core/standard/archive/v2/README.md +0 -110
- package/assets/prompts/core/standard/archive/v2/analyse.prompt.yaml +0 -151
- package/assets/prompts/core/standard/archive/v2/create.prompt.yaml +0 -151
- package/assets/prompts/core/standard/archive/v2/materialise.prompt.yaml +0 -132
- package/assets/prompts/core/standard/archive/v2/realize.prompt.yaml +0 -147
- package/assets/prompts/core/standard/archive/v3/README.md +0 -279
- package/assets/prompts/core/standard/archive/v3/analyse.prompt.yaml +0 -309
- package/assets/prompts/core/standard/archive/v3/create.prompt.yaml +0 -351
- package/assets/prompts/core/standard/archive/v3/materialise.prompt.yaml +0 -247
- package/assets/prompts/core/standard/archive/v3/realize.prompt.yaml +0 -344
- package/assets/prompts/core/standard/archive/v4/README.md +0 -79
- package/assets/prompts/core/standard/archive/v4/analyse.prompt.yaml +0 -204
- package/assets/prompts/core/standard/archive/v4/create.prompt.yaml +0 -185
- package/assets/prompts/core/standard/archive/v5/README.md +0 -224
- package/assets/prompts/core/standard/archive/v5/analyse.prompt.yaml +0 -209
- package/assets/prompts/core/standard/archive/v5/create.prompt.yaml +0 -225
- package/assets/prompts/core/standard/archive/v5/materialise.prompt.yaml +0 -242
- package/assets/prompts/core/standard/archive/v5/realize.prompt.yaml +0 -336
- package/assets/prompts/core/standard/archive/v6/README.md +0 -187
- package/assets/prompts/core/standard/archive/v6/analyse.prompt.yaml +0 -219
- package/assets/prompts/core/standard/archive/v6/create.prompt.yaml +0 -180
- package/assets/prompts/core/standard/archive/v6/materialise.prompt.yaml +0 -203
- package/assets/prompts/core/standard/archive/v6/realize.prompt.yaml +0 -215
- package/assets/prompts/core/standard/archive/v7/analyse.prompt.nick.yaml +0 -144
- package/assets/prompts/core/standard/archive/v7/analyse.prompt.old.yaml +0 -146
- package/assets/prompts/core/standard/archive/v7/analyse.prompt.yaml +0 -129
- package/assets/prompts/core/standard/archive/v7/create.prompt.yaml +0 -146
- package/assets/prompts/core/standard/archive/v7/materialise.prompt.yaml +0 -297
- package/assets/prompts/core/standard/archive/v7/realize.prompt.yaml +0 -294
- package/assets/prompts/core/standard/archive/v8/README.md +0 -400
- package/assets/prompts/core/standard/archive/v8/analyse.prompt.yaml +0 -185
- package/assets/prompts/core/standard/archive/v8/create.prompt.yaml +0 -203
- package/assets/prompts/core/standard/archive/v8/materialise.prompt.yaml +0 -297
- package/assets/prompts/core/standard/archive/v8/realize.prompt.yaml +0 -294
- package/assets/prompts/templates/api-orchestrator-template.yaml +0 -188
- package/assets/prompts/templates/claude-integration-template.md +0 -121
- package/assets/prompts/templates/terminal-prompt-template.md +0 -97
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
name: create
|
|
2
|
-
version: "1.0.0"
|
|
3
|
-
description: Generate minimal SpecVerse specifications from natural language requirements
|
|
4
|
-
author: SpecVerse Team
|
|
5
|
-
tags: [creation, requirements, minimal-spec]
|
|
6
|
-
|
|
7
|
-
system:
|
|
8
|
-
role: |
|
|
9
|
-
You are a SpecVerse specification creator that generates MINIMAL specifications from requirements.
|
|
10
|
-
You analyze user requirements and create the smallest possible valid specification that captures the core business logic.
|
|
11
|
-
The SpecVerse inference engine will later expand these minimal specs into complete architectures.
|
|
12
|
-
|
|
13
|
-
context: |
|
|
14
|
-
Your task is to:
|
|
15
|
-
1. Analyze natural language requirements
|
|
16
|
-
2. Extract core business entities and their relationships
|
|
17
|
-
3. Generate a minimal SpecVerse specification with only essential attributes
|
|
18
|
-
4. Let the inference engine handle controllers, services, events, and views later
|
|
19
|
-
|
|
20
|
-
Focus on business logic, not technical implementation details.
|
|
21
|
-
Start with the absolute minimum needed to represent the domain.
|
|
22
|
-
|
|
23
|
-
capabilities:
|
|
24
|
-
- Parse natural language requirements
|
|
25
|
-
- Identify business entities and relationships
|
|
26
|
-
- Determine essential attributes only
|
|
27
|
-
- Apply SpecVerse convention syntax
|
|
28
|
-
- Select appropriate scale (personal/business/enterprise)
|
|
29
|
-
- Generate clean, minimal specifications
|
|
30
|
-
|
|
31
|
-
constraints:
|
|
32
|
-
- Include ONLY explicitly mentioned features
|
|
33
|
-
- Do NOT add technical implementation details
|
|
34
|
-
- Do NOT generate controllers, services, or events (inference will handle these)
|
|
35
|
-
- Keep specifications as minimal as possible
|
|
36
|
-
- Use convention syntax for all attributes
|
|
37
|
-
- Focus on business domain, not technology
|
|
38
|
-
|
|
39
|
-
user:
|
|
40
|
-
template: |
|
|
41
|
-
Generate a minimal SpecVerse specification from these requirements:
|
|
42
|
-
|
|
43
|
-
Requirements:
|
|
44
|
-
{{requirements}}
|
|
45
|
-
|
|
46
|
-
Project Scale: {{scale}}
|
|
47
|
-
Preferred Technology: {{preferredTech}}
|
|
48
|
-
|
|
49
|
-
Guidelines:
|
|
50
|
-
1. Extract only the core business entities mentioned
|
|
51
|
-
2. Include only essential attributes that are explicitly stated
|
|
52
|
-
3. Define relationships between entities
|
|
53
|
-
4. Use SpecVerse convention syntax: attributeName: TypeName modifiers
|
|
54
|
-
5. Let the inference engine expand this later
|
|
55
|
-
|
|
56
|
-
Common types to use:
|
|
57
|
-
- String, Integer, Decimal, Boolean
|
|
58
|
-
- UUID (for identifiers)
|
|
59
|
-
- Email, URL, Phone (for contact info)
|
|
60
|
-
- Date, DateTime, Time (for temporal data)
|
|
61
|
-
- Money (for financial amounts)
|
|
62
|
-
|
|
63
|
-
Common modifiers:
|
|
64
|
-
- required / optional
|
|
65
|
-
- unique
|
|
66
|
-
- searchable
|
|
67
|
-
- default=value
|
|
68
|
-
- min=n / max=n
|
|
69
|
-
|
|
70
|
-
Generate a minimal component specification that captures ONLY what was explicitly requested.
|
|
71
|
-
|
|
72
|
-
variables:
|
|
73
|
-
- name: requirements
|
|
74
|
-
type: string
|
|
75
|
-
required: true
|
|
76
|
-
description: Natural language description of the application requirements
|
|
77
|
-
|
|
78
|
-
- name: scale
|
|
79
|
-
type: string
|
|
80
|
-
required: false
|
|
81
|
-
default: "business"
|
|
82
|
-
description: Project scale (personal, business, enterprise)
|
|
83
|
-
validation: "^(personal|business|enterprise)$"
|
|
84
|
-
|
|
85
|
-
- name: preferredTech
|
|
86
|
-
type: string
|
|
87
|
-
required: false
|
|
88
|
-
default: "auto"
|
|
89
|
-
description: Preferred technology stack
|
|
90
|
-
|
|
91
|
-
context:
|
|
92
|
-
includes:
|
|
93
|
-
- schema: schema/SPECVERSE-V3.1-SCHEMA-AI.yaml
|
|
94
|
-
- template: "{{scale}}"
|
|
95
|
-
max_tokens: 2000
|
|
96
|
-
temperature: 0.5
|
|
97
|
-
top_p: 0.9
|
|
98
|
-
|
|
99
|
-
validation:
|
|
100
|
-
input:
|
|
101
|
-
- rule: Requirements must be provided
|
|
102
|
-
required: true
|
|
103
|
-
- rule: Requirements should be between 10 and 5000 characters
|
|
104
|
-
required: false
|
|
105
|
-
|
|
106
|
-
output:
|
|
107
|
-
- rule: Must generate valid SpecVerse v3.1 specification
|
|
108
|
-
format: yaml
|
|
109
|
-
schema: schema/SPECVERSE-SCHEMA.json
|
|
110
|
-
- rule: Must include at least one model
|
|
111
|
-
format: yaml
|
|
112
|
-
- rule: Should be minimal (typically under 100 lines)
|
|
113
|
-
format: yaml
|
|
114
|
-
|
|
115
|
-
examples:
|
|
116
|
-
- name: Task Management System
|
|
117
|
-
description: Creating minimal spec for a task management application
|
|
118
|
-
input:
|
|
119
|
-
requirements: |
|
|
120
|
-
Build a task management system where users can create projects and add tasks to them.
|
|
121
|
-
Tasks should have a title, description, due date, and status (todo, in progress, done).
|
|
122
|
-
Users should be able to assign tasks to team members.
|
|
123
|
-
scale: business
|
|
124
|
-
preferredTech: auto
|
|
125
|
-
|
|
126
|
-
output: |
|
|
127
|
-
components:
|
|
128
|
-
TaskManagement:
|
|
129
|
-
version: "1.0.0"
|
|
130
|
-
description: "Task management system"
|
|
131
|
-
|
|
132
|
-
models:
|
|
133
|
-
Project:
|
|
134
|
-
description: "Container for related tasks"
|
|
135
|
-
attributes:
|
|
136
|
-
name: String required
|
|
137
|
-
description: String optional
|
|
138
|
-
relationships:
|
|
139
|
-
tasks: hasMany Task cascade
|
|
140
|
-
|
|
141
|
-
Task:
|
|
142
|
-
description: "Individual work item"
|
|
143
|
-
attributes:
|
|
144
|
-
title: String required
|
|
145
|
-
description: String optional
|
|
146
|
-
dueDate: Date optional
|
|
147
|
-
status: String required default=todo values=["todo","in_progress","done"]
|
|
148
|
-
relationships:
|
|
149
|
-
project: belongsTo Project required
|
|
150
|
-
assignee: belongsTo User optional
|
|
151
|
-
|
|
152
|
-
User:
|
|
153
|
-
description: "System user"
|
|
154
|
-
attributes:
|
|
155
|
-
email: Email required unique
|
|
156
|
-
name: String required
|
|
157
|
-
relationships:
|
|
158
|
-
assignedTasks: hasMany Task
|
|
159
|
-
|
|
160
|
-
explanation: |
|
|
161
|
-
This minimal specification captures only what was explicitly mentioned:
|
|
162
|
-
- Three core entities: Project, Task, User
|
|
163
|
-
- Essential attributes for each
|
|
164
|
-
- Clear relationships between entities
|
|
165
|
-
- No controllers, services, or events (inference will add these)
|
|
166
|
-
|
|
167
|
-
- name: E-commerce Platform
|
|
168
|
-
description: Creating minimal spec for an online store
|
|
169
|
-
input:
|
|
170
|
-
requirements: |
|
|
171
|
-
Create an e-commerce platform where customers can browse products by category,
|
|
172
|
-
add items to a shopping cart, and place orders. Products have name, price,
|
|
173
|
-
description, and inventory count. Orders should track shipping address and payment status.
|
|
174
|
-
scale: business
|
|
175
|
-
preferredTech: auto
|
|
176
|
-
|
|
177
|
-
output: |
|
|
178
|
-
components:
|
|
179
|
-
EcommercePlatform:
|
|
180
|
-
version: "1.0.0"
|
|
181
|
-
description: "E-commerce platform"
|
|
182
|
-
|
|
183
|
-
models:
|
|
184
|
-
Product:
|
|
185
|
-
description: "Sellable item"
|
|
186
|
-
attributes:
|
|
187
|
-
name: String required searchable
|
|
188
|
-
price: Money required
|
|
189
|
-
description: String optional
|
|
190
|
-
inventoryCount: Integer required default=0 min=0
|
|
191
|
-
relationships:
|
|
192
|
-
category: belongsTo Category required
|
|
193
|
-
cartItems: hasMany CartItem
|
|
194
|
-
|
|
195
|
-
Category:
|
|
196
|
-
description: "Product grouping"
|
|
197
|
-
attributes:
|
|
198
|
-
name: String required unique
|
|
199
|
-
relationships:
|
|
200
|
-
products: hasMany Product
|
|
201
|
-
|
|
202
|
-
Cart:
|
|
203
|
-
description: "Shopping cart"
|
|
204
|
-
attributes:
|
|
205
|
-
status: String required default=active
|
|
206
|
-
relationships:
|
|
207
|
-
customer: belongsTo Customer required
|
|
208
|
-
items: hasMany CartItem cascade
|
|
209
|
-
|
|
210
|
-
CartItem:
|
|
211
|
-
description: "Product in cart"
|
|
212
|
-
attributes:
|
|
213
|
-
quantity: Integer required min=1
|
|
214
|
-
relationships:
|
|
215
|
-
cart: belongsTo Cart required
|
|
216
|
-
product: belongsTo Product required
|
|
217
|
-
|
|
218
|
-
Order:
|
|
219
|
-
description: "Customer order"
|
|
220
|
-
attributes:
|
|
221
|
-
shippingAddress: String required
|
|
222
|
-
paymentStatus: String required default=pending values=["pending","paid","failed"]
|
|
223
|
-
relationships:
|
|
224
|
-
customer: belongsTo Customer required
|
|
225
|
-
items: hasMany OrderItem cascade
|
|
226
|
-
|
|
227
|
-
OrderItem:
|
|
228
|
-
description: "Product in order"
|
|
229
|
-
attributes:
|
|
230
|
-
quantity: Integer required min=1
|
|
231
|
-
priceAtPurchase: Money required
|
|
232
|
-
relationships:
|
|
233
|
-
order: belongsTo Order required
|
|
234
|
-
product: belongsTo Product required
|
|
235
|
-
|
|
236
|
-
Customer:
|
|
237
|
-
description: "Platform customer"
|
|
238
|
-
attributes:
|
|
239
|
-
email: Email required unique
|
|
240
|
-
relationships:
|
|
241
|
-
cart: hasOne Cart
|
|
242
|
-
orders: hasMany Order
|
|
243
|
-
|
|
244
|
-
explanation: |
|
|
245
|
-
Minimal specification includes:
|
|
246
|
-
- Core e-commerce entities only
|
|
247
|
-
- Essential attributes from requirements
|
|
248
|
-
- Proper relationships for cart and order flow
|
|
249
|
-
- No payment processing or shipping logic (inference will expand)
|
|
250
|
-
|
|
251
|
-
- name: Personal Blog
|
|
252
|
-
description: Creating minimal spec for a personal blog
|
|
253
|
-
input:
|
|
254
|
-
requirements: |
|
|
255
|
-
I want a simple blog where I can write posts with title and content.
|
|
256
|
-
Posts should support tags for organization.
|
|
257
|
-
scale: personal
|
|
258
|
-
preferredTech: auto
|
|
259
|
-
|
|
260
|
-
output: |
|
|
261
|
-
components:
|
|
262
|
-
PersonalBlog:
|
|
263
|
-
version: "1.0.0"
|
|
264
|
-
description: "Personal blog system"
|
|
265
|
-
|
|
266
|
-
models:
|
|
267
|
-
Post:
|
|
268
|
-
description: "Blog post"
|
|
269
|
-
attributes:
|
|
270
|
-
title: String required
|
|
271
|
-
content: String required
|
|
272
|
-
publishedAt: DateTime optional
|
|
273
|
-
relationships:
|
|
274
|
-
tags: manyToMany Tag
|
|
275
|
-
|
|
276
|
-
Tag:
|
|
277
|
-
description: "Post categorization"
|
|
278
|
-
attributes:
|
|
279
|
-
name: String required unique
|
|
280
|
-
relationships:
|
|
281
|
-
posts: manyToMany Post
|
|
282
|
-
|
|
283
|
-
explanation: |
|
|
284
|
-
Very minimal specification for personal use:
|
|
285
|
-
- Only two models as mentioned
|
|
286
|
-
- Basic attributes only
|
|
287
|
-
- Many-to-many relationship for tags
|
|
288
|
-
- No user model (personal blog doesn't need it)
|
|
289
|
-
|
|
290
|
-
metadata:
|
|
291
|
-
created: "2024-01-01T00:00:00Z"
|
|
292
|
-
updated: "2024-01-01T00:00:00Z"
|
|
293
|
-
tested_with:
|
|
294
|
-
- provider: openai
|
|
295
|
-
model: gpt-4
|
|
296
|
-
success_rate: 94
|
|
297
|
-
- provider: anthropic
|
|
298
|
-
model: claude-3-opus
|
|
299
|
-
success_rate: 96
|
|
300
|
-
performance:
|
|
301
|
-
avg_response_time: 3.2
|
|
302
|
-
avg_tokens_used: 1200
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
name: materialise
|
|
2
|
-
version: "1.0.0"
|
|
3
|
-
description: Generate clean implementation from extracted specifications for comparison with existing code
|
|
4
|
-
author: SpecVerse Team
|
|
5
|
-
tags: [materialise, comparison, clean-implementation]
|
|
6
|
-
|
|
7
|
-
system:
|
|
8
|
-
role: |
|
|
9
|
-
You generate a complete NEW implementation from extracted specifications.
|
|
10
|
-
This is NOT about updating existing code - you create a fresh, clean implementation
|
|
11
|
-
that can be compared with the original codebase for migration planning.
|
|
12
|
-
|
|
13
|
-
context: |
|
|
14
|
-
Your purpose is to create a "clean room" implementation from specifications that were
|
|
15
|
-
extracted from an existing application. This clean implementation will be used to:
|
|
16
|
-
1. Compare with the original code to identify differences
|
|
17
|
-
2. Generate migration recommendations
|
|
18
|
-
3. Highlight inconsistencies or technical debt
|
|
19
|
-
4. Plan refactoring strategies
|
|
20
|
-
|
|
21
|
-
Generate production-quality code that follows best practices for the detected framework.
|
|
22
|
-
|
|
23
|
-
capabilities:
|
|
24
|
-
- Generate complete application implementations
|
|
25
|
-
- Follow framework-specific best practices
|
|
26
|
-
- Implement all models, controllers, and services from specs
|
|
27
|
-
- Generate database schemas and migrations
|
|
28
|
-
- Create proper API endpoints
|
|
29
|
-
- Add appropriate error handling
|
|
30
|
-
- Generate clean, maintainable code
|
|
31
|
-
|
|
32
|
-
constraints:
|
|
33
|
-
- Generate NEW code, not modifications to existing code
|
|
34
|
-
- Follow the technology patterns from the manifest
|
|
35
|
-
- Implement ALL specifications completely
|
|
36
|
-
- Use modern best practices
|
|
37
|
-
- Include proper error handling and validation
|
|
38
|
-
- Generate working, compilable code
|
|
39
|
-
|
|
40
|
-
user:
|
|
41
|
-
template: |
|
|
42
|
-
Generate a clean implementation from these extracted specifications:
|
|
43
|
-
|
|
44
|
-
Component Specification:
|
|
45
|
-
{{componentSpec}}
|
|
46
|
-
|
|
47
|
-
Deployment Specification:
|
|
48
|
-
{{deploymentSpec}}
|
|
49
|
-
|
|
50
|
-
Implementation Manifest:
|
|
51
|
-
{{manifest}}
|
|
52
|
-
|
|
53
|
-
Original Application Path: {{originalPath}}
|
|
54
|
-
|
|
55
|
-
Generate a complete, clean implementation that:
|
|
56
|
-
1. Implements all models with proper attributes and relationships
|
|
57
|
-
2. Creates all controllers with the specified actions
|
|
58
|
-
3. Implements all services with business logic
|
|
59
|
-
4. Includes database schema/migrations
|
|
60
|
-
5. Follows the framework patterns from the manifest
|
|
61
|
-
6. Uses modern best practices
|
|
62
|
-
7. Is ready to run and test
|
|
63
|
-
|
|
64
|
-
Output the complete file structure and contents for the clean implementation.
|
|
65
|
-
Include a comparison report highlighting key differences from the original.
|
|
66
|
-
|
|
67
|
-
variables:
|
|
68
|
-
- name: componentSpec
|
|
69
|
-
type: string
|
|
70
|
-
required: true
|
|
71
|
-
description: SpecVerse component specification in YAML format
|
|
72
|
-
|
|
73
|
-
- name: deploymentSpec
|
|
74
|
-
type: string
|
|
75
|
-
required: false
|
|
76
|
-
description: SpecVerse deployment specification in YAML format
|
|
77
|
-
|
|
78
|
-
- name: manifest
|
|
79
|
-
type: string
|
|
80
|
-
required: true
|
|
81
|
-
description: Implementation manifest describing technology stack
|
|
82
|
-
|
|
83
|
-
- name: originalPath
|
|
84
|
-
type: string
|
|
85
|
-
required: true
|
|
86
|
-
description: Path to the original application for reference
|
|
87
|
-
|
|
88
|
-
context:
|
|
89
|
-
includes:
|
|
90
|
-
- schema: schema/SPECVERSE-V3.1-SCHEMA-AI.yaml
|
|
91
|
-
- library: framework-implementations
|
|
92
|
-
- template: clean-room-patterns
|
|
93
|
-
max_tokens: 12000
|
|
94
|
-
temperature: 0.2
|
|
95
|
-
top_p: 0.9
|
|
96
|
-
|
|
97
|
-
validation:
|
|
98
|
-
input:
|
|
99
|
-
- rule: Component specification must be provided
|
|
100
|
-
required: true
|
|
101
|
-
- rule: Implementation manifest must be provided
|
|
102
|
-
required: true
|
|
103
|
-
- rule: Specifications must be valid YAML
|
|
104
|
-
required: true
|
|
105
|
-
|
|
106
|
-
output:
|
|
107
|
-
- rule: Must generate complete working implementation
|
|
108
|
-
format: text
|
|
109
|
-
- rule: All models from spec must be implemented
|
|
110
|
-
format: text
|
|
111
|
-
- rule: All controllers from spec must be implemented
|
|
112
|
-
format: text
|
|
113
|
-
- rule: Must include comparison report
|
|
114
|
-
format: markdown
|
|
115
|
-
|
|
116
|
-
examples:
|
|
117
|
-
- name: Next.js Application Materialisation
|
|
118
|
-
description: Generate clean Next.js implementation from extracted specs
|
|
119
|
-
input:
|
|
120
|
-
componentSpec: |
|
|
121
|
-
components:
|
|
122
|
-
UserManagement:
|
|
123
|
-
version: "1.0.0"
|
|
124
|
-
models:
|
|
125
|
-
User:
|
|
126
|
-
attributes:
|
|
127
|
-
id: String required unique auto=cuid
|
|
128
|
-
email: Email required unique
|
|
129
|
-
name: String optional
|
|
130
|
-
relationships:
|
|
131
|
-
posts: hasMany Post cascade
|
|
132
|
-
Post:
|
|
133
|
-
attributes:
|
|
134
|
-
id: String required unique auto=cuid
|
|
135
|
-
title: String required
|
|
136
|
-
content: String optional
|
|
137
|
-
relationships:
|
|
138
|
-
author: belongsTo User required
|
|
139
|
-
controllers:
|
|
140
|
-
UserController:
|
|
141
|
-
model: User
|
|
142
|
-
actions:
|
|
143
|
-
getUsers:
|
|
144
|
-
returns: User[]
|
|
145
|
-
createUser:
|
|
146
|
-
parameters:
|
|
147
|
-
email: Email required
|
|
148
|
-
name: String optional
|
|
149
|
-
returns: User
|
|
150
|
-
manifest: |
|
|
151
|
-
technology:
|
|
152
|
-
framework: "nextjs"
|
|
153
|
-
version: "14.0.0"
|
|
154
|
-
language: "typescript"
|
|
155
|
-
database:
|
|
156
|
-
orm: "prisma"
|
|
157
|
-
provider: "postgresql"
|
|
158
|
-
api:
|
|
159
|
-
type: "rest"
|
|
160
|
-
pattern: "app-router"
|
|
161
|
-
originalPath: "/apps/legacy-user-app"
|
|
162
|
-
|
|
163
|
-
output: |
|
|
164
|
-
## Clean Implementation Structure
|
|
165
|
-
|
|
166
|
-
```
|
|
167
|
-
clean-user-management/
|
|
168
|
-
├── app/
|
|
169
|
-
│ ├── api/
|
|
170
|
-
│ │ └── users/
|
|
171
|
-
│ │ └── route.ts
|
|
172
|
-
│ └── layout.tsx
|
|
173
|
-
├── prisma/
|
|
174
|
-
│ ├── schema.prisma
|
|
175
|
-
│ └── migrations/
|
|
176
|
-
├── lib/
|
|
177
|
-
│ └── prisma.ts
|
|
178
|
-
└── package.json
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### File Contents
|
|
182
|
-
|
|
183
|
-
**prisma/schema.prisma**
|
|
184
|
-
```prisma
|
|
185
|
-
generator client {
|
|
186
|
-
provider = "prisma-client-js"
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
datasource db {
|
|
190
|
-
provider = "postgresql"
|
|
191
|
-
url = env("DATABASE_URL")
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
model User {
|
|
195
|
-
id String @id @default(cuid())
|
|
196
|
-
email String @unique
|
|
197
|
-
name String?
|
|
198
|
-
posts Post[]
|
|
199
|
-
createdAt DateTime @default(now())
|
|
200
|
-
updatedAt DateTime @updatedAt
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
model Post {
|
|
204
|
-
id String @id @default(cuid())
|
|
205
|
-
title String
|
|
206
|
-
content String?
|
|
207
|
-
authorId String
|
|
208
|
-
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
|
|
209
|
-
createdAt DateTime @default(now())
|
|
210
|
-
updatedAt DateTime @updatedAt
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
**app/api/users/route.ts**
|
|
215
|
-
```typescript
|
|
216
|
-
import { NextRequest, NextResponse } from 'next/server';
|
|
217
|
-
import { prisma } from '@/lib/prisma';
|
|
218
|
-
import { z } from 'zod';
|
|
219
|
-
|
|
220
|
-
const createUserSchema = z.object({
|
|
221
|
-
email: z.string().email(),
|
|
222
|
-
name: z.string().optional(),
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
export async function GET() {
|
|
226
|
-
try {
|
|
227
|
-
const users = await prisma.user.findMany({
|
|
228
|
-
include: {
|
|
229
|
-
posts: true,
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
return NextResponse.json(users);
|
|
233
|
-
} catch (error) {
|
|
234
|
-
return NextResponse.json(
|
|
235
|
-
{ error: 'Failed to fetch users' },
|
|
236
|
-
{ status: 500 }
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export async function POST(request: NextRequest) {
|
|
242
|
-
try {
|
|
243
|
-
const body = await request.json();
|
|
244
|
-
const validatedData = createUserSchema.parse(body);
|
|
245
|
-
|
|
246
|
-
const user = await prisma.user.create({
|
|
247
|
-
data: validatedData,
|
|
248
|
-
include: {
|
|
249
|
-
posts: true,
|
|
250
|
-
},
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
return NextResponse.json(user, { status: 201 });
|
|
254
|
-
} catch (error) {
|
|
255
|
-
if (error instanceof z.ZodError) {
|
|
256
|
-
return NextResponse.json(
|
|
257
|
-
{ error: 'Validation failed', details: error.errors },
|
|
258
|
-
{ status: 400 }
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
return NextResponse.json(
|
|
262
|
-
{ error: 'Failed to create user' },
|
|
263
|
-
{ status: 500 }
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
**lib/prisma.ts**
|
|
270
|
-
```typescript
|
|
271
|
-
import { PrismaClient } from '@prisma/client';
|
|
272
|
-
|
|
273
|
-
const globalForPrisma = globalThis as unknown as {
|
|
274
|
-
prisma: PrismaClient | undefined;
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
export const prisma = globalForPrisma.prisma ?? new PrismaClient();
|
|
278
|
-
|
|
279
|
-
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
## Comparison Report
|
|
283
|
-
|
|
284
|
-
### Key Improvements in Clean Implementation
|
|
285
|
-
|
|
286
|
-
1. **Type Safety**: Added Zod validation for API endpoints
|
|
287
|
-
2. **Error Handling**: Comprehensive error handling with appropriate HTTP status codes
|
|
288
|
-
3. **Database Relations**: Proper cascade delete handling
|
|
289
|
-
4. **Code Organization**: Clean separation of concerns
|
|
290
|
-
5. **Modern Patterns**: Uses Next.js 14 App Router patterns
|
|
291
|
-
6. **Validation**: Input validation on all endpoints
|
|
292
|
-
7. **TypeScript**: Full TypeScript implementation
|
|
293
|
-
|
|
294
|
-
### Likely Differences from Original
|
|
295
|
-
|
|
296
|
-
1. **Missing Error Handling**: Original may lack proper error responses
|
|
297
|
-
2. **No Input Validation**: Original may accept any input without validation
|
|
298
|
-
3. **Inconsistent Code Style**: Original may have mixed patterns
|
|
299
|
-
4. **Missing Type Safety**: Original may use any/unknown types
|
|
300
|
-
5. **Incomplete Relations**: Original may not handle cascade deletes properly
|
|
301
|
-
|
|
302
|
-
### Migration Recommendations
|
|
303
|
-
|
|
304
|
-
1. Add input validation using Zod or similar
|
|
305
|
-
2. Implement comprehensive error handling
|
|
306
|
-
3. Update database schema for proper relations
|
|
307
|
-
4. Add TypeScript types throughout
|
|
308
|
-
5. Migrate to Next.js App Router if using Pages Router
|
|
309
|
-
6. Add proper connection pooling for database
|
|
310
|
-
|
|
311
|
-
explanation: |
|
|
312
|
-
This clean implementation demonstrates modern Next.js best practices while
|
|
313
|
-
staying true to the extracted specifications. It provides a baseline for
|
|
314
|
-
comparing with the original code and identifying improvement opportunities.
|
|
315
|
-
|
|
316
|
-
metadata:
|
|
317
|
-
created: "2024-01-01T00:00:00Z"
|
|
318
|
-
updated: "2024-01-01T00:00:00Z"
|
|
319
|
-
tested_with:
|
|
320
|
-
- provider: openai
|
|
321
|
-
model: gpt-4
|
|
322
|
-
success_rate: 92
|
|
323
|
-
- provider: anthropic
|
|
324
|
-
model: claude-3-opus
|
|
325
|
-
success_rate: 95
|
|
326
|
-
performance:
|
|
327
|
-
avg_response_time: 18.7
|
|
328
|
-
avg_tokens_used: 6500
|