@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.
- package/dist/index.js +365 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/templates/agents/action.md +1 -0
- package/templates/agents/ba-writer.md +33 -0
- package/templates/agents/explore-codebase.md +1 -0
- package/templates/agents/explore-docs.md +1 -0
- package/templates/agents/fix-grammar.md +1 -0
- package/templates/agents/snipper.md +1 -0
- package/templates/skills/admin/SKILL.md +6 -0
- package/templates/skills/ai-prompt/SKILL.md +32 -136
- package/templates/skills/ai-prompt/steps/step-01-implementation.md +122 -0
- package/templates/skills/apex/SKILL.md +120 -0
- package/templates/skills/apex/_shared.md +86 -0
- package/templates/skills/apex/references/agent-teams-protocol.md +164 -0
- package/templates/skills/apex/references/smartstack-layers.md +173 -0
- package/templates/skills/apex/steps/step-00-init.md +156 -0
- package/templates/skills/apex/steps/step-01-analyze.md +169 -0
- package/templates/skills/apex/steps/step-02-plan.md +160 -0
- package/templates/skills/apex/steps/step-03-execute.md +166 -0
- package/templates/skills/apex/steps/step-04-validate.md +138 -0
- package/templates/skills/apex/steps/step-05-examine.md +124 -0
- package/templates/skills/apex/steps/step-06-resolve.md +105 -0
- package/templates/skills/apex/steps/step-07-tests.md +130 -0
- package/templates/skills/apex/steps/step-08-run-tests.md +115 -0
- package/templates/skills/application/SKILL.md +10 -0
- package/templates/skills/application/references/backend-controller-hierarchy.md +58 -0
- package/templates/skills/application/references/backend-entity-seeding.md +72 -0
- package/templates/skills/application/references/backend-verification.md +88 -0
- package/templates/skills/application/references/frontend-verification.md +111 -0
- package/templates/skills/application/references/nav-fallback-procedure.md +200 -0
- package/templates/skills/application/references/provider-template.md +134 -0
- package/templates/skills/application/references/test-frontend.md +73 -0
- package/templates/skills/application/references/test-prerequisites.md +72 -0
- package/templates/skills/application/steps/step-01-navigation.md +7 -198
- package/templates/skills/application/steps/step-03b-provider.md +4 -128
- package/templates/skills/application/steps/step-04-backend.md +20 -350
- package/templates/skills/application/steps/step-05-frontend.md +12 -101
- package/templates/skills/application/steps/step-07-tests.md +12 -132
- package/templates/skills/business-analyse/SKILL.md +11 -2
- package/templates/skills/business-analyse/html/ba-interactive.html +176 -14
- package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +1 -0
- package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +16 -4
- package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +7 -2
- package/templates/skills/business-analyse/html/src/scripts/09-export.js +103 -0
- package/templates/skills/business-analyse/html/src/scripts/10-comments.js +12 -6
- package/templates/skills/business-analyse/html/src/scripts/11-review-panel.js +24 -2
- package/templates/skills/business-analyse/html/src/styles/08-review-panel.css +12 -0
- package/templates/skills/business-analyse/html/src/template.html +1 -0
- package/templates/skills/business-analyse/references/cadrage-structure-cards.md +78 -0
- package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +97 -0
- package/templates/skills/business-analyse/references/consolidation-structural-checks.md +92 -0
- package/templates/skills/business-analyse/references/deploy-data-build.md +121 -0
- package/templates/skills/business-analyse/references/deploy-modes.md +49 -0
- package/templates/skills/business-analyse/references/handoff-file-templates.md +119 -0
- package/templates/skills/business-analyse/references/handoff-mappings.md +81 -0
- package/templates/skills/business-analyse/references/html-data-mapping.md +10 -2
- package/templates/skills/business-analyse/references/init-schema-deployment.md +65 -0
- package/templates/skills/business-analyse/references/review-data-mapping.md +363 -0
- package/templates/skills/business-analyse/references/spec-auto-inference.md +57 -0
- package/templates/skills/business-analyse/references/ui-dashboard-spec.md +85 -0
- package/templates/skills/business-analyse/references/ui-resource-cards.md +110 -0
- package/templates/skills/business-analyse/references/validate-incremental-html.md +55 -0
- package/templates/skills/business-analyse/steps/step-00-init.md +35 -68
- package/templates/skills/business-analyse/steps/step-01-cadrage.md +5 -194
- package/templates/skills/business-analyse/steps/step-03a-data.md +6 -49
- package/templates/skills/business-analyse/steps/step-03b-ui.md +12 -178
- package/templates/skills/business-analyse/steps/step-03d-validate.md +3 -48
- package/templates/skills/business-analyse/steps/step-04-consolidation.md +9 -104
- package/templates/skills/business-analyse/steps/step-05a-handoff.md +25 -441
- package/templates/skills/business-analyse/steps/step-05b-deploy.md +19 -187
- package/templates/skills/business-analyse/steps/step-06-review.md +277 -0
- package/templates/skills/cc-agent/references/agent-behavior-patterns.md +95 -0
- package/templates/skills/cc-agent/steps/step-02-generate.md +5 -78
- package/templates/skills/check-version/SKILL.md +7 -0
- package/templates/skills/controller/references/controller-code-templates.md +159 -0
- package/templates/skills/controller/references/permission-sync-templates.md +152 -0
- package/templates/skills/controller/steps/step-03-generate.md +6 -158
- package/templates/skills/controller/steps/step-04-perms.md +5 -144
- package/templates/skills/debug/SKILL.md +7 -0
- package/templates/skills/explore/SKILL.md +6 -0
- package/templates/skills/feature-full/SKILL.md +39 -142
- package/templates/skills/feature-full/steps/step-01-implementation.md +120 -0
- package/templates/skills/gitflow/references/init-config-template.md +135 -0
- package/templates/skills/gitflow/references/init-name-normalization.md +103 -0
- package/templates/skills/gitflow/references/plan-template.md +69 -0
- package/templates/skills/gitflow/references/start-efcore-preflight.md +70 -0
- package/templates/skills/gitflow/references/start-local-config.md +110 -0
- package/templates/skills/gitflow/steps/step-init.md +18 -289
- package/templates/skills/gitflow/steps/step-plan.md +6 -63
- package/templates/skills/gitflow/steps/step-start.md +16 -126
- package/templates/skills/mcp/SKILL.md +9 -213
- package/templates/skills/mcp/steps/step-01-healthcheck.md +108 -0
- package/templates/skills/mcp/steps/step-02-tools.md +73 -0
- package/templates/skills/notification/SKILL.md +7 -0
- package/templates/skills/quick-search/SKILL.md +5 -0
- package/templates/skills/ralph-loop/SKILL.md +99 -381
- package/templates/skills/ralph-loop/references/category-rules.md +259 -0
- package/templates/skills/ralph-loop/references/compact-loop.md +182 -0
- package/templates/skills/ralph-loop/references/task-transform-legacy.md +259 -0
- package/templates/skills/ralph-loop/references/team-orchestration.md +189 -0
- package/templates/skills/ralph-loop/steps/step-00-init.md +111 -383
- package/templates/skills/ralph-loop/steps/step-01-task.md +79 -896
- package/templates/skills/ralph-loop/steps/step-02-execute.md +68 -680
- package/templates/skills/ralph-loop/steps/step-03-commit.md +47 -277
- package/templates/skills/ralph-loop/steps/step-04-check.md +124 -607
- package/templates/skills/ralph-loop/steps/step-05-report.md +68 -367
- package/templates/skills/refactor/SKILL.md +12 -176
- package/templates/skills/refactor/steps/step-01-discover.md +60 -0
- package/templates/skills/refactor/steps/step-02-execute.md +67 -0
- package/templates/skills/review-code/SKILL.md +19 -257
- package/templates/skills/review-code/steps/step-01-smartstack.md +96 -0
- package/templates/skills/review-code/steps/step-02-detailed-review.md +80 -0
- package/templates/skills/review-code/steps/step-03-react.md +44 -0
- package/templates/skills/ui-components/SKILL.md +7 -0
- package/templates/skills/utils/SKILL.md +6 -0
- package/templates/skills/validate/SKILL.md +6 -0
- package/templates/skills/validate-feature/SKILL.md +8 -0
- package/templates/skills/workflow/SKILL.md +40 -118
- package/templates/skills/workflow/steps/step-01-implementation.md +84 -0
|
@@ -6,373 +6,155 @@ next_step: steps/step-01-task.md
|
|
|
6
6
|
|
|
7
7
|
# Step 0: Initialization
|
|
8
8
|
|
|
9
|
-
## MANDATORY
|
|
9
|
+
## MANDATORY RULES:
|
|
10
10
|
|
|
11
11
|
- NEVER skip MCP verification
|
|
12
|
-
- ALWAYS parse ALL flags before any
|
|
13
|
-
- ONLY check
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- **CONTEXT BUDGET**: Keep init output COMPACT. Do NOT dump verbose MCP responses or long file listings. Every token saved here = more tokens for actual code generation in the COMPACT LOOP.
|
|
18
|
-
- **NEVER DELEGATE**: Do NOT use the Task tool to delegate the Ralph loop to a sub-agent. The loop MUST run in the main agent context. Sub-agents lose skill context and stop prematurely.
|
|
12
|
+
- ALWAYS parse ALL flags before any action
|
|
13
|
+
- ONLY check resume if -r flag is set
|
|
14
|
+
- CONTEXT BUDGET: Keep output COMPACT
|
|
15
|
+
- **NEVER DELEGATE** the main Ralph loop to a sub-agent (single module)
|
|
16
|
+
- **Multi-module (2+ modules):** Use Agent Teams for parallel execution
|
|
19
17
|
|
|
20
18
|
## YOUR TASK:
|
|
21
19
|
|
|
22
|
-
Initialize the Ralph loop
|
|
20
|
+
Initialize the Ralph loop: parse flags, verify MCP, setup environment, detect multi-module.
|
|
23
21
|
|
|
24
22
|
---
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
## Default Configuration
|
|
24
|
+
## 1. Parse Flags
|
|
28
25
|
|
|
29
26
|
```yaml
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</defaults>
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## EXECUTION SEQUENCE:
|
|
27
|
+
Defaults:
|
|
28
|
+
max_iterations: 50
|
|
29
|
+
completion_promise: null
|
|
30
|
+
verbose_mode: false
|
|
31
|
+
resume_mode: false
|
|
32
|
+
current_iteration: 1
|
|
41
33
|
|
|
42
|
-
### 1. Parse Flags and Input
|
|
43
|
-
|
|
44
|
-
**Step 1: Load defaults from config above**
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
{max_iterations} = 50
|
|
48
|
-
{completion_promise} = null
|
|
49
|
-
{verbose_mode} = false
|
|
50
|
-
{resume_mode} = false
|
|
51
|
-
{current_iteration} = 1
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
**Step 2: Parse user input and override defaults:**
|
|
55
|
-
|
|
56
|
-
```
|
|
57
34
|
Flags:
|
|
58
|
-
-m N
|
|
59
|
-
-c TEXT
|
|
60
|
-
-v
|
|
61
|
-
-r
|
|
62
|
-
|
|
63
|
-
Remainder -> {task_description}
|
|
35
|
+
-m N / --max-iterations N → {max_iterations} = N
|
|
36
|
+
-c TEXT / --completion-promise TEXT → {completion_promise} = TEXT
|
|
37
|
+
-v / --verbose → {verbose_mode} = true
|
|
38
|
+
-r / --resume → {resume_mode} = true
|
|
39
|
+
Remainder → {task_description}
|
|
64
40
|
```
|
|
65
41
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
**CRITICAL: Do NOT proceed without MCP verification!**
|
|
42
|
+
## 2. Verify MCP (MANDATORY)
|
|
69
43
|
|
|
70
|
-
**Check SmartStack MCP:**
|
|
71
44
|
```
|
|
72
|
-
mcp__smartstack__validate_conventions:
|
|
73
|
-
|
|
74
|
-
(just to verify connectivity)
|
|
45
|
+
mcp__smartstack__validate_conventions: checks: ["all"] → {mcp_smartstack} = true/false
|
|
46
|
+
mcp__context7__resolve-library-id: libraryName: "test" → {mcp_context7} = true/false
|
|
75
47
|
```
|
|
76
48
|
|
|
77
|
-
|
|
78
|
-
```
|
|
79
|
-
mcp__context7__resolve-library-id:
|
|
80
|
-
libraryName: "test"
|
|
81
|
-
query: "connectivity check"
|
|
82
|
-
(just to verify connectivity)
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**Record MCP status for metadata:**
|
|
86
|
-
```
|
|
87
|
-
{mcp_smartstack} = true/false
|
|
88
|
-
{mcp_context7} = true/false
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**If ANY MCP fails:**
|
|
92
|
-
```
|
|
93
|
-
╔══════════════════════════════════════════════════════════════════╗
|
|
94
|
-
║ ❌ MCP SERVER UNAVAILABLE ║
|
|
95
|
-
╠══════════════════════════════════════════════════════════════════╣
|
|
96
|
-
║ Server: {failed_server} ║
|
|
97
|
-
║ Status: Connection failed ║
|
|
98
|
-
╠══════════════════════════════════════════════════════════════════╣
|
|
99
|
-
║ RALPH CANNOT PROCEED WITHOUT MCP ║
|
|
100
|
-
║ ║
|
|
101
|
-
║ Troubleshooting: ║
|
|
102
|
-
║ 1. Run: smartstack check-mcp ║
|
|
103
|
-
║ 2. Restart Claude Code ║
|
|
104
|
-
║ 3. Check MCP server configuration ║
|
|
105
|
-
╚══════════════════════════════════════════════════════════════════╝
|
|
106
|
-
|
|
107
|
-
STOP - Do not proceed.
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### 3. Check Resume Mode
|
|
49
|
+
If ANY fails: show error, suggest `smartstack check-mcp`, STOP.
|
|
111
50
|
|
|
112
|
-
|
|
51
|
+
## 3. Resume Mode
|
|
113
52
|
|
|
114
|
-
|
|
115
|
-
2. If not found:
|
|
116
|
-
- Error: "No active Ralph loop to resume"
|
|
117
|
-
- Ask user to start new loop
|
|
118
|
-
- STOP
|
|
53
|
+
If `{resume_mode} = true`:
|
|
119
54
|
|
|
120
|
-
|
|
55
|
+
1. Check `.ralph/prd.json` exists → error if not
|
|
56
|
+
2. Detect format:
|
|
57
|
+
- `$version === "3.0.0"` → **v3 unified** (native, preferred)
|
|
58
|
+
- `$version === "2.0.0"` → **v2 legacy** (OK, continue)
|
|
59
|
+
- `.project && .requirements && !.$version` → **FORMAT A (DEPRECATED)** — warn and transform via step-01
|
|
60
|
+
- Other → error
|
|
61
|
+
3. Check branch consistency: current branch vs `prd.metadata.branch`
|
|
62
|
+
4. Restore state: `current_iteration`, `completion_promise`, `max_iterations`
|
|
63
|
+
5. If `modules-queue.json` exists: restore multi-module state
|
|
64
|
+
6. Continue to step-01
|
|
121
65
|
|
|
122
|
-
|
|
123
|
-
const prd = readJSON('.ralph/prd.json');
|
|
124
|
-
|
|
125
|
-
if (prd.$version !== "2.0.0") {
|
|
126
|
-
echo "❌ prd.json schema version unsupported: ${prd.$version || 'missing'}";
|
|
127
|
-
echo " Expected: 2.0.0";
|
|
128
|
-
echo " Re-run /business-analyse to generate a fresh prd.json";
|
|
129
|
-
STOP;
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
4. **Validate integrity (v2 resume):**
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
# Check branch consistency
|
|
137
|
-
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
138
|
-
PRD_BRANCH={prd.metadata.branch}
|
|
139
|
-
|
|
140
|
-
if [ "$CURRENT_BRANCH" != "$PRD_BRANCH" ]; then
|
|
141
|
-
echo "⚠️ Branch mismatch: prd.json was created on '$PRD_BRANCH', now on '$CURRENT_BRANCH'"
|
|
142
|
-
# Ask user: continue on current branch or switch
|
|
143
|
-
AskUserQuestion:
|
|
144
|
-
header: "Branch"
|
|
145
|
-
question: "prd.json was created on '$PRD_BRANCH' but you're on '$CURRENT_BRANCH'. Continue?"
|
|
146
|
-
options:
|
|
147
|
-
- label: "Continue on $CURRENT_BRANCH"
|
|
148
|
-
description: "Update metadata and continue"
|
|
149
|
-
- label: "Cancel"
|
|
150
|
-
description: "Switch branch manually first"
|
|
151
|
-
fi
|
|
152
|
-
|
|
153
|
-
# Check for external commits since last update
|
|
154
|
-
LAST_UPDATED={prd.updated_at}
|
|
155
|
-
EXTERNAL_COMMITS=$(git log --since="$LAST_UPDATED" --oneline --not --author="Co-Authored-By: Claude" | wc -l)
|
|
156
|
-
|
|
157
|
-
if [ "$EXTERNAL_COMMITS" -gt 0 ]; then
|
|
158
|
-
echo "⚠️ $EXTERNAL_COMMITS external commits detected since last Ralph iteration"
|
|
159
|
-
echo " prd.json state may not reflect current code state"
|
|
160
|
-
fi
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
5. **Restore state from prd.json:**
|
|
164
|
-
- Read `prd.config.current_iteration` → `{current_iteration}`
|
|
165
|
-
- Read `prd.config.completion_promise` → `{completion_promise}`
|
|
166
|
-
- Read `prd.config.max_iterations` → `{max_iterations}`
|
|
167
|
-
- Read progress.txt for context
|
|
168
|
-
|
|
169
|
-
6. **Restore multi-module state (if applicable):**
|
|
170
|
-
```javascript
|
|
171
|
-
if (fileExists('.ralph/modules-queue.json')) {
|
|
172
|
-
const queue = readJSON('.ralph/modules-queue.json');
|
|
173
|
-
const currentModule = queue.modules[queue.currentIndex];
|
|
174
|
-
|
|
175
|
-
// Restore module state
|
|
176
|
-
{modules_queue} = queue;
|
|
177
|
-
{current_module} = currentModule.code;
|
|
178
|
-
|
|
179
|
-
console.log(`Resuming multi-module: ${currentModule.code} (${queue.currentIndex + 1}/${queue.totalModules})`);
|
|
180
|
-
console.log(`Modules completed: ${queue.completedModules}/${queue.totalModules}`);
|
|
181
|
-
}
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
- Continue to step-01
|
|
185
|
-
|
|
186
|
-
### 4. Initialize .ralph/ Structure (new loop)
|
|
187
|
-
|
|
188
|
-
**Create directory structure:**
|
|
189
|
-
|
|
190
|
-
```
|
|
191
|
-
.ralph/
|
|
192
|
-
├── prd.json # Will be created in step-01
|
|
193
|
-
├── progress.txt # Will be created in step-01
|
|
194
|
-
├── logs/
|
|
195
|
-
└── reports/
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
**Commands:**
|
|
199
|
-
```bash
|
|
200
|
-
mkdir -p .ralph/logs
|
|
201
|
-
mkdir -p .ralph/reports
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### 4a. Auto-Recovery: Detect BA Artifacts Without PRD (NEW)
|
|
205
|
-
|
|
206
|
-
> **Scenario:** Business-analyse completed (feature.json with status="handed-off") but step-05b
|
|
207
|
-
> didn't generate PRD files (context exhaustion). Ralph-loop auto-recovers by running `ss derive-prd`.
|
|
208
|
-
|
|
209
|
-
**Check for BA artifacts when no PRD files exist:**
|
|
66
|
+
## 4. Initialize .ralph/ (new loop)
|
|
210
67
|
|
|
211
68
|
```bash
|
|
212
|
-
|
|
213
|
-
SINGLE_PRD_EXISTS=$(test -f .ralph/prd.json && echo "yes" || echo "no")
|
|
69
|
+
mkdir -p .ralph/logs .ralph/reports
|
|
214
70
|
```
|
|
215
71
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
```bash
|
|
219
|
-
# Search for handed-off master feature.json
|
|
220
|
-
MASTER_FEATURE=$(find docs/business -maxdepth 4 -name "feature.json" -path "*/business-analyse/*" 2>/dev/null | head -1)
|
|
221
|
-
```
|
|
72
|
+
### 4a. Auto-Recovery: BA Artifacts Without PRD
|
|
222
73
|
|
|
223
|
-
|
|
74
|
+
If no PRD files exist (neither `prd-*.json` nor `prd.json`):
|
|
224
75
|
|
|
225
76
|
```javascript
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
║ BA ARTIFACT VALIDATION ║
|
|
236
|
-
╠══════════════════════════════════════════════════════════════════╣
|
|
237
|
-
║ Master feature.json: ✅ Found (status: ${master.status}) ║
|
|
238
|
-
║ Application: ${master.metadata?.application || 'unknown'} ║
|
|
239
|
-
║ Modules: ${master.modules?.length || 0} ║
|
|
240
|
-
║ PRD files: ❌ Missing — will auto-generate ║
|
|
241
|
-
╠══════════════════════════════════════════════════════════════════╣
|
|
242
|
-
║ Running: ss derive-prd --application ${MASTER_FEATURE} ║
|
|
243
|
-
╚══════════════════════════════════════════════════════════════════╝
|
|
244
|
-
`);
|
|
245
|
-
|
|
246
|
-
// Execute ss derive-prd to generate missing PRD files
|
|
247
|
-
// This is a deterministic CLI command (no LLM), safe to auto-run
|
|
248
|
-
exec(`ss derive-prd --application ${MASTER_FEATURE}`);
|
|
249
|
-
|
|
250
|
-
// Verify PRD files were generated
|
|
251
|
-
const newPrdFiles = glob('.ralph/prd-*.json');
|
|
252
|
-
if (newPrdFiles.length === 0) {
|
|
253
|
-
console.log("❌ ss derive-prd failed to generate PRD files");
|
|
254
|
-
console.log(" Verify: ss derive-prd is installed (npm list -g @atlashub/smartstack-cli)");
|
|
255
|
-
console.log(" Manual: ss derive-prd --application " + MASTER_FEATURE);
|
|
256
|
-
STOP;
|
|
77
|
+
const masterFeature = findFile('docs/business/**/business-analyse/**/feature.json');
|
|
78
|
+
if (masterFeature) {
|
|
79
|
+
const master = readJSON(masterFeature);
|
|
80
|
+
if (master.status === 'handed-off' || master.handoff?.status === 'handed-off') {
|
|
81
|
+
console.log('BA artifacts detected without PRD — auto-recovering...');
|
|
82
|
+
exec(`ss derive-prd --application ${masterFeature}`);
|
|
83
|
+
const newPrds = glob('.ralph/prd-*.json');
|
|
84
|
+
if (newPrds.length === 0) { console.log('ss derive-prd failed'); STOP; }
|
|
85
|
+
console.log(`Auto-recovered ${newPrds.length} PRD files`);
|
|
257
86
|
}
|
|
258
|
-
|
|
259
|
-
console.log(`✅ Auto-recovered ${newPrdFiles.length} PRD files`);
|
|
260
|
-
// Continue to section 4b which will detect and queue them
|
|
261
87
|
}
|
|
262
88
|
```
|
|
263
89
|
|
|
264
|
-
|
|
265
|
-
- No BA artifacts → proceed normally (step-01 will create prd.json from task description)
|
|
266
|
-
|
|
267
|
-
**IF PRD files already exist:**
|
|
268
|
-
- Skip auto-recovery entirely → proceed to section 4b
|
|
269
|
-
|
|
270
|
-
### 4b. Detect Multi-Module PRDs (from BA Handoff or Auto-Recovery)
|
|
90
|
+
### 4b. Detect Multi-Module PRDs
|
|
271
91
|
|
|
272
|
-
**After creating `.ralph/` directory, check for per-module PRD files:**
|
|
273
|
-
|
|
274
|
-
```bash
|
|
275
|
-
# Count prd-*.json files (generated by BA handoff via ss derive-prd)
|
|
276
|
-
PRD_FILES=$(ls .ralph/prd-*.json 2>/dev/null)
|
|
277
|
-
PRD_COUNT=$(echo "$PRD_FILES" | grep -c "prd-" 2>/dev/null || echo "0")
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
**If multiple prd-*.json files found (PRD_COUNT > 0):**
|
|
281
|
-
|
|
282
|
-
1. **Read module order from master feature.json (if available):**
|
|
283
|
-
```bash
|
|
284
|
-
# Look for master feature.json that references modules
|
|
285
|
-
MASTER_FEATURE=$(find docs/business -maxdepth 4 -name "feature.json" -path "*/business-analyse/*" | head -1)
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
2. **Build module queue:**
|
|
289
92
|
```javascript
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
93
|
+
const prdFiles = glob('.ralph/prd-*.json');
|
|
94
|
+
const PRD_COUNT = prdFiles.length;
|
|
95
|
+
|
|
96
|
+
if (PRD_COUNT > 0) {
|
|
97
|
+
// Build module queue (from master feature.json order or alphabetical)
|
|
98
|
+
const modules = [];
|
|
99
|
+
const masterFeature = findFile('docs/business/**/business-analyse/**/feature.json');
|
|
100
|
+
if (masterFeature) {
|
|
101
|
+
const master = readJSON(masterFeature);
|
|
102
|
+
const moduleOrder = master.metadata?.workflow?.moduleOrder || [];
|
|
103
|
+
for (const mod of moduleOrder) {
|
|
104
|
+
if (fileExists(`.ralph/prd-${mod.code}.json`)) {
|
|
105
|
+
modules.push({ code: mod.code, prdFile: `.ralph/prd-${mod.code}.json`, status: 'pending' });
|
|
106
|
+
}
|
|
298
107
|
}
|
|
299
108
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
109
|
+
// Fallback: alphabetical
|
|
110
|
+
if (modules.length === 0) {
|
|
111
|
+
for (const file of prdFiles) {
|
|
112
|
+
const code = file.match(/prd-(.+)\.json$/)[1];
|
|
113
|
+
modules.push({ code, prdFile: `.ralph/${file}`, status: 'pending' });
|
|
114
|
+
}
|
|
305
115
|
}
|
|
306
|
-
}
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
3. **Create modules-queue.json:**
|
|
310
|
-
```json
|
|
311
|
-
{
|
|
312
|
-
"modules": [
|
|
313
|
-
{ "code": "mod1", "prdFile": ".ralph/prd-mod1.json", "status": "pending" },
|
|
314
|
-
{ "code": "mod2", "prdFile": ".ralph/prd-mod2.json", "status": "pending" }
|
|
315
|
-
],
|
|
316
|
-
"currentIndex": 0,
|
|
317
|
-
"totalModules": 2,
|
|
318
|
-
"completedModules": 0
|
|
319
|
-
}
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
4. **Set first module as active:**
|
|
323
|
-
```javascript
|
|
324
|
-
modules[0].status = "in-progress";
|
|
325
|
-
```
|
|
326
116
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
```
|
|
117
|
+
// Create modules-queue.json
|
|
118
|
+
modules[0].status = 'in-progress';
|
|
119
|
+
const queue = { modules, currentIndex: 0, totalModules: modules.length, completedModules: 0 };
|
|
120
|
+
writeJSON('.ralph/modules-queue.json', queue);
|
|
121
|
+
console.log(`Multi-module: ${modules.length} modules → ${modules.map(m => m.code).join(' → ')}`);
|
|
333
122
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
✓ Master feature.json: {MASTER_FEATURE} (status: handed-off)
|
|
338
|
-
✓ Module feature.json: {module_count} modules (all handed-off)
|
|
339
|
-
✓ PRD files: {PRD_COUNT} modules (.ralph/prd-*.json)
|
|
340
|
-
✓ progress.txt: {exists ? "present" : "will be created"}
|
|
341
|
-
[PASS] All BA artifacts valid. Multi-module development ready.
|
|
123
|
+
{modules_queue} = queue;
|
|
124
|
+
{current_module} = modules[0].code;
|
|
125
|
+
}
|
|
342
126
|
```
|
|
343
127
|
|
|
344
|
-
|
|
345
|
-
- Skip queue creation (backward compatible)
|
|
346
|
-
- Proceed normally
|
|
128
|
+
### 4c. Team Orchestration (multi-module, 2+ modules)
|
|
347
129
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
130
|
+
```javascript
|
|
131
|
+
if (PRD_COUNT > 1) {
|
|
132
|
+
// Read references/team-orchestration.md for full protocol
|
|
133
|
+
// Detect dependency layers from master feature.json
|
|
134
|
+
const layers = master.metadata?.workflow?.dependencyGraph?.layers;
|
|
135
|
+
|
|
136
|
+
if (layers) {
|
|
137
|
+
// PARALLEL MODE: Use Agent Teams
|
|
138
|
+
TeamCreate({ team_name: `ralph-${appName}` });
|
|
139
|
+
|
|
140
|
+
// For each layer, spawn teammates in parallel
|
|
141
|
+
// Layer 0: foundation modules (spawn, wait for LAYER_READY)
|
|
142
|
+
// Layer 1+: dependent modules (spawn after previous layer completes)
|
|
143
|
+
// See references/team-orchestration.md for teammate prompt template
|
|
144
|
+
|
|
145
|
+
// After all layers: cross-module verify → step-05 → TeamDelete
|
|
146
|
+
// STOP here — team orchestration takes over
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// If no layers: fall through to sequential mode (classic compact loop)
|
|
150
|
+
}
|
|
352
151
|
```
|
|
353
152
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
**If {completion_promise} is null:**
|
|
357
|
-
|
|
358
|
-
```yaml
|
|
359
|
-
AskUserQuestion:
|
|
360
|
-
header: "Promise"
|
|
361
|
-
question: "What text should signal completion?"
|
|
362
|
-
options:
|
|
363
|
-
- label: "COMPLETE"
|
|
364
|
-
description: "Standard completion signal"
|
|
365
|
-
- label: "ALL TESTS PASS"
|
|
366
|
-
description: "For test-focused tasks"
|
|
367
|
-
- label: "DONE"
|
|
368
|
-
description: "Simple completion"
|
|
369
|
-
- label: "Custom..."
|
|
370
|
-
description: "Specify custom text"
|
|
371
|
-
```
|
|
153
|
+
## 5. Completion Promise
|
|
372
154
|
|
|
373
|
-
|
|
155
|
+
If `{completion_promise}` is null: ask user to choose (COMPLETE, ALL TESTS PASS, DONE, or custom).
|
|
374
156
|
|
|
375
|
-
|
|
157
|
+
## 6. Collect Metadata
|
|
376
158
|
|
|
377
159
|
```bash
|
|
378
160
|
CLI_VERSION=$(node -e "console.log(require('package.json').version)" 2>/dev/null || echo "unknown")
|
|
@@ -380,73 +162,19 @@ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
|
380
162
|
PROJECT_PATH=$(pwd)
|
|
381
163
|
```
|
|
382
164
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
{
|
|
386
|
-
cli_version: CLI_VERSION,
|
|
387
|
-
branch: CURRENT_BRANCH,
|
|
388
|
-
project_path: PROJECT_PATH,
|
|
389
|
-
mcp_servers: { smartstack: {mcp_smartstack}, context7: {mcp_context7} }
|
|
390
|
-
}
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
### 7. Log Initialization
|
|
394
|
-
|
|
395
|
-
**If {verbose_mode} = true:**
|
|
396
|
-
|
|
397
|
-
Write to `.ralph/logs/{timestamp}.log`:
|
|
398
|
-
```
|
|
399
|
-
[{timestamp}] RALPH LOOP INITIALIZED
|
|
400
|
-
Task: {task_description}
|
|
401
|
-
Max iterations: {max_iterations}
|
|
402
|
-
Completion promise: {completion_promise}
|
|
403
|
-
MCP Status: SmartStack {mcp_smartstack ? "✅" : "❌"}, Context7 {mcp_context7 ? "✅" : "❌"}
|
|
404
|
-
Schema: v2.0.0
|
|
405
|
-
Branch: {CURRENT_BRANCH}
|
|
165
|
+
```javascript
|
|
166
|
+
{metadata} = { cli_version: CLI_VERSION, branch: CURRENT_BRANCH, project_path: PROJECT_PATH,
|
|
167
|
+
mcp_servers: { smartstack: {mcp_smartstack}, context7: {mcp_context7} } }
|
|
406
168
|
```
|
|
407
169
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
**Always show COMPACT summary:**
|
|
170
|
+
## 7. Show Summary
|
|
411
171
|
|
|
412
172
|
```
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
║ Max iterations: {max_iterations} ║
|
|
418
|
-
║ Completion: <promise>{completion_promise}</promise> ║
|
|
419
|
-
║ MCP: ✅ Ready ║
|
|
420
|
-
║ Schema: v2.0.0 ║
|
|
421
|
-
║ Branch: {CURRENT_BRANCH} ║
|
|
422
|
-
║ {modules_queue ? "Modules: " + totalModules + " (" + module_codes.join(" → ") + ")" : "Mode: single module"} ║
|
|
423
|
-
╠══════════════════════════════════════════════════════════════════╣
|
|
424
|
-
║ Files: ║
|
|
425
|
-
║ - .ralph/prd.json (tasks) ║
|
|
426
|
-
║ - .ralph/progress.txt (memory) ║
|
|
427
|
-
║ {modules_queue ? "- .ralph/modules-queue.json (module tracking)" : ""} ║
|
|
428
|
-
╚══════════════════════════════════════════════════════════════════╝
|
|
429
|
-
|
|
173
|
+
RALPH LOOP INITIALIZED
|
|
174
|
+
Task: {task_description} | Max: {max_iterations} | Promise: {completion_promise}
|
|
175
|
+
MCP: Ready | Branch: {branch} | Schema: v3.0.0
|
|
176
|
+
{modules_queue ? `Modules: ${totalModules} (${module_codes.join(' → ')})` : 'Mode: single module'}
|
|
430
177
|
-> Loading tasks...
|
|
431
178
|
```
|
|
432
179
|
|
|
433
|
-
**
|
|
434
|
-
|
|
435
|
-
---
|
|
436
|
-
|
|
437
|
-
## SUCCESS METRICS:
|
|
438
|
-
|
|
439
|
-
- All flags correctly parsed
|
|
440
|
-
- MCP servers verified and available
|
|
441
|
-
- .ralph/ directory structure created
|
|
442
|
-
- Completion promise defined
|
|
443
|
-
- Metadata collected (branch, version, MCP status)
|
|
444
|
-
- prd.json v2 schema validated (if resume)
|
|
445
|
-
- Branch integrity validated (if resume)
|
|
446
|
-
- Multi-module prd files detected and modules-queue.json created (if applicable)
|
|
447
|
-
- Output is COMPACT
|
|
448
|
-
- Proceeded to step-01 immediately after summary
|
|
449
|
-
|
|
450
|
-
## NEXT STEP:
|
|
451
|
-
|
|
452
|
-
After showing initialization summary, always proceed directly to `./step-01-task.md`
|
|
180
|
+
**Proceed directly to step-01-task.md**
|