@coderule/mcp 2.1.0 → 2.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.
- package/dist/mcp-cli.cjs +139 -0
- package/dist/mcp-cli.cjs.map +1 -1
- package/dist/mcp-cli.js +141 -2
- package/dist/mcp-cli.js.map +1 -1
- package/package.json +2 -2
package/dist/mcp-cli.cjs
CHANGED
|
@@ -2413,6 +2413,145 @@ ${statusText}`;
|
|
|
2413
2413
|
return { content: [{ type: "text", text }] };
|
|
2414
2414
|
}
|
|
2415
2415
|
);
|
|
2416
|
+
server.registerTool(
|
|
2417
|
+
"dump_bush",
|
|
2418
|
+
{
|
|
2419
|
+
title: "Dump Raw Index (Debug)",
|
|
2420
|
+
description: "Debug tool. Downloads the raw HDF5 bush file for the current snapshot and saves it to the specified path. Returns an HDF5 bush reader skill with format documentation and Python code examples.",
|
|
2421
|
+
inputSchema: {
|
|
2422
|
+
filePath: zod.z.string().min(1, "File path is required").refine((p) => p.endsWith(".h5"), "File must have .h5 extension").describe(
|
|
2423
|
+
"Full file name to save (use base dir + any name with .h5 extension), e.g. /tmp/snapshot.h5"
|
|
2424
|
+
)
|
|
2425
|
+
},
|
|
2426
|
+
annotations: {
|
|
2427
|
+
readOnlyHint: false,
|
|
2428
|
+
destructiveHint: false,
|
|
2429
|
+
idempotentHint: true,
|
|
2430
|
+
openWorldHint: true
|
|
2431
|
+
}
|
|
2432
|
+
},
|
|
2433
|
+
async ({ filePath }) => {
|
|
2434
|
+
const deadline = Date.now() + runtime.config.maxQueryWaitMs;
|
|
2435
|
+
while (Date.now() < deadline) {
|
|
2436
|
+
if (isLocalStable()) break;
|
|
2437
|
+
await sleep3(250);
|
|
2438
|
+
}
|
|
2439
|
+
if (!isLocalStable()) {
|
|
2440
|
+
const statusText2 = formatStatus(
|
|
2441
|
+
await collectIndexingStatus(runtime, runner)
|
|
2442
|
+
);
|
|
2443
|
+
return {
|
|
2444
|
+
content: [
|
|
2445
|
+
{
|
|
2446
|
+
type: "text",
|
|
2447
|
+
text: `Indexer not ready (local hashing/dirty). Current status:
|
|
2448
|
+
|
|
2449
|
+
${statusText2}`
|
|
2450
|
+
}
|
|
2451
|
+
],
|
|
2452
|
+
isError: true
|
|
2453
|
+
};
|
|
2454
|
+
}
|
|
2455
|
+
let currentHash = computeSnapshot(runtime.filesRepo).snapshotHash;
|
|
2456
|
+
let lastStatus;
|
|
2457
|
+
while (Date.now() < deadline) {
|
|
2458
|
+
if (!isLocalStable()) {
|
|
2459
|
+
while (Date.now() < deadline) {
|
|
2460
|
+
if (isLocalStable()) break;
|
|
2461
|
+
await sleep3(250);
|
|
2462
|
+
}
|
|
2463
|
+
if (!isLocalStable()) break;
|
|
2464
|
+
currentHash = computeSnapshot(runtime.filesRepo).snapshotHash;
|
|
2465
|
+
continue;
|
|
2466
|
+
}
|
|
2467
|
+
try {
|
|
2468
|
+
const status = await withDeadline2(
|
|
2469
|
+
runtime.clients.sync.checkSnapshotStatus(currentHash),
|
|
2470
|
+
deadline
|
|
2471
|
+
);
|
|
2472
|
+
lastStatus = status.status;
|
|
2473
|
+
if (status.status === "READY") {
|
|
2474
|
+
try {
|
|
2475
|
+
const bushBuffer = await withDeadline2(
|
|
2476
|
+
runtime.clients.sync.downloadSnapshotBush(currentHash),
|
|
2477
|
+
deadline
|
|
2478
|
+
);
|
|
2479
|
+
await fs5.mkdir(path2.dirname(filePath), { recursive: true });
|
|
2480
|
+
await fs5.writeFile(filePath, Buffer.from(bushBuffer));
|
|
2481
|
+
runtime.logger.info(
|
|
2482
|
+
{
|
|
2483
|
+
filePath,
|
|
2484
|
+
snapshotHash: currentHash,
|
|
2485
|
+
bytes: bushBuffer.byteLength
|
|
2486
|
+
},
|
|
2487
|
+
"HDF5 bush file saved"
|
|
2488
|
+
);
|
|
2489
|
+
const skill = await withDeadline2(
|
|
2490
|
+
runtime.clients.sync.getHdf5BushReaderSkill(),
|
|
2491
|
+
deadline
|
|
2492
|
+
);
|
|
2493
|
+
return {
|
|
2494
|
+
content: [
|
|
2495
|
+
{
|
|
2496
|
+
type: "text",
|
|
2497
|
+
text: `HDF5 bush saved to ${filePath} (${bushBuffer.byteLength} bytes, snapshot ${currentHash}).
|
|
2498
|
+
|
|
2499
|
+
${skill}`
|
|
2500
|
+
}
|
|
2501
|
+
]
|
|
2502
|
+
};
|
|
2503
|
+
} catch (error) {
|
|
2504
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
2505
|
+
runtime.logger.error(
|
|
2506
|
+
{ err: error, snapshotHash: currentHash },
|
|
2507
|
+
"Bush download failed"
|
|
2508
|
+
);
|
|
2509
|
+
return {
|
|
2510
|
+
content: [
|
|
2511
|
+
{
|
|
2512
|
+
type: "text",
|
|
2513
|
+
text: `Failed to download bush for snapshot ${currentHash}: ${message}`
|
|
2514
|
+
}
|
|
2515
|
+
],
|
|
2516
|
+
isError: true
|
|
2517
|
+
};
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
if (status.status === "FAILED") {
|
|
2521
|
+
while (Date.now() < deadline) {
|
|
2522
|
+
if (isLocalStable()) break;
|
|
2523
|
+
await sleep3(250);
|
|
2524
|
+
}
|
|
2525
|
+
if (!isLocalStable()) break;
|
|
2526
|
+
currentHash = computeSnapshot(runtime.filesRepo).snapshotHash;
|
|
2527
|
+
continue;
|
|
2528
|
+
}
|
|
2529
|
+
runtime.outbox.enqueueSnapshot(runtime.config.rootId, 0);
|
|
2530
|
+
} catch {
|
|
2531
|
+
}
|
|
2532
|
+
const newHash = computeSnapshot(runtime.filesRepo).snapshotHash;
|
|
2533
|
+
if (newHash !== currentHash) {
|
|
2534
|
+
currentHash = newHash;
|
|
2535
|
+
continue;
|
|
2536
|
+
}
|
|
2537
|
+
await sleep3(500);
|
|
2538
|
+
}
|
|
2539
|
+
const statusText = formatStatus(
|
|
2540
|
+
await collectIndexingStatus(runtime, runner)
|
|
2541
|
+
);
|
|
2542
|
+
return {
|
|
2543
|
+
content: [
|
|
2544
|
+
{
|
|
2545
|
+
type: "text",
|
|
2546
|
+
text: `Snapshot not READY before deadline (last status: ${lastStatus ?? "unknown"}). Current status:
|
|
2547
|
+
|
|
2548
|
+
${statusText}`
|
|
2549
|
+
}
|
|
2550
|
+
],
|
|
2551
|
+
isError: true
|
|
2552
|
+
};
|
|
2553
|
+
}
|
|
2554
|
+
);
|
|
2416
2555
|
return server;
|
|
2417
2556
|
}
|
|
2418
2557
|
|