@atlashub/smartstack-cli 3.29.0 → 3.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlashub/smartstack-cli",
3
- "version": "3.29.0",
3
+ "version": "3.31.0",
4
4
  "description": "SmartStack Claude Code automation toolkit - GitFlow, EF Core migrations, prompts and more",
5
5
  "author": {
6
6
  "name": "SmartStack",
@@ -287,8 +287,8 @@ Load ONLY relevant categories based on feature type:
287
287
 
288
288
  **Team mode workflow (Propose & Review):**
289
289
  1. Steps 00-02 execute inline in the main conversation (interactive with user)
290
- 2. After step-02 decomposition: `TeamCreate({ team_name: "ba-{appName}" })`
291
- 3. For each module: spawn autonomous agent, agent proposes complete specification, team lead presents to user for validation
290
+ 2. After step-02 decomposition: clean up old team data (§1a), then `TeamCreate({ team_name: "ba-{appName}" })` — **CRITICAL: capture the RETURNED team name** (may differ from requested)
291
+ 3. For each module: spawn autonomous agent using the **returned** team name, agent proposes complete specification, team lead presents to user for validation
292
292
  4. After all modules specified: spawn consolidation agent (steps 04a + 04b), present report for user approval (04c)
293
293
  5. After consolidation approved: spawn handoff agent (steps 05a + 05b + 05c)
294
294
  6. `TeamDelete()` cleanup
@@ -24,12 +24,17 @@ Your mission: specify module "{moduleCode}" completely and autonomously.
24
24
  ## Mode: PROPOSE & REVIEW (Autonomous)
25
25
 
26
26
  You work WITHOUT user interaction:
27
- - Do NOT use AskUserQuestion — you make all decisions autonomously
27
+ - **ABSOLUTE PROHIBITION: NEVER use AskUserQuestion**not in ANY step (03a1, 03a2, 03b, 03c, 03d)
28
+ - The step files you load contain AskUserQuestion calls — these are for INLINE MODE ONLY
29
+ - When you see `AskUserQuestion` in a step file → replace with ULTRATHINK autonomous decision
30
+ - When you see `Ask via AskUserQuestion` → decide autonomously based on context
31
+ - When you see validation options (Auto-corriger, Réviser, etc.) → auto-correct silently
28
32
  - Use ULTRATHINK to reason about every design choice
29
33
  - Base decisions on the context below + SmartStack conventions
30
34
  - Write the specification to feature.json via ba-writer operations
31
35
  - Send a structured proposal summary to the team lead when done
32
36
  - Wait for approval or revision feedback
37
+ - In step-03d: SKIP section 12 (Loop Decision) entirely → go to section 12-bis (Agent Mode)
33
38
 
34
39
  ## Module Context
35
40
 
@@ -223,7 +228,29 @@ SendMessage({
223
228
  summary: "{moduleCode} module complete"
224
229
  })
225
230
 
226
- Then STOP do not proceed to next module. The team lead handles ordering.
231
+ Then WAIT for the team lead to send you a `shutdown_request`.
232
+ Do NOT proceed to next module — the team lead handles module ordering.
233
+
234
+ ### Shutdown handling (MANDATORY):
235
+
236
+ When you receive a message with `type: "shutdown_request"` from the team lead:
237
+ → Extract the `requestId` from the JSON message
238
+ → IMMEDIATELY respond with:
239
+
240
+ ```
241
+ SendMessage({
242
+ type: "shutdown_response",
243
+ request_id: "{requestId from the shutdown_request}",
244
+ approve: true
245
+ })
246
+ ```
247
+
248
+ This terminates your process. Do NOT output any text after sending `shutdown_response`.
249
+
250
+ **IMPORTANT:** Do NOT confuse APPROVED with shutdown. The sequence is:
251
+ 1. Team lead sends `APPROVED:{moduleCode}` → you update status + send `MODULE_COMPLETE`
252
+ 2. Team lead sends `shutdown_request` → you respond with `shutdown_response approve: true` → you terminate
253
+ These are TWO separate steps. Never try to self-terminate or call `shutdown_response` without a `shutdown_request`.
227
254
 
228
255
  ## ID Naming Convention
229
256
 
@@ -10,14 +10,34 @@
10
10
 
11
11
  After step-02 decomposition is complete and client has approved the module structure:
12
12
 
13
+ ### 1a. Clean Up Old Team Data (MANDATORY)
14
+
15
+ Before creating the team, clean up any leftover data from previous sessions to prevent stale task collisions:
16
+
17
+ ```bash
18
+ # Remove leftover task files from previous runs
19
+ rm -f ~/.claude/tasks/ba-{appName}/*.json 2>/dev/null
20
+ # Remove leftover team directory (TeamDelete may leave remnants)
21
+ rm -rf ~/.claude/teams/ba-{appName} 2>/dev/null
13
22
  ```
14
- TeamCreate({ team_name: "ba-{appName}" })
23
+
24
+ > **Why:** If a previous session used the same team name and crashed or was interrupted,
25
+ > leftover task files will be picked up by new agents, causing them to receive stale
26
+ > task_assignment notifications for wrong modules.
27
+
28
+ ### 1b. Create Team and Capture Actual Name
29
+
30
+ ```javascript
31
+ const result = TeamCreate({ team_name: "ba-{appName}" });
32
+ // CRITICAL: TeamCreate may return a DIFFERENT name than requested!
33
+ // Always use the RETURNED team_name, not the requested one.
34
+ const actualTeamName = result.team_name;
15
35
  ```
16
36
 
17
37
  Store team context for the session:
18
38
  ```javascript
19
39
  const teamContext = {
20
- teamName: "ba-{appName}",
40
+ teamName: actualTeamName, // ← RETURNED name, NOT "ba-{appName}"
21
41
  moduleOrder: metadata.workflow.moduleOrder,
22
42
  dependencyLayers: dependencyGraph.layers || null,
23
43
  currentModuleIdx: 0,
@@ -26,6 +46,9 @@ const teamContext = {
26
46
  };
27
47
  ```
28
48
 
49
+ > **WARNING:** NEVER hardcode `"ba-{appName}"` in subsequent calls.
50
+ > Always use `teamContext.teamName` (the actual name returned by TeamCreate).
51
+
29
52
  ---
30
53
 
31
54
  ## 2. Module Agent Spawn — Sequential by Topological Order
@@ -54,7 +77,7 @@ Before spawning, gather the context the agent needs:
54
77
  ```javascript
55
78
  Task({
56
79
  subagent_type: "general-purpose",
57
- team_name: "ba-{appName}",
80
+ team_name: teamContext.teamName, // ← ACTUAL name from TeamCreate result
58
81
  name: "mod-{moduleCode}",
59
82
  model: "opus",
60
83
  mode: "bypassPermissions",
@@ -85,13 +108,21 @@ Task({
85
108
  - Reason: later modules may reference entities/FKs from earlier modules
86
109
  - **Future optimization**: modules in the same dependency layer with no cross-refs COULD run in parallel
87
110
 
111
+ ### 2d. After Spawning — Wait for Agent Message
112
+
113
+ After calling `Task()` to spawn the module agent, the team lead **MUST WAIT** for the agent to send a message.
114
+ Messages from teammates are delivered automatically — do NOT poll or re-spawn.
115
+
116
+ The agent will send `PROPOSAL_READY:{moduleCode}` when its specification is complete.
117
+ This may take several minutes. The team lead does nothing until the message arrives.
118
+
88
119
  ---
89
120
 
90
121
  ## 3. Propose & Review Protocol
91
122
 
92
123
  ### 3a. Team Lead Receives PROPOSAL_READY
93
124
 
94
- After the agent finishes specifying a module, it sends:
125
+ The module agent sends this message when specification is complete:
95
126
 
96
127
  ```
97
128
  PROPOSAL_READY:{moduleCode}
@@ -130,9 +161,9 @@ PROPOSAL_READY:{moduleCode}
130
161
  - ...
131
162
  ```
132
163
 
133
- ### 3b. Team Lead Presents to User
164
+ ### 3b. Present to User and Handle Response
134
165
 
135
- Format the proposal for user review:
166
+ **Step 1:** Format and display the proposal:
136
167
 
137
168
  ```
138
169
  ═══════════════════════════════════════════════════════════
@@ -144,7 +175,7 @@ Format the proposal for user review:
144
175
  ─────────────────────────────────────────────────────────
145
176
  ```
146
177
 
147
- Then ask user via AskUserQuestion:
178
+ **Step 2:** Ask the user via AskUserQuestion:
148
179
 
149
180
  ```
150
181
  Validez-vous cette specification ?
@@ -154,9 +185,9 @@ Options:
154
185
  3. "Voir detail" → team lead reads module feature.json and displays full content
155
186
  ```
156
187
 
157
- ### 3c. Approval Flow
188
+ **Step 3 IMMEDIATELY after AskUserQuestion returns, handle the response:**
158
189
 
159
- **If user approves:**
190
+ **IF user selected "Valider" (approve):**
160
191
  ```
161
192
  SendMessage({
162
193
  type: "message",
@@ -165,9 +196,12 @@ SendMessage({
165
196
  summary: "{moduleCode} approved by user"
166
197
  })
167
198
  ```
168
- Agent writes final status, sends MODULE_COMPLETE, and shuts down.
199
+ CRITICAL: You MUST send this message. Do NOT skip this step.
200
+ → Then WAIT for the agent to send `MODULE_COMPLETE:{moduleCode}` (see §4).
169
201
 
170
- **If user requests modifications:**
202
+ **IF user selected "Modifier" (revision):**
203
+ → Ask user for specific feedback via AskUserQuestion
204
+ → Then send:
171
205
  ```
172
206
  SendMessage({
173
207
  type: "message",
@@ -176,14 +210,14 @@ SendMessage({
176
210
  summary: "{moduleCode} revision requested"
177
211
  })
178
212
  ```
179
- Agent applies changes, re-validates, sends new PROPOSAL_READY.
213
+ Then WAIT for the agent to send a new `PROPOSAL_READY` → go back to Step 1.
180
214
 
181
- **If user wants to see detail:**
182
- Team lead reads module feature.json via ba-reader.readSection({feature_id, section})
183
- Displays relevant sections in detail
184
- Re-asks validation question
215
+ **IF user selected "Voir detail":**
216
+ Read module feature.json via ba-reader.readSection({feature_id, section})
217
+ Display relevant sections in detail
218
+ Go back to Step 2 (re-ask the validation question)
185
219
 
186
- ### 3d. Revision Limits
220
+ ### 3c. Revision Limits
187
221
 
188
222
  - Max **3 revision cycles** per module
189
223
  - After 3 rejections: team lead asks user if they want to switch to **inline interactive mode** for this module
@@ -192,30 +226,42 @@ SendMessage({
192
226
 
193
227
  ---
194
228
 
195
- ## 4. Module Completion & Advancement
229
+ ## 4. Module Completion & Agent Shutdown
230
+
231
+ When the team lead receives `MODULE_COMPLETE:{moduleCode}` from the agent, execute these steps **IN ORDER**:
196
232
 
197
- When agent sends MODULE_COMPLETE:
233
+ ### 4a. Update Tracking
198
234
 
199
235
  ```javascript
200
- // Update tracking
201
236
  teamContext.completedModules.push(moduleCode);
202
237
  teamContext.currentModuleIdx++;
203
238
 
204
- // Update master feature.json
205
239
  ba-writer.advanceModuleLoop({feature_id});
206
240
  ba-writer.updateModuleStatus({feature_id, moduleCode, status: "specified"});
207
241
 
208
- // Display progress
209
242
  Display: "✓ Module {moduleCode} specified ({completedModules.length}/{moduleOrder.length})"
243
+ ```
244
+
245
+ ### 4b. Shutdown Agent (MANDATORY — do NOT skip)
246
+
247
+ **IMMEDIATELY** after receiving MODULE_COMPLETE, send shutdown_request to terminate the agent:
210
248
 
211
- // Shutdown agent
249
+ ```
212
250
  SendMessage({
213
251
  type: "shutdown_request",
214
252
  recipient: "mod-{moduleCode}",
215
253
  content: "Module complete, shutting down"
216
- });
254
+ })
217
255
  ```
218
256
 
257
+ The agent will respond with `shutdown_response approve: true` and terminate.
258
+ **Wait for the agent to confirm shutdown** before spawning the next agent.
259
+
260
+ > **WARNING:** If you skip this step, the agent will remain running indefinitely.
261
+ > The agent CANNOT self-terminate — it NEEDS this shutdown_request from you.
262
+
263
+ ### 4c. Next Module or Consolidation
264
+
219
265
  If more modules remain → spawn next module agent (go to §2).
220
266
  If all modules complete → proceed to §5 (Consolidation).
221
267
 
@@ -234,7 +280,7 @@ Display: "═══ All modules specified — Starting consolidation ═══"
234
280
  ```javascript
235
281
  Task({
236
282
  subagent_type: "general-purpose",
237
- team_name: "ba-{appName}",
283
+ team_name: teamContext.teamName, // ← ACTUAL name from TeamCreate result
238
284
  name: "consolidation",
239
285
  model: "opus",
240
286
  mode: "bypassPermissions",
@@ -293,7 +339,7 @@ After approval → shutdown consolidation agent → proceed to §6.
293
339
  ```javascript
294
340
  Task({
295
341
  subagent_type: "general-purpose",
296
- team_name: "ba-{appName}",
342
+ team_name: teamContext.teamName, // ← ACTUAL name from TeamCreate result
297
343
  name: "handoff",
298
344
  model: "sonnet",
299
345
  mode: "bypassPermissions",
@@ -346,13 +392,21 @@ Display final status to user. If quality gate PASS → ready for /ralph-loop.
346
392
  After handoff complete:
347
393
 
348
394
  ```javascript
349
- // Shutdown any remaining agents
350
- for (const agentName of ["consolidation", "handoff"]) {
395
+ // Safety net: shutdown ALL remaining agents (module agents + consolidation + handoff)
396
+ // Module agents should already be shut down in §4b, but this catches any missed ones.
397
+ const allAgents = [
398
+ ...teamContext.moduleOrder.map(m => `mod-${m}`),
399
+ "consolidation",
400
+ "handoff"
401
+ ];
402
+
403
+ for (const agentName of allAgents) {
351
404
  SendMessage({
352
405
  type: "shutdown_request",
353
406
  recipient: agentName,
354
407
  content: "Workflow complete"
355
408
  });
409
+ // Ignore errors for already-terminated agents
356
410
  }
357
411
 
358
412
  // Delete team
@@ -361,6 +415,9 @@ TeamDelete();
361
415
  Display: "═══ Business-analyse complete — Team cleaned up ═══"
362
416
  ```
363
417
 
418
+ > **Note:** Sending shutdown_request to an already-terminated agent is harmless.
419
+ > This safety net ensures no orphan agents remain running.
420
+
364
421
  ---
365
422
 
366
423
  ## 8. Error Recovery
@@ -402,8 +459,9 @@ If the entire session crashes:
402
459
  1. User restarts `/business-analyse`
403
460
  2. Step-00 detects existing feature.json with `status: "decomposed"` or partial modules
404
461
  3. Reads `metadata.workflow.completedModules` to know which modules are done
405
- 4. Creates new team, spawns agent for next incomplete module
406
- 5. Continues normally
462
+ 4. **Cleans up old team/task data** (§1a cleanup step) before creating new team
463
+ 5. Creates new team (§1b — captures actual team name), spawns agent for next incomplete module
464
+ 6. Continues normally
407
465
 
408
466
  ---
409
467
 
@@ -17,6 +17,18 @@ next_step: steps/step-03b-ui.md
17
17
  - **ID NAMING RULE:** All IDs MUST include module prefix (BR-{CAT}-{PREFIX}-{NNN}, OBJ-{PREFIX}-{NNN}, etc.)
18
18
  - **SCHEMA CONFORMITY RULE:** ALL data MUST fit within feature-schema.json structure
19
19
 
20
+ ## MODE DETECTION (inherited from step-03a1)
21
+
22
+ > **CRITICAL: Re-check your execution mode before proceeding.**
23
+
24
+ **IF you are running as a TEAM AGENT** (your prompt contains `PROPOSE & REVIEW` or `team-lead` as recipient):
25
+ → **NEVER** use `AskUserQuestion` — replace ALL user interactions with ULTRATHINK autonomous decisions
26
+ → You are in autonomous mode — make all choices based on decomposition data + SmartStack conventions
27
+ → Do NOT present options to the user — you PROPOSE to the team lead via SendMessage, not to the user
28
+
29
+ **IF you are running in the MAIN CONVERSATION** (classic inline mode):
30
+ → Normal interactive mode — use `AskUserQuestion` as documented below
31
+
20
32
  ## YOUR TASK
21
33
 
22
34
  Define the module's analysis section: objectives, entities (with attributes and relationships), business rules, process flow, and data lifecycle.
@@ -14,6 +14,18 @@ next_step: steps/step-03c-compile.md
14
14
  - ALWAYS use ULTRATHINK mode
15
15
  - This step is EXECUTED ONCE PER MODULE, after step-03a1-setup.md and step-03a2-analysis.md
16
16
  - **WIREFRAME RULE:** Every section MUST have a wireframe in `specification.uiWireframes[]`. No section without a validated mockup.
17
+
18
+ ## MODE DETECTION (inherited from step-03a1)
19
+
20
+ > **CRITICAL: Re-check your execution mode before proceeding.**
21
+
22
+ **IF you are running as a TEAM AGENT** (your prompt contains `PROPOSE & REVIEW` or `team-lead` as recipient):
23
+ → **NEVER** use `AskUserQuestion` — replace ALL wireframe validations with ULTRATHINK self-review
24
+ → Generate wireframes autonomously, self-validate them, move on
25
+ → Do NOT ask the user to validate mockups — the team lead handles review after PROPOSAL_READY
26
+
27
+ **IF you are running in the MAIN CONVERSATION** (classic inline mode):
28
+ → Normal interactive mode — display wireframes then ask for validation via `AskUserQuestion`
17
29
  - **ID NAMING RULE (MANDATORY, NO EXCEPTION):**
18
30
  All IDs MUST include a module prefix to guarantee application-wide uniqueness.
19
31
  The prefix is derived from the module code initials (2-4 chars):
@@ -15,6 +15,21 @@ next_step: steps/step-03a1-setup.md OR steps/step-04a-collect.md (conditional)
15
15
  - This step VALIDATES the specification from step-03c, writes it to feature.json, and decides loop continuation
16
16
  - ALWAYS verify specification completeness before writing
17
17
  - ALL communication in `{language}`
18
+
19
+ ## MODE DETECTION (inherited from step-03a1)
20
+
21
+ > **CRITICAL: Re-check your execution mode before proceeding.**
22
+
23
+ **IF you are running as a TEAM AGENT** (your prompt contains `PROPOSE & REVIEW` or `team-lead` as recipient):
24
+ → **NEVER** use `AskUserQuestion` in ANY section below (sections 9d, 10, 12)
25
+ → Section 9d: if validation fails, AUTO-CORRECT silently (no user options)
26
+ → Section 12: **SKIP ENTIRELY** — go directly to section 12-bis (Agent Mode)
27
+ → After writing feature.json, send `PROPOSAL_READY` to team lead via SendMessage
28
+ → NEVER present options/menus to the user — you are an autonomous agent
29
+
30
+ **IF you are running in the MAIN CONVERSATION** (classic inline mode):
31
+ → Normal interactive mode — use `AskUserQuestion` as documented
32
+ → Section 12-bis does NOT apply to you
18
33
  - **ID NAMING RULE (MANDATORY, NO EXCEPTION):**
19
34
  All IDs MUST include a module prefix to guarantee application-wide uniqueness.
20
35
  The prefix is derived from the module code initials (2-4 chars):
@@ -167,6 +182,10 @@ if (entityAutoFixCount > 0) {
167
182
 
168
183
  #### 9d. Decision
169
184
 
185
+ > **TEAM AGENT MODE:** If running as team agent, SKIP AskUserQuestion. On FAIL → auto-correct silently. On PASS → proceed directly to section 11 (write). NEVER present options to the user.
186
+
187
+ **INLINE MODE ONLY (main conversation):**
188
+
170
189
  IF validation PASS:
171
190
  Display summary, ask client for confirmation
172
191
 
@@ -482,6 +501,10 @@ Uses the **same mapping** as step-05b-deploy.md — only difference is `moduleSp
482
501
 
483
502
  ### 12. Loop Decision
484
503
 
504
+ > **TEAM AGENT MODE: SKIP THIS ENTIRE SECTION.** If you are a team agent (your prompt contains `PROPOSE & REVIEW`), go directly to **section 12-bis** below. Section 12 is for inline mode ONLY. You MUST NOT load the next step or advance the module loop — the team lead handles orchestration.
505
+
506
+ **INLINE MODE ONLY (main conversation):**
507
+
485
508
  ```
486
509
  ba-writer.advanceModuleLoop({feature_id})
487
510
  → Increments currentModuleIndex
@@ -595,7 +618,24 @@ SendMessage({
595
618
  })
596
619
  ```
597
620
 
598
- **STOP HERE**do NOT loop to next module. The team lead handles module ordering and will spawn a new agent for the next module.
621
+ Then WAITthe team lead will send you a `shutdown_request`.
622
+ Do NOT loop to next module. The team lead handles module ordering and will spawn a new agent for the next module.
623
+
624
+ ### E. Shutdown (MANDATORY)
625
+
626
+ When you receive a `shutdown_request` from the team lead:
627
+
628
+ ```
629
+ SendMessage({
630
+ type: "shutdown_response",
631
+ request_id: "{requestId from the shutdown_request message}",
632
+ approve: true
633
+ })
634
+ ```
635
+
636
+ This terminates your process. Do NOT output any text after `shutdown_response`.
637
+
638
+ **Sequence reminder:** APPROVED → MODULE_COMPLETE → shutdown_request → shutdown_response (4 separate steps, never skip).
599
639
 
600
640
  ---
601
641