@atlashub/smartstack-cli 3.8.0 → 3.9.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 (120) hide show
  1. package/dist/index.js +365 -2
  2. package/dist/index.js.map +1 -1
  3. package/package.json +2 -1
  4. package/templates/agents/action.md +1 -0
  5. package/templates/agents/ba-writer.md +33 -0
  6. package/templates/agents/explore-codebase.md +1 -0
  7. package/templates/agents/explore-docs.md +1 -0
  8. package/templates/agents/fix-grammar.md +1 -0
  9. package/templates/agents/snipper.md +1 -0
  10. package/templates/skills/admin/SKILL.md +6 -0
  11. package/templates/skills/ai-prompt/SKILL.md +32 -136
  12. package/templates/skills/ai-prompt/steps/step-01-implementation.md +122 -0
  13. package/templates/skills/apex/SKILL.md +120 -0
  14. package/templates/skills/apex/_shared.md +86 -0
  15. package/templates/skills/apex/references/agent-teams-protocol.md +164 -0
  16. package/templates/skills/apex/references/smartstack-layers.md +173 -0
  17. package/templates/skills/apex/steps/step-00-init.md +156 -0
  18. package/templates/skills/apex/steps/step-01-analyze.md +169 -0
  19. package/templates/skills/apex/steps/step-02-plan.md +160 -0
  20. package/templates/skills/apex/steps/step-03-execute.md +166 -0
  21. package/templates/skills/apex/steps/step-04-validate.md +138 -0
  22. package/templates/skills/apex/steps/step-05-examine.md +124 -0
  23. package/templates/skills/apex/steps/step-06-resolve.md +105 -0
  24. package/templates/skills/apex/steps/step-07-tests.md +130 -0
  25. package/templates/skills/apex/steps/step-08-run-tests.md +115 -0
  26. package/templates/skills/application/SKILL.md +10 -0
  27. package/templates/skills/application/references/backend-controller-hierarchy.md +58 -0
  28. package/templates/skills/application/references/backend-entity-seeding.md +72 -0
  29. package/templates/skills/application/references/backend-verification.md +88 -0
  30. package/templates/skills/application/references/frontend-verification.md +111 -0
  31. package/templates/skills/application/references/nav-fallback-procedure.md +200 -0
  32. package/templates/skills/application/references/provider-template.md +134 -0
  33. package/templates/skills/application/references/test-frontend.md +73 -0
  34. package/templates/skills/application/references/test-prerequisites.md +72 -0
  35. package/templates/skills/application/steps/step-01-navigation.md +7 -198
  36. package/templates/skills/application/steps/step-03b-provider.md +4 -128
  37. package/templates/skills/application/steps/step-04-backend.md +20 -350
  38. package/templates/skills/application/steps/step-05-frontend.md +12 -101
  39. package/templates/skills/application/steps/step-07-tests.md +12 -132
  40. package/templates/skills/business-analyse/SKILL.md +11 -2
  41. package/templates/skills/business-analyse/html/ba-interactive.html +176 -14
  42. package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +1 -0
  43. package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +16 -4
  44. package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +7 -2
  45. package/templates/skills/business-analyse/html/src/scripts/09-export.js +103 -0
  46. package/templates/skills/business-analyse/html/src/scripts/10-comments.js +12 -6
  47. package/templates/skills/business-analyse/html/src/scripts/11-review-panel.js +24 -2
  48. package/templates/skills/business-analyse/html/src/styles/08-review-panel.css +12 -0
  49. package/templates/skills/business-analyse/html/src/template.html +1 -0
  50. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +78 -0
  51. package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +97 -0
  52. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +92 -0
  53. package/templates/skills/business-analyse/references/deploy-data-build.md +121 -0
  54. package/templates/skills/business-analyse/references/deploy-modes.md +49 -0
  55. package/templates/skills/business-analyse/references/handoff-file-templates.md +119 -0
  56. package/templates/skills/business-analyse/references/handoff-mappings.md +81 -0
  57. package/templates/skills/business-analyse/references/html-data-mapping.md +10 -2
  58. package/templates/skills/business-analyse/references/init-schema-deployment.md +65 -0
  59. package/templates/skills/business-analyse/references/review-data-mapping.md +363 -0
  60. package/templates/skills/business-analyse/references/spec-auto-inference.md +57 -0
  61. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +85 -0
  62. package/templates/skills/business-analyse/references/ui-resource-cards.md +110 -0
  63. package/templates/skills/business-analyse/references/validate-incremental-html.md +55 -0
  64. package/templates/skills/business-analyse/steps/step-00-init.md +35 -68
  65. package/templates/skills/business-analyse/steps/step-01-cadrage.md +5 -194
  66. package/templates/skills/business-analyse/steps/step-03a-data.md +6 -49
  67. package/templates/skills/business-analyse/steps/step-03b-ui.md +12 -178
  68. package/templates/skills/business-analyse/steps/step-03d-validate.md +3 -48
  69. package/templates/skills/business-analyse/steps/step-04-consolidation.md +9 -104
  70. package/templates/skills/business-analyse/steps/step-05a-handoff.md +25 -441
  71. package/templates/skills/business-analyse/steps/step-05b-deploy.md +19 -187
  72. package/templates/skills/business-analyse/steps/step-06-review.md +277 -0
  73. package/templates/skills/cc-agent/references/agent-behavior-patterns.md +95 -0
  74. package/templates/skills/cc-agent/steps/step-02-generate.md +5 -78
  75. package/templates/skills/check-version/SKILL.md +7 -0
  76. package/templates/skills/controller/references/controller-code-templates.md +159 -0
  77. package/templates/skills/controller/references/permission-sync-templates.md +152 -0
  78. package/templates/skills/controller/steps/step-03-generate.md +6 -158
  79. package/templates/skills/controller/steps/step-04-perms.md +5 -144
  80. package/templates/skills/debug/SKILL.md +7 -0
  81. package/templates/skills/explore/SKILL.md +6 -0
  82. package/templates/skills/feature-full/SKILL.md +39 -142
  83. package/templates/skills/feature-full/steps/step-01-implementation.md +120 -0
  84. package/templates/skills/gitflow/references/init-config-template.md +135 -0
  85. package/templates/skills/gitflow/references/init-name-normalization.md +103 -0
  86. package/templates/skills/gitflow/references/plan-template.md +69 -0
  87. package/templates/skills/gitflow/references/start-efcore-preflight.md +70 -0
  88. package/templates/skills/gitflow/references/start-local-config.md +110 -0
  89. package/templates/skills/gitflow/steps/step-init.md +18 -289
  90. package/templates/skills/gitflow/steps/step-plan.md +6 -63
  91. package/templates/skills/gitflow/steps/step-start.md +16 -126
  92. package/templates/skills/mcp/SKILL.md +9 -213
  93. package/templates/skills/mcp/steps/step-01-healthcheck.md +108 -0
  94. package/templates/skills/mcp/steps/step-02-tools.md +73 -0
  95. package/templates/skills/notification/SKILL.md +7 -0
  96. package/templates/skills/quick-search/SKILL.md +5 -0
  97. package/templates/skills/ralph-loop/SKILL.md +99 -381
  98. package/templates/skills/ralph-loop/references/category-rules.md +259 -0
  99. package/templates/skills/ralph-loop/references/compact-loop.md +182 -0
  100. package/templates/skills/ralph-loop/references/task-transform-legacy.md +259 -0
  101. package/templates/skills/ralph-loop/references/team-orchestration.md +189 -0
  102. package/templates/skills/ralph-loop/steps/step-00-init.md +111 -383
  103. package/templates/skills/ralph-loop/steps/step-01-task.md +79 -896
  104. package/templates/skills/ralph-loop/steps/step-02-execute.md +68 -680
  105. package/templates/skills/ralph-loop/steps/step-03-commit.md +47 -277
  106. package/templates/skills/ralph-loop/steps/step-04-check.md +124 -607
  107. package/templates/skills/ralph-loop/steps/step-05-report.md +68 -367
  108. package/templates/skills/refactor/SKILL.md +12 -176
  109. package/templates/skills/refactor/steps/step-01-discover.md +60 -0
  110. package/templates/skills/refactor/steps/step-02-execute.md +67 -0
  111. package/templates/skills/review-code/SKILL.md +19 -257
  112. package/templates/skills/review-code/steps/step-01-smartstack.md +96 -0
  113. package/templates/skills/review-code/steps/step-02-detailed-review.md +80 -0
  114. package/templates/skills/review-code/steps/step-03-react.md +44 -0
  115. package/templates/skills/ui-components/SKILL.md +7 -0
  116. package/templates/skills/utils/SKILL.md +6 -0
  117. package/templates/skills/validate/SKILL.md +6 -0
  118. package/templates/skills/validate-feature/SKILL.md +8 -0
  119. package/templates/skills/workflow/SKILL.md +40 -118
  120. package/templates/skills/workflow/steps/step-01-implementation.md +84 -0
@@ -6,14 +6,11 @@ next_step: steps/step-03-commit.md
6
6
 
7
7
  # Step 2: Execute Task
8
8
 
9
- > **CONTEXT OPTIMIZATION:** This file is only read ONCE (first iteration).
10
- > After the first full iteration, ALL subsequent iterations use the COMPACT LOOP
11
- > in step-04-check.md section 5 which includes inline execution.
12
- > **DO NOT re-read this file for iterations > 1.**
9
+ > **CONTEXT OPTIMIZATION:** Read ONCE (first iteration). Subsequent iterations use compact-loop.md.
13
10
 
14
11
  ## YOUR TASK:
15
12
 
16
- Execute the current task(s) from prd.json. For the first iteration, execute ONE task. After the first iteration, the compact loop in step-04 handles batch execution.
13
+ Execute the current task from prd.json. First iteration = ONE task. After that, compact loop handles batches.
17
14
 
18
15
  **ULTRA THINK about the implementation.**
19
16
 
@@ -21,11 +18,11 @@ Execute the current task(s) from prd.json. For the first iteration, execute ONE
21
18
 
22
19
  ## EXECUTION RULES:
23
20
 
24
- 1. **ATOMIC CHANGES** - Changes should be complete and working
25
- 2. **USE MCP** - Validate with SmartStack MCP (once per batch, not per task)
26
- 3. **TRACK FILES** - Record every file created or modified
27
- 4. **CHECK DEPENDENCIES** - Verify all dependencies are met before starting
28
- 5. **BATCH ALLOWED** - Multiple tasks of the same category can be batched (max 5)
21
+ 1. **ATOMIC CHANGES** Complete and working
22
+ 2. **USE MCP** Validate with SmartStack MCP (once per batch)
23
+ 3. **TRACK FILES** Record every file created or modified
24
+ 4. **CHECK DEPENDENCIES** Verify before starting
25
+ 5. **BATCH ALLOWED** Same category, max 5 tasks
29
26
 
30
27
  ---
31
28
 
@@ -33,737 +30,128 @@ Execute the current task(s) from prd.json. For the first iteration, execute ONE
33
30
 
34
31
  ### 1. Verify Dependencies
35
32
 
36
- **BEFORE starting, check all dependencies are satisfied:**
37
-
38
33
  ```javascript
39
34
  const prd = readJSON('.ralph/prd.json');
40
35
  const task = prd.tasks.find(t => t.id === {current_task_id});
41
-
42
36
  for (const depId of task.dependencies) {
43
37
  const dep = prd.tasks.find(t => t.id === depId);
44
38
  if (!dep || dep.status !== 'completed') {
45
- echo `❌ BLOCKED: Task ${task.id} depends on task ${depId} (status: ${dep?.status || 'missing'})`;
46
- task.status = 'blocked';
47
- task.error = `Dependency task ${depId} not completed (${dep?.status})`;
39
+ task.status = 'blocked'; task.error = `Dependency ${depId} not completed`;
48
40
  writeJSON('.ralph/prd.json', prd);
49
- STOP - return to step-01 to find next eligible task
41
+ STOP return to step-01
50
42
  }
51
43
  }
52
44
  ```
53
45
 
54
- ### 2. Mark Task as In-Progress
55
-
56
- **Update prd.json immediately:**
46
+ ### 2. Mark In-Progress
57
47
 
58
48
  ```javascript
59
49
  task.status = 'in_progress';
60
50
  task.started_at = new Date().toISOString();
61
- prd.updated_at = task.started_at;
62
51
  writeJSON('.ralph/prd.json', prd);
63
52
  ```
64
53
 
65
- ### 3. Understand the Task
54
+ ### 3. Understand and Execute
66
55
 
67
- **ULTRA THINK:**
56
+ **ULTRA THINK:** What needs to be done? What files? What acceptance criteria? What category?
68
57
 
69
- - What exactly needs to be done?
70
- - What files need to be created/modified?
71
- - What are the acceptance criteria? → `{current_task_criteria}`
72
- - What patterns should be followed?
73
- - What category is this? → `{current_task_category}`
58
+ **Read `references/category-rules.md` for category-specific execution rules.**
74
59
 
75
- **Category-specific guidance:**
60
+ Key category triggers:
76
61
 
77
- | Category | MCP Tools | Patterns |
78
- |----------|-----------|----------|
79
- | `domain` | `validate_conventions` | Entity base class, IHasData, audit fields |
80
- | `application` | `validate_conventions`, `scaffold_extension` | CQRS, MediatR, FluentValidation |
81
- | `infrastructure` | `check_migrations`, `suggest_migration` | EF Core config, HasData seeding, IClientSeedDataProvider, SqlObjects |
82
- | `api` | `scaffold_routes`, `validate_security` | Controller conventions, authorization, context-based folder hierarchy |
83
- | `frontend` | `validate_frontend_routes`, `scaffold_frontend_extension` | React patterns, hooks, Layout wrapper |
84
- | `i18n` | - | 4-language JSON structure |
85
- | `test` | `scaffold_tests`, `analyze_test_coverage` | xUnit, test naming conventions |
86
- | `validation` | `validate_conventions` | Build, test, lint checks |
62
+ | Category | Special Action |
63
+ |----------|---------------|
64
+ | `infrastructure` with `_migrationMeta` | Migration sequence: MCP suggest add → update → build |
65
+ | `infrastructure` with seed data keywords | **MANDATORY**: Read `references/core-seed-data.md` |
66
+ | `frontend` | MCP-first: scaffold_api_client scaffold_routes pages |
67
+ | `test` | Generate via MCP run fix loop 100% pass required |
68
+ | `validation` | Clean build full test suite MCP validate |
87
69
 
88
- **Test task guidance — TDD CYCLE (MANDATORY):**
70
+ ### 4. Implement
89
71
 
90
- > **CRITICAL:** Tests are NOT optional. Every feature MUST have tests that pass.
91
- > The cycle is: Generate Code Generate Tests → Run Tests → Fix Code → Re-run Tests → Pass.
72
+ - Create/modify files following SmartStack conventions
73
+ - Track: `{files_created} = []`, `{files_modified} = []`
74
+ - Use MCP tools per category (see category-rules.md)
92
75
 
93
- When executing `test` category tasks, follow this EXACT sequence:
76
+ ### 5. Post-Infrastructure Build Gate (BLOCKING)
94
77
 
95
- **1. ENSURE TEST PROJECT EXISTS (BLOCKING)**
78
+ **After completing ALL infrastructure tasks (configs + migration + seed data):**
96
79
 
97
80
  ```bash
98
- # Detect project name from solution
99
- PROJECT_NAME=$(basename $(pwd))
100
- TEST_PROJECT="tests/${PROJECT_NAME}.Tests.Unit"
101
-
102
- if [ ! -d "$TEST_PROJECT" ]; then
103
- echo "⚠️ Test project missing. Scaffolding now..."
104
-
105
- # Create test project
106
- dotnet new xunit -n "${PROJECT_NAME}.Tests.Unit" -o "$TEST_PROJECT"
107
-
108
- # Add required packages
109
- cd "$TEST_PROJECT"
110
- dotnet add package Moq --version 4.20.72
111
- dotnet add package FluentAssertions --version 8.3.0
112
- dotnet add package Microsoft.Extensions.DependencyInjection --version 10.0.2
113
- cd ../..
114
-
115
- # Add project references to all src/ projects
116
- for proj in src/*/*.csproj; do
117
- dotnet add "$TEST_PROJECT" reference "$proj"
118
- done
119
-
120
- # Add test project to solution
121
- dotnet sln add "$TEST_PROJECT/${PROJECT_NAME}.Tests.Unit.csproj"
122
-
123
- echo "✅ Test project scaffolded at $TEST_PROJECT"
124
- fi
81
+ dotnet build --no-restore
125
82
  ```
126
83
 
127
- **2. GENERATE TESTS USING MCP (DO NOT WRITE MANUALLY)**
84
+ MUST pass before proceeding to application/api/test/frontend. Fix if fails.
128
85
 
129
- ```javascript
130
- // Identify what to test based on task description
131
- const task = prd.tasks.find(t => t.id === {current_task_id});
132
- const testType = detectTestType(task.description); // "unit" | "integration" | "security"
133
-
134
- // For domain tests
135
- if (task.description.includes("domain entity") || task.description.includes("value object")) {
136
- // Call MCP to scaffold domain tests
137
- mcp__smartstack__scaffold_tests({
138
- module: extractModuleName(task.description),
139
- test_type: "unit",
140
- target_layer: "domain",
141
- target_file: identifyEntityFile(task.description)
142
- });
143
- }
144
-
145
- // For service tests
146
- if (task.description.includes("service")) {
147
- mcp__smartstack__scaffold_tests({
148
- module: extractModuleName(task.description),
149
- test_type: "unit",
150
- target_layer: "application",
151
- target_file: identifyServiceFile(task.description)
152
- });
153
- }
154
-
155
- // For controller tests
156
- if (task.description.includes("controller") || task.description.includes("API")) {
157
- mcp__smartstack__scaffold_tests({
158
- module: extractModuleName(task.description),
159
- test_type: "integration",
160
- target_layer: "api",
161
- target_file: identifyControllerFile(task.description)
162
- });
163
- }
164
-
165
- // For security/permissions tests
166
- if (task.description.includes("permission") || task.description.includes("security")) {
167
- mcp__smartstack__scaffold_tests({
168
- module: extractModuleName(task.description),
169
- test_type: "security",
170
- target_layer: "api",
171
- target_file: identifyControllerFile(task.description)
172
- });
173
- }
174
- ```
175
-
176
- **3. RUN TESTS IMMEDIATELY (BLOCKING)**
177
-
178
- ```bash
179
- # Build test project first
180
- dotnet build "$TEST_PROJECT" --no-restore
181
-
182
- # Run tests with detailed output
183
- dotnet test "$TEST_PROJECT" --no-build --verbosity normal
86
+ ### 6. Validate with MCP
184
87
 
185
- # Capture exit code
186
- TEST_EXIT_CODE=$?
187
88
  ```
89
+ mcp__smartstack__validate_conventions: checks: ["all"]
188
90
 
189
- **4. ANALYZE RESULTS AND IMPROVE (LOOP UNTIL GREEN)**
190
-
191
- ```javascript
192
- if (TEST_EXIT_CODE !== 0) {
193
- echo "❌ Tests failed. Analyzing failures...";
194
-
195
- // Parse test output to identify failures
196
- const failures = parseTestFailures(testOutput);
197
-
198
- // CRITICAL: DO NOT PROCEED. Fix the code.
199
- for (const failure of failures) {
200
- echo ` - ${failure.testName}: ${failure.reason}`;
201
-
202
- // Identify what needs fixing
203
- if (failure.reason.includes("NullReferenceException")) {
204
- // Fix null handling in implementation
205
- } else if (failure.reason.includes("Expected") && failure.reason.includes("Actual")) {
206
- // Fix logic to match expected behavior
207
- } else if (failure.reason.includes("NotImplementedException")) {
208
- // Implement missing method
209
- }
210
- }
211
-
212
- // After fixes, RE-RUN TESTS (step 3)
213
- // LOOP until TEST_EXIT_CODE === 0
214
-
215
- // If cannot fix after 3 attempts:
216
- task.status = 'failed';
217
- task.error = `Tests failed after 3 fix attempts: ${failures.map(f => f.testName).join(', ')}`;
218
- // STOP - do not proceed to commit
219
- }
220
-
221
- if (TEST_EXIT_CODE === 0) {
222
- echo "✅ All tests passed!";
223
- {validation_result} = "passed";
224
- }
91
+ # Category-specific:
92
+ infrastructure → mcp__smartstack__check_migrations
93
+ api → mcp__smartstack__validate_security
94
+ frontend → mcp__smartstack__validate_frontend_routes
95
+ test → mcp__smartstack__analyze_test_coverage
225
96
  ```
226
97
 
227
- **5. VERIFY TEST COVERAGE (MANDATORY ≥80%)**
228
-
229
- ```javascript
230
- // Use MCP to analyze coverage
231
- const coverage = mcp__smartstack__analyze_test_coverage({
232
- project_path: process.cwd(),
233
- module: extractModuleName(task.description)
234
- });
235
-
236
- if (coverage.percentage < 80) {
237
- echo `⚠️ Test coverage ${coverage.percentage}% < 80% minimum`;
238
- echo `Missing coverage for: ${coverage.uncovered_files.join(', ')}`;
239
-
240
- // Generate additional tests for uncovered code
241
- for (const file of coverage.uncovered_files) {
242
- mcp__smartstack__scaffold_tests({
243
- module: extractModuleName(task.description),
244
- test_type: "unit",
245
- target_file: file
246
- });
247
- }
98
+ If validation fails: fix re-validate → do NOT proceed until clean.
248
99
 
249
- // Re-run tests (go back to step 3)
250
- }
251
-
252
- echo `✅ Test coverage: ${coverage.percentage}% (${coverage.lines_covered}/${coverage.lines_total} lines)`;
253
- ```
254
-
255
- **6. TEST TASK COMPLETION CRITERIA**
256
-
257
- A test task is ONLY complete when:
258
- - ✅ Test project exists
259
- - ✅ Tests generated via MCP (NOT manually written)
260
- - ✅ `dotnet test` exits with code 0 (all tests pass)
261
- - ✅ Test coverage ≥ 80%
262
- - ✅ No `[Fact(Skip = "...")]` present (no skipped tests)
263
-
264
- **If ANY criterion fails, task.status = 'failed' and DO NOT commit.**
265
-
266
- **Validation task guidance — FINAL VERIFICATION (BLOCKING):**
267
-
268
- > **CRITICAL:** The validation task is the LAST task in each module. It verifies the module is production-ready.
100
+ ### 7. Check Acceptance Criteria
269
101
 
270
- When executing `validation` category tasks, follow this EXACT sequence:
102
+ Verify against `{current_task_criteria}`. If not met: continue working. If impossible: document in `task.error`.
271
103
 
272
- **1. CLEAN BUILD (MANDATORY)**
104
+ ### 8. Build & Test Verification (BLOCKING)
273
105
 
106
+ **Backend — EVERY task (domain, infra, application, api):**
274
107
  ```bash
275
- echo "🔨 Running clean build..."
276
-
277
- # Clean previous builds
278
- dotnet clean --verbosity quiet
279
-
280
- # Restore dependencies
281
- dotnet restore --verbosity quiet
282
-
283
- # Build entire solution
284
- dotnet build --no-restore --verbosity normal
285
-
286
- BUILD_EXIT_CODE=$?
287
-
288
- if [ $BUILD_EXIT_CODE -ne 0 ]; then
289
- echo "╔════════════════════════════════════════════════════════════╗"
290
- echo "║ ❌ BUILD FAILED ║"
291
- echo "╠════════════════════════════════════════════════════════════╣"
292
- echo "║ The solution does not compile. ║"
293
- echo "║ This indicates a critical error in the code. ║"
294
- echo "╠════════════════════════════════════════════════════════════╣"
295
- echo "║ CORRECTIVE ACTION: ║"
296
- echo "║ 1. Review build errors above ║"
297
- echo "║ 2. Fix compilation errors ║"
298
- echo "║ 3. Re-run: dotnet build ║"
299
- echo "║ 4. Once build succeeds, Ralph will continue ║"
300
- echo "╚════════════════════════════════════════════════════════════╝"
301
-
302
- task.status = 'failed';
303
- task.error = 'Build failed. See build output for details.';
304
- exit 1;
305
- fi
306
-
307
- echo "✅ Build succeeded";
108
+ dotnet build --no-restore
308
109
  ```
110
+ If FAIL → read error output → identify file:line → fix code → rebuild → loop until exit code 0.
309
111
 
310
- **2. RUN FULL TEST SUITE (MANDATORY)**
311
-
112
+ **Test category tasks MANDATORY execution:**
312
113
  ```bash
313
- echo "🧪 Running full test suite..."
314
-
315
- PROJECT_NAME=$(basename $(pwd))
316
- TEST_PROJECT="tests/${PROJECT_NAME}.Tests.Unit"
317
-
318
- if [ ! -d "$TEST_PROJECT" ]; then
319
- echo "⚠️ WARNING: No test project found at $TEST_PROJECT";
320
- echo "This module has NO tests. This is NOT recommended.";
321
- task.validation = "warning: no tests";
322
- else
323
- # Run ALL tests with detailed output
324
- dotnet test "$TEST_PROJECT" --no-build --verbosity normal --logger "console;verbosity=detailed"
325
-
326
- TEST_EXIT_CODE=$?
327
-
328
- if [ $TEST_EXIT_CODE -ne 0 ]; then
329
- echo "╔════════════════════════════════════════════════════════════╗"
330
- echo "║ ❌ TESTS FAILED ║"
331
- echo "╠════════════════════════════════════════════════════════════╣"
332
- echo "║ One or more tests are failing. ║"
333
- echo "║ The module is NOT production-ready. ║"
334
- echo "╠════════════════════════════════════════════════════════════╣"
335
- echo "║ CORRECTIVE ACTION: ║"
336
- echo "║ 1. Review test failures above ║"
337
- echo "║ 2. Fix the failing code or tests ║"
338
- echo "║ 3. Re-run: dotnet test ║"
339
- echo "║ 4. Once all tests pass, Ralph will continue ║"
340
- echo "╚════════════════════════════════════════════════════════════╝"
341
-
342
- task.status = 'failed';
343
- task.error = 'Test suite failed. Module not production-ready.';
344
- exit 1;
345
- fi
346
-
347
- echo "✅ All tests passed";
348
- fi
349
- ```
350
-
351
- **3. MCP VALIDATION (MANDATORY)**
352
-
353
- ```javascript
354
- echo "🔍 Running MCP validation...";
355
-
356
- // Validate SmartStack conventions
357
- const validation = mcp__smartstack__validate_conventions({
358
- checks: ["all"]
359
- });
360
-
361
- if (validation.status === "error" || validation.errors.length > 0) {
362
- echo "❌ MCP validation failed:";
363
- for (const error of validation.errors) {
364
- echo ` - ${error.file}: ${error.message}`;
365
- }
366
-
367
- task.status = 'failed';
368
- task.error = `MCP validation failed: ${validation.errors.length} error(s)`;
369
- exit 1;
370
- }
371
-
372
- if (validation.warnings.length > 0) {
373
- echo "⚠️ MCP validation warnings:";
374
- for (const warning of validation.warnings) {
375
- echo ` - ${warning.file}: ${warning.message}`;
376
- }
377
- task.validation = `passed with ${validation.warnings.length} warning(s)`;
378
- } else {
379
- task.validation = "passed";
380
- }
381
-
382
- echo "✅ MCP validation passed";
383
- ```
384
-
385
- **4. GENERATE VALIDATION REPORT**
386
-
387
- ```javascript
388
- const report = {
389
- module: {current_module},
390
- build: { status: "success", duration: buildDuration },
391
- tests: {
392
- status: TEST_EXIT_CODE === 0 ? "success" : "failed",
393
- total: testStats.total,
394
- passed: testStats.passed,
395
- failed: testStats.failed,
396
- skipped: testStats.skipped,
397
- duration: testStats.duration,
398
- coverage: coverage.percentage
399
- },
400
- mcp: {
401
- status: validation.status,
402
- errors: validation.errors.length,
403
- warnings: validation.warnings.length
404
- },
405
- production_ready: (BUILD_EXIT_CODE === 0 && TEST_EXIT_CODE === 0 && validation.errors.length === 0)
406
- };
407
-
408
- // Append to progress.txt
409
- const progressEntry = `
410
- ╔═══════════════════════════════════════════════════════════════╗
411
- ║ MODULE VALIDATION REPORT - ${current_module}
412
- ╠═══════════════════════════════════════════════════════════════╣
413
- ║ Build: ${report.build.status.toUpperCase()}
414
- ║ Tests: ${report.tests.passed}/${report.tests.total} passed (${report.tests.coverage}% coverage)
415
- ║ MCP: ${report.mcp.status.toUpperCase()} (${report.mcp.errors} errors, ${report.mcp.warnings} warnings)
416
- ║ Production Ready: ${report.production_ready ? "YES ✅" : "NO ❌"}
417
- ╚═══════════════════════════════════════════════════════════════╝
418
- `;
419
- appendToFile('.ralph/progress.txt', progressEntry);
420
-
421
- echo progressEntry;
422
- ```
423
-
424
- **5. VALIDATION TASK COMPLETION CRITERIA**
425
-
426
- A validation task is ONLY complete when:
427
- - ✅ `dotnet build` exits with code 0
428
- - ✅ `dotnet test` exits with code 0 (or no test project + warning logged)
429
- - ✅ MCP `validate_conventions` has 0 errors
430
- - ✅ Production ready = true
431
-
432
- **If ANY criterion fails, task.status = 'failed', module is NOT production-ready, and Ralph STOPS.**
433
-
434
- **Infrastructure task guidance (MANDATORY directory conventions):**
435
-
436
- When executing `infrastructure` category tasks, follow these rules strictly:
437
-
438
- 1. **Core seed data (navigation, permissions, roles) — CONDITIONAL REFERENCE LOADING:**
439
-
440
- > **IF** the current task description contains "seed data", "SeedData",
441
- > "NavigationModule", "PermissionsSeedData", "RolesSeedData", or "IClientSeedDataProvider":
442
- > **THEN read `references/core-seed-data.md`** for COMPLETE execution guidance including:
443
- > - Parameter extraction from PRD seedDataCore / task `_seedDataMeta`
444
- > - MCP `generate_permissions` call sequence (primary) with fallback templates
445
- > - `NavigationModuleSeedData.cs` template (deterministic GUIDs, 4 languages)
446
- > - `PermissionsSeedData.cs` template (wraps MCP output)
447
- > - `RolesSeedData.cs` template (context-based role mapping)
448
- > - `IClientSeedDataProvider` complete implementation template
449
- > - DI registration pattern
450
- > - Verification checklist (BLOCKING)
451
- >
452
- > **This reference is MANDATORY for seed data tasks. Do NOT improvise.**
453
-
454
- **Directory convention:** All seed data files MUST go under `Infrastructure/Persistence/Seeding/Data/{Module}/`
455
- - NEVER use `Infrastructure/Data/SeedData/` or `Data/SeedData/`
456
-
457
- 2. **IClientSeedDataProvider** (client projects with `extensions` DbContext):
458
- - Generate at `Infrastructure/Persistence/Seeding/{AppPascalName}SeedDataProvider.cs`
459
- - Register in DI: `services.AddScoped<IClientSeedDataProvider, {AppPascalName}SeedDataProvider>()`
460
- - Must implement: SeedNavigationAsync, SeedPermissionsAsync, SeedRolePermissionsAsync
461
- - **Complete template and rules in `references/core-seed-data.md`**
462
-
463
- 3. **DevDataSeeder** for domain entity seed data:
464
- - Located at `Infrastructure/Persistence/Seeding/DevDataSeeder.cs`
465
- - Implements `IDevDataSeeder`, registered in DI
466
-
467
- 4. **Migrations** MUST all be in `Infrastructure/Persistence/Migrations/`
468
- - NEVER create subdirectories under Migrations/
469
- - Always use `-o Persistence/Migrations` flag with `dotnet ef migrations add`
470
-
471
- 5. **SQL Objects** go under `Infrastructure/Persistence/SqlObjects/`
472
- - `Functions/` for TVFs and scalar functions (.sql files)
473
- - Use `SqlObjectHelper.cs` for embedded resource loading
474
- - Use `CREATE OR ALTER` in SQL files for idempotency
475
-
476
- **Frontend task guidance — MCP-FIRST PROTOCOL (MANDATORY):**
477
-
478
- > **CRITICAL:** Frontend code is generated via MCP tools, NOT written from scratch.
479
- > Writing plain HTML tables, custom div cards, or hardcoded Tailwind is FORBIDDEN.
480
- > The MCP tools produce SmartStack-compliant code automatically.
481
-
482
- **Execution sequence for frontend tasks (follow IN ORDER):**
483
-
484
- 1. **Call `mcp__smartstack__scaffold_api_client`** FIRST
485
- - Generates: `{entity}Api.ts` with type-safe CRUD methods + React Query hook
486
- - Uses `apiClient` (NOT axios), NavRoute integration, permission checking
487
- - Output: `src/services/api/{module}Api.ts`
488
-
489
- 2. **Call `mcp__smartstack__scaffold_routes`** (source: "controllers", scope: "all")
490
- - Updates: `navRoutes.generated.ts` + route config in App.tsx
491
- - Generates: Nested routes INSIDE correct Layout wrapper
492
- - Context mapping: `business.*` → `BusinessLayout`, `platform.*` → `AdminLayout`
493
-
494
- 3. **Create pages using SmartStack components** (reference: `templates-frontend.md`)
495
- - **List pages**: Use `SmartTable` (NOT HTML `<table>`), `SmartFilter`, `EntityCard` for grid view
496
- - **Detail pages**: Use `EntityDetailCard`, `StatusBadge`, tab layout
497
- - **Create/Edit pages**: Use `SmartForm` with `FluentValidation`-backed fields, tab layout
498
- - **Dashboard pages**: Use `StatCard`, Recharts components
499
- - Match wireframes from feature.json `specification.uiWireframes[]`
500
-
501
- 4. **Create preferences hook**: `use{Module}Preferences.ts`
502
- - pageSize, sortColumn, sortDirection, visibleColumns, viewMode, filters
503
-
504
- 5. **Generate i18n** (4 languages: fr, en, it, de)
505
- - All UI labels, validation messages, button text, empty states
506
-
507
- 6. **Post-generation validation (BLOCKING)**:
508
- - `npm run typecheck` MUST pass
509
- - NO hardcoded colors (scan for `bg-blue-`, `text-gray-`, etc.)
510
- - CSS variables ONLY: `bg-[var(--bg-card)]`, `text-[var(--text-primary)]`
511
- - Routes are NESTED and INSIDE Layout wrapper
512
- - All pages have loading/error/empty states
513
- - API client uses `@/services/api/apiClient` (NOT `import axios`)
514
- - `EntityCard` for grid views (NOT custom `<div>` cards)
515
-
516
- **FORBIDDEN patterns (any of these = FAIL the task):**
517
- ```
518
- import axios from 'axios' → use @/services/api/apiClient
519
- <table>...</table> → use SmartTable component
520
- <div className="bg-blue-600"> → use bg-[var(--color-accent-600)]
521
- <Route path="/business/app/mod" /> → MUST be nested inside BusinessLayout
522
- Only fr/en translations → MUST have 4 languages (fr, en, it, de)
523
- ```
524
-
525
- **Layout wrapper mapping:**
526
- | Context | Layout | Route path |
527
- |---------|--------|------------|
528
- | `platform.*` | `AdminLayout` | `/platform` |
529
- | `business.*` | `BusinessLayout` | `/business` |
530
- | `personal.*` | `UserLayout` | `/personal/myspace` |
531
-
532
- **Backend folder hierarchy (MANDATORY for ALL layers):**
533
-
534
- > **CRITICAL:** ALL backend files MUST be organized by `{ContextPascal}/{ApplicationName}/{ModuleName}/` hierarchy.
535
- > Derive from PRD `project.application` and feature.json `metadata.context`.
536
- > The file paths in prd.json already include this hierarchy — follow them exactly.
537
-
538
- When executing `domain`, `application`, `infrastructure`, `api`, or `test` category tasks:
539
-
540
- 1. **ALL layers use context/application/module folder hierarchy:**
541
-
542
- | Layer | Path Pattern |
543
- |-------|-------------|
544
- | Domain | `Domain/Entities/{ContextPascal}/{App}/{Module}/{Entity}.cs` |
545
- | Domain Enums | `Domain/Enums/{ContextPascal}/{App}/{Module}/{Enum}.cs` |
546
- | Domain Exceptions | `Domain/Exceptions/{ContextPascal}/{App}/{Module}/{Exception}.cs` |
547
- | Application Services | `Application/Services/{ContextPascal}/{App}/{Module}/{Service}.cs` |
548
- | Application DTOs | `Application/DTOs/{ContextPascal}/{App}/{Module}/{Dto}.cs` |
549
- | Application Validators | `Application/Validators/{ContextPascal}/{App}/{Module}/{Validator}.cs` |
550
- | Infrastructure Configs | `Infrastructure/Persistence/Configurations/{ContextPascal}/{App}/{Module}/{Config}.cs` |
551
- | API Controllers | `Api/Controllers/{ContextShort}/{App}/{Entity}Controller.cs` |
552
- | Tests | `Tests/Unit/Domain/{ContextPascal}/{App}/{Module}/{Tests}.cs` |
553
-
554
- 2. **Controller context-to-folder mapping (`{ContextShort}`):**
555
-
556
- | NavRoute Prefix | Controller Folder |
557
- |-----------------|-------------------|
558
- | `platform.administration` | `Admin` |
559
- | `platform.support` | `Support` |
560
- | `business.*` | `Business` |
561
- | `personal.*` | `User` |
562
-
563
- 3. **Reference:** SmartStack.app `Api/Controllers/` for the canonical structure
564
-
565
- ### 4. Explore Context (if needed)
566
-
567
- **Use subagents sparingly:**
568
-
569
- ```
570
- If exploration needed:
571
- - Use explore-codebase agent for file discovery
572
- - Use explore-docs agent for library docs
573
- - Use Context7 MCP for documentation
574
- ```
575
-
576
- **Prefer direct tool usage:**
577
- - Glob for file patterns
578
- - Grep for code search
579
- - Read for file contents
580
-
581
- ### 5. Execute Implementation
582
-
583
- **Implement the task:**
584
-
585
- - Create/modify files as needed
586
- - Follow existing patterns in codebase
587
- - Use SmartStack conventions
588
- - Add appropriate logging
589
- - Handle errors properly
590
-
591
- **Track every file operation:**
592
-
593
- ```
594
- {files_created} = [] // Accumulate as you create files
595
- {files_modified} = [] // Accumulate as you modify files
596
- ```
597
-
598
- **Use TodoWrite to track sub-steps:**
599
-
600
- ```
601
- If task has multiple parts:
602
- 1. Create TodoWrite entries for each part
603
- 2. Mark in_progress as you work
604
- 3. Mark completed when done
605
- ```
606
-
607
- ### 6. Validate with MCP
608
-
609
- **After implementation, validate based on category:**
610
-
611
- ```
612
- # Always run general validation
613
- mcp__smartstack__validate_conventions:
614
- checks: ["all"]
615
-
616
- # Category-specific validation
617
- if category == "infrastructure":
618
- mcp__smartstack__check_migrations
619
-
620
- if category == "api":
621
- mcp__smartstack__validate_security
622
-
623
- if category == "frontend":
624
- mcp__smartstack__validate_frontend_routes
625
-
626
- if category == "test":
627
- mcp__smartstack__analyze_test_coverage
628
- ```
629
-
630
- **Record validation result:**
631
- ```
632
- {validation_result} = "passed" | "failed: {reason}"
633
- ```
634
-
635
- **If validation fails:**
636
- - Fix the issues
637
- - Re-validate
638
- - Do NOT proceed until valid
639
- - If cannot fix: set `{validation_result} = "failed: {reason}"`
640
-
641
- ### 7. Check Acceptance Criteria
642
-
643
- **Verify against `{current_task_criteria}`:**
644
-
645
- ```
646
- ULTRA THINK: Does the implementation satisfy the acceptance criteria?
647
-
648
- Criteria: {current_task_criteria}
649
-
650
- ✅ Met / ❌ Not met (explain why)
114
+ TEST_PROJECT="tests/$(basename $(pwd)).Tests.Unit"
115
+ dotnet build "$TEST_PROJECT" --no-restore
116
+ dotnet test "$TEST_PROJECT" --no-build --verbosity normal
651
117
  ```
118
+ If FAIL → analyze failing test names → fix SOURCE CODE (not tests) → rebuild → retest.
119
+ **Loop until 100% pass — NEVER proceed with failing tests.**
652
120
 
653
- **If criteria NOT met:**
654
- - Continue working until met
655
- - If impossible to meet: document in `{task_error}`
656
-
657
- ### 8. Run Quick Tests
658
-
659
- **If applicable:**
660
-
121
+ **Frontend tasks MANDATORY verification:**
661
122
  ```bash
662
- # For backend changes (domain, application, infrastructure, api)
663
- dotnet build --no-restore 2>&1
664
-
665
- # For frontend changes
666
- npm run lint && npm run typecheck
667
-
668
- # For test category
669
- dotnet test --filter "FullyQualifiedName~{relevant_test}"
123
+ npm run typecheck # TypeScript compilation MUST exit 0
124
+ npm run lint # ESLint — MUST exit 0
670
125
  ```
126
+ If FAIL → read errors → fix TSX/TS files → re-run → loop until pass.
671
127
 
672
- **If tests fail:**
673
- - Fix the failing tests
674
- - Re-run until passing
675
- - Document what was fixed
676
-
677
- ### 9. Update Task State in prd.json
128
+ **Error resolution cycle (ALL categories):**
129
+ 1. Read the FULL error output (not just first line)
130
+ 2. Identify root cause: file path + line number
131
+ 3. Fix the issue in source code
132
+ 4. Rebuild: `dotnet build --no-restore` or `npm run typecheck`
133
+ 5. If still failing repeat from step 1
134
+ 6. **NEVER** mark task completed with failing build or tests
135
+ 7. **NEVER** skip the verification — it is BLOCKING
678
136
 
679
- **Persist tracking data BEFORE committing:**
137
+ ### 9. Update Task State
680
138
 
681
139
  ```javascript
682
- const prd = readJSON('.ralph/prd.json');
683
- const task = prd.tasks.find(t => t.id === {current_task_id});
684
-
685
- task.files_changed = {
686
- created: {files_created},
687
- modified: {files_modified}
688
- };
140
+ task.files_changed = { created: {files_created}, modified: {files_modified} };
689
141
  task.validation = {validation_result};
690
-
691
- // If task failed
692
- if ({task_failed}) {
693
- task.status = 'failed';
694
- task.error = '{failure_reason}';
695
- task.completed_at = new Date().toISOString();
696
- }
697
-
142
+ if ({task_failed}) { task.status = 'failed'; task.error = '{reason}'; task.completed_at = now; }
698
143
  prd.updated_at = new Date().toISOString();
699
144
  writeJSON('.ralph/prd.json', prd);
700
145
  ```
701
146
 
702
- **Note: `task.status` stays `"in_progress"` until step-03 confirms the commit. Only `"failed"` is set here if the task cannot be completed.**
703
-
704
- ---
705
-
706
- ## IMPORTANT CONSTRAINTS:
707
-
708
- ### What TO DO:
709
- - Implement exactly what the task describes
710
- - Follow existing patterns
711
- - Validate changes with MCP
712
- - Track all file operations
713
- - Check acceptance criteria
714
- - Write minimal, clean code
715
-
716
- ### What NOT TO DO:
717
- - Don't implement other tasks
718
- - Don't refactor unrelated code
719
- - Don't add "nice to have" features
720
- - Don't skip validation
721
- - Don't forget to track files
722
-
723
- ---
724
-
725
- ## OUTPUT FORMAT:
726
-
727
- ```
728
- Task Executed:
729
-
730
- | Action | Details |
731
- |--------|---------|
732
- | Task | [{current_task_id}] {current_task_description} |
733
- | Category | {current_task_category} |
734
- | Files Created | {files_created} |
735
- | Files Modified | {files_modified} |
736
- | Validation | {validation_result} |
737
- | Acceptance | ✅ Criteria met |
738
- | Tests | ✅ Passed |
739
-
740
- -> Committing changes...
741
- ```
147
+ Note: `task.status` stays `"in_progress"` until step-03 confirms commit. Only `"failed"` is set here.
742
148
 
743
149
  ---
744
150
 
745
- ## ERROR HANDLING:
746
-
747
- **If task cannot be completed:**
748
-
749
- 1. Document the blocker in `task.error`
750
- 2. Set `task.status = "failed"` in prd.json
751
- 3. Update progress.txt with learnings
752
- 4. Proceed to step-03 to save progress (commit what was done)
753
- 5. step-04 will handle blocked downstream tasks
754
-
755
- **If build fails:**
756
-
757
- 1. Analyze error messages
758
- 2. Fix the issues
759
- 3. Re-build until success
760
- 4. Then proceed
761
-
762
- **If validation fails:**
151
+ ## CONSTRAINTS:
763
152
 
764
- 1. Fix validation issues
765
- 2. Re-validate until clean
766
- 3. If unfixable: document in `task.error`, set `task.validation = "failed: {reason}"`
153
+ **DO:** Implement exactly what task describes, follow patterns, validate with MCP, track files, check criteria.
154
+ **DON'T:** Implement other tasks, refactor unrelated code, add extras, skip validation.
767
155
 
768
156
  ---
769
157