nightralph 0.0.41 → 0.0.43

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/meta.json CHANGED
@@ -27,7 +27,7 @@
27
27
  "format": "esm"
28
28
  },
29
29
  "src/worktree.ts": {
30
- "bytes": 5906,
30
+ "bytes": 5414,
31
31
  "imports": [
32
32
  {
33
33
  "path": "node:child_process",
@@ -105,7 +105,7 @@
105
105
  "format": "esm"
106
106
  },
107
107
  "src/display.ts": {
108
- "bytes": 12060,
108
+ "bytes": 12695,
109
109
  "imports": [
110
110
  {
111
111
  "path": "<runtime>",
@@ -142,7 +142,7 @@
142
142
  "format": "esm"
143
143
  },
144
144
  "src/orchestrator.ts": {
145
- "bytes": 68690,
145
+ "bytes": 70485,
146
146
  "imports": [
147
147
  {
148
148
  "path": "node:child_process",
@@ -239,7 +239,7 @@
239
239
  "format": "esm"
240
240
  },
241
241
  "src/index.ts": {
242
- "bytes": 10174,
242
+ "bytes": 10581,
243
243
  "imports": [
244
244
  {
245
245
  "path": "node:fs",
@@ -310,7 +310,7 @@
310
310
  "imports": [],
311
311
  "exports": [],
312
312
  "inputs": {},
313
- "bytes": 182428
313
+ "bytes": 185720
314
314
  },
315
315
  "dist/index.js": {
316
316
  "imports": [
@@ -472,16 +472,16 @@
472
472
  "entryPoint": "src/index.ts",
473
473
  "inputs": {
474
474
  "src/index.ts": {
475
- "bytesInOutput": 6856
475
+ "bytesInOutput": 7078
476
476
  },
477
477
  "src/setup.ts": {
478
478
  "bytesInOutput": 4816
479
479
  },
480
480
  "src/orchestrator.ts": {
481
- "bytesInOutput": 47579
481
+ "bytesInOutput": 48600
482
482
  },
483
483
  "src/worktree.ts": {
484
- "bytesInOutput": 4523
484
+ "bytesInOutput": 4088
485
485
  },
486
486
  "src/progress.ts": {
487
487
  "bytesInOutput": 4419
@@ -490,7 +490,7 @@
490
490
  "bytesInOutput": 4995
491
491
  },
492
492
  "src/display.ts": {
493
- "bytesInOutput": 7931
493
+ "bytesInOutput": 8285
494
494
  },
495
495
  "src/testcmd.ts": {
496
496
  "bytesInOutput": 1914
@@ -499,7 +499,7 @@
499
499
  "bytesInOutput": 1937
500
500
  }
501
501
  },
502
- "bytes": 85416
502
+ "bytes": 86578
503
503
  }
504
504
  }
505
505
  }
@@ -865,7 +865,6 @@ function dryRunIsolated(opts) {
865
865
  for (const t of ready) {
866
866
  const num = String(t.num).padStart(2, "0");
867
867
  const branchName = buildBranchName(
868
- opts.repoRoot,
869
868
  opts.repoName,
870
869
  t
871
870
  );
@@ -909,6 +908,9 @@ Test command: ${opts.testCmd}`
909
908
  console.log(
910
909
  `Retry delay: ${opts.retryDelay ?? 0}s`
911
910
  );
911
+ console.log(
912
+ `Concurrency: ${opts.concurrency ?? DEFAULT_CONCURRENCY}`
913
+ );
912
914
  console.log(
913
915
  `
914
916
  Merge strategy: ${strategyDesc}`
@@ -1030,6 +1032,35 @@ async function respawnAndRetryMerge(opts) {
1030
1032
  __name(respawnAndRetryMerge, "respawnAndRetryMerge");
1031
1033
  const DEFAULT_RETRIES = 3;
1032
1034
  const DEFAULT_RETRY_DELAY = 30;
1035
+ const DEFAULT_CONCURRENCY = 5;
1036
+ async function runPool(items, limit, fn) {
1037
+ const size = Math.max(1, Math.floor(limit));
1038
+ const results = new Array(
1039
+ items.length
1040
+ );
1041
+ let next = 0;
1042
+ async function worker() {
1043
+ while (next < items.length) {
1044
+ const i = next++;
1045
+ try {
1046
+ results[i] = {
1047
+ status: "fulfilled",
1048
+ value: await fn(items[i])
1049
+ };
1050
+ } catch (reason) {
1051
+ results[i] = { status: "rejected", reason };
1052
+ }
1053
+ }
1054
+ }
1055
+ __name(worker, "worker");
1056
+ const workers = Array.from(
1057
+ { length: Math.min(size, items.length) },
1058
+ () => worker()
1059
+ );
1060
+ await Promise.all(workers);
1061
+ return results;
1062
+ }
1063
+ __name(runPool, "runPool");
1033
1064
  function retryDelayFor(base, attempt) {
1034
1065
  return base * 2 ** (attempt - 2);
1035
1066
  }
@@ -1214,11 +1245,12 @@ function runProgress(tickets) {
1214
1245
  };
1215
1246
  }
1216
1247
  __name(runProgress, "runProgress");
1217
- async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, testCmd, display, maxTurns, effort, retries, retryDelay) {
1248
+ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, testCmd, display, maxTurns, effort, retries, retryDelay, concurrency) {
1218
1249
  mkdirSync(logsDir, { recursive: true });
1219
1250
  const d = display ?? createDisplay();
1220
1251
  const maxAttempts = (retries ?? DEFAULT_RETRIES) + 1;
1221
1252
  const delayBase = retryDelay ?? 0;
1253
+ const poolSize = concurrency ?? DEFAULT_CONCURRENCY;
1222
1254
  const providerName = basename(agentCmd);
1223
1255
  const isKnown = providerName in EFFORT_LADDERS;
1224
1256
  let totalWaves = 0;
@@ -1249,8 +1281,10 @@ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, te
1249
1281
  filename: t.filename
1250
1282
  }))
1251
1283
  );
1252
- const results = await Promise.allSettled(
1253
- ready.map(async (t) => {
1284
+ const results = await runPool(
1285
+ ready,
1286
+ poolSize,
1287
+ async (t) => {
1254
1288
  const prompt = renderPrompt(
1255
1289
  specBody,
1256
1290
  t,
@@ -1304,7 +1338,7 @@ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, te
1304
1338
  });
1305
1339
  }
1306
1340
  return { ticket: t, result };
1307
- })
1341
+ }
1308
1342
  );
1309
1343
  let waveCompleted = 0;
1310
1344
  for (const r of results) {
@@ -1357,6 +1391,7 @@ async function runWavesIsolated(opts) {
1357
1391
  const d = opts.display ?? createDisplay();
1358
1392
  const retries = opts.retries ?? DEFAULT_RETRIES;
1359
1393
  const retryDelay = opts.retryDelay ?? 0;
1394
+ const poolSize = opts.concurrency ?? DEFAULT_CONCURRENCY;
1360
1395
  let totalWaves = 0;
1361
1396
  for (const _ of simulateWaves(opts.tickets)) totalWaves++;
1362
1397
  const repoRoot = getRepoRoot();
@@ -1408,8 +1443,10 @@ async function runWavesIsolated(opts) {
1408
1443
  filename: t.filename
1409
1444
  }))
1410
1445
  );
1411
- const outcomes = await Promise.all(
1412
- ready.map((t) => runTicketAttempts({
1446
+ const settled = await runPool(
1447
+ ready,
1448
+ poolSize,
1449
+ (t) => runTicketAttempts({
1413
1450
  ticket: t,
1414
1451
  repoRoot,
1415
1452
  repoName,
@@ -1425,7 +1462,10 @@ async function runWavesIsolated(opts) {
1425
1462
  retries,
1426
1463
  retryDelay,
1427
1464
  d
1428
- }))
1465
+ })
1466
+ );
1467
+ const outcomes = settled.map(
1468
+ (r) => r.status === "fulfilled" ? r.value : { kind: "error", error: r.reason }
1429
1469
  );
1430
1470
  let waveCompleted = 0;
1431
1471
  const successfulBranches = [];
@@ -1703,6 +1743,7 @@ __name(runWavesIsolated, "runWavesIsolated");
1703
1743
  export {
1704
1744
  ALL_EFFORT_LEVELS,
1705
1745
  COMPLETED_RE,
1746
+ DEFAULT_CONCURRENCY,
1706
1747
  DEFAULT_RETRIES,
1707
1748
  DEFAULT_RETRY_DELAY,
1708
1749
  EFFORT_LADDERS,
@@ -1726,6 +1767,7 @@ export {
1726
1767
  renderMergePrompt,
1727
1768
  renderPrompt,
1728
1769
  retryDelayFor,
1770
+ runPool,
1729
1771
  runWaves,
1730
1772
  runWavesIsolated,
1731
1773
  scanTickets,