@synth-coder/memhub 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.factory/commands/opsx-apply.md +150 -0
- package/.factory/commands/opsx-archive.md +155 -0
- package/.factory/commands/opsx-explore.md +171 -0
- package/.factory/commands/opsx-propose.md +104 -0
- package/.factory/skills/openspec-apply-change/SKILL.md +156 -0
- package/.factory/skills/openspec-archive-change/SKILL.md +114 -0
- package/.factory/skills/openspec-explore/SKILL.md +288 -0
- package/.factory/skills/openspec-propose/SKILL.md +110 -0
- package/.github/workflows/ci.yml +48 -12
- package/.github/workflows/release.yml +67 -0
- package/AGENTS.md +158 -17
- package/README.md +147 -66
- package/README.zh-CN.md +75 -23
- package/dist/src/cli/agents/claude-code.d.ts +5 -0
- package/dist/src/cli/agents/claude-code.d.ts.map +1 -0
- package/dist/src/cli/agents/claude-code.js +14 -0
- package/dist/src/cli/agents/claude-code.js.map +1 -0
- package/dist/src/cli/agents/cline.d.ts +5 -0
- package/dist/src/cli/agents/cline.d.ts.map +1 -0
- package/dist/src/cli/agents/cline.js +14 -0
- package/dist/src/cli/agents/cline.js.map +1 -0
- package/dist/src/cli/agents/codex.d.ts +5 -0
- package/dist/src/cli/agents/codex.d.ts.map +1 -0
- package/dist/src/cli/agents/codex.js +14 -0
- package/dist/src/cli/agents/codex.js.map +1 -0
- package/dist/src/cli/agents/cursor.d.ts +5 -0
- package/dist/src/cli/agents/cursor.d.ts.map +1 -0
- package/dist/src/cli/agents/cursor.js +14 -0
- package/dist/src/cli/agents/cursor.js.map +1 -0
- package/dist/src/cli/agents/factory-droid.d.ts +5 -0
- package/dist/src/cli/agents/factory-droid.d.ts.map +1 -0
- package/dist/src/cli/agents/factory-droid.js +14 -0
- package/dist/src/cli/agents/factory-droid.js.map +1 -0
- package/dist/src/cli/agents/gemini-cli.d.ts +5 -0
- package/dist/src/cli/agents/gemini-cli.d.ts.map +1 -0
- package/dist/src/cli/agents/gemini-cli.js +14 -0
- package/dist/src/cli/agents/gemini-cli.js.map +1 -0
- package/dist/src/cli/agents/index.d.ts +14 -0
- package/dist/src/cli/agents/index.d.ts.map +1 -0
- package/dist/src/cli/agents/index.js +30 -0
- package/dist/src/cli/agents/index.js.map +1 -0
- package/dist/src/cli/agents/windsurf.d.ts +5 -0
- package/dist/src/cli/agents/windsurf.d.ts.map +1 -0
- package/dist/src/cli/agents/windsurf.js +14 -0
- package/dist/src/cli/agents/windsurf.js.map +1 -0
- package/dist/src/cli/index.d.ts +8 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +168 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/init.d.ts +34 -0
- package/dist/src/cli/init.d.ts.map +1 -0
- package/dist/src/cli/init.js +160 -0
- package/dist/src/cli/init.js.map +1 -0
- package/dist/src/cli/instructions.d.ts +29 -0
- package/dist/src/cli/instructions.d.ts.map +1 -0
- package/dist/src/cli/instructions.js +141 -0
- package/dist/src/cli/instructions.js.map +1 -0
- package/dist/src/cli/types.d.ts +22 -0
- package/dist/src/cli/types.d.ts.map +1 -0
- package/dist/src/cli/types.js +86 -0
- package/dist/src/cli/types.js.map +1 -0
- package/dist/src/contracts/schemas.js.map +1 -1
- package/dist/src/server/mcp-server.d.ts +8 -0
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/mcp-server.js +30 -16
- package/dist/src/server/mcp-server.js.map +1 -1
- package/dist/src/services/embedding-service.d.ts.map +1 -1
- package/dist/src/services/embedding-service.js +1 -1
- package/dist/src/services/embedding-service.js.map +1 -1
- package/dist/src/services/memory-service.d.ts +1 -0
- package/dist/src/services/memory-service.d.ts.map +1 -1
- package/dist/src/services/memory-service.js +125 -82
- package/dist/src/services/memory-service.js.map +1 -1
- package/dist/src/storage/markdown-storage.d.ts.map +1 -1
- package/dist/src/storage/markdown-storage.js +1 -1
- package/dist/src/storage/markdown-storage.js.map +1 -1
- package/dist/src/storage/vector-index.d.ts.map +1 -1
- package/dist/src/storage/vector-index.js +4 -5
- package/dist/src/storage/vector-index.js.map +1 -1
- package/docs/README.md +21 -0
- package/docs/mcp-tools.md +136 -0
- package/docs/user-guide.md +182 -0
- package/package.json +22 -19
- package/src/cli/agents/claude-code.ts +14 -0
- package/src/cli/agents/cline.ts +14 -0
- package/src/cli/agents/codex.ts +14 -0
- package/src/cli/agents/cursor.ts +14 -0
- package/src/cli/agents/factory-droid.ts +14 -0
- package/src/cli/agents/gemini-cli.ts +14 -0
- package/src/cli/agents/index.ts +36 -0
- package/src/cli/agents/windsurf.ts +14 -0
- package/src/cli/index.ts +192 -0
- package/src/cli/init.ts +218 -0
- package/src/cli/instructions.ts +156 -0
- package/src/cli/types.ts +112 -0
- package/src/contracts/mcp.ts +1 -1
- package/src/contracts/schemas.ts +4 -4
- package/src/contracts/types.ts +4 -4
- package/src/server/mcp-server.ts +36 -29
- package/src/services/embedding-service.ts +80 -80
- package/src/services/memory-service.ts +142 -107
- package/src/storage/markdown-storage.ts +1 -9
- package/src/storage/vector-index.ts +117 -118
- package/test/cli/init.test.ts +380 -0
- package/test/server/mcp-server.test.ts +45 -3
- package/test/services/memory-service.test.ts +16 -4
- package/test/storage/frontmatter-parser.test.ts +1 -1
- package/test/storage/markdown-storage.test.ts +19 -10
- package/test/storage/vector-index.test.ts +129 -133
- package/test/utils/slugify.test.ts +5 -1
- package/docs/architecture.md +0 -349
- package/docs/contracts.md +0 -119
- package/docs/prompt-template.md +0 -79
- package/docs/proposals/mcp-typescript-sdk-refactor.md +0 -568
- package/docs/proposals/proposal-close-gates.md +0 -58
- package/docs/tool-calling-policy.md +0 -107
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Implement tasks from an OpenSpec change (Experimental)
|
|
3
|
+
argument-hint: command arguments
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Implement tasks from an OpenSpec change.
|
|
7
|
+
|
|
8
|
+
**Input**: Optionally specify a change name (e.g., `/opsx:apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
9
|
+
|
|
10
|
+
**Steps**
|
|
11
|
+
|
|
12
|
+
1. **Select the change**
|
|
13
|
+
|
|
14
|
+
If a name is provided, use it. Otherwise:
|
|
15
|
+
- Infer from conversation context if the user mentioned a change
|
|
16
|
+
- Auto-select if only one active change exists
|
|
17
|
+
- If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
|
|
18
|
+
|
|
19
|
+
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
|
|
20
|
+
|
|
21
|
+
2. **Check status to understand the schema**
|
|
22
|
+
```bash
|
|
23
|
+
openspec status --change "<name>" --json
|
|
24
|
+
```
|
|
25
|
+
Parse the JSON to understand:
|
|
26
|
+
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
|
27
|
+
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
|
|
28
|
+
|
|
29
|
+
3. **Get apply instructions**
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
openspec instructions apply --change "<name>" --json
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This returns:
|
|
36
|
+
- Context file paths (varies by schema)
|
|
37
|
+
- Progress (total, complete, remaining)
|
|
38
|
+
- Task list with status
|
|
39
|
+
- Dynamic instruction based on current state
|
|
40
|
+
|
|
41
|
+
**Handle states:**
|
|
42
|
+
- If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue`
|
|
43
|
+
- If `state: "all_done"`: congratulate, suggest archive
|
|
44
|
+
- Otherwise: proceed to implementation
|
|
45
|
+
|
|
46
|
+
4. **Read context files**
|
|
47
|
+
|
|
48
|
+
Read the files listed in `contextFiles` from the apply instructions output.
|
|
49
|
+
The files depend on the schema being used:
|
|
50
|
+
- **spec-driven**: proposal, specs, design, tasks
|
|
51
|
+
- Other schemas: follow the contextFiles from CLI output
|
|
52
|
+
|
|
53
|
+
5. **Show current progress**
|
|
54
|
+
|
|
55
|
+
Display:
|
|
56
|
+
- Schema being used
|
|
57
|
+
- Progress: "N/M tasks complete"
|
|
58
|
+
- Remaining tasks overview
|
|
59
|
+
- Dynamic instruction from CLI
|
|
60
|
+
|
|
61
|
+
6. **Implement tasks (loop until done or blocked)**
|
|
62
|
+
|
|
63
|
+
For each pending task:
|
|
64
|
+
- Show which task is being worked on
|
|
65
|
+
- Make the code changes required
|
|
66
|
+
- Keep changes minimal and focused
|
|
67
|
+
- Mark task complete in the tasks file: `- [ ]` → `- [x]`
|
|
68
|
+
- Continue to next task
|
|
69
|
+
|
|
70
|
+
**Pause if:**
|
|
71
|
+
- Task is unclear → ask for clarification
|
|
72
|
+
- Implementation reveals a design issue → suggest updating artifacts
|
|
73
|
+
- Error or blocker encountered → report and wait for guidance
|
|
74
|
+
- User interrupts
|
|
75
|
+
|
|
76
|
+
7. **On completion or pause, show status**
|
|
77
|
+
|
|
78
|
+
Display:
|
|
79
|
+
- Tasks completed this session
|
|
80
|
+
- Overall progress: "N/M tasks complete"
|
|
81
|
+
- If all done: suggest archive
|
|
82
|
+
- If paused: explain why and wait for guidance
|
|
83
|
+
|
|
84
|
+
**Output During Implementation**
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
## Implementing: <change-name> (schema: <schema-name>)
|
|
88
|
+
|
|
89
|
+
Working on task 3/7: <task description>
|
|
90
|
+
[...implementation happening...]
|
|
91
|
+
✓ Task complete
|
|
92
|
+
|
|
93
|
+
Working on task 4/7: <task description>
|
|
94
|
+
[...implementation happening...]
|
|
95
|
+
✓ Task complete
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Output On Completion**
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
## Implementation Complete
|
|
102
|
+
|
|
103
|
+
**Change:** <change-name>
|
|
104
|
+
**Schema:** <schema-name>
|
|
105
|
+
**Progress:** 7/7 tasks complete ✓
|
|
106
|
+
|
|
107
|
+
### Completed This Session
|
|
108
|
+
- [x] Task 1
|
|
109
|
+
- [x] Task 2
|
|
110
|
+
...
|
|
111
|
+
|
|
112
|
+
All tasks complete! You can archive this change with `/opsx:archive`.
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Output On Pause (Issue Encountered)**
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
## Implementation Paused
|
|
119
|
+
|
|
120
|
+
**Change:** <change-name>
|
|
121
|
+
**Schema:** <schema-name>
|
|
122
|
+
**Progress:** 4/7 tasks complete
|
|
123
|
+
|
|
124
|
+
### Issue Encountered
|
|
125
|
+
<description of the issue>
|
|
126
|
+
|
|
127
|
+
**Options:**
|
|
128
|
+
1. <option 1>
|
|
129
|
+
2. <option 2>
|
|
130
|
+
3. Other approach
|
|
131
|
+
|
|
132
|
+
What would you like to do?
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Guardrails**
|
|
136
|
+
- Keep going through tasks until done or blocked
|
|
137
|
+
- Always read context files before starting (from the apply instructions output)
|
|
138
|
+
- If task is ambiguous, pause and ask before implementing
|
|
139
|
+
- If implementation reveals issues, pause and suggest artifact updates
|
|
140
|
+
- Keep code changes minimal and scoped to each task
|
|
141
|
+
- Update task checkbox immediately after completing each task
|
|
142
|
+
- Pause on errors, blockers, or unclear requirements - don't guess
|
|
143
|
+
- Use contextFiles from CLI output, don't assume specific file names
|
|
144
|
+
|
|
145
|
+
**Fluid Workflow Integration**
|
|
146
|
+
|
|
147
|
+
This skill supports the "actions on a change" model:
|
|
148
|
+
|
|
149
|
+
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
|
|
150
|
+
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Archive a completed change in the experimental workflow
|
|
3
|
+
argument-hint: command arguments
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Archive a completed change in the experimental workflow.
|
|
7
|
+
|
|
8
|
+
**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.
|
|
9
|
+
|
|
10
|
+
**Steps**
|
|
11
|
+
|
|
12
|
+
1. **If no change name provided, prompt for selection**
|
|
13
|
+
|
|
14
|
+
Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
15
|
+
|
|
16
|
+
Show only active changes (not already archived).
|
|
17
|
+
Include the schema used for each change if available.
|
|
18
|
+
|
|
19
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
20
|
+
|
|
21
|
+
2. **Check artifact completion status**
|
|
22
|
+
|
|
23
|
+
Run `openspec status --change "<name>" --json` to check artifact completion.
|
|
24
|
+
|
|
25
|
+
Parse the JSON to understand:
|
|
26
|
+
- `schemaName`: The workflow being used
|
|
27
|
+
- `artifacts`: List of artifacts with their status (`done` or other)
|
|
28
|
+
|
|
29
|
+
**If any artifacts are not `done`:**
|
|
30
|
+
- Display warning listing incomplete artifacts
|
|
31
|
+
- Prompt user for confirmation to continue
|
|
32
|
+
- Proceed if user confirms
|
|
33
|
+
|
|
34
|
+
3. **Check task completion status**
|
|
35
|
+
|
|
36
|
+
Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
|
|
37
|
+
|
|
38
|
+
Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
|
|
39
|
+
|
|
40
|
+
**If incomplete tasks found:**
|
|
41
|
+
- Display warning showing count of incomplete tasks
|
|
42
|
+
- Prompt user for confirmation to continue
|
|
43
|
+
- Proceed if user confirms
|
|
44
|
+
|
|
45
|
+
**If no tasks file exists:** Proceed without task-related warning.
|
|
46
|
+
|
|
47
|
+
4. **Assess delta spec sync state**
|
|
48
|
+
|
|
49
|
+
Check for delta specs at `openspec/changes/<name>/specs/`. If none exist, proceed without sync prompt.
|
|
50
|
+
|
|
51
|
+
**If delta specs exist:**
|
|
52
|
+
- Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
|
|
53
|
+
- Determine what changes would be applied (adds, modifications, removals, renames)
|
|
54
|
+
- Show a combined summary before prompting
|
|
55
|
+
|
|
56
|
+
**Prompt options:**
|
|
57
|
+
- If changes needed: "Sync now (recommended)", "Archive without syncing"
|
|
58
|
+
- If already synced: "Archive now", "Sync anyway", "Cancel"
|
|
59
|
+
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
5. **Perform the archive**
|
|
63
|
+
|
|
64
|
+
Create the archive directory if it doesn't exist:
|
|
65
|
+
```bash
|
|
66
|
+
mkdir -p openspec/changes/archive
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Generate target name using current date: `YYYY-MM-DD-<change-name>`
|
|
70
|
+
|
|
71
|
+
**Check if target already exists:**
|
|
72
|
+
- If yes: Fail with error, suggest renaming existing archive or using different date
|
|
73
|
+
- If no: Move the change directory to archive
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
6. **Display summary**
|
|
80
|
+
|
|
81
|
+
Show archive completion summary including:
|
|
82
|
+
- Change name
|
|
83
|
+
- Schema that was used
|
|
84
|
+
- Archive location
|
|
85
|
+
- Spec sync status (synced / sync skipped / no delta specs)
|
|
86
|
+
- Note about any warnings (incomplete artifacts/tasks)
|
|
87
|
+
|
|
88
|
+
**Output On Success**
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
## Archive Complete
|
|
92
|
+
|
|
93
|
+
**Change:** <change-name>
|
|
94
|
+
**Schema:** <schema-name>
|
|
95
|
+
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
|
|
96
|
+
**Specs:** ✓ Synced to main specs
|
|
97
|
+
|
|
98
|
+
All artifacts complete. All tasks complete.
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Output On Success (No Delta Specs)**
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
## Archive Complete
|
|
105
|
+
|
|
106
|
+
**Change:** <change-name>
|
|
107
|
+
**Schema:** <schema-name>
|
|
108
|
+
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
|
|
109
|
+
**Specs:** No delta specs
|
|
110
|
+
|
|
111
|
+
All artifacts complete. All tasks complete.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Output On Success With Warnings**
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
## Archive Complete (with warnings)
|
|
118
|
+
|
|
119
|
+
**Change:** <change-name>
|
|
120
|
+
**Schema:** <schema-name>
|
|
121
|
+
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
|
|
122
|
+
**Specs:** Sync skipped (user chose to skip)
|
|
123
|
+
|
|
124
|
+
**Warnings:**
|
|
125
|
+
- Archived with 2 incomplete artifacts
|
|
126
|
+
- Archived with 3 incomplete tasks
|
|
127
|
+
- Delta spec sync was skipped (user chose to skip)
|
|
128
|
+
|
|
129
|
+
Review the archive if this was not intentional.
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Output On Error (Archive Exists)**
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
## Archive Failed
|
|
136
|
+
|
|
137
|
+
**Change:** <change-name>
|
|
138
|
+
**Target:** openspec/changes/archive/YYYY-MM-DD-<name>/
|
|
139
|
+
|
|
140
|
+
Target archive directory already exists.
|
|
141
|
+
|
|
142
|
+
**Options:**
|
|
143
|
+
1. Rename the existing archive
|
|
144
|
+
2. Delete the existing archive if it's a duplicate
|
|
145
|
+
3. Wait until a different date to archive
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Guardrails**
|
|
149
|
+
- Always prompt for change selection if not provided
|
|
150
|
+
- Use artifact graph (openspec status --json) for completion checking
|
|
151
|
+
- Don't block archive on warnings - just inform and confirm
|
|
152
|
+
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
|
|
153
|
+
- Show clear summary of what happened
|
|
154
|
+
- If sync is requested, use the Skill tool to invoke `openspec-sync-specs` (agent-driven)
|
|
155
|
+
- If delta specs exist, always run the sync assessment and show the combined summary before prompting
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Enter explore mode - think through ideas, investigate problems, clarify requirements
|
|
3
|
+
argument-hint: command arguments
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
|
|
7
|
+
|
|
8
|
+
**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.
|
|
9
|
+
|
|
10
|
+
**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.
|
|
11
|
+
|
|
12
|
+
**Input**: The argument after `/opsx:explore` is whatever the user wants to think about. Could be:
|
|
13
|
+
- A vague idea: "real-time collaboration"
|
|
14
|
+
- A specific problem: "the auth system is getting unwieldy"
|
|
15
|
+
- A change name: "add-dark-mode" (to explore in context of that change)
|
|
16
|
+
- A comparison: "postgres vs sqlite for this"
|
|
17
|
+
- Nothing (just enter explore mode)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## The Stance
|
|
22
|
+
|
|
23
|
+
- **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
|
|
24
|
+
- **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.
|
|
25
|
+
- **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
|
|
26
|
+
- **Adaptive** - Follow interesting threads, pivot when new information emerges
|
|
27
|
+
- **Patient** - Don't rush to conclusions, let the shape of the problem emerge
|
|
28
|
+
- **Grounded** - Explore the actual codebase when relevant, don't just theorize
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## What You Might Do
|
|
33
|
+
|
|
34
|
+
Depending on what the user brings, you might:
|
|
35
|
+
|
|
36
|
+
**Explore the problem space**
|
|
37
|
+
- Ask clarifying questions that emerge from what they said
|
|
38
|
+
- Challenge assumptions
|
|
39
|
+
- Reframe the problem
|
|
40
|
+
- Find analogies
|
|
41
|
+
|
|
42
|
+
**Investigate the codebase**
|
|
43
|
+
- Map existing architecture relevant to the discussion
|
|
44
|
+
- Find integration points
|
|
45
|
+
- Identify patterns already in use
|
|
46
|
+
- Surface hidden complexity
|
|
47
|
+
|
|
48
|
+
**Compare options**
|
|
49
|
+
- Brainstorm multiple approaches
|
|
50
|
+
- Build comparison tables
|
|
51
|
+
- Sketch tradeoffs
|
|
52
|
+
- Recommend a path (if asked)
|
|
53
|
+
|
|
54
|
+
**Visualize**
|
|
55
|
+
```
|
|
56
|
+
┌─────────────────────────────────────────┐
|
|
57
|
+
│ Use ASCII diagrams liberally │
|
|
58
|
+
├─────────────────────────────────────────┤
|
|
59
|
+
│ │
|
|
60
|
+
│ ┌────────┐ ┌────────┐ │
|
|
61
|
+
│ │ State │────────▶│ State │ │
|
|
62
|
+
│ │ A │ │ B │ │
|
|
63
|
+
│ └────────┘ └────────┘ │
|
|
64
|
+
│ │
|
|
65
|
+
│ System diagrams, state machines, │
|
|
66
|
+
│ data flows, architecture sketches, │
|
|
67
|
+
│ dependency graphs, comparison tables │
|
|
68
|
+
│ │
|
|
69
|
+
└─────────────────────────────────────────┘
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Surface risks and unknowns**
|
|
73
|
+
- Identify what could go wrong
|
|
74
|
+
- Find gaps in understanding
|
|
75
|
+
- Suggest spikes or investigations
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## OpenSpec Awareness
|
|
80
|
+
|
|
81
|
+
You have full context of the OpenSpec system. Use it naturally, don't force it.
|
|
82
|
+
|
|
83
|
+
### Check for context
|
|
84
|
+
|
|
85
|
+
At the start, quickly check what exists:
|
|
86
|
+
```bash
|
|
87
|
+
openspec list --json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
This tells you:
|
|
91
|
+
- If there are active changes
|
|
92
|
+
- Their names, schemas, and status
|
|
93
|
+
- What the user might be working on
|
|
94
|
+
|
|
95
|
+
If the user mentioned a specific change name, read its artifacts for context.
|
|
96
|
+
|
|
97
|
+
### When no change exists
|
|
98
|
+
|
|
99
|
+
Think freely. When insights crystallize, you might offer:
|
|
100
|
+
|
|
101
|
+
- "This feels solid enough to start a change. Want me to create a proposal?"
|
|
102
|
+
- Or keep exploring - no pressure to formalize
|
|
103
|
+
|
|
104
|
+
### When a change exists
|
|
105
|
+
|
|
106
|
+
If the user mentions a change or you detect one is relevant:
|
|
107
|
+
|
|
108
|
+
1. **Read existing artifacts for context**
|
|
109
|
+
- `openspec/changes/<name>/proposal.md`
|
|
110
|
+
- `openspec/changes/<name>/design.md`
|
|
111
|
+
- `openspec/changes/<name>/tasks.md`
|
|
112
|
+
- etc.
|
|
113
|
+
|
|
114
|
+
2. **Reference them naturally in conversation**
|
|
115
|
+
- "Your design mentions using Redis, but we just realized SQLite fits better..."
|
|
116
|
+
- "The proposal scopes this to premium users, but we're now thinking everyone..."
|
|
117
|
+
|
|
118
|
+
3. **Offer to capture when decisions are made**
|
|
119
|
+
|
|
120
|
+
| Insight Type | Where to Capture |
|
|
121
|
+
|--------------|------------------|
|
|
122
|
+
| New requirement discovered | `specs/<capability>/spec.md` |
|
|
123
|
+
| Requirement changed | `specs/<capability>/spec.md` |
|
|
124
|
+
| Design decision made | `design.md` |
|
|
125
|
+
| Scope changed | `proposal.md` |
|
|
126
|
+
| New work identified | `tasks.md` |
|
|
127
|
+
| Assumption invalidated | Relevant artifact |
|
|
128
|
+
|
|
129
|
+
Example offers:
|
|
130
|
+
- "That's a design decision. Capture it in design.md?"
|
|
131
|
+
- "This is a new requirement. Add it to specs?"
|
|
132
|
+
- "This changes scope. Update the proposal?"
|
|
133
|
+
|
|
134
|
+
4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## What You Don't Have To Do
|
|
139
|
+
|
|
140
|
+
- Follow a script
|
|
141
|
+
- Ask the same questions every time
|
|
142
|
+
- Produce a specific artifact
|
|
143
|
+
- Reach a conclusion
|
|
144
|
+
- Stay on topic if a tangent is valuable
|
|
145
|
+
- Be brief (this is thinking time)
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Ending Discovery
|
|
150
|
+
|
|
151
|
+
There's no required ending. Discovery might:
|
|
152
|
+
|
|
153
|
+
- **Flow into a proposal**: "Ready to start? I can create a change proposal."
|
|
154
|
+
- **Result in artifact updates**: "Updated design.md with these decisions"
|
|
155
|
+
- **Just provide clarity**: User has what they need, moves on
|
|
156
|
+
- **Continue later**: "We can pick this up anytime"
|
|
157
|
+
|
|
158
|
+
When things crystallize, you might offer a summary - but it's optional. Sometimes the thinking IS the value.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Guardrails
|
|
163
|
+
|
|
164
|
+
- **Don't implement** - Never write code or implement features. Creating OpenSpec artifacts is fine, writing application code is not.
|
|
165
|
+
- **Don't fake understanding** - If something is unclear, dig deeper
|
|
166
|
+
- **Don't rush** - Discovery is thinking time, not task time
|
|
167
|
+
- **Don't force structure** - Let patterns emerge naturally
|
|
168
|
+
- **Don't auto-capture** - Offer to save insights, don't just do it
|
|
169
|
+
- **Do visualize** - A good diagram is worth many paragraphs
|
|
170
|
+
- **Do explore the codebase** - Ground discussions in reality
|
|
171
|
+
- **Do question assumptions** - Including the user's and your own
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Propose a new change - create it and generate all artifacts in one step
|
|
3
|
+
argument-hint: command arguments
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Propose a new change - create the change and generate all artifacts in one step.
|
|
7
|
+
|
|
8
|
+
I'll create a change with artifacts:
|
|
9
|
+
- proposal.md (what & why)
|
|
10
|
+
- design.md (how)
|
|
11
|
+
- tasks.md (implementation steps)
|
|
12
|
+
|
|
13
|
+
When ready to implement, run /opsx:apply
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
**Input**: The argument after `/opsx:propose` is the change name (kebab-case), OR a description of what the user wants to build.
|
|
18
|
+
|
|
19
|
+
**Steps**
|
|
20
|
+
|
|
21
|
+
1. **If no input provided, ask what they want to build**
|
|
22
|
+
|
|
23
|
+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
24
|
+
> "What change do you want to work on? Describe what you want to build or fix."
|
|
25
|
+
|
|
26
|
+
From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`).
|
|
27
|
+
|
|
28
|
+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
29
|
+
|
|
30
|
+
2. **Create the change directory**
|
|
31
|
+
```bash
|
|
32
|
+
openspec new change "<name>"
|
|
33
|
+
```
|
|
34
|
+
This creates a scaffolded change at `openspec/changes/<name>/` with `.openspec.yaml`.
|
|
35
|
+
|
|
36
|
+
3. **Get the artifact build order**
|
|
37
|
+
```bash
|
|
38
|
+
openspec status --change "<name>" --json
|
|
39
|
+
```
|
|
40
|
+
Parse the JSON to get:
|
|
41
|
+
- `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
|
|
42
|
+
- `artifacts`: list of all artifacts with their status and dependencies
|
|
43
|
+
|
|
44
|
+
4. **Create artifacts in sequence until apply-ready**
|
|
45
|
+
|
|
46
|
+
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
47
|
+
|
|
48
|
+
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
49
|
+
|
|
50
|
+
a. **For each artifact that is `ready` (dependencies satisfied)**:
|
|
51
|
+
- Get instructions:
|
|
52
|
+
```bash
|
|
53
|
+
openspec instructions <artifact-id> --change "<name>" --json
|
|
54
|
+
```
|
|
55
|
+
- The instructions JSON includes:
|
|
56
|
+
- `context`: Project background (constraints for you - do NOT include in output)
|
|
57
|
+
- `rules`: Artifact-specific rules (constraints for you - do NOT include in output)
|
|
58
|
+
- `template`: The structure to use for your output file
|
|
59
|
+
- `instruction`: Schema-specific guidance for this artifact type
|
|
60
|
+
- `outputPath`: Where to write the artifact
|
|
61
|
+
- `dependencies`: Completed artifacts to read for context
|
|
62
|
+
- Read any completed dependency files for context
|
|
63
|
+
- Create the artifact file using `template` as the structure
|
|
64
|
+
- Apply `context` and `rules` as constraints - but do NOT copy them into the file
|
|
65
|
+
- Show brief progress: "Created <artifact-id>"
|
|
66
|
+
|
|
67
|
+
b. **Continue until all `applyRequires` artifacts are complete**
|
|
68
|
+
- After creating each artifact, re-run `openspec status --change "<name>" --json`
|
|
69
|
+
- Check if every artifact ID in `applyRequires` has `status: "done"` in the artifacts array
|
|
70
|
+
- Stop when all `applyRequires` artifacts are done
|
|
71
|
+
|
|
72
|
+
c. **If an artifact requires user input** (unclear context):
|
|
73
|
+
- Use **AskUserQuestion tool** to clarify
|
|
74
|
+
- Then continue with creation
|
|
75
|
+
|
|
76
|
+
5. **Show final status**
|
|
77
|
+
```bash
|
|
78
|
+
openspec status --change "<name>"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Output**
|
|
82
|
+
|
|
83
|
+
After completing all artifacts, summarize:
|
|
84
|
+
- Change name and location
|
|
85
|
+
- List of artifacts created with brief descriptions
|
|
86
|
+
- What's ready: "All artifacts created! Ready for implementation."
|
|
87
|
+
- Prompt: "Run `/opsx:apply` to start implementing."
|
|
88
|
+
|
|
89
|
+
**Artifact Creation Guidelines**
|
|
90
|
+
|
|
91
|
+
- Follow the `instruction` field from `openspec instructions` for each artifact type
|
|
92
|
+
- The schema defines what each artifact should contain - follow it
|
|
93
|
+
- Read dependency artifacts for context before creating new ones
|
|
94
|
+
- Use `template` as the structure for your output file - fill in its sections
|
|
95
|
+
- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file
|
|
96
|
+
- Do NOT copy `<context>`, `<rules>`, `<project_context>` blocks into the artifact
|
|
97
|
+
- These guide what you write, but should never appear in the output
|
|
98
|
+
|
|
99
|
+
**Guardrails**
|
|
100
|
+
- Create ALL artifacts needed for implementation (as defined by schema's `apply.requires`)
|
|
101
|
+
- Always read dependency artifacts before creating a new one
|
|
102
|
+
- If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
|
|
103
|
+
- If a change with that name already exists, ask if user wants to continue it or create a new one
|
|
104
|
+
- Verify each artifact file exists after writing before proceeding to next
|