@cleocode/brain 2026.11.11 → 2026.11.12

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 CHANGED
@@ -2,38 +2,35 @@
2
2
 
3
3
  > Part of [CLEO](https://github.com/kryptobaseddev/cleo#readme). Start with the root README; run `cleo <command> --help` for any command.
4
4
 
5
- The unified-graph **Brain** substrate for CLEO: a substrate-agnostic projection
6
- across five substrates: **brain** (memory), **nexus** (code graph), **tasks**,
7
- **conduit** (messages) and **agent-registry** (agents).
8
-
9
- > **Known defect (T14583).** The adapters still open the legacy per-domain
10
- > files (`brain.db`, `tasks.db`, `conduit.db` under the project `.cleo/`,
11
- > `signaldock.db` and `nexus.db` under CLEO home). The live store is one
12
- > `cleo.db` per scope with prefixed tables (`tasks_tasks`,
13
- > `agent_registry_agents`, …); `tasks.db` and `brain.db` are decoys and
14
- > `signaldock.db` is retired. Until T14583 lands, `getAllSubstrates()` reads
15
- > stale or empty files.
16
-
17
- ## Purpose
18
-
19
- `@cleocode/brain` promotes the unified-graph substrate from a studio-internal
20
- module to a first-class workspace package, mirroring `@cleocode/nexus`. Operator
21
- mandate per T962 reconciliation: BRAIN is the super-domain (wraps memory +
22
- nexus + tasks + conduit + the agent registry), deserves CLI access, and needs a
23
- package standalone publish lane.
5
+ The unified-graph **Brain** projection for CLEO: one node-and-edge graph read
6
+ from five substrates: **brain** (memory), **nexus** (code graph), **tasks**,
7
+ **conduit** (legacy messages) and **agent-registry** (agents). CLEO Studio
8
+ (`packages/studio`) is its consumer.
9
+
10
+ > **Known defect (T14583).** The adapters do not read the live store yet.
11
+ > `src/db-connections.ts` and `src/cleo-home.ts` open the legacy per-domain
12
+ > files (`brain.db`, `tasks.db`, `conduit.db` under the project `.cleo/`;
13
+ > `nexus.db` and `signaldock.db` under CLEO home) and query bare table names
14
+ > (`tasks`, `sessions`, `messages`, `agents`, `nexus_nodes`, …). The live store
15
+ > is one `cleo.db` per scope with prefixed tables (`tasks_tasks`,
16
+ > `agent_registry_agents`, …), and those legacy files are gone or stale. A
17
+ > missing file makes its substrate return no nodes, so `getAllSubstrates()`
18
+ > returns an empty or stale graph until T14583 moves the adapters to `cleo.db`.
24
19
 
25
20
  ## Substrates
26
21
 
27
22
  Every node carries a substrate-prefixed ID so cross-substrate edges can
28
23
  reference nodes unambiguously, e.g. `brain:O-abc` vs `nexus:sym-123`.
29
24
 
30
- | Substrate | File the adapter opens today (see T14583) | Node kinds |
31
- |------------------|-------------------------------------------|------------------------------------------|
32
- | `brain` | `brain.db` (project) | observation, decision, pattern, learning |
33
- | `nexus` | `nexus.db` (global) | symbol, file |
34
- | `tasks` | `tasks.db` (project) | task, session |
35
- | `conduit` | `conduit.db` (project) | message |
36
- | `agent-registry` | `signaldock.db` (global) | agent |
25
+ | Substrate | File the adapter opens today (T14583) | Node kinds |
26
+ |------------------|---------------------------------------|------------------------------------------|
27
+ | `brain` | `brain.db` (project) | observation, decision, pattern, learning |
28
+ | `nexus` | `nexus.db` (global) | symbol, file |
29
+ | `tasks` | `tasks.db` (project) | task, session |
30
+ | `conduit` | `conduit.db` (project) | message |
31
+ | `agent-registry` | `signaldock.db` (global) | agent |
32
+
33
+ Conduit is legacy (T13933); agent messaging now runs on AgentMBX.
37
34
 
38
35
  ## Usage
39
36
 
@@ -44,6 +41,11 @@ const graph: BrainGraph = getAllSubstrates({ limit: 500, minWeight: 0 });
44
41
  console.log(`${graph.nodes.length} nodes across ${Object.keys(graph.counts.nodes).length} substrates`);
45
42
  ```
46
43
 
44
+ `BrainQueryOptions` also takes `substrates` (query a subset) and `projectCtx`
45
+ (the project paths to read). After loading, `getAllSubstrates` fetches a stub
46
+ node (`meta.isStub: true`) for any edge target not already loaded, so
47
+ cross-substrate edges are kept.
48
+
47
49
  Individual substrate adapters are exported from `@cleocode/brain/adapters`:
48
50
 
49
51
  ```ts
@@ -56,27 +58,31 @@ import {
56
58
  } from '@cleocode/brain/adapters';
57
59
  ```
58
60
 
61
+ The root entry point also exports the path helpers (`getBrainDbPath`,
62
+ `getTasksDbPath`, …), the raw connection getters (`getBrainDb`, `getTasksDb`,
63
+ …) and `resolveDefaultProjectContext`. They resolve the legacy files described
64
+ above.
65
+
59
66
  ## Wire Format
60
67
 
61
- The wire format (types `BrainNode`, `BrainEdge`, `BrainGraph`,
62
- `BrainQueryOptions`, `BrainStreamEvent`) is re-exported from the top-level
63
- entry point. See `src/types.ts` for the canonical definitions.
68
+ The graph types (`BrainNode`, `BrainEdge`, `BrainGraph`, `BrainSubstrate`,
69
+ `BrainQueryOptions`, `BrainStreamEvent`, `BrainNodeKind`,
70
+ `BrainConnectionStatus`, `BrainProjectContext`) are defined in
71
+ `packages/contracts/src/brain-graph.ts` and re-exported here through
72
+ `src/types.ts`.
64
73
 
65
- A parallel **contracts mirror** lives at
66
- `@cleocode/contracts/operations/brain` (T968) for programmatic-API
67
- consumers. It describes the HTTP wire format for the brain.* operations
68
- and is intentionally structurally distinct from these runtime types (e.g.
69
- contract `BrainNode` uses `type: string` + `data`, runtime uses `kind:
70
- BrainNodeKind` + `meta` + an optional adapter-produced `weight`).
74
+ A separate wire contract lives at `@cleocode/contracts/operations/brain`
75
+ (T968) for the brain.* operations. It is structurally distinct from the
76
+ runtime graph types: `BrainNodeWire` uses `type: string` + `data`, while the
77
+ runtime `BrainNode` uses `kind: BrainNodeKind` + `meta` + an optional
78
+ `weight`, and its substrate names use `memory` where the runtime uses `brain`.
71
79
 
72
80
  ## Naming
73
81
 
74
- All exported types carry the `Brain*` prefix (`BrainNode`, `BrainEdge`,
75
- `BrainGraph`, `BrainSubstrate`, `BrainQueryOptions`, `BrainStreamEvent`,
76
- `BrainConnectionStatus`, `BrainNodeKind`). T973 completed the LB* → Brain*
77
- rename started by the T969 package extraction. The `LB*` prefix is no
78
- longer exported by this package.
82
+ All exported types carry the `Brain*` prefix. T973 completed the `LB*` →
83
+ `Brain*` rename started by the T969 package extraction; no `LB*` name is
84
+ exported.
79
85
 
80
86
  ## License
81
87
 
82
- MIT — see LICENSE.
88
+ MIT. See LICENSE.