maskweaver 0.9.4 → 0.9.6

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 (229) hide show
  1. package/README.ko.md +638 -592
  2. package/README.md +671 -667
  3. package/dist/cli/doctor.js +5 -21
  4. package/dist/cli/install.d.ts +0 -8
  5. package/dist/cli/install.js +0 -39
  6. package/dist/context/config.d.ts +0 -22
  7. package/dist/context/config.js +0 -28
  8. package/dist/context/feature.d.ts +0 -39
  9. package/dist/context/feature.js +0 -77
  10. package/dist/context/files.d.ts +0 -13
  11. package/dist/context/files.js +1 -24
  12. package/dist/context/index.d.ts +0 -7
  13. package/dist/context/index.js +0 -12
  14. package/dist/context/project.d.ts +0 -21
  15. package/dist/context/project.js +0 -30
  16. package/dist/context/types.d.ts +0 -48
  17. package/dist/context/types.js +0 -12
  18. package/dist/context/utils.d.ts +0 -18
  19. package/dist/context/utils.js +0 -27
  20. package/dist/core/engine/promptBuilder.d.ts +0 -17
  21. package/dist/core/engine/promptBuilder.js +0 -28
  22. package/dist/core/index.d.ts +0 -6
  23. package/dist/core/index.js +0 -9
  24. package/dist/core/loader/MaskLoader.d.ts +0 -23
  25. package/dist/core/loader/MaskLoader.js +0 -29
  26. package/dist/core/schema/types.d.ts +0 -47
  27. package/dist/core/schema/types.js +0 -6
  28. package/dist/core/schema/validator.d.ts +0 -14
  29. package/dist/core/schema/validator.js +0 -18
  30. package/dist/i18n/index.d.ts +0 -18
  31. package/dist/i18n/index.js +4 -23
  32. package/dist/index.d.ts +0 -8
  33. package/dist/index.js +0 -8
  34. package/dist/lib.d.ts +0 -5
  35. package/dist/lib.js +0 -12
  36. package/dist/memory/chunking.d.ts +0 -22
  37. package/dist/memory/chunking.js +2 -37
  38. package/dist/memory/core.d.ts +0 -29
  39. package/dist/memory/core.js +1 -52
  40. package/dist/memory/index.d.ts +0 -5
  41. package/dist/memory/index.js +0 -10
  42. package/dist/memory/indexer.d.ts +0 -21
  43. package/dist/memory/indexer.js +0 -44
  44. package/dist/memory/providers/examples.d.ts +0 -5
  45. package/dist/memory/providers/examples.js +4 -64
  46. package/dist/memory/providers/factory.d.ts +0 -44
  47. package/dist/memory/providers/factory.js +0 -46
  48. package/dist/memory/providers/index.d.ts +0 -26
  49. package/dist/memory/providers/index.js +0 -28
  50. package/dist/memory/providers/ollama.d.ts +0 -6
  51. package/dist/memory/providers/ollama.js +1 -8
  52. package/dist/memory/providers/openai.d.ts +0 -6
  53. package/dist/memory/providers/openai.js +1 -8
  54. package/dist/memory/providers/openrouter.d.ts +0 -6
  55. package/dist/memory/providers/openrouter.js +0 -8
  56. package/dist/memory/providers/text-only.d.ts +0 -13
  57. package/dist/memory/providers/text-only.js +0 -17
  58. package/dist/memory/providers/types.d.ts +0 -39
  59. package/dist/memory/providers/types.js +0 -7
  60. package/dist/memory/providers/voyage.d.ts +0 -22
  61. package/dist/memory/providers/voyage.js +1 -24
  62. package/dist/memory/search/hybrid.d.ts +0 -12
  63. package/dist/memory/search/hybrid.js +1 -22
  64. package/dist/memory/store/sqlite.d.ts +0 -72
  65. package/dist/memory/store/sqlite.js +4 -127
  66. package/dist/plugin/config/index.d.ts +0 -112
  67. package/dist/plugin/config/index.js +0 -115
  68. package/dist/plugin/index.d.ts +0 -13
  69. package/dist/plugin/index.js +1 -123
  70. package/dist/plugin/tools/command-registry.d.ts +0 -6
  71. package/dist/plugin/tools/command-registry.js +0 -14
  72. package/dist/plugin/tools/context.d.ts +0 -12
  73. package/dist/plugin/tools/context.js +0 -58
  74. package/dist/plugin/tools/maskSave.d.ts +0 -3
  75. package/dist/plugin/tools/maskSave.js +0 -3
  76. package/dist/plugin/tools/memoryGet.d.ts +0 -3
  77. package/dist/plugin/tools/memoryGet.js +0 -3
  78. package/dist/plugin/tools/memoryIndexer.d.ts +0 -3
  79. package/dist/plugin/tools/memoryIndexer.js +0 -10
  80. package/dist/plugin/tools/memorySearch.d.ts +0 -31
  81. package/dist/plugin/tools/memorySearch.js +0 -79
  82. package/dist/plugin/tools/memoryWrite.d.ts +0 -8
  83. package/dist/plugin/tools/memoryWrite.js +0 -32
  84. package/dist/plugin/tools/retrospect.d.ts +0 -3
  85. package/dist/plugin/tools/retrospect.js +0 -3
  86. package/dist/plugin/tools/slashcommand.d.ts +0 -11
  87. package/dist/plugin/tools/slashcommand.js +0 -38
  88. package/dist/plugin/tools/squad.d.ts +0 -12
  89. package/dist/plugin/tools/squad.js +11 -83
  90. package/dist/plugin/tools/weave.d.ts +0 -6
  91. package/dist/plugin/tools/weave.js +0 -78
  92. package/dist/plugin/types.d.ts +0 -20
  93. package/dist/plugin/types.js +0 -7
  94. package/dist/retrospect/index.d.ts +0 -7
  95. package/dist/retrospect/index.js +0 -9
  96. package/dist/retrospect/mask-save.d.ts +0 -12
  97. package/dist/retrospect/mask-save.js +1 -80
  98. package/dist/retrospect/retrospect.d.ts +0 -18
  99. package/dist/retrospect/retrospect.js +0 -63
  100. package/dist/retrospect/strategies/base.d.ts +0 -15
  101. package/dist/retrospect/strategies/base.js +0 -7
  102. package/dist/retrospect/strategies/deep.d.ts +0 -12
  103. package/dist/retrospect/strategies/deep.js +0 -24
  104. package/dist/retrospect/strategies/index.d.ts +0 -12
  105. package/dist/retrospect/strategies/index.js +0 -12
  106. package/dist/retrospect/strategies/quick.d.ts +0 -12
  107. package/dist/retrospect/strategies/quick.js +0 -19
  108. package/dist/retrospect/strategies/standard.d.ts +0 -12
  109. package/dist/retrospect/strategies/standard.js +0 -15
  110. package/dist/retrospect/types.d.ts +0 -7
  111. package/dist/retrospect/types.js +0 -7
  112. package/dist/shared/config.d.ts +0 -105
  113. package/dist/shared/config.js +0 -33
  114. package/dist/shared/errors.d.ts +0 -18
  115. package/dist/shared/errors.js +0 -19
  116. package/dist/shared/generate-agents.d.ts +0 -69
  117. package/dist/shared/generate-agents.js +2 -86
  118. package/dist/shared/image.d.ts +0 -67
  119. package/dist/shared/image.js +6 -104
  120. package/dist/shared/index.d.ts +0 -5
  121. package/dist/shared/index.js +0 -7
  122. package/dist/shared/model-registry.d.ts +0 -72
  123. package/dist/shared/model-registry.js +5 -95
  124. package/dist/shared/types.d.ts +0 -15
  125. package/dist/shared/types.js +0 -3
  126. package/dist/shared-context/dag.d.ts +0 -105
  127. package/dist/shared-context/dag.js +3 -114
  128. package/dist/shared-context/index.d.ts +0 -5
  129. package/dist/shared-context/index.js +0 -15
  130. package/dist/shared-context/logger.d.ts +0 -37
  131. package/dist/shared-context/logger.js +0 -41
  132. package/dist/shared-context/parallel-executor.d.ts +0 -54
  133. package/dist/shared-context/parallel-executor.js +4 -56
  134. package/dist/shared-context/session.d.ts +0 -56
  135. package/dist/shared-context/session.js +0 -47
  136. package/dist/shared-context/squad.d.ts +0 -68
  137. package/dist/shared-context/squad.js +0 -63
  138. package/dist/shared-context/storage.d.ts +0 -132
  139. package/dist/shared-context/storage.js +0 -116
  140. package/dist/shared-context/task.d.ts +0 -120
  141. package/dist/shared-context/task.js +0 -152
  142. package/dist/shared-context/test/dag.test.js +9 -14
  143. package/dist/shared-context/test/logger.test.d.ts +0 -8
  144. package/dist/shared-context/test/logger.test.js +0 -52
  145. package/dist/shared-context/test/session.test.d.ts +0 -7
  146. package/dist/shared-context/test/session.test.js +0 -63
  147. package/dist/shared-context/test/squad.test.d.ts +0 -10
  148. package/dist/shared-context/test/squad.test.js +2 -68
  149. package/dist/shared-context/test/storage.test.d.ts +0 -8
  150. package/dist/shared-context/test/storage.test.js +0 -68
  151. package/dist/shared-context/test/task.test.d.ts +0 -7
  152. package/dist/shared-context/test/task.test.js +0 -54
  153. package/dist/shared-context/test/watchdog.test.d.ts +0 -7
  154. package/dist/shared-context/test/watchdog.test.js +3 -58
  155. package/dist/shared-context/types.d.ts +0 -215
  156. package/dist/shared-context/types.js +0 -125
  157. package/dist/shared-context/watchdog.d.ts +0 -127
  158. package/dist/shared-context/watchdog.js +0 -148
  159. package/dist/shared-context/worktree.d.ts +0 -68
  160. package/dist/shared-context/worktree.js +2 -34
  161. package/dist/verify/budget.d.ts +0 -29
  162. package/dist/verify/budget.js +0 -34
  163. package/dist/verify/critical-files.d.ts +0 -17
  164. package/dist/verify/critical-files.js +0 -37
  165. package/dist/verify/escalation.d.ts +0 -20
  166. package/dist/verify/escalation.js +0 -22
  167. package/dist/verify/index.d.ts +0 -5
  168. package/dist/verify/index.js +0 -11
  169. package/dist/verify/prompts.d.ts +0 -20
  170. package/dist/verify/prompts.js +0 -20
  171. package/dist/verify/types.d.ts +0 -26
  172. package/dist/verify/types.js +1 -12
  173. package/dist/verify/verifier.d.ts +0 -29
  174. package/dist/verify/verifier.js +0 -54
  175. package/dist/version.d.ts +1 -16
  176. package/dist/version.js +1 -16
  177. package/dist/weave/bridge.d.ts +0 -35
  178. package/dist/weave/bridge.js +0 -51
  179. package/dist/weave/environment/detector.d.ts +0 -6
  180. package/dist/weave/environment/detector.js +4 -45
  181. package/dist/weave/environment/index.d.ts +0 -19
  182. package/dist/weave/environment/index.js +1 -39
  183. package/dist/weave/environment/issues.d.ts +0 -35
  184. package/dist/weave/environment/issues.js +0 -59
  185. package/dist/weave/git.d.ts +0 -8
  186. package/dist/weave/git.js +0 -8
  187. package/dist/weave/index.d.ts +0 -13
  188. package/dist/weave/index.js +2 -28
  189. package/dist/weave/knowledge/global.d.ts +0 -39
  190. package/dist/weave/knowledge/global.js +2 -78
  191. package/dist/weave/loop.js +0 -3
  192. package/dist/weave/orchestrator.d.ts +0 -69
  193. package/dist/weave/orchestrator.js +1 -101
  194. package/dist/weave/phase-manager.d.ts +0 -64
  195. package/dist/weave/phase-manager.js +0 -89
  196. package/dist/weave/security/secret-scan.d.ts +0 -14
  197. package/dist/weave/security/secret-scan.js +0 -19
  198. package/dist/weave/stages/build.js +0 -15
  199. package/dist/weave/stages/execute.d.ts +0 -42
  200. package/dist/weave/stages/execute.js +4 -86
  201. package/dist/weave/stages/handoff.d.ts +0 -7
  202. package/dist/weave/stages/handoff.js +0 -43
  203. package/dist/weave/stages/index.d.ts +0 -3
  204. package/dist/weave/stages/index.js +0 -3
  205. package/dist/weave/stages/intake.d.ts +0 -8
  206. package/dist/weave/stages/intake.js +5 -65
  207. package/dist/weave/stages/map.d.ts +0 -1
  208. package/dist/weave/stages/openspec.d.ts +0 -1
  209. package/dist/weave/stages/plan.d.ts +0 -11
  210. package/dist/weave/stages/plan.js +1 -53
  211. package/dist/weave/stages/refine.d.ts +0 -7
  212. package/dist/weave/stages/refine.js +0 -7
  213. package/dist/weave/stages/research.d.ts +0 -6
  214. package/dist/weave/stages/research.js +0 -6
  215. package/dist/weave/stages/spec.d.ts +0 -12
  216. package/dist/weave/stages/spec.js +0 -17
  217. package/dist/weave/types.d.ts +0 -20
  218. package/dist/weave/types.js +0 -5
  219. package/dist/weave/verification/commands.d.ts +0 -12
  220. package/dist/weave/verification/commands.js +0 -19
  221. package/dist/weave/verification/index.d.ts +0 -6
  222. package/dist/weave/verification/index.js +1 -19
  223. package/dist/weave/verification/playwright.d.ts +0 -47
  224. package/dist/weave/verification/playwright.js +1 -90
  225. package/dist/weave/worktree.d.ts +0 -16
  226. package/dist/weave/worktree.js +0 -23
  227. package/dist/weave/yaml-repair.d.ts +0 -39
  228. package/dist/weave/yaml-repair.js +13 -116
  229. package/package.json +1 -1
@@ -1,21 +1,8 @@
1
- /**
2
- * Text-Only Provider (Null Object Pattern)
3
- *
4
- * Graceful degradation when no embedding service is available.
5
- * Returns empty vectors, allowing the system to function in text-only mode.
6
- * Vector search is skipped; only FTS keyword matching is used.
7
- *
8
- * Use case: Development, testing, or when embedding APIs are unavailable.
9
- */
10
1
  import type { Embedding, HealthCheckResult, IEmbeddingProvider, ProviderConfig } from "./types.js";
11
2
  export declare class TextOnlyProvider implements IEmbeddingProvider {
12
3
  readonly name = "Text-Only (No Embeddings)";
13
4
  readonly type: "text-only";
14
5
  readonly dimensions: number;
15
- /**
16
- * When true, signals that this provider cannot produce meaningful embeddings.
17
- * Consumers should skip vector search and rely on text/keyword search only.
18
- */
19
6
  readonly isTextOnly = true;
20
7
  constructor(config: ProviderConfig);
21
8
  healthCheck(): Promise<HealthCheckResult>;
@@ -1,35 +1,18 @@
1
- /**
2
- * Text-Only Provider (Null Object Pattern)
3
- *
4
- * Graceful degradation when no embedding service is available.
5
- * Returns empty vectors, allowing the system to function in text-only mode.
6
- * Vector search is skipped; only FTS keyword matching is used.
7
- *
8
- * Use case: Development, testing, or when embedding APIs are unavailable.
9
- */
10
1
  export class TextOnlyProvider {
11
2
  name = "Text-Only (No Embeddings)";
12
3
  type = "text-only";
13
4
  dimensions;
14
- /**
15
- * When true, signals that this provider cannot produce meaningful embeddings.
16
- * Consumers should skip vector search and rely on text/keyword search only.
17
- */
18
5
  isTextOnly = true;
19
6
  constructor(config) {
20
- // dimensions = 0 signals "no real embeddings" — consumers should skip vector ops.
21
- // If an explicit dimension is provided (e.g., for testing), honor it.
22
7
  this.dimensions = config.dimensions ?? 0;
23
8
  }
24
9
  async healthCheck() {
25
- // Always healthy - it's a fallback
26
10
  return {
27
11
  ok: true,
28
12
  hint: "Text-only mode: semantic search will be limited to keyword matching"
29
13
  };
30
14
  }
31
15
  async embed(texts) {
32
- // Return empty vectors — dimension 0 signals "no real embedding"
33
16
  return texts.map(() => []);
34
17
  }
35
18
  async embedQuery(text) {
@@ -1,23 +1,10 @@
1
- /**
2
- * Embedding Provider Types
3
- *
4
- * Clean interface design following Interface Segregation Principle.
5
- * Each provider implements the IEmbeddingProvider contract while maintaining
6
- * flexibility for provider-specific optimizations.
7
- */
8
1
  export type Embedding = number[];
9
2
  export type ProviderType = "ollama" | "openai" | "voyage" | "openrouter" | "text-only";
10
- /**
11
- * Health check result with actionable feedback
12
- */
13
3
  export interface HealthCheckResult {
14
4
  ok: boolean;
15
5
  reason?: string;
16
6
  hint?: string;
17
7
  }
18
- /**
19
- * Provider configuration - immutable after construction
20
- */
21
8
  export interface ProviderConfig {
22
9
  type: ProviderType;
23
10
  apiKey?: string;
@@ -25,38 +12,12 @@ export interface ProviderConfig {
25
12
  baseUrl?: string;
26
13
  dimensions?: number;
27
14
  }
28
- /**
29
- * Core embedding provider interface
30
- *
31
- * Design principle: "Program to an interface, not an implementation"
32
- * This enables Strategy Pattern for swappable embedding backends.
33
- */
34
15
  export interface IEmbeddingProvider {
35
- /** Provider identifier */
36
16
  readonly name: string;
37
- /** Provider type for factory selection */
38
17
  readonly type: ProviderType;
39
- /** Output vector dimensions */
40
18
  readonly dimensions: number;
41
- /**
42
- * Verify provider is ready and reachable
43
- * Should be fast and non-destructive
44
- */
45
19
  healthCheck(): Promise<HealthCheckResult>;
46
- /**
47
- * Generate embeddings for multiple texts
48
- * @param texts - Array of text strings to embed
49
- * @returns Array of embedding vectors
50
- */
51
20
  embed(texts: string[]): Promise<Embedding[]>;
52
- /**
53
- * Optional: Generate code-optimized embeddings
54
- * Some providers (like Voyage) have specialized code models
55
- */
56
21
  embedCode?(texts: string[]): Promise<Embedding[]>;
57
- /**
58
- * Optional: Generate query-optimized embedding
59
- * For asymmetric search (query vs document)
60
- */
61
22
  embedQuery?(text: string): Promise<Embedding>;
62
23
  }
@@ -1,8 +1 @@
1
- /**
2
- * Embedding Provider Types
3
- *
4
- * Clean interface design following Interface Segregation Principle.
5
- * Each provider implements the IEmbeddingProvider contract while maintaining
6
- * flexibility for provider-specific optimizations.
7
- */
8
1
  export {};
@@ -1,11 +1,3 @@
1
- /**
2
- * Voyage AI Embedding Provider
3
- *
4
- * Specialized embeddings with code-specific models (voyage-code-3).
5
- * Supports asymmetric search with input_type distinction.
6
- *
7
- * Key feature: embedCode() method for superior code understanding.
8
- */
9
1
  import type { Embedding, HealthCheckResult, IEmbeddingProvider, ProviderConfig } from "./types.js";
10
2
  export declare class VoyageProvider implements IEmbeddingProvider {
11
3
  readonly name = "Voyage AI";
@@ -17,22 +9,8 @@ export declare class VoyageProvider implements IEmbeddingProvider {
17
9
  constructor(config: ProviderConfig);
18
10
  private validateDimensions;
19
11
  healthCheck(): Promise<HealthCheckResult>;
20
- /**
21
- * General-purpose embedding (documents)
22
- */
23
12
  embed(texts: string[]): Promise<Embedding[]>;
24
- /**
25
- * Code-optimized embedding
26
- * Use voyage-code-3 model for best results
27
- */
28
13
  embedCode(texts: string[]): Promise<Embedding[]>;
29
- /**
30
- * Query-optimized embedding
31
- * For asymmetric search (query vs document)
32
- */
33
14
  embedQuery(text: string): Promise<Embedding>;
34
- /**
35
- * Core embedding method with input_type specification
36
- */
37
15
  private embedWithType;
38
16
  }
@@ -1,11 +1,3 @@
1
- /**
2
- * Voyage AI Embedding Provider
3
- *
4
- * Specialized embeddings with code-specific models (voyage-code-3).
5
- * Supports asymmetric search with input_type distinction.
6
- *
7
- * Key feature: embedCode() method for superior code understanding.
8
- */
9
1
  const VALID_DIMENSIONS = [256, 512, 1024, 2048];
10
2
  const CODE_MODELS = ["voyage-code-3"];
11
3
  const GENERAL_MODELS = ["voyage-4-lite", "voyage-4-large"];
@@ -28,7 +20,7 @@ export class VoyageProvider {
28
20
  }
29
21
  validateDimensions(dim) {
30
22
  if (!dim)
31
- return 1024; // Default for voyage-4-lite
23
+ return 1024;
32
24
  if (!VALID_DIMENSIONS.includes(dim)) {
33
25
  throw new Error(`Invalid dimensions ${dim}. Must be one of: ${VALID_DIMENSIONS.join(", ")}`);
34
26
  }
@@ -36,7 +28,6 @@ export class VoyageProvider {
36
28
  }
37
29
  async healthCheck() {
38
30
  try {
39
- // Test with a minimal embedding request
40
31
  const response = await fetch(`${this.baseUrl}/embeddings`, {
41
32
  method: "POST",
42
33
  headers: {
@@ -74,16 +65,9 @@ export class VoyageProvider {
74
65
  };
75
66
  }
76
67
  }
77
- /**
78
- * General-purpose embedding (documents)
79
- */
80
68
  async embed(texts) {
81
69
  return this.embedWithType(texts, "document");
82
70
  }
83
- /**
84
- * Code-optimized embedding
85
- * Use voyage-code-3 model for best results
86
- */
87
71
  async embedCode(texts) {
88
72
  const isCodeModel = CODE_MODELS.includes(this.model);
89
73
  if (!isCodeModel) {
@@ -91,17 +75,10 @@ export class VoyageProvider {
91
75
  }
92
76
  return this.embedWithType(texts, "document");
93
77
  }
94
- /**
95
- * Query-optimized embedding
96
- * For asymmetric search (query vs document)
97
- */
98
78
  async embedQuery(text) {
99
79
  const [embedding] = await this.embedWithType([text], "query");
100
80
  return embedding;
101
81
  }
102
- /**
103
- * Core embedding method with input_type specification
104
- */
105
82
  async embedWithType(texts, inputType) {
106
83
  const response = await fetch(`${this.baseUrl}/embeddings`, {
107
84
  method: "POST",
@@ -1,15 +1,3 @@
1
- /**
2
- * Hybrid Search - Combine vector and text search
3
- *
4
- * Simple weighted combination of vector similarity and FTS scores.
5
- * Gracefully degrades to text-only when no embedding is available.
6
- */
7
1
  import type { SearchResult } from '../core.js';
8
2
  import type { SearchOptions } from '../store/sqlite.js';
9
- /**
10
- * Hybrid search combining vector and text search.
11
- *
12
- * If queryEmbedding is empty/missing, automatically falls back
13
- * to text-only search with adjusted scoring.
14
- */
15
3
  export declare function hybridSearch(query: string, queryEmbedding: number[], options?: SearchOptions): SearchResult[];
@@ -1,42 +1,23 @@
1
- /**
2
- * Hybrid Search - Combine vector and text search
3
- *
4
- * Simple weighted combination of vector similarity and FTS scores.
5
- * Gracefully degrades to text-only when no embedding is available.
6
- */
7
1
  import { getDatabase } from '../store/sqlite.js';
8
2
  const DEFAULT_VECTOR_WEIGHT = 0.7;
9
3
  const DEFAULT_TEXT_WEIGHT = 0.3;
10
4
  const DEFAULT_MIN_SCORE = 0.35;
11
5
  const DEFAULT_MAX_RESULTS = 6;
12
- /**
13
- * Hybrid search combining vector and text search.
14
- *
15
- * If queryEmbedding is empty/missing, automatically falls back
16
- * to text-only search with adjusted scoring.
17
- */
18
6
  export function hybridSearch(query, queryEmbedding, options = {}) {
19
7
  const { limit = DEFAULT_MAX_RESULTS, minScore = DEFAULT_MIN_SCORE, vectorWeight = DEFAULT_VECTOR_WEIGHT, textWeight = DEFAULT_TEXT_WEIGHT, sourceFilter, } = options;
20
8
  const db = getDatabase();
21
- // SQLite not available - return empty results (graceful degradation)
22
9
  if (!db) {
23
10
  return [];
24
11
  }
25
- // Get more candidates for reranking
26
12
  const candidateLimit = limit * 3;
27
- // Determine if we can do vector search
28
13
  const hasEmbedding = queryEmbedding && queryEmbedding.length > 0;
29
- // Run vector search only if we have a real embedding
30
14
  const vectorResults = hasEmbedding
31
15
  ? db.searchByVector(queryEmbedding, candidateLimit, sourceFilter)
32
16
  : [];
33
- // Always try text search
34
17
  const textResults = db.searchByText(query, candidateLimit);
35
- // If both are empty, nothing to merge
36
18
  if (vectorResults.length === 0 && textResults.length === 0) {
37
19
  return [];
38
20
  }
39
- // Merge results
40
21
  const scoreMap = new Map();
41
22
  for (const result of vectorResults) {
42
23
  scoreMap.set(result.chunk.id, {
@@ -58,14 +39,12 @@ export function hybridSearch(query, queryEmbedding, options = {}) {
58
39
  });
59
40
  }
60
41
  }
61
- // Calculate combined scores
62
- // When in text-only mode, use text score directly (don't penalize via vectorWeight)
63
42
  const effectiveMinScore = hasEmbedding ? minScore : minScore * textWeight;
64
43
  const results = Array.from(scoreMap.values())
65
44
  .map(({ chunk, vectorScore, textScore }) => {
66
45
  const combinedScore = hasEmbedding
67
46
  ? vectorScore * vectorWeight + textScore * textWeight
68
- : textScore; // Pure text mode — use raw text score
47
+ : textScore;
69
48
  return {
70
49
  chunk,
71
50
  score: combinedScore,
@@ -1,21 +1,5 @@
1
- /**
2
- * SQLite Storage - Persistent chunk and embedding storage
3
- *
4
- * Uses better-sqlite3 for Node.js compatibility.
5
- * WAL mode for concurrent access.
6
- *
7
- * NOTE: better-sqlite3 is an optional dependency.
8
- * This module uses dynamic import to avoid errors when not installed.
9
- */
10
1
  import { type Chunk, type SearchResult } from '../core.js';
11
- /**
12
- * Check if SQLite is available without throwing.
13
- * Returns true if SQLite can be loaded, false otherwise.
14
- */
15
2
  export declare function isSqliteAvailable(): boolean;
16
- /**
17
- * Get the reason SQLite is unavailable.
18
- */
19
3
  export declare function getSqliteUnavailableReason(): string;
20
4
  export interface SearchOptions {
21
5
  limit?: number;
@@ -29,62 +13,19 @@ export declare class MemoryDatabase {
29
13
  private statements;
30
14
  private ftsAvailable;
31
15
  private constructor();
32
- /**
33
- * Create a new MemoryDatabase instance.
34
- * Uses async factory pattern because better-sqlite3 is dynamically imported.
35
- * Returns null if SQLite is not available (graceful degradation).
36
- */
37
16
  static create(dbPath: string): Promise<MemoryDatabase | null>;
38
- /**
39
- * Initialize database schema.
40
- */
41
17
  private initSchema;
42
- /**
43
- * Prepare SQL statements for reuse.
44
- */
45
18
  private prepareStatements;
46
- /**
47
- * Insert or update chunk.
48
- *
49
- * If embedding is empty (e.g., text-only mode), the chunk is stored
50
- * but the embedding row is skipped. This allows text search to work
51
- * while vector search gracefully returns no results for these chunks.
52
- */
53
19
  upsertChunk(chunk: Chunk, embedding: number[]): number;
54
- /**
55
- * Bulk insert chunks in transaction.
56
- */
57
20
  upsertChunks(chunks: Array<{
58
21
  chunk: Chunk;
59
22
  embedding: number[];
60
23
  }>): number[];
61
- /**
62
- * Delete chunks by path.
63
- */
64
24
  deleteChunksByPath(path: string): number;
65
- /**
66
- * Check if chunk changed.
67
- */
68
25
  isChunkChanged(path: string, hash: string): boolean;
69
- /**
70
- * Get chunks by path.
71
- */
72
26
  getChunksByPath(path: string): Chunk[];
73
- /**
74
- * Vector similarity search.
75
- *
76
- * Returns empty results if queryEmbedding is empty (e.g., text-only mode).
77
- * Skips stored embeddings with dimension mismatches instead of crashing.
78
- */
79
27
  searchByVector(queryEmbedding: number[], limit?: number, sourceFilter?: Chunk['source'][]): SearchResult[];
80
- /**
81
- * Full-text search using FTS5.
82
- * Returns empty results if FTS is not available.
83
- */
84
28
  searchByText(query: string, limit?: number): SearchResult[];
85
- /**
86
- * Normalize FTS query.
87
- */
88
29
  private normalizeFtsQuery;
89
30
  recordMaskUsage(maskName: string, taskDescription?: string, effectivenessScore?: number): void;
90
31
  getMaskStats(): Array<{
@@ -103,21 +44,8 @@ export declare class MemoryDatabase {
103
44
  optimize(): void;
104
45
  close(): void;
105
46
  }
106
- /**
107
- * Initialize the database.
108
- * Returns null if SQLite is not available (graceful degradation).
109
- */
110
47
  export declare function initDatabase(dbPath: string): Promise<MemoryDatabase | null>;
111
- /**
112
- * Get the database instance.
113
- * Returns null if SQLite is not available or not initialized.
114
- * Use this for optional memory features.
115
- */
116
48
  export declare function getDatabase(): MemoryDatabase | null;
117
- /**
118
- * Try to get the database instance, returning null if not initialized.
119
- * Use this when database access is optional (e.g., in intake stage).
120
- */
121
49
  export declare function tryGetDatabase(): MemoryDatabase | null;
122
50
  export declare function upsertChunk(chunk: Chunk, embedding: number[]): number;
123
51
  export declare function searchByVector(embedding: number[], limit?: number): SearchResult[];