@skedulo/memory-hub-mcp 0.2.32 → 0.2.34
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 +140 -3
- package/assets/session-stop.sh +206 -17
- package/assets/skills/ask/SKILL.md +32 -6
- package/assets/skills/ask/references/qa.md +1 -0
- package/assets/skills/delegate-ticket/SKILL.md +5 -0
- package/assets/skills/fold-findings/SKILL.md +36 -5
- package/assets/skills/memory-hub/SKILL.md +2 -2
- package/assets/skills/plan-ticket/SKILL.md +36 -13
- package/assets/skills/project-knowledge/SKILL.md +6 -5
- package/assets/skills/project-knowledge/references/create-refresh.md +52 -5
- package/assets/skills/project-knowledge/references/page-format.md +6 -0
- package/assets/skills/project-knowledge/references/touch.md +4 -1
- package/assets/skills/sweep-knowledge/SKILL.md +253 -23
- package/assets/skills/test-scripts/SKILL.md +309 -0
- package/assets/skills/{plan-ticket/references/test-scripts.md → test-scripts/references/format.md} +63 -28
- package/assets/uninstall-memory-hub.sh +1 -1
- package/assets/user-prompt-submit.sh +53 -8
- package/dist/bulk.js +25 -8
- package/dist/change-tools.js +71 -0
- package/dist/check-tools.js +348 -0
- package/dist/cli.js +37 -1
- package/dist/client.js +27 -0
- package/dist/coverage.js +469 -0
- package/dist/git-remote.js +2 -0
- package/dist/import-apply.js +3 -2
- package/dist/index.js +42 -4
- package/dist/item-targets.js +304 -0
- package/dist/near-copy.js +85 -21
- package/dist/pack-import.js +1 -0
- package/dist/routine.js +15 -3
- package/dist/save.js +53 -3
- package/dist/session-context.js +12 -3
- package/dist/similar-notice.js +27 -9
- package/dist/sweep.js +71 -5
- package/dist/watch.js +570 -0
- package/package.json +1 -1
- package/skill-guide.md +157 -31
package/dist/similar-notice.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.similarNotice = exports.batchClosingLine = exports.closingLine = exports.ownerLabel = exports.canEdit = void 0;
|
|
4
|
+
const near_copy_1 = require("./near-copy");
|
|
4
5
|
const PREVIEW = 160;
|
|
5
6
|
function canEdit(match) {
|
|
6
7
|
return match.editable ?? match.mine !== false;
|
|
@@ -28,9 +29,22 @@ function citeAdvice(matches) {
|
|
|
28
29
|
const uids = matches.map((match) => match.uid).join(', ');
|
|
29
30
|
return `you cannot edit ${uids}, so cite ${matches.length === 1 ? 'it' : 'them'} in the new memory instead of repeating ${matches.length === 1 ? 'it' : 'them'}`;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// Merging into your own item shared wider than this save would widen who reads the new text.
|
|
33
|
+
function sharedWider(match, saveVisibility) {
|
|
34
|
+
return Boolean(match.mine && match.visibility && saveVisibility && (0, near_copy_1.widerThan)(match.visibility, saveVisibility));
|
|
35
|
+
}
|
|
36
|
+
function sort(matches, saveVisibility) {
|
|
37
|
+
return {
|
|
38
|
+
editable: matches.filter((match) => canEdit(match) && !sharedWider(match, saveVisibility)),
|
|
39
|
+
wider: matches.filter((match) => canEdit(match) && sharedWider(match, saveVisibility)),
|
|
40
|
+
locked: matches.filter((match) => !canEdit(match)),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function widerAdvice(match) {
|
|
44
|
+
return `${match.uid} is yours but shared wider (${match.visibility}) than this save, so cite it instead of merging into it; keep the new one only if it adds something it doesn't say.`;
|
|
45
|
+
}
|
|
46
|
+
function closingLine(type, newUid, matches, saveVisibility) {
|
|
47
|
+
const { editable, wider, locked } = sort(matches, saveVisibility);
|
|
34
48
|
const parts = [];
|
|
35
49
|
if (editable.length > 0) {
|
|
36
50
|
const target = editable.length === 1 ? editable[0].uid : '<that uid>';
|
|
@@ -38,22 +52,26 @@ function closingLine(type, newUid, matches) {
|
|
|
38
52
|
const supersedes = type === 'Scenario' ? '' : ', or pass supersedes next time';
|
|
39
53
|
parts.push(`To keep a single copy, update the existing one${which} with memory_update type=${type} uid=${target} ${UPDATE_GUARD} and the merged text, then memory_delete type=${type} uid=${newUid}${supersedes}.`);
|
|
40
54
|
}
|
|
55
|
+
parts.push(...wider.map(widerAdvice));
|
|
41
56
|
if (locked.length > 0) {
|
|
42
|
-
parts.push(`${
|
|
57
|
+
parts.push(`${parts.length > 0 ? 'For the others' : 'Otherwise'}, ${citeAdvice(locked)}; keep the new one only if it adds something they don't say.`);
|
|
43
58
|
}
|
|
44
59
|
return parts.join(' ');
|
|
45
60
|
}
|
|
46
61
|
exports.closingLine = closingLine;
|
|
47
|
-
function batchClosingLine(
|
|
48
|
-
const
|
|
49
|
-
const
|
|
62
|
+
function batchClosingLine(items) {
|
|
63
|
+
const sorted = items.map((item) => sort(item.matches, item.visibility));
|
|
64
|
+
const editable = sorted.flatMap((item) => item.editable);
|
|
65
|
+
const wider = sorted.flatMap((item) => item.wider);
|
|
66
|
+
const locked = sorted.flatMap((item) => item.locked);
|
|
50
67
|
const parts = [];
|
|
51
68
|
if (editable.length > 0) {
|
|
52
69
|
parts.push(`Where one you can edit already covers it (${editable.map((match) => match.uid).join(', ')}), memory_update that uid with the merged text and ${UPDATE_GUARD}, then memory_delete the new copy.`);
|
|
53
70
|
}
|
|
71
|
+
parts.push(...wider.map(widerAdvice));
|
|
54
72
|
if (locked.length > 0) {
|
|
55
73
|
const advice = citeAdvice(locked);
|
|
56
|
-
parts.push(
|
|
74
|
+
parts.push(parts.length > 0 ? `For the others, ${advice}.` : `${advice.charAt(0).toUpperCase()}${advice.slice(1)}.`);
|
|
57
75
|
}
|
|
58
76
|
return parts.join(' ');
|
|
59
77
|
}
|
|
@@ -68,7 +86,7 @@ function similarNotice(type, result) {
|
|
|
68
86
|
`Saved as ${result.uid}, but it looks like ${matches.length === 1 ? 'a memory' : 'memories'} already saved:`,
|
|
69
87
|
...matches.map(describe),
|
|
70
88
|
];
|
|
71
|
-
lines.push(closingLine(type, result.uid, matches));
|
|
89
|
+
lines.push(closingLine(type, result.uid, matches, result.visibility));
|
|
72
90
|
return lines.join('\n');
|
|
73
91
|
}
|
|
74
92
|
exports.similarNotice = similarNotice;
|
package/dist/sweep.js
CHANGED
|
@@ -5,6 +5,7 @@ const child_process_1 = require("child_process");
|
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const check_sources_1 = require("./check-sources");
|
|
7
7
|
const client_1 = require("./client");
|
|
8
|
+
const item_targets_1 = require("./item-targets");
|
|
8
9
|
const git_remote_1 = require("./git-remote");
|
|
9
10
|
const staleness_1 = require("./staleness");
|
|
10
11
|
exports.SWEEP_USAGE = 'memory-hub-mcp sweep --repo <owner/name> --checkout <path> [--stamp]';
|
|
@@ -13,24 +14,27 @@ exports.REPO_NAME = /^[A-Za-z0-9_-][A-Za-z0-9_.-]*\/[A-Za-z0-9_-][A-Za-z0-9_.-]*
|
|
|
13
14
|
const WEEK_MS = 7 * 24 * 60 * 60 * 1000;
|
|
14
15
|
const GIT_TIMEOUT_MS = 60_000;
|
|
15
16
|
const GIT_MAX_BUFFER = 64 * 1024 * 1024;
|
|
17
|
+
const CLAIM_BATCH = 50;
|
|
18
|
+
const schemeFree = (key) => key.slice(key.indexOf(':') + 1);
|
|
19
|
+
const PROJECT_PAGE_MARKER = ' › ';
|
|
16
20
|
async function fetchItem(client, item) {
|
|
17
21
|
const uid = item.uid;
|
|
18
22
|
switch (item.type) {
|
|
19
23
|
case 'Fact': {
|
|
20
24
|
const got = await client.getFact({ uid });
|
|
21
|
-
return { text: got.content, source: got.source, lastModifiedDate: got.lastModifiedDate };
|
|
25
|
+
return { text: got.content, source: got.source, lastModifiedDate: got.lastModifiedDate, upstream: got.upstream };
|
|
22
26
|
}
|
|
23
27
|
case 'Skill': {
|
|
24
28
|
const got = await client.getSkill({ uid });
|
|
25
|
-
return { text: got.content, source: got.source, lastModifiedDate: got.lastModifiedDate };
|
|
29
|
+
return { text: got.content, source: got.source, lastModifiedDate: got.lastModifiedDate, upstream: got.upstream };
|
|
26
30
|
}
|
|
27
31
|
case 'Scenario': {
|
|
28
32
|
const got = await client.getScenario({ uid });
|
|
29
|
-
return { text: got.summary, source: got.source, lastModifiedDate: got.lastModifiedDate };
|
|
33
|
+
return { text: got.summary, source: got.source, lastModifiedDate: got.lastModifiedDate, upstream: got.upstream };
|
|
30
34
|
}
|
|
31
35
|
case 'Wiki': {
|
|
32
36
|
const got = await client.getWikiPage({ uid });
|
|
33
|
-
return { text: got.content, source: got.source, lastModifiedDate: got.lastModifiedDate };
|
|
37
|
+
return { text: got.content, source: got.source, lastModifiedDate: got.lastModifiedDate, upstream: got.upstream };
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
}
|
|
@@ -74,6 +78,7 @@ async function performSweep(deps, input) {
|
|
|
74
78
|
}
|
|
75
79
|
const result = { repo, target, unchanged: [], changed: [], nothingCited: [], unknownCommit: [], otherRepo: [], errors: [] };
|
|
76
80
|
const toStamp = [];
|
|
81
|
+
const codeOnly = [];
|
|
77
82
|
const now = deps.now().getTime();
|
|
78
83
|
for (const item of await (0, check_sources_1.listBySourceRepo)(client, repo)) {
|
|
79
84
|
try {
|
|
@@ -84,8 +89,12 @@ async function performSweep(deps, input) {
|
|
|
84
89
|
switch (staleness.status) {
|
|
85
90
|
case 'unchanged':
|
|
86
91
|
result.unchanged.push(item.uid);
|
|
87
|
-
if (source)
|
|
92
|
+
if (source) {
|
|
88
93
|
toStamp.push({ item, source, lastModifiedDate });
|
|
94
|
+
const key = codeOnlyKey(repo, item, full, source);
|
|
95
|
+
if (key)
|
|
96
|
+
codeOnly.push({ item, source, key });
|
|
97
|
+
}
|
|
89
98
|
break;
|
|
90
99
|
case 'nothing-cited':
|
|
91
100
|
result.nothingCited.push(item.uid);
|
|
@@ -145,9 +154,66 @@ async function performSweep(deps, input) {
|
|
|
145
154
|
}
|
|
146
155
|
}
|
|
147
156
|
}
|
|
157
|
+
result.checkStamped = await stampCheckRows(deps, target, codeOnly, result);
|
|
148
158
|
return result;
|
|
149
159
|
}
|
|
150
160
|
exports.performSweep = performSweep;
|
|
161
|
+
function codeOnlyKey(repo, item, full, source) {
|
|
162
|
+
if (item.type === 'Wiki' && item.title.includes(PROJECT_PAGE_MARKER))
|
|
163
|
+
return undefined;
|
|
164
|
+
const targets = (0, item_targets_1.itemTargets)({ type: item.type, title: item.title, text: full.text, source, upstream: full.upstream, createdDate: '', lastModifiedDate: full.lastModifiedDate ?? '' }, []);
|
|
165
|
+
const ours = repo.toLowerCase();
|
|
166
|
+
return targets.length > 0 && targets.every((target) => target.kind === 'repo' && target.identity === ours) ? targets[0].key : undefined;
|
|
167
|
+
}
|
|
168
|
+
async function stampCheckRows(deps, target, codeOnly, result) {
|
|
169
|
+
const { client, exec } = deps;
|
|
170
|
+
const ready = [];
|
|
171
|
+
for (const { item, source, key } of codeOnly) {
|
|
172
|
+
const old = source.commit.trim();
|
|
173
|
+
if (!HEX_SHA.test(old))
|
|
174
|
+
continue;
|
|
175
|
+
const reached = old.toLowerCase() === target.toLowerCase() || (await exec(['merge-base', '--is-ancestor', '--end-of-options', old, target]).then(() => true, () => false));
|
|
176
|
+
if (reached)
|
|
177
|
+
ready.push({ item, key });
|
|
178
|
+
}
|
|
179
|
+
const stamped = [];
|
|
180
|
+
for (let start = 0; start < ready.length; start += CLAIM_BATCH) {
|
|
181
|
+
const batch = ready.slice(start, start + CLAIM_BATCH);
|
|
182
|
+
let claimed;
|
|
183
|
+
try {
|
|
184
|
+
const { results } = await client.claimChecks({ items: batch.map(({ item }) => ({ type: item.type, uid: item.uid })), force: true });
|
|
185
|
+
claimed = new Map(results.filter((claim) => claim.outcome === 'claimed').map((claim) => [claim.uid, claim.required ?? []]));
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
batch.forEach(({ item }) => result.errors.push({ uid: item.uid, error: `check not stamped: ${message(error)}` }));
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
for (const { item, key } of batch.filter(({ item }) => claimed.has(item.uid))) {
|
|
192
|
+
const ours = schemeFree(key);
|
|
193
|
+
const other = claimed.get(item.uid).filter((identity) => identity.toLowerCase() !== ours);
|
|
194
|
+
if (other.length > 0) {
|
|
195
|
+
await client.releaseCheck({ type: item.type, uid: item.uid, note: `needs-judgement: ${other.join(', ')}` }).catch(() => undefined);
|
|
196
|
+
result.checkNotStamped = [...(result.checkNotStamped ?? []), item.uid];
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
await client.stampCheck({ type: item.type, uid: item.uid, checkedAgainst: `${key}@${target}` });
|
|
201
|
+
stamped.push(item.uid);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
const text = message(error);
|
|
205
|
+
if (!text.startsWith('Not held')) {
|
|
206
|
+
await client.releaseCheck({ type: item.type, uid: item.uid, note: `needs-judgement: ${text}` }).catch(() => undefined);
|
|
207
|
+
}
|
|
208
|
+
if (text.startsWith('Missing sources'))
|
|
209
|
+
result.checkNotStamped = [...(result.checkNotStamped ?? []), item.uid];
|
|
210
|
+
else
|
|
211
|
+
result.errors.push({ uid: item.uid, error: `check not stamped: ${text}` });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return stamped;
|
|
216
|
+
}
|
|
151
217
|
function gitIn(checkout) {
|
|
152
218
|
return (args) => new Promise((done, fail) => {
|
|
153
219
|
(0, child_process_1.execFile)('git', ['-C', checkout, ...args], { encoding: 'utf8', timeout: GIT_TIMEOUT_MS, maxBuffer: GIT_MAX_BUFFER }, (err, stdout) => err ? fail(err) : done(stdout));
|