@coderule/mcp 2.1.0 → 2.2.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/dist/mcp-cli.cjs CHANGED
@@ -2413,6 +2413,128 @@ ${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
+ const bushBuffer = await withDeadline2(
2475
+ runtime.clients.sync.downloadSnapshotBush(currentHash),
2476
+ deadline
2477
+ );
2478
+ await fs5.mkdir(path2.dirname(filePath), { recursive: true });
2479
+ await fs5.writeFile(filePath, Buffer.from(bushBuffer));
2480
+ runtime.logger.info(
2481
+ {
2482
+ filePath,
2483
+ snapshotHash: currentHash,
2484
+ bytes: bushBuffer.byteLength
2485
+ },
2486
+ "HDF5 bush file saved"
2487
+ );
2488
+ const skill = await withDeadline2(
2489
+ runtime.clients.sync.getHdf5BushReaderSkill(),
2490
+ deadline
2491
+ );
2492
+ return {
2493
+ content: [
2494
+ {
2495
+ type: "text",
2496
+ text: `HDF5 bush saved to ${filePath} (${bushBuffer.byteLength} bytes, snapshot ${currentHash}).
2497
+
2498
+ ${skill}`
2499
+ }
2500
+ ]
2501
+ };
2502
+ }
2503
+ if (status.status === "FAILED") {
2504
+ while (Date.now() < deadline) {
2505
+ if (isLocalStable()) break;
2506
+ await sleep3(250);
2507
+ }
2508
+ if (!isLocalStable()) break;
2509
+ currentHash = computeSnapshot(runtime.filesRepo).snapshotHash;
2510
+ continue;
2511
+ }
2512
+ runtime.outbox.enqueueSnapshot(runtime.config.rootId, 0);
2513
+ } catch {
2514
+ }
2515
+ const newHash = computeSnapshot(runtime.filesRepo).snapshotHash;
2516
+ if (newHash !== currentHash) {
2517
+ currentHash = newHash;
2518
+ continue;
2519
+ }
2520
+ await sleep3(500);
2521
+ }
2522
+ const statusText = formatStatus(
2523
+ await collectIndexingStatus(runtime, runner)
2524
+ );
2525
+ return {
2526
+ content: [
2527
+ {
2528
+ type: "text",
2529
+ text: `Snapshot not READY before deadline (last status: ${lastStatus ?? "unknown"}). Current status:
2530
+
2531
+ ${statusText}`
2532
+ }
2533
+ ],
2534
+ isError: true
2535
+ };
2536
+ }
2537
+ );
2416
2538
  return server;
2417
2539
  }
2418
2540