@kolivri/memoreal-mcp 1.0.2 → 1.1.0

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/src/server.mjs CHANGED
@@ -19,6 +19,17 @@ import {
19
19
  runCliSetupWizard,
20
20
  sanitizeClientName,
21
21
  } from './wizard.mjs';
22
+ import {
23
+ bootstrapProjectContext,
24
+ CODE_INTEL_TOOLS,
25
+ hasProjectMarkers,
26
+ runLocalCodeIntelFallback,
27
+ } from './bootstrap.mjs';
28
+ import {
29
+ resolveProjectNamespaceInfo,
30
+ deriveNamespaceCrossOs,
31
+ sanitizeLogicalNamespace,
32
+ } from '../bin/memoreal-ns.mjs';
22
33
 
23
34
  const PACKAGE_VERSION = (() => {
24
35
  try {
@@ -29,7 +40,7 @@ const PACKAGE_VERSION = (() => {
29
40
  } catch {
30
41
  // Fallback below if package.json cannot be read
31
42
  }
32
- return '1.0.1';
43
+ return '1.1.0';
33
44
  })();
34
45
 
35
46
  export function createMemorealMcpService(options = {}) {
@@ -49,12 +60,23 @@ export function createMemorealMcpService(options = {}) {
49
60
 
50
61
  const getApiUrl = () => resolveEffectiveApiUrl('', getConfigOpts());
51
62
 
52
- const defaultNamespace = (
63
+ const rawConfiguredNs = (
53
64
  options.namespace ??
54
65
  env.MEMOREAL_NAMESPACE ??
55
66
  env.MEMORIA_NAMESPACE ??
56
- 'default'
57
- ).trim() || 'default';
67
+ ''
68
+ ).trim();
69
+ const explicitConfiguredNs =
70
+ rawConfiguredNs && rawConfiguredNs !== 'default' ? rawConfiguredNs : '';
71
+ const cwdNsInfo = resolveProjectNamespaceInfo(
72
+ options.projectDir || process.cwd(),
73
+ explicitConfiguredNs || undefined,
74
+ env
75
+ );
76
+ const defaultNamespace =
77
+ explicitConfiguredNs ||
78
+ (cwdNsInfo.isCodeProject ? cwdNsInfo.namespace : 'default') ||
79
+ 'default';
58
80
  const fetchImpl = options.fetchImpl || globalThis.fetch;
59
81
  const requestTimeoutMs = Number(
60
82
  options.requestTimeoutMs ??
@@ -74,18 +96,33 @@ export function createMemorealMcpService(options = {}) {
74
96
  return key;
75
97
  }
76
98
 
77
- async function forwardCloudRpc(method, params, overrideKey) {
99
+ async function forwardCloudRpc(method, params, overrideKey, migrationInfo = cwdNsInfo) {
78
100
  const apiKey = requireApiKey(overrideKey);
79
101
  const apiUrl = getApiUrl();
80
102
  const endpoint = apiUrl.endsWith('/v1/mcp') ? apiUrl : `${apiUrl}/v1/mcp`;
81
103
 
104
+ const reqHeaders = {
105
+ 'content-type': 'application/json',
106
+ accept: 'application/json',
107
+ authorization: `Bearer ${apiKey}`,
108
+ 'x-memoreal-client-version': PACKAGE_VERSION,
109
+ 'user-agent': `@kolivri/memoreal-mcp/${PACKAGE_VERSION}`,
110
+ };
111
+
112
+ if (
113
+ migrationInfo?.isCodeProject &&
114
+ migrationInfo?.legacyNamespace &&
115
+ migrationInfo.legacyNamespace !== migrationInfo.namespace &&
116
+ (!params?.arguments?.namespace || params.arguments.namespace === migrationInfo.namespace)
117
+ ) {
118
+ reqHeaders['x-memoreal-legacy-namespace'] = migrationInfo.legacyNamespace;
119
+ reqHeaders['x-memoreal-code-project'] = '1';
120
+ reqHeaders['x-memoreal-namespace'] = migrationInfo.namespace;
121
+ }
122
+
82
123
  const response = await fetchImpl(endpoint, {
83
124
  method: 'POST',
84
- headers: {
85
- 'content-type': 'application/json',
86
- accept: 'application/json',
87
- authorization: `Bearer ${apiKey}`,
88
- },
125
+ headers: reqHeaders,
89
126
  body: JSON.stringify({
90
127
  jsonrpc: '2.0',
91
128
  id: `mem_${Date.now()}`,
@@ -155,6 +192,41 @@ export function createMemorealMcpService(options = {}) {
155
192
  return await wizard.handleConnectAccount(args);
156
193
  }
157
194
 
195
+ if (name === 'bootstrap_project') {
196
+ const apiKey = requireApiKey(args.apiKey);
197
+ const bDir = args.project_dir || args.path || options.projectDir || process.cwd();
198
+ const bNsInfo = resolveProjectNamespaceInfo(bDir, explicitConfiguredNs || undefined, env);
199
+ const rawBNs = typeof args.namespace === 'string' ? args.namespace.trim() : '';
200
+ const remapBootstrapNs =
201
+ args.namespace === undefined ||
202
+ rawBNs === '' ||
203
+ rawBNs === 'default' ||
204
+ (!explicitConfiguredNs &&
205
+ bNsInfo.isCodeProject &&
206
+ (rawBNs === bNsInfo.legacyNamespace ||
207
+ rawBNs === deriveNamespaceCrossOs(bDir) ||
208
+ sanitizeLogicalNamespace(rawBNs) === sanitizeLogicalNamespace(bNsInfo.legacyNamespace || '')));
209
+ const res = await bootstrapProjectContext({
210
+ projectDir: bDir,
211
+ apiUrl: getApiUrl(),
212
+ apiKey,
213
+ namespace: remapBootstrapNs ? (explicitConfiguredNs || undefined) : rawBNs,
214
+ fetchImpl,
215
+ writeIdeRules: Boolean(args.write_ide_rules),
216
+ });
217
+ return {
218
+ bootstrapped: Boolean(res?.success),
219
+ imported_files: res?.docsImported || [],
220
+ symbols_indexed: res?.symbolsIndexed || 0,
221
+ ...res,
222
+ };
223
+ }
224
+
225
+ const activeDir = args.project_dir || args.path || options.projectDir || process.cwd();
226
+ const activeNsInfo = (args.project_dir || args.path)
227
+ ? resolveProjectNamespaceInfo(activeDir, explicitConfiguredNs || undefined, env)
228
+ : cwdNsInfo;
229
+
158
230
  const normalizedArgs = { ...args };
159
231
  if (name === 'explain_code') {
160
232
  const targetStr = typeof args.target === 'string' ? args.target.trim() : '';
@@ -167,29 +239,144 @@ export function createMemorealMcpService(options = {}) {
167
239
  normalizedArgs.symbol = sym;
168
240
  }
169
241
 
242
+ const rawCallerNs = typeof normalizedArgs.namespace === 'string' ? normalizedArgs.namespace.trim() : '';
243
+ const shouldRemapNs =
244
+ name !== 'health' &&
245
+ (normalizedArgs.namespace === undefined ||
246
+ rawCallerNs === '' ||
247
+ rawCallerNs === 'default' ||
248
+ (!explicitConfiguredNs &&
249
+ activeNsInfo.isCodeProject &&
250
+ (rawCallerNs === activeNsInfo.legacyNamespace ||
251
+ rawCallerNs === deriveNamespaceCrossOs(activeDir) ||
252
+ sanitizeLogicalNamespace(rawCallerNs) === sanitizeLogicalNamespace(activeNsInfo.legacyNamespace || ''))));
253
+
170
254
  const enrichedArgs = {
171
255
  ...normalizedArgs,
172
- ...(normalizedArgs.namespace === undefined && name !== 'health' ? { namespace: defaultNamespace } : {}),
256
+ ...(shouldRemapNs
257
+ ? { namespace: activeNsInfo.isCodeProject ? activeNsInfo.namespace : defaultNamespace }
258
+ : {}),
173
259
  };
174
260
 
175
- const result = await forwardCloudRpc(
176
- 'tools/call',
177
- {
178
- name,
179
- arguments: enrichedArgs,
180
- },
181
- args.apiKey
182
- );
261
+ let result;
262
+ if (CODE_INTEL_TOOLS.includes(name)) {
263
+ const localProjectDir =
264
+ args.project_dir || args.path || options.projectDir || process.cwd();
265
+ const localRepoExists = hasProjectMarkers(localProjectDir) || fs.existsSync(localProjectDir);
183
266
 
267
+ try {
268
+ result = await forwardCloudRpc(
269
+ 'tools/call',
270
+ {
271
+ name,
272
+ arguments: enrichedArgs,
273
+ },
274
+ args.apiKey,
275
+ activeNsInfo
276
+ );
277
+ } catch (err) {
278
+ const msg = String(err?.message || err);
279
+ const isAuthError =
280
+ msg.includes('Missing Memoreal API key') ||
281
+ msg.includes('(401)') ||
282
+ msg.includes('401') ||
283
+ msg.includes('403');
284
+ if (isAuthError || !localRepoExists) {
285
+ throw err;
286
+ }
287
+ result = { total_candidates: 0 };
288
+ }
289
+ } else {
290
+ result = await forwardCloudRpc(
291
+ 'tools/call',
292
+ {
293
+ name,
294
+ arguments: enrichedArgs,
295
+ },
296
+ args.apiKey,
297
+ activeNsInfo
298
+ );
299
+ }
300
+
301
+ let data = result;
184
302
  const textBlock = result?.content?.[0]?.text;
185
303
  if (textBlock) {
186
304
  try {
187
- return JSON.parse(textBlock);
305
+ data = JSON.parse(textBlock);
188
306
  } catch {
189
- return { raw: textBlock };
307
+ data = { raw: textBlock };
190
308
  }
191
309
  }
192
- return result;
310
+
311
+ if (CODE_INTEL_TOOLS.includes(name)) {
312
+ const localProjectDir =
313
+ args.project_dir || args.path || options.projectDir || process.cwd();
314
+
315
+ const hasZeroCandidates =
316
+ data?.total_candidates === 0 ||
317
+ data?.total_matches === 0 ||
318
+ data?.count === 0 ||
319
+ data?.gap_count === 0 ||
320
+ data?.total_nodes === 0 ||
321
+ (Array.isArray(data?.results) && data.results.length === 0) ||
322
+ (Array.isArray(data?.matches) && data.matches.length === 0) ||
323
+ (Array.isArray(data?.files) && data.files.length === 0) ||
324
+ (Array.isArray(data?.references) && data.references.length === 0) ||
325
+ (Array.isArray(data?.affected) && data.affected.length === 0) ||
326
+ (Array.isArray(data?.candidates) && data.candidates.length === 0) ||
327
+ (Array.isArray(data?.implementors) && data.implementors.length === 0) ||
328
+ (Array.isArray(data?.gaps) && data.gaps.length === 0) ||
329
+ (Array.isArray(data?.risks) && data.risks.length === 0) ||
330
+ (Array.isArray(data?.effects) && data.effects.length === 0) ||
331
+ (Array.isArray(data?.causes) && data.causes.length === 0) ||
332
+ (Array.isArray(data?.chain) && data.chain.length === 0) ||
333
+ (Array.isArray(data?.worklist) && data.worklist.length === 0);
334
+
335
+ const isUnindexedLocalRepo = hasProjectMarkers(localProjectDir) || fs.existsSync(localProjectDir);
336
+
337
+ if (Boolean(args.project_dir || args.path) || (hasZeroCandidates && isUnindexedLocalRepo)) {
338
+ const fallback = runLocalCodeIntelFallback(name, enrichedArgs, localProjectDir);
339
+ const enriched = (data && typeof data === 'object') ? { ...data, ...fallback } : fallback;
340
+ if ((!Array.isArray(enriched.files) || enriched.files.length === 0) && (Array.isArray(fallback?.files) || Array.isArray(fallback?.matches))) {
341
+ enriched.files = (Array.isArray(fallback?.files) && fallback.files.length > 0) ? fallback.files : fallback.matches;
342
+ }
343
+ if ((!Array.isArray(enriched.references) || enriched.references.length === 0) && Array.isArray(fallback?.references)) {
344
+ enriched.references = fallback.references;
345
+ }
346
+ if ((!Array.isArray(enriched.affected) || enriched.affected.length === 0) && (Array.isArray(fallback?.affected) || Array.isArray(fallback?.direct_callers))) {
347
+ enriched.affected = (Array.isArray(fallback?.affected) && fallback.affected.length > 0) ? fallback.affected : fallback.direct_callers;
348
+ }
349
+ if ((!Array.isArray(enriched.candidates) || enriched.candidates.length === 0) && (Array.isArray(fallback?.candidates) || Array.isArray(fallback?.unused_symbols))) {
350
+ enriched.candidates = (Array.isArray(fallback?.candidates) && fallback.candidates.length > 0) ? fallback.candidates : fallback.unused_symbols;
351
+ }
352
+ if ((!Array.isArray(enriched.gaps) || enriched.gaps.length === 0) && (Array.isArray(fallback?.gaps) || Array.isArray(fallback?.uncovered_files))) {
353
+ enriched.gaps = (Array.isArray(fallback?.gaps) && fallback.gaps.length > 0)
354
+ ? fallback.gaps
355
+ : fallback.uncovered_files.map((f) => ({ file: f }));
356
+ }
357
+ if ((!Array.isArray(enriched.effects) || enriched.effects.length === 0) && (Array.isArray(fallback?.effects) || Array.isArray(fallback?.downstream_symbols))) {
358
+ enriched.effects = (Array.isArray(fallback?.effects) && fallback.effects.length > 0) ? fallback.effects : fallback.downstream_symbols;
359
+ }
360
+ if ((!Array.isArray(enriched.causes) || enriched.causes.length === 0) && (Array.isArray(fallback?.causes) || Array.isArray(fallback?.potential_causes))) {
361
+ enriched.causes = (Array.isArray(fallback?.causes) && fallback.causes.length > 0) ? fallback.causes : fallback.potential_causes;
362
+ }
363
+ if ((!Array.isArray(enriched.chain) || enriched.chain.length === 0) && (Array.isArray(fallback?.chain) || Array.isArray(fallback?.history))) {
364
+ enriched.chain = (Array.isArray(fallback?.chain) && fallback.chain.length > 0) ? fallback.chain : fallback.history;
365
+ }
366
+ if ((!Array.isArray(enriched.worklist) || enriched.worklist.length === 0) && Array.isArray(fallback?.worklist)) {
367
+ enriched.worklist = fallback.worklist;
368
+ }
369
+ if ((!Array.isArray(enriched.risks) || enriched.risks.length === 0) && Array.isArray(fallback?.risks)) {
370
+ enriched.risks = fallback.risks;
371
+ }
372
+ if (!enriched.explanation && fallback?.summary) {
373
+ enriched.explanation = fallback.summary;
374
+ }
375
+ return enriched;
376
+ }
377
+ }
378
+
379
+ return data;
193
380
  }
194
381
 
195
382
  async function readResource(uri) {
@@ -197,7 +384,7 @@ export function createMemorealMcpService(options = {}) {
197
384
  throw new Error(`Unknown resource URI: "${uri}"`);
198
385
  }
199
386
 
200
- const result = await forwardCloudRpc('resources/read', { uri });
387
+ const result = await forwardCloudRpc('resources/read', { uri }, undefined, cwdNsInfo);
201
388
  if (Array.isArray(result?.contents) && result.contents[0]) {
202
389
  return result.contents[0];
203
390
  }
@@ -548,6 +735,34 @@ const isDirectExecution = (() => {
548
735
 
549
736
  if (isDirectExecution) {
550
737
  const subCmd = (process.argv[2] || '').trim().toLowerCase();
738
+ if (subCmd === '--help' || subCmd === '-h' || subCmd === 'help') {
739
+ console.log(`Memoreal Cloud MCP Server & Setup CLI (v${PACKAGE_VERSION})
740
+
741
+ Usage:
742
+ memoreal-mcp [command] [options]
743
+ node ./src/server.mjs [command] [options]
744
+
745
+ Commands:
746
+ setup, init, login Run interactive or headless CLI onboarding wizard
747
+ (no command) Start stdio Model Context Protocol (MCP) server
748
+
749
+ Options:
750
+ --browser Open browser for 1-click OAuth device authorization
751
+ --no-browser Display URL and device code without opening browser
752
+ --no-bootstrap Skip automatic repo cold-start memory indexing
753
+ --key <api-key> Authenticate with an existing Memoreal API key
754
+ --tool <slug> Configure specific IDE (cursor, opencode, claude-code, codex, vscode, windsurf)
755
+ --api-url <url> Custom Memoreal Cloud API URL (defaults to https://memoreal.kolivri.com)
756
+ --version, -v Show version number
757
+ --help, -h Show this help message`);
758
+ process.exit(0);
759
+ }
760
+
761
+ if (subCmd === '--version' || subCmd === '-v') {
762
+ console.log(PACKAGE_VERSION);
763
+ process.exit(0);
764
+ }
765
+
551
766
  if (subCmd === 'setup' || subCmd === 'login' || subCmd === 'init') {
552
767
  runCliSetupWizard({ argv: process.argv.slice(2) })
553
768
  .then((res) => {
package/src/wizard.mjs CHANGED
@@ -7,18 +7,35 @@ import {
7
7
  resolveEffectiveApiUrl,
8
8
  saveMemorealConfig,
9
9
  configureDetectedIdes,
10
+ provisionMemorealAgentAssets,
10
11
  } from './config-store.mjs';
12
+ import {
13
+ bootstrapProjectContext,
14
+ hasProjectMarkers,
15
+ } from './bootstrap.mjs';
11
16
 
12
17
  export function normalizeClientToolSlug(rawName) {
13
18
  if (typeof rawName !== 'string') return '';
14
19
  const trimmed = rawName.trim();
15
20
  if (/opencode/i.test(trimmed)) return 'opencode';
16
21
  if (/cursor/i.test(trimmed)) return 'cursor';
22
+ if (/claude[-_\s]*desktop/i.test(trimmed)) return 'claude-desktop';
17
23
  if (/claude[-_\s]*code|claude[-_\s]*cli|^claude$/i.test(trimmed)) return 'claude-code';
18
24
  if (/visual\s*studio\s*code|\bvscode\b|vs[-_\s]*code|copilot/i.test(trimmed)) return 'vscode';
19
25
  if (/windsurf|codeium/i.test(trimmed)) return 'windsurf';
20
26
  if (/\bzed\b/i.test(trimmed)) return 'zed';
21
- if (/\bcodex\b/i.test(trimmed)) return 'codex';
27
+ if (/\b(?:openai[-_\s]*)?codex\b/i.test(trimmed)) return 'codex';
28
+ if (/\bgemini(?:[-_\s]*cli)?\b/i.test(trimmed)) return 'gemini';
29
+ if (/\broo(?:[-_\s]*(?:code|cline))?\b/i.test(trimmed)) return 'roo-code';
30
+ if (/\bkilo(?:[-_\s]*code)?\b/i.test(trimmed)) return 'kilo-code';
31
+ if (/\bcline\b|claude[-_\s]*dev/i.test(trimmed)) return 'cline';
32
+ if (/\bcontinue(?:[-_\s]*dev)?\b/i.test(trimmed)) return 'continue';
33
+ if (/\bgoose\b/i.test(trimmed)) return 'goose';
34
+ if (/\b(?:sourcegraph[-_\s]*)?amp\b/i.test(trimmed)) return 'amp';
35
+ if (/\bkiro\b/i.test(trimmed)) return 'kiro';
36
+ if (/\bamazon[-_\s]*q\b|\bamazonq\b|^q[-_\s]*cli$|^q$/i.test(trimmed)) return 'amazon-q';
37
+ if (/\btrae\b/i.test(trimmed)) return 'trae';
38
+ if (/\baider\b/i.test(trimmed)) return 'aider';
22
39
  return '';
23
40
  }
24
41
 
@@ -82,7 +99,7 @@ export function openUrlInBrowser(url, options = {}) {
82
99
  if (env.MEMOREAL_NO_BROWSER === '1') {
83
100
  return false;
84
101
  }
85
- if (typeof url !== 'string' || !/^https?:\/\/[^\s"<>]+$/i.test(url.trim())) {
102
+ if (typeof url !== 'string' || !/^https?:\/\/[^\s"<>'\\`\x00-\x1f\x7f]+$/i.test(url.trim())) {
86
103
  return false;
87
104
  }
88
105
 
@@ -96,8 +113,11 @@ export function openUrlInBrowser(url, options = {}) {
96
113
  cmd = 'open';
97
114
  args = [targetUrl];
98
115
  } else if (platform === 'win32') {
99
- cmd = 'cmd';
100
- args = ['/c', 'start', '', targetUrl];
116
+ cmd = 'rundll32';
117
+ args = ['url.dll,FileProtocolHandler', targetUrl];
118
+ } else if (platform === 'linux' && (env.WSL_DISTRO_NAME || env.WSL_INTEROP)) {
119
+ cmd = 'rundll32.exe';
120
+ args = ['url.dll,FileProtocolHandler', targetUrl];
101
121
  } else {
102
122
  cmd = 'xdg-open';
103
123
  args = [targetUrl];
@@ -462,6 +482,14 @@ export function createConnectWizardController(options = {}) {
462
482
  homeDir,
463
483
  env,
464
484
  preferredTool: toolSlug,
485
+ platform,
486
+ });
487
+ provisionMemorealAgentAssets({
488
+ homeDir,
489
+ projectDir: options.projectDir,
490
+ env,
491
+ preferredTool: toolSlug,
492
+ platform,
465
493
  });
466
494
  const cleanWs = sanitizeWorkspaceMetadata(pollData.workspace);
467
495
  state.status = 'connected';
@@ -652,6 +680,7 @@ export async function runCliSetupWizard(options = {}) {
652
680
  }
653
681
 
654
682
  let cliBrowser = null;
683
+ let cliBootstrap = null;
655
684
  let cliApiUrl = '';
656
685
  let cliKey = '';
657
686
  let cliTool = '';
@@ -663,6 +692,10 @@ export async function runCliSetupWizard(options = {}) {
663
692
  cliBrowser = true;
664
693
  } else if (arg === '--no-browser') {
665
694
  cliBrowser = false;
695
+ } else if (arg === '--no-bootstrap') {
696
+ cliBootstrap = false;
697
+ } else if (arg === '--bootstrap') {
698
+ cliBootstrap = true;
666
699
  } else if (arg === '--api-url' || arg === '--url') {
667
700
  cliApiUrl = rawArgs[++i] || '';
668
701
  } else if (arg.startsWith('--api-url=')) {
@@ -684,12 +717,13 @@ export async function runCliSetupWizard(options = {}) {
684
717
 
685
718
  if (showHelp) {
686
719
  output.write(
687
- 'Usage: memoreal-mcp setup [options]\n\n' +
720
+ 'Usage: memoreal-mcp setup|init [options]\n\n' +
688
721
  'Options:\n' +
689
722
  ' --browser Non-interactive browser OAuth device pairing\n' +
690
723
  ' --no-browser Do not launch browser automatically\n' +
724
+ ' --no-bootstrap Skip automatic repo cold-start memory indexing\n' +
691
725
  ' --key <api-key> Configure using an existing Memoreal API key\n' +
692
- ' --tool <slug> Preferred IDE tool (cursor, opencode, claude-code, vscode, etc.)\n' +
726
+ ' --tool <slug> Preferred IDE tool (codex, claude-code, cursor, opencode, windsurf, vscode, zed, gemini, cline, roo-code, kilo-code, continue, goose, amp, kiro, amazon-q, trae, aider)\n' +
693
727
  ' --api-url <url> Custom Memoreal Cloud API URL\n' +
694
728
  ' --help, -h Show this help message\n'
695
729
  );
@@ -779,8 +813,36 @@ export async function runCliSetupWizard(options = {}) {
779
813
  homeDir,
780
814
  env,
781
815
  preferredTool: toolSlug,
816
+ platform,
817
+ });
818
+
819
+ const targetProjectDir = options.projectDir ?? (options.homeDir ? options.homeDir : process.cwd());
820
+ const assets = provisionMemorealAgentAssets({
821
+ homeDir,
822
+ projectDir: targetProjectDir,
823
+ env,
824
+ preferredTool: toolSlug,
825
+ platform,
782
826
  });
783
827
 
828
+ let bootstrapResult = null;
829
+ if (cliBootstrap !== false && hasProjectMarkers(targetProjectDir)) {
830
+ output.write('Bootstrapping repository context into Memoreal Cloud...\n');
831
+ try {
832
+ bootstrapResult = await bootstrapProjectContext({
833
+ projectDir: targetProjectDir,
834
+ apiUrl: effectiveApiUrl,
835
+ apiKey: cleanKey,
836
+ fetchImpl,
837
+ });
838
+ if (bootstrapResult?.success) {
839
+ output.write(`Indexed ${bootstrapResult.importedCount} documentation files and ${bootstrapResult.symbolsIndexed} code symbols.\n`);
840
+ }
841
+ } catch (err) {
842
+ output.write(`Warning: Repository bootstrap skipped or failed: ${err.message}\n`);
843
+ }
844
+ }
845
+
784
846
  let workspace = null;
785
847
  if (authRes.ok) {
786
848
  workspace = sanitizeWorkspaceMetadata(authRes.data?.workspace);
@@ -796,6 +858,8 @@ export async function runCliSetupWizard(options = {}) {
796
858
  configPath: saved.configPath,
797
859
  updatedIdes: ides.updated,
798
860
  workspace,
861
+ provisionedAssets: assets?.provisioned || [],
862
+ bootstrap: bootstrapResult,
799
863
  };
800
864
  }
801
865
 
@@ -897,8 +961,36 @@ export async function runCliSetupWizard(options = {}) {
897
961
  homeDir,
898
962
  env,
899
963
  preferredTool: toolSlug,
964
+ platform,
965
+ });
966
+
967
+ const targetProjectDir = options.projectDir ?? (options.homeDir ? options.homeDir : process.cwd());
968
+ const assets = provisionMemorealAgentAssets({
969
+ homeDir,
970
+ projectDir: targetProjectDir,
971
+ env,
972
+ preferredTool: toolSlug,
973
+ platform,
900
974
  });
901
975
 
976
+ let bootstrapResult = null;
977
+ if (cliBootstrap !== false && hasProjectMarkers(targetProjectDir)) {
978
+ output.write('Bootstrapping repository context into Memoreal Cloud...\n');
979
+ try {
980
+ bootstrapResult = await bootstrapProjectContext({
981
+ projectDir: targetProjectDir,
982
+ apiUrl: effectiveApiUrl,
983
+ apiKey: freshKey,
984
+ fetchImpl,
985
+ });
986
+ if (bootstrapResult?.success) {
987
+ output.write(`Indexed ${bootstrapResult.importedCount} documentation files and ${bootstrapResult.symbolsIndexed} code symbols.\n`);
988
+ }
989
+ } catch (err) {
990
+ output.write(`Warning: Repository bootstrap skipped or failed: ${err.message}\n`);
991
+ }
992
+ }
993
+
902
994
  output.write('Verifying connection with Memoreal Cloud...\n');
903
995
  try {
904
996
  const authRes = await verifyApiKeyAuth(effectiveApiUrl, freshKey, { fetchImpl });
@@ -917,5 +1009,7 @@ export async function runCliSetupWizard(options = {}) {
917
1009
  configPath: saved.configPath,
918
1010
  updatedIdes: ides.updated,
919
1011
  workspace,
1012
+ provisionedAssets: assets?.provisioned || [],
1013
+ bootstrap: bootstrapResult,
920
1014
  };
921
1015
  }
package/.actor/Dockerfile DELETED
@@ -1,6 +0,0 @@
1
- FROM apify/actor-node:20
2
- WORKDIR /usr/src/app
3
- COPY package.json package-lock.json* ./
4
- RUN npm ci --omit=dev
5
- COPY . ./
6
- CMD ["node", "./src/apify-main.mjs"]
package/.actor/actor.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "actorSpecification": 1,
3
- "name": "memoreal-mcp",
4
- "title": "Memoreal — Deterministic AI Memory & Code Intelligence (MCP / Standby / Task)",
5
- "description": "Deterministic long-term memory and code intelligence engine for AI agents (100% on LongMemEval in 12.9 ms, 0 LLM tokens, 14 Cloud MCP tools).",
6
- "version": "1.0",
7
- "buildTag": "latest",
8
- "environmentVariables": {
9
- "MEMOREAL_API_URL": "https://memoreal.kolivri.com",
10
- "MEMORIA_API_URL": "https://memoria.kolivri.com"
11
- },
12
- "input": "./input_schema.json",
13
- "dockerfile": "./Dockerfile",
14
- "readme": "../README.md"
15
- }
@@ -1,92 +0,0 @@
1
- {
2
- "title": "Memoreal MCP Actor Input Schema",
3
- "type": "object",
4
- "schemaVersion": 1,
5
- "properties": {
6
- "apiKey": {
7
- "title": "Memoreal API Key",
8
- "type": "string",
9
- "description": "Memoreal Cloud API key from https://memoreal.kolivri.com/register",
10
- "editor": "textfield",
11
- "isSecret": true
12
- },
13
- "namespace": {
14
- "title": "Namespace",
15
- "type": "string",
16
- "description": "Workspace namespace",
17
- "editor": "textfield",
18
- "default": "default"
19
- },
20
- "action": {
21
- "title": "Action",
22
- "type": "string",
23
- "description": "Memory action to execute or run as standby MCP server",
24
- "editor": "select",
25
- "default": "context",
26
- "enum": [
27
- "recall",
28
- "context",
29
- "encode",
30
- "search_code",
31
- "health",
32
- "standby_mcp"
33
- ],
34
- "enumTitles": [
35
- "Recall Memories (recall)",
36
- "Build Context (context)",
37
- "Encode Memory (encode)",
38
- "Search Code Symbols (search_code)",
39
- "Health & Engine Status (health)",
40
- "Standby MCP Server (standby_mcp)"
41
- ]
42
- },
43
- "query": {
44
- "title": "Query",
45
- "type": "string",
46
- "description": "Query for recall, context, or search_code",
47
- "editor": "textfield"
48
- },
49
- "content": {
50
- "title": "Content",
51
- "type": "string",
52
- "description": "Memory text to encode when action is encode",
53
- "editor": "textarea"
54
- },
55
- "type": {
56
- "title": "Memory Tier",
57
- "type": "string",
58
- "description": "Memory tier/type when action is encode",
59
- "editor": "select",
60
- "default": "episodic",
61
- "enum": [
62
- "episodic",
63
- "semantic",
64
- "buffer",
65
- "core"
66
- ],
67
- "enumTitles": [
68
- "Episodic",
69
- "Semantic",
70
- "Buffer",
71
- "Core"
72
- ]
73
- },
74
- "salience": {
75
- "title": "Salience",
76
- "type": "number",
77
- "description": "Salience score between 0.0 and 1.0",
78
- "editor": "number",
79
- "minimum": 0,
80
- "maximum": 1,
81
- "default": 0.5
82
- },
83
- "tokenBudget": {
84
- "title": "Token Budget",
85
- "type": "integer",
86
- "description": "Token budget for recall or context assembly",
87
- "editor": "number",
88
- "default": 4096
89
- }
90
- },
91
- "required": []
92
- }
package/Dockerfile DELETED
@@ -1,5 +0,0 @@
1
- FROM node:22-alpine
2
- WORKDIR /app
3
- COPY package.json ./
4
- COPY src ./src
5
- ENTRYPOINT ["node", "src/server.mjs"]