@atlashub/smartstack-cli 3.36.0 → 3.38.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 (219) hide show
  1. package/dist/index.js +16 -24
  2. package/dist/index.js.map +1 -1
  3. package/dist/mcp-entry.mjs +201 -256
  4. package/dist/mcp-entry.mjs.map +1 -1
  5. package/package.json +3 -2
  6. package/scripts/extract-api-endpoints.ts +325 -0
  7. package/scripts/extract-business-rules.ts +440 -0
  8. package/scripts/generate-doc-with-mock-ui.ts +804 -0
  9. package/scripts/health-check.sh +168 -0
  10. package/scripts/postinstall.js +18 -0
  11. package/templates/agents/ba-reader.md +9 -9
  12. package/templates/agents/ba-writer.md +12 -15
  13. package/templates/agents/code-reviewer.md +1 -1
  14. package/templates/agents/docs-context-reader.md +1 -1
  15. package/templates/agents/gitflow/merge.md +0 -4
  16. package/templates/agents/gitflow/pr.md +0 -4
  17. package/templates/agents/gitflow/start.md +30 -5
  18. package/templates/mcp-scaffolding/frontend/nav-routes.ts.hbs +20 -20
  19. package/templates/mcp-scaffolding/frontend/routes.tsx.hbs +16 -24
  20. package/templates/mcp-scaffolding/migrations/seed-roles.cs.hbs +2 -2
  21. package/templates/skills/_resources/mcp-validate-documentation-spec.md +3 -3
  22. package/templates/skills/_shared.md +15 -17
  23. package/templates/skills/ai-prompt/SKILL.md +1 -1
  24. package/templates/skills/ai-prompt/steps/step-00-init.md +47 -0
  25. package/templates/skills/apex/SKILL.md +3 -4
  26. package/templates/skills/apex/_shared.md +10 -20
  27. package/templates/skills/apex/references/analysis-methods.md +141 -0
  28. package/templates/skills/apex/references/challenge-questions.md +1 -21
  29. package/templates/skills/apex/references/core-seed-data.md +35 -57
  30. package/templates/skills/apex/references/examine-build-validation.md +87 -0
  31. package/templates/skills/apex/references/execution-frontend-gates.md +177 -0
  32. package/templates/skills/apex/references/execution-frontend-patterns.md +105 -0
  33. package/templates/skills/apex/references/execution-layer1-rules.md +96 -0
  34. package/templates/skills/apex/references/initialization-challenge-flow.md +110 -0
  35. package/templates/skills/apex/references/planning-layer-mapping.md +151 -0
  36. package/templates/skills/apex/references/post-checks.md +145 -40
  37. package/templates/skills/apex/references/smartstack-api.md +35 -51
  38. package/templates/skills/apex/references/smartstack-frontend.md +17 -17
  39. package/templates/skills/apex/references/smartstack-layers.md +38 -62
  40. package/templates/skills/apex/steps/step-00-init.md +14 -26
  41. package/templates/skills/apex/steps/step-01-analyze.md +10 -143
  42. package/templates/skills/apex/steps/step-02-plan.md +10 -92
  43. package/templates/skills/apex/steps/step-03-execute.md +47 -249
  44. package/templates/skills/apex/steps/step-04-examine.md +14 -78
  45. package/templates/skills/apex/steps/step-05-deep-review.md +2 -2
  46. package/templates/skills/apex/steps/step-08-run-tests.md +2 -0
  47. package/templates/skills/application/SKILL.md +6 -7
  48. package/templates/skills/application/references/backend-controller-hierarchy.md +16 -16
  49. package/templates/skills/application/references/backend-seeding-and-dto-output.md +83 -0
  50. package/templates/skills/application/references/backend-table-prefix-mapping.md +79 -0
  51. package/templates/skills/application/references/backend-verification.md +1 -1
  52. package/templates/skills/application/references/frontend-i18n-and-output.md +67 -0
  53. package/templates/skills/application/references/frontend-route-naming.md +117 -0
  54. package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +107 -0
  55. package/templates/skills/application/references/frontend-verification.md +12 -12
  56. package/templates/skills/application/references/init-parameter-detection.md +120 -0
  57. package/templates/skills/application/references/migration-checklist-troubleshooting.md +100 -0
  58. package/templates/skills/application/references/nav-fallback-procedure.md +5 -6
  59. package/templates/skills/application/references/provider-template.md +2 -6
  60. package/templates/skills/application/references/roles-client-project-handling.md +55 -0
  61. package/templates/skills/application/references/roles-fallback-procedure.md +149 -0
  62. package/templates/skills/application/references/test-coverage-requirements.md +213 -0
  63. package/templates/skills/application/references/test-frontend.md +3 -3
  64. package/templates/skills/application/steps/step-00-init.md +11 -141
  65. package/templates/skills/application/steps/step-01-navigation.md +3 -3
  66. package/templates/skills/application/steps/step-02-permissions.md +4 -4
  67. package/templates/skills/application/steps/step-03-roles.md +18 -175
  68. package/templates/skills/application/steps/step-03b-provider.md +1 -2
  69. package/templates/skills/application/steps/step-04-backend.md +19 -110
  70. package/templates/skills/application/steps/step-05-frontend.md +17 -143
  71. package/templates/skills/application/steps/step-06-migration.md +12 -60
  72. package/templates/skills/application/steps/step-07-tests.md +9 -76
  73. package/templates/skills/application/templates-backend.md +29 -27
  74. package/templates/skills/application/templates-frontend.md +48 -48
  75. package/templates/skills/application/templates-seed.md +57 -131
  76. package/templates/skills/business-analyse/SKILL.md +27 -30
  77. package/templates/skills/business-analyse/_architecture.md +6 -6
  78. package/templates/skills/business-analyse/_shared.md +60 -88
  79. package/templates/skills/business-analyse/questionnaire/04-data.md +3 -3
  80. package/templates/skills/business-analyse/questionnaire/06-security.md +1 -1
  81. package/templates/skills/business-analyse/questionnaire/13-cross-module.md +1 -1
  82. package/templates/skills/business-analyse/react/application-viewer.md +12 -12
  83. package/templates/skills/business-analyse/react/components.md +8 -12
  84. package/templates/skills/business-analyse/react/schema.md +11 -11
  85. package/templates/skills/business-analyse/references/agent-module-prompt.md +2 -3
  86. package/templates/skills/business-analyse/references/analysis-semantic-checks.md +190 -0
  87. package/templates/skills/business-analyse/references/cache-warming-strategy.md +2 -2
  88. package/templates/skills/business-analyse/references/cadrage-challenge-patterns.md +41 -0
  89. package/templates/skills/business-analyse/references/cadrage-coverage-matrix.md +74 -0
  90. package/templates/skills/business-analyse/references/cadrage-shared-modules.md +69 -0
  91. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +1 -1
  92. package/templates/skills/business-analyse/references/compilation-structure-cards.md +297 -0
  93. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +2 -2
  94. package/templates/skills/business-analyse/references/deploy-modes.md +5 -5
  95. package/templates/skills/business-analyse/references/detection-strategies.md +7 -7
  96. package/templates/skills/business-analyse/references/handoff-file-templates.md +14 -22
  97. package/templates/skills/business-analyse/references/handoff-mappings.md +4 -4
  98. package/templates/skills/business-analyse/references/handoff-seeddata-generation.md +312 -0
  99. package/templates/skills/business-analyse/references/init-schema-deployment.md +3 -3
  100. package/templates/skills/business-analyse/references/naming-conventions.md +22 -24
  101. package/templates/skills/business-analyse/references/prd-generation.md +2 -2
  102. package/templates/skills/business-analyse/references/review-data-mapping.md +2 -2
  103. package/templates/skills/business-analyse/references/robustness-checks.md +1 -1
  104. package/templates/skills/business-analyse/references/spec-auto-inference.md +3 -3
  105. package/templates/skills/business-analyse/references/team-orchestration.md +49 -6
  106. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +1 -1
  107. package/templates/skills/business-analyse/references/ui-resource-cards.md +18 -18
  108. package/templates/skills/business-analyse/references/validate-incremental-html.md +2 -2
  109. package/templates/skills/business-analyse/references/validation-checklist.md +2 -2
  110. package/templates/skills/business-analyse/schemas/application-schema.json +4 -5
  111. package/templates/skills/business-analyse/schemas/project-schema.json +1 -6
  112. package/templates/skills/business-analyse/schemas/sections/metadata-schema.json +2 -3
  113. package/templates/skills/business-analyse/schemas/sections/specification-schema.json +4 -4
  114. package/templates/skills/business-analyse/steps/step-00-init.md +8 -17
  115. package/templates/skills/business-analyse/steps/step-01-cadrage.md +35 -198
  116. package/templates/skills/business-analyse/steps/step-01b-applications.md +16 -20
  117. package/templates/skills/business-analyse/steps/step-02-decomposition.md +1 -1
  118. package/templates/skills/business-analyse/steps/step-03a1-setup.md +4 -4
  119. package/templates/skills/business-analyse/steps/step-03a2-analysis.md +1 -1
  120. package/templates/skills/business-analyse/steps/step-03b-ui.md +4 -4
  121. package/templates/skills/business-analyse/steps/step-03c-compile.md +66 -140
  122. package/templates/skills/business-analyse/steps/step-03d-validate.md +2 -2
  123. package/templates/skills/business-analyse/steps/step-04a-collect.md +2 -2
  124. package/templates/skills/business-analyse/steps/step-04b-analyze.md +42 -160
  125. package/templates/skills/business-analyse/steps/step-04c-decide.md +1 -1
  126. package/templates/skills/business-analyse/steps/step-05a-handoff.md +74 -104
  127. package/templates/skills/business-analyse/steps/step-05b-deploy.md +13 -11
  128. package/templates/skills/business-analyse/steps/step-06-review.md +3 -3
  129. package/templates/skills/business-analyse/templates/tpl-frd.md +13 -13
  130. package/templates/skills/business-analyse/templates/tpl-handoff.md +12 -12
  131. package/templates/skills/business-analyse/templates-frd.md +25 -25
  132. package/templates/skills/business-analyse/templates-react.md +15 -21
  133. package/templates/skills/controller/SKILL.md +1 -1
  134. package/templates/skills/controller/postman-templates.md +1 -1
  135. package/templates/skills/controller/references/controller-code-templates.md +2 -2
  136. package/templates/skills/controller/references/mcp-scaffold-workflow.md +209 -0
  137. package/templates/skills/controller/references/permission-sync-templates.md +13 -16
  138. package/templates/skills/controller/steps/step-00-init.md +11 -11
  139. package/templates/skills/controller/steps/step-03-generate.md +64 -103
  140. package/templates/skills/controller/templates.md +67 -71
  141. package/templates/skills/debug/SKILL.md +13 -218
  142. package/templates/skills/debug/steps/step-00-init.md +57 -0
  143. package/templates/skills/debug/steps/step-01-analyze.md +219 -0
  144. package/templates/skills/debug/steps/step-02-resolve.md +85 -0
  145. package/templates/skills/documentation/SKILL.md +49 -345
  146. package/templates/skills/documentation/data-schema.md +11 -8
  147. package/templates/skills/documentation/steps/step-00-init.md +70 -0
  148. package/templates/skills/documentation/steps/step-01-scan.md +113 -0
  149. package/templates/skills/documentation/steps/step-02-generate.md +231 -0
  150. package/templates/skills/documentation/steps/step-03-validate.md +238 -0
  151. package/templates/skills/documentation/templates.md +480 -322
  152. package/templates/skills/efcore/references/both-contexts.md +32 -0
  153. package/templates/skills/efcore/references/database-operations.md +67 -0
  154. package/templates/skills/efcore/references/destructive-operations.md +38 -0
  155. package/templates/skills/efcore/references/reset-operations.md +81 -0
  156. package/templates/skills/efcore/references/seed-methods.md +86 -0
  157. package/templates/skills/efcore/references/shared-init-functions.md +250 -0
  158. package/templates/skills/efcore/references/sql-objects-injection.md +61 -0
  159. package/templates/skills/efcore/references/troubleshooting.md +81 -0
  160. package/templates/skills/efcore/steps/db/step-deploy.md +1 -32
  161. package/templates/skills/efcore/steps/db/step-reset.md +7 -103
  162. package/templates/skills/efcore/steps/db/step-seed.md +10 -132
  163. package/templates/skills/efcore/steps/db/step-status.md +5 -44
  164. package/templates/skills/efcore/steps/migration/step-03-validate.md +8 -62
  165. package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +1 -57
  166. package/templates/skills/efcore/steps/shared/step-00-init.md +11 -254
  167. package/templates/skills/efcore/steps/squash/step-03-create.md +1 -58
  168. package/templates/skills/feature-full/SKILL.md +1 -1
  169. package/templates/skills/feature-full/steps/step-00-init.md +57 -0
  170. package/templates/skills/feature-full/steps/step-01-implementation.md +1 -1
  171. package/templates/skills/gitflow/SKILL.md +1 -1
  172. package/templates/skills/gitflow/_shared.md +23 -0
  173. package/templates/skills/gitflow/references/commit-message-generation.md +58 -0
  174. package/templates/skills/gitflow/references/commit-migration-validation.md +49 -0
  175. package/templates/skills/gitflow/references/finish-cleanup.md +51 -0
  176. package/templates/skills/gitflow/references/finish-version-bumping.md +45 -0
  177. package/templates/skills/gitflow/references/init-environment-detection.md +41 -0
  178. package/templates/skills/gitflow/references/init-questions.md +185 -0
  179. package/templates/skills/gitflow/references/init-structure-creation.md +71 -0
  180. package/templates/skills/gitflow/references/init-version-detection.md +21 -0
  181. package/templates/skills/gitflow/references/init-workspace-detection.md +43 -0
  182. package/templates/skills/gitflow/references/merge-ci-status.md +36 -0
  183. package/templates/skills/gitflow/references/merge-execution.md +62 -0
  184. package/templates/skills/gitflow/references/merge-pr-context.md +76 -0
  185. package/templates/skills/gitflow/references/pr-build-checks.md +60 -0
  186. package/templates/skills/gitflow/references/pr-generation.md +58 -0
  187. package/templates/skills/gitflow/references/start-branch-normalization.md +28 -0
  188. package/templates/skills/gitflow/references/start-worktree-creation.md +50 -0
  189. package/templates/skills/gitflow/references/sync-push-verify.md +44 -0
  190. package/templates/skills/gitflow/references/sync-rebase-conflicts.md +38 -0
  191. package/templates/skills/gitflow/steps/step-commit.md +12 -91
  192. package/templates/skills/gitflow/steps/step-finish.md +15 -159
  193. package/templates/skills/gitflow/steps/step-init.md +24 -326
  194. package/templates/skills/gitflow/steps/step-merge.md +17 -176
  195. package/templates/skills/gitflow/steps/step-pr.md +10 -116
  196. package/templates/skills/gitflow/steps/step-start.md +16 -109
  197. package/templates/skills/gitflow/steps/step-sync.md +6 -69
  198. package/templates/skills/ralph-loop/SKILL.md +6 -0
  199. package/templates/skills/ralph-loop/references/category-completeness.md +185 -0
  200. package/templates/skills/ralph-loop/references/compact-loop.md +1 -1
  201. package/templates/skills/ralph-loop/references/init-resume-recovery.md +127 -0
  202. package/templates/skills/ralph-loop/references/module-transition.md +151 -0
  203. package/templates/skills/ralph-loop/references/multi-module-queue.md +171 -0
  204. package/templates/skills/ralph-loop/references/parallel-execution.md +246 -0
  205. package/templates/skills/ralph-loop/references/task-transform-legacy.md +6 -9
  206. package/templates/skills/ralph-loop/references/team-orchestration.md +45 -3
  207. package/templates/skills/ralph-loop/steps/step-00-init.md +36 -109
  208. package/templates/skills/ralph-loop/steps/step-01-task.md +15 -163
  209. package/templates/skills/ralph-loop/steps/step-02-execute.md +8 -154
  210. package/templates/skills/ralph-loop/steps/step-04-check.md +21 -73
  211. package/templates/skills/review-code/references/owasp-api-top10.md +5 -5
  212. package/templates/skills/review-code/references/smartstack-conventions.md +11 -11
  213. package/templates/skills/validate-feature/references/api-smoke-tests.md +140 -0
  214. package/templates/skills/validate-feature/references/db-validation-checks.md +180 -0
  215. package/templates/skills/validate-feature/steps/step-01-compile.md +5 -2
  216. package/templates/skills/validate-feature/steps/step-04-api-smoke.md +34 -145
  217. package/templates/skills/validate-feature/steps/step-05-db-validation.md +74 -260
  218. package/templates/skills/workflow/SKILL.md +1 -1
  219. package/templates/skills/workflow/steps/step-00-init.md +57 -0
@@ -0,0 +1,87 @@
1
+ # Examine Build & Migration Validation
2
+
3
+ > **Loaded by:** step-04-examine.md (sections 4-5)
4
+ > **Purpose:** Build verification, migration validation, database testing procedures.
5
+
6
+ ---
7
+
8
+ ## Build Verification
9
+
10
+ ```bash
11
+ # Cleanup corrupted EF Core design-time artifacts (Roslyn BuildHost bug on Windows/WSL)
12
+ for d in src/*/bin?Debug bin?Debug; do [ -d "$d" ] && echo "Removing corrupted artifact: $d" && rm -rf "$d"; done
13
+
14
+ # Backend
15
+ dotnet clean && dotnet restore && dotnet build
16
+
17
+ # Post-build cleanup (WSL Roslyn recreates literal bin\Debug folders after each build)
18
+ for d in src/*/bin?Debug bin?Debug; do [ -d "$d" ] && rm -rf "$d"; done
19
+
20
+ # Frontend (if applicable)
21
+ npm run typecheck
22
+ ```
23
+
24
+ **BLOCKING:** Both must pass. If failure, classify error per `references/error-classification.md`:
25
+ - Category A (missing package) → `dotnet add package` → rebuild
26
+ - Category B (assembly conflict) → resolve version → rebuild
27
+ - Category C (DI missing) → fix DI registration → rebuild
28
+ - Category D (migration broken) → fix migration → rebuild
29
+ - Category E (config) → fix config → rebuild
30
+ - Category F (source code) → fix code → rebuild
31
+
32
+ ---
33
+
34
+ ## Migration Validation (if needs_migration)
35
+
36
+ ### Pending Model Changes Check
37
+
38
+ ```bash
39
+ INFRA_PROJECT=$(ls src/*Infrastructure*/*.csproj 2>/dev/null | head -1)
40
+ API_PROJECT=$(ls src/*Api*/*.csproj 2>/dev/null | head -1)
41
+
42
+ dotnet ef migrations has-pending-model-changes \
43
+ --project "$INFRA_PROJECT" \
44
+ --startup-project "$API_PROJECT"
45
+ ```
46
+
47
+ **BLOCKING** if pending changes detected → migration is missing.
48
+
49
+ ### Migration Application Test (SQL Server LocalDB)
50
+
51
+ ```bash
52
+ DB_NAME="SmartStack_Apex_Examine_$(date +%s)"
53
+ CONN_STRING="Server=(localdb)\\MSSQLLocalDB;Database=$DB_NAME;Integrated Security=true;TrustServerCertificate=true;Connect Timeout=120;"
54
+
55
+ dotnet ef database update \
56
+ --connection "$CONN_STRING" \
57
+ --project "$INFRA_PROJECT" \
58
+ --startup-project "$API_PROJECT"
59
+ ```
60
+
61
+ **BLOCKING** if migration fails on SQL Server. Common issues:
62
+ - SQLite-only syntax in migrations (fix: regenerate migration)
63
+ - Column type mismatches (fix: update EF configuration)
64
+ - Missing foreign key targets (fix: reorder migrations)
65
+
66
+ ### Integration Tests on Real SQL Server
67
+
68
+ ```bash
69
+ # Integration tests use DatabaseFixture → real SQL Server LocalDB
70
+ # This validates: LINQ→SQL, multi-tenant isolation, soft delete, EF configs
71
+ INT_TEST_PROJECT=$(ls tests/*Tests.Integration*/*.csproj 2>/dev/null | head -1)
72
+ if [ -n "$INT_TEST_PROJECT" ]; then
73
+ dotnet test "$INT_TEST_PROJECT" --no-build --verbosity normal
74
+ fi
75
+ ```
76
+
77
+ Tests running against SQL Server catch issues that SQLite misses:
78
+ - Case sensitivity in string comparisons
79
+ - Date/time function differences
80
+ - IDENTITY vs AUTOINCREMENT behavior
81
+ - Global query filter translation to T-SQL
82
+
83
+ ### Cleanup
84
+
85
+ ```bash
86
+ sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "IF DB_ID('$DB_NAME') IS NOT NULL BEGIN ALTER DATABASE [$DB_NAME] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [$DB_NAME]; END" 2>/dev/null
87
+ ```
@@ -0,0 +1,177 @@
1
+ # Frontend Compliance Gate — 5 Mandatory Checks
2
+
3
+ > **Loaded by:** step-03-execute.md (FRONTEND COMPLIANCE GATE section)
4
+ > **Condition:** MANDATORY before any frontend commit
5
+ > **Purpose:** Automated checks that catch the most common failures in generated code.
6
+
7
+ ---
8
+
9
+ ## Gate 1: CSS Variables (Theme System)
10
+
11
+ Check for hardcoded Tailwind colors — MUST use CSS variables.
12
+
13
+ ```bash
14
+ ALL_PAGES=$(find src/pages/ src/components/ -name "*.tsx" 2>/dev/null | grep -v node_modules | grep -v "\.test\.")
15
+ if [ -n "$ALL_PAGES" ]; then
16
+ HARDCODED=$(grep -Pn '(bg|text|border)-(?!\[)(red|blue|green|gray|white|black|slate|zinc|neutral|stone)-' $ALL_PAGES 2>/dev/null)
17
+ if [ -n "$HARDCODED" ]; then
18
+ echo "FAIL: Hardcoded Tailwind colors found — must use CSS variables"
19
+ echo "$HARDCODED"
20
+ else
21
+ echo "PASS: CSS variables"
22
+ fi
23
+ fi
24
+ ```
25
+
26
+ **If hardcoded colors found, replace BEFORE committing:**
27
+
28
+ | Old | New |
29
+ |-----|-----|
30
+ | `bg-white` | `bg-[var(--bg-card)]` |
31
+ | `bg-gray-50` | `bg-[var(--bg-primary)]` |
32
+ | `text-gray-900` | `text-[var(--text-primary)]` |
33
+ | `text-gray-500/600` | `text-[var(--text-secondary)]` |
34
+ | `border-gray-200` | `border-[var(--border-color)]` |
35
+ | `bg-blue-600` / `text-blue-600` | `bg-[var(--color-accent-500)]` / `text-[var(--color-accent-500)]` |
36
+ | `hover:bg-blue-700` | `hover:bg-[var(--color-accent-600)]` |
37
+ | `text-red-500` | `text-[var(--error-text)]` |
38
+ | `bg-green-500` | `bg-[var(--success-bg)]` |
39
+
40
+ ---
41
+
42
+ ## Gate 2: Forms as Pages (ZERO Modals/Drawers/Slide-overs)
43
+
44
+ Check for modal/dialog/drawer/slide-over imports and inline form patterns — FORBIDDEN.
45
+
46
+ ```bash
47
+ PAGE_FILES=$(find src/pages/ -name "*.tsx" 2>/dev/null)
48
+ if [ -n "$PAGE_FILES" ]; then
49
+ FAIL=false
50
+
51
+ # 2a. Component imports
52
+ MODAL_IMPORTS=$(grep -Pn "import.*(?:Modal|Dialog|Drawer|Popup|Sheet|SlideOver|Overlay)" $PAGE_FILES 2>/dev/null)
53
+ if [ -n "$MODAL_IMPORTS" ]; then
54
+ echo "FAIL: Modal/Dialog/Drawer component imports — forms MUST be full pages"
55
+ echo "$MODAL_IMPORTS"
56
+ FAIL=true
57
+ fi
58
+
59
+ # 2b. State variables for inline forms (catches drawers/slide-overs without imports)
60
+ MODAL_STATE=$(grep -Pn "useState.*(?:isOpen|showModal|showDialog|showCreate|showEdit|showForm|isCreating|isEditing|showDrawer|showPanel|showSlideOver|selectedEntity|editingEntity)" $PAGE_FILES 2>/dev/null)
61
+ if [ -n "$MODAL_STATE" ]; then
62
+ echo "FAIL: Inline form state detected — forms MUST be separate page components with own routes"
63
+ echo "$MODAL_STATE"
64
+ FAIL=true
65
+ fi
66
+
67
+ if [ "$FAIL" = true ]; then
68
+ echo "Fix: Create EntityCreatePage.tsx (route: /create) and EntityEditPage.tsx (route: /:id/edit)"
69
+ echo "See smartstack-frontend.md section 3b"
70
+ else
71
+ echo "PASS: No modals/drawers"
72
+ fi
73
+ fi
74
+ ```
75
+
76
+ **If modals/drawers found:** Replace with separate `EntityCreatePage.tsx` (route: `/{module}/create`) and `EntityEditPage.tsx` (route: `/{module}/:id/edit`). See `smartstack-frontend.md` section 3b.
77
+
78
+ ---
79
+
80
+ ## Gate 3: I18n File Structure
81
+
82
+ Verify translation files exist as separate JSON per language.
83
+
84
+ ```bash
85
+ if [ ! -d "src/i18n/locales" ]; then
86
+ echo "FAIL: Missing src/i18n/locales/ directory — create it with 4 languages"
87
+ else
88
+ for LANG in fr en it de; do
89
+ JSON_FILES=$(find "src/i18n/locales/$LANG" -name "*.json" 2>/dev/null | wc -l)
90
+ if [ "$JSON_FILES" -eq 0 ]; then
91
+ echo "FAIL: No JSON files in src/i18n/locales/$LANG/"
92
+ else
93
+ echo "PASS: $LANG ($JSON_FILES files)"
94
+ fi
95
+ done
96
+ fi
97
+ ```
98
+
99
+ **If i18n structure wrong:** Create `src/i18n/locales/{fr,en,it,de}/{module}.json` following the template in `smartstack-frontend.md` section 2. NEVER embed translations in a single `.ts` file.
100
+
101
+ **Correct structure:**
102
+ ```
103
+ src/i18n/locales/
104
+ ├── fr/{module}.json ← French (primary)
105
+ ├── en/{module}.json ← English
106
+ ├── it/{module}.json ← Italian
107
+ └── de/{module}.json ← German
108
+ ```
109
+
110
+ Each file MUST contain: `title`, `description`, `actions`, `labels`, `columns`, `form`, `errors`, `validation`, `messages`, `empty`.
111
+
112
+ ---
113
+
114
+ ## Gate 4: Lazy Loading
115
+
116
+ Check for static page imports in route/App files.
117
+
118
+ ```bash
119
+ APP_TSX=$(find src/ -name "App.tsx" -not -path "*/node_modules/*" 2>/dev/null | head -1)
120
+ ROUTE_FILES=$(find src/routes/ -name "*.tsx" -o -name "*.ts" 2>/dev/null)
121
+ if [ -n "$APP_TSX" ]; then
122
+ STATIC_IMPORTS=$(grep -Pn "^import .+ from '@/pages/" "$APP_TSX" $ROUTE_FILES 2>/dev/null)
123
+ if [ -n "$STATIC_IMPORTS" ]; then
124
+ echo "FAIL: Static page imports in App.tsx/routes — MUST use React.lazy()"
125
+ echo "$STATIC_IMPORTS"
126
+ else
127
+ echo "PASS: Lazy loading"
128
+ fi
129
+ fi
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Gate 5: useTranslation in Pages
135
+
136
+ Verify pages use i18n.
137
+
138
+ ```bash
139
+ PAGE_FILES=$(find src/pages/ -name "*.tsx" 2>/dev/null | grep -v "\.test\." | grep -v node_modules)
140
+ if [ -n "$PAGE_FILES" ]; then
141
+ TOTAL=$(echo "$PAGE_FILES" | wc -l)
142
+ WITH_I18N=$(grep -l "useTranslation" $PAGE_FILES 2>/dev/null | wc -l)
143
+ if [ "$WITH_I18N" -eq 0 ]; then
144
+ echo "FAIL: No pages use useTranslation — all text must be translated"
145
+ else
146
+ echo "PASS: $WITH_I18N/$TOTAL pages use useTranslation"
147
+ fi
148
+ fi
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Explicit I18n File Creation
154
+
155
+ When creating i18n files, generate EXACTLY this structure:
156
+
157
+ ```
158
+ src/i18n/locales/
159
+ ├── fr/{module}.json ← French (primary)
160
+ ├── en/{module}.json ← English
161
+ ├── it/{module}.json ← Italian
162
+ └── de/{module}.json ← German
163
+ ```
164
+
165
+ Each file MUST contain these keys: `title`, `description`, `actions`, `labels`, `columns`, `form`, `errors`, `validation`, `messages`, `empty`. See `smartstack-frontend.md` section 2 for the complete JSON template.
166
+
167
+ ---
168
+
169
+ ## ALL 5 Gates MUST PASS
170
+
171
+ **Before creating the frontend commit:**
172
+ 1. Do NOT commit frontend changes until ALL checks pass
173
+ 2. If ANY gate fails, fix the issues first
174
+ 3. When delegating to `/ui-components` skill, include explicit instructions:
175
+ - "CSS: Use CSS variables ONLY — `bg-[var(--bg-card)]`, `text-[var(--text-primary)]`. NEVER use hardcoded Tailwind colors."
176
+ - "Forms: Create/Edit forms are FULL PAGES with own routes (e.g., `/create`, `/:id/edit`). NEVER use modals/dialogs."
177
+ - "I18n: ALL text must use `t('namespace:key', 'Fallback')`. Generate JSON files in `src/i18n/locales/`."
@@ -0,0 +1,105 @@
1
+ # Frontend Patterns — Economy Mode Guidelines
2
+
3
+ > **Loaded by:** step-03-execute.md (Layer 1 section: economy_mode frontend tasks)
4
+ > **Purpose:** Quick reference for frontend creation in sequential (economy) mode.
5
+ > **Detailed patterns:** See `smartstack-frontend.md` (referenced from smartstack-layers.md)
6
+
7
+ ---
8
+
9
+ ## Frontend Tasks — Sequential Execution (economy_mode)
10
+
11
+ For each frontend task in the plan (Layer 1):
12
+
13
+ 1. **API Client:** `MCP scaffold_api_client` → API client + types + React Query hook
14
+ 2. **Routes:** `MCP scaffold_routes` with `outputFormat: 'clientRoutes'` for lazy imports
15
+ 3. **Pages:** **INVOKE `/ui-components` skill** (read SKILL.md + ALL patterns) — MANDATORY for ALL page types
16
+
17
+ ---
18
+
19
+ ## Required Page Types Per Module
20
+
21
+ Create ALL 4 page types per module:
22
+ - `ListPage.tsx` — entity list with SmartTable/EntityCard
23
+ - `DetailPage.tsx` — entity detail view
24
+ - `EntityCreatePage.tsx` (route: `/create`) — FULL PAGE form, NEVER modal
25
+ - `EntityEditPage.tsx` (route: `/:id/edit`) — FULL PAGE form, NEVER modal
26
+
27
+ **Wire ALL routes in App.tsx:** `index` (ListPage), `:id` (DetailPage), `create` (CreatePage), `:id/edit` (EditPage)
28
+
29
+ ---
30
+
31
+ ## Foreign Key (FK) Fields — CRITICAL
32
+
33
+ Any Guid FK property (e.g., EmployeeId, DepartmentId) MUST use `EntityLookup` component:
34
+ - **NEVER** a `<select>` dropdown
35
+ - **NEVER** a `<input type="text">`
36
+ - **A `<select>` loaded from API state is NOT a substitute for EntityLookup**
37
+
38
+ See `smartstack-frontend.md` section 6 for the full EntityLookup pattern. Backend GetAll endpoints MUST support `?search=` parameter (enables EntityLookup on frontend).
39
+
40
+ ---
41
+
42
+ ## Forms: ZERO Modals/Popups/Drawers/Slide-overs
43
+
44
+ **ALL forms are full pages with their own URL:**
45
+ - Create forms: route `/{module}/create`
46
+ - Edit forms: route `/{module}/:id/edit`
47
+ - NEVER embed forms as drawers, panels, or slide-overs
48
+ - Back button with `navigate(-1)` on every form page
49
+
50
+ ---
51
+
52
+ ## Detail Pages: Tab Behavior (CRITICAL)
53
+
54
+ **Tabs MUST switch content LOCALLY via `setActiveTab()` — NEVER `navigate()` to another page.**
55
+
56
+ Sub-resource data (e.g., employee's leaves) loads inline via API call filtered by parent entity ID. See `smartstack-frontend.md` section 3 "Tab Behavior Rules".
57
+
58
+ ---
59
+
60
+ ## Tests (MANDATORY)
61
+
62
+ Generate form tests as co-located files:
63
+ - `EntityCreatePage.test.tsx` (next to CreatePage.tsx)
64
+ - `EntityEditPage.test.tsx` (next to EditPage.tsx)
65
+
66
+ Cover: rendering, validation, submit, pre-fill, navigation, errors. See `smartstack-frontend.md` section 8 for test templates.
67
+
68
+ ---
69
+
70
+ ## Section-Level Routes (if sections exist)
71
+
72
+ **SECTION PERMISSIONS:** After calling `MCP generate_permissions` for the module navRoute (2 segments: `{app}.{module}`), also call it for EACH section navRoute (3 segments: `{app}.{module}.{section}`)
73
+
74
+ **SECTION ROUTES:** After generating module routes, add section child routes to the module's `children` array. Wire `PermissionGuard` for section routes with section-level permissions.
75
+
76
+ ---
77
+
78
+ ## Sub-Resource Handling
79
+
80
+ If a section controller has sub-resource endpoints (e.g., `[HttpGet("types")]` for LeaveTypes inside LeavesController), you MUST EITHER:
81
+ 1. Create dedicated frontend pages for the sub-resource (ListPage, CreatePage, EditPage) with routes wired in App.tsx, OR
82
+ 2. NOT include any `navigate()` button that links to those sub-resource pages
83
+
84
+ **Prefer separate controllers** with `[NavRoute(..., Suffix = "types")]` — see `smartstack-api.md` Sub-Resource Pattern. A dead link (navigate to a route with no page) is a BLOCKING issue (POST-CHECK 42).
85
+
86
+ ---
87
+
88
+ ## I18n (Translations)
89
+
90
+ Generate i18n JSON files for all 4 languages (fr, en, it, de):
91
+ - Location: `src/i18n/locales/{lang}/{module}.json`
92
+ - Keys: `actions`, `labels`, `errors`, `validation`, `columns`, `form`, `messages`, `empty`
93
+ - ALL `t()` calls MUST use namespace prefix + fallback: `t('ns:key', 'Default text')`
94
+
95
+ **CRITICAL:** After creating i18n JSON files, register EACH new namespace in the i18n config file (config.ts/index.ts/i18n.ts). Unregistered namespaces → `useTranslation(['module'])` returns empty strings at runtime. POST-CHECK 45 validates this.
96
+
97
+ ---
98
+
99
+ ## Folder Structure
100
+
101
+ MUST use: `src/pages/{App}/{Module}/` hierarchy (NOT flat).
102
+
103
+ All pages must follow: **hooks → useEffect(load) → loading state → error state → content**
104
+
105
+ Use **CSS variables ONLY** for styling — hardcoded Tailwind colors are BLOCKING (POST-CHECK 13).
@@ -0,0 +1,96 @@
1
+ # Layer 1: Execution Rules — Application + API + Seed Data
2
+
3
+ > **Loaded by:** step-03-execute.md (section: Layer 1)
4
+ > **Purpose:** Critical rules for Layer 1 execution — NavRoute, permissions, validators, code generation, frontend patterns.
5
+
6
+ ---
7
+
8
+ ## NavRoute and Permission Kebab-Case (CRITICAL)
9
+
10
+ **ALL NavRoute segments and permission codes MUST use kebab-case for multi-word identifiers.**
11
+
12
+ Root cause (test-apex-007): Controllers had `[NavRoute("humanresources.employees")]` instead of `[NavRoute("human-resources.employees")]`. This mismatched seed data routes and permission codes, causing 404s and permission denials at runtime.
13
+
14
+ **Rules:**
15
+ - NavRoute: `human-resources.employees` (NEVER `humanresources.employees`)
16
+ - Permissions: `human-resources.employees.read` (segments MATCH NavRoute exactly)
17
+ - Seed data codes: `human-resources` (NEVER `humanresources`)
18
+ - C# class names stay PascalCase (`HumanResourcesController`) — only route/permission strings use kebab-case
19
+ - POST-CHECKs 41 + 48 validate this. Fix BEFORE committing.
20
+
21
+ ---
22
+
23
+ ## Controller Route Attribute (BLOCKING)
24
+
25
+ **Controllers with `[NavRoute]` must NOT have `[Route]` attribute.**
26
+
27
+ Root cause (test-apex-007): ALL 7 controllers had BOTH `[Route("api/...")]` AND `[NavRoute("...")]`. In SmartStack, `[NavRoute]` resolves routes dynamically from Navigation entities in the database at startup. Having `[Route]` alongside causes route conflicts → all endpoints return 404.
28
+
29
+ **Rules:**
30
+ - `[NavRoute("app.module")]` is the ONLY route attribute needed on controllers
31
+ - **FORBIDDEN:** `[Route("api/human-resources/employees")]` alongside `[NavRoute]`
32
+ - **FORBIDDEN:** `[Route("api/[controller]")]` alongside `[NavRoute]`
33
+ - If generating via MCP `scaffold_extension` with `navRoute` option → output is correct (NavRoute only)
34
+ - If generating via `/controller` skill → verify NO `[Route]` is added
35
+ - POST-CHECK 50 validates this. Fix BEFORE committing.
36
+
37
+ ---
38
+
39
+ ## Validators DI Registration (CRITICAL)
40
+
41
+ After creating validators, they MUST be registered in DI. Without registration, `[FromBody]` DTOs are never validated.
42
+
43
+ ```csharp
44
+ In DependencyInjection.cs (or ServiceCollectionExtensions.cs):
45
+ services.AddValidatorsFromAssemblyContaining<Create{Entity}DtoValidator>();
46
+ ```
47
+
48
+ POST-CHECK 46 validates this. If validators exist but no DI registration → BLOCKING.
49
+
50
+ ---
51
+
52
+ ## Date Fields — Use DateOnly (CRITICAL)
53
+
54
+ **ALL date-only fields in DTOs MUST use `DateOnly`, NEVER `string`.**
55
+
56
+ Root cause (test-apex-007): WorkLog DTO had `string Date` instead of `DateOnly Date`. This causes: no date validation, inconsistent date formats, parsing errors.
57
+
58
+ **Type mapping for DTOs:**
59
+
60
+ | Domain type | DTO type | Example |
61
+ |-------------|----------|---------|
62
+ | `DateTime` | `DateTime` | `CreatedAt`, `UpdatedAt` |
63
+ | Date-only field | `DateOnly` | `Date`, `StartDate`, `EndDate`, `BirthDate` |
64
+ | `string` for date | **FORBIDDEN** | Never use `string` for dates |
65
+ | `DateTime` for date-only | **Avoid** | Use `DateOnly` when no time component needed |
66
+
67
+ POST-CHECK 47 validates this. If a DTO has `string` type for a property named `*Date*` → BLOCKING.
68
+
69
+ ---
70
+
71
+ ## Code Generation (if entities have codePattern != "manual")
72
+
73
+ For each entity with auto-generated code pattern (from feature.json or step-02 decisions):
74
+
75
+ ```
76
+ 1. Create CodePatternConfig for the entity (strategy, prefix, digits from codePattern)
77
+ 2. Register ICodeGenerator<TEntity> in DependencyInjection.cs (Infrastructure layer)
78
+ → See references/code-generation.md for DI registration pattern
79
+ 3. Update CreateDto: REMOVE Code property (auto-generated, not user-provided)
80
+ 4. Update CreateDtoValidator: REMOVE Code regex rule (not in DTO anymore)
81
+ 5. Update service CreateAsync: inject ICodeGenerator<TEntity>, call NextCodeAsync()
82
+ → Code is auto-generated BEFORE entity creation
83
+ → See references/code-generation.md for service integration pattern
84
+ 6. Keep Code in ResponseDto (returned to frontend after creation)
85
+ 7. Keep Code in UpdateDto ONLY if code is mutable (rare — discuss with user)
86
+ ```
87
+
88
+ **CRITICAL:** If `codePattern.strategy == "manual"` (or no codePattern), keep the current behavior: Code stays in CreateDto, user provides it, validator has regex rule.
89
+
90
+ ---
91
+
92
+ ## Sequential vs Parallel Execution
93
+
94
+ **If economy_mode:** Execute each item from the plan sequentially using skills and MCP.
95
+
96
+ **If NOT economy_mode:** See `references/agent-teams-protocol.md` for parallel team-based execution with exec-backend and exec-frontend teammates.
@@ -0,0 +1,110 @@
1
+ # Initialization — Challenge Flow & Hierarchy Definition
2
+
3
+ > **Loaded by:** step-00-init.md (sections 4-5)
4
+ > **Purpose:** Detailed flow for challenging user hierarchy assumptions and defining the 4-level navigation structure.
5
+
6
+ ---
7
+
8
+ ## Challenge Questions Reference
9
+
10
+ > **Complete question templates with validation:**
11
+ > Load `references/challenge-questions.md` for the actual YAML question blocks and validation logic.
12
+
13
+ ---
14
+
15
+ ## 4-Level Navigation Hierarchy (BLOCKING RULE)
16
+
17
+ SmartStack uses a **4-level navigation hierarchy:**
18
+ - **Level 1: Application** — e.g., "HumanResources", "ProjectManagement"
19
+ - **Level 2: Module** — e.g., "Employees", "Timesheet"
20
+ - **Level 3: Section** — e.g., "List", "Dashboard", "Approval"
21
+ - **Level 4: Resource** — e.g., "Export", "Settings" (optional)
22
+
23
+ **BLOCKING RULE:** Every module MUST have at least one section. A module without sections produces an incomplete navigation tree, broken seed data, and missing frontend routes.
24
+
25
+ ---
26
+
27
+ ## Step 4: Validate Application Level (4a)
28
+
29
+ Load application question from `references/challenge-questions.md` section 4a.
30
+
31
+ **If `{app_name}` was clearly inferred from the task description:**
32
+ - Skip question, use inferred value
33
+
34
+ **If unclear:**
35
+ - Present question with best guess as recommended option
36
+ - Options:
37
+ 1. "Inferred app name (Recommended)" + description
38
+ 2. "New application" + option to create
39
+ 3. "Existing application" + option to select from scanned projects
40
+ - If "New application": collect `{app_name}`, `{app_code}`, `{app_icon}`, `{app_labels}` (4 langs)
41
+ - If "Existing application": scan `**/Seeding/Data/**/NavigationApplicationSeedData.cs` and present discovered apps
42
+
43
+ ---
44
+
45
+ ## Step 4b: Validate Module Level
46
+
47
+ Load module question from `references/challenge-questions.md` section 4b.
48
+
49
+ **If `{module_code}` was clearly inferred:**
50
+ - Skip question
51
+
52
+ **If unclear:**
53
+ - Present question with best guess(es) as options
54
+ - Options:
55
+ 1. "Inferred module code (Recommended)" + from task description
56
+ 2. "Alternative suggestions" + based on keywords
57
+ - User selects or enters custom value
58
+ - Store as `{module_code}` (kebab-case)
59
+
60
+ ---
61
+
62
+ ## Step 4c: Define Sections (MANDATORY — at least one)
63
+
64
+ Load section questions from `references/challenge-questions.md` section 4c.
65
+
66
+ **BLOCKING VALIDATION:** Sections list MUST contain at least one entry before proceeding.
67
+
68
+ Infer section suggestions from:
69
+ 1. Task description (extract nouns/concepts that suggest functional sub-areas)
70
+ 2. PRD/feature.json if available (module.sections)
71
+ 3. Common patterns: "list" (default for simple CRUD), "dashboard", "settings", "reports"
72
+
73
+ **Question format:**
74
+ ```yaml
75
+ question: "What sections should the module '{module_code}' contain?
76
+ (Select at least one — use 'Other' to add custom sections)"
77
+ options:
78
+ - label: "<inferred section 1>"
79
+ description: "Primary functional area based on module purpose"
80
+ - label: "<inferred section 2>"
81
+ description: "Secondary functional area"
82
+ - label: "<inferred section 3>"
83
+ description: "Additional area inferred from context"
84
+ multiSelect: true
85
+ ```
86
+
87
+ **Validation (BLOCKING):**
88
+ ```
89
+ IF {sections}.length == 0:
90
+ DISPLAY: "Every module must have at least one section."
91
+ → Re-ask the sections question
92
+ → DO NOT proceed to next step
93
+ ```
94
+
95
+ **Store for each section:**
96
+ ```yaml
97
+ sections:
98
+ - code: "section-kebab"
99
+ labels: { fr: "...", en: "...", it: "...", de: "..." }
100
+ icon: "LucideIconName"
101
+ displayOrder: 10
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Delegate Mode Skip (if -d)
107
+
108
+ When `/ralph-loop` invokes `/apex -d {prd_path}`, ALL hierarchy is extracted from the PRD file:
109
+ - Skip sections 2-4 (no interactive questions)
110
+ - Jump directly to section 3 (MCP verify)