@synth-coder/memhub 0.2.3 → 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.
Files changed (143) hide show
  1. package/.eslintrc.cjs +45 -45
  2. package/.factory/commands/opsx-apply.md +150 -150
  3. package/.factory/commands/opsx-archive.md +155 -155
  4. package/.factory/commands/opsx-explore.md +171 -171
  5. package/.factory/commands/opsx-propose.md +104 -104
  6. package/.factory/skills/openspec-apply-change/SKILL.md +156 -156
  7. package/.factory/skills/openspec-archive-change/SKILL.md +114 -114
  8. package/.factory/skills/openspec-explore/SKILL.md +288 -288
  9. package/.factory/skills/openspec-propose/SKILL.md +110 -110
  10. package/.github/workflows/ci.yml +110 -74
  11. package/.github/workflows/release.yml +67 -0
  12. package/.iflow/commands/opsx-apply.md +152 -152
  13. package/.iflow/commands/opsx-archive.md +157 -157
  14. package/.iflow/commands/opsx-explore.md +173 -173
  15. package/.iflow/commands/opsx-propose.md +106 -106
  16. package/.iflow/skills/openspec-apply-change/SKILL.md +156 -156
  17. package/.iflow/skills/openspec-archive-change/SKILL.md +114 -114
  18. package/.iflow/skills/openspec-explore/SKILL.md +288 -288
  19. package/.iflow/skills/openspec-propose/SKILL.md +110 -110
  20. package/.prettierrc +11 -11
  21. package/AGENTS.md +167 -169
  22. package/README.md +276 -195
  23. package/README.zh-CN.md +245 -193
  24. package/dist/src/cli/agents/claude-code.d.ts +5 -0
  25. package/dist/src/cli/agents/claude-code.d.ts.map +1 -0
  26. package/dist/src/cli/agents/claude-code.js +14 -0
  27. package/dist/src/cli/agents/claude-code.js.map +1 -0
  28. package/dist/src/cli/agents/cline.d.ts +5 -0
  29. package/dist/src/cli/agents/cline.d.ts.map +1 -0
  30. package/dist/src/cli/agents/cline.js +14 -0
  31. package/dist/src/cli/agents/cline.js.map +1 -0
  32. package/dist/src/cli/agents/codex.d.ts +5 -0
  33. package/dist/src/cli/agents/codex.d.ts.map +1 -0
  34. package/dist/src/cli/agents/codex.js +14 -0
  35. package/dist/src/cli/agents/codex.js.map +1 -0
  36. package/dist/src/cli/agents/cursor.d.ts +5 -0
  37. package/dist/src/cli/agents/cursor.d.ts.map +1 -0
  38. package/dist/src/cli/agents/cursor.js +14 -0
  39. package/dist/src/cli/agents/cursor.js.map +1 -0
  40. package/dist/src/cli/agents/factory-droid.d.ts +5 -0
  41. package/dist/src/cli/agents/factory-droid.d.ts.map +1 -0
  42. package/dist/src/cli/agents/factory-droid.js +14 -0
  43. package/dist/src/cli/agents/factory-droid.js.map +1 -0
  44. package/dist/src/cli/agents/gemini-cli.d.ts +5 -0
  45. package/dist/src/cli/agents/gemini-cli.d.ts.map +1 -0
  46. package/dist/src/cli/agents/gemini-cli.js +14 -0
  47. package/dist/src/cli/agents/gemini-cli.js.map +1 -0
  48. package/dist/src/cli/agents/index.d.ts +14 -0
  49. package/dist/src/cli/agents/index.d.ts.map +1 -0
  50. package/dist/src/cli/agents/index.js +30 -0
  51. package/dist/src/cli/agents/index.js.map +1 -0
  52. package/dist/src/cli/agents/windsurf.d.ts +5 -0
  53. package/dist/src/cli/agents/windsurf.d.ts.map +1 -0
  54. package/dist/src/cli/agents/windsurf.js +14 -0
  55. package/dist/src/cli/agents/windsurf.js.map +1 -0
  56. package/dist/src/cli/index.d.ts +8 -0
  57. package/dist/src/cli/index.d.ts.map +1 -0
  58. package/dist/src/cli/index.js +168 -0
  59. package/dist/src/cli/index.js.map +1 -0
  60. package/dist/src/cli/init.d.ts +34 -0
  61. package/dist/src/cli/init.d.ts.map +1 -0
  62. package/dist/src/cli/init.js +160 -0
  63. package/dist/src/cli/init.js.map +1 -0
  64. package/dist/src/cli/instructions.d.ts +29 -0
  65. package/dist/src/cli/instructions.d.ts.map +1 -0
  66. package/dist/src/cli/instructions.js +141 -0
  67. package/dist/src/cli/instructions.js.map +1 -0
  68. package/dist/src/cli/types.d.ts +22 -0
  69. package/dist/src/cli/types.d.ts.map +1 -0
  70. package/dist/src/cli/types.js +86 -0
  71. package/dist/src/cli/types.js.map +1 -0
  72. package/dist/src/contracts/mcp.js +34 -34
  73. package/dist/src/contracts/schemas.js.map +1 -1
  74. package/dist/src/server/mcp-server.d.ts.map +1 -1
  75. package/dist/src/server/mcp-server.js +7 -14
  76. package/dist/src/server/mcp-server.js.map +1 -1
  77. package/dist/src/services/embedding-service.d.ts.map +1 -1
  78. package/dist/src/services/embedding-service.js +1 -1
  79. package/dist/src/services/embedding-service.js.map +1 -1
  80. package/dist/src/services/memory-service.d.ts.map +1 -1
  81. package/dist/src/services/memory-service.js.map +1 -1
  82. package/dist/src/storage/markdown-storage.d.ts.map +1 -1
  83. package/dist/src/storage/markdown-storage.js +1 -1
  84. package/dist/src/storage/markdown-storage.js.map +1 -1
  85. package/dist/src/storage/vector-index.d.ts.map +1 -1
  86. package/dist/src/storage/vector-index.js +4 -5
  87. package/dist/src/storage/vector-index.js.map +1 -1
  88. package/docs/README.md +21 -0
  89. package/docs/mcp-tools.md +136 -0
  90. package/docs/user-guide.md +182 -0
  91. package/package.json +61 -59
  92. package/src/cli/agents/claude-code.ts +14 -0
  93. package/src/cli/agents/cline.ts +14 -0
  94. package/src/cli/agents/codex.ts +14 -0
  95. package/src/cli/agents/cursor.ts +14 -0
  96. package/src/cli/agents/factory-droid.ts +14 -0
  97. package/src/cli/agents/gemini-cli.ts +14 -0
  98. package/src/cli/agents/index.ts +36 -0
  99. package/src/cli/agents/windsurf.ts +14 -0
  100. package/src/cli/index.ts +192 -0
  101. package/src/cli/init.ts +218 -0
  102. package/src/cli/instructions.ts +156 -0
  103. package/src/cli/types.ts +112 -0
  104. package/src/contracts/index.ts +12 -12
  105. package/src/contracts/mcp.ts +223 -223
  106. package/src/contracts/schemas.ts +307 -307
  107. package/src/contracts/types.ts +410 -410
  108. package/src/index.ts +8 -8
  109. package/src/server/index.ts +5 -5
  110. package/src/server/mcp-server.ts +169 -186
  111. package/src/services/embedding-service.ts +114 -114
  112. package/src/services/index.ts +5 -5
  113. package/src/services/memory-service.ts +656 -663
  114. package/src/storage/frontmatter-parser.ts +243 -243
  115. package/src/storage/index.ts +6 -6
  116. package/src/storage/markdown-storage.ts +228 -236
  117. package/src/storage/vector-index.ts +159 -160
  118. package/src/utils/index.ts +5 -5
  119. package/src/utils/slugify.ts +63 -63
  120. package/test/cli/init.test.ts +380 -0
  121. package/test/contracts/schemas.test.ts +313 -313
  122. package/test/contracts/types.test.ts +21 -21
  123. package/test/frontmatter-parser-more.test.ts +94 -94
  124. package/test/server/mcp-server.test.ts +211 -210
  125. package/test/services/memory-service-edge.test.ts +248 -248
  126. package/test/services/memory-service.test.ts +291 -279
  127. package/test/storage/frontmatter-parser.test.ts +223 -223
  128. package/test/storage/markdown-storage.test.ts +226 -217
  129. package/test/storage/storage-edge.test.ts +238 -238
  130. package/test/storage/vector-index.test.ts +149 -153
  131. package/test/utils/slugify-edge.test.ts +94 -94
  132. package/test/utils/slugify.test.ts +72 -68
  133. package/tsconfig.json +25 -25
  134. package/tsconfig.test.json +8 -8
  135. package/vitest.config.ts +29 -29
  136. package/docs/architecture-diagrams.md +0 -368
  137. package/docs/architecture.md +0 -381
  138. package/docs/contracts.md +0 -190
  139. package/docs/prompt-template.md +0 -33
  140. package/docs/proposals/mcp-typescript-sdk-refactor.md +0 -568
  141. package/docs/proposals/proposal-close-gates.md +0 -58
  142. package/docs/tool-calling-policy.md +0 -101
  143. package/docs/vector-search.md +0 -306
package/.eslintrc.cjs CHANGED
@@ -1,46 +1,46 @@
1
- module.exports = {
2
- root: true,
3
- parser: '@typescript-eslint/parser',
4
- parserOptions: {
5
- ecmaVersion: 2022,
6
- sourceType: 'module',
7
- project: ['./tsconfig.json', './tsconfig.test.json'],
8
- tsconfigRootDir: __dirname,
9
- },
10
- plugins: ['@typescript-eslint'],
11
- extends: [
12
- 'eslint:recommended',
13
- 'plugin:@typescript-eslint/recommended',
14
- 'plugin:@typescript-eslint/recommended-requiring-type-checking',
15
- 'prettier',
16
- ],
17
- rules: {
18
- '@typescript-eslint/explicit-function-return-type': 'off',
19
- '@typescript-eslint/no-explicit-any': 'error',
20
- '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
21
- '@typescript-eslint/prefer-readonly': 'error',
22
- '@typescript-eslint/strict-boolean-expressions': 'off',
23
- 'no-console': ['warn', { allow: ['error', 'warn'] }],
24
- 'import/no-unresolved': 'off',
25
- 'import/order': 'off',
26
- },
27
- env: {
28
- node: true,
29
- es2022: true,
30
- },
31
- ignorePatterns: ['dist/', 'node_modules/', '*.config.*'],
32
- overrides: [
33
- {
34
- // Test files
35
- files: ['test/**/*.ts'],
36
- rules: {
37
- '@typescript-eslint/no-unused-vars': 'off',
38
- '@typescript-eslint/require-await': 'off',
39
- '@typescript-eslint/no-unsafe-assignment': 'off',
40
- '@typescript-eslint/no-unsafe-member-access': 'off',
41
- '@typescript-eslint/no-unsafe-call': 'off',
42
- '@typescript-eslint/no-unsafe-return': 'off',
43
- },
44
- },
45
- ],
1
+ module.exports = {
2
+ root: true,
3
+ parser: '@typescript-eslint/parser',
4
+ parserOptions: {
5
+ ecmaVersion: 2022,
6
+ sourceType: 'module',
7
+ project: ['./tsconfig.json', './tsconfig.test.json'],
8
+ tsconfigRootDir: __dirname,
9
+ },
10
+ plugins: ['@typescript-eslint'],
11
+ extends: [
12
+ 'eslint:recommended',
13
+ 'plugin:@typescript-eslint/recommended',
14
+ 'plugin:@typescript-eslint/recommended-requiring-type-checking',
15
+ 'prettier',
16
+ ],
17
+ rules: {
18
+ '@typescript-eslint/explicit-function-return-type': 'off',
19
+ '@typescript-eslint/no-explicit-any': 'error',
20
+ '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
21
+ '@typescript-eslint/prefer-readonly': 'error',
22
+ '@typescript-eslint/strict-boolean-expressions': 'off',
23
+ 'no-console': ['warn', { allow: ['error', 'warn'] }],
24
+ 'import/no-unresolved': 'off',
25
+ 'import/order': 'off',
26
+ },
27
+ env: {
28
+ node: true,
29
+ es2022: true,
30
+ },
31
+ ignorePatterns: ['dist/', 'node_modules/', '*.config.*'],
32
+ overrides: [
33
+ {
34
+ // Test files
35
+ files: ['test/**/*.ts'],
36
+ rules: {
37
+ '@typescript-eslint/no-unused-vars': 'off',
38
+ '@typescript-eslint/require-await': 'off',
39
+ '@typescript-eslint/no-unsafe-assignment': 'off',
40
+ '@typescript-eslint/no-unsafe-member-access': 'off',
41
+ '@typescript-eslint/no-unsafe-call': 'off',
42
+ '@typescript-eslint/no-unsafe-return': 'off',
43
+ },
44
+ },
45
+ ],
46
46
  };
@@ -1,150 +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
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