@skedulo/memory-hub-mcp 0.2.10 → 0.2.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/README.md CHANGED
@@ -162,9 +162,11 @@ detect; `memory_listTeams` shows the team names to link it to.
162
162
  ## Tags
163
163
 
164
164
  `memory_save`/`memory_recall`'s `tags` parameter is a fixed picklist
165
- matching the `AgentFacts`/`AgentSkills` custom objects' `Tags` field exactly: `ConnectedFunction`,
166
- `HorizonComponent`, `TriggeredAction`, `ObjectModel`, `MobileExtension`, `Deployment`, `Auth`,
167
- `Testing`, `Other`. The tool's Zod schema enforces this — any other value fails validation
165
+ matching the `AgentFacts`/`AgentSkills`/`AgentWikiPages` custom objects' `Tags` field exactly:
166
+ `ConnectedFunction`, `HorizonComponent`, `TriggeredAction`, `ObjectModel`, `MobileExtension`,
167
+ `Deployment`, `Auth`, `Testing`, `BreezeUI`, `PSS`, `PSF`, `Optimization`, `Webhooks`, `Salesforce`,
168
+ `Other`, `ArchitectureMap`, `SOW`, `TDD`, `AI`, `API`, `Mobile`, `Infrastructure`, `Security`,
169
+ `Messaging` (24 in all; `TAG_VALUES` in `src/index.ts` is the source of truth). The tool's Zod schema enforces this — any other value fails validation
168
170
  before the request reaches the connected function (which otherwise 400s with no indication of
169
171
  what went wrong). If the underlying Picklist's `allowedValues` ever changes, update `TAG_VALUES`
170
172
  in `src/index.ts` to match.
package/assets/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: se-ai-memory-hub
3
- description: Use when working in a repo where the memory-hub MCP tools (memory_recall, memory_save, memory_upsertPersona, memory_setVisibility, memory_bulkPromoteRepoScoped, memory_grantAccess, memory_checkRepoStatus, memory_linkRepoTeam, memory_moveResourceRepo, memory_listRepos, memory_getSkillGuide) are available, to recall prior context mid-session, save durable facts/skills/scenarios, update your persona, and share items with your team on explicit request
3
+ description: Use when working in a repo where the memory-hub MCP tools (memory_recall, memory_list, memory_save, memory_saveBatch, memory_upsertPersona, memory_setVisibility, memory_bulkPromoteRepoScoped, memory_grantAccess, memory_checkRepoStatus, memory_linkRepoTeam, memory_moveResourceRepo, memory_listRepos, memory_registerRepo, memory_checkSources, memory_listTeams, memory_joinTeam, memory_addTeamMember, memory_listTeamMembers, memory_whoCanRead, memory_update, memory_getSkillGuide) are available, to recall prior context mid-session, save durable facts/skills/scenarios, update your persona, and share items with your team on explicit request
4
4
  ---
5
5
 
6
6
  # SE AI Memory Hub
@@ -345,7 +345,7 @@ FACTS_TEAM_N=0
345
345
  SKILLS_SELF_N=$(leg_total "$TMP_DIR/skills_self.json" "$(count_items "$SKILLS_SELF")")
346
346
  SKILLS_TEAM_N=$(leg_total "$TMP_DIR/skills_team.json" "$(count_items "$SKILLS_TEAM")")
347
347
 
348
- # The team-scope query matches DevAgentId == self OR Visibility == "Team", so
348
+ # The team-scope query matches DevAgentId == self OR Visibility == "Team" or "Org", so
349
349
  # self-owned items also come back in the team results. Drop anything already
350
350
  # shown under "Your ..." so it isn't rendered twice.
351
351
  FACTS_TEAM=$(comm -23 <(echo "$FACTS_TEAM" | sort) <(echo "$FACTS_SELF" | sort) 2>/dev/null || true)
package/dist/bulk.js ADDED
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.performLinkRepoTeam = exports.performMoveResourceRepo = exports.performSaveBatch = exports.performSaveItem = exports.MAX_LINK_BATCH = exports.MAX_MOVE_BATCH = exports.MAX_SAVE_BATCH = void 0;
4
+ const capture_1 = require("./capture");
5
+ const save_1 = require("./save");
6
+ exports.MAX_SAVE_BATCH = 25;
7
+ exports.MAX_MOVE_BATCH = 100;
8
+ exports.MAX_LINK_BATCH = 50;
9
+ function message(err) {
10
+ return err instanceof Error ? err.message : String(err);
11
+ }
12
+ async function performSaveItem(deps, input) {
13
+ const refused = await (0, capture_1.captureUpsert)(deps, input);
14
+ if (refused) {
15
+ return { refused: refused.message };
16
+ }
17
+ const result = await (0, save_1.performSave)(deps, input);
18
+ (0, capture_1.logCapture)({ action: 'saved', type: input.type, uid: result.uid, externalRef: input.externalRef });
19
+ return { result };
20
+ }
21
+ exports.performSaveItem = performSaveItem;
22
+ function describeMatch(match) {
23
+ const owner = match.mine === undefined ? '' : match.mine ? ', yours' : ", a teammate's";
24
+ return `${match.uid} (${match.similarity.toFixed(2)}${owner})`;
25
+ }
26
+ async function performSaveBatch(deps, items) {
27
+ if (items.length === 0) {
28
+ throw new Error('items must not be empty.');
29
+ }
30
+ if (items.length > exports.MAX_SAVE_BATCH) {
31
+ throw new Error(`items must contain at most ${exports.MAX_SAVE_BATCH} items, got: ${items.length}`);
32
+ }
33
+ const results = [];
34
+ const similarNotices = [];
35
+ for (const [index, input] of items.entries()) {
36
+ try {
37
+ const outcome = await performSaveItem(deps, input);
38
+ if ('refused' in outcome) {
39
+ results.push({ index, error: outcome.refused });
40
+ continue;
41
+ }
42
+ const { possibleDuplicate, similar, ...saved } = outcome.result;
43
+ const matches = similar?.length ? similar : possibleDuplicate ? [possibleDuplicate] : [];
44
+ const similarTo = matches.map(describeMatch);
45
+ results.push({ index, ...saved, ...(similarTo.length ? { similarTo } : {}) });
46
+ if (similarTo.length) {
47
+ similarNotices.push(`- item ${index} (${saved.uid}) resembles ${similarTo.join(', ')}`);
48
+ }
49
+ }
50
+ catch (err) {
51
+ results.push({ index, error: message(err) });
52
+ }
53
+ }
54
+ return { results, similarNotices };
55
+ }
56
+ exports.performSaveBatch = performSaveBatch;
57
+ function performMoveResourceRepo(deps, input) {
58
+ const hasOne = input.resourceId !== undefined;
59
+ const hasMany = input.resourceIds !== undefined;
60
+ if (hasOne === hasMany) {
61
+ throw new Error('Pass exactly one of resourceId or resourceIds.');
62
+ }
63
+ if (hasMany) {
64
+ const ids = input.resourceIds;
65
+ if (ids.length === 0) {
66
+ throw new Error('resourceIds must not be empty.');
67
+ }
68
+ if (ids.length > exports.MAX_MOVE_BATCH) {
69
+ throw new Error(`resourceIds must contain at most ${exports.MAX_MOVE_BATCH} ids, got: ${ids.length}`);
70
+ }
71
+ }
72
+ return deps.client.moveResourceRepo(input);
73
+ }
74
+ exports.performMoveResourceRepo = performMoveResourceRepo;
75
+ async function performLinkRepoTeam(deps, input) {
76
+ if (input.repoName !== undefined && input.repoNames !== undefined) {
77
+ throw new Error('Pass at most one of repoName or repoNames.');
78
+ }
79
+ if (input.repoNames === undefined) {
80
+ const repoName = input.repoName ?? deps.detectRepoName();
81
+ if (!repoName) {
82
+ return { error: 'No repo detected in this session. Pass repoName to say which repo to link.' };
83
+ }
84
+ return deps.client.linkRepoTeam({ repoName, teamName: input.teamName });
85
+ }
86
+ if (input.repoNames.length === 0) {
87
+ throw new Error('repoNames must not be empty.');
88
+ }
89
+ if (input.repoNames.length > exports.MAX_LINK_BATCH) {
90
+ throw new Error(`repoNames must contain at most ${exports.MAX_LINK_BATCH} names, got: ${input.repoNames.length}`);
91
+ }
92
+ const results = [];
93
+ for (const repoName of input.repoNames) {
94
+ try {
95
+ const request = { repoName, teamName: input.teamName };
96
+ const resolved = await deps.client.linkRepoTeam(request);
97
+ results.push({ repoName, uid: resolved.uid, devTeamId: resolved.devTeamId });
98
+ }
99
+ catch (err) {
100
+ results.push({ repoName, error: message(err) });
101
+ }
102
+ }
103
+ return { results };
104
+ }
105
+ exports.performLinkRepoTeam = performLinkRepoTeam;
package/dist/capture.js CHANGED
@@ -26,6 +26,12 @@ async function findOwnFactUid(deps, content, externalRef) {
26
26
  return similar.sort((a, b) => (b.similarity ?? 0) - (a.similarity ?? 0))[0]?.uid;
27
27
  }
28
28
  async function captureUpsert(deps, input, env = process.env) {
29
+ if (isCaptureMode(env) && input.visibility !== undefined) {
30
+ return {
31
+ message: `Not saved: capture mode never sets visibility, so the requested ${input.visibility} visibility was not applied. ` +
32
+ 'Save again without visibility; a human can share the item afterwards.',
33
+ };
34
+ }
29
35
  if (!isCaptureMode(env) || input.type !== 'Fact' || !input.content) {
30
36
  return undefined;
31
37
  }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.performCheckSources = exports.execGit = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const TYPES = ['Fact', 'Skill', 'Scenario', 'Wiki'];
6
+ const PAGE_SIZE = 200;
7
+ const HEX_SHA = /^[0-9a-f]{7,64}$/i;
8
+ const execGit = (args) => new Promise((resolve, reject) => {
9
+ (0, child_process_1.execFile)('git', args, { cwd: process.cwd(), encoding: 'utf8' }, (err, stdout) => (err ? reject(err) : resolve(stdout)));
10
+ });
11
+ exports.execGit = execGit;
12
+ async function listBySourceRepo(client, sourceRepo) {
13
+ const items = [];
14
+ for (const type of TYPES) {
15
+ let offset = 0;
16
+ for (;;) {
17
+ const page = await client.listResources({ type, sourceRepo, offset, limit: PAGE_SIZE });
18
+ items.push(...page.items);
19
+ offset += page.items.length;
20
+ if (page.items.length === 0 || offset >= page.total) {
21
+ break;
22
+ }
23
+ }
24
+ }
25
+ return items;
26
+ }
27
+ async function compareToHead(exec, sha) {
28
+ if (!HEX_SHA.test(sha)) {
29
+ return {};
30
+ }
31
+ const behind = await exec(['rev-list', '--count', `${sha}..HEAD`]).then((out) => Number.parseInt(out.trim(), 10), () => undefined);
32
+ if (behind === undefined || Number.isNaN(behind)) {
33
+ return {};
34
+ }
35
+ if (behind > 0) {
36
+ return { behind };
37
+ }
38
+ const isAncestor = await exec(['merge-base', '--is-ancestor', sha, 'HEAD']).then(() => true, () => false);
39
+ return isAncestor ? { behind } : { behind, notAncestor: true };
40
+ }
41
+ async function performCheckSources(deps, input) {
42
+ const repo = (input.repo ?? deps.detectRepoName() ?? '').trim();
43
+ if (!repo) {
44
+ throw new Error('No repo detected in this session. Pass repo as owner/name.');
45
+ }
46
+ const cwdRepo = deps.detectRepoName()?.trim();
47
+ if (input.repo && cwdRepo && cwdRepo.toLowerCase() !== repo.toLowerCase()) {
48
+ throw new Error(`repo "${repo}" does not match this directory's repo "${cwdRepo}". Run this from a checkout of ${repo}, since commits are compared with the local git history.`);
49
+ }
50
+ const exec = deps.exec ?? exports.execGit;
51
+ const head = await exec(['rev-parse', 'HEAD']).then((out) => out.trim(), () => {
52
+ throw new Error('The current directory is not a git checkout, so commits cannot be compared. Run this from a checkout of the repo.');
53
+ });
54
+ const listed = await listBySourceRepo(deps.client, repo);
55
+ const behindBySha = new Map();
56
+ const items = [];
57
+ for (const item of listed) {
58
+ if (!item.source) {
59
+ continue;
60
+ }
61
+ const sha = item.source.commit;
62
+ if (!behindBySha.has(sha)) {
63
+ behindBySha.set(sha, await compareToHead(exec, sha));
64
+ }
65
+ const { behind, notAncestor } = behindBySha.get(sha) ?? {};
66
+ items.push({
67
+ uid: item.uid,
68
+ type: item.type,
69
+ title: item.title,
70
+ source: item.source,
71
+ ...(behind === undefined ? { unknownCommit: true } : { commitsBehind: behind }),
72
+ ...(notAncestor ? { notAncestor } : {}),
73
+ });
74
+ }
75
+ // An unknown sha has no count to rank by, so those sort last.
76
+ items.sort((a, b) => (b.commitsBehind ?? -1) - (a.commitsBehind ?? -1));
77
+ return { repo, head, checked: items.length, items };
78
+ }
79
+ exports.performCheckSources = performCheckSources;
package/dist/client.js CHANGED
@@ -95,12 +95,30 @@ class MemoryHubClient {
95
95
  listTeams() {
96
96
  return this.post('/memory/list-teams', {});
97
97
  }
98
+ joinTeam(input) {
99
+ return this.post('/memory/join-team', input);
100
+ }
101
+ addTeamMember(input) {
102
+ return this.post('/memory/add-team-member', input);
103
+ }
104
+ listTeamMembers(input) {
105
+ return this.post('/memory/list-team-members', input);
106
+ }
107
+ whoCanRead(input) {
108
+ return this.post('/memory/who-can-read', input);
109
+ }
98
110
  listRepos(input) {
99
111
  return this.post('/memory/list-repos', input);
100
112
  }
113
+ registerRepo(input) {
114
+ return this.post('/memory/register-repo', input);
115
+ }
101
116
  moveResourceRepo(input) {
102
117
  return this.post('/memory/move-resource-repo', input);
103
118
  }
119
+ listResources(input) {
120
+ return this.post('/memory/list-resources', input);
121
+ }
104
122
  resolveRepo(input) {
105
123
  return this.post('/memory/resolve-repo', input);
106
124
  }
package/dist/index.js CHANGED
@@ -7,11 +7,15 @@ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
7
7
  const zod_1 = require("zod");
8
8
  const client_1 = require("./client");
9
9
  const list_repos_1 = require("./list-repos");
10
+ const check_sources_1 = require("./check-sources");
11
+ const source_1 = require("./source");
10
12
  const repo_context_1 = require("./repo-context");
11
13
  const task_context_1 = require("./task-context");
12
14
  const git_remote_1 = require("./git-remote");
13
15
  const embeddings_1 = require("./embeddings");
14
- const save_1 = require("./save");
16
+ const bulk_1 = require("./bulk");
17
+ const set_visibility_1 = require("./set-visibility");
18
+ const teams_1 = require("./teams");
15
19
  const capture_1 = require("./capture");
16
20
  const recall_1 = require("./recall");
17
21
  const guide_check_1 = require("./guide-check");
@@ -43,6 +47,12 @@ const TAG_VALUES = [
43
47
  'ArchitectureMap',
44
48
  'SOW',
45
49
  'TDD',
50
+ 'AI',
51
+ 'API',
52
+ 'Mobile',
53
+ 'Infrastructure',
54
+ 'Security',
55
+ 'Messaging',
46
56
  ];
47
57
  // The team's one deployed memory-hub function. MEMORY_HUB_FUNCTION_URL only needs to
48
58
  // be set to override this (e.g. pointing at a local `sked function dev` instance).
@@ -120,7 +130,7 @@ server.tool('memory_recall', "Recall this developer's (or their team's) Facts, S
120
130
  const result = await (0, recall_1.performRecall)({ client, embed: embeddings_1.embed }, input);
121
131
  return { content: [...embeddingNoticeBlocks(), { type: 'text', text: JSON.stringify(result) }] };
122
132
  });
123
- server.tool('memory_get', "Fetch one Fact/Skill/Scenario/Wiki page in full by its uid. memory_recall truncates every item it lists (500 chars by default), so use this to read anything longer than a paragraph — take the uid from a memory_recall result.", {
133
+ server.tool('memory_get', "Fetch one Fact/Skill/Scenario/Wiki page in full by its uid (a Wiki page also returns its links and backlinks). memory_recall truncates every item it lists (500 chars by default), so use this to read anything longer than a paragraph — take the uid from a memory_recall result.", {
124
134
  type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
125
135
  uid: zod_1.z.string().min(1).describe('The uid from a memory_recall result.'),
126
136
  }, async (input) => {
@@ -133,7 +143,7 @@ server.tool('memory_get', "Fetch one Fact/Skill/Scenario/Wiki page in full by it
133
143
  : await client.getWikiPage({ uid: input.uid });
134
144
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
135
145
  });
136
- server.tool('memory_save', 'Save a Fact, Skill, Scenario, or Wiki page to the SE AI Memory Hub. Written Team visibility automatically if the attached repo is already linked to a team, otherwise Private. See memory_getSkillGuide for which type to use and which fields it needs. The current repo is detected automatically unless you pass an explicit repo (from memory_listRepos) to target a different one.', {
146
+ const saveShape = {
137
147
  type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
138
148
  content: zod_1.z.string().optional().describe('Required for Fact, Skill, Wiki.'),
139
149
  title: zod_1.z.string().optional().describe('Required for Skill, Wiki.'),
@@ -142,28 +152,65 @@ server.tool('memory_save', 'Save a Fact, Skill, Scenario, or Wiki page to the SE
142
152
  links: zod_1.z.array(zod_1.z.string()).optional().describe('Wiki only — UIDs of other wiki pages this one depends on.'),
143
153
  tags: zod_1.z.array(zod_1.z.enum(TAG_VALUES)).optional().describe('Fact, Skill, Wiki only.'),
144
154
  externalRef: zod_1.z.string().optional().describe("Fact, Scenario, Wiki only — the Linear/Jira ticket this relates to, e.g. 'SOL-1234' — pass it when the user mentions a ticket."),
145
- repo: zod_1.z.string().min(1).optional().describe('An explicit DevRepos uid from memory_listRepos, overriding the current-directory auto-detected repo.'),
146
- }, async (input) => {
147
- const refused = await (0, capture_1.captureUpsert)({ client, embed: embeddings_1.embed }, input);
148
- if (refused) {
149
- return { content: [{ type: 'text', text: refused.message }] };
155
+ repo: zod_1.z.string().min(1).optional().describe('A DevRepos uid from memory_listRepos, or an owner/name that is already registered, overriding the current-directory auto-detected repo.'),
156
+ visibility: zod_1.z.enum(['Private', 'Team', 'Org']).optional().describe('Only when the human approved sharing this item or batch in this conversation. Org is readable by everyone in the tenant. Omit it to get the default. Team is refused on a repo no team owns yet.'),
157
+ source: source_1.sourceSchema.optional().describe(source_1.SOURCE_DESCRIPTION),
158
+ };
159
+ const saveDeps = {
160
+ client,
161
+ embed: embeddings_1.embed,
162
+ currentRepoUid: () => repoContext.currentRepoUid(),
163
+ resolveTaskUid: (ref, repoUid) => taskContext.resolveTaskUid(ref, repoUid),
164
+ };
165
+ server.tool('memory_save', 'Save a Fact, Skill, Scenario, or Wiki page to the SE AI Memory Hub. Written Team visibility automatically if the attached repo is already linked to a team, otherwise Private, unless visibility is passed. The result reports the saved visibility, repoId, repoName and teamName. See memory_getSkillGuide for which type to use and which fields it needs. The current repo is detected automatically unless you pass an explicit repo (from memory_listRepos) to target a different one.', saveShape, async (input) => {
166
+ const outcome = await (0, bulk_1.performSaveItem)(saveDeps, input);
167
+ if ('refused' in outcome) {
168
+ return { content: [{ type: 'text', text: outcome.refused }] };
150
169
  }
151
- const result = await (0, save_1.performSave)({
152
- client,
153
- embed: embeddings_1.embed,
154
- currentRepoUid: () => repoContext.currentRepoUid(),
155
- resolveTaskUid: (ref, repoUid) => taskContext.resolveTaskUid(ref, repoUid),
156
- }, input);
157
- (0, capture_1.logCapture)({ action: 'saved', type: input.type, uid: result.uid, externalRef: input.externalRef });
158
170
  return {
159
171
  content: [
160
172
  ...(await joinNoticeBlocks()),
161
- ...similarNoticeBlocks(input.type, result),
173
+ ...similarNoticeBlocks(input.type, outcome.result),
162
174
  ...embeddingNoticeBlocks(),
163
- { type: 'text', text: JSON.stringify(result) },
175
+ { type: 'text', text: JSON.stringify(outcome.result) },
164
176
  ],
165
177
  };
166
178
  });
179
+ server.tool('memory_saveBatch', 'Save up to 25 Facts/Skills/Scenarios/Wiki pages in one call, each item shaped exactly like a memory_save call (same required fields, repo and visibility rules). Items are saved in order; each reports its own result or error, so one bad item does not stop the rest. Possible duplicates are listed compactly per item. Pass visibility only when the human approved sharing this batch in this conversation.', { items: zod_1.z.array(zod_1.z.object(saveShape)).min(1).max(25) }, async (input) => {
180
+ const { results, similarNotices } = await (0, bulk_1.performSaveBatch)(saveDeps, input.items);
181
+ const similarBlock = similarNotices.length
182
+ ? [
183
+ {
184
+ type: 'text',
185
+ text: `Saved, but these look like memories already saved:\n${similarNotices.join('\n')}\nWhere one of yours already covers it, memory_update that uid with the merged text and memory_delete the new copy.`,
186
+ },
187
+ ]
188
+ : [];
189
+ return {
190
+ content: [
191
+ ...(await joinNoticeBlocks()),
192
+ ...similarBlock,
193
+ ...embeddingNoticeBlocks(),
194
+ { type: 'text', text: JSON.stringify({ results }) },
195
+ ],
196
+ };
197
+ });
198
+ server.tool('memory_list', "List memory items of one type that you can see, newest first, with a title, visibility, repo and whether each is yours — an inventory for choosing which items to share, move or review. Feed the uids to memory_setVisibility or memory_moveResourceRepo as resourceIds. Returns total (all matches) and one page of items; page with offset. Not a search: use memory_recall to find content by meaning.", {
199
+ type: zod_1.z.enum(['Fact', 'Scenario', 'Skill', 'Wiki']),
200
+ repo: zod_1.z.string().min(1).nullable().optional().describe('A DevRepos uid from memory_listRepos. null lists only items with no repo; omit for any repo.'),
201
+ visibility: zod_1.z.enum(['Private', 'Team', 'Restricted', 'Org']).optional(),
202
+ titlePrefix: zod_1.z.string().min(1).optional().describe('Case-insensitive start of the title (Fact: content, Scenario: summary).'),
203
+ tags: zod_1.z.array(zod_1.z.enum(TAG_VALUES)).optional().describe('Items carrying any of these tags. Not supported for Scenario.'),
204
+ mine: zod_1.z.boolean().optional().describe('true: only items you saved.'),
205
+ createdAfter: zod_1.z.string().min(1).optional().describe('ISO date or datetime. Skills filter on last modified instead of created.'),
206
+ sourceRepo: zod_1.z.string().min(1).optional().describe('owner/name, exact: only items whose source.repo is this.'),
207
+ verifiedBefore: zod_1.z.string().min(1).refine(source_1.isIsoDate, 'verifiedBefore must be an ISO date or datetime').optional().describe('Only items last verified before this ISO date or datetime.'),
208
+ offset: zod_1.z.number().int().min(0).optional(),
209
+ limit: zod_1.z.number().int().min(1).max(200).optional().describe('Default 50, max 200.'),
210
+ }, async (input) => {
211
+ const result = await client.listResources(input);
212
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
213
+ });
167
214
  server.tool('memory_upsertPersona', "Update this developer's durable persona profile (preferences/decisions/patterns) — each provided field replaces its prior value, not appends.", {
168
215
  preferences: zod_1.z.string().optional(),
169
216
  decisions: zod_1.z.string().optional(),
@@ -172,12 +219,13 @@ server.tool('memory_upsertPersona', "Update this developer's durable persona pro
172
219
  const result = await client.upsertPersona(input);
173
220
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
174
221
  });
175
- server.tool('memory_setVisibility', "Change who can see a Fact/Scenario/Skill/Wiki page — promote to Team or Restricted, or demote back to Private. Only call this when a human in the conversation explicitly asks to share, promote, or un-share something — never autonomously.", {
222
+ server.tool('memory_setVisibility', "Change who can see a Fact/Scenario/Skill/Wiki page — promote to Team, Org (everyone in the tenant) or Restricted, or demote back to Private. Pass resourceId for one item, or resourceIds (1-100 uids of one resourceType) for a batch; each item reports its own result. Only call this when a human in the conversation explicitly asks to share, promote, or un-share something — never autonomously.", {
176
223
  resourceType: zod_1.z.enum(['Fact', 'Scenario', 'Skill', 'Wiki']),
177
- resourceId: zod_1.z.string(),
178
- newVisibility: zod_1.z.enum(['Private', 'Team', 'Restricted']),
224
+ resourceId: zod_1.z.string().min(1).optional().describe('One item. Give exactly one of resourceId or resourceIds.'),
225
+ resourceIds: zod_1.z.array(zod_1.z.string().min(1)).min(1).max(100).optional().describe('A batch of up to 100 items of the same resourceType.'),
226
+ newVisibility: zod_1.z.enum(['Private', 'Team', 'Org', 'Restricted']),
179
227
  }, async (input) => {
180
- const result = await client.promoteVisibility(input);
228
+ const result = await (0, set_visibility_1.performSetVisibility)({ client }, input);
181
229
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
182
230
  });
183
231
  server.tool('memory_bulkPromoteRepoScoped', "Bulk catch-up: promotes all of this developer's existing Private Facts/Scenarios/Skills/Wiki pages whose repo is already linked to a team, to Team visibility — for content saved before repo-scoped saves started defaulting to Team automatically. Only touches your own items. Only call this when a human in the conversation explicitly asks for it — never autonomously. Re-running it will also re-promote any item you've since deliberately demoted with memory_setVisibility, so don't call it more than once without the human asking again.", {}, async () => {
@@ -192,23 +240,50 @@ server.tool('memory_grantAccess', 'Grant a specific teammate access to one of yo
192
240
  const result = await client.grantAccess(input);
193
241
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
194
242
  });
195
- server.tool('memory_moveResourceRepo', "Reassign an already-saved Fact/Scenario/Skill/Wiki page to a different repo, or clear its repo association with repo: null. Look up the target repo's uid with memory_listRepos first.", {
243
+ server.tool('memory_moveResourceRepo', "Reassign an already-saved Fact/Scenario/Skill/Wiki page to a different repo, or clear its repo association with repo: null. Pass resourceId for one item, or resourceIds (1-100 uids of one resourceType) for a batch; each item reports its own result. Look up the target repo's uid with memory_listRepos first.", {
196
244
  resourceType: zod_1.z.enum(['Fact', 'Scenario', 'Skill', 'Wiki']),
197
- resourceId: zod_1.z.string(),
245
+ resourceId: zod_1.z.string().min(1).optional().describe('One item. Give exactly one of resourceId or resourceIds.'),
246
+ resourceIds: zod_1.z.array(zod_1.z.string().min(1)).min(1).max(100).optional().describe('A batch of up to 100 items of the same resourceType.'),
198
247
  repo: zod_1.z.string().nullable(),
199
248
  }, async (input) => {
200
- const result = await client.moveResourceRepo(input);
249
+ const result = await (0, bulk_1.performMoveResourceRepo)({ client }, input);
201
250
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
202
251
  });
203
- server.tool('memory_checkRepoStatus', "Check whether the current repo is linked to a memory team yet, reporting the linked team and whether you are a member. See memory_getSkillGuide for what to do if it isn't.", {}, async () => {
252
+ server.tool('memory_checkRepoStatus', "Check whether the current repo is linked to a memory team yet, reporting the linked team and whether you are a member (linked: false with registered: true means the repo exists but has no team). See memory_getSkillGuide for what to do if it isn't.", {}, async () => {
204
253
  const status = await repoContext.checkRepoStatus();
205
254
  return { content: [...(await joinNoticeBlocks()), { type: 'text', text: JSON.stringify(status) }] };
206
255
  });
207
- server.tool('memory_listTeams', "List the memory teams this developer belongs to, for choosing a teamName to pass to memory_linkRepoTeam.", {}, async () => {
256
+ server.tool('memory_listTeams', "List the memory teams this developer belongs to, with each team's memberCount, for choosing a teamName to pass to memory_linkRepoTeam.", {}, async () => {
208
257
  const { teams } = await client.listTeams();
209
258
  return { content: [{ type: 'text', text: JSON.stringify({ teams }) }] };
210
259
  });
211
- 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.", {
260
+ server.tool('memory_joinTeam', "Join an EXISTING memory team by name (case-insensitive; it never creates one). Joining changes who can read the team's Team-visibility items, so only call this when a human in the conversation explicitly asks to join that team — never autonomously. Use memory_listTeams for teams you already belong to.", {
261
+ teamName: zod_1.z.string().min(1),
262
+ }, async (input) => {
263
+ const result = await (0, teams_1.performJoinTeam)({ client }, input);
264
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
265
+ });
266
+ server.tool('memory_addTeamMember', "Add a teammate to a memory team you already belong to. agent is their DevAgents uid or their exact display name (case-insensitive); an ambiguous or unknown name errors with candidates. Idempotent. Adding a member changes who can read the team's Team-visibility items, so only call this when a human in the conversation explicitly asks to add that person — never autonomously, the same rule as sharing. Co-membership is symmetric: the new member can read the Team-visibility items of every member, and every member can read theirs, including the repo-less Team items the new member saved, without that person's separate consent. Tell the person being added before you do it.", {
267
+ teamName: zod_1.z.string().min(1),
268
+ agent: zod_1.z.string().min(1).describe('A DevAgents uid or an exact display name.'),
269
+ }, async (input) => {
270
+ const result = await (0, teams_1.performAddTeamMember)({ client }, input);
271
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
272
+ });
273
+ server.tool('memory_listTeamMembers', "List the members (uid and display name) of a memory team by name. Only members of that team may list it.", {
274
+ teamName: zod_1.z.string().min(1),
275
+ }, async (input) => {
276
+ const result = await (0, teams_1.performListTeamMembers)({ client }, input);
277
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
278
+ });
279
+ server.tool('memory_whoCanRead', "Preview who can read one Fact/Scenario/Skill/Wiki page you can read, from its actual visibility: { visibility, audience }. audience.kind is author (Private), everyone (Org), team (the repo's owning team with memberCount), coMembers (Team with no repo: the author's teams, with memberCount and readerCount) or grants (Restricted: the granted agents by display name). Use it to check sharing instead of guessing from your own session.", {
280
+ type: zod_1.z.enum(['Fact', 'Scenario', 'Skill', 'Wiki']),
281
+ uid: zod_1.z.string().min(1),
282
+ }, async (input) => {
283
+ const result = await (0, teams_1.performWhoCanRead)({ client }, input);
284
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
285
+ });
286
+ 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; links for a Wiki page; factIds for a Scenario; repo (a uid from memory_listRepos, or null for not project-specific) and source (or null to clear it) for any. Only the author can update. When this repeats or corrects something you already saved, use this, not memory_save.", {
212
287
  type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
213
288
  uid: zod_1.z.string().min(1),
214
289
  content: zod_1.z.string().min(1).optional().describe('Fact, Skill, Wiki: the full new text, not a patch.'),
@@ -216,6 +291,9 @@ server.tool('memory_update', "Revise a memory you saved, in place, instead of sa
216
291
  summary: zod_1.z.string().min(1).optional().describe('Scenario only: the full new summary.'),
217
292
  tags: zod_1.z.array(zod_1.z.enum(TAG_VALUES)).optional().describe('Fact, Skill, Wiki only. Replaces the existing tags.'),
218
293
  repo: zod_1.z.string().min(1).nullable().optional().describe('A DevRepos uid, or null to clear it.'),
294
+ links: zod_1.z.array(zod_1.z.string().min(1)).optional().describe('Wiki only: the full new list of target wiki page uids; [] clears. Replaces, not appends.'),
295
+ factIds: zod_1.z.array(zod_1.z.string().min(1)).optional().describe('Scenario only: the full new list of YOUR fact uids that belong to it; [] unlinks all. Facts that are not yours come back as skippedFactIds.'),
296
+ source: source_1.sourceSchema.nullable().optional().describe(`${source_1.SOURCE_DESCRIPTION} Pass it after re-checking the item against the repo; null clears the source.`),
219
297
  }, async (input) => {
220
298
  const result = await (0, revise_1.performUpdate)({ client, embed: embeddings_1.embed }, input);
221
299
  (0, capture_1.logCapture)({ action: 'updated', type: input.type, uid: result.uid });
@@ -235,34 +313,35 @@ server.tool('memory_setTaskStatus', "Mark a ticket's task Done when its work is
235
313
  const result = await (0, revise_1.performSetTaskStatus)({ client }, input);
236
314
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
237
315
  });
238
- 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.", {
316
+ 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. includeUnlinked also lists repos no team owns yet (teamName null).", {
239
317
  query: zod_1.z.string().optional().describe('Case-insensitive substring filter on repo name.'),
318
+ includeUnlinked: zod_1.z.boolean().optional().describe('true: also return repos with no team, with teamName null.'),
240
319
  }, async (input) => {
241
- const repos = await (0, list_repos_1.listReposForTools)(client, input.query);
320
+ const repos = await (0, list_repos_1.listReposForTools)(client, input.query, input.includeUnlinked === true);
242
321
  return { content: [{ type: 'text', text: JSON.stringify({ repos }) }] };
243
322
  });
244
- server.tool('memory_linkRepoTeam', "Link a repo to a team by name (existing or new) after the user has confirmed which team it belongs to. Defaults to the repo of the current directory; pass repoName to link a different one, or from a host with no repo at all (Claude Desktop). Use memory_listTeams to see the team names to choose from.", {
323
+ server.tool('memory_linkRepoTeam', "Link a repo to a team by name (existing or new) after the user has confirmed which team it belongs to. Defaults to the repo of the current directory; pass repoName to link a different one, or from a host with no repo at all (Claude Desktop). Pass repoNames (1-50) to link several repos to the same team in one call; each reports its own result. Use memory_listTeams to see the team names to choose from.", {
245
324
  teamName: zod_1.z.string(),
246
325
  repoName: zod_1.z
247
326
  .string()
248
327
  .min(1)
249
328
  .optional()
250
- .describe('Repo to link. Defaults to the current directory\'s repo; required when there is none.'),
329
+ .describe('Repo to link. Defaults to the current directory\'s repo; required when there is none. Not with repoNames.'),
330
+ repoNames: zod_1.z.array(zod_1.z.string().min(1)).min(1).max(50).optional().describe('A batch of up to 50 repos to link to teamName.'),
251
331
  }, async (input) => {
252
- const repoName = input.repoName ?? (0, git_remote_1.detectRepoName)();
253
- if (!repoName) {
254
- return {
255
- content: [
256
- {
257
- type: 'text',
258
- text: JSON.stringify({
259
- error: 'No repo detected in this session. Pass repoName to say which repo to link.',
260
- }),
261
- },
262
- ],
263
- };
264
- }
265
- const result = await client.linkRepoTeam({ repoName, teamName: input.teamName });
332
+ const result = await (0, bulk_1.performLinkRepoTeam)({ client, detectRepoName: git_remote_1.detectRepoName }, input);
333
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
334
+ });
335
+ server.tool('memory_registerRepo', "Register a repo nobody has linked to a team yet, so memory can be saved against it. Defaults to the repo of the current directory; pass repoName (owner/name) otherwise. Returns the existing repo if it is already registered: { uid, name, teamName, created }. Items on a repo with no team cannot be Team-visible (Private or Org only) until memory_linkRepoTeam links it.", {
336
+ repoName: zod_1.z.string().min(1).optional().describe("owner/name. Defaults to the current directory's repo; required when there is none."),
337
+ }, async (input) => {
338
+ const result = await (0, list_repos_1.performRegisterRepo)({ client, detectRepoName: git_remote_1.detectRepoName }, input);
339
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
340
+ });
341
+ server.tool('memory_checkSources', "Find memories that may be stale against a repo checkout. Lists the items you can read whose source.repo is the given repo (default: the current directory's repo) and, using git in the current directory, reports how many commits HEAD is ahead of each item's source.commit (commitsBehind), or unknownCommit: true when that commit is not in the local history. Most behind first; unknown commits last. Changes nothing: re-read the repo, then memory_update the item with its new source.", {
342
+ repo: zod_1.z.string().min(1).optional().describe("owner/name. Defaults to the current directory's repo."),
343
+ }, async (input) => {
344
+ const result = await (0, check_sources_1.performCheckSources)({ client, detectRepoName: git_remote_1.detectRepoName }, input);
266
345
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
267
346
  });
268
347
  server.tool('memory_sessionContext', "Load this developer's saved memory-hub context: their persona profile, facts, skills, and — when the session has a repo — its wiki pages. Call once at the start of a conversation. If the result has persona.configured false, offer once to set up their persona with memory_upsertPersona, then drop it for the rest of the conversation. On Claude Code the SessionStart hook already covers facts and skills; call this there for the persona, or if that context is missing.", {}, async () => {
@@ -1,17 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listReposForTools = void 0;
3
+ exports.performRegisterRepo = exports.listReposForTools = void 0;
4
+ const capture_1 = require("./capture");
4
5
  // Fans out listTeams() -> listRepos() per team and flattens into one list
5
6
  // labeled with each repo's team name — the small, infrequent list a caller
6
7
  // picks a target repo uid from (for memory_saveX's repo param or
7
- // memory_moveResourceRepo). A single team's listRepos failing degrades that
8
- // team's repos out of the result rather than failing the whole call, since
9
- // a partial list is still useful for picking a repo and a total failure
10
- // isn't warranted by one team's transient error.
11
- async function listReposForTools(client, query) {
8
+ // memory_moveResourceRepo). A single call failing degrades its repos out of
9
+ // the result rather than failing the whole call, since a partial list is
10
+ // still useful for picking a repo. includeUnlinked adds one extra call for
11
+ // repos no team owns, which also works for a user on no teams.
12
+ async function listReposForTools(client, query, includeUnlinked = false) {
12
13
  const { teams } = await client.listTeams();
13
- const perTeam = await Promise.allSettled(teams.map((team) => client.listRepos({ teamId: team.uid }).then((result) => result.repos.map((repo) => ({ uid: repo.uid, name: repo.name, teamName: team.name })))));
14
- const allRepos = perTeam
14
+ const perTeam = teams.map((team) => client.listRepos({ teamId: team.uid }).then((result) => result.repos.map((repo) => ({ uid: repo.uid, name: repo.name, teamName: team.name }))));
15
+ const unlinked = includeUnlinked
16
+ ? [
17
+ client.listRepos({ unlinkedOnly: true }).then((result) => result.repos.map((repo) => ({ uid: repo.uid, name: repo.name, teamName: null }))),
18
+ ]
19
+ : [];
20
+ const settled = await Promise.allSettled([...perTeam, ...unlinked]);
21
+ const allRepos = settled
15
22
  .filter((result) => result.status === 'fulfilled')
16
23
  .flatMap((result) => result.value);
17
24
  if (!query) {
@@ -21,3 +28,14 @@ async function listReposForTools(client, query) {
21
28
  return allRepos.filter((repo) => repo.name.toLowerCase().includes(normalizedQuery));
22
29
  }
23
30
  exports.listReposForTools = listReposForTools;
31
+ function performRegisterRepo(deps, input) {
32
+ if ((0, capture_1.isCaptureMode)()) {
33
+ throw new Error('memory_registerRepo is not allowed in capture mode.');
34
+ }
35
+ const repoName = (input.repoName ?? deps.detectRepoName() ?? '').trim();
36
+ if (!repoName) {
37
+ throw new Error('No repo detected in this session. Pass repoName as owner/name.');
38
+ }
39
+ return deps.client.registerRepo({ repoName });
40
+ }
41
+ exports.performRegisterRepo = performRegisterRepo;
@@ -61,8 +61,17 @@ function createRepoContext(client, detectName = git_remote_1.detectRepoName, det
61
61
  };
62
62
  }
63
63
  // resolveRepo auto-joins the repo's team, so a linked repo always means membership.
64
- const team = result.devTeamId ? { teamId: result.devTeamId, teamName: result.teamName, member: true } : {};
65
- return { uid: result.uid, name: result.name, justJoinedTeamName: result.justJoinedTeamName, ...team };
64
+ if (!result.devTeamId) {
65
+ return { uid: result.uid, name: result.name, registered: true, linked: false, teamNameHint };
66
+ }
67
+ return {
68
+ uid: result.uid,
69
+ name: result.name,
70
+ justJoinedTeamName: result.justJoinedTeamName,
71
+ teamId: result.devTeamId,
72
+ teamName: result.teamName,
73
+ member: true,
74
+ };
66
75
  }
67
76
  catch {
68
77
  return NO_REPO;
package/dist/revise.js CHANGED
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.performSetTaskStatus = exports.performDelete = exports.performUpdate = void 0;
4
+ const source_1 = require("./source");
4
5
  const save_1 = require("./save");
6
+ const capture_1 = require("./capture");
5
7
  // Which fields each type accepts. Anything else is refused, not dropped, so a typo cannot look like a successful edit.
6
8
  const ALLOWED = {
7
- Fact: ['content', 'tags', 'repo'],
8
- Skill: ['title', 'content', 'tags', 'repo'],
9
- Scenario: ['summary', 'repo'],
10
- Wiki: ['title', 'content', 'tags', 'repo'],
9
+ Fact: ['content', 'tags', 'repo', 'source'],
10
+ Skill: ['title', 'content', 'tags', 'repo', 'source'],
11
+ Scenario: ['summary', 'repo', 'factIds', 'source'],
12
+ Wiki: ['title', 'content', 'tags', 'repo', 'links', 'source'],
11
13
  };
12
- const FIELDS = ['content', 'title', 'summary', 'tags', 'repo'];
14
+ const FIELDS = ['content', 'title', 'summary', 'tags', 'repo', 'links', 'factIds', 'source'];
13
15
  // The text an item is embedded from, matching save.ts, so a revised item stays comparable to the rest.
14
16
  function embeddedText(type, current) {
15
17
  if (type === 'Fact')
@@ -34,12 +36,28 @@ async function performUpdate(deps, input) {
34
36
  const { client, embed } = deps;
35
37
  const given = FIELDS.filter((field) => input[field] !== undefined);
36
38
  if (given.length === 0) {
37
- throw new Error('Nothing to update: pass at least one of content, title, summary, tags or repo.');
39
+ throw new Error('Nothing to update: pass at least one of content, title, summary, tags, repo, links, factIds or source.');
38
40
  }
39
41
  const refused = given.filter((field) => !ALLOWED[input.type].includes(field));
40
42
  if (refused.length > 0) {
43
+ if (refused.includes('links')) {
44
+ throw new Error(`links applies to a Wiki page only; a ${input.type} has none.`);
45
+ }
46
+ if (refused.includes('factIds')) {
47
+ throw new Error(`factIds applies to a Scenario only; a ${input.type} has none.`);
48
+ }
41
49
  throw new Error(`A ${input.type} has no ${refused.join(', ')}. It accepts: ${ALLOWED[input.type].join(', ')}.`);
42
50
  }
51
+ if ((0, capture_1.isCaptureMode)() && (input.links !== undefined || input.factIds !== undefined)) {
52
+ throw new Error('links and factIds replace whole lists and are not allowed in capture mode.');
53
+ }
54
+ for (const field of ['links', 'factIds']) {
55
+ const value = input[field];
56
+ if (value !== undefined && (!Array.isArray(value) || value.some((item) => typeof item !== 'string' || item.trim() === ''))) {
57
+ throw new Error(`${field} must be an array of non-empty uid strings (an empty array clears it).`);
58
+ }
59
+ }
60
+ (0, source_1.assertSource)(input.source, true);
43
61
  const repo = typeof input.repo === 'string' ? await (0, save_1.validateRepoArg)(client, input.repo) : input.repo;
44
62
  const textChanged = input.content !== undefined || input.title !== undefined || input.summary !== undefined;
45
63
  let embedding;
package/dist/save.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.performSave = exports.validateRepoArg = void 0;
4
+ const source_1 = require("./source");
4
5
  const UID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
5
6
  const OWNER_NAME_PATTERN = /^[^/\s]+\/[^/\s]+$/;
6
7
  async function validateRepoArg(client, repo) {
@@ -12,7 +13,7 @@ async function validateRepoArg(client, repo) {
12
13
  if (resolved.uid) {
13
14
  return resolved.uid;
14
15
  }
15
- throw new Error(`repo must be a uid from memory_listRepos; "${repo}" is not a linked repo`);
16
+ throw new Error(`repo must be a uid from memory_listRepos; "${repo}" is not a registered repo`);
16
17
  }
17
18
  throw new Error(`repo must be a uid from memory_listRepos, got "${repo}"`);
18
19
  }
@@ -24,6 +25,7 @@ exports.validateRepoArg = validateRepoArg;
24
25
  // itself untestable, the same reason list-repos.ts was extracted earlier.
25
26
  async function performSave(deps, input) {
26
27
  const { client, embed, currentRepoUid, resolveTaskUid } = deps;
28
+ (0, source_1.assertSource)(input.source);
27
29
  const explicitRepo = () => (input.repo === undefined ? undefined : validateRepoArg(client, input.repo));
28
30
  // Required-field checks run BEFORE any repo resolution/network call — the old
29
31
  // per-type tools got this for free from Zod (`content: z.string()`, not
@@ -38,7 +40,7 @@ async function performSave(deps, input) {
38
40
  const repo = (await explicitRepo()) ?? (await currentRepoUid());
39
41
  const devTaskId = input.externalRef ? await resolveTaskUid(input.externalRef, repo ?? null) : undefined;
40
42
  const embedding = await embed(input.content).catch(() => undefined);
41
- return client.saveFact({ content: input.content, tags: input.tags, devTaskId, repo, embedding });
43
+ return client.saveFact({ content: input.content, tags: input.tags, devTaskId, repo, embedding, visibility: input.visibility, source: input.source });
42
44
  }
43
45
  case 'Skill': {
44
46
  if (!input.title || !input.content) {
@@ -46,7 +48,7 @@ async function performSave(deps, input) {
46
48
  }
47
49
  const repo = (await explicitRepo()) ?? (await currentRepoUid());
48
50
  const embedding = await embed(`${input.title}\n\n${input.content}`).catch(() => undefined);
49
- return client.saveSkill({ title: input.title, content: input.content, tags: input.tags, repo, embedding });
51
+ return client.saveSkill({ title: input.title, content: input.content, tags: input.tags, repo, embedding, visibility: input.visibility, source: input.source });
50
52
  }
51
53
  case 'Scenario': {
52
54
  if (!input.summary) {
@@ -55,7 +57,7 @@ async function performSave(deps, input) {
55
57
  const repo = (await explicitRepo()) ?? (await currentRepoUid());
56
58
  const devTaskId = input.externalRef ? await resolveTaskUid(input.externalRef, repo ?? null) : undefined;
57
59
  const embedding = await embed(input.summary).catch(() => undefined);
58
- return client.saveScenario({ summary: input.summary, factIds: input.factIds, devTaskId, repo, embedding });
60
+ return client.saveScenario({ summary: input.summary, factIds: input.factIds, devTaskId, repo, embedding, visibility: input.visibility, source: input.source });
59
61
  }
60
62
  case 'Wiki': {
61
63
  if (!input.title || !input.content) {
@@ -72,6 +74,8 @@ async function performSave(deps, input) {
72
74
  devTaskId,
73
75
  repo,
74
76
  embedding,
77
+ visibility: input.visibility,
78
+ source: input.source,
75
79
  });
76
80
  }
77
81
  }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.performSetVisibility = void 0;
4
+ function performSetVisibility(deps, input) {
5
+ const hasOne = input.resourceId !== undefined;
6
+ const hasMany = input.resourceIds !== undefined;
7
+ if (hasOne === hasMany) {
8
+ throw new Error('Pass exactly one of resourceId or resourceIds.');
9
+ }
10
+ if (hasMany && input.resourceIds.length === 0) {
11
+ throw new Error('resourceIds must not be empty.');
12
+ }
13
+ return deps.client.promoteVisibility(input);
14
+ }
15
+ exports.performSetVisibility = performSetVisibility;
package/dist/source.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertSource = exports.SOURCE_DESCRIPTION = exports.sourceSchema = exports.isIsoDate = void 0;
4
+ const zod_1 = require("zod");
5
+ const REPO_PATTERN = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
6
+ const COMMIT_PATTERN = /^[0-9a-fA-F]{7,64}$/;
7
+ const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/;
8
+ function isIsoDate(value) {
9
+ return ISO_DATE_PATTERN.test(value) && !Number.isNaN(new Date(value).getTime());
10
+ }
11
+ exports.isIsoDate = isIsoDate;
12
+ exports.sourceSchema = zod_1.z.object({
13
+ repo: zod_1.z.string().max(255).regex(REPO_PATTERN, 'repo must be in owner/name form'),
14
+ commit: zod_1.z.string().regex(COMMIT_PATTERN, 'commit must be 7-64 hex characters'),
15
+ verifiedAt: zod_1.z.string().refine(isIsoDate, 'verifiedAt must be an ISO date').optional(),
16
+ });
17
+ exports.SOURCE_DESCRIPTION = 'The repo this knowledge was derived from and the HEAD commit sha you read: { repo: "owner/name", commit, verifiedAt? }. verifiedAt defaults to now.';
18
+ function assertSource(source, allowNull = false) {
19
+ if (source === undefined || (source === null && allowNull)) {
20
+ return;
21
+ }
22
+ const parsed = exports.sourceSchema.safeParse(source);
23
+ if (!parsed.success) {
24
+ throw new Error(`source is invalid: ${parsed.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ')}`);
25
+ }
26
+ }
27
+ exports.assertSource = assertSource;
package/dist/teams.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.performWhoCanRead = exports.performListTeamMembers = exports.performAddTeamMember = exports.performJoinTeam = void 0;
4
+ function requireText(value, name) {
5
+ if (typeof value !== 'string' || value.trim() === '') {
6
+ throw new Error(`${name} is required.`);
7
+ }
8
+ return value.trim();
9
+ }
10
+ async function performJoinTeam(deps, input) {
11
+ return deps.client.joinTeam({ teamName: requireText(input.teamName, 'teamName') });
12
+ }
13
+ exports.performJoinTeam = performJoinTeam;
14
+ async function performAddTeamMember(deps, input) {
15
+ return deps.client.addTeamMember({ teamName: requireText(input.teamName, 'teamName'), agent: requireText(input.agent, 'agent') });
16
+ }
17
+ exports.performAddTeamMember = performAddTeamMember;
18
+ async function performListTeamMembers(deps, input) {
19
+ return deps.client.listTeamMembers({ teamName: requireText(input.teamName, 'teamName') });
20
+ }
21
+ exports.performListTeamMembers = performListTeamMembers;
22
+ async function performWhoCanRead(deps, input) {
23
+ return deps.client.whoCanRead({ resourceType: input.type, uid: requireText(input.uid, 'uid') });
24
+ }
25
+ exports.performWhoCanRead = performWhoCanRead;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skedulo/memory-hub-mcp",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "MCP server for the SE AI Memory Hub: recall and save developer memory from Claude Code and Claude Desktop.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
package/skill-guide.md CHANGED
@@ -70,7 +70,11 @@ picklist, not a free-form string — pick from `ConnectedFunction`,
70
70
  codebase-map skills described below, not for facts), `SOW` (a Statement of
71
71
  Work), `TDD` (a Technical Design Doc) — `SOW`/`TDD` are most useful on wiki
72
72
  pages, where a whole document usually lands (see below), but are valid on
73
- Fact, Skill, or Wiki saves alike. The tool schema enforces this, so an invalid tag fails
73
+ Fact, Skill, or Wiki saves alike. Newer tags: `AI` (LLMs, agents, MCP, prompts),
74
+ `API` (REST/GraphQL endpoints and schemas), `Mobile` (the Skedulo mobile app/v3 —
75
+ not `MobileExtension`, which is MEX forms), `Infrastructure` (CI/CD, pipelines,
76
+ hosting, environments), `Security` (permissions, secrets, vulnerabilities),
77
+ `Messaging` (SMS, email, notifications, queues). The tool schema enforces this, so an invalid tag fails
74
78
  with a clear validation error rather than reaching the backend — if this
75
79
  list and the schema's actual error ever disagree, trust the error: this
76
80
  list is prose, kept in sync by hand.
@@ -98,6 +102,14 @@ list is prose, kept in sync by hand.
98
102
  Reach for this instead of `type: 'Fact'` when what you learned will
99
103
  still be true next month, not just relevant to the task at hand.
100
104
 
105
+ `memory_save`, `memory_update` and `memory_moveResourceRepo` report where the
106
+ item ended up — `visibility`, `repoId`, `repoName` and `teamName` — read from
107
+ the saved record. Check them instead of assuming the default applied. `repo`
108
+ on a save takes a uid from `memory_listRepos` or an `owner/name` of a repo
109
+ already linked to a team. `visibility` (`Private`, `Team` or `Org`) overrides
110
+ the default, but only pass it when the human approved sharing that item or
111
+ batch in this conversation — see "Sharing" below.
112
+
101
113
  **Wiki pages can depend on each other** — pass `links` (an array of other
102
114
  wiki page UIDs) on a `type: 'Wiki'` save to connect a page to the ones it
103
115
  depends on, e.g. a TDD linking to the SOW it was scoped against, or an
@@ -106,11 +118,13 @@ a graph in the panel's Wiki tab. There's no separate "dependency" concept —
106
118
  a link *is* the dependency edge, just without a label on it (plain
107
119
  "linked," not "depends on" vs. "supersedes"). The link is directional (the page you're saving is the source, each UID in
108
120
  `links` is a target) and computes backlinks automatically for the reverse
109
- direction — but only the panel's Wiki tab currently shows either
110
- direction. Neither `memory_recall` nor any other MCP tool returns a
111
- page's links or backlinks today, so you can pass `links` when saving, but
112
- can't currently query them back mid-session — check the panel, or the
113
- page you already have the UID for, if you need to see them.
121
+ direction. `memory_get type=Wiki` returns `links` (the targets this page
122
+ points at) and `backlinks` (pages that link to it) for any page you can
123
+ read, whoever authored it: links are limited to target pages you can read, and
124
+ backlinks to source pages you can read. To change a page's links later, pass
125
+ the full new `links` list to `memory_update` (it replaces; `[]` clears). Read
126
+ the current list with `memory_get` first. The panel's Wiki tab shows the same
127
+ graph.
114
128
 
115
129
  **If the user hands you a document (PDF, Word, PowerPoint, etc.) to turn
116
130
  into a wiki page**, and a `convert_to_markdown` tool is available (from the
@@ -190,8 +204,12 @@ repeats a memory of yours, change that memory instead of saving another one:
190
204
 
191
205
  - **`memory_update`** with `type`, `uid` and only the fields that change
192
206
  (`content`/`tags` for a Fact; `title`/`content`/`tags` for a Skill or Wiki
193
- page; `summary` for a Scenario; `repo`, or `null`, for any). Pass the full
194
- new text, not a patch. It re-embeds the text, so search keeps working. Only
207
+ page; `summary` for a Scenario; `links` for a Wiki page; `factIds` for a
208
+ Scenario; `repo`, or `null`, and `source`, or `null`, for any). Pass the full new text, not a patch.
209
+ `links` (target wiki uids) and `factIds` (uids of your facts that belong to
210
+ the scenario) replace the whole list; `[]` clears it. A fact that is not
211
+ yours comes back in `skippedFactIds` instead of failing; facts left out of the
212
+ new list are unlinked from the scenario. It re-embeds the text, so search keeps working. Only
195
213
  the author can update.
196
214
  - **`memory_delete`** removes one of your memories for good. Use it for a copy
197
215
  you have just merged into another, or a memory that is wrong or obsolete.
@@ -304,23 +322,125 @@ Two consequences worth knowing:
304
322
  now. Use `memory_setVisibility` to demote it back, the same way you'd use
305
323
  it to promote something the other direction (see below).
306
324
 
325
+ ## Checking who can read an item
326
+
327
+ - **`memory_whoCanRead`** — `type` and `uid` of an item you can read; returns
328
+ `{ visibility, audience }` where `audience.kind` is `author`, `everyone`,
329
+ `team` (the repo's team, with `memberCount`), `coMembers` (Team item with no
330
+ repo: the author's teams plus `readerCount`) or `grants` (Restricted: display
331
+ names of the granted agents). Use it to check who sees an item instead of
332
+ guessing from the author's session. It only reads, so it needs no
333
+ permission.
334
+
307
335
  ## Sharing — only on explicit human request
308
336
 
337
+ - **`memory_joinTeam`** — `teamName` of an existing team (never creates one).
338
+ **`memory_addTeamMember`** — `teamName` you already belong to and `agent`
339
+ (a uid or exact display name; idempotent). Both change who can read Team
340
+ items, so call them only when a human explicitly asks, like sharing.
341
+ Membership is symmetric: adding someone shares their own repo-less Team
342
+ items with every member of the team, and theirs with them, so tell the
343
+ person being added first.
344
+ **`memory_listTeamMembers`** — `teamName`; members only. `memory_listTeams`
345
+ now includes each team's `memberCount`.
309
346
  - **`memory_setVisibility`** — changes a Fact/Scenario/Skill/Wiki page's
310
- visibility in either direction: promote to `Team` or `Restricted`, or
311
- demote back to `Private` (e.g. to undo an automatic Team default, or to
312
- walk back an earlier promote/grant).
347
+ visibility in either direction: promote to `Team`, `Org` or `Restricted`,
348
+ or demote back to `Private` (e.g. to undo an automatic Team default, or to
349
+ walk back an earlier promote/grant). Pass `resourceId` for one item, or
350
+ `resourceIds` (1-100 uids, all one `resourceType`) for a batch; a batch
351
+ reports a result or an error per item, so a bad uid doesn't sink the rest.
313
352
  - **`memory_grantAccess`** — shares a specific item with one named teammate
314
353
  (automatically promotes it to `Restricted` if needed).
315
354
 
316
- **Call these two tools only when a human explicitly asks, in the current
355
+ Visibility levels: `Private` is you only. `Team` is the team that owns the
356
+ item's repo (or, for a repo-less item, every team you're in). `Org` is every
357
+ agent in the tenant, whatever their team. Use `Team` for work notes that
358
+ belong with one engagement; use `Org` only for knowledge that is useful
359
+ across teams and safe for everyone in the tenant to read — a reusable skill, a
360
+ platform gotcha, a standing reference. When in doubt, `Team`. `Restricted`
361
+ needs a named person, so only `memory_grantAccess` sets it, never a save.
362
+
363
+ **Never put secrets, credentials, customer personal data, or details of an
364
+ unfixed vulnerability in a `Team` or `Org` item.** Visibility is enforced only
365
+ by the memory-hub function, not by the platform: the underlying records are
366
+ not locked down by a platform access policy, so anyone with data access to the
367
+ tenant can read them. Keep anything that sensitive out of memory entirely.
368
+
369
+ **Call these tools only when a human explicitly asks, in the current
317
370
  conversation, to share, promote, un-share, or demote something** — e.g.
318
- "share that fact with the team," "give Alice access to this skill," or
319
- "actually make that one private again." Never call them autonomously based
320
- on your own judgment that something seems worth sharing (or un-sharing);
321
- that judgment belongs to the person who owns the item, not to you. This
322
- rule applies the same way in both directions — a demote is not a safer
323
- default action just because it narrows visibility.
371
+ "share that fact with the team," "make these Org-visible," "give Alice access
372
+ to this skill," or "actually make that one private again." Never call them
373
+ autonomously based on your own judgment that something seems worth sharing
374
+ (or un-sharing); that judgment belongs to the person who owns the item, not to
375
+ you. This rule applies the same way in both directions — a demote is not a
376
+ safer default action just because it narrows visibility.
377
+
378
+ **Bulk tools.** Each batch reports a result or error per item and never stops
379
+ on one bad item.
380
+
381
+ - **`memory_list`** — inventory of one `type` you can see, newest first
382
+ (`uid`, title, `visibility`, repo, `mine`), with `total` and a page of items
383
+ (`offset`, `limit` up to 200, default 50). Filters: `repo` (a uid; `null`
384
+ means no repo), `visibility`, `titlePrefix`, `tags` (not for Scenario),
385
+ `mine`, `createdAfter` (ISO date), `sourceRepo` (`owner/name`, exact) and
386
+ `verifiedBefore` (ISO date; items last verified earlier). Each item carries its
387
+ `source` when it has one. It is not a search; use `memory_recall`
388
+ for that. It changes nothing.
389
+ - **`memory_saveBatch`** — `items` (1-25), each exactly a `memory_save` input.
390
+ Results come back by `index`; duplicates appear as a short `similarTo` list.
391
+ - **`memory_moveResourceRepo`** — `resourceId` or `resourceIds` (1-100, one
392
+ `resourceType`), exactly one.
393
+ - **`memory_linkRepoTeam`** — `repoName`, or `repoNames` (1-50) for one
394
+ `teamName`; with neither it uses the current repo. It also gives a repo
395
+ registered with `memory_registerRepo` its first team.
396
+
397
+ **Bulk-sharing recipe.** Call `memory_list` (e.g. `mine: true`, a `repo`,
398
+ `visibility: 'Team'`) and collect the uids from every page first, until
399
+ `offset` reaches `total`. Changing an item can drop it out of the filter and
400
+ shift later pages, so don't change anything while paging. Show the human the
401
+ whole set and wait for them to approve exactly that set. Then call
402
+ `memory_setVisibility` with `resourceIds` in chunks of 100 (or re-list from
403
+ offset 0 after each change). Listing never authorises sharing; the
404
+ explicit-request rule above still applies.
405
+
406
+ **Sharing a batch.** When the human approves sharing a named batch once ("save
407
+ these and make them Org-visible", "share everything from this session with the
408
+ team"), that one approval covers the whole batch, so don't ask again per item.
409
+ Either pass `visibility` on each `memory_save` (or `memory_saveBatch` item),
410
+ or save first and then call `memory_setVisibility` with `resourceIds`. A subagent may do this only for the
411
+ batch the human approved in this conversation, and never for anything it saved
412
+ on its own initiative. Capture mode refuses any save that carries `visibility`,
413
+ so a batch share must be done in the live conversation. The allow rules are
414
+ `mcp__plugin_memory-hub_memory-hub__memory_setVisibility` and
415
+ `mcp__plugin_memory-hub_memory-hub__memory_moveResourceRepo` (plugin), or
416
+ `mcp__memory-hub__memory_setVisibility` and
417
+ `mcp__memory-hub__memory_moveResourceRepo` (standalone server). A rule is a
418
+ per-user opt-in that removes the last interactive check before an item goes
419
+ Team or Org, so add it only while doing an approved bulk share.
420
+
421
+ ## Source tracking: keeping repo knowledge fresh
422
+
423
+ Knowledge you derive from a repo goes stale as the repo moves. When you save a
424
+ Fact, Skill, Scenario or Wiki page from reading a repo, pass `source` on
425
+ `memory_save` (or each `memory_saveBatch` item): `{ repo: 'owner/name', commit,
426
+ verifiedAt? }`, where `commit` is the HEAD sha (7-64 hex characters) of the
427
+ checkout you read (`git rev-parse HEAD`). `verifiedAt` defaults to now. Leave
428
+ `source` off for knowledge that is not tied to a repo's contents, such as a
429
+ preference or a decision. Capture mode may pass `source`.
430
+
431
+ To find what has gone stale, call `memory_checkSources` (optionally with `repo`;
432
+ it defaults to the current directory's repo, and must be run from a checkout of
433
+ it). It lists the items you can read whose `source.repo` is that repo and, from
434
+ local git, how many commits HEAD is ahead of each item's `source.commit`
435
+ (`commitsBehind`), most behind first. `unknownCommit: true` means that commit is
436
+ not in the local history (for example a rebase or a shallow clone), so it is
437
+ listed last and its age is unknown. `notAncestor: true` means the commit is
438
+ not behind HEAD but is not an ancestor of it either (HEAD is behind it or on
439
+ another branch), so `commitsBehind` is not a staleness signal there. It changes nothing. For each item worth
440
+ refreshing, re-read the repo, then `memory_update` it with the corrected text
441
+ (if any) and a new `source` at the current HEAD; `source: null` clears it.
442
+ `memory_list` with `sourceRepo` and `verifiedBefore` finds items by when they
443
+ were last verified instead of by commits.
324
444
 
325
445
  ## Targeting a different repo explicitly
326
446
 
@@ -339,7 +459,12 @@ If you get the repo wrong after the fact — or want to clear a save back to
339
459
  repo-less — call `memory_moveResourceRepo` with `resourceType` (`Fact`,
340
460
  `Skill`, `Scenario`, or `Wiki`), the item's `resourceId`, and the corrected
341
461
  `repo` uid from `memory_listRepos`. Pass `repo: null` instead of a uid to
342
- clear it back to unscoped rather than reassign it.
462
+ clear it back to unscoped rather than reassign it. To move many at once, pass
463
+ `resourceIds` (up to 100 of one `resourceType`) instead of `resourceId`. List
464
+ the set with `memory_list` and collect every page's uids before moving
465
+ anything, since a move drops items out of a `repo` filter and shifts later
466
+ pages. Moving Team-visible items into another team's repo changes who can read
467
+ them.
343
468
 
344
469
  ## Linking a repo to a team
345
470
 
@@ -349,8 +474,12 @@ Call `memory_checkRepoStatus` (no arguments) once per session, the first
349
474
  time it's relevant (e.g. before your first save, or if a recall/save
350
475
  result looks unscoped when you expected repo context).
351
476
 
352
- - If the result has no `needsTeamSelection`, nothing to do — the repo is
353
- already linked (or none was detected at all).
477
+ - If the result has `linked: false` and `registered: true`, the repo exists
478
+ but no team owns it. Offer `memory_linkRepoTeam` once (`memory_listTeams`
479
+ lists the teams; mention `teamNameHint` as a guess), and drop it if the
480
+ user declines: saves still work, with Team visibility refused.
481
+ - If the result has neither `needsTeamSelection` nor `linked: false`, nothing
482
+ to do — the repo is already linked (or none was detected at all).
354
483
  - If it has `needsTeamSelection: true`, ask the user directly which team
355
484
  this repo belongs to. Offer `agentTeams` as the likely options, and
356
485
  mention `teamNameHint` as a guess if it's present — e.g. *"This repo
@@ -361,7 +490,19 @@ result looks unscoped when you expected repo context).
361
490
  - With no repo detected at all (Claude Desktop starts the server with no
362
491
  project directory), `memory_linkRepoTeam` still works, but you have to
363
492
  name the repo: pass `repoName` alongside `teamName`. `memory_listTeams`
364
- lists the teams to choose from. Never guess the repo name — ask.
493
+ lists the teams to choose from. Never guess the repo name — ask. To link
494
+ several repos to one team, pass `repoNames` (up to 50) instead.
495
+
496
+ **A repo nobody has linked yet.** If the user has no team for it, or does not
497
+ want to choose one now, call `memory_registerRepo` (no arguments for the current
498
+ repo, or `repoName` as `owner/name`). It creates the repo with no team, or
499
+ returns the existing one: `{ uid, name, teamName, created }`. Items on a repo
500
+ with no team are readable by their author only, so Team visibility is refused
501
+ there (on `memory_save`, `memory_setVisibility` and when moving a Team item onto
502
+ it); use Private, or Org if the human approves sharing it, until the repo is
503
+ linked with `memory_linkRepoTeam`. `memory_listRepos` with `includeUnlinked:
504
+ true` also lists repos with no team (`teamName: null`). `memory_registerRepo`
505
+ is refused in capture mode.
365
506
 
366
507
  This only needs to happen once per repo per agent. Do this on explicit
367
508
  user confirmation, not a guess of your own — an SE works several client