@coderule/mcp 1.6.0 → 1.6.2

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
@@ -852,6 +852,9 @@ var Hasher = class {
852
852
  await this.worker.terminate();
853
853
  }
854
854
  }
855
+ async yieldToEventLoop() {
856
+ await new Promise((resolve) => setImmediate(resolve));
857
+ }
855
858
  resolveAbsolutePath(record) {
856
859
  if (path__default.default.isAbsolute(record.display_path)) {
857
860
  return record.display_path;
@@ -922,6 +925,9 @@ var Hasher = class {
922
925
  const absPath = this.resolveAbsolutePath(record);
923
926
  const exists = await this.ensureExists(absPath, record);
924
927
  if (!exists) {
928
+ if (this.inlineMode) {
929
+ await this.yieldToEventLoop();
930
+ }
925
931
  continue;
926
932
  }
927
933
  try {
@@ -946,6 +952,9 @@ var Hasher = class {
946
952
  failures.push(record.id);
947
953
  }
948
954
  }
955
+ if (this.inlineMode) {
956
+ await this.yieldToEventLoop();
957
+ }
949
958
  }
950
959
  if (successes.length) {
951
960
  this.log.debug({ count: successes.length }, "Hashing succeeded");
@@ -1242,7 +1251,7 @@ async function publishSnapshot(rootPath, filesRepo, snapshotsRepo, syncClient, l
1242
1251
  }
1243
1252
 
1244
1253
  // src/service/InitialSync.ts
1245
- async function runInitialSyncPipeline(runtime) {
1254
+ async function runInitialSyncPipeline(runtime, options) {
1246
1255
  const inventoryLogger = runtime.logger.child({ scope: "inventory" });
1247
1256
  await runInventory({
1248
1257
  rootPath: runtime.config.rootPath,
@@ -1258,19 +1267,22 @@ async function runInitialSyncPipeline(runtime) {
1258
1267
  hashLogger.debug("Hasher processed batch");
1259
1268
  }
1260
1269
  }
1261
- const syncLogger = runtime.logger.child({ scope: "snapshot" });
1262
- const result = await publishSnapshot(
1263
- runtime.config.rootPath,
1264
- runtime.filesRepo,
1265
- runtime.snapshotsRepo,
1266
- runtime.clients.sync,
1267
- syncLogger,
1268
- {
1269
- maxAttempts: runtime.config.maxSnapshotAttempts,
1270
- uploadChunkSize: runtime.config.uploadChunkSize
1271
- }
1270
+ const computation = computeSnapshot(runtime.filesRepo);
1271
+ const createdAt = Date.now();
1272
+ runtime.snapshotsRepo.insert(
1273
+ computation.snapshotHash,
1274
+ computation.filesCount,
1275
+ computation.totalSize,
1276
+ createdAt
1272
1277
  );
1273
- return result;
1278
+ runtime.outbox.enqueueSnapshot(runtime.config.rootId, 0);
1279
+ return {
1280
+ snapshotHash: computation.snapshotHash,
1281
+ filesCount: computation.filesCount,
1282
+ totalSize: computation.totalSize,
1283
+ status: "READY",
1284
+ createdAt
1285
+ };
1274
1286
  }
1275
1287
  async function createChokidarWatcher(options, usePolling) {
1276
1288
  const log = options.logger.child({
@@ -2104,7 +2116,9 @@ async function main() {
2104
2116
  runtime.logger.info("MCP server connected via stdio");
2105
2117
  let initialCreatedAt;
2106
2118
  try {
2107
- const initial = await runInitialSyncPipeline(runtime);
2119
+ const initial = await runInitialSyncPipeline(runtime, {
2120
+ blockUntilReady: false
2121
+ });
2108
2122
  runtime.logger.info(
2109
2123
  {
2110
2124
  snapshotHash: initial.snapshotHash,