@skedulo/memory-hub-mcp 0.2.3 → 0.2.4
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/assets/session-stop.sh +5 -3
- package/dist/client.js +27 -0
- package/dist/index.js +33 -17
- package/dist/revise.js +85 -0
- package/dist/similar-notice.js +29 -0
- package/package.json +1 -1
- package/skill-guide.md +30 -0
package/assets/session-stop.sh
CHANGED
|
@@ -41,14 +41,16 @@ would be worth knowing next time, in this repo or across the team — not
|
|
|
41
41
|
narration or exploration. If you already called memory_save with type
|
|
42
42
|
"Fact" or "Scenario" for it earlier in this same session, do not save it
|
|
43
43
|
again. If nothing in this session qualifies, do nothing and finish.
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
For each item that qualifies, first call memory_recall with a query for it.
|
|
45
|
+
If one of your own memories already covers it, call memory_update on that
|
|
46
|
+
memory with the revised full text instead of saving a copy. Otherwise call
|
|
47
|
+
memory_save (type "Fact" or "Scenario"). Never delete anything.'
|
|
46
48
|
|
|
47
49
|
LOG_FILE="${TMPDIR:-/tmp}/memory-hub-stop-hook.log"
|
|
48
50
|
{
|
|
49
51
|
echo "---- $(date -u +%FT%TZ) session=$SESSION_ID ----"
|
|
50
52
|
MEMORY_HUB_STOP_HOOK_ACTIVE=1 claude -p --resume "$SESSION_ID" \
|
|
51
|
-
--allowedTools "mcp__memory-hub__memory_recall,mcp__memory-hub__memory_save" \
|
|
53
|
+
--allowedTools "mcp__memory-hub__memory_recall,mcp__memory-hub__memory_save,mcp__memory-hub__memory_update" \
|
|
52
54
|
--permission-prompts none \
|
|
53
55
|
--model haiku \
|
|
54
56
|
--no-session-persistence \
|
package/dist/client.js
CHANGED
|
@@ -20,6 +20,33 @@ class MemoryHubClient {
|
|
|
20
20
|
recall(input) {
|
|
21
21
|
return this.post('/memory/recall', input);
|
|
22
22
|
}
|
|
23
|
+
updateFact(input) {
|
|
24
|
+
return this.post('/memory/update-fact', input);
|
|
25
|
+
}
|
|
26
|
+
updateSkill(input) {
|
|
27
|
+
return this.post('/memory/update-skill', input);
|
|
28
|
+
}
|
|
29
|
+
updateScenario(input) {
|
|
30
|
+
return this.post('/memory/update-scenario', input);
|
|
31
|
+
}
|
|
32
|
+
updateWikiPage(input) {
|
|
33
|
+
return this.post('/memory/update-wiki-page', input);
|
|
34
|
+
}
|
|
35
|
+
deleteFact(input) {
|
|
36
|
+
return this.post('/memory/delete-fact', input);
|
|
37
|
+
}
|
|
38
|
+
deleteSkill(input) {
|
|
39
|
+
return this.post('/memory/delete-skill', input);
|
|
40
|
+
}
|
|
41
|
+
deleteScenario(input) {
|
|
42
|
+
return this.post('/memory/delete-scenario', input);
|
|
43
|
+
}
|
|
44
|
+
deleteWikiPage(input) {
|
|
45
|
+
return this.post('/memory/delete-wiki-page', input);
|
|
46
|
+
}
|
|
47
|
+
updateTask(input) {
|
|
48
|
+
return this.post('/memory/update-task', input);
|
|
49
|
+
}
|
|
23
50
|
saveFact(input) {
|
|
24
51
|
return this.post('/memory/save-fact', input);
|
|
25
52
|
}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,8 @@ const embeddings_1 = require("./embeddings");
|
|
|
14
14
|
const save_1 = require("./save");
|
|
15
15
|
const recall_1 = require("./recall");
|
|
16
16
|
const guide_check_1 = require("./guide-check");
|
|
17
|
+
const revise_1 = require("./revise");
|
|
18
|
+
const similar_notice_1 = require("./similar-notice");
|
|
17
19
|
const session_context_1 = require("./session-context");
|
|
18
20
|
// Must match the AgentFacts/AgentSkills/AgentWikiPages Tags custom field's Picklist
|
|
19
21
|
// allowedValues (src/object-model/custom-fields/{AgentFacts,AgentSkills,AgentWikiPages}/*-Tags.custom-field.json)
|
|
@@ -83,22 +85,10 @@ async function joinNoticeBlocks() {
|
|
|
83
85
|
},
|
|
84
86
|
];
|
|
85
87
|
}
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
function duplicateNoticeBlocks(result) {
|
|
91
|
-
const match = result.possibleDuplicate;
|
|
92
|
-
if (!match) {
|
|
93
|
-
return [];
|
|
94
|
-
}
|
|
95
|
-
const when = match.lastModifiedDate ? ` on ${match.lastModifiedDate.slice(0, 10)}` : '';
|
|
96
|
-
return [
|
|
97
|
-
{
|
|
98
|
-
type: 'text',
|
|
99
|
-
text: `Note: this looks similar to something already saved${when}: "${match.content}". Saved as new anyway — consider recalling and updating that one instead next time.`,
|
|
100
|
-
},
|
|
101
|
-
];
|
|
88
|
+
// The save has already happened (dedup only warns), so this just makes the match visible to the agent.
|
|
89
|
+
function similarNoticeBlocks(type, result) {
|
|
90
|
+
const text = (0, similar_notice_1.similarNotice)(type, result);
|
|
91
|
+
return text ? [{ type: 'text', text }] : [];
|
|
102
92
|
}
|
|
103
93
|
server.tool('memory_getSkillGuide', 'Get the current SE AI Memory Hub usage guide — when to recall, what to save where, sharing rules, repo linking. Call this first when the se-ai-memory-hub skill triggers.', {}, async () => {
|
|
104
94
|
// Read from disk on every call, not cached at module load — this is the whole point:
|
|
@@ -156,7 +146,7 @@ server.tool('memory_save', 'Save a Fact, Skill, Scenario, or Wiki page to the SE
|
|
|
156
146
|
return {
|
|
157
147
|
content: [
|
|
158
148
|
...(await joinNoticeBlocks()),
|
|
159
|
-
...
|
|
149
|
+
...similarNoticeBlocks(input.type, result),
|
|
160
150
|
{ type: 'text', text: JSON.stringify(result) },
|
|
161
151
|
],
|
|
162
152
|
};
|
|
@@ -205,6 +195,32 @@ server.tool('memory_listTeams', "List the memory teams this developer belongs to
|
|
|
205
195
|
const { teams } = await client.listTeams();
|
|
206
196
|
return { content: [{ type: 'text', text: JSON.stringify({ teams }) }] };
|
|
207
197
|
});
|
|
198
|
+
server.tool('memory_update', "Revise a memory you saved, in place, instead of saving a second copy. Pass the uid (from memory_recall, memory_get or a memory_save notice) and only the fields to change: content and tags for a Fact; title, content and tags for a Skill or Wiki page; summary for a Scenario; repo (a uid from memory_listRepos, or null for not project-specific) for any. Only the author can update. When this repeats or corrects something you already saved, use this, not memory_save.", {
|
|
199
|
+
type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
|
|
200
|
+
uid: zod_1.z.string().min(1),
|
|
201
|
+
content: zod_1.z.string().min(1).optional().describe('Fact, Skill, Wiki: the full new text, not a patch.'),
|
|
202
|
+
title: zod_1.z.string().min(1).optional().describe('Skill, Wiki only.'),
|
|
203
|
+
summary: zod_1.z.string().min(1).optional().describe('Scenario only: the full new summary.'),
|
|
204
|
+
tags: zod_1.z.array(zod_1.z.enum(TAG_VALUES)).optional().describe('Fact, Skill, Wiki only. Replaces the existing tags.'),
|
|
205
|
+
repo: zod_1.z.string().min(1).nullable().optional().describe('A DevRepos uid, or null to clear it.'),
|
|
206
|
+
}, async (input) => {
|
|
207
|
+
const result = await (0, revise_1.performUpdate)({ client, embed: embeddings_1.embed }, input);
|
|
208
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
209
|
+
});
|
|
210
|
+
server.tool('memory_delete', "Permanently delete one memory you saved. Use it to remove a copy you have just merged into another, or a memory that is wrong or obsolete. It cannot be undone and only the author can delete. Prefer memory_update when the memory is still partly right.", {
|
|
211
|
+
type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
|
|
212
|
+
uid: zod_1.z.string().min(1),
|
|
213
|
+
}, async (input) => {
|
|
214
|
+
const result = await (0, revise_1.performDelete)({ client }, input);
|
|
215
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
216
|
+
});
|
|
217
|
+
server.tool('memory_setTaskStatus', "Mark a ticket's task Done when its work is finished, or Open to reopen it. Takes the ticket ref used with memory_save externalRef, e.g. 'SOL-1234'. Anyone on the task's team can do this.", {
|
|
218
|
+
externalRef: zod_1.z.string().min(1),
|
|
219
|
+
status: zod_1.z.enum(['Open', 'Done']),
|
|
220
|
+
}, async (input) => {
|
|
221
|
+
const result = await (0, revise_1.performSetTaskStatus)({ client }, input);
|
|
222
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
223
|
+
});
|
|
208
224
|
server.tool('memory_listRepos', "List repos across this developer's teams, with an optional substring query filter, for targeting memory_save or memory_moveResourceRepo at a repo other than the current directory.", {
|
|
209
225
|
query: zod_1.z.string().optional().describe('Case-insensitive substring filter on repo name.'),
|
|
210
226
|
}, async (input) => {
|
package/dist/revise.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.performSetTaskStatus = exports.performDelete = exports.performUpdate = void 0;
|
|
4
|
+
// Which fields each type accepts. Anything else is refused, not dropped, so a typo cannot look like a successful edit.
|
|
5
|
+
const ALLOWED = {
|
|
6
|
+
Fact: ['content', 'tags', 'repo'],
|
|
7
|
+
Skill: ['title', 'content', 'tags', 'repo'],
|
|
8
|
+
Scenario: ['summary', 'repo'],
|
|
9
|
+
Wiki: ['title', 'content', 'tags', 'repo'],
|
|
10
|
+
};
|
|
11
|
+
const FIELDS = ['content', 'title', 'summary', 'tags', 'repo'];
|
|
12
|
+
// The text an item is embedded from, matching save.ts, so a revised item stays comparable to the rest.
|
|
13
|
+
function embeddedText(type, current) {
|
|
14
|
+
if (type === 'Fact')
|
|
15
|
+
return current.content ?? '';
|
|
16
|
+
if (type === 'Scenario')
|
|
17
|
+
return current.summary ?? '';
|
|
18
|
+
return `${current.title ?? ''}\n\n${current.content ?? ''}`;
|
|
19
|
+
}
|
|
20
|
+
async function fetchCurrent(client, type, uid) {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'Fact':
|
|
23
|
+
return client.getFact({ uid });
|
|
24
|
+
case 'Skill':
|
|
25
|
+
return client.getSkill({ uid });
|
|
26
|
+
case 'Scenario':
|
|
27
|
+
return client.getScenario({ uid });
|
|
28
|
+
case 'Wiki':
|
|
29
|
+
return client.getWikiPage({ uid });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function performUpdate(deps, input) {
|
|
33
|
+
const { client, embed } = deps;
|
|
34
|
+
const given = FIELDS.filter((field) => input[field] !== undefined);
|
|
35
|
+
if (given.length === 0) {
|
|
36
|
+
throw new Error('Nothing to update: pass at least one of content, title, summary, tags or repo.');
|
|
37
|
+
}
|
|
38
|
+
const refused = given.filter((field) => !ALLOWED[input.type].includes(field));
|
|
39
|
+
if (refused.length > 0) {
|
|
40
|
+
throw new Error(`A ${input.type} has no ${refused.join(', ')}. It accepts: ${ALLOWED[input.type].join(', ')}.`);
|
|
41
|
+
}
|
|
42
|
+
const textChanged = input.content !== undefined || input.title !== undefined || input.summary !== undefined;
|
|
43
|
+
let embedding;
|
|
44
|
+
if (textChanged) {
|
|
45
|
+
const current = await fetchCurrent(client, input.type, input.uid);
|
|
46
|
+
const merged = {
|
|
47
|
+
title: input.title ?? current.title,
|
|
48
|
+
content: input.content ?? current.content,
|
|
49
|
+
summary: input.summary ?? current.summary,
|
|
50
|
+
};
|
|
51
|
+
// No embedding is better than a stale one: the function clears the old vector when the text changes.
|
|
52
|
+
embedding = await embed(embeddedText(input.type, merged)).catch(() => undefined);
|
|
53
|
+
}
|
|
54
|
+
const { type, uid, ...changes } = input;
|
|
55
|
+
const body = { uid, ...changes, ...(embedding ? { embedding } : {}) };
|
|
56
|
+
switch (type) {
|
|
57
|
+
case 'Fact':
|
|
58
|
+
return client.updateFact(body);
|
|
59
|
+
case 'Skill':
|
|
60
|
+
return client.updateSkill(body);
|
|
61
|
+
case 'Scenario':
|
|
62
|
+
return client.updateScenario(body);
|
|
63
|
+
case 'Wiki':
|
|
64
|
+
return client.updateWikiPage(body);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.performUpdate = performUpdate;
|
|
68
|
+
async function performDelete(deps, input) {
|
|
69
|
+
const { client } = deps;
|
|
70
|
+
switch (input.type) {
|
|
71
|
+
case 'Fact':
|
|
72
|
+
return client.deleteFact({ uid: input.uid });
|
|
73
|
+
case 'Skill':
|
|
74
|
+
return client.deleteSkill({ uid: input.uid });
|
|
75
|
+
case 'Scenario':
|
|
76
|
+
return client.deleteScenario({ uid: input.uid });
|
|
77
|
+
case 'Wiki':
|
|
78
|
+
return client.deleteWikiPage({ uid: input.uid });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.performDelete = performDelete;
|
|
82
|
+
function performSetTaskStatus(deps, input) {
|
|
83
|
+
return deps.client.updateTask(input);
|
|
84
|
+
}
|
|
85
|
+
exports.performSetTaskStatus = performSetTaskStatus;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.similarNotice = void 0;
|
|
4
|
+
const PREVIEW = 160;
|
|
5
|
+
function describe(match) {
|
|
6
|
+
const owner = match.mine === undefined ? '' : match.mine ? ', yours' : ", a teammate's";
|
|
7
|
+
const when = match.lastModifiedDate ? `, updated ${match.lastModifiedDate.slice(0, 10)}` : '';
|
|
8
|
+
const label = match.title ? `${match.title}: ` : '';
|
|
9
|
+
const body = match.content.replace(/\s+/g, ' ').trim();
|
|
10
|
+
const preview = body.length > PREVIEW ? `${body.slice(0, PREVIEW)}…` : body;
|
|
11
|
+
return `- ${match.uid} (${match.similarity.toFixed(2)}${owner}${when}) ${label}"${preview}"`;
|
|
12
|
+
}
|
|
13
|
+
// The save has already happened when this runs; the point is to let the agent keep one copy instead of two.
|
|
14
|
+
function similarNotice(type, result) {
|
|
15
|
+
const matches = result.similar?.length ? result.similar : result.possibleDuplicate ? [result.possibleDuplicate] : [];
|
|
16
|
+
if (matches.length === 0) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
const lines = [
|
|
20
|
+
`Saved as ${result.uid}, but it looks like ${matches.length === 1 ? 'a memory' : 'memories'} already saved:`,
|
|
21
|
+
...matches.map(describe),
|
|
22
|
+
];
|
|
23
|
+
const editable = matches.some((match) => match.mine !== false);
|
|
24
|
+
lines.push(editable
|
|
25
|
+
? `If one of yours already covers this, keep a single copy: memory_update type=${type} uid=<that uid> with the merged text, then memory_delete type=${type} uid=${result.uid}.`
|
|
26
|
+
: "Those belong to teammates and cannot be edited, so keep the new one only if it adds something they don't say.");
|
|
27
|
+
return lines.join('\n');
|
|
28
|
+
}
|
|
29
|
+
exports.similarNotice = similarNotice;
|
package/package.json
CHANGED
package/skill-guide.md
CHANGED
|
@@ -147,6 +147,36 @@ stopping point, save what's already distilled now — compaction summarizes
|
|
|
147
147
|
lossily, and a fact that only exists in your reasoning does not survive
|
|
148
148
|
it. A save that happens is worth more than a better-timed one that doesn't.
|
|
149
149
|
|
|
150
|
+
## Revise, don't re-save
|
|
151
|
+
|
|
152
|
+
A memory is not frozen. When you learn something that corrects, completes or
|
|
153
|
+
repeats a memory of yours, change that memory instead of saving another one:
|
|
154
|
+
|
|
155
|
+
- **`memory_update`** with `type`, `uid` and only the fields that change
|
|
156
|
+
(`content`/`tags` for a Fact; `title`/`content`/`tags` for a Skill or Wiki
|
|
157
|
+
page; `summary` for a Scenario; `repo`, or `null`, for any). Pass the full
|
|
158
|
+
new text, not a patch. It re-embeds the text, so search keeps working. Only
|
|
159
|
+
the author can update.
|
|
160
|
+
- **`memory_delete`** removes one of your memories for good. Use it for a copy
|
|
161
|
+
you have just merged into another, or a memory that is wrong or obsolete.
|
|
162
|
+
Prefer `memory_update` while the memory is still partly right.
|
|
163
|
+
- **`memory_setTaskStatus`** with the ticket `externalRef` marks that ticket's
|
|
164
|
+
task `Done` when its work is finished, or `Open` to reopen it. Any member of
|
|
165
|
+
the task's team can do this.
|
|
166
|
+
|
|
167
|
+
`memory_save` checks what you are saving against everything you can see. If it
|
|
168
|
+
looks like an existing memory, the reply starts with `Saved as <uid>, but it
|
|
169
|
+
looks like …` and lists each match with its uid, a similarity score and whether
|
|
170
|
+
it is yours. When a match is yours and already covers the point, keep one copy:
|
|
171
|
+
`memory_update` the old one with the merged text, then `memory_delete` the one
|
|
172
|
+
you just saved. A teammate's memory cannot be edited; keep your new one only if
|
|
173
|
+
it adds something theirs does not say. The check only warns, so a distinct
|
|
174
|
+
memory that shares vocabulary with another is saved either way.
|
|
175
|
+
|
|
176
|
+
Before saving a decision or root cause that you suspect was recorded before,
|
|
177
|
+
run `memory_recall` with a query for it first. A status that has changed (a PR
|
|
178
|
+
merged, a rollout finished) is an update to the old memory, not a new fact.
|
|
179
|
+
|
|
150
180
|
## Mapping an unfamiliar codebase
|
|
151
181
|
|
|
152
182
|
When asked to get oriented in a repo or subsystem you haven't worked in
|