@jcyamacho/agent-memory 0.0.10 → 0.0.11
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 +8 -5
- package/dist/index.js +35 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -134,15 +134,18 @@ memories:
|
|
|
134
134
|
|
|
135
135
|
1. **Text relevance** is the primary signal -- memories whose content best
|
|
136
136
|
matches your search terms rank highest.
|
|
137
|
-
2. **Workspace match** is a strong secondary signal. When you pass
|
|
138
|
-
|
|
137
|
+
2. **Workspace match** is a strong secondary signal. When you pass
|
|
138
|
+
`workspace`, exact matches rank highest, sibling repositories get a small
|
|
139
|
+
boost, and unrelated workspaces rank lowest.
|
|
139
140
|
3. **Global memories** (saved without a workspace) are treated as relevant
|
|
140
|
-
everywhere.
|
|
141
|
+
everywhere. When you pass `workspace`, they rank below exact workspace
|
|
142
|
+
matches and above sibling or unrelated repositories.
|
|
141
143
|
4. **Recency** is a minor tiebreaker -- newer memories rank slightly above older
|
|
142
144
|
ones when other signals are equal.
|
|
143
145
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
If you omit `workspace`, recall falls back to text relevance and recency only.
|
|
147
|
+
For best results, pass `workspace` whenever you have one. Save memories without
|
|
148
|
+
a workspace only when they apply across all projects.
|
|
146
149
|
|
|
147
150
|
## Database location
|
|
148
151
|
|
package/dist/index.js
CHANGED
|
@@ -12464,7 +12464,7 @@ class StdioServerTransport {
|
|
|
12464
12464
|
}
|
|
12465
12465
|
}
|
|
12466
12466
|
// package.json
|
|
12467
|
-
var version2 = "0.0.
|
|
12467
|
+
var version2 = "0.0.11";
|
|
12468
12468
|
|
|
12469
12469
|
// src/config.ts
|
|
12470
12470
|
import { homedir } from "node:os";
|
|
@@ -19940,6 +19940,8 @@ var RETRIEVAL_SCORE_WEIGHT = 8;
|
|
|
19940
19940
|
var WORKSPACE_MATCH_WEIGHT = 4;
|
|
19941
19941
|
var RECENCY_WEIGHT = 1;
|
|
19942
19942
|
var MAX_COMPOSITE_SCORE = RETRIEVAL_SCORE_WEIGHT + WORKSPACE_MATCH_WEIGHT + RECENCY_WEIGHT;
|
|
19943
|
+
var GLOBAL_WORKSPACE_SCORE = 0.5;
|
|
19944
|
+
var SIBLING_WORKSPACE_SCORE = 0.25;
|
|
19943
19945
|
|
|
19944
19946
|
class MemoryService {
|
|
19945
19947
|
repository;
|
|
@@ -19979,7 +19981,7 @@ class MemoryService {
|
|
|
19979
19981
|
return reranked.sort((a, b) => b.score - a.score).slice(0, requestedLimit);
|
|
19980
19982
|
}
|
|
19981
19983
|
}
|
|
19982
|
-
|
|
19984
|
+
function normalizeLimit(value) {
|
|
19983
19985
|
if (value === undefined) {
|
|
19984
19986
|
return DEFAULT_LIMIT;
|
|
19985
19987
|
}
|
|
@@ -19987,32 +19989,48 @@ var normalizeLimit = (value) => {
|
|
|
19987
19989
|
throw new ValidationError(`Limit must be an integer between 1 and ${MAX_LIMIT}.`);
|
|
19988
19990
|
}
|
|
19989
19991
|
return value;
|
|
19990
|
-
}
|
|
19991
|
-
|
|
19992
|
+
}
|
|
19993
|
+
function normalizeOptionalString(value) {
|
|
19992
19994
|
const trimmed = value?.trim();
|
|
19993
19995
|
return trimmed ? trimmed : undefined;
|
|
19994
|
-
}
|
|
19995
|
-
|
|
19996
|
+
}
|
|
19997
|
+
function normalizeTerms(terms) {
|
|
19996
19998
|
const normalizedTerms = terms.map((term) => term.trim()).filter(Boolean);
|
|
19997
19999
|
return [...new Set(normalizedTerms)];
|
|
19998
|
-
}
|
|
19999
|
-
|
|
20000
|
-
|
|
20001
|
-
|
|
20000
|
+
}
|
|
20001
|
+
function normalizeWorkspacePath(value) {
|
|
20002
|
+
return value.trim().replaceAll("\\", "/").replace(/\/+/g, "/").split("/").filter(Boolean).join("/");
|
|
20003
|
+
}
|
|
20004
|
+
function computeWorkspaceScore(memoryWs, queryWs) {
|
|
20005
|
+
if (!queryWs) {
|
|
20006
|
+
return 0;
|
|
20007
|
+
}
|
|
20008
|
+
if (!memoryWs) {
|
|
20002
20009
|
return GLOBAL_WORKSPACE_SCORE;
|
|
20003
|
-
|
|
20010
|
+
}
|
|
20011
|
+
const normalizedMemoryWs = normalizeWorkspacePath(memoryWs);
|
|
20012
|
+
if (normalizedMemoryWs === queryWs) {
|
|
20004
20013
|
return 1;
|
|
20005
|
-
|
|
20006
|
-
|
|
20007
|
-
|
|
20014
|
+
}
|
|
20015
|
+
const queryLastSlashIndex = queryWs.lastIndexOf("/");
|
|
20016
|
+
const memoryLastSlashIndex = normalizedMemoryWs.lastIndexOf("/");
|
|
20017
|
+
if (queryLastSlashIndex <= 0 || memoryLastSlashIndex <= 0) {
|
|
20018
|
+
return 0;
|
|
20019
|
+
}
|
|
20020
|
+
const queryParent = queryWs.slice(0, queryLastSlashIndex);
|
|
20021
|
+
const memoryParent = normalizedMemoryWs.slice(0, memoryLastSlashIndex);
|
|
20022
|
+
return memoryParent === queryParent ? SIBLING_WORKSPACE_SCORE : 0;
|
|
20023
|
+
}
|
|
20024
|
+
function rerankSearchResults(results, workspace) {
|
|
20008
20025
|
if (results.length <= 1) {
|
|
20009
20026
|
return results;
|
|
20010
20027
|
}
|
|
20028
|
+
const normalizedQueryWs = workspace ? normalizeWorkspacePath(workspace) : undefined;
|
|
20011
20029
|
const updatedAtTimes = results.map((result) => result.updatedAt.getTime());
|
|
20012
20030
|
const minUpdatedAt = Math.min(...updatedAtTimes);
|
|
20013
20031
|
const maxUpdatedAt = Math.max(...updatedAtTimes);
|
|
20014
|
-
return
|
|
20015
|
-
const workspaceScore = computeWorkspaceScore(result.workspace,
|
|
20032
|
+
return results.map((result) => {
|
|
20033
|
+
const workspaceScore = computeWorkspaceScore(result.workspace, normalizedQueryWs);
|
|
20016
20034
|
const recencyScore = maxUpdatedAt === minUpdatedAt ? 0 : (result.updatedAt.getTime() - minUpdatedAt) / (maxUpdatedAt - minUpdatedAt);
|
|
20017
20035
|
const combinedScore = (result.score * RETRIEVAL_SCORE_WEIGHT + workspaceScore * WORKSPACE_MATCH_WEIGHT + recencyScore * RECENCY_WEIGHT) / MAX_COMPOSITE_SCORE;
|
|
20018
20036
|
return {
|
|
@@ -20020,7 +20038,7 @@ var rerankSearchResults = (results, workspace) => {
|
|
|
20020
20038
|
score: toNormalizedScore(combinedScore)
|
|
20021
20039
|
};
|
|
20022
20040
|
});
|
|
20023
|
-
}
|
|
20041
|
+
}
|
|
20024
20042
|
|
|
20025
20043
|
// src/tools/shared.ts
|
|
20026
20044
|
var toMcpError = (error2) => {
|