@atlashub/smartstack-cli 1.34.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.
- package/.documentation/installation.html +56 -31
- package/dist/index.js +1098 -582
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/agents/docs-context-reader.md +125 -0
- package/templates/agents/docs-sync-checker.md +122 -0
- package/templates/hooks/docs-drift-check.md +97 -0
- package/templates/skills/_resources/context-digest-template.md +53 -0
- package/templates/skills/_resources/doc-context-cache.md +62 -0
- package/templates/skills/_resources/docs-manifest-schema.md +157 -0
- package/templates/skills/_resources/mcp-validate-documentation-spec.md +183 -0
- package/templates/skills/_shared.md +15 -7
- package/templates/skills/apex/SKILL.md +6 -0
- package/templates/skills/apex/steps/step-00-init.md +9 -0
- package/templates/skills/apex/steps/step-01-analyze.md +36 -0
- package/templates/skills/apex/steps/step-02-plan.md +38 -0
- package/templates/skills/apex/steps/step-03-execute.md +39 -0
- package/templates/skills/apex/steps/step-04-validate.md +31 -1
- package/templates/skills/apex/steps/step-04b-doc-sync.md +162 -0
- package/templates/skills/apex/steps/step-05-examine.md +7 -0
- package/templates/skills/apex/templates/04b-doc-sync.md +31 -0
- package/templates/skills/apex/templates/context-digest.md +35 -0
- package/templates/skills/application/steps/step-04-backend.md +17 -17
- package/templates/skills/application/steps/step-05-frontend.md +4 -1
- package/templates/skills/application/templates-backend.md +8 -8
- package/templates/skills/application/templates-frontend.md +8 -8
- package/templates/skills/business-analyse/SKILL.md +18 -5
- package/templates/skills/business-analyse/_shared.md +306 -4
- package/templates/skills/business-analyse/questionnaire/01-context.md +21 -6
- package/templates/skills/business-analyse/questionnaire/02-stakeholders.md +34 -0
- package/templates/skills/business-analyse/questionnaire/03-scope.md +23 -0
- package/templates/skills/business-analyse/questionnaire/04-data.md +44 -0
- package/templates/skills/business-analyse/questionnaire/05-integrations.md +29 -7
- package/templates/skills/business-analyse/questionnaire/06-security.md +28 -0
- package/templates/skills/business-analyse/questionnaire/07-ui.md +32 -7
- package/templates/skills/business-analyse/questionnaire/08-performance.md +21 -0
- package/templates/skills/business-analyse/questionnaire/09-constraints.md +29 -6
- package/templates/skills/business-analyse/questionnaire/10-documentation.md +27 -6
- package/templates/skills/business-analyse/questionnaire/11-data-lifecycle.md +59 -0
- package/templates/skills/business-analyse/questionnaire/12-migration.md +58 -0
- package/templates/skills/business-analyse/questionnaire/13-cross-module.md +69 -0
- package/templates/skills/business-analyse/steps/step-00-init.md +110 -16
- package/templates/skills/business-analyse/steps/step-01-discover.md +530 -85
- package/templates/skills/business-analyse/steps/step-02-analyse.md +81 -25
- package/templates/skills/business-analyse/steps/step-03-specify.md +116 -24
- package/templates/skills/business-analyse/steps/step-04-validate.md +107 -33
- package/templates/skills/business-analyse/steps/step-05-handoff.md +256 -33
- package/templates/skills/business-analyse/steps/step-06-doc-html.md +84 -25
- package/templates/skills/business-analyse/templates/{frd-handoff.md → tpl-handoff.md} +18 -4
- package/templates/skills/business-analyse/templates-frd.md +19 -5
- package/templates/skills/business-analyse/tracking/change-template.md +30 -0
- package/templates/skills/documentation/SKILL.md +68 -31
- package/templates/skills/documentation/data-schema.md +198 -0
- package/templates/skills/documentation/templates.md +30 -1
- package/templates/skills/gitflow/_shared.md +188 -53
- package/templates/skills/gitflow/phases/abort.md +28 -16
- package/templates/skills/gitflow/phases/cleanup.md +13 -9
- package/templates/skills/gitflow/phases/status.md +16 -17
- package/templates/skills/gitflow/steps/step-commit.md +11 -5
- package/templates/skills/gitflow/steps/step-finish.md +43 -33
- package/templates/skills/gitflow/steps/step-init.md +134 -2
- package/templates/skills/gitflow/steps/step-merge.md +24 -10
- package/templates/skills/gitflow/steps/step-pr.md +42 -28
- package/templates/skills/gitflow/steps/step-start.md +19 -13
- package/templates/skills/gitflow/templates/config.json +14 -4
- package/templates/skills/ralph-loop/SKILL.md +58 -9
- package/templates/skills/ralph-loop/steps/step-00-init.md +170 -30
- package/templates/skills/ralph-loop/steps/step-01-task.md +243 -40
- package/templates/skills/ralph-loop/steps/step-02-execute.md +142 -24
- package/templates/skills/ralph-loop/steps/step-03-commit.md +140 -36
- package/templates/skills/ralph-loop/steps/step-04-check.md +128 -44
- package/templates/skills/ralph-loop/steps/step-05-report.md +175 -88
- /package/templates/skills/business-analyse/templates/{frd-brd.md → tpl-brd.md} +0 -0
- /package/templates/skills/business-analyse/templates/{frd-discovery.md → tpl-discovery.md} +0 -0
- /package/templates/skills/business-analyse/templates/{frd-spec.md → tpl-frd.md} +0 -0
|
@@ -16,23 +16,21 @@ Create a pull request with proper target, title, and description based on branch
|
|
|
16
16
|
|
|
17
17
|
## EXECUTION SEQUENCE:
|
|
18
18
|
|
|
19
|
-
### 1. Detect
|
|
19
|
+
### 1. Load Config and Detect Provider
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
[[ "$
|
|
22
|
+
# Load GitFlow config (sets GF_* variables)
|
|
23
|
+
read_gitflow_config || { echo "❌ Run /gitflow init first."; exit 1; }
|
|
24
|
+
|
|
25
|
+
GIT_PROVIDER="$GF_PROVIDER"
|
|
26
|
+
|
|
27
|
+
# Extract Azure DevOps details if needed
|
|
28
|
+
if [ "$GIT_PROVIDER" = "azuredevops" ]; then
|
|
29
|
+
[[ "$GF_REMOTE_URL" =~ dev\.azure\.com/([^/]+)/([^/]+)/_git/([^/]+) ]] && {
|
|
30
30
|
AZURE_ORG="${BASH_REMATCH[1]}"
|
|
31
31
|
AZURE_PROJECT="${BASH_REMATCH[2]}"
|
|
32
32
|
AZURE_REPO="${BASH_REMATCH[3]}"
|
|
33
33
|
}
|
|
34
|
-
else
|
|
35
|
-
GIT_PROVIDER="unknown"
|
|
36
34
|
fi
|
|
37
35
|
```
|
|
38
36
|
|
|
@@ -42,10 +40,10 @@ fi
|
|
|
42
40
|
CURRENT=$(git rev-parse --abbrev-ref HEAD)
|
|
43
41
|
|
|
44
42
|
case "$CURRENT" in
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*)
|
|
43
|
+
${GF_FEATURE_PREFIX}*) TARGET_BRANCH="$GF_DEVELOP_BRANCH" ;;
|
|
44
|
+
${GF_RELEASE_PREFIX}*) TARGET_BRANCH="$GF_MAIN_BRANCH" ;;
|
|
45
|
+
${GF_HOTFIX_PREFIX}*) TARGET_BRANCH="$GF_MAIN_BRANCH" ;;
|
|
46
|
+
*) TARGET_BRANCH="$GF_DEVELOP_BRANCH" ;;
|
|
49
47
|
esac
|
|
50
48
|
```
|
|
51
49
|
|
|
@@ -90,16 +88,26 @@ EXISTING_PR=$(gh pr list --head "$CURRENT" --json number --jq '.[0].number' 2>/d
|
|
|
90
88
|
### 4. Run Pre-PR Checks
|
|
91
89
|
|
|
92
90
|
```bash
|
|
93
|
-
# Build check
|
|
91
|
+
# Build check (multi-runtime detection)
|
|
94
92
|
echo "Running build check..."
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
# Migration check
|
|
101
|
-
echo "Checking migrations..."
|
|
102
|
-
dotnet ef migrations list 2>&1 || echo "No migrations or EF Core not configured"
|
|
93
|
+
if [ -f "*.sln" ] || ls *.csproj 2>/dev/null | head -1 > /dev/null; then
|
|
94
|
+
dotnet build --no-restore 2>&1 || {
|
|
95
|
+
echo "❌ .NET build failed. Fix before creating PR."
|
|
96
|
+
STOP
|
|
97
|
+
}
|
|
98
|
+
# Migration check
|
|
99
|
+
echo "Checking migrations..."
|
|
100
|
+
dotnet ef migrations list 2>&1 || echo "No migrations or EF Core not configured"
|
|
101
|
+
elif [ -f "package.json" ]; then
|
|
102
|
+
npm run build 2>&1 || {
|
|
103
|
+
echo "❌ npm build failed. Fix before creating PR."
|
|
104
|
+
STOP
|
|
105
|
+
}
|
|
106
|
+
elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
|
|
107
|
+
echo "Python project detected — skipping build check"
|
|
108
|
+
else
|
|
109
|
+
echo "⚠️ No known build system detected — skipping build check"
|
|
110
|
+
fi
|
|
103
111
|
```
|
|
104
112
|
|
|
105
113
|
### 5. Generate PR Content
|
|
@@ -112,7 +120,7 @@ BRANCH_TYPE=$(echo $CURRENT | cut -d'/' -f1)
|
|
|
112
120
|
case "$BRANCH_TYPE" in
|
|
113
121
|
feature) TITLE="feat: $BRANCH_NAME" ;;
|
|
114
122
|
hotfix) TITLE="fix: $BRANCH_NAME" ;;
|
|
115
|
-
release) TITLE="release: v$
|
|
123
|
+
release) TITLE="release: v$GF_VERSION" ;;
|
|
116
124
|
esac
|
|
117
125
|
```
|
|
118
126
|
|
|
@@ -187,13 +195,19 @@ fi
|
|
|
187
195
|
### 8. Store PR Info
|
|
188
196
|
|
|
189
197
|
```bash
|
|
190
|
-
#
|
|
198
|
+
# Persist PR info for merge step (uses config path for portability)
|
|
199
|
+
CONFIG_DIR=$(dirname "$GF_CONFIG_FILE")
|
|
200
|
+
cat > "$CONFIG_DIR/cache/pr-state.json" << EOF
|
|
191
201
|
{
|
|
192
|
-
"pr_number": $PR_NUMBER,
|
|
202
|
+
"pr_number": "$PR_NUMBER",
|
|
193
203
|
"pr_url": "$PR_URL",
|
|
204
|
+
"source_branch": "$CURRENT",
|
|
194
205
|
"target_branch": "$TARGET_BRANCH",
|
|
195
|
-
"git_provider": "$GIT_PROVIDER"
|
|
206
|
+
"git_provider": "$GIT_PROVIDER",
|
|
207
|
+
"created_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
196
208
|
}
|
|
209
|
+
EOF
|
|
210
|
+
echo "✓ PR state saved to $CONFIG_DIR/cache/pr-state.json"
|
|
197
211
|
```
|
|
198
212
|
|
|
199
213
|
### 9. Summary
|
|
@@ -31,18 +31,22 @@ Create a new feature/release/hotfix branch with optional worktree setup.
|
|
|
31
31
|
|
|
32
32
|
## EXECUTION SEQUENCE:
|
|
33
33
|
|
|
34
|
-
### 1. Analyze Context
|
|
34
|
+
### 1. Load Config and Analyze Context
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
+
# Load GitFlow config (sets GF_* variables)
|
|
38
|
+
# See _shared.md → READ_GITFLOW_CONFIG for all variables
|
|
39
|
+
read_gitflow_config || { echo "❌ Run /gitflow init first."; exit 1; }
|
|
40
|
+
|
|
37
41
|
CURRENT_BRANCH=$(git branch --show-current)
|
|
38
42
|
git fetch origin --quiet
|
|
39
43
|
|
|
40
|
-
# Version
|
|
41
|
-
VERSION
|
|
44
|
+
# Version from config
|
|
45
|
+
VERSION="$GF_VERSION"
|
|
42
46
|
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none")
|
|
43
47
|
|
|
44
48
|
# Develop ahead of main?
|
|
45
|
-
DEVELOP_AHEAD=$(git rev-list --count origin
|
|
49
|
+
DEVELOP_AHEAD=$(git rev-list --count origin/$GF_MAIN_BRANCH..origin/$GF_DEVELOP_BRANCH 2>/dev/null || echo "0")
|
|
46
50
|
|
|
47
51
|
# Working directory status
|
|
48
52
|
DIRTY=$(git status --porcelain | wc -l)
|
|
@@ -129,17 +133,17 @@ esac
|
|
|
129
133
|
|
|
130
134
|
### 6. Create Branch and Worktree
|
|
131
135
|
|
|
132
|
-
**Read worktree mode from config:**
|
|
136
|
+
**Read worktree mode from config (already loaded by read_gitflow_config):**
|
|
133
137
|
```bash
|
|
134
|
-
WORKTREE_MODE
|
|
138
|
+
WORKTREE_MODE="$GF_WORKTREE_MODE"
|
|
135
139
|
```
|
|
136
140
|
|
|
137
|
-
**Mode: organized**
|
|
141
|
+
**Mode: organized (uses absolute paths from config)**
|
|
138
142
|
```bash
|
|
139
143
|
case "$branch_type" in
|
|
140
|
-
feature) WORKTREE_PATH="
|
|
141
|
-
release) WORKTREE_PATH="
|
|
142
|
-
hotfix) WORKTREE_PATH="
|
|
144
|
+
feature) WORKTREE_PATH="$GF_FEATURES_PATH/$BRANCH_NAME" ;;
|
|
145
|
+
release) WORKTREE_PATH="$GF_RELEASES_PATH/v$VERSION" ;;
|
|
146
|
+
hotfix) WORKTREE_PATH="$GF_HOTFIXES_PATH/$BRANCH_NAME" ;;
|
|
143
147
|
esac
|
|
144
148
|
|
|
145
149
|
mkdir -p "$(dirname $WORKTREE_PATH)"
|
|
@@ -181,13 +185,15 @@ API_DIR=$(find "$WORKTREE_PATH" -type d -name "*.Api" -path "*/src/*" | head -1)
|
|
|
181
185
|
WEB_DIR=$(find "$WORKTREE_PATH" -type d -name "*-web" -path "*/web/*" | head -1)
|
|
182
186
|
|
|
183
187
|
# Generate unique ports based on branch name hash (to avoid conflicts between worktrees)
|
|
184
|
-
|
|
188
|
+
# Use shasum (portable across macOS/Linux/Windows Git Bash) with md5sum fallback
|
|
189
|
+
HASH=$(echo "$BRANCH_NAME" | shasum 2>/dev/null || echo "$BRANCH_NAME" | md5sum 2>/dev/null || echo "$BRANCH_NAME" | cksum)
|
|
190
|
+
HASH=$(echo "$HASH" | cut -c1-4)
|
|
185
191
|
HASH_NUM=$((16#$HASH % 100))
|
|
186
192
|
API_PORT=$((5200 + HASH_NUM))
|
|
187
193
|
WEB_PORT=$((5300 + HASH_NUM))
|
|
188
194
|
|
|
189
|
-
# Project
|
|
190
|
-
PROJECT_NAME=$(
|
|
195
|
+
# Project name from config (not from pwd)
|
|
196
|
+
PROJECT_NAME=$(echo "$GF_PROJECT_NAME" | tr '[:upper:]' '[:lower:]')
|
|
191
197
|
DB_NAME=$(echo "${PROJECT_NAME}_${branch_type}_${BRANCH_NAME}" | cut -c1-63)
|
|
192
198
|
```
|
|
193
199
|
|
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
"version": "2.0.0",
|
|
3
3
|
"repository": {
|
|
4
4
|
"name": "",
|
|
5
|
+
"rootFolder": "",
|
|
6
|
+
"nameVariants": {
|
|
7
|
+
"pascalCaseDot": "",
|
|
8
|
+
"pascalCase": "",
|
|
9
|
+
"kebabCase": "",
|
|
10
|
+
"snakeCase": "",
|
|
11
|
+
"displayName": ""
|
|
12
|
+
},
|
|
5
13
|
"defaultBranch": "main",
|
|
6
14
|
"remoteUrl": ""
|
|
7
15
|
},
|
|
8
16
|
"git": {
|
|
9
|
-
"provider": "
|
|
17
|
+
"provider": "",
|
|
10
18
|
"branches": {
|
|
11
19
|
"main": "main",
|
|
12
20
|
"develop": "develop"
|
|
@@ -21,9 +29,11 @@
|
|
|
21
29
|
"enabled": true,
|
|
22
30
|
"mode": "organized",
|
|
23
31
|
"structure": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
32
|
+
"main": "",
|
|
33
|
+
"develop": "",
|
|
34
|
+
"features": "",
|
|
35
|
+
"releases": "",
|
|
36
|
+
"hotfixes": ""
|
|
27
37
|
}
|
|
28
38
|
},
|
|
29
39
|
"versioning": {
|
|
@@ -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
|
|
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,16 +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
|
-
"
|
|
195
|
-
"
|
|
196
|
-
"
|
|
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
|
+
},
|
|
197
219
|
"tasks": [
|
|
198
|
-
{
|
|
199
|
-
|
|
200
|
-
|
|
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": []
|
|
201
237
|
}
|
|
202
238
|
```
|
|
239
|
+
|
|
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
|
|
203
249
|
</file_structure>
|
|
204
250
|
|
|
205
251
|
<execution_rules>
|
|
@@ -214,11 +260,14 @@ Before ANY work, verify MCP servers:
|
|
|
214
260
|
|
|
215
261
|
<success_criteria>
|
|
216
262
|
|
|
217
|
-
- All tasks in prd.json have `
|
|
263
|
+
- All tasks in prd.json have `status: "completed"` (or `"skipped"`)
|
|
264
|
+
- No tasks with `status: "blocked"` remain
|
|
218
265
|
- MCP validations pass
|
|
219
|
-
- Git commits atomic per task
|
|
266
|
+
- Git commits atomic per task with `commit_hash` tracked
|
|
267
|
+
- `history[]` contains entry for every completed task
|
|
220
268
|
- Completion promise output when genuinely complete
|
|
221
269
|
- Final report generated in `.ralph/reports/`
|
|
270
|
+
- `prd.json` top-level `status` set to `"completed"` or `"partial"`
|
|
222
271
|
</success_criteria>
|
|
223
272
|
|
|
224
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,
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
|
295
|
+
MCP Status: SmartStack {mcp_smartstack ? "✅" : "❌"}, Context7 {mcp_context7 ? "✅" : "❌"}
|
|
296
|
+
Schema: v2.0.0
|
|
297
|
+
Branch: {CURRENT_BRANCH}
|
|
163
298
|
```
|
|
164
299
|
|
|
165
|
-
###
|
|
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
|
|