@skedulo/memory-hub-mcp 0.2.0 → 0.2.1

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.
@@ -25,6 +25,12 @@ call() {
25
25
  # comfortable headroom even if both rounds hit the cap. Bumped from 2s/3s after live
26
26
  # runs showed occasional silent drops (a call's own timeout, not a logic bug) under
27
27
  # real tenant latency.
28
+ # Test seam: replay canned per-leg responses so budget and assembly logic test offline.
29
+ if [ -n "${MEMORY_HUB_FIXTURE_DIR:-}" ]; then
30
+ cp "$MEMORY_HUB_FIXTURE_DIR/$(basename "$out_file")" "$out_file" 2>/dev/null || true
31
+ return 0
32
+ fi
33
+
28
34
  curl -sS --connect-timeout 3 --max-time 5 \
29
35
  -X POST "${FUNCTION_URL}${path}" \
30
36
  -H "Authorization: Bearer ${TOKEN}" \
@@ -115,10 +121,19 @@ if [ -z "$TEAM_NAME_HINT" ] && [ -n "$REPO_NAME" ]; then
115
121
  TEAM_NAME_HINT=$(humanize_repo_slug "$REPO_NAME" 2>/dev/null || true)
116
122
  fi
117
123
 
118
- call "/memory/recall" '{"scope":"self"}' "$TMP_DIR/facts_self.json" &
119
- call "/memory/recall" '{"scope":"team"}' "$TMP_DIR/facts_team.json" &
120
- call "/memory/list-skills" '{"scope":"self"}' "$TMP_DIR/skills_self.json" &
121
- call "/memory/list-skills" '{"scope":"team"}' "$TMP_DIR/skills_team.json" &
124
+ # Oversized means silently unread: past the inline cap the block is only previewed. 8000 is conservative, not measured.
125
+ BUDGET="${MEMORY_HUB_MAX_CHARS:-8000}"
126
+
127
+ # Legs oversubscribe BUDGET on purpose: the server drops past its cap silently, so the clip below must be the binding one.
128
+ FETCH_FACTS=$((BUDGET / 3))
129
+ FETCH_SKILLS=$((BUDGET / 4))
130
+ FETCH_REPO_FACTS=$((BUDGET / 2))
131
+ FETCH_REPO_REST=$((BUDGET / 3))
132
+
133
+ call "/memory/recall" "{\"scope\":\"self\",\"maxTotalChars\":$FETCH_FACTS}" "$TMP_DIR/facts_self.json" &
134
+ call "/memory/recall" "{\"scope\":\"team\",\"maxTotalChars\":$FETCH_FACTS}" "$TMP_DIR/facts_team.json" &
135
+ call "/memory/list-skills" "{\"scope\":\"self\",\"maxTotalChars\":$FETCH_SKILLS}" "$TMP_DIR/skills_self.json" &
136
+ call "/memory/list-skills" "{\"scope\":\"team\",\"maxTotalChars\":$FETCH_SKILLS}" "$TMP_DIR/skills_team.json" &
122
137
  if [ -n "$REPO_NAME" ]; then
123
138
  REPO_NAME_JSON=$(printf '%s' "$REPO_NAME" | jq -Rs . 2>/dev/null || true)
124
139
  if [ -n "$REPO_NAME_JSON" ]; then
@@ -141,66 +156,147 @@ if [ -s "$TMP_DIR/repo.json" ]; then
141
156
  fi
142
157
 
143
158
  if [ -n "$REPO_UID" ]; then
144
- REPO_BODY=$(printf '{"scope":"team","repo":%s}' "$(printf '%s' "$REPO_UID" | jq -Rs .)")
145
- call "/memory/recall" "$REPO_BODY" "$TMP_DIR/facts_repo.json" &
146
- call "/memory/list-skills" "$REPO_BODY" "$TMP_DIR/skills_repo.json" &
147
- call "/memory/recall-wiki" "$REPO_BODY" "$TMP_DIR/wiki_repo.json" &
159
+ # The repo legs get the larger share — they are first in priority order below.
160
+ REPO_UID_JSON=$(printf '%s' "$REPO_UID" | jq -Rs .)
161
+ call "/memory/recall" "$(printf '{"scope":"team","repo":%s,"maxTotalChars":%d}' "$REPO_UID_JSON" "$FETCH_REPO_FACTS")" "$TMP_DIR/facts_repo.json" &
162
+ call "/memory/list-skills" "$(printf '{"scope":"team","repo":%s,"maxTotalChars":%d}' "$REPO_UID_JSON" "$FETCH_REPO_REST")" "$TMP_DIR/skills_repo.json" &
163
+ call "/memory/recall-wiki" "$(printf '{"scope":"team","repo":%s,"maxTotalChars":%d}' "$REPO_UID_JSON" "$FETCH_REPO_REST")" "$TMP_DIR/wiki_repo.json" &
148
164
  wait
149
165
  fi
150
166
 
167
+ # -c, not -r: content is multi-line, and sort/comm dedup plus the budget clip below are
168
+ # all line-oriented — one JSON-escaped line per item is what keeps an item atomic through
169
+ # them, instead of its lines being alphabetised apart. add_section decodes at the end.
170
+ #
151
171
  # Appends "(updated YYYY-MM-DD)" when lastModifiedDate is present, nothing otherwise —
152
172
  # the panel shows the same signal as a relative "N days ago" label, but the raw date
153
173
  # is cheaper to compute in jq and just as usable for the agent's own judgment (it can
154
174
  # already see today's date in its own context).
175
+ STAMP='(if .lastModifiedDate then " (updated " + .lastModifiedDate[0:10] + ")" else "" end)'
176
+
177
+ # The function truncates each item at 500 chars (handlers/recallMemory.ts), which can cut
178
+ # inside a code fence and leave every later section rendering as one code block.
179
+ CLOSE_FENCE='if ([match("```"; "g")] | length) % 2 == 1 then . + "\n```" else . end'
180
+
181
+ # A cut at exactly the cap reads as complete, because the "(updated …)" stamp still follows it.
182
+ ITEM_CAP=500
183
+ ELIDE="if length >= $ITEM_CAP then . + \"…\" else . end"
184
+
185
+ # Without this a stored "## heading" renders at the level of the hook's own section headings.
186
+ INDENT='gsub("\n"; "\n ")'
187
+
155
188
  extract_facts() {
156
- jq -r '.facts[]? | "- " + .content + (if .lastModifiedDate then " (updated " + .lastModifiedDate[0:10] + ")" else "" end)' "$1" 2>/dev/null || true
189
+ jq -c ".facts[]? | (\"- \" + (.content | $ELIDE) + $STAMP) | $CLOSE_FENCE | $INDENT" "$1" 2>/dev/null || true
157
190
  }
158
191
 
159
192
  extract_skills() {
160
- jq -r '.skills[]? | "- " + .title + ": " + .content + (if .lastModifiedDate then " (updated " + .lastModifiedDate[0:10] + ")" else "" end)' "$1" 2>/dev/null || true
193
+ jq -c ".skills[]? | (\"- \" + .title + \": \" + (.content | $ELIDE) + $STAMP) | $CLOSE_FENCE | $INDENT" "$1" 2>/dev/null || true
161
194
  }
162
195
 
163
196
  extract_wiki() {
164
- jq -r '.pages[]? | "- " + .title + ": " + .content + (if .lastModifiedDate then " (updated " + .lastModifiedDate[0:10] + ")" else "" end)' "$1" 2>/dev/null || true
197
+ jq -c ".pages[]? | (\"- \" + .title + \": \" + (.content | $ELIDE) + $STAMP) | $CLOSE_FENCE | $INDENT" "$1" 2>/dev/null || true
198
+ }
199
+
200
+ # Absent on functions deployed before the field existed; fall back to what arrived rather than inventing a number.
201
+ leg_total() {
202
+ local sent
203
+ sent=$(jq -r '.total // empty' "$1" 2>/dev/null || true)
204
+ case "$sent" in
205
+ '' | *[!0-9]*) printf '%s' "$2" ;;
206
+ *) printf '%s' "$sent" ;;
207
+ esac
165
208
  }
166
209
 
167
210
  # Counts non-empty "- "-prefixed lines in a var (0 for an empty string, never 1) —
168
211
  # used only for the diagnostic summary line below, not for any content shown above.
169
212
  count_items() {
170
213
  [ -z "$1" ] && { printf '0'; return 0; }
171
- printf '%s\n' "$1" | grep -c '^-' 2>/dev/null || printf '0'
214
+ printf '%s\n' "$1" | grep -c '^"-' 2>/dev/null || printf '0'
172
215
  }
173
216
 
174
217
  NL=$'\n'
175
218
  CONTEXT=""
176
219
 
220
+ # Reserved so the omission footer can never itself be the thing squeezed out.
221
+ FOOTER_RESERVE=120
222
+ REMAINING=$((BUDGET - FOOTER_RESERVE))
223
+ SKIPPED=""
224
+
225
+ # Even share per section, recomputed: huge facts/repo sections cannot starve skills, and unspent budget flows onward.
226
+ SECTIONS_LEFT=4
227
+ [ -n "$REPO_UID" ] && SECTIONS_LEFT=5
228
+
229
+ # Emits at most $1 chars of $2, whole items only. $3 is what the server holds — its cap has usually dropped items already.
230
+ clip_to_budget() {
231
+ local budget="$1" text="$2" avail="$3" out="" line used=0 shown=0 seen=0
232
+ while IFS= read -r line; do
233
+ [ -n "$line" ] || continue
234
+ seen=$((seen + 1))
235
+ if [ "$shown" -eq "$((seen - 1))" ] && [ $((used + ${#line} + 1)) -le "$budget" ]; then
236
+ out="${out}${line}${NL}"
237
+ used=$((used + ${#line} + 1))
238
+ shown=$((shown + 1))
239
+ fi
240
+ done <<< "$text"
241
+ printf '%s' "$out"
242
+ [ "$shown" -gt 0 ] || return 0
243
+ # Pre-dedup, so team counts can overstate by items also shown under self/repo.
244
+ [ "$avail" -ge "$seen" ] 2>/dev/null || avail="$seen"
245
+ if [ "$avail" -gt "$shown" ]; then
246
+ # A bare memory_recall returns newest-first — the same items already above.
247
+ printf '_showing %d of %d — ask memory_recall with a query for the rest._' "$shown" "$avail" | jq -R .
248
+ fi
249
+ }
250
+
251
+ add_section() {
252
+ local heading="$1" body="$2" avail="${3:-0}" clipped rendered room share
253
+ # Counted before the decrement, or the second-to-last section is handed the entire remainder.
254
+ local mine="$SECTIONS_LEFT"
255
+ [ "$SECTIONS_LEFT" -gt 1 ] && SECTIONS_LEFT=$((SECTIONS_LEFT - 1))
256
+ [ -n "$body" ] || return 0
257
+ # Heading plus the "## " and blank-line overhead, charged before clipping so a section
258
+ # can never push the total over by its own frame.
259
+ room=$((REMAINING - ${#heading} - 6))
260
+ share=$((room / mine))
261
+ [ "$share" -lt "$room" ] && room="$share"
262
+ # Below this a section is all frame and no content; recorded, not silent.
263
+ if [ "$room" -le 150 ]; then
264
+ SKIPPED="${SKIPPED}${SKIPPED:+, }${heading}"
265
+ return 0
266
+ fi
267
+ clipped=$(clip_to_budget "$room" "$body" "$avail")
268
+ # Room for the frame but not one item is the same omission as a skipped section.
269
+ if [ -z "$clipped" ]; then
270
+ SKIPPED="${SKIPPED}${SKIPPED:+, }${heading}"
271
+ return 0
272
+ fi
273
+ rendered=$(printf '%s\n' "$clipped" | jq -r . 2>/dev/null || true)
274
+ [ -n "$rendered" ] || return 0
275
+ CONTEXT="${CONTEXT}## ${heading}${NL}${rendered}${NL}${NL}"
276
+ # Charged on the escaped length, which is the larger one — the budget errs small.
277
+ REMAINING=$((REMAINING - ${#clipped} - ${#heading} - 6))
278
+ }
279
+
177
280
  FACTS_SELF=$(extract_facts "$TMP_DIR/facts_self.json")
178
281
  FACTS_TEAM=$(extract_facts "$TMP_DIR/facts_team.json")
179
282
  SKILLS_SELF=$(extract_skills "$TMP_DIR/skills_self.json")
180
283
  SKILLS_TEAM=$(extract_skills "$TMP_DIR/skills_team.json")
181
284
 
285
+ FACTS_SELF_N=$(leg_total "$TMP_DIR/facts_self.json" "$(count_items "$FACTS_SELF")")
286
+ FACTS_TEAM_N=$(leg_total "$TMP_DIR/facts_team.json" "$(count_items "$FACTS_TEAM")")
287
+ SKILLS_SELF_N=$(leg_total "$TMP_DIR/skills_self.json" "$(count_items "$SKILLS_SELF")")
288
+ SKILLS_TEAM_N=$(leg_total "$TMP_DIR/skills_team.json" "$(count_items "$SKILLS_TEAM")")
289
+
182
290
  # The team-scope query matches DevAgentId == self OR Visibility == "Team", so
183
291
  # self-owned items also come back in the team results. Drop anything already
184
292
  # shown under "Your ..." so it isn't rendered twice.
185
293
  FACTS_TEAM=$(comm -23 <(echo "$FACTS_TEAM" | sort) <(echo "$FACTS_SELF" | sort) 2>/dev/null || true)
186
294
  SKILLS_TEAM=$(comm -23 <(echo "$SKILLS_TEAM" | sort) <(echo "$SKILLS_SELF" | sort) 2>/dev/null || true)
187
295
 
188
- if [ -n "$FACTS_SELF" ]; then
189
- CONTEXT="${CONTEXT}## Your memory-hub facts${NL}${FACTS_SELF}${NL}${NL}"
190
- fi
191
- if [ -n "$FACTS_TEAM" ]; then
192
- CONTEXT="${CONTEXT}## Team memory-hub facts${NL}${FACTS_TEAM}${NL}${NL}"
193
- fi
194
- if [ -n "$SKILLS_SELF" ]; then
195
- CONTEXT="${CONTEXT}## Your memory-hub skills${NL}${SKILLS_SELF}${NL}${NL}"
196
- fi
197
- if [ -n "$SKILLS_TEAM" ]; then
198
- CONTEXT="${CONTEXT}## Team memory-hub skills${NL}${SKILLS_TEAM}${NL}${NL}"
199
- fi
200
-
201
- # Additive, never narrowing: this is an extra section on top of the four above, not a
202
- # filter applied to them. It surfaces what the whole team knows about this specific
203
- # repo — including from members whose work this developer has never seen.
296
+ # Additive, never narrowing: a section alongside the self/team ones, not a filter applied
297
+ # to them — what the whole team knows about this repo, including from members this
298
+ # developer has never worked with.
299
+ REPO_SECTION=""
204
300
  if [ -n "$REPO_UID" ]; then
205
301
  FACTS_REPO=$(extract_facts "$TMP_DIR/facts_repo.json")
206
302
  SKILLS_REPO=$(extract_skills "$TMP_DIR/skills_repo.json")
@@ -208,6 +304,11 @@ if [ -n "$REPO_UID" ]; then
208
304
  # page is only ever fetched here, in this one repo-scoped round, so there's
209
305
  # nothing to subtract it against.
210
306
  WIKI_REPO=$(extract_wiki "$TMP_DIR/wiki_repo.json")
307
+ REPO_N=$((
308
+ $(leg_total "$TMP_DIR/facts_repo.json" "$(count_items "$FACTS_REPO")") +
309
+ $(leg_total "$TMP_DIR/skills_repo.json" "$(count_items "$SKILLS_REPO")") +
310
+ $(leg_total "$TMP_DIR/wiki_repo.json" "$(count_items "$WIKI_REPO")")
311
+ ))
211
312
 
212
313
  # The repo-scoped query ({"scope":"team","repo":...}) is a superset filter of what
213
314
  # the team query already fetched, so dedup against both the self and team sections
@@ -217,7 +318,6 @@ if [ -n "$REPO_UID" ]; then
217
318
  SKILLS_REPO=$(comm -23 <(echo "$SKILLS_REPO" | sort) <(echo "$SKILLS_TEAM" | sort) 2>/dev/null || true)
218
319
  SKILLS_REPO=$(comm -23 <(echo "$SKILLS_REPO" | sort) <(echo "$SKILLS_SELF" | sort) 2>/dev/null || true)
219
320
 
220
- REPO_SECTION=""
221
321
  if [ -n "$FACTS_REPO" ]; then
222
322
  REPO_SECTION="${REPO_SECTION}${FACTS_REPO}${NL}"
223
323
  fi
@@ -227,10 +327,6 @@ if [ -n "$REPO_UID" ]; then
227
327
  if [ -n "$WIKI_REPO" ]; then
228
328
  REPO_SECTION="${REPO_SECTION}${WIKI_REPO}${NL}"
229
329
  fi
230
-
231
- if [ -n "$REPO_SECTION" ]; then
232
- CONTEXT="${CONTEXT}## Team knowledge for ${REPO_NAME}${NL}${REPO_SECTION}${NL}"
233
- fi
234
330
  fi
235
331
 
236
332
  # A completed-but-empty run and a timed-out/killed run both look identical from the
@@ -247,18 +343,38 @@ else
247
343
  fi
248
344
  DIAG="${DIAG}_"
249
345
 
250
- # Recall above is the hook's own automation — it never saves anything new, and an
346
+ # Recall below is the hook's own automation — it never saves anything new, and an
251
347
  # agent reading only the facts/skills sections has no reason to infer that a
252
348
  # separate, non-automatic step exists for the other half (on-demand mid-session
253
349
  # recall, and saving durable results once a task lands). State that explicitly and
254
350
  # unconditionally (not gated behind having any facts to show) so an agent that
255
- # finds nothing above still knows to check back in before finishing a task.
256
- CONTEXT="${CONTEXT}## Reminder${NL}"
257
- CONTEXT="${CONTEXT}The above is an automatic recall only - it never saves anything new.${NL}"
258
- CONTEXT="${CONTEXT}Invoke the se-ai-memory-hub skill during this session: memory_recall before${NL}"
259
- CONTEXT="${CONTEXT}investigating something that smells like prior context, and memory_save${NL}"
260
- CONTEXT="${CONTEXT}(type \"Fact\" or \"Scenario\") once a task produces a durable decision, root${NL}"
261
- CONTEXT="${CONTEXT}cause, or fix worth keeping for next time.${NL}${NL}"
351
+ # finds nothing below still knows to check back in before finishing a task.
352
+ #
353
+ # First, not last: it is the only part that asks for an action, so it has to survive the
354
+ # budget even when nothing else does.
355
+ REMINDER="## Reminder${NL}"
356
+ REMINDER="${REMINDER}What follows is an automatic recall only - it never saves anything new.${NL}"
357
+ REMINDER="${REMINDER}Invoke the se-ai-memory-hub skill during this session: memory_recall before${NL}"
358
+ REMINDER="${REMINDER}investigating something that smells like prior context, and memory_save${NL}"
359
+ REMINDER="${REMINDER}(type \"Fact\" or \"Scenario\") once a task produces a durable decision, root${NL}"
360
+ REMINDER="${REMINDER}cause, or fix worth keeping for next time.${NL}${NL}"
361
+ CONTEXT="$REMINDER"
362
+ REMAINING=$((REMAINING - ${#REMINDER} - ${#DIAG}))
363
+
364
+ # Priority order, most repo-specific first: whatever the budget cuts should be the
365
+ # content least likely to bear on the repo this session is actually in.
366
+ if [ -n "$REPO_UID" ]; then
367
+ add_section "Team knowledge for ${REPO_NAME}" "$REPO_SECTION" "${REPO_N:-0}"
368
+ fi
369
+ add_section "Your memory-hub facts" "$FACTS_SELF" "$FACTS_SELF_N"
370
+ add_section "Team memory-hub facts" "$FACTS_TEAM" "$FACTS_TEAM_N"
371
+ add_section "Your memory-hub skills" "$SKILLS_SELF" "$SKILLS_SELF_N"
372
+ add_section "Team memory-hub skills" "$SKILLS_TEAM" "$SKILLS_TEAM_N"
373
+
374
+ # A section that never fit is the omission most likely to be read as "there is nothing there".
375
+ if [ -n "$SKIPPED" ]; then
376
+ CONTEXT="${CONTEXT}_Omitted for space: ${SKIPPED}. Ask memory_recall with a query._${NL}${NL}"
377
+ fi
262
378
 
263
379
  CONTEXT="${CONTEXT}${DIAG}${NL}"
264
380
 
package/dist/client.js CHANGED
@@ -68,6 +68,20 @@ class MemoryHubClient {
68
68
  linkRepoTeam(input) {
69
69
  return this.post('/memory/link-repo-team', input);
70
70
  }
71
+ // Full, uncapped content by uid — recall truncates every item to
72
+ // DEFAULT_MAX_CHARS_PER_ITEM, so anything longer is only readable through these.
73
+ getFact(input) {
74
+ return this.post('/memory/get-fact', input);
75
+ }
76
+ getSkill(input) {
77
+ return this.post('/memory/get-skill', input);
78
+ }
79
+ getScenario(input) {
80
+ return this.post('/memory/get-scenario', input);
81
+ }
82
+ getWikiPage(input) {
83
+ return this.post('/memory/get-wiki-page', input);
84
+ }
71
85
  saveWikiPage(input) {
72
86
  return this.post('/memory/save-wiki-page', input);
73
87
  }
package/dist/index.js CHANGED
@@ -114,10 +114,25 @@ server.tool('memory_recall', "Recall this developer's (or their team's) Facts, S
114
114
  query: zod_1.z.string().optional(),
115
115
  tags: zod_1.z.array(zod_1.z.enum(TAG_VALUES)).optional().describe('Fact only.'),
116
116
  externalRef: zod_1.z.string().optional().describe("Fact, Scenario only — filter to items linked to this Linear/Jira ticket ref, e.g. 'SOL-1234'. Does not create a task if the ref doesn't resolve to one — returns no results instead."),
117
+ maxCharsPerItem: zod_1.z.number().int().positive().optional().describe('Per-item content cap, default 500. Raise it to read longer items inline; prefer memory_get for a single long one.'),
118
+ maxTotalChars: zod_1.z.number().int().positive().optional().describe('Cap across all items, default 6000.'),
117
119
  }, async (input) => {
118
120
  const result = await (0, recall_1.performRecall)({ client, embed: embeddings_1.embed }, input);
119
121
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
120
122
  });
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.", {
124
+ type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
125
+ uid: zod_1.z.string().min(1).describe('The uid from a memory_recall result.'),
126
+ }, async (input) => {
127
+ const result = input.type === 'Fact'
128
+ ? await client.getFact({ uid: input.uid })
129
+ : input.type === 'Skill'
130
+ ? await client.getSkill({ uid: input.uid })
131
+ : input.type === 'Scenario'
132
+ ? await client.getScenario({ uid: input.uid })
133
+ : await client.getWikiPage({ uid: input.uid });
134
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
135
+ });
121
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.', {
122
137
  type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
123
138
  content: zod_1.z.string().optional().describe('Required for Fact, Skill, Wiki.'),
package/dist/recall.js CHANGED
@@ -7,6 +7,7 @@ exports.performRecall = void 0;
7
7
  async function performRecall(deps, input) {
8
8
  const { client, embed } = deps;
9
9
  const queryEmbedding = input.query ? await embed(input.query).catch(() => undefined) : undefined;
10
+ const caps = { maxCharsPerItem: input.maxCharsPerItem, maxTotalChars: input.maxTotalChars };
10
11
  switch (input.type) {
11
12
  case 'Fact':
12
13
  return client.recall({
@@ -15,18 +16,20 @@ async function performRecall(deps, input) {
15
16
  tags: input.tags,
16
17
  externalRef: input.externalRef,
17
18
  queryEmbedding,
19
+ ...caps,
18
20
  });
19
21
  case 'Skill':
20
- return client.listSkills({ scope: input.scope, query: input.query, queryEmbedding });
22
+ return client.listSkills({ scope: input.scope, query: input.query, queryEmbedding, ...caps });
21
23
  case 'Scenario':
22
24
  return client.recallScenarios({
23
25
  scope: input.scope,
24
26
  query: input.query,
25
27
  externalRef: input.externalRef,
26
28
  queryEmbedding,
29
+ ...caps,
27
30
  });
28
31
  case 'Wiki':
29
- return client.recallWiki({ scope: input.scope, query: input.query, queryEmbedding });
32
+ return client.recallWiki({ scope: input.scope, query: input.query, queryEmbedding, ...caps });
30
33
  }
31
34
  }
32
35
  exports.performRecall = performRecall;
package/dist/setup.js CHANGED
@@ -131,17 +131,26 @@ function writeUserEnv(path, env) {
131
131
  writeJson(path, settings);
132
132
  }
133
133
  exports.writeUserEnv = writeUserEnv;
134
- // Appended, not replaced: a developer may have their own SessionStart hooks, and
135
- // re-running setup must not stack duplicates of ours.
134
+ // Only our own entries are touched — a developer may have their own SessionStart hooks.
135
+ // "Ours" is the script's identity, not its exact path: setup-dev.sh registers the repo
136
+ // checkout and this installer ~/.claude/memory-hub-hook, so matching the exact string
137
+ // lets both stack copies of the same script. Replaces, keeping any timeout it carried.
136
138
  function registerSessionStartHook(path, hookPath) {
137
139
  const settings = readJson(path);
138
140
  const hooks = (settings.hooks ||= {});
139
141
  const entries = (hooks.SessionStart ||= []);
140
- const already = entries.some((entry) => (entry.hooks || []).some((h) => h.command === hookPath));
141
- if (!already)
142
- entries.push({ hooks: [{ type: 'command', command: hookPath }] });
142
+ const isOurs = (command) => typeof command === 'string' &&
143
+ (command.trim() === hookPath || command.trim().endsWith('memory-hub-hook/session-start.sh'));
144
+ const ours = entries.flatMap((entry) => (entry.hooks || []).filter((h) => isOurs(h.command)));
145
+ const already = ours.length === 1 && ours[0].command === hookPath;
146
+ const kept = { type: 'command', ...ours[0], command: hookPath };
147
+ for (const entry of entries) {
148
+ entry.hooks = (entry.hooks || []).filter((h) => !isOurs(h.command));
149
+ }
150
+ hooks.SessionStart = entries.filter((entry) => entry.hooks.length > 0);
151
+ hooks.SessionStart.push({ hooks: [kept] });
143
152
  writeJson(path, settings);
144
- return already;
153
+ return { already, replaced: already ? 0 : ours.length };
145
154
  }
146
155
  exports.registerSessionStartHook = registerSessionStartHook;
147
156
  function installAssets() {
@@ -260,8 +269,13 @@ async function runSetup(argv = []) {
260
269
  // Code gives it, not from the MCP server's env block.
261
270
  writeUserEnv((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'), env);
262
271
  const { hookPath } = installAssets();
263
- const already = registerSessionStartHook((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'), hookPath);
264
- console.log(` SessionStart hook -> ${hookPath}${already ? ' (already registered)' : ''}`);
272
+ const { already, replaced } = registerSessionStartHook((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'), hookPath);
273
+ const note = already
274
+ ? ' (already registered)'
275
+ : replaced > 0
276
+ ? ` (replaced ${replaced} earlier registration${replaced > 1 ? 's' : ''})`
277
+ : '';
278
+ console.log(` SessionStart hook -> ${hookPath}${note}`);
265
279
  console.log(' skill -> ~/.claude/skills/se-ai-memory-hub/SKILL.md');
266
280
  for (const tool of ['curl', 'jq']) {
267
281
  if ((0, child_process_1.spawnSync)('which', [tool]).status !== 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skedulo/memory-hub-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
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": {