@applica-software-guru/sdd-core 1.8.1 → 1.8.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.
Files changed (57) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/parser/bug-parser.d.ts.map +1 -1
  6. package/dist/parser/bug-parser.js +2 -1
  7. package/dist/parser/bug-parser.js.map +1 -1
  8. package/dist/parser/cr-parser.d.ts.map +1 -1
  9. package/dist/parser/cr-parser.js +2 -1
  10. package/dist/parser/cr-parser.js.map +1 -1
  11. package/dist/prompt/draft-prompt-generator.d.ts +1 -1
  12. package/dist/prompt/draft-prompt-generator.d.ts.map +1 -1
  13. package/dist/prompt/draft-prompt-generator.js +19 -35
  14. package/dist/prompt/draft-prompt-generator.js.map +1 -1
  15. package/dist/remote/api-client.d.ts +2 -2
  16. package/dist/remote/api-client.d.ts.map +1 -1
  17. package/dist/remote/api-client.js +4 -4
  18. package/dist/remote/api-client.js.map +1 -1
  19. package/dist/remote/sync-engine.js +12 -8
  20. package/dist/remote/sync-engine.js.map +1 -1
  21. package/dist/scaffold/skill-adapters.d.ts +0 -9
  22. package/dist/scaffold/skill-adapters.d.ts.map +1 -1
  23. package/dist/scaffold/skill-adapters.js +17 -0
  24. package/dist/scaffold/skill-adapters.js.map +1 -1
  25. package/dist/scaffold/templates.d.ts +1 -5
  26. package/dist/scaffold/templates.d.ts.map +1 -1
  27. package/dist/scaffold/templates.generated.d.ts +7 -0
  28. package/dist/scaffold/templates.generated.d.ts.map +1 -0
  29. package/dist/scaffold/templates.generated.js +464 -0
  30. package/dist/scaffold/templates.generated.js.map +1 -0
  31. package/dist/scaffold/templates.js +8 -338
  32. package/dist/scaffold/templates.js.map +1 -1
  33. package/dist/sdd.d.ts +0 -1
  34. package/dist/sdd.d.ts.map +1 -1
  35. package/dist/sdd.js +1 -18
  36. package/dist/sdd.js.map +1 -1
  37. package/package.json +2 -1
  38. package/scripts/generate-templates.mjs +38 -0
  39. package/src/index.ts +1 -1
  40. package/src/parser/bug-parser.ts +5 -3
  41. package/src/parser/cr-parser.ts +5 -3
  42. package/src/prompt/draft-prompt-generator.ts +18 -38
  43. package/src/remote/api-client.ts +2 -2
  44. package/src/remote/sync-engine.ts +15 -15
  45. package/src/scaffold/skill-adapters.ts +18 -11
  46. package/src/scaffold/templates.generated.ts +466 -0
  47. package/src/scaffold/templates.ts +9 -342
  48. package/src/sdd.ts +1 -19
  49. package/tests/agent-defaults.test.ts +24 -0
  50. package/tests/api-client.test.ts +6 -6
  51. package/tests/draft-prompt.test.ts +78 -0
  52. package/dist/prompt/apply-prompt-generator.d.ts +0 -4
  53. package/dist/prompt/apply-prompt-generator.d.ts.map +0 -1
  54. package/dist/prompt/apply-prompt-generator.js +0 -97
  55. package/dist/prompt/apply-prompt-generator.js.map +0 -1
  56. package/src/prompt/apply-prompt-generator.ts +0 -117
  57. package/tests/apply.test.ts +0 -117
@@ -0,0 +1,466 @@
1
+ // @generated — DO NOT EDIT. Source of truth: packages/skill/
2
+ // Regenerate with: node packages/core/scripts/generate-templates.mjs
3
+
4
+ export const SKILL_MD_TEMPLATE = `---
5
+ name: sdd
6
+ description: >
7
+ Story Driven Development workflow. Use when working in a project
8
+ with .sdd/config.yaml, or when the user mentions SDD, sdd sync,
9
+ story driven development, or spec-driven development.
10
+ license: MIT
11
+ compatibility: Requires sdd CLI (npm i -g @applica-software-guru/sdd)
12
+ allowed-tools: Bash(sdd:*) Read Glob Grep
13
+ metadata:
14
+ author: applica-software-guru
15
+ version: "1.0"
16
+ ---
17
+
18
+ # SDD — Story Driven Development
19
+
20
+ ## Detection
21
+
22
+ This project uses SDD if \`.sdd/config.yaml\` exists in the project root.
23
+
24
+ ## Workflow
25
+
26
+ Follow this loop every time you work on an SDD project:
27
+
28
+ 1. Run \`sdd bug open\` — check if there are open bugs to fix first
29
+ 2. If there are open bugs, fix the code/docs, then run \`sdd mark-bug-resolved\`
30
+ 3. Run \`sdd cr pending\` — check if there are change requests to process
31
+ 4. If there are pending CRs, apply them to the docs, then run \`sdd mark-cr-applied\`
32
+ 5. Run \`sdd sync\` to see what needs to be implemented
33
+ 6. Read the documentation files listed in the sync output
34
+ 7. Implement what each file describes, writing code inside \`code/\`
35
+ 8. After implementing, mark files as synced:
36
+
37
+ \`\`\`
38
+ sdd mark-synced product/features/auth.md
39
+ \`\`\`
40
+
41
+ Or mark all pending files at once:
42
+
43
+ \`\`\`
44
+ sdd mark-synced
45
+ \`\`\`
46
+
47
+ 9. **Commit immediately after mark-synced** — this is mandatory:
48
+
49
+ \`\`\`
50
+ git add -A && git commit -m "sdd sync: <brief description of what was implemented>"
51
+ \`\`\`
52
+
53
+ Do NOT skip this step. Every mark-synced must be followed by a git commit.
54
+
55
+ 10. If remote sync is configured (remote section in \`.sdd/config.yaml\` and API key available), remind the user they can publish updates with:
56
+
57
+ \`\`\`
58
+ sdd push
59
+ \`\`\`
60
+
61
+ ### Removing a feature
62
+
63
+ If a documentation file has \`status: deleted\`, it means that feature should be removed.
64
+ Delete the related code in \`code/\`, then run \`sdd mark-synced <file>\` (the doc file will be removed automatically), then commit.
65
+
66
+ ## Available commands
67
+
68
+ - \`sdd status\` — See all documentation files and their state (new/changed/deleted/synced)
69
+ - \`sdd diff\` — See what changed since last sync
70
+ - \`sdd sync\` — Get the sync prompt for pending files (includes git diff for changed files)
71
+ - \`sdd validate\` — Check for broken references and issues
72
+ - \`sdd mark-synced [files...]\` — Mark specific files (or all) as synced
73
+ - \`sdd cr list\` — List all change requests with their status
74
+ - \`sdd cr pending\` — Show pending change requests to process
75
+ - \`sdd mark-cr-applied [files...]\` — Mark change requests as applied
76
+ - \`sdd bug list\` — List all bugs with their status
77
+ - \`sdd bug open\` — Show open bugs to fix
78
+ - \`sdd mark-bug-resolved [files...]\` — Mark bugs as resolved
79
+
80
+ ## Rules
81
+
82
+ 1. **Always commit after mark-synced** — run \`git add -A && git commit -m "sdd sync: ..."\` immediately after \`sdd mark-synced\`. Never leave synced files uncommitted.
83
+ 2. Before running \`sdd sync\`, check for open bugs with \`sdd bug open\` and pending change requests with \`sdd cr pending\`
84
+ 3. If there are pending CRs, apply them to the docs first, then mark them with \`sdd mark-cr-applied\`
85
+ 4. Only implement what the sync prompt asks for
86
+ 5. All generated code goes inside \`code/\`
87
+ 6. Respect all constraints in \`## Agent Notes\` sections (if present)
88
+ 7. Do not edit files inside \`.sdd/\` manually
89
+ 8. If remote is configured, suggest \`sdd push\` after successful local sync + commit
90
+
91
+ ## Project structure
92
+
93
+ - \`product/\` — What to build (vision, users, features)
94
+ - \`system/\` — How to build it (entities, architecture, tech stack, interfaces)
95
+ - \`code/\` — All generated source code goes here
96
+ - \`change-requests/\` — Change requests to the documentation
97
+ - \`bugs/\` — Bug reports
98
+ - \`.sdd/\` — Project config and sync state (do not edit)
99
+
100
+ ## References
101
+
102
+ For detailed information on specific topics, see:
103
+
104
+ - [File format and status lifecycle](references/file-format.md)
105
+ - [Change Requests workflow](references/change-requests.md)
106
+ - [Bug workflow](references/bugs.md)
107
+ - [Remote pull/enrich/push workflow](../sdd-remote/SKILL.md)
108
+ - [UI Component workflow](../sdd-ui/SKILL.md)
109
+ `;
110
+
111
+ export const SKILL_UI_MD_TEMPLATE = `---
112
+ name: sdd-ui
113
+ description: >
114
+ UI Component Editor workflow. Use when the user wants to implement a React component
115
+ from a screenshot in an SDD project, iterating visually with live preview.
116
+ license: MIT
117
+ compatibility: >
118
+ Requires sdd CLI (npm i -g @applica-software-guru/sdd).
119
+ Requires Playwright MCP configured in Claude Code
120
+ (e.g. @playwright/mcp or @executeautomation/playwright-mcp).
121
+ allowed-tools: Bash(sdd:*) Read Glob Grep Edit Write mcp__playwright__screenshot mcp__playwright__navigate mcp__playwright__click
122
+ metadata:
123
+ author: applica-software-guru
124
+ version: "1.1"
125
+ ---
126
+
127
+ # SDD UI — Visual Component Editor
128
+
129
+ ## Purpose
130
+
131
+ Use this workflow when implementing a React component from a screenshot reference in an SDD project.
132
+ The split-panel editor shows the spec screenshot on the left and the live component on the right,
133
+ so you can iterate visually until they match.
134
+
135
+ ## Prerequisites
136
+
137
+ - \`sdd\` CLI installed globally
138
+ - Playwright MCP configured in Claude Code settings
139
+ - e.g. \`@playwright/mcp\` or \`@executeautomation/playwright-mcp\`
140
+ - If not configured, inform the user and stop — visual feedback won't work without it
141
+
142
+ ## Workflow
143
+
144
+ ### Step 1 — Read the spec
145
+
146
+ Read the SDD feature file to understand what the component should look like and do.
147
+ Look for any screenshot paths referenced in the feature doc.
148
+
149
+ ### Step 2 — Launch the editor
150
+
151
+ \`\`\`bash
152
+ # Single screenshot — detached (recommended when run by an agent)
153
+ sdd ui launch-editor LoginForm \\
154
+ --screenshot product/features/auth/login.png \\
155
+ --detach
156
+
157
+ # Multiple screenshots (e.g. desktop + mobile)
158
+ sdd ui launch-editor LoginForm \\
159
+ --screenshot product/features/auth/login-desktop.png \\
160
+ --screenshot product/features/auth/login-mobile.png \\
161
+ --detach
162
+ \`\`\`
163
+
164
+ The command will:
165
+ - Scaffold \`code/components/LoginForm.tsx\` if it doesn't exist
166
+ - Print the exact component file path to edit
167
+ - Start the editor at \`http://localhost:5174\`
168
+
169
+ With \`--detach\` the process runs in background and the terminal is immediately free.
170
+ Without \`--detach\` it runs in foreground (use Ctrl+C to stop).
171
+
172
+ With multiple screenshots, the left panel shows a tab per screenshot.
173
+ With a single screenshot, no tab bar is shown.
174
+
175
+ ### Step 3 — Implement the component
176
+
177
+ Edit the file printed by \`sdd ui launch-editor\` (e.g. \`code/components/LoginForm.tsx\`).
178
+
179
+ Write a React component that matches the screenshot. Use standard HTML/CSS or inline styles —
180
+ no external UI library unless the project already uses one.
181
+
182
+ Vite HMR will update the right panel automatically on every save.
183
+
184
+ ### Step 4 — Visual check with Playwright
185
+
186
+ After each save, screenshot the live preview and compare it with the spec:
187
+
188
+ \`\`\`
189
+ mcp__playwright__navigate http://localhost:5174
190
+ mcp__playwright__screenshot
191
+ \`\`\`
192
+
193
+ The left panel already shows the spec screenshot for direct comparison.
194
+ Note differences in layout, spacing, typography, colors, and component structure.
195
+
196
+ ### Step 5 — Iterate
197
+
198
+ Edit component → Playwright screenshot → compare → repeat until the preview matches the spec.
199
+
200
+ ### Step 6 — Finalize
201
+
202
+ \`\`\`bash
203
+ sdd ui stop
204
+ sdd mark-synced product/features/auth/login.md
205
+ git add -A && git commit -m "sdd sync: implement LoginForm component"
206
+ \`\`\`
207
+
208
+ ## Notes
209
+
210
+ - The component file is permanent — it lives in \`code/components/\` and is part of your project
211
+ - Port \`5174\` by default (not \`5173\`) to avoid conflicts with the user's app dev server
212
+ - If the component needs props, scaffold it with hardcoded sample data for the preview
213
+
214
+ ## Troubleshooting
215
+
216
+ **Playwright MCP not configured:**
217
+ Stop and ask the user to add it to their Claude Code MCP settings before continuing.
218
+
219
+ **Component import fails in preview:**
220
+ Check that the component file has a valid default export and no TypeScript errors.
221
+
222
+ **Port already in use:**
223
+ \`sdd ui launch-editor LoginForm --screenshot login.png --port 5175\`
224
+ `;
225
+
226
+ export const SKILL_REMOTE_MD_TEMPLATE = `---
227
+ name: sdd-remote
228
+ description: >
229
+ Remote sync workflow for Story Driven Development. Use when the user asks
230
+ to update local state from remote changes, process remote drafts, and push
231
+ enriched items back.
232
+ license: MIT
233
+ compatibility: Requires sdd CLI (npm i -g @applica-software-guru/sdd)
234
+ allowed-tools: Bash(sdd:*) Read Glob Grep
235
+ metadata:
236
+ author: applica-software-guru
237
+ version: "1.0"
238
+ ---
239
+
240
+ # SDD Remote - Pull, Enrich, Push
241
+
242
+ ## Purpose
243
+
244
+ Use this skill to synchronize local SDD docs with remote updates, enrich draft content,
245
+ and publish the enriched result to remote in active states.
246
+
247
+ ## Detection
248
+
249
+ This workflow applies when:
250
+
251
+ - \`.sdd/config.yaml\` exists in the project root
252
+ - The user asks to update local state from remote, pull pending CRs/bugs/docs,
253
+ enrich drafts, or push pending remote updates
254
+
255
+ ## Workflow
256
+
257
+ Follow this sequence in order:
258
+
259
+ 1. Verify remote configuration
260
+
261
+ \`\`\`bash
262
+ test -f .sdd/config.yaml && sdd remote status
263
+ \`\`\`
264
+
265
+ If remote is not configured or disconnected, run:
266
+
267
+ \`\`\`bash
268
+ sdd remote init
269
+ \`\`\`
270
+
271
+ Then stop and ask the user for URL/API key if needed.
272
+
273
+ 2. Pull remote updates (docs + CRs + bugs)
274
+
275
+ \`\`\`bash
276
+ sdd pull
277
+ \`\`\`
278
+
279
+ Optional scoped pulls:
280
+
281
+ \`\`\`bash
282
+ sdd pull --docs-only
283
+ sdd pull --crs-only
284
+ sdd pull --bugs-only
285
+ \`\`\`
286
+
287
+ 3. Generate draft TODO list for your coding agent
288
+
289
+ \`\`\`bash
290
+ sdd drafts
291
+ \`\`\`
292
+
293
+ This command lists all local draft docs, CRs, and bugs and prints a minimal TODO-style prompt.
294
+ Give that prompt to your coding agent. If additional context is needed, the agent can fetch it directly from project files.
295
+
296
+ 4. Transition enriched drafts to active states
297
+
298
+ \`\`\`bash
299
+ sdd mark-drafts-enriched
300
+ \`\`\`
301
+
302
+ This performs:
303
+
304
+ - Document: \`draft -> new\`
305
+ - Change Request: \`draft -> pending\`
306
+ - Bug: \`draft -> open\`
307
+
308
+ 5. Push local pending updates to remote
309
+
310
+ \`\`\`bash
311
+ sdd push
312
+ \`\`\`
313
+
314
+ 6. Verify final remote sync state
315
+
316
+ \`\`\`bash
317
+ sdd remote status
318
+ \`\`\`
319
+
320
+ ## Rules
321
+
322
+ 1. Always check remote configuration before pull/push (\`sdd remote status\`)
323
+ 2. Do not use \`sdd push --all\` unless the user explicitly asks for a full reseed
324
+ 3. If pull reports conflicts, do not overwrite local files blindly; report conflicts and ask how to proceed
325
+ 4. Do not edit files inside \`.sdd/\` manually
326
+ 5. Keep status transitions explicit: enrich first, then \`sdd mark-drafts-enriched\`, then push
327
+
328
+ ## Related commands
329
+
330
+ - \`sdd remote init\`
331
+ - \`sdd remote status\`
332
+ - \`sdd pull\`
333
+ - \`sdd drafts\`
334
+ - \`sdd mark-drafts-enriched\`
335
+ - \`sdd push\`
336
+ `;
337
+
338
+ export const FILE_FORMAT_REFERENCE = `# File Format and Status Lifecycle
339
+
340
+ ## YAML Frontmatter
341
+
342
+ Every \`.md\` file in \`product/\` and \`system/\` must start with this YAML frontmatter:
343
+
344
+ \`\`\`yaml
345
+ ---
346
+ title: "File title"
347
+ status: new
348
+ author: ""
349
+ last-modified: "2025-01-01T00:00:00.000Z"
350
+ version: "1.0"
351
+ ---
352
+ \`\`\`
353
+
354
+ ## Status values
355
+
356
+ - **\`new\`** — new file, needs to be implemented
357
+ - **\`changed\`** — modified since last sync, code needs updating
358
+ - **\`deleted\`** — feature to be removed, agent should delete related code
359
+ - **\`synced\`** — already implemented, up to date
360
+
361
+ ## Version
362
+
363
+ Patch-bump on each edit: 1.0 → 1.1 → 1.2
364
+
365
+ ## Last-modified
366
+
367
+ ISO 8601 datetime, updated on each edit.
368
+
369
+ ## How sync works
370
+
371
+ \`sdd sync\` generates a structured prompt for the agent based on pending files:
372
+
373
+ - **\`new\` files**: the agent reads the full documentation and implements it from scratch
374
+ - **\`changed\` files**: SDD uses \`git diff\` to compute what changed in the documentation since the last commit, and includes the diff in the sync prompt — this way the agent sees exactly what was modified and can update only the affected code
375
+ - **\`deleted\` files**: the agent removes the related code
376
+
377
+ This is why **committing after every mark-synced is mandatory** — the git history is what SDD uses to detect changes.
378
+
379
+ ## UX and screenshots
380
+
381
+ When a feature has UX mockups or screenshots, place them next to the feature doc:
382
+
383
+ - **Simple feature** (no screenshots): \`product/features/auth.md\`
384
+ - **Feature with screenshots**: use a folder with \`index.md\`:
385
+
386
+ \`\`\`
387
+ product/features/auth/
388
+ index.md ← feature doc
389
+ login.png ← screenshot
390
+ register.png ← screenshot
391
+ \`\`\`
392
+
393
+ Reference images in the markdown with relative paths:
394
+
395
+ \`\`\`markdown
396
+ ## UX
397
+
398
+ ![Login screen](login.png)
399
+ ![Register screen](register.png)
400
+ \`\`\`
401
+
402
+ Both formats work — use a folder only when you have screenshots or multiple files for a feature.
403
+ `;
404
+
405
+ export const CHANGE_REQUESTS_REFERENCE = `# Change Requests
406
+
407
+ Change Requests (CRs) are markdown files in \`change-requests/\` that describe modifications to the documentation.
408
+
409
+ ## CR format
410
+
411
+ \`\`\`yaml
412
+ ---
413
+ title: "Add authentication feature"
414
+ status: draft
415
+ author: "user"
416
+ created-at: "2025-01-01T00:00:00.000Z"
417
+ ---
418
+ \`\`\`
419
+
420
+ - **status**: \`draft\` (pending) or \`applied\` (already processed)
421
+ - **status**: \`draft\` (needs enrichment), \`pending\` (ready to process), or \`applied\` (already processed)
422
+
423
+ ## CR workflow
424
+
425
+ 1. Check for pending CRs: \`sdd cr pending\`
426
+ 2. Read each pending CR and apply the described changes to the documentation files (marking them as \`new\`, \`changed\`, or \`deleted\`)
427
+ 3. After applying a CR to the docs, mark it: \`sdd mark-cr-applied change-requests/CR-001.md\`
428
+ 4. Then run \`sdd sync\` to implement the code changes
429
+
430
+ ## CR commands
431
+
432
+ - \`sdd cr list\` — See all change requests and their status
433
+ - \`sdd cr pending\` — Show only pending CRs to process
434
+ - \`sdd mark-cr-applied [files...]\` — Mark CRs as applied after updating the docs
435
+ `;
436
+
437
+ export const BUGS_REFERENCE = `# Bugs
438
+
439
+ Bugs are markdown files in \`bugs/\` that describe problems found in the codebase.
440
+
441
+ ## Bug format
442
+
443
+ \`\`\`yaml
444
+ ---
445
+ title: "Login fails with empty password"
446
+ status: open
447
+ author: "user"
448
+ created-at: "2025-01-01T00:00:00.000Z"
449
+ ---
450
+ \`\`\`
451
+
452
+ - **status**: \`draft\` (needs enrichment), \`open\` (needs fixing), or \`resolved\` (already fixed)
453
+
454
+ ## Bug workflow
455
+
456
+ 1. Check for open bugs: \`sdd bug open\`
457
+ 2. Read each open bug and fix the code and/or documentation
458
+ 3. After fixing a bug, mark it: \`sdd mark-bug-resolved bugs/BUG-001.md\`
459
+ 4. Commit the fix
460
+
461
+ ## Bug commands
462
+
463
+ - \`sdd bug list\` — See all bugs and their status
464
+ - \`sdd bug open\` — Show only open bugs to fix
465
+ - \`sdd mark-bug-resolved [files...]\` — Mark bugs as resolved after fixing
466
+ `;