@synth-coder/memhub 0.2.2 → 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,74 +1,74 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: [main, master]
6
- pull_request:
7
- branches: [main, master]
8
-
9
- jobs:
10
- quality:
11
- name: Quality Gate
12
- runs-on: ubuntu-latest
13
-
14
- strategy:
15
- matrix:
16
- node-version: [18.x, 20.x]
17
-
18
- steps:
19
- - name: Checkout repository
20
- uses: actions/checkout@v4
21
-
22
- - name: Setup Node.js ${{ matrix.node-version }}
23
- uses: actions/setup-node@v4
24
- with:
25
- node-version: ${{ matrix.node-version }}
26
- cache: 'npm'
27
-
28
- - name: Install dependencies
29
- run: npm ci
30
-
31
- - name: Run linter
32
- run: npm run lint
33
-
34
- - name: Check formatting
35
- run: npm run format:check
36
-
37
- - name: Run type check
38
- run: npm run typecheck
39
-
40
- - name: Run tests with coverage
41
- run: npm run test:coverage
42
-
43
- - name: Upload coverage reports
44
- uses: codecov/codecov-action@v3
45
- if: matrix.node-version == '20.x'
46
- with:
47
- files: ./coverage/lcov.info
48
- fail_ci_if_error: false
49
-
50
- build:
51
- name: Build
52
- runs-on: ubuntu-latest
53
- needs: quality
54
-
55
- steps:
56
- - name: Checkout repository
57
- uses: actions/checkout@v4
58
-
59
- - name: Setup Node.js
60
- uses: actions/setup-node@v4
61
- with:
62
- node-version: 20.x
63
- cache: 'npm'
64
-
65
- - name: Install dependencies
66
- run: npm ci
67
-
68
- - name: Build project
69
- run: npm run build
70
-
71
- - name: Check build output
72
- run: |
73
- test -f dist/index.js
74
- test -f dist/server/mcp-server.js
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ quality:
11
+ name: Quality Gate
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ node-version: [18.x, 20.x]
17
+
18
+ steps:
19
+ - name: Checkout repository
20
+ uses: actions/checkout@v4
21
+
22
+ - name: Setup Node.js ${{ matrix.node-version }}
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: ${{ matrix.node-version }}
26
+ cache: 'npm'
27
+
28
+ - name: Install dependencies
29
+ run: npm ci
30
+
31
+ - name: Run linter
32
+ run: npm run lint
33
+
34
+ - name: Check formatting
35
+ run: npm run format:check
36
+
37
+ - name: Run type check
38
+ run: npm run typecheck
39
+
40
+ - name: Run tests with coverage
41
+ run: npm run test:coverage
42
+
43
+ - name: Upload coverage reports
44
+ uses: codecov/codecov-action@v3
45
+ if: matrix.node-version == '20.x'
46
+ with:
47
+ files: ./coverage/lcov.info
48
+ fail_ci_if_error: false
49
+
50
+ build:
51
+ name: Build
52
+ runs-on: ubuntu-latest
53
+ needs: quality
54
+
55
+ steps:
56
+ - name: Checkout repository
57
+ uses: actions/checkout@v4
58
+
59
+ - name: Setup Node.js
60
+ uses: actions/setup-node@v4
61
+ with:
62
+ node-version: 20.x
63
+ cache: 'npm'
64
+
65
+ - name: Install dependencies
66
+ run: npm ci
67
+
68
+ - name: Build project
69
+ run: npm run build
70
+
71
+ - name: Check build output
72
+ run: |
73
+ test -f dist/index.js
74
+ test -f dist/server/mcp-server.js
@@ -1,152 +1,152 @@
1
- ---
2
- name: /opsx-apply
3
- id: opsx-apply
4
- category: Workflow
5
- description: Implement tasks from an OpenSpec change (Experimental)
6
- ---
7
-
8
- Implement tasks from an OpenSpec change.
9
-
10
- **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.
11
-
12
- **Steps**
13
-
14
- 1. **Select the change**
15
-
16
- If a name is provided, use it. Otherwise:
17
- - Infer from conversation context if the user mentioned a change
18
- - Auto-select if only one active change exists
19
- - If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
20
-
21
- Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
22
-
23
- 2. **Check status to understand the schema**
24
- ```bash
25
- openspec status --change "<name>" --json
26
- ```
27
- Parse the JSON to understand:
28
- - `schemaName`: The workflow being used (e.g., "spec-driven")
29
- - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
30
-
31
- 3. **Get apply instructions**
32
-
33
- ```bash
34
- openspec instructions apply --change "<name>" --json
35
- ```
36
-
37
- This returns:
38
- - Context file paths (varies by schema)
39
- - Progress (total, complete, remaining)
40
- - Task list with status
41
- - Dynamic instruction based on current state
42
-
43
- **Handle states:**
44
- - If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue`
45
- - If `state: "all_done"`: congratulate, suggest archive
46
- - Otherwise: proceed to implementation
47
-
48
- 4. **Read context files**
49
-
50
- Read the files listed in `contextFiles` from the apply instructions output.
51
- The files depend on the schema being used:
52
- - **spec-driven**: proposal, specs, design, tasks
53
- - Other schemas: follow the contextFiles from CLI output
54
-
55
- 5. **Show current progress**
56
-
57
- Display:
58
- - Schema being used
59
- - Progress: "N/M tasks complete"
60
- - Remaining tasks overview
61
- - Dynamic instruction from CLI
62
-
63
- 6. **Implement tasks (loop until done or blocked)**
64
-
65
- For each pending task:
66
- - Show which task is being worked on
67
- - Make the code changes required
68
- - Keep changes minimal and focused
69
- - Mark task complete in the tasks file: `- [ ]` → `- [x]`
70
- - Continue to next task
71
-
72
- **Pause if:**
73
- - Task is unclear → ask for clarification
74
- - Implementation reveals a design issue → suggest updating artifacts
75
- - Error or blocker encountered → report and wait for guidance
76
- - User interrupts
77
-
78
- 7. **On completion or pause, show status**
79
-
80
- Display:
81
- - Tasks completed this session
82
- - Overall progress: "N/M tasks complete"
83
- - If all done: suggest archive
84
- - If paused: explain why and wait for guidance
85
-
86
- **Output During Implementation**
87
-
88
- ```
89
- ## Implementing: <change-name> (schema: <schema-name>)
90
-
91
- Working on task 3/7: <task description>
92
- [...implementation happening...]
93
- ✓ Task complete
94
-
95
- Working on task 4/7: <task description>
96
- [...implementation happening...]
97
- ✓ Task complete
98
- ```
99
-
100
- **Output On Completion**
101
-
102
- ```
103
- ## Implementation Complete
104
-
105
- **Change:** <change-name>
106
- **Schema:** <schema-name>
107
- **Progress:** 7/7 tasks complete ✓
108
-
109
- ### Completed This Session
110
- - [x] Task 1
111
- - [x] Task 2
112
- ...
113
-
114
- All tasks complete! You can archive this change with `/opsx:archive`.
115
- ```
116
-
117
- **Output On Pause (Issue Encountered)**
118
-
119
- ```
120
- ## Implementation Paused
121
-
122
- **Change:** <change-name>
123
- **Schema:** <schema-name>
124
- **Progress:** 4/7 tasks complete
125
-
126
- ### Issue Encountered
127
- <description of the issue>
128
-
129
- **Options:**
130
- 1. <option 1>
131
- 2. <option 2>
132
- 3. Other approach
133
-
134
- What would you like to do?
135
- ```
136
-
137
- **Guardrails**
138
- - Keep going through tasks until done or blocked
139
- - Always read context files before starting (from the apply instructions output)
140
- - If task is ambiguous, pause and ask before implementing
141
- - If implementation reveals issues, pause and suggest artifact updates
142
- - Keep code changes minimal and scoped to each task
143
- - Update task checkbox immediately after completing each task
144
- - Pause on errors, blockers, or unclear requirements - don't guess
145
- - Use contextFiles from CLI output, don't assume specific file names
146
-
147
- **Fluid Workflow Integration**
148
-
149
- This skill supports the "actions on a change" model:
150
-
151
- - **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
152
- - **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
1
+ ---
2
+ name: /opsx-apply
3
+ id: opsx-apply
4
+ category: Workflow
5
+ description: Implement tasks from an OpenSpec change (Experimental)
6
+ ---
7
+
8
+ Implement tasks from an OpenSpec change.
9
+
10
+ **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.
11
+
12
+ **Steps**
13
+
14
+ 1. **Select the change**
15
+
16
+ If a name is provided, use it. Otherwise:
17
+ - Infer from conversation context if the user mentioned a change
18
+ - Auto-select if only one active change exists
19
+ - If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
20
+
21
+ Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
22
+
23
+ 2. **Check status to understand the schema**
24
+ ```bash
25
+ openspec status --change "<name>" --json
26
+ ```
27
+ Parse the JSON to understand:
28
+ - `schemaName`: The workflow being used (e.g., "spec-driven")
29
+ - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
30
+
31
+ 3. **Get apply instructions**
32
+
33
+ ```bash
34
+ openspec instructions apply --change "<name>" --json
35
+ ```
36
+
37
+ This returns:
38
+ - Context file paths (varies by schema)
39
+ - Progress (total, complete, remaining)
40
+ - Task list with status
41
+ - Dynamic instruction based on current state
42
+
43
+ **Handle states:**
44
+ - If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue`
45
+ - If `state: "all_done"`: congratulate, suggest archive
46
+ - Otherwise: proceed to implementation
47
+
48
+ 4. **Read context files**
49
+
50
+ Read the files listed in `contextFiles` from the apply instructions output.
51
+ The files depend on the schema being used:
52
+ - **spec-driven**: proposal, specs, design, tasks
53
+ - Other schemas: follow the contextFiles from CLI output
54
+
55
+ 5. **Show current progress**
56
+
57
+ Display:
58
+ - Schema being used
59
+ - Progress: "N/M tasks complete"
60
+ - Remaining tasks overview
61
+ - Dynamic instruction from CLI
62
+
63
+ 6. **Implement tasks (loop until done or blocked)**
64
+
65
+ For each pending task:
66
+ - Show which task is being worked on
67
+ - Make the code changes required
68
+ - Keep changes minimal and focused
69
+ - Mark task complete in the tasks file: `- [ ]` → `- [x]`
70
+ - Continue to next task
71
+
72
+ **Pause if:**
73
+ - Task is unclear → ask for clarification
74
+ - Implementation reveals a design issue → suggest updating artifacts
75
+ - Error or blocker encountered → report and wait for guidance
76
+ - User interrupts
77
+
78
+ 7. **On completion or pause, show status**
79
+
80
+ Display:
81
+ - Tasks completed this session
82
+ - Overall progress: "N/M tasks complete"
83
+ - If all done: suggest archive
84
+ - If paused: explain why and wait for guidance
85
+
86
+ **Output During Implementation**
87
+
88
+ ```
89
+ ## Implementing: <change-name> (schema: <schema-name>)
90
+
91
+ Working on task 3/7: <task description>
92
+ [...implementation happening...]
93
+ ✓ Task complete
94
+
95
+ Working on task 4/7: <task description>
96
+ [...implementation happening...]
97
+ ✓ Task complete
98
+ ```
99
+
100
+ **Output On Completion**
101
+
102
+ ```
103
+ ## Implementation Complete
104
+
105
+ **Change:** <change-name>
106
+ **Schema:** <schema-name>
107
+ **Progress:** 7/7 tasks complete ✓
108
+
109
+ ### Completed This Session
110
+ - [x] Task 1
111
+ - [x] Task 2
112
+ ...
113
+
114
+ All tasks complete! You can archive this change with `/opsx:archive`.
115
+ ```
116
+
117
+ **Output On Pause (Issue Encountered)**
118
+
119
+ ```
120
+ ## Implementation Paused
121
+
122
+ **Change:** <change-name>
123
+ **Schema:** <schema-name>
124
+ **Progress:** 4/7 tasks complete
125
+
126
+ ### Issue Encountered
127
+ <description of the issue>
128
+
129
+ **Options:**
130
+ 1. <option 1>
131
+ 2. <option 2>
132
+ 3. Other approach
133
+
134
+ What would you like to do?
135
+ ```
136
+
137
+ **Guardrails**
138
+ - Keep going through tasks until done or blocked
139
+ - Always read context files before starting (from the apply instructions output)
140
+ - If task is ambiguous, pause and ask before implementing
141
+ - If implementation reveals issues, pause and suggest artifact updates
142
+ - Keep code changes minimal and scoped to each task
143
+ - Update task checkbox immediately after completing each task
144
+ - Pause on errors, blockers, or unclear requirements - don't guess
145
+ - Use contextFiles from CLI output, don't assume specific file names
146
+
147
+ **Fluid Workflow Integration**
148
+
149
+ This skill supports the "actions on a change" model:
150
+
151
+ - **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
152
+ - **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly