@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.js CHANGED
@@ -837,6 +837,9 @@ var Hasher = class {
837
837
  await this.worker.terminate();
838
838
  }
839
839
  }
840
+ async yieldToEventLoop() {
841
+ await new Promise((resolve) => setImmediate(resolve));
842
+ }
840
843
  resolveAbsolutePath(record) {
841
844
  if (path.isAbsolute(record.display_path)) {
842
845
  return record.display_path;
@@ -907,6 +910,9 @@ var Hasher = class {
907
910
  const absPath = this.resolveAbsolutePath(record);
908
911
  const exists = await this.ensureExists(absPath, record);
909
912
  if (!exists) {
913
+ if (this.inlineMode) {
914
+ await this.yieldToEventLoop();
915
+ }
910
916
  continue;
911
917
  }
912
918
  try {
@@ -931,6 +937,9 @@ var Hasher = class {
931
937
  failures.push(record.id);
932
938
  }
933
939
  }
940
+ if (this.inlineMode) {
941
+ await this.yieldToEventLoop();
942
+ }
934
943
  }
935
944
  if (successes.length) {
936
945
  this.log.debug({ count: successes.length }, "Hashing succeeded");
@@ -1227,7 +1236,7 @@ async function publishSnapshot(rootPath, filesRepo, snapshotsRepo, syncClient, l
1227
1236
  }
1228
1237
 
1229
1238
  // src/service/InitialSync.ts
1230
- async function runInitialSyncPipeline(runtime) {
1239
+ async function runInitialSyncPipeline(runtime, options) {
1231
1240
  const inventoryLogger = runtime.logger.child({ scope: "inventory" });
1232
1241
  await runInventory({
1233
1242
  rootPath: runtime.config.rootPath,
@@ -1243,19 +1252,22 @@ async function runInitialSyncPipeline(runtime) {
1243
1252
  hashLogger.debug("Hasher processed batch");
1244
1253
  }
1245
1254
  }
1246
- const syncLogger = runtime.logger.child({ scope: "snapshot" });
1247
- const result = await publishSnapshot(
1248
- runtime.config.rootPath,
1249
- runtime.filesRepo,
1250
- runtime.snapshotsRepo,
1251
- runtime.clients.sync,
1252
- syncLogger,
1253
- {
1254
- maxAttempts: runtime.config.maxSnapshotAttempts,
1255
- uploadChunkSize: runtime.config.uploadChunkSize
1256
- }
1255
+ const computation = computeSnapshot(runtime.filesRepo);
1256
+ const createdAt = Date.now();
1257
+ runtime.snapshotsRepo.insert(
1258
+ computation.snapshotHash,
1259
+ computation.filesCount,
1260
+ computation.totalSize,
1261
+ createdAt
1257
1262
  );
1258
- return result;
1263
+ runtime.outbox.enqueueSnapshot(runtime.config.rootId, 0);
1264
+ return {
1265
+ snapshotHash: computation.snapshotHash,
1266
+ filesCount: computation.filesCount,
1267
+ totalSize: computation.totalSize,
1268
+ status: "READY",
1269
+ createdAt
1270
+ };
1259
1271
  }
1260
1272
  async function createChokidarWatcher(options, usePolling) {
1261
1273
  const log = options.logger.child({
@@ -2089,7 +2101,9 @@ async function main() {
2089
2101
  runtime.logger.info("MCP server connected via stdio");
2090
2102
  let initialCreatedAt;
2091
2103
  try {
2092
- const initial = await runInitialSyncPipeline(runtime);
2104
+ const initial = await runInitialSyncPipeline(runtime, {
2105
+ blockUntilReady: false
2106
+ });
2093
2107
  runtime.logger.info(
2094
2108
  {
2095
2109
  snapshotHash: initial.snapshotHash,