@atlashub/smartstack-cli 1.35.0 → 1.36.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.
@@ -111,7 +111,7 @@ The loop only stops when this exact tag is output or max iterations reached.
111
111
  1. Parse flags and task description
112
112
  2. Verify MCP servers are available (MANDATORY)
113
113
  3. Initialize .ralph/ structure and state files
114
- 4. Load current task from prd.json (or create initial tasks)
114
+ 4. Load current task from prd.json (or create initial task breakdown with categories, dependencies, and acceptance criteria)
115
115
  5. Execute ONE task per iteration
116
116
  6. Commit changes, update progress
117
117
  7. Check completion criteria
@@ -131,6 +131,10 @@ The loop only stops when this exact tag is output or max iterations reached.
131
131
  | `{current_iteration}` | number | Current iteration count |
132
132
  | `{tasks_completed}` | number | Number of tasks completed |
133
133
  | `{tasks_total}` | number | Total tasks in prd.json |
134
+ | `{task_status}` | string | Current task status (pending/in_progress/completed/failed/skipped/blocked) |
135
+ | `{task_category}` | string | Task category (domain/application/infrastructure/api/frontend/i18n/test/validation) |
136
+ | `{files_created}` | string[] | Files created during current task |
137
+ | `{files_modified}` | string[] | Files modified during current task |
134
138
 
135
139
  </state_variables>
136
140
 
@@ -190,19 +194,58 @@ Before ANY work, verify MCP servers:
190
194
  **prd.json structure:**
191
195
  ```json
192
196
  {
197
+ "$version": "2.0.0",
193
198
  "feature": "{task_description}",
194
- "created": "2024-01-01T00:00:00Z",
195
- "max_iterations": 50,
196
- "completion_promise": "COMPLETE",
197
- "source": null,
199
+ "status": "in_progress",
200
+ "created": "2026-01-30T15:00:00.000Z",
201
+ "updated_at": "2026-01-30T16:30:00.000Z",
202
+ "metadata": {
203
+ "cli_version": "1.36.0",
204
+ "branch": "feature/user-auth",
205
+ "project_path": "/path/to/project",
206
+ "mcp_servers": { "smartstack": true, "context7": true }
207
+ },
208
+ "config": {
209
+ "max_iterations": 50,
210
+ "completion_promise": "COMPLETE",
211
+ "current_iteration": 1
212
+ },
213
+ "source": {
214
+ "type": "ba-handoff",
215
+ "handoff_path": "path/to/4-development-handoff.md",
216
+ "frd_path": null,
217
+ "brd_path": null
218
+ },
198
219
  "tasks": [
199
- { "id": 1, "description": "Task 1", "passes": false },
200
- { "id": 2, "description": "Task 2", "passes": false }
201
- ]
220
+ {
221
+ "id": 1,
222
+ "description": "Create User entity in Domain layer",
223
+ "status": "pending",
224
+ "category": "domain",
225
+ "dependencies": [],
226
+ "acceptance_criteria": "Entity compiles, properties match handoff spec",
227
+ "started_at": null,
228
+ "completed_at": null,
229
+ "iteration": null,
230
+ "commit_hash": null,
231
+ "files_changed": { "created": [], "modified": [] },
232
+ "validation": null,
233
+ "error": null
234
+ }
235
+ ],
236
+ "history": []
202
237
  }
203
238
  ```
204
239
 
205
- > **`source` field:** Optional path to the BA handoff document that generated this task list (set by `/business-analyse` step-05). When present, Ralph Loop can reference the handoff for detailed specifications. `null` when tasks are created directly by Ralph Loop.
240
+ > **Schema v2 notes:**
241
+ > - `$version`: Schema version for forward migration
242
+ > - `status` (top-level): `pending` | `in_progress` | `completed` | `failed` | `partial`
243
+ > - `source.type`: `ba-handoff` | `direct` | `feature-full` — `null` when tasks are created directly by Ralph Loop
244
+ > - `task.status`: `pending` | `in_progress` | `completed` | `failed` | `skipped` | `blocked`
245
+ > - `task.category`: `domain` | `application` | `infrastructure` | `api` | `frontend` | `i18n` | `test` | `validation` | `other`
246
+ > - `task.dependencies`: Array of task IDs that must be `completed` before this task can start
247
+ > - `history`: Structured iteration journal (replaces unstructured progress.txt for traceability)
248
+ > - **Backward compatibility**: step-00 auto-migrates v1 prd.json (with `passes` boolean) to v2 format
206
249
  </file_structure>
207
250
 
208
251
  <execution_rules>
@@ -217,11 +260,14 @@ Before ANY work, verify MCP servers:
217
260
 
218
261
  <success_criteria>
219
262
 
220
- - All tasks in prd.json have `passes: true`
263
+ - All tasks in prd.json have `status: "completed"` (or `"skipped"`)
264
+ - No tasks with `status: "blocked"` remain
221
265
  - MCP validations pass
222
- - Git commits atomic per task
266
+ - Git commits atomic per task with `commit_hash` tracked
267
+ - `history[]` contains entry for every completed task
223
268
  - Completion promise output when genuinely complete
224
269
  - Final report generated in `.ralph/reports/`
270
+ - `prd.json` top-level `status` set to `"completed"` or `"partial"`
225
271
  </success_criteria>
226
272
 
227
273
  <available_commands>
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: step-00-init
3
- description: Initialize Ralph loop - parse args, verify MCP, setup state
3
+ description: Initialize Ralph loop - parse args, verify MCP, setup state, migrate v1
4
4
  next_step: steps/step-01-task.md
5
5
  ---
6
6
 
@@ -13,10 +13,11 @@ next_step: steps/step-01-task.md
13
13
  - ONLY check for resume if -r flag is set
14
14
  - YOU ARE AN INITIALIZER, not an executor
15
15
  - FORBIDDEN to load step-01 until init is complete
16
+ - ALWAYS check prd.json version and migrate if v1
16
17
 
17
18
  ## YOUR TASK:
18
19
 
19
- Initialize the Ralph loop by parsing flags, verifying MCP availability, and setting up the execution environment.
20
+ Initialize the Ralph loop by parsing flags, verifying MCP availability, setting up the execution environment, and validating integrity on resume.
20
21
 
21
22
  ---
22
23
 
@@ -73,26 +74,32 @@ mcp__smartstack__validate_conventions:
73
74
 
74
75
  **Check Context7 MCP:**
75
76
  ```
76
- mcp__plugin_context7_context7__resolve-library-id:
77
+ mcp__context7__resolve-library-id:
77
78
  libraryName: "test"
78
79
  query: "connectivity check"
79
80
  (just to verify connectivity)
80
81
  ```
81
82
 
83
+ **Record MCP status for metadata:**
84
+ ```
85
+ {mcp_smartstack} = true/false
86
+ {mcp_context7} = true/false
87
+ ```
88
+
82
89
  **If ANY MCP fails:**
83
90
  ```
84
91
  ╔══════════════════════════════════════════════════════════════════╗
85
- ║ ❌ MCP SERVER UNAVAILABLE
92
+ ║ ❌ MCP SERVER UNAVAILABLE
86
93
  ╠══════════════════════════════════════════════════════════════════╣
87
- ║ Server: {failed_server}
88
- ║ Status: Connection failed
94
+ ║ Server: {failed_server}
95
+ ║ Status: Connection failed
89
96
  ╠══════════════════════════════════════════════════════════════════╣
90
- ║ RALPH CANNOT PROCEED WITHOUT MCP
91
-
92
- ║ Troubleshooting:
93
- ║ 1. Run: smartstack check-mcp
94
- ║ 2. Restart Claude Code
95
- ║ 3. Check MCP server configuration
97
+ ║ RALPH CANNOT PROCEED WITHOUT MCP
98
+
99
+ ║ Troubleshooting:
100
+ ║ 1. Run: smartstack check-mcp
101
+ ║ 2. Restart Claude Code
102
+ ║ 3. Check MCP server configuration
96
103
  ╚══════════════════════════════════════════════════════════════════╝
97
104
 
98
105
  STOP - Do not proceed.
@@ -103,16 +110,122 @@ STOP - Do not proceed.
103
110
  **If {resume_mode} = true:**
104
111
 
105
112
  1. Check for existing `.ralph/prd.json`
106
- 2. If found:
107
- - Read prd.json to restore state
108
- - Read progress.txt for context
109
- - Set {current_iteration} from state
110
- - Continue to step-01
111
- 3. If not found:
113
+ 2. If not found:
112
114
  - Error: "No active Ralph loop to resume"
113
115
  - Ask user to start new loop
116
+ - STOP
117
+
118
+ 3. If found, **validate schema version:**
119
+
120
+ ```javascript
121
+ const prd = readJSON('.ralph/prd.json');
114
122
 
115
- ### 4. Initialize .ralph/ Structure
123
+ // v1 detection: has "passes" field in tasks or no "$version"
124
+ const isV1 = !prd.$version || prd.tasks?.some(t => 'passes' in t);
125
+
126
+ if (isV1) {
127
+ // AUTO-MIGRATE v1 → v2
128
+ migrateV1toV2(prd);
129
+ }
130
+ ```
131
+
132
+ **v1 → v2 Migration logic:**
133
+
134
+ ```javascript
135
+ function migrateV1toV2(prd) {
136
+ prd.$version = "2.0.0";
137
+ prd.status = prd.tasks.every(t => t.passes) ? "completed" : "in_progress";
138
+ prd.updated_at = new Date().toISOString();
139
+
140
+ // Migrate source field
141
+ if (typeof prd.source === 'string') {
142
+ prd.source = { type: "ba-handoff", handoff_path: prd.source, frd_path: null, brd_path: null };
143
+ } else if (prd.source === null || prd.source === undefined) {
144
+ prd.source = null;
145
+ }
146
+
147
+ // Group flat config fields
148
+ prd.config = {
149
+ max_iterations: prd.max_iterations || 50,
150
+ completion_promise: prd.completion_promise || "COMPLETE",
151
+ current_iteration: prd.current_iteration || 1
152
+ };
153
+ delete prd.max_iterations;
154
+ delete prd.completion_promise;
155
+ delete prd.current_iteration;
156
+
157
+ // Add metadata
158
+ prd.metadata = {
159
+ cli_version: "unknown (migrated)",
160
+ branch: getCurrentBranch(),
161
+ project_path: process.cwd(),
162
+ mcp_servers: { smartstack: {mcp_smartstack}, context7: {mcp_context7} }
163
+ };
164
+
165
+ // Migrate tasks
166
+ prd.tasks = prd.tasks.map(t => ({
167
+ id: t.id,
168
+ description: t.description,
169
+ status: t.passes ? "completed" : "pending",
170
+ category: "other",
171
+ dependencies: [],
172
+ acceptance_criteria: null,
173
+ started_at: null,
174
+ completed_at: t.passes ? prd.updated_at : null,
175
+ iteration: null,
176
+ commit_hash: null,
177
+ files_changed: { created: [], modified: [] },
178
+ validation: null,
179
+ error: null
180
+ }));
181
+
182
+ // Initialize history
183
+ prd.history = [];
184
+
185
+ // Write migrated file
186
+ writeJSON('.ralph/prd.json', prd);
187
+ echo "✅ Migrated prd.json from v1 to v2";
188
+ }
189
+ ```
190
+
191
+ 4. **Validate integrity (v2 resume):**
192
+
193
+ ```bash
194
+ # Check branch consistency
195
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
196
+ PRD_BRANCH={prd.metadata.branch}
197
+
198
+ if [ "$CURRENT_BRANCH" != "$PRD_BRANCH" ]; then
199
+ echo "⚠️ Branch mismatch: prd.json was created on '$PRD_BRANCH', now on '$CURRENT_BRANCH'"
200
+ # Ask user: continue on current branch or switch
201
+ AskUserQuestion:
202
+ header: "Branch"
203
+ question: "prd.json was created on '$PRD_BRANCH' but you're on '$CURRENT_BRANCH'. Continue?"
204
+ options:
205
+ - label: "Continue on $CURRENT_BRANCH"
206
+ description: "Update metadata and continue"
207
+ - label: "Cancel"
208
+ description: "Switch branch manually first"
209
+ fi
210
+
211
+ # Check for external commits since last update
212
+ LAST_UPDATED={prd.updated_at}
213
+ EXTERNAL_COMMITS=$(git log --since="$LAST_UPDATED" --oneline --not --author="Co-Authored-By: Claude" | wc -l)
214
+
215
+ if [ "$EXTERNAL_COMMITS" -gt 0 ]; then
216
+ echo "⚠️ $EXTERNAL_COMMITS external commits detected since last Ralph iteration"
217
+ echo " prd.json state may not reflect current code state"
218
+ fi
219
+ ```
220
+
221
+ 5. **Restore state from prd.json:**
222
+ - Read `prd.config.current_iteration` → `{current_iteration}`
223
+ - Read `prd.config.completion_promise` → `{completion_promise}`
224
+ - Read `prd.config.max_iterations` → `{max_iterations}`
225
+ - Read progress.txt for context
226
+ - Continue to step-01
227
+
228
+ ### 4. Initialize .ralph/ Structure (new loop)
116
229
 
117
230
  **Create directory structure:**
118
231
 
@@ -149,7 +262,27 @@ AskUserQuestion:
149
262
  description: "Specify custom text"
150
263
  ```
151
264
 
152
- ### 6. Log Initialization
265
+ ### 6. Collect Metadata
266
+
267
+ **Gather execution context:**
268
+
269
+ ```bash
270
+ CLI_VERSION=$(node -e "console.log(require('package.json').version)" 2>/dev/null || echo "unknown")
271
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
272
+ PROJECT_PATH=$(pwd)
273
+ ```
274
+
275
+ **Store metadata for prd.json creation (step-01):**
276
+ ```
277
+ {metadata} = {
278
+ cli_version: CLI_VERSION,
279
+ branch: CURRENT_BRANCH,
280
+ project_path: PROJECT_PATH,
281
+ mcp_servers: { smartstack: {mcp_smartstack}, context7: {mcp_context7} }
282
+ }
283
+ ```
284
+
285
+ ### 7. Log Initialization
153
286
 
154
287
  **If {verbose_mode} = true:**
155
288
 
@@ -159,25 +292,29 @@ Write to `.ralph/logs/{timestamp}.log`:
159
292
  Task: {task_description}
160
293
  Max iterations: {max_iterations}
161
294
  Completion promise: {completion_promise}
162
- MCP Status: SmartStack ✅, Context7 ✅
295
+ MCP Status: SmartStack {mcp_smartstack ? "✅" : "❌"}, Context7 {mcp_context7 ? "" : "❌"}
296
+ Schema: v2.0.0
297
+ Branch: {CURRENT_BRANCH}
163
298
  ```
164
299
 
165
- ### 7. Show Summary and Proceed
300
+ ### 8. Show Summary and Proceed
166
301
 
167
302
  **Always show COMPACT summary:**
168
303
 
169
304
  ```
170
305
  ╔══════════════════════════════════════════════════════════════════╗
171
- ║ RALPH LOOP INITIALIZED
306
+ ║ RALPH LOOP INITIALIZED
172
307
  ╠══════════════════════════════════════════════════════════════════╣
173
- ║ Task: {task_description}
174
- ║ Max iterations: {max_iterations}
175
- ║ Completion: <promise>{completion_promise}</promise>
176
- ║ MCP: ✅ Ready
308
+ ║ Task: {task_description}
309
+ ║ Max iterations: {max_iterations}
310
+ ║ Completion: <promise>{completion_promise}</promise>
311
+ ║ MCP: ✅ Ready
312
+ ║ Schema: v2.0.0 ║
313
+ ║ Branch: {CURRENT_BRANCH} ║
177
314
  ╠══════════════════════════════════════════════════════════════════╣
178
- ║ Files:
179
- ║ - .ralph/prd.json (tasks)
180
- ║ - .ralph/progress.txt (memory)
315
+ ║ Files:
316
+ ║ - .ralph/prd.json (tasks)
317
+ ║ - .ralph/progress.txt (memory)
181
318
  ╚══════════════════════════════════════════════════════════════════╝
182
319
 
183
320
  -> Loading tasks...
@@ -193,6 +330,9 @@ MCP Status: SmartStack ✅, Context7 ✅
193
330
  - MCP servers verified and available
194
331
  - .ralph/ directory structure created
195
332
  - Completion promise defined
333
+ - Metadata collected (branch, version, MCP status)
334
+ - v1 prd.json migrated to v2 (if resume)
335
+ - Branch integrity validated (if resume)
196
336
  - Output is COMPACT
197
337
  - Proceeded to step-01 immediately after summary
198
338