specstocode 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +218 -0
- package/bin/productbuilders.js +2 -0
- package/bin/specstocode.js +2 -0
- package/dist/chunk-55DTUCLY.js +417 -0
- package/dist/chunk-CYA6I7NV.js +34 -0
- package/dist/chunk-J22FYEMI.js +84 -0
- package/dist/chunk-NAOZWXOF.js +39 -0
- package/dist/chunk-P4M7CVDK.js +249 -0
- package/dist/chunk-QKMZ2SBR.js +39 -0
- package/dist/chunk-WPVDURTJ.js +79 -0
- package/dist/complexity-TUS6F2UI.js +71 -0
- package/dist/import-prd-HP66GKRA.js +114 -0
- package/dist/index.js +1763 -0
- package/dist/log-GSWUQF6Z.js +98 -0
- package/dist/prompt-WAWCRGHN.js +16 -0
- package/dist/research-UGNKVMZ5.js +49 -0
- package/dist/scope-BY5WSTPD.js +10 -0
- package/dist/setup-VBFEFGTK.js +9 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# ProductBuilders CLI
|
|
2
|
+
|
|
3
|
+
Plan, validate, and build products — from your terminal. Turn a problem into a structured product blueprint with AI-powered story mapping.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
██████╗ ██████╗
|
|
7
|
+
██╔══██╗██╔══██╗ ProductBuilders
|
|
8
|
+
██████╔╝██████╔╝ Stop building for nobody.
|
|
9
|
+
██╔═══╝ ██╔══██╗
|
|
10
|
+
██║ ██████╔╝
|
|
11
|
+
╚═╝ ╚═════╝
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g productbuilders
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Getting Started
|
|
21
|
+
|
|
22
|
+
### 1. Log in
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
productbuilders login
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Opens your browser to authenticate with [ProductBuilders.pro](https://productbuilders.pro). You only need to do this once per machine.
|
|
29
|
+
|
|
30
|
+
### 2. Start a new project
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
productbuilders start
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Interactive guided flow:
|
|
37
|
+
1. **Describe your problem** — what are you trying to solve?
|
|
38
|
+
2. **AI discovery questions** — sharpens your thinking with targeted questions
|
|
39
|
+
3. **Pitch synthesis** — generates a one-liner pitch and target user
|
|
40
|
+
4. **Name your product** — pick from AI-suggested names or type your own
|
|
41
|
+
5. **Validate** — publish to Explore to get feedback before building
|
|
42
|
+
6. **Scope** — generates a blueprint, story map, and optional HTML mockup
|
|
43
|
+
|
|
44
|
+
### 3. Connect to your codebase
|
|
45
|
+
|
|
46
|
+
After scoping, connect the story map to your project directory:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
productbuilders init pb_sync_<your-token>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Your project now has:
|
|
53
|
+
- `PRODUCTBUILDERS.md` — product context (personas, stories, acceptance criteria)
|
|
54
|
+
- `.productbuilders/config.json` — sync config (auto-gitignored)
|
|
55
|
+
|
|
56
|
+
### 4. Configure your AI tool
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
productbuilders setup
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Sets up [Claude Code](https://claude.com/claude-code) and/or [Cursor](https://cursor.com) with:
|
|
63
|
+
- `CLAUDE.md` / `.cursorrules` with product context
|
|
64
|
+
- Slash commands for the development workflow (inside Claude Code, not the terminal)
|
|
65
|
+
- `ARCHITECTURE.md` and `CONVENTIONS.md` scaffolding
|
|
66
|
+
|
|
67
|
+
### 5. Build
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
productbuilders next # See what to build first
|
|
71
|
+
productbuilders done <id> # Mark a story as complete
|
|
72
|
+
productbuilders stories # List all stories
|
|
73
|
+
productbuilders status # View progress dashboard
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## All Commands
|
|
79
|
+
|
|
80
|
+
### Project Creation
|
|
81
|
+
|
|
82
|
+
| Command | Description |
|
|
83
|
+
|---------|-------------|
|
|
84
|
+
| `productbuilders login` | Authenticate (opens browser) |
|
|
85
|
+
| `productbuilders logout` | Log out |
|
|
86
|
+
| `productbuilders start` | New project — guided flow from problem to pitch |
|
|
87
|
+
| `productbuilders scope [id]` | Scope a project — blueprint, story map, mockup |
|
|
88
|
+
| `productbuilders setup` | Configure Claude Code / Cursor |
|
|
89
|
+
| `productbuilders templates [name]` | Browse starter templates |
|
|
90
|
+
|
|
91
|
+
### Story Management
|
|
92
|
+
|
|
93
|
+
| Command | Description |
|
|
94
|
+
|---------|-------------|
|
|
95
|
+
| `productbuilders init [token]` | Connect project to a story map |
|
|
96
|
+
| `productbuilders sync` | Refresh PRODUCTBUILDERS.md |
|
|
97
|
+
| `productbuilders status` | Progress dashboard |
|
|
98
|
+
| `productbuilders stories [-f filter]` | List stories (filter: todo/done/keyword) |
|
|
99
|
+
| `productbuilders next` | Next priority story with acceptance criteria |
|
|
100
|
+
| `productbuilders done <id>` | Mark story as done (accepts ID prefix) |
|
|
101
|
+
| `productbuilders add <title>` | Create a new story |
|
|
102
|
+
| `productbuilders decide [title]` | Log an architectural decision |
|
|
103
|
+
| `productbuilders note <id> [note]` | Add implementation notes |
|
|
104
|
+
|
|
105
|
+
### Analysis (coming soon)
|
|
106
|
+
|
|
107
|
+
| Command | Description |
|
|
108
|
+
|---------|-------------|
|
|
109
|
+
| `productbuilders complexity [id]` | AI complexity scoring |
|
|
110
|
+
| `productbuilders research [query]` | Research with project context |
|
|
111
|
+
| `productbuilders import [file]` | Import PRD as stories |
|
|
112
|
+
|
|
113
|
+
### Integration
|
|
114
|
+
|
|
115
|
+
| Command | Description |
|
|
116
|
+
|---------|-------------|
|
|
117
|
+
| `productbuilders mcp [--mode]` | Start MCP server (core/standard/all) |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## MCP Server
|
|
122
|
+
|
|
123
|
+
Give Claude Code or Cursor native access to your story map.
|
|
124
|
+
|
|
125
|
+
### Setup
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"mcpServers": {
|
|
130
|
+
"productbuilders": {
|
|
131
|
+
"command": "npx",
|
|
132
|
+
"args": ["productbuilders", "mcp"],
|
|
133
|
+
"cwd": "/path/to/your/project"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Add to `~/.claude/settings.json` (Claude Code) or your Cursor MCP config.
|
|
140
|
+
|
|
141
|
+
### Tool Modes
|
|
142
|
+
|
|
143
|
+
Control token usage with `--mode`:
|
|
144
|
+
|
|
145
|
+
| Mode | Tools | Use case |
|
|
146
|
+
|------|-------|----------|
|
|
147
|
+
| `core` | 5 | Day-to-day dev (list, mark done, status, notes) |
|
|
148
|
+
| `standard` | 8 | Active dev (+ create, context, decisions) |
|
|
149
|
+
| `all` | 11 | Full power (+ complexity, research, import) |
|
|
150
|
+
|
|
151
|
+
### Available Tools
|
|
152
|
+
|
|
153
|
+
| Tool | Mode | Description |
|
|
154
|
+
|------|------|-------------|
|
|
155
|
+
| `list_stories` | core | List stories with optional filter |
|
|
156
|
+
| `mark_done` | core | Mark a story as complete |
|
|
157
|
+
| `mark_in_progress` | core | Mark a story as in progress |
|
|
158
|
+
| `get_status` | core | Progress summary |
|
|
159
|
+
| `add_note` | core | Add implementation notes |
|
|
160
|
+
| `create_story` | standard | Create a new story |
|
|
161
|
+
| `get_context` | standard | Fetch PRODUCTBUILDERS.md |
|
|
162
|
+
| `log_decision` | standard | Log an architectural decision |
|
|
163
|
+
| `analyze_complexity` | all | AI complexity scoring |
|
|
164
|
+
| `research` | all | AI research with project context |
|
|
165
|
+
| `import_prd` | all | Parse PRD into stories |
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Templates
|
|
170
|
+
|
|
171
|
+
Starter story maps for common product types:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
productbuilders templates # List all
|
|
175
|
+
productbuilders templates saas # View details
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
| Template | Description | Stories |
|
|
179
|
+
|----------|-------------|---------|
|
|
180
|
+
| `saas` | Multi-tenant SaaS with auth, billing, dashboards | 16 |
|
|
181
|
+
| `marketplace` | Two-sided marketplace with payments | 13 |
|
|
182
|
+
| `mobile-app` | Consumer app with feed, social, notifications | 12 |
|
|
183
|
+
| `ai-tool` | AI-powered tool with streaming and billing | 12 |
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## How It Works
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
ProductBuilders.pro Your Project
|
|
191
|
+
┌──────────────────┐ ┌──────────────────┐
|
|
192
|
+
│ │ │ │
|
|
193
|
+
│ Story Map UI │◄── sync API ───►│ CLI / MCP │
|
|
194
|
+
│ (plan here) │ │ (build here) │
|
|
195
|
+
│ │ │ │
|
|
196
|
+
│ ┌────────────┐ │ GET /context │ PRODUCTBUILDERS │
|
|
197
|
+
│ │ Activities │ │ ───────────────► │ .md │
|
|
198
|
+
│ │ Steps │ │ │ │
|
|
199
|
+
│ │ Stories │ │ PATCH /stories │ Claude Code / │
|
|
200
|
+
│ │ Personas │ │ ◄─────────────── │ Cursor / etc │
|
|
201
|
+
│ └────────────┘ │ │ │
|
|
202
|
+
└──────────────────┘ └──────────────────┘
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
1. **Start** — describe your problem, AI generates discovery questions and a pitch
|
|
206
|
+
2. **Validate** — publish to Explore, get feedback and intent signals
|
|
207
|
+
3. **Scope** — AI generates blueprint, story map, and mockup
|
|
208
|
+
4. **Connect** — `productbuilders init` links your codebase to the story map
|
|
209
|
+
5. **Build** — your AI tool reads PRODUCTBUILDERS.md for context
|
|
210
|
+
6. **Track** — mark stories done, log decisions, add notes — all flows back to the map
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Links
|
|
215
|
+
|
|
216
|
+
- [ProductBuilders.pro](https://productbuilders.pro) — the web app
|
|
217
|
+
- [Explore](https://productbuilders.pro/explore) — discover what others are building
|
|
218
|
+
- [Community](https://productbuilders.pro/community) — connect with builders
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import {
|
|
2
|
+
requireAuth
|
|
3
|
+
} from "./chunk-CYA6I7NV.js";
|
|
4
|
+
import {
|
|
5
|
+
choose,
|
|
6
|
+
closePrompt
|
|
7
|
+
} from "./chunk-WPVDURTJ.js";
|
|
8
|
+
import {
|
|
9
|
+
hasConfig,
|
|
10
|
+
requireConfig
|
|
11
|
+
} from "./chunk-NAOZWXOF.js";
|
|
12
|
+
|
|
13
|
+
// src/commands/setup.ts
|
|
14
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync } from "fs";
|
|
15
|
+
import { execSync } from "child_process";
|
|
16
|
+
import { join } from "path";
|
|
17
|
+
async function setup() {
|
|
18
|
+
requireAuth();
|
|
19
|
+
if (!hasConfig()) {
|
|
20
|
+
console.log(" Not connected to a project. Run `npx specstocode init` first.");
|
|
21
|
+
closePrompt();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const config = requireConfig();
|
|
25
|
+
const idx = await choose(" Which AI tool do you want to configure?", [
|
|
26
|
+
"Claude Code",
|
|
27
|
+
"Cursor",
|
|
28
|
+
"Both"
|
|
29
|
+
]);
|
|
30
|
+
const tools = idx === 0 ? ["claude"] : idx === 1 ? ["cursor"] : ["claude", "cursor"];
|
|
31
|
+
for (const tool of tools) {
|
|
32
|
+
if (tool === "claude") setupClaudeCode(config.syncToken);
|
|
33
|
+
if (tool === "cursor") setupCursor(config.syncToken);
|
|
34
|
+
}
|
|
35
|
+
generateAgentDocs();
|
|
36
|
+
console.log(`
|
|
37
|
+
\u2705 Agent configuration complete!
|
|
38
|
+
|
|
39
|
+
Your AI tool now has:
|
|
40
|
+
\u2022 Product context from your specstocode story map
|
|
41
|
+
\u2022 Slash commands for the development workflow
|
|
42
|
+
\u2022 Agent guides for implementing, testing, and documenting features
|
|
43
|
+
\u2022 Architecture and conventions scaffolding
|
|
44
|
+
|
|
45
|
+
Slash commands (use inside Claude Code / Cursor, not the terminal):
|
|
46
|
+
/pb-propose Propose a new change \u2014 creates stories + local spec
|
|
47
|
+
/pb-next Pick up the next story
|
|
48
|
+
/pb-implement Full implementation playbook
|
|
49
|
+
/pb-review Review against acceptance criteria
|
|
50
|
+
/pb-document Document what was built
|
|
51
|
+
/pb-test Generate tests from ACs
|
|
52
|
+
/pb-status Show progress
|
|
53
|
+
/pb-done Mark a story as done
|
|
54
|
+
/pb-sync Refresh product context
|
|
55
|
+
/pb-context Load focused context for the current story
|
|
56
|
+
|
|
57
|
+
Terminal commands (use anywhere):
|
|
58
|
+
specstocode status Show story map progress
|
|
59
|
+
specstocode next Next priority story
|
|
60
|
+
specstocode done <id> Mark a story as done
|
|
61
|
+
specstocode stories List all stories
|
|
62
|
+
specstocode sync Refresh SPECSTOCODE.md
|
|
63
|
+
`);
|
|
64
|
+
closePrompt();
|
|
65
|
+
}
|
|
66
|
+
function setupClaudeCode(syncToken) {
|
|
67
|
+
const cwd = process.cwd();
|
|
68
|
+
const claudeMdPath = join(cwd, "CLAUDE.md");
|
|
69
|
+
const claudeBlock = `
|
|
70
|
+
# specstocode Integration
|
|
71
|
+
|
|
72
|
+
This project is connected to a specstocode story map.
|
|
73
|
+
Read SPECSTOCODE.md for the full product context: personas, user journey, stories, and acceptance criteria.
|
|
74
|
+
|
|
75
|
+
## Context hierarchy
|
|
76
|
+
|
|
77
|
+
1. **SPECSTOCODE.md** \u2014 what to build (stories, acceptance criteria, personas)
|
|
78
|
+
2. **ARCHITECTURE.md** \u2014 how the system is structured (decisions, patterns, trade-offs)
|
|
79
|
+
3. **CONVENTIONS.md** \u2014 how to write code (naming, file structure, testing patterns)
|
|
80
|
+
|
|
81
|
+
Refresh product context anytime: \`npx specstocode sync\`
|
|
82
|
+
|
|
83
|
+
## Development workflow
|
|
84
|
+
|
|
85
|
+
### Starting work
|
|
86
|
+
1. Run \`npx specstocode next\` to get the highest-priority story
|
|
87
|
+
2. Read the acceptance criteria \u2014 these define "done"
|
|
88
|
+
3. Check ARCHITECTURE.md for relevant technical decisions
|
|
89
|
+
4. Plan your approach before writing code
|
|
90
|
+
|
|
91
|
+
### During development
|
|
92
|
+
- Follow patterns in CONVENTIONS.md
|
|
93
|
+
- If you discover a new requirement, create a story:
|
|
94
|
+
\`npx specstocode add "Story title" --activity "Activity name" --priority must\`
|
|
95
|
+
- If you make an architectural decision, log it:
|
|
96
|
+
\`npx specstocode decide "Decision title" -d "What was decided and why"\`
|
|
97
|
+
|
|
98
|
+
### Completing work
|
|
99
|
+
1. Verify all acceptance criteria are met
|
|
100
|
+
2. Add implementation notes:
|
|
101
|
+
\`npx specstocode note <story-id> "How this was implemented, gotchas"\`
|
|
102
|
+
3. Mark done: \`npx specstocode done <story-id>\`
|
|
103
|
+
4. Commit: \`git commit -m "feat: description [SC-<id>]"\`
|
|
104
|
+
|
|
105
|
+
### Writing back to specstocode
|
|
106
|
+
Everything you record flows back to the story map so the team has context:
|
|
107
|
+
- **Stories**: \`npx specstocode add\` / \`done\` / \`note\`
|
|
108
|
+
- **Decisions**: \`npx specstocode decide\`
|
|
109
|
+
- **Context refresh**: \`npx specstocode sync\`
|
|
110
|
+
`;
|
|
111
|
+
if (existsSync(claudeMdPath)) {
|
|
112
|
+
const existing = readFileSync(claudeMdPath, "utf-8");
|
|
113
|
+
if (!existing.includes("specstocode Integration")) {
|
|
114
|
+
writeFileSync(claudeMdPath, existing + "\n" + claudeBlock);
|
|
115
|
+
console.log(" \u2713 Updated CLAUDE.md with specstocode agent workflow");
|
|
116
|
+
} else {
|
|
117
|
+
console.log(" \u2713 CLAUDE.md already configured");
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
writeFileSync(claudeMdPath, claudeBlock.trim() + "\n");
|
|
121
|
+
console.log(" \u2713 Created CLAUDE.md with specstocode agent workflow");
|
|
122
|
+
}
|
|
123
|
+
const commandsDir = join(cwd, ".claude", "commands");
|
|
124
|
+
if (!existsSync(commandsDir)) mkdirSync(commandsDir, { recursive: true });
|
|
125
|
+
writeFileSync(
|
|
126
|
+
join(commandsDir, "pb-next.md"),
|
|
127
|
+
`# Pick up the next story
|
|
128
|
+
|
|
129
|
+
1. Run \`npx specstocode next\` to get the highest-priority story
|
|
130
|
+
2. Read the acceptance criteria carefully \u2014 these define "done"
|
|
131
|
+
3. Check ARCHITECTURE.md for relevant technical decisions
|
|
132
|
+
4. Read CONVENTIONS.md for coding patterns to follow
|
|
133
|
+
5. Outline your implementation plan before writing code
|
|
134
|
+
6. Ask for confirmation before proceeding
|
|
135
|
+
`
|
|
136
|
+
);
|
|
137
|
+
writeFileSync(
|
|
138
|
+
join(commandsDir, "pb-implement.md"),
|
|
139
|
+
`# Implement a story
|
|
140
|
+
|
|
141
|
+
## Process
|
|
142
|
+
1. Run \`npx specstocode next\` to identify the story (or use the story ID provided)
|
|
143
|
+
2. Read SPECSTOCODE.md for full product context
|
|
144
|
+
3. Read the story's acceptance criteria \u2014 each one is a requirement
|
|
145
|
+
4. Check ARCHITECTURE.md for technical decisions that affect this work
|
|
146
|
+
5. Plan: which files change? Simplest approach? Edge cases in the ACs?
|
|
147
|
+
6. Implement the feature
|
|
148
|
+
7. Verify each acceptance criterion is met
|
|
149
|
+
8. Write or update tests if applicable
|
|
150
|
+
|
|
151
|
+
## Write back to specstocode
|
|
152
|
+
9. Add implementation notes:
|
|
153
|
+
\`npx specstocode note <story-id> "How this was implemented"\`
|
|
154
|
+
10. Log any significant decisions:
|
|
155
|
+
\`npx specstocode decide "Decision title" -d "What and why" -c architecture\`
|
|
156
|
+
11. Log any trade-offs:
|
|
157
|
+
\`npx specstocode decide "Trade-off" -d "What and why" -c trade-off\`
|
|
158
|
+
12. If you discovered new requirements:
|
|
159
|
+
\`npx specstocode add "title" --activity "Activity" --priority should\`
|
|
160
|
+
13. Mark done: \`npx specstocode done <story-id>\`
|
|
161
|
+
14. Commit: \`git commit -m "feat: description [SC-<id>]"\`
|
|
162
|
+
|
|
163
|
+
## Rules
|
|
164
|
+
- Don't over-engineer. Build exactly what the acceptance criteria describe.
|
|
165
|
+
- Always log significant decisions \u2014 future developers need context.
|
|
166
|
+
- Follow patterns in CONVENTIONS.md
|
|
167
|
+
`
|
|
168
|
+
);
|
|
169
|
+
writeFileSync(
|
|
170
|
+
join(commandsDir, "pb-review.md"),
|
|
171
|
+
`# Review against acceptance criteria
|
|
172
|
+
|
|
173
|
+
1. Identify the story being worked on
|
|
174
|
+
2. For each acceptance criterion:
|
|
175
|
+
- Does the implementation satisfy it? (yes/no/partial)
|
|
176
|
+
- If partial, what's missing?
|
|
177
|
+
3. Check for: edge cases, error handling, accessibility, security
|
|
178
|
+
4. Summarise: what's done, what needs work, any concerns
|
|
179
|
+
`
|
|
180
|
+
);
|
|
181
|
+
writeFileSync(
|
|
182
|
+
join(commandsDir, "pb-document.md"),
|
|
183
|
+
`# Document a feature
|
|
184
|
+
|
|
185
|
+
1. Check which story was just completed
|
|
186
|
+
2. Read SPECSTOCODE.md for product context
|
|
187
|
+
3. Write a brief markdown doc explaining:
|
|
188
|
+
- What was built and why
|
|
189
|
+
- How it works (architecture-level)
|
|
190
|
+
- Decisions made and trade-offs
|
|
191
|
+
- How to test it manually
|
|
192
|
+
4. Log decisions to specstocode:
|
|
193
|
+
\`npx specstocode decide "Title" -d "Description" -c architecture\`
|
|
194
|
+
5. Add implementation notes:
|
|
195
|
+
\`npx specstocode note <story-id> "Summary of how it works"\`
|
|
196
|
+
6. Update ARCHITECTURE.md if needed
|
|
197
|
+
7. Update CONVENTIONS.md if new patterns were introduced
|
|
198
|
+
`
|
|
199
|
+
);
|
|
200
|
+
writeFileSync(
|
|
201
|
+
join(commandsDir, "pb-test.md"),
|
|
202
|
+
`# Write tests for a story
|
|
203
|
+
|
|
204
|
+
1. Get the story details: \`npx specstocode next\` or provided story ID
|
|
205
|
+
2. Each acceptance criterion becomes at least one test
|
|
206
|
+
3. Also consider: error cases, boundary conditions, integration points
|
|
207
|
+
4. Follow testing patterns in CONVENTIONS.md
|
|
208
|
+
5. Run the tests to verify they pass
|
|
209
|
+
`
|
|
210
|
+
);
|
|
211
|
+
writeFileSync(
|
|
212
|
+
join(commandsDir, "pb-status.md"),
|
|
213
|
+
`Run \`npx specstocode status\` and \`npx specstocode stories --filter todo\` to show current progress and remaining backlog. Summarise what's done and what's left.`
|
|
214
|
+
);
|
|
215
|
+
writeFileSync(
|
|
216
|
+
join(commandsDir, "pb-done.md"),
|
|
217
|
+
`Ask which story was just completed, then run \`npx specstocode done <id>\`. Also ask if there are any implementation notes to add: \`npx specstocode note <id> "..."\``
|
|
218
|
+
);
|
|
219
|
+
writeFileSync(
|
|
220
|
+
join(commandsDir, "pb-sync.md"),
|
|
221
|
+
`Run \`npx specstocode sync\` to refresh SPECSTOCODE.md with the latest story map. Then re-read SPECSTOCODE.md to update your context.`
|
|
222
|
+
);
|
|
223
|
+
writeFileSync(
|
|
224
|
+
join(commandsDir, "pb-propose.md"),
|
|
225
|
+
`# Propose a new change
|
|
226
|
+
|
|
227
|
+
Use this when you want to plan a new feature, improvement, or fix before writing code.
|
|
228
|
+
specstocode stores the source of truth in your online story map \u2014 this command creates
|
|
229
|
+
stories there AND saves a local spec for the AI to reference during implementation.
|
|
230
|
+
|
|
231
|
+
## Process
|
|
232
|
+
1. Ask the user: "What do you want to build or change? Describe the problem and the solution."
|
|
233
|
+
2. Help them break it into 2-5 stories with clear acceptance criteria (each AC is testable)
|
|
234
|
+
3. Run: \`npx specstocode propose <change-name>\`
|
|
235
|
+
- The CLI will guide through: problem, solution, activity, priority, stories + ACs
|
|
236
|
+
- Stories are created in the live story map at specstocode.com
|
|
237
|
+
- A local spec is saved to \`pb-changes/<name>/proposal.md\`
|
|
238
|
+
4. Once done: \`npx specstocode sync\` to pull the new stories into SPECSTOCODE.md
|
|
239
|
+
5. Run \`npx specstocode next\` to start implementing
|
|
240
|
+
|
|
241
|
+
## Tips
|
|
242
|
+
- Change names should be kebab-case: add-dark-mode, fix-auth-flow, onboarding-revamp
|
|
243
|
+
- Keep stories small \u2014 one story = one deployable increment
|
|
244
|
+
- Write ACs as testable outcomes: "Given X, when Y, then Z" or "User can..."
|
|
245
|
+
- If the change is already defined in the UI, just run \`npx specstocode sync\` instead
|
|
246
|
+
`
|
|
247
|
+
);
|
|
248
|
+
writeFileSync(
|
|
249
|
+
join(commandsDir, "pb-context.md"),
|
|
250
|
+
`# Load current story context
|
|
251
|
+
|
|
252
|
+
Use this to focus on a single story without loading the full story map.
|
|
253
|
+
|
|
254
|
+
## When to use
|
|
255
|
+
- At the start of a coding session for a specific story
|
|
256
|
+
- When switching between stories mid-session
|
|
257
|
+
- When you need a clean, focused view of ACs and notes
|
|
258
|
+
|
|
259
|
+
## Process
|
|
260
|
+
1. Run \`npx specstocode next\` to get the active story \u2014 this automatically writes the context file to \`.specstocode/stories/<id>.md\`
|
|
261
|
+
2. Read that file \u2014 it contains: title, user story, acceptance criteria (as checkboxes), notes, and space for relevant files
|
|
262
|
+
3. Use it as your working document throughout implementation:
|
|
263
|
+
- Check off ACs as you satisfy them
|
|
264
|
+
- Add file paths under "Relevant files" as you discover them
|
|
265
|
+
- Run \`npx specstocode note <id> "..."\` to log notes (updates both remote map and local file)
|
|
266
|
+
4. When all ACs are checked: \`npx specstocode done <id>\`
|
|
267
|
+
|
|
268
|
+
## If you already know the story ID
|
|
269
|
+
The file is at \`.specstocode/stories/<full-story-id>.md\` \u2014 read it directly.
|
|
270
|
+
`
|
|
271
|
+
);
|
|
272
|
+
console.log(" \u2713 Created slash commands: /pb-propose, /pb-next, /pb-implement, /pb-review, /pb-document, /pb-test, /pb-status, /pb-done, /pb-sync, /pb-context");
|
|
273
|
+
try {
|
|
274
|
+
execSync("openclaw --version", { stdio: "ignore" });
|
|
275
|
+
const registration = JSON.stringify({
|
|
276
|
+
command: "npx",
|
|
277
|
+
args: ["specstocode", "mcp"],
|
|
278
|
+
cwd
|
|
279
|
+
});
|
|
280
|
+
execSync(`openclaw mcp set specstocode '${registration}'`, { stdio: "inherit" });
|
|
281
|
+
console.log(" \u2713 Registered with OpenClaw MCP \u2014 coding agents can now access your story map live");
|
|
282
|
+
} catch {
|
|
283
|
+
console.log(`
|
|
284
|
+
To enable MCP tools (recommended), add to your Claude Code MCP config:
|
|
285
|
+
|
|
286
|
+
{
|
|
287
|
+
"mcpServers": {
|
|
288
|
+
"specstocode": {
|
|
289
|
+
"command": "npx",
|
|
290
|
+
"args": ["specstocode", "mcp"],
|
|
291
|
+
"cwd": "${cwd}"
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
Or if you use OpenClaw: npx specstocode openclaw-register
|
|
297
|
+
`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function setupCursor(syncToken) {
|
|
301
|
+
const cwd = process.cwd();
|
|
302
|
+
const cursorRulesPath = join(cwd, ".cursorrules");
|
|
303
|
+
const cursorBlock = `
|
|
304
|
+
# specstocode Integration
|
|
305
|
+
|
|
306
|
+
## Context files
|
|
307
|
+
1. **SPECSTOCODE.md** \u2014 product story map with personas, stories, acceptance criteria
|
|
308
|
+
2. **ARCHITECTURE.md** \u2014 technical decisions and system structure
|
|
309
|
+
3. **CONVENTIONS.md** \u2014 coding patterns, naming, file structure
|
|
310
|
+
|
|
311
|
+
## Workflow
|
|
312
|
+
- Next story: \`npx specstocode next\`
|
|
313
|
+
- Mark done: \`npx specstocode done <id>\`
|
|
314
|
+
- Add notes: \`npx specstocode note <id> "..."\`
|
|
315
|
+
- Log decisions: \`npx specstocode decide "Title" -d "Why"\`
|
|
316
|
+
- Create stories: \`npx specstocode add "title" --activity "Name"\`
|
|
317
|
+
- Refresh context: \`npx specstocode sync\`
|
|
318
|
+
|
|
319
|
+
## Rules
|
|
320
|
+
- Read acceptance criteria before implementing
|
|
321
|
+
- Don't over-engineer \u2014 build what's needed
|
|
322
|
+
- Log decisions and trade-offs back to specstocode
|
|
323
|
+
- Follow patterns in CONVENTIONS.md
|
|
324
|
+
`;
|
|
325
|
+
if (existsSync(cursorRulesPath)) {
|
|
326
|
+
const existing = readFileSync(cursorRulesPath, "utf-8");
|
|
327
|
+
if (!existing.includes("specstocode Integration")) {
|
|
328
|
+
writeFileSync(cursorRulesPath, existing + "\n" + cursorBlock);
|
|
329
|
+
console.log(" \u2713 Updated .cursorrules");
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
writeFileSync(cursorRulesPath, cursorBlock.trim() + "\n");
|
|
333
|
+
console.log(" \u2713 Created .cursorrules");
|
|
334
|
+
}
|
|
335
|
+
console.log(`
|
|
336
|
+
To enable MCP tools in Cursor:
|
|
337
|
+
|
|
338
|
+
{
|
|
339
|
+
"mcpServers": {
|
|
340
|
+
"specstocode": {
|
|
341
|
+
"command": "npx",
|
|
342
|
+
"args": ["specstocode", "mcp"],
|
|
343
|
+
"cwd": "${cwd}"
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
`);
|
|
348
|
+
}
|
|
349
|
+
function generateAgentDocs() {
|
|
350
|
+
const cwd = process.cwd();
|
|
351
|
+
const archPath = join(cwd, "ARCHITECTURE.md");
|
|
352
|
+
if (!existsSync(archPath)) {
|
|
353
|
+
writeFileSync(
|
|
354
|
+
archPath,
|
|
355
|
+
`# Architecture
|
|
356
|
+
|
|
357
|
+
Document technical decisions here. Your AI tool reads this before implementing features.
|
|
358
|
+
|
|
359
|
+
## Decisions
|
|
360
|
+
|
|
361
|
+
| Date | Decision | Rationale |
|
|
362
|
+
|------|----------|-----------|
|
|
363
|
+
| ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]} | Project initialised with specstocode | Story-map-driven development |
|
|
364
|
+
|
|
365
|
+
## Stack
|
|
366
|
+
|
|
367
|
+
_Fill in your tech stack here._
|
|
368
|
+
|
|
369
|
+
## Patterns
|
|
370
|
+
|
|
371
|
+
_Document recurring patterns._
|
|
372
|
+
|
|
373
|
+
## Trade-offs
|
|
374
|
+
|
|
375
|
+
_Record trade-offs and why._
|
|
376
|
+
`
|
|
377
|
+
);
|
|
378
|
+
console.log(" \u2713 Created ARCHITECTURE.md scaffold");
|
|
379
|
+
}
|
|
380
|
+
const convPath = join(cwd, "CONVENTIONS.md");
|
|
381
|
+
if (!existsSync(convPath)) {
|
|
382
|
+
writeFileSync(
|
|
383
|
+
convPath,
|
|
384
|
+
`# Conventions
|
|
385
|
+
|
|
386
|
+
Coding rules for this project. Your AI tool follows these when writing code.
|
|
387
|
+
|
|
388
|
+
## File structure
|
|
389
|
+
|
|
390
|
+
_Describe your preferred file/folder structure._
|
|
391
|
+
|
|
392
|
+
## Naming
|
|
393
|
+
|
|
394
|
+
_Naming conventions (camelCase, PascalCase, etc.)._
|
|
395
|
+
|
|
396
|
+
## Testing
|
|
397
|
+
|
|
398
|
+
_Testing patterns._
|
|
399
|
+
|
|
400
|
+
## Git
|
|
401
|
+
|
|
402
|
+
- Branches: \`feat/<description>\`, \`fix/<description>\`
|
|
403
|
+
- Commits: \`feat: description [PB-<story-id>]\`
|
|
404
|
+
- Always create PRs \u2014 never commit directly to main
|
|
405
|
+
|
|
406
|
+
## Code style
|
|
407
|
+
|
|
408
|
+
_Linting, formatting, style preferences._
|
|
409
|
+
`
|
|
410
|
+
);
|
|
411
|
+
console.log(" \u2713 Created CONVENTIONS.md scaffold");
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export {
|
|
416
|
+
setup
|
|
417
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/lib/auth.ts
|
|
2
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
var AUTH_DIR = join(homedir(), ".specstocode");
|
|
6
|
+
var AUTH_FILE = join(AUTH_DIR, "auth.json");
|
|
7
|
+
function getAuth() {
|
|
8
|
+
try {
|
|
9
|
+
const raw = readFileSync(AUTH_FILE, "utf-8");
|
|
10
|
+
return JSON.parse(raw);
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function saveAuth(data) {
|
|
16
|
+
if (!existsSync(AUTH_DIR)) mkdirSync(AUTH_DIR, { recursive: true });
|
|
17
|
+
writeFileSync(AUTH_FILE, JSON.stringify(data, null, 2) + "\n", { mode: 384 });
|
|
18
|
+
}
|
|
19
|
+
function requireAuth() {
|
|
20
|
+
const auth = getAuth();
|
|
21
|
+
if (!auth) {
|
|
22
|
+
console.error("Not logged in. Run: npx specstocode login");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
return auth;
|
|
26
|
+
}
|
|
27
|
+
var API_BASE = "https://specstocode.com";
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
getAuth,
|
|
31
|
+
saveAuth,
|
|
32
|
+
requireAuth,
|
|
33
|
+
API_BASE
|
|
34
|
+
};
|