maskweaver 0.9.4 → 0.9.5

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 (227) hide show
  1. package/dist/cli/doctor.js +5 -21
  2. package/dist/cli/install.d.ts +0 -8
  3. package/dist/cli/install.js +0 -39
  4. package/dist/context/config.d.ts +0 -22
  5. package/dist/context/config.js +0 -28
  6. package/dist/context/feature.d.ts +0 -39
  7. package/dist/context/feature.js +0 -77
  8. package/dist/context/files.d.ts +0 -13
  9. package/dist/context/files.js +1 -24
  10. package/dist/context/index.d.ts +0 -7
  11. package/dist/context/index.js +0 -12
  12. package/dist/context/project.d.ts +0 -21
  13. package/dist/context/project.js +0 -30
  14. package/dist/context/types.d.ts +0 -48
  15. package/dist/context/types.js +0 -12
  16. package/dist/context/utils.d.ts +0 -18
  17. package/dist/context/utils.js +0 -27
  18. package/dist/core/engine/promptBuilder.d.ts +0 -17
  19. package/dist/core/engine/promptBuilder.js +0 -28
  20. package/dist/core/index.d.ts +0 -6
  21. package/dist/core/index.js +0 -9
  22. package/dist/core/loader/MaskLoader.d.ts +0 -23
  23. package/dist/core/loader/MaskLoader.js +0 -29
  24. package/dist/core/schema/types.d.ts +0 -47
  25. package/dist/core/schema/types.js +0 -6
  26. package/dist/core/schema/validator.d.ts +0 -14
  27. package/dist/core/schema/validator.js +0 -18
  28. package/dist/i18n/index.d.ts +0 -18
  29. package/dist/i18n/index.js +4 -23
  30. package/dist/index.d.ts +0 -8
  31. package/dist/index.js +0 -8
  32. package/dist/lib.d.ts +0 -5
  33. package/dist/lib.js +0 -12
  34. package/dist/memory/chunking.d.ts +0 -22
  35. package/dist/memory/chunking.js +2 -37
  36. package/dist/memory/core.d.ts +0 -29
  37. package/dist/memory/core.js +1 -52
  38. package/dist/memory/index.d.ts +0 -5
  39. package/dist/memory/index.js +0 -10
  40. package/dist/memory/indexer.d.ts +0 -21
  41. package/dist/memory/indexer.js +0 -44
  42. package/dist/memory/providers/examples.d.ts +0 -5
  43. package/dist/memory/providers/examples.js +4 -64
  44. package/dist/memory/providers/factory.d.ts +0 -44
  45. package/dist/memory/providers/factory.js +0 -46
  46. package/dist/memory/providers/index.d.ts +0 -26
  47. package/dist/memory/providers/index.js +0 -28
  48. package/dist/memory/providers/ollama.d.ts +0 -6
  49. package/dist/memory/providers/ollama.js +1 -8
  50. package/dist/memory/providers/openai.d.ts +0 -6
  51. package/dist/memory/providers/openai.js +1 -8
  52. package/dist/memory/providers/openrouter.d.ts +0 -6
  53. package/dist/memory/providers/openrouter.js +0 -8
  54. package/dist/memory/providers/text-only.d.ts +0 -13
  55. package/dist/memory/providers/text-only.js +0 -17
  56. package/dist/memory/providers/types.d.ts +0 -39
  57. package/dist/memory/providers/types.js +0 -7
  58. package/dist/memory/providers/voyage.d.ts +0 -22
  59. package/dist/memory/providers/voyage.js +1 -24
  60. package/dist/memory/search/hybrid.d.ts +0 -12
  61. package/dist/memory/search/hybrid.js +1 -22
  62. package/dist/memory/store/sqlite.d.ts +0 -72
  63. package/dist/memory/store/sqlite.js +4 -127
  64. package/dist/plugin/config/index.d.ts +0 -112
  65. package/dist/plugin/config/index.js +0 -115
  66. package/dist/plugin/index.d.ts +0 -13
  67. package/dist/plugin/index.js +1 -123
  68. package/dist/plugin/tools/command-registry.d.ts +0 -6
  69. package/dist/plugin/tools/command-registry.js +0 -14
  70. package/dist/plugin/tools/context.d.ts +0 -12
  71. package/dist/plugin/tools/context.js +0 -58
  72. package/dist/plugin/tools/maskSave.d.ts +0 -3
  73. package/dist/plugin/tools/maskSave.js +0 -3
  74. package/dist/plugin/tools/memoryGet.d.ts +0 -3
  75. package/dist/plugin/tools/memoryGet.js +0 -3
  76. package/dist/plugin/tools/memoryIndexer.d.ts +0 -3
  77. package/dist/plugin/tools/memoryIndexer.js +0 -10
  78. package/dist/plugin/tools/memorySearch.d.ts +0 -31
  79. package/dist/plugin/tools/memorySearch.js +0 -79
  80. package/dist/plugin/tools/memoryWrite.d.ts +0 -8
  81. package/dist/plugin/tools/memoryWrite.js +0 -32
  82. package/dist/plugin/tools/retrospect.d.ts +0 -3
  83. package/dist/plugin/tools/retrospect.js +0 -3
  84. package/dist/plugin/tools/slashcommand.d.ts +0 -11
  85. package/dist/plugin/tools/slashcommand.js +0 -38
  86. package/dist/plugin/tools/squad.d.ts +0 -12
  87. package/dist/plugin/tools/squad.js +11 -83
  88. package/dist/plugin/tools/weave.d.ts +0 -6
  89. package/dist/plugin/tools/weave.js +0 -78
  90. package/dist/plugin/types.d.ts +0 -20
  91. package/dist/plugin/types.js +0 -7
  92. package/dist/retrospect/index.d.ts +0 -7
  93. package/dist/retrospect/index.js +0 -9
  94. package/dist/retrospect/mask-save.d.ts +0 -12
  95. package/dist/retrospect/mask-save.js +1 -80
  96. package/dist/retrospect/retrospect.d.ts +0 -18
  97. package/dist/retrospect/retrospect.js +0 -63
  98. package/dist/retrospect/strategies/base.d.ts +0 -15
  99. package/dist/retrospect/strategies/base.js +0 -7
  100. package/dist/retrospect/strategies/deep.d.ts +0 -12
  101. package/dist/retrospect/strategies/deep.js +0 -24
  102. package/dist/retrospect/strategies/index.d.ts +0 -12
  103. package/dist/retrospect/strategies/index.js +0 -12
  104. package/dist/retrospect/strategies/quick.d.ts +0 -12
  105. package/dist/retrospect/strategies/quick.js +0 -19
  106. package/dist/retrospect/strategies/standard.d.ts +0 -12
  107. package/dist/retrospect/strategies/standard.js +0 -15
  108. package/dist/retrospect/types.d.ts +0 -7
  109. package/dist/retrospect/types.js +0 -7
  110. package/dist/shared/config.d.ts +0 -105
  111. package/dist/shared/config.js +0 -33
  112. package/dist/shared/errors.d.ts +0 -18
  113. package/dist/shared/errors.js +0 -19
  114. package/dist/shared/generate-agents.d.ts +0 -69
  115. package/dist/shared/generate-agents.js +2 -86
  116. package/dist/shared/image.d.ts +0 -67
  117. package/dist/shared/image.js +6 -104
  118. package/dist/shared/index.d.ts +0 -5
  119. package/dist/shared/index.js +0 -7
  120. package/dist/shared/model-registry.d.ts +0 -72
  121. package/dist/shared/model-registry.js +5 -95
  122. package/dist/shared/types.d.ts +0 -15
  123. package/dist/shared/types.js +0 -3
  124. package/dist/shared-context/dag.d.ts +0 -105
  125. package/dist/shared-context/dag.js +3 -114
  126. package/dist/shared-context/index.d.ts +0 -5
  127. package/dist/shared-context/index.js +0 -15
  128. package/dist/shared-context/logger.d.ts +0 -37
  129. package/dist/shared-context/logger.js +0 -41
  130. package/dist/shared-context/parallel-executor.d.ts +0 -54
  131. package/dist/shared-context/parallel-executor.js +4 -56
  132. package/dist/shared-context/session.d.ts +0 -56
  133. package/dist/shared-context/session.js +0 -47
  134. package/dist/shared-context/squad.d.ts +0 -68
  135. package/dist/shared-context/squad.js +0 -63
  136. package/dist/shared-context/storage.d.ts +0 -132
  137. package/dist/shared-context/storage.js +0 -116
  138. package/dist/shared-context/task.d.ts +0 -120
  139. package/dist/shared-context/task.js +0 -152
  140. package/dist/shared-context/test/dag.test.js +9 -14
  141. package/dist/shared-context/test/logger.test.d.ts +0 -8
  142. package/dist/shared-context/test/logger.test.js +0 -52
  143. package/dist/shared-context/test/session.test.d.ts +0 -7
  144. package/dist/shared-context/test/session.test.js +0 -63
  145. package/dist/shared-context/test/squad.test.d.ts +0 -10
  146. package/dist/shared-context/test/squad.test.js +2 -68
  147. package/dist/shared-context/test/storage.test.d.ts +0 -8
  148. package/dist/shared-context/test/storage.test.js +0 -68
  149. package/dist/shared-context/test/task.test.d.ts +0 -7
  150. package/dist/shared-context/test/task.test.js +0 -54
  151. package/dist/shared-context/test/watchdog.test.d.ts +0 -7
  152. package/dist/shared-context/test/watchdog.test.js +3 -58
  153. package/dist/shared-context/types.d.ts +0 -215
  154. package/dist/shared-context/types.js +0 -125
  155. package/dist/shared-context/watchdog.d.ts +0 -127
  156. package/dist/shared-context/watchdog.js +0 -148
  157. package/dist/shared-context/worktree.d.ts +0 -68
  158. package/dist/shared-context/worktree.js +2 -34
  159. package/dist/verify/budget.d.ts +0 -29
  160. package/dist/verify/budget.js +0 -34
  161. package/dist/verify/critical-files.d.ts +0 -17
  162. package/dist/verify/critical-files.js +0 -37
  163. package/dist/verify/escalation.d.ts +0 -20
  164. package/dist/verify/escalation.js +0 -22
  165. package/dist/verify/index.d.ts +0 -5
  166. package/dist/verify/index.js +0 -11
  167. package/dist/verify/prompts.d.ts +0 -20
  168. package/dist/verify/prompts.js +0 -20
  169. package/dist/verify/types.d.ts +0 -26
  170. package/dist/verify/types.js +1 -12
  171. package/dist/verify/verifier.d.ts +0 -29
  172. package/dist/verify/verifier.js +0 -54
  173. package/dist/version.d.ts +1 -16
  174. package/dist/version.js +1 -16
  175. package/dist/weave/bridge.d.ts +0 -35
  176. package/dist/weave/bridge.js +0 -51
  177. package/dist/weave/environment/detector.d.ts +0 -6
  178. package/dist/weave/environment/detector.js +4 -45
  179. package/dist/weave/environment/index.d.ts +0 -19
  180. package/dist/weave/environment/index.js +1 -39
  181. package/dist/weave/environment/issues.d.ts +0 -35
  182. package/dist/weave/environment/issues.js +0 -59
  183. package/dist/weave/git.d.ts +0 -8
  184. package/dist/weave/git.js +0 -8
  185. package/dist/weave/index.d.ts +0 -13
  186. package/dist/weave/index.js +2 -28
  187. package/dist/weave/knowledge/global.d.ts +0 -39
  188. package/dist/weave/knowledge/global.js +2 -78
  189. package/dist/weave/loop.js +0 -3
  190. package/dist/weave/orchestrator.d.ts +0 -69
  191. package/dist/weave/orchestrator.js +1 -101
  192. package/dist/weave/phase-manager.d.ts +0 -64
  193. package/dist/weave/phase-manager.js +0 -89
  194. package/dist/weave/security/secret-scan.d.ts +0 -14
  195. package/dist/weave/security/secret-scan.js +0 -19
  196. package/dist/weave/stages/build.js +0 -15
  197. package/dist/weave/stages/execute.d.ts +0 -42
  198. package/dist/weave/stages/execute.js +4 -86
  199. package/dist/weave/stages/handoff.d.ts +0 -7
  200. package/dist/weave/stages/handoff.js +0 -43
  201. package/dist/weave/stages/index.d.ts +0 -3
  202. package/dist/weave/stages/index.js +0 -3
  203. package/dist/weave/stages/intake.d.ts +0 -8
  204. package/dist/weave/stages/intake.js +5 -65
  205. package/dist/weave/stages/map.d.ts +0 -1
  206. package/dist/weave/stages/openspec.d.ts +0 -1
  207. package/dist/weave/stages/plan.d.ts +0 -11
  208. package/dist/weave/stages/plan.js +1 -53
  209. package/dist/weave/stages/refine.d.ts +0 -7
  210. package/dist/weave/stages/refine.js +0 -7
  211. package/dist/weave/stages/research.d.ts +0 -6
  212. package/dist/weave/stages/research.js +0 -6
  213. package/dist/weave/stages/spec.d.ts +0 -12
  214. package/dist/weave/stages/spec.js +0 -17
  215. package/dist/weave/types.d.ts +0 -20
  216. package/dist/weave/types.js +0 -5
  217. package/dist/weave/verification/commands.d.ts +0 -12
  218. package/dist/weave/verification/commands.js +0 -19
  219. package/dist/weave/verification/index.d.ts +0 -6
  220. package/dist/weave/verification/index.js +1 -19
  221. package/dist/weave/verification/playwright.d.ts +0 -47
  222. package/dist/weave/verification/playwright.js +1 -90
  223. package/dist/weave/worktree.d.ts +0 -16
  224. package/dist/weave/worktree.js +0 -23
  225. package/dist/weave/yaml-repair.d.ts +0 -39
  226. package/dist/weave/yaml-repair.js +13 -116
  227. package/package.json +1 -1
@@ -1,15 +1,3 @@
1
- /**
2
- * Context Management Tool
3
- *
4
- * 피처 기반 작업 컨텍스트 관리 도구
5
- *
6
- * 설계 원칙:
7
- * - 의도를 드러내는 코드 (Intention-Revealing)
8
- * - 명확한 에러 메시지
9
- * - 일관된 JSON 응답 형식
10
- *
11
- * @author Martin Fowler's Dummy Human
12
- */
13
1
  import { z } from "zod";
14
2
  import type { ToolFactory } from '../types.js';
15
3
  export declare const contextSchema: z.ZodObject<{
@@ -1,20 +1,5 @@
1
- /**
2
- * Context Management Tool
3
- *
4
- * 피처 기반 작업 컨텍스트 관리 도구
5
- *
6
- * 설계 원칙:
7
- * - 의도를 드러내는 코드 (Intention-Revealing)
8
- * - 명확한 에러 메시지
9
- * - 일관된 JSON 응답 형식
10
- *
11
- * @author Martin Fowler's Dummy Human
12
- */
13
1
  import { z } from "zod";
14
2
  import * as core from '../../context/index.js';
15
- // ============================================================================
16
- // Schema 정의
17
- // ============================================================================
18
3
  export const contextSchema = z.object({
19
4
  action: z.enum([
20
5
  "start", "switch", "status", "done",
@@ -38,9 +23,6 @@ function successResponse(action, message, data) {
38
23
  function errorResponse(action, message) {
39
24
  return createResponse(false, action, message);
40
25
  }
41
- // ============================================================================
42
- // Tool Factory
43
- // ============================================================================
44
26
  export function createContextTool() {
45
27
  return {
46
28
  description: `작업 컨텍스트를 관리합니다.
@@ -91,14 +73,6 @@ export function createContextTool() {
91
73
  }
92
74
  };
93
75
  }
94
- // ============================================================================
95
- // 액션 핸들러
96
- // ============================================================================
97
- /**
98
- * 새 피처 시작
99
- *
100
- * 피처를 생성하고 즉시 활성화합니다.
101
- */
102
76
  async function handleStart(basePath, name, goal) {
103
77
  if (!name || name.trim().length === 0) {
104
78
  return errorResponse("start", "피처 이름(name)을 입력해주세요. 예: name=\"login-oauth\"");
@@ -106,12 +80,10 @@ async function handleStart(basePath, name, goal) {
106
80
  if (!goal || goal.trim().length === 0) {
107
81
  return errorResponse("start", "피처 목표(goal)를 입력해주세요. 예: goal=\"OAuth 로그인 구현\"");
108
82
  }
109
- // 피처 생성
110
83
  const createResult = await core.createFeature(basePath, name, goal);
111
84
  if (!createResult.success || !createResult.data) {
112
85
  return errorResponse("start", createResult.error || "피처 생성에 실패했습니다");
113
86
  }
114
- // 생성된 피처를 활성화
115
87
  const switchResult = await core.switchFeature(basePath, createResult.data.id);
116
88
  if (!switchResult.success) {
117
89
  return errorResponse("start", switchResult.error || "피처 활성화에 실패했습니다");
@@ -123,16 +95,10 @@ async function handleStart(basePath, name, goal) {
123
95
  status: "active"
124
96
  });
125
97
  }
126
- /**
127
- * 피처 전환
128
- *
129
- * ID 또는 이름으로 피처를 찾아 전환합니다.
130
- */
131
98
  async function handleSwitch(basePath, id, name) {
132
99
  if (!id && !name) {
133
100
  return errorResponse("switch", "피처 ID(id) 또는 이름(name)을 입력해주세요");
134
101
  }
135
- // ID가 없으면 이름으로 피처 찾기
136
102
  let featureId = id;
137
103
  if (!featureId && name) {
138
104
  const listResult = await core.listFeatures(basePath);
@@ -158,9 +124,6 @@ async function handleSwitch(basePath, id, name) {
158
124
  files: result.data.files
159
125
  });
160
126
  }
161
- /**
162
- * 현재 상태 표시
163
- */
164
127
  async function handleStatus(basePath) {
165
128
  const activeResult = await core.getActiveFeature(basePath);
166
129
  if (!activeResult.success) {
@@ -184,12 +147,8 @@ async function handleStatus(basePath) {
184
147
  blockers: feature.blockers
185
148
  });
186
149
  }
187
- /**
188
- * 피처 완료
189
- */
190
150
  async function handleDone(basePath, id) {
191
151
  let featureId = id;
192
- // ID가 없으면 현재 활성 피처 사용
193
152
  if (!featureId) {
194
153
  const activeResult = await core.getActiveFeature(basePath);
195
154
  if (!activeResult.success) {
@@ -212,14 +171,10 @@ async function handleDone(basePath, id) {
212
171
  totalFiles: result.data.files.length
213
172
  });
214
173
  }
215
- /**
216
- * 파일 추가
217
- */
218
174
  async function handleAdd(basePath, file) {
219
175
  if (!file || file.trim().length === 0) {
220
176
  return errorResponse("add", "추가할 파일 경로(file)를 입력해주세요. 예: file=\"src/auth/oauth.ts\"");
221
177
  }
222
- // 활성 피처 확인
223
178
  const activeResult = await core.getActiveFeature(basePath);
224
179
  if (!activeResult.success) {
225
180
  return errorResponse("add", activeResult.error || "활성 피처 조회에 실패했습니다");
@@ -237,14 +192,10 @@ async function handleAdd(basePath, file) {
237
192
  fileCount: result.data.files.length
238
193
  });
239
194
  }
240
- /**
241
- * 파일 제거
242
- */
243
195
  async function handleDrop(basePath, file) {
244
196
  if (!file || file.trim().length === 0) {
245
197
  return errorResponse("drop", "제거할 파일 경로(file)를 입력해주세요. 예: file=\"src/old-file.ts\"");
246
198
  }
247
- // 활성 피처 확인
248
199
  const activeResult = await core.getActiveFeature(basePath);
249
200
  if (!activeResult.success) {
250
201
  return errorResponse("drop", activeResult.error || "활성 피처 조회에 실패했습니다");
@@ -262,14 +213,10 @@ async function handleDrop(basePath, file) {
262
213
  fileCount: result.data.files.length
263
214
  });
264
215
  }
265
- /**
266
- * 목표 변경
267
- */
268
216
  async function handleGoal(basePath, goal) {
269
217
  if (!goal || goal.trim().length === 0) {
270
218
  return errorResponse("goal", "새 목표(goal)를 입력해주세요. 예: goal=\"OAuth 로그인 + 소셜 연동\"");
271
219
  }
272
- // 활성 피처 확인
273
220
  const activeResult = await core.getActiveFeature(basePath);
274
221
  if (!activeResult.success) {
275
222
  return errorResponse("goal", activeResult.error || "활성 피처 조회에 실패했습니다");
@@ -287,9 +234,6 @@ async function handleGoal(basePath, goal) {
287
234
  newGoal: result.data.goal
288
235
  });
289
236
  }
290
- /**
291
- * 모든 피처 목록
292
- */
293
237
  async function handleList(basePath) {
294
238
  const listResult = await core.listFeatures(basePath);
295
239
  if (!listResult.success || !listResult.data) {
@@ -302,7 +246,6 @@ async function handleList(basePath) {
302
246
  features: []
303
247
  });
304
248
  }
305
- // 활성 피처 확인
306
249
  const projectResult = await core.getProjectContext(basePath);
307
250
  const activeId = projectResult.success && projectResult.data
308
251
  ? projectResult.data.activeFeatureId
@@ -316,7 +259,6 @@ async function handleList(basePath) {
316
259
  fileCount: f.files.length,
317
260
  updatedAt: f.updatedAt
318
261
  }));
319
- // 상태별 카운트
320
262
  const counts = {
321
263
  active: features.filter(f => f.status === "active").length,
322
264
  paused: features.filter(f => f.status === "paused").length,
@@ -1,5 +1,2 @@
1
- /**
2
- * Mask Save Tool - Save effective masks to library
3
- */
4
1
  import type { ToolFactory } from "../types.js";
5
2
  export declare function createMaskSaveTool(): ToolFactory;
@@ -1,6 +1,3 @@
1
- /**
2
- * Mask Save Tool - Save effective masks to library
3
- */
4
1
  import { z } from "zod";
5
2
  import { saveMask } from "../../retrospect/index.js";
6
3
  export function createMaskSaveTool() {
@@ -1,6 +1,3 @@
1
- /**
2
- * Memory Get Tool - Read memory file contents
3
- */
4
1
  import { z } from "zod";
5
2
  import type { ToolFactory } from '../types.js';
6
3
  export declare const memoryGetSchema: z.ZodObject<{
@@ -1,6 +1,3 @@
1
- /**
2
- * Memory Get Tool - Read memory file contents
3
- */
4
1
  import { z } from "zod";
5
2
  import { existsSync, readFileSync } from 'fs';
6
3
  export const memoryGetSchema = z.object({
@@ -1,5 +1,2 @@
1
- /**
2
- * Memory Indexer Tool - Index memory files for semantic search
3
- */
4
1
  import type { ToolFactory } from "../types.js";
5
2
  export declare function createMemoryIndexerTool(): ToolFactory;
@@ -1,15 +1,8 @@
1
- /**
2
- * Memory Indexer Tool - Index memory files for semantic search
3
- */
4
1
  import { z } from "zod";
5
2
  import { indexFile, reindexFile, indexAllMemoryFiles } from "../../memory/index.js";
6
3
  import { createProvider, selectBestProvider } from "../../memory/index.js";
7
4
  import { getMemoryProviderConfig } from "../../shared/config.js";
8
- /**
9
- * Get embedding provider based on configuration
10
- */
11
5
  async function getConfiguredProvider(worktree) {
12
- // Try to load config from maskweaver.config.json
13
6
  const memoryConfig = getMemoryProviderConfig(worktree);
14
7
  if (memoryConfig && memoryConfig.provider) {
15
8
  const providerConfig = {
@@ -30,7 +23,6 @@ async function getConfiguredProvider(worktree) {
30
23
  console.warn(`Failed to create provider: ${error}`);
31
24
  }
32
25
  }
33
- // Fallback
34
26
  const fallbackConfigs = [
35
27
  { type: "ollama", model: "bge-m3", dimensions: 1024 },
36
28
  { type: "ollama", model: "nomic-embed-text", dimensions: 768 },
@@ -53,13 +45,11 @@ Actions:
53
45
  async execute(args, context) {
54
46
  try {
55
47
  const basePath = context.worktree;
56
- // Create embedding provider from config
57
48
  const provider = await getConfiguredProvider(basePath);
58
49
  const getEmbedding = async (text) => {
59
50
  const embeddings = await provider.embed([text]);
60
51
  return embeddings[0];
61
52
  };
62
- // Execute action
63
53
  switch (args.action) {
64
54
  case "index":
65
55
  await indexFile(args.path, getEmbedding, basePath);
@@ -1,27 +1,4 @@
1
- /**
2
- * Memory Search Tool
3
- *
4
- * Hybrid search: Vector similarity + Text matching
5
- *
6
- * "Clear is better than clever." - Rob Pike
7
- *
8
- * Architecture:
9
- * - Lazy provider initialization (only on first call)
10
- * - Graceful degradation (auto-fallback to working providers)
11
- * - Result caching at provider level
12
- * - JSON response format for consistent parsing
13
- */
14
1
  import { z } from "zod";
15
- /**
16
- * Memory search arguments schema
17
- *
18
- * Sources:
19
- * - memory: Long-term knowledge (MEMORY.md)
20
- * - masks: Mask usage history and effectiveness
21
- * - retrospect: Daily retrospectives and lessons
22
- * - daily: Today's work log
23
- * - user: User preferences and information (USER.md)
24
- */
25
2
  declare const memorySearchArgsSchema: z.ZodObject<{
26
3
  query: z.ZodString;
27
4
  maxResults: z.ZodOptional<z.ZodNumber>;
@@ -38,14 +15,6 @@ type MemorySearchArgs = z.infer<typeof memorySearchArgsSchema>;
38
15
  export interface MemorySearchToolContext {
39
16
  worktree: string;
40
17
  }
41
- /**
42
- * Create memory search tool
43
- *
44
- * Factory pattern allows:
45
- * - Dependency injection (context)
46
- * - Testing with mock providers
47
- * - Configuration per instance
48
- */
49
18
  export declare function createMemorySearchTool(): {
50
19
  description: string;
51
20
  args: z.ZodObject<{
@@ -1,33 +1,7 @@
1
- /**
2
- * Memory Search Tool
3
- *
4
- * Hybrid search: Vector similarity + Text matching
5
- *
6
- * "Clear is better than clever." - Rob Pike
7
- *
8
- * Architecture:
9
- * - Lazy provider initialization (only on first call)
10
- * - Graceful degradation (auto-fallback to working providers)
11
- * - Result caching at provider level
12
- * - JSON response format for consistent parsing
13
- */
14
1
  import { z } from "zod";
15
2
  import { hybridSearch, initDatabase, getDbPath, selectBestProvider, createProvider, CONFIG, } from "../../memory/index.js";
16
3
  import { getMemoryProviderConfig } from "../../shared/config.js";
17
4
  import path from "node:path";
18
- // ============================================================================
19
- // Schema Definition
20
- // ============================================================================
21
- /**
22
- * Memory search arguments schema
23
- *
24
- * Sources:
25
- * - memory: Long-term knowledge (MEMORY.md)
26
- * - masks: Mask usage history and effectiveness
27
- * - retrospect: Daily retrospectives and lessons
28
- * - daily: Today's work log
29
- * - user: User preferences and information (USER.md)
30
- */
31
5
  const memorySearchArgsSchema = z.object({
32
6
  query: z.string().describe("Natural language search query"),
33
7
  maxResults: z.number().optional().describe("Maximum results to return (default: 6)"),
@@ -37,37 +11,14 @@ const memorySearchArgsSchema = z.object({
37
11
  .optional()
38
12
  .describe("Filter by source types (default: all)"),
39
13
  });
40
- // ============================================================================
41
- // Provider State (Singleton Pattern)
42
- // ============================================================================
43
- /**
44
- * Lazy-initialized embedding provider
45
- *
46
- * Benefits:
47
- * - No initialization cost if tool is never used
48
- * - Automatic provider selection on first use
49
- * - Shared across all search calls
50
- */
51
14
  let providerInstance = null;
52
15
  let providerWorktree = null;
53
- /**
54
- * Get or initialize the embedding provider
55
- *
56
- * Reads configuration from maskweaver.config.json if available.
57
- * Falls back to default provider chain if no config found.
58
- *
59
- * @param worktree - Project root path for config lookup
60
- * @returns Initialized provider (may be text-only fallback)
61
- */
62
16
  async function getProvider(worktree) {
63
- // Return cached provider if same worktree
64
17
  if (providerInstance && providerWorktree === worktree) {
65
18
  return providerInstance;
66
19
  }
67
- // Try to load config from maskweaver.config.json
68
20
  const memoryConfig = getMemoryProviderConfig(worktree);
69
21
  if (memoryConfig && memoryConfig.provider) {
70
- // Use configured provider
71
22
  const providerConfig = {
72
23
  type: memoryConfig.provider,
73
24
  model: memoryConfig.model,
@@ -90,7 +41,6 @@ async function getProvider(worktree) {
90
41
  console.warn(`Failed to create provider: ${error}`);
91
42
  }
92
43
  }
93
- // Fallback: Try Ollama with bge-m3 (common default)
94
44
  const fallbackConfigs = [
95
45
  { type: "ollama", model: "bge-m3", dimensions: 1024 },
96
46
  { type: "ollama", model: "nomic-embed-text", dimensions: 768 },
@@ -100,14 +50,6 @@ async function getProvider(worktree) {
100
50
  providerWorktree = worktree;
101
51
  return providerInstance;
102
52
  }
103
- /**
104
- * Create memory search tool
105
- *
106
- * Factory pattern allows:
107
- * - Dependency injection (context)
108
- * - Testing with mock providers
109
- * - Configuration per instance
110
- */
111
53
  export function createMemorySearchTool() {
112
54
  return {
113
55
  description: `Search memories using semantic similarity and keyword matching.
@@ -122,32 +64,18 @@ Keywords: "remember", "before", "last time", "previous"`,
122
64
  args: memorySearchArgsSchema,
123
65
  async execute(args, context) {
124
66
  try {
125
- // Configuration with defaults
126
67
  const maxResults = args.maxResults ?? CONFIG.search.defaultMaxResults;
127
68
  const minScore = args.minScore ?? CONFIG.search.defaultMinScore;
128
- // ====================================================================
129
- // 1. Initialize Database
130
- // ====================================================================
131
69
  const dbPath = getDbPath(context.worktree);
132
70
  await initDatabase(dbPath);
133
- // ====================================================================
134
- // 2. Get Embedding Provider (lazy initialization)
135
- // ====================================================================
136
71
  const provider = await getProvider(context.worktree);
137
- // Generate query embedding (embed takes array, returns array)
138
72
  const embeddingResults = await provider.embed([args.query]);
139
73
  const embedding = embeddingResults[0];
140
- // ====================================================================
141
- // 3. Hybrid Search
142
- // ====================================================================
143
74
  const results = hybridSearch(args.query, embedding, {
144
75
  limit: maxResults,
145
76
  minScore: minScore,
146
77
  sourceFilter: args.sources,
147
78
  });
148
- // ====================================================================
149
- // 4. Format Results
150
- // ====================================================================
151
79
  if (results.length === 0) {
152
80
  return JSON.stringify({
153
81
  results: [],
@@ -156,7 +84,6 @@ Keywords: "remember", "before", "last time", "previous"`,
156
84
  message: "No relevant memories found.",
157
85
  }, null, 2);
158
86
  }
159
- // Convert to relative paths and truncate snippets
160
87
  const formattedResults = results.map((r) => {
161
88
  const relativePath = path.relative(context.worktree, r.chunk.path);
162
89
  const snippet = r.chunk.text.length > 200
@@ -179,11 +106,7 @@ Keywords: "remember", "before", "last time", "previous"`,
179
106
  }, null, 2);
180
107
  }
181
108
  catch (error) {
182
- // ====================================================================
183
- // 5. Error Handling
184
- // ====================================================================
185
109
  const message = error instanceof Error ? error.message : String(error);
186
- // Embedding service connection failure
187
110
  if (message.includes("fetch") || message.includes("ECONNREFUSED")) {
188
111
  return JSON.stringify({
189
112
  error: true,
@@ -191,7 +114,6 @@ Keywords: "remember", "before", "last time", "previous"`,
191
114
  query: args.query,
192
115
  }, null, 2);
193
116
  }
194
- // Database initialization failure
195
117
  if (message.includes("Database") || message.includes("SQLite")) {
196
118
  return JSON.stringify({
197
119
  error: true,
@@ -199,7 +121,6 @@ Keywords: "remember", "before", "last time", "previous"`,
199
121
  query: args.query,
200
122
  }, null, 2);
201
123
  }
202
- // Generic error
203
124
  return JSON.stringify({
204
125
  error: true,
205
126
  message: message,
@@ -1,10 +1,2 @@
1
- /**
2
- * Memory Write Tool
3
- *
4
- * Saves content to memory files with automatic indexing.
5
- * Each function does one thing well.
6
- *
7
- * @author Kent Beck's Dummy Human
8
- */
9
1
  import type { ToolFactory } from "../types.js";
10
2
  export declare function createMemoryWriteTool(): ToolFactory;
@@ -1,26 +1,12 @@
1
- /**
2
- * Memory Write Tool
3
- *
4
- * Saves content to memory files with automatic indexing.
5
- * Each function does one thing well.
6
- *
7
- * @author Kent Beck's Dummy Human
8
- */
9
1
  import { z } from "zod";
10
2
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
11
3
  import { dirname, join, relative } from "path";
12
4
  import { getMemoryPath, getTodayFileName, } from "../../memory/index.js";
13
- // ============================================================================
14
- // Schema Definition
15
- // ============================================================================
16
5
  const memoryWriteArgsSchema = z.object({
17
6
  content: z.string().describe("Content to save (markdown format)"),
18
7
  target: z.enum(["daily", "memory", "user"]).describe("Target location"),
19
8
  section: z.string().optional().describe("Section title (e.g., 'User Preferences')"),
20
9
  });
21
- // ============================================================================
22
- // Tool Factory
23
- // ============================================================================
24
10
  export function createMemoryWriteTool() {
25
11
  return {
26
12
  description: `Saves content to memory files.
@@ -44,9 +30,6 @@ export function createMemoryWriteTool() {
44
30
  },
45
31
  };
46
32
  }
47
- // ============================================================================
48
- // Path Resolution
49
- // ============================================================================
50
33
  function determineFilePath(target, worktree) {
51
34
  if (target === "daily") {
52
35
  const dailyDir = getMemoryPath("daily", worktree);
@@ -54,9 +37,6 @@ function determineFilePath(target, worktree) {
54
37
  }
55
38
  return getMemoryPath(target, worktree);
56
39
  }
57
- // ============================================================================
58
- // File System Operations
59
- // ============================================================================
60
40
  function ensureDirectoryExists(filePath) {
61
41
  const dir = dirname(filePath);
62
42
  if (!existsSync(dir)) {
@@ -73,9 +53,6 @@ function saveContent(filePath, content) {
73
53
  const normalized = content.trim() + "\n";
74
54
  writeFileSync(filePath, normalized, "utf-8");
75
55
  }
76
- // ============================================================================
77
- // Content Building
78
- // ============================================================================
79
56
  function buildNewContent(existing, newText, section) {
80
57
  if (section) {
81
58
  return updateSection(existing, section, newText);
@@ -127,21 +104,12 @@ function buildEntry(timestamp, text) {
127
104
  function isEmpty(content) {
128
105
  return content.trim().length === 0;
129
106
  }
130
- // ============================================================================
131
- // Indexing
132
- // ============================================================================
133
107
  async function tryReindexing(_filePath) {
134
- // NOTE: Reindexing requires embedding provider setup
135
- // For now, skip auto-reindex on write. Use memory_indexer tool instead.
136
- // To enable: instantiate provider and call reindexFile(filePath, getEmbedding)
137
108
  }
138
109
  function logIndexingWarning(error) {
139
110
  const message = error instanceof Error ? error.message : String(error);
140
111
  console.warn("[memoryWrite] Indexing skipped:", message);
141
112
  }
142
- // ============================================================================
143
- // Response Formatting
144
- // ============================================================================
145
113
  function formatSuccessResponse(filePath, target, worktree) {
146
114
  const relativePath = relative(worktree, filePath);
147
115
  return JSON.stringify({
@@ -1,5 +1,2 @@
1
- /**
2
- * Retrospect Tool - Session retrospective
3
- */
4
1
  import type { ToolFactory } from "../types.js";
5
2
  export declare function createRetrospectTool(): ToolFactory;
@@ -1,6 +1,3 @@
1
- /**
2
- * Retrospect Tool - Session retrospective
3
- */
4
1
  import { z } from "zod";
5
2
  import { performRetrospect } from "../../retrospect/index.js";
6
3
  export function createRetrospectTool() {
@@ -1,14 +1,3 @@
1
- /**
2
- * Slashcommand Tool for OpenCode Plugin
3
- *
4
- * Handles slash commands directly as a tool, inspired by oh-my-opencode.
5
- * This ensures commands work on first run without requiring restart.
6
- *
7
- * Pattern: Commands are discovered from:
8
- * 1. Built-in embedded commands (always available)
9
- * 2. Package assets/commands/ folder
10
- * 3. Project .opencode/commands/ folder (overrides)
11
- */
12
1
  import { z } from 'zod';
13
2
  export declare function createSlashcommandTool(assetsDir?: string): {
14
3
  description: string;