specweave 1.0.256 → 1.0.259

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.
Files changed (113) hide show
  1. package/CLAUDE.md +56 -221
  2. package/README.md +31 -0
  3. package/bin/specweave.js +17 -0
  4. package/dist/src/adapters/README.md +4 -4
  5. package/dist/src/adapters/agents-md-generator.d.ts.map +1 -1
  6. package/dist/src/adapters/agents-md-generator.js +0 -2
  7. package/dist/src/adapters/agents-md-generator.js.map +1 -1
  8. package/dist/src/adapters/claude/README.md +3 -3
  9. package/dist/src/adapters/claude/adapter.js +3 -3
  10. package/dist/src/adapters/claude-md-generator.js +1 -1
  11. package/dist/src/adapters/claude-md-generator.js.map +1 -1
  12. package/dist/src/adapters/registry.yaml +1 -1
  13. package/dist/src/cli/commands/create-increment.d.ts +24 -0
  14. package/dist/src/cli/commands/create-increment.d.ts.map +1 -0
  15. package/dist/src/cli/commands/create-increment.js +53 -0
  16. package/dist/src/cli/commands/create-increment.js.map +1 -0
  17. package/dist/src/cli/commands/init.d.ts.map +1 -1
  18. package/dist/src/cli/commands/init.js +48 -31
  19. package/dist/src/cli/commands/init.js.map +1 -1
  20. package/dist/src/cli/commands/update.d.ts.map +1 -1
  21. package/dist/src/cli/commands/update.js +36 -0
  22. package/dist/src/cli/commands/update.js.map +1 -1
  23. package/dist/src/cli/helpers/init/directory-structure.d.ts.map +1 -1
  24. package/dist/src/cli/helpers/init/directory-structure.js +13 -1
  25. package/dist/src/cli/helpers/init/directory-structure.js.map +1 -1
  26. package/dist/src/cli/helpers/init/summary-banner.d.ts +11 -0
  27. package/dist/src/cli/helpers/init/summary-banner.d.ts.map +1 -1
  28. package/dist/src/cli/helpers/init/summary-banner.js +49 -3
  29. package/dist/src/cli/helpers/init/summary-banner.js.map +1 -1
  30. package/dist/src/cli/helpers/issue-tracker/index.d.ts.map +1 -1
  31. package/dist/src/cli/helpers/issue-tracker/index.js +0 -1
  32. package/dist/src/cli/helpers/issue-tracker/index.js.map +1 -1
  33. package/dist/src/cli/helpers/issue-tracker/sync-config-writer.d.ts.map +1 -1
  34. package/dist/src/cli/helpers/issue-tracker/sync-config-writer.js +6 -2
  35. package/dist/src/cli/helpers/issue-tracker/sync-config-writer.js.map +1 -1
  36. package/dist/src/core/ac-progress-sync.d.ts +13 -0
  37. package/dist/src/core/ac-progress-sync.d.ts.map +1 -1
  38. package/dist/src/core/ac-progress-sync.js +28 -0
  39. package/dist/src/core/ac-progress-sync.js.map +1 -1
  40. package/dist/src/core/config/types.d.ts +24 -1
  41. package/dist/src/core/config/types.d.ts.map +1 -1
  42. package/dist/src/core/config/types.js +6 -1
  43. package/dist/src/core/config/types.js.map +1 -1
  44. package/dist/src/core/doctor/checkers/project-structure-checker.d.ts +1 -0
  45. package/dist/src/core/doctor/checkers/project-structure-checker.d.ts.map +1 -1
  46. package/dist/src/core/doctor/checkers/project-structure-checker.js +53 -3
  47. package/dist/src/core/doctor/checkers/project-structure-checker.js.map +1 -1
  48. package/dist/src/core/fabric/security-scanner.d.ts.map +1 -1
  49. package/dist/src/core/fabric/security-scanner.js +70 -9
  50. package/dist/src/core/fabric/security-scanner.js.map +1 -1
  51. package/dist/src/core/increment/increment-utils.d.ts +6 -0
  52. package/dist/src/core/increment/increment-utils.d.ts.map +1 -1
  53. package/dist/src/core/increment/increment-utils.js +5 -0
  54. package/dist/src/core/increment/increment-utils.js.map +1 -1
  55. package/dist/src/core/living-docs/discovery.d.ts +2 -0
  56. package/dist/src/core/living-docs/discovery.d.ts.map +1 -1
  57. package/dist/src/core/living-docs/discovery.js +91 -17
  58. package/dist/src/core/living-docs/discovery.js.map +1 -1
  59. package/dist/src/core/living-docs/intelligent-analyzer/index.d.ts +5 -0
  60. package/dist/src/core/living-docs/intelligent-analyzer/index.d.ts.map +1 -1
  61. package/dist/src/core/living-docs/intelligent-analyzer/index.js +3 -3
  62. package/dist/src/core/living-docs/intelligent-analyzer/index.js.map +1 -1
  63. package/dist/src/core/living-docs/lsp-bootstrapper.d.ts +64 -0
  64. package/dist/src/core/living-docs/lsp-bootstrapper.d.ts.map +1 -0
  65. package/dist/src/core/living-docs/lsp-bootstrapper.js +118 -0
  66. package/dist/src/core/living-docs/lsp-bootstrapper.js.map +1 -0
  67. package/dist/src/core/project/project-service.d.ts +10 -1
  68. package/dist/src/core/project/project-service.d.ts.map +1 -1
  69. package/dist/src/core/project/project-service.js +37 -2
  70. package/dist/src/core/project/project-service.js.map +1 -1
  71. package/dist/src/core/universal-auto-create.d.ts +64 -0
  72. package/dist/src/core/universal-auto-create.d.ts.map +1 -0
  73. package/dist/src/core/universal-auto-create.js +228 -0
  74. package/dist/src/core/universal-auto-create.js.map +1 -0
  75. package/package.json +1 -1
  76. package/plugins/specweave/PLUGIN.md +0 -3
  77. package/plugins/specweave/commands/living-docs.md +0 -2
  78. package/plugins/specweave/hooks/stop-sync.sh +34 -5
  79. package/plugins/specweave/hooks/user-prompt-submit.sh +115 -326
  80. package/plugins/specweave/hooks/v2/dispatchers/post-tool-use.sh +19 -5
  81. package/plugins/specweave/hooks/v2/handlers/ac-sync-dispatcher.sh +14 -4
  82. package/plugins/specweave/hooks/v2/handlers/universal-auto-create-dispatcher.sh +181 -0
  83. package/plugins/specweave/lib/hooks/sync-living-docs.js +4 -2
  84. package/plugins/specweave/scripts/skill-context.sh +160 -0
  85. package/plugins/specweave/skills/architect/SKILL.md +1 -1
  86. package/plugins/specweave/skills/archive-increments/SKILL.md +13 -3
  87. package/plugins/specweave/skills/auto/SKILL.md +92 -1038
  88. package/plugins/specweave/skills/do/SKILL.md +66 -1106
  89. package/plugins/specweave/skills/docs/SKILL.md +124 -56
  90. package/plugins/specweave/skills/done/SKILL.md +76 -1406
  91. package/plugins/specweave/skills/framework/SKILL.md +1 -1
  92. package/plugins/specweave/skills/increment/SKILL.md +1 -1
  93. package/plugins/specweave/skills/increment-planner/SKILL.md +29 -19
  94. package/plugins/specweave/skills/jobs/SKILL.md +52 -0
  95. package/plugins/specweave/skills/multi-project-spec-mapper/SKILL.md +1 -1
  96. package/plugins/specweave/skills/save/SKILL.md +51 -1372
  97. package/plugins/specweave/skills/smart-reopen-detector/SKILL.md +1 -1
  98. package/plugins/specweave/skills/tdd-orchestrator/SKILL.md +1 -1
  99. package/plugins/specweave/skills/validate/SKILL.md +65 -848
  100. package/plugins/specweave-backend/skills/database-optimizer/SKILL.md +1 -1
  101. package/plugins/specweave-backend/skills/graphql/SKILL.md +1 -1
  102. package/plugins/specweave-frontend/skills/design-system-architect/SKILL.md +1 -1
  103. package/plugins/specweave-frontend/skills/frontend/SKILL.md +1 -1
  104. package/plugins/specweave-frontend/skills/frontend-architect/SKILL.md +1 -1
  105. package/plugins/specweave-frontend/skills/frontend-design/SKILL.md +1 -1
  106. package/plugins/specweave-frontend/skills/i18n-expert/SKILL.md +1 -1
  107. package/plugins/specweave-payments/skills/billing-automation/SKILL.md +1 -1
  108. package/plugins/specweave-testing/skills/accessibility-testing/SKILL.md +1 -1
  109. package/src/templates/CLAUDE.md.template +50 -356
  110. package/src/templates/config.json.template +5 -1
  111. package/plugins/specweave/commands/brownfield-analyzer.md +0 -408
  112. package/plugins/specweave/commands/brownfield-onboarder.md +0 -837
  113. package/plugins/specweave/commands/export-skills.md +0 -179
@@ -10,1421 +10,100 @@ argument-hint: "[message]"
10
10
 
11
11
  !`s="save"; for d in .specweave/skill-memories .claude/skill-memories "$HOME/.claude/skill-memories"; do p="$d/$s.md"; [ -f "$p" ] && awk '/^## Learnings$/{ok=1;next}/^## /{ok=0}ok' "$p" && break; done 2>/dev/null; true`
12
12
 
13
- **SMART SAVE** - Handles everything automatically: commit message generation, remote sync (pull/rebase), branch setup, and push. Just run `/sw:save` and it figures out what to do!
14
-
15
- ## ⚠️ MANDATORY: Nested Repository Scanning (SpecWeave-Specific)
16
-
17
- **THIS IS NOT OPTIONAL.** Before ANY git operations, you MUST scan for nested repositories:
18
-
19
- ### Step 1: ALWAYS Scan for Nested Repos First
20
-
21
- ```bash
22
- # MANDATORY: Execute this BEFORE anything else
23
- echo "🔍 Scanning for nested repositories..."
24
-
25
- # Priority folders for SpecWeave projects
26
- NESTED_REPOS=()
27
- for dir in repositories packages services apps libs; do
28
- if [ -d "$dir" ]; then
29
- for repo in "$dir"/*/; do
30
- if [ -d "${repo}.git" ]; then
31
- NESTED_REPOS+=("${repo%/}")
32
- echo " 📁 Found: ${repo%/}"
33
- fi
34
- done
35
- fi
36
- done
37
-
38
- # Also include parent project if it has .git
39
- if [ -d ".git" ]; then
40
- echo " 📁 Found: . (parent project)"
41
- fi
42
- ```
43
-
44
- ### Step 2: Report What Was Found
45
-
46
- ```markdown
47
- 📡 **Repository Scan Results:**
48
-
49
- | Repository | Path | Status |
50
- |------------|------|--------|
51
- | parent-project | . | ✅ Has changes |
52
- | frontend | repositories/frontend | ✅ Has changes |
53
- | backend | repositories/backend | ⏭️ No changes |
54
- | shared-lib | repositories/shared-lib | ✅ Has changes |
55
-
56
- **Total:** 4 repos found, 3 with changes
57
- ```
58
-
59
- ### Why This Matters
60
-
61
- SpecWeave projects often use the `repositories/` folder for multi-repo setups. **NEVER** assume single-repo mode without explicitly checking for nested repos first.
62
-
63
- **Common SpecWeave project structure:**
64
- ```
65
- my-project/
66
- ├── .specweave/ # SpecWeave config
67
- ├── repositories/ # ← ALWAYS check this folder!
68
- │ ├── frontend/.git # Nested repo
69
- │ ├── backend/.git # Nested repo
70
- │ └── shared/.git # Nested repo
71
- └── .git # Parent repo
72
- ```
73
-
74
- ---
75
-
76
- ## TL;DR - Just Works!
13
+ ## Usage
77
14
 
78
15
  ```bash
79
- /sw:save # FULLY AUTOMATIC - generates message, syncs, pushes (NO prompts!)
16
+ /sw:save # Fully automatic - generates message, syncs, pushes
80
17
  /sw:save "msg" # Your message, auto-sync
81
18
  /sw:save -i # Interactive - asks before each step
19
+ /sw:save --dry-run # Preview without executing
82
20
  ```
83
21
 
84
- **What it handles automatically:**
85
- - ✅ All files included (`git add -A`) - trust your `.gitignore`
86
- - ✅ No commit message? → Generates from changes
87
- - ✅ Remote has new commits? → Auto-pulls (rebase by default)
88
- - ✅ Uncommitted changes during pull? → Auto-stash/unstash
89
- - ✅ Branch not tracking? → Auto-setup with `-u`
90
- - ✅ Multi-repo umbrella? → Syncs all repos
91
- - ⚠️ Warns (but doesn't block) if secrets/huge files detected
92
- - ⛔ **NEVER force pushes** - Always merges with remote safely
93
-
94
- ## What This Command Does (In Order)
95
-
96
- ### ⚠️ EXECUTION ORDER IS MANDATORY
97
-
98
- 1. **🔍 SCAN FOR NESTED REPOS (ALWAYS FIRST!)**
99
- - Check `repositories/`, `packages/`, `services/`, `apps/`, `libs/`
100
- - Find ALL `.git` directories up to 4 levels deep
101
- - Include parent project if it has `.git`
102
- - **NEVER skip this step even for "simple" projects!**
103
-
104
- 2. **📊 Report discovered repos** - Show table of all repos found with their status
22
+ ## Execution Order (MANDATORY)
105
23
 
106
- 3. **🔍 Pre-flight check** - Check remote status for EACH repo BEFORE anything else
107
-
108
- 4. **🔄 Smart sync** - Auto-pull/rebase if behind remote (with stash if needed)
109
-
110
- 5. **📝 Auto-commit message** - Generate from changes if not provided
111
-
112
- 6. **🚀 Push** - Push to remote with auto-retry on recoverable errors
113
-
114
- 7. **✅ Report** - Show summary of what was done across ALL repos
115
-
116
- ### Repository Detection (MANDATORY Auto-Discovery)
117
-
118
- **⚠️ THIS IS NOT OPTIONAL. ALWAYS RUN THESE CHECKS:**
119
-
120
- The `/sw:save` command uses a **three-tier detection strategy**:
121
-
122
- 1. **Umbrella Config (priority)** - If `umbrella.childRepos` is configured in `.specweave/config.json`, uses that list
123
- 2. **🔴 Git-Scan (ALWAYS RUN THIS!)** - Scan for nested `.git` directories (up to 4 levels deep)
124
- - **MUST check**: `repositories/`, `packages/`, `services/`, `apps/`, `libs/`
125
- - Works for microservices architectures without explicit configuration
126
- - **NEVER assume no nested repos without scanning first!**
127
- 3. **Parent Project** - Always includes the root project if it has `.git`
128
-
129
- ### 🔴 MANDATORY: Execute These Commands FIRST
24
+ ### 1. Scan for Nested Repos (ALWAYS FIRST)
130
25
 
131
26
  ```bash
132
- # Step 0: ALWAYS run this before ANY git operations!
133
- echo "🔍 Scanning for repositories..."
134
-
135
- # Check for nested repos in standard SpecWeave folders
136
- for folder in repositories packages services apps libs; do
137
- if [ -d "$folder" ]; then
138
- echo " Checking $folder/..."
139
- for repo in "$folder"/*/; do
140
- if [ -d "${repo}.git" ]; then
141
- echo " ✅ Found repo: ${repo%/}"
142
- fi
143
- done
144
- fi
145
- done
146
-
147
- # Check parent project
148
- if [ -d ".git" ]; then
149
- echo " ✅ Found repo: . (parent project)"
150
- fi
151
- ```
152
-
153
- #### Git-Scan Algorithm (CRITICAL for Microservices)
154
-
155
- **MANDATORY: When no umbrella config exists, ALWAYS scan for nested repos:**
156
-
157
- ```bash
158
- # Step 1: Find all nested .git directories (excluding .git itself and node_modules)
159
- find . -maxdepth 4 -type d -name ".git" \
160
- -not -path "./.git" \
161
- -not -path "*/node_modules/*" \
162
- -not -path "*/.specweave/*" \
163
- 2>/dev/null
164
-
165
- # Step 2: For each .git found, the parent directory is a repo
166
- # Example output:
167
- # ./repositories/frontend/.git → repositories/frontend is a repo
168
- # ./repositories/backend/.git → repositories/backend is a repo
169
- # ./packages/shared/.git → packages/shared is a repo
170
- ```
171
-
172
- **Priority scan paths** (check these first for performance):
173
- 1. `repositories/*/` - Standard SpecWeave multi-repo layout
174
- 2. `packages/*/` - Monorepo packages
175
- 3. `services/*/` - Microservices
176
- 4. `apps/*/` - App directories
177
- 5. `libs/*/` - Library directories
178
-
179
- **Full discovery example:**
180
-
181
- ```bash
182
- # Discovery script that /sw:save internally executes
183
- REPOS=()
184
-
185
- # 1. Check umbrella config first
186
- if [ -f ".specweave/config.json" ]; then
187
- UMBRELLA_REPOS=$(jq -r '.umbrella.childRepos[]?.path // empty' .specweave/config.json 2>/dev/null)
188
- if [ -n "$UMBRELLA_REPOS" ]; then
189
- while IFS= read -r repo; do
190
- [ -d "$repo/.git" ] && REPOS+=("$repo")
191
- done <<< "$UMBRELLA_REPOS"
192
- fi
193
- fi
194
-
195
- # 2. If no umbrella config OR it's empty, scan for nested repos
196
- if [ ${#REPOS[@]} -eq 0 ]; then
197
- # Scan priority paths first
198
- for dir in repositories packages services apps libs; do
199
- if [ -d "$dir" ]; then
200
- for repo in "$dir"/*/; do
201
- [ -d "${repo}.git" ] && REPOS+=("${repo%/}")
202
- done
203
- fi
27
+ for dir in repositories packages services apps libs; do
28
+ [ -d "$dir" ] && for repo in "$dir"/*/; do
29
+ [ -d "${repo}.git" ] && echo "Found: ${repo%/}"
204
30
  done
205
-
206
- # Full recursive scan if nothing found in priority paths
207
- if [ ${#REPOS[@]} -eq 0 ]; then
208
- while IFS= read -r git_dir; do
209
- REPOS+=("$(dirname "$git_dir")")
210
- done < <(find . -maxdepth 4 -type d -name ".git" -not -path "./.git" -not -path "*/node_modules/*" 2>/dev/null)
211
- fi
212
- fi
213
-
214
- # 3. Always include parent project if it has .git
215
- [ -d ".git" ] && REPOS+=(".")
216
-
217
- # Result: REPOS array contains all repositories to process
218
- echo "Discovered repos: ${REPOS[*]}"
219
- ```
220
-
221
- **Example: Microservices without config**
222
-
223
- ```
224
- my-project/ # ← Parent repo (included via tier 3)
225
- ├── repositories/
226
- │ ├── frontend/ # ← Auto-discovered via tier 2
227
- │ │ └── .git
228
- │ ├── backend/ # ← Auto-discovered via tier 2
229
- │ │ └── .git
230
- │ └── shared-lib/ # ← Auto-discovered via tier 2
231
- │ └── .git
232
- └── .specweave/
233
- ```
234
-
235
- Running `/sw:save` will detect and commit+push to **all 4 repositories** automatically!
236
-
237
- **Microservices in `services/` folder:**
238
- ```
239
- my-platform/
240
- ├── services/
241
- │ ├── auth-service/ # ← Auto-discovered
242
- │ │ └── .git
243
- │ ├── payment-service/ # ← Auto-discovered
244
- │ │ └── .git
245
- │ └── notification-service/ # ← Auto-discovered
246
- │ └── .git
247
- └── .specweave/
248
- ```
249
-
250
- **Monorepo with `packages/`:**
251
- ```
252
- my-monorepo/
253
- ├── packages/
254
- │ ├── frontend/ # ← Auto-discovered
255
- │ │ └── .git
256
- │ ├── backend/ # ← Auto-discovered
257
- │ │ └── .git
258
- │ └── shared/ # ← Auto-discovered
259
- │ └── .git
260
- └── .git # ← Parent repo also included
261
- ```
262
-
263
- ## Usage
264
-
265
- ```bash
266
- # FULLY AUTOMATIC - zero prompts! (DEFAULT)
267
- /sw:save
268
-
269
- # With your own commit message
270
- /sw:save "feat: Add menu builder"
271
-
272
- # Interactive mode - asks before each action
273
- /sw:save -i
274
- /sw:save --interactive
275
-
276
- # Dry run - preview without executing
277
- /sw:save --dry-run
278
-
279
- # Force push (careful! requires "FORCE" confirmation)
280
- /sw:save --force
281
- ```
282
-
283
- ## Auto-Generated Commit Messages (IMPORTANT!)
284
-
285
- When no commit message is provided, **automatically analyze git changes and generate a conventional commit message**.
286
-
287
- ### Step-by-Step Algorithm
288
-
289
- #### 1. Get Git Changes
290
-
291
- ```bash
292
- # Get file status
293
- git status --porcelain
294
-
295
- # Get diff stats for context
296
- git diff --stat HEAD
297
-
298
- # Check for active increment
299
- ls .specweave/increments/*/metadata.json 2>/dev/null | head -1
300
- ```
301
-
302
- #### 2. Categorize Files by Type
303
-
304
- Parse `git status --porcelain` output. Status codes:
305
- - `??` = untracked (new)
306
- - ` M` or `M ` = modified
307
- - ` D` or `D ` = deleted
308
- - `R ` = renamed
309
- - `A ` = added (staged)
310
-
311
- **File Category Rules:**
312
-
313
- | Pattern | Category | Commit Type |
314
- |---------|----------|-------------|
315
- | `*.md`, `docs/`, `README*`, `CHANGELOG*` | docs | `docs:` |
316
- | `src/**/*.ts` (excluding `*.test.ts`) | source | `feat:` or `refactor:` |
317
- | `*.test.ts`, `tests/`, `__tests__/`, `*.spec.ts` | tests | `test:` |
318
- | `package.json`, `package-lock.json`, `*.config.*`, `tsconfig*` | config | `chore:` |
319
- | `.github/`, `.gitlab-ci*`, `Jenkinsfile`, `.circleci/` | ci | `ci:` |
320
- | `esbuild*`, `webpack*`, `dist/`, `build/` | build | `build:` |
321
- | `.specweave/increments/*/` | increment | use increment name |
322
- | `*.css`, `*.scss`, `*.less` | styles | `style:` |
323
- | `scripts/`, `bin/` | scripts | `chore:` |
324
-
325
- #### 3. Determine Primary Type
326
-
327
- ```
328
- Count files per category:
329
- docs: 5 files
330
- source: 2 files
331
- tests: 1 file
332
-
333
- Primary = category with most files
334
- If tie → prefer in order: feat > docs > test > chore
335
- ```
336
-
337
- #### 4. Determine Action Verb
338
-
339
- ```
340
- Count by status:
341
- new (??, A): 3 files → "add"
342
- modified (M): 5 files → "update"
343
- deleted (D): 0 files → "remove"
344
- renamed (R): 0 files → "rename"
345
-
346
- Primary action = most common status
347
- If new > modified → "add"
348
- If deleted > others → "remove"
349
- Else → "update"
350
- ```
351
-
352
- #### 5. Derive Scope from Common Path
353
-
354
- ```
355
- Files:
356
- docs-site/docs/guides/file1.md
357
- docs-site/docs/overview/file2.md
358
- docs-site/docs/intro.md
359
-
360
- Common path = docs-site/docs/
361
- Scope = "docs-site" (first significant directory)
362
-
363
- Rules:
364
- - If all files share a common directory → use as scope
365
- - If files are in src/[subdir]/ → use subdir as scope
366
- - If files are scattered → no scope (omit parentheses)
367
- - Special scopes: cli, hooks, plugins, docs-site
368
- ```
369
-
370
- #### 6. Check for Increment Context
371
-
372
- ```bash
373
- # Find active increment
374
- ACTIVE=$(cat .specweave/increments/*/metadata.json 2>/dev/null | \
375
- grep -l '"status": "active"' | head -1)
376
-
377
- if [ -n "$ACTIVE" ]; then
378
- INCREMENT_NAME=$(dirname "$ACTIVE" | xargs basename)
379
- # Example: 0001-academy-restructure
380
- fi
381
- ```
382
-
383
- **If increment is active AND increment files are in changes:**
384
- - Include increment reference in message
385
- - Use increment title/name for context
386
-
387
- #### 7. Generate Message
388
-
389
- **Format:** `type(scope): action description`
390
-
391
- **Generation Rules:**
392
-
393
- ```
394
- # Pattern 1: Pure docs changes
395
- docs(docs-site): update learning journey documentation
396
-
397
- # Pattern 2: New feature with tests
398
- feat(auth): add user authentication service
399
-
400
- # Pattern 3: Increment-related work
401
- docs: add academy section (0001-academy-restructure)
402
-
403
- # Pattern 4: Mixed changes
404
- chore: update config and documentation
405
-
406
- # Pattern 5: Single file change
407
- refactor(cli): simplify init command logic
408
-
409
- # Pattern 6: Dependency updates
410
- chore(deps): update package dependencies
411
- ```
412
-
413
- **Description Templates:**
414
-
415
- | Action | File Count | Template |
416
- |--------|------------|----------|
417
- | add | 1 | `add [filename without ext]` |
418
- | add | 2-5 | `add [primary thing] and [count-1] more` |
419
- | add | >5 | `add [category] files` |
420
- | update | 1 | `update [filename]` |
421
- | update | 2-5 | `update [primary thing] and related files` |
422
- | update | >5 | `update [scope/category]` |
423
- | remove | any | `remove [thing(s)]` |
424
-
425
- #### 8. Execute (Default) or Confirm (Interactive Mode)
426
-
427
- **DEFAULT BEHAVIOR (no `-i` flag):** Just use the generated message and proceed:
428
-
429
- ```markdown
430
- 📊 Analyzing changes...
431
-
432
- 🤖 Auto-generated: `docs(docs-site): add academy section and update learning journey`
433
-
434
- ✅ Committing and pushing...
435
- ```
436
-
437
- **INTERACTIVE MODE (`-i` flag):** Ask for confirmation:
438
-
439
- ```markdown
440
- 📊 **Analyzing changes...**
441
-
442
- Detected:
443
- 📄 5 modified documentation files
444
- 📁 1 new increment folder (0001-academy-restructure)
445
- 📁 1 new docs section (academy/)
446
-
447
- 🤖 **Auto-generated commit message:**
448
-
449
- `docs(docs-site): add academy section and update learning journey`
450
-
451
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
452
-
453
- ? **Choose action:**
454
- 1️⃣ Use this message
455
- 2️⃣ Edit message
456
- 3️⃣ Enter custom message
457
- ```
458
-
459
- ### Example Auto-Generations
460
-
461
- **Example 1: Documentation updates**
462
- ```
463
- Input:
464
- M docs-site/docs/guides/specweave-learning-journey.md
465
- M docs-site/docs/intro.md
466
- M docs-site/docs/overview/features.md
467
- ?? docs-site/docs/academy/
468
-
469
- Output: docs(docs-site): add academy section and update documentation
470
- ```
471
-
472
- **Example 2: Feature development**
473
- ```
474
- Input:
475
- ?? src/services/payment.ts
476
- ?? src/services/payment.test.ts
477
- M src/types/index.ts
478
-
479
- Output: feat: add payment service with tests
480
- ```
481
-
482
- **Example 3: CI/CD changes**
483
- ```
484
- Input:
485
- M .github/workflows/ci.yml
486
- M .github/workflows/release.yml
487
-
488
- Output: ci: update CI and release workflows
489
- ```
490
-
491
- **Example 4: Dependency update**
492
- ```
493
- Input:
494
- M package.json
495
- M package-lock.json
496
-
497
- Output: chore(deps): update dependencies
498
- ```
499
-
500
- **Example 5: Refactoring**
501
- ```
502
- Input:
503
- M src/cli/commands/init.ts
504
- M src/cli/helpers/init/types.ts
505
- M src/cli/helpers/init/config-detection.ts
506
-
507
- Output: refactor(cli): update init command structure
508
- ```
509
-
510
- **Example 6: Mixed changes with increment**
511
- ```
512
- Input:
513
- M src/components/Menu.tsx
514
- M docs/api.md
515
- ?? .specweave/increments/0042-menu-builder/
516
-
517
- Active increment: 0042-menu-builder
518
-
519
- Output: feat: implement menu builder (0042)
520
- ```
521
-
522
- **Example 7: Test additions**
523
- ```
524
- Input:
525
- ?? tests/integration/auth.test.ts
526
- ?? tests/integration/payment.test.ts
527
- M jest.config.js
528
-
529
- Output: test: add integration tests for auth and payment
530
- ```
531
-
532
- **Example 8: Single file**
533
- ```
534
- Input:
535
- M README.md
536
-
537
- Output: docs: update README
538
- ```
539
-
540
- ### Fallback Behavior
541
-
542
- If analysis cannot determine a meaningful message:
543
-
544
- ```markdown
545
- ⚠️ Could not auto-generate a meaningful commit message.
546
-
547
- Changes detected:
548
- - 15 files across multiple categories
549
- - No clear primary category
550
-
551
- ? Please enter a commit message:
552
- > _
553
- ```
554
-
555
- ### Multi-Repo Message Generation
556
-
557
- For umbrella setups, generate per-repo messages:
558
-
559
- ```markdown
560
- 📊 Analyzing changes across repositories...
561
-
562
- **frontend** (4 files):
563
- Auto-generated: `feat(components): add menu builder UI`
564
-
565
- **backend** (2 files):
566
- Auto-generated: `feat(api): add menu endpoints`
567
-
568
- **shared** (1 file):
569
- Auto-generated: `chore: update shared types`
570
-
571
- ? Use same message for all, or per-repo messages?
572
- 1️⃣ Same message (enter custom)
573
- 2️⃣ Use auto-generated per-repo messages
574
- 3️⃣ Edit each message
31
+ done
32
+ [ -d ".git" ] && echo "Found: . (parent project)"
575
33
  ```
576
34
 
577
- ## SMART SYNC ALGORITHM (The Magic!)
35
+ **Three-tier detection**: (1) `umbrella.childRepos` from `.specweave/config.json` if configured, (2) git-scan of nested `.git` dirs up to 4 levels deep, (3) parent project `.git`.
578
36
 
579
- ### Pre-Flight Check - BEFORE Any Commit
580
-
581
- **ALWAYS check remote status first.** Don't wait for push to fail!
37
+ ### 2. Pre-Flight Check
582
38
 
583
39
  ```bash
584
- # Step 1: Fetch without merge (safe, just gets info)
585
40
  git fetch origin
586
-
587
- # Step 2: Check relationship between local and remote
588
41
  LOCAL=$(git rev-parse HEAD)
589
42
  REMOTE=$(git rev-parse @{u} 2>/dev/null || echo "no-upstream")
590
43
  BASE=$(git merge-base HEAD @{u} 2>/dev/null || echo "no-base")
591
-
592
- # Step 3: Determine sync state
593
- if [ "$REMOTE" = "no-upstream" ]; then
594
- STATE="no-tracking"
595
- elif [ "$LOCAL" = "$REMOTE" ]; then
596
- STATE="up-to-date"
597
- elif [ "$LOCAL" = "$BASE" ]; then
598
- STATE="behind" # Remote has commits we don't have
599
- elif [ "$REMOTE" = "$BASE" ]; then
600
- STATE="ahead" # We have commits remote doesn't have
601
- else
602
- STATE="diverged" # Both have unique commits
603
- fi
604
44
  ```
605
45
 
606
- ### Smart Sync Decision Tree
46
+ Determine state: `up-to-date` | `ahead` | `behind` | `diverged` | `no-tracking`.
607
47
 
608
- ```
609
- ┌─────────────────────────────────────────────────────────────────┐
610
- │ PRE-FLIGHT CHECK │
611
- ├─────────────────────────────────────────────────────────────────┤
612
- │ git fetch origin (safe - just gets metadata) │
613
- │ Compare LOCAL vs REMOTE vs BASE │
614
- └──────────────────────────┬──────────────────────────────────────┘
615
-
616
- ┌───────────────┼───────────────┐
617
- ▼ ▼ ▼
618
- ┌──────────┐ ┌──────────┐ ┌──────────┐
619
- │ UP-TO- │ │ AHEAD │ │ BEHIND │
620
- │ DATE │ │ (local │ │ (remote │
621
- │ │ │ has new) │ │ has new) │
622
- └────┬─────┘ └────┬─────┘ └────┬─────┘
623
- │ │ │
624
- Just commit Just commit ┌────┴────┐
625
- and push and push │ STASH │
626
- │ PULL │
627
- │ UNSTASH │
628
- └────┬────┘
629
-
630
- Then commit
631
- and push
48
+ ### 3. Smart Sync
632
49
 
633
- ┌───────────────┴───────────────┐
634
- ▼ ▼
635
- ┌──────────────┐ ┌──────────────┐
636
- │ DIVERGED │ │ NO TRACKING │
637
- │ (both have │ │ (new branch) │
638
- │ unique) │ │ │
639
- └──────┬───────┘ └──────┬───────┘
640
- │ │
641
- ┌──────┴──────┐ Auto setup:
642
- │ STASH │ git push -u
643
- │ PULL │ origin HEAD
644
- │ --rebase │
645
- │ UNSTASH │
646
- └──────┬──────┘
647
-
648
- Then commit
649
- and push
650
- ```
50
+ - **behind/diverged**: Stash dirty files, `git pull --rebase`, unstash
51
+ - **no-tracking**: `git push -u origin HEAD`
52
+ - **up-to-date/ahead**: No sync needed, proceed
651
53
 
652
- ### Stash Handling (Auto-Magic!)
54
+ ### 4. Auto-Commit Message (if none provided)
653
55
 
654
- **Problem**: Can't pull/rebase with uncommitted changes.
655
- **Solution**: Auto-stash, sync, unstash.
56
+ Run `git status --porcelain` and categorize files:
656
57
 
657
- ```bash
658
- # Check if working tree is dirty
659
- DIRTY=$(git status --porcelain)
660
-
661
- if [ -n "$DIRTY" ] && [ "$STATE" != "up-to-date" ] && [ "$STATE" != "ahead" ]; then
662
- echo "📦 Stashing uncommitted changes..."
663
- git stash push -m "specweave-save-autostash"
664
- STASHED=true
665
- fi
666
-
667
- # Do the sync (pull/rebase)
668
- git pull --rebase origin $(git branch --show-current)
669
-
670
- # Restore stash if we stashed
671
- if [ "$STASHED" = true ]; then
672
- echo "📦 Restoring stashed changes..."
673
- git stash pop
674
- fi
675
- ```
676
-
677
- ### Conflict Handling
678
-
679
- **If rebase/merge has conflicts:**
680
-
681
- ```markdown
682
- ⚠️ **Merge conflict detected!**
683
-
684
- Conflicting files:
685
- - src/services/auth.ts
686
- - package.json
687
-
688
- Options:
689
- 1. 🔧 Resolve conflicts manually (I'll wait)
690
- 2. ⏮️ Abort rebase, keep local state
691
- 3. 🔀 Try merge instead of rebase
692
-
693
- ? Choose:
694
- ```
695
-
696
- **Smart Auto-Resolution** (no user input needed for these):
697
-
698
- | File Type | Resolution | Reason |
699
- |-----------|------------|--------|
700
- | `package-lock.json` | Delete, run `npm install` | Auto-regenerates correctly |
701
- | `yarn.lock` | Delete, run `yarn` | Auto-regenerates correctly |
702
- | `.specweave/increments/*/metadata.json` | Keep LOCAL | Your work takes precedence |
703
- | `.specweave/increments/*/tasks.md` | Keep LOCAL | Your progress |
704
- | `*.md` in `.specweave/` | Keep LOCAL | Your documentation |
705
- | `dist/`, `build/`, `node_modules/` | Keep REMOTE | Will rebuild anyway |
58
+ | Pattern | Type |
59
+ |---------|------|
60
+ | `src/**/*.ts` (not test) | `feat:` / `refactor:` |
61
+ | `*.test.ts`, `tests/` | `test:` |
62
+ | `*.md`, `docs/` | `docs:` |
63
+ | `package.json`, `*.config.*` | `chore:` |
64
+ | `.github/`, CI files | `ci:` |
65
+ | `.specweave/increments/*/` | use increment name |
706
66
 
707
- **Files that ALWAYS need manual resolution:**
708
- - Source code (`*.ts`, `*.js`, `*.tsx`)
709
- - Configuration (`*.config.*`, `tsconfig.json`)
710
- - Environment (`.env*`)
67
+ **Format**: `type(scope): action description` -- scope from common path, action from most common status (add/update/remove). If active increment and increment files changed, reference it.
711
68
 
712
- ### Smart File Importance Detection
713
-
714
- When conflicts occur, automatically categorize:
715
-
716
- ```markdown
717
- 🔍 Analyzing conflict importance...
718
-
719
- MUST INCLUDE (your work):
720
- ✓ src/services/auth.ts (modified by you)
721
- ✓ tests/auth.test.ts (new file)
722
- ✓ .specweave/increments/0042/ (your increment)
723
-
724
- CAN AUTO-RESOLVE:
725
- ✓ package-lock.json → npm install
726
- ✓ dist/bundle.js → rebuild
727
-
728
- NEEDS DECISION:
729
- ⚠️ package.json (both modified version)
730
- LOCAL: "version": "1.2.0"
731
- REMOTE: "version": "1.1.5"
732
- → Keep LOCAL (your version bump)? [Y/n]
733
- ```
734
-
735
- ### NEVER Force Push (Safety First!)
736
-
737
- **Force push is DISABLED by default.** Even with `--force` flag:
738
-
739
- ```markdown
740
- User: /sw:save --force
741
-
742
- Claude:
743
- ⚠️ Force push requested!
744
-
745
- This will OVERWRITE remote history. Are you SURE?
746
- - Remote has 3 commits that will be LOST
747
- - Other team members may lose work
748
-
749
- ? Type "FORCE" to confirm (or anything else to cancel):
750
- ```
69
+ ### 5. Commit and Push
751
70
 
752
- **The `--force` flag requires explicit confirmation** because:
753
- - It destroys remote history
754
- - Team members lose commits
755
- - Usually indicates a workflow problem
756
-
757
- **Better alternatives:**
758
- - Let auto-sync handle it (rebase/merge)
759
- - Create a new branch: `/sw:save --branch fix-conflict`
760
- - Ask team to pull before you push
761
-
762
- ### Full Smart Workflow
763
-
764
- ```markdown
765
- /sw:save
766
-
767
- 📡 Scanning repositories...
768
- Mode: Single repo (my-project)
769
-
770
- 🔍 Pre-flight check...
771
- Remote: origin/develop
772
- Local: 3 commits ahead, 2 commits behind
773
- State: DIVERGED
774
-
775
- 📦 Stashing uncommitted changes... (5 files)
776
- Created: stash@{0} "specweave-save-autostash"
777
-
778
- 🔄 Syncing with remote...
779
- git pull --rebase origin develop
780
- ✓ Rebased 3 commits onto latest remote
781
-
782
- 📦 Restoring stashed changes...
783
- ✓ Applied stash@{0}
784
-
785
- 📊 Analyzing changes...
786
- Detected: 5 modified files in src/
787
- Active increment: 0042-menu-builder
788
-
789
- 🤖 Auto-generated message:
790
- feat(menu): implement drag-drop menu builder
791
-
792
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
793
-
794
- ? Action: [1] Use message [2] Edit [3] Custom
795
- > 1
796
-
797
- 💾 Committing...
798
- git add -A
799
- git commit -m "feat(menu): implement drag-drop menu builder"
800
-
801
- 🚀 Pushing...
802
- git push origin develop
803
- ✓ Pushed to origin/develop
804
-
805
- ✅ DONE!
806
- Synced: 2 commits from remote
807
- Committed: 1 new commit
808
- Pushed: 4 commits total
809
- ```
810
-
811
- ### Workflow
812
-
813
- ### Step 1: Detect Repositories
814
-
815
- ```markdown
816
- 📡 Scanning for repositories...
817
-
818
- Mode: Umbrella (3 child repos)
819
-
820
- Repositories:
821
- 1. sw-qr-menu-fe (./sw-qr-menu-fe)
822
- 2. sw-qr-menu-be (./sw-qr-menu-be)
823
- 3. sw-qr-menu-shared (./sw-qr-menu-shared)
824
- ```
825
-
826
- ### Step 2: Pre-Flight Check (NEW!)
827
-
828
- ```markdown
829
- 🔍 Pre-flight check...
830
-
831
- sw-qr-menu-fe:
832
- Branch: develop
833
- Remote: origin/develop
834
- State: ✓ UP-TO-DATE
835
-
836
- sw-qr-menu-be:
837
- Branch: develop
838
- Remote: origin/develop
839
- State: ⚠️ BEHIND (2 commits)
840
- Action: Will pull --rebase before push
841
-
842
- sw-qr-menu-shared:
843
- Branch: develop
844
- Remote: origin/develop
845
- State: ✓ AHEAD (1 commit, ready to push)
846
- ```
847
-
848
- ### Step 3: Smart Sync (Auto-Pull/Rebase)
849
-
850
- ```markdown
851
- 🔄 Syncing repositories...
852
-
853
- sw-qr-menu-be:
854
- 📦 Stashing 3 uncommitted files...
855
- 🔄 git pull --rebase origin develop
856
- Applied: 2 commits from remote
857
- 📦 Restoring stashed files...
858
- ✓ Synced!
859
-
860
- sw-qr-menu-fe:
861
- ✓ Already up-to-date
862
-
863
- sw-qr-menu-shared:
864
- ✓ Already ahead, ready to push
865
- ```
866
-
867
- ### Step 4: Generate/Confirm Message
868
-
869
- ```markdown
870
- 📊 Analyzing changes across repos...
871
-
872
- sw-qr-menu-fe (4 files):
873
- 🤖 Auto: feat(components): add menu builder UI
874
-
875
- sw-qr-menu-be (2 files):
876
- 🤖 Auto: feat(api): add menu endpoints
877
-
878
- sw-qr-menu-shared (0 files):
879
- ⏭️ Skip (no changes)
880
-
881
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
882
-
883
- ? Use per-repo messages or same for all?
884
- [1] Per-repo (auto-generated)
885
- [2] Same message (enter custom)
886
- [3] Edit each
887
-
888
- > 1
889
- ```
890
-
891
- ### Step 5: Commit & Push
892
-
893
- ```markdown
894
- 💾 Saving changes...
895
-
896
- sw-qr-menu-fe:
897
- git add -A
898
- git commit -m "feat(components): add menu builder UI"
899
- git push origin develop
900
- ✓ Done!
901
-
902
- sw-qr-menu-be:
903
- git add -A
904
- git commit -m "feat(api): add menu endpoints"
905
- git push origin develop
906
- ✓ Done!
907
-
908
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
909
-
910
- ✅ SUMMARY
911
-
912
- Synced: 1 repo (pulled 2 commits)
913
- Saved: 2/3 repos
914
- Skipped: 1 (no changes)
915
-
916
- Commits:
917
- sw-qr-menu-fe: feat(components): add menu builder UI
918
- sw-qr-menu-be: feat(api): add menu endpoints
919
- ```
920
-
921
- ## Remote Setup Options
922
-
923
- When a repository has no remote configured:
924
-
925
- ### Option 1: Manual URL
926
-
927
- ```markdown
928
- Enter remote URL: https://github.com/myorg/my-repo.git
929
-
930
- git remote add origin https://github.com/myorg/my-repo.git
931
- ```
932
-
933
- ### Option 2: GitHub Convention
934
-
935
- Uses the folder name as repo name under your GitHub username/org:
936
-
937
- ```markdown
938
- GitHub organization/user: myorg
939
- Repo name (folder): sw-qr-menu-fe
940
-
941
- Remote: https://github.com/myorg/sw-qr-menu-fe
942
- git remote add origin https://github.com/myorg/sw-qr-menu-fe
943
- ```
944
-
945
- ### Option 3: From Umbrella Config
946
-
947
- If `githubUrl` is configured in umbrella config:
948
-
949
- ```json
950
- {
951
- "umbrella": {
952
- "childRepos": [
953
- {
954
- "id": "sw-qr-menu-fe",
955
- "path": "./sw-qr-menu-fe",
956
- "githubUrl": "https://github.com/myorg/sw-qr-menu-fe"
957
- }
958
- ]
959
- }
960
- }
961
- ```
962
-
963
- ```markdown
964
- Using URL from umbrella config:
965
- git remote add origin https://github.com/myorg/sw-qr-menu-fe
966
- ```
967
-
968
- ### Option 4: Skip
969
-
970
- ```markdown
971
- Skipping sw-qr-menu-fe (no remote, user chose to skip)
972
- ```
973
-
974
- ## Error Handling
975
-
976
- ### Push Failure (Authentication)
977
-
978
- ```markdown
979
- sw-qr-menu-fe:
980
- ❌ Push failed: Permission denied (publickey)
981
-
982
- Quick fixes:
983
- 1. Test SSH: ssh -T git@github.com
984
- 2. Switch to HTTPS: git remote set-url origin https://github.com/...
985
- 3. Check token scope (needs 'repo')
986
-
987
- ? [R]etry / [S]kip repo / [A]bort all
988
- ```
989
-
990
- ### Divergent History (NOW HANDLED AUTOMATICALLY!)
991
-
992
- **Old behavior**: Wait for push to fail, then ask.
993
- **New behavior**: Detect BEFORE push, auto-sync!
994
-
995
- ```markdown
996
- 🔍 Pre-flight detected: DIVERGED (3 ahead, 2 behind)
997
-
998
- 🔄 Auto-syncing...
999
- git stash push -m "autostash"
1000
- git pull --rebase origin develop
1001
- git stash pop
1002
- ✓ Synced!
1003
-
1004
- Now ready to commit and push.
1005
- ```
1006
-
1007
- **If auto-sync fails** (rare, only on complex conflicts):
1008
-
1009
- ```markdown
1010
- ⚠️ Rebase conflict in: src/services/auth.ts
1011
-
1012
- Options:
1013
- 1. 🔧 Open editor to resolve (I'll wait)
1014
- 2. 🔀 Try merge instead of rebase
1015
- 3. ⏮️ Abort and keep local state (no push)
1016
- 4. 💪 Force push (overwrites remote - DANGEROUS)
1017
-
1018
- ? Choice:
1019
- ```
1020
-
1021
- ### Branch Not Tracking (NOW AUTO-SETUP!)
1022
-
1023
- **Old behavior**: Ask user what to do.
1024
- **New behavior**: Auto-setup tracking!
1025
-
1026
- ```markdown
1027
- 🔍 Pre-flight: Branch 'feature-x' has no upstream
1028
-
1029
- 🔧 Auto-fixing...
1030
- git push -u origin feature-x
1031
- ✓ Branch now tracks origin/feature-x
1032
- ```
1033
-
1034
- ### Stash Conflicts (Rare)
1035
-
1036
- ```markdown
1037
- ⚠️ Stash pop conflict!
1038
-
1039
- Your stashed changes conflict with pulled changes.
1040
- Conflicting files:
1041
- - package.json
1042
-
1043
- Options:
1044
- 1. 🔧 Resolve manually (stash is in stash@{0})
1045
- 2. 🗑️ Drop stash, keep pulled version
1046
- 3. ⏮️ Restore original state (abort everything)
1047
-
1048
- ? Choice:
71
+ ```bash
72
+ git add -A
73
+ git commit -m "<message>"
74
+ git push origin <branch>
1049
75
  ```
1050
76
 
1051
- ## Integration with Umbrella Config
77
+ For multi-repo: generate per-repo messages and commit/push each repo with changes.
1052
78
 
1053
- This command reads from `.specweave/config.json`:
79
+ ### 6. Report Summary
1054
80
 
1055
- ```json
1056
- {
1057
- "umbrella": {
1058
- "enabled": true,
1059
- "childRepos": [
1060
- {
1061
- "id": "sw-qr-menu-fe",
1062
- "path": "./sw-qr-menu-fe",
1063
- "prefix": "FE",
1064
- "githubUrl": "https://github.com/myorg/sw-qr-menu-fe"
1065
- },
1066
- {
1067
- "id": "sw-qr-menu-be",
1068
- "path": "./sw-qr-menu-be",
1069
- "prefix": "BE",
1070
- "githubUrl": "https://github.com/myorg/sw-qr-menu-be"
1071
- }
1072
- ]
1073
- }
1074
- }
1075
- ```
81
+ Show repos synced, committed, skipped, and commit messages used.
1076
82
 
1077
- ### ID Strategy
83
+ ## Conflict Handling
1078
84
 
1079
- **IMPORTANT**: The `id` field MUST match your canonical source name:
85
+ **Auto-resolvable**: `package-lock.json`/`yarn.lock` (delete + reinstall), `.specweave/` metadata (keep LOCAL), `dist/`/`build/` (keep REMOTE).
1080
86
 
1081
- | Scenario | ID Source | Example |
1082
- |----------|-----------|---------|
1083
- | 1:1 Repo Mapping | Exact repo name | `sw-qr-menu-fe` |
1084
- | JIRA Project | Project key (lowercase) | `WEBAPP` → `webapp` |
1085
- | ADO Project | Project name (kebab-case) | `Frontend Team` → `frontend-team` |
1086
-
1087
- ```
1088
- ✅ CORRECT: id: "sw-qr-menu-fe" (matches repo name)
1089
- ❌ WRONG: id: "fe" (arbitrary abbreviation)
1090
- ```
87
+ **Manual resolution required**: Source code, config files, env files. Present options: resolve manually, try merge instead, abort, or force push (requires typing "FORCE").
1091
88
 
1092
- **Benefits:**
1093
- - Auto-discovers all child repos
1094
- - Uses `githubUrl` for remote setup
1095
- - Skips repos not in config (optional: `--all` to include)
89
+ **NEVER force push by default.** `--force` flag requires explicit "FORCE" confirmation.
1096
90
 
1097
- ## Single Repo Mode
91
+ ## No Remote Configured
1098
92
 
1099
- Without umbrella config, operates on current repository:
93
+ Prompt user with the **exact project name** in the dialog. Options: enter URL manually, skip push (commit only), or cancel. For umbrella: check if clone job is running first.
1100
94
 
1101
- ```markdown
1102
- /sw:save "chore: Update dependencies"
1103
-
1104
- Scanning for repositories...
1105
- Mode: Single repository
1106
- Repository: my-project (.)
1107
-
1108
- my-project:
1109
- Status: 2 files changed
1110
- - package.json (modified)
1111
- - package-lock.json (modified)
1112
- Remote: origin -> github.com/user/my-project
1113
-
1114
- Saving changes...
1115
-
1116
- my-project:
1117
- Staging: git add -A
1118
- Committing: chore: Update dependencies
1119
- Pushing: origin/main
1120
- Done
1121
-
1122
- Summary:
1123
- Saved: 1/1 repository
1124
- ```
1125
-
1126
- ### No Remote Configured (Single Repo or Parent Project)
1127
-
1128
- If operating in single-repo mode and no git remote is configured, prompt the user with the **EXACT project name** in the question:
1129
-
1130
- ```markdown
1131
- ⚠️ No remote repository configured for 'sw-content-repurposer' (parent project).
1132
-
1133
- How would you like to proceed?
1134
- 1. 📝 Enter URL manually - I'll provide the GitHub/GitLab URL for this repository
1135
- 2. ⏭️ Skip push (commit only) - Just commit locally, I'll set up remote later
1136
- 3. ❌ Cancel - Don't commit or push anything right now
1137
- ```
1138
-
1139
- **IMPORTANT**: Always include the project/repository name in the dialog so the user knows WHICH repository is missing the remote. For umbrella setups, this helps distinguish between:
1140
- - Parent project (the umbrella root directory)
1141
- - Child repositories (cloned into `repositories/` folder)
1142
-
1143
- **Check for pending clone jobs**: If `umbrella.childRepos` is empty but a clone job is running (check `/sw:jobs`), inform the user:
1144
-
1145
- ```markdown
1146
- ℹ️ Repository cloning is in progress (job: a84e4fe5).
1147
-
1148
- The child repositories are being cloned in the background. Options:
1149
- 1. ⏳ Wait for cloning to complete (run `/sw:jobs` to check status)
1150
- 2. 💾 Save parent project only (commit .specweave/ changes)
1151
- 3. ❌ Cancel and retry later
1152
- ```
1153
-
1154
- ## Flags and Options
95
+ ## Flags
1155
96
 
1156
97
  | Flag | Description |
1157
98
  |------|-------------|
1158
- | `--interactive` / `-i` | **Interactive mode** - Ask for confirmation before each step |
1159
- | `--dry-run` | Preview mode - show what would happen |
99
+ | `-i` / `--interactive` | Ask confirmation before each step |
100
+ | `--dry-run` | Preview without executing |
1160
101
  | `--sync=rebase` | (default) Pull --rebase before push |
1161
- | `--sync=merge` | Pull --merge instead of rebase |
1162
- | `--sync=none` | Skip auto-sync (old behavior) |
1163
- | `--no-stash` | Don't auto-stash (fail if dirty + needs sync) |
102
+ | `--sync=merge` | Pull --merge instead |
103
+ | `--sync=none` | Skip auto-sync |
104
+ | `--no-push` | Commit only |
105
+ | `--force` | Force push (requires "FORCE" confirmation) |
106
+ | `--branch <name>` | Create new branch instead of force pushing |
1164
107
  | `--repos <list>` | Only save specific repos (comma-separated) |
1165
- | `--skip-no-remote` | Skip repos without remotes (don't prompt) |
108
+ | `--skip-no-remote` | Skip repos without remotes |
1166
109
  | `--all` | Include repos outside umbrella config |
1167
- | `--no-push` | Commit but don't push |
1168
- | `--force` | Force push (REQUIRES typing "FORCE" to confirm!) |
1169
- | `--branch <name>` | Create new branch instead of force pushing |
1170
-
1171
- ### Quick Reference
1172
-
1173
- ```bash
1174
- # Most common - fully automatic (DEFAULT!)
1175
- /sw:save
1176
-
1177
- # Preview what will happen
1178
- /sw:save --dry-run
1179
-
1180
- # Custom message, automatic sync
1181
- /sw:save "feat: new feature"
1182
-
1183
- # Interactive - asks before each step
1184
- /sw:save -i
1185
-
1186
- # Merge instead of rebase
1187
- /sw:save --sync=merge
1188
-
1189
- # Create branch if conflicts (safest!)
1190
- /sw:save --branch my-changes
1191
-
1192
- # Old behavior (fail if behind)
1193
- /sw:save --sync=none
1194
- ```
1195
-
1196
- ### Conflict Resolution Strategy
1197
-
1198
- **Default priority: YOUR WORK WINS**
1199
-
1200
- When merging with remote, the command follows this priority:
1201
- 1. **Your code changes** - Always preserved
1202
- 2. **Your increment files** - Always preserved
1203
- 3. **Lock files** - Regenerated (npm/yarn)
1204
- 4. **Build artifacts** - Use remote (will rebuild)
1205
- 5. **Config conflicts** - Ask user
1206
-
1207
- This ensures you never lose work while still syncing with team.
1208
-
1209
- ## Best Practices
1210
-
1211
- 1. **Just run `/sw:save`** - Zero prompts, fully automatic! Let it figure things out
1212
- 2. **Use `-i` for control** - Interactive mode when you want to review/edit the message
1213
- 3. **Preview with `--dry-run`** - See what will happen before committing
1214
- 4. **Configure `githubUrl` in umbrella config** - Enables auto-remote setup
1215
- 5. **Trust the auto-message** - It analyzes changes intelligently
1216
-
1217
- ## Example Interactions
1218
-
1219
- ### Zero-Args Fully Automatic (The Power Move!)
1220
-
1221
- ```
1222
- User: /sw:save
1223
-
1224
- Claude:
1225
- 📡 Scanning... Single repo (specweave)
1226
-
1227
- 🔍 Pre-flight check...
1228
- Branch: develop → origin/develop
1229
- State: DIVERGED (2 ahead, 3 behind)
1230
-
1231
- 📦 Stashing 5 uncommitted files...
1232
- 🔄 Syncing: git pull --rebase origin develop
1233
- ✓ Rebased 2 commits onto 3 new remote commits
1234
- 📦 Restoring stashed files...
1235
-
1236
- 📊 Analyzing changes...
1237
- 🤖 Auto: feat(save): add smart sync with auto-pull
1238
-
1239
- 💾 Saving...
1240
- git add -A
1241
- git commit -m "feat(save): add smart sync with auto-pull"
1242
- git push origin develop
1243
-
1244
- ✅ DONE! (synced 3 + pushed 3 commits)
1245
- ```
1246
-
1247
- **That's it!** One command, zero prompts, handles everything.
1248
-
1249
- ### With Commit Message (Still Smart!)
1250
-
1251
- ```
1252
- User: /sw:save "feat: Complete user registration"
1253
-
1254
- Claude:
1255
- 📡 Scanning... Umbrella (3 repos)
1256
-
1257
- 🔍 Pre-flight check...
1258
- frontend: ✓ UP-TO-DATE
1259
- backend: ⚠️ BEHIND (2 commits)
1260
- shared: ✓ No changes
1261
-
1262
- 🔄 Syncing backend...
1263
- git pull --rebase origin develop
1264
- ✓ Applied 2 remote commits
1265
-
1266
- 💾 Saving...
1267
-
1268
- frontend:
1269
- git add -A && commit && push ✓
1270
-
1271
- backend:
1272
- git add -A && commit && push ✓
1273
-
1274
- ✅ Saved 2/3 repos with: feat: Complete user registration
1275
- ```
1276
-
1277
- ### Interactive Mode (With `-i` flag)
1278
-
1279
- ```
1280
- User: /sw:save -i
1281
-
1282
- Claude:
1283
- 📡 Scanning... Single repo
1284
-
1285
- 🔍 Pre-flight: ✓ UP-TO-DATE (no sync needed)
1286
-
1287
- 📊 Analyzing changes...
1288
- 5 modified docs, 1 new folder
1289
-
1290
- 🤖 Auto-generated:
1291
- docs(docs-site): add academy section
1292
-
1293
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1294
-
1295
- ? [1] Use [2] Edit [3] Custom
1296
-
1297
- User: 1
1298
-
1299
- 💾 Committing & pushing...
1300
- ✅ Done!
1301
- ```
1302
-
1303
- ### Handling Merge Conflicts (Rare but Covered!)
1304
-
1305
- ```
1306
- User: /sw:save
1307
-
1308
- Claude:
1309
- 📡 Scanning... Single repo
1310
-
1311
- 🔍 Pre-flight: DIVERGED
1312
-
1313
- 📦 Stashing...
1314
- 🔄 Syncing: git pull --rebase
1315
- ⚠️ CONFLICT in src/config.ts
1316
-
1317
- Conflict preview:
1318
- <<<<<<< HEAD
1319
- maxRetries: 5
1320
- =======
1321
- maxRetries: 3
1322
- >>>>>>> upstream
1323
-
1324
- ? Options:
1325
- [1] 🔧 Resolve manually (I'll wait)
1326
- [2] 🔀 Try merge instead
1327
- [3] ⏮️ Abort (keep local)
1328
- [4] 💪 Force push (DANGEROUS)
1329
-
1330
- User: 1
1331
-
1332
- Waiting for conflict resolution...
1333
- Run: git rebase --continue
1334
- Then say: continue
1335
-
1336
- User: continue
1337
-
1338
- 🔄 Continuing...
1339
- 📦 Restoring stash...
1340
- 💾 Saving...
1341
- ✅ Done!
1342
- ```
1343
-
1344
- ### First-Time Remote Setup
1345
-
1346
- ```
1347
- User: /sw:save "Initial commit"
1348
-
1349
- Claude:
1350
- Scanning for repositories...
1351
- Mode: Umbrella (2 child repos)
1352
-
1353
- frontend:
1354
- Status: 15 files changed
1355
- Remote: Not configured
1356
-
1357
- ? No remote configured for frontend. Choose:
1358
- 1. Enter URL manually
1359
- 2. Use GitHub convention
1360
- 3. Skip this repo
1361
-
1362
- User: 2
1363
-
1364
- ? GitHub organization/user: myorg
1365
-
1366
- Claude:
1367
- Adding remote: git remote add origin https://github.com/myorg/frontend
1368
-
1369
- backend:
1370
- Status: 10 files changed
1371
- Remote: Not configured (using from umbrella config)
1372
- Adding remote: git remote add origin https://github.com/myorg/backend
1373
-
1374
- Saving changes...
1375
- [continues with commit and push]
1376
- ```
1377
-
1378
- ### Dry Run Preview
1379
-
1380
- ```
1381
- User: /sw:save --dry-run
1382
-
1383
- Claude:
1384
- DRY RUN MODE - No changes will be made
1385
-
1386
- Scanning for repositories...
1387
- Mode: Umbrella (3 child repos)
1388
-
1389
- Would process:
1390
-
1391
- frontend:
1392
- Status: 3 files changed
1393
- Would: git add -A
1394
- Would: git commit -m "[message]"
1395
- Would: git push origin main
1396
-
1397
- backend:
1398
- Status: 1 file changed
1399
- Would: git add -A
1400
- Would: git commit -m "[message]"
1401
- Would: git push origin main
1402
-
1403
- shared:
1404
- Status: No changes
1405
- Would: Skip (nothing to commit)
1406
-
1407
- ? Enter commit message to see full preview: feat: Update API
1408
-
1409
- Preview complete. Run without --dry-run to execute.
1410
- ```
1411
-
1412
- ## Related Commands
1413
-
1414
- - `/sw-release:align` - Align versions across repos (for releases)
1415
- - `/sw:sync-progress` - Sync task progress to external tools
1416
- - `/sw-github:sync` - Sync increments to GitHub issues
1417
-
1418
- ## Dependencies
1419
-
1420
- **Required:**
1421
- - Git installed and configured
1422
- - SSH key or HTTPS credentials for push
1423
-
1424
- **Optional:**
1425
- - Umbrella config (for multi-repo mode)
1426
- - GitHub CLI (`gh`) for repo creation
1427
-
1428
- ---
1429
-
1430
- **Use this command** to save and push changes across all your repositories with a single command, handling remote setup automatically.