crbro-memory 1.4.0 β 1.5.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.
- package/README.md +49 -8
- package/bin/crbro.mjs +109 -0
- package/dist/engine/brain.d.ts +3 -0
- package/dist/engine/brain.d.ts.map +1 -1
- package/dist/engine/brain.js +15 -1
- package/dist/engine/brain.js.map +1 -1
- package/dist/engine/cortex.d.ts +61 -7
- package/dist/engine/cortex.d.ts.map +1 -1
- package/dist/engine/cortex.js +168 -23
- package/dist/engine/cortex.js.map +1 -1
- package/dist/engine/maintenance.d.ts +6 -1
- package/dist/engine/maintenance.d.ts.map +1 -1
- package/dist/engine/maintenance.js +19 -5
- package/dist/engine/maintenance.js.map +1 -1
- package/dist/engine/prefrontal.d.ts +13 -2
- package/dist/engine/prefrontal.d.ts.map +1 -1
- package/dist/engine/prefrontal.js +46 -10
- package/dist/engine/prefrontal.js.map +1 -1
- package/dist/miner/index.d.ts.map +1 -1
- package/dist/miner/index.js +35 -30
- package/dist/miner/index.js.map +1 -1
- package/dist/search/index.d.ts +46 -6
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +335 -74
- package/dist/search/index.js.map +1 -1
- package/dist/search/tokenize.d.ts +23 -0
- package/dist/search/tokenize.d.ts.map +1 -0
- package/dist/search/tokenize.js +83 -0
- package/dist/search/tokenize.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +125 -14
- package/dist/server.js.map +1 -1
- package/dist/types/index.d.ts +39 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/fs.d.ts +3 -1
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js +6 -2
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/hash.d.ts +20 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +45 -0
- package/dist/utils/hash.js.map +1 -0
- package/package.json +53 -53
package/README.md
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
# π§ CRBRO β Persistent Neural Memory for AI
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/crbro-memory)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://modelcontextprotocol.io)
|
|
6
|
+
|
|
3
7
|
**CRBRO** is a local MCP (Model Context Protocol) server that gives your AI assistant **persistent long-term memory** across sessions. It uses a biological neural architecture β cortex, synapses, hippocampus β to store, connect, and retrieve knowledge automatically.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
Free and open source (MIT). All 16 tools included β no license, no account, no tiers.
|
|
12
|
+
|
|
13
|
+
> β **If CRBRO gives your AI a memory worth keeping, a star on GitHub is the best way to support it.**
|
|
6
14
|
|
|
7
15
|
## Features
|
|
8
16
|
|
|
9
17
|
- **𧬠Biological Architecture** β Knowledge organized as neurons (cortex), connections (synapses), and session memory (hippocampus)
|
|
10
|
-
- **π
|
|
18
|
+
- **π Fact-Level Search** β Powered by [Orama](https://orama.com/). Every fact is indexed on its own, so a topic with hundreds of facts stays as findable as one with three, and each result comes back with the exact fact that matched and the date it was recorded
|
|
11
19
|
- **π₯ Heat Scores** β Automatic relevance tracking based on frequency, recency, and connectivity
|
|
20
|
+
- **βοΈ Correctable** β Knowledge can be superseded or retracted, not just piled up. A memory that only appends keeps serving yesterday's answer with today's confidence
|
|
12
21
|
- **πΊοΈ Global Map** β Cluster detection and cross-domain bridge identification
|
|
13
22
|
- **βοΈ Knowledge Miner** β Optionally scans your local `.md`/`.txt` notes and feeds them into the brain
|
|
14
23
|
- **π Fully Local** β Runs on Node.js alone: no Python, no Docker, no databases, no external services. Your memory never leaves your machine
|
|
@@ -25,6 +34,17 @@ npx crbro-memory init
|
|
|
25
34
|
|
|
26
35
|
### 2. Add to your MCP config
|
|
27
36
|
|
|
37
|
+
> **Register CRBRO at the user level, not per-project.** Your brain lives in
|
|
38
|
+
> `~/.crbro/` and is shared across every folder β but if you register the
|
|
39
|
+
> server inside a single project, other folders won't have the tools and it
|
|
40
|
+
> will *look* like the memory is gone. User-level registration makes it
|
|
41
|
+
> available everywhere, which is the whole point.
|
|
42
|
+
|
|
43
|
+
**Claude Code** (one command, available in every folder):
|
|
44
|
+
```bash
|
|
45
|
+
claude mcp add --scope user crbro -- npx -y crbro-memory
|
|
46
|
+
```
|
|
47
|
+
|
|
28
48
|
**Claude Desktop** (`~/AppData/Roaming/Claude/claude_desktop_config.json`):
|
|
29
49
|
```json
|
|
30
50
|
{
|
|
@@ -37,7 +57,7 @@ npx crbro-memory init
|
|
|
37
57
|
}
|
|
38
58
|
```
|
|
39
59
|
|
|
40
|
-
**Cursor** (
|
|
60
|
+
**Cursor** (`~/.cursor/mcp.json` β the one in your home folder, not a project's `.cursor/`):
|
|
41
61
|
```json
|
|
42
62
|
{
|
|
43
63
|
"mcpServers": {
|
|
@@ -51,7 +71,7 @@ npx crbro-memory init
|
|
|
51
71
|
|
|
52
72
|
### 3. Start using it
|
|
53
73
|
|
|
54
|
-
Your AI will now have access to
|
|
74
|
+
Your AI will now have access to 16 memory tools. Start any session with `crbro_boot`.
|
|
55
75
|
|
|
56
76
|
## Tools
|
|
57
77
|
|
|
@@ -62,7 +82,7 @@ Your AI will now have access to 15 memory tools. Start any session with `crbro_b
|
|
|
62
82
|
| `crbro_learn` | Store a fact, decision, pattern, or preference |
|
|
63
83
|
| `crbro_neuron` | Read a specific neuron (topic) with all its knowledge |
|
|
64
84
|
| `crbro_neurons` | List neurons with optional filters (domain, type, heat) |
|
|
65
|
-
| `crbro_recall` | Search
|
|
85
|
+
| `crbro_recall` | Search every stored fact, not just topic names β returns the fact that matched |
|
|
66
86
|
| `crbro_connect` | Create or strengthen a connection between neurons |
|
|
67
87
|
| `crbro_connections` | Get all connections for a neuron |
|
|
68
88
|
| `crbro_session_log` | Log a session summary |
|
|
@@ -70,7 +90,8 @@ Your AI will now have access to 15 memory tools. Start any session with `crbro_b
|
|
|
70
90
|
| `crbro_context` | Read/update active working context |
|
|
71
91
|
| `crbro_hot_topics` | Get the most active topics by heat score |
|
|
72
92
|
| `crbro_global_map` | View the neural network β clusters and cross-domain bridges |
|
|
73
|
-
| `
|
|
93
|
+
| `crbro_revise` | Mark facts as superseded or retracted when they stop being true |
|
|
94
|
+
| `crbro_maintenance` | Brain maintenance β heat, pruning, integrity, index rebuild |
|
|
74
95
|
| `crbro_consolidate` | End-of-session consolidation |
|
|
75
96
|
|
|
76
97
|
## Architecture
|
|
@@ -89,9 +110,9 @@ Your AI will now have access to 15 memory tools. Start any session with `crbro_b
|
|
|
89
110
|
β βββ active_context.json
|
|
90
111
|
β βββ hot_topics.json
|
|
91
112
|
β βββ global_map.json
|
|
92
|
-
βββ archives/ β Cold neurons
|
|
113
|
+
βββ archives/ β Cold neurons (opt-in; nothing is archived unless you ask)
|
|
93
114
|
βββ .search/ β Orama search index
|
|
94
|
-
βββ
|
|
115
|
+
βββ chunks.index.json β one document per fact
|
|
95
116
|
```
|
|
96
117
|
|
|
97
118
|
## Heat Score Algorithm
|
|
@@ -121,9 +142,29 @@ npx crbro-memory remove-miner # Remove the scheduled task
|
|
|
121
142
|
npx crbro-memory # Start MCP server (stdio)
|
|
122
143
|
npx crbro-memory init # Initialize brain + detect IDEs
|
|
123
144
|
npx crbro-memory status # Show brain status
|
|
145
|
+
npx crbro-memory reindex # Rebuild the search index
|
|
146
|
+
npx crbro-memory eval # Measure retrieval quality against your own query set
|
|
124
147
|
npx crbro-memory --help # Help
|
|
125
148
|
```
|
|
126
149
|
|
|
150
|
+
### Measuring retrieval
|
|
151
|
+
|
|
152
|
+
`eval` is there so you can tell a fix from a feeling. Write
|
|
153
|
+
`~/.crbro/.eval/queries.json` as a list of questions you would actually ask,
|
|
154
|
+
each naming the neuron that should answer it:
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
[
|
|
158
|
+
{ "query": "how we deploy the api",
|
|
159
|
+
"expect_neuron": "project_octochat",
|
|
160
|
+
"expect_contains": "Cloud Run" }
|
|
161
|
+
]
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Then `npx crbro-memory eval` reports how often the right neuron comes back
|
|
165
|
+
first, how often it makes the top three, and MRR β plus every miss, so you can
|
|
166
|
+
see what it got wrong instead of guessing.
|
|
167
|
+
|
|
127
168
|
## License
|
|
128
169
|
|
|
129
170
|
MIT β see [LICENSE](LICENSE). Built by [Octonove](https://github.com/Octonove).
|
package/bin/crbro.mjs
CHANGED
|
@@ -273,6 +273,111 @@ if (command === 'init') {
|
|
|
273
273
|
console.log('');
|
|
274
274
|
}).catch(console.error);
|
|
275
275
|
|
|
276
|
+
} else if (command === 'reindex') {
|
|
277
|
+
// βββ Rebuild the search index from the cortex ββββββββββββββββββ
|
|
278
|
+
Promise.all([
|
|
279
|
+
import('../dist/engine/brain.js'),
|
|
280
|
+
import('../dist/search/index.js'),
|
|
281
|
+
]).then(async ([{ Brain }, { SearchEngine }]) => {
|
|
282
|
+
const brain = new Brain();
|
|
283
|
+
const engine = new SearchEngine(brain);
|
|
284
|
+
|
|
285
|
+
console.log('');
|
|
286
|
+
console.log(' π Rebuilding the CRBRO search index...');
|
|
287
|
+
const started = Date.now();
|
|
288
|
+
const indexed = await engine.rebuild();
|
|
289
|
+
const seconds = ((Date.now() - started) / 1000).toFixed(1);
|
|
290
|
+
|
|
291
|
+
console.log('');
|
|
292
|
+
console.log(` β
${indexed} chunks indexed in ${seconds}s`);
|
|
293
|
+
console.log(' Every fact, decision and pattern is now searchable on its own,');
|
|
294
|
+
console.log(' so a big neuron is no longer buried by short ones.');
|
|
295
|
+
console.log('');
|
|
296
|
+
}).catch(console.error);
|
|
297
|
+
|
|
298
|
+
} else if (command === 'eval') {
|
|
299
|
+
// βββ Measure retrieval quality against a query set βββββββββββββ
|
|
300
|
+
//
|
|
301
|
+
// Without a number you cannot tell a fix from a feeling. The file is
|
|
302
|
+
// .crbro/.eval/queries.json β a list of { query, expect_neuron } and
|
|
303
|
+
// optionally expect_contains, the substring the matched fact should carry.
|
|
304
|
+
Promise.all([
|
|
305
|
+
import('../dist/engine/brain.js'),
|
|
306
|
+
import('../dist/search/index.js'),
|
|
307
|
+
import('fs/promises'),
|
|
308
|
+
]).then(async ([{ Brain }, { SearchEngine }, fsp]) => {
|
|
309
|
+
const brain = new Brain();
|
|
310
|
+
const evalPath = join(brain.paths.root, '.eval', 'queries.json');
|
|
311
|
+
|
|
312
|
+
let queries;
|
|
313
|
+
try {
|
|
314
|
+
queries = JSON.parse(await fsp.readFile(evalPath, 'utf-8'));
|
|
315
|
+
} catch {
|
|
316
|
+
console.log('');
|
|
317
|
+
console.log(` No query set found at ${evalPath}`);
|
|
318
|
+
console.log(' Create it as a JSON array, for example:');
|
|
319
|
+
console.log('');
|
|
320
|
+
console.log(' [');
|
|
321
|
+
console.log(' { "query": "how we deploy the api", "expect_neuron": "project_octochat",');
|
|
322
|
+
console.log(' "expect_contains": "Cloud Run" }');
|
|
323
|
+
console.log(' ]');
|
|
324
|
+
console.log('');
|
|
325
|
+
console.log(' Build it from facts you already saved: take six or eight words');
|
|
326
|
+
console.log(' out of a real fact and name the neuron that holds it.');
|
|
327
|
+
console.log('');
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const engine = new SearchEngine(brain);
|
|
332
|
+
await engine.init();
|
|
333
|
+
|
|
334
|
+
let atOne = 0, atThree = 0, reciprocal = 0, contentOk = 0;
|
|
335
|
+
const misses = [];
|
|
336
|
+
|
|
337
|
+
for (const q of queries) {
|
|
338
|
+
const results = await engine.search(q.query, { limit: 10 });
|
|
339
|
+
const rank = results.findIndex(r => r.neuron_id === q.expect_neuron);
|
|
340
|
+
|
|
341
|
+
if (rank === 0) atOne++;
|
|
342
|
+
if (rank >= 0 && rank < 3) atThree++;
|
|
343
|
+
if (rank >= 0) reciprocal += 1 / (rank + 1);
|
|
344
|
+
|
|
345
|
+
if (rank === 0 && q.expect_contains) {
|
|
346
|
+
if (results[0].matching_content.includes(q.expect_contains)) contentOk++;
|
|
347
|
+
else misses.push(` ~ "${q.query}" β right neuron, wrong fact returned`);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (rank !== 0) {
|
|
351
|
+
const got = results[0] ? results[0].neuron_id : '(nothing)';
|
|
352
|
+
misses.push(` β "${q.query}" β expected ${q.expect_neuron}, got ${got}` +
|
|
353
|
+
(rank > 0 ? ` (it was #${rank + 1})` : ''));
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const n = queries.length;
|
|
358
|
+
const pct = (x) => `${((x / n) * 100).toFixed(1)}%`;
|
|
359
|
+
|
|
360
|
+
console.log('');
|
|
361
|
+
console.log(' π CRBRO retrieval eval');
|
|
362
|
+
console.log(' βββββββββββββββββββββββ');
|
|
363
|
+
console.log(` Queries: ${n}`);
|
|
364
|
+
console.log(` Right first hit: ${atOne}/${n} (${pct(atOne)})`);
|
|
365
|
+
console.log(` In the top 3: ${atThree}/${n} (${pct(atThree)})`);
|
|
366
|
+
console.log(` MRR: ${(reciprocal / n).toFixed(3)}`);
|
|
367
|
+
if (queries.some(q => q.expect_contains)) {
|
|
368
|
+
const withContent = queries.filter(q => q.expect_contains).length;
|
|
369
|
+
console.log(` Right fact shown: ${contentOk}/${withContent}`);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (misses.length > 0) {
|
|
373
|
+
console.log('');
|
|
374
|
+
console.log(' Misses:');
|
|
375
|
+
for (const m of misses.slice(0, 25)) console.log(m);
|
|
376
|
+
if (misses.length > 25) console.log(` ... and ${misses.length - 25} more`);
|
|
377
|
+
}
|
|
378
|
+
console.log('');
|
|
379
|
+
}).catch(console.error);
|
|
380
|
+
|
|
276
381
|
} else if (command === '--help' || command === '-h') {
|
|
277
382
|
// βββ Help ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
278
383
|
console.log('');
|
|
@@ -289,6 +394,10 @@ if (command === 'init') {
|
|
|
289
394
|
console.log(' npx crbro-memory miner-status Check auto-miner status');
|
|
290
395
|
console.log(' npx crbro-memory remove-miner Remove auto-miner');
|
|
291
396
|
console.log('');
|
|
397
|
+
console.log(' Search:');
|
|
398
|
+
console.log(' npx crbro-memory reindex Rebuild the search index');
|
|
399
|
+
console.log(' npx crbro-memory eval Measure retrieval against .crbro/.eval/queries.json');
|
|
400
|
+
console.log('');
|
|
292
401
|
console.log(' Server:');
|
|
293
402
|
console.log(' npx crbro-memory Start MCP server (stdio)');
|
|
294
403
|
console.log('');
|
package/dist/engine/brain.d.ts
CHANGED
|
@@ -16,7 +16,10 @@ export declare class BrainPaths {
|
|
|
16
16
|
activeContext(): string;
|
|
17
17
|
hotTopics(): string;
|
|
18
18
|
globalMap(): string;
|
|
19
|
+
/** Pre-v2 index. Kept only so the migration can delete it. */
|
|
19
20
|
searchIndex(): string;
|
|
21
|
+
/** Chunk-level index (v2+). Separate filename so an old index is never loaded. */
|
|
22
|
+
chunksIndex(): string;
|
|
20
23
|
}
|
|
21
24
|
export declare class Brain {
|
|
22
25
|
private manifest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../src/engine/brain.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAoC,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAQnH,qBAAa,UAAU;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,CAAC,EAAE,MAAM;IAW5B,QAAQ,IAAI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AM,GAAG,MAAM;IAI3B,aAAa,IAAI,MAAM;IAIvB,SAAS,IAAI,MAAM;IAInB,SAAS,IAAI,MAAM;IAInB,8DAA8D;IAC9D,WAAW,IAAI,MAAM;IAIrB,kFAAkF;IAClF,WAAW,IAAI,MAAM;CAGtB;AAID,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAyB;IACzC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;gBAEf,OAAO,CAAC,EAAE,MAAM;IAI5B;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,QAAQ,CAAC;IAkDrC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAgEjC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;IAUtC;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/D;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;CA4CpD"}
|
package/dist/engine/brain.js
CHANGED
|
@@ -53,9 +53,14 @@ class BrainPaths {
|
|
|
53
53
|
globalMap() {
|
|
54
54
|
return node_path_1.default.join(this.prefrontal, 'global_map.json');
|
|
55
55
|
}
|
|
56
|
+
/** Pre-v2 index. Kept only so the migration can delete it. */
|
|
56
57
|
searchIndex() {
|
|
57
58
|
return node_path_1.default.join(this.search, 'orama.index.json');
|
|
58
59
|
}
|
|
60
|
+
/** Chunk-level index (v2+). Separate filename so an old index is never loaded. */
|
|
61
|
+
chunksIndex() {
|
|
62
|
+
return node_path_1.default.join(this.search, 'chunks.index.json');
|
|
63
|
+
}
|
|
59
64
|
}
|
|
60
65
|
exports.BrainPaths = BrainPaths;
|
|
61
66
|
// βββ Brain Manager βββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -144,6 +149,11 @@ class Brain {
|
|
|
144
149
|
const activeContext = await (0, fs_js_1.readJSON)(this.paths.activeContext());
|
|
145
150
|
// Load active protocols
|
|
146
151
|
const activeProtocols = await this.loadProtocols();
|
|
152
|
+
// Pending items, split into what is open and what was just closed.
|
|
153
|
+
const openItems = (activeContext?.pending_tasks || []).map(t => typeof t === 'string'
|
|
154
|
+
? { id: '', text: t, added: '' }
|
|
155
|
+
: t);
|
|
156
|
+
const recentlyClosed = activeContext?.recently_closed || [];
|
|
147
157
|
// Update boot timestamp
|
|
148
158
|
this.manifest.last_boot = (0, fs_js_1.now)();
|
|
149
159
|
await (0, fs_js_1.writeJSON)(this.paths.manifest(), this.manifest);
|
|
@@ -156,7 +166,11 @@ class Brain {
|
|
|
156
166
|
last_session: activeContext?.last_session || null,
|
|
157
167
|
active_context: activeContext,
|
|
158
168
|
active_protocols: activeProtocols,
|
|
159
|
-
|
|
169
|
+
open_items: openItems,
|
|
170
|
+
recently_closed: recentlyClosed,
|
|
171
|
+
message: `CRBRO boot complete. ${this.manifest.total_neurons} neurons, ${this.manifest.total_synapses} synapses, ` +
|
|
172
|
+
`${this.manifest.total_sessions} sessions. ${activeProtocols.length} active protocol(s). ` +
|
|
173
|
+
`${openItems.length} open item(s), ${recentlyClosed.length} recently closed.`,
|
|
160
174
|
};
|
|
161
175
|
}
|
|
162
176
|
/**
|
package/dist/engine/brain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain.js","sourceRoot":"","sources":["../../src/engine/brain.ts"],"names":[],"mappings":";AAAA,oEAAoE;AACpE,gEAAgE;;;;;;AAEhE,0DAA6B;AAC7B,qCAAyC;AACzC,0CAAsE;AAGtE,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC7H,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM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SAAS,CAAC,CAAC,CAAC;gBACjE,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;gBAE9D,oDAAoD;gBACpD,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK;qBAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;qBAChB,IAAI,CAAC,MAAM,CAAC,CAAC;gBAEhB,IAAI,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC;oBACxB,SAAS,CAAC,IAAI,CAAC;wBACb,EAAE,EAAE,MAAM,CAAC,EAAE;wBACb,IAAI,EAAE,MAAM,CAAC,IAAI;wBACjB,QAAQ;wBACR,YAAY;wBACZ,MAAM;qBACP,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;QAChD,CAAC;QAED,mCAAmC;QACnC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;QAClD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA1MD,sBA0MC"}
|
package/dist/engine/cortex.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import type { Brain } from './brain.js';
|
|
2
|
-
import type { Neuron, NeuronType } from '../types/index.js';
|
|
2
|
+
import type { Neuron, NeuronType, FactStatus } from '../types/index.js';
|
|
3
|
+
export type Indexer = (neuron: Neuron) => Promise<void> | void;
|
|
3
4
|
export declare class Cortex {
|
|
4
5
|
private brain;
|
|
6
|
+
/**
|
|
7
|
+
* Optional hook invoked after every write. Wiring it here β rather than
|
|
8
|
+
* calling the search engine from each caller β is what guarantees the miner
|
|
9
|
+
* path gets indexed too. Before this, the miner wrote straight to disk and
|
|
10
|
+
* 91% of the brain never reached the index.
|
|
11
|
+
*/
|
|
12
|
+
private indexer;
|
|
5
13
|
constructor(brain: Brain);
|
|
14
|
+
setIndexer(indexer: Indexer | null): void;
|
|
15
|
+
private reindex;
|
|
6
16
|
/**
|
|
7
17
|
* Get a neuron by ID.
|
|
8
18
|
*/
|
|
@@ -12,27 +22,71 @@ export declare class Cortex {
|
|
|
12
22
|
*/
|
|
13
23
|
peek(id: string): Promise<Neuron | null>;
|
|
14
24
|
/**
|
|
15
|
-
* Find a neuron by name
|
|
16
|
-
*
|
|
25
|
+
* Find a neuron by name.
|
|
26
|
+
*
|
|
27
|
+
* Returns null rather than guessing. That is the point: the previous
|
|
28
|
+
* implementation fell back to substring containment in either direction,
|
|
29
|
+
* which routed "Coches Chinos" into
|
|
30
|
+
* `project_walkthrough_skill_articulo_coches_chinos_primera_publicacin`
|
|
31
|
+
* and "SEO" into `process_walkthrough_creacin_de_4_2_pendientes...`.
|
|
32
|
+
* Knowledge written into the wrong neuron is recalled attributed to the
|
|
33
|
+
* wrong neuron, and no amount of index tuning repairs that. A wrong guess
|
|
34
|
+
* is worse than a new neuron.
|
|
17
35
|
*/
|
|
18
36
|
findByName(name: string): Promise<Neuron | null>;
|
|
19
37
|
/**
|
|
20
38
|
* Create a new neuron.
|
|
39
|
+
* Refuses to clobber: two different names can slugify to the same id, and
|
|
40
|
+
* the old code wrote straight over the existing file, losing every fact in it.
|
|
21
41
|
*/
|
|
22
42
|
create(name: string, type: NeuronType, domain: string, summary?: string): Promise<Neuron>;
|
|
23
43
|
/**
|
|
24
|
-
* Learn β add a fact, decision, or
|
|
25
|
-
*
|
|
44
|
+
* Learn β add a fact, decision, pattern or preference to a neuron.
|
|
45
|
+
* Creates the neuron if it does not exist.
|
|
26
46
|
*/
|
|
27
47
|
learn(topic: string, type: 'fact' | 'decision' | 'pattern' | 'preference', content: string, options?: {
|
|
28
48
|
confidence?: number;
|
|
29
49
|
domain?: string;
|
|
30
50
|
rationale?: string;
|
|
31
51
|
neuronType?: NeuronType;
|
|
52
|
+
/** Write to this exact neuron and skip name resolution entirely. */
|
|
53
|
+
neuronId?: string;
|
|
54
|
+
/** Who is writing: 'session' (default), 'miner', 'manual'. */
|
|
55
|
+
source?: string;
|
|
56
|
+
/** Ids or verbatim texts of facts this one replaces. */
|
|
57
|
+
supersedes?: string[];
|
|
58
|
+
/**
|
|
59
|
+
* Create the neuron when the topic is unknown. Default true.
|
|
60
|
+
* The miner passes false: an automated pass guessing at topic names is
|
|
61
|
+
* how a brain ends up with a thousand neurons called things like
|
|
62
|
+
* `lang_juego_billar_8_ball`, each of them shorter -- and therefore
|
|
63
|
+
* easier to retrieve -- than the knowledge that matters.
|
|
64
|
+
*/
|
|
65
|
+
createIfMissing?: boolean;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
neuron: Neuron | null;
|
|
68
|
+
action: 'created' | 'updated' | 'skipped';
|
|
69
|
+
superseded: number;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Mark facts as no longer current.
|
|
73
|
+
*
|
|
74
|
+
* `superseded` β a newer fact replaces it.
|
|
75
|
+
* `retracted` β it was never true.
|
|
76
|
+
*
|
|
77
|
+
* Facts are matched by id, and failing that by verbatim text, because the
|
|
78
|
+
* caller usually has the text in front of it and not the hash.
|
|
79
|
+
*/
|
|
80
|
+
revise(neuronRef: string, targets: string[], options?: {
|
|
81
|
+
status?: FactStatus;
|
|
82
|
+
note?: string;
|
|
83
|
+
replacedBy?: string;
|
|
32
84
|
}): Promise<{
|
|
33
|
-
neuron: Neuron;
|
|
34
|
-
|
|
85
|
+
neuron: Neuron | null;
|
|
86
|
+
revised: number;
|
|
35
87
|
}>;
|
|
88
|
+
/** Flip matching facts to a non-active status. Returns how many changed. */
|
|
89
|
+
private retire;
|
|
36
90
|
/**
|
|
37
91
|
* List all neurons with optional filters.
|
|
38
92
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cortex.d.ts","sourceRoot":"","sources":["../../src/eng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