brainbank 0.1.1 → 0.2.0

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 (50) hide show
  1. package/README.md +149 -16
  2. package/dist/{types-Da_zLLOl.d.ts → base-9vfWRHCV.d.ts} +131 -31
  3. package/dist/{chunk-YGSEUWLV.js → chunk-6MFTQV3O.js} +911 -674
  4. package/dist/chunk-6MFTQV3O.js.map +1 -0
  5. package/dist/chunk-7JCEW7LT.js +266 -0
  6. package/dist/chunk-7JCEW7LT.js.map +1 -0
  7. package/dist/{chunk-GOUBW7UA.js → chunk-F6SJ3U4H.js} +98 -34
  8. package/dist/chunk-F6SJ3U4H.js.map +1 -0
  9. package/dist/{chunk-MJ3Y24H6.js → chunk-FJJY4H2Y.js} +11 -11
  10. package/dist/chunk-FJJY4H2Y.js.map +1 -0
  11. package/dist/{chunk-3GAIDXRW.js → chunk-GUT5MSJT.js} +5 -11
  12. package/dist/chunk-GUT5MSJT.js.map +1 -0
  13. package/dist/{chunk-2P3EGY6S.js → chunk-QNHBCOKB.js} +2 -2
  14. package/dist/chunk-QNHBCOKB.js.map +1 -0
  15. package/dist/{chunk-4ZKBQ33J.js → chunk-V4UJKXPK.js} +23 -5
  16. package/dist/chunk-V4UJKXPK.js.map +1 -0
  17. package/dist/chunk-WR4WXKJT.js +723 -0
  18. package/dist/chunk-WR4WXKJT.js.map +1 -0
  19. package/dist/{chunk-Z5SU54HP.js → chunk-X6645UVR.js} +3 -3
  20. package/dist/chunk-X6645UVR.js.map +1 -0
  21. package/dist/cli.js +150 -100
  22. package/dist/cli.js.map +1 -1
  23. package/dist/code.d.ts +5 -5
  24. package/dist/code.js +1 -1
  25. package/dist/docs.d.ts +4 -6
  26. package/dist/docs.js +1 -1
  27. package/dist/git.d.ts +5 -5
  28. package/dist/git.js +1 -1
  29. package/dist/index.d.ts +95 -104
  30. package/dist/index.js +13 -13
  31. package/dist/memory.d.ts +5 -7
  32. package/dist/memory.js +9 -12
  33. package/dist/memory.js.map +1 -1
  34. package/dist/notes.d.ts +4 -6
  35. package/dist/notes.js +7 -10
  36. package/dist/notes.js.map +1 -1
  37. package/dist/{openai-PCTYLOWI.js → openai-CYDMYX7X.js} +2 -2
  38. package/package.json +24 -4
  39. package/dist/chunk-2P3EGY6S.js.map +0 -1
  40. package/dist/chunk-3GAIDXRW.js.map +0 -1
  41. package/dist/chunk-4ZKBQ33J.js.map +0 -1
  42. package/dist/chunk-EDKSKLX4.js +0 -490
  43. package/dist/chunk-EDKSKLX4.js.map +0 -1
  44. package/dist/chunk-GOUBW7UA.js.map +0 -1
  45. package/dist/chunk-MJ3Y24H6.js.map +0 -1
  46. package/dist/chunk-N6ZMBFDE.js +0 -224
  47. package/dist/chunk-N6ZMBFDE.js.map +0 -1
  48. package/dist/chunk-YGSEUWLV.js.map +0 -1
  49. package/dist/chunk-Z5SU54HP.js.map +0 -1
  50. /package/dist/{openai-PCTYLOWI.js.map → openai-CYDMYX7X.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'node:events';
2
- import { P as ProgressCallback, a as BrainBankConfig, I as Indexer, C as Collection, b as IndexResult, D as DocumentCollection, S as SearchResult, c as ContextOptions, d as CoEditSuggestion, e as IndexStats, R as ResolvedConfig, E as EmbeddingProvider, V as VectorIndex, f as SearchHit, g as CodeChunk, h as Database, H as HNSWIndex, M as MemoryPattern, i as Reranker } from './types-Da_zLLOl.js';
3
- export { B as BrainBankModule, j as CollectionAddOptions, k as CollectionItem, l as CollectionSearchOptions, m as DistilledStrategy, n as DocChunk, G as GitCommitRecord, o as IndexerContext, p as ModuleContext, q as SearchResultType } from './types-Da_zLLOl.js';
2
+ import { P as ProgressCallback, B as BrainBankConfig, I as Indexer, C as Collection, S as StageProgressCallback, a as IndexResult, D as DocumentCollection, b as SearchResult, c as ContextOptions, d as CoEditSuggestion, e as IndexStats, R as ResolvedConfig, E as EmbeddingProvider, V as VectorIndex, f as SearchHit, g as CodeChunk, h as Database, H as HNSWIndex, L as LearningPattern, i as Reranker } from './base-9vfWRHCV.js';
3
+ export { j as CodeResult, k as CodeResultMetadata, l as CollectionAddOptions, m as CollectionItem, n as CollectionPlugin, o as CollectionResult, p as CollectionSearchOptions, q as CommitResult, r as CommitResultMetadata, s as DistilledStrategy, t as DocChunk, u as DocumentResult, v as DocumentResultMetadata, G as GitCommitRecord, w as IndexablePlugin, x as IndexerContext, y as PatternResult, z as PatternResultMetadata, A as SearchResultType, F as SearchablePlugin, W as WatchablePlugin } from './base-9vfWRHCV.js';
4
4
  export { code } from './code.js';
5
5
  export { git } from './git.js';
6
6
  export { docs } from './docs.js';
@@ -73,31 +73,25 @@ interface ReembedOptions {
73
73
  /**
74
74
  * BrainBank — Main Orchestrator
75
75
  *
76
- * Composable semantic knowledge bank for AI agents.
77
- * Enable only the modules you need via .use():
76
+ * Thin facade that composes four services:
77
+ * IndexerRegistry — registration + lookup
78
+ * Initializer — two-phase startup (earlyInit / lateInit)
79
+ * SearchAPI — all search + context logic
80
+ * IndexAPI — code / git / docs indexing orchestration
78
81
  *
79
- * import { BrainBank } from 'brainbank';
80
- * import { code } from 'brainbank/code';
81
- * import { docs } from 'brainbank/docs';
82
- * import { notes } from 'brainbank/notes';
83
- * import { memory } from 'brainbank/memory';
84
- *
85
- * const brain = new BrainBank()
86
- * .use(code({ repoPath: '.' }))
87
- * .use(docs())
88
- * .use(notes())
89
- * .use(memory());
82
+ * All heavy logic lives in those modules; BrainBank owns state,
83
+ * guards (requireInit / initialize()), and public API shape.
90
84
  */
91
85
 
92
86
  declare class BrainBank extends EventEmitter {
93
87
  private _config;
94
88
  private _db;
95
89
  private _embedding;
96
- private _modules;
97
- private _search?;
98
- private _bm25?;
99
- private _contextBuilder?;
90
+ private _registry;
91
+ private _searchAPI?;
92
+ private _indexAPI?;
100
93
  private _initialized;
94
+ private _initPromise;
101
95
  private _watcher?;
102
96
  private _collections;
103
97
  private _kvHnsw?;
@@ -112,24 +106,17 @@ declare class BrainBank extends EventEmitter {
112
106
  use(indexer: Indexer): this;
113
107
  /** Get the list of registered indexer names. */
114
108
  get indexers(): string[];
115
- /** @deprecated Use .indexers instead. */
116
- get modules(): string[];
117
109
  /** Check if an indexer is loaded. Also matches type prefix (e.g. 'code' matches 'code:frontend'). */
118
110
  has(name: string): boolean;
119
111
  /** Get an indexer instance. Throws if not loaded. */
120
- indexer<T extends Indexer = Indexer>(name: string): T;
121
- /** @deprecated Use .indexer() instead. */
122
- module(name: string): Indexer;
123
- /** Find all indexers whose name equals or starts with the type prefix. */
124
- private _findAllByType;
125
- /** Find the first indexer that matches the type. */
126
- private _findFirstByType;
112
+ indexer<T extends Indexer = Indexer>(n: string): T;
127
113
  /**
128
114
  * Initialize database, HNSW indices, and load existing vectors.
129
115
  * Only initializes registered modules.
130
116
  * Automatically called by index/search methods if not yet initialized.
131
117
  */
132
118
  initialize(): Promise<void>;
119
+ private _runInitialize;
133
120
  /**
134
121
  * Get or create a dynamic collection.
135
122
  * Collections are the universal data primitive — store anything, search semantically.
@@ -141,24 +128,26 @@ declare class BrainBank extends EventEmitter {
141
128
  collection(name: string): Collection;
142
129
  /** List all collection names that have data. */
143
130
  listCollectionNames(): string[];
144
- /**
145
- * Index code and git history in one call.
146
- * Incremental — only processes changes since last run.
147
- */
148
131
  index(options?: {
132
+ modules?: ('code' | 'git' | 'docs')[];
149
133
  gitDepth?: number;
150
134
  forceReindex?: boolean;
151
- onProgress?: (stage: string, msg: string) => void;
135
+ onProgress?: StageProgressCallback;
152
136
  }): Promise<{
153
137
  code?: IndexResult;
154
138
  git?: IndexResult;
139
+ docs?: Record<string, {
140
+ indexed: number;
141
+ skipped: number;
142
+ chunks: number;
143
+ }>;
155
144
  }>;
156
- /** Index only code files. */
145
+ /** Index only code files (all repos in multi-repo mode). */
157
146
  indexCode(options?: {
158
147
  forceReindex?: boolean;
159
148
  onProgress?: ProgressCallback;
160
149
  }): Promise<IndexResult>;
161
- /** Index only git history. */
150
+ /** Index only git history (all repos in multi-repo mode). */
162
151
  indexGit(options?: {
163
152
  depth?: number;
164
153
  onProgress?: ProgressCallback;
@@ -203,7 +192,7 @@ declare class BrainBank extends EventEmitter {
203
192
  search(query: string, options?: {
204
193
  codeK?: number;
205
194
  gitK?: number;
206
- memoryK?: number;
195
+ patternK?: number;
207
196
  minScore?: number;
208
197
  useMMR?: boolean;
209
198
  }): Promise<SearchResult[]>;
@@ -216,26 +205,18 @@ declare class BrainBank extends EventEmitter {
216
205
  * Best quality — catches both exact keyword matches and conceptual similarities.
217
206
  */
218
207
  hybridSearch(query: string, options?: {
219
- /** @deprecated Use collections: { code: N } instead */
220
208
  codeK?: number;
221
- /** @deprecated Use collections: { git: N } instead */
222
209
  gitK?: number;
223
- memoryK?: number;
210
+ patternK?: number;
224
211
  minScore?: number;
225
212
  useMMR?: boolean;
226
- /**
227
- * Sources to include and max results per source.
228
- * Reserved keys: "code", "git", "docs" control built-in indexers.
229
- * Any other key is treated as a KV collection name.
230
- * Example: { code: 8, git: 5, docs: 4, errors: 3, slack: 2 }
231
- */
232
213
  collections?: Record<string, number>;
233
214
  }): Promise<SearchResult[]>;
234
215
  /** BM25 keyword search only (no embeddings needed). */
235
216
  searchBM25(query: string, options?: {
236
217
  codeK?: number;
237
218
  gitK?: number;
238
- memoryK?: number;
219
+ patternK?: number;
239
220
  }): SearchResult[];
240
221
  /** Rebuild FTS5 indices. */
241
222
  rebuildFTS(): void;
@@ -248,23 +229,11 @@ declare class BrainBank extends EventEmitter {
248
229
  /**
249
230
  * Start watching for file changes and auto-re-index.
250
231
  * Works with built-in and custom indexers.
251
- *
252
- * const watcher = brain.watch({
253
- * onIndex: (file, indexer) => console.log(`${indexer}: ${file}`),
254
- * });
255
- * // later: watcher.close();
256
232
  */
257
233
  watch(options?: WatchOptions): Watcher;
258
234
  /**
259
235
  * Re-embed all existing text with the current embedding provider.
260
236
  * Use this when switching providers (e.g. Local → OpenAI).
261
- * Does NOT re-parse files, git history, or documents — only regenerates vectors.
262
- *
263
- * @example
264
- * const brain = new BrainBank({ embeddingProvider: new OpenAIEmbedding() });
265
- * await brain.initialize();
266
- * const result = await brain.reembed();
267
- * // → { code: 1200, git: 500, docs: 80, kv: 45, notes: 12, total: 1837 }
268
237
  */
269
238
  reembed(options?: ReembedOptions): Promise<ReembedResult>;
270
239
  /** Close database and release resources. */
@@ -273,8 +242,7 @@ declare class BrainBank extends EventEmitter {
273
242
  get isInitialized(): boolean;
274
243
  /** The resolved configuration. */
275
244
  get config(): Readonly<ResolvedConfig>;
276
- /** Load vectors from SQLite into HNSW index. */
277
- private _loadVectors;
245
+ private _requireInit;
278
246
  }
279
247
 
280
248
  /**
@@ -294,9 +262,11 @@ declare class LocalEmbedding implements EmbeddingProvider {
294
262
  model?: string;
295
263
  cacheDir?: string;
296
264
  });
265
+ private _pipelinePromise;
297
266
  /**
298
267
  * Lazy-load the transformer pipeline.
299
268
  * Singleton — created once and reused.
269
+ * Promise-deduped to prevent concurrent downloads.
300
270
  */
301
271
  private _getPipeline;
302
272
  /**
@@ -340,7 +310,6 @@ declare class OpenAIEmbedding implements EmbeddingProvider {
340
310
  private _model;
341
311
  private _baseUrl;
342
312
  private _requestDims;
343
- private _retrying;
344
313
  constructor(options?: OpenAIEmbeddingOptions);
345
314
  embed(text: string): Promise<Float32Array>;
346
315
  embedBatch(texts: string[]): Promise<Float32Array[]>;
@@ -367,6 +336,14 @@ declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
367
336
  */
368
337
  declare function normalize(vec: Float32Array): Float32Array;
369
338
 
339
+ declare const DEFAULTS: ResolvedConfig;
340
+ /**
341
+ * Merge partial config with defaults.
342
+ * All fields become required.
343
+ * Relative dbPath is resolved against repoPath.
344
+ */
345
+ declare function resolveConfig(partial?: BrainBankConfig): ResolvedConfig;
346
+
370
347
  /**
371
348
  * BrainBank — Maximum Marginal Relevance (MMR)
372
349
  *
@@ -385,11 +362,11 @@ declare function normalize(vec: Float32Array): Float32Array;
385
362
  declare function searchMMR(index: VectorIndex, query: Float32Array, vectorCache: Map<number, Float32Array>, k: number, lambda?: number): SearchHit[];
386
363
 
387
364
  /**
388
- * BrainBank — Code Chunker
365
+ * BrainBank — Tree-Sitter Code Chunker
389
366
  *
390
- * Language-aware code splitting into semantic blocks.
391
- * Detects functions, classes, and methods using regex + brace balancing.
392
- * Falls back to sliding window for unsupported languages.
367
+ * AST-aware code splitting using native tree-sitter bindings.
368
+ * Extracts semantic blocks (functions, classes, methods, interfaces)
369
+ * from the AST. Falls back to sliding window for unsupported languages.
393
370
  */
394
371
 
395
372
  interface ChunkerConfig {
@@ -404,19 +381,39 @@ declare class CodeChunker {
404
381
  private MAX;
405
382
  private MIN;
406
383
  private OVERLAP;
384
+ private _parser;
385
+ private _langCache;
407
386
  constructor(config?: ChunkerConfig);
408
- /**
409
- * Split file content into semantic chunks.
410
- * Small files (< maxLines) become a single chunk.
411
- * For JS/TS/Python: detects functions and classes.
412
- * For other languages: sliding window with overlap.
413
- */
414
- chunk(filePath: string, content: string, language: string): CodeChunk[];
415
- private _chunkJS;
416
- private _chunkPython;
387
+ /** Lazy-init tree-sitter parser. */
388
+ private _ensureParser;
389
+ /** Load a language grammar (cached). */
390
+ private _loadGrammar;
391
+ /**
392
+ * Split file content into semantic chunks using tree-sitter AST.
393
+ * Falls back to sliding window if grammar isn't available.
394
+ */
395
+ chunk(filePath: string, content: string, language: string): Promise<CodeChunk[]>;
396
+ /** Walk AST and extract top-level semantic blocks. */
397
+ private _extractChunks;
398
+ /** Classify and process a single AST node. */
399
+ private _processNode;
400
+ /** Check which category a node type belongs to. */
401
+ private _categorize;
402
+ /** Process a matched declaration: class → split by methods, else → chunk directly. */
403
+ private _processDeclaration;
404
+ /** Split a large class into individual method chunks. */
405
+ private _splitClassIntoMethods;
406
+ /** Find the class body node. */
407
+ private _findClassBody;
408
+ /** Extract name from an AST node. */
409
+ private _extractName;
410
+ /** Map category to chunk type. */
411
+ private _toChunkType;
412
+ /** Add a node as a chunk, avoiding duplicates. */
413
+ private _addChunk;
417
414
  private _chunkGeneric;
418
- private _findBlockEnd;
419
- private _splitLarge;
415
+ /** Split a large block into overlapping sub-chunks. */
416
+ private _splitLargeBlock;
420
417
  }
421
418
 
422
419
  /**
@@ -493,11 +490,11 @@ declare class GitIndexer {
493
490
  * Indexes generic document collections (markdown, text, etc.)
494
491
  * with heading-aware smart chunking, inspired by qmd.
495
492
  *
496
- * const indexer = new DocIndexer(db, embedding, hnsw, vecCache);
493
+ * const indexer = new DocsIndexer(db, embedding, hnsw, vecCache);
497
494
  * await indexer.indexCollection('notes', '/path/to/notes', '**\/*.md');
498
495
  */
499
496
 
500
- declare class DocIndexer {
497
+ declare class DocsIndexer {
501
498
  private _db;
502
499
  private _embedding;
503
500
  private _hnsw;
@@ -532,6 +529,8 @@ declare class DocIndexer {
532
529
  * Extract document title from first heading or filename.
533
530
  */
534
531
  private _extractTitle;
532
+ /** Skip well-known output/vendor directories when walking docs. */
533
+ private _isIgnoredDocDir;
535
534
  }
536
535
 
537
536
  /**
@@ -568,18 +567,18 @@ declare class PatternStore {
568
567
  * Store a learned pattern.
569
568
  * Returns the pattern ID.
570
569
  */
571
- learn(pattern: MemoryPattern): Promise<number>;
570
+ learn(pattern: LearningPattern): Promise<number>;
572
571
  /**
573
572
  * Search for similar successful patterns.
574
573
  * Filters by minimum success rate.
575
574
  */
576
- search(query: string, k?: number, minSuccess?: number): Promise<(MemoryPattern & {
575
+ search(query: string, k?: number, minSuccess?: number): Promise<(LearningPattern & {
577
576
  score: number;
578
577
  })[]>;
579
578
  /**
580
579
  * Get all patterns for a specific task type.
581
580
  */
582
- getByTaskType(taskType: string, limit?: number): MemoryPattern[];
581
+ getByTaskType(taskType: string, limit?: number): LearningPattern[];
583
582
  /** Total number of stored patterns. */
584
583
  get count(): number;
585
584
  }
@@ -695,20 +694,20 @@ declare class NoteStore {
695
694
  }
696
695
 
697
696
  /**
698
- * BrainBank — Unified Search
697
+ * BrainBank — Multi-Index Search
699
698
  *
700
- * Searches across all three indices (code, git, memory)
699
+ * Searches across all three indices (code, git, memory patterns)
701
700
  * and returns typed results sorted by relevance.
702
701
  */
703
702
 
704
- interface SearchDeps {
703
+ interface SearchConfig {
705
704
  db: Database;
706
705
  codeHnsw?: HNSWIndex;
707
706
  gitHnsw?: HNSWIndex;
708
- memHnsw?: HNSWIndex;
707
+ patternHnsw?: HNSWIndex;
709
708
  codeVecs: Map<number, Float32Array>;
710
709
  gitVecs: Map<number, Float32Array>;
711
- memVecs: Map<number, Float32Array>;
710
+ patternVecs: Map<number, Float32Array>;
712
711
  embedding: EmbeddingProvider;
713
712
  reranker?: Reranker;
714
713
  }
@@ -717,8 +716,8 @@ interface SearchOptions {
717
716
  codeK?: number;
718
717
  /** Max git results. Default: 5 */
719
718
  gitK?: number;
720
- /** Max memory results. Default: 4 */
721
- memoryK?: number;
719
+ /** Max pattern results. Default: 4 */
720
+ patternK?: number;
722
721
  /** Minimum similarity score. Default: 0.25 */
723
722
  minScore?: number;
724
723
  /** Use MMR for diversity. Default: true */
@@ -726,9 +725,9 @@ interface SearchOptions {
726
725
  /** MMR lambda. Default: 0.7 */
727
726
  mmrLambda?: number;
728
727
  }
729
- declare class UnifiedSearch {
730
- private _deps;
731
- constructor(deps: SearchDeps);
728
+ declare class MultiIndexSearch {
729
+ private _config;
730
+ constructor(config: SearchConfig);
732
731
  /**
733
732
  * Search across all indices.
734
733
  * Returns combined results sorted by score.
@@ -771,8 +770,8 @@ declare class CoEditAnalyzer {
771
770
 
772
771
  declare class ContextBuilder {
773
772
  private _search;
774
- private _coEdits;
775
- constructor(_search: UnifiedSearch, _coEdits: CoEditAnalyzer);
773
+ private _coEdits?;
774
+ constructor(_search: MultiIndexSearch, _coEdits?: CoEditAnalyzer | undefined);
776
775
  /**
777
776
  * Build a full context block for a task.
778
777
  * Returns clean markdown ready for system prompt injection.
@@ -793,8 +792,8 @@ interface BM25Options {
793
792
  codeK?: number;
794
793
  /** Max git results. Default: 5 */
795
794
  gitK?: number;
796
- /** Max memory results. Default: 4 */
797
- memoryK?: number;
795
+ /** Max pattern results. Default: 4 */
796
+ patternK?: number;
798
797
  }
799
798
  declare class BM25Search {
800
799
  private _db;
@@ -834,12 +833,4 @@ declare class BM25Search {
834
833
  */
835
834
  declare function reciprocalRankFusion(resultSets: SearchResult[][], k?: number, maxResults?: number): SearchResult[];
836
835
 
837
- declare const DEFAULTS: ResolvedConfig;
838
- /**
839
- * Merge partial config with defaults.
840
- * All fields become required.
841
- * Relative dbPath is resolved against repoPath.
842
- */
843
- declare function resolveConfig(partial?: BrainBankConfig): ResolvedConfig;
844
-
845
- export { BM25Search, BrainBank, BrainBankConfig, CoEditAnalyzer, CoEditSuggestion, CodeChunk, CodeChunker, CodeIndexer, Collection, Consolidator, ContextBuilder, ContextOptions, DEFAULTS, DocIndexer, DocumentCollection, EmbeddingProvider, GitIndexer, HNSWIndex, IGNORE_DIRS, IndexResult, IndexStats, Indexer, LocalEmbedding, MemoryPattern, type NoteDigest, NoteStore, OpenAIEmbedding, type OpenAIEmbeddingOptions, PatternStore, ProgressCallback, type RecallOptions, type ReembedOptions, type ReembedResult, Reranker, ResolvedConfig, SUPPORTED_EXTENSIONS, SearchHit, SearchResult, type StoredNote, UnifiedSearch, VectorIndex, type WatchOptions, type Watcher, cosineSimilarity, getLanguage, isSupported, normalize, reciprocalRankFusion, resolveConfig, searchMMR };
836
+ export { BM25Search, BrainBank, BrainBankConfig, CoEditAnalyzer, CoEditSuggestion, CodeChunk, CodeChunker, CodeIndexer, Collection, Consolidator, ContextBuilder, ContextOptions, DEFAULTS, DocsIndexer, DocumentCollection, EmbeddingProvider, GitIndexer, HNSWIndex, IGNORE_DIRS, IndexResult, IndexStats, Indexer, LearningPattern, LocalEmbedding, MultiIndexSearch, type NoteDigest, NoteStore, OpenAIEmbedding, type OpenAIEmbeddingOptions, PatternStore, ProgressCallback, type RecallOptions, type ReembedOptions, type ReembedResult, Reranker, ResolvedConfig, SUPPORTED_EXTENSIONS, SearchHit, SearchResult, StageProgressCallback, type StoredNote, VectorIndex, type WatchOptions, type Watcher, cosineSimilarity, getLanguage, isSupported, normalize, reciprocalRankFusion, resolveConfig, searchMMR };
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  NoteStore
3
- } from "./chunk-MJ3Y24H6.js";
3
+ } from "./chunk-FJJY4H2Y.js";
4
4
  import {
5
5
  Consolidator,
6
6
  PatternStore
7
- } from "./chunk-Z5SU54HP.js";
7
+ } from "./chunk-X6645UVR.js";
8
8
  import {
9
9
  BM25Search,
10
10
  BrainBank,
@@ -13,10 +13,10 @@ import {
13
13
  DEFAULTS,
14
14
  HNSWIndex,
15
15
  LocalEmbedding,
16
- UnifiedSearch,
16
+ MultiIndexSearch,
17
17
  resolveConfig,
18
18
  searchMMR
19
- } from "./chunk-YGSEUWLV.js";
19
+ } from "./chunk-6MFTQV3O.js";
20
20
  import {
21
21
  CodeChunker,
22
22
  CodeIndexer,
@@ -25,26 +25,26 @@ import {
25
25
  code,
26
26
  getLanguage,
27
27
  isSupported
28
- } from "./chunk-EDKSKLX4.js";
28
+ } from "./chunk-WR4WXKJT.js";
29
29
  import {
30
30
  CoEditAnalyzer,
31
31
  GitIndexer,
32
32
  git
33
- } from "./chunk-N6ZMBFDE.js";
33
+ } from "./chunk-7JCEW7LT.js";
34
34
  import {
35
- DocIndexer,
35
+ DocsIndexer,
36
36
  docs
37
- } from "./chunk-GOUBW7UA.js";
37
+ } from "./chunk-F6SJ3U4H.js";
38
38
  import {
39
39
  reciprocalRankFusion
40
- } from "./chunk-4ZKBQ33J.js";
40
+ } from "./chunk-V4UJKXPK.js";
41
41
  import {
42
42
  cosineSimilarity,
43
43
  normalize
44
- } from "./chunk-2P3EGY6S.js";
44
+ } from "./chunk-QNHBCOKB.js";
45
45
  import {
46
46
  OpenAIEmbedding
47
- } from "./chunk-3GAIDXRW.js";
47
+ } from "./chunk-GUT5MSJT.js";
48
48
  import "./chunk-7QVYU63E.js";
49
49
  export {
50
50
  BM25Search,
@@ -56,16 +56,16 @@ export {
56
56
  Consolidator,
57
57
  ContextBuilder,
58
58
  DEFAULTS,
59
- DocIndexer,
59
+ DocsIndexer,
60
60
  GitIndexer,
61
61
  HNSWIndex,
62
62
  IGNORE_DIRS,
63
63
  LocalEmbedding,
64
+ MultiIndexSearch,
64
65
  NoteStore,
65
66
  OpenAIEmbedding,
66
67
  PatternStore,
67
68
  SUPPORTED_EXTENSIONS,
68
- UnifiedSearch,
69
69
  code,
70
70
  cosineSimilarity,
71
71
  docs,
package/dist/memory.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { B as BrainBankModule } from './types-Da_zLLOl.js';
1
+ import { I as Indexer } from './base-9vfWRHCV.js';
2
2
  import 'better-sqlite3';
3
3
 
4
4
  /**
5
- * BrainBank — Memory Module
5
+ * BrainBank — Memory Plugin
6
6
  *
7
7
  * Agent learns from completed tasks — stores patterns,
8
8
  * consolidates failures, distills strategies.
@@ -11,9 +11,7 @@ import 'better-sqlite3';
11
11
  * brain.use(memory());
12
12
  */
13
13
 
14
- interface MemoryModuleOptions {
15
- }
16
- /** Create an agent memory (learning) module. */
17
- declare function memory(opts?: MemoryModuleOptions): BrainBankModule;
14
+ /** Create an agent memory plugin. */
15
+ declare function memory(): Indexer;
18
16
 
19
- export { type MemoryModuleOptions, memory };
17
+ export { memory };
package/dist/memory.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  Consolidator,
3
3
  PatternStore
4
- } from "./chunk-Z5SU54HP.js";
5
- import "./chunk-2P3EGY6S.js";
4
+ } from "./chunk-X6645UVR.js";
5
+ import "./chunk-QNHBCOKB.js";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-7QVYU63E.js";
9
9
 
10
- // src/memory/strategy-distiller.ts
10
+ // src/memory/distiller.ts
11
11
  var StrategyDistiller = class {
12
12
  constructor(_db) {
13
13
  this._db = _db;
@@ -80,13 +80,10 @@ var StrategyDistiller = class {
80
80
  }
81
81
  };
82
82
 
83
- // src/plugins/memory.ts
84
- var MemoryModuleImpl = class {
85
- constructor(opts = {}) {
86
- this.opts = opts;
87
- }
83
+ // src/indexers/memory/memory-plugin.ts
84
+ var MemoryPlugin = class {
88
85
  static {
89
- __name(this, "MemoryModuleImpl");
86
+ __name(this, "MemoryPlugin");
90
87
  }
91
88
  name = "memory";
92
89
  hnsw;
@@ -111,7 +108,7 @@ var MemoryModuleImpl = class {
111
108
  /** Store a learned pattern. */
112
109
  async learn(pattern) {
113
110
  const id = await this.patternStore.learn(pattern);
114
- if (this.patternStore.count % 50 === 0) {
111
+ if (this.patternStore.count > 0 && this.patternStore.count % 50 === 0) {
115
112
  this.consolidator.consolidate();
116
113
  }
117
114
  return id;
@@ -136,8 +133,8 @@ var MemoryModuleImpl = class {
136
133
  };
137
134
  }
138
135
  };
139
- function memory(opts) {
140
- return new MemoryModuleImpl(opts);
136
+ function memory() {
137
+ return new MemoryPlugin();
141
138
  }
142
139
  __name(memory, "memory");
143
140
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/memory/strategy-distiller.ts","../src/plugins/memory.ts"],"sourcesContent":["/**\n * BrainBank — Strategy Distiller\n * \n * Aggregates top patterns for a task type into a single strategy text.\n * Analogous to SONA's Deep Loop — periodic knowledge distillation.\n */\n\nimport type { Database } from '../storage/database.ts';\nimport type { DistilledStrategy } from '../types.ts';\n\nexport class StrategyDistiller {\n constructor(private _db: Database) {}\n\n /**\n * Distill top patterns for a task type into a strategy.\n * Updates the distilled_strategies table.\n */\n distill(taskType: string, topK: number = 10): DistilledStrategy | null {\n const patterns = this._db.prepare(`\n SELECT task, approach, outcome, critique, success_rate\n FROM memory_patterns\n WHERE task_type = ? AND success_rate >= 0.7\n ORDER BY success_rate DESC, created_at DESC\n LIMIT ?\n `).all(taskType, topK) as any[];\n\n if (patterns.length === 0) return null;\n\n // Build strategy text from top patterns\n const lines: string[] = [];\n const avgSuccess = patterns.reduce((sum: number, p: any) => sum + p.success_rate, 0) / patterns.length;\n\n lines.push(`Strategy for \"${taskType}\" (${patterns.length} patterns, avg success ${Math.round(avgSuccess * 100)}%):`);\n lines.push('');\n\n for (const p of patterns) {\n lines.push(`• ${p.approach} (${Math.round(p.success_rate * 100)}%)`);\n if (p.critique) lines.push(` └ ${p.critique}`);\n }\n\n const strategy = lines.join('\\n');\n const confidence = avgSuccess;\n const now = Math.floor(Date.now() / 1000);\n\n this._db.prepare(`\n INSERT INTO distilled_strategies (task_type, strategy, confidence, updated_at)\n VALUES (?, ?, ?, ?)\n ON CONFLICT(task_type) DO UPDATE SET\n strategy = excluded.strategy,\n confidence = excluded.confidence,\n updated_at = excluded.updated_at\n `).run(taskType, strategy, confidence, now);\n\n return { taskType, strategy, confidence, updatedAt: now };\n }\n\n /**\n * Get a distilled strategy for a task type.\n */\n get(taskType: string): DistilledStrategy | null {\n const row = this._db.prepare(\n 'SELECT * FROM distilled_strategies WHERE task_type = ?'\n ).get(taskType) as any;\n\n if (!row) return null;\n return {\n taskType: row.task_type,\n strategy: row.strategy,\n confidence: row.confidence,\n updatedAt: row.updated_at,\n };\n }\n\n /**\n * List all distilled strategies.\n */\n list(): DistilledStrategy[] {\n const rows = this._db.prepare(\n 'SELECT * FROM distilled_strategies ORDER BY confidence DESC'\n ).all() as any[];\n\n return rows.map(r => ({\n taskType: r.task_type,\n strategy: r.strategy,\n confidence: r.confidence,\n updatedAt: r.updated_at,\n }));\n }\n}\n","/**\n * BrainBank — Memory Module\n * \n * Agent learns from completed tasks — stores patterns,\n * consolidates failures, distills strategies.\n * \n * import { memory } from 'brainbank/memory';\n * brain.use(memory());\n */\n\nimport type { BrainBankModule, ModuleContext } from './types.ts';\nimport type { HNSWIndex } from '../vector/hnsw.ts';\nimport type { Database } from '../storage/database.ts';\nimport { PatternStore } from '../memory/pattern-store.ts';\nimport { Consolidator } from '../memory/consolidator.ts';\nimport { StrategyDistiller } from '../memory/strategy-distiller.ts';\nimport type { MemoryPattern, DistilledStrategy } from '../types.ts';\n\nexport interface MemoryModuleOptions {}\n\nclass MemoryModuleImpl implements BrainBankModule {\n readonly name = 'memory';\n hnsw!: HNSWIndex;\n patternStore!: PatternStore;\n consolidator!: Consolidator;\n distiller!: StrategyDistiller;\n vecCache = new Map<number, Float32Array>();\n private _db!: Database;\n\n constructor(private opts: MemoryModuleOptions = {}) {}\n\n async initialize(ctx: ModuleContext): Promise<void> {\n this._db = ctx.db;\n this.hnsw = await ctx.createHnsw(100_000);\n ctx.loadVectors('memory_vectors', 'pattern_id', this.hnsw, this.vecCache);\n\n this.patternStore = new PatternStore({\n db: ctx.db,\n hnsw: this.hnsw,\n vectorCache: this.vecCache,\n embedding: ctx.embedding,\n });\n\n this.consolidator = new Consolidator(ctx.db, this.vecCache);\n this.distiller = new StrategyDistiller(ctx.db);\n }\n\n /** Store a learned pattern. */\n async learn(pattern: MemoryPattern): Promise<number> {\n const id = await this.patternStore.learn(pattern);\n\n // Auto-consolidate every 50 patterns\n if (this.patternStore.count % 50 === 0) {\n this.consolidator.consolidate();\n }\n\n return id;\n }\n\n /** Search for similar patterns. */\n async search(query: string, k: number = 4): Promise<(MemoryPattern & { score: number })[]> {\n return this.patternStore.search(query, k);\n }\n\n /** Consolidate: prune old failures + deduplicate. */\n consolidate(): { pruned: number; deduped: number } {\n return this.consolidator.consolidate();\n }\n\n /** Distill patterns into a strategy. */\n distill(taskType: string): DistilledStrategy | null {\n return this.distiller.distill(taskType);\n }\n\n stats(): Record<string, any> {\n return {\n patterns: this.patternStore.count,\n avgSuccess: (this._db.prepare('SELECT AVG(success_rate) as a FROM memory_patterns').get() as any).a ?? 0,\n hnswSize: this.hnsw.size,\n };\n }\n}\n\n/** Create an agent memory (learning) module. */\nexport function memory(opts?: MemoryModuleOptions): BrainBankModule {\n return new MemoryModuleImpl(opts);\n}\n"],"mappings":";;;;;;;;;;AAUO,IAAM,oBAAN,MAAwB;AAAA,EAC3B,YAAoB,KAAe;AAAf;AAAA,EAAgB;AAAA,EAXxC,OAU+B;AAAA;A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A,QAAQ,UAA4C;AAChD,WAAO,KAAK,UAAU,QAAQ,QAAQ;AAAA,EAC1C;AAAA,EAEA,QAA6B;AACzB,WAAO;AAAA,MACH,UAAU,KAAK,aAAa;AAAA,MAC5B,YAAa,KAAK,IAAI,QAAQ,oDAAoD,EAAE,IAAI,EAAU,KAAK;AAAA,MACvG,UAAU,KAAK,KAAK;AAAA,IACxB;AAAA,EACJ;AACJ;AAGO,SAAS,OAAO,MAA6C;AAChE,SAAO,IAAI,iBAAiB,IAAI;AACpC;AAFgB;","names":[]}
1
+ {"version":3,"sources":["../src/memory/distiller.ts","../src/indexers/memory/memory-plugin.ts"],"sourcesContent":["/**\n * BrainBank — Strategy Distiller\n * \n * Aggregates top patterns for a task type into a single strategy text.\n * Analogous to SONA's Deep Loop — periodic knowledge distillation.\n */\n\nimport type { Database } from '../db/database.ts';\nimport type { DistilledStrategy } from '../types.ts';\n\nexport class StrategyDistiller {\n constructor(private _db: Database) {}\n\n /**\n * Distill top patterns for a task type into a strategy.\n * Updates the distilled_strategies table.\n */\n distill(taskType: string, topK: number = 10): DistilledStrategy | null {\n const patterns = this._db.prepare(`\n SELECT task, approach, outcome, critique, success_rate\n FROM memory_patterns\n WHERE task_type = ? AND success_rate >= 0.7\n ORDER BY success_rate DESC, created_at DESC\n LIMIT ?\n `).all(taskType, topK) as any[];\n\n if (patterns.length === 0) return null;\n\n // Build strategy text from top patterns\n const lines: string[] = [];\n const avgSuccess = patterns.reduce((sum: number, p: any) => sum + p.success_rate, 0) / patterns.length;\n\n lines.push(`Strategy for \"${taskType}\" (${patterns.length} patterns, avg success ${Math.round(avgSuccess * 100)}%):`);\n lines.push('');\n\n for (const p of patterns) {\n lines.push(`• ${p.approach} (${Math.round(p.success_rate * 100)}%)`);\n if (p.critique) lines.push(` └ ${p.critique}`);\n }\n\n const strategy = lines.join('\\n');\n const confidence = avgSuccess;\n const now = Math.floor(Date.now() / 1000);\n\n this._db.prepare(`\n INSERT INTO distilled_strategies (task_type, strategy, confidence, updated_at)\n VALUES (?, ?, ?, ?)\n ON CONFLICT(task_type) DO UPDATE SET\n strategy = excluded.strategy,\n confidence = excluded.confidence,\n updated_at = excluded.updated_at\n `).run(taskType, strategy, confidence, now);\n\n return { taskType, strategy, confidence, updatedAt: now };\n }\n\n /**\n * Get a distilled strategy for a task type.\n */\n get(taskType: string): DistilledStrategy | null {\n const row = this._db.prepare(\n 'SELECT * FROM distilled_strategies WHERE task_type = ?'\n ).get(taskType) as any;\n\n if (!row) return null;\n return {\n taskType: row.task_type,\n strategy: row.strategy,\n confidence: row.confidence,\n updatedAt: row.updated_at,\n };\n }\n\n /**\n * List all distilled strategies.\n */\n list(): DistilledStrategy[] {\n const rows = this._db.prepare(\n 'SELECT * FROM distilled_strategies ORDER BY confidence DESC'\n ).all() as any[];\n\n return rows.map(r => ({\n taskType: r.task_type,\n strategy: r.strategy,\n confidence: r.confidence,\n updatedAt: r.updated_at,\n }));\n }\n}\n","/**\n * BrainBank — Memory Plugin\n * \n * Agent learns from completed tasks — stores patterns,\n * consolidates failures, distills strategies.\n * \n * import { memory } from 'brainbank/memory';\n * brain.use(memory());\n */\n\nimport type { Indexer, IndexerContext } from '../base.ts';\nimport type { HNSWIndex } from '../../providers/vector/hnsw.ts';\nimport type { Database } from '../../db/database.ts';\nimport { PatternStore } from '../../memory/store.ts';\nimport { Consolidator } from '../../memory/consolidator.ts';\nimport { StrategyDistiller } from '../../memory/distiller.ts';\nimport type { LearningPattern, DistilledStrategy } from '../../types.ts';\n\nclass MemoryPlugin implements Indexer {\n readonly name = 'memory';\n hnsw!: HNSWIndex;\n patternStore!: PatternStore;\n consolidator!: Consolidator;\n distiller!: StrategyDistiller;\n vecCache = new Map<number, Float32Array>();\n private _db!: Database;\n\n async initialize(ctx: IndexerContext): Promise<void> {\n this._db = ctx.db;\n this.hnsw = await ctx.createHnsw(100_000);\n ctx.loadVectors('memory_vectors', 'pattern_id', this.hnsw, this.vecCache);\n\n this.patternStore = new PatternStore({\n db: ctx.db,\n hnsw: this.hnsw,\n vectorCache: this.vecCache,\n embedding: ctx.embedding,\n });\n\n this.consolidator = new Consolidator(ctx.db, this.vecCache);\n this.distiller = new StrategyDistiller(ctx.db);\n }\n\n /** Store a learned pattern. */\n async learn(pattern: LearningPattern): Promise<number> {\n const id = await this.patternStore.learn(pattern);\n\n // Auto-consolidate every 50 patterns (guard against count=0)\n if (this.patternStore.count > 0 && this.patternStore.count % 50 === 0) {\n this.consolidator.consolidate();\n }\n\n return id;\n }\n\n /** Search for similar patterns. */\n async search(query: string, k: number = 4): Promise<(LearningPattern & { score: number })[]> {\n return this.patternStore.search(query, k);\n }\n\n /** Consolidate: prune old failures + deduplicate. */\n consolidate(): { pruned: number; deduped: number } {\n return this.consolidator.consolidate();\n }\n\n /** Distill patterns into a strategy. */\n distill(taskType: string): DistilledStrategy | null {\n return this.distiller.distill(taskType);\n }\n\n stats(): Record<string, any> {\n return {\n patterns: this.patternStore.count,\n avgSuccess: (this._db.prepare('SELECT AVG(success_rate) as a FROM memory_patterns').get() as any).a ?? 0,\n hnswSize: this.hnsw.size,\n };\n }\n}\n\n/** Create an agent memory plugin. */\nexport function memory(): Indexer {\n return new MemoryPlugin();\n}\n"],"mappings":";;;;;;;;;;AAUO,IAAM,oBAAN,MAAwB;AAAA,EAC3B,YAAoB,KAAe;AAAf;AAAA,EAAgB;AAAA,EAXxC,OAU+B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO3B,QAAQ,UAAkB,OAAe,IAA8B;AACnE,UAAM,WAAW,KAAK,IAAI,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAMjC,EAAE,IAAI,UAAU,IAAI;AAErB,QAAI,SAAS,WAAW,EAAG,QAAO;AAGlC,UAAM,QAAkB,CAAC;AACzB,UAAM,aAAa,SAAS,OAAO,CAAC,KAAa,MAAW,MAAM,EAAE,cAAc,CAAC,IAAI,SAAS;AAEhG,UAAM,KAAK,iBAAiB,QAAQ,MAAM,SAA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';
1
+ import { I as Indexer } from './base-9vfWRHCV.js';
2
2
  import 'better-sqlite3';
3
3
 
4
4
  /**
@@ -11,9 +11,7 @@ import 'better-sqlite3';
11
11
  * brain.use(notes());
12
12
  */
13
13
 
14
- interface NotesModuleOptions {
15
- }
16
- /** Create a notes memory module. */
17
- declare function notes(opts?: NotesModuleOptions): BrainBankModule;
14
+ /** Create a notes plugin. */
15
+ declare function notes(): Indexer;
18
16
 
19
- export { type NotesModuleOptions, notes };
17
+ export { notes };
package/dist/notes.js CHANGED
@@ -1,18 +1,15 @@
1
1
  import {
2
2
  NoteStore
3
- } from "./chunk-MJ3Y24H6.js";
4
- import "./chunk-4ZKBQ33J.js";
3
+ } from "./chunk-FJJY4H2Y.js";
4
+ import "./chunk-V4UJKXPK.js";
5
5
  import {
6
6
  __name
7
7
  } from "./chunk-7QVYU63E.js";
8
8
 
9
- // src/plugins/notes.ts
10
- var NotesModuleImpl = class {
11
- constructor(opts = {}) {
12
- this.opts = opts;
13
- }
9
+ // src/indexers/notes/notes-plugin.ts
10
+ var NotesPlugin = class {
14
11
  static {
15
- __name(this, "NotesModuleImpl");
12
+ __name(this, "NotesPlugin");
16
13
  }
17
14
  name = "notes";
18
15
  hnsw;
@@ -47,8 +44,8 @@ var NotesModuleImpl = class {
47
44
  return this.store.count();
48
45
  }
49
46
  };
50
- function notes(opts) {
51
- return new NotesModuleImpl(opts);
47
+ function notes() {
48
+ return new NotesPlugin();
52
49
  }
53
50
  __name(notes, "notes");
54
51
  export {