@coderule/mcp 1.5.0 → 1.6.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/cli.cjs CHANGED
@@ -45,6 +45,8 @@ var DEFAULT_QUEUE_POLL_INTERVAL_MS = 500;
45
45
  var DEFAULT_HASH_BATCH_SIZE = 32;
46
46
  var DEFAULT_MAX_SNAPSHOT_ATTEMPTS = 5;
47
47
  var DEFAULT_HTTP_TIMEOUT_MS = 12e4;
48
+ var DEFAULT_UPLOAD_CHUNK_SIZE = 1;
49
+ var DEFAULT_MAX_QUERY_WAIT_MS = 5e4;
48
50
 
49
51
  // src/config/Configurator.ts
50
52
  var DEFAULT_RETRIEVAL_FORMATTER = "standard";
@@ -72,6 +74,14 @@ function parseInteger(value, fallback) {
72
74
  }
73
75
  return parsed;
74
76
  }
77
+ function parseSecondsToMs(value, fallbackMs) {
78
+ if (!value) return fallbackMs;
79
+ const seconds = Number.parseInt(value, 10);
80
+ if (Number.isNaN(seconds) || seconds <= 0) {
81
+ throw new Error(`Invalid seconds value: ${value}`);
82
+ }
83
+ return seconds * 1e3;
84
+ }
75
85
  function parseFormatter(value) {
76
86
  if (!value) return DEFAULT_RETRIEVAL_FORMATTER;
77
87
  const normalized = value.toLowerCase();
@@ -118,7 +128,9 @@ async function resolveConfig({
118
128
  maxSnapshotAttempts: DEFAULTS.maxSnapshotAttempts,
119
129
  retrievalFormatter: parseFormatter(
120
130
  process.env.CODERULE_RETRIEVAL_FORMATTER
121
- )
131
+ ),
132
+ uploadChunkSize: DEFAULT_UPLOAD_CHUNK_SIZE,
133
+ maxQueryWaitMs: DEFAULT_MAX_QUERY_WAIT_MS
122
134
  };
123
135
  if (process.env.CODERULE_SNAPSHOT_DEBOUNCE_MS) {
124
136
  baseConfig.snapshotDebounceMs = parseInteger(
@@ -160,6 +172,16 @@ async function resolveConfig({
160
172
  process.env.CODERULE_HTTP_TIMEOUT,
161
173
  DEFAULT_HTTP_TIMEOUT_MS
162
174
  );
175
+ if (process.env.CODERULE_UPLOAD_CHUNK_SIZE) {
176
+ baseConfig.uploadChunkSize = parseInteger(
177
+ process.env.CODERULE_UPLOAD_CHUNK_SIZE,
178
+ baseConfig.uploadChunkSize
179
+ );
180
+ }
181
+ baseConfig.maxQueryWaitMs = parseSecondsToMs(
182
+ process.env.CODERULE_MAX_WAIT_TIME,
183
+ baseConfig.maxQueryWaitMs
184
+ );
163
185
  logger.debug(
164
186
  {
165
187
  rootPath,
@@ -1093,7 +1115,7 @@ async function withRetries(op, logger2, context, maxAttempts) {
1093
1115
  }
1094
1116
  }
1095
1117
  }
1096
- async function uploadMissing(rootPath, missing, syncClient, logger2, maxAttempts, chunkSize = 64) {
1118
+ async function uploadMissing(rootPath, missing, syncClient, logger2, maxAttempts, chunkSize = 1) {
1097
1119
  if (!missing || missing.length === 0) return;
1098
1120
  const total = missing.length;
1099
1121
  const chunks = [];
@@ -1135,7 +1157,7 @@ async function uploadMissing(rootPath, missing, syncClient, logger2, maxAttempts
1135
1157
  async function ensureSnapshotCreated(rootPath, computation, syncClient, logger2, options) {
1136
1158
  const { snapshotHash, files } = computation;
1137
1159
  const maxAttempts = options?.maxAttempts ?? 5;
1138
- const uploadChunkSize = options?.uploadChunkSize ?? 64;
1160
+ const uploadChunkSize = options?.uploadChunkSize ?? 1;
1139
1161
  let status = await withRetries(
1140
1162
  () => syncClient.checkSnapshotStatus(snapshotHash),
1141
1163
  logger2,
@@ -1240,7 +1262,10 @@ async function runInitialSyncPipeline(runtime) {
1240
1262
  runtime.snapshotsRepo,
1241
1263
  runtime.clients.sync,
1242
1264
  syncLogger,
1243
- { maxAttempts: runtime.config.maxSnapshotAttempts }
1265
+ {
1266
+ maxAttempts: runtime.config.maxSnapshotAttempts,
1267
+ uploadChunkSize: runtime.config.uploadChunkSize
1268
+ }
1244
1269
  );
1245
1270
  return result;
1246
1271
  }
@@ -1644,7 +1669,10 @@ var ServiceRunner = class {
1644
1669
  this.runtime.snapshotsRepo,
1645
1670
  this.runtime.clients.sync,
1646
1671
  log,
1647
- { maxAttempts: this.runtime.config.maxSnapshotAttempts }
1672
+ {
1673
+ maxAttempts: this.runtime.config.maxSnapshotAttempts,
1674
+ uploadChunkSize: this.runtime.config.uploadChunkSize
1675
+ }
1648
1676
  );
1649
1677
  this.runtime.outbox.ack(job.id, this.fsControlLeaseOwner);
1650
1678
  this.state.updateSnapshotReady(result.createdAt);
@@ -1771,7 +1799,9 @@ var ENV_FLAG_MAP = {
1771
1799
  "queue-poll": "CODERULE_QUEUE_POLL_INTERVAL_MS",
1772
1800
  "hash-batch": "CODERULE_HASH_BATCH_SIZE",
1773
1801
  "hash-lease": "CODERULE_HASH_LEASE_MS",
1774
- "max-snapshot-attempts": "CODERULE_MAX_SNAPSHOT_ATTEMPTS"
1802
+ "max-snapshot-attempts": "CODERULE_MAX_SNAPSHOT_ATTEMPTS",
1803
+ "upload-chunk-size": "CODERULE_UPLOAD_CHUNK_SIZE",
1804
+ "max-wait-time": "CODERULE_MAX_WAIT_TIME"
1775
1805
  };
1776
1806
  function printUsage() {
1777
1807
  console.log(`Usage: coderule-scanner [token] [options]
@@ -1795,6 +1825,8 @@ Options:
1795
1825
  --hash-batch <n> Override CODERULE_HASH_BATCH_SIZE
1796
1826
  --hash-lease <ms> Override CODERULE_HASH_LEASE_MS
1797
1827
  --max-snapshot-attempts <n> Override CODERULE_MAX_SNAPSHOT_ATTEMPTS
1828
+ --upload-chunk-size <n> Override CODERULE_UPLOAD_CHUNK_SIZE (default 1)
1829
+ --max-wait-time <sec> Override CODERULE_MAX_WAIT_TIME (default 50s)
1798
1830
  KEY=value Set arbitrary environment variable
1799
1831
  --help Show this message
1800
1832
  `);