@memoraone/mcp 0.1.18 → 0.1.19
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/dist/cli.cjs +1 -1
- package/dist/daemon.cjs +76 -33
- package/dist/index.cjs +76 -33
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
package/dist/daemon.cjs
CHANGED
|
@@ -418,11 +418,18 @@ var MemoraClient = class {
|
|
|
418
418
|
);
|
|
419
419
|
}
|
|
420
420
|
if (!res.ok) {
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
421
|
+
const accepted = options?.acceptStatuses?.includes(res.status);
|
|
422
|
+
if (accepted) {
|
|
423
|
+
return res.text ? JSON.parse(res.text) : null;
|
|
424
|
+
}
|
|
425
|
+
const quiet = options?.quietHttpStatuses?.includes(res.status);
|
|
426
|
+
if (!quiet) {
|
|
427
|
+
const snippet = res.text.length > 200 ? `${res.text.slice(0, 200)}...` : res.text;
|
|
428
|
+
process.stderr.write(
|
|
429
|
+
`[memoraone-mcp][error] http error method=POST url=${url} status=${res.status} body=${snippet}
|
|
424
430
|
`
|
|
425
|
-
|
|
431
|
+
);
|
|
432
|
+
}
|
|
426
433
|
throw new MemoraOneHttpError(res.status, res.statusText, res.text);
|
|
427
434
|
}
|
|
428
435
|
console.error(
|
|
@@ -465,41 +472,70 @@ var memoraClient_default = MemoraClient;
|
|
|
465
472
|
// src/sourceRegistration.ts
|
|
466
473
|
var path4 = __toESM(require("path"), 1);
|
|
467
474
|
var import_node_url = require("url");
|
|
475
|
+
var LOG_PREFIX = "[memoraone-mcp][source-registration]";
|
|
476
|
+
function buildRepoSourcePayload(normalizedRepoPath, ideType) {
|
|
477
|
+
const body = {
|
|
478
|
+
kind: "repo",
|
|
479
|
+
label: path4.basename(normalizedRepoPath),
|
|
480
|
+
uri: (0, import_node_url.pathToFileURL)(normalizedRepoPath).href
|
|
481
|
+
};
|
|
482
|
+
if (ideType) {
|
|
483
|
+
body.metadata = {
|
|
484
|
+
ide_type: ideType
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
return body;
|
|
488
|
+
}
|
|
468
489
|
async function registerRepoSource(client, projectId, repoPath, ideType) {
|
|
469
|
-
const normalizedRepoPath = path4.resolve(repoPath);
|
|
470
|
-
const endpointPath = `/v1/projects/${projectId}/sources`;
|
|
471
|
-
console.error(
|
|
472
|
-
`[memoraone-mcp DEBUG registerRepoSource] registerRepoSource() called projectId=${projectId} repoPath(raw)=${JSON.stringify(repoPath)} repoPath(normalized)=${JSON.stringify(normalizedRepoPath)} ideType=${ideType ?? "(none)"}`
|
|
473
|
-
);
|
|
474
490
|
try {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
body.metadata = {
|
|
482
|
-
ide_type: ideType
|
|
483
|
-
};
|
|
491
|
+
if (repoPath === void 0 || repoPath === null || String(repoPath).trim() === "") {
|
|
492
|
+
process.stderr.write(
|
|
493
|
+
`${LOG_PREFIX} skipped: empty repoPath (cannot register workspace)
|
|
494
|
+
`
|
|
495
|
+
);
|
|
496
|
+
return;
|
|
484
497
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
498
|
+
const normalizedRepoPath = path4.resolve(String(repoPath));
|
|
499
|
+
const body = buildRepoSourcePayload(normalizedRepoPath, ideType);
|
|
500
|
+
const primaryPath = `/v1/projects/${projectId}/sources`;
|
|
501
|
+
const alternatePath = `/v1/projects/${projectId}/sources/register`;
|
|
502
|
+
process.stderr.write(
|
|
503
|
+
`${LOG_PREFIX} registering projectId=${projectId} path=${normalizedRepoPath} ideType=${ideType ?? "(none)"}
|
|
504
|
+
`
|
|
491
505
|
);
|
|
506
|
+
try {
|
|
507
|
+
await client.post(primaryPath, body, {
|
|
508
|
+
acceptStatuses: [409],
|
|
509
|
+
log: false,
|
|
510
|
+
quietHttpStatuses: [404, 405, 501]
|
|
511
|
+
});
|
|
512
|
+
process.stderr.write(`${LOG_PREFIX} ok: POST ${primaryPath}
|
|
513
|
+
`);
|
|
514
|
+
return;
|
|
515
|
+
} catch (err) {
|
|
516
|
+
if (err instanceof MemoraOneHttpError && (err.status === 404 || err.status === 405 || err.status === 501)) {
|
|
517
|
+
process.stderr.write(
|
|
518
|
+
`${LOG_PREFIX} primary route returned ${err.status}; retrying POST ${alternatePath}
|
|
519
|
+
`
|
|
520
|
+
);
|
|
521
|
+
await client.post(alternatePath, body, { acceptStatuses: [409], log: false });
|
|
522
|
+
process.stderr.write(`${LOG_PREFIX} ok: POST ${alternatePath}
|
|
523
|
+
`);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
throw err;
|
|
527
|
+
}
|
|
492
528
|
} catch (err) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
529
|
+
const msg = String(err?.message ?? err);
|
|
530
|
+
process.stderr.write(`${LOG_PREFIX} failed: ${msg}
|
|
531
|
+
`);
|
|
496
532
|
if (err instanceof MemoraOneHttpError) {
|
|
497
533
|
const bodyStr = typeof err.body === "string" ? err.body : JSON.stringify(err.body ?? null);
|
|
498
|
-
|
|
499
|
-
|
|
534
|
+
process.stderr.write(
|
|
535
|
+
`${LOG_PREFIX} http status=${err.status} body=${bodyStr.length > 500 ? bodyStr.slice(0, 500) + "..." : bodyStr}
|
|
536
|
+
`
|
|
500
537
|
);
|
|
501
538
|
}
|
|
502
|
-
console.warn("[memoraone-mcp] registerRepoSource failed:", err);
|
|
503
539
|
}
|
|
504
540
|
}
|
|
505
541
|
|
|
@@ -1083,6 +1119,7 @@ async function acquireWorkspaceMapLock() {
|
|
|
1083
1119
|
const maxRetries = 10;
|
|
1084
1120
|
const retryDelayMs = 50;
|
|
1085
1121
|
const maxLockAgeMs = 5e3;
|
|
1122
|
+
await ensureWorkspaceDir();
|
|
1086
1123
|
let lockAcquired = false;
|
|
1087
1124
|
let retries = 0;
|
|
1088
1125
|
while (!lockAcquired && retries < maxRetries) {
|
|
@@ -1699,10 +1736,16 @@ async function main(opts = {}) {
|
|
|
1699
1736
|
runtime.apiKeyFingerprint = fingerprintApiKey(apiKeyToUse);
|
|
1700
1737
|
runtime.client = new memoraClient_default(config2, projectId, apiKeyToUse);
|
|
1701
1738
|
workspaceRoot = binding.workspaceRoot;
|
|
1702
|
-
|
|
1703
|
-
`[memoraone-mcp
|
|
1739
|
+
process.stderr.write(
|
|
1740
|
+
`[memoraone-mcp] registering workspace source bindingSource=${binding.bindingSource} workspaceRoot=${workspaceRoot ?? "(unset)"} m1Path=${binding.m1Path}
|
|
1741
|
+
`
|
|
1742
|
+
);
|
|
1743
|
+
await registerRepoSource(
|
|
1744
|
+
runtime.client,
|
|
1745
|
+
runtime.projectId,
|
|
1746
|
+
binding.workspaceRoot,
|
|
1747
|
+
runtime.ideType
|
|
1704
1748
|
);
|
|
1705
|
-
await registerRepoSource(runtime.client, runtime.projectId, workspaceRoot, runtime.ideType);
|
|
1706
1749
|
if (debugAuth) {
|
|
1707
1750
|
console.error("[memoraone-mcp][auth] repo root:", binding.workspaceRoot);
|
|
1708
1751
|
console.error("[memoraone-mcp][auth] project_id:", projectId);
|
package/dist/index.cjs
CHANGED
|
@@ -226,11 +226,18 @@ var MemoraClient = class {
|
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
if (!res.ok) {
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
const accepted = options?.acceptStatuses?.includes(res.status);
|
|
230
|
+
if (accepted) {
|
|
231
|
+
return res.text ? JSON.parse(res.text) : null;
|
|
232
|
+
}
|
|
233
|
+
const quiet = options?.quietHttpStatuses?.includes(res.status);
|
|
234
|
+
if (!quiet) {
|
|
235
|
+
const snippet = res.text.length > 200 ? `${res.text.slice(0, 200)}...` : res.text;
|
|
236
|
+
process.stderr.write(
|
|
237
|
+
`[memoraone-mcp][error] http error method=POST url=${url} status=${res.status} body=${snippet}
|
|
232
238
|
`
|
|
233
|
-
|
|
239
|
+
);
|
|
240
|
+
}
|
|
234
241
|
throw new MemoraOneHttpError(res.status, res.statusText, res.text);
|
|
235
242
|
}
|
|
236
243
|
console.error(
|
|
@@ -405,41 +412,70 @@ async function resolveAuthoritativeBinding(workspaceRoot) {
|
|
|
405
412
|
// src/sourceRegistration.ts
|
|
406
413
|
var path3 = __toESM(require("path"), 1);
|
|
407
414
|
var import_node_url = require("url");
|
|
415
|
+
var LOG_PREFIX = "[memoraone-mcp][source-registration]";
|
|
416
|
+
function buildRepoSourcePayload(normalizedRepoPath, ideType) {
|
|
417
|
+
const body = {
|
|
418
|
+
kind: "repo",
|
|
419
|
+
label: path3.basename(normalizedRepoPath),
|
|
420
|
+
uri: (0, import_node_url.pathToFileURL)(normalizedRepoPath).href
|
|
421
|
+
};
|
|
422
|
+
if (ideType) {
|
|
423
|
+
body.metadata = {
|
|
424
|
+
ide_type: ideType
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
return body;
|
|
428
|
+
}
|
|
408
429
|
async function registerRepoSource(client, projectId, repoPath, ideType) {
|
|
409
|
-
const normalizedRepoPath = path3.resolve(repoPath);
|
|
410
|
-
const endpointPath = `/v1/projects/${projectId}/sources`;
|
|
411
|
-
console.error(
|
|
412
|
-
`[memoraone-mcp DEBUG registerRepoSource] registerRepoSource() called projectId=${projectId} repoPath(raw)=${JSON.stringify(repoPath)} repoPath(normalized)=${JSON.stringify(normalizedRepoPath)} ideType=${ideType ?? "(none)"}`
|
|
413
|
-
);
|
|
414
430
|
try {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
body.metadata = {
|
|
422
|
-
ide_type: ideType
|
|
423
|
-
};
|
|
431
|
+
if (repoPath === void 0 || repoPath === null || String(repoPath).trim() === "") {
|
|
432
|
+
process.stderr.write(
|
|
433
|
+
`${LOG_PREFIX} skipped: empty repoPath (cannot register workspace)
|
|
434
|
+
`
|
|
435
|
+
);
|
|
436
|
+
return;
|
|
424
437
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
438
|
+
const normalizedRepoPath = path3.resolve(String(repoPath));
|
|
439
|
+
const body = buildRepoSourcePayload(normalizedRepoPath, ideType);
|
|
440
|
+
const primaryPath = `/v1/projects/${projectId}/sources`;
|
|
441
|
+
const alternatePath = `/v1/projects/${projectId}/sources/register`;
|
|
442
|
+
process.stderr.write(
|
|
443
|
+
`${LOG_PREFIX} registering projectId=${projectId} path=${normalizedRepoPath} ideType=${ideType ?? "(none)"}
|
|
444
|
+
`
|
|
431
445
|
);
|
|
446
|
+
try {
|
|
447
|
+
await client.post(primaryPath, body, {
|
|
448
|
+
acceptStatuses: [409],
|
|
449
|
+
log: false,
|
|
450
|
+
quietHttpStatuses: [404, 405, 501]
|
|
451
|
+
});
|
|
452
|
+
process.stderr.write(`${LOG_PREFIX} ok: POST ${primaryPath}
|
|
453
|
+
`);
|
|
454
|
+
return;
|
|
455
|
+
} catch (err) {
|
|
456
|
+
if (err instanceof MemoraOneHttpError && (err.status === 404 || err.status === 405 || err.status === 501)) {
|
|
457
|
+
process.stderr.write(
|
|
458
|
+
`${LOG_PREFIX} primary route returned ${err.status}; retrying POST ${alternatePath}
|
|
459
|
+
`
|
|
460
|
+
);
|
|
461
|
+
await client.post(alternatePath, body, { acceptStatuses: [409], log: false });
|
|
462
|
+
process.stderr.write(`${LOG_PREFIX} ok: POST ${alternatePath}
|
|
463
|
+
`);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
throw err;
|
|
467
|
+
}
|
|
432
468
|
} catch (err) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
469
|
+
const msg = String(err?.message ?? err);
|
|
470
|
+
process.stderr.write(`${LOG_PREFIX} failed: ${msg}
|
|
471
|
+
`);
|
|
436
472
|
if (err instanceof MemoraOneHttpError) {
|
|
437
473
|
const bodyStr = typeof err.body === "string" ? err.body : JSON.stringify(err.body ?? null);
|
|
438
|
-
|
|
439
|
-
|
|
474
|
+
process.stderr.write(
|
|
475
|
+
`${LOG_PREFIX} http status=${err.status} body=${bodyStr.length > 500 ? bodyStr.slice(0, 500) + "..." : bodyStr}
|
|
476
|
+
`
|
|
440
477
|
);
|
|
441
478
|
}
|
|
442
|
-
console.warn("[memoraone-mcp] registerRepoSource failed:", err);
|
|
443
479
|
}
|
|
444
480
|
}
|
|
445
481
|
|
|
@@ -1023,6 +1059,7 @@ async function acquireWorkspaceMapLock() {
|
|
|
1023
1059
|
const maxRetries = 10;
|
|
1024
1060
|
const retryDelayMs = 50;
|
|
1025
1061
|
const maxLockAgeMs = 5e3;
|
|
1062
|
+
await ensureWorkspaceDir();
|
|
1026
1063
|
let lockAcquired = false;
|
|
1027
1064
|
let retries = 0;
|
|
1028
1065
|
while (!lockAcquired && retries < maxRetries) {
|
|
@@ -1639,10 +1676,16 @@ async function main(opts = {}) {
|
|
|
1639
1676
|
runtime.apiKeyFingerprint = fingerprintApiKey(apiKeyToUse);
|
|
1640
1677
|
runtime.client = new memoraClient_default(config2, projectId, apiKeyToUse);
|
|
1641
1678
|
workspaceRoot = binding.workspaceRoot;
|
|
1642
|
-
|
|
1643
|
-
`[memoraone-mcp
|
|
1679
|
+
process.stderr.write(
|
|
1680
|
+
`[memoraone-mcp] registering workspace source bindingSource=${binding.bindingSource} workspaceRoot=${workspaceRoot ?? "(unset)"} m1Path=${binding.m1Path}
|
|
1681
|
+
`
|
|
1682
|
+
);
|
|
1683
|
+
await registerRepoSource(
|
|
1684
|
+
runtime.client,
|
|
1685
|
+
runtime.projectId,
|
|
1686
|
+
binding.workspaceRoot,
|
|
1687
|
+
runtime.ideType
|
|
1644
1688
|
);
|
|
1645
|
-
await registerRepoSource(runtime.client, runtime.projectId, workspaceRoot, runtime.ideType);
|
|
1646
1689
|
if (debugAuth) {
|
|
1647
1690
|
console.error("[memoraone-mcp][auth] repo root:", binding.workspaceRoot);
|
|
1648
1691
|
console.error("[memoraone-mcp][auth] project_id:", projectId);
|