@speclife/cli 0.9.0 → 0.9.2

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.
@@ -4,295 +4,23 @@ id: speclife-setup
4
4
  category: SpecLife
5
5
  description: Discover project configuration and populate openspec/speclife.md.
6
6
  ---
7
- # /speclife setup
8
-
9
- Discover project configuration and populate `openspec/speclife.md`.
10
-
11
- ## ⚡ Execution
12
-
13
- **When this command is invoked, IMMEDIATELY execute the workflow below.**
14
-
15
- - Scan project files to detect build system and commands
16
- - Check for existing workflows and context files
17
- - Update `openspec/speclife.md` with discovered configuration
18
- - Offer to create publish workflow if missing (ask first)
19
-
20
- ## Goal
21
-
22
- Auto-detect project commands (test, build, lint), publishing configuration, and context files to configure speclife for this project.
23
-
24
- ## Steps
25
-
26
- 1. **Read current config**: Check if `openspec/speclife.md` exists and what's already configured
27
-
28
- 2. **Detect build system**: Look for project configuration files:
29
- - `package.json` → Node.js (npm/yarn/pnpm)
30
- - `Cargo.toml` → Rust (cargo)
31
- - `go.mod` → Go
32
- - `Makefile` → Make-based
33
- - `pyproject.toml` or `setup.py` → Python
34
- - `build.gradle` or `pom.xml` → Java
35
-
36
- 3. **Extract commands**: From the detected build system, find:
37
- - **Test command**: e.g., `npm test`, `cargo test`, `make test`
38
- - **Build command**: e.g., `npm run build`, `cargo build`, `make build`
39
- - **Lint command**: e.g., `npm run lint`, `cargo clippy`, `make lint`
40
-
41
- 4. **Detect publish configuration**: Based on project type:
42
-
43
- | Project Type | Detection | Registry | Secret Required |
44
- |--------------|-----------|----------|-----------------|
45
- | Node.js | `package.json` with `name` (not private) | npm | `NPM_TOKEN` |
46
- | Node.js monorepo | `workspaces` in package.json | npm | `NPM_TOKEN` |
47
- | Rust | `Cargo.toml` with `[package]` | crates.io | `CARGO_REGISTRY_TOKEN` |
48
- | Python | `pyproject.toml` with `[project]` | PyPI | `PYPI_TOKEN` |
49
- | Go | `go.mod` | N/A (no central registry) | None |
50
- | Internal/private | `"private": true` in package.json | N/A | None |
51
-
52
- 5. **Check for existing workflows**: Look in `.github/workflows/` for:
53
- - `publish.yml` or similar publish workflow
54
- - `release.yml` - release workflow
55
-
56
- 6. **Identify context files**: Look for common documentation:
57
- - `openspec/project.md` - project context
58
- - `openspec/AGENTS.md` - agent guidelines
59
- - `README.md` - project overview
60
- - `CONTRIBUTING.md` - contribution guidelines
61
-
62
- 7. **Update speclife.md**: Write discovered values to `openspec/speclife.md`
63
-
64
- 8. **Offer to create publish workflow** (if missing):
65
- - If no publish workflow exists AND project is publishable (not private, not Go):
66
- - Ask: "No publish workflow found. Would you like me to create `.github/workflows/publish.yml`?"
67
- - If user agrees, create the appropriate workflow from the templates below
68
- - Remind user to add the required secret in repo settings
69
- - If project is private (`"private": true`) or Go (no central registry):
70
- - Skip this step (no publish workflow needed)
71
-
72
- 9. **Report**: Tell the user what was configured and any next steps
73
-
74
- ## Publish Workflow Templates
75
-
76
- Use these templates when creating publish workflows:
77
-
78
- ### Node.js (single package)
79
- ```yaml
80
- # .github/workflows/publish.yml
81
- name: Publish to npm
82
- on:
83
- release:
84
- types: [published]
85
-
86
- jobs:
87
- publish:
88
- runs-on: ubuntu-latest
89
- steps:
90
- - uses: actions/checkout@v4
91
- - uses: actions/setup-node@v4
92
- with:
93
- node-version: '20'
94
- registry-url: 'https://registry.npmjs.org'
95
- - run: npm ci
96
- - run: npm test
97
- - run: npm publish --access public
98
- env:
99
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
100
- ```
101
-
102
- ### Node.js (monorepo with workspaces)
103
- ```yaml
104
- # .github/workflows/publish.yml
105
- name: Publish to npm
106
- on:
107
- release:
108
- types: [published]
109
-
110
- jobs:
111
- publish:
112
- runs-on: ubuntu-latest
113
- steps:
114
- - uses: actions/checkout@v4
115
- - uses: actions/setup-node@v4
116
- with:
117
- node-version: '20'
118
- registry-url: 'https://registry.npmjs.org'
119
- - run: npm ci
120
- - run: npm run build
121
- - run: npm test
122
- # Publish each workspace package
123
- - run: npm publish -w packages/<package-name> --access public
124
- env:
125
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
126
- ```
127
-
128
- ### Rust
129
- ```yaml
130
- # .github/workflows/publish.yml
131
- name: Publish to crates.io
132
- on:
133
- release:
134
- types: [published]
135
-
136
- jobs:
137
- publish:
138
- runs-on: ubuntu-latest
139
- steps:
140
- - uses: actions/checkout@v4
141
- - uses: dtolnay/rust-toolchain@stable
142
- - run: cargo test
143
- - run: cargo publish
144
- env:
145
- CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
146
- ```
147
-
148
- ### Python
149
- ```yaml
150
- # .github/workflows/publish.yml
151
- name: Publish to PyPI
152
- on:
153
- release:
154
- types: [published]
155
-
156
- jobs:
157
- publish:
158
- runs-on: ubuntu-latest
159
- steps:
160
- - uses: actions/checkout@v4
161
- - uses: actions/setup-python@v5
162
- with:
163
- python-version: '3.11'
164
- - run: pip install build twine
165
- - run: python -m build
166
- - run: twine upload dist/*
167
- env:
168
- TWINE_USERNAME: __token__
169
- TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
170
- ```
171
-
172
- ## Output
173
-
174
- Update `openspec/speclife.md` with discovered configuration:
175
-
176
- ```markdown
177
- # SpecLife Configuration
178
-
179
- ## Commands
180
-
181
- - **Test:** `<detected-test-command>`
182
- - **Build:** `<detected-build-command>`
183
- - **Lint:** `<detected-lint-command>`
184
-
185
- ## Release Policy
186
-
187
- - **Auto-release:** patch and minor versions
188
- - **Manual release:** major versions (breaking changes)
189
-
190
- ## Publish
191
-
192
- - **Registry:** npm / PyPI / crates.io / None
193
- - **Workflow:** .github/workflows/publish.yml (exists / TODO)
194
- - **Secret:** NPM_TOKEN / PYPI_TOKEN / CARGO_REGISTRY_TOKEN
195
-
196
- ## Context Files
197
-
198
- When implementing changes, always read:
199
- - `openspec/project.md` - project context and conventions
200
- - `openspec/AGENTS.md` - agent guidelines
201
- - `README.md` - project overview
202
- ```
203
-
204
- ## Example Output
205
-
206
- ### When publish workflow exists:
207
- ```
208
- User: /speclife setup
209
-
210
- Agent:
211
- Detecting project configuration...
212
-
213
- ✓ Project type: Node.js monorepo (npm workspaces)
214
- ✓ Packages: @speclife/core, @speclife/cli, @speclife/mcp-server
215
-
216
- Commands detected:
217
- ✓ Test: npm test
218
- ✓ Build: npm run build
219
- ✓ Lint: npm run lint
220
-
221
- Workflows:
222
- ✓ Release: .github/workflows/release.yml
223
- ✓ Publish: .github/workflows/publish.yml
224
-
225
- Context files:
226
- ✓ openspec/project.md
227
- ✓ openspec/AGENTS.md
228
- ✓ README.md
229
-
230
- ✓ Updated openspec/speclife.md
231
- ```
232
-
233
- ### When publish workflow is missing:
234
- ```
235
- User: /speclife setup
236
-
237
- Agent:
238
- Detecting project configuration...
239
-
240
- ✓ Project type: Node.js (single package)
241
- ✓ Package: my-awesome-lib
242
-
243
- Commands detected:
244
- ✓ Test: npm test
245
- ✓ Build: npm run build
246
- ✓ Lint: npm run lint
247
-
248
- Workflows:
249
- ✓ Release: .github/workflows/release.yml
250
- ⚠ Publish: Not found
251
-
252
- This package appears to be publishable to npm. Would you like me to create
253
- `.github/workflows/publish.yml`?
254
-
255
- User: yes
256
-
257
- Agent:
258
- ✓ Created .github/workflows/publish.yml
259
-
260
- ⚠️ Remember to add NPM_TOKEN to your repository secrets:
261
- GitHub → Settings → Secrets and variables → Actions → New repository secret
262
-
263
- Get your token from: https://www.npmjs.com/settings/~/tokens
264
-
265
- ✓ Updated openspec/speclife.md
266
-
267
- Done! Your project is configured for automated releases and publishing.
268
- ```
269
-
270
- ### When project is private:
271
- ```
272
- User: /speclife setup
273
-
274
- Agent:
275
- Detecting project configuration...
276
-
277
- ✓ Project type: Node.js (private package)
278
-
279
- Commands detected:
280
- ✓ Test: npm test
281
- ✓ Build: npm run build
282
-
283
- Workflows:
284
- ✓ Release: .github/workflows/release.yml
285
- ℹ Publish: Not needed (private package)
286
-
287
- ✓ Updated openspec/speclife.md
288
- ```
289
-
290
- ## Notes
291
-
292
- - If a command can't be detected, leave it as a TODO for the user
293
- - Don't overwrite user customizations if speclife.md already exists
294
- - This command is idempotent - safe to run multiple times
295
- - Always ask before creating publish workflow (don't auto-create)
296
- - Remind about secrets after creating publish workflow
297
-
298
-
7
+ **Guardrails**
8
+ - Execute immediately—scan project to auto-detect configuration
9
+ - Don't overwrite existing user customizations in speclife.md
10
+ - Ask before creating publish workflow (don't auto-create)
11
+
12
+ **Steps**
13
+ 1. Read existing `openspec/speclife.md` if present.
14
+ 2. Detect build system: package.json (Node), Cargo.toml (Rust), go.mod (Go), pyproject.toml (Python), etc.
15
+ 3. Extract commands: test, build, lint from detected system (e.g., `npm test`, `cargo test`).
16
+ 4. Detect publish config: registry (npm/crates.io/PyPI), required secret, private flag.
17
+ 5. Check `.github/workflows/` for existing release/publish workflows.
18
+ 6. Identify context files: `openspec/project.md`, `openspec/AGENTS.md`, `README.md`.
19
+ 7. Update `openspec/speclife.md` with discovered values.
20
+ 8. If publishable and no publish workflow exists: ask user, create if agreed, remind about secrets.
21
+ 9. Report: project type, detected commands, workflow status, what was configured.
22
+
23
+ **Reference**
24
+ - Publish workflow templates: Node.js, Rust, Python (standard patterns)
25
+ - Private packages (`"private": true`) skip publish workflow
26
+ - Go has no central registry—skip publish step
@@ -4,165 +4,21 @@ id: speclife-ship
4
4
  category: SpecLife
5
5
  description: Commit changes, push to remote, and create a PR for review.
6
6
  ---
7
- # /speclife ship
8
-
9
- Create a PR from your current branch. Works with spec branches and ad-hoc branches.
10
-
11
- ## Execution
12
-
13
- **When this command is invoked, IMMEDIATELY execute the workflow below.**
14
-
15
- - Do NOT skip steps or ask for confirmation before starting
16
- - Detect branch type first, then follow the appropriate flow
17
- - If there are uncommitted changes, proceed to stage and commit them
18
- - Create or update PR as the final step
19
- - **STOP after PR created—do NOT auto-invoke `/speclife land`**
20
-
21
- ## TL;DR
22
-
23
- ```
24
- /speclife ship # Ship current branch
25
- /speclife ship --draft # Create as draft PR
26
- ```
27
-
28
- **Quick flow:**
29
- 1. Detect branch type (spec vs ad-hoc)
30
- 2. For spec branches: validate → commit changes → archive → commit archive
31
- 3. For ad-hoc branches: stage, commit
32
- 4. Push, create/update PR
33
-
34
- ## Mode Detection
35
-
36
- ```bash
37
- BRANCH=$(git branch --show-current)
38
- ```
39
-
40
- | Branch | Type | Behavior |
41
- |--------|------|----------|
42
- | `spec/*` | **Spec** | Full workflow with OpenSpec (validate, archive) |
43
- | Any other non-main | **Ad-hoc** | Simplified (skip spec steps) |
44
- | `main` | **Error** | Cannot ship from main |
45
-
46
- Note: Spec mode is determined by branch name prefix (`spec/`), not worktree existence. Works identically whether you're in a worktree or the main repo.
47
-
48
- ## Core Steps
49
-
50
- ### 1. Spec Branch Only
51
- If spec branch detected:
52
- - Run `openspec validate <change-id>`
53
- - Read proposal.md for commit message
54
- - Commit the implementation changes:
55
- ```bash
56
- git add -A
57
- git commit -m "<type>: <description>"
58
- ```
59
- - Run `/openspec-archive` (may require updating project.md)
60
- - Commit the archive changes:
61
- ```bash
62
- git add -A
63
- git commit -m "chore: archive <change-id> spec"
64
- ```
65
- - Skip to step 3 (push only, no additional commit needed)
66
-
67
- ### 2. Ad-hoc Branch Only
68
- - Infer commit type from branch name (`fix/*` → `fix:`, `feat/*` → `feat:`)
69
- - Ask user for commit message if needed
70
-
71
- ### 3. All Branches
72
- ```bash
73
- # For ad-hoc branches only (spec branches already committed above):
74
- git add -A
75
- git commit -m "<type>: <description>" # if uncommitted changes
76
-
77
- # All branches:
78
- git push -u origin <branch>
79
- ```
80
-
81
- ### 4. Create PR
82
- ```bash
83
- # Check if PR exists
84
- gh pr view --json url 2>/dev/null
85
-
86
- # If not, create
87
- gh pr create --fill --base main
88
- # Or: gh pr create --fill --base main --draft
89
- ```
90
-
91
- ### 5. Report and STOP
92
- ```
93
- ✓ Committed: "feat: description"
94
- ✓ Pushed to origin/<branch>
95
- ✓ Created PR #42: <url>
96
-
97
- Next: After approval, run /speclife land
98
- ```
99
-
100
- **⛔ STOP HERE.** Do NOT proceed to merge. Wait for:
101
- 1. PR review and approval
102
- 2. User to invoke `/speclife land`
103
-
104
- ---
105
-
106
- <!-- REFERENCE SECTIONS - Read only when needed -->
107
-
108
- ## Appendix: Commit Type Inference
109
-
110
- | Branch Pattern | Commit Type |
111
- |----------------|-------------|
112
- | `fix/*`, `bugfix/*`, `hotfix/*` | `fix:` |
113
- | `feat/*`, `feature/*` | `feat:` |
114
- | `docs/*` | `docs:` |
115
- | `refactor/*` | `refactor:` |
116
- | `chore/*` | `chore:` |
117
- | Other | Ask user |
118
-
119
- ## Appendix: Error Handling
120
-
121
- **Cannot ship from main:**
122
- ```
123
- ❌ Cannot ship from main. Create a branch first.
124
- ```
125
-
126
- **No changes:**
127
- ```
128
- ❌ No changes to ship. Working directory clean.
129
- ```
130
-
131
- **Spec validation failed:**
132
- ```
133
- ❌ Spec validation failed:
134
- - proposal.md: Missing "What" section
135
- Fix issues and retry, or use --skip-validation
136
- ```
137
-
138
- **PR already exists:**
139
- ```
140
- ℹ️ PR #43 already exists. Pushing updates...
141
- ✓ Updated PR #43
142
- ```
143
-
144
- ## Appendix: Examples
145
-
146
- **Spec branch:**
147
- ```
148
- User: /speclife ship
149
-
150
- Agent:
151
- ℹ️ Spec branch: spec/add-oauth-login
152
- ✓ Validated spec
153
- ✓ Committed: "feat: add OAuth login"
154
- ✓ Archived to openspec/changes/archive/
155
- ✓ Committed: "chore: archive add-oauth-login spec"
156
- ✓ Pushed to origin/spec/add-oauth-login
157
- ✓ Created PR #42
158
- ```
159
-
160
- **Ad-hoc branch:**
161
- ```
162
- User: /speclife ship
163
-
164
- Agent:
165
- ℹ️ Ad-hoc branch: fix/login-bug
166
- ✓ Committed: "fix: resolve login redirect"
167
- ✓ Created PR #43
168
- ```
7
+ **Guardrails**
8
+ - Execute immediately—do not ask for confirmation
9
+ - Detect branch type: `spec/*` = full OpenSpec workflow, other non-main = ad-hoc, `main` = error
10
+ - STOP after PR created—do NOT auto-invoke `/speclife land`
11
+ - Do NOT manually replicate `openspec` commands—run them and report errors if they fail
12
+
13
+ **Steps**
14
+ 1. For spec branches: run `openspec validate <id>`, commit changes, run `openspec archive <id> --yes`, commit archive.
15
+ 2. For ad-hoc branches: infer commit type from branch name (`fix/*` `fix:`, `feat/*` → `feat:`), ask if ambiguous.
16
+ 3. Push branch: `git push -u origin <branch>`.
17
+ 4. Create/update PR: `gh pr create --title "<type>: <description>" --body "<body>" --base main` (add `--draft` if requested).
18
+ 5. Report: commits made, branch pushed, PR URL. Next: `/speclife land` after approval.
19
+
20
+ **Reference**
21
+ - Commit type inference: fix/bugfix/hotfix → `fix:`, feat/feature → `feat:`, docs → `docs:`, refactor → `refactor:`, chore → `chore:`
22
+ - If PR exists, push updates it automatically
23
+ - PR title: use conventional commit format (`<type>: <meaningful description>`)
24
+ - PR body: if `.github/pull_request_template.md` exists, read it and fill in each section based on the change context