mcp-agents-memory 0.9.11 → 0.9.12
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/build/index.js +29 -9
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -58924,11 +58924,10 @@ var CLUSTER_SYSTEM = `You are a keyword clustering assistant for a personal memo
|
|
|
58924
58924
|
Given a list of d_tags (short hyphenated keywords) with their occurrence counts,
|
|
58925
58925
|
group semantically similar tags that refer to the same project or topic.
|
|
58926
58926
|
|
|
58927
|
-
OUTPUT strict JSON array:
|
|
58928
|
-
[
|
|
58929
|
-
{ "canonical": "<best-slug>", "members": ["<tag1>", "<tag2>", ...] }
|
|
58930
|
-
|
|
58931
|
-
]
|
|
58927
|
+
OUTPUT strict JSON object (NOT a bare array):
|
|
58928
|
+
{ "clusters": [
|
|
58929
|
+
{ "canonical": "<best-slug>", "members": ["<tag1>", "<tag2>", ...] }
|
|
58930
|
+
] }
|
|
58932
58931
|
|
|
58933
58932
|
Rules:
|
|
58934
58933
|
- canonical must be one of the input tags (pick the most descriptive one) or a clean slug if none fit
|
|
@@ -58936,6 +58935,25 @@ Rules:
|
|
|
58936
58935
|
- Only group tags that clearly refer to the same project/topic
|
|
58937
58936
|
- Tags with no similar counterparts become their own single-member cluster
|
|
58938
58937
|
- Do NOT merge unrelated topics just because they share one word`;
|
|
58938
|
+
var CLUSTER_SCHEMA = {
|
|
58939
|
+
type: "object",
|
|
58940
|
+
properties: {
|
|
58941
|
+
clusters: {
|
|
58942
|
+
type: "array",
|
|
58943
|
+
items: {
|
|
58944
|
+
type: "object",
|
|
58945
|
+
properties: {
|
|
58946
|
+
canonical: { type: "string" },
|
|
58947
|
+
members: { type: "array", items: { type: "string" } }
|
|
58948
|
+
},
|
|
58949
|
+
required: ["canonical", "members"],
|
|
58950
|
+
additionalProperties: false
|
|
58951
|
+
}
|
|
58952
|
+
}
|
|
58953
|
+
},
|
|
58954
|
+
required: ["clusters"],
|
|
58955
|
+
additionalProperties: false
|
|
58956
|
+
};
|
|
58939
58957
|
async function clusterDTags(tags) {
|
|
58940
58958
|
if (tags.length === 0) return [];
|
|
58941
58959
|
const tagList = tags.map((t) => `${t.tag} (${t.cnt}x)`).join(", ");
|
|
@@ -58946,9 +58964,10 @@ ${tagList}`;
|
|
|
58946
58964
|
raw = await callRole("clusterer", {
|
|
58947
58965
|
system: CLUSTER_SYSTEM,
|
|
58948
58966
|
user: userPrompt,
|
|
58949
|
-
|
|
58967
|
+
jsonSchema: CLUSTER_SCHEMA,
|
|
58950
58968
|
enableThinking: false,
|
|
58951
|
-
maxTokens:
|
|
58969
|
+
maxTokens: 4096
|
|
58970
|
+
// was 512 — 50개 태그 클러스터링 출력이 잘려 invalid JSON 폴백됨 (ctx 8192 내 여유)
|
|
58952
58971
|
});
|
|
58953
58972
|
} catch (err2) {
|
|
58954
58973
|
console.error("\u26A0\uFE0F [DTagPromoter] clusterer call failed, falling back to no clustering:", err2);
|
|
@@ -58956,8 +58975,9 @@ ${tagList}`;
|
|
|
58956
58975
|
}
|
|
58957
58976
|
let parsed;
|
|
58958
58977
|
try {
|
|
58959
|
-
|
|
58960
|
-
|
|
58978
|
+
const obj = JSON.parse(raw);
|
|
58979
|
+
parsed = obj?.clusters;
|
|
58980
|
+
if (!Array.isArray(parsed)) throw new Error("no clusters array");
|
|
58961
58981
|
} catch {
|
|
58962
58982
|
console.error("\u26A0\uFE0F [DTagPromoter] clusterer returned invalid JSON, falling back:", raw.slice(0, 200));
|
|
58963
58983
|
return tags.map((t) => ({ canonical: t.tag, members: [t.tag], total: t.cnt }));
|