specweave 1.0.423 → 1.0.424

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": "specweave",
3
- "version": "1.0.423",
3
+ "version": "1.0.424",
4
4
  "description": "Spec-driven development framework for AI coding agents. Works with Claude Code, Codex, Antigravity, Cursor, Copilot & more. 100+ skills, 49 CLI commands, verified skill certification, autonomous execution, and living documentation.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  disable-model-invocation: true
3
- description: Smart auto-commit with remote sync (handles pull/rebase/stash, auto-generates messages, supports multi-repo).
3
+ description: Smart auto-commit with remote sync (handles pull/rebase/stash, auto-generates messages, supports multi-repo). Ensures clean working tree — every file committed or gitignored.
4
4
  argument-hint: "[message]"
5
5
  ---
6
6
 
@@ -19,8 +19,17 @@ argument-hint: "[message]"
19
19
  /sw:save --dry-run # Preview without executing
20
20
  ```
21
21
 
22
+ ## Core Guarantee
23
+
24
+ **After `/sw:save` completes, `git status` must be clean in every repo** — zero untracked files, zero unstaged changes. Achieved by:
25
+ - Committing all important files (source, config, docs, specs, lock files)
26
+ - Gitignoring all unimportant files (build output, deps, OS junk, secrets)
27
+ - Applying this per-repo for both umbrella and all nested repositories
28
+
22
29
  ## Execution Order (MANDATORY)
23
30
 
31
+ Steps 2–7 run **per repo** — first all nested repos (innermost first), then the umbrella/parent project last.
32
+
24
33
  ### 1. Scan for Nested Repos (ALWAYS FIRST)
25
34
 
26
35
  ```bash
@@ -52,9 +61,88 @@ Determine state: `up-to-date` | `ahead` | `behind` | `diverged` | `no-tracking`.
52
61
  - **no-tracking**: `git push -u origin HEAD`
53
62
  - **up-to-date/ahead**: No sync needed, proceed
54
63
 
55
- ### 4. Auto-Commit Message (if none provided)
64
+ ### 4. Smart Staging (MANDATORY replaces `git add -A`)
65
+
66
+ **Goal**: Every file in the repo is accounted for — either staged for commit or covered by `.gitignore`. Nothing left dangling.
67
+
68
+ #### Phase 1: Stage all tracked modifications
69
+
70
+ ```bash
71
+ git add -u # Modified/deleted files already under source control — always safe
72
+ ```
73
+
74
+ This handles: edited source files, updated configs, deleted files, submodule pointer changes.
75
+
76
+ #### Phase 2: Classify untracked files
77
+
78
+ ```bash
79
+ git ls-files --others --exclude-standard
80
+ ```
81
+
82
+ This lists files that are (a) not tracked and (b) not already covered by `.gitignore`. For each, classify using the table below. Match **top-down** — first match wins.
83
+
84
+ | Class | Patterns | Action |
85
+ |-------|----------|--------|
86
+ | **Dependencies** | `node_modules/`, `vendor/`, `bower_components/`, `.pnp.*`, `__pypackages__/`, `.venv/`, `venv/`, `env/` (Python) | `.gitignore` |
87
+ | **Build output** | `dist/`, `build/`, `.next/`, `.nuxt/`, `.output/`, `out/`, `.svelte-kit/`, `.vercel/`, `.netlify/`, `.turbo/`, `storybook-static/`, `*.tsbuildinfo` | `.gitignore` |
88
+ | **Cache** | `.cache/`, `.parcel-cache/`, `.eslintcache`, `.stylelintcache`, `tsconfig.tsbuildinfo` | `.gitignore` |
89
+ | **Coverage** | `coverage/`, `.nyc_output/`, `lcov.info` | `.gitignore` |
90
+ | **Logs** | `*.log`, `npm-debug.log*`, `yarn-debug.log*`, `pnpm-debug.log*`, `lerna-debug.log*` | `.gitignore` |
91
+ | **OS artifacts** | `.DS_Store`, `Thumbs.db`, `desktop.ini`, `._*`, `ehthumbs.db` | `.gitignore` |
92
+ | **Editor/IDE** | `.idea/`, `*.iml`, `*.swp`, `*.swo`, `*~`, `.project`, `.classpath`, `.settings/` | `.gitignore` |
93
+ | **Runtime** | `.wrangler/`, `.dev.vars`, `*.pid`, `*.seed`, `.env.sentry-build-plugin` | `.gitignore` |
94
+ | **Package artifacts** | `*.tgz`, `*.tar.gz` (in repo root or release dirs) | `.gitignore` |
95
+ | **Secrets** | `.env`, `.env.local`, `.env.*.local` (**NOT** `.env.example`, `.env.template`, `.env.sample`), `*.pem`, `*.key`, `*.p12`, `*.pfx`, `*.jks`, `*.keystore` | `.gitignore` + **warn user** |
96
+ | **Large binaries** | Any single file > 5 MB not inside `src/` or `assets/` | **skip** + **warn user** (don't gitignore — let user decide) |
97
+ | **Source (default)** | Everything else: source files, configs, docs, specs, tests, lock files, CI files, `.specweave/`, `.github/`, `*.md` | `git add <file>` |
98
+
99
+ **Critical**: `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml` are **Source** — always commit.
100
+
101
+ #### Phase 3: Update .gitignore (if patterns were added)
102
+
103
+ For each pattern classified as `.gitignore` in Phase 2:
104
+
105
+ 1. **Check if .gitignore exists** — if not, create it
106
+ 2. **Check if pattern already present** — `grep -qxF '<pattern>' .gitignore` (exact line match) or check if a parent pattern already covers it (e.g., `node_modules/` covers `node_modules/foo/`)
107
+ 3. **Append missing patterns** under a clearly marked section:
108
+
109
+ ```gitignore
110
+ # Auto-managed by sw:save — do not edit this section manually
111
+ .DS_Store
112
+ node_modules/
113
+ dist/
114
+ .env
115
+ ```
116
+
117
+ If the `# Auto-managed by sw:save` section already exists, append new patterns there. Otherwise create it at the end of the file.
118
+
119
+ 4. **Stage .gitignore**: `git add .gitignore`
120
+
121
+ #### Phase 4: Stage remaining approved source files
56
122
 
57
- Run `git status --porcelain` and categorize files:
123
+ ```bash
124
+ git add <each file classified as Source in Phase 2>
125
+ ```
126
+
127
+ Use `git add` with explicit file paths — **never** `git add -A` or `git add .`.
128
+
129
+ #### Phase 5: Verify clean state
130
+
131
+ ```bash
132
+ untracked=$(git ls-files --others --exclude-standard)
133
+ if [ -n "$untracked" ]; then
134
+ echo "WARNING: Remaining untracked files (not staged, not gitignored):"
135
+ echo "$untracked"
136
+ fi
137
+ ```
138
+
139
+ - If **zero untracked** remain → clean state achieved, proceed
140
+ - If **untracked remain** (missed by classification) → warn, but still proceed with commit. These files carry forward to next save.
141
+ - In `--interactive` mode: prompt user for each remaining untracked file (stage / gitignore / skip)
142
+
143
+ ### 5. Auto-Commit Message (if none provided)
144
+
145
+ Analyze **staged files only** using `git diff --cached --name-only` and categorize:
58
146
 
59
147
  | Pattern | Type |
60
148
  |---------|------|
@@ -64,22 +152,44 @@ Run `git status --porcelain` and categorize files:
64
152
  | `package.json`, `*.config.*` | `chore:` |
65
153
  | `.github/`, CI files | `ci:` |
66
154
  | `.specweave/increments/*/` | use increment name |
155
+ | `.gitignore` (only change) | `chore: update gitignore` |
156
+ | Mixed (many categories) | `chore: sync changes` or most dominant type |
67
157
 
68
- **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.
158
+ **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.
69
159
 
70
- ### 5. Commit and Push
160
+ ### 6. Commit and Push
71
161
 
72
162
  ```bash
73
- git add -A
74
163
  git commit -m "<message>"
75
164
  git push origin <branch>
76
165
  ```
77
166
 
78
- For multi-repo: generate per-repo messages and commit/push each repo with changes.
167
+ **No `git add` here** all staging was completed in Step 4.
168
+
169
+ For multi-repo: Steps 2–6 run per repo. Nested repos commit/push first (innermost first), umbrella project last (so submodule pointers reflect the latest nested commits).
170
+
171
+ ### 7. Report Summary
79
172
 
80
- ### 6. Report Summary
173
+ Show per repo:
174
+
175
+ ```
176
+ === Save Report ===
177
+
178
+ repo: repositories/org/my-app
179
+ committed: 12 files (8 source, 2 config, 1 test, 1 doc)
180
+ gitignored: 3 patterns added (.DS_Store, dist/, .env)
181
+ warnings: .env detected — added to .gitignore
182
+ push: origin/main ✓
183
+
184
+ repo: . (umbrella)
185
+ committed: 4 files (3 specs, 1 submodule ref)
186
+ gitignored: 0 patterns (already covered)
187
+ push: origin/main ✓
188
+
189
+ All repos clean ✓
190
+ ```
81
191
 
82
- Show repos synced, committed, skipped, and commit messages used.
192
+ If `--dry-run`: show what WOULD be committed, gitignored, and warned execute nothing.
83
193
 
84
194
  ## Conflict Handling
85
195