@skedulo/memory-hub-mcp 0.2.1 → 0.2.2
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-start.sh +17 -3
- package/dist/guide-check.js +24 -0
- package/dist/index.js +4 -1
- package/dist/recall.js +26 -6
- package/package.json +1 -1
- package/skill-guide.md +13 -5
package/assets/session-start.sh
CHANGED
|
@@ -185,16 +185,21 @@ ELIDE="if length >= $ITEM_CAP then . + \"…\" else . end"
|
|
|
185
185
|
# Without this a stored "## heading" renders at the level of the hook's own section headings.
|
|
186
186
|
INDENT='gsub("\n"; "\n ")'
|
|
187
187
|
|
|
188
|
+
# The function flags a cut item; an older one sends no flag and keeps just the "…" above.
|
|
189
|
+
cut_pointer() {
|
|
190
|
+
printf '(if .truncated then " [cut at \\(.content | length) of \\(.fullLength) — memory_get type=%s uid=\\(.uid)]" else "" end)' "$1"
|
|
191
|
+
}
|
|
192
|
+
|
|
188
193
|
extract_facts() {
|
|
189
|
-
jq -c ".facts[]? | (\"- \" + (.content | $ELIDE) + $STAMP) | $CLOSE_FENCE | $INDENT" "$1" 2>/dev/null || true
|
|
194
|
+
jq -c ".facts[]? | (\"- \" + (.content | $ELIDE) + $(cut_pointer Fact) + $STAMP) | $CLOSE_FENCE | $INDENT" "$1" 2>/dev/null || true
|
|
190
195
|
}
|
|
191
196
|
|
|
192
197
|
extract_skills() {
|
|
193
|
-
jq -c ".skills[]? | (\"- \" + .title + \": \" + (.content | $ELIDE) + $STAMP) | $CLOSE_FENCE | $INDENT" "$1" 2>/dev/null || true
|
|
198
|
+
jq -c ".skills[]? | (\"- \" + .title + \": \" + (.content | $ELIDE) + $(cut_pointer Skill) + $STAMP) | $CLOSE_FENCE | $INDENT" "$1" 2>/dev/null || true
|
|
194
199
|
}
|
|
195
200
|
|
|
196
201
|
extract_wiki() {
|
|
197
|
-
jq -c ".pages[]? | (\"- \" + .title + \": \" + (.content | $ELIDE) + $STAMP) | $CLOSE_FENCE | $INDENT" "$1" 2>/dev/null || true
|
|
202
|
+
jq -c ".pages[]? | (\"- \" + .title + \": \" + (.content | $ELIDE) + $(cut_pointer Wiki) + $STAMP) | $CLOSE_FENCE | $INDENT" "$1" 2>/dev/null || true
|
|
198
203
|
}
|
|
199
204
|
|
|
200
205
|
# Absent on functions deployed before the field existed; fall back to what arrived rather than inventing a number.
|
|
@@ -352,12 +357,21 @@ DIAG="${DIAG}_"
|
|
|
352
357
|
#
|
|
353
358
|
# First, not last: it is the only part that asks for an action, so it has to survive the
|
|
354
359
|
# budget even when nothing else does.
|
|
360
|
+
# A stale build cannot warn about itself, so the hook, which a git pull does refresh, has to.
|
|
361
|
+
MCP_DIR="${MEMORY_HUB_MCP_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../memory-hub-mcp" 2>/dev/null && pwd)}"
|
|
362
|
+
STALE_MCP=""
|
|
363
|
+
if [ -n "$MCP_DIR" ] && [ -f "$MCP_DIR/dist/index.js" ] &&
|
|
364
|
+
[ -n "$(find "$MCP_DIR/src" "$MCP_DIR/skill-guide.md" -type f \( -name '*.ts' -o -name '*.md' \) ! -name '*.test.ts' -newer "$MCP_DIR/dist/index.js" 2>/dev/null | head -1)" ]; then
|
|
365
|
+
STALE_MCP="WARNING: the memory-hub MCP build in this checkout is older than its source, so tools the guide names (memory_get) may be missing and recalled items cut at 500 chars cannot be fetched whole. Tell the user to run ./scripts/setup-dev.sh (or cd memory-hub-mcp && yarn build) and restart the session.${NL}${NL}"
|
|
366
|
+
fi
|
|
367
|
+
|
|
355
368
|
REMINDER="## Reminder${NL}"
|
|
356
369
|
REMINDER="${REMINDER}What follows is an automatic recall only - it never saves anything new.${NL}"
|
|
357
370
|
REMINDER="${REMINDER}Invoke the se-ai-memory-hub skill during this session: memory_recall before${NL}"
|
|
358
371
|
REMINDER="${REMINDER}investigating something that smells like prior context, and memory_save${NL}"
|
|
359
372
|
REMINDER="${REMINDER}(type \"Fact\" or \"Scenario\") once a task produces a durable decision, root${NL}"
|
|
360
373
|
REMINDER="${REMINDER}cause, or fix worth keeping for next time.${NL}${NL}"
|
|
374
|
+
REMINDER="${REMINDER}${STALE_MCP}"
|
|
361
375
|
CONTEXT="$REMINDER"
|
|
362
376
|
REMAINING=$((REMAINING - ${#REMINDER} - ${#DIAG}))
|
|
363
377
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.staleBuildNotice = exports.toolsMentioned = void 0;
|
|
4
|
+
// The guide is read from disk, so a pull without a rebuild pairs a new guide with an old build.
|
|
5
|
+
function toolsMentioned(guide) {
|
|
6
|
+
return [...new Set(guide.match(/\bmemory_[A-Za-z]+\b/g) ?? [])].sort();
|
|
7
|
+
}
|
|
8
|
+
exports.toolsMentioned = toolsMentioned;
|
|
9
|
+
function staleBuildNotice(guide, registered) {
|
|
10
|
+
// Fail open: with no registry to compare against, a warning would be noise.
|
|
11
|
+
if (registered.length === 0) {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
const have = new Set(registered);
|
|
15
|
+
const missing = toolsMentioned(guide).filter((name) => !have.has(name));
|
|
16
|
+
if (missing.length === 0) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
return (`WARNING: this memory-hub-mcp build is older than its guide. The guide below refers to ` +
|
|
20
|
+
`${missing.join(', ')}, which this build does not expose, so those steps will fail. ` +
|
|
21
|
+
`Tell the user to rebuild (\`cd memory-hub-mcp && yarn build\`, or rerun ./scripts/setup-dev.sh) ` +
|
|
22
|
+
`and restart the session.\n\n---\n\n`);
|
|
23
|
+
}
|
|
24
|
+
exports.staleBuildNotice = staleBuildNotice;
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ const git_remote_1 = require("./git-remote");
|
|
|
13
13
|
const embeddings_1 = require("./embeddings");
|
|
14
14
|
const save_1 = require("./save");
|
|
15
15
|
const recall_1 = require("./recall");
|
|
16
|
+
const guide_check_1 = require("./guide-check");
|
|
16
17
|
const session_context_1 = require("./session-context");
|
|
17
18
|
// Must match the AgentFacts/AgentSkills/AgentWikiPages Tags custom field's Picklist
|
|
18
19
|
// allowedValues (src/object-model/custom-fields/{AgentFacts,AgentSkills,AgentWikiPages}/*-Tags.custom-field.json)
|
|
@@ -106,7 +107,9 @@ server.tool('memory_getSkillGuide', 'Get the current SE AI Memory Hub usage guid
|
|
|
106
107
|
// itself and updates on every `yarn build`, not via a separate manual `cp` step.
|
|
107
108
|
const guidePath = (0, path_1.join)(__dirname, '..', 'skill-guide.md');
|
|
108
109
|
const guide = (0, fs_1.readFileSync)(guidePath, 'utf-8');
|
|
109
|
-
|
|
110
|
+
// The SDK has no public tool list; if this internal moves, the check just goes silent.
|
|
111
|
+
const registered = Object.keys(server._registeredTools ?? {});
|
|
112
|
+
return { content: [{ type: 'text', text: (0, guide_check_1.staleBuildNotice)(guide, registered) + guide }] };
|
|
110
113
|
});
|
|
111
114
|
server.tool('memory_recall', "Recall this developer's (or their team's) Facts, Skills, Scenarios, or Wiki pages. See memory_getSkillGuide for when to use each type.", {
|
|
112
115
|
type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
|
package/dist/recall.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.performRecall = void 0;
|
|
4
|
+
// In-band, not just a JSON field: an agent skimming the text must still see the cut and the uid.
|
|
5
|
+
function markCuts(type, listKey, textKey, result) {
|
|
6
|
+
const items = result?.[listKey];
|
|
7
|
+
if (!Array.isArray(items)) {
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
const marked = items.map((item) => {
|
|
11
|
+
if (!item.truncated) {
|
|
12
|
+
return item;
|
|
13
|
+
}
|
|
14
|
+
const { truncated: _truncated, fullLength, ...rest } = item;
|
|
15
|
+
const text = typeof rest[textKey] === 'string' ? rest[textKey] : '';
|
|
16
|
+
const of = typeof fullLength === 'number' ? ` of ${fullLength.toLocaleString('en-US')}` : '';
|
|
17
|
+
return {
|
|
18
|
+
...rest,
|
|
19
|
+
[textKey]: `${text}\n[cut at ${text.length}${of} chars — memory_get type=${type} uid=${rest.uid}]`,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
return { ...result, [listKey]: marked };
|
|
23
|
+
}
|
|
4
24
|
// Extracted from four near-identical memory_recall/listSkills/recallScenarios/
|
|
5
25
|
// recallWiki tool handlers — see save.ts's comment for why (index.ts's module-scope
|
|
6
26
|
// side effects make it untestable directly).
|
|
@@ -10,26 +30,26 @@ async function performRecall(deps, input) {
|
|
|
10
30
|
const caps = { maxCharsPerItem: input.maxCharsPerItem, maxTotalChars: input.maxTotalChars };
|
|
11
31
|
switch (input.type) {
|
|
12
32
|
case 'Fact':
|
|
13
|
-
return client.recall({
|
|
33
|
+
return markCuts('Fact', 'facts', 'content', await client.recall({
|
|
14
34
|
scope: input.scope,
|
|
15
35
|
query: input.query,
|
|
16
36
|
tags: input.tags,
|
|
17
37
|
externalRef: input.externalRef,
|
|
18
38
|
queryEmbedding,
|
|
19
39
|
...caps,
|
|
20
|
-
});
|
|
40
|
+
}));
|
|
21
41
|
case 'Skill':
|
|
22
|
-
return client.listSkills({ scope: input.scope, query: input.query, queryEmbedding, ...caps });
|
|
42
|
+
return markCuts('Skill', 'skills', 'content', await client.listSkills({ scope: input.scope, query: input.query, queryEmbedding, ...caps }));
|
|
23
43
|
case 'Scenario':
|
|
24
|
-
return client.recallScenarios({
|
|
44
|
+
return markCuts('Scenario', 'scenarios', 'summary', await client.recallScenarios({
|
|
25
45
|
scope: input.scope,
|
|
26
46
|
query: input.query,
|
|
27
47
|
externalRef: input.externalRef,
|
|
28
48
|
queryEmbedding,
|
|
29
49
|
...caps,
|
|
30
|
-
});
|
|
50
|
+
}));
|
|
31
51
|
case 'Wiki':
|
|
32
|
-
return client.recallWiki({ scope: input.scope, query: input.query, queryEmbedding, ...caps });
|
|
52
|
+
return markCuts('Wiki', 'pages', 'content', await client.recallWiki({ scope: input.scope, query: input.query, queryEmbedding, ...caps }));
|
|
33
53
|
}
|
|
34
54
|
}
|
|
35
55
|
exports.performRecall = performRecall;
|
package/package.json
CHANGED
package/skill-guide.md
CHANGED
|
@@ -27,10 +27,16 @@ filters to facts/scenarios linked to that ticket, and returns nothing (not
|
|
|
27
27
|
everything) if the ref was never used before.
|
|
28
28
|
|
|
29
29
|
Recall truncates every item it lists — 500 characters each, 6000 across the
|
|
30
|
-
result — so a Skill long enough to be worth writing down is
|
|
31
|
-
readable from a recall.
|
|
32
|
-
`
|
|
33
|
-
|
|
30
|
+
result — so a Skill long enough to be worth writing down is rarely fully
|
|
31
|
+
readable from a recall. A cut item ends with a marker such as
|
|
32
|
+
`[cut at 500 of 3,412 chars — memory_get type=Skill uid=<uid>]`; call
|
|
33
|
+
`memory_get` with that `type` and `uid` for the whole thing. No marker means
|
|
34
|
+
the item is complete. A query that is exactly a Skill's or Wiki page's title
|
|
35
|
+
returns that item whole (up to the 6000 total), so use the exact title when you
|
|
36
|
+
know it. Raise `maxCharsPerItem` / `maxTotalChars` instead only when you need
|
|
37
|
+
several long items at once. If `memory_get` or those parameters are missing
|
|
38
|
+
from your tools, your memory-hub-mcp build is stale: tell the user to rerun
|
|
39
|
+
`./scripts/setup-dev.sh` (or `cd memory-hub-mcp && yarn build`) and restart.
|
|
34
40
|
|
|
35
41
|
## Save at the end of a task
|
|
36
42
|
|
|
@@ -51,7 +57,9 @@ Call `memory_save` with a `type` of `'Fact'`, `'Skill'`, `'Scenario'`, or
|
|
|
51
57
|
different repo explicitly" below).
|
|
52
58
|
- **`type: 'Skill'`** — a reusable procedure or fix you'd want to reach
|
|
53
59
|
for again. Pass `title` and `content` (the actual steps/code), and
|
|
54
|
-
optionally `tags`. The repo is attached automatically, as above.
|
|
60
|
+
optionally `tags`. The repo is attached automatically, as above. Recall
|
|
61
|
+
shows only the first 500 characters, so put the answer — the exact
|
|
62
|
+
endpoint, command, or rule — in the first ~400 and the background after it.
|
|
55
63
|
|
|
56
64
|
`tags` (on Fact/Skill/Wiki saves, and on `memory_recall`) is a fixed
|
|
57
65
|
picklist, not a free-form string — pick from `ConnectedFunction`,
|