@skedulo/memory-hub-mcp 0.2.5 → 0.2.6

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
@@ -57,6 +57,10 @@ have no equivalent there. Two consequences, both permanent until Desktop grows h
57
57
 
58
58
  ### Install and set up
59
59
 
60
+ For Claude Code, `setup` installs the `memory-hub` plugin from the repo's marketplace when the
61
+ `claude` CLI and your GitHub access allow it, and turns its auto-update on; otherwise, or with
62
+ `--no-plugin`, it installs the hooks and skill directly as described below.
63
+
60
64
  Two commands, no config file to edit. No GitHub access, no git clone, no build step, no npm
61
65
  account:
62
66
 
@@ -86,6 +90,41 @@ Skedulo API token, and the package is useless without one.
86
90
 
87
91
  Re-run `memory-hub-mcp setup` anytime — it keeps a token that's already configured.
88
92
 
93
+ ### Updates
94
+
95
+ `setup` registers the server as `npx -y @skedulo/memory-hub-mcp@latest`, so every Claude start runs
96
+ the newest published version. On start, that server brings the hooks and `SKILL.md` that `setup`
97
+ copied into `~/.claude` up to its own version (never down), so nobody re-runs anything after a
98
+ release. Two exceptions: a release that adds a new kind of hook still needs `memory-hub-mcp setup`
99
+ once, and `setup --no-auto-update` pins the installed binary instead (update it with
100
+ `npm i -g @skedulo/memory-hub-mcp`, then re-run `setup`).
101
+
102
+ The first start after a release fetches the new version, about 1 to 5 seconds with the dependencies
103
+ already in npm's cache. `setup` warms that cache, so nobody's first start pays the ~430 MB cold
104
+ download (about 16 seconds).
105
+
106
+ ### Releasing
107
+
108
+ `main` is the release branch: npm is published from it, and the plugin marketplace follows it. A
109
+ release has three steps:
110
+
111
+ 1. Bump `version` in this `package.json` and in `.claude-plugin/plugin.json` at the repo root to the
112
+ same number (a test fails until they match), and merge that to `dev`.
113
+ 2. Merge `dev` into `main` ("Release dev to main"). Only a new version updates installed plugins, so
114
+ this is what brings plugin users the new hooks and skill, at their next session.
115
+ 3. Publish from `main` straight away, so the hooks don't run ahead of the server for long.
116
+ `@latest` reaches everyone at their next start, so stage it first:
117
+ ```sh
118
+ npm publish --tag next # latest is untouched
119
+ npx -y @skedulo/memory-hub-mcp@next --help # try it
120
+ npm dist-tag add @skedulo/memory-hub-mcp@<version> latest # release it
121
+ ```
122
+
123
+ A hook or skill fix on its own still ships as a patch release.
124
+
125
+ Roll back by pointing `latest` at the previous version:
126
+ `npm dist-tag add @skedulo/memory-hub-mcp@<previous> latest`.
127
+
89
128
  <details>
90
129
  <summary>Configuring by hand instead</summary>
91
130
 
@@ -10,6 +10,10 @@ FUNCTION_URL="${MEMORY_HUB_FUNCTION_URL:-https://dev-api.test.skl.io/function/me
10
10
  TOKEN="${MEMORY_HUB_MCP_TOKEN:-}"
11
11
 
12
12
  if [ -z "$TOKEN" ]; then
13
+ # A plugin install has no setup step of its own, so it says how to add the token.
14
+ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then
15
+ printf '%s\n' '{"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "memory-hub plugin: MEMORY_HUB_MCP_TOKEN is not set, so memory is off this session. Tell the user to run `npx -y @skedulo/memory-hub-mcp setup --code` in a terminal, then restart Claude Code."}}'
16
+ fi
13
17
  exit 0
14
18
  fi
15
19
 
@@ -50,7 +50,7 @@ LOG_FILE="${TMPDIR:-/tmp}/memory-hub-stop-hook.log"
50
50
  {
51
51
  echo "---- $(date -u +%FT%TZ) session=$SESSION_ID ----"
52
52
  MEMORY_HUB_STOP_HOOK_ACTIVE=1 claude -p --resume "$SESSION_ID" \
53
- --allowedTools "mcp__memory-hub__memory_recall,mcp__memory-hub__memory_save,mcp__memory-hub__memory_update" \
53
+ --allowedTools "mcp__memory-hub__memory_recall,mcp__memory-hub__memory_save,mcp__memory-hub__memory_update,mcp__plugin_memory-hub_memory-hub__memory_recall,mcp__plugin_memory-hub_memory-hub__memory_save,mcp__plugin_memory-hub_memory-hub__memory_update" \
54
54
  --permission-prompts none \
55
55
  --model haiku \
56
56
  --no-session-persistence \
@@ -48,10 +48,13 @@ if [ -n "${MEMORY_HUB_EMBED_CMD:-}" ]; then
48
48
  EMBED=("$MEMORY_HUB_EMBED_CMD")
49
49
  elif [ -f "$HOOK_DIR/../memory-hub-mcp/dist/cli.js" ] && command -v node >/dev/null 2>&1; then
50
50
  EMBED=(node "$HOOK_DIR/../memory-hub-mcp/dist/cli.js" embed)
51
+ elif CLI_PATH=$(head -n 1 "$HOME/.claude/memory-hub-hook/cli-path" 2>/dev/null) && [ -f "$CLI_PATH" ] && command -v node >/dev/null 2>&1; then
52
+ EMBED=(node "$CLI_PATH" embed)
51
53
  elif command -v memory-hub-mcp >/dev/null 2>&1; then
52
54
  EMBED=(memory-hub-mcp embed)
53
55
  else
54
- SERVER_CMD=$(jq -r '.mcpServers["memory-hub"].command // empty' "$HOME/.claude.json" 2>/dev/null)
56
+ # A launch with args (npx -y ...) would run `npx embed`, so only a bare binary is usable.
57
+ SERVER_CMD=$(jq -r '.mcpServers["memory-hub"] | select((.args // []) | length == 0) | .command // empty' "$HOME/.claude.json" 2>/dev/null)
55
58
  [ -n "$SERVER_CMD" ] && [ -x "$SERVER_CMD" ] && EMBED=("$SERVER_CMD" embed)
56
59
  fi
57
60
 
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.refreshInstalledAssets = exports.syncInstalledAssets = exports.recordInstall = exports.recordCliPath = exports.compareVersions = exports.packageVersion = exports.installDirs = exports.CLI_PATH_FILE = exports.VERSION_FILE = exports.HOOK_SCRIPTS = void 0;
4
+ const fs_1 = require("fs");
5
+ const os_1 = require("os");
6
+ const path_1 = require("path");
7
+ exports.HOOK_SCRIPTS = ['session-start.sh', 'session-stop.sh', 'user-prompt-submit.sh'];
8
+ exports.VERSION_FILE = '.installed-version';
9
+ // The prompt hook runs `embed` from this path, i.e. the build the host last launched.
10
+ exports.CLI_PATH_FILE = 'cli-path';
11
+ function installDirs(home = (0, os_1.homedir)()) {
12
+ return {
13
+ hookDir: (0, path_1.join)(home, '.claude', 'memory-hub-hook'),
14
+ skillFile: (0, path_1.join)(home, '.claude', 'skills', 'se-ai-memory-hub', 'SKILL.md'),
15
+ };
16
+ }
17
+ exports.installDirs = installDirs;
18
+ function packageVersion(distDir = __dirname) {
19
+ return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(distDir, '..', 'package.json'), 'utf8')).version;
20
+ }
21
+ exports.packageVersion = packageVersion;
22
+ // A prerelease suffix is ignored, so 0.3.0-next.1 counts as 0.3.0.
23
+ function compareVersions(a, b) {
24
+ const parts = (v) => v.split('-')[0].split('.').map((n) => parseInt(n, 10) || 0);
25
+ const [x, y] = [parts(a), parts(b)];
26
+ for (let i = 0; i < Math.max(x.length, y.length); i++) {
27
+ const diff = (x[i] ?? 0) - (y[i] ?? 0);
28
+ if (diff !== 0)
29
+ return Math.sign(diff);
30
+ }
31
+ return 0;
32
+ }
33
+ exports.compareVersions = compareVersions;
34
+ function recordCliPath(hookDir, cliPath) {
35
+ (0, fs_1.mkdirSync)(hookDir, { recursive: true });
36
+ (0, fs_1.writeFileSync)((0, path_1.join)(hookDir, exports.CLI_PATH_FILE), `${cliPath}\n`);
37
+ }
38
+ exports.recordCliPath = recordCliPath;
39
+ function recordInstall(hookDir, version, cliPath) {
40
+ (0, fs_1.writeFileSync)((0, path_1.join)(hookDir, exports.VERSION_FILE), `${version}\n`);
41
+ recordCliPath(hookDir, cliPath);
42
+ }
43
+ exports.recordInstall = recordInstall;
44
+ function syncInstalledAssets(options) {
45
+ const hooks = exports.HOOK_SCRIPTS.map((name) => ({
46
+ src: (0, path_1.join)(options.assetsDir, name),
47
+ dest: (0, path_1.join)(options.hookDir, name),
48
+ executable: true,
49
+ }));
50
+ // Never recreates a removed script: an unregistered copy would never run.
51
+ if (!hooks.some((hook) => (0, fs_1.existsSync)(hook.dest)))
52
+ return { updated: [], skipped: 'not-installed' };
53
+ const marker = (0, path_1.join)(options.hookDir, exports.VERSION_FILE);
54
+ // Never downgrades, so a stale global install cannot undo a newer one.
55
+ const previous = (0, fs_1.existsSync)(marker) ? (0, fs_1.readFileSync)(marker, 'utf8').trim() : '';
56
+ if (previous && compareVersions(options.version, previous) < 0)
57
+ return { updated: [], skipped: 'newer-installed' };
58
+ const files = [...hooks, { src: (0, path_1.join)(options.assetsDir, 'SKILL.md'), dest: options.skillFile, executable: false }];
59
+ const updated = [];
60
+ for (const file of files) {
61
+ if (!(0, fs_1.existsSync)(file.src) || !(0, fs_1.existsSync)(file.dest))
62
+ continue;
63
+ if ((0, fs_1.readFileSync)(file.src).equals((0, fs_1.readFileSync)(file.dest)))
64
+ continue;
65
+ (0, fs_1.copyFileSync)(file.src, file.dest);
66
+ if (file.executable)
67
+ (0, fs_1.chmodSync)(file.dest, 0o755);
68
+ updated.push(file.dest);
69
+ }
70
+ recordInstall(options.hookDir, options.version, options.cliPath);
71
+ return { updated };
72
+ }
73
+ exports.syncInstalledAssets = syncInstalledAssets;
74
+ function refreshInstalledAssets({ distDir = __dirname, home = (0, os_1.homedir)(), log = (line) => console.error(line) } = {}) {
75
+ // A repo checkout runs its hooks in place, so it has no installed copies to refresh.
76
+ if (!distDir.split(path_1.sep).includes('node_modules'))
77
+ return undefined;
78
+ try {
79
+ const version = packageVersion(distDir);
80
+ const { hookDir, skillFile } = installDirs(home);
81
+ const cliPath = (0, path_1.join)(distDir, 'cli.js');
82
+ const result = syncInstalledAssets({ assetsDir: (0, path_1.join)(distDir, '..', 'assets'), hookDir, skillFile, version, cliPath });
83
+ // A plugin install has no copied hooks, but its prompt hook still needs this to embed.
84
+ if (result.skipped === 'not-installed')
85
+ recordCliPath(hookDir, cliPath);
86
+ if (result.updated.length > 0) {
87
+ log(`memory-hub-mcp ${version}: refreshed ${result.updated.length} installed hook/skill file(s)`);
88
+ }
89
+ return result;
90
+ }
91
+ catch (error) {
92
+ log(`memory-hub-mcp: could not refresh installed hooks: ${error instanceof Error ? error.message : String(error)}`);
93
+ return undefined;
94
+ }
95
+ }
96
+ exports.refreshInstalledAssets = refreshInstalledAssets;
package/dist/cli.js CHANGED
@@ -20,9 +20,13 @@ else if (command === 'embed') {
20
20
  else if (command === '--help' || command === '-h') {
21
21
  console.log(`memory-hub-mcp — MCP server for the SE AI Memory Hub
22
22
 
23
- memory-hub-mcp setup log in, then wire up Claude Code (MCP server + SessionStart
24
- hook + skill) and/or Claude Desktop (MCP server), and verify
23
+ memory-hub-mcp setup log in, then wire up Claude Code and/or Claude Desktop, and verify
25
24
  the token. Pass --code, --desktop or --both to skip the prompt.
25
+ For Claude Code it installs the memory-hub plugin with auto-update
26
+ on (needs the claude CLI and GitHub access; --no-plugin installs
27
+ the hooks and skill directly instead). The server runs as
28
+ npx ...@latest, so each start picks up the newest release;
29
+ --no-auto-update pins this install instead.
26
30
  memory-hub-mcp embed print the embedding of the text on stdin (or the arguments) as JSON;
27
31
  used by the UserPromptSubmit hook. Exits non-zero if it cannot.
28
32
  memory-hub-mcp run the MCP server on stdio (how a host launches it)
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ const guide_check_1 = require("./guide-check");
17
17
  const revise_1 = require("./revise");
18
18
  const similar_notice_1 = require("./similar-notice");
19
19
  const session_context_1 = require("./session-context");
20
+ const asset_sync_1 = require("./asset-sync");
20
21
  // Must match the AgentFacts/AgentSkills/AgentWikiPages Tags custom field's Picklist
21
22
  // allowedValues (src/object-model/custom-fields/{AgentFacts,AgentSkills,AgentWikiPages}/*-Tags.custom-field.json)
22
23
  // exactly — the connected function 400s on any value outside this set, with
@@ -255,5 +256,6 @@ server.tool('memory_sessionContext', "Load this developer's saved memory-hub con
255
256
  const context = await (0, session_context_1.buildSessionContext)({ client, currentRepoUid: repoContext.currentRepoUid });
256
257
  return { content: [{ type: 'text', text: JSON.stringify(context) }] };
257
258
  });
259
+ (0, asset_sync_1.refreshInstalledAssets)();
258
260
  const transport = new stdio_js_1.StdioServerTransport();
259
261
  server.connect(transport);
package/dist/setup.js CHANGED
@@ -1,17 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runSetup = exports.registerPromptHook = exports.registerSessionStartHook = exports.writeUserEnv = exports.writeDesktopConfig = exports.writeMcpServer = exports.functionUrl = exports.desktopConfigPath = void 0;
3
+ exports.runSetup = exports.registerPromptHook = exports.registerSessionStartHook = exports.removeMcpServer = exports.removeCopiedAssets = exports.unregisterHooks = exports.installPlugin = exports.enableMarketplaceAutoUpdate = exports.writeUserEnv = exports.writeDesktopConfig = exports.writeMcpServer = exports.functionUrl = exports.desktopConfigPath = exports.mcpLaunch = exports.pluginInstalled = exports.PLUGIN_ID = exports.MARKETPLACE_REF = exports.MARKETPLACE_REPO = exports.MARKETPLACE_NAME = exports.launchPath = exports.PACKAGE_SPEC = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const fs_1 = require("fs");
6
6
  const os_1 = require("os");
7
7
  const path_1 = require("path");
8
8
  const readline_1 = require("readline");
9
+ const asset_sync_1 = require("./asset-sync");
9
10
  const DEFAULT_API_HOST = 'dev-api.test.skl.io';
10
11
  const DEFAULT_TENANT = 'memory-hub';
11
12
  const SKED_CONFIG = (0, path_1.join)((0, os_1.homedir)(), '.config', 'sked', 'config.json');
12
13
  // Shipped in the package (see scripts/copy-assets.sh) so a teammate with no repo
13
14
  // checkout still gets the hook and skill that scripts/setup-dev.sh installs.
14
15
  const ASSETS = (0, path_1.join)(__dirname, '..', 'assets');
16
+ exports.PACKAGE_SPEC = '@skedulo/memory-hub-mcp@latest';
17
+ // Claude Desktop starts servers with a bare PATH, and npx and our bin both run `#!/usr/bin/env node`.
18
+ function launchPath(execPath, currentPath = process.env.PATH || '', sep = path_1.delimiter) {
19
+ return [...new Set([(0, path_1.dirname)(execPath), ...currentPath.split(sep).filter(Boolean)])].join(sep);
20
+ }
21
+ exports.launchPath = launchPath;
22
+ exports.MARKETPLACE_NAME = 'se-ai-memory-hub';
23
+ exports.MARKETPLACE_REPO = 'Skedulo/se-ai-memory-hub';
24
+ // npm releases ship from dev, and plugin.json's pinned version gates the update, so hooks move with the server.
25
+ exports.MARKETPLACE_REF = 'dev';
26
+ exports.PLUGIN_ID = `memory-hub@${exports.MARKETPLACE_NAME}`;
27
+ function pluginInstalled(path = (0, path_1.join)((0, os_1.homedir)(), '.claude', 'plugins', 'installed_plugins.json')) {
28
+ return Object.prototype.hasOwnProperty.call(readJson(path).plugins || {}, exports.PLUGIN_ID);
29
+ }
30
+ exports.pluginInstalled = pluginInstalled;
31
+ // Hosts don't launch MCP servers from a login shell, so the command must be an absolute path.
32
+ function mcpLaunch(options) {
33
+ if (!options.autoUpdate)
34
+ return { command: options.binPath, args: [] };
35
+ const npx = (0, path_1.join)((0, path_1.dirname)(options.execPath), 'npx');
36
+ const command = options.os !== 'win32' && (options.exists ?? fs_1.existsSync)(npx) ? npx : 'npx';
37
+ return { command, args: ['-y', exports.PACKAGE_SPEC] };
38
+ }
39
+ exports.mcpLaunch = mcpLaunch;
15
40
  // Claude Desktop's config lives in the OS app-data dir, not the repo — a teammate
16
41
  // installing from npm has no repo, so this is the only file setup touches for Desktop.
17
42
  function desktopConfigPath() {
@@ -108,14 +133,14 @@ function functionUrl(apiBase) {
108
133
  exports.functionUrl = functionUrl;
109
134
  // Merge, never replace: the file almost always holds other MCP servers, and a
110
135
  // teammate may have deliberately pointed MEMORY_HUB_FUNCTION_URL somewhere else.
111
- function writeMcpServer(path, command, env) {
136
+ function writeMcpServer(path, command, env, args) {
112
137
  const config = readJson(path);
113
138
  const servers = (config.mcpServers ||= {});
114
139
  const existing = servers['memory-hub'] || {};
115
140
  servers['memory-hub'] = {
116
141
  ...existing,
117
142
  command,
118
- args: existing.args || [],
143
+ args: args ?? existing.args ?? [],
119
144
  env: { ...(existing.env || {}), ...env },
120
145
  };
121
146
  writeJson(path, config);
@@ -152,6 +177,102 @@ function registerHook(path, event, hookPath, script, timeout) {
152
177
  writeJson(path, settings);
153
178
  return { already, replaced: already ? 0 : ours.length };
154
179
  }
180
+ // Third-party marketplaces don't auto-update unless this documented settings key says so.
181
+ function enableMarketplaceAutoUpdate(path) {
182
+ const settings = readJson(path);
183
+ const known = (settings.extraKnownMarketplaces ||= {});
184
+ const entry = known[exports.MARKETPLACE_NAME] || {};
185
+ known[exports.MARKETPLACE_NAME] = {
186
+ ...entry,
187
+ source: entry.source || { source: 'github', repo: exports.MARKETPLACE_REPO, ref: exports.MARKETPLACE_REF },
188
+ autoUpdate: true,
189
+ };
190
+ writeJson(path, settings);
191
+ }
192
+ exports.enableMarketplaceAutoUpdate = enableMarketplaceAutoUpdate;
193
+ function installPlugin(run, settingsPath, installedPath) {
194
+ const lastLine = (output) => output.trim().split('\n').pop() || 'no output';
195
+ const added = run(['plugin', 'marketplace', 'add', `${exports.MARKETPLACE_REPO}#${exports.MARKETPLACE_REF}`]);
196
+ if (added.status !== 0)
197
+ return { ok: false, reason: lastLine(added.output) };
198
+ enableMarketplaceAutoUpdate(settingsPath);
199
+ const installed = run(['plugin', 'install', exports.PLUGIN_ID]);
200
+ if (installed.status !== 0)
201
+ return { ok: false, reason: lastLine(installed.output) };
202
+ return pluginInstalled(installedPath) ? { ok: true } : { ok: false, reason: 'claude reported success but did not list the plugin' };
203
+ }
204
+ exports.installPlugin = installPlugin;
205
+ // Without repo access git would otherwise wait on a password prompt or an SSH host-key question.
206
+ function claudeRunner() {
207
+ if ((0, child_process_1.spawnSync)('which', ['claude']).status !== 0)
208
+ return undefined;
209
+ return (args) => {
210
+ const result = (0, child_process_1.spawnSync)('claude', args, {
211
+ encoding: 'utf8',
212
+ timeout: 180000,
213
+ env: {
214
+ ...process.env,
215
+ GIT_TERMINAL_PROMPT: '0',
216
+ GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND || 'ssh -o BatchMode=yes',
217
+ },
218
+ });
219
+ return { status: result.status, output: `${result.stdout || ''}${result.stderr || ''}` };
220
+ };
221
+ }
222
+ // The plugin brings its own hooks, so setup's copies would run every hook twice.
223
+ function unregisterHooks(path) {
224
+ const settings = readJson(path);
225
+ let removed = 0;
226
+ for (const [event, script] of [['SessionStart', 'session-start.sh'], ['UserPromptSubmit', 'user-prompt-submit.sh']]) {
227
+ const entries = settings.hooks?.[event];
228
+ if (!Array.isArray(entries))
229
+ continue;
230
+ for (const entry of entries) {
231
+ const before = (entry.hooks || []).length;
232
+ entry.hooks = (entry.hooks || []).filter((h) => !(typeof h.command === 'string' && h.command.trim().endsWith(`memory-hub-hook/${script}`)));
233
+ removed += before - entry.hooks.length;
234
+ }
235
+ settings.hooks[event] = entries.filter((entry) => entry.hooks.length > 0);
236
+ }
237
+ if (removed > 0)
238
+ writeJson(path, settings);
239
+ return removed;
240
+ }
241
+ exports.unregisterHooks = unregisterHooks;
242
+ // Under the plugin a copied SKILL.md lists the skill twice. state/ and cli-path stay: the plugin's prompt hook uses them.
243
+ function removeCopiedAssets(settingsPath, home = (0, os_1.homedir)()) {
244
+ const { hookDir, skillFile } = (0, asset_sync_1.installDirs)(home);
245
+ const referenced = JSON.stringify(readJson(settingsPath).hooks || {});
246
+ // By suffix, so a hook written as ~/... or $HOME/... still protects its copy.
247
+ const removed = [];
248
+ const remove = (path) => {
249
+ if (!(0, fs_1.existsSync)(path))
250
+ return;
251
+ (0, fs_1.unlinkSync)(path);
252
+ removed.push(path);
253
+ };
254
+ remove(skillFile);
255
+ if ((0, fs_1.existsSync)((0, path_1.dirname)(skillFile)) && (0, fs_1.readdirSync)((0, path_1.dirname)(skillFile)).length === 0)
256
+ (0, fs_1.rmdirSync)((0, path_1.dirname)(skillFile));
257
+ for (const script of asset_sync_1.HOOK_SCRIPTS) {
258
+ const path = (0, path_1.join)(hookDir, script);
259
+ if (!referenced.includes(`memory-hub-hook/${script}`))
260
+ remove(path);
261
+ }
262
+ if (!asset_sync_1.HOOK_SCRIPTS.some((script) => (0, fs_1.existsSync)((0, path_1.join)(hookDir, script))))
263
+ remove((0, path_1.join)(hookDir, asset_sync_1.VERSION_FILE));
264
+ return removed;
265
+ }
266
+ exports.removeCopiedAssets = removeCopiedAssets;
267
+ function removeMcpServer(path) {
268
+ const config = readJson(path);
269
+ if (!config.mcpServers?.['memory-hub'])
270
+ return false;
271
+ delete config.mcpServers['memory-hub'];
272
+ writeJson(path, config);
273
+ return true;
274
+ }
275
+ exports.removeMcpServer = removeMcpServer;
155
276
  function registerSessionStartHook(path, hookPath) {
156
277
  return registerHook(path, 'SessionStart', hookPath, 'session-start.sh');
157
278
  }
@@ -162,16 +283,16 @@ function registerPromptHook(path, hookPath) {
162
283
  }
163
284
  exports.registerPromptHook = registerPromptHook;
164
285
  function installAssets() {
165
- const hookDir = (0, path_1.join)((0, os_1.homedir)(), '.claude', 'memory-hub-hook');
166
- const skillDir = (0, path_1.join)((0, os_1.homedir)(), '.claude', 'skills', 'se-ai-memory-hub');
286
+ const { hookDir, skillFile } = (0, asset_sync_1.installDirs)();
167
287
  (0, fs_1.mkdirSync)(hookDir, { recursive: true });
168
- (0, fs_1.mkdirSync)(skillDir, { recursive: true });
288
+ (0, fs_1.mkdirSync)((0, path_1.dirname)(skillFile), { recursive: true });
169
289
  for (const name of ['session-start.sh', 'session-stop.sh', 'user-prompt-submit.sh']) {
170
290
  const dest = (0, path_1.join)(hookDir, name);
171
291
  (0, fs_1.copyFileSync)((0, path_1.join)(ASSETS, name), dest);
172
292
  (0, fs_1.chmodSync)(dest, 0o755);
173
293
  }
174
- (0, fs_1.copyFileSync)((0, path_1.join)(ASSETS, 'SKILL.md'), (0, path_1.join)(skillDir, 'SKILL.md'));
294
+ (0, fs_1.copyFileSync)((0, path_1.join)(ASSETS, 'SKILL.md'), skillFile);
295
+ (0, asset_sync_1.recordInstall)(hookDir, (0, asset_sync_1.packageVersion)(), (0, path_1.join)(__dirname, 'cli.js'));
175
296
  return { hookPath: (0, path_1.join)(hookDir, 'session-start.sh'), promptHookPath: (0, path_1.join)(hookDir, 'user-prompt-submit.sh') };
176
297
  }
177
298
  // A wrong token does not make the server fail loudly — every recall degrades to
@@ -195,6 +316,11 @@ async function verify(url, token) {
195
316
  console.log(` couldn't reach ${url} — check your network, not necessarily the token`);
196
317
  }
197
318
  }
319
+ // The first npx run downloads ~430 MB of dependencies; doing it here keeps the host's first start fast.
320
+ function warmLaunch(launch) {
321
+ const result = (0, child_process_1.spawnSync)(launch.command, [...launch.args, '--help'], { stdio: 'ignore', timeout: 300000 });
322
+ return result.status === 0;
323
+ }
198
324
  async function chooseHosts() {
199
325
  console.log(' Which host do you use?');
200
326
  console.log(' 1) Claude Code (MCP server + startup hook + skill)');
@@ -264,15 +390,66 @@ async function runSetup(argv = []) {
264
390
  token = credentials.token;
265
391
  }
266
392
  const url = credentials?.apiBase ? functionUrl(credentials.apiBase) : prior.url || functionUrl();
267
- // The absolute path to this installed binary: neither host launches MCP servers
268
- // from a login shell, so a bare command name on the user's PATH won't resolve.
269
- const command = (0, path_1.resolve)(process.argv[1]);
393
+ const autoUpdate = !argv.includes('--no-auto-update');
394
+ const launch = mcpLaunch({ autoUpdate, binPath: (0, path_1.resolve)(process.argv[1]), execPath: process.execPath, os: (0, os_1.platform)() });
395
+ const shown = [launch.command, ...launch.args].join(' ');
270
396
  const env = { MEMORY_HUB_MCP_TOKEN: token, MEMORY_HUB_FUNCTION_URL: url };
271
- if (hosts.includes('code')) {
397
+ const serverEnv = { ...env, PATH: launchPath(process.execPath) };
398
+ console.log();
399
+ console.log('==> Updates');
400
+ if (autoUpdate) {
401
+ console.log(` each start runs the newest published version (${exports.PACKAGE_SPEC}), and refreshes`);
402
+ console.log(' any hooks and skill setup copied to match. --no-auto-update pins this install instead.');
403
+ console.log(" fetching it into npm's cache now, so the first start is fast...");
404
+ if (!warmLaunch(launch)) {
405
+ console.log(" warning: couldn't fetch it. The first start needs the network and may be slow;");
406
+ console.log(' re-run with --no-auto-update if this machine is often offline.');
407
+ }
408
+ }
409
+ else {
410
+ console.log(' pinned to this install. Update with `npm i -g @skedulo/memory-hub-mcp` and re-run setup.');
411
+ }
412
+ const settingsPath = (0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json');
413
+ let plugin = hosts.includes('code') && pluginInstalled();
414
+ if (hosts.includes('code') && !plugin && !argv.includes('--no-plugin')) {
415
+ console.log();
416
+ console.log('==> Claude Code plugin');
417
+ const run = claudeRunner();
418
+ if (!run) {
419
+ console.log(' the `claude` CLI is not on PATH, so the hooks and skill are installed directly instead.');
420
+ }
421
+ else {
422
+ console.log(` installing ${exports.PLUGIN_ID} from ${exports.MARKETPLACE_REPO}#${exports.MARKETPLACE_REF} (uses your GitHub access)...`);
423
+ const result = installPlugin(run, settingsPath);
424
+ plugin = result.ok;
425
+ console.log(result.ok
426
+ ? ' installed, with auto-update on: skill and hook changes arrive with each new session.'
427
+ : ` couldn't install it (${result.reason}), so the hooks and skill are installed directly instead.`);
428
+ }
429
+ }
430
+ if (plugin) {
431
+ console.log();
432
+ console.log('==> Claude Code');
433
+ console.log(` the ${exports.PLUGIN_ID} plugin brings the MCP server, hooks and skill, so setup only`);
434
+ console.log(' stores your token for them, and keeps the plugin on auto-update.');
435
+ enableMarketplaceAutoUpdate(settingsPath);
436
+ writeUserEnv(settingsPath, env);
437
+ const hooks = unregisterHooks(settingsPath);
438
+ const server = removeMcpServer((0, path_1.join)((0, os_1.homedir)(), '.claude.json'));
439
+ const copies = removeCopiedAssets(settingsPath);
440
+ if (hooks > 0 || server) {
441
+ const parts = [hooks > 0 ? `${hooks} hook registration${hooks > 1 ? 's' : ''}` : '', server ? 'the ~/.claude.json MCP server' : ''];
442
+ console.log(` removed ${parts.filter(Boolean).join(' and ')} that duplicated the plugin (.bak kept)`);
443
+ }
444
+ if (copies.length > 0) {
445
+ console.log(` removed ${copies.length} copied skill/hook file${copies.length > 1 ? 's' : ''} the plugin replaces`);
446
+ }
447
+ }
448
+ else if (hosts.includes('code')) {
272
449
  console.log();
273
450
  console.log('==> Claude Code');
274
- writeMcpServer((0, path_1.join)((0, os_1.homedir)(), '.claude.json'), command, env);
275
- console.log(` MCP server -> ${command}`);
451
+ writeMcpServer((0, path_1.join)((0, os_1.homedir)(), '.claude.json'), launch.command, serverEnv, launch.args);
452
+ console.log(` MCP server -> ${shown}`);
276
453
  // The hook is a shell script, so it reads the token from the environment Claude
277
454
  // Code gives it, not from the MCP server's env block.
278
455
  writeUserEnv((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'), env);
@@ -297,8 +474,8 @@ async function runSetup(argv = []) {
297
474
  console.log();
298
475
  console.log('==> Claude Desktop');
299
476
  const path = desktopConfigPath();
300
- writeMcpServer(path, command, env);
301
- console.log(` MCP server -> ${command}`);
477
+ writeMcpServer(path, launch.command, serverEnv, launch.args);
478
+ console.log(` MCP server -> ${shown}`);
302
479
  console.log(` config -> ${path}`);
303
480
  console.log(' no hook: Desktop has no hook system, so startup injection and');
304
481
  console.log(' end-of-session auto-save are Claude Code only.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skedulo/memory-hub-mcp",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
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": {