@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.js CHANGED
@@ -30,6 +30,8 @@ var DEFAULT_QUEUE_POLL_INTERVAL_MS = 500;
30
30
  var DEFAULT_HASH_BATCH_SIZE = 32;
31
31
  var DEFAULT_MAX_SNAPSHOT_ATTEMPTS = 5;
32
32
  var DEFAULT_HTTP_TIMEOUT_MS = 12e4;
33
+ var DEFAULT_UPLOAD_CHUNK_SIZE = 1;
34
+ var DEFAULT_MAX_QUERY_WAIT_MS = 5e4;
33
35
 
34
36
  // src/config/Configurator.ts
35
37
  var DEFAULT_RETRIEVAL_FORMATTER = "standard";
@@ -57,6 +59,14 @@ function parseInteger(value, fallback) {
57
59
  }
58
60
  return parsed;
59
61
  }
62
+ function parseSecondsToMs(value, fallbackMs) {
63
+ if (!value) return fallbackMs;
64
+ const seconds = Number.parseInt(value, 10);
65
+ if (Number.isNaN(seconds) || seconds <= 0) {
66
+ throw new Error(`Invalid seconds value: ${value}`);
67
+ }
68
+ return seconds * 1e3;
69
+ }
60
70
  function parseFormatter(value) {
61
71
  if (!value) return DEFAULT_RETRIEVAL_FORMATTER;
62
72
  const normalized = value.toLowerCase();
@@ -103,7 +113,9 @@ async function resolveConfig({
103
113
  maxSnapshotAttempts: DEFAULTS.maxSnapshotAttempts,
104
114
  retrievalFormatter: parseFormatter(
105
115
  process.env.CODERULE_RETRIEVAL_FORMATTER
106
- )
116
+ ),
117
+ uploadChunkSize: DEFAULT_UPLOAD_CHUNK_SIZE,
118
+ maxQueryWaitMs: DEFAULT_MAX_QUERY_WAIT_MS
107
119
  };
108
120
  if (process.env.CODERULE_SNAPSHOT_DEBOUNCE_MS) {
109
121
  baseConfig.snapshotDebounceMs = parseInteger(
@@ -145,6 +157,16 @@ async function resolveConfig({
145
157
  process.env.CODERULE_HTTP_TIMEOUT,
146
158
  DEFAULT_HTTP_TIMEOUT_MS
147
159
  );
160
+ if (process.env.CODERULE_UPLOAD_CHUNK_SIZE) {
161
+ baseConfig.uploadChunkSize = parseInteger(
162
+ process.env.CODERULE_UPLOAD_CHUNK_SIZE,
163
+ baseConfig.uploadChunkSize
164
+ );
165
+ }
166
+ baseConfig.maxQueryWaitMs = parseSecondsToMs(
167
+ process.env.CODERULE_MAX_WAIT_TIME,
168
+ baseConfig.maxQueryWaitMs
169
+ );
148
170
  logger.debug(
149
171
  {
150
172
  rootPath,
@@ -1078,7 +1100,7 @@ async function withRetries(op, logger2, context, maxAttempts) {
1078
1100
  }
1079
1101
  }
1080
1102
  }
1081
- async function uploadMissing(rootPath, missing, syncClient, logger2, maxAttempts, chunkSize = 64) {
1103
+ async function uploadMissing(rootPath, missing, syncClient, logger2, maxAttempts, chunkSize = 1) {
1082
1104
  if (!missing || missing.length === 0) return;
1083
1105
  const total = missing.length;
1084
1106
  const chunks = [];
@@ -1120,7 +1142,7 @@ async function uploadMissing(rootPath, missing, syncClient, logger2, maxAttempts
1120
1142
  async function ensureSnapshotCreated(rootPath, computation, syncClient, logger2, options) {
1121
1143
  const { snapshotHash, files } = computation;
1122
1144
  const maxAttempts = options?.maxAttempts ?? 5;
1123
- const uploadChunkSize = options?.uploadChunkSize ?? 64;
1145
+ const uploadChunkSize = options?.uploadChunkSize ?? 1;
1124
1146
  let status = await withRetries(
1125
1147
  () => syncClient.checkSnapshotStatus(snapshotHash),
1126
1148
  logger2,
@@ -1225,7 +1247,10 @@ async function runInitialSyncPipeline(runtime) {
1225
1247
  runtime.snapshotsRepo,
1226
1248
  runtime.clients.sync,
1227
1249
  syncLogger,
1228
- { maxAttempts: runtime.config.maxSnapshotAttempts }
1250
+ {
1251
+ maxAttempts: runtime.config.maxSnapshotAttempts,
1252
+ uploadChunkSize: runtime.config.uploadChunkSize
1253
+ }
1229
1254
  );
1230
1255
  return result;
1231
1256
  }
@@ -1629,7 +1654,10 @@ var ServiceRunner = class {
1629
1654
  this.runtime.snapshotsRepo,
1630
1655
  this.runtime.clients.sync,
1631
1656
  log,
1632
- { maxAttempts: this.runtime.config.maxSnapshotAttempts }
1657
+ {
1658
+ maxAttempts: this.runtime.config.maxSnapshotAttempts,
1659
+ uploadChunkSize: this.runtime.config.uploadChunkSize
1660
+ }
1633
1661
  );
1634
1662
  this.runtime.outbox.ack(job.id, this.fsControlLeaseOwner);
1635
1663
  this.state.updateSnapshotReady(result.createdAt);
@@ -1756,7 +1784,9 @@ var ENV_FLAG_MAP = {
1756
1784
  "queue-poll": "CODERULE_QUEUE_POLL_INTERVAL_MS",
1757
1785
  "hash-batch": "CODERULE_HASH_BATCH_SIZE",
1758
1786
  "hash-lease": "CODERULE_HASH_LEASE_MS",
1759
- "max-snapshot-attempts": "CODERULE_MAX_SNAPSHOT_ATTEMPTS"
1787
+ "max-snapshot-attempts": "CODERULE_MAX_SNAPSHOT_ATTEMPTS",
1788
+ "upload-chunk-size": "CODERULE_UPLOAD_CHUNK_SIZE",
1789
+ "max-wait-time": "CODERULE_MAX_WAIT_TIME"
1760
1790
  };
1761
1791
  function printUsage() {
1762
1792
  console.log(`Usage: coderule-scanner [token] [options]
@@ -1780,6 +1810,8 @@ Options:
1780
1810
  --hash-batch <n> Override CODERULE_HASH_BATCH_SIZE
1781
1811
  --hash-lease <ms> Override CODERULE_HASH_LEASE_MS
1782
1812
  --max-snapshot-attempts <n> Override CODERULE_MAX_SNAPSHOT_ATTEMPTS
1813
+ --upload-chunk-size <n> Override CODERULE_UPLOAD_CHUNK_SIZE (default 1)
1814
+ --max-wait-time <sec> Override CODERULE_MAX_WAIT_TIME (default 50s)
1783
1815
  KEY=value Set arbitrary environment variable
1784
1816
  --help Show this message
1785
1817
  `);