@atlashub/smartstack-cli 3.7.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 (133) hide show
  1. package/dist/index.js +365 -2
  2. package/dist/index.js.map +1 -1
  3. package/package.json +4 -2
  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 +3214 -2246
  42. package/templates/skills/business-analyse/html/build-html.js +77 -0
  43. package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +130 -0
  44. package/templates/skills/business-analyse/html/src/scripts/02-navigation.js +22 -0
  45. package/templates/skills/business-analyse/html/src/scripts/03-render-cadrage.js +208 -0
  46. package/templates/skills/business-analyse/html/src/scripts/04-render-modules.js +211 -0
  47. package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +554 -0
  48. package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +110 -0
  49. package/templates/skills/business-analyse/html/src/scripts/07-render-handoff.js +90 -0
  50. package/templates/skills/business-analyse/html/src/scripts/08-editing.js +45 -0
  51. package/templates/skills/business-analyse/html/src/scripts/09-export.js +168 -0
  52. package/templates/skills/business-analyse/html/src/scripts/10-comments.js +171 -0
  53. package/templates/skills/business-analyse/html/src/scripts/11-review-panel.js +161 -0
  54. package/templates/skills/business-analyse/html/src/styles/01-variables.css +38 -0
  55. package/templates/skills/business-analyse/html/src/styles/02-layout.css +101 -0
  56. package/templates/skills/business-analyse/html/src/styles/03-navigation.css +62 -0
  57. package/templates/skills/business-analyse/html/src/styles/04-cards.css +196 -0
  58. package/templates/skills/business-analyse/html/src/styles/05-modules.css +325 -0
  59. package/templates/skills/business-analyse/html/src/styles/06-wireframes.css +230 -0
  60. package/templates/skills/business-analyse/html/src/styles/07-comments.css +184 -0
  61. package/templates/skills/business-analyse/html/src/styles/08-review-panel.css +241 -0
  62. package/templates/skills/business-analyse/html/src/template.html +623 -0
  63. package/templates/skills/business-analyse/references/cadrage-structure-cards.md +78 -0
  64. package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +97 -0
  65. package/templates/skills/business-analyse/references/consolidation-structural-checks.md +92 -0
  66. package/templates/skills/business-analyse/references/deploy-data-build.md +121 -0
  67. package/templates/skills/business-analyse/references/deploy-modes.md +49 -0
  68. package/templates/skills/business-analyse/references/handoff-file-templates.md +119 -0
  69. package/templates/skills/business-analyse/references/handoff-mappings.md +81 -0
  70. package/templates/skills/business-analyse/references/html-data-mapping.md +10 -2
  71. package/templates/skills/business-analyse/references/init-schema-deployment.md +65 -0
  72. package/templates/skills/business-analyse/references/review-data-mapping.md +363 -0
  73. package/templates/skills/business-analyse/references/spec-auto-inference.md +57 -0
  74. package/templates/skills/business-analyse/references/ui-dashboard-spec.md +85 -0
  75. package/templates/skills/business-analyse/references/ui-resource-cards.md +110 -0
  76. package/templates/skills/business-analyse/references/validate-incremental-html.md +55 -0
  77. package/templates/skills/business-analyse/steps/step-00-init.md +35 -68
  78. package/templates/skills/business-analyse/steps/step-01-cadrage.md +5 -194
  79. package/templates/skills/business-analyse/steps/step-03a-data.md +6 -49
  80. package/templates/skills/business-analyse/steps/step-03b-ui.md +12 -178
  81. package/templates/skills/business-analyse/steps/step-03d-validate.md +3 -48
  82. package/templates/skills/business-analyse/steps/step-04-consolidation.md +9 -104
  83. package/templates/skills/business-analyse/steps/step-05a-handoff.md +25 -441
  84. package/templates/skills/business-analyse/steps/step-05b-deploy.md +19 -187
  85. package/templates/skills/business-analyse/steps/step-06-review.md +277 -0
  86. package/templates/skills/cc-agent/references/agent-behavior-patterns.md +95 -0
  87. package/templates/skills/cc-agent/steps/step-02-generate.md +5 -78
  88. package/templates/skills/check-version/SKILL.md +7 -0
  89. package/templates/skills/controller/references/controller-code-templates.md +159 -0
  90. package/templates/skills/controller/references/permission-sync-templates.md +152 -0
  91. package/templates/skills/controller/steps/step-03-generate.md +6 -158
  92. package/templates/skills/controller/steps/step-04-perms.md +5 -144
  93. package/templates/skills/debug/SKILL.md +7 -0
  94. package/templates/skills/explore/SKILL.md +6 -0
  95. package/templates/skills/feature-full/SKILL.md +39 -142
  96. package/templates/skills/feature-full/steps/step-01-implementation.md +120 -0
  97. package/templates/skills/gitflow/references/init-config-template.md +135 -0
  98. package/templates/skills/gitflow/references/init-name-normalization.md +103 -0
  99. package/templates/skills/gitflow/references/plan-template.md +69 -0
  100. package/templates/skills/gitflow/references/start-efcore-preflight.md +70 -0
  101. package/templates/skills/gitflow/references/start-local-config.md +110 -0
  102. package/templates/skills/gitflow/steps/step-init.md +18 -289
  103. package/templates/skills/gitflow/steps/step-plan.md +6 -63
  104. package/templates/skills/gitflow/steps/step-start.md +16 -126
  105. package/templates/skills/mcp/SKILL.md +9 -213
  106. package/templates/skills/mcp/steps/step-01-healthcheck.md +108 -0
  107. package/templates/skills/mcp/steps/step-02-tools.md +73 -0
  108. package/templates/skills/notification/SKILL.md +7 -0
  109. package/templates/skills/quick-search/SKILL.md +5 -0
  110. package/templates/skills/ralph-loop/SKILL.md +99 -381
  111. package/templates/skills/ralph-loop/references/category-rules.md +259 -0
  112. package/templates/skills/ralph-loop/references/compact-loop.md +182 -0
  113. package/templates/skills/ralph-loop/references/task-transform-legacy.md +259 -0
  114. package/templates/skills/ralph-loop/references/team-orchestration.md +189 -0
  115. package/templates/skills/ralph-loop/steps/step-00-init.md +111 -383
  116. package/templates/skills/ralph-loop/steps/step-01-task.md +79 -896
  117. package/templates/skills/ralph-loop/steps/step-02-execute.md +68 -680
  118. package/templates/skills/ralph-loop/steps/step-03-commit.md +47 -277
  119. package/templates/skills/ralph-loop/steps/step-04-check.md +124 -607
  120. package/templates/skills/ralph-loop/steps/step-05-report.md +68 -367
  121. package/templates/skills/refactor/SKILL.md +12 -176
  122. package/templates/skills/refactor/steps/step-01-discover.md +60 -0
  123. package/templates/skills/refactor/steps/step-02-execute.md +67 -0
  124. package/templates/skills/review-code/SKILL.md +19 -257
  125. package/templates/skills/review-code/steps/step-01-smartstack.md +96 -0
  126. package/templates/skills/review-code/steps/step-02-detailed-review.md +80 -0
  127. package/templates/skills/review-code/steps/step-03-react.md +44 -0
  128. package/templates/skills/ui-components/SKILL.md +7 -0
  129. package/templates/skills/utils/SKILL.md +6 -0
  130. package/templates/skills/validate/SKILL.md +6 -0
  131. package/templates/skills/validate-feature/SKILL.md +8 -0
  132. package/templates/skills/workflow/SKILL.md +40 -118
  133. package/templates/skills/workflow/steps/step-01-implementation.md +84 -0
@@ -0,0 +1,164 @@
1
+ # Agent Teams Protocol — APEX
2
+
3
+ > **Loaded by:** step-01 (analysis scan) and step-03 (parallel execution)
4
+ > **Condition:** NOT economy_mode
5
+ > **Purpose:** Reusable protocol for TeamCreate, coordination, and shutdown.
6
+
7
+ ---
8
+
9
+ ## Team Creation (T08)
10
+
11
+ ```yaml
12
+ TeamCreate:
13
+ team_name: "apex-{phase}" # e.g., "apex-analyze", "apex-exec"
14
+ description: "{phase purpose}" # e.g., "Scan SmartStack project for existing code"
15
+ ```
16
+
17
+ Always provide both `team_name` and `description`.
18
+
19
+ ---
20
+
21
+ ## Teammate Spawning (T12)
22
+
23
+ ```yaml
24
+ Task:
25
+ subagent_type: "general-purpose"
26
+ team_name: "apex-{phase}" # Must match TeamCreate
27
+ name: "{teammate-name}" # e.g., "scan-backend", "exec-frontend"
28
+ model: "sonnet" | "opus" # sonnet for scan, opus for dev (T02/T06)
29
+ mode: "bypassPermissions"
30
+ prompt: "{detailed task prompt}"
31
+ ```
32
+
33
+ ### Model Assignment (T02/T06)
34
+
35
+ | Task Type | Model | Justification |
36
+ |-----------|-------|---------------|
37
+ | Scan/read files | Sonnet | Read-only, no analysis needed |
38
+ | Read context (PRD, feature.json) | Sonnet | Read-only extraction |
39
+ | Code development | Opus | Complex generation via skills/MCP |
40
+ | Fix/resolve | Opus | Requires reasoning |
41
+
42
+ ---
43
+
44
+ ## Task List Coordination (T10)
45
+
46
+ Team lead manages the task list:
47
+
48
+ ```
49
+ 1. TaskCreate: create task for each work item, assign owner
50
+ 2. Teammate: TaskUpdate(status: "in_progress") before starting
51
+ 3. Teammate: TaskUpdate(status: "completed") after finishing
52
+ 4. Lead: TaskList to monitor progress
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Communication (T09)
58
+
59
+ **Default:** Direct messages (DM) between specific agents.
60
+
61
+ ```yaml
62
+ SendMessage:
63
+ type: "message" # DM, not broadcast
64
+ recipient: "{teammate-name}" # By name, not UUID
65
+ content: "{message}"
66
+ summary: "{5-10 word preview}"
67
+ ```
68
+
69
+ **Broadcast:** ONLY for emergency (all-stop, critical blocker).
70
+
71
+ ```yaml
72
+ SendMessage:
73
+ type: "broadcast" # Expensive: N teammates = N deliveries
74
+ content: "{urgent message}"
75
+ summary: "{critical issue summary}"
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Team Decomposition (C01)
81
+
82
+ ### Step-01 Analyze: Split by scan scope
83
+
84
+ ```
85
+ scan-backend : Domain/ + Infrastructure/ + Application/ + Api/
86
+ scan-frontend : src/pages/ + src/components/ + src/locales/
87
+ scan-context : .ralph/ + docs/business/
88
+ ```
89
+
90
+ ### Step-03 Execute: Split by execution layer
91
+
92
+ ```
93
+ exec-backend : Application services + API controllers + Seed data
94
+ exec-frontend : Pages + Components + Routes + I18n
95
+ ```
96
+
97
+ Each teammate has an **isolated scope** (C02): backend never touches frontend.
98
+
99
+ ---
100
+
101
+ ## Coordination (C03)
102
+
103
+ ### Step-01: Lead aggregates scan results
104
+
105
+ ```
106
+ 1. Spawn 3 scan teammates
107
+ 2. Each reports findings via DM to lead
108
+ 3. Lead merges into unified analysis
109
+ ```
110
+
111
+ ### Step-03: Lead verifies between layers
112
+
113
+ ```
114
+ 1. Layer 0: lead executes (domain + infra + migration)
115
+ 2. Build gate: dotnet build --no-restore → MUST PASS
116
+ 3. Layer 1: spawn exec-backend + exec-frontend
117
+ 4. Wait for both to complete
118
+ 5. Build gate: dotnet build + npm typecheck → MUST PASS
119
+ 6. Layer 2: lead executes final validation
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Idle Handling (T13)
125
+
126
+ Teammates go idle after every turn — this is **normal**.
127
+ - Idle does NOT mean done or unavailable
128
+ - Sending a message to an idle teammate wakes them up
129
+ - Do NOT treat idle as an error
130
+
131
+ ---
132
+
133
+ ## Graceful Shutdown (T11)
134
+
135
+ After phase completes:
136
+
137
+ ```yaml
138
+ # For each teammate:
139
+ SendMessage:
140
+ type: "shutdown_request"
141
+ recipient: "{teammate-name}"
142
+ content: "Phase complete, shutting down"
143
+
144
+ # Teammate responds:
145
+ SendMessage:
146
+ type: "shutdown_response"
147
+ request_id: "{from_request}"
148
+ approve: true
149
+
150
+ # After all confirmations:
151
+ TeamDelete
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Decision Matrix
157
+
158
+ | Condition | Action |
159
+ |-----------|--------|
160
+ | economy_mode = true | NO teams, all sequential |
161
+ | Only backend work | NO teams, agent principal |
162
+ | Only frontend work | NO teams, agent principal |
163
+ | Backend + Frontend | Teams: exec-backend + exec-frontend |
164
+ | Analysis phase | Teams: scan-backend + scan-frontend + scan-context |
@@ -0,0 +1,173 @@
1
+ # SmartStack Layers — Execution Rules & Skill/MCP Mapping
2
+
3
+ > **Loaded by:** step-02 (planning) and step-03 (execution)
4
+ > **Purpose:** Defines per-layer folder conventions, skill/MCP tools, and verification rules.
5
+
6
+ ---
7
+
8
+ ## Layer 0 — Domain (sequential)
9
+
10
+ **Entities:** `Domain/Entities/{ContextPascal}/{App}/{Module}/`
11
+ **Enums:** `Domain/Enums/{ContextPascal}/{App}/{Module}/`
12
+ **Exceptions:** `Domain/Exceptions/{ContextPascal}/{App}/{Module}/`
13
+
14
+ | Action | Tool |
15
+ |--------|------|
16
+ | Create entity | MCP `scaffold_extension` (type: entity) |
17
+ | Validate | MCP `validate_conventions` |
18
+
19
+ **Rules:**
20
+ - Inherit `AuditableEntity`, implement `IHasData` for multi-tenant
21
+ - Audit fields: CreatedAt, CreatedBy, ModifiedAt, ModifiedBy
22
+ - Domain events for state changes
23
+ - Value objects for composite values
24
+
25
+ ---
26
+
27
+ ## Layer 0 — Infrastructure: EF Core (sequential)
28
+
29
+ **Configs:** `Infrastructure/Persistence/Configurations/{ContextPascal}/{App}/{Module}/`
30
+ **Migrations:** `Infrastructure/Persistence/Migrations/` (NEVER subdirectories)
31
+
32
+ | Action | Tool |
33
+ |--------|------|
34
+ | Create config | MCP `scaffold_extension` (type: configuration) |
35
+ | Create migration | MCP `suggest_migration` → `dotnet ef migrations add` |
36
+ | Validate | MCP `check_migrations` |
37
+
38
+ **Rules:**
39
+ - One config per entity, table name = plural
40
+ - All relationships explicitly configured
41
+ - Indexes on FKs and frequent queries
42
+ - Register DbSet in ExtensionsDbContext
43
+ - Migration name ALWAYS from MCP `suggest_migration`
44
+ - Migration flag: `-o Persistence/Migrations`
45
+
46
+ **BLOCKING:** `dotnet build --no-restore` MUST pass after migration.
47
+
48
+ ---
49
+
50
+ ## Layer 1 — Application (parallel with API)
51
+
52
+ **Services:** `Application/Services/{ContextPascal}/{App}/{Module}/`
53
+ **DTOs:** `Application/DTOs/{ContextPascal}/{App}/{Module}/`
54
+ **Validators:** `Application/Validators/{ContextPascal}/{App}/{Module}/`
55
+
56
+ | Action | Tool |
57
+ |--------|------|
58
+ | Create service/DTO | MCP `scaffold_extension` |
59
+ | Complex service logic | /application skill |
60
+ | Validate | MCP `validate_conventions` |
61
+
62
+ **Rules:**
63
+ - CQRS with MediatR
64
+ - FluentValidation for all commands
65
+ - DTOs separate from domain entities
66
+ - Service interfaces in Application, implementations in Infrastructure
67
+
68
+ ---
69
+
70
+ ## Layer 1 — API (parallel with Application)
71
+
72
+ **Controllers:** `Api/Controllers/{ContextShort}/{App}/{Entity}Controller.cs`
73
+
74
+ | Context | Controller Folder |
75
+ |---------|-------------------|
76
+ | `platform.administration` | `Admin` |
77
+ | `platform.support` | `Support` |
78
+ | `business.*` | `Business` |
79
+ | `personal.*` | `User` |
80
+
81
+ | Action | Tool |
82
+ |--------|------|
83
+ | Simple CRUD controller | MCP `scaffold_extension` |
84
+ | Complex controller | /controller skill |
85
+ | Validate | MCP `validate_security` |
86
+
87
+ **Rules:**
88
+ - `[RequirePermission(Permissions.{Module}.{Action})]` on EVERY endpoint
89
+ - NEVER use `[Authorize]` without specific permission
90
+ - Swagger XML documentation
91
+ - Return DTOs, never domain entities
92
+
93
+ ---
94
+
95
+ ## Layer 1 — Seed Data (parallel)
96
+
97
+ **Folder:** `Infrastructure/Persistence/Seeding/Data/{ModulePascal}/`
98
+
99
+ | Action | Tool |
100
+ |--------|------|
101
+ | Generate permissions | MCP `generate_permissions` (PRIMARY) |
102
+ | Navigation seed | Template below |
103
+ | Roles seed | Template below |
104
+ | Provider | Template below |
105
+
106
+ ### Seed Data Chain (5 files)
107
+
108
+ 1. **NavigationModuleSeedData.cs** — Deterministic GUIDs (SHA256), 4 languages
109
+ 2. **PermissionsSeedData.cs** — MCP `generate_permissions` first, fallback template
110
+ 3. **RolesSeedData.cs** — Context-based: Admin=CRUD, Manager=CRU, Contributor=CR, Viewer=R
111
+ 4. **SeedConstants.cs** — Shared deterministic GUIDs
112
+ 5. **{App}SeedDataProvider.cs** — Implements IClientSeedDataProvider
113
+ - SeedNavigationAsync + SeedPermissionsAsync + SeedRolePermissionsAsync
114
+ - DI: `services.AddScoped<IClientSeedDataProvider, {App}SeedDataProvider>()`
115
+
116
+ **FORBIDDEN:**
117
+ - `Guid.NewGuid()` → use deterministic GUIDs (SHA256)
118
+ - Missing translations (must have fr, en, it, de)
119
+ - Empty seed classes with no seeding logic
120
+
121
+ ---
122
+
123
+ ## Layer 2 — Frontend (parallel with I18n)
124
+
125
+ **Pages:** `src/pages/{ContextPascal}/{AppPascal}/{Module}/`
126
+ **Components:** `src/components/{Module}/`
127
+
128
+ | Action | Tool |
129
+ |--------|------|
130
+ | API client | MCP `scaffold_api_client` |
131
+ | Routes | MCP `scaffold_routes` |
132
+ | Complex pages | /ui-components skill |
133
+ | Validate routes | MCP `validate_frontend_routes` |
134
+
135
+ **Layout mapping:**
136
+
137
+ | Context | Layout | Route prefix |
138
+ |---------|--------|-------------|
139
+ | `platform.*` | `AdminLayout` | `/platform` |
140
+ | `business.*` | `BusinessLayout` | `/business` |
141
+ | `personal.*` | `UserLayout` | `/personal/myspace` |
142
+
143
+ **Components:** SmartTable, SmartFilter, EntityCard, SmartForm, StatCard (NEVER raw HTML)
144
+ **CSS:** Variables only → `bg-[var(--bg-card)]`, `text-[var(--text-primary)]`
145
+
146
+ **FORBIDDEN:**
147
+ - `src/pages/{Module}/` (flat, missing Context/App)
148
+ - `import axios` → use `@/services/api/apiClient`
149
+ - `<table>` → use SmartTable
150
+ - Hardcoded colors → use CSS variables
151
+ - Only fr/en → MUST have 4 languages
152
+
153
+ ---
154
+
155
+ ## Layer 2 — I18n
156
+
157
+ 4 JSON files: fr, en, it, de — identical key structures.
158
+
159
+ ---
160
+
161
+ ## Layer 3 — Tests (sequential, if -t)
162
+
163
+ | Action | Tool |
164
+ |--------|------|
165
+ | Unit tests (domain) | MCP `scaffold_tests` (target_layer: domain) |
166
+ | Unit tests (app) | MCP `scaffold_tests` (target_layer: application) |
167
+ | Integration tests (api) | MCP `scaffold_tests` (target_layer: api, type: integration) |
168
+ | Security tests | MCP `scaffold_tests` (type: security) |
169
+ | Coverage check | MCP `analyze_test_coverage` |
170
+ | Scenarios | MCP `suggest_test_scenarios` |
171
+
172
+ **Target:** >= 80% coverage, 100% pass rate.
173
+ **Fix CODE, not tests.**
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: step-00-init
3
+ description: Parse flags, detect SmartStack context, verify MCP availability
4
+ model: sonnet
5
+ next_step: steps/step-01-analyze.md
6
+ ---
7
+
8
+ # Step 0: Initialize
9
+
10
+ ## LOAD SHARED
11
+
12
+ Read `_shared.md` for SmartStack detection patterns and MCP tools reference.
13
+
14
+ ---
15
+
16
+ ## 1. Parse Flags
17
+
18
+ Extract flags from the raw input:
19
+
20
+ ```
21
+ Input: "{raw_input}"
22
+
23
+ Flags to detect: -a, -x, -s, -t, -e, -r, -pr
24
+ Remaining text after flag removal = {task_description}
25
+ ```
26
+
27
+ **Defaults:**
28
+
29
+ ```yaml
30
+ auto_mode: false
31
+ examine_mode: false
32
+ save_mode: false
33
+ test_mode: false
34
+ economy_mode: false
35
+ pr_mode: false
36
+ resume_mode: false
37
+ ```
38
+
39
+ ---
40
+
41
+ ## 2. Detect SmartStack Context
42
+
43
+ Scan the project to identify the SmartStack hierarchy:
44
+
45
+ ```
46
+ 1. Glob("*.sln") → confirm .NET project
47
+ 2. Glob("docs/business/**/*") → list existing BA artifacts
48
+ 3. Glob(".ralph/prd-*.json") → list existing PRDs
49
+ 4. Glob("src/pages/**/*.tsx") → confirm frontend exists
50
+ ```
51
+
52
+ **From task description, infer:**
53
+ - `{context_code}`: business (default), platform, personal
54
+ - `{app_name}`: application name
55
+ - `{module_code}`: target module
56
+ - `{sections}`: sections being added/modified
57
+
58
+ **From existing artifacts:**
59
+ - `{prd_path}`: `.ralph/prd-{module_code}.json` if exists
60
+ - `{feature_path}`: `docs/business/{app}/{module}/business-analyse/*/feature.json` if exists
61
+
62
+ **If hierarchy cannot be inferred, ask the user:**
63
+
64
+ ```yaml
65
+ questions:
66
+ - header: "Context"
67
+ question: "What is the SmartStack context for this work?"
68
+ options:
69
+ - label: "Business (Recommended)"
70
+ description: "Business application module"
71
+ - label: "Platform"
72
+ description: "Platform administration or support"
73
+ - label: "Personal"
74
+ description: "Personal user space"
75
+ multiSelect: false
76
+ ```
77
+
78
+ ---
79
+
80
+ ## 3. Verify MCP Availability
81
+
82
+ ```
83
+ Call: mcp__smartstack__validate_conventions (quick connectivity test)
84
+
85
+ IF success → MCP available, proceed normally
86
+ IF failure → warn user, continue in degraded mode (manual tools only)
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 4. Determine Needs
92
+
93
+ ```
94
+ needs_seed_data = true IF:
95
+ - New module or new section with navigation entries
96
+ - Task mentions "navigation", "permissions", "roles", "seed"
97
+
98
+ needs_migration = true IF:
99
+ - New entities or entity modifications detected
100
+ - Task mentions "entity", "field", "table", "column", "migration"
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 5. Resume Mode (if -r)
106
+
107
+ ```
108
+ IF resume_mode:
109
+ 1. Read .claude/output/apex/ → find latest task folder
110
+ 2. Read 00-context.md → restore state variables
111
+ 3. Find last completed step file
112
+ 4. Route to next step directly
113
+ → SKIP to identified next step
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 6. Save Mode Setup (if -s)
119
+
120
+ ```
121
+ IF save_mode:
122
+ 1. Generate task_id: NN-kebab-case from task_description
123
+ 2. Create .claude/output/apex/{task_id}/
124
+ 3. Write 00-context.md with:
125
+ - Timestamp
126
+ - All state variables (generic + SmartStack)
127
+ - Flags
128
+ - Detected hierarchy
129
+ ```
130
+
131
+ ---
132
+
133
+ ## 7. Display Context Summary
134
+
135
+ ```
136
+ **APEX SmartStack - Initialization Complete**
137
+
138
+ **Task:** {task_description}
139
+ **Context:** {context_code} / {app_name} / {module_code}
140
+ **Sections:** {sections}
141
+
142
+ **Sources:**
143
+ - PRD: {prd_path || "none"}
144
+ - Feature: {feature_path || "none"}
145
+
146
+ **Flags:** {active_flags}
147
+ **MCP:** {available|degraded}
148
+ **Needs migration:** {yes|no}
149
+ **Needs seed data:** {yes|no}
150
+ ```
151
+
152
+ ---
153
+
154
+ ## NEXT STEP
155
+
156
+ Load `steps/step-01-analyze.md`
@@ -0,0 +1,169 @@
1
+ ---
2
+ name: step-01-analyze
3
+ description: Explore existing code to understand what exists — do NOT plan yet
4
+ model: opus
5
+ prev_step: steps/step-00-init.md
6
+ next_step: steps/step-02-plan.md
7
+ ---
8
+
9
+ # Step 1: Analyze
10
+
11
+ **Goal:** Understand what EXISTS in the codebase. Pure exploration, NO planning.
12
+
13
+ ## LOAD CONDITIONALLY
14
+
15
+ - If NOT `{economy_mode}`: read `references/agent-teams-protocol.md`
16
+
17
+ ---
18
+
19
+ ## 1. Context Sources
20
+
21
+ Read available context (in order of priority):
22
+
23
+ **A. PRD (if exists):**
24
+ ```
25
+ Read {prd_path} → extract:
26
+ - filesToCreate (7 categories)
27
+ - brToCodeMapping
28
+ - permissionMatrix
29
+ - acceptance criteria
30
+ ```
31
+
32
+ **B. Feature.json (if exists):**
33
+ ```
34
+ Read {feature_path} → extract:
35
+ - Module structure (sections, resources)
36
+ - Business rules
37
+ - Entity definitions
38
+ - Permission structure
39
+ ```
40
+
41
+ **C. Task description only:**
42
+ If neither PRD nor feature.json exists, rely on task description and code exploration.
43
+
44
+ ---
45
+
46
+ ## 2. Code Exploration
47
+
48
+ ### If economy_mode: Direct Tools
49
+
50
+ Use Glob, Grep, Read, and MCP tools directly:
51
+
52
+ ```
53
+ Backend:
54
+ - Glob("**/Domain/Entities/**/{module_code}/**/*.cs")
55
+ - Glob("**/Infrastructure/Persistence/Configurations/**/{module_code}/**/*.cs")
56
+ - Glob("**/Application/Services/**/{module_code}/**/*.cs")
57
+ - Glob("**/Api/Controllers/**/*{module_code}*Controller.cs")
58
+ - Glob("**/Infrastructure/Persistence/Seeding/Data/{module_code}/**/*.cs")
59
+
60
+ Frontend:
61
+ - Glob("src/pages/**/{module_code}/**/*.tsx")
62
+ - Glob("src/components/**/{module_code}/**/*.tsx")
63
+
64
+ MCP:
65
+ - mcp__smartstack__api_docs → existing API surface
66
+ - mcp__smartstack__analyze_extension_points → React extension points
67
+ ```
68
+
69
+ ### If NOT economy_mode: Agent Teams
70
+
71
+ > **Protocol:** See `references/agent-teams-protocol.md`
72
+
73
+ ```
74
+ TeamCreate("apex-analyze", description: "Scan SmartStack project for existing code")
75
+
76
+ Spawn 3 teammates (Sonnet, read-only tools: Glob, Grep, Read):
77
+
78
+ 1. scan-backend:
79
+ "Scan backend code for module {module_code} in app {app_name}.
80
+ Find: entities, EF configs, services, DTOs, validators, controllers.
81
+ Report: file paths, class names, key patterns found.
82
+ Folders: Domain/, Infrastructure/, Application/, Api/"
83
+
84
+ 2. scan-frontend:
85
+ "Scan frontend code for module {module_code} in app {app_name}.
86
+ Find: pages, components, hooks, i18n files, route definitions.
87
+ Report: file paths, component names, route patterns.
88
+ Folders: src/pages/, src/components/, src/locales/"
89
+
90
+ 3. scan-context:
91
+ "Read context artifacts for module {module_code} in app {app_name}.
92
+ Read: .ralph/prd-{module_code}.json, docs/business/**/feature.json.
93
+ Report: sections, entities, business rules, permissions, acceptance criteria."
94
+
95
+ Wait for all 3 teammates to report via SendMessage (DM to lead).
96
+ Aggregate results.
97
+
98
+ Shutdown teammates → TeamDelete("apex-analyze")
99
+ ```
100
+
101
+ ---
102
+
103
+ ## 3. Seed Data Inventory
104
+
105
+ Check existing seed data:
106
+
107
+ ```
108
+ Glob("**/Seeding/Data/{module_code}/*SeedData.cs")
109
+ Glob("**/Seeding/*SeedDataProvider.cs")
110
+ ```
111
+
112
+ Identify:
113
+ - NavigationModuleSeedData: exists? complete?
114
+ - PermissionsSeedData: exists? complete?
115
+ - RolesSeedData: exists? complete?
116
+ - SeedConstants: exists?
117
+ - IClientSeedDataProvider: exists? registered in DI?
118
+
119
+ ---
120
+
121
+ ## 4. Gap Analysis
122
+
123
+ Compare what EXISTS vs what the TASK REQUIRES:
124
+
125
+ ```
126
+ For each element in the task description:
127
+ - EXISTS and COMPLETE → mark as "skip"
128
+ - EXISTS but INCOMPLETE → mark as "modify"
129
+ - DOES NOT EXIST → mark as "create"
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 5. Analysis Summary
135
+
136
+ ```
137
+ **APEX SmartStack - Analysis Complete**
138
+
139
+ **Existing Code:**
140
+ - Entities: {list with paths}
141
+ - EF Configs: {list with paths}
142
+ - Services: {list with paths}
143
+ - Controllers: {list with paths}
144
+ - Frontend pages: {list with paths}
145
+ - Seed data: {status per type}
146
+ - Tests: {list with paths}
147
+
148
+ **Required Changes:**
149
+ - Create: {list of new files/elements}
150
+ - Modify: {list of files to change}
151
+ - Skip: {list of existing complete elements}
152
+
153
+ **Acceptance Criteria:** (inferred from PRD/feature/task)
154
+ - AC1: {criterion}
155
+ - AC2: {criterion}
156
+ ...
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 6. Save Output (if save_mode)
162
+
163
+ Write to `{output_dir}/01-analyze.md` with analysis results.
164
+
165
+ ---
166
+
167
+ ## NEXT STEP
168
+
169
+ Load `steps/step-02-plan.md`