@cleocode/brain 2026.11.16 → 2026.11.17
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 +31 -21
- package/dist/src/adapters/agent-registry.d.ts +12 -9
- package/dist/src/adapters/agent-registry.d.ts.map +1 -1
- package/dist/src/adapters/agent-registry.js +40 -65
- package/dist/src/adapters/agent-registry.js.map +1 -1
- package/dist/src/adapters/brain.d.ts +3 -2
- package/dist/src/adapters/brain.d.ts.map +1 -1
- package/dist/src/adapters/brain.js +172 -172
- package/dist/src/adapters/brain.js.map +1 -1
- package/dist/src/adapters/conduit.d.ts +5 -4
- package/dist/src/adapters/conduit.d.ts.map +1 -1
- package/dist/src/adapters/conduit.js +53 -64
- package/dist/src/adapters/conduit.js.map +1 -1
- package/dist/src/adapters/index.d.ts +2 -2
- package/dist/src/adapters/index.d.ts.map +1 -1
- package/dist/src/adapters/index.js +11 -10
- package/dist/src/adapters/index.js.map +1 -1
- package/dist/src/adapters/nexus.d.ts +5 -3
- package/dist/src/adapters/nexus.d.ts.map +1 -1
- package/dist/src/adapters/nexus.js +47 -44
- package/dist/src/adapters/nexus.js.map +1 -1
- package/dist/src/adapters/tasks.d.ts +4 -2
- package/dist/src/adapters/tasks.d.ts.map +1 -1
- package/dist/src/adapters/tasks.js +93 -92
- package/dist/src/adapters/tasks.js.map +1 -1
- package/dist/src/cleo-home.d.ts +22 -12
- package/dist/src/cleo-home.d.ts.map +1 -1
- package/dist/src/cleo-home.js +24 -20
- package/dist/src/cleo-home.js.map +1 -1
- package/dist/src/db-connections.d.ts +23 -101
- package/dist/src/db-connections.d.ts.map +1 -1
- package/dist/src/db-connections.js +43 -169
- package/dist/src/db-connections.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/project-context.d.ts +15 -7
- package/dist/src/project-context.d.ts.map +1 -1
- package/dist/src/project-context.js +10 -15
- package/dist/src/project-context.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conduit.js","sourceRoot":"","sources":["../../../src/adapters/conduit.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"conduit.js","sourceRoot":"","sources":["../../../src/adapters/conduit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAcrE;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAA6B,EAAE;IAIjE,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,IAAI,4BAA4B,EAAE,CAAC;IACjE,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAEhE,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAgB,EAAE,CAAC;IAE9B,gBAAgB,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE;QAC3B,IAAI,CAAC;YACH,uBAAuB;YACvB,MAAM,OAAO,GAAG,QAAQ,CACtB,EAAE,CAAC,OAAO,CACR;;;;iBAIO,CACR,EACD,iBAAiB,CAClB,CAAC;YAEF,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuD,CAAC;YAElF,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;gBAC1B,4CAA4C;gBAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,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EAAE,EAAE;oBACnC,IAAI,EAAE,UAAU;oBAChB,MAAM;oBACN,SAAS,EAAE,OAAO;iBACnB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,kCAAkC;QACpC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Barrel for all substrate adapters.
|
|
3
3
|
*
|
|
4
4
|
* Re-exports individual adapter functions and provides the unified
|
|
5
|
-
* `getAllSubstrates()` function that merges results from all five
|
|
6
|
-
* into a single BrainGraph.
|
|
5
|
+
* `getAllSubstrates()` function that merges results from all five substrates
|
|
6
|
+
* (read from the project and global `cleo.db`) into a single BrainGraph.
|
|
7
7
|
*/
|
|
8
8
|
export { getAgentRegistrySubstrate } from './agent-registry.js';
|
|
9
9
|
export { getBrainSubstrate } from './brain.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI/C,OAAO,KAAK,EAEV,UAAU,EAEV,iBAAiB,EAElB,MAAM,aAAa,CAAC;AAoIrB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU,CA2E5E"}
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
* Barrel for all substrate adapters.
|
|
3
3
|
*
|
|
4
4
|
* Re-exports individual adapter functions and provides the unified
|
|
5
|
-
* `getAllSubstrates()` function that merges results from all five
|
|
6
|
-
* into a single BrainGraph.
|
|
5
|
+
* `getAllSubstrates()` function that merges results from all five substrates
|
|
6
|
+
* (read from the project and global `cleo.db`) into a single BrainGraph.
|
|
7
7
|
*/
|
|
8
8
|
export { getAgentRegistrySubstrate } from './agent-registry.js';
|
|
9
9
|
export { getBrainSubstrate } from './brain.js';
|
|
10
10
|
export { getConduitSubstrate } from './conduit.js';
|
|
11
11
|
export { getNexusSubstrate } from './nexus.js';
|
|
12
12
|
export { getTasksSubstrate } from './tasks.js';
|
|
13
|
-
import { allTyped,
|
|
13
|
+
import { allTyped, readProjectStore } from '../db-connections.js';
|
|
14
|
+
import { resolveDefaultProjectContext } from '../project-context.js';
|
|
14
15
|
import { getAgentRegistrySubstrate } from './agent-registry.js';
|
|
15
16
|
import { getBrainSubstrate } from './brain.js';
|
|
16
17
|
import { getConduitSubstrate } from './conduit.js';
|
|
@@ -37,9 +38,10 @@ const ADAPTER_MAP = {
|
|
|
37
38
|
*
|
|
38
39
|
* @param loadedNodeIds - Set of already-loaded node IDs (substrate-prefixed).
|
|
39
40
|
* @param edges - All edges collected from substrates (may reference unloaded targets).
|
|
41
|
+
* @param ctx - Project whose `cleo.db` code graph resolves nexus stubs.
|
|
40
42
|
* @returns Array of stub BrainNode objects for missing targets.
|
|
41
43
|
*/
|
|
42
|
-
function loadStubNodesForEdgeTargets(loadedNodeIds, edges) {
|
|
44
|
+
function loadStubNodesForEdgeTargets(loadedNodeIds, edges, ctx) {
|
|
43
45
|
// Collect all target IDs referenced by edges but not yet loaded
|
|
44
46
|
const missingTargetIds = new Set();
|
|
45
47
|
for (const edge of edges) {
|
|
@@ -69,14 +71,13 @@ function loadStubNodesForEdgeTargets(loadedNodeIds, edges) {
|
|
|
69
71
|
// Load stubs for nexus targets (most common cross-substrate case)
|
|
70
72
|
const nexusStubs = stubsBySubstrate.get('nexus');
|
|
71
73
|
if (nexusStubs && nexusStubs.length > 0) {
|
|
72
|
-
|
|
73
|
-
if (db) {
|
|
74
|
+
readProjectStore(ctx, (db) => {
|
|
74
75
|
try {
|
|
75
76
|
const rawNexusIds = nexusStubs.map((id) => id.replace(/^nexus:/, ''));
|
|
76
77
|
const placeholders = rawNexusIds.map(() => '?').join(',');
|
|
77
78
|
// Query minimal node data: id, kind, name
|
|
78
|
-
const stubRows = allTyped(db.prepare(`SELECT id, kind, name
|
|
79
|
-
FROM nexus_nodes
|
|
79
|
+
const stubRows = allTyped(db.prepare(`SELECT id, kind, COALESCE(name, label) AS name
|
|
80
|
+
FROM main.nexus_nodes
|
|
80
81
|
WHERE id IN (${placeholders})`), ...rawNexusIds);
|
|
81
82
|
for (const row of stubRows) {
|
|
82
83
|
const kind = row.kind === 'file' || row.kind === 'folder' || row.kind === 'module'
|
|
@@ -96,7 +97,7 @@ function loadStubNodesForEdgeTargets(loadedNodeIds, edges) {
|
|
|
96
97
|
catch {
|
|
97
98
|
// Silently continue on error; stubs are supplemental
|
|
98
99
|
}
|
|
99
|
-
}
|
|
100
|
+
});
|
|
100
101
|
}
|
|
101
102
|
// For other substrates (tasks, brain, conduit, signaldock), create minimal stubs
|
|
102
103
|
// without DB queries — they are rare as cross-substrate edge targets.
|
|
@@ -172,7 +173,7 @@ export function getAllSubstrates(options = {}) {
|
|
|
172
173
|
// within the requested set — never inject nodes from excluded substrates, as that
|
|
173
174
|
// would violate the caller's filter contract.
|
|
174
175
|
const requestedSubstrateSet = options.substrates ? new Set(options.substrates) : null;
|
|
175
|
-
const stubNodes = loadStubNodesForEdgeTargets(seenIds, allEdges);
|
|
176
|
+
const stubNodes = loadStubNodesForEdgeTargets(seenIds, allEdges, options.projectCtx ?? resolveDefaultProjectContext());
|
|
176
177
|
for (const stubNode of stubNodes) {
|
|
177
178
|
if (!seenIds.has(stubNode.id)) {
|
|
178
179
|
// Skip stubs from substrates not in the requested set
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAuB,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAQ1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBA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K,EAAE,QAAQ;QACf,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;QAChD,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NEXUS substrate adapter for the Living Brain API.
|
|
3
3
|
*
|
|
4
|
-
* Queries
|
|
4
|
+
* Queries the code graph in the project `cleo.db` (`nexus_nodes`,
|
|
5
|
+
* `nexus_relations`; project-resident per ADR-090) and returns
|
|
6
|
+
* BrainNodes/BrainEdges for code symbols and files.
|
|
5
7
|
* Prioritises high-in-degree nodes (most-called functions, most-imported files)
|
|
6
8
|
* since the full nexus graph can exceed 10k nodes.
|
|
7
9
|
*
|
|
@@ -9,12 +11,12 @@
|
|
|
9
11
|
*/
|
|
10
12
|
import type { BrainEdge, BrainNode, BrainQueryOptions } from '../types.js';
|
|
11
13
|
/**
|
|
12
|
-
* Returns all BrainNodes and BrainEdges sourced from
|
|
14
|
+
* Returns all BrainNodes and BrainEdges sourced from the project code graph.
|
|
13
15
|
*
|
|
14
16
|
* Fetches the highest in-degree nodes (capped at perSubstrateLimit) and
|
|
15
17
|
* all relations between those nodes.
|
|
16
18
|
*
|
|
17
|
-
* @param options - Query options (limit,
|
|
19
|
+
* @param options - Query options (limit, projectCtx).
|
|
18
20
|
* @returns Nodes and edges from the NEXUS substrate.
|
|
19
21
|
*/
|
|
20
22
|
export declare function getNexusSubstrate(options?: BrainQueryOptions): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../src/adapters/nexus.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../src/adapters/nexus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAiB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAyB1F;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,iBAAsB,GAAG;IAClE,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CAyEA"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NEXUS substrate adapter for the Living Brain API.
|
|
3
3
|
*
|
|
4
|
-
* Queries
|
|
4
|
+
* Queries the code graph in the project `cleo.db` (`nexus_nodes`,
|
|
5
|
+
* `nexus_relations`; project-resident per ADR-090) and returns
|
|
6
|
+
* BrainNodes/BrainEdges for code symbols and files.
|
|
5
7
|
* Prioritises high-in-degree nodes (most-called functions, most-imported files)
|
|
6
8
|
* since the full nexus graph can exceed 10k nodes.
|
|
7
9
|
*
|
|
8
10
|
* Node IDs are prefixed with "nexus:" to prevent collisions.
|
|
9
11
|
*/
|
|
10
|
-
import { allTyped,
|
|
12
|
+
import { allTyped, readProjectStore } from '../db-connections.js';
|
|
13
|
+
import { resolveDefaultProjectContext } from '../project-context.js';
|
|
11
14
|
/** Maps nexus node kinds to BrainNodeKind. */
|
|
12
15
|
function mapKind(nexusKind) {
|
|
13
16
|
if (nexusKind === 'file' || nexusKind === 'folder' || nexusKind === 'module')
|
|
@@ -15,27 +18,26 @@ function mapKind(nexusKind) {
|
|
|
15
18
|
return 'symbol';
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
|
-
* Returns all BrainNodes and BrainEdges sourced from
|
|
21
|
+
* Returns all BrainNodes and BrainEdges sourced from the project code graph.
|
|
19
22
|
*
|
|
20
23
|
* Fetches the highest in-degree nodes (capped at perSubstrateLimit) and
|
|
21
24
|
* all relations between those nodes.
|
|
22
25
|
*
|
|
23
|
-
* @param options - Query options (limit,
|
|
26
|
+
* @param options - Query options (limit, projectCtx).
|
|
24
27
|
* @returns Nodes and edges from the NEXUS substrate.
|
|
25
28
|
*/
|
|
26
29
|
export function getNexusSubstrate(options = {}) {
|
|
27
|
-
const
|
|
28
|
-
if (!db)
|
|
29
|
-
return { nodes: [], edges: [] };
|
|
30
|
+
const ctx = options.projectCtx ?? resolveDefaultProjectContext();
|
|
30
31
|
const perSubstrateLimit = Math.ceil((options.limit ?? 500) / 5);
|
|
31
32
|
const nodes = [];
|
|
32
33
|
const edges = [];
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
readProjectStore(ctx, (db) => {
|
|
35
|
+
try {
|
|
36
|
+
// Count in-degree for each node to use as weight
|
|
37
|
+
const nodeRows = allTyped(db.prepare(`SELECT n.id, n.kind, COALESCE(n.name, n.label) AS name, n.indexed_at,
|
|
36
38
|
COUNT(r.target_id) AS in_degree
|
|
37
|
-
FROM nexus_nodes n
|
|
38
|
-
LEFT JOIN nexus_relations r ON r.target_id = n.id
|
|
39
|
+
FROM main.nexus_nodes n
|
|
40
|
+
LEFT JOIN main.nexus_relations r ON r.target_id = n.id
|
|
39
41
|
WHERE n.kind IN (
|
|
40
42
|
'file', 'function', 'method', 'class', 'interface',
|
|
41
43
|
'type_alias', 'constant', 'module', 'enum'
|
|
@@ -43,41 +45,42 @@ export function getNexusSubstrate(options = {}) {
|
|
|
43
45
|
GROUP BY n.id
|
|
44
46
|
ORDER BY in_degree DESC
|
|
45
47
|
LIMIT ?`), perSubstrateLimit);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
FROM nexus_relations
|
|
48
|
+
for (const row of nodeRows) {
|
|
49
|
+
nodes.push({
|
|
50
|
+
id: `nexus:${row.id}`,
|
|
51
|
+
kind: mapKind(row.kind),
|
|
52
|
+
substrate: 'nexus',
|
|
53
|
+
label: row.name,
|
|
54
|
+
weight: row.in_degree > 0 ? Math.min(1, row.in_degree / 50) : undefined,
|
|
55
|
+
createdAt: row.indexed_at ?? null,
|
|
56
|
+
meta: { nexus_kind: row.kind, in_degree: row.in_degree },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// Edges between loaded nodes only
|
|
60
|
+
const nodeIds = new Set(nodes.map((n) => n.id));
|
|
61
|
+
const rawIds = new Set([...nodeIds].map((id) => id.replace(/^nexus:/, '')));
|
|
62
|
+
// Fetch all relations touching these nodes (both directions)
|
|
63
|
+
const placeholders = [...rawIds].map(() => '?').join(',');
|
|
64
|
+
if (rawIds.size === 0)
|
|
65
|
+
return;
|
|
66
|
+
const relRows = allTyped(db.prepare(`SELECT source_id, target_id, type, confidence
|
|
67
|
+
FROM main.nexus_relations
|
|
66
68
|
WHERE source_id IN (${placeholders})
|
|
67
69
|
AND target_id IN (${placeholders})`), ...rawIds, ...rawIds);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
for (const row of relRows) {
|
|
71
|
+
edges.push({
|
|
72
|
+
source: `nexus:${row.source_id}`,
|
|
73
|
+
target: `nexus:${row.target_id}`,
|
|
74
|
+
type: row.type,
|
|
75
|
+
weight: row.confidence ?? 0.5,
|
|
76
|
+
substrate: 'nexus',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Return partial results on error
|
|
76
82
|
}
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
// Return partial results on error
|
|
80
|
-
}
|
|
83
|
+
});
|
|
81
84
|
return { nodes, edges };
|
|
82
85
|
}
|
|
83
86
|
//# sourceMappingURL=nexus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexus.js","sourceRoot":"","sources":["../../../src/adapters/nexus.ts"],"names":[],"mappings":"AAAA
|
|
1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;oBAC7B,SAAS,EAAE,OAAO;iBACnB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,kCAAkC;QACpC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TASKS substrate adapter for the Living Brain API.
|
|
3
3
|
*
|
|
4
|
-
* Queries
|
|
4
|
+
* Queries the project `cleo.db` (`tasks_tasks`, `tasks_sessions`,
|
|
5
|
+
* `tasks_task_relations`, `tasks_task_dependencies`) and returns
|
|
6
|
+
* BrainNodes/BrainEdges for tasks and sessions.
|
|
5
7
|
* Prioritises critical/high priority tasks and active sessions.
|
|
6
8
|
*
|
|
7
9
|
* Node IDs are prefixed with "tasks:" to prevent collisions.
|
|
8
10
|
*/
|
|
9
11
|
import type { BrainEdge, BrainNode, BrainQueryOptions } from '../types.js';
|
|
10
12
|
/**
|
|
11
|
-
* Returns all BrainNodes and BrainEdges sourced from
|
|
13
|
+
* Returns all BrainNodes and BrainEdges sourced from the project `cleo.db`.
|
|
12
14
|
*
|
|
13
15
|
* Fetches tasks ordered by priority, plus recent sessions.
|
|
14
16
|
* Synthesizes parent→child, dependency, and relation edges.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../../src/adapters/tasks.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../../src/adapters/tasks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA6C3E;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,iBAAsB,GAAG;IAClE,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CA8IA"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TASKS substrate adapter for the Living Brain API.
|
|
3
3
|
*
|
|
4
|
-
* Queries
|
|
4
|
+
* Queries the project `cleo.db` (`tasks_tasks`, `tasks_sessions`,
|
|
5
|
+
* `tasks_task_relations`, `tasks_task_dependencies`) and returns
|
|
6
|
+
* BrainNodes/BrainEdges for tasks and sessions.
|
|
5
7
|
* Prioritises critical/high priority tasks and active sessions.
|
|
6
8
|
*
|
|
7
9
|
* Node IDs are prefixed with "tasks:" to prevent collisions.
|
|
8
10
|
*/
|
|
9
|
-
import { allTyped,
|
|
11
|
+
import { allTyped, readProjectStore } from '../db-connections.js';
|
|
10
12
|
import { resolveDefaultProjectContext } from '../project-context.js';
|
|
11
13
|
/** Maps priority string to numeric weight for BrainNode.weight. */
|
|
12
14
|
function priorityWeight(priority) {
|
|
@@ -19,7 +21,7 @@ function priorityWeight(priority) {
|
|
|
19
21
|
return map[priority] ?? 0.25;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
|
-
* Returns all BrainNodes and BrainEdges sourced from
|
|
24
|
+
* Returns all BrainNodes and BrainEdges sourced from the project `cleo.db`.
|
|
23
25
|
*
|
|
24
26
|
* Fetches tasks ordered by priority, plus recent sessions.
|
|
25
27
|
* Synthesizes parent→child, dependency, and relation edges.
|
|
@@ -29,17 +31,15 @@ function priorityWeight(priority) {
|
|
|
29
31
|
*/
|
|
30
32
|
export function getTasksSubstrate(options = {}) {
|
|
31
33
|
const ctx = options.projectCtx ?? resolveDefaultProjectContext();
|
|
32
|
-
const db = getTasksDb(ctx);
|
|
33
|
-
if (!db)
|
|
34
|
-
return { nodes: [], edges: [] };
|
|
35
34
|
const perSubstrateLimit = Math.ceil((options.limit ?? 500) / 5);
|
|
36
35
|
const minWeight = options.minWeight ?? 0;
|
|
37
36
|
const nodes = [];
|
|
38
37
|
const edges = [];
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
readProjectStore(ctx, (db) => {
|
|
39
|
+
try {
|
|
40
|
+
// Tasks (prioritised by severity, then recency)
|
|
41
|
+
const taskRows = allTyped(db.prepare(`SELECT id, title, status, priority, type, parent_id, created_at
|
|
42
|
+
FROM main.tasks_tasks
|
|
43
43
|
WHERE status NOT IN ('archived', 'cancelled')
|
|
44
44
|
ORDER BY
|
|
45
45
|
CASE priority
|
|
@@ -47,97 +47,98 @@ export function getTasksSubstrate(options = {}) {
|
|
|
47
47
|
END,
|
|
48
48
|
created_at DESC
|
|
49
49
|
LIMIT ?`), Math.ceil(perSubstrateLimit * 0.8));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
substrate: 'tasks',
|
|
60
|
-
label: row.title,
|
|
61
|
-
weight,
|
|
62
|
-
createdAt: row.created_at,
|
|
63
|
-
meta: {
|
|
64
|
-
status: row.status,
|
|
65
|
-
priority: row.priority,
|
|
66
|
-
type: row.type,
|
|
67
|
-
parent_id: row.parent_id,
|
|
68
|
-
created_at: row.created_at,
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
// Sessions (most recent)
|
|
73
|
-
const sessionRows = allTyped(db.prepare(`SELECT id, status, started_at, ended_at
|
|
74
|
-
FROM sessions
|
|
75
|
-
ORDER BY started_at DESC
|
|
76
|
-
LIMIT ?`), Math.ceil(perSubstrateLimit * 0.2));
|
|
77
|
-
const sessionIds = new Set();
|
|
78
|
-
for (const row of sessionRows) {
|
|
79
|
-
sessionIds.add(row.id);
|
|
80
|
-
nodes.push({
|
|
81
|
-
id: `tasks:${row.id}`,
|
|
82
|
-
kind: 'session',
|
|
83
|
-
substrate: 'tasks',
|
|
84
|
-
label: `Session ${row.id.slice(-8)}`,
|
|
85
|
-
weight: row.status === 'active' ? 0.9 : 0.4,
|
|
86
|
-
createdAt: row.started_at,
|
|
87
|
-
meta: {
|
|
88
|
-
status: row.status,
|
|
89
|
-
started_at: row.started_at,
|
|
90
|
-
ended_at: row.ended_at,
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
// Parent → child task edges
|
|
95
|
-
for (const row of taskRows) {
|
|
96
|
-
if (row.parent_id && taskIds.has(row.parent_id)) {
|
|
97
|
-
edges.push({
|
|
98
|
-
source: `tasks:${row.parent_id}`,
|
|
99
|
-
target: `tasks:${row.id}`,
|
|
100
|
-
type: 'parent_of',
|
|
101
|
-
weight: 0.9,
|
|
50
|
+
const taskIds = new Set();
|
|
51
|
+
for (const row of taskRows) {
|
|
52
|
+
const weight = priorityWeight(row.priority);
|
|
53
|
+
if (weight < minWeight)
|
|
54
|
+
continue;
|
|
55
|
+
taskIds.add(row.id);
|
|
56
|
+
nodes.push({
|
|
57
|
+
id: `tasks:${row.id}`,
|
|
58
|
+
kind: 'task',
|
|
102
59
|
substrate: 'tasks',
|
|
60
|
+
label: row.title,
|
|
61
|
+
weight,
|
|
62
|
+
createdAt: row.created_at,
|
|
63
|
+
meta: {
|
|
64
|
+
status: row.status,
|
|
65
|
+
priority: row.priority,
|
|
66
|
+
type: row.type,
|
|
67
|
+
parent_id: row.parent_id,
|
|
68
|
+
created_at: row.created_at,
|
|
69
|
+
},
|
|
103
70
|
});
|
|
104
71
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
target: `tasks:${row.related_task_id}`,
|
|
117
|
-
type: row.relation_type,
|
|
118
|
-
weight: 0.7,
|
|
72
|
+
// Sessions (most recent)
|
|
73
|
+
const sessionRows = allTyped(db.prepare(`SELECT id, status, started_at, ended_at
|
|
74
|
+
FROM main.tasks_sessions
|
|
75
|
+
ORDER BY started_at DESC
|
|
76
|
+
LIMIT ?`), Math.ceil(perSubstrateLimit * 0.2));
|
|
77
|
+
const sessionIds = new Set();
|
|
78
|
+
for (const row of sessionRows) {
|
|
79
|
+
sessionIds.add(row.id);
|
|
80
|
+
nodes.push({
|
|
81
|
+
id: `tasks:${row.id}`,
|
|
82
|
+
kind: 'session',
|
|
119
83
|
substrate: 'tasks',
|
|
84
|
+
label: `Session ${row.id.slice(-8)}`,
|
|
85
|
+
weight: row.status === 'active' ? 0.9 : 0.4,
|
|
86
|
+
createdAt: row.started_at,
|
|
87
|
+
meta: {
|
|
88
|
+
status: row.status,
|
|
89
|
+
started_at: row.started_at,
|
|
90
|
+
ended_at: row.ended_at,
|
|
91
|
+
},
|
|
120
92
|
});
|
|
121
93
|
}
|
|
122
|
-
//
|
|
123
|
-
const
|
|
124
|
-
|
|
94
|
+
// Parent → child task edges
|
|
95
|
+
for (const row of taskRows) {
|
|
96
|
+
if (row.parent_id && taskIds.has(row.parent_id)) {
|
|
97
|
+
edges.push({
|
|
98
|
+
source: `tasks:${row.parent_id}`,
|
|
99
|
+
target: `tasks:${row.id}`,
|
|
100
|
+
type: 'parent_of',
|
|
101
|
+
weight: 0.9,
|
|
102
|
+
substrate: 'tasks',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Task relations
|
|
107
|
+
if (taskIds.size > 0) {
|
|
108
|
+
const placeholders = [...taskIds].map(() => '?').join(',');
|
|
109
|
+
const relRows = allTyped(db.prepare(`SELECT task_id, related_to, relation_type
|
|
110
|
+
FROM main.tasks_task_relations
|
|
125
111
|
WHERE task_id IN (${placeholders})
|
|
126
|
-
AND
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
112
|
+
AND related_to IN (${placeholders})`), ...taskIds, ...taskIds);
|
|
113
|
+
for (const row of relRows) {
|
|
114
|
+
edges.push({
|
|
115
|
+
source: `tasks:${row.task_id}`,
|
|
116
|
+
target: `tasks:${row.related_to}`,
|
|
117
|
+
type: row.relation_type,
|
|
118
|
+
weight: 0.7,
|
|
119
|
+
substrate: 'tasks',
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
// Task dependencies
|
|
123
|
+
const depRows = allTyped(db.prepare(`SELECT task_id, depends_on
|
|
124
|
+
FROM main.tasks_task_dependencies
|
|
125
|
+
WHERE task_id IN (${placeholders})
|
|
126
|
+
AND depends_on IN (${placeholders})`), ...taskIds, ...taskIds);
|
|
127
|
+
for (const row of depRows) {
|
|
128
|
+
edges.push({
|
|
129
|
+
source: `tasks:${row.task_id}`,
|
|
130
|
+
target: `tasks:${row.depends_on}`,
|
|
131
|
+
type: 'depends_on',
|
|
132
|
+
weight: 0.85,
|
|
133
|
+
substrate: 'tasks',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
138
|
+
catch {
|
|
139
|
+
// Return partial results on error
|
|
140
|
+
}
|
|
141
|
+
});
|
|
141
142
|
return { nodes, edges };
|
|
142
143
|
}
|
|
143
144
|
//# sourceMappingURL=tasks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../src/adapters/tasks.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../src/adapters/tasks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAmCrE,mEAAmE;AACnE,SAAS,cAAc,CAAC,QAAgB;IACtC,MAAM,GAAG,GAA2B;QAClC,QAAQ,EAAE,GAAG;QACb,IAAI,EAAE,IAAI;QACV,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