@cleocode/brain 2026.5.4 → 2026.5.5

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 (46) hide show
  1. package/package.json +2 -2
  2. package/dist/src/adapters/brain.d.ts +0 -35
  3. package/dist/src/adapters/brain.d.ts.map +0 -1
  4. package/dist/src/adapters/brain.js +0 -303
  5. package/dist/src/adapters/brain.js.map +0 -1
  6. package/dist/src/adapters/conduit.d.ts +0 -25
  7. package/dist/src/adapters/conduit.d.ts.map +0 -1
  8. package/dist/src/adapters/conduit.js +0 -94
  9. package/dist/src/adapters/conduit.js.map +0 -1
  10. package/dist/src/adapters/index.d.ts +0 -32
  11. package/dist/src/adapters/index.d.ts.map +0 -1
  12. package/dist/src/adapters/index.js +0 -194
  13. package/dist/src/adapters/index.js.map +0 -1
  14. package/dist/src/adapters/nexus.d.ts +0 -24
  15. package/dist/src/adapters/nexus.d.ts.map +0 -1
  16. package/dist/src/adapters/nexus.js +0 -83
  17. package/dist/src/adapters/nexus.js.map +0 -1
  18. package/dist/src/adapters/signaldock.d.ts +0 -25
  19. package/dist/src/adapters/signaldock.d.ts.map +0 -1
  20. package/dist/src/adapters/signaldock.js +0 -86
  21. package/dist/src/adapters/signaldock.js.map +0 -1
  22. package/dist/src/adapters/tasks.d.ts +0 -23
  23. package/dist/src/adapters/tasks.d.ts.map +0 -1
  24. package/dist/src/adapters/tasks.js +0 -143
  25. package/dist/src/adapters/tasks.js.map +0 -1
  26. package/dist/src/cleo-home.d.ts +0 -46
  27. package/dist/src/cleo-home.d.ts.map +0 -1
  28. package/dist/src/cleo-home.js +0 -79
  29. package/dist/src/cleo-home.js.map +0 -1
  30. package/dist/src/db-connections.d.ts +0 -94
  31. package/dist/src/db-connections.d.ts.map +0 -1
  32. package/dist/src/db-connections.js +0 -130
  33. package/dist/src/db-connections.js.map +0 -1
  34. package/dist/src/index.d.ts +0 -26
  35. package/dist/src/index.d.ts.map +0 -1
  36. package/dist/src/index.js +0 -29
  37. package/dist/src/index.js.map +0 -1
  38. package/dist/src/project-context.d.ts +0 -41
  39. package/dist/src/project-context.d.ts.map +0 -1
  40. package/dist/src/project-context.js +0 -42
  41. package/dist/src/project-context.js.map +0 -1
  42. package/dist/src/types.d.ts +0 -22
  43. package/dist/src/types.d.ts.map +0 -1
  44. package/dist/src/types.js +0 -22
  45. package/dist/src/types.js.map +0 -1
  46. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -1,46 +0,0 @@
1
- /**
2
- * Resolves CLEO home and project data paths.
3
- *
4
- * Resolution order:
5
- * 1. `CLEO_HOME` env var — explicit override
6
- * 2. XDG_DATA_HOME / platform default (`~/.local/share/cleo` on Linux)
7
- *
8
- * Project data (tasks.db, brain.db, conduit.db) is resolved from:
9
- * 1. `CLEO_ROOT` env var (project root)
10
- * 2. `process.cwd()/.cleo/`
11
- *
12
- * This module is a trimmed mirror of `packages/studio/src/lib/server/cleo-home.ts`
13
- * that contains only the path helpers required by the Living Brain substrate
14
- * adapters. Kept in sync manually; both files are small and stable.
15
- *
16
- * @task T969
17
- */
18
- /**
19
- * Returns the CLEO home directory (where global DBs live).
20
- *
21
- * Resolution order:
22
- * 1. `CLEO_HOME` env var
23
- * 2. Platform default:
24
- * - macOS: `~/Library/Application Support/cleo`
25
- * - Windows: `%LOCALAPPDATA%\cleo`
26
- * - Linux: `$XDG_DATA_HOME/cleo` (defaults to `~/.local/share/cleo`)
27
- */
28
- export declare function getCleoHome(): string;
29
- /**
30
- * Returns the project's `.cleo/` directory.
31
- * Resolved from `CLEO_ROOT` env var, falling back to `process.cwd()`.
32
- */
33
- export declare function getCleoProjectDir(): string;
34
- /** Returns the absolute path to the global nexus.db file. */
35
- export declare function getNexusDbPath(): string;
36
- /** Returns the absolute path to the project-scoped brain.db file. */
37
- export declare function getBrainDbPath(): string;
38
- /** Returns the absolute path to the project-scoped tasks.db file. */
39
- export declare function getTasksDbPath(): string;
40
- /** Returns the absolute path to the project-scoped conduit.db file. */
41
- export declare function getConduitDbPath(): string;
42
- /** Returns the absolute path to the global signaldock.db file. */
43
- export declare function getSignaldockDbPath(): string;
44
- /** Returns true when the given DB file exists on disk. */
45
- export declare function dbExists(dbPath: string): boolean;
46
- //# sourceMappingURL=cleo-home.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cleo-home.d.ts","sourceRoot":"","sources":["../../src/cleo-home.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH;;;;;;;;;GASG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAepC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAG1C;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,qEAAqE;AACrE,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,qEAAqE;AACrE,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,uEAAuE;AACvE,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,kEAAkE;AAClE,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED,0DAA0D;AAC1D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD"}
@@ -1,79 +0,0 @@
1
- /**
2
- * Resolves CLEO home and project data paths.
3
- *
4
- * Resolution order:
5
- * 1. `CLEO_HOME` env var — explicit override
6
- * 2. XDG_DATA_HOME / platform default (`~/.local/share/cleo` on Linux)
7
- *
8
- * Project data (tasks.db, brain.db, conduit.db) is resolved from:
9
- * 1. `CLEO_ROOT` env var (project root)
10
- * 2. `process.cwd()/.cleo/`
11
- *
12
- * This module is a trimmed mirror of `packages/studio/src/lib/server/cleo-home.ts`
13
- * that contains only the path helpers required by the Living Brain substrate
14
- * adapters. Kept in sync manually; both files are small and stable.
15
- *
16
- * @task T969
17
- */
18
- import { existsSync } from 'node:fs';
19
- import { homedir } from 'node:os';
20
- import { join } from 'node:path';
21
- /**
22
- * Returns the CLEO home directory (where global DBs live).
23
- *
24
- * Resolution order:
25
- * 1. `CLEO_HOME` env var
26
- * 2. Platform default:
27
- * - macOS: `~/Library/Application Support/cleo`
28
- * - Windows: `%LOCALAPPDATA%\cleo`
29
- * - Linux: `$XDG_DATA_HOME/cleo` (defaults to `~/.local/share/cleo`)
30
- */
31
- export function getCleoHome() {
32
- if (process.env['CLEO_HOME']) {
33
- return process.env['CLEO_HOME'];
34
- }
35
- const platform = process.platform;
36
- const home = homedir();
37
- if (platform === 'darwin') {
38
- return join(home, 'Library', 'Application Support', 'cleo');
39
- }
40
- if (platform === 'win32') {
41
- const localAppData = process.env['LOCALAPPDATA'] ?? join(home, 'AppData', 'Local');
42
- return join(localAppData, 'cleo');
43
- }
44
- const xdgDataHome = process.env['XDG_DATA_HOME'] ?? join(home, '.local', 'share');
45
- return join(xdgDataHome, 'cleo');
46
- }
47
- /**
48
- * Returns the project's `.cleo/` directory.
49
- * Resolved from `CLEO_ROOT` env var, falling back to `process.cwd()`.
50
- */
51
- export function getCleoProjectDir() {
52
- const root = process.env['CLEO_ROOT'] ?? process.cwd();
53
- return join(root, '.cleo');
54
- }
55
- /** Returns the absolute path to the global nexus.db file. */
56
- export function getNexusDbPath() {
57
- return join(getCleoHome(), 'nexus.db');
58
- }
59
- /** Returns the absolute path to the project-scoped brain.db file. */
60
- export function getBrainDbPath() {
61
- return join(getCleoProjectDir(), 'brain.db');
62
- }
63
- /** Returns the absolute path to the project-scoped tasks.db file. */
64
- export function getTasksDbPath() {
65
- return join(getCleoProjectDir(), 'tasks.db');
66
- }
67
- /** Returns the absolute path to the project-scoped conduit.db file. */
68
- export function getConduitDbPath() {
69
- return join(getCleoProjectDir(), 'conduit.db');
70
- }
71
- /** Returns the absolute path to the global signaldock.db file. */
72
- export function getSignaldockDbPath() {
73
- return join(getCleoHome(), 'signaldock.db');
74
- }
75
- /** Returns true when the given DB file exists on disk. */
76
- export function dbExists(dbPath) {
77
- return existsSync(dbPath);
78
- }
79
- //# source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AAC;IACvD,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7B,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;AACzC,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,iBAAiB,EAAE,EAAE,UAAU,CAAC,CAAC;AAC/C,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,CAAC,iBAAiB,EAAE,EAAE,UAAU,CAAC,CAAC;AAC/C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,CAAC,iBAAiB,EAAE,EAAE,YAAY,CAAC,CAAC;AACjD,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,mBAAmB;IACjC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,eAAe,CAAC,CAAC;AAC9C,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
@@ -1,94 +0,0 @@
1
- /**
2
- * Read-only SQLite connection helpers for the Living Brain substrate adapters.
3
- *
4
- * Uses node:sqlite (Node.js built-in).
5
- *
6
- * Global databases (nexus.db, signaldock.db) are shared across all projects
7
- * and use module-level caches — their path is fixed per machine and never
8
- * changes between requests.
9
- *
10
- * Per-project databases (brain.db, tasks.db, conduit.db) are resolved from
11
- * the active {@link ProjectContext} passed by the caller. No cross-request
12
- * caching is performed: opening SQLite with `node:sqlite` is sub-millisecond,
13
- * and caching across different ProjectContexts is the precise bug this
14
- * module's Studio counterpart was rewritten to avoid.
15
- *
16
- * This file is a trimmed mirror of
17
- * `packages/studio/src/lib/server/db/connections.ts`, containing only the
18
- * getters required by the substrate adapters.
19
- *
20
- * @task T969
21
- */
22
- import type { DatabaseSync as _DatabaseSyncType } from 'node:sqlite';
23
- import type { ProjectContext } from './project-context.js';
24
- type DatabaseSync = _DatabaseSyncType;
25
- declare const DatabaseSync: new (path: import("fs").PathLike, options?: import("node:sqlite").DatabaseSyncOptions | undefined) => DatabaseSync;
26
- /**
27
- * Minimal structural view of a `node:sqlite` prepared statement.
28
- *
29
- * `node:sqlite` returns rows as `Record<string, SQLOutputValue>[]` — a generic
30
- * shape that's not directly assignable to the row interfaces defined by each
31
- * substrate adapter. This type captures just the subset of `StatementSync`
32
- * used by the typed-row helper below.
33
- */
34
- interface PreparedStatementLike {
35
- all(...params: unknown[]): unknown[];
36
- }
37
- /**
38
- * Executes a prepared statement and returns rows typed as `T[]`.
39
- *
40
- * This helper consolidates the SQL-to-TypeScript boundary into a single,
41
- * auditable location. Each adapter specifies the expected row shape via the
42
- * type parameter; the unknown→T conversion happens exactly once per call
43
- * site rather than being scattered across every query site.
44
- *
45
- * Callers remain responsible for validating that the SQL projection matches
46
- * the declared type `T`.
47
- *
48
- * @param stmt - A prepared `node:sqlite` StatementSync.
49
- * @param params - Anonymous parameter bindings for the statement.
50
- * @returns Rows materialised as `T[]`.
51
- */
52
- export declare function allTyped<T>(stmt: PreparedStatementLike, ...params: unknown[]): T[];
53
- /**
54
- * Returns a read-only connection to the global nexus.db.
55
- * Returns null when the file does not exist on disk.
56
- */
57
- export declare function getNexusDb(): DatabaseSync | null;
58
- /**
59
- * Returns a read-only connection to the global signaldock.db.
60
- * Returns null when the file does not exist on disk.
61
- */
62
- export declare function getSignaldockDb(): DatabaseSync | null;
63
- /**
64
- * Opens a connection to brain.db for the given project context.
65
- *
66
- * Each call opens a fresh DatabaseSync against the path stored in `ctx`.
67
- * Returns null when brain.db does not exist for the project.
68
- *
69
- * @param ctx - The active project context.
70
- */
71
- export declare function getBrainDb(ctx: ProjectContext): DatabaseSync | null;
72
- /**
73
- * Opens a connection to tasks.db for the given project context.
74
- *
75
- * Each call opens a fresh DatabaseSync against the path stored in `ctx`.
76
- * Returns null when tasks.db does not exist for the project.
77
- *
78
- * @param ctx - The active project context.
79
- */
80
- export declare function getTasksDb(ctx: ProjectContext): DatabaseSync | null;
81
- /**
82
- * Opens a connection to conduit.db for the given project context.
83
- *
84
- * conduit.db lives alongside brain.db in the project's `.cleo/` directory.
85
- * Its path is derived from the brain.db path since `ProjectContext` does not
86
- * carry a dedicated `conduitDbPath` field.
87
- *
88
- * Returns null when conduit.db does not exist for the project.
89
- *
90
- * @param ctx - The active project context.
91
- */
92
- export declare function getConduitDb(ctx: ProjectContext): DatabaseSync | null;
93
- export {};
94
- //# sourceMappingURL=db-connections.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db-connections.d.ts","sourceRoot":"","sources":["../../src/db-connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,OAAO,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,KAAK,YAAY,GAAG,iBAAiB,CAAC;AACtC,QAAA,MAAQ,YAAY,wGAC8D,YACjF,CAAC;AAMF;;;;;;;GAOG;AACH,UAAU,qBAAqB;IAC7B,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;CACtC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,CAElF;AAgBD;;;GAGG;AACH,wBAAgB,UAAU,IAAI,YAAY,GAAG,IAAI,CAMhD;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAMrD;AAMD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY,GAAG,IAAI,CAInE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY,GAAG,IAAI,CAInE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY,GAAG,IAAI,CAIrE"}
@@ -1,130 +0,0 @@
1
- /**
2
- * Read-only SQLite connection helpers for the Living Brain substrate adapters.
3
- *
4
- * Uses node:sqlite (Node.js built-in).
5
- *
6
- * Global databases (nexus.db, signaldock.db) are shared across all projects
7
- * and use module-level caches — their path is fixed per machine and never
8
- * changes between requests.
9
- *
10
- * Per-project databases (brain.db, tasks.db, conduit.db) are resolved from
11
- * the active {@link ProjectContext} passed by the caller. No cross-request
12
- * caching is performed: opening SQLite with `node:sqlite` is sub-millisecond,
13
- * and caching across different ProjectContexts is the precise bug this
14
- * module's Studio counterpart was rewritten to avoid.
15
- *
16
- * This file is a trimmed mirror of
17
- * `packages/studio/src/lib/server/db/connections.ts`, containing only the
18
- * getters required by the substrate adapters.
19
- *
20
- * @task T969
21
- */
22
- import { existsSync } from 'node:fs';
23
- import { createRequire } from 'node:module';
24
- import { dirname, join } from 'node:path';
25
- import { dbExists, getNexusDbPath, getSignaldockDbPath } from './cleo-home.js';
26
- const _require = createRequire(import.meta.url);
27
- const { DatabaseSync } = _require('node:sqlite');
28
- /**
29
- * Executes a prepared statement and returns rows typed as `T[]`.
30
- *
31
- * This helper consolidates the SQL-to-TypeScript boundary into a single,
32
- * auditable location. Each adapter specifies the expected row shape via the
33
- * type parameter; the unknown→T conversion happens exactly once per call
34
- * site rather than being scattered across every query site.
35
- *
36
- * Callers remain responsible for validating that the SQL projection matches
37
- * the declared type `T`.
38
- *
39
- * @param stmt - A prepared `node:sqlite` StatementSync.
40
- * @param params - Anonymous parameter bindings for the statement.
41
- * @returns Rows materialised as `T[]`.
42
- */
43
- export function allTyped(stmt, ...params) {
44
- return stmt.all(...params);
45
- }
46
- // ---------------------------------------------------------------------------
47
- // Global singleton caches (path never changes per process)
48
- // ---------------------------------------------------------------------------
49
- /** Cached nexus.db connection — global, path is machine-scoped. */
50
- let nexusDb = null;
51
- /** Cached signaldock.db connection — global, path is machine-scoped. */
52
- let signaldockDb = null;
53
- // ---------------------------------------------------------------------------
54
- // Global DB getters (cached per process)
55
- // ---------------------------------------------------------------------------
56
- /**
57
- * Returns a read-only connection to the global nexus.db.
58
- * Returns null when the file does not exist on disk.
59
- */
60
- export function getNexusDb() {
61
- if (nexusDb)
62
- return nexusDb;
63
- const path = getNexusDbPath();
64
- if (!dbExists(path))
65
- return null;
66
- nexusDb = new DatabaseSync(path, { open: true });
67
- return nexusDb;
68
- }
69
- /**
70
- * Returns a read-only connection to the global signaldock.db.
71
- * Returns null when the file does not exist on disk.
72
- */
73
- export function getSignaldockDb() {
74
- if (signaldockDb)
75
- return signaldockDb;
76
- const path = getSignaldockDbPath();
77
- if (!dbExists(path))
78
- return null;
79
- signaldockDb = new DatabaseSync(path, { open: true });
80
- return signaldockDb;
81
- }
82
- // ---------------------------------------------------------------------------
83
- // Per-project DB getters (NOT cached — resolved from ProjectContext)
84
- // ---------------------------------------------------------------------------
85
- /**
86
- * Opens a connection to brain.db for the given project context.
87
- *
88
- * Each call opens a fresh DatabaseSync against the path stored in `ctx`.
89
- * Returns null when brain.db does not exist for the project.
90
- *
91
- * @param ctx - The active project context.
92
- */
93
- export function getBrainDb(ctx) {
94
- const path = ctx.brainDbPath;
95
- if (!existsSync(path))
96
- return null;
97
- return new DatabaseSync(path, { open: true });
98
- }
99
- /**
100
- * Opens a connection to tasks.db for the given project context.
101
- *
102
- * Each call opens a fresh DatabaseSync against the path stored in `ctx`.
103
- * Returns null when tasks.db does not exist for the project.
104
- *
105
- * @param ctx - The active project context.
106
- */
107
- export function getTasksDb(ctx) {
108
- const path = ctx.tasksDbPath;
109
- if (!existsSync(path))
110
- return null;
111
- return new DatabaseSync(path, { open: true });
112
- }
113
- /**
114
- * Opens a connection to conduit.db for the given project context.
115
- *
116
- * conduit.db lives alongside brain.db in the project's `.cleo/` directory.
117
- * Its path is derived from the brain.db path since `ProjectContext` does not
118
- * carry a dedicated `conduitDbPath` field.
119
- *
120
- * Returns null when conduit.db does not exist for the project.
121
- *
122
- * @param ctx - The active project context.
123
- */
124
- export function getConduitDb(ctx) {
125
- const path = join(dirname(ctx.brainDbPath), 'conduit.db');
126
- if (!existsSync(path))
127
- return null;
128
- return new DatabaseSync(path, { open: true });
129
- }
130
- //# sourceMappingURL=db-connections.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db-connections.js","sourceRoot":"","sources":["../../src/db-connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG/E,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEhD,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC,aAAa,CAE9C,CAAC;AAkBF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CAAI,IAA2B,EAAE,GAAG,MAAiB;IAC3E,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAQ,CAAC;AACpC,CAAC;AAED,8EAA8E;AAC9E,2DAA2D;AAC3D,8EAA8E;AAE9E,mEAAmE;AACnE,IAAI,OAAO,GAAwB,IAAI,CAAC;AAExC,wEAAwE;AACxE,IAAI,YAAY,GAAwB,IAAI,CAAC;AAE7C,8EAA8E;AAC9E,yCAAyC;AACzC,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,IAAI,OAAO;QAAE,OAAO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IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC,CAAC;IAC1D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC"}
@@ -1,26 +0,0 @@
1
- /**
2
- * Public entry point for `@cleocode/brain` — the unified-graph substrate for CLEO.
3
- *
4
- * Exports:
5
- * - Wire-format types (BrainNode, BrainEdge, BrainGraph, BrainQueryOptions, BrainStreamEvent, BrainConnectionStatus, BrainNodeKind, BrainSubstrate)
6
- * - Unified query function (`getAllSubstrates`)
7
- * - Individual substrate adapters (`getBrainSubstrate`, `getNexusSubstrate`, `getTasksSubstrate`, `getConduitSubstrate`, `getSignaldockSubstrate`)
8
- * - Project context helpers (`ProjectContext`, `resolveDefaultProjectContext`)
9
- * - Path helpers (`getCleoHome`, `getCleoProjectDir`, `getBrainDbPath`, etc.)
10
- *
11
- * @remarks
12
- * T973 renamed the `LB*` prefix to `Brain*` to align the runtime naming with
13
- * the `@cleocode/contracts/operations/brain` wire format and the operator's
14
- * BRAIN super-graph mental model. The runtime shapes (fields, unions) remain
15
- * intentionally distinct from the contracts shapes — these are the types
16
- * produced by the substrate adapters in this package.
17
- *
18
- * @task T969 (original extraction) · T973 (LB* → Brain* rename)
19
- */
20
- export { getAllSubstrates, getBrainSubstrate, getConduitSubstrate, getNexusSubstrate, getSignaldockSubstrate, getTasksSubstrate, } from './adapters/index.js';
21
- export { dbExists, getBrainDbPath, getCleoHome, getCleoProjectDir, getConduitDbPath, getNexusDbPath, getSignaldockDbPath, getTasksDbPath, } from './cleo-home.js';
22
- export { getBrainDb, getConduitDb, getNexusDb, getSignaldockDb, getTasksDb, } from './db-connections.js';
23
- export type { ProjectContext } from './project-context.js';
24
- export { resolveDefaultProjectContext } from './project-context.js';
25
- export type { BrainConnectionStatus, BrainEdge, BrainGraph, BrainNode, BrainNodeKind, BrainProjectContext, BrainQueryOptions, BrainStreamEvent, BrainSubstrate, } from './types.js';
26
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,eAAe,EACf,UAAU,GACX,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGpE,YAAY,EACV,qBAAqB,EACrB,SAAS,EACT,UAAU,EACV,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC"}
package/dist/src/index.js DELETED
@@ -1,29 +0,0 @@
1
- /**
2
- * Public entry point for `@cleocode/brain` — the unified-graph substrate for CLEO.
3
- *
4
- * Exports:
5
- * - Wire-format types (BrainNode, BrainEdge, BrainGraph, BrainQueryOptions, BrainStreamEvent, BrainConnectionStatus, BrainNodeKind, BrainSubstrate)
6
- * - Unified query function (`getAllSubstrates`)
7
- * - Individual substrate adapters (`getBrainSubstrate`, `getNexusSubstrate`, `getTasksSubstrate`, `getConduitSubstrate`, `getSignaldockSubstrate`)
8
- * - Project context helpers (`ProjectContext`, `resolveDefaultProjectContext`)
9
- * - Path helpers (`getCleoHome`, `getCleoProjectDir`, `getBrainDbPath`, etc.)
10
- *
11
- * @remarks
12
- * T973 renamed the `LB*` prefix to `Brain*` to align the runtime naming with
13
- * the `@cleocode/contracts/operations/brain` wire format and the operator's
14
- * BRAIN super-graph mental model. The runtime shapes (fields, unions) remain
15
- * intentionally distinct from the contracts shapes — these are the types
16
- * produced by the substrate adapters in this package.
17
- *
18
- * @task T969 (original extraction) · T973 (LB* → Brain* rename)
19
- */
20
- // Substrate adapters and unified query
21
- export { getAllSubstrates, getBrainSubstrate, getConduitSubstrate, getNexusSubstrate, getSignaldockSubstrate, getTasksSubstrate, } from './adapters/index.js';
22
- // Path helpers (re-exported for downstream consumers that need to resolve
23
- // DB paths without importing the connection helpers directly)
24
- export { dbExists, getBrainDbPath, getCleoHome, getCleoProjectDir, getConduitDbPath, getNexusDbPath, getSignaldockDbPath, getTasksDbPath, } from './cleo-home.js';
25
- // Low-level connection getters (for advanced consumers; studio typically uses
26
- // its own connection helpers and passes ProjectContext to the adapters instead)
27
- export { getBrainDb, getConduitDb, getNexusDb, getSignaldockDb, getTasksDb, } from './db-connections.js';
28
- export { resolveDefaultProjectContext } from './project-context.js';
29
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,uCAAuC;AACvC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,0EAA0E;AAC1E,8DAA8D;AAC9D,OAAO,EACL,QAAQ,EACR,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,8EAA8E;AAC9E,gFAAgF;AAChF,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,eAAe,EACf,UAAU,GACX,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,41 +0,0 @@
1
- /**
2
- * Project context resolution for the Living Brain substrate.
3
- *
4
- * `ProjectContext` carries the resolved absolute paths for the per-project
5
- * databases (brain.db, tasks.db) so substrate adapters can route queries to
6
- * the correct project without depending on SvelteKit request locals.
7
- *
8
- * The `ProjectContext` shape defined here is structurally compatible with
9
- * (i.e. a subtype of) the studio's richer `ProjectContext` in
10
- * `packages/studio/src/lib/server/project-context.ts`. Studio callers may
11
- * pass their full context directly; it will satisfy this interface via
12
- * structural typing.
13
- *
14
- * `resolveDefaultProjectContext` derives a fallback context from
15
- * `CLEO_ROOT` / `process.cwd()` when no explicit context is supplied.
16
- *
17
- * @task T969
18
- */
19
- /**
20
- * Resolved paths for the active project context.
21
- *
22
- * Studio's `ProjectContext` type carries additional fields (projectId, name,
23
- * brainDbExists, tasksDbExists). TypeScript structural typing allows Studio to
24
- * pass its richer type wherever this interface is expected.
25
- */
26
- export interface ProjectContext {
27
- /** Absolute path to the project root. */
28
- projectPath: string;
29
- /** Absolute path to brain.db for this project. */
30
- brainDbPath: string;
31
- /** Absolute path to tasks.db for this project. */
32
- tasksDbPath: string;
33
- }
34
- /**
35
- * Resolve the default project context (current project from `CLEO_ROOT` / cwd).
36
- * Used as fallback when no explicit project context is supplied.
37
- *
38
- * @returns A context whose paths derive from `getCleoProjectDir()`.
39
- */
40
- export declare function resolveDefaultProjectContext(): ProjectContext;
41
- //# sourceMappingURL=project-context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"project-context.d.ts","sourceRoot":"","sources":["../../src/project-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,IAAI,cAAc,CAa7D"}
@@ -1,42 +0,0 @@
1
- /**
2
- * Project context resolution for the Living Brain substrate.
3
- *
4
- * `ProjectContext` carries the resolved absolute paths for the per-project
5
- * databases (brain.db, tasks.db) so substrate adapters can route queries to
6
- * the correct project without depending on SvelteKit request locals.
7
- *
8
- * The `ProjectContext` shape defined here is structurally compatible with
9
- * (i.e. a subtype of) the studio's richer `ProjectContext` in
10
- * `packages/studio/src/lib/server/project-context.ts`. Studio callers may
11
- * pass their full context directly; it will satisfy this interface via
12
- * structural typing.
13
- *
14
- * `resolveDefaultProjectContext` derives a fallback context from
15
- * `CLEO_ROOT` / `process.cwd()` when no explicit context is supplied.
16
- *
17
- * @task T969
18
- */
19
- import { existsSync } from 'node:fs';
20
- import { join } from 'node:path';
21
- import { getCleoProjectDir } from './cleo-home.js';
22
- /**
23
- * Resolve the default project context (current project from `CLEO_ROOT` / cwd).
24
- * Used as fallback when no explicit project context is supplied.
25
- *
26
- * @returns A context whose paths derive from `getCleoProjectDir()`.
27
- */
28
- export function resolveDefaultProjectContext() {
29
- const projectDir = getCleoProjectDir();
30
- const projectPath = projectDir.replace(/\/.cleo$/, '');
31
- const brainDbPath = join(projectDir, 'brain.db');
32
- const tasksDbPath = join(projectDir, 'tasks.db');
33
- // existsSync is referenced to match the studio surface, and documents intent;
34
- // adapters re-check existence before opening to avoid stale races.
35
- void existsSync;
36
- return {
37
- projectPath,
38
- brainDbPath,
39
- tasksDbPath,
40
- };
41
- }
42
- //# sourceMappingURL=project-context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"project-context.js","sourceRoot":"","sources":["../../src/project-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAkBnD;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B;IAC1C,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;IACvC,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACjD,8EAA8E;IAC9E,mEAAmE;IACnE,KAAK,UAAU,CAAC;IAChB,OAAO;QACL,WAAW;QACX,WAAW;QACX,WAAW;KACZ,CAAC;AACJ,CAAC"}
@@ -1,22 +0,0 @@
1
- /**
2
- * Brain unified-graph runtime types — re-exported from `@cleocode/contracts`.
3
- *
4
- * The canonical definitions live in
5
- * `packages/contracts/src/brain-graph.ts`. This file re-exports them so
6
- * existing imports of `'../types.js'` within `@cleocode/brain` continue to
7
- * resolve without change, and external consumers that `import from
8
- * '@cleocode/brain'` also receive the same canonical shapes.
9
- *
10
- * @remarks
11
- * T989 unified the three duplicate copies of BrainNode/BrainEdge/BrainGraph:
12
- * - `packages/brain/src/types.ts` (this file — was the runtime definition)
13
- * - `packages/contracts/src/operations/brain.ts` (wire-format, now renamed)
14
- * - `packages/studio/src/routes/api/memory/graph/+server.ts` (raw-DB types, renamed)
15
- *
16
- * @task T989 — Unify BrainNode / BrainEdge types (single canonical shape)
17
- * @task T973 — LB* → Brain* rename
18
- * @task T969 — `@cleocode/brain` package extraction
19
- * @see packages/contracts/src/brain-graph.ts (canonical source)
20
- */
21
- export type { BrainConnectionStatus, BrainEdge, BrainGraph, BrainNode, BrainNodeKind, BrainProjectContext, BrainQueryOptions, BrainStreamEvent, BrainSubstrate, } from '@cleocode/contracts';
22
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,YAAY,EACV,qBAAqB,EACrB,SAAS,EACT,UAAU,EACV,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC"}
package/dist/src/types.js DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * Brain unified-graph runtime types — re-exported from `@cleocode/contracts`.
3
- *
4
- * The canonical definitions live in
5
- * `packages/contracts/src/brain-graph.ts`. This file re-exports them so
6
- * existing imports of `'../types.js'` within `@cleocode/brain` continue to
7
- * resolve without change, and external consumers that `import from
8
- * '@cleocode/brain'` also receive the same canonical shapes.
9
- *
10
- * @remarks
11
- * T989 unified the three duplicate copies of BrainNode/BrainEdge/BrainGraph:
12
- * - `packages/brain/src/types.ts` (this file — was the runtime definition)
13
- * - `packages/contracts/src/operations/brain.ts` (wire-format, now renamed)
14
- * - `packages/studio/src/routes/api/memory/graph/+server.ts` (raw-DB types, renamed)
15
- *
16
- * @task T989 — Unify BrainNode / BrainEdge types (single canonical shape)
17
- * @task T973 — LB* → Brain* rename
18
- * @task T969 — `@cleocode/brain` package extraction
19
- * @see packages/contracts/src/brain-graph.ts (canonical source)
20
- */
21
- export {};
22
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}