@borntorecycle/mcp-the-brain 0.1.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.
Files changed (54) hide show
  1. package/README.md +74 -0
  2. package/dist/bin/mcp-the-brain.d.ts +3 -0
  3. package/dist/bin/mcp-the-brain.d.ts.map +1 -0
  4. package/dist/bin/mcp-the-brain.js +3 -0
  5. package/dist/bin/mcp-the-brain.js.map +1 -0
  6. package/dist/src/config.d.ts +15 -0
  7. package/dist/src/config.d.ts.map +1 -0
  8. package/dist/src/config.js +83 -0
  9. package/dist/src/config.js.map +1 -0
  10. package/dist/src/server.d.ts +2 -0
  11. package/dist/src/server.d.ts.map +1 -0
  12. package/dist/src/server.js +161 -0
  13. package/dist/src/server.js.map +1 -0
  14. package/dist/src/store/indexStore.d.ts +20 -0
  15. package/dist/src/store/indexStore.d.ts.map +1 -0
  16. package/dist/src/store/indexStore.js +63 -0
  17. package/dist/src/store/indexStore.js.map +1 -0
  18. package/dist/src/store/markdownStore.d.ts +27 -0
  19. package/dist/src/store/markdownStore.d.ts.map +1 -0
  20. package/dist/src/store/markdownStore.js +176 -0
  21. package/dist/src/store/markdownStore.js.map +1 -0
  22. package/dist/src/store/vectorStore.d.ts +26 -0
  23. package/dist/src/store/vectorStore.d.ts.map +1 -0
  24. package/dist/src/store/vectorStore.js +164 -0
  25. package/dist/src/store/vectorStore.js.map +1 -0
  26. package/dist/src/tools/listBySubsystem.d.ts +15 -0
  27. package/dist/src/tools/listBySubsystem.d.ts.map +1 -0
  28. package/dist/src/tools/listBySubsystem.js +28 -0
  29. package/dist/src/tools/listBySubsystem.js.map +1 -0
  30. package/dist/src/tools/promoteToShared.d.ts +14 -0
  31. package/dist/src/tools/promoteToShared.d.ts.map +1 -0
  32. package/dist/src/tools/promoteToShared.js +63 -0
  33. package/dist/src/tools/promoteToShared.js.map +1 -0
  34. package/dist/src/tools/rebuildIndex.d.ts +14 -0
  35. package/dist/src/tools/rebuildIndex.d.ts.map +1 -0
  36. package/dist/src/tools/rebuildIndex.js +60 -0
  37. package/dist/src/tools/rebuildIndex.js.map +1 -0
  38. package/dist/src/tools/recallKnowledge.d.ts +36 -0
  39. package/dist/src/tools/recallKnowledge.d.ts.map +1 -0
  40. package/dist/src/tools/recallKnowledge.js +141 -0
  41. package/dist/src/tools/recallKnowledge.js.map +1 -0
  42. package/dist/src/tools/recordEntry.d.ts +24 -0
  43. package/dist/src/tools/recordEntry.d.ts.map +1 -0
  44. package/dist/src/tools/recordEntry.js +82 -0
  45. package/dist/src/tools/recordEntry.js.map +1 -0
  46. package/dist/src/tools/updateEntry.d.ts +26 -0
  47. package/dist/src/tools/updateEntry.d.ts.map +1 -0
  48. package/dist/src/tools/updateEntry.js +45 -0
  49. package/dist/src/tools/updateEntry.js.map +1 -0
  50. package/dist/src/types.d.ts +73 -0
  51. package/dist/src/types.d.ts.map +1 -0
  52. package/dist/src/types.js +3 -0
  53. package/dist/src/types.js.map +1 -0
  54. package/package.json +44 -0
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # MCP The Brain
2
+
3
+ A Model Context Protocol (MCP) server for structured project memory — semantic search over outcomes, patterns, and module knowledge.
4
+
5
+ ## What It Does
6
+
7
+ The Brain gives your AI coding assistant (Copilot, Claude, Cursor) access to structured project memory:
8
+ - **Outcomes** — "X worked/failed because Y"
9
+ - **Patterns** — "When doing A, prefer approach B"
10
+ - **Module Knowledge** — "Module M is sensitive to N"
11
+
12
+ Memory entries are stored as `.md` files in your repo (Git-versioned, diffable), with optional semantic search via Ollama embeddings + LanceDB.
13
+
14
+ ## Quick Setup
15
+
16
+ ### 1. Create `.brain.json` in your project root
17
+
18
+ ```json
19
+ {
20
+ "schema": 1,
21
+ "projectName": "Your-Project",
22
+ "memoryRoot": "memories/project",
23
+ "sharedMemoryRoot": "~/.brain/shared",
24
+ "embedding": {
25
+ "provider": "ollama",
26
+ "model": "nomic-embed-text"
27
+ }
28
+ }
29
+ ```
30
+
31
+ ### 2. Create memory directories
32
+
33
+ ```
34
+ memories/project/outcomes/
35
+ memories/project/patterns/
36
+ memories/project/module-knowledge/
37
+ ```
38
+
39
+ ### 3. Add `.vscode/mcp.json`
40
+
41
+ ```json
42
+ {
43
+ "servers": {
44
+ "the-brain": {
45
+ "command": "npx",
46
+ "args": ["-y", "@borntorecycle/mcp-the-brain"],
47
+ "cwd": "${workspaceFolder}"
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### 4. (Optional) Install Ollama for semantic search
54
+
55
+ ```
56
+ ollama pull nomic-embed-text
57
+ ```
58
+
59
+ Without Ollama, The Brain works in text-only mode.
60
+
61
+ ## Tools
62
+
63
+ | Tool | Description |
64
+ |------|-------------|
65
+ | `recall_knowledge` | Search memories by query, subsystem, tags, type |
66
+ | `record_entry` | Create a new memory entry |
67
+ | `update_entry` | Update or supersede an existing entry |
68
+ | `list_by_subsystem` | List entries for a specific module |
69
+ | `promote_to_shared` | Copy entry to cross-project shared memory |
70
+ | `rebuild_index` | Regenerate index + embeddings from .md files |
71
+
72
+ ## License
73
+
74
+ MIT
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import '../src/server.js';
3
+ //# sourceMappingURL=mcp-the-brain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-the-brain.d.ts","sourceRoot":"","sources":["../../bin/mcp-the-brain.ts"],"names":[],"mappings":";AACA,OAAO,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import '../src/server.js';
3
+ //# sourceMappingURL=mcp-the-brain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-the-brain.js","sourceRoot":"","sources":["../../bin/mcp-the-brain.ts"],"names":[],"mappings":";AACA,OAAO,kBAAkB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { BrainConfig } from './types.js';
2
+ /**
3
+ * Load and validate .brain.json from the given working directory.
4
+ * Throws with a clear message if the file is missing or invalid.
5
+ */
6
+ export declare function loadConfig(cwd: string): BrainConfig;
7
+ /**
8
+ * Resolve the absolute path for the project memory root.
9
+ */
10
+ export declare function resolveMemoryRoot(cwd: string, config: BrainConfig): string;
11
+ /**
12
+ * Resolve the absolute path for the shared memory root.
13
+ */
14
+ export declare function resolveSharedRoot(config: BrainConfig): string;
15
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuB9C;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAiDnD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAE1E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAE7D"}
@@ -0,0 +1,83 @@
1
+ // ─── .brain.json Configuration Reader ───
2
+ import { readFileSync, existsSync } from 'node:fs';
3
+ import { resolve, join } from 'node:path';
4
+ import { homedir } from 'node:os';
5
+ const DEFAULT_CONFIG = {
6
+ schema: 1,
7
+ memoryRoot: 'memories/project',
8
+ sharedMemoryRoot: '~/.brain/shared',
9
+ embedding: {
10
+ provider: 'ollama',
11
+ model: 'nomic-embed-text',
12
+ },
13
+ };
14
+ /**
15
+ * Resolve ~ to the user's home directory.
16
+ */
17
+ function expandTilde(p) {
18
+ if (p.startsWith('~/') || p.startsWith('~\\')) {
19
+ return join(homedir(), p.slice(2));
20
+ }
21
+ if (p === '~')
22
+ return homedir();
23
+ return p;
24
+ }
25
+ /**
26
+ * Load and validate .brain.json from the given working directory.
27
+ * Throws with a clear message if the file is missing or invalid.
28
+ */
29
+ export function loadConfig(cwd) {
30
+ const configPath = resolve(cwd, '.brain.json');
31
+ if (!existsSync(configPath)) {
32
+ throw new Error(`No .brain.json found in ${cwd}. ` +
33
+ `Create a .brain.json file at the root of your project. ` +
34
+ `See https://github.com/HITM4N84/mcp-the-brain for setup instructions.`);
35
+ }
36
+ let raw;
37
+ try {
38
+ raw = readFileSync(configPath, 'utf-8');
39
+ }
40
+ catch (err) {
41
+ throw new Error(`Failed to read .brain.json at ${configPath}: ${err.message}`);
42
+ }
43
+ let parsed;
44
+ try {
45
+ parsed = JSON.parse(raw);
46
+ }
47
+ catch {
48
+ throw new Error(`.brain.json at ${configPath} is not valid JSON.`);
49
+ }
50
+ if (typeof parsed.projectName !== 'string' || parsed.projectName.length === 0) {
51
+ throw new Error(`.brain.json: "projectName" is required and must be a non-empty string.`);
52
+ }
53
+ const config = {
54
+ schema: typeof parsed.schema === 'number' ? parsed.schema : DEFAULT_CONFIG.schema,
55
+ projectName: parsed.projectName,
56
+ memoryRoot: typeof parsed.memoryRoot === 'string' ? parsed.memoryRoot : DEFAULT_CONFIG.memoryRoot,
57
+ sharedMemoryRoot: typeof parsed.sharedMemoryRoot === 'string'
58
+ ? parsed.sharedMemoryRoot
59
+ : DEFAULT_CONFIG.sharedMemoryRoot,
60
+ embedding: {
61
+ provider: typeof parsed.embedding?.provider === 'string'
62
+ ? parsed.embedding.provider
63
+ : DEFAULT_CONFIG.embedding.provider,
64
+ model: typeof parsed.embedding?.model === 'string'
65
+ ? parsed.embedding.model
66
+ : DEFAULT_CONFIG.embedding.model,
67
+ },
68
+ };
69
+ return config;
70
+ }
71
+ /**
72
+ * Resolve the absolute path for the project memory root.
73
+ */
74
+ export function resolveMemoryRoot(cwd, config) {
75
+ return resolve(cwd, config.memoryRoot);
76
+ }
77
+ /**
78
+ * Resolve the absolute path for the shared memory root.
79
+ */
80
+ export function resolveSharedRoot(config) {
81
+ return expandTilde(config.sharedMemoryRoot);
82
+ }
83
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AA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,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,MAAmB;IAChE,OAAO,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAmB;IACnD,OAAO,WAAW,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":""}
@@ -0,0 +1,161 @@
1
+ // ─── MCP The Brain — Server Entry Point ───
2
+ // A Model Context Protocol server for structured project memory.
3
+ // Exposes 6 tools: recall_knowledge, record_entry, update_entry,
4
+ // list_by_subsystem, promote_to_shared, rebuild_index.
5
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
7
+ import { z } from 'zod';
8
+ import { loadConfig, resolveMemoryRoot } from './config.js';
9
+ import { recallKnowledge } from './tools/recallKnowledge.js';
10
+ import { recordEntry } from './tools/recordEntry.js';
11
+ import { updateEntry } from './tools/updateEntry.js';
12
+ import { listBySubsystem } from './tools/listBySubsystem.js';
13
+ import { promoteToShared } from './tools/promoteToShared.js';
14
+ import { rebuildIndex } from './tools/rebuildIndex.js';
15
+ import { checkDegradation } from './store/vectorStore.js';
16
+ import { existsSync, mkdirSync } from 'node:fs';
17
+ // ─── Configuration ───
18
+ const cwd = process.cwd();
19
+ let config;
20
+ try {
21
+ config = loadConfig(cwd);
22
+ }
23
+ catch (err) {
24
+ // CRITICAL: For stdio MCP servers, NEVER write to stdout (corrupts JSON-RPC).
25
+ // All diagnostic output goes to stderr.
26
+ process.stderr.write(`FATAL: ${err.message}\n`);
27
+ process.exit(1);
28
+ }
29
+ // Ensure memory directories exist
30
+ const memoryRoot = resolveMemoryRoot(cwd, config);
31
+ if (!existsSync(memoryRoot)) {
32
+ mkdirSync(memoryRoot, { recursive: true });
33
+ }
34
+ // Check degradation status at startup
35
+ const startupDegradation = await checkDegradation(config);
36
+ if (startupDegradation.degraded) {
37
+ process.stderr.write(`⚠ The Brain starting in degraded mode: ${startupDegradation.reason}\n` +
38
+ ` Semantic search disabled. Text-only mode active.\n`);
39
+ }
40
+ else {
41
+ process.stderr.write(`✓ The Brain ready (project: ${config.projectName})\n`);
42
+ }
43
+ // ─── MCP Server ───
44
+ const server = new McpServer({
45
+ name: 'the-brain',
46
+ version: '0.1.0',
47
+ });
48
+ // ─── Tool: recall_knowledge ───
49
+ server.tool('recall_knowledge', 'Search project memory for relevant past outcomes, patterns, and module knowledge. ' +
50
+ 'Uses semantic search when available, falls back to text matching.', {
51
+ query: z.string().describe('Natural language query to search memories for'),
52
+ subsystems: z.array(z.string()).optional().describe('Filter by module IDs (e.g., ["analyticalSimEngine"])'),
53
+ tags: z.array(z.string()).optional().describe('Filter by tags (e.g., ["calibration", "poisson"])'),
54
+ type: z.enum(['outcome', 'pattern', 'module-knowledge']).optional().describe('Filter by memory type'),
55
+ limit: z.number().min(1).max(20).optional().describe('Maximum results to return (default: 5)'),
56
+ scope: z.enum(['project', 'shared', 'all']).optional().describe('Search scope (default: "all" = project + shared)'),
57
+ }, async (params) => {
58
+ const result = await recallKnowledge(cwd, config, params);
59
+ return {
60
+ content: [{
61
+ type: 'text',
62
+ text: JSON.stringify(result, null, 2),
63
+ }],
64
+ };
65
+ });
66
+ // ─── Tool: record_entry ───
67
+ server.tool('record_entry', 'Create a new memory entry (outcome, pattern, or module-knowledge). ' +
68
+ 'Writes a .md file, updates index.json, and generates embedding if Ollama is available.', {
69
+ type: z.enum(['outcome', 'pattern', 'module-knowledge']).describe('Memory entry type'),
70
+ title: z.string().describe('One-line summary of the knowledge'),
71
+ context: z.string().describe('What situation led to this knowledge'),
72
+ result: z.string().describe('What happened (success/failure/partial)'),
73
+ reason: z.string().describe('Root cause analysis'),
74
+ lesson: z.string().describe('Actionable takeaway for future decisions'),
75
+ action: z.string().describe('What was done as a result'),
76
+ subsystems: z.array(z.string()).describe('Module IDs from INDEX_Project.md'),
77
+ tags: z.array(z.string()).describe('Free-form searchable tags'),
78
+ relatedAdrs: z.array(z.string()).optional().describe('Back-references to ADR identifiers'),
79
+ confidence: z.enum(['high', 'medium', 'low']).optional().describe('Confidence level (default: medium)'),
80
+ }, async (params) => {
81
+ const result = await recordEntry(cwd, config, params);
82
+ return {
83
+ content: [{
84
+ type: 'text',
85
+ text: JSON.stringify(result, null, 2),
86
+ }],
87
+ };
88
+ });
89
+ // ─── Tool: update_entry ───
90
+ server.tool('update_entry', 'Update an existing memory entry. Can modify body fields, status, confidence, tags, etc. ' +
91
+ 'Setting status to "superseded" requires providing superseded-by ID.', {
92
+ id: z.string().describe('ID of the entry to update (e.g., "OUT-2026-0315-001")'),
93
+ updates: z.object({
94
+ title: z.string().optional(),
95
+ context: z.string().optional(),
96
+ result: z.string().optional(),
97
+ reason: z.string().optional(),
98
+ lesson: z.string().optional(),
99
+ action: z.string().optional(),
100
+ status: z.enum(['validated', 'superseded', 'uncertain', 'deprecated']).optional(),
101
+ confidence: z.enum(['high', 'medium', 'low']).optional(),
102
+ tags: z.array(z.string()).optional(),
103
+ subsystems: z.array(z.string()).optional(),
104
+ 'superseded-by': z.string().optional(),
105
+ }).describe('Fields to update'),
106
+ }, async (params) => {
107
+ const result = await updateEntry(cwd, config, params);
108
+ return {
109
+ content: [{
110
+ type: 'text',
111
+ text: JSON.stringify(result, null, 2),
112
+ }],
113
+ };
114
+ });
115
+ // ─── Tool: list_by_subsystem ───
116
+ server.tool('list_by_subsystem', 'List all memory entries that reference a given module/subsystem ID. Fast path via index.json.', {
117
+ subsystem: z.string().describe('Module ID to filter by (e.g., "analyticalSimEngine", "optimizer")'),
118
+ scope: z.enum(['project', 'shared', 'all']).optional().describe('Search scope (default: "all")'),
119
+ }, (params) => {
120
+ const result = listBySubsystem(cwd, config, params);
121
+ return {
122
+ content: [{
123
+ type: 'text',
124
+ text: JSON.stringify(result, null, 2),
125
+ }],
126
+ };
127
+ });
128
+ // ─── Tool: promote_to_shared ───
129
+ server.tool('promote_to_shared', 'Copy a project memory entry to shared cross-project memory (~/.brain/shared/). ' +
130
+ 'The original project entry is NOT deleted.', {
131
+ id: z.string().describe('ID of the project entry to promote'),
132
+ removeProjectSpecific: z.array(z.string()).optional()
133
+ .describe('Fields to clear when promoting (e.g., ["subsystems"] for project-specific module IDs)'),
134
+ }, async (params) => {
135
+ const result = await promoteToShared(cwd, config, params);
136
+ return {
137
+ content: [{
138
+ type: 'text',
139
+ text: JSON.stringify(result, null, 2),
140
+ }],
141
+ };
142
+ });
143
+ // ─── Tool: rebuild_index ───
144
+ server.tool('rebuild_index', 'Regenerate index.json and vector embeddings from all .md memory files. ' +
145
+ 'Idempotent — safe to run at any time.', {
146
+ scope: z.enum(['project', 'shared', 'all']).optional()
147
+ .describe('Which indexes to rebuild (default: "all")'),
148
+ }, async (params) => {
149
+ const result = await rebuildIndex(cwd, config, params);
150
+ return {
151
+ content: [{
152
+ type: 'text',
153
+ text: JSON.stringify(result, null, 2),
154
+ }],
155
+ };
156
+ });
157
+ // ─── Start stdio transport ───
158
+ const transport = new StdioServerTransport();
159
+ await server.connect(transport);
160
+ process.stderr.write(`✓ The Brain MCP server connected (stdio)\n`);
161
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,iEAAiE;AACjE,iEAAiE;AACjE,uDAAuD;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,E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M,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAEhC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { IndexEntry, MemoryEntry } from '../types.js';
2
+ /**
3
+ * Read index.json from a memory root.
4
+ * Returns empty array if file doesn't exist.
5
+ */
6
+ export declare function readIndex(memoryRoot: string): IndexEntry[];
7
+ /**
8
+ * Write index.json to a memory root.
9
+ * Entries are sorted by date (newest first).
10
+ */
11
+ export declare function writeIndex(memoryRoot: string, entries: IndexEntry[]): void;
12
+ /**
13
+ * Convert a MemoryEntry to an IndexEntry.
14
+ */
15
+ export declare function entryToIndexEntry(entry: MemoryEntry, relativeFile: string): IndexEntry;
16
+ /**
17
+ * Add or update a single entry in the index.
18
+ */
19
+ export declare function upsertIndexEntry(memoryRoot: string, indexEntry: IndexEntry): void;
20
+ //# sourceMappingURL=indexStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexStore.d.ts","sourceRoot":"","sources":["../../../src/store/indexStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,EAAE,CAc1D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,CAO1E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,GAAG,UAAU,CAatF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAWjF"}
@@ -0,0 +1,63 @@
1
+ // ─── Index Store: Read/Write index.json for fast metadata lookups ───
2
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ /**
5
+ * Read index.json from a memory root.
6
+ * Returns empty array if file doesn't exist.
7
+ */
8
+ export function readIndex(memoryRoot) {
9
+ const indexPath = join(memoryRoot, 'index.json');
10
+ if (!existsSync(indexPath)) {
11
+ return [];
12
+ }
13
+ try {
14
+ const raw = readFileSync(indexPath, 'utf-8');
15
+ return JSON.parse(raw);
16
+ }
17
+ catch (err) {
18
+ process.stderr.write(`⚠ Failed to read index.json: ${err.message}\n`);
19
+ return [];
20
+ }
21
+ }
22
+ /**
23
+ * Write index.json to a memory root.
24
+ * Entries are sorted by date (newest first).
25
+ */
26
+ export function writeIndex(memoryRoot, entries) {
27
+ const indexPath = join(memoryRoot, 'index.json');
28
+ // Sort by date descending
29
+ const sorted = [...entries].sort((a, b) => b.date.localeCompare(a.date));
30
+ writeFileSync(indexPath, JSON.stringify(sorted, null, 2) + '\n', 'utf-8');
31
+ }
32
+ /**
33
+ * Convert a MemoryEntry to an IndexEntry.
34
+ */
35
+ export function entryToIndexEntry(entry, relativeFile) {
36
+ return {
37
+ id: entry.frontmatter.id,
38
+ type: entry.frontmatter.type,
39
+ file: relativeFile,
40
+ title: entry.body.title,
41
+ date: entry.frontmatter.date,
42
+ subsystems: entry.frontmatter.subsystems,
43
+ tags: entry.frontmatter.tags,
44
+ relatedAdrs: entry.frontmatter['related-adrs'],
45
+ status: entry.frontmatter.status,
46
+ confidence: entry.frontmatter.confidence,
47
+ };
48
+ }
49
+ /**
50
+ * Add or update a single entry in the index.
51
+ */
52
+ export function upsertIndexEntry(memoryRoot, indexEntry) {
53
+ const entries = readIndex(memoryRoot);
54
+ const existing = entries.findIndex(e => e.id === indexEntry.id);
55
+ if (existing >= 0) {
56
+ entries[existing] = indexEntry;
57
+ }
58
+ else {
59
+ entries.push(indexEntry);
60
+ }
61
+ writeIndex(memoryRoot, entries);
62
+ }
63
+ //# sourceMappingURL=indexStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexStore.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E,YAAoB;IACxE,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,WAAW,CAAC,EAAE;QACxB,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI;QAC5B,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK;QACvB,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI;QAC5B,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,UAAU;QACxC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI;QAC5B,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC;QAC9C,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM;QAChC,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,UAAU;KACzC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB,EAAE,UAAsB;IACzE,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,EAAE,CAAC,CAAC;IAEhE,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QAClB,OAAO,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;IAED,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { MemoryEntry, MemoryFrontmatter, MemoryBody } from '../types.js';
2
+ /**
3
+ * Read a single memory entry from a .md file.
4
+ */
5
+ export declare function readEntry(filePath: string, source: 'project' | 'shared'): MemoryEntry;
6
+ /**
7
+ * Read all memory entries from a memory root directory.
8
+ */
9
+ export declare function readAllEntries(memoryRoot: string, source: 'project' | 'shared'): MemoryEntry[];
10
+ /**
11
+ * Write a new memory entry as a .md file.
12
+ * Returns the relative file path within the memory root.
13
+ */
14
+ export declare function writeEntry(memoryRoot: string, frontmatter: MemoryFrontmatter, body: MemoryBody): string;
15
+ /**
16
+ * Update an existing memory entry's frontmatter and/or body.
17
+ */
18
+ export declare function updateEntryFile(memoryRoot: string, id: string, updates: Partial<MemoryFrontmatter & MemoryBody>): void;
19
+ /**
20
+ * Find an entry by ID across the type directories.
21
+ */
22
+ export declare function findEntryById(memoryRoot: string, id: string, source: 'project' | 'shared'): MemoryEntry | null;
23
+ /**
24
+ * Get the relative file path for an entry within the memory root.
25
+ */
26
+ export declare function getEntryRelativePath(memoryRoot: string, entry: MemoryEntry): string;
27
+ //# sourceMappingURL=markdownStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdownStore.d.ts","sourceRoot":"","sources":["../../../src/store/markdownStore.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAgC1F;;GAEG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAarF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,EAAE,CAmB9F;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,iBAAiB,EAC9B,IAAI,EAAE,UAAU,GACf,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,CAAC,iBAAiB,GAAG,UAAU,CAAC,GAC/C,IAAI,CAiBN;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,SAAS,GAAG,QAAQ,GAC3B,WAAW,GAAG,IAAI,CAQpB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAEnF"}