open-wiki-spec 0.3.0 → 0.4.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 (54) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +33 -2
  3. package/dist/cli/commands/init.d.ts +1 -1
  4. package/dist/cli/commands/init.d.ts.map +1 -1
  5. package/dist/cli/commands/init.js +14 -2
  6. package/dist/cli/commands/init.js.map +1 -1
  7. package/dist/cli/init/agents/agents-md.d.ts +24 -0
  8. package/dist/cli/init/agents/agents-md.d.ts.map +1 -0
  9. package/dist/cli/init/agents/agents-md.js +100 -0
  10. package/dist/cli/init/agents/agents-md.js.map +1 -0
  11. package/dist/cli/init/agents/claude.d.ts +12 -0
  12. package/dist/cli/init/agents/claude.d.ts.map +1 -0
  13. package/dist/cli/init/agents/claude.js +38 -0
  14. package/dist/cli/init/agents/claude.js.map +1 -0
  15. package/dist/cli/init/agents/codex.d.ts +15 -0
  16. package/dist/cli/init/agents/codex.d.ts.map +1 -0
  17. package/dist/cli/init/agents/codex.js +68 -0
  18. package/dist/cli/init/agents/codex.js.map +1 -0
  19. package/dist/cli/init/agents/detect.d.ts +19 -0
  20. package/dist/cli/init/agents/detect.d.ts.map +1 -0
  21. package/dist/cli/init/agents/detect.js +78 -0
  22. package/dist/cli/init/agents/detect.js.map +1 -0
  23. package/dist/cli/init/agents/index.d.ts +15 -0
  24. package/dist/cli/init/agents/index.d.ts.map +1 -0
  25. package/dist/cli/init/agents/index.js +22 -0
  26. package/dist/cli/init/agents/index.js.map +1 -0
  27. package/dist/cli/init/agents/transform.d.ts +10 -0
  28. package/dist/cli/init/agents/transform.d.ts.map +1 -0
  29. package/dist/cli/init/agents/transform.js +24 -0
  30. package/dist/cli/init/agents/transform.js.map +1 -0
  31. package/dist/cli/init/agents/types.d.ts +19 -0
  32. package/dist/cli/init/agents/types.d.ts.map +1 -0
  33. package/dist/cli/init/agents/types.js +2 -0
  34. package/dist/cli/init/agents/types.js.map +1 -0
  35. package/dist/cli/init/init-engine.d.ts.map +1 -1
  36. package/dist/cli/init/init-engine.js +16 -10
  37. package/dist/cli/init/init-engine.js.map +1 -1
  38. package/dist/cli/init/skill-generator.d.ts +11 -9
  39. package/dist/cli/init/skill-generator.d.ts.map +1 -1
  40. package/dist/cli/init/skill-generator.js +8 -988
  41. package/dist/cli/init/skill-generator.js.map +1 -1
  42. package/dist/cli/init/types.d.ts +8 -0
  43. package/dist/cli/init/types.d.ts.map +1 -1
  44. package/dist/cli/init/types.js +0 -3
  45. package/dist/cli/init/types.js.map +1 -1
  46. package/dist/cli/init/workflow-definitions.d.ts +15 -0
  47. package/dist/cli/init/workflow-definitions.d.ts.map +1 -0
  48. package/dist/cli/init/workflow-definitions.js +75 -0
  49. package/dist/cli/init/workflow-definitions.js.map +1 -0
  50. package/dist/core/embedding/embedder.d.ts +5 -1
  51. package/dist/core/embedding/embedder.d.ts.map +1 -1
  52. package/dist/core/embedding/embedder.js +5 -1
  53. package/dist/core/embedding/embedder.js.map +1 -1
  54. package/package.json +2 -1
@@ -1,993 +1,13 @@
1
- /**
2
- * Generates Claude Code skill files for ows workflows.
3
- */
4
- import * as fs from 'node:fs';
5
- import * as path from 'node:path';
6
- export const WORKFLOW_SKILLS = {
7
- propose: {
8
- name: 'ows-propose',
9
- description: 'Propose a new change to the codebase wiki.',
10
- instructions: `Run the open-wiki-spec propose workflow.
11
-
12
- **Input**: The argument after \`/ows-propose\` is a natural language description of what the user wants to build or change. If omitted, ask what they want to work on.
13
-
14
- **Steps**
15
-
16
- 1. **If no input provided, ask what they want to build**
17
-
18
- Ask the user to describe what they want to build or change in the codebase.
19
-
20
- **IMPORTANT**: Do NOT proceed without understanding what the user wants.
21
-
22
- 2. **If input is long natural language, refine it first**
23
-
24
- Extract the core from the user's input:
25
- - **intent**: add / modify / remove / query
26
- - **keywords**: 3-5 essential keywords (prioritize technical terms, feature names, system names)
27
- - **summary**: 1-sentence summary
28
-
29
- Example: "우리 앱에서 워치랑 연동해서 수영 기록을 자동으로 가져오는데 HealthKit에서 데이터를 못 가져오는 케이스가 있어서 그걸 Sentry로 추적하고 싶거든"
30
- → summary: "HealthKit 워치 동기화 실패 Sentry 추적"
31
- → keywords: "워치 동기화,HealthKit,Sentry,에러 추적"
32
-
33
- 3. **Run preflight retrieval (dry-run first)**
34
- \`\`\`bash
35
- ows propose "<summary>" --keywords "<keyword1>,<keyword2>,..." --dry-run --json
36
- \`\`\`
37
- If the user's input is already concise, skip \`--keywords\` and use the input directly:
38
- \`\`\`bash
39
- ows propose "<user's description>" --dry-run --json
40
- \`\`\`
41
- Parse the JSON output to understand:
42
- - \`retrieval.classification\`: one of \`existing_change\`, \`existing_feature\`, \`new_feature\`, \`needs_confirmation\`
43
- - \`retrieval.confidence\`: \`high\`, \`medium\`, or \`low\`
44
- - \`retrieval.candidates\`: scored candidate list with scores and match reasons
45
- - \`classification.primary_candidate\`: the top matching note
46
- - \`sequencing_warnings\`: any parallel work conflicts
47
-
48
- 4. **Act based on classification**
49
-
50
- ---
51
-
52
- **If \`needs_confirmation\`**: Show the top candidates with their scores and match reasons. Ask the user to choose:
53
- - Which existing Feature to attach to, OR
54
- - Which existing Change to continue, OR
55
- - Create a new Feature + Change
56
-
57
- **If \`existing_feature\`**: Show which Feature matched and why. Confirm with the user before creating a new Change attached to it.
58
-
59
- **If \`existing_change\`**: Show the matching active Change. Suggest continuing it instead of creating a new one. Offer \`/ows-continue\` as next step.
60
-
61
- **If \`new_feature\`**: Confirm with the user that nothing similar exists and proceed.
62
-
63
- ---
64
-
65
- 5. **Execute the propose (if confirmed)**
66
-
67
- **IMPORTANT**: Use the same \`--keywords\` from the dry-run step to ensure consistent retrieval results.
68
-
69
- For \`new_feature\` or \`existing_feature\` classification, run directly:
70
- \`\`\`bash
71
- ows propose "<summary>" --keywords "<keyword1>,<keyword2>,..." --json
72
- \`\`\`
73
-
74
- For \`needs_confirmation\` (after user chooses), use \`--force-classification\` AND \`--force-target\`:
75
- \`\`\`bash
76
- # User chose to create new Feature + Change:
77
- ows propose "<summary>" --force-classification new_feature --json
78
- # User chose an existing Feature (use the candidate id from dry-run):
79
- ows propose "<summary>" --force-classification existing_feature --force-target "<candidate-id>" --json
80
- # User chose to continue an existing Change (hand off to continue):
81
- /ows-continue <candidate-change-id>
82
- \`\`\`
83
- **IMPORTANT**: When user picks \`existing_feature\` or \`existing_change\`, always include \`--force-target <id>\` with the candidate's actual id from the dry-run results. Without it, the engine uses the top candidate which may not be what the user chose.
84
-
85
- 6. **Show results**
86
-
87
- Display:
88
- - Classification decision and reasoning
89
- - Created/updated Change note path and ID
90
- - Linked Feature note (if applicable)
91
- - Next step: "Run \`/ows-continue <changeId>\` to fill in Change sections."
92
-
93
- **Output**
94
-
95
- After completing, summarize:
96
- - What was created or updated
97
- - Why (classification reasoning from retrieval)
98
- - What to do next
99
-
100
- **Retrieval Quality**
101
-
102
- The propose workflow automatically enriches the query with system_terms by matching feature/entity terms against System note titles and aliases in the vault index. This means:
103
- - System-related queries like "auth login" will auto-detect System notes titled "Authentication" and use them for scoring
104
- - Partial title matches are supported: a search for "auth" will match "Feature: Auth Login" (partial match, +20 points)
105
- - Title prefix stripping: "auth login" matches "Feature: Auth Login" (prefix-stripped match, +30 points)
106
- - Derived aliases are auto-generated from note titles and IDs, improving alias-based matching even when no explicit aliases are set
107
-
108
- **Guardrails**
109
- - Always show dry-run results before creating anything
110
- - If classification is \`needs_confirmation\`, NEVER auto-decide — always ask the user
111
- - If \`sequencing_warnings\` are present, show them prominently before proceeding
112
- - If confidence is \`low\`, warn the user that results may be inaccurate`,
113
- },
114
- continue: {
115
- name: 'ows-continue',
116
- description: 'Continue work on an existing Change.',
117
- instructions: `Continue working on an existing Change by filling sections or advancing status.
118
-
119
- **Input**: Optionally specify a change ID after \`/ows-continue\` (e.g., \`/ows-continue change-add-auth\`). If omitted and only one active change exists, it is auto-selected. If multiple active changes exist, the CLI returns a list and the agent must ask the user to choose.
120
-
121
- **Steps**
122
-
123
- 1. **If no change ID provided**
124
-
125
- Run \`ows continue --json\`. The CLI will:
126
- - **If 1 active change**: auto-select it and proceed.
127
- - **If 2+ active changes**: return an error with the list of active changes. Show them and let the user pick, then re-run with the chosen ID.
128
- - **If 0 active changes**: return an error. Suggest \`/ows-propose\` to create one.
129
-
130
- **IMPORTANT**: When the CLI returns multiple active changes, NEVER auto-select. Always ask the user.
131
-
132
- 2. **Check current status**
133
- \`\`\`bash
134
- ows status <changeId> --json
135
- \`\`\`
136
- Parse the JSON to understand:
137
- - Current status (proposed, planned, in_progress, applied)
138
- - Section completeness (which sections are filled vs empty)
139
- - Task progress (N/M done)
140
- - \`nextAction\`: what should be done next (see all 7 types below)
141
-
142
- 3. **Act based on nextAction**
143
-
144
- The nextAction algorithm returns one of 7 deterministic action types based on current status and section/task state:
145
-
146
- ---
147
-
148
- **If \`fill_section\`** (status: proposed): A required section is missing. Help the user write the missing section content. Read the Change note, identify what's missing, and draft content. Required sections for planned transition: Why, Delta Summary, Tasks, Validation.
149
-
150
- **If \`transition\`** (status: proposed -> planned): All required sections are filled. Run \`ows continue <changeId> --json\` to advance the status from proposed to planned.
151
-
152
- **If \`blocked\`** (status: planned): The Change has unresolved \`depends_on\` entries. Show blocking dependencies (change IDs that are not yet applied) and help resolve them.
153
-
154
- **If \`start_implementation\`** (status: planned -> in_progress): Dependencies are resolved and tasks exist. The CLI will auto-transition to in_progress. Show the first unchecked task and help the user begin implementing.
155
-
156
- **If \`continue_task\`** (status: in_progress): Show the next unchecked task and help the user work through it.
157
-
158
- **If \`ready_to_apply\`** (status: in_progress): All tasks are complete. Suggest running \`/ows-apply <changeId>\` to apply the Change to canonical Feature notes. Do NOT attempt to transition status here -- the apply workflow owns the in_progress -> applied transition.
159
-
160
- **If \`verify_then_archive\`** (status: applied): The Change has been applied. Suggest running \`/ows-verify\` and then archiving.
161
-
162
- ---
163
-
164
- 4. **After each action, show updated status**
165
- \`\`\`bash
166
- ows status <changeId>
167
- \`\`\`
168
-
169
- **Output**
170
-
171
- After each invocation, show:
172
- - Current status and what changed
173
- - Section/task progress
174
- - What to do next
175
-
176
- **Context Enrichment**
177
-
178
- The continue result includes a \`context\` object with real content from linked notes (truncated at 500 chars per section):
179
- - \`context.features[]\`: Purpose, Current Behavior, Requirements sections from linked Feature notes
180
- - \`context.decisions[]\`: Summary, Context, Decision sections from linked Decision notes
181
- - \`context.systems[]\`: Purpose, Boundaries sections from linked System notes
182
- - \`context.sources[]\`: Summary, Content sections from linked Source notes
183
-
184
- Use this context to inform section writing (especially Why and Delta Summary).
185
-
186
- **Guardrails**
187
- - Perform ONE section fill or ONE status transition per invocation
188
- - Always read the Change note before modifying it
189
- - Use the \`context\` from the continue result to inform your writing — do not ignore linked note content
190
- - If context is unclear, ask the user before writing
191
- - Show status after every change
192
- - The continue workflow owns proposed->planned and planned->in_progress transitions ONLY
193
- - The in_progress->applied transition is owned exclusively by the apply workflow`,
194
- },
195
- apply: {
196
- name: 'ows-apply',
197
- description: 'Apply a Change to canonical Feature notes.',
198
- instructions: `Apply a completed Change to canonical Feature notes, updating the wiki's current state.
199
-
200
- **Input**: Specify a change ID after \`/ows-apply\` (e.g., \`/ows-apply change-add-auth\`). The change ID is **required** by the CLI. If the user does not provide one, run \`ows list --json\` and let them choose from changes with status \`in_progress\`.
201
-
202
- **Prerequisites**: The CLI enforces these before applying:
203
- - Change status MUST be \`in_progress\` (use \`/ows-continue\` to advance if needed)
204
- - ALL tasks in the Change note must be checked (\`[x]\`)
205
-
206
- **Available flags**:
207
- - \`--json\`: Output structured JSON result
208
- - \`--dry-run\`: Validate without writing any files (use this to preview)
209
- - \`--force-stale\`: Apply even when stale base fingerprints are detected
210
- - \`--no-auto-transition\`: Keep status as \`in_progress\` after writing (use when ADDED/MODIFIED markers need manual content before finalizing)
211
- - \`--no-log\`: Skip appending to \`wiki/00-meta/log.md\`
212
-
213
- **Steps**
214
-
215
- 1. **If no change ID provided, prompt for selection**
216
-
217
- Run \`ows list --json\` to get applicable changes. Show only changes with status \`in_progress\`.
218
-
219
- **IMPORTANT**: Do NOT guess or auto-select. Always let the user choose.
220
-
221
- 2. **Preview with dry-run first**
222
- \`\`\`bash
223
- ows apply <changeId> --dry-run --json
224
- \`\`\`
225
- Parse the result to check for stale entries or validation errors before committing.
226
-
227
- 3. **Handle dry-run results**
228
-
229
- ---
230
-
231
- **If stale_base detected** (\`staleReport.blocked: true\`): Show which Feature requirements have changed since the Change was created (base fingerprint mismatch). Ask the user how to resolve:
232
- - Re-run with \`--force-stale\` to apply anyway
233
- - Update the Change's Delta Summary to reflect current state
234
- - Abort and investigate
235
-
236
- **If validation errors**: Show pre-validation errors (e.g., ADDED requirement already exists, MODIFIED requirement not found). These must be fixed in the Change note.
237
-
238
- **If clean**: Proceed to actual apply.
239
-
240
- ---
241
-
242
- 4. **Execute the apply (if confirmed)**
243
-
244
- **CRITICAL: If the Change has ADDED or MODIFIED operations, use \`--no-auto-transition\` on the first apply** so the status stays in \`in_progress\` until you've filled in the marker contents. Example:
245
- \`\`\`bash
246
- # First apply: insert markers without transitioning to applied
247
- ows apply <changeId> --no-auto-transition --json
248
- \`\`\`
249
- Without this flag, the change will transition to \`applied\` while the Feature note still contains unfilled \`<!-- ADDED ... -->\` marker comments, and \`ows verify\` will then report \`UNFILLED_APPLY_MARKER\` errors.
250
-
251
- For changes with ONLY programmatic ops (RENAMED/REMOVED), a single plain apply is fine:
252
- \`\`\`bash
253
- ows apply <changeId> --json
254
- \`\`\`
255
-
256
- The apply uses a **two-phase commit** pattern:
257
- - **Phase 1** (validate & compute): Parse Delta Summary, stale-check all entries, pre-validate operations. No files written.
258
- - **Phase 2** (write): Only if Phase 1 passes. Apply operations in **atomic order**: RENAMED -> REMOVED -> MODIFIED -> ADDED.
259
-
260
- The apply engine programmatically modifies Feature notes:
261
- - **RENAMED**: Automatically renames the requirement in the Feature note. Fully automated.
262
- - **REMOVED**: Automatically removes the requirement from the Feature note. Fully automated.
263
- - **MODIFIED**: Inserts a \`<!-- MODIFIED by change: <changeId> -->\` marker after the requirement heading. The agent must then update the requirement text.
264
- - **ADDED**: Inserts a \`<!-- ADDED by change: <changeId>. Fill in normative statement (SHALL/MUST) and scenarios (WHEN/THEN). -->\` marker in the Requirements section. The agent must then write the new requirement content.
265
-
266
- 5. **Fill marker contents (if using --no-auto-transition)**
267
-
268
- Open each Feature note listed in \`result.modifiedFiles\`, find the \`<!-- ADDED ... -->\` and \`<!-- MODIFIED ... -->\` marker comments, and replace them with real requirement text (SHALL/MUST normative + WHEN/THEN scenarios). Then remove the marker comment itself.
269
-
270
- 6. **Finalize apply**
271
- \`\`\`bash
272
- # Second apply: now that markers are filled, transition to applied
273
- ows apply <changeId> --json
274
- \`\`\`
275
-
276
- 7. **Show final state**
277
- \`\`\`bash
278
- ows status <changeId>
279
- \`\`\`
280
-
281
- **Output On Success**
282
-
283
- \`\`\`
284
- ## Apply Complete
285
-
286
- **Change:** <changeId>
287
- **Status:** applied
288
-
289
- ### Updated Features
290
- - Feature: Auth Login — updated Requirements section
291
- - Feature: User Profile — added new requirement
292
-
293
- The canonical wiki state now reflects this change.
294
- \`\`\`
295
-
296
- **Guardrails**
297
- - The change ID is required -- always ensure one is provided before calling \`ows apply\`
298
- - Always dry-run first to catch stale entries and validation errors
299
- - If stale_base is detected, NEVER auto-resolve -- always ask the user
300
- - Show a clear diff of what will change in each Feature before applying
301
- - After apply, suggest archiving if appropriate
302
- - Only the apply workflow can transition a Change from in_progress to applied`,
303
- },
304
- verify: {
305
- name: 'ows-verify',
306
- description: 'Verify vault consistency.',
307
- instructions: `Verify vault consistency across multiple dimensions.
308
-
309
- **Input**: Optionally specify a change ID after \`/ows-verify\` to verify a specific change. If omitted, verify the entire vault.
310
-
311
- **Available flags**:
312
- - \`--json\`: Output structured JSON result
313
- - \`--strict\`: Treat warnings as errors (both errors and warnings must be zero for pass)
314
-
315
- **Steps**
316
-
317
- 1. **Run verification**
318
- \`\`\`bash
319
- ows verify --json
320
- # or for a specific change:
321
- ows verify <changeId> --json
322
- # strict mode:
323
- ows verify --strict --json
324
- \`\`\`
325
-
326
- 2. **Parse the VerifyReport**
327
-
328
- The report includes \`pass\` (boolean), \`total_notes\`, \`issues\` array, and a \`summary\` object with counts per dimension. The four verification dimensions are:
329
-
330
- - **completeness**: Required sections present, feature/change section coverage, minimum headings
331
- - **correctness**: Status lifecycle validity, stale base detection, operation validation matrix, schema version match, drift detection
332
- - **coherence**: Parallel change conflict detection (via sequencing engine), description consistency, decision consistency, depends_on integrity
333
- - **vault_integrity**: Duplicate IDs, missing IDs, unresolved wikilinks, ambiguous aliases, orphan notes, archive placement, invalid frontmatter types
334
-
335
- Each issue in the \`issues\` array has:
336
- - \`dimension\`: one of the four dimensions above
337
- - \`severity\`: \`error\`, \`warning\`, or \`info\`
338
- - \`code\`: machine-readable issue code (e.g., \`DUPLICATE_ID\`, \`STALE_BASE\`)
339
- - \`message\`: human-readable description
340
- - \`note_path\`: file path of the affected note (use for navigation)
341
- - \`note_id\`: ID of the affected note
342
- - \`suggestion\`: recommended fix
343
-
344
- 3. **Present results**
345
-
346
- **If pass**:
347
- \`\`\`
348
- ## Vault Verification: PASS
349
- No issues found across N notes.
350
- \`\`\`
351
-
352
- **If issues found**:
353
- Show errors first, then warnings, then info. Group by dimension for clarity:
354
-
355
- \`\`\`
356
- ## Vault Verification: FAIL
357
-
358
- ### Errors (must fix)
359
- - [vault_integrity] Feature: Auth Login — missing required "id" in frontmatter
360
- - [vault_integrity] Change: Add Passkey — wikilink [[Feature: Auth]] does not resolve
361
- - [correctness] Change: Add Auth — stale base detected for Feature: User Profile
362
-
363
- ### Warnings (should fix)
364
- - [vault_integrity] Ambiguous alias "login" matches 2 notes
365
- - [coherence] Changes "add-auth" and "fix-login" both touch Feature: Auth Login
366
-
367
- ### Info
368
- - [coherence] Active Feature "auth" references archived Decision "use-jwt"
369
- \`\`\`
370
-
371
- For each issue, include the \`suggestion\` field and \`note_path\` from the report.
372
-
373
- **Guardrails**
374
- - Always show the full report, don't summarize away issues
375
- - Present errors before warnings before info
376
- - Include file paths (\`note_path\`) so the user can navigate to issues
377
- - If verification fails, suggest specific fixes for each issue
378
- - Use \`--strict\` when preparing for release or archiving`,
379
- },
380
- query: {
381
- name: 'ows-query',
382
- description: 'Search the vault graph and optionally create a Query note.',
383
- instructions: `Search the vault knowledge graph to answer questions or find related notes.
384
-
385
- **Input**: The argument after \`/ows-query\` is a natural language question (e.g., \`/ows-query "how does authentication work?"\`).
386
-
387
- **Steps**
388
-
389
- 1. **Run the query**
390
- \`\`\`bash
391
- ows query "<question>" --json
392
- \`\`\`
393
-
394
- 2. **Parse the result**
395
-
396
- The JSON output includes:
397
- - \`searchResult\`: scored candidates from the vault graph
398
- - \`contextDocument\`: a synthesized context document built from matching notes
399
- - \`assessment\`: whether a Query note should be created (\`shouldCreate\`, \`confidence\`, \`reasons\`)
400
-
401
- 3. **Present findings**
402
-
403
- Show the context document and top matching notes:
404
- - Note title, type, score, and match reasons
405
- - Relevant sections from each matching note
406
- - Links to related notes for further exploration
407
-
408
- 4. **If assessment recommends note creation**
409
-
410
- Ask the user if they want to save the findings as a Query note:
411
- > "This query surfaced enough novel findings to be worth saving. Create a Query note?"
412
-
413
- If yes:
414
- \`\`\`bash
415
- ows query "<question>" --json --save
416
- \`\`\`
417
-
418
- 5. **Offer next steps**
419
-
420
- Based on findings, suggest:
421
- - Reading specific vault notes for deeper context
422
- - Running \`/ows-propose\` if the query reveals work to be done
423
- - Running \`/ows-query\` with a more specific question
424
-
425
- **Guardrails**
426
- - Always show match reasons so the user understands WHY notes were surfaced
427
- - Don't auto-save Query notes — always ask the user first
428
- - If no candidates found, suggest refining the question or checking vault content`,
429
- },
430
- status: {
431
- name: 'ows-status',
432
- description: 'Show the current state of a Change.',
433
- instructions: `Show the current state and progress of a Change.
434
-
435
- **Input**: Optionally specify a change ID after \`/ows-status\` (e.g., \`/ows-status change-add-auth\`). If omitted, show all active changes.
436
-
437
- **Steps**
438
-
439
- 1. **If change ID provided**:
440
- \`\`\`bash
441
- ows status <changeId> --json
442
- \`\`\`
443
-
444
- The JSON output includes:
445
- - \`changeId\`: the change's ID
446
- - \`status\`: one of \`proposed\`, \`planned\`, \`in_progress\`, \`applied\`, \`archived\`
447
- - \`features\`: linked Feature IDs
448
- - \`sectionCompleteness\`: \`{ why, deltaSummary, tasks, validation, designApproach? }\`
449
- - \`taskProgress\`: \`{ total, completed }\`
450
- - \`nextAction\`: the recommended next step (see below)
451
- - \`blockedBy\`: array of blocking change IDs
452
-
453
- **nextAction types** (deterministic based on status and progress):
454
- - \`fill_section\` (proposed): A required section is missing. \`target\` names the section.
455
- - \`transition\` (proposed): All sections filled. \`to\` is the target status (planned).
456
- - \`start_implementation\` (planned): Ready to begin implementing.
457
- - \`continue_task\` (in_progress): Tasks remain. \`target\` is the next task description.
458
- - \`blocked\` (any): \`blockers\` lists the blocking change IDs.
459
- - \`ready_to_apply\` (in_progress): All tasks complete. Suggest \`/ows-apply\`.
460
- - \`verify_then_archive\` (applied): Change applied. Suggest \`/ows-verify\` then archiving.
461
-
462
- 2. **If no change ID (list all)**:
463
- \`\`\`bash
464
- ows list --json
465
- \`\`\`
466
-
467
- Show a summary table of all active changes:
468
- \`\`\`
469
- | Change ID | Status | Tasks | Next Action |
470
- |---------------------|-------------|-------|---------------------|
471
- | change-add-auth | in_progress | 3/7 | continue_task |
472
- | change-fix-routing | proposed | 0/0 | fill_section |
473
- | change-add-passkey | in_progress | 5/5 | ready_to_apply |
474
- | change-old-refactor | applied | 4/4 | verify_then_archive |
475
- \`\`\`
476
-
477
- **Guardrails**
478
- - Show actionable next steps, not just raw status
479
- - If blocked, explain what is blocking and suggest resolution
480
- - For \`ready_to_apply\`, suggest \`/ows-apply <changeId>\`
481
- - For \`verify_then_archive\`, suggest \`/ows-verify\` followed by \`ows archive <changeId>\``,
482
- },
483
- retrieve: {
484
- name: 'ows-retrieve',
485
- description: 'Run a standalone retrieval scan against the vault graph (retrieval subagent).',
486
- instructions: `Run the open-wiki-spec retrieval subagent.
487
-
488
- This skill is the **retrieval subagent** described in overview.md section 9.3. It delegates vault similarity scan to \`ows propose --dry-run --json\`, which runs the full retrieval pipeline (lexical retrieval, graph expansion, scoring, classification) without creating or modifying any notes.
489
-
490
- **Input**: The argument after \`/ows-retrieve\` is a natural language description of what the user wants to find or check against the vault.
491
-
492
- **When to use**:
493
- - Before proposing a change, to check what already exists in the vault
494
- - To answer "is there already a Feature/Change for X?" without side effects
495
- - As a preflight check before any vault-modifying workflow
496
- - When you need structured search results for decision-making
497
-
498
- **Steps**
499
-
500
- 1. **Run retrieval (dry-run)**
501
- \`\`\`bash
502
- ows propose "<user's description>" --dry-run --json
503
- \`\`\`
504
-
505
- 2. **Parse the JSON output**
506
-
507
- The key fields are:
508
- - \`retrieval.classification\`: one of \`existing_change\`, \`existing_feature\`, \`new_feature\`, \`needs_confirmation\`
509
- - \`retrieval.confidence\`: \`high\`, \`medium\`, or \`low\`
510
- - \`retrieval.candidates\`: scored candidate list with \`id\`, \`type\`, \`title\`, \`score\`, \`reasons\`
511
- - \`retrieval.warnings\`: any index quality warnings
512
- - \`retrieval.sequencing\`: parallel safety and related change info (\`status\`: \`parallel_safe\`, \`needs_review\`, \`conflict_candidate\`, \`conflict_critical\`, or \`blocked\`)
513
-
514
- 3. **Present results to user**
515
-
516
- Show a summary table of top candidates:
517
- \`\`\`
518
- ## Retrieval Results: "<query>"
519
-
520
- Classification: existing_feature (confidence: high)
521
-
522
- | # | Note | Type | Score | Key Reasons |
523
- |---|----------------------------|---------|-------|--------------------------------|
524
- | 1 | Feature: Auth Login | feature | 87 | alias match, same system |
525
- | 2 | Change: Improve Auth UX | change | 61 | active overlap, shared source |
526
- \`\`\`
527
-
528
- Then explain the classification:
529
- - \`existing_feature\`: A matching Feature already exists. Attach new work to it.
530
- - \`existing_change\`: An active Change with the same purpose exists. Continue it instead of creating a new one.
531
- - \`new_feature\`: Nothing similar found. Safe to create new Feature + Change.
532
- - \`needs_confirmation\`: Ambiguous results. Show candidates and ask for user choice.
533
-
534
- 4. **Suggest next steps**
535
-
536
- Based on classification:
537
- - \`existing_feature\` / \`new_feature\`: "Run \`/ows-propose\` to create the Change."
538
- - \`existing_change\`: "Run \`/ows-continue <changeId>\` to continue the existing Change."
539
- - \`needs_confirmation\`: "Which of these candidates is the right match?"
540
-
541
- **Contract**:
542
- - **Input**: natural language description (same as \`ows propose\`)
543
- - **Output**: structured ProposeResult JSON (in dry-run mode) with \`action\`, \`retrieval\`, \`classification\`, \`target_change\`, \`target_feature\`, \`prerequisites\`, \`transitioned_to_planned\`, \`sequencing_warnings\`
544
- - **Side effects**: NONE (dry-run mode)
545
-
546
- **Example**:
547
- \`\`\`bash
548
- ows propose "add passkey login support" --dry-run --json
549
- \`\`\`
550
-
551
- Output (abbreviated):
552
- \`\`\`json
553
- {
554
- "action": "created_change",
555
- "retrieval": {
556
- "query": "add passkey login support",
557
- "classification": "existing_feature",
558
- "confidence": "high",
559
- "candidates": [
560
- { "id": "feature-auth-login", "type": "feature", "title": "Feature: Auth Login", "score": 87, "reasons": ["alias match: login", "same system: authentication"] }
561
- ],
562
- "sequencing": { "status": "parallel_safe", "related_changes": [], "reasons": [] },
563
- "warnings": []
564
- },
565
- "classification": {
566
- "classification": "existing_feature",
567
- "confidence": "high",
568
- "primary_candidate": { "id": "feature-auth-login", "type": "feature", "title": "Feature: Auth Login", "score": 87 },
569
- "secondary_candidate": null,
570
- "reasons": ["alias match: login", "same system: authentication"]
571
- },
572
- "target_change": null,
573
- "target_feature": null,
574
- "prerequisites": null,
575
- "transitioned_to_planned": false,
576
- "sequencing_warnings": []
577
- }
578
- \`\`\`
579
-
580
- **Guardrails**
581
- - This is READ-ONLY — never create or modify vault notes
582
- - Always show match reasons so the user can verify the classification
583
- - If confidence is \`low\`, explicitly warn the user
584
- - If warnings are present, show them prominently
585
- - If \`sequencing.status\` is not \`parallel_safe\`, warn about potential conflicts with active Changes`,
586
- },
587
- archive: {
588
- name: 'ows-archive',
589
- description: 'Archive an applied Change to 99-archive/.',
590
- instructions: `Archive a completed Change, moving it from the active changes directory to 99-archive/.
591
-
592
- **Input**: Specify a change ID after \`/ows-archive\` (e.g., \`/ows-archive change-add-auth\`). The change ID is **required** by the CLI. If the user does not provide one, run \`ows list --json\` and let them choose from changes with status \`applied\`.
593
-
594
- **Prerequisites**: The CLI enforces that only \`applied\` changes can be archived. If the change is not applied, guide the user through \`/ows-apply\` first.
595
-
596
- **Available flags**:
597
- - \`--json\`: Output structured JSON result
598
- - \`--force\`: Archive even if verify finds errors
599
-
600
- **Steps**
601
-
602
- 1. **If no change ID provided, prompt for selection**
603
-
604
- Run \`ows list --json\` to get changes. Show only changes with status \`applied\`.
605
-
606
- **IMPORTANT**: Do NOT guess or auto-select. Always let the user choose.
607
-
608
- 2. **Verify before archiving**
609
-
610
- The archive command automatically runs \`ows verify\` on the change before archiving. If verify finds errors, the archive will fail unless \`--force\` is used.
611
-
612
- Suggest running \`/ows-verify <changeId>\` first so the user can review issues.
613
-
614
- 3. **Execute the archive**
615
- \`\`\`bash
616
- ows archive <changeId> --json
617
- \`\`\`
618
-
619
- 4. **Handle results**
620
-
621
- ---
622
-
623
- **If successful**: Show the old and new paths.
624
-
625
- **If verify failed**: Show the verify errors and ask the user:
626
- - Fix the issues and retry
627
- - Force archive with \`ows archive <changeId> --force --json\`
628
-
629
- ---
630
-
631
- **Output On Success**
632
-
633
- \`\`\`
634
- ## Archive Complete
635
-
636
- **Change:** <changeId>
637
- **From:** wiki/04-changes/<filename>.md
638
- **To:** wiki/99-archive/<filename>.md
639
-
640
- The change has been archived. Decision history is preserved.
641
- \`\`\`
642
-
643
- **Guardrails**
644
- - Only applied changes can be archived
645
- - Always show verify results before forcing an archive
646
- - If verify fails, explain the issues before offering --force
647
- - After archiving, the change is no longer active in the vault`,
648
- },
649
- init: {
650
- name: 'ows-init',
651
- description: 'Initialize a new open-wiki-spec vault.',
652
- instructions: `Initialize a new open-wiki-spec vault in the current project or a specified path.
653
-
654
- **Input**: Optionally specify a target path after \`/ows-init\` (e.g., \`/ows-init ./my-project\`). If omitted, initializes in the current working directory.
655
-
656
- **Available flags**:
657
- - \`--json\`: Output structured JSON result
658
- - \`--force\`: Force re-initialization, recreating meta files even if they exist
659
- - \`--skip-seed\`: Skip creating seed notes (source and system placeholders)
660
-
661
- **Steps**
662
-
663
- 1. **Run initialization**
664
- \`\`\`bash
665
- ows init --json
666
- # or with a path:
667
- ows init <path> --json
668
- # force re-init:
669
- ows init --force --json
670
- # skip seed notes:
671
- ows init --skip-seed --json
672
- \`\`\`
673
-
674
- 2. **Parse the result**
675
-
676
- The JSON output includes:
677
- - \`mode\`: \`fresh\` (new vault) or \`extend\` (existing directory)
678
- - \`wikiPath\`: path to the created wiki directory
679
- - \`directoriesCreated\`: list of directories created
680
- - \`metaFilesCreated\`: list of meta files created (log.md, index, etc.)
681
- - \`seedFilesCreated\`: list of seed notes created (Source and System placeholders)
682
- - \`skillFilesGenerated\`: list of Claude Code skill files generated
683
- - \`warnings\`: any warnings during initialization
684
-
685
- 3. **Present results**
686
-
687
- **If fresh init**:
688
- \`\`\`
689
- ## Vault Initialized
690
-
691
- Created new vault at: <wikiPath>
692
- - N directories created
693
- - N meta files created
694
- - N seed notes created
695
- - N skill files generated
696
-
697
- Next steps:
698
- 1. Edit \`wiki/01-sources/seed-context.md\` to describe your project (stack, constraints, goals)
699
- 2. Edit \`wiki/02-systems/default-system.md\` to define your primary system boundary
700
- 3. Run \`/ows-propose\` to create your first Change
701
- \`\`\`
702
-
703
- **If extend** (existing directory):
704
- \`\`\`
705
- ## Vault Extended
706
-
707
- Extended existing vault at: <wikiPath>
708
- - N new directories added
709
- - N meta files updated
710
-
711
- Your existing notes are preserved. Seed notes are not overwritten.
712
- \`\`\`
713
-
714
- **Seed Notes**
715
-
716
- On fresh init, two seed notes are created:
717
- - \`wiki/01-sources/seed-context.md\` — A placeholder Source note for the user to fill with project context (tech stack, goals, constraints)
718
- - \`wiki/02-systems/default-system.md\` — A default System note for the user to define their primary system boundary
719
-
720
- In extend mode, existing seed notes are never overwritten. Use \`--skip-seed\` to skip seed creation entirely.
721
-
722
- **Guardrails**
723
- - If the vault already exists and --force is not used, the init will extend rather than overwrite
724
- - Never destroy existing vault content
725
- - Encourage the user to edit seed-context.md after init — it improves retrieval quality
726
- - Show warnings if any files were skipped`,
727
- },
728
- explore: {
729
- name: 'ows-explore',
730
- description: 'Enter exploration mode — investigate the codebase without implementing.',
731
- instructions: `Enter thinking/exploration mode. Investigate the codebase, architecture, and existing behavior without making any code changes.
732
-
733
- **Input**: The argument after \`/ows-explore\` is a topic, question, or area to investigate (e.g., \`/ows-explore "how does the auth flow work?"\`).
734
-
735
- **Purpose**: This is a safe space to investigate before committing to any plan. Unlike \`/ows-propose\`, this does NOT create any vault notes or changes. Use this to build understanding before proposing work.
736
-
737
- **Steps**
738
-
739
- 1. **Understand the investigation scope**
740
-
741
- Parse the user's question and identify:
742
- - What system/feature area is involved
743
- - What kind of answer is needed (architecture overview, data flow, bug root cause, etc.)
744
- - What files/modules are likely relevant
745
-
746
- 2. **Search the vault for existing knowledge**
747
- \`\`\`bash
748
- ows query "<topic>" --json
749
- \`\`\`
750
- Check if the vault already has relevant Feature, System, Decision, or Query notes.
751
-
752
- 3. **Explore the codebase**
753
-
754
- Read code, trace call paths, examine data flows. Use whatever tools are available:
755
- - File reading and search
756
- - Symbol navigation
757
- - Dependency tracing
758
- - Architecture visualization (ASCII diagrams)
759
-
760
- 4. **Document findings**
761
-
762
- Present findings with:
763
- - Architecture diagrams (ASCII) where helpful
764
- - Key files and their roles
765
- - Data flow descriptions
766
- - Relevant existing vault notes
767
- - Questions that remain unanswered
768
-
769
- 5. **Suggest next steps**
770
-
771
- Based on findings:
772
- - "This is well-understood. No action needed."
773
- - "Consider creating a Decision note to record this rationale."
774
- - "This reveals work to do. Run \`/ows-propose\` to formalize it."
775
- - "Save these findings as a Query note? Run \`ows query '<topic>' --save\`"
776
-
777
- **Rules**
778
- - **NO code changes** — this is read-only investigation
779
- - **NO vault modifications** — don't create notes (suggest it, but don't do it)
780
- - **Be thorough** — read actual code, don't guess from file names
781
- - **Visualize** — use ASCII diagrams for architecture, data flows, component relationships
782
- - **Connect to vault** — reference existing vault notes when relevant
783
- - **Capture for later** — if findings are substantial, suggest saving as a Query note`,
784
- },
785
- onboard: {
786
- name: 'ows-onboard',
787
- description: 'Guided tutorial for first-time open-wiki-spec users.',
788
- instructions: `Guide a first-time user through a complete open-wiki-spec cycle using their actual codebase.
789
-
790
- **Purpose**: Help new users learn ows by doing — not by reading docs. Walk them through a real (small) cycle from propose to archive.
791
-
792
- **Steps**
793
-
794
- 1. **Check vault state**
795
- \`\`\`bash
796
- ows list --json
797
- ows verify --json
798
- \`\`\`
799
- Determine if the vault is freshly initialized or already has content.
800
-
801
- 2. **Explain the vault structure**
802
-
803
- Give a quick orientation:
804
- \`\`\`
805
- wiki/
806
- 00-meta/ — Vault metadata and conventions
807
- 01-sources/ — External references (PRDs, docs)
808
- 02-systems/ — System/component boundaries
809
- 03-features/ — Feature specifications (the "what is")
810
- 04-changes/ — Active work units (the "what's changing")
811
- 05-decisions/ — Design decisions and rationale
812
- 06-queries/ — Investigation notes
813
- 99-archive/ — Completed changes
814
- \`\`\`
815
-
816
- 3. **Pick a small real task**
817
-
818
- Help the user identify a small, concrete task from their project:
819
- - A simple feature addition
820
- - A bug fix
821
- - A small refactor
822
-
823
- The task should be completable in ~15 minutes. Ask the user what they'd like to work on.
824
-
825
- 4. **Walk through the full cycle**
826
-
827
- Guide the user step by step (pausing for confirmation at each stage):
828
-
829
- **a. Propose** (\`/ows-propose\`)
830
- - Show how retrieval scans for existing work
831
- - Explain the classification result
832
- - Create the Feature + Change notes
833
-
834
- **b. Fill sections** (\`/ows-continue\`)
835
- - Help write the Why section
836
- - Help write the Delta Summary
837
- - Help write Tasks
838
- - Help write Validation
839
- - Show the proposed → planned transition
840
-
841
- **c. Implement** (\`/ows-continue\`)
842
- - Work through the tasks
843
- - Show how tasks are tracked
844
-
845
- **d. Apply** (\`/ows-apply\`)
846
- - Show how the Feature note gets updated
847
- - Explain the two-phase commit
848
-
849
- **e. Verify** (\`/ows-verify\`)
850
- - Run the 4-dimension check
851
- - Explain what each dimension means
852
-
853
- **f. Archive** (\`/ows-archive\`)
854
- - Move the completed change
855
- - Show the clean state
856
-
857
- 5. **Wrap up**
858
-
859
- Summarize what they learned:
860
- - 6 note types and their purposes
861
- - The lifecycle: propose → plan → implement → apply → verify → archive
862
- - Key commands they'll use daily
863
- - Where to find help (README, \`/ows-status\`, \`/ows-query\`)
864
-
865
- **Guardrails**
866
- - Pause after EACH major step for user confirmation
867
- - Keep explanations concise — show, don't lecture
868
- - Use the user's actual project, not hypothetical examples
869
- - If the user gets confused, simplify — don't add complexity
870
- - The goal is confidence, not completeness`,
871
- },
872
- migrate: {
873
- name: 'ows-migrate',
874
- description: 'Migrate an existing OpenSpec project to open-wiki-spec format.',
875
- instructions: `Migrate an existing OpenSpec project to open-wiki-spec format.
876
-
877
- This converts an OpenSpec directory structure (\`openspec/changes/\`, \`openspec/specs/\`) to the open-wiki-spec flat wiki format (\`wiki/\`).
878
-
879
- **Input**: Optionally specify the OpenSpec directory path after \`/ows-migrate\`. If omitted, the CLI will auto-detect \`openspec/\` in the current directory.
880
-
881
- **Available flags**:
882
- - \`--json\`: Output structured JSON result
883
- - \`--dry-run\`: Show what would be migrated without writing files
884
- - \`--skip-archive\`: Skip migrating archived changes
885
-
886
- **Steps**
887
-
888
- 1. **Always dry-run first**
889
- \`\`\`bash
890
- ows migrate --dry-run --json
891
- # or with explicit path:
892
- ows migrate <openspec-dir> --dry-run --json
893
- \`\`\`
894
-
895
- 2. **Parse the migration plan**
896
-
897
- The dry-run returns a plan with:
898
- - \`openspecPath\`: detected OpenSpec source directory
899
- - \`wikiPath\`: target wiki directory
900
- - \`steps\`: list of migration steps, each with:
901
- - \`name\`: step name
902
- - \`description\`: what it does
903
- - \`outputs\`: files to create (with \`targetPath\` and \`sourceDescription\`)
904
- - \`warnings\`: any issues detected
905
- - \`totalFiles\`: total files to create
906
- - \`totalWarnings\`: total warning count
907
-
908
- 3. **Show the plan to the user**
909
-
910
- Present a summary of what will be migrated:
911
- \`\`\`
912
- ## Migration Plan
913
-
914
- **Source:** openspec/
915
- **Target:** wiki/
916
-
917
- Files to create: N
918
- Warnings: M
919
-
920
- ### Steps
921
- 1. <step name> - <description> (N files)
922
- 2. ...
923
- \`\`\`
924
-
925
- If there are warnings, show them prominently.
926
- Ask the user to confirm before proceeding.
927
-
928
- 4. **Execute migration (if confirmed)**
929
- \`\`\`bash
930
- ows migrate --json
931
- \`\`\`
932
-
933
- 5. **Show results**
934
-
935
- Display:
936
- - Files written
937
- - Files skipped (already exist)
938
- - Errors (if any)
939
- - Warnings
940
-
941
- Suggest running \`/ows-verify\` after migration to check vault consistency.
942
-
943
- **Guardrails**
944
- - Always dry-run before migrating
945
- - Never overwrite existing files in the target wiki directory
946
- - Show all warnings before proceeding
947
- - After migration, suggest running \`/ows-verify\` to validate the result`,
948
- },
949
- };
950
- /**
951
- * Generate a skill markdown file.
952
- */
1
+ import { WORKFLOW_DEFINITIONS } from './workflow-definitions.js';
2
+ import { ClaudeAdapter } from './agents/claude.js';
3
+ /** Legacy keyed map: { propose: {name, description, instructions}, ... } */
4
+ export const WORKFLOW_SKILLS = Object.fromEntries(WORKFLOW_DEFINITIONS.map((d) => [d.key, { name: d.name, description: d.description, instructions: d.body }]));
5
+ /** Legacy single-file renderer (Claude frontmatter + body). */
953
6
  export function generateSkillFile(skillDef) {
954
- return `---
955
- name: ${skillDef.name}
956
- description: ${skillDef.description}
957
- ---
958
-
959
- ${skillDef.instructions}
960
- `;
7
+ return `---\nname: ${skillDef.name}\ndescription: ${skillDef.description}\n---\n\n${skillDef.instructions}\n`;
961
8
  }
962
- /**
963
- * Write all skill files to the Claude Code commands directory.
964
- * If a user has customized an existing skill file (contents differ from the
965
- * previously-generated version), back it up before overwriting so users
966
- * never lose their customizations.
967
- */
9
+ /** Legacy writer — delegates to ClaudeAdapter (identical output). */
968
10
  export function writeAllSkillFiles(projectPath) {
969
- const claudeDir = path.join(projectPath, '.claude', 'commands');
970
- fs.mkdirSync(claudeDir, { recursive: true });
971
- const generated = [];
972
- for (const [workflowName, skillDef] of Object.entries(WORKFLOW_SKILLS)) {
973
- const skillPath = path.join(claudeDir, `ows-${workflowName}.md`);
974
- const newContent = generateSkillFile(skillDef);
975
- // If file exists and differs from what we're about to write, back it up
976
- if (fs.existsSync(skillPath)) {
977
- try {
978
- const existingContent = fs.readFileSync(skillPath, 'utf-8');
979
- if (existingContent !== newContent) {
980
- const backupPath = `${skillPath}.bak`;
981
- fs.writeFileSync(backupPath, existingContent);
982
- }
983
- }
984
- catch {
985
- // Best-effort backup — don't block init if read fails
986
- }
987
- }
988
- fs.writeFileSync(skillPath, newContent);
989
- generated.push(skillPath);
990
- }
991
- return generated;
11
+ return new ClaudeAdapter().writeAll(projectPath, WORKFLOW_DEFINITIONS);
992
12
  }
993
13
  //# sourceMappingURL=skill-generator.js.map