@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.
- package/README.md +74 -0
- package/dist/bin/mcp-the-brain.d.ts +3 -0
- package/dist/bin/mcp-the-brain.d.ts.map +1 -0
- package/dist/bin/mcp-the-brain.js +3 -0
- package/dist/bin/mcp-the-brain.js.map +1 -0
- package/dist/src/config.d.ts +15 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +83 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/server.d.ts +2 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +161 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/store/indexStore.d.ts +20 -0
- package/dist/src/store/indexStore.d.ts.map +1 -0
- package/dist/src/store/indexStore.js +63 -0
- package/dist/src/store/indexStore.js.map +1 -0
- package/dist/src/store/markdownStore.d.ts +27 -0
- package/dist/src/store/markdownStore.d.ts.map +1 -0
- package/dist/src/store/markdownStore.js +176 -0
- package/dist/src/store/markdownStore.js.map +1 -0
- package/dist/src/store/vectorStore.d.ts +26 -0
- package/dist/src/store/vectorStore.d.ts.map +1 -0
- package/dist/src/store/vectorStore.js +164 -0
- package/dist/src/store/vectorStore.js.map +1 -0
- package/dist/src/tools/listBySubsystem.d.ts +15 -0
- package/dist/src/tools/listBySubsystem.d.ts.map +1 -0
- package/dist/src/tools/listBySubsystem.js +28 -0
- package/dist/src/tools/listBySubsystem.js.map +1 -0
- package/dist/src/tools/promoteToShared.d.ts +14 -0
- package/dist/src/tools/promoteToShared.d.ts.map +1 -0
- package/dist/src/tools/promoteToShared.js +63 -0
- package/dist/src/tools/promoteToShared.js.map +1 -0
- package/dist/src/tools/rebuildIndex.d.ts +14 -0
- package/dist/src/tools/rebuildIndex.d.ts.map +1 -0
- package/dist/src/tools/rebuildIndex.js +60 -0
- package/dist/src/tools/rebuildIndex.js.map +1 -0
- package/dist/src/tools/recallKnowledge.d.ts +36 -0
- package/dist/src/tools/recallKnowledge.d.ts.map +1 -0
- package/dist/src/tools/recallKnowledge.js +141 -0
- package/dist/src/tools/recallKnowledge.js.map +1 -0
- package/dist/src/tools/recordEntry.d.ts +24 -0
- package/dist/src/tools/recordEntry.d.ts.map +1 -0
- package/dist/src/tools/recordEntry.js +82 -0
- package/dist/src/tools/recordEntry.js.map +1 -0
- package/dist/src/tools/updateEntry.d.ts +26 -0
- package/dist/src/tools/updateEntry.d.ts.map +1 -0
- package/dist/src/tools/updateEntry.js +45 -0
- package/dist/src/tools/updateEntry.js.map +1 -0
- package/dist/src/types.d.ts +73 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recallKnowledge.d.ts","sourceRoot":"","sources":["../../../src/tools/recallKnowledge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAe,UAAU,EAAE,WAAW,EAAc,eAAe,EAAE,MAAM,aAAa,CAAC;AAOlH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,KAAK,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,UAAU,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;QAC7B,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM,CAAC;YAChB,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC,CAAC;IACH,WAAW,EAAE,eAAe,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,YAAY,CAAC,CA4HvB"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// ─── Tool: recall_knowledge — Search memories (hybrid: text + semantic) ───
|
|
2
|
+
import { readIndex } from '../store/indexStore.js';
|
|
3
|
+
import { findEntryById } from '../store/markdownStore.js';
|
|
4
|
+
import { embed, vectorSearch, checkDegradation } from '../store/vectorStore.js';
|
|
5
|
+
import { resolveMemoryRoot, resolveSharedRoot } from '../config.js';
|
|
6
|
+
/**
|
|
7
|
+
* Main recall_knowledge implementation.
|
|
8
|
+
*/
|
|
9
|
+
export async function recallKnowledge(cwd, config, params) {
|
|
10
|
+
const { query, subsystems, tags, type, limit = 5, scope = 'all', } = params;
|
|
11
|
+
const degradation = await checkDegradation(config);
|
|
12
|
+
const projectRoot = resolveMemoryRoot(cwd, config);
|
|
13
|
+
const sharedRoot = resolveSharedRoot(config);
|
|
14
|
+
// Collect candidate entries from index(es)
|
|
15
|
+
let candidates = [];
|
|
16
|
+
if (scope === 'project' || scope === 'all') {
|
|
17
|
+
const projectIdx = readIndex(projectRoot);
|
|
18
|
+
candidates.push(...projectIdx.map(e => ({ ...e, source: 'project' })));
|
|
19
|
+
}
|
|
20
|
+
if (scope === 'shared' || scope === 'all') {
|
|
21
|
+
const sharedIdx = readIndex(sharedRoot);
|
|
22
|
+
candidates.push(...sharedIdx.map(e => ({ ...e, source: 'shared' })));
|
|
23
|
+
}
|
|
24
|
+
// Apply metadata filters
|
|
25
|
+
if (type) {
|
|
26
|
+
candidates = candidates.filter(c => c.type === type);
|
|
27
|
+
}
|
|
28
|
+
if (subsystems && subsystems.length > 0) {
|
|
29
|
+
candidates = candidates.filter(c => c.subsystems.some(s => subsystems.includes(s)));
|
|
30
|
+
}
|
|
31
|
+
if (tags && tags.length > 0) {
|
|
32
|
+
candidates = candidates.filter(c => c.tags.some(t => tags.includes(t)));
|
|
33
|
+
}
|
|
34
|
+
// Ranking: try semantic search first, fall back to text matching
|
|
35
|
+
let rankedIds;
|
|
36
|
+
if (!degradation.degraded) {
|
|
37
|
+
// Semantic search path
|
|
38
|
+
const queryVector = await embed(query, config.embedding.model);
|
|
39
|
+
if (queryVector) {
|
|
40
|
+
const allRoots = [
|
|
41
|
+
...(scope !== 'shared' ? [projectRoot] : []),
|
|
42
|
+
...(scope !== 'project' ? [sharedRoot] : []),
|
|
43
|
+
];
|
|
44
|
+
const vectorResults = [];
|
|
45
|
+
for (const root of allRoots) {
|
|
46
|
+
const results = await vectorSearch(root, queryVector, limit * 2);
|
|
47
|
+
vectorResults.push(...results);
|
|
48
|
+
}
|
|
49
|
+
// Sort by score descending
|
|
50
|
+
vectorResults.sort((a, b) => b.score - a.score);
|
|
51
|
+
rankedIds = vectorResults.map(r => r.id);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Embedding failed — fall back to text
|
|
55
|
+
rankedIds = textSearch(candidates, query);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Degraded mode: text-only search
|
|
60
|
+
rankedIds = textSearch(candidates, query);
|
|
61
|
+
}
|
|
62
|
+
// Filter candidates to ranked order, keep only those that passed metadata filter
|
|
63
|
+
const candidateMap = new Map(candidates.map(c => [c.id, c]));
|
|
64
|
+
const orderedCandidates = rankedIds
|
|
65
|
+
.filter(id => candidateMap.has(id))
|
|
66
|
+
.map(id => candidateMap.get(id))
|
|
67
|
+
.slice(0, limit);
|
|
68
|
+
// If semantic search returned fewer results than available, fill with text matches
|
|
69
|
+
if (orderedCandidates.length < limit && orderedCandidates.length < candidates.length) {
|
|
70
|
+
const seen = new Set(orderedCandidates.map(c => c.id));
|
|
71
|
+
const textRanked = textSearch(candidates, query);
|
|
72
|
+
for (const id of textRanked) {
|
|
73
|
+
if (seen.has(id))
|
|
74
|
+
continue;
|
|
75
|
+
const c = candidateMap.get(id);
|
|
76
|
+
if (c) {
|
|
77
|
+
orderedCandidates.push(c);
|
|
78
|
+
seen.add(id);
|
|
79
|
+
}
|
|
80
|
+
if (orderedCandidates.length >= limit)
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Read full entries
|
|
85
|
+
const entries = orderedCandidates.map(c => {
|
|
86
|
+
const root = c.source === 'project' ? projectRoot : sharedRoot;
|
|
87
|
+
const entry = findEntryById(root, c.id, c.source);
|
|
88
|
+
if (!entry)
|
|
89
|
+
return null;
|
|
90
|
+
return {
|
|
91
|
+
id: entry.frontmatter.id,
|
|
92
|
+
type: entry.frontmatter.type,
|
|
93
|
+
title: entry.body.title,
|
|
94
|
+
date: entry.frontmatter.date,
|
|
95
|
+
subsystems: entry.frontmatter.subsystems,
|
|
96
|
+
tags: entry.frontmatter.tags,
|
|
97
|
+
status: entry.frontmatter.status,
|
|
98
|
+
confidence: entry.frontmatter.confidence,
|
|
99
|
+
source: c.source,
|
|
100
|
+
body: {
|
|
101
|
+
context: entry.body.context,
|
|
102
|
+
result: entry.body.result,
|
|
103
|
+
reason: entry.body.reason,
|
|
104
|
+
lesson: entry.body.lesson,
|
|
105
|
+
action: entry.body.action,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}).filter((e) => e !== null);
|
|
109
|
+
return {
|
|
110
|
+
entries,
|
|
111
|
+
degradation,
|
|
112
|
+
totalMatches: candidates.length,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
// ─── Text-based search (fallback / degraded mode) ───
|
|
116
|
+
function textSearch(candidates, query) {
|
|
117
|
+
const queryLower = query.toLowerCase();
|
|
118
|
+
const queryTokens = queryLower.split(/\s+/).filter(t => t.length > 2);
|
|
119
|
+
const scored = candidates.map(c => {
|
|
120
|
+
const searchText = [
|
|
121
|
+
c.title,
|
|
122
|
+
...c.tags,
|
|
123
|
+
...c.subsystems,
|
|
124
|
+
...c.relatedAdrs,
|
|
125
|
+
].join(' ').toLowerCase();
|
|
126
|
+
let score = 0;
|
|
127
|
+
for (const token of queryTokens) {
|
|
128
|
+
if (searchText.includes(token))
|
|
129
|
+
score++;
|
|
130
|
+
}
|
|
131
|
+
// Exact title match gets a big boost
|
|
132
|
+
if (c.title.toLowerCase().includes(queryLower))
|
|
133
|
+
score += 5;
|
|
134
|
+
return { id: c.id, score };
|
|
135
|
+
});
|
|
136
|
+
return scored
|
|
137
|
+
.filter(s => s.score > 0)
|
|
138
|
+
.sort((a, b) => b.score - a.score)
|
|
139
|
+
.map(s => s.id);
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=recallKnowledge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recallKnowledge.js","sourceRoot":"","sources":["../../../src/tools/recallKnowledge.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAG7E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAa,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAsB,MAAM,yBAAyB,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAmCpE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAW,EACX,MAAmB,EACnB,MAAoB;IAEpB,MAAM,EACJ,KAAK,EACL,UAAU,EACV,IAA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AC,KAAK,GAAG,CAAC,CAAC;SACxB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;SACjC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BrainConfig, MemoryType, Confidence } from '../types.js';
|
|
2
|
+
export interface RecordParams {
|
|
3
|
+
type: MemoryType;
|
|
4
|
+
title: string;
|
|
5
|
+
context: string;
|
|
6
|
+
result: string;
|
|
7
|
+
reason: string;
|
|
8
|
+
lesson: string;
|
|
9
|
+
action: string;
|
|
10
|
+
subsystems: string[];
|
|
11
|
+
tags: string[];
|
|
12
|
+
relatedAdrs?: string[];
|
|
13
|
+
confidence?: Confidence;
|
|
14
|
+
}
|
|
15
|
+
export interface RecordResult {
|
|
16
|
+
id: string;
|
|
17
|
+
file: string;
|
|
18
|
+
embeddingGenerated: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Main record_entry implementation.
|
|
22
|
+
*/
|
|
23
|
+
export declare function recordEntry(cwd: string, config: BrainConfig, params: RecordParams): Promise<RecordResult>;
|
|
24
|
+
//# sourceMappingURL=recordEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordEntry.d.ts","sourceRoot":"","sources":["../../../src/tools/recordEntry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAiC,UAAU,EAAE,MAAM,aAAa,CAAC;AAMtG,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAwBD;;GAEG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,YAAY,CAAC,CA4DvB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// ─── Tool: record_entry — Create a new memory entry ───
|
|
2
|
+
import { writeEntry } from '../store/markdownStore.js';
|
|
3
|
+
import { readIndex, upsertIndexEntry } from '../store/indexStore.js';
|
|
4
|
+
import { embed, upsertVector, buildEmbeddingText, isOllamaAvailable } from '../store/vectorStore.js';
|
|
5
|
+
import { resolveMemoryRoot } from '../config.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generate a unique entry ID based on type, date, and existing entries.
|
|
8
|
+
*/
|
|
9
|
+
function generateId(type, memoryRoot) {
|
|
10
|
+
const prefix = type === 'outcome' ? 'OUT' : type === 'pattern' ? 'PAT' : 'MOD';
|
|
11
|
+
const now = new Date();
|
|
12
|
+
const dateStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}`;
|
|
13
|
+
// Find highest sequence for this prefix+date
|
|
14
|
+
const index = readIndex(memoryRoot);
|
|
15
|
+
const pattern = `${prefix}-${dateStr}-`;
|
|
16
|
+
const existing = index
|
|
17
|
+
.filter(e => e.id.startsWith(pattern))
|
|
18
|
+
.map(e => {
|
|
19
|
+
const seq = parseInt(e.id.slice(pattern.length), 10);
|
|
20
|
+
return isNaN(seq) ? 0 : seq;
|
|
21
|
+
});
|
|
22
|
+
const nextSeq = existing.length > 0 ? Math.max(...existing) + 1 : 1;
|
|
23
|
+
return `${prefix}-${dateStr}-${String(nextSeq).padStart(3, '0')}`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Main record_entry implementation.
|
|
27
|
+
*/
|
|
28
|
+
export async function recordEntry(cwd, config, params) {
|
|
29
|
+
const memoryRoot = resolveMemoryRoot(cwd, config);
|
|
30
|
+
// Generate ID
|
|
31
|
+
const id = generateId(params.type, memoryRoot);
|
|
32
|
+
const now = new Date();
|
|
33
|
+
const dateStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
|
34
|
+
// Build frontmatter
|
|
35
|
+
const frontmatter = {
|
|
36
|
+
id,
|
|
37
|
+
type: params.type,
|
|
38
|
+
date: dateStr,
|
|
39
|
+
subsystems: params.subsystems,
|
|
40
|
+
tags: params.tags,
|
|
41
|
+
'related-adrs': params.relatedAdrs ?? [],
|
|
42
|
+
status: 'validated',
|
|
43
|
+
confidence: params.confidence ?? 'medium',
|
|
44
|
+
'superseded-by': null,
|
|
45
|
+
};
|
|
46
|
+
// Build body
|
|
47
|
+
const body = {
|
|
48
|
+
title: params.title,
|
|
49
|
+
context: params.context,
|
|
50
|
+
result: params.result,
|
|
51
|
+
reason: params.reason,
|
|
52
|
+
lesson: params.lesson,
|
|
53
|
+
action: params.action,
|
|
54
|
+
};
|
|
55
|
+
// Write the .md file
|
|
56
|
+
const relativeFile = writeEntry(memoryRoot, frontmatter, body);
|
|
57
|
+
// Update index.json
|
|
58
|
+
upsertIndexEntry(memoryRoot, {
|
|
59
|
+
id,
|
|
60
|
+
type: params.type,
|
|
61
|
+
file: relativeFile,
|
|
62
|
+
title: params.title,
|
|
63
|
+
date: dateStr,
|
|
64
|
+
subsystems: params.subsystems,
|
|
65
|
+
tags: params.tags,
|
|
66
|
+
relatedAdrs: params.relatedAdrs ?? [],
|
|
67
|
+
status: 'validated',
|
|
68
|
+
confidence: params.confidence ?? 'medium',
|
|
69
|
+
});
|
|
70
|
+
// Generate embedding if Ollama is available
|
|
71
|
+
let embeddingGenerated = false;
|
|
72
|
+
if (await isOllamaAvailable()) {
|
|
73
|
+
const text = buildEmbeddingText(params.title, params.context, params.result, params.lesson);
|
|
74
|
+
const vector = await embed(text, config.embedding.model);
|
|
75
|
+
if (vector) {
|
|
76
|
+
await upsertVector(memoryRoot, id, vector);
|
|
77
|
+
embeddingGenerated = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return { id, file: relativeFile, embeddingGenerated };
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=recordEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordEntry.js","sourceRoot":"","sources":["../../../src/tools/recordEntry.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAGzD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAsBjD;;GAEG;AACH,SAAS,UAAU,CAAC,IAAgB,EAAE,UAAkB;IACtD,MAAM,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/E,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,OAAO,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,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AAW,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE;QACrC,MAAM,EAAE,WAAW;QACnB,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,QAAQ;KAC1C,CAAC,CAAC;IAEH,4CAA4C;IAC5C,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAC/B,IAAI,MAAM,iBAAiB,EAAE,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5F,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,YAAY,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;YAC3C,kBAAkB,GAAG,IAAI,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BrainConfig } from '../types.js';
|
|
2
|
+
export interface UpdateParams {
|
|
3
|
+
id: string;
|
|
4
|
+
updates: Partial<{
|
|
5
|
+
title: string;
|
|
6
|
+
context: string;
|
|
7
|
+
result: string;
|
|
8
|
+
reason: string;
|
|
9
|
+
lesson: string;
|
|
10
|
+
action: string;
|
|
11
|
+
status: string;
|
|
12
|
+
confidence: string;
|
|
13
|
+
tags: string[];
|
|
14
|
+
subsystems: string[];
|
|
15
|
+
'superseded-by': string;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
export interface UpdateResult {
|
|
19
|
+
success: boolean;
|
|
20
|
+
embeddingUpdated: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Main update_entry implementation.
|
|
24
|
+
*/
|
|
25
|
+
export declare function updateEntry(cwd: string, config: BrainConfig, params: UpdateParams): Promise<UpdateResult>;
|
|
26
|
+
//# sourceMappingURL=updateEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateEntry.d.ts","sourceRoot":"","sources":["../../../src/tools/updateEntry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAiC,MAAM,aAAa,CAAC;AAM9E,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,YAAY,CAAC,CAiDvB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// ─── Tool: update_entry — Update/supersede an existing memory entry ───
|
|
2
|
+
import { updateEntryFile, findEntryById, getEntryRelativePath } from '../store/markdownStore.js';
|
|
3
|
+
import { upsertIndexEntry } from '../store/indexStore.js';
|
|
4
|
+
import { embed, upsertVector, buildEmbeddingText, isOllamaAvailable } from '../store/vectorStore.js';
|
|
5
|
+
import { resolveMemoryRoot } from '../config.js';
|
|
6
|
+
/**
|
|
7
|
+
* Main update_entry implementation.
|
|
8
|
+
*/
|
|
9
|
+
export async function updateEntry(cwd, config, params) {
|
|
10
|
+
const memoryRoot = resolveMemoryRoot(cwd, config);
|
|
11
|
+
// Apply updates to the .md file
|
|
12
|
+
updateEntryFile(memoryRoot, params.id, params.updates);
|
|
13
|
+
// Re-read the updated entry to refresh index
|
|
14
|
+
const entry = findEntryById(memoryRoot, params.id, 'project');
|
|
15
|
+
if (!entry) {
|
|
16
|
+
throw new Error(`Entry ${params.id} not found after update — this should not happen.`);
|
|
17
|
+
}
|
|
18
|
+
const relativeFile = getEntryRelativePath(memoryRoot, entry);
|
|
19
|
+
// Update index.json
|
|
20
|
+
upsertIndexEntry(memoryRoot, {
|
|
21
|
+
id: entry.frontmatter.id,
|
|
22
|
+
type: entry.frontmatter.type,
|
|
23
|
+
file: relativeFile,
|
|
24
|
+
title: entry.body.title,
|
|
25
|
+
date: entry.frontmatter.date,
|
|
26
|
+
subsystems: entry.frontmatter.subsystems,
|
|
27
|
+
tags: entry.frontmatter.tags,
|
|
28
|
+
relatedAdrs: entry.frontmatter['related-adrs'],
|
|
29
|
+
status: entry.frontmatter.status,
|
|
30
|
+
confidence: entry.frontmatter.confidence,
|
|
31
|
+
});
|
|
32
|
+
// Re-embed if body fields changed
|
|
33
|
+
let embeddingUpdated = false;
|
|
34
|
+
const bodyFieldsChanged = ['title', 'context', 'result', 'lesson'].some(k => k in params.updates);
|
|
35
|
+
if (bodyFieldsChanged && await isOllamaAvailable()) {
|
|
36
|
+
const text = buildEmbeddingText(entry.body.title, entry.body.context, entry.body.result, entry.body.lesson);
|
|
37
|
+
const vector = await embed(text, config.embedding.model);
|
|
38
|
+
if (vector) {
|
|
39
|
+
await upsertVector(memoryRoot, params.id, vector);
|
|
40
|
+
embeddingUpdated = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { success: true, embeddingUpdated };
|
|
44
|
+
}
|
|
45
|
+
//# s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'validated' | 'superseded' | 'uncertain' | 'deprecated';
|
|
5
|
+
/** Confidence level */
|
|
6
|
+
export type Confidence = 'high' | 'medium' | 'low';
|
|
7
|
+
/** Memory scope for search */
|
|
8
|
+
export type MemoryScope = 'project' | 'shared' | 'all';
|
|
9
|
+
/** YAML frontmatter parsed from a memory entry .md file */
|
|
10
|
+
export interface MemoryFrontmatter {
|
|
11
|
+
id: string;
|
|
12
|
+
type: MemoryType;
|
|
13
|
+
date: string;
|
|
14
|
+
subsystems: string[];
|
|
15
|
+
tags: string[];
|
|
16
|
+
'related-adrs': string[];
|
|
17
|
+
status: MemoryStatus;
|
|
18
|
+
confidence: Confidence;
|
|
19
|
+
'superseded-by': string | null;
|
|
20
|
+
project?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Body sections of a memory entry */
|
|
23
|
+
export interface MemoryBody {
|
|
24
|
+
title: string;
|
|
25
|
+
context: string;
|
|
26
|
+
result: string;
|
|
27
|
+
reason: string;
|
|
28
|
+
lesson: string;
|
|
29
|
+
action: string;
|
|
30
|
+
}
|
|
31
|
+
/** A complete memory entry (frontmatter + body + source info) */
|
|
32
|
+
export interface MemoryEntry {
|
|
33
|
+
frontmatter: MemoryFrontmatter;
|
|
34
|
+
body: MemoryBody;
|
|
35
|
+
rawContent: string;
|
|
36
|
+
filePath: string;
|
|
37
|
+
source: 'project' | 'shared';
|
|
38
|
+
}
|
|
39
|
+
/** Index entry (lightweight, stored in index.json) */
|
|
40
|
+
export interface IndexEntry {
|
|
41
|
+
id: string;
|
|
42
|
+
type: MemoryType;
|
|
43
|
+
file: string;
|
|
44
|
+
title: string;
|
|
45
|
+
date: string;
|
|
46
|
+
subsystems: string[];
|
|
47
|
+
tags: string[];
|
|
48
|
+
relatedAdrs: string[];
|
|
49
|
+
status: MemoryStatus;
|
|
50
|
+
confidence: Confidence;
|
|
51
|
+
}
|
|
52
|
+
/** .brain.json configuration */
|
|
53
|
+
export interface BrainConfig {
|
|
54
|
+
schema: number;
|
|
55
|
+
projectName: string;
|
|
56
|
+
memoryRoot: string;
|
|
57
|
+
sharedMemoryRoot: string;
|
|
58
|
+
embedding: {
|
|
59
|
+
provider: string;
|
|
60
|
+
model: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Result from vector search (includes similarity score) */
|
|
64
|
+
export interface VectorSearchResult {
|
|
65
|
+
id: string;
|
|
66
|
+
score: number;
|
|
67
|
+
}
|
|
68
|
+
/** Degradation info returned when Ollama is unavailable */
|
|
69
|
+
export interface DegradationInfo {
|
|
70
|
+
degraded: boolean;
|
|
71
|
+
reason?: string;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,yBAAyB;AACzB,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAEpE,0BAA0B;AAC1B,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,CAAC;AAEnF,uBAAuB;AACvB,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEnD,8BAA8B;AAC9B,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEvD,2DAA2D;AAC3D,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM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IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,kCAAkC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@borntorecycle/mcp-the-brain",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for structured project memory — semantic search over outcomes, patterns, and module knowledge",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mcp-the-brain": "./dist/bin/mcp-the-brain.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"prepublishOnly": "npm run build",
|
|
15
|
+
"clean": "node -e \"const fs=require('fs'); fs.rmSync('dist',{recursive:true,force:true})\""
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"memory",
|
|
21
|
+
"knowledge-base",
|
|
22
|
+
"semantic-search",
|
|
23
|
+
"lancedb",
|
|
24
|
+
"ollama"
|
|
25
|
+
],
|
|
26
|
+
"author": "Pierre (HITM4N84)",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
33
|
+
"gray-matter": "^4.0.3",
|
|
34
|
+
"zod": "^3.25.0"
|
|
35
|
+
},
|
|
36
|
+
"optionalDependencies": {
|
|
37
|
+
"@lancedb/lancedb": "^0.15.0",
|
|
38
|
+
"apache-arrow": "^18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^22.0.0",
|
|
42
|
+
"typescript": "^5.7.0"
|
|
43
|
+
}
|
|
44
|
+
}
|