@speclife/cli 0.9.0 → 0.9.1

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": "@speclife/cli",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "CLI for SpecLife - for CI/scripts",
5
5
  "repository": {
6
6
  "type": "git",
@@ -4,162 +4,25 @@ id: speclife-convert
4
4
  category: SpecLife
5
5
  description: Switch between branch-only and worktree modes for current change.
6
6
  ---
7
- # /speclife convert
8
-
9
- Switch between branch-only and worktree modes for current change.
10
-
11
- ## ⚡ Execution
12
-
13
- **When this command is invoked, IMMEDIATELY execute the workflow below.**
14
-
15
- - Parse "to worktree" or "to branch" from the invocation
16
- - Check prerequisites before proceeding
17
- - Handle uncommitted changes (prompt to commit/stash)
18
- - Complete the conversion and report next steps
19
-
20
- ## Usage
21
-
22
- ```
23
- /speclife convert to worktree # Branch → Worktree
24
- /speclife convert to branch # Worktree Branch
25
- ```
26
-
27
- ## When to use
28
-
29
- **To worktree:** You started simple but now need to work on something else in parallel.
30
-
31
- **To branch:** Your IDE struggles with worktrees, or you want simpler setup.
32
-
33
- ## Steps
34
-
35
- ### Convert to Worktree
36
-
37
- Prerequisites:
38
- - Must be on a `spec/*` branch in main repo
39
- - Cannot already be in a worktree
40
-
41
- ```bash
42
- # 1. Check we're on a spec branch
43
- BRANCH=$(git branch --show-current)
44
- [[ ! "$BRANCH" =~ ^spec/ ]] && error "Not on a spec branch"
45
-
46
- # 2. Extract change-id
47
- CHANGE_ID=${BRANCH#spec/}
48
-
49
- # 3. Check worktree doesn't already exist
50
- [[ -d "worktrees/$CHANGE_ID" ]] && error "Worktree already exists"
51
- ```
52
-
53
- Steps:
54
- 1. **Commit changes** if any uncommitted work exists (or ask user to stash)
55
- 2. **Create worktree** from current branch:
56
- ```bash
57
- git worktree add worktrees/$CHANGE_ID $BRANCH
58
- ```
59
- 3. **Return to main** in original repo:
60
- ```bash
61
- git checkout main
62
- ```
63
- 4. **Bootstrap environment** in worktree (symlink node_modules, etc.)
64
- 5. **Report:**
65
- ```
66
- ✓ Created worktree at worktrees/<change-id>/
67
- ✓ Main repo now on main branch
68
-
69
- Next: cd worktrees/<change-id>/ to continue work
70
- ```
71
-
72
- ### Convert to Branch
73
-
74
- Prerequisites:
75
- - Must be in a worktree (not main repo)
76
- - Must be on a `spec/*` branch
77
-
78
- ```bash
79
- # Detect if we're in a worktree
80
- WORKTREE_ROOT=$(git rev-parse --path-format=relative --git-common-dir)
81
- [[ "$WORKTREE_ROOT" == ".git" ]] && error "Not in a worktree"
82
- ```
83
-
84
- Steps:
85
- 1. **Commit changes** if any uncommitted work exists (or ask user to stash)
86
- 2. **Note current branch and worktree path**
87
- 3. **Go to main repo:**
88
- ```bash
89
- cd $(git worktree list | grep -v '^\[' | head -1 | awk '{print $1}')
90
- ```
91
- 4. **Checkout the branch:**
92
- ```bash
93
- git checkout $BRANCH
94
- ```
95
- 5. **Remove worktree** (keeps branch):
96
- ```bash
97
- git worktree remove worktrees/$CHANGE_ID
98
- ```
99
- 6. **Report:**
100
- ```
101
- ✓ Removed worktree
102
- ✓ Now on <branch> in main repo
103
-
104
- Next: Continue work here. Use /speclife convert to worktree if you need parallel work later.
105
- ```
106
-
107
- ## Examples
108
-
109
- **Branch → Worktree:**
110
- ```
111
- User: /speclife convert to worktree
112
-
113
- Agent:
114
- ℹ️ Current: spec/add-oauth on main repo
115
- ✓ Committed pending changes
116
- ✓ Created worktree at worktrees/add-oauth/
117
- ✓ Switched main repo to main branch
118
-
119
- Next: cd worktrees/add-oauth/
120
- ```
121
-
122
- **Worktree → Branch:**
123
- ```
124
- User: /speclife convert to branch
125
-
126
- Agent:
127
- ℹ️ Current: worktrees/add-oauth/ on spec/add-oauth
128
- ✓ Committed pending changes
129
- ✓ Checked out spec/add-oauth in main repo
130
- ✓ Removed worktree
131
-
132
- Next: Continue in main repo
133
- ```
134
-
135
- ## Error Handling
136
-
137
- **Not on a spec branch:**
138
- ```
139
- ❌ Not on a spec/* branch. This command only works with spec branches.
140
- ```
141
-
142
- **Already in target mode:**
143
- ```
144
- ℹ️ Already in worktree mode. Nothing to convert.
145
- ```
146
-
147
- **Uncommitted changes:**
148
- ```
149
- ⚠️ You have uncommitted changes:
150
- - src/auth.ts (modified)
151
- - package.json (modified)
152
-
153
- Options:
154
- 1. Commit now (recommended)
155
- 2. Stash and continue
156
- 3. Abort
157
- ```
158
-
159
- ## Notes
160
-
161
- - Converting preserves all commits and history
162
- - Branch name stays the same (`spec/<change-id>`)
163
- - Spec files in `openspec/changes/<change-id>/` work in both modes
164
- - You can convert back and forth as needed
165
-
7
+ **Guardrails**
8
+ - Execute immediately—parse "to worktree" or "to branch" from invocation
9
+ - Require: on a `spec/*` branch
10
+ - Handle uncommitted changes: prompt to commit or stash
11
+
12
+ **Steps (to worktree)**
13
+ 1. Check: must be on `spec/*` branch in main repo, worktree doesn't already exist.
14
+ 2. Commit any uncommitted changes (or ask user to stash).
15
+ 3. Create worktree: `git worktree add worktrees/<change-id> <branch>`.
16
+ 4. Return main repo to main: `git checkout main`.
17
+ 5. Report: worktree created, next step is `cd worktrees/<change-id>/`.
18
+
19
+ **Steps (to branch)**
20
+ 1. Check: must be in a worktree on `spec/*` branch.
21
+ 2. Commit any uncommitted changes.
22
+ 3. Go to main repo, checkout the branch: `git checkout <branch>`.
23
+ 4. Remove worktree: `git worktree remove worktrees/<change-id>`.
24
+ 5. Report: worktree removed, continue in main repo.
25
+
26
+ **Reference**
27
+ - Converts preserve all commits and history
28
+ - Branch name stays same; spec files work in both modes
@@ -2,245 +2,24 @@
2
2
  name: /speclife-land
3
3
  id: speclife-land
4
4
  category: SpecLife
5
- description: Merge an approved PR, clean up, and trigger auto-release if applicable.
5
+ description: Merge an approved PR, clean up, and trigger auto-release.
6
6
  ---
7
- # /speclife land
8
-
9
- Merge a PR into main. Works with any PR - yours, team members', or external contributors'.
10
-
11
- ## ⚡ Execution
12
-
13
- **When this command is invoked, IMMEDIATELY execute the workflow below.**
14
-
15
- - Do NOT skip steps or ask for excessive confirmation
16
- - If PR number is provided (#42), use that PR
17
- - If on a feature branch, find the PR for that branch
18
- - If on main, prompt for PR number
19
- - **STOP after reporting—this is a terminal command in the workflow**
20
-
21
- ## TL;DR
22
-
23
- ```
24
- /speclife land # Land PR for current branch
25
- /speclife land #42 # Land specific PR by number
26
- ```
27
-
28
- **Quick flow:**
29
- 1. Find PR (from branch or number)
30
- 2. Verify ready (approved, CI passing)
31
- 3. Detect version bump type (feat → minor, fix → patch)
32
- 4. If major (breaking) → confirm with user
33
- 5. Bump version in feature branch, push
34
- 6. Squash merge PR (version included)
35
- 7. Cleanup (worktree if spec branch)
36
- 8. GitHub Actions auto-creates release
37
-
38
- ## Mode Detection
39
-
40
- ```bash
41
- BRANCH=$(git branch --show-current)
42
- ```
43
-
44
- | Invocation | Mode |
45
- |------------|------|
46
- | `/speclife land` on feature branch | Land PR for current branch |
47
- | `/speclife land #42` | Land specific PR |
48
- | `/speclife land` on main | Prompt for PR number |
49
-
50
- ## Core Steps
51
-
52
- ### 1. Find PR
53
- ```bash
54
- # By branch
55
- gh pr view --json number,state,reviewDecision
56
-
57
- # By number
58
- gh pr view 42 --json number,state,reviewDecision
59
- ```
60
-
61
- ### 2. Check Ready
62
- Required:
63
- - ✓ State: open
64
- - ✓ Reviews: approved (or none required)
65
- - ✓ CI: passing
66
- - ✓ Mergeable: no conflicts
67
-
68
- If not ready → report issues and stop.
69
-
70
- ### 3. Detect Version Bump
71
- Analyze PR title/commits to determine version bump:
72
-
73
- | Pattern | Bump | Example |
74
- |---------|------|---------|
75
- | `feat:` | minor | `feat: add OAuth login` |
76
- | `fix:` | patch | `fix: correct redirect URL` |
77
- | `feat!:` or `BREAKING CHANGE` | major | `feat!: redesign auth API` |
78
- | `docs:`, `chore:`, `test:` | patch | `docs: update README` |
79
-
80
- ### 4. Confirm for Major (Breaking Changes)
81
- If major bump detected:
82
- ```
83
- ⚠️ Breaking change detected in PR #42.
84
- This will bump version to v2.0.0 (major).
85
-
86
- Proceed? (y/n)
87
- ```
88
- - If user confirms → continue
89
- - If user declines → abort, suggest `/speclife release --major` for manual control
90
-
91
- ### 5. Bump Version in Feature Branch
92
- **Do this BEFORE merging, in the feature branch:**
93
- ```bash
94
- # Get current version
95
- CURRENT=$(node -p "require('./package.json').version")
96
-
97
- # Calculate new version
98
- npm version <patch|minor|major> --no-git-tag-version
99
- npm version <patch|minor|major> --no-git-tag-version --workspaces
100
-
101
- # Commit and push to feature branch
102
- git add -A
103
- git commit -m "chore(release): v<new-version>"
104
- git push origin <branch>
105
- ```
106
-
107
- This ensures the version bump is included in the squash merge.
108
-
109
- ### 6. Squash Merge PR
110
- ```bash
111
- gh pr merge $PR --squash --delete-branch
112
- ```
113
-
114
- The merged commit includes both the feature AND the version bump.
115
-
116
- ### 7. Update Local
117
- ```bash
118
- git checkout main
119
- git pull origin main
120
- ```
121
-
122
- ### 8. Cleanup
123
-
124
- | Type | Action |
125
- |------|--------|
126
- | Spec branch with worktree | `speclife worktree rm <change-id>` |
127
- | Spec branch (no worktree) | `git branch -d spec/<change-id>` |
128
- | Ad-hoc branch | `git branch -d <branch>` (if local exists) |
129
- | External PR | Nothing (no local branch) |
130
-
131
- **Detection:**
132
- ```bash
133
- CHANGE_ID=${BRANCH#spec/}
134
- WORKTREE_PATH="worktrees/$CHANGE_ID"
135
- if [[ -d "$WORKTREE_PATH" ]]; then
136
- speclife worktree rm $CHANGE_ID # removes worktree + branch
137
- else
138
- git branch -d $BRANCH # just removes branch
139
- fi
140
- ```
141
-
142
- ### 9. Report and STOP
143
- ```
144
- ✓ Bumped version to v1.3.0 (minor)
145
- ✓ Merged PR #42 (squash)
146
- ✓ Cleaned up worktree
147
- ℹ️ GitHub Actions will create release automatically
148
- ```
149
-
150
- **⛔ STOP HERE.** GitHub Actions will handle tag/release creation.
151
-
152
- ---
153
-
154
- <!-- REFERENCE SECTIONS - Read only when needed -->
155
-
156
- ## Appendix: Error Handling
157
-
158
- **PR not found:**
159
- ```
160
- ❌ No PR found for branch. Run /speclife ship first.
161
- ```
162
-
163
- **PR not ready:**
164
- ```
165
- ❌ PR #42 not ready:
166
- - Review: changes_requested
167
- - CI: failing
168
- Address issues and retry.
169
- ```
170
-
171
- **Merge conflicts:**
172
- ```
173
- ❌ Merge conflicts detected.
174
- Run /speclife sync, resolve, push, then retry.
175
- ```
176
-
177
- **On main without PR number:**
178
- ```
179
- ℹ️ On main. Which PR to land?
180
- Recent PRs:
181
- #45 - feat: dark mode (approved ✓)
182
- #44 - fix: memory leak (needs review)
183
- ```
184
-
185
- ## Appendix: Examples
186
-
187
- **Spec branch (minor):**
188
- ```
189
- User: /speclife land
190
-
191
- Agent:
192
- ✓ PR #42 approved, CI passing
193
- ℹ️ Detected: feat: → minor bump
194
- ✓ Bumped version to v1.3.0
195
- ✓ Pushed version commit to feature branch
196
- ✓ Merged PR #42 (squash)
197
- ✓ Removed worktree
198
- ℹ️ GitHub Actions will create release v1.3.0
199
- ```
200
-
201
- **By PR number (external):**
202
- ```
203
- User: /speclife land #45
204
-
205
- Agent:
206
- ℹ️ PR #45 by @contributor
207
- ℹ️ Detected: fix: → patch bump
208
- ✓ Bumped version to v1.2.4
209
- ✓ Merged PR #45 (squash)
210
- ℹ️ GitHub Actions will create release v1.2.4
211
- Thanks @contributor!
212
- ```
213
-
214
- **Major version (confirmation required):**
215
- ```
216
- User: /speclife land
217
-
218
- Agent:
219
- ✓ PR #50 approved, CI passing
220
- ⚠️ Breaking change detected (feat!:)
221
- This will bump to v2.0.0 (major).
222
- Proceed? (y/n)
223
-
224
- User: y
225
-
226
- Agent:
227
- ✓ Bumped version to v2.0.0
228
- ✓ Merged PR #50 (squash)
229
- ℹ️ GitHub Actions will create release v2.0.0
230
- ```
231
-
232
- **Major version (user declines):**
233
- ```
234
- User: /speclife land
235
-
236
- Agent:
237
- ⚠️ Breaking change detected (feat!:)
238
- This will bump to v2.0.0 (major).
239
- Proceed? (y/n)
240
-
241
- User: n
242
-
243
- Agent:
244
- ℹ️ Aborted. When ready, run:
245
- /speclife release --major
246
- ```
7
+ **Guardrails**
8
+ - Execute immediately—if PR number provided (#42), use it; if on feature branch, find its PR; if on main, prompt for PR number
9
+ - Confirm with user only for major (breaking) version bumps
10
+ - STOP after reporting—GitHub Actions handles release
11
+
12
+ **Steps**
13
+ 1. Find PR: by branch (`gh pr view`) or by number (`gh pr view <num>`); error if not found.
14
+ 2. Check readiness: state=open, approved (or no reviews required), CI passing, no conflicts; report issues and stop if not ready.
15
+ 3. Detect version bump from PR title/commits: `feat:` minor, `fix:/docs:/chore:` → patch, `feat!:/BREAKING CHANGE` → major.
16
+ 4. For major bumps: confirm with user; abort if declined (suggest `/speclife release --major` for manual control).
17
+ 5. Bump version in feature branch: `npm version <bump> --no-git-tag-version`, commit `chore(release): v<version>`, push.
18
+ 6. Squash merge: `gh pr merge --squash --delete-branch`.
19
+ 7. Update local: `git checkout main && git pull`.
20
+ 8. Cleanup: remove worktree if spec branch (`speclife worktree rm <id>`), else delete local branch.
21
+ 9. Report: version bumped, PR merged, cleanup done, GitHub Actions creating release.
22
+
23
+ **Reference**
24
+ - Version bump happens BEFORE merge so it's included in squash commit
25
+ - Release workflow triggered by `chore(release): vX.X.X` commit message
@@ -2,118 +2,23 @@
2
2
  name: /speclife-release
3
3
  id: speclife-release
4
4
  category: SpecLife
5
- description: Create a release with version bump for manual releases (major versions).
5
+ description: Create a release with version bump (typically for major versions).
6
6
  ---
7
- # /speclife release
8
-
9
- Create a release with version bump. Used for manual releases (typically major versions).
10
-
11
- ## ⚡ Execution
12
-
13
- **When this command is invoked, IMMEDIATELY execute the workflow below.**
14
-
15
- - Check that we're on the main branch
16
- - Analyze commits to determine version bump (or use explicit flag)
17
- - Update version files and changelog
18
- - Commit and push to trigger release workflow
19
-
20
- ## Usage
21
-
22
- ```
23
- /speclife release # Auto-detect version bump
24
- /speclife release --major # Force major version bump
25
- /speclife release --minor # Force minor version bump
26
- /speclife release --patch # Force patch version bump
27
- ```
28
-
29
- ## When to Use
30
-
31
- - **Major releases**: Breaking changes that require manual review
32
- - **Forced releases**: When auto-release is disabled or skipped
33
- - **Independent releases**: Creating a release without going through `/speclife land`
34
-
35
- ## Preconditions
36
-
37
- - On `main` branch
38
- - Working directory clean
39
- - Changes merged since last release (for auto-detect)
40
-
41
- ## Steps
42
-
43
- 1. **Check branch**: Ensure on `main` branch
44
- - If not, suggest switching or report error
45
-
46
- 2. **Analyze commits**: Determine suggested version bump
47
- - Get commits since last tag
48
- - `feat:` commits → minor
49
- - `fix:` commits → patch
50
- - `BREAKING CHANGE` or `!` → major
51
- - Use explicit flag if provided (--major, --minor, --patch)
52
-
53
- 3. **Get current version**: Read from package.json (or equivalent)
54
-
55
- 4. **Calculate new version**: Apply bump to current version
56
- - Major: 1.2.3 → 2.0.0
57
- - Minor: 1.2.3 → 1.3.0
58
- - Patch: 1.2.3 → 1.2.4
59
-
60
- 5. **Update version file**: Write new version to package.json
61
-
62
- 6. **Update CHANGELOG**: Add release notes
63
- - Group commits by type (Features, Fixes, etc.)
64
- - Include commit messages and PR references
65
-
66
- 7. **Commit**: `git commit -am "chore(release): vX.X.X"`
67
- - This commit message triggers the release workflow
68
-
69
- 8. **Push**: `git push origin main`
70
-
71
- 9. **Create release PR** (optional, for review):
72
- - If major release, create PR for review
73
- - If patch/minor with auto-merge, push directly
74
-
75
- 10. **Report**: Show next steps
76
-
77
- ## Example
78
-
79
- ```
80
- User: /speclife release --major
81
-
82
- Agent:
83
- Analyzing commits since v1.2.3...
84
- - feat: add OAuth login (breaking: changes auth API)
85
- - fix: correct redirect URL
86
- - docs: update API documentation
87
-
88
- Current version: 1.2.3
89
- New version: 2.0.0 (major bump)
90
-
91
- ✓ Updated package.json to 2.0.0
92
- ✓ Updated CHANGELOG.md
93
- ✓ Committed: "chore(release): v2.0.0"
94
- ✓ Pushed to origin/main
95
-
96
- Release workflow triggered. GitHub Actions will:
97
- 1. Create tag v2.0.0
98
- 2. Create GitHub Release with notes
99
- 3. Publish to npm (if configured)
100
-
101
- Done! Release v2.0.0 is being created.
102
- ```
103
-
104
- ## Release Workflow
105
-
106
- When the `chore(release): vX.X.X` commit is pushed, the GitHub Actions workflow (`.github/workflows/speclife-release.yml`) automatically:
107
-
108
- 1. Extracts version from commit message
109
- 2. Creates git tag
110
- 3. Creates GitHub Release with auto-generated notes
111
- 4. Optionally publishes to package registry
112
-
113
- ## Notes
114
-
115
- - For patch/minor releases, prefer using `/speclife land` which handles auto-release
116
- - Major releases should go through this command for explicit control
117
- - The release commit message format `chore(release): vX.X.X` is required for the workflow
118
-
119
-
7
+ **Guardrails**
8
+ - Execute immediately—must be on main with clean working directory
9
+ - Use for major releases or when auto-release was skipped
10
+ - For patch/minor, prefer `/speclife land` which handles auto-release
11
+
12
+ **Steps**
13
+ 1. Check branch: must be on `main`; error otherwise.
14
+ 2. Analyze commits since last tag: `feat:` → minor, `fix:` → patch, `BREAKING CHANGE` or `!` → major; use explicit flag (--major/--minor/--patch) if provided.
15
+ 3. Calculate new version from current `package.json`.
16
+ 4. Update version: `npm version <bump> --no-git-tag-version` (and workspaces if monorepo).
17
+ 5. Update CHANGELOG.md with grouped commits.
18
+ 6. Commit: `git commit -am "chore(release): v<version>"`.
19
+ 7. Push: `git push origin main`.
20
+ 8. Report: version bumped, pushed, GitHub Actions will create tag and release.
21
+
22
+ **Reference**
23
+ - Commit message format `chore(release): vX.X.X` triggers release workflow
24
+ - Major releases should use this command; patch/minor typically via `/speclife land`