maskweaver 0.9.3 → 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 (246) hide show
  1. package/README.ko.md +279 -325
  2. package/README.md +109 -113
  3. package/assets/commands/meta/commands.json +34 -34
  4. package/assets/commands/weave-agents.md +12 -52
  5. package/assets/commands/weave-approve.md +12 -51
  6. package/assets/commands/weave-archive.md +21 -0
  7. package/assets/commands/weave-build.md +20 -89
  8. package/assets/commands/weave-craft.md +22 -43
  9. package/assets/commands/weave-help.md +37 -106
  10. package/assets/commands/weave-init.md +26 -108
  11. package/assets/commands/weave-interview.md +13 -111
  12. package/assets/commands/weave-map.md +13 -99
  13. package/assets/commands/weave-prepare.md +23 -69
  14. package/assets/commands/weave-refine-plan.md +26 -59
  15. package/assets/commands/weave-repair.md +22 -70
  16. package/assets/commands/weave-status.md +22 -155
  17. package/assets/commands/weave-troubleshoot.md +11 -47
  18. package/assets/commands/weave-verify.md +23 -44
  19. package/assets/commands/weave-worktree.md +27 -69
  20. package/dist/cli/doctor.js +5 -21
  21. package/dist/cli/install.d.ts +0 -8
  22. package/dist/cli/install.js +0 -39
  23. package/dist/context/config.d.ts +0 -22
  24. package/dist/context/config.js +0 -28
  25. package/dist/context/feature.d.ts +0 -39
  26. package/dist/context/feature.js +0 -77
  27. package/dist/context/files.d.ts +0 -13
  28. package/dist/context/files.js +1 -24
  29. package/dist/context/index.d.ts +0 -7
  30. package/dist/context/index.js +0 -12
  31. package/dist/context/project.d.ts +0 -21
  32. package/dist/context/project.js +0 -30
  33. package/dist/context/types.d.ts +0 -48
  34. package/dist/context/types.js +0 -12
  35. package/dist/context/utils.d.ts +0 -18
  36. package/dist/context/utils.js +0 -27
  37. package/dist/core/engine/promptBuilder.d.ts +0 -17
  38. package/dist/core/engine/promptBuilder.js +0 -28
  39. package/dist/core/index.d.ts +0 -6
  40. package/dist/core/index.js +0 -9
  41. package/dist/core/loader/MaskLoader.d.ts +0 -23
  42. package/dist/core/loader/MaskLoader.js +0 -29
  43. package/dist/core/schema/types.d.ts +0 -47
  44. package/dist/core/schema/types.js +0 -6
  45. package/dist/core/schema/validator.d.ts +0 -14
  46. package/dist/core/schema/validator.js +0 -18
  47. package/dist/i18n/index.d.ts +0 -18
  48. package/dist/i18n/index.js +4 -23
  49. package/dist/index.d.ts +0 -8
  50. package/dist/index.js +0 -8
  51. package/dist/lib.d.ts +0 -5
  52. package/dist/lib.js +0 -12
  53. package/dist/memory/chunking.d.ts +0 -22
  54. package/dist/memory/chunking.js +2 -37
  55. package/dist/memory/core.d.ts +0 -29
  56. package/dist/memory/core.js +1 -52
  57. package/dist/memory/index.d.ts +0 -5
  58. package/dist/memory/index.js +0 -10
  59. package/dist/memory/indexer.d.ts +0 -21
  60. package/dist/memory/indexer.js +0 -44
  61. package/dist/memory/providers/examples.d.ts +0 -5
  62. package/dist/memory/providers/examples.js +4 -64
  63. package/dist/memory/providers/factory.d.ts +0 -44
  64. package/dist/memory/providers/factory.js +0 -46
  65. package/dist/memory/providers/index.d.ts +0 -26
  66. package/dist/memory/providers/index.js +0 -28
  67. package/dist/memory/providers/ollama.d.ts +0 -6
  68. package/dist/memory/providers/ollama.js +1 -8
  69. package/dist/memory/providers/openai.d.ts +0 -6
  70. package/dist/memory/providers/openai.js +1 -8
  71. package/dist/memory/providers/openrouter.d.ts +0 -6
  72. package/dist/memory/providers/openrouter.js +0 -8
  73. package/dist/memory/providers/text-only.d.ts +0 -13
  74. package/dist/memory/providers/text-only.js +0 -17
  75. package/dist/memory/providers/types.d.ts +0 -39
  76. package/dist/memory/providers/types.js +0 -7
  77. package/dist/memory/providers/voyage.d.ts +0 -22
  78. package/dist/memory/providers/voyage.js +1 -24
  79. package/dist/memory/search/hybrid.d.ts +0 -12
  80. package/dist/memory/search/hybrid.js +1 -22
  81. package/dist/memory/store/sqlite.d.ts +0 -72
  82. package/dist/memory/store/sqlite.js +4 -127
  83. package/dist/plugin/config/index.d.ts +0 -112
  84. package/dist/plugin/config/index.js +0 -115
  85. package/dist/plugin/index.d.ts +0 -13
  86. package/dist/plugin/index.js +1 -124
  87. package/dist/plugin/tools/command-registry.d.ts +0 -6
  88. package/dist/plugin/tools/command-registry.js +0 -14
  89. package/dist/plugin/tools/context.d.ts +0 -12
  90. package/dist/plugin/tools/context.js +0 -58
  91. package/dist/plugin/tools/maskSave.d.ts +0 -3
  92. package/dist/plugin/tools/maskSave.js +0 -3
  93. package/dist/plugin/tools/memoryGet.d.ts +0 -3
  94. package/dist/plugin/tools/memoryGet.js +0 -3
  95. package/dist/plugin/tools/memoryIndexer.d.ts +0 -3
  96. package/dist/plugin/tools/memoryIndexer.js +0 -10
  97. package/dist/plugin/tools/memorySearch.d.ts +0 -31
  98. package/dist/plugin/tools/memorySearch.js +0 -79
  99. package/dist/plugin/tools/memoryWrite.d.ts +0 -8
  100. package/dist/plugin/tools/memoryWrite.js +0 -32
  101. package/dist/plugin/tools/retrospect.d.ts +0 -3
  102. package/dist/plugin/tools/retrospect.js +0 -3
  103. package/dist/plugin/tools/slashcommand.d.ts +0 -11
  104. package/dist/plugin/tools/slashcommand.js +0 -38
  105. package/dist/plugin/tools/squad.d.ts +0 -12
  106. package/dist/plugin/tools/squad.js +11 -83
  107. package/dist/plugin/tools/weave.d.ts +0 -6
  108. package/dist/plugin/tools/weave.js +0 -78
  109. package/dist/plugin/types.d.ts +0 -20
  110. package/dist/plugin/types.js +0 -7
  111. package/dist/retrospect/index.d.ts +0 -7
  112. package/dist/retrospect/index.js +0 -9
  113. package/dist/retrospect/mask-save.d.ts +0 -12
  114. package/dist/retrospect/mask-save.js +1 -80
  115. package/dist/retrospect/retrospect.d.ts +0 -18
  116. package/dist/retrospect/retrospect.js +0 -63
  117. package/dist/retrospect/strategies/base.d.ts +0 -15
  118. package/dist/retrospect/strategies/base.js +0 -7
  119. package/dist/retrospect/strategies/deep.d.ts +0 -12
  120. package/dist/retrospect/strategies/deep.js +0 -24
  121. package/dist/retrospect/strategies/index.d.ts +0 -12
  122. package/dist/retrospect/strategies/index.js +0 -12
  123. package/dist/retrospect/strategies/quick.d.ts +0 -12
  124. package/dist/retrospect/strategies/quick.js +0 -19
  125. package/dist/retrospect/strategies/standard.d.ts +0 -12
  126. package/dist/retrospect/strategies/standard.js +0 -15
  127. package/dist/retrospect/types.d.ts +0 -7
  128. package/dist/retrospect/types.js +0 -7
  129. package/dist/shared/config.d.ts +0 -105
  130. package/dist/shared/config.js +0 -33
  131. package/dist/shared/errors.d.ts +0 -18
  132. package/dist/shared/errors.js +0 -19
  133. package/dist/shared/generate-agents.d.ts +0 -69
  134. package/dist/shared/generate-agents.js +2 -86
  135. package/dist/shared/image.d.ts +0 -67
  136. package/dist/shared/image.js +6 -104
  137. package/dist/shared/index.d.ts +0 -5
  138. package/dist/shared/index.js +0 -7
  139. package/dist/shared/model-registry.d.ts +0 -72
  140. package/dist/shared/model-registry.js +5 -95
  141. package/dist/shared/types.d.ts +0 -15
  142. package/dist/shared/types.js +0 -3
  143. package/dist/shared-context/dag.d.ts +0 -105
  144. package/dist/shared-context/dag.js +3 -114
  145. package/dist/shared-context/index.d.ts +0 -5
  146. package/dist/shared-context/index.js +0 -15
  147. package/dist/shared-context/logger.d.ts +0 -37
  148. package/dist/shared-context/logger.js +0 -41
  149. package/dist/shared-context/parallel-executor.d.ts +0 -54
  150. package/dist/shared-context/parallel-executor.js +4 -56
  151. package/dist/shared-context/session.d.ts +0 -56
  152. package/dist/shared-context/session.js +0 -47
  153. package/dist/shared-context/squad.d.ts +0 -68
  154. package/dist/shared-context/squad.js +0 -63
  155. package/dist/shared-context/storage.d.ts +0 -132
  156. package/dist/shared-context/storage.js +0 -116
  157. package/dist/shared-context/task.d.ts +0 -120
  158. package/dist/shared-context/task.js +0 -152
  159. package/dist/shared-context/test/dag.test.js +9 -14
  160. package/dist/shared-context/test/logger.test.d.ts +0 -8
  161. package/dist/shared-context/test/logger.test.js +0 -52
  162. package/dist/shared-context/test/session.test.d.ts +0 -7
  163. package/dist/shared-context/test/session.test.js +0 -63
  164. package/dist/shared-context/test/squad.test.d.ts +0 -10
  165. package/dist/shared-context/test/squad.test.js +2 -68
  166. package/dist/shared-context/test/storage.test.d.ts +0 -8
  167. package/dist/shared-context/test/storage.test.js +0 -68
  168. package/dist/shared-context/test/task.test.d.ts +0 -7
  169. package/dist/shared-context/test/task.test.js +0 -54
  170. package/dist/shared-context/test/watchdog.test.d.ts +0 -7
  171. package/dist/shared-context/test/watchdog.test.js +3 -58
  172. package/dist/shared-context/types.d.ts +0 -215
  173. package/dist/shared-context/types.js +0 -125
  174. package/dist/shared-context/watchdog.d.ts +0 -127
  175. package/dist/shared-context/watchdog.js +0 -148
  176. package/dist/shared-context/worktree.d.ts +0 -68
  177. package/dist/shared-context/worktree.js +2 -34
  178. package/dist/verify/budget.d.ts +0 -29
  179. package/dist/verify/budget.js +0 -34
  180. package/dist/verify/critical-files.d.ts +0 -17
  181. package/dist/verify/critical-files.js +0 -37
  182. package/dist/verify/escalation.d.ts +0 -20
  183. package/dist/verify/escalation.js +0 -22
  184. package/dist/verify/index.d.ts +0 -5
  185. package/dist/verify/index.js +0 -11
  186. package/dist/verify/prompts.d.ts +0 -20
  187. package/dist/verify/prompts.js +0 -20
  188. package/dist/verify/types.d.ts +0 -26
  189. package/dist/verify/types.js +1 -12
  190. package/dist/verify/verifier.d.ts +0 -29
  191. package/dist/verify/verifier.js +0 -54
  192. package/dist/version.d.ts +1 -16
  193. package/dist/version.js +1 -16
  194. package/dist/weave/bridge.d.ts +0 -35
  195. package/dist/weave/bridge.js +0 -51
  196. package/dist/weave/environment/detector.d.ts +0 -6
  197. package/dist/weave/environment/detector.js +4 -45
  198. package/dist/weave/environment/index.d.ts +0 -19
  199. package/dist/weave/environment/index.js +1 -39
  200. package/dist/weave/environment/issues.d.ts +0 -35
  201. package/dist/weave/environment/issues.js +0 -59
  202. package/dist/weave/git.d.ts +0 -8
  203. package/dist/weave/git.js +0 -8
  204. package/dist/weave/index.d.ts +0 -13
  205. package/dist/weave/index.js +2 -28
  206. package/dist/weave/knowledge/global.d.ts +0 -39
  207. package/dist/weave/knowledge/global.js +2 -78
  208. package/dist/weave/loop.js +0 -3
  209. package/dist/weave/orchestrator.d.ts +0 -69
  210. package/dist/weave/orchestrator.js +1 -101
  211. package/dist/weave/phase-manager.d.ts +0 -64
  212. package/dist/weave/phase-manager.js +0 -89
  213. package/dist/weave/security/secret-scan.d.ts +0 -14
  214. package/dist/weave/security/secret-scan.js +0 -19
  215. package/dist/weave/stages/build.js +0 -15
  216. package/dist/weave/stages/execute.d.ts +0 -42
  217. package/dist/weave/stages/execute.js +4 -86
  218. package/dist/weave/stages/handoff.d.ts +0 -7
  219. package/dist/weave/stages/handoff.js +0 -43
  220. package/dist/weave/stages/index.d.ts +0 -3
  221. package/dist/weave/stages/index.js +0 -3
  222. package/dist/weave/stages/intake.d.ts +0 -8
  223. package/dist/weave/stages/intake.js +5 -65
  224. package/dist/weave/stages/map.d.ts +0 -1
  225. package/dist/weave/stages/openspec.d.ts +0 -1
  226. package/dist/weave/stages/plan.d.ts +0 -11
  227. package/dist/weave/stages/plan.js +1 -53
  228. package/dist/weave/stages/refine.d.ts +0 -7
  229. package/dist/weave/stages/refine.js +0 -7
  230. package/dist/weave/stages/research.d.ts +0 -6
  231. package/dist/weave/stages/research.js +0 -6
  232. package/dist/weave/stages/spec.d.ts +0 -12
  233. package/dist/weave/stages/spec.js +0 -17
  234. package/dist/weave/types.d.ts +0 -20
  235. package/dist/weave/types.js +0 -5
  236. package/dist/weave/verification/commands.d.ts +0 -12
  237. package/dist/weave/verification/commands.js +0 -19
  238. package/dist/weave/verification/index.d.ts +0 -6
  239. package/dist/weave/verification/index.js +1 -19
  240. package/dist/weave/verification/playwright.d.ts +0 -47
  241. package/dist/weave/verification/playwright.js +1 -90
  242. package/dist/weave/worktree.d.ts +0 -16
  243. package/dist/weave/worktree.js +0 -23
  244. package/dist/weave/yaml-repair.d.ts +0 -39
  245. package/dist/weave/yaml-repair.js +13 -116
  246. package/package.json +1 -1
@@ -1,13 +1,4 @@
1
- /**
2
- * Text Chunking - Break text into manageable pieces
3
- *
4
- * Simple line-based chunking with overlap.
5
- * Preserves context at chunk boundaries.
6
- */
7
1
  import { CONFIG, hashText, determineSource } from './core.js';
8
- /**
9
- * Chunk text into overlapping segments.
10
- */
11
2
  export function chunkText(text, filePath) {
12
3
  const { maxTokens, overlapTokens, charsPerToken } = CONFIG.chunking;
13
4
  const source = determineSource(filePath);
@@ -16,32 +7,28 @@ export function chunkText(text, filePath) {
16
7
  const maxChars = maxTokens * charsPerToken;
17
8
  const overlapChars = overlapTokens * charsPerToken;
18
9
  let currentChunkLines = [];
19
- let currentChunkStart = 1; // 1-based line number
10
+ let currentChunkStart = 1;
20
11
  let currentLength = 0;
21
12
  for (let i = 0; i < lines.length; i++) {
22
13
  const line = lines[i];
23
- const lineLength = line.length + 1; // +1 for newline
14
+ const lineLength = line.length + 1;
24
15
  if (currentLength + lineLength <= maxChars) {
25
16
  currentChunkLines.push(line);
26
17
  currentLength += lineLength;
27
18
  }
28
19
  else {
29
- // Save current chunk
30
20
  if (currentChunkLines.length > 0) {
31
21
  const chunkText = currentChunkLines.join('\n');
32
22
  if (chunkText.trim().length > 0) {
33
23
  chunks.push(createChunk(filePath, currentChunkStart, currentChunkStart + currentChunkLines.length - 1, chunkText, source));
34
24
  }
35
25
  }
36
- // Calculate overlap
37
26
  const overlapLines = calculateOverlapLines(currentChunkLines, overlapChars);
38
- // Start new chunk
39
27
  currentChunkStart = i + 1 - overlapLines.length;
40
28
  currentChunkLines = [...overlapLines, line];
41
29
  currentLength = currentChunkLines.join('\n').length;
42
30
  }
43
31
  }
44
- // Save last chunk
45
32
  if (currentChunkLines.length > 0) {
46
33
  const chunkText = currentChunkLines.join('\n');
47
34
  if (chunkText.trim().length > 0) {
@@ -50,9 +37,6 @@ export function chunkText(text, filePath) {
50
37
  }
51
38
  return chunks;
52
39
  }
53
- /**
54
- * Calculate overlap lines from end of chunk.
55
- */
56
40
  function calculateOverlapLines(lines, overlapChars) {
57
41
  const result = [];
58
42
  let length = 0;
@@ -65,9 +49,6 @@ function calculateOverlapLines(lines, overlapChars) {
65
49
  }
66
50
  return result;
67
51
  }
68
- /**
69
- * Create chunk object.
70
- */
71
52
  function createChunk(path, startLine, endLine, text, source) {
72
53
  return {
73
54
  path,
@@ -78,27 +59,17 @@ function createChunk(path, startLine, endLine, text, source) {
78
59
  source,
79
60
  };
80
61
  }
81
- /**
82
- * Estimate tokens in text.
83
- */
84
62
  export function estimateTokens(text) {
85
63
  if (!text || text.length === 0)
86
64
  return 0;
87
- // Korean characters: ~2 tokens per char
88
65
  const koreanChars = (text.match(/[\uAC00-\uD7A3]/g) || []).length;
89
- // English words: ~1.3 tokens per word
90
66
  const englishWords = (text.match(/[a-zA-Z]+/g) || []).length;
91
- // Other chars
92
67
  const otherChars = text.length - koreanChars - (englishWords * 5);
93
68
  const koreanTokens = koreanChars * 2;
94
69
  const englishTokens = englishWords * 1.3;
95
70
  const otherTokens = Math.max(0, otherChars) / 4;
96
71
  return Math.ceil(koreanTokens + englishTokens + otherTokens);
97
72
  }
98
- /**
99
- * Split text into sentences.
100
- * Handles both English and Korean.
101
- */
102
73
  export function splitIntoSentences(text) {
103
74
  const sentenceEnders = /([.!?。!?])\s+/g;
104
75
  const sentences = [];
@@ -114,9 +85,6 @@ export function splitIntoSentences(text) {
114
85
  return sentences.filter(s => s.length > 0);
115
86
  }
116
87
  const HEADER_REGEX = /^(#{1,6})\s+(.+)$/;
117
- /**
118
- * Parse markdown into sections.
119
- */
120
88
  export function parseMarkdownSections(content) {
121
89
  const lines = content.split('\n');
122
90
  const sections = [];
@@ -128,7 +96,6 @@ export function parseMarkdownSections(content) {
128
96
  const lineNumber = i + 1;
129
97
  const headerMatch = line.match(HEADER_REGEX);
130
98
  if (headerMatch) {
131
- // Save previous section
132
99
  if (currentSection !== null || currentLines.length > 0) {
133
100
  sections.push({
134
101
  header: currentSection?.header || '',
@@ -138,7 +105,6 @@ export function parseMarkdownSections(content) {
138
105
  endLine: lineNumber - 1
139
106
  });
140
107
  }
141
- // Start new section
142
108
  currentSection = {
143
109
  header: headerMatch[2],
144
110
  content: '',
@@ -153,7 +119,6 @@ export function parseMarkdownSections(content) {
153
119
  currentLines.push(line);
154
120
  }
155
121
  }
156
- // Save last section
157
122
  if (currentLines.length > 0) {
158
123
  sections.push({
159
124
  header: currentSection?.header || '',
@@ -1,8 +1,3 @@
1
- /**
2
- * Memory Core - Simple utilities for text processing
3
- *
4
- * Clear is better than clever.
5
- */
6
1
  export declare const CONFIG: {
7
2
  readonly chunking: {
8
3
  readonly maxTokens: 400;
@@ -36,34 +31,10 @@ export interface SearchResult {
36
31
  score: number;
37
32
  matchType: 'vector' | 'text' | 'hybrid';
38
33
  }
39
- /**
40
- * Hash text using djb2 algorithm.
41
- * Simple, fast, good enough for our use case.
42
- */
43
34
  export declare function hashText(text: string): string;
44
- /**
45
- * Estimate token count.
46
- * Rough approximation: 4 chars ≈ 1 token
47
- */
48
35
  export declare function estimateTokens(text: string): number;
49
- /**
50
- * Determine source type from file path.
51
- */
52
36
  export declare function determineSource(filePath: string): SourceType;
53
- /**
54
- * Calculate cosine similarity between two vectors.
55
- * Single pass for efficiency.
56
- *
57
- * Returns 0 on dimension mismatch instead of throwing,
58
- * to prevent a single bad embedding from crashing the entire search.
59
- */
60
37
  export declare function cosineSimilarity(a: number[], b: number[]): number;
61
- /**
62
- * Float32 version - more memory efficient.
63
- *
64
- * Returns 0 on dimension mismatch instead of throwing,
65
- * to prevent a single bad embedding from crashing the entire search.
66
- */
67
38
  export declare function cosineSimilarityFloat32(a: Float32Array, b: Float32Array): number;
68
39
  export declare function toFloat32Array(embedding: number[]): Float32Array;
69
40
  export declare function embeddingToBlob(embedding: number[]): Buffer;
@@ -1,12 +1,4 @@
1
- /**
2
- * Memory Core - Simple utilities for text processing
3
- *
4
- * Clear is better than clever.
5
- */
6
1
  import { join } from "path";
7
- // ============================================================================
8
- // Configuration
9
- // ============================================================================
10
2
  export const CONFIG = {
11
3
  chunking: {
12
4
  maxTokens: 400,
@@ -23,31 +15,17 @@ export const CONFIG = {
23
15
  defaultMinScore: 0.35,
24
16
  },
25
17
  };
26
- // ============================================================================
27
- // Text Processing
28
- // ============================================================================
29
- /**
30
- * Hash text using djb2 algorithm.
31
- * Simple, fast, good enough for our use case.
32
- */
33
18
  export function hashText(text) {
34
19
  let hash = 5381;
35
20
  for (let i = 0; i < text.length; i++) {
36
21
  hash = ((hash << 5) + hash) + text.charCodeAt(i);
37
- hash = hash & hash; // Convert to 32bit integer
22
+ hash = hash & hash;
38
23
  }
39
24
  return Math.abs(hash).toString(16);
40
25
  }
41
- /**
42
- * Estimate token count.
43
- * Rough approximation: 4 chars ≈ 1 token
44
- */
45
26
  export function estimateTokens(text) {
46
27
  return Math.ceil(text.length / CONFIG.chunking.charsPerToken);
47
28
  }
48
- /**
49
- * Determine source type from file path.
50
- */
51
29
  export function determineSource(filePath) {
52
30
  const lower = filePath.toLowerCase().replace(/\\/g, '/');
53
31
  if (lower.includes('/daily/') || (lower.endsWith('.md') && /\d{4}-\d{2}-\d{2}/.test(lower))) {
@@ -67,18 +45,7 @@ export function determineSource(filePath) {
67
45
  }
68
46
  return 'code';
69
47
  }
70
- // ============================================================================
71
- // Similarity
72
- // ============================================================================
73
- // Deduplicated warning: only log dimension mismatch once per session
74
48
  let _dimensionMismatchWarned = false;
75
- /**
76
- * Calculate cosine similarity between two vectors.
77
- * Single pass for efficiency.
78
- *
79
- * Returns 0 on dimension mismatch instead of throwing,
80
- * to prevent a single bad embedding from crashing the entire search.
81
- */
82
49
  export function cosineSimilarity(a, b) {
83
50
  if (a.length === 0 || b.length === 0)
84
51
  return 0;
@@ -104,12 +71,6 @@ export function cosineSimilarity(a, b) {
104
71
  const magnitude = Math.sqrt(magnitudeA) * Math.sqrt(magnitudeB);
105
72
  return magnitude === 0 ? 0 : dotProduct / magnitude;
106
73
  }
107
- /**
108
- * Float32 version - more memory efficient.
109
- *
110
- * Returns 0 on dimension mismatch instead of throwing,
111
- * to prevent a single bad embedding from crashing the entire search.
112
- */
113
74
  export function cosineSimilarityFloat32(a, b) {
114
75
  if (a.length === 0 || b.length === 0)
115
76
  return 0;
@@ -135,9 +96,6 @@ export function cosineSimilarityFloat32(a, b) {
135
96
  const magnitude = Math.sqrt(magnitudeA) * Math.sqrt(magnitudeB);
136
97
  return magnitude === 0 ? 0 : dotProduct / magnitude;
137
98
  }
138
- // ============================================================================
139
- // Embedding Conversion
140
- // ============================================================================
141
99
  export function toFloat32Array(embedding) {
142
100
  return new Float32Array(embedding);
143
101
  }
@@ -152,9 +110,6 @@ export function blobToNumberArray(blob) {
152
110
  const float32 = new Float32Array(blob.buffer, blob.byteOffset, blob.byteLength / 4);
153
111
  return Array.from(float32);
154
112
  }
155
- // ============================================================================
156
- // Date Utilities
157
- // ============================================================================
158
113
  export function getTodayFileName() {
159
114
  const now = new Date();
160
115
  const year = now.getFullYear();
@@ -168,9 +123,6 @@ export function dateToFileName(date) {
168
123
  const day = String(date.getDate()).padStart(2, '0');
169
124
  return `${year}-${month}-${day}.md`;
170
125
  }
171
- // ============================================================================
172
- // Path Utilities
173
- // ============================================================================
174
126
  export function getMemoryPath(type, basePath = process.cwd()) {
175
127
  const memoryDir = join(basePath, CONFIG.paths.memoryDir);
176
128
  switch (type) {
@@ -194,9 +146,6 @@ export function getDbPath(basePath = process.cwd()) {
194
146
  export function getDataDir(basePath = process.cwd()) {
195
147
  return join(basePath, CONFIG.paths.dataDir);
196
148
  }
197
- // ============================================================================
198
- // Utilities
199
- // ============================================================================
200
149
  export function sleep(ms) {
201
150
  return new Promise(resolve => setTimeout(resolve, ms));
202
151
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * @maskweaver/memory
3
- *
4
- * Memory system with embeddings and vector search
5
- */
6
1
  export type { SourceType, MemoryType, Chunk, SearchResult, } from "./core.js";
7
2
  export { CONFIG, hashText, estimateTokens, determineSource, cosineSimilarity, cosineSimilarityFloat32, toFloat32Array, embeddingToBlob, blobToEmbedding, blobToNumberArray, getTodayFileName, dateToFileName, getMemoryPath, getDbPath, getDataDir, sleep, getConfig, } from "./core.js";
8
3
  export type { Embedding, ProviderType, HealthCheckResult, ProviderConfig, IEmbeddingProvider, } from "./providers/types.js";
@@ -1,21 +1,11 @@
1
- /**
2
- * @maskweaver/memory
3
- *
4
- * Memory system with embeddings and vector search
5
- */
6
1
  export { CONFIG, hashText, estimateTokens, determineSource, cosineSimilarity, cosineSimilarityFloat32, toFloat32Array, embeddingToBlob, blobToEmbedding, blobToNumberArray, getTodayFileName, dateToFileName, getMemoryPath, getDbPath, getDataDir, sleep, getConfig, } from "./core.js";
7
2
  export { OllamaProvider } from "./providers/ollama.js";
8
3
  export { OpenAIProvider } from "./providers/openai.js";
9
4
  export { VoyageProvider } from "./providers/voyage.js";
10
5
  export { OpenRouterProvider } from "./providers/openrouter.js";
11
6
  export { TextOnlyProvider } from "./providers/text-only.js";
12
- // Provider factory
13
7
  export { createProvider, selectBestProvider, getDefaultConfigs, } from "./providers/factory.js";
14
- // Chunking
15
8
  export { chunkText, parseMarkdownSections, splitIntoSentences } from "./chunking.js";
16
- // Storage
17
9
  export { MemoryDatabase, initDatabase, getDatabase, tryGetDatabase, isSqliteAvailable, getSqliteUnavailableReason, upsertChunk, searchByVector, searchByText, deleteChunksByPath, getChunksByPath, } from "./store/sqlite.js";
18
- // Search
19
10
  export { hybridSearch } from "./search/hybrid.js";
20
- // Indexing
21
11
  export { indexFile, reindexFile, indexAllMemoryFiles, classifySource, } from "./indexer.js";
@@ -1,8 +1,3 @@
1
- /**
2
- * File Indexer - Process markdown files into searchable chunks
3
- *
4
- * Read file → Parse sections → Chunk → Hash → Embed → Store
5
- */
6
1
  import { type SourceType } from './core.js';
7
2
  type EmbeddingProvider = (text: string) => Promise<number[]>;
8
3
  export interface MarkdownSection {
@@ -12,25 +7,9 @@ export interface MarkdownSection {
12
7
  startLine: number;
13
8
  endLine: number;
14
9
  }
15
- /**
16
- * Parse markdown into sections.
17
- */
18
10
  export declare function parseMarkdownSections(content: string): MarkdownSection[];
19
- /**
20
- * Classify source from file path.
21
- */
22
11
  export declare function classifySource(filePath: string): SourceType;
23
- /**
24
- * Index a single file.
25
- * Only re-embeds chunks that changed (based on hash).
26
- */
27
12
  export declare function indexFile(filePath: string, getEmbedding: EmbeddingProvider, basePath?: string): Promise<void>;
28
- /**
29
- * Reindex file (delete all chunks and reindex).
30
- */
31
13
  export declare function reindexFile(filePath: string, getEmbedding: EmbeddingProvider, basePath?: string): Promise<void>;
32
- /**
33
- * Index all memory files in directory.
34
- */
35
14
  export declare function indexAllMemoryFiles(baseDir: string, getEmbedding: EmbeddingProvider, basePath?: string): Promise<void>;
36
15
  export {};
@@ -1,16 +1,8 @@
1
- /**
2
- * File Indexer - Process markdown files into searchable chunks
3
- *
4
- * Read file → Parse sections → Chunk → Hash → Embed → Store
5
- */
6
1
  import { readFile } from 'fs/promises';
7
2
  import { chunkText } from './chunking.js';
8
3
  import { initDatabase, upsertChunk, deleteChunksByPath, getChunksByPath } from './store/sqlite.js';
9
4
  import { getDbPath } from './core.js';
10
5
  const HEADER_REGEX = /^(#{1,6})\s+(.+)$/;
11
- /**
12
- * Parse markdown into sections.
13
- */
14
6
  export function parseMarkdownSections(content) {
15
7
  const lines = content.split('\n');
16
8
  const sections = [];
@@ -22,7 +14,6 @@ export function parseMarkdownSections(content) {
22
14
  const lineNumber = i + 1;
23
15
  const headerMatch = line.match(HEADER_REGEX);
24
16
  if (headerMatch) {
25
- // Save previous section
26
17
  if (currentSection !== null || currentLines.length > 0) {
27
18
  sections.push({
28
19
  header: currentSection?.header || '',
@@ -32,7 +23,6 @@ export function parseMarkdownSections(content) {
32
23
  endLine: lineNumber - 1
33
24
  });
34
25
  }
35
- // Start new section
36
26
  currentSection = {
37
27
  header: headerMatch[2],
38
28
  content: '',
@@ -47,7 +37,6 @@ export function parseMarkdownSections(content) {
47
37
  currentLines.push(line);
48
38
  }
49
39
  }
50
- // Save last section
51
40
  if (currentLines.length > 0) {
52
41
  sections.push({
53
42
  header: currentSection?.header || '',
@@ -59,9 +48,6 @@ export function parseMarkdownSections(content) {
59
48
  }
60
49
  return sections;
61
50
  }
62
- /**
63
- * Classify source from file path.
64
- */
65
51
  export function classifySource(filePath) {
66
52
  const normalized = filePath.replace(/\\/g, '/').toLowerCase();
67
53
  const fileName = normalized.split('/').pop() || '';
@@ -77,34 +63,17 @@ export function classifySource(filePath) {
77
63
  return 'daily';
78
64
  return 'memory';
79
65
  }
80
- // ============================================================================
81
- // File Processing
82
- // ============================================================================
83
- /**
84
- * Process markdown file into chunks.
85
- */
86
66
  async function processFile(filePath) {
87
67
  const content = await readFile(filePath, 'utf-8');
88
68
  return chunkText(content, filePath);
89
69
  }
90
- // ============================================================================
91
- // Indexing
92
- // ============================================================================
93
- /**
94
- * Index a single file.
95
- * Only re-embeds chunks that changed (based on hash).
96
- */
97
70
  export async function indexFile(filePath, getEmbedding, basePath) {
98
71
  console.log(`[Indexer] Processing: ${filePath}`);
99
- // Initialize database
100
72
  await initDatabase(getDbPath(basePath));
101
- // Process file
102
73
  const chunks = await processFile(filePath);
103
74
  console.log(`[Indexer] Generated ${chunks.length} chunks`);
104
- // Get existing chunks for hash comparison
105
75
  const existingChunks = getChunksByPath(filePath);
106
76
  const existingHashes = new Set(existingChunks.map(c => c.hash));
107
- // Process only changed chunks
108
77
  let newCount = 0;
109
78
  let skippedCount = 0;
110
79
  for (const chunk of chunks) {
@@ -112,22 +81,16 @@ export async function indexFile(filePath, getEmbedding, basePath) {
112
81
  skippedCount++;
113
82
  continue;
114
83
  }
115
- // New or changed chunk - compute embedding
116
84
  const embedding = await getEmbedding(chunk.text);
117
85
  upsertChunk(chunk, embedding);
118
86
  newCount++;
119
87
  }
120
88
  console.log(`[Indexer] Completed: ${newCount} new, ${skippedCount} unchanged`);
121
89
  }
122
- /**
123
- * Reindex file (delete all chunks and reindex).
124
- */
125
90
  export async function reindexFile(filePath, getEmbedding, basePath) {
126
91
  console.log(`[Indexer] Reindexing: ${filePath}`);
127
92
  await initDatabase(getDbPath(basePath));
128
- // Delete existing chunks
129
93
  deleteChunksByPath(filePath);
130
- // Process and index all chunks
131
94
  const chunks = await processFile(filePath);
132
95
  for (const chunk of chunks) {
133
96
  const embedding = await getEmbedding(chunk.text);
@@ -135,13 +98,9 @@ export async function reindexFile(filePath, getEmbedding, basePath) {
135
98
  }
136
99
  console.log(`[Indexer] Reindexed ${chunks.length} chunks`);
137
100
  }
138
- /**
139
- * Index all memory files in directory.
140
- */
141
101
  export async function indexAllMemoryFiles(baseDir, getEmbedding, basePath) {
142
102
  console.log(`[Indexer] Scanning directory: ${baseDir}`);
143
103
  await initDatabase(getDbPath(basePath || baseDir));
144
- // Main memory files
145
104
  const mainFiles = ['MEMORY.md', 'MASKS.md', 'RETROSPECT.md', 'USER.md'];
146
105
  let totalFiles = 0;
147
106
  for (const fileName of mainFiles) {
@@ -151,11 +110,8 @@ export async function indexAllMemoryFiles(baseDir, getEmbedding, basePath) {
151
110
  totalFiles++;
152
111
  }
153
112
  catch (error) {
154
- // File doesn't exist or not readable
155
113
  console.log(`[Indexer] Skipping ${fileName}: ${error}`);
156
114
  }
157
115
  }
158
- // TODO: Scan daily directory
159
- // This requires glob or fs.readdir
160
116
  console.log(`[Indexer] Completed indexing ${totalFiles} files`);
161
117
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * Embedding Provider Usage Examples
3
- *
4
- * Practical examples showing how to use the provider system.
5
- */
6
1
  declare function example1_autoSelection(): Promise<void>;
7
2
  declare function example2_manualSelection(): Promise<void>;
8
3
  declare function example3_codeEmbedding(): Promise<void>;