brainbank 0.8.6 → 0.9.1
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.
- package/README.md +9 -0
- package/dist/{chunk-IRKE4KMJ.js → chunk-6NM6WRDX.js} +52 -15
- package/dist/chunk-6NM6WRDX.js.map +1 -0
- package/dist/cli.js +203 -63
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +6 -12
- package/dist/index.js +1 -1
- package/package.json +5 -4
- package/src/cli/commands/help.ts +3 -0
- package/src/cli/commands/index.ts +37 -6
- package/src/cli/commands/mcp-export.ts +163 -0
- package/src/cli/index.ts +7 -0
- package/src/constants.ts +8 -0
- package/src/db/adapter.ts +3 -3
- package/src/db/sqlite-adapter.ts +32 -22
- package/src/engine/reembed.ts +2 -2
- package/src/providers/vector/hnsw-loader.ts +2 -2
- package/dist/chunk-IRKE4KMJ.js.map +0 -1
package/README.md
CHANGED
|
@@ -24,6 +24,15 @@ BrainBank gives LLMs a long-term memory that persists between sessions.
|
|
|
24
24
|
npm i -g brainbank @brainbank/code @brainbank/git @brainbank/docs
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
> [!IMPORTANT]
|
|
28
|
+
> **Node 23+ users:** `@brainbank/code` uses [tree-sitter](https://github.com/tree-sitter/node-tree-sitter) native bindings for AST parsing. On **Node 23 and 24**, V8 headers require C++20 but tree-sitter's `binding.gyp` defaults to C++17, causing the install to fail with `"C++20 or later required."`. Fix it by setting the C++ standard before install:
|
|
29
|
+
>
|
|
30
|
+
> ```bash
|
|
31
|
+
> CXXFLAGS="-std=c++20" npm i -g brainbank
|
|
32
|
+
> ```
|
|
33
|
+
>
|
|
34
|
+
> Node ≤22 is unaffected — prebuilt binaries are available and no compilation is needed.
|
|
35
|
+
|
|
27
36
|
> If you get `ERESOLVE` errors, use `npm i --legacy-peer-deps` — tree-sitter grammars have overlapping peer dep ranges.
|
|
28
37
|
|
|
29
38
|
### CLI — zero code
|
|
@@ -60,12 +60,16 @@ function resolveConfig(partial = {}) {
|
|
|
60
60
|
__name(resolveConfig, "resolveConfig");
|
|
61
61
|
|
|
62
62
|
// src/constants.ts
|
|
63
|
+
import { createRequire } from "module";
|
|
64
|
+
var require2 = createRequire(import.meta.url);
|
|
65
|
+
var pkg = require2("../package.json");
|
|
66
|
+
var VERSION = pkg.version;
|
|
63
67
|
var HNSW = {
|
|
64
68
|
KV: "kv"
|
|
65
69
|
};
|
|
66
70
|
|
|
67
71
|
// src/db/sqlite-adapter.ts
|
|
68
|
-
import
|
|
72
|
+
import { DatabaseSync } from "node:sqlite";
|
|
69
73
|
import * as fs from "fs";
|
|
70
74
|
import * as path2 from "path";
|
|
71
75
|
var SCHEMA_VERSION = 9;
|
|
@@ -158,7 +162,7 @@ function wrapStatement(stmt) {
|
|
|
158
162
|
const info = stmt.run(...params);
|
|
159
163
|
return {
|
|
160
164
|
lastInsertRowid: info.lastInsertRowid,
|
|
161
|
-
changes: info.changes
|
|
165
|
+
changes: Number(info.changes)
|
|
162
166
|
};
|
|
163
167
|
},
|
|
164
168
|
iterate(...params) {
|
|
@@ -183,11 +187,11 @@ var SQLiteAdapter = class {
|
|
|
183
187
|
if (!fs.existsSync(dir)) {
|
|
184
188
|
fs.mkdirSync(dir, { recursive: true });
|
|
185
189
|
}
|
|
186
|
-
this._db = new
|
|
187
|
-
this._db.
|
|
188
|
-
this._db.
|
|
189
|
-
this._db.
|
|
190
|
-
this._db.
|
|
190
|
+
this._db = new DatabaseSync(dbPath);
|
|
191
|
+
this._db.exec("PRAGMA journal_mode = WAL");
|
|
192
|
+
this._db.exec("PRAGMA busy_timeout = 5000");
|
|
193
|
+
this._db.exec("PRAGMA synchronous = NORMAL");
|
|
194
|
+
this._db.exec("PRAGMA foreign_keys = ON");
|
|
191
195
|
createSchema(this);
|
|
192
196
|
}
|
|
193
197
|
/** Prepare a reusable statement. */
|
|
@@ -200,25 +204,31 @@ var SQLiteAdapter = class {
|
|
|
200
204
|
}
|
|
201
205
|
/** Run a function inside a transaction. Auto-commits on success, auto-rollbacks on error. */
|
|
202
206
|
transaction(fn) {
|
|
203
|
-
|
|
204
|
-
|
|
207
|
+
this._db.exec("BEGIN");
|
|
208
|
+
try {
|
|
209
|
+
const result = fn();
|
|
210
|
+
this._db.exec("COMMIT");
|
|
211
|
+
return result;
|
|
212
|
+
} catch (err) {
|
|
213
|
+
this._db.exec("ROLLBACK");
|
|
214
|
+
throw err;
|
|
215
|
+
}
|
|
205
216
|
}
|
|
206
217
|
/** Run a prepared statement on multiple rows. Wraps in a single transaction. */
|
|
207
218
|
batch(sql, rows) {
|
|
208
219
|
const stmt = this._db.prepare(sql);
|
|
209
|
-
|
|
220
|
+
this.transaction(() => {
|
|
210
221
|
for (const row of rows) {
|
|
211
222
|
stmt.run(...row);
|
|
212
223
|
}
|
|
213
224
|
});
|
|
214
|
-
tx();
|
|
215
225
|
}
|
|
216
226
|
/** Close the database. */
|
|
217
227
|
close() {
|
|
218
228
|
this._db.close();
|
|
219
229
|
}
|
|
220
230
|
/**
|
|
221
|
-
* Access the underlying `
|
|
231
|
+
* Access the underlying `node:sqlite` DatabaseSync instance.
|
|
222
232
|
*
|
|
223
233
|
* @deprecated Use `DatabaseAdapter` methods instead. This exists
|
|
224
234
|
* only for gradual migration of plugins that depend on driver internals.
|
|
@@ -661,6 +671,13 @@ var ContextBuilder = class {
|
|
|
661
671
|
this._configFields = _configFields;
|
|
662
672
|
this._expander = _expander;
|
|
663
673
|
}
|
|
674
|
+
_search;
|
|
675
|
+
_registry;
|
|
676
|
+
_pruner;
|
|
677
|
+
_embedding;
|
|
678
|
+
_rerankerName;
|
|
679
|
+
_configFields;
|
|
680
|
+
_expander;
|
|
664
681
|
static {
|
|
665
682
|
__name(this, "ContextBuilder");
|
|
666
683
|
}
|
|
@@ -872,6 +889,7 @@ var CompositeBM25Search = class {
|
|
|
872
889
|
constructor(_registry) {
|
|
873
890
|
this._registry = _registry;
|
|
874
891
|
}
|
|
892
|
+
_registry;
|
|
875
893
|
static {
|
|
876
894
|
__name(this, "CompositeBM25Search");
|
|
877
895
|
}
|
|
@@ -917,6 +935,7 @@ var CompositeVectorSearch = class _CompositeVectorSearch {
|
|
|
917
935
|
constructor(_c) {
|
|
918
936
|
this._c = _c;
|
|
919
937
|
}
|
|
938
|
+
_c;
|
|
920
939
|
static {
|
|
921
940
|
__name(this, "CompositeVectorSearch");
|
|
922
941
|
}
|
|
@@ -969,6 +988,11 @@ var HNSWIndex = class {
|
|
|
969
988
|
this._efConstruction = _efConstruction;
|
|
970
989
|
this._efSearch = _efSearch;
|
|
971
990
|
}
|
|
991
|
+
_dims;
|
|
992
|
+
_maxElements;
|
|
993
|
+
_M;
|
|
994
|
+
_efConstruction;
|
|
995
|
+
_efSearch;
|
|
972
996
|
static {
|
|
973
997
|
__name(this, "HNSWIndex");
|
|
974
998
|
}
|
|
@@ -1120,6 +1144,12 @@ var Collection = class {
|
|
|
1120
1144
|
this._vecs = _vecs;
|
|
1121
1145
|
this._reranker = _reranker;
|
|
1122
1146
|
}
|
|
1147
|
+
_name;
|
|
1148
|
+
_db;
|
|
1149
|
+
_embedding;
|
|
1150
|
+
_hnsw;
|
|
1151
|
+
_vecs;
|
|
1152
|
+
_reranker;
|
|
1123
1153
|
static {
|
|
1124
1154
|
__name(this, "Collection");
|
|
1125
1155
|
}
|
|
@@ -1397,6 +1427,11 @@ var KVService = class {
|
|
|
1397
1427
|
this._vecs = _vecs;
|
|
1398
1428
|
this._reranker = _reranker;
|
|
1399
1429
|
}
|
|
1430
|
+
_db;
|
|
1431
|
+
_embedding;
|
|
1432
|
+
_hnsw;
|
|
1433
|
+
_vecs;
|
|
1434
|
+
_reranker;
|
|
1400
1435
|
static {
|
|
1401
1436
|
__name(this, "KVService");
|
|
1402
1437
|
}
|
|
@@ -2097,8 +2132,8 @@ async function rebuildHnsw(db, table, hnsw, vecs) {
|
|
|
2097
2132
|
`SELECT ${table.fkColumn} as id, embedding FROM ${table.vectorTable}`
|
|
2098
2133
|
).all();
|
|
2099
2134
|
for (const row of rows) {
|
|
2100
|
-
const
|
|
2101
|
-
const vec = new Float32Array(
|
|
2135
|
+
const emb = row.embedding;
|
|
2136
|
+
const vec = new Float32Array(emb.buffer.slice(emb.byteOffset, emb.byteOffset + emb.byteLength));
|
|
2102
2137
|
hnsw.add(vec, row.id);
|
|
2103
2138
|
vecs.set(row.id, vec);
|
|
2104
2139
|
}
|
|
@@ -2138,6 +2173,7 @@ var SearchAPI = class {
|
|
|
2138
2173
|
constructor(_d) {
|
|
2139
2174
|
this._d = _d;
|
|
2140
2175
|
}
|
|
2176
|
+
_d;
|
|
2141
2177
|
static {
|
|
2142
2178
|
__name(this, "SearchAPI");
|
|
2143
2179
|
}
|
|
@@ -3235,6 +3271,7 @@ __name(createBrain, "createBrain");
|
|
|
3235
3271
|
export {
|
|
3236
3272
|
DEFAULTS,
|
|
3237
3273
|
resolveConfig,
|
|
3274
|
+
VERSION,
|
|
3238
3275
|
HNSW,
|
|
3239
3276
|
SQLiteAdapter,
|
|
3240
3277
|
createTracker,
|
|
@@ -3283,4 +3320,4 @@ export {
|
|
|
3283
3320
|
resetFactoryCache,
|
|
3284
3321
|
createBrain
|
|
3285
3322
|
};
|
|
3286
|
-
//# sourceMappingURL=chunk-
|
|
3323
|
+
//# sourceMappingURL=chunk-6NM6WRDX.js.map
|