@kynetic-ai/spec 0.3.0 → 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.
Files changed (160) hide show
  1. package/dist/cli/batch-exec.d.ts +0 -9
  2. package/dist/cli/batch-exec.d.ts.map +1 -1
  3. package/dist/cli/batch-exec.js +16 -4
  4. package/dist/cli/batch-exec.js.map +1 -1
  5. package/dist/cli/commands/derive.d.ts.map +1 -1
  6. package/dist/cli/commands/derive.js +2 -1
  7. package/dist/cli/commands/derive.js.map +1 -1
  8. package/dist/cli/commands/guard.d.ts +43 -0
  9. package/dist/cli/commands/guard.d.ts.map +1 -0
  10. package/dist/cli/commands/guard.js +200 -0
  11. package/dist/cli/commands/guard.js.map +1 -0
  12. package/dist/cli/commands/index.d.ts +1 -0
  13. package/dist/cli/commands/index.d.ts.map +1 -1
  14. package/dist/cli/commands/index.js +1 -0
  15. package/dist/cli/commands/index.js.map +1 -1
  16. package/dist/cli/commands/item.d.ts.map +1 -1
  17. package/dist/cli/commands/item.js +18 -0
  18. package/dist/cli/commands/item.js.map +1 -1
  19. package/dist/cli/commands/log.d.ts.map +1 -1
  20. package/dist/cli/commands/log.js +5 -4
  21. package/dist/cli/commands/log.js.map +1 -1
  22. package/dist/cli/commands/meta.d.ts.map +1 -1
  23. package/dist/cli/commands/meta.js +2 -1
  24. package/dist/cli/commands/meta.js.map +1 -1
  25. package/dist/cli/commands/plan-import.d.ts.map +1 -1
  26. package/dist/cli/commands/plan-import.js +100 -30
  27. package/dist/cli/commands/plan-import.js.map +1 -1
  28. package/dist/cli/commands/ralph.d.ts.map +1 -1
  29. package/dist/cli/commands/ralph.js +143 -330
  30. package/dist/cli/commands/ralph.js.map +1 -1
  31. package/dist/cli/commands/session.d.ts +73 -1
  32. package/dist/cli/commands/session.d.ts.map +1 -1
  33. package/dist/cli/commands/session.js +607 -162
  34. package/dist/cli/commands/session.js.map +1 -1
  35. package/dist/cli/commands/setup.d.ts.map +1 -1
  36. package/dist/cli/commands/setup.js +97 -217
  37. package/dist/cli/commands/setup.js.map +1 -1
  38. package/dist/cli/commands/skill-install.d.ts +4 -1
  39. package/dist/cli/commands/skill-install.d.ts.map +1 -1
  40. package/dist/cli/commands/skill-install.js +62 -5
  41. package/dist/cli/commands/skill-install.js.map +1 -1
  42. package/dist/cli/commands/task.d.ts.map +1 -1
  43. package/dist/cli/commands/task.js +128 -59
  44. package/dist/cli/commands/task.js.map +1 -1
  45. package/dist/cli/commands/tasks.d.ts.map +1 -1
  46. package/dist/cli/commands/tasks.js +2 -4
  47. package/dist/cli/commands/tasks.js.map +1 -1
  48. package/dist/cli/commands/triage.d.ts.map +1 -1
  49. package/dist/cli/commands/triage.js +12 -98
  50. package/dist/cli/commands/triage.js.map +1 -1
  51. package/dist/cli/index.d.ts.map +1 -1
  52. package/dist/cli/index.js +2 -1
  53. package/dist/cli/index.js.map +1 -1
  54. package/dist/cli/output.d.ts.map +1 -1
  55. package/dist/cli/output.js +18 -4
  56. package/dist/cli/output.js.map +1 -1
  57. package/dist/daemon/routes/triage.ts +4 -70
  58. package/dist/parser/config.d.ts +106 -0
  59. package/dist/parser/config.d.ts.map +1 -1
  60. package/dist/parser/config.js +47 -0
  61. package/dist/parser/config.js.map +1 -1
  62. package/dist/parser/file-lock.d.ts +14 -0
  63. package/dist/parser/file-lock.d.ts.map +1 -0
  64. package/dist/parser/file-lock.js +124 -0
  65. package/dist/parser/file-lock.js.map +1 -0
  66. package/dist/parser/index.d.ts +1 -0
  67. package/dist/parser/index.d.ts.map +1 -1
  68. package/dist/parser/index.js +1 -0
  69. package/dist/parser/index.js.map +1 -1
  70. package/dist/parser/plan-document.d.ts +44 -0
  71. package/dist/parser/plan-document.d.ts.map +1 -1
  72. package/dist/parser/plan-document.js +76 -8
  73. package/dist/parser/plan-document.js.map +1 -1
  74. package/dist/parser/plans.d.ts.map +1 -1
  75. package/dist/parser/plans.js +28 -102
  76. package/dist/parser/plans.js.map +1 -1
  77. package/dist/parser/shadow.d.ts.map +1 -1
  78. package/dist/parser/shadow.js +11 -7
  79. package/dist/parser/shadow.js.map +1 -1
  80. package/dist/parser/yaml.d.ts.map +1 -1
  81. package/dist/parser/yaml.js +322 -297
  82. package/dist/parser/yaml.js.map +1 -1
  83. package/dist/ralph/events.d.ts.map +1 -1
  84. package/dist/ralph/events.js +24 -0
  85. package/dist/ralph/events.js.map +1 -1
  86. package/dist/ralph/index.d.ts +1 -1
  87. package/dist/ralph/index.d.ts.map +1 -1
  88. package/dist/ralph/index.js +1 -1
  89. package/dist/ralph/index.js.map +1 -1
  90. package/dist/ralph/subagent.d.ts +12 -1
  91. package/dist/ralph/subagent.d.ts.map +1 -1
  92. package/dist/ralph/subagent.js +22 -3
  93. package/dist/ralph/subagent.js.map +1 -1
  94. package/dist/schema/batch.d.ts +2 -0
  95. package/dist/schema/batch.d.ts.map +1 -1
  96. package/dist/schema/common.d.ts +6 -0
  97. package/dist/schema/common.d.ts.map +1 -1
  98. package/dist/schema/common.js +8 -0
  99. package/dist/schema/common.js.map +1 -1
  100. package/dist/schema/task.d.ts +22 -0
  101. package/dist/schema/task.d.ts.map +1 -1
  102. package/dist/schema/task.js +7 -0
  103. package/dist/schema/task.js.map +1 -1
  104. package/dist/sessions/store.d.ts +226 -1
  105. package/dist/sessions/store.d.ts.map +1 -1
  106. package/dist/sessions/store.js +712 -38
  107. package/dist/sessions/store.js.map +1 -1
  108. package/dist/sessions/types.d.ts +51 -2
  109. package/dist/sessions/types.d.ts.map +1 -1
  110. package/dist/sessions/types.js +25 -0
  111. package/dist/sessions/types.js.map +1 -1
  112. package/dist/strings/errors.d.ts +4 -0
  113. package/dist/strings/errors.d.ts.map +1 -1
  114. package/dist/strings/errors.js +2 -0
  115. package/dist/strings/errors.js.map +1 -1
  116. package/dist/strings/labels.d.ts +2 -0
  117. package/dist/strings/labels.d.ts.map +1 -1
  118. package/dist/strings/labels.js +2 -0
  119. package/dist/strings/labels.js.map +1 -1
  120. package/dist/triage/actions.d.ts +27 -0
  121. package/dist/triage/actions.d.ts.map +1 -0
  122. package/dist/triage/actions.js +95 -0
  123. package/dist/triage/actions.js.map +1 -0
  124. package/dist/triage/constants.d.ts +6 -0
  125. package/dist/triage/constants.d.ts.map +1 -0
  126. package/dist/triage/constants.js +7 -0
  127. package/dist/triage/constants.js.map +1 -0
  128. package/dist/triage/index.d.ts +3 -0
  129. package/dist/triage/index.d.ts.map +1 -0
  130. package/dist/triage/index.js +3 -0
  131. package/dist/triage/index.js.map +1 -0
  132. package/dist/utils/git.d.ts +2 -0
  133. package/dist/utils/git.d.ts.map +1 -1
  134. package/dist/utils/git.js +21 -5
  135. package/dist/utils/git.js.map +1 -1
  136. package/package.json +1 -1
  137. package/plugin/.claude-plugin/marketplace.json +1 -1
  138. package/plugin/.claude-plugin/plugin.json +1 -1
  139. package/plugin/plugins/kspec/skills/create-workflow/SKILL.md +235 -0
  140. package/plugin/plugins/kspec/skills/observations/SKILL.md +143 -0
  141. package/plugin/plugins/kspec/skills/plan/SKILL.md +343 -0
  142. package/plugin/plugins/kspec/skills/reflect/SKILL.md +161 -0
  143. package/plugin/plugins/kspec/skills/review/SKILL.md +230 -0
  144. package/plugin/plugins/kspec/skills/task-work/SKILL.md +319 -0
  145. package/plugin/plugins/kspec/skills/triage-automation/SKILL.md +140 -0
  146. package/plugin/plugins/kspec/skills/triage-inbox/SKILL.md +232 -0
  147. package/plugin/plugins/kspec/skills/writing-specs/SKILL.md +354 -0
  148. package/templates/agents-sections/03-task-lifecycle.md +2 -2
  149. package/templates/agents-sections/04-pr-workflow.md +3 -3
  150. package/templates/agents-sections/05-commit-convention.md +14 -0
  151. package/templates/skills/create-workflow/SKILL.md +228 -0
  152. package/templates/skills/manifest.yaml +45 -0
  153. package/templates/skills/observations/SKILL.md +137 -0
  154. package/templates/skills/plan/SKILL.md +336 -0
  155. package/templates/skills/reflect/SKILL.md +155 -0
  156. package/templates/skills/review/SKILL.md +223 -0
  157. package/templates/skills/task-work/SKILL.md +312 -0
  158. package/templates/skills/triage-automation/SKILL.md +134 -0
  159. package/templates/skills/triage-inbox/SKILL.md +225 -0
  160. package/templates/skills/writing-specs/SKILL.md +347 -0
@@ -0,0 +1,347 @@
1
+ # Writing Specs
2
+
3
+ Create and maintain specification items — the source of truth for what to build. This skill covers spec structure, writing good acceptance criteria, using traits, and organizing specs in the hierarchy.
4
+
5
+ ## When to Use
6
+
7
+ - Creating a new feature, requirement, or constraint spec
8
+ - Adding or refining acceptance criteria
9
+ - Applying traits for cross-cutting behaviors
10
+ - Organizing specs under the right module/parent
11
+ - Reviewing spec quality before deriving tasks
12
+
13
+ **Not for:** Task management (use `/kspec:task-work`), plan-to-spec translation (use `/kspec:plan`), or triage (use `/kspec:triage`).
14
+
15
+ ## Finding Things
16
+
17
+ Use CLI commands to discover and inspect specs. **Do NOT search `.kspec/` YAML files manually.**
18
+
19
+ | Need | Command |
20
+ |------|---------|
21
+ | View spec + all ACs | `kspec item get @ref` |
22
+ | Search by keyword | `kspec search "keyword"` |
23
+ | List by type | `kspec item list --type feature` |
24
+ | All modules | `kspec item list --type module` |
25
+ | All traits | `kspec trait list` |
26
+ | Trait details + ACs | `kspec item get @trait-slug` |
27
+ | Items under a parent | `kspec item list --under @parent` |
28
+
29
+ ## Core Principles
30
+
31
+ 1. **Spec defines WHAT, not HOW** — Describe the desired behavior, not the implementation
32
+ 2. **Every spec needs AC** — A spec without acceptance criteria is incomplete
33
+ 3. **Given/When/Then is testable** — Each AC should map to at least one test
34
+ 4. **Traits eliminate duplication** — Cross-cutting concerns belong in traits, not copied across specs
35
+ 5. **Use CLI, not YAML** — All changes through `kspec` commands for auto-commit
36
+
37
+ ## Spec Hierarchy
38
+
39
+ Specs live in modules and form a tree:
40
+
41
+ ```
42
+ module (organizational grouping)
43
+ ├── feature (user-facing capability)
44
+ │ ├── requirement (specific testable behavior)
45
+ │ └── constraint (limitation or boundary)
46
+ ├── feature
47
+ │ └── requirement
48
+ └── decision (architectural choice, ADR-style)
49
+ ```
50
+
51
+ ### Choosing the Right Type
52
+
53
+ | Type | Use when | Example |
54
+ |------|----------|---------|
55
+ | `module` | Grouping related features | "CLI Commands", "Web UI", "Schema" |
56
+ | `feature` | User-facing capability | "JSON Export", "Inbox Triage", "Shadow Sync" |
57
+ | `requirement` | Specific testable behavior within a feature | "Export validates output format", "Triage records audit trail" |
58
+ | `constraint` | Non-functional limit or boundary | "Response time < 200ms", "Max 1000 items per module" |
59
+ | `decision` | Architectural choice with rationale | "Use YAML over JSON for spec files" |
60
+ | `trait` | Reusable AC bundle for cross-cutting behaviors | "JSON output mode", "Confirmation prompts" |
61
+
62
+ **Rule of thumb:** If it has acceptance criteria that a user could verify, it's a feature or requirement. If it constrains how something works, it's a constraint. If multiple specs need the same behavior, extract a trait.
63
+
64
+ ## Writing Acceptance Criteria
65
+
66
+ AC are the heart of a spec. They define what "done" means.
67
+
68
+ ### Format
69
+
70
+ ```
71
+ Given: precondition (state before the action)
72
+ When: action (what triggers the behavior)
73
+ Then: outcome (observable, verifiable result)
74
+ ```
75
+
76
+ ### Good AC Patterns
77
+
78
+ **Specific and testable:**
79
+ ```bash
80
+ kspec item ac add @json-export \
81
+ --given "user has 3 tasks in project" \
82
+ --when "user runs 'kspec tasks list --json'" \
83
+ --then "stdout contains valid JSON array with 3 task objects"
84
+ ```
85
+
86
+ **Covers error cases:**
87
+ ```bash
88
+ kspec item ac add @json-export \
89
+ --given "project has no tasks" \
90
+ --when "user runs 'kspec tasks list --json'" \
91
+ --then "stdout contains empty JSON array []"
92
+ ```
93
+
94
+ **Boundary behavior:**
95
+ ```bash
96
+ kspec item ac add @bulk-delete \
97
+ --given "user passes 50 refs (maximum supported)" \
98
+ --when "user runs bulk delete" \
99
+ --then "all 50 items deleted in single operation"
100
+ ```
101
+
102
+ ### AC Anti-patterns
103
+
104
+ | Anti-pattern | Problem | Better |
105
+ |-------------|---------|--------|
106
+ | "System works correctly" | Not testable | Describe specific observable outcome |
107
+ | "User is happy" | Subjective | Describe what they can do or see |
108
+ | "Fast performance" | Not measurable | "Response returns within 200ms" |
109
+ | "Handles errors" | Vague | Specific error scenario + expected behavior |
110
+ | Duplicating trait AC | Maintenance burden | Apply the trait instead |
111
+
112
+ ### AC Naming Convention
113
+
114
+ AC IDs are auto-generated (`ac-1`, `ac-2`, ...) or can be explicit:
115
+
116
+ ```bash
117
+ # Auto-generated
118
+ kspec item ac add @feature --given "..." --when "..." --then "..."
119
+
120
+ # Explicit ID for clarity
121
+ kspec item ac add @feature --id ac-json-valid --given "..." --when "..." --then "..."
122
+ ```
123
+
124
+ ### How Many ACs?
125
+
126
+ - **Minimum 1** — Every spec needs at least one
127
+ - **Typical: 2-5** — Happy path + key error cases
128
+ - **If 8+** — Consider splitting the spec into smaller requirements
129
+ - **Each AC = one behavior** — Don't combine multiple verifiable outcomes
130
+
131
+ ## Working with Traits
132
+
133
+ Traits are reusable bundles of acceptance criteria. When a spec implements a trait, it inherits all the trait's ACs.
134
+
135
+ ### When to Use Traits
136
+
137
+ Apply a trait when a spec needs a standard cross-cutting behavior:
138
+
139
+ ```bash
140
+ # Discover available traits
141
+ kspec trait list
142
+
143
+ # View trait details (shows ACs that will be inherited)
144
+ kspec trait get @trait-json-output
145
+
146
+ # Apply trait to spec
147
+ kspec item trait add @my-command @trait-json-output
148
+
149
+ # Apply multiple traits
150
+ kspec item trait add @my-command @trait-json-output @trait-dry-run
151
+ ```
152
+
153
+ ### Common Traits
154
+
155
+ | Trait | When to apply |
156
+ |-------|---------------|
157
+ | `@trait-json-output` | Command produces machine-readable output |
158
+ | `@trait-dry-run` | Command supports preview before execution |
159
+ | `@trait-confirmation-prompt` | Command is destructive |
160
+ | `@trait-filterable-list` | Command lists items with filter options |
161
+ | `@trait-shadow-commit` | Command modifies `.kspec/` data |
162
+ | `@trait-semantic-exit-codes` | Command exit code carries meaning |
163
+ | `@trait-error-guidance` | Command gives recovery suggestions on errors |
164
+ | `@trait-multi-ref-batch` | Command accepts multiple references |
165
+ | `@trait-priority-parameter` | Command accepts priority option |
166
+
167
+ ### Creating New Traits
168
+
169
+ If 3+ specs need the same behavior, consider extracting a trait:
170
+
171
+ ```bash
172
+ # Create the trait
173
+ kspec trait add "Pagination Support" --description "Commands that paginate large result sets" --slug trait-pagination
174
+
175
+ # Add ACs to the trait
176
+ kspec item ac add @trait-pagination --given "result set > page size" --when "command runs" --then "first page shown with pagination indicator"
177
+ kspec item ac add @trait-pagination --given "user requests next page" --when "user passes --page 2" --then "second page of results shown"
178
+ ```
179
+
180
+ ### Trait AC Coverage
181
+
182
+ When implementing specs with traits, all inherited ACs must be covered by tests:
183
+
184
+ ```javascript
185
+ // AC: @trait-json-output ac-1
186
+ it('should output valid JSON with --json flag', () => { ... });
187
+ ```
188
+
189
+ Run `kspec validate` to check for uncovered trait ACs.
190
+
191
+ ## Creating Specs
192
+
193
+ ### New Feature Under a Module
194
+
195
+ ```bash
196
+ # 1. Find the right parent module
197
+ kspec item list --type module
198
+
199
+ # 2. Create the feature
200
+ kspec item add --under @cli-module --title "Bulk Operations" --type feature --slug bulk-ops
201
+
202
+ # 3. Add description
203
+ kspec item set @bulk-ops --description "Support batch operations on multiple items in a single command"
204
+
205
+ # 4. Add acceptance criteria
206
+ kspec item ac add @bulk-ops \
207
+ --given "user provides 3 item refs" \
208
+ --when "user runs bulk delete" \
209
+ --then "all 3 items deleted and confirmation shown"
210
+
211
+ kspec item ac add @bulk-ops \
212
+ --given "one of 3 refs is invalid" \
213
+ --when "user runs bulk delete" \
214
+ --then "error reported for invalid ref, valid refs still processed"
215
+
216
+ # 5. Apply relevant traits
217
+ kspec item trait add @bulk-ops @trait-confirmation-prompt @trait-dry-run
218
+
219
+ # 6. Validate
220
+ kspec validate
221
+ ```
222
+
223
+ ### Requirement Under a Feature
224
+
225
+ ```bash
226
+ kspec item add --under @bulk-ops --title "Ref validation in batch mode" --type requirement --slug bulk-ref-validation
227
+ kspec item ac add @bulk-ref-validation \
228
+ --given "batch contains mix of valid and invalid refs" \
229
+ --when "batch executes" \
230
+ --then "report lists each ref with success/failure status"
231
+ ```
232
+
233
+ ### Updating Existing Specs
234
+
235
+ ```bash
236
+ # View current state
237
+ kspec item get @feature-slug
238
+
239
+ # Update description
240
+ kspec item set @feature-slug --description "Updated description"
241
+
242
+ # Add missing AC
243
+ kspec item ac add @feature-slug --given "..." --when "..." --then "..."
244
+
245
+ # Update existing AC
246
+ kspec item ac set @feature-slug ac-2 --then "updated expected outcome"
247
+
248
+ # Mark implementation status
249
+ kspec item set @feature-slug --status implemented
250
+
251
+ # Add relationships
252
+ kspec item set @feature-slug --depends-on @other-feature
253
+ kspec item set @feature-slug --relates-to @related-item
254
+ ```
255
+
256
+ ## Spec Quality Checklist
257
+
258
+ Before deriving a task from a spec, verify:
259
+
260
+ - [ ] **Description** — Explains what and why (not how)
261
+ - [ ] **AC coverage** — At least happy path + primary error case
262
+ - [ ] **AC testability** — Each AC maps to a concrete test
263
+ - [ ] **Traits applied** — Cross-cutting behaviors use traits, not duplicated AC
264
+ - [ ] **Correct parent** — Placed under the right module/feature
265
+ - [ ] **No implementation details** — AC describes behavior, not code structure
266
+ - [ ] **Validation passes** — `kspec validate` reports no errors for this item
267
+
268
+ ## Validation
269
+
270
+ ```bash
271
+ # Full validation
272
+ kspec validate
273
+
274
+ # Completeness check
275
+ kspec validate --completeness
276
+
277
+ # Spec-task alignment
278
+ kspec validate --alignment
279
+
280
+ # Strict mode (warnings → errors)
281
+ kspec validate --strict
282
+ ```
283
+
284
+ **Exit codes:** `0` = success, `4` = errors, `6` = warnings only.
285
+
286
+ Validation catches:
287
+ - Missing acceptance criteria
288
+ - Broken references (`@slug` pointing to nonexistent items)
289
+ - Missing descriptions
290
+ - Orphaned specs (no linked tasks)
291
+ - Uncovered trait ACs
292
+
293
+ ## Command Reference
294
+
295
+ ### Item Management
296
+
297
+ ```bash
298
+ kspec item list [--type <type>] # List items
299
+ kspec item get <ref> # Get item details with ACs and traits
300
+ kspec item add --under <parent> --title "..." --type <type> [--slug <slug>]
301
+ kspec item set <ref> --title "..." # Update fields
302
+ kspec item set <ref> --description "..."
303
+ kspec item set <ref> --status <status> # implementation status
304
+ kspec item set <ref> --depends-on <ref>
305
+ kspec item set <ref> --relates-to <ref>
306
+ kspec item patch <ref> --data '{...}' # Complex updates
307
+ kspec item delete <ref> [--force]
308
+ ```
309
+
310
+ ### Acceptance Criteria
311
+
312
+ ```bash
313
+ kspec item ac list <ref> # List ACs for item
314
+ kspec item ac add <ref> --given "..." --when "..." --then "..."
315
+ kspec item ac add <ref> --id <id> --given "..." --when "..." --then "..."
316
+ kspec item ac set <ref> <ac-id> --then "updated"
317
+ kspec item ac remove <ref> <ac-id> [--force]
318
+ ```
319
+
320
+ ### Traits
321
+
322
+ ```bash
323
+ kspec trait list # All traits with AC counts
324
+ kspec trait get <ref> # Trait details
325
+ kspec trait add "Name" --description "..." [--slug <slug>]
326
+ kspec item trait add <spec> <trait> [<trait2> ...]
327
+ kspec item trait remove <spec> <trait> [<trait2> ...]
328
+ ```
329
+
330
+ ### Deriving Tasks
331
+
332
+ Once a spec is ready, derive a task to track implementation:
333
+
334
+ ```bash
335
+ kspec derive @feature-slug # Create task linked to spec
336
+ kspec derive @feature-slug --priority 2
337
+ ```
338
+
339
+ The derived task gets `spec_ref: @feature-slug` automatically.
340
+
341
+ ## Integration
342
+
343
+ - **`/kspec:plan`** — Plans create specs via import or manual creation
344
+ - **`/kspec:task-work`** — Tasks reference specs; AC guides implementation
345
+ - **`/kspec:triage`** — Inbox items may reveal spec gaps
346
+ - **`/kspec:observations`** — Friction may indicate missing specs
347
+ - **`/kspec:review`** — Reviews check AC coverage