@atlashub/smartstack-cli 1.21.0 → 1.23.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": "1.21.0",
3
+ "version": "1.23.0",
4
4
  "description": "SmartStack Claude Code automation toolkit - GitFlow, APEX, EF Core migrations, prompts and more",
5
5
  "author": {
6
6
  "name": "SmartStack",
@@ -10,6 +10,48 @@ tools: Bash, Read, Write, Glob, AskUserQuestion
10
10
 
11
11
  You initialize a GitFlow project.
12
12
 
13
+ ## MANDATORY FIRST CHECK: Existing GitFlow Configuration
14
+
15
+ **BEFORE anything else, check if GitFlow is already initialized in the current directory:**
16
+
17
+ ```bash
18
+ # Check for existing GitFlow config
19
+ if [ -f ".claude/gitflow/config.json" ]; then
20
+ echo "EXISTING_GITFLOW=true"
21
+ cat .claude/gitflow/config.json
22
+ else
23
+ echo "EXISTING_GITFLOW=false"
24
+ fi
25
+ ```
26
+
27
+ **If `EXISTING_GITFLOW=true`, you MUST ask the user BEFORE proceeding:**
28
+
29
+ ```json
30
+ {
31
+ "questions": [{
32
+ "question": "GitFlow is already initialized in this project. What do you want to do?",
33
+ "header": "Existing",
34
+ "options": [
35
+ {"label": "View configuration", "description": "Display current GitFlow settings"},
36
+ {"label": "Reconfigure", "description": "Reset and reconfigure GitFlow (keeps git history)"},
37
+ {"label": "Repair", "description": "Fix missing directories or corrupted config"},
38
+ {"label": "Cancel", "description": "Exit without changes"}
39
+ ],
40
+ "multiSelect": false
41
+ }]
42
+ }
43
+ ```
44
+
45
+ **Handle responses:**
46
+ - **View configuration**: Display the config in a formatted table and EXIT
47
+ - **Reconfigure**: Continue with the init workflow (will overwrite existing config)
48
+ - **Repair**: Check directories, validate config, fix issues, then EXIT
49
+ - **Cancel**: EXIT immediately
50
+
51
+ **⛔ DO NOT continue to URL/clone steps if user selects "View" or "Cancel".**
52
+
53
+ ---
54
+
13
55
  ## MANDATORY WORKFLOW FOR URL MODE
14
56
 
15
57
  When the user provides a URL (starts with `https://` or `git@`), you MUST execute these steps IN ORDER:
@@ -8,110 +8,219 @@ next_step: null
8
8
 
9
9
  ## YOUR TASK:
10
10
 
11
- Set up GitFlow configuration, create main/develop branches, and configure worktree structure.
11
+ Set up GitFlow configuration with bare repository, worktrees, and branches.
12
12
 
13
13
  **ULTRA THINK before creating configuration.**
14
14
 
15
15
  ---
16
16
 
17
+ ## MANDATORY QUESTIONS
18
+
19
+ **⛔ ALWAYS ask these 3 questions, even if values can be auto-detected:**
20
+
21
+ | Question | Variable | Auto-detect from |
22
+ |----------|----------|------------------|
23
+ | Repository URL | `{REPO_URL}` | `git remote get-url origin` |
24
+ | Root folder | `{ROOT_FOLDER}` | Parent of current directory |
25
+ | Project name | `{PROJECT_NAME}` | Repo name from URL or folder |
26
+
27
+ ---
28
+
17
29
  ## EXECUTION SEQUENCE:
18
30
 
19
- ### 1. Detect Environment
31
+ ### 1. Detect Environment (for defaults only)
20
32
 
21
33
  ```bash
22
- # Check if already initialized
23
- [ -f ".claude/gitflow/config.json" ] && {
24
- echo "GitFlow already initialized"
25
- # Show current config and ask to reinitialize
26
- }
34
+ # Check if we're in a git repository
35
+ IS_GIT_REPO=$(git rev-parse --git-dir 2>/dev/null && echo "true" || echo "false")
36
+
37
+ # Auto-detect values for defaults (will be confirmed by user)
38
+ DETECTED_URL=$(git remote get-url origin 2>/dev/null || echo "")
39
+ DETECTED_FOLDER=$(dirname "$(pwd)")
40
+ DETECTED_NAME=$(basename -s .git "$DETECTED_URL" 2>/dev/null || basename "$(pwd)")
27
41
 
28
42
  # Detect git provider
29
- REMOTE_URL=$(git remote get-url origin 2>/dev/null || echo "")
30
- if [[ "$REMOTE_URL" == *"github.com"* ]]; then
43
+ if [[ "$DETECTED_URL" == *"github.com"* ]]; then
31
44
  GIT_PROVIDER="github"
32
- elif [[ "$REMOTE_URL" == *"dev.azure.com"* ]]; then
45
+ elif [[ "$DETECTED_URL" == *"dev.azure.com"* ]]; then
33
46
  GIT_PROVIDER="azuredevops"
34
47
  else
35
48
  GIT_PROVIDER="unknown"
36
49
  fi
37
50
 
38
- # Detect existing branches
39
- HAS_MAIN=$(git branch -r --list "origin/main" | wc -l)
40
- HAS_DEVELOP=$(git branch -r --list "origin/develop" | wc -l)
51
+ # Check if already initialized
52
+ ALREADY_INITIALIZED=$([ -f ".claude/gitflow/config.json" ] && echo "true" || echo "false")
41
53
  ```
42
54
 
43
- ### 2. Configuration Questions
55
+ ### 2. Handle Existing Configuration
56
+
57
+ **If `ALREADY_INITIALIZED` = true:**
58
+
59
+ Display current configuration and ask what to do:
44
60
 
45
61
  ```yaml
46
62
  AskUserQuestion:
47
- - header: "Mode"
48
- question: "How do you want to set up GitFlow?"
63
+ - header: "Existing"
64
+ question: "GitFlow is already initialized. Current config will be shown. What do you want to do?"
49
65
  options:
50
- - label: "Quick Setup (Recommended)"
51
- description: "Auto-detect settings, create branches"
52
- - label: "Custom Setup"
53
- description: "Configure each option manually"
54
- - label: "Existing Config"
55
- description: "Use existing .claude/gitflow/config.json"
66
+ - label: "Reconfigure (Recommended)"
67
+ description: "Review and update all settings"
68
+ - label: "Repair"
69
+ description: "Fix missing directories only"
70
+ - label: "View only"
71
+ description: "Display current config and exit"
72
+ - label: "Cancel"
73
+ description: "Exit without changes"
74
+ multiSelect: false
75
+ ```
76
+
77
+ **Handle choices:**
78
+ - **Reconfigure**: Continue to step 3 (will ask all questions again)
79
+ - **Repair**: Check directories, fix missing ones, exit
80
+ - **View only**: Display config, exit
81
+ - **Cancel**: Exit immediately
82
+
83
+ ### 3. MANDATORY: Ask Repository URL
84
+
85
+ **⛔ ALWAYS ask, even if URL was detected:**
86
+
87
+ ```yaml
88
+ AskUserQuestion:
89
+ - header: "Repository"
90
+ question: "Repository URL? (detected: {DETECTED_URL})"
91
+ options:
92
+ - label: "Use detected URL (Recommended)"
93
+ description: "{DETECTED_URL}"
94
+ - label: "Enter GitHub URL"
95
+ description: "https://github.com/org/repo.git"
96
+ - label: "Enter Azure DevOps URL"
97
+ description: "https://dev.azure.com/org/project/_git/repo"
98
+ - label: "Local only (no remote)"
99
+ description: "Initialize without remote (limited features)"
100
+ multiSelect: false
101
+ ```
102
+
103
+ **If user selects "Enter GitHub URL" or "Enter Azure DevOps URL":**
104
+ - Capture URL via "Other" input
105
+ - Validate format
106
+ - Update `{REPO_URL}` and `{GIT_PROVIDER}`
107
+
108
+ ### 4. MANDATORY: Ask Root Folder
109
+
110
+ **⛔ ALWAYS ask where to create the project structure:**
111
+
112
+ ```yaml
113
+ AskUserQuestion:
114
+ - header: "Location"
115
+ question: "Root folder for project? (All worktrees will be created here)"
116
+ options:
117
+ - label: "Use parent folder (Recommended)"
118
+ description: "{DETECTED_FOLDER}/"
119
+ - label: "Use current folder"
120
+ description: "$(pwd)/ - Will create subfolders here"
121
+ - label: "Enter custom path"
122
+ description: "Specify a different location"
123
+ multiSelect: false
124
+ ```
125
+
126
+ **Explain the structure that will be created:**
127
+
128
+ ```
129
+ {ROOT_FOLDER}/
130
+ ├── .bare/ # Git bare repository
131
+ ├── 01-Main/ # Worktree: main branch
132
+ ├── 02-Develop/ # Worktree: develop branch
133
+ ├── features/ # Feature branch worktrees
134
+ ├── releases/ # Release branch worktrees
135
+ └── hotfixes/ # Hotfix branch worktrees
136
+ ```
137
+
138
+ ### 5. MANDATORY: Ask Project Name
56
139
 
140
+ **⛔ ALWAYS ask to confirm project name:**
141
+
142
+ ```yaml
143
+ AskUserQuestion:
144
+ - header: "Project"
145
+ question: "Project name? (detected: {DETECTED_NAME})"
146
+ options:
147
+ - label: "Use detected name (Recommended)"
148
+ description: "Project: {DETECTED_NAME}"
149
+ - label: "Enter custom name"
150
+ description: "Specify a different project name"
151
+ multiSelect: false
152
+ ```
153
+
154
+ ### 6. Ask Worktree Mode
155
+
156
+ ```yaml
157
+ AskUserQuestion:
57
158
  - header: "Worktrees"
58
159
  question: "How should worktrees be organized?"
59
160
  options:
60
161
  - label: "Organized (Recommended)"
61
- description: "../features/, ../releases/, ../hotfixes/"
62
- - label: "Adjacent"
63
- description: "../worktrees/{type}/"
162
+ description: "01-Main, 02-Develop, features/, releases/, hotfixes/"
163
+ - label: "Simple"
164
+ description: "main/, develop/, features/, releases/, hotfixes/"
64
165
  - label: "Disabled"
65
- description: "No worktrees, use git checkout"
166
+ description: "No worktrees, use git checkout (not recommended)"
167
+ multiSelect: false
66
168
  ```
67
169
 
68
- ### 3. Create Branches (if needed)
170
+ ### 7. Create Directory Structure
171
+
172
+ **⛔ Create the COMPLETE structure:**
69
173
 
70
174
  ```bash
71
- # Ensure we have main
72
- [ "$HAS_MAIN" -eq 0 ] && {
73
- git checkout -b main
74
- git push -u origin main
75
- }
175
+ cd "{ROOT_FOLDER}"
76
176
 
77
- # Ensure we have develop
78
- [ "$HAS_DEVELOP" -eq 0 ] && {
79
- git checkout main
80
- git checkout -b develop
81
- git push -u origin develop
82
- }
83
- ```
177
+ # Create bare repository if not exists
178
+ if [ ! -d ".bare" ]; then
179
+ git clone --bare "{REPO_URL}" .bare
180
+ # Configure bare repo for worktrees
181
+ cd .bare
182
+ git config core.bare false
183
+ git config core.worktree ..
184
+ cd ..
185
+ fi
84
186
 
85
- ### 4. Create Directory Structure
187
+ # Create worktree directories
188
+ mkdir -p features releases hotfixes
86
189
 
87
- ```bash
88
- mkdir -p .claude/gitflow/{plans,logs,cache,backup}
89
-
90
- # Create worktree directories if mode != disabled
91
- case "$WORKTREE_MODE" in
92
- organized)
93
- mkdir -p ../features ../releases ../hotfixes
94
- ;;
95
- adjacent)
96
- mkdir -p ../worktrees/{features,releases,hotfixes}
97
- ;;
98
- esac
190
+ # Organized mode: numbered main folders
191
+ if [ "$WORKTREE_MODE" = "organized" ]; then
192
+ # Create main worktree
193
+ [ ! -d "01-Main" ] && git worktree add 01-Main main
194
+
195
+ # Create develop worktree
196
+ [ ! -d "02-Develop" ] && git worktree add 02-Develop develop
197
+ fi
198
+
199
+ # Simple mode: named folders
200
+ if [ "$WORKTREE_MODE" = "simple" ]; then
201
+ [ ! -d "main" ] && git worktree add main main
202
+ [ ! -d "develop" ] && git worktree add develop develop
203
+ fi
204
+
205
+ # Create gitflow config directory (in develop worktree)
206
+ DEVELOP_PATH=$([ "$WORKTREE_MODE" = "organized" ] && echo "02-Develop" || echo "develop")
207
+ mkdir -p "$DEVELOP_PATH/.claude/gitflow/{plans,logs,cache,backup}"
99
208
  ```
100
209
 
101
- ### 5. Create Configuration
210
+ ### 8. Create Configuration
102
211
 
103
- **Write `.claude/gitflow/config.json`:**
212
+ **Write `.claude/gitflow/config.json` in develop worktree:**
104
213
 
105
214
  ```json
106
215
  {
107
216
  "version": "2.0.0",
108
217
  "repository": {
109
- "name": "{repo_name}",
110
- "defaultBranch": "main",
111
- "remoteUrl": "{remote_url}"
218
+ "name": "{PROJECT_NAME}",
219
+ "rootFolder": "{ROOT_FOLDER}",
220
+ "remoteUrl": "{REPO_URL}"
112
221
  },
113
222
  "git": {
114
- "provider": "{github|azuredevops}",
223
+ "provider": "{GIT_PROVIDER}",
115
224
  "branches": {
116
225
  "main": "main",
117
226
  "develop": "develop"
@@ -124,24 +233,25 @@ esac
124
233
  },
125
234
  "worktrees": {
126
235
  "enabled": true,
127
- "mode": "{organized|adjacent|disabled}",
236
+ "mode": "{WORKTREE_MODE}",
128
237
  "structure": {
129
- "features": "../features",
130
- "releases": "../releases",
131
- "hotfixes": "../hotfixes"
238
+ "main": "{ROOT_FOLDER}/01-Main",
239
+ "develop": "{ROOT_FOLDER}/02-Develop",
240
+ "features": "{ROOT_FOLDER}/features",
241
+ "releases": "{ROOT_FOLDER}/releases",
242
+ "hotfixes": "{ROOT_FOLDER}/hotfixes"
132
243
  }
133
244
  },
134
245
  "versioning": {
135
246
  "strategy": "semver",
136
- "current": "{X.Y.Z}",
247
+ "current": "{VERSION}",
137
248
  "tagPrefix": "v",
138
249
  "sources": ["csproj", "package.json", "VERSION"]
139
250
  },
140
251
  "efcore": {
141
252
  "enabled": true,
142
253
  "validateOnCommit": true,
143
- "blockDestructive": true,
144
- "migrationNaming": "{context}_v{version}_{sequence}_{Description}"
254
+ "blockDestructive": true
145
255
  },
146
256
  "workflow": {
147
257
  "push": {
@@ -151,16 +261,16 @@ esac
151
261
  "autoLabels": true,
152
262
  "requireReview": true
153
263
  }
154
- },
155
- "language": {
156
- "code": "en"
157
264
  }
158
265
  }
159
266
  ```
160
267
 
161
- ### 6. Detect Version
268
+ ### 9. Detect Version
162
269
 
163
270
  ```bash
271
+ # In develop worktree
272
+ cd "$DEVELOP_PATH"
273
+
164
274
  # Priority: csproj > Directory.Build.props > package.json > VERSION > tag
165
275
  VERSION=$(grep -oP '<Version>\K[^<]+' *.csproj 2>/dev/null | head -1)
166
276
  [ -z "$VERSION" ] && VERSION=$(grep -oP '<Version>\K[^<]+' Directory.Build.props 2>/dev/null)
@@ -170,40 +280,68 @@ VERSION=$(grep -oP '<Version>\K[^<]+' *.csproj 2>/dev/null | head -1)
170
280
  [ -z "$VERSION" ] && VERSION="0.1.0"
171
281
  ```
172
282
 
173
- ### 7. Summary
283
+ ### 10. Summary
174
284
 
175
285
  ```
176
286
  ╔══════════════════════════════════════════════════════════════════╗
177
287
  ║ GITFLOW INITIALIZED ║
178
288
  ╠══════════════════════════════════════════════════════════════════╣
179
- Repository: {repo_name}
180
- Provider: {github|azuredevops}
181
- Version: {X.Y.Z}
289
+ Project: {PROJECT_NAME}
290
+ Root: {ROOT_FOLDER}
291
+ Remote: {REPO_URL}
292
+ ║ Provider: {GIT_PROVIDER} ║
293
+ ║ Version: {VERSION} ║
182
294
  ╠══════════════════════════════════════════════════════════════════╣
183
- Branches: ║
184
- - main: ✅ Ready
185
- ║ - develop: Ready
295
+ Structure: ║
296
+ ├── .bare/ (git bare repository)
297
+ ├── 01-Main/ (main branch)
298
+ ║ ├── 02-Develop/ (develop branch) ✅ ║
299
+ ║ ├── features/ (feature worktrees) ✅ ║
300
+ ║ ├── releases/ (release worktrees) ✅ ║
301
+ ║ └── hotfixes/ (hotfix worktrees) ✅ ║
186
302
  ╠══════════════════════════════════════════════════════════════════╣
187
- Worktrees: {mode}
188
- ║ - ../features/ (for feature branches) ║
189
- ║ - ../releases/ (for release branches) ║
190
- ║ - ../hotfixes/ (for hotfix branches) ║
303
+ Config: 02-Develop/.claude/gitflow/config.json
191
304
  ╠══════════════════════════════════════════════════════════════════╣
192
- Config: .claude/gitflow/config.json
193
- ╠══════════════════════════════════════════════════════════════════╣
194
- ║ NEXT: /gitflow start feature <name> ║
305
+ NEXT: cd 02-Develop && /gitflow -f <feature-name>
195
306
  ╚══════════════════════════════════════════════════════════════════╝
196
307
  ```
197
308
 
198
309
  ---
199
310
 
311
+ ## VALIDATION CHECKLIST:
312
+
313
+ Before completing init, verify:
314
+
315
+ - [ ] Repository URL confirmed by user
316
+ - [ ] Root folder confirmed by user
317
+ - [ ] Project name confirmed by user
318
+ - [ ] .bare/ directory exists
319
+ - [ ] 01-Main/ worktree exists and is on main branch
320
+ - [ ] 02-Develop/ worktree exists and is on develop branch
321
+ - [ ] features/, releases/, hotfixes/ directories exist
322
+ - [ ] .claude/gitflow/config.json created in develop worktree
323
+
324
+ ---
325
+
326
+ ## ERROR HANDLING:
327
+
328
+ | Error | Solution |
329
+ |-------|----------|
330
+ | Clone fails | Check URL, network, credentials |
331
+ | Worktree exists | Skip or offer to recreate |
332
+ | Permission denied | Check folder permissions |
333
+ | Branch missing | Create from default branch |
334
+
335
+ ---
336
+
200
337
  ## SUCCESS CRITERIA:
201
338
 
202
- - Configuration file created
203
- - main and develop branches exist
204
- - Worktree directories created (if enabled)
205
- - Version detected and stored
339
+ - All 3 mandatory questions asked
340
+ - Complete folder structure created
341
+ - Both main and develop worktrees functional
342
+ - Configuration file created
343
+ - ✅ User can navigate to 02-Develop and start working
206
344
 
207
345
  ## NEXT STEP:
208
346
 
209
- Init is standalone. User can now run `/gitflow start feature <name>`.
347
+ Init is standalone. User should `cd 02-Develop` then run `/gitflow -f <feature-name>`.