@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/cli.cjs CHANGED
@@ -849,6 +849,9 @@ var Hasher = class {
849
849
  await this.worker.terminate();
850
850
  }
851
851
  }
852
+ async yieldToEventLoop() {
853
+ await new Promise((resolve) => setImmediate(resolve));
854
+ }
852
855
  resolveAbsolutePath(record) {
853
856
  if (path__default.default.isAbsolute(record.display_path)) {
854
857
  return record.display_path;
@@ -919,6 +922,9 @@ var Hasher = class {
919
922
  const absPath = this.resolveAbsolutePath(record);
920
923
  const exists = await this.ensureExists(absPath, record);
921
924
  if (!exists) {
925
+ if (this.inlineMode) {
926
+ await this.yieldToEventLoop();
927
+ }
922
928
  continue;
923
929
  }
924
930
  try {
@@ -943,6 +949,9 @@ var Hasher = class {
943
949
  failures.push(record.id);
944
950
  }
945
951
  }
952
+ if (this.inlineMode) {
953
+ await this.yieldToEventLoop();
954
+ }
946
955
  }
947
956
  if (successes.length) {
948
957
  this.log.debug({ count: successes.length }, "Hashing succeeded");
@@ -1239,7 +1248,7 @@ async function publishSnapshot(rootPath, filesRepo, snapshotsRepo, syncClient, l
1239
1248
  }
1240
1249
 
1241
1250
  // src/service/InitialSync.ts
1242
- async function runInitialSyncPipeline(runtime) {
1251
+ async function runInitialSyncPipeline(runtime, options) {
1243
1252
  const inventoryLogger = runtime.logger.child({ scope: "inventory" });
1244
1253
  await runInventory({
1245
1254
  rootPath: runtime.config.rootPath,
@@ -1255,19 +1264,37 @@ async function runInitialSyncPipeline(runtime) {
1255
1264
  hashLogger.debug("Hasher processed batch");
1256
1265
  }
1257
1266
  }
1258
- const syncLogger = runtime.logger.child({ scope: "snapshot" });
1259
- const result = await publishSnapshot(
1260
- runtime.config.rootPath,
1261
- runtime.filesRepo,
1262
- runtime.snapshotsRepo,
1263
- runtime.clients.sync,
1264
- syncLogger,
1265
- {
1266
- maxAttempts: runtime.config.maxSnapshotAttempts,
1267
- uploadChunkSize: runtime.config.uploadChunkSize
1268
- }
1267
+ if (options?.blockUntilReady !== false) {
1268
+ const syncLogger = runtime.logger.child({ scope: "snapshot" });
1269
+ const result = await publishSnapshot(
1270
+ runtime.config.rootPath,
1271
+ runtime.filesRepo,
1272
+ runtime.snapshotsRepo,
1273
+ runtime.clients.sync,
1274
+ syncLogger,
1275
+ {
1276
+ maxAttempts: runtime.config.maxSnapshotAttempts,
1277
+ uploadChunkSize: runtime.config.uploadChunkSize
1278
+ }
1279
+ );
1280
+ return result;
1281
+ }
1282
+ const computation = computeSnapshot(runtime.filesRepo);
1283
+ const createdAt = Date.now();
1284
+ runtime.snapshotsRepo.insert(
1285
+ computation.snapshotHash,
1286
+ computation.filesCount,
1287
+ computation.totalSize,
1288
+ createdAt
1269
1289
  );
1270
- return result;
1290
+ runtime.outbox.enqueueSnapshot(runtime.config.rootId, 0);
1291
+ return {
1292
+ snapshotHash: computation.snapshotHash,
1293
+ filesCount: computation.filesCount,
1294
+ totalSize: computation.totalSize,
1295
+ status: "READY",
1296
+ createdAt
1297
+ };
1271
1298
  }
1272
1299
  async function createChokidarWatcher(options, usePolling) {
1273
1300
  const log = options.logger.child({
@@ -1731,7 +1758,9 @@ function awaitShutdownSignals() {
1731
1758
  async function runInitialSync(params) {
1732
1759
  const runtime = await bootstrap(params);
1733
1760
  try {
1734
- const result = await runInitialSyncPipeline(runtime);
1761
+ const result = await runInitialSyncPipeline(runtime, {
1762
+ blockUntilReady: true
1763
+ });
1735
1764
  runtime.logger.info(
1736
1765
  {
1737
1766
  snapshotHash: result.snapshotHash,
@@ -1755,7 +1784,9 @@ async function runService(params) {
1755
1784
  await runner.prepareWatcher(true);
1756
1785
  let initialCreatedAt;
1757
1786
  try {
1758
- const initial = await runInitialSyncPipeline(runtime);
1787
+ const initial = await runInitialSyncPipeline(runtime, {
1788
+ blockUntilReady: false
1789
+ });
1759
1790
  runtime.logger.info(
1760
1791
  {
1761
1792
  snapshotHash: initial.snapshotHash,