@synth-coder/memhub 0.2.1 → 0.2.3

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 (71) hide show
  1. package/.eslintrc.cjs +45 -45
  2. package/.factory/commands/opsx-apply.md +150 -0
  3. package/.factory/commands/opsx-archive.md +155 -0
  4. package/.factory/commands/opsx-explore.md +171 -0
  5. package/.factory/commands/opsx-propose.md +104 -0
  6. package/.factory/skills/openspec-apply-change/SKILL.md +156 -0
  7. package/.factory/skills/openspec-archive-change/SKILL.md +114 -0
  8. package/.factory/skills/openspec-explore/SKILL.md +288 -0
  9. package/.factory/skills/openspec-propose/SKILL.md +110 -0
  10. package/.github/workflows/ci.yml +74 -74
  11. package/.iflow/commands/opsx-apply.md +152 -152
  12. package/.iflow/commands/opsx-archive.md +157 -157
  13. package/.iflow/commands/opsx-explore.md +173 -173
  14. package/.iflow/commands/opsx-propose.md +106 -106
  15. package/.iflow/skills/openspec-apply-change/SKILL.md +156 -156
  16. package/.iflow/skills/openspec-archive-change/SKILL.md +114 -114
  17. package/.iflow/skills/openspec-explore/SKILL.md +288 -288
  18. package/.iflow/skills/openspec-propose/SKILL.md +110 -110
  19. package/.prettierrc +11 -11
  20. package/AGENTS.md +169 -26
  21. package/README.md +195 -195
  22. package/README.zh-CN.md +193 -193
  23. package/dist/src/contracts/mcp.js +34 -34
  24. package/dist/src/server/mcp-server.d.ts +8 -0
  25. package/dist/src/server/mcp-server.d.ts.map +1 -1
  26. package/dist/src/server/mcp-server.js +23 -2
  27. package/dist/src/server/mcp-server.js.map +1 -1
  28. package/dist/src/services/memory-service.d.ts +1 -0
  29. package/dist/src/services/memory-service.d.ts.map +1 -1
  30. package/dist/src/services/memory-service.js +125 -82
  31. package/dist/src/services/memory-service.js.map +1 -1
  32. package/docs/architecture-diagrams.md +368 -0
  33. package/docs/architecture.md +381 -349
  34. package/docs/contracts.md +190 -119
  35. package/docs/prompt-template.md +33 -79
  36. package/docs/proposals/mcp-typescript-sdk-refactor.md +568 -568
  37. package/docs/proposals/proposal-close-gates.md +58 -58
  38. package/docs/tool-calling-policy.md +101 -107
  39. package/docs/vector-search.md +306 -0
  40. package/package.json +59 -58
  41. package/src/contracts/index.ts +12 -12
  42. package/src/contracts/mcp.ts +222 -222
  43. package/src/contracts/schemas.ts +307 -307
  44. package/src/contracts/types.ts +410 -410
  45. package/src/index.ts +8 -8
  46. package/src/server/index.ts +5 -5
  47. package/src/server/mcp-server.ts +185 -161
  48. package/src/services/embedding-service.ts +114 -114
  49. package/src/services/index.ts +5 -5
  50. package/src/services/memory-service.ts +663 -621
  51. package/src/storage/frontmatter-parser.ts +243 -243
  52. package/src/storage/index.ts +6 -6
  53. package/src/storage/markdown-storage.ts +236 -236
  54. package/src/storage/vector-index.ts +160 -160
  55. package/src/utils/index.ts +5 -5
  56. package/src/utils/slugify.ts +63 -63
  57. package/test/contracts/schemas.test.ts +313 -313
  58. package/test/contracts/types.test.ts +21 -21
  59. package/test/frontmatter-parser-more.test.ts +94 -94
  60. package/test/server/mcp-server.test.ts +210 -169
  61. package/test/services/memory-service-edge.test.ts +248 -248
  62. package/test/services/memory-service.test.ts +278 -278
  63. package/test/storage/frontmatter-parser.test.ts +222 -222
  64. package/test/storage/markdown-storage.test.ts +216 -216
  65. package/test/storage/storage-edge.test.ts +238 -238
  66. package/test/storage/vector-index.test.ts +153 -153
  67. package/test/utils/slugify-edge.test.ts +94 -94
  68. package/test/utils/slugify.test.ts +68 -68
  69. package/tsconfig.json +25 -25
  70. package/tsconfig.test.json +8 -8
  71. package/vitest.config.ts +29 -29
@@ -1,157 +1,157 @@
1
- ---
2
- name: /opsx-archive
3
- id: opsx-archive
4
- category: Workflow
5
- description: Archive a completed change in the experimental workflow
6
- ---
7
-
8
- Archive a completed change in the experimental workflow.
9
-
10
- **Input**: Optionally specify a change name after `/opsx:archive` (e.g., `/opsx:archive add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
11
-
12
- **Steps**
13
-
14
- 1. **If no change name provided, prompt for selection**
15
-
16
- Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
17
-
18
- Show only active changes (not already archived).
19
- Include the schema used for each change if available.
20
-
21
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
22
-
23
- 2. **Check artifact completion status**
24
-
25
- Run `openspec status --change "<name>" --json` to check artifact completion.
26
-
27
- Parse the JSON to understand:
28
- - `schemaName`: The workflow being used
29
- - `artifacts`: List of artifacts with their status (`done` or other)
30
-
31
- **If any artifacts are not `done`:**
32
- - Display warning listing incomplete artifacts
33
- - Prompt user for confirmation to continue
34
- - Proceed if user confirms
35
-
36
- 3. **Check task completion status**
37
-
38
- Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
39
-
40
- Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
41
-
42
- **If incomplete tasks found:**
43
- - Display warning showing count of incomplete tasks
44
- - Prompt user for confirmation to continue
45
- - Proceed if user confirms
46
-
47
- **If no tasks file exists:** Proceed without task-related warning.
48
-
49
- 4. **Assess delta spec sync state**
50
-
51
- Check for delta specs at `openspec/changes/<name>/specs/`. If none exist, proceed without sync prompt.
52
-
53
- **If delta specs exist:**
54
- - Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
55
- - Determine what changes would be applied (adds, modifications, removals, renames)
56
- - Show a combined summary before prompting
57
-
58
- **Prompt options:**
59
- - If changes needed: "Sync now (recommended)", "Archive without syncing"
60
- - If already synced: "Archive now", "Sync anyway", "Cancel"
61
-
62
- If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change '<name>'. Delta spec analysis: <include the analyzed delta spec summary>"). Proceed to archive regardless of choice.
63
-
64
- 5. **Perform the archive**
65
-
66
- Create the archive directory if it doesn't exist:
67
- ```bash
68
- mkdir -p openspec/changes/archive
69
- ```
70
-
71
- Generate target name using current date: `YYYY-MM-DD-<change-name>`
72
-
73
- **Check if target already exists:**
74
- - If yes: Fail with error, suggest renaming existing archive or using different date
75
- - If no: Move the change directory to archive
76
-
77
- ```bash
78
- mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
79
- ```
80
-
81
- 6. **Display summary**
82
-
83
- Show archive completion summary including:
84
- - Change name
85
- - Schema that was used
86
- - Archive location
87
- - Spec sync status (synced / sync skipped / no delta specs)
88
- - Note about any warnings (incomplete artifacts/tasks)
89
-
90
- **Output On Success**
91
-
92
- ```
93
- ## Archive Complete
94
-
95
- **Change:** <change-name>
96
- **Schema:** <schema-name>
97
- **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
98
- **Specs:** ✓ Synced to main specs
99
-
100
- All artifacts complete. All tasks complete.
101
- ```
102
-
103
- **Output On Success (No Delta Specs)**
104
-
105
- ```
106
- ## Archive Complete
107
-
108
- **Change:** <change-name>
109
- **Schema:** <schema-name>
110
- **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
111
- **Specs:** No delta specs
112
-
113
- All artifacts complete. All tasks complete.
114
- ```
115
-
116
- **Output On Success With Warnings**
117
-
118
- ```
119
- ## Archive Complete (with warnings)
120
-
121
- **Change:** <change-name>
122
- **Schema:** <schema-name>
123
- **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
124
- **Specs:** Sync skipped (user chose to skip)
125
-
126
- **Warnings:**
127
- - Archived with 2 incomplete artifacts
128
- - Archived with 3 incomplete tasks
129
- - Delta spec sync was skipped (user chose to skip)
130
-
131
- Review the archive if this was not intentional.
132
- ```
133
-
134
- **Output On Error (Archive Exists)**
135
-
136
- ```
137
- ## Archive Failed
138
-
139
- **Change:** <change-name>
140
- **Target:** openspec/changes/archive/YYYY-MM-DD-<name>/
141
-
142
- Target archive directory already exists.
143
-
144
- **Options:**
145
- 1. Rename the existing archive
146
- 2. Delete the existing archive if it's a duplicate
147
- 3. Wait until a different date to archive
148
- ```
149
-
150
- **Guardrails**
151
- - Always prompt for change selection if not provided
152
- - Use artifact graph (openspec status --json) for completion checking
153
- - Don't block archive on warnings - just inform and confirm
154
- - Preserve .openspec.yaml when moving to archive (it moves with the directory)
155
- - Show clear summary of what happened
156
- - If sync is requested, use the Skill tool to invoke `openspec-sync-specs` (agent-driven)
157
- - If delta specs exist, always run the sync assessment and show the combined summary before prompting
1
+ ---
2
+ name: /opsx-archive
3
+ id: opsx-archive
4
+ category: Workflow
5
+ description: Archive a completed change in the experimental workflow
6
+ ---
7
+
8
+ Archive a completed change in the experimental workflow.
9
+
10
+ **Input**: Optionally specify a change name after `/opsx:archive` (e.g., `/opsx:archive add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
11
+
12
+ **Steps**
13
+
14
+ 1. **If no change name provided, prompt for selection**
15
+
16
+ Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
17
+
18
+ Show only active changes (not already archived).
19
+ Include the schema used for each change if available.
20
+
21
+ **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
22
+
23
+ 2. **Check artifact completion status**
24
+
25
+ Run `openspec status --change "<name>" --json` to check artifact completion.
26
+
27
+ Parse the JSON to understand:
28
+ - `schemaName`: The workflow being used
29
+ - `artifacts`: List of artifacts with their status (`done` or other)
30
+
31
+ **If any artifacts are not `done`:**
32
+ - Display warning listing incomplete artifacts
33
+ - Prompt user for confirmation to continue
34
+ - Proceed if user confirms
35
+
36
+ 3. **Check task completion status**
37
+
38
+ Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
39
+
40
+ Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
41
+
42
+ **If incomplete tasks found:**
43
+ - Display warning showing count of incomplete tasks
44
+ - Prompt user for confirmation to continue
45
+ - Proceed if user confirms
46
+
47
+ **If no tasks file exists:** Proceed without task-related warning.
48
+
49
+ 4. **Assess delta spec sync state**
50
+
51
+ Check for delta specs at `openspec/changes/<name>/specs/`. If none exist, proceed without sync prompt.
52
+
53
+ **If delta specs exist:**
54
+ - Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
55
+ - Determine what changes would be applied (adds, modifications, removals, renames)
56
+ - Show a combined summary before prompting
57
+
58
+ **Prompt options:**
59
+ - If changes needed: "Sync now (recommended)", "Archive without syncing"
60
+ - If already synced: "Archive now", "Sync anyway", "Cancel"
61
+
62
+ If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change '<name>'. Delta spec analysis: <include the analyzed delta spec summary>"). Proceed to archive regardless of choice.
63
+
64
+ 5. **Perform the archive**
65
+
66
+ Create the archive directory if it doesn't exist:
67
+ ```bash
68
+ mkdir -p openspec/changes/archive
69
+ ```
70
+
71
+ Generate target name using current date: `YYYY-MM-DD-<change-name>`
72
+
73
+ **Check if target already exists:**
74
+ - If yes: Fail with error, suggest renaming existing archive or using different date
75
+ - If no: Move the change directory to archive
76
+
77
+ ```bash
78
+ mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
79
+ ```
80
+
81
+ 6. **Display summary**
82
+
83
+ Show archive completion summary including:
84
+ - Change name
85
+ - Schema that was used
86
+ - Archive location
87
+ - Spec sync status (synced / sync skipped / no delta specs)
88
+ - Note about any warnings (incomplete artifacts/tasks)
89
+
90
+ **Output On Success**
91
+
92
+ ```
93
+ ## Archive Complete
94
+
95
+ **Change:** <change-name>
96
+ **Schema:** <schema-name>
97
+ **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
98
+ **Specs:** ✓ Synced to main specs
99
+
100
+ All artifacts complete. All tasks complete.
101
+ ```
102
+
103
+ **Output On Success (No Delta Specs)**
104
+
105
+ ```
106
+ ## Archive Complete
107
+
108
+ **Change:** <change-name>
109
+ **Schema:** <schema-name>
110
+ **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
111
+ **Specs:** No delta specs
112
+
113
+ All artifacts complete. All tasks complete.
114
+ ```
115
+
116
+ **Output On Success With Warnings**
117
+
118
+ ```
119
+ ## Archive Complete (with warnings)
120
+
121
+ **Change:** <change-name>
122
+ **Schema:** <schema-name>
123
+ **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
124
+ **Specs:** Sync skipped (user chose to skip)
125
+
126
+ **Warnings:**
127
+ - Archived with 2 incomplete artifacts
128
+ - Archived with 3 incomplete tasks
129
+ - Delta spec sync was skipped (user chose to skip)
130
+
131
+ Review the archive if this was not intentional.
132
+ ```
133
+
134
+ **Output On Error (Archive Exists)**
135
+
136
+ ```
137
+ ## Archive Failed
138
+
139
+ **Change:** <change-name>
140
+ **Target:** openspec/changes/archive/YYYY-MM-DD-<name>/
141
+
142
+ Target archive directory already exists.
143
+
144
+ **Options:**
145
+ 1. Rename the existing archive
146
+ 2. Delete the existing archive if it's a duplicate
147
+ 3. Wait until a different date to archive
148
+ ```
149
+
150
+ **Guardrails**
151
+ - Always prompt for change selection if not provided
152
+ - Use artifact graph (openspec status --json) for completion checking
153
+ - Don't block archive on warnings - just inform and confirm
154
+ - Preserve .openspec.yaml when moving to archive (it moves with the directory)
155
+ - Show clear summary of what happened
156
+ - If sync is requested, use the Skill tool to invoke `openspec-sync-specs` (agent-driven)
157
+ - If delta specs exist, always run the sync assessment and show the combined summary before prompting
@@ -1,173 +1,173 @@
1
- ---
2
- name: /opsx-explore
3
- id: opsx-explore
4
- category: Workflow
5
- description: Enter explore mode - think through ideas, investigate problems, clarify requirements
6
- ---
7
-
8
- Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
9
-
10
- **IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first and create a change proposal. You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing.
11
-
12
- **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore.
13
-
14
- **Input**: The argument after `/opsx:explore` is whatever the user wants to think about. Could be:
15
- - A vague idea: "real-time collaboration"
16
- - A specific problem: "the auth system is getting unwieldy"
17
- - A change name: "add-dark-mode" (to explore in context of that change)
18
- - A comparison: "postgres vs sqlite for this"
19
- - Nothing (just enter explore mode)
20
-
21
- ---
22
-
23
- ## The Stance
24
-
25
- - **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
26
- - **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
27
- - **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
28
- - **Adaptive** - Follow interesting threads, pivot when new information emerges
29
- - **Patient** - Don't rush to conclusions, let the shape of the problem emerge
30
- - **Grounded** - Explore the actual codebase when relevant, don't just theorize
31
-
32
- ---
33
-
34
- ## What You Might Do
35
-
36
- Depending on what the user brings, you might:
37
-
38
- **Explore the problem space**
39
- - Ask clarifying questions that emerge from what they said
40
- - Challenge assumptions
41
- - Reframe the problem
42
- - Find analogies
43
-
44
- **Investigate the codebase**
45
- - Map existing architecture relevant to the discussion
46
- - Find integration points
47
- - Identify patterns already in use
48
- - Surface hidden complexity
49
-
50
- **Compare options**
51
- - Brainstorm multiple approaches
52
- - Build comparison tables
53
- - Sketch tradeoffs
54
- - Recommend a path (if asked)
55
-
56
- **Visualize**
57
- ```
58
- ┌─────────────────────────────────────────┐
59
- │ Use ASCII diagrams liberally │
60
- ├─────────────────────────────────────────┤
61
- │ │
62
- │ ┌────────┐ ┌────────┐ │
63
- │ │ State │────────▶│ State │ │
64
- │ │ A │ │ B │ │
65
- │ └────────┘ └────────┘ │
66
- │ │
67
- │ System diagrams, state machines, │
68
- │ data flows, architecture sketches, │
69
- │ dependency graphs, comparison tables │
70
- │ │
71
- └─────────────────────────────────────────┘
72
- ```
73
-
74
- **Surface risks and unknowns**
75
- - Identify what could go wrong
76
- - Find gaps in understanding
77
- - Suggest spikes or investigations
78
-
79
- ---
80
-
81
- ## OpenSpec Awareness
82
-
83
- You have full context of the OpenSpec system. Use it naturally, don't force it.
84
-
85
- ### Check for context
86
-
87
- At the start, quickly check what exists:
88
- ```bash
89
- openspec list --json
90
- ```
91
-
92
- This tells you:
93
- - If there are active changes
94
- - Their names, schemas, and status
95
- - What the user might be working on
96
-
97
- If the user mentioned a specific change name, read its artifacts for context.
98
-
99
- ### When no change exists
100
-
101
- Think freely. When insights crystallize, you might offer:
102
-
103
- - "This feels solid enough to start a change. Want me to create a proposal?"
104
- - Or keep exploring - no pressure to formalize
105
-
106
- ### When a change exists
107
-
108
- If the user mentions a change or you detect one is relevant:
109
-
110
- 1. **Read existing artifacts for context**
111
- - `openspec/changes/<name>/proposal.md`
112
- - `openspec/changes/<name>/design.md`
113
- - `openspec/changes/<name>/tasks.md`
114
- - etc.
115
-
116
- 2. **Reference them naturally in conversation**
117
- - "Your design mentions using Redis, but we just realized SQLite fits better..."
118
- - "The proposal scopes this to premium users, but we're now thinking everyone..."
119
-
120
- 3. **Offer to capture when decisions are made**
121
-
122
- | Insight Type | Where to Capture |
123
- |--------------|------------------|
124
- | New requirement discovered | `specs/<capability>/spec.md` |
125
- | Requirement changed | `specs/<capability>/spec.md` |
126
- | Design decision made | `design.md` |
127
- | Scope changed | `proposal.md` |
128
- | New work identified | `tasks.md` |
129
- | Assumption invalidated | Relevant artifact |
130
-
131
- Example offers:
132
- - "That's a design decision. Capture it in design.md?"
133
- - "This is a new requirement. Add it to specs?"
134
- - "This changes scope. Update the proposal?"
135
-
136
- 4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
137
-
138
- ---
139
-
140
- ## What You Don't Have To Do
141
-
142
- - Follow a script
143
- - Ask the same questions every time
144
- - Produce a specific artifact
145
- - Reach a conclusion
146
- - Stay on topic if a tangent is valuable
147
- - Be brief (this is thinking time)
148
-
149
- ---
150
-
151
- ## Ending Discovery
152
-
153
- There's no required ending. Discovery might:
154
-
155
- - **Flow into a proposal**: "Ready to start? I can create a change proposal."
156
- - **Result in artifact updates**: "Updated design.md with these decisions"
157
- - **Just provide clarity**: User has what they need, moves on
158
- - **Continue later**: "We can pick this up anytime"
159
-
160
- When things crystallize, you might offer a summary - but it's optional. Sometimes the thinking IS the value.
161
-
162
- ---
163
-
164
- ## Guardrails
165
-
166
- - **Don't implement** - Never write code or implement features. Creating OpenSpec artifacts is fine, writing application code is not.
167
- - **Don't fake understanding** - If something is unclear, dig deeper
168
- - **Don't rush** - Discovery is thinking time, not task time
169
- - **Don't force structure** - Let patterns emerge naturally
170
- - **Don't auto-capture** - Offer to save insights, don't just do it
171
- - **Do visualize** - A good diagram is worth many paragraphs
172
- - **Do explore the codebase** - Ground discussions in reality
173
- - **Do question assumptions** - Including the user's and your own
1
+ ---
2
+ name: /opsx-explore
3
+ id: opsx-explore
4
+ category: Workflow
5
+ description: Enter explore mode - think through ideas, investigate problems, clarify requirements
6
+ ---
7
+
8
+ Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
9
+
10
+ **IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first and create a change proposal. You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing.
11
+
12
+ **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore.
13
+
14
+ **Input**: The argument after `/opsx:explore` is whatever the user wants to think about. Could be:
15
+ - A vague idea: "real-time collaboration"
16
+ - A specific problem: "the auth system is getting unwieldy"
17
+ - A change name: "add-dark-mode" (to explore in context of that change)
18
+ - A comparison: "postgres vs sqlite for this"
19
+ - Nothing (just enter explore mode)
20
+
21
+ ---
22
+
23
+ ## The Stance
24
+
25
+ - **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
26
+ - **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
27
+ - **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
28
+ - **Adaptive** - Follow interesting threads, pivot when new information emerges
29
+ - **Patient** - Don't rush to conclusions, let the shape of the problem emerge
30
+ - **Grounded** - Explore the actual codebase when relevant, don't just theorize
31
+
32
+ ---
33
+
34
+ ## What You Might Do
35
+
36
+ Depending on what the user brings, you might:
37
+
38
+ **Explore the problem space**
39
+ - Ask clarifying questions that emerge from what they said
40
+ - Challenge assumptions
41
+ - Reframe the problem
42
+ - Find analogies
43
+
44
+ **Investigate the codebase**
45
+ - Map existing architecture relevant to the discussion
46
+ - Find integration points
47
+ - Identify patterns already in use
48
+ - Surface hidden complexity
49
+
50
+ **Compare options**
51
+ - Brainstorm multiple approaches
52
+ - Build comparison tables
53
+ - Sketch tradeoffs
54
+ - Recommend a path (if asked)
55
+
56
+ **Visualize**
57
+ ```
58
+ ┌─────────────────────────────────────────┐
59
+ │ Use ASCII diagrams liberally │
60
+ ├─────────────────────────────────────────┤
61
+ │ │
62
+ │ ┌────────┐ ┌────────┐ │
63
+ │ │ State │────────▶│ State │ │
64
+ │ │ A │ │ B │ │
65
+ │ └────────┘ └────────┘ │
66
+ │ │
67
+ │ System diagrams, state machines, │
68
+ │ data flows, architecture sketches, │
69
+ │ dependency graphs, comparison tables │
70
+ │ │
71
+ └─────────────────────────────────────────┘
72
+ ```
73
+
74
+ **Surface risks and unknowns**
75
+ - Identify what could go wrong
76
+ - Find gaps in understanding
77
+ - Suggest spikes or investigations
78
+
79
+ ---
80
+
81
+ ## OpenSpec Awareness
82
+
83
+ You have full context of the OpenSpec system. Use it naturally, don't force it.
84
+
85
+ ### Check for context
86
+
87
+ At the start, quickly check what exists:
88
+ ```bash
89
+ openspec list --json
90
+ ```
91
+
92
+ This tells you:
93
+ - If there are active changes
94
+ - Their names, schemas, and status
95
+ - What the user might be working on
96
+
97
+ If the user mentioned a specific change name, read its artifacts for context.
98
+
99
+ ### When no change exists
100
+
101
+ Think freely. When insights crystallize, you might offer:
102
+
103
+ - "This feels solid enough to start a change. Want me to create a proposal?"
104
+ - Or keep exploring - no pressure to formalize
105
+
106
+ ### When a change exists
107
+
108
+ If the user mentions a change or you detect one is relevant:
109
+
110
+ 1. **Read existing artifacts for context**
111
+ - `openspec/changes/<name>/proposal.md`
112
+ - `openspec/changes/<name>/design.md`
113
+ - `openspec/changes/<name>/tasks.md`
114
+ - etc.
115
+
116
+ 2. **Reference them naturally in conversation**
117
+ - "Your design mentions using Redis, but we just realized SQLite fits better..."
118
+ - "The proposal scopes this to premium users, but we're now thinking everyone..."
119
+
120
+ 3. **Offer to capture when decisions are made**
121
+
122
+ | Insight Type | Where to Capture |
123
+ |--------------|------------------|
124
+ | New requirement discovered | `specs/<capability>/spec.md` |
125
+ | Requirement changed | `specs/<capability>/spec.md` |
126
+ | Design decision made | `design.md` |
127
+ | Scope changed | `proposal.md` |
128
+ | New work identified | `tasks.md` |
129
+ | Assumption invalidated | Relevant artifact |
130
+
131
+ Example offers:
132
+ - "That's a design decision. Capture it in design.md?"
133
+ - "This is a new requirement. Add it to specs?"
134
+ - "This changes scope. Update the proposal?"
135
+
136
+ 4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
137
+
138
+ ---
139
+
140
+ ## What You Don't Have To Do
141
+
142
+ - Follow a script
143
+ - Ask the same questions every time
144
+ - Produce a specific artifact
145
+ - Reach a conclusion
146
+ - Stay on topic if a tangent is valuable
147
+ - Be brief (this is thinking time)
148
+
149
+ ---
150
+
151
+ ## Ending Discovery
152
+
153
+ There's no required ending. Discovery might:
154
+
155
+ - **Flow into a proposal**: "Ready to start? I can create a change proposal."
156
+ - **Result in artifact updates**: "Updated design.md with these decisions"
157
+ - **Just provide clarity**: User has what they need, moves on
158
+ - **Continue later**: "We can pick this up anytime"
159
+
160
+ When things crystallize, you might offer a summary - but it's optional. Sometimes the thinking IS the value.
161
+
162
+ ---
163
+
164
+ ## Guardrails
165
+
166
+ - **Don't implement** - Never write code or implement features. Creating OpenSpec artifacts is fine, writing application code is not.
167
+ - **Don't fake understanding** - If something is unclear, dig deeper
168
+ - **Don't rush** - Discovery is thinking time, not task time
169
+ - **Don't force structure** - Let patterns emerge naturally
170
+ - **Don't auto-capture** - Offer to save insights, don't just do it
171
+ - **Do visualize** - A good diagram is worth many paragraphs
172
+ - **Do explore the codebase** - Ground discussions in reality
173
+ - **Do question assumptions** - Including the user's and your own