@atlashub/smartstack-cli 4.75.0 → 4.76.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.js +87 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/skills/apex/SKILL.md +2 -2
- package/templates/skills/apex/references/checks/frontend-checks.sh +26 -0
- package/templates/skills/apex/references/checks/seed-checks.sh +47 -7
- package/templates/skills/apex/references/core-seed-data.md +20 -18
- package/templates/skills/apex/references/post-checks.md +18 -1
- package/templates/skills/apex/references/smartstack-api.md +4 -4
- package/templates/skills/apex/references/smartstack-frontend.md +1 -1
- package/templates/skills/apex/references/smartstack-layers.md +6 -6
- package/templates/skills/apex/steps/step-00-init.md +1 -1
- package/templates/skills/apex/steps/step-03b-layer1-seed.md +26 -0
- package/templates/skills/apex/steps/step-03d-layer3-frontend.md +124 -2
- package/templates/skills/apex/steps/step-04-examine.md +163 -0
- package/templates/skills/apex-verify/SKILL.md +110 -0
- package/templates/skills/apex-verify/references/audit-rules.md +50 -0
- package/templates/skills/apex-verify/steps/step-00-init.md +119 -0
- package/templates/skills/apex-verify/steps/step-01-nav-audit.md +92 -0
- package/templates/skills/apex-verify/steps/step-02-crud-audit.md +127 -0
- package/templates/skills/apex-verify/steps/step-03-perm-audit.md +119 -0
- package/templates/skills/apex-verify/steps/step-04-route-audit.md +98 -0
- package/templates/skills/apex-verify/steps/step-05-report.md +110 -0
- package/templates/skills/application/templates-frontend.md +2 -2
- package/templates/skills/business-analyse/SKILL.md +3 -3
- package/templates/skills/business-analyse/_shared.md +37 -0
- package/templates/skills/business-analyse/references/03-json-schemas.md +11 -3
- package/templates/skills/business-analyse/references/03-post-check-validation.md +64 -0
- package/templates/skills/business-analyse/references/canonical-json-formats.md +7 -3
- package/templates/skills/business-analyse/references/robustness-checks.md +1 -1
- package/templates/skills/business-analyse/references/validation-checklist.md +5 -5
- package/templates/skills/business-analyse/schemas/sections/analysis-schema.json +15 -4
- package/templates/skills/business-analyse/steps/step-03-specify.md +162 -4
- package/templates/skills/business-analyse/steps/step-04-consolidate.md +211 -1
- package/templates/skills/business-analyse-handoff/references/agent-handoff-transform-prompt.md +3 -0
- package/templates/skills/business-analyse-html/html/ba-interactive.html +198 -16
- package/templates/skills/business-analyse-html/html/src/scripts/01-data-init.js +64 -0
- package/templates/skills/business-analyse-html/html/src/scripts/05-render-specs.js +80 -11
- package/templates/skills/business-analyse-html/html/src/scripts/06-render-consolidation.js +2 -2
- package/templates/skills/business-analyse-html/html/src/scripts/06-render-mockups.js +6 -3
- package/templates/skills/business-analyse-html/html/src/scripts/12-render-diagrams.js +46 -0
- package/templates/skills/business-analyse-html/references/02-feature-data-building.md +4 -2
- package/templates/skills/business-analyse-html/references/data-build.md +2 -0
- package/templates/skills/business-analyse-html/references/data-mapping.md +88 -21
- package/templates/skills/business-analyse-html/steps/step-02-build-data.md +6 -0
- package/templates/skills/business-analyse-html/steps/step-04-verify.md +92 -3
- package/templates/skills/business-analyse-quick/SKILL.md +807 -0
- package/templates/skills/{sketch → business-analyse-quick}/references/domain-heuristics.md +59 -3
- package/templates/skills/business-analyse-quick/references/prd-schema.md +268 -0
- package/templates/skills/business-analyse-review/references/review-data-mapping.md +6 -0
- package/templates/skills/dev-start/SKILL.md +7 -7
- package/templates/skills/sketch/SKILL.md +15 -153
- package/templates/skills/ui-components/SKILL.md +1 -1
- package/templates/skills/ui-components/patterns/data-table.md +1 -1
|
@@ -0,0 +1,807 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: business-analyse-quick
|
|
3
|
+
description: |
|
|
4
|
+
Quick business analysis (Mini-BA) that produces a Mini-PRD for /apex delegate mode.
|
|
5
|
+
Use this skill when:
|
|
6
|
+
- User has a vague idea ("I want an HR app with employees and absences")
|
|
7
|
+
- User doesn't know the exact entities, fields, or structure needed
|
|
8
|
+
- User needs structured specifications before running /apex
|
|
9
|
+
- Scope is small enough (≤ 6 entities) — for larger scope, use /business-analyse
|
|
10
|
+
Produces .ralph/prd-{module}.json + 5 companion spec files.
|
|
11
|
+
model: opus
|
|
12
|
+
argument-hint: "<vague idea in natural language>"
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<objective>
|
|
16
|
+
Transform a vague user prompt into a structured Mini-PRD (.ralph/prd-{module}.json) with 5 companion specification files, ready for `/apex -d` delegate mode. /business-analyse-quick is a rapid interactive design assistant — it guides the user through 3 phases (Cadrage → Specification → Generation) with 12-15 targeted questions.
|
|
17
|
+
|
|
18
|
+
**Key principles:**
|
|
19
|
+
- Interactive: 12-15 questions via AskUserQuestion (max 2 questions per call)
|
|
20
|
+
- Context-aware: scans codebase for existing apps, modules, entities
|
|
21
|
+
- Structured output: PRD v4.0 + entities/rules/usecases/permissions/screens JSON files
|
|
22
|
+
- Domain heuristics ACCELERATE inference — propose, then validate with user
|
|
23
|
+
- APEX compatibility: output is directly consumable by `/apex -d`
|
|
24
|
+
</objective>
|
|
25
|
+
|
|
26
|
+
<quick_start>
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
/business-analyse-quick une app RH avec employés et absences
|
|
30
|
+
/business-analyse-quick I want to manage customer orders and invoices
|
|
31
|
+
/business-analyse-quick gestion de projets avec tâches et jalons
|
|
32
|
+
/business-analyse-quick stock management with products and warehouses
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
</quick_start>
|
|
36
|
+
|
|
37
|
+
<anti_patterns>
|
|
38
|
+
- DO NOT skip user interaction — every major decision must be validated
|
|
39
|
+
- DO NOT call MCP tools — validation is /apex's job
|
|
40
|
+
- DO NOT generate actual source code — only specification JSON files
|
|
41
|
+
- DO NOT produce more than 6 entities without redirecting to /business-analyse
|
|
42
|
+
- DO NOT assume architecture without confirming with user
|
|
43
|
+
- DO NOT mix languages in JSON values — all content in `{conversation_language}` chosen in Step 2
|
|
44
|
+
- DO NOT use accented characters in entity names — PascalCase, valid C# identifiers only
|
|
45
|
+
- DO NOT generate ASCII-only French/German/Italian labels — "Employés" not "Employes", "Département" not "Departement", "Übersicht" not "Ubersicht", "attività" not "attivita". UTF-8 accents are MANDATORY in all i18n label values.
|
|
46
|
+
</anti_patterns>
|
|
47
|
+
|
|
48
|
+
<algorithm>
|
|
49
|
+
|
|
50
|
+
# ═══════════════════════════════════════════════════════
|
|
51
|
+
# PHASE 1: CADRAGE (Framing) — 3-4 questions
|
|
52
|
+
# ═══════════════════════════════════════════════════════
|
|
53
|
+
|
|
54
|
+
## Step 0: Banner + Load References
|
|
55
|
+
|
|
56
|
+
Display version banner:
|
|
57
|
+
```
|
|
58
|
+
═══════════════════════════════════════════════════════════
|
|
59
|
+
SmartStack /business-analyse-quick — Mini-BA → Mini-PRD
|
|
60
|
+
v{{SMARTSTACK_VERSION}}
|
|
61
|
+
═══════════════════════════════════════════════════════════
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Read `references/domain-heuristics.md` — domain pattern table with entities, properties, sections, rules, and workflows for 15 common business domains.
|
|
65
|
+
|
|
66
|
+
## Step 1: Deep Codebase Scan (MANDATORY — silent)
|
|
67
|
+
|
|
68
|
+
> **This scan is BLOCKING.** You MUST know what already exists before proposing anything.
|
|
69
|
+
|
|
70
|
+
**1a. Application inventory:**
|
|
71
|
+
```
|
|
72
|
+
Glob("**/NavigationApplicationSeedData.cs") → existing applications
|
|
73
|
+
Glob("*.sln") → confirm SmartStack project
|
|
74
|
+
```
|
|
75
|
+
Read each NavigationApplicationSeedData file to extract: app code, app label, description.
|
|
76
|
+
|
|
77
|
+
**1b. Module inventory (per detected app):**
|
|
78
|
+
```
|
|
79
|
+
Glob("**/NavigationModuleSeedData.cs") → existing modules per app
|
|
80
|
+
Glob("**/NavigationSectionSeedData.cs") → existing sections per module
|
|
81
|
+
```
|
|
82
|
+
Read each file to extract: module code, module label, section codes.
|
|
83
|
+
|
|
84
|
+
**1c. Entity inventory:**
|
|
85
|
+
```
|
|
86
|
+
Glob("**/Domain/Entities/**/*.cs") → existing entity names
|
|
87
|
+
```
|
|
88
|
+
Extract entity names from filenames (strip .cs). Group by app/module folder.
|
|
89
|
+
|
|
90
|
+
**1d. Existing BA documentation:**
|
|
91
|
+
```
|
|
92
|
+
Glob("docs/**/index.json") → previous BA work
|
|
93
|
+
Glob(".ralph/prd-*.json") → existing PRDs
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Store all results as `{detected_apps}`, `{detected_modules}`, `{detected_entities}`, `{detected_prd}`.
|
|
97
|
+
|
|
98
|
+
## Step 2: First Contact (AskUserQuestion #1)
|
|
99
|
+
|
|
100
|
+
**AskUserQuestion** with 3 questions (max allowed per call):
|
|
101
|
+
|
|
102
|
+
- **Q1** (header: "Language"): "In which language should I communicate and write the specifications?"
|
|
103
|
+
- Options: "Français" / "English" / "Italiano" / "Deutsch"
|
|
104
|
+
- This sets `{conversation_language}` — ALL subsequent questions, displays, and JSON content values will use this language
|
|
105
|
+
|
|
106
|
+
- **Q2** (header: "Scope"): "Is this a new application or an update to an existing one?"
|
|
107
|
+
- Options: "New application" / "Update to {app1}" / "Update to {app2}" (one option per detected app, max 3)
|
|
108
|
+
- If no apps detected: only "New application" option
|
|
109
|
+
|
|
110
|
+
- **Q3** (header: "Description"): "Describe what you want to build in 1-2 sentences"
|
|
111
|
+
- Options are illustrative examples from user's prompt domain — user will likely use "Other" for free text
|
|
112
|
+
|
|
113
|
+
**Language rule:** From this point on, ALL text output (questions, tables, summaries) and ALL JSON string values (descriptions, rule statements, use case steps, screen labels) MUST be in `{conversation_language}`. The i18n `labels` fields always contain all 4 languages regardless.
|
|
114
|
+
|
|
115
|
+
**If UPDATE selected** → AskUserQuestion #2 (1 question):
|
|
116
|
+
- Display detected modules for the selected app
|
|
117
|
+
- **Q4** (header: "Module"): "Which module?"
|
|
118
|
+
- Options: "New module for {app}" / "{existing_module_1}" / "{existing_module_2}" (from Step 1b)
|
|
119
|
+
|
|
120
|
+
## Step 3: Domain Research + Deep Inference (ULTRATHINK)
|
|
121
|
+
|
|
122
|
+
> **ULTRATHINK is MANDATORY here. Do NOT skip or rush this step.**
|
|
123
|
+
> This is where the quality of the entire analysis is determined.
|
|
124
|
+
|
|
125
|
+
### 3a. Web Research (MANDATORY if domain is not trivial CRUD)
|
|
126
|
+
|
|
127
|
+
**Perform 1-3 WebSearch calls** to understand the domain:
|
|
128
|
+
- Search for best practices in the user's domain (e.g., "HR management system features", "project management app architecture")
|
|
129
|
+
- Search for industry standards or regulations if applicable (e.g., "leave management legal requirements {country}")
|
|
130
|
+
- Search for common workflows in the domain
|
|
131
|
+
|
|
132
|
+
**Skip WebSearch ONLY if:**
|
|
133
|
+
- The domain is a textbook CRUD with no business logic (simple reference table)
|
|
134
|
+
- The heuristics table already covers the domain exhaustively
|
|
135
|
+
|
|
136
|
+
### 3b. Collision Detection (MANDATORY)
|
|
137
|
+
|
|
138
|
+
Cross-reference inferred entities with `{detected_entities}` from Step 1c:
|
|
139
|
+
```
|
|
140
|
+
For each inferred entity:
|
|
141
|
+
IF entity name already exists in codebase:
|
|
142
|
+
→ Flag as COLLISION — this entity already exists
|
|
143
|
+
→ Decision: reuse existing entity (FK to it) OR rename new entity
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Cross-reference inferred module with `{detected_modules}` from Step 1b:
|
|
147
|
+
```
|
|
148
|
+
IF module code already exists for the selected app:
|
|
149
|
+
→ Flag as COLLISION — redirect user to update flow
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 3c. Full Architecture Inference (ULTRATHINK)
|
|
153
|
+
|
|
154
|
+
From user description + domain heuristics + web research + existing codebase:
|
|
155
|
+
|
|
156
|
+
**CRITICAL — Module Splitting Rule:**
|
|
157
|
+
> One module = one functional domain. If the user mentions multiple business concepts
|
|
158
|
+
> that have distinct lifecycles, actors, or workflows, they MUST be separate modules.
|
|
159
|
+
>
|
|
160
|
+
> Examples:
|
|
161
|
+
> - "employees and absences" → 2 modules: `employees` + `absence-management`
|
|
162
|
+
> - "orders and invoicing" → 2 modules: `orders` + `invoicing`
|
|
163
|
+
> - "projects with tasks and milestones" → 1 module: `projects` (tasks/milestones are sub-entities of project)
|
|
164
|
+
>
|
|
165
|
+
> **Test:** Can concept A exist without concept B? If yes → separate modules.
|
|
166
|
+
> "An absence REQUIRES an employee but an employee does NOT require absences" → 2 modules.
|
|
167
|
+
|
|
168
|
+
1. **Application:** PascalCase name, determine if new or existing
|
|
169
|
+
2. **Modules (PLURAL):** For EACH distinct functional domain:
|
|
170
|
+
- `code` (kebab-case), PascalCase name, description
|
|
171
|
+
- Which entities belong to this module
|
|
172
|
+
- Inter-module dependencies (e.g., absence-management depends on employees)
|
|
173
|
+
3. **Sections per module:** for EACH section infer:
|
|
174
|
+
- `code` (kebab-case)
|
|
175
|
+
- `sectionType`: primary | functional | embedded
|
|
176
|
+
- `permissionMode`: crud | custom | read-only | inherit
|
|
177
|
+
- `labels` in 4 languages (fr, en, it, de)
|
|
178
|
+
- `icon` suggestion
|
|
179
|
+
- Which entities are displayed in this section
|
|
180
|
+
- **NEVER create sections for detail/create/edit** — these are implicit APEX pages (routes /:id, /create, /:id/edit under the primary section). Only create primary (list/CRUD), functional (approve, calendar), and embedded (dashboard, kpi) sections.
|
|
181
|
+
4. **Resources** per section: for EACH section infer:
|
|
182
|
+
- `code` (kebab-case, e.g., "employees-grid")
|
|
183
|
+
- `type`: SmartTable | SmartForm | DetailCard | KpiPanel | Timeline | Chart | Calendar
|
|
184
|
+
- Which entity it displays
|
|
185
|
+
- Key columns (for SmartTable) or fields (for SmartForm)
|
|
186
|
+
5. **Entities:** name (PascalCase, valid C#), key attributes, types, nullable, FK
|
|
187
|
+
6. **FK relationships:** between new entities AND to existing entities (User, Organisation, detected entities). Cross-module FK are critical (e.g., Absence.EmployeeId → Employee in another module)
|
|
188
|
+
7. **Business rules:** from heuristics `typicalRules` + web research + domain knowledge
|
|
189
|
+
8. **Complexity deduction per module:**
|
|
190
|
+
- `simple-crud` if ≤ 2 entities with no workflow/status transitions
|
|
191
|
+
- `crud-rules` if validations, computed fields, or status fields present
|
|
192
|
+
- `crud-workflow` if approval flows, notifications, or email mentioned
|
|
193
|
+
- `complex` if > 4 entities with specific business logic
|
|
194
|
+
9. **Workflow detection:** from heuristics `workflow` field + user description
|
|
195
|
+
10. **Role derivation** (MANDATORY — at least 2 roles):
|
|
196
|
+
a. Start with Admin role: `"{App} Admin"` — level: admin, wildcard access
|
|
197
|
+
b. Check domain heuristics for `typicalRoles` — if available, adopt them as starting point
|
|
198
|
+
c. If workflow detected (approval, validation) → add a manager-level role (e.g., `"{App} Manager"`)
|
|
199
|
+
d. If multiple distinct actor types identified (e.g., employee vs HR staff) → derive per-actor roles
|
|
200
|
+
e. If no domain signals → default to 3-role set: Admin + Contributor + Viewer
|
|
201
|
+
f. Apply the 4-level hierarchy as ceiling: admin > manager > contributor > viewer
|
|
202
|
+
(only include levels that match the domain — not every domain needs all 4)
|
|
203
|
+
g. Each role: name (string), level (admin|manager|contributor|viewer), description (string)
|
|
204
|
+
11. **Person Extension Pattern:** if an entity has FirstName + LastName + Email attributes
|
|
205
|
+
12. **i18n labels** in 4 languages for all hierarchy levels
|
|
206
|
+
|
|
207
|
+
### 3d. Architecture Challenge (ULTRATHINK — self-review)
|
|
208
|
+
|
|
209
|
+
Before presenting to the user, CHALLENGE your own architecture:
|
|
210
|
+
|
|
211
|
+
- [ ] **Module split correct?** Separate lifecycles = separate modules. Never cram unrelated domains into 1 module.
|
|
212
|
+
- [ ] **Cross-module dependencies declared?** If module B references entities from module A, this FK must be explicit.
|
|
213
|
+
- [ ] **Missing sections?** Does a module need a dashboard? An approval queue? Import/export? Calendar?
|
|
214
|
+
- [ ] **No detail/create/edit sections?** These are implicit APEX pages (routes under primary section), NOT sections. Only create primary (list), functional (approve, calendar), and embedded (dashboard) sections.
|
|
215
|
+
- [ ] **Entity completeness?** Are there implicit entities? (e.g., if "absences" → do we need AbsenceType? AbsenceBalance?)
|
|
216
|
+
- [ ] **FK to existing entities?** Does an entity need User (CreatedBy, AssignedTo)? Organisation? Another app's entity?
|
|
217
|
+
- [ ] **Collisions resolved?** Every collision from 3b must have a decision (reuse vs rename)
|
|
218
|
+
- [ ] **Workflow states?** If workflow detected, are states defined as an enum entity?
|
|
219
|
+
- [ ] **Resource appropriateness?** Is SmartTable the right choice or should it be a Kanban board? Timeline? Calendar?
|
|
220
|
+
- [ ] **Roles derived?** At least Admin + 1 operational role. Roles match detected actors/workflow. Checked domain heuristics `typicalRoles`.
|
|
221
|
+
- [ ] **Permission paths predictable?** Each section with `permissionMode: crud` will generate 4+ permission paths (`{App}.{Module}.Read/Create/Update/Delete`). Each section with `permissionMode: custom` needs explicit paths.
|
|
222
|
+
|
|
223
|
+
**Scope Guard per module:** If any single module has > 6 entities:
|
|
224
|
+
```
|
|
225
|
+
Module {module} has too many entities (> 6). Split it further or use /business-analyse.
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Total Scope Guard:** If total entities across all modules > 10:
|
|
229
|
+
```
|
|
230
|
+
This scope is too large for /business-analyse-quick (> 10 entities total).
|
|
231
|
+
Use /business-analyse for a full analysis with stakeholder interviews and design phase.
|
|
232
|
+
```
|
|
233
|
+
→ STOP
|
|
234
|
+
|
|
235
|
+
## Step 4: Propose Full Architecture (AskUserQuestion #3)
|
|
236
|
+
|
|
237
|
+
Display the COMPLETE architecture as a **tree** (NOT a table — tables are unreadable for hierarchical data).
|
|
238
|
+
|
|
239
|
+
```markdown
|
|
240
|
+
### Proposed Architecture
|
|
241
|
+
|
|
242
|
+
**Application:** {app_name} ({new/existing})
|
|
243
|
+
**Complexity:** {complexity_per_module}
|
|
244
|
+
|
|
245
|
+
#### Navigation Tree
|
|
246
|
+
|
|
247
|
+
{AppCode} — {label_fr}
|
|
248
|
+
├── {module-1-code} — {label_fr} ({complexity})
|
|
249
|
+
│ ├── [P] {section-code} — {label_fr} ← {Entity1}, {Entity2}
|
|
250
|
+
│ │ ├── {entities}-grid (SmartTable)
|
|
251
|
+
│ │ └── {entity}-form (SmartForm)
|
|
252
|
+
│ │ └── (implicit: detail /:id, create /create, edit /:id/edit)
|
|
253
|
+
│ ├── [F] approve — {label_fr} ← {Entity1}
|
|
254
|
+
│ │ └── approve-queue (SmartTable)
|
|
255
|
+
│ └── [E] dashboard — {label_fr}
|
|
256
|
+
│ └── kpi-panel (KpiPanel)
|
|
257
|
+
│
|
|
258
|
+
├── {module-2-code} — {label_fr} ({complexity})
|
|
259
|
+
│ ├── [P] {section-code} — {label_fr} ← {Entity3}
|
|
260
|
+
│ │ ├── {entities}-grid (SmartTable)
|
|
261
|
+
│ │ └── {entity}-form (SmartForm)
|
|
262
|
+
│ │ └── (implicit: detail /:id, create /create, edit /:id/edit)
|
|
263
|
+
│ └── [F] calendar — {label_fr} ← {Entity3}
|
|
264
|
+
│ └── {entity}-calendar (Calendar)
|
|
265
|
+
|
|
266
|
+
Legend: [P]=primary (crud) [F]=functional [E]=embedded
|
|
267
|
+
Note: detail/create/edit pages are IMPLICIT routes under [P] sections — NOT separate sections
|
|
268
|
+
|
|
269
|
+
#### Cross-Module Dependencies
|
|
270
|
+
- {module-2} → {module-1}: {Entity3}.{FK} → {Entity1}
|
|
271
|
+
|
|
272
|
+
#### Entities
|
|
273
|
+
|
|
274
|
+
| Entity | Module | Key Attributes | FK → | Collision? |
|
|
275
|
+
|--------|--------|---------------|------|------------|
|
|
276
|
+
| {Entity1} | {module-1} | {attr1}:{type}, {attr2}:{type} | → {Target} | None |
|
|
277
|
+
| {Entity3} | {module-2} | {attr1}:{type}, {attr2}:{type} | → {Entity1} (cross-module) | None |
|
|
278
|
+
|
|
279
|
+
#### Workflow
|
|
280
|
+
- **{Entity}** ({module}): {state1} → {state2} → {state3} / {state4}
|
|
281
|
+
|
|
282
|
+
#### Roles & Permissions Preview
|
|
283
|
+
|
|
284
|
+
| Role | Level | Typical Access |
|
|
285
|
+
|------|-------|----------------|
|
|
286
|
+
| {App} Admin | admin | Full module access (wildcard `{App}.*`) |
|
|
287
|
+
| {Role2} | manager | Read + Create + Update + Approve |
|
|
288
|
+
| {Role3} | contributor | Read + Create |
|
|
289
|
+
| {Role4} | viewer | Read only |
|
|
290
|
+
|
|
291
|
+
> Roles derived from: {source — domain heuristics / workflow actors / default hierarchy}.
|
|
292
|
+
> Permission paths will follow: `{ApplicationPascalCase}.{ModulePascalCase}.{Action}`
|
|
293
|
+
|
|
294
|
+
#### Findings from research
|
|
295
|
+
- {key_insight_1_from_web_research}
|
|
296
|
+
- {key_insight_2_from_web_research}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Then **AskUserQuestion** with 1 question:
|
|
300
|
+
- **Q5** (header: "Architecture"): "Is this architecture correct?"
|
|
301
|
+
- Options: "Yes, proceed to specification" / "No, let me correct" / "I want to add context"
|
|
302
|
+
|
|
303
|
+
If "No" or "Add context" → collect correction, re-run Step 3c-3d inference, re-display. Loop max 2 times.
|
|
304
|
+
|
|
305
|
+
# ═══════════════════════════════════════════════════════
|
|
306
|
+
# PHASE 2: SPECIFICATION (8-10 questions)
|
|
307
|
+
# ═══════════════════════════════════════════════════════
|
|
308
|
+
|
|
309
|
+
## Step 5: Entity Specification (AskUserQuestion #4)
|
|
310
|
+
|
|
311
|
+
Display proposed entities as a detailed table:
|
|
312
|
+
|
|
313
|
+
```markdown
|
|
314
|
+
### Proposed Entities
|
|
315
|
+
|
|
316
|
+
| Entity | Key Attributes | Relationships | Code Pattern |
|
|
317
|
+
|--------|---------------|---------------|--------------|
|
|
318
|
+
| Employee | FirstName:string, LastName:string, Email:string, HireDate:DateTime | → Department (FK) | emp-{tenant}-00001 |
|
|
319
|
+
| Department | Name:string, Code:string | → Department? (self-ref) | dep-{tenant}-00001 |
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Then **AskUserQuestion**:
|
|
323
|
+
- **Q5** (header: "Entities"): "Here are the entities I propose. What would you like to change?"
|
|
324
|
+
- Options: "Accept all as proposed" / "Modify entities" / "Add more entities"
|
|
325
|
+
|
|
326
|
+
**If "Modify" or "Add"** → AskUserQuestion #5:
|
|
327
|
+
- **Q6** (header: "Details"): "Describe the changes you want (add/remove entities, change properties, add relationships)"
|
|
328
|
+
- User provides corrections via free text (Other)
|
|
329
|
+
- Re-infer with corrections applied, re-display table for confirmation
|
|
330
|
+
|
|
331
|
+
## Step 6: Dependencies + Person Extension Pattern (silent scan + 0-1 question)
|
|
332
|
+
|
|
333
|
+
Scan existing codebase for entity conflicts:
|
|
334
|
+
```
|
|
335
|
+
Glob("**/Domain/Entities/**/*.cs") → existing entity names
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
**Check for:**
|
|
339
|
+
- Name conflicts with existing entities → warn user
|
|
340
|
+
- FK dependencies on User entity (auth_Users)
|
|
341
|
+
- FK dependencies on Organisation entity
|
|
342
|
+
- Person Extension Pattern candidates: entities with FirstName + LastName + Email attributes
|
|
343
|
+
|
|
344
|
+
**If Person Extension Pattern detected** → AskUserQuestion #6:
|
|
345
|
+
- **Q7** (header: "Person Pattern"): "Entity {X} has personal attributes (name, email). SmartStack links these to auth_Users via the Person Extension Pattern. Should I apply it?"
|
|
346
|
+
- Options: "Yes, link to User" / "No, keep standalone" / "Explain the pattern"
|
|
347
|
+
- If "Explain": display brief explanation, then re-ask Yes/No
|
|
348
|
+
|
|
349
|
+
If PEP applied: add `personRoleConfig` to entity, change UserId type to `string` (ASP.NET Identity convention).
|
|
350
|
+
|
|
351
|
+
## Step 7: Business Rules + Cross-Cutting Needs (AskUserQuestion #7)
|
|
352
|
+
|
|
353
|
+
**AskUserQuestion** with 1 multiSelect question:
|
|
354
|
+
- **Q8** (header: "Needs", multiSelect: true): "Does this module need any of the following?"
|
|
355
|
+
- "Status transitions / approval workflow" — e.g., Draft → Submitted → Approved
|
|
356
|
+
- "Automated notifications (email, in-app)" — triggered by status changes or events
|
|
357
|
+
- "Calculated / computed fields" — e.g., TotalAmount = sum of lines
|
|
358
|
+
- "Date constraints (start < end, deadlines)" — temporal validation rules
|
|
359
|
+
- "Uniqueness constraints beyond Code" — e.g., unique email, unique serial number
|
|
360
|
+
- "AI-powered features (generation, classification, recommendation)"
|
|
361
|
+
|
|
362
|
+
**If "Status transitions" selected** → AskUserQuestion #8:
|
|
363
|
+
- **Q9** (header: "Workflow"): "Describe the workflow for {main entity}"
|
|
364
|
+
- Options: "{suggested workflow from heuristics}" / "Linear: Draft → Submitted → Approved/Rejected" / "Multi-step with delegation" / "Custom (describe)"
|
|
365
|
+
|
|
366
|
+
**If "AI-powered features" selected** → AskUserQuestion #9:
|
|
367
|
+
- **Q10** (header: "AI Feature"): "What type of AI integration?"
|
|
368
|
+
- Options: "Content generation (text, summaries)" / "Classification (categorize, tag)" / "Recommendations (suggest, predict)" / "Custom (describe)"
|
|
369
|
+
|
|
370
|
+
After collecting all answers, compile business rules:
|
|
371
|
+
1. Start with `typicalRules` from domain heuristics
|
|
372
|
+
2. Add rules from selected needs (workflow transitions, date constraints, uniqueness, calculations)
|
|
373
|
+
3. Add any user-specified custom rules
|
|
374
|
+
|
|
375
|
+
## Step 8: Sections + Navigation (AskUserQuestion #10)
|
|
376
|
+
|
|
377
|
+
Display proposed sections:
|
|
378
|
+
|
|
379
|
+
```markdown
|
|
380
|
+
### Proposed Sections
|
|
381
|
+
|
|
382
|
+
| Section | Type | Pages | Permission |
|
|
383
|
+
|---------|------|-------|------------|
|
|
384
|
+
| list | primary | List + implicit Detail/Create/Edit | CRUD |
|
|
385
|
+
| dashboard | embedded | KPIs, Charts | read-only |
|
|
386
|
+
| approve | functional | Approval queue | custom |
|
|
387
|
+
|
|
388
|
+
> **Note:** detail/create/edit pages are implicit routes under the primary section
|
|
389
|
+
> (/:id, /create, /:id/edit). Do NOT create separate sections for them.
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
Then **AskUserQuestion**:
|
|
393
|
+
- **Q11** (header: "Sections", multiSelect: true): "Here are the planned sections. Select any you want to add or remove:"
|
|
394
|
+
- List current sections as selected by default
|
|
395
|
+
- Offer additional options: "Add dashboard section" / "Add import/export section" / "Add calendar view" / "Remove {section}" (for each optional section)
|
|
396
|
+
|
|
397
|
+
## Step 9: Challenge + Final Validation (AskUserQuestion #11)
|
|
398
|
+
|
|
399
|
+
**ULTRATHINK: Final review checklist:**
|
|
400
|
+
- [ ] All entities have at least one FK or are standalone with justification
|
|
401
|
+
- [ ] No orphan entities (entity without a section)
|
|
402
|
+
- [ ] Entity-section mapping is clear (which entity belongs to which section)
|
|
403
|
+
- [ ] Business rules reference valid entity names
|
|
404
|
+
- [ ] Workflow states are consistent with status enum values
|
|
405
|
+
- [ ] **Roles defined:** at least Admin + 1 operational role (from Step 3c item 10)
|
|
406
|
+
- [ ] **Permission paths cover all CRUD sections:** each module has at minimum Read, Create, Update, Delete paths
|
|
407
|
+
- [ ] **Permission path format:** `{ApplicationPascalCase}.{ModulePascalCase}.{Action}` (3-segment) — PascalCase, no hyphens, no spaces
|
|
408
|
+
- [ ] **Role-permission matrix complete:** every role in matrix exists in roles[], every path in matrix exists in permissionPaths
|
|
409
|
+
- [ ] i18n labels provided in 4 languages
|
|
410
|
+
|
|
411
|
+
Display full specification summary as markdown, including any issues found.
|
|
412
|
+
|
|
413
|
+
Then **AskUserQuestion**:
|
|
414
|
+
- **Q12** (header: "Final"): "The specification is ready. Any last changes?"
|
|
415
|
+
- Options: "Generate the PRD" / "I want to change something" / "Start over"
|
|
416
|
+
|
|
417
|
+
If "change something" → collect changes, apply, re-display summary. Loop max 1 time.
|
|
418
|
+
If "Start over" → restart from Step 2.
|
|
419
|
+
|
|
420
|
+
# ═══════════════════════════════════════════════════════
|
|
421
|
+
# PHASE 3: GENERATION (0 questions, 1 final choice)
|
|
422
|
+
# ═══════════════════════════════════════════════════════
|
|
423
|
+
|
|
424
|
+
## Step 10: Entity Name Quality Gate (BLOCKING)
|
|
425
|
+
|
|
426
|
+
Before generating any files, validate all entity names:
|
|
427
|
+
```
|
|
428
|
+
For each entity name:
|
|
429
|
+
- Must be PascalCase
|
|
430
|
+
- Must be a valid C# identifier (no spaces, accents, apostrophes)
|
|
431
|
+
- Must not contain: àâäéèêëïîôùûüçÀÂÄÉÈÊËÏÎÔÙÛÜÇ or spaces or apostrophes
|
|
432
|
+
|
|
433
|
+
If any invalid name found → fix automatically (strip accents, PascalCase) and warn user.
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## Step 11: Compute PRD v4.0 (one per module)
|
|
437
|
+
|
|
438
|
+
Read `references/prd-schema.md` for the exact JSON structure.
|
|
439
|
+
|
|
440
|
+
**Repeat for EACH module** identified in Step 3c. Each module gets its own PRD + 5 companion files.
|
|
441
|
+
|
|
442
|
+
Build the PRD object with these computed values:
|
|
443
|
+
|
|
444
|
+
**project:**
|
|
445
|
+
- `application` = {app_name} (PascalCase)
|
|
446
|
+
- `module` = {module_code} (kebab-case)
|
|
447
|
+
|
|
448
|
+
**expectedFiles:** Generate file paths using deterministic templates from prd-schema.md.
|
|
449
|
+
For EACH entity in this module, generate paths in: domain, infrastructure, application (service + 3 DTOs + validator), api (controller).
|
|
450
|
+
For the module, generate paths in: seedData (4 files: NavModule, NavSection, Permissions, Roles), frontend (4 pages per entity: List, Detail, Create, Edit + i18n × 4 langs), tests.
|
|
451
|
+
|
|
452
|
+
**Route convention:** The `route` field in screens.json follows a UNIFORM rule for ALL sections: `route` = `/{app-kebab}/{module-kebab}/{section-code}`. For a `list` section: `/{app-kebab}/{module-kebab}/list`. `navigate('create')` (relative) correctly resolves to `/{module}/create` in React Router v6.
|
|
453
|
+
|
|
454
|
+
**specificationFiles:** Relative paths to companion files:
|
|
455
|
+
```json
|
|
456
|
+
{
|
|
457
|
+
"entities": "prd-{module}.entities.json",
|
|
458
|
+
"permissions": "prd-{module}.permissions.json",
|
|
459
|
+
"rules": "prd-{module}.rules.json",
|
|
460
|
+
"usecases": "prd-{module}.usecases.json",
|
|
461
|
+
"screens": "prd-{module}.screens.json"
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
**tasks:** Generate one task per major work item, with dependencies:
|
|
466
|
+
- Task per entity (domain layer, no dependencies)
|
|
467
|
+
- Task for EF configs (depends on entity tasks)
|
|
468
|
+
- Task for seed data (depends on entity tasks)
|
|
469
|
+
- Task per service (depends on entity tasks)
|
|
470
|
+
- Task per controller (depends on service tasks)
|
|
471
|
+
- Task per frontend page set (4 pages per entity: List, Detail, Create, Edit — depends on controller tasks)
|
|
472
|
+
- Task for tests (depends on all above)
|
|
473
|
+
|
|
474
|
+
**Cross-module dependencies:** If module B has entities with FK to module A, the PRD for module B must list module A as a dependency. APEX will process them in topological order.
|
|
475
|
+
|
|
476
|
+
## Step 12: Generate Companion Specification Files
|
|
477
|
+
|
|
478
|
+
Generate 5 JSON files following the schemas in `references/prd-schema.md`:
|
|
479
|
+
|
|
480
|
+
### entities.json
|
|
481
|
+
For each entity collected in Phase 2:
|
|
482
|
+
- `name`: PascalCase entity name
|
|
483
|
+
- `description`: one-line description
|
|
484
|
+
- `personRoleConfig`: only if Person Extension Pattern applied
|
|
485
|
+
- `attributes`: all collected properties with name, type, required, unique, searchable flags
|
|
486
|
+
- `relationships`: all FK relationships with target, type (ManyToOne/OneToMany/etc.), description
|
|
487
|
+
- `codePattern`: strategy (default: sequential), prefix (first 3 letters), digits (5), separator ("-"), includeTenantSlug (true)
|
|
488
|
+
- `estimatedVolume`: inferred from domain (low: 50/1000, medium: 200/5000, high: 1000/25000)
|
|
489
|
+
|
|
490
|
+
### rules.json
|
|
491
|
+
For each business rule collected in Steps 7-9:
|
|
492
|
+
- `id`: BR-{CAT}-{MODULE_SHORT}-{NNN} format
|
|
493
|
+
- `name`, `category`, `statement`, `severity`, `priority`
|
|
494
|
+
- `entities`: list of affected entity names
|
|
495
|
+
- `examples`: at least 1 input/expected pair per rule
|
|
496
|
+
- `formula` for calculation rules, `conditions`+`consequences` for workflow rules
|
|
497
|
+
|
|
498
|
+
### usecases.json
|
|
499
|
+
Generate standard CRUD use cases per entity + custom use cases from workflow:
|
|
500
|
+
- CRUD: Create, Read (list), Read (detail), Update, Delete per entity
|
|
501
|
+
- Custom: one UC per workflow transition, one UC per functional section
|
|
502
|
+
- Each UC: id, name, sectionCode, primaryActor, permission, preconditions, mainScenario (3-5 steps), postconditions, businessRules refs
|
|
503
|
+
|
|
504
|
+
### permissions.json — Deterministic Generation
|
|
505
|
+
|
|
506
|
+
> **This section generates a complete, cross-validated permissions file.**
|
|
507
|
+
> Roles were derived in Step 3c item 10 and confirmed by the user in Step 4.
|
|
508
|
+
|
|
509
|
+
**A. Roles**
|
|
510
|
+
|
|
511
|
+
Include the roles derived in Step 3c. AT MINIMUM:
|
|
512
|
+
1. `"{App} Admin"` — level: admin, description: "Full access to {module} module"
|
|
513
|
+
2. One operational role from domain analysis (Manager, Contributor, etc.)
|
|
514
|
+
|
|
515
|
+
Optional: additional roles from workflow actors or domain heuristics `typicalRoles`.
|
|
516
|
+
|
|
517
|
+
Format per role:
|
|
518
|
+
```json
|
|
519
|
+
{ "role": "{Name}", "level": "{admin|manager|contributor|viewer}", "description": "..." }
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
**B. Permission Paths**
|
|
523
|
+
|
|
524
|
+
For EACH module, compute paths deterministically:
|
|
525
|
+
|
|
526
|
+
```
|
|
527
|
+
base = "{ApplicationPascalCase}.{ModulePascalCase}"
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
Where `{ApplicationPascalCase}` is the app name in PascalCase (e.g., `HumanResources`) and `{ModulePascalCase}` is the module code converted from kebab-case to PascalCase (e.g., `absence-management` → `AbsenceManagement`).
|
|
531
|
+
|
|
532
|
+
**Standard paths (ALWAYS generate for each module):**
|
|
533
|
+
- `{base}.Read`
|
|
534
|
+
- `{base}.Create`
|
|
535
|
+
- `{base}.Update`
|
|
536
|
+
- `{base}.Delete`
|
|
537
|
+
|
|
538
|
+
**Conditional paths (add if applicable):**
|
|
539
|
+
- If export needed (user selected or heuristic suggests) → `{base}.Export`
|
|
540
|
+
- If import needed → `{base}.Import`
|
|
541
|
+
- If approval workflow detected → `{base}.Approve`
|
|
542
|
+
- If admin section exists → `{base}.Admin`
|
|
543
|
+
|
|
544
|
+
**Section-specific paths (4-segment, only if section has `permissionMode: "custom"`):**
|
|
545
|
+
- `{base}.{SectionPascalCase}.{Action}`
|
|
546
|
+
- Example: `HumanResources.AbsenceManagement.Approve.Read`
|
|
547
|
+
|
|
548
|
+
**IMPORTANT:** Permission paths are per MODULE, not per entity. A module with 3 entities (e.g., Absence, AbsenceType, AbsenceBalance) gets ONE set of paths like `HumanResources.AbsenceManagement.Read`, not three separate sets.
|
|
549
|
+
|
|
550
|
+
**C. Matrix (roleAssignments)**
|
|
551
|
+
|
|
552
|
+
Map each role to its permission paths using the hierarchy:
|
|
553
|
+
|
|
554
|
+
| Role level | Gets these permissions |
|
|
555
|
+
|------------|----------------------|
|
|
556
|
+
| admin | `["{base}.*"]` (wildcard — covers all current and future paths) |
|
|
557
|
+
| manager | All Read + Create + Update + Approve paths (explicit list) |
|
|
558
|
+
| contributor | Read + Create paths only (explicit list) |
|
|
559
|
+
| viewer | Read paths only (explicit list) |
|
|
560
|
+
| custom | Specific permission list derived from workflow analysis |
|
|
561
|
+
|
|
562
|
+
**D. Cross-Validation (BLOCKING — do NOT generate file if any check fails)**
|
|
563
|
+
|
|
564
|
+
Before writing permissions.json, verify:
|
|
565
|
+
1. Every `permission` field referenced in usecases.json exists in `permissionPaths`
|
|
566
|
+
2. Every section in screens.json with `permissionMode` not equal to `"inherit"` has a corresponding permission in `permissionPaths`
|
|
567
|
+
3. Every role name in `matrix.roleAssignments` exists in the `roles[]` array
|
|
568
|
+
4. `permissionPaths.length >= 4` (at minimum: Read, Create, Update, Delete)
|
|
569
|
+
5. No duplicate permission paths
|
|
570
|
+
|
|
571
|
+
If any check fails, fix the data (add missing paths, add missing roles) before generating the file.
|
|
572
|
+
|
|
573
|
+
### screens.json
|
|
574
|
+
Generate from sections collected in Step 8:
|
|
575
|
+
- **NEVER include sections with code "detail", "create", "edit", or "*-detail"** — these are implicit APEX routes, not sections
|
|
576
|
+
- For each section: code, sectionType, permissionMode, labels (4 langs), route, permission
|
|
577
|
+
- For primary sections: SmartTable resource with columns from entity attributes, default actions
|
|
578
|
+
- For functional sections: appropriate resource type (SmartForm for approval, etc.)
|
|
579
|
+
- For embedded sections: KpiPanel, Chart, or other widget resources
|
|
580
|
+
- Column format deduction: string→text, DateTime→date, decimal→number, bool→boolean, enum→badge
|
|
581
|
+
- **Route validation:** Verify every section has `route` equal to `"/{app-kebab}/{module-kebab}/{section-code}"` — including `list` sections (route ends with `/list`)
|
|
582
|
+
|
|
583
|
+
### I18n Label Quality Gate (BLOCKING — run before writing ANY companion file)
|
|
584
|
+
|
|
585
|
+
Before writing screens.json, entities.json, and usecases.json, verify ALL text labels have correct UTF-8 accents.
|
|
586
|
+
|
|
587
|
+
**Primary rule:** Write proper French/German/Italian with accents. You are an LLM that knows these languages — write them correctly.
|
|
588
|
+
|
|
589
|
+
**Safety net — common ASCII-stripping corrections:**
|
|
590
|
+
|
|
591
|
+
| ASCII (WRONG) | Accented (CORRECT) | Language |
|
|
592
|
+
|---|---|---|
|
|
593
|
+
| Employes | Employés | FR |
|
|
594
|
+
| Employe | Employé | FR |
|
|
595
|
+
| Departement | Département | FR |
|
|
596
|
+
| Departements | Départements | FR |
|
|
597
|
+
| Prenom | Prénom | FR |
|
|
598
|
+
| Numero | Numéro | FR |
|
|
599
|
+
| Societe | Société | FR |
|
|
600
|
+
| Categorie | Catégorie | FR |
|
|
601
|
+
| Categories | Catégories | FR |
|
|
602
|
+
| Securite | Sécurité | FR |
|
|
603
|
+
| Conge | Congé | FR |
|
|
604
|
+
| Conges | Congés | FR |
|
|
605
|
+
| Generalites | Généralités | FR |
|
|
606
|
+
| Resume | Résumé | FR |
|
|
607
|
+
| Echeance | Échéance | FR |
|
|
608
|
+
| Activite | Activité | FR |
|
|
609
|
+
| Salarie | Salarié | FR |
|
|
610
|
+
| Creee | Créée | FR |
|
|
611
|
+
| Cree | Créé | FR |
|
|
612
|
+
| Modifiee | Modifiée | FR |
|
|
613
|
+
| Modifie | Modifié | FR |
|
|
614
|
+
| Taux occupation | Taux d'occupation | FR |
|
|
615
|
+
| Detail employe | Détail employé | FR |
|
|
616
|
+
| Departement parent | Département parent | FR |
|
|
617
|
+
| Soldes de conges | Soldes de congés | FR |
|
|
618
|
+
| Demi-journee | Demi-journée | FR |
|
|
619
|
+
| Ubersicht | Übersicht | DE |
|
|
620
|
+
| Beschaftigungsgrad | Beschäftigungsgrad | DE |
|
|
621
|
+
| Uberabteilung | Überabteilung | DE |
|
|
622
|
+
| attivita | attività | IT |
|
|
623
|
+
|
|
624
|
+
**Scan all label objects** in sections[].labels, resources[].columns[].label, and any description fields. If any value matches the ASCII column above, replace it with the accented version.
|
|
625
|
+
|
|
626
|
+
**This gate is BLOCKING:** do NOT write the file if any French label lacks expected accents.
|
|
627
|
+
|
|
628
|
+
## Step 13: Write Files
|
|
629
|
+
|
|
630
|
+
Write 6 files per module to `.ralph/` directory:
|
|
631
|
+
|
|
632
|
+
```
|
|
633
|
+
For EACH module:
|
|
634
|
+
.ralph/prd-{module}.json — PRD manifest
|
|
635
|
+
.ralph/prd-{module}.entities.json — Entity specifications
|
|
636
|
+
.ralph/prd-{module}.rules.json — Business rules
|
|
637
|
+
.ralph/prd-{module}.usecases.json — Use cases
|
|
638
|
+
.ralph/prd-{module}.screens.json — Screen specifications
|
|
639
|
+
.ralph/prd-{module}.permissions.json — Permission matrix
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
Also generate a queue file for multi-module execution:
|
|
643
|
+
```
|
|
644
|
+
.ralph/modules-queue.json
|
|
645
|
+
```
|
|
646
|
+
```json
|
|
647
|
+
{
|
|
648
|
+
"application": "{app_name}",
|
|
649
|
+
"modules": [
|
|
650
|
+
{ "code": "{module-1}", "prd": "prd-{module-1}.json", "dependsOn": [] },
|
|
651
|
+
{ "code": "{module-2}", "prd": "prd-{module-2}.json", "dependsOn": ["{module-1}"] }
|
|
652
|
+
]
|
|
653
|
+
}
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
Ensure `.ralph/` directory exists before writing.
|
|
657
|
+
|
|
658
|
+
## Step 14: Display Summary + Handoff
|
|
659
|
+
|
|
660
|
+
Display the generation summary:
|
|
661
|
+
|
|
662
|
+
```
|
|
663
|
+
═══════════════════════════════════════════════════════════════
|
|
664
|
+
/business-analyse-quick — Mini-PRD Generated
|
|
665
|
+
═══════════════════════════════════════════════════════════════
|
|
666
|
+
|
|
667
|
+
Application: {app_name}
|
|
668
|
+
Modules: {module_count}
|
|
669
|
+
|
|
670
|
+
{module-1-code} ({complexity})
|
|
671
|
+
Entities: {count} ({entity_names})
|
|
672
|
+
Sections: {count} ({section_names})
|
|
673
|
+
Rules: {count} | Use Cases: {count}
|
|
674
|
+
Roles: {count} ({role_names}) | Permissions: {path_count} paths
|
|
675
|
+
|
|
676
|
+
{module-2-code} ({complexity}) → depends on {module-1-code}
|
|
677
|
+
Entities: {count} ({entity_names})
|
|
678
|
+
Sections: {count} ({section_names})
|
|
679
|
+
Rules: {count} | Use Cases: {count}
|
|
680
|
+
Roles: {count} ({role_names}) | Permissions: {path_count} paths
|
|
681
|
+
|
|
682
|
+
Total files: {total_expected} expected across 8 categories
|
|
683
|
+
|
|
684
|
+
Artifacts written:
|
|
685
|
+
.ralph/modules-queue.json — Execution order
|
|
686
|
+
.ralph/prd-{module-1}.json + 5 specs — Module 1
|
|
687
|
+
.ralph/prd-{module-2}.json + 5 specs — Module 2
|
|
688
|
+
|
|
689
|
+
═══════════════════════════════════════════════════════════════
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
Then **AskUserQuestion** (final choice):
|
|
693
|
+
- **Q-final** (header: "Next step"): "What would you like to do?"
|
|
694
|
+
- Options:
|
|
695
|
+
- "Run /apex -d for all modules (sequential, respecting dependencies)"
|
|
696
|
+
- "Run /apex -d for {module-1} only (start with first module)"
|
|
697
|
+
- "Edit specifications manually"
|
|
698
|
+
- "Cancel"
|
|
699
|
+
|
|
700
|
+
</algorithm>
|
|
701
|
+
|
|
702
|
+
<handoff>
|
|
703
|
+
|
|
704
|
+
Based on user selection:
|
|
705
|
+
|
|
706
|
+
```
|
|
707
|
+
IF user selects "Run /apex -d for all modules":
|
|
708
|
+
→ Execute Ralph-Loop (see below)
|
|
709
|
+
|
|
710
|
+
IF user selects "Run /apex -d for {module-1} only":
|
|
711
|
+
→ Execute Ralph-Loop for single module (see below)
|
|
712
|
+
|
|
713
|
+
IF user selects "Edit specifications manually":
|
|
714
|
+
→ Display the list of generated files in .ralph/
|
|
715
|
+
→ Display: "Edit the JSON files, then run:
|
|
716
|
+
/apex -d .ralph/prd-{module}.json (per module)"
|
|
717
|
+
→ STOP
|
|
718
|
+
|
|
719
|
+
IF user selects "Cancel":
|
|
720
|
+
→ Display: "Cancelled. Your specifications remain in .ralph/ for later use."
|
|
721
|
+
→ STOP
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
## Ralph-Loop — Module Execution with PRD Compliance
|
|
725
|
+
|
|
726
|
+
> **EXECUTION GUARANTEE:** Once the user selects "Run /apex -d", execute ALL selected modules
|
|
727
|
+
> without stopping for confirmation between modules. The loop runs autonomously.
|
|
728
|
+
|
|
729
|
+
### Algorithm
|
|
730
|
+
|
|
731
|
+
```javascript
|
|
732
|
+
const queue = readJSON('.ralph/modules-queue.json');
|
|
733
|
+
const results = [];
|
|
734
|
+
|
|
735
|
+
// If user selected single module, filter queue to that module only
|
|
736
|
+
const modulesToRun = singleModule
|
|
737
|
+
? queue.modules.filter(m => m.code === singleModule)
|
|
738
|
+
: queue.modules;
|
|
739
|
+
|
|
740
|
+
for (const module of modulesToRun) {
|
|
741
|
+
// 1. Dependency check
|
|
742
|
+
if (module.dependsOn?.length > 0) {
|
|
743
|
+
const unmetDeps = module.dependsOn.filter(dep =>
|
|
744
|
+
!results.find(r => r.code === dep && r.status !== 'skipped')
|
|
745
|
+
);
|
|
746
|
+
if (unmetDeps.length > 0) {
|
|
747
|
+
results.push({
|
|
748
|
+
code: module.code,
|
|
749
|
+
status: 'skipped',
|
|
750
|
+
reason: `Unmet dependencies: ${unmetDeps.join(', ')}`
|
|
751
|
+
});
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// 2. Execute /apex -d for this module
|
|
757
|
+
// /apex now includes PRD Compliance Gate (step-04 section 6d)
|
|
758
|
+
// which validates columns, actions, permissions, i18n against companion specs
|
|
759
|
+
Skill("apex", args: `-d .ralph/${module.prd}`);
|
|
760
|
+
|
|
761
|
+
// 3. Verify completion status
|
|
762
|
+
const prd = readJSON(`.ralph/${module.prd}`);
|
|
763
|
+
const allTasksDone = prd.tasks?.every(t => t.status === 'completed') ?? false;
|
|
764
|
+
|
|
765
|
+
results.push({
|
|
766
|
+
code: module.code,
|
|
767
|
+
status: allTasksDone ? 'completed' : 'completed-with-warnings',
|
|
768
|
+
taskCount: prd.tasks?.length || 0,
|
|
769
|
+
completedTasks: prd.tasks?.filter(t => t.status === 'completed').length || 0
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
### Ralph-Loop Report
|
|
775
|
+
|
|
776
|
+
After all modules are processed, display the execution report:
|
|
777
|
+
|
|
778
|
+
```
|
|
779
|
+
═══════════════════════════════════════════════════════════════
|
|
780
|
+
Ralph-Loop — Execution Report
|
|
781
|
+
═══════════════════════════════════════════════════════════════
|
|
782
|
+
|
|
783
|
+
Application: {app_name}
|
|
784
|
+
Modules: {modulesToRun.length} executed
|
|
785
|
+
|
|
786
|
+
Module Status Tasks
|
|
787
|
+
─────────────────────────────────────────────────────────────
|
|
788
|
+
{module-1} COMPLETED {n}/{n} tasks done
|
|
789
|
+
{module-2} COMPLETED {n}/{n} tasks done
|
|
790
|
+
{module-3} SKIPPED Unmet dep: {dep}
|
|
791
|
+
|
|
792
|
+
═══════════════════════════════════════════════════════════════
|
|
793
|
+
|
|
794
|
+
PRD Compliance: Validated by /apex step-04 section 6d
|
|
795
|
+
PC-1 (columns) PASS
|
|
796
|
+
PC-2 (actions) PASS
|
|
797
|
+
PC-3 (i18n) PASS
|
|
798
|
+
PC-4 (permissions) PASS
|
|
799
|
+
|
|
800
|
+
═══════════════════════════════════════════════════════════════
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
> **Note:** The retry mechanism for PRD compliance issues is handled INTERNALLY by `/apex`
|
|
804
|
+
> (step-04 returns to step-03d for fixes). The ralph-loop does NOT re-invoke `/apex` for
|
|
805
|
+
> individual compliance failures — it trusts `/apex`'s internal correction loop.
|
|
806
|
+
|
|
807
|
+
</handoff>
|