toon-memory 2.9.6 → 2.10.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/mcp/server.js +11943 -11329
- package/package.json +2 -2
- package/src/lib/context.ts +27 -4
- package/src/lib/fuzzy.ts +58 -0
- package/src/lib/git.ts +16 -0
- package/src/lib/graph.ts +7 -1
- package/src/lib/quality.ts +17 -3
- package/src/lib/synonyms.ts +118 -0
- package/src/lib/utils.ts +7 -1
- package/src/mcp/tools.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toon-memory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "MCP server giving AI coding agents offline, token-efficient persistent memory — 21 tools, 80% fewer tool calls, recall decisions, patterns, and bugs across sessions. No LLM, no server; works with 15+ agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@inquirer/prompts": "^8.5.2",
|
|
35
|
-
"@modelcontextprotocol/server": "^2.0.0-beta.
|
|
35
|
+
"@modelcontextprotocol/server": "^2.0.0-beta.5",
|
|
36
36
|
"@toon-format/toon": "^2.3.0",
|
|
37
37
|
"zod": "^4.4.3"
|
|
38
38
|
},
|
package/src/lib/context.ts
CHANGED
|
@@ -18,8 +18,10 @@ import { join } from "path"
|
|
|
18
18
|
import { parseEntries, buildGraph, bm25Scores, centrality, renderCompact, type GraphEntry } from "./graph"
|
|
19
19
|
import { qualityScore } from "./quality"
|
|
20
20
|
import { normalize, isExpiredLocal, tokenize, importance } from "./utils"
|
|
21
|
+
import { expandSynonyms } from "./synonyms"
|
|
22
|
+
import { fuzzyMatch } from "./fuzzy"
|
|
21
23
|
import { coordinationView, currentBranch, pruneSessions, listSessions } from "./sessions"
|
|
22
|
-
import { readRecentCommits, gitStatusSummary, readGitIndex } from "./git"
|
|
24
|
+
import { readRecentCommits, gitStatusSummary, readGitIndex, fileMtimes } from "./git"
|
|
23
25
|
import { scanProjectStructure, readManifest, readEnvExample } from "./project-scan"
|
|
24
26
|
import { findFilesByPattern, searchCode, findCallers } from "./code-search"
|
|
25
27
|
|
|
@@ -60,6 +62,7 @@ function formatRelevantEntries(data: string, task: string, limit: number = 6): s
|
|
|
60
62
|
const bm25 = bm25Scores(entries, task)
|
|
61
63
|
const cent = centrality(adjacency)
|
|
62
64
|
const qTokens = tokenize(task)
|
|
65
|
+
const expandedTokens = expandSynonyms(qTokens)
|
|
63
66
|
|
|
64
67
|
const scored = entries
|
|
65
68
|
.filter((e) => !(e.ttl && isExpiredLocal(e.ttl)))
|
|
@@ -67,7 +70,10 @@ function formatRelevantEntries(data: string, task: string, limit: number = 6): s
|
|
|
67
70
|
const text = normalize(
|
|
68
71
|
`${e.id} ${e.category} ${e.key} ${e.content} ${e.file} ${e.tags.join(" ")}`
|
|
69
72
|
)
|
|
70
|
-
const
|
|
73
|
+
const docTokens = text.split(" ")
|
|
74
|
+
const exactMatch = qTokens.length === 0 || expandedTokens.some((t) => text.includes(t))
|
|
75
|
+
const fuzzy = !exactMatch && qTokens.length > 0 && fuzzyMatch(qTokens, docTokens)
|
|
76
|
+
const matchesQuery = exactMatch || fuzzy
|
|
71
77
|
const bm25Score = bm25.get(e.key) || 0
|
|
72
78
|
const centScore = cent.get(e.key) || 0
|
|
73
79
|
const impScore = importance(e)
|
|
@@ -539,14 +545,31 @@ export function generateContextHealth(data: string, root: string): { report: Hea
|
|
|
539
545
|
score -= 5
|
|
540
546
|
}
|
|
541
547
|
|
|
542
|
-
// 6.
|
|
548
|
+
// 6. Code drift detection: entries whose linked file changed after creation
|
|
549
|
+
const mtimes = fileMtimes(root)
|
|
550
|
+
const driftedEntries: string[] = []
|
|
551
|
+
for (const e of entries) {
|
|
552
|
+
if (!e.file) continue
|
|
553
|
+
const filePath = e.file.split(":")[0]
|
|
554
|
+
if (!filePath) continue
|
|
555
|
+
const fileDate = mtimes.get(filePath)
|
|
556
|
+
if (fileDate && e.date && fileDate > e.date) {
|
|
557
|
+
driftedEntries.push(`${e.key} (${e.file} modified ${fileDate})`)
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (driftedEntries.length > 0) {
|
|
561
|
+
warnings.push(`${driftedEntries.length} entries with stale file refs: ${driftedEntries.slice(0, 3).join("; ")}`)
|
|
562
|
+
score -= 4
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// 7. Stale sessions
|
|
543
566
|
const sessions = listSessions()
|
|
544
567
|
const stale = sessions.filter((s) => !s.active && !s.ended)
|
|
545
568
|
if (stale.length > 0) {
|
|
546
569
|
info.push(`${stale.length} stale sessions (will be pruned automatically)`)
|
|
547
570
|
}
|
|
548
571
|
|
|
549
|
-
//
|
|
572
|
+
// 8. Entry count
|
|
550
573
|
if (entries.length > 80) {
|
|
551
574
|
warnings.push(`${entries.length} entries (near limit of 100)`)
|
|
552
575
|
score -= 3
|
package/src/lib/fuzzy.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fuzzy token matching via Levenshtein distance.
|
|
3
|
+
*
|
|
4
|
+
* Handles typos and minor variations (e.g. "tiemout" ≈ "timeout").
|
|
5
|
+
* Pure JS — zero dependencies, ~20 lines of core logic.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Levenshtein edit distance between two strings.
|
|
10
|
+
* Classic DP approach, O(n*m) time, O(min(n,m)) space.
|
|
11
|
+
*/
|
|
12
|
+
export function levenshtein(a: string, b: string): number {
|
|
13
|
+
const al = a.length
|
|
14
|
+
const bl = b.length
|
|
15
|
+
if (al === 0) return bl
|
|
16
|
+
if (bl === 0) return al
|
|
17
|
+
|
|
18
|
+
// Optimization: only keep two rows at a time
|
|
19
|
+
let prev = new Array(bl + 1)
|
|
20
|
+
let curr = new Array(bl + 1)
|
|
21
|
+
for (let j = 0; j <= bl; j++) prev[j] = j
|
|
22
|
+
|
|
23
|
+
for (let i = 1; i <= al; i++) {
|
|
24
|
+
curr[0] = i
|
|
25
|
+
for (let j = 1; j <= bl; j++) {
|
|
26
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1
|
|
27
|
+
curr[j] = Math.min(
|
|
28
|
+
prev[j] + 1, // deletion
|
|
29
|
+
curr[j - 1] + 1, // insertion
|
|
30
|
+
prev[j - 1] + cost // substitution
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
;[prev, curr] = [curr, prev]
|
|
34
|
+
}
|
|
35
|
+
return prev[bl]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Check if any query token fuzzy-matches any document token
|
|
40
|
+
* within the given Levenshtein distance.
|
|
41
|
+
*
|
|
42
|
+
* Short-circuits on first match for speed.
|
|
43
|
+
*/
|
|
44
|
+
export function fuzzyMatch(
|
|
45
|
+
queryTokens: string[],
|
|
46
|
+
docTokens: string[],
|
|
47
|
+
maxDistance: number = 2
|
|
48
|
+
): boolean {
|
|
49
|
+
for (const qt of queryTokens) {
|
|
50
|
+
// Skip very short tokens (1-2 chars) — too many false positives
|
|
51
|
+
if (qt.length <= 2) continue
|
|
52
|
+
for (const dt of docTokens) {
|
|
53
|
+
if (Math.abs(qt.length - dt.length) > maxDistance) continue
|
|
54
|
+
if (levenshtein(qt, dt) <= maxDistance) return true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return false
|
|
58
|
+
}
|
package/src/lib/git.ts
CHANGED
|
@@ -149,6 +149,22 @@ export function readGitIndex(cwd?: string): string[] {
|
|
|
149
149
|
return parseIndex(dir).map((e) => e.name)
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Return a map of file path → last-modified date (YYYY-MM-DD) from the git index.
|
|
154
|
+
* Used for drift detection: compare entry creation date against file mtime.
|
|
155
|
+
*/
|
|
156
|
+
export function fileMtimes(cwd?: string): Map<string, string> {
|
|
157
|
+
const dir = gitDir(cwd)
|
|
158
|
+
if (!dir) return new Map()
|
|
159
|
+
const entries = parseIndex(dir)
|
|
160
|
+
const out = new Map<string, string>()
|
|
161
|
+
for (const e of entries) {
|
|
162
|
+
const date = new Date(e.mtimeSec * 1000).toISOString().split("T")[0]
|
|
163
|
+
out.set(e.name, date)
|
|
164
|
+
}
|
|
165
|
+
return out
|
|
166
|
+
}
|
|
167
|
+
|
|
152
168
|
/**
|
|
153
169
|
* Parse a raw git object (decompressed with zlib).
|
|
154
170
|
* Returns the object type and content.
|
package/src/lib/graph.ts
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { normalize, isExpiredLocal, tokenize, importance } from "./utils"
|
|
18
|
+
import { expandSynonyms } from "./synonyms"
|
|
19
|
+
import { fuzzyMatch } from "./fuzzy"
|
|
18
20
|
|
|
19
21
|
export interface GraphEntry {
|
|
20
22
|
id: string
|
|
@@ -207,6 +209,7 @@ export function graphRecallDetailed(
|
|
|
207
209
|
const to_date = opts.to_date || ""
|
|
208
210
|
|
|
209
211
|
const qTokens = tokenize(query)
|
|
212
|
+
const expandedTokens = expandSynonyms(qTokens)
|
|
210
213
|
const bm25 = bm25Scores(entries, query)
|
|
211
214
|
const cent = centrality(adjacency)
|
|
212
215
|
|
|
@@ -219,7 +222,10 @@ export function graphRecallDetailed(
|
|
|
219
222
|
const text = normalize(
|
|
220
223
|
`${e.id} ${e.category} ${e.key} ${e.content} ${e.file} ${e.tags.join(" ")}`
|
|
221
224
|
)
|
|
222
|
-
|
|
225
|
+
const docTokens = text.split(" ")
|
|
226
|
+
const exactMatch = expandedTokens.some((t) => text.includes(t))
|
|
227
|
+
const fuzzy = !exactMatch && fuzzyMatch(qTokens, docTokens)
|
|
228
|
+
if (qTokens.length > 0 && !exactMatch && !fuzzy) continue
|
|
223
229
|
seedKeys.add(e.key)
|
|
224
230
|
}
|
|
225
231
|
|
package/src/lib/quality.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
import { parseEntries, buildGraph, bm25Scores, centrality, renderCompact, type GraphEntry } from "./graph"
|
|
11
11
|
import { normalize, isExpiredLocal, tokenize, importance } from "./utils"
|
|
12
|
+
import { expandSynonyms } from "./synonyms"
|
|
13
|
+
import { fuzzyMatch } from "./fuzzy"
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Quality score for an entry (0..1). Pure heuristics, no LLM.
|
|
@@ -100,7 +102,7 @@ export function mergeEntries(existingLine: string, newLine: string): string {
|
|
|
100
102
|
export function generateSmartRecall(
|
|
101
103
|
data: string,
|
|
102
104
|
intent: string,
|
|
103
|
-
opts: { limit?: number; category?: string; bumpAccess?: (ids: string[]) => void } = {}
|
|
105
|
+
opts: { limit?: number; category?: string; bumpAccess?: (ids: string[]) => void; fileMtimes?: Map<string, string> } = {}
|
|
104
106
|
): string {
|
|
105
107
|
const entries = parseEntries(data)
|
|
106
108
|
if (entries.length === 0) return "Empty memory."
|
|
@@ -110,8 +112,10 @@ export function generateSmartRecall(
|
|
|
110
112
|
const cent = centrality(adjacency)
|
|
111
113
|
const limit = opts.limit ?? 8
|
|
112
114
|
const category = opts.category || ""
|
|
115
|
+
const mtimes = opts.fileMtimes
|
|
113
116
|
|
|
114
117
|
const qTokens = tokenize(intent)
|
|
118
|
+
const expandedTokens = expandSynonyms(qTokens)
|
|
115
119
|
|
|
116
120
|
const scored = entries
|
|
117
121
|
.filter((e) => {
|
|
@@ -123,12 +127,22 @@ export function generateSmartRecall(
|
|
|
123
127
|
const text = normalize(
|
|
124
128
|
`${e.id} ${e.category} ${e.key} ${e.content} ${e.file} ${e.tags.join(" ")}`
|
|
125
129
|
)
|
|
126
|
-
const
|
|
130
|
+
const docTokens = text.split(" ")
|
|
131
|
+
const exactMatch = qTokens.length === 0 || expandedTokens.some((t) => text.includes(t))
|
|
132
|
+
const fuzzy = !exactMatch && qTokens.length > 0 && fuzzyMatch(qTokens, docTokens)
|
|
133
|
+
const matchesQuery = exactMatch || fuzzy
|
|
127
134
|
const bm25Score = bm25.get(e.key) || 0
|
|
128
135
|
const centScore = cent.get(e.key) || 0
|
|
129
136
|
const impScore = importance(e)
|
|
137
|
+
// Drift penalty: if the linked file was modified after the entry was created
|
|
138
|
+
let drift = 0
|
|
139
|
+
if (mtimes && e.file) {
|
|
140
|
+
const filePath = e.file.split(":")[0]
|
|
141
|
+
const fileDate = mtimes.get(filePath)
|
|
142
|
+
if (fileDate && e.date && fileDate > e.date) drift = 0.3
|
|
143
|
+
}
|
|
130
144
|
const combined =
|
|
131
|
-
bm25Score + 0.3 * centScore + 0.3 * impScore + (matchesQuery ? 0.5 : 0)
|
|
145
|
+
bm25Score + 0.3 * centScore + 0.3 * impScore + (matchesQuery ? 0.5 : 0) - drift
|
|
132
146
|
return { entry: e, score: combined, matchesQuery }
|
|
133
147
|
})
|
|
134
148
|
.filter((x) => x.score > 0 || x.matchesQuery)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain-specific synonym dictionary for toon-memory.
|
|
3
|
+
*
|
|
4
|
+
* Maps common coding/DevOps terms to their equivalents so that queries
|
|
5
|
+
* like "conexión caída" can find entries containing "timeout de red".
|
|
6
|
+
* Pure static map — zero LLM, zero network, zero embeddings.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const SYNONYMS: Record<string, string[]> = {
|
|
10
|
+
// Infrastructure / networking
|
|
11
|
+
"conexión": ["timeout", "red", "conectar", "disconnect", "connection", "conn"],
|
|
12
|
+
"conectar": ["timeout", "red", "conexión", "connect", "connection"],
|
|
13
|
+
"caída": ["down", "crash", "fail", "error", "dropped", "falla"],
|
|
14
|
+
"down": ["caída", "crash", "fail", "caer", "offline"],
|
|
15
|
+
"crash": ["caída", "down", "fail", "error", "colapso"],
|
|
16
|
+
"timeout": ["conexión", "red", "expirar", "deadline", "exceed"],
|
|
17
|
+
"red": ["network", "conexión", "ip", "dns", "proxy", "gateway"],
|
|
18
|
+
"network": ["red", "conexión", "ip", "dns", "proxy"],
|
|
19
|
+
"server": ["servidor", "backend", "api", "host"],
|
|
20
|
+
"servidor": ["server", "backend", "api", "host"],
|
|
21
|
+
"client": ["cliente", "frontend", "browser", "user-agent"],
|
|
22
|
+
"cliente": ["client", "frontend", "browser"],
|
|
23
|
+
|
|
24
|
+
// Data / storage
|
|
25
|
+
"cache": ["redis", "memcached", "cached", "caché"],
|
|
26
|
+
"redis": ["cache", "memcached", "session", "pubsub"],
|
|
27
|
+
"pool": ["pool", "connection pool", "pooling", "concurrencia"],
|
|
28
|
+
"database": ["db", "postgres", "mysql", "mongo", "sql", "base de datos"],
|
|
29
|
+
"db": ["database", "postgres", "mysql", "mongo", "sql"],
|
|
30
|
+
"session": ["sesión", "cookie", "token", "auth"],
|
|
31
|
+
|
|
32
|
+
// Errors / debugging
|
|
33
|
+
"error": ["bug", "exception", "fail", "fallo", "error", "err"],
|
|
34
|
+
"bug": ["error", "defect", "issue", "fallo", "problema"],
|
|
35
|
+
"exception": ["error", "throw", "catch", "error"],
|
|
36
|
+
"fail": ["error", "falla", "fallo", "crash", "fail"],
|
|
37
|
+
"falla": ["error", "fail", "fallo", "bug", "crash"],
|
|
38
|
+
"debug": ["debugging", "log", "trace", "diagnóstico"],
|
|
39
|
+
"log": ["logging", "debug", "trace", "registro"],
|
|
40
|
+
"warning": ["warn", "advertencia", "alerta"],
|
|
41
|
+
|
|
42
|
+
// Architecture
|
|
43
|
+
"auth": ["authentication", "autenticación", "login", "jwt", "token", "oauth"],
|
|
44
|
+
"autenticación": ["auth", "authentication", "login", "jwt", "oauth"],
|
|
45
|
+
"api": ["endpoint", "route", "rest", "graphql", "rpc"],
|
|
46
|
+
"endpoint": ["api", "route", "url", "path"],
|
|
47
|
+
"config": ["configuración", "settings", "env", "environment"],
|
|
48
|
+
"configuración": ["config", "settings", "env", "environment"],
|
|
49
|
+
"deploy": ["deployment", "despliegue", "release", "ship", "ci/cd"],
|
|
50
|
+
"despliegue": ["deploy", "deployment", "release", "publish"],
|
|
51
|
+
"migration": ["migración", "migrate", "upgrade", "schema change"],
|
|
52
|
+
"migración": ["migration", "migrate", "upgrade"],
|
|
53
|
+
|
|
54
|
+
// Code / patterns
|
|
55
|
+
"refactor": ["refactoring", "reorganizar", "reestructurar", "clean"],
|
|
56
|
+
"reestructurar": ["refactor", "refactoring", "reorganizar", "restructure"],
|
|
57
|
+
"pattern": ["patrón", "pattern", "convention", "norma", "estándar"],
|
|
58
|
+
"patrón": ["pattern", "convention", "norma", "estándar"],
|
|
59
|
+
"decision": ["decisión", "decision", "elección", "choice", "acuerdo"],
|
|
60
|
+
"decisión": ["decision", "elección", "choice", "acuerdo"],
|
|
61
|
+
"knowledge": ["conocimiento", "knowledge", "info", "información"],
|
|
62
|
+
"conocimiento": ["knowledge", "info", "información"],
|
|
63
|
+
|
|
64
|
+
// Performance
|
|
65
|
+
"performance": ["rendimiento", "perf", "latency", "throughput", "speed"],
|
|
66
|
+
"rendimiento": ["performance", "perf", "latency", "speed"],
|
|
67
|
+
"latency": ["latencia", "delay", "response time", "rt"],
|
|
68
|
+
"latencia": ["latency", "delay", "response time"],
|
|
69
|
+
"memory": ["memoria", "ram", "heap", "leak"],
|
|
70
|
+
"memoria": ["memory", "ram", "heap", "leak"],
|
|
71
|
+
"leak": ["fuga", "memory leak", "memoria"],
|
|
72
|
+
|
|
73
|
+
// Testing
|
|
74
|
+
"test": ["testing", "prueba", "tests", "spec"],
|
|
75
|
+
"prueba": ["test", "testing", "spec"],
|
|
76
|
+
"mock": ["mocking", "stub", "fake", "doble"],
|
|
77
|
+
"coverage": ["cobertura", "coverage", "tests"],
|
|
78
|
+
|
|
79
|
+
// Git / VCS
|
|
80
|
+
"commit": ["commits", "提交", "checkpoint", "save"],
|
|
81
|
+
"branch": ["rama", "branch", "feature branch", "checkout"],
|
|
82
|
+
"rama": ["branch", "feature branch", "checkout"],
|
|
83
|
+
"merge": ["mergear", "merge", "combine", "unir"],
|
|
84
|
+
"conflict": ["conflicto", "conflict", "merge conflict", "clash"],
|
|
85
|
+
"conflicto": ["conflict", "merge conflict", "clash"],
|
|
86
|
+
"revert": ["rollback", "deshacer", "undo", "restore"],
|
|
87
|
+
|
|
88
|
+
// UI / frontend
|
|
89
|
+
"ui": ["interfaz", "interface", "gui", "frontend", "vista"],
|
|
90
|
+
"interfaz": ["ui", "interface", "gui", "frontend"],
|
|
91
|
+
"component": ["componente", "widget", "module", "pieza"],
|
|
92
|
+
"componente": ["component", "widget", "module"],
|
|
93
|
+
"responsive": ["responsive", "mobile", "adaptativo", "layout"],
|
|
94
|
+
"layout": ["diseño", "design", "layout", "estructura"],
|
|
95
|
+
|
|
96
|
+
// DevOps
|
|
97
|
+
"docker": ["container", "contenedor", "image", "imagen"],
|
|
98
|
+
"contenedor": ["docker", "container", "image"],
|
|
99
|
+
"kubernetes": ["k8s", "cluster", "pods", "deployment"],
|
|
100
|
+
"ci/cd": ["pipeline", "deploy", "continuous integration", "continuous deployment"],
|
|
101
|
+
"monitoring": ["monitoreo", "observability", "metrics", "alerts"],
|
|
102
|
+
"monitoreo": ["monitoring", "observability", "metrics"],
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Expand query tokens with domain synonyms.
|
|
107
|
+
* Returns a deduplicated set containing the original tokens + their synonyms.
|
|
108
|
+
*/
|
|
109
|
+
export function expandSynonyms(queryTokens: string[]): string[] {
|
|
110
|
+
const expanded = new Set(queryTokens)
|
|
111
|
+
for (const token of queryTokens) {
|
|
112
|
+
const synonyms = SYNONYMS[token]
|
|
113
|
+
if (synonyms) {
|
|
114
|
+
for (const s of synonyms) expanded.add(s)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return [...expanded]
|
|
118
|
+
}
|
package/src/lib/utils.ts
CHANGED
|
@@ -22,4 +22,10 @@ export function importance(e: { date: string; accessed: number }): number {
|
|
|
22
22
|
return recency * 0.6 + freq * 0.4
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const tokenize = (s: string): string[] =>
|
|
25
|
+
export const tokenize = (s: string): string[] =>
|
|
26
|
+
s
|
|
27
|
+
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
28
|
+
.replace(/[-_]/g, " ")
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.split(/\s+/)
|
|
31
|
+
.filter(Boolean)
|
package/src/mcp/tools.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { graphRecallDetailed, renderCompact, parseEntries } from "../lib/graph"
|
|
|
15
15
|
import { qualityScore, mergeEntries, generateSmartRecall } from "../lib/quality"
|
|
16
16
|
import { generateContextBrief, generateContextGenerate, generateContextDiff, generateContextFocus, generateContextHealth, generateContextExport } from "../lib/context"
|
|
17
17
|
import { coordinationView, resolveSessionId, currentBranch, SESSION_TTL_MS } from "../lib/sessions"
|
|
18
|
+
import { fileMtimes } from "../lib/git"
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Register all 20 memory tools.
|
|
@@ -27,7 +28,7 @@ server.registerTool(
|
|
|
27
28
|
"memory_remember",
|
|
28
29
|
{
|
|
29
30
|
title: "Save to Memory",
|
|
30
|
-
description: "Save a fact to the project's persistent memory (decisions, patterns, bugs, knowledge). Persists between sessions.",
|
|
31
|
+
description: "Save a fact to the project's persistent memory (decisions, patterns, bugs, knowledge). Persists between sessions. To mark an entry as obsolete, save a new entry with tags containing 'superseded' (e.g. tags: 'superseded;zod').",
|
|
31
32
|
inputSchema: {
|
|
32
33
|
category: z.enum(["decision", "pattern", "bug", "knowledge"]).describe("Category of the fact"),
|
|
33
34
|
key: z.string().describe("Short title in kebab-case (e.g. risk-engine-priority)"),
|
|
@@ -365,7 +366,8 @@ server.registerTool(
|
|
|
365
366
|
},
|
|
366
367
|
async ({ intent, limit, category }) => {
|
|
367
368
|
const data = readMemory()
|
|
368
|
-
const
|
|
369
|
+
const mtimes = fileMtimes()
|
|
370
|
+
const result = generateSmartRecall(data, intent, { limit, category, fileMtimes: mtimes })
|
|
369
371
|
return { content: [{ type: "text" as const, text: result }] }
|
|
370
372
|
}
|
|
371
373
|
)
|