@coderule/mcp 2.0.0 → 2.0.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.js CHANGED
@@ -1425,6 +1425,21 @@ async function runInitialSyncPipeline(runtime, options) {
1425
1425
  hashLogger.debug("Hasher processed batch");
1426
1426
  }
1427
1427
  }
1428
+ if (options?.blockUntilReady !== false) {
1429
+ const syncLogger = runtime.logger.child({ scope: "snapshot" });
1430
+ const result = await publishSnapshot(
1431
+ runtime.config.rootPath,
1432
+ runtime.filesRepo,
1433
+ runtime.snapshotsRepo,
1434
+ runtime.clients.sync,
1435
+ syncLogger,
1436
+ {
1437
+ maxAttempts: runtime.config.maxSnapshotAttempts,
1438
+ uploadChunkSize: runtime.config.uploadChunkSize
1439
+ }
1440
+ );
1441
+ return result;
1442
+ }
1428
1443
  const computation = computeSnapshot(runtime.filesRepo);
1429
1444
  const createdAt = Date.now();
1430
1445
  runtime.snapshotsRepo.insert(
@@ -2250,6 +2265,9 @@ function printUsage() {
2250
2265
  console.log(
2251
2266
  " --clean, --reindex Remove existing local state before running"
2252
2267
  );
2268
+ console.log(
2269
+ " --exit Exit after reindex (use with --reindex)"
2270
+ );
2253
2271
  console.log(
2254
2272
  " --inline-hasher Force inline hashing (debug only)"
2255
2273
  );
@@ -2297,6 +2315,7 @@ function parseArgs(argv) {
2297
2315
  let token = process.env.CODERULE_TOKEN;
2298
2316
  let rootPath;
2299
2317
  let clean = false;
2318
+ let exit = false;
2300
2319
  let inlineHasher = false;
2301
2320
  const env = {};
2302
2321
  const args = [...argv];
@@ -2310,6 +2329,10 @@ function parseArgs(argv) {
2310
2329
  clean = true;
2311
2330
  continue;
2312
2331
  }
2332
+ if (arg === "--exit") {
2333
+ exit = true;
2334
+ continue;
2335
+ }
2313
2336
  if (arg === "--inline-hasher") {
2314
2337
  inlineHasher = true;
2315
2338
  continue;
@@ -2366,7 +2389,7 @@ function parseArgs(argv) {
2366
2389
  "Missing token. Provide via argument or CODERULE_TOKEN environment variable."
2367
2390
  );
2368
2391
  }
2369
- return { token, rootPath, clean, inlineHasher, env };
2392
+ return { token, rootPath, clean, exit, inlineHasher, env };
2370
2393
  }
2371
2394
  async function ensureClean(configToken, rootPath) {
2372
2395
  const config = await resolveConfig({ token: configToken, rootPath });
@@ -2419,6 +2442,23 @@ async function main() {
2419
2442
  rootPath: options.rootPath
2420
2443
  });
2421
2444
  const runner = new ServiceRunner(runtime);
2445
+ if (options.exit && options.clean) {
2446
+ try {
2447
+ const initial = await runInitialSyncPipeline(runtime, {
2448
+ blockUntilReady: true
2449
+ });
2450
+ runtime.logger.info(
2451
+ {
2452
+ snapshotHash: initial.snapshotHash,
2453
+ filesCount: initial.filesCount
2454
+ },
2455
+ "Reindex completed; exiting"
2456
+ );
2457
+ } finally {
2458
+ await runner.stop();
2459
+ }
2460
+ return;
2461
+ }
2422
2462
  try {
2423
2463
  await runner.prepareWatcher(true);
2424
2464
  const server = createMcpServer({ runtime, runner });