nightralph 0.0.27 → 0.0.31

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
@@ -142,7 +142,7 @@
142
142
  "format": "esm"
143
143
  },
144
144
  "src/orchestrator.ts": {
145
- "bytes": 57999,
145
+ "bytes": 59897,
146
146
  "imports": [
147
147
  {
148
148
  "path": "node:child_process",
@@ -234,7 +234,7 @@
234
234
  "format": "esm"
235
235
  },
236
236
  "src/index.ts": {
237
- "bytes": 10283,
237
+ "bytes": 10237,
238
238
  "imports": [
239
239
  {
240
240
  "path": "node:fs",
@@ -305,7 +305,7 @@
305
305
  "imports": [],
306
306
  "exports": [],
307
307
  "inputs": {},
308
- "bytes": 165317
308
+ "bytes": 168087
309
309
  },
310
310
  "dist/index.js": {
311
311
  "imports": [
@@ -462,13 +462,13 @@
462
462
  "entryPoint": "src/index.ts",
463
463
  "inputs": {
464
464
  "src/index.ts": {
465
- "bytesInOutput": 6890
465
+ "bytesInOutput": 6851
466
466
  },
467
467
  "src/setup.ts": {
468
468
  "bytesInOutput": 4265
469
469
  },
470
470
  "src/orchestrator.ts": {
471
- "bytesInOutput": 40993
471
+ "bytesInOutput": 42217
472
472
  },
473
473
  "src/worktree.ts": {
474
474
  "bytesInOutput": 3788
@@ -489,7 +489,7 @@
489
489
  "bytesInOutput": 1937
490
490
  }
491
491
  },
492
- "bytes": 77575
492
+ "bytes": 78760
493
493
  }
494
494
  }
495
495
  }
@@ -318,7 +318,26 @@ function getProviderArgs(cmd) {
318
318
  return PROVIDER_ARGS[name] ?? [];
319
319
  }
320
320
  __name(getProviderArgs, "getProviderArgs");
321
- const THINKING_LEVELS = [
321
+ const EFFORT_LADDERS = {
322
+ pi: [
323
+ "off",
324
+ "minimal",
325
+ "low",
326
+ "medium",
327
+ "high",
328
+ "xhigh",
329
+ "max"
330
+ ],
331
+ claude: [
332
+ "low",
333
+ "medium",
334
+ "high",
335
+ "xhigh",
336
+ "max"
337
+ ],
338
+ codex: ["low", "medium", "high"]
339
+ };
340
+ const ALL_EFFORT_LEVELS = [
322
341
  "off",
323
342
  "minimal",
324
343
  "low",
@@ -327,12 +346,14 @@ const THINKING_LEVELS = [
327
346
  "xhigh",
328
347
  "max"
329
348
  ];
330
- function escalateThinking(level) {
349
+ function escalateEffort(provider, level) {
331
350
  if (!level) return "high";
332
- const i = THINKING_LEVELS.indexOf(level);
333
- return THINKING_LEVELS[Math.min(i + 1, THINKING_LEVELS.length - 1)];
351
+ const ladder = EFFORT_LADDERS[provider];
352
+ const i = ladder.indexOf(level);
353
+ if (i === -1) return level;
354
+ return ladder[Math.min(i + 1, ladder.length - 1)];
334
355
  }
335
- __name(escalateThinking, "escalateThinking");
356
+ __name(escalateEffort, "escalateEffort");
336
357
  function formatStreamLine(line) {
337
358
  let obj;
338
359
  try {
@@ -468,14 +489,39 @@ function spawnAgent(opts) {
468
489
  if (opts.model) {
469
490
  args.push("--model", opts.model);
470
491
  }
471
- if (opts.maxTurns) {
472
- args.push("--max-turns", String(opts.maxTurns));
473
- }
474
492
  const providerName = basename(opts.agentCmd);
475
493
  const isClaude = providerName === "claude";
476
494
  const isPi = providerName === "pi";
477
- if (isPi && opts.thinking) {
478
- args.push("--thinking", opts.thinking);
495
+ if (opts.maxTurns) {
496
+ if (isClaude) {
497
+ args.push(
498
+ "--max-turns",
499
+ String(opts.maxTurns)
500
+ );
501
+ } else if (opts.onLine) {
502
+ opts.onLine(
503
+ `Warning: --max-turns not supported by ${providerName}, skipping`
504
+ );
505
+ }
506
+ }
507
+ if (opts.effort && providerName in EFFORT_LADDERS) {
508
+ const ladder = EFFORT_LADDERS[providerName];
509
+ if (!ladder.includes(opts.effort)) {
510
+ if (opts.onLine) {
511
+ opts.onLine(
512
+ `Warning: effort '${opts.effort}' not supported by ${providerName}, skipping`
513
+ );
514
+ }
515
+ } else if (isPi) {
516
+ args.push("--thinking", opts.effort);
517
+ } else if (isClaude) {
518
+ args.push("--effort", opts.effort);
519
+ } else if (providerName === "codex") {
520
+ args.push(
521
+ "-c",
522
+ `model_reasoning_effort=${opts.effort}`
523
+ );
524
+ }
479
525
  }
480
526
  const prefix = opts.label ? ` [${opts.label}] ` : " ";
481
527
  let promptFile = null;
@@ -706,7 +752,7 @@ Prompt for first ready ticket (${firstReady[0].filename}):
706
752
  Test command: ${opts.testCmd ?? "(none)"}`
707
753
  );
708
754
  console.log(
709
- `Thinking: ${opts.thinking ?? "(provider default)"}`
755
+ `Effort: ${opts.effort ?? "(provider default)"}`
710
756
  );
711
757
  console.log(
712
758
  `Retries: ${opts.retries ?? DEFAULT_RETRIES}`
@@ -835,7 +881,7 @@ async function respawnAndRetryMerge(opts) {
835
881
  return mergeResult.success;
836
882
  }
837
883
  __name(respawnAndRetryMerge, "respawnAndRetryMerge");
838
- const DEFAULT_RETRIES = 2;
884
+ const DEFAULT_RETRIES = 3;
839
885
  const DEFAULT_RETRY_DELAY = 30;
840
886
  function retryDelayFor(base, attempt) {
841
887
  return base * 2 ** (attempt - 2);
@@ -883,7 +929,7 @@ async function runTicketAttempt(opts) {
883
929
  cwd: worktree.worktreePath,
884
930
  label: ticket.filename.replace(/\.md$/, ""),
885
931
  maxTurns: opts.maxTurns,
886
- thinking: opts.thinking,
932
+ effort: opts.effort,
887
933
  onLine: /* @__PURE__ */ __name((line) => d.log(line), "onLine")
888
934
  });
889
935
  if (agentResult.timedOut) {
@@ -962,8 +1008,9 @@ __name(runTicketAttempt, "runTicketAttempt");
962
1008
  async function runTicketAttempts(opts) {
963
1009
  const { ticket, d } = opts;
964
1010
  const maxAttempts = opts.retries + 1;
965
- const isPi = basename(opts.agentCmd) === "pi";
966
- let thinking = opts.thinking;
1011
+ const providerName = basename(opts.agentCmd);
1012
+ const isKnown = providerName in EFFORT_LADDERS;
1013
+ let effort = opts.effort;
967
1014
  let outcome = {
968
1015
  kind: "no-commits",
969
1016
  worktreePath: "",
@@ -973,10 +1020,15 @@ async function runTicketAttempts(opts) {
973
1020
  if (attempt === 1) {
974
1021
  d.log(` Starting ${ticket.filename}`);
975
1022
  } else {
976
- thinking = escalateThinking(thinking);
1023
+ if (isKnown) {
1024
+ effort = escalateEffort(
1025
+ providerName,
1026
+ effort
1027
+ );
1028
+ }
977
1029
  const delay = retryDelayFor(opts.retryDelay, attempt);
978
1030
  d.log(
979
- ` ${ticket.filename}: retrying (attempt ${attempt}/${maxAttempts}` + (isPi ? `, thinking ${thinking}` : "") + (delay > 0 ? `, waiting ${delay}s` : "") + ")"
1031
+ ` ${ticket.filename}: retrying (attempt ${attempt}/${maxAttempts}` + (isKnown && effort ? `, effort ${effort}` : "") + (delay > 0 ? `, waiting ${delay}s` : "") + ")"
980
1032
  );
981
1033
  if (delay > 0) await sleep(delay * 1e3);
982
1034
  }
@@ -984,7 +1036,7 @@ async function runTicketAttempts(opts) {
984
1036
  outcome = await runTicketAttempt({
985
1037
  ...opts,
986
1038
  attempt,
987
- thinking
1039
+ effort
988
1040
  });
989
1041
  } catch (error) {
990
1042
  d.log(
@@ -1017,12 +1069,13 @@ function runProgress(tickets) {
1017
1069
  };
1018
1070
  }
1019
1071
  __name(runProgress, "runProgress");
1020
- async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, display, maxTurns, thinking, retries, retryDelay) {
1072
+ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, display, maxTurns, effort, retries, retryDelay) {
1021
1073
  mkdirSync(logsDir, { recursive: true });
1022
1074
  const d = display ?? createDisplay();
1023
1075
  const maxAttempts = (retries ?? DEFAULT_RETRIES) + 1;
1024
1076
  const delayBase = retryDelay ?? 0;
1025
- const isPi = basename(agentCmd) === "pi";
1077
+ const providerName = basename(agentCmd);
1078
+ const isKnown = providerName in EFFORT_LADDERS;
1026
1079
  let totalWaves = 0;
1027
1080
  for (const _ of simulateWaves(tickets)) totalWaves++;
1028
1081
  let totalCompleted = 0;
@@ -1060,7 +1113,7 @@ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, di
1060
1113
  );
1061
1114
  d.setTicketStatus(t.num, "in-progress");
1062
1115
  d.log(` Starting ${t.filename}`);
1063
- let level = thinking;
1116
+ let level = effort;
1064
1117
  let result = await spawnAgent({
1065
1118
  prompt,
1066
1119
  agentCmd,
@@ -1069,14 +1122,19 @@ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, di
1069
1122
  logPath: attemptLogPath(logsDir, t, 1, ".log"),
1070
1123
  label,
1071
1124
  maxTurns,
1072
- thinking: level,
1125
+ effort: level,
1073
1126
  onLine: /* @__PURE__ */ __name((line) => d.log(line), "onLine")
1074
1127
  });
1075
1128
  for (let attempt = 2; result.exitCode !== 0 && !result.timedOut && attempt <= maxAttempts; attempt++) {
1076
- level = escalateThinking(level);
1129
+ if (isKnown) {
1130
+ level = escalateEffort(
1131
+ providerName,
1132
+ level
1133
+ );
1134
+ }
1077
1135
  const delay = retryDelayFor(delayBase, attempt);
1078
1136
  d.log(
1079
- ` ${t.filename}: agent exited ${result.exitCode}; retrying (attempt ${attempt}/${maxAttempts}` + (isPi ? `, thinking ${level}` : "") + (delay > 0 ? `, waiting ${delay}s` : "") + ")"
1137
+ ` ${t.filename}: agent exited ${result.exitCode}; retrying (attempt ${attempt}/${maxAttempts}` + (isKnown && level ? `, effort ${level}` : "") + (delay > 0 ? `, waiting ${delay}s` : "") + ")"
1080
1138
  );
1081
1139
  if (delay > 0) await sleep(delay * 1e3);
1082
1140
  result = await spawnAgent({
@@ -1092,7 +1150,7 @@ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, di
1092
1150
  ),
1093
1151
  label,
1094
1152
  maxTurns,
1095
- thinking: level,
1153
+ effort: level,
1096
1154
  onLine: /* @__PURE__ */ __name((line) => d.log(line), "onLine")
1097
1155
  });
1098
1156
  }
@@ -1210,7 +1268,7 @@ async function runWavesIsolated(opts) {
1210
1268
  logsDir: opts.logsDir,
1211
1269
  testCmd: opts.testCmd,
1212
1270
  maxTurns: opts.maxTurns,
1213
- thinking: opts.thinking,
1271
+ effort: opts.effort,
1214
1272
  retries,
1215
1273
  retryDelay,
1216
1274
  d
@@ -1473,17 +1531,18 @@ Finished: ${totalCompleted} completed` + (remaining.length > 0 ? `, ${remaining.
1473
1531
  }
1474
1532
  __name(runWavesIsolated, "runWavesIsolated");
1475
1533
  export {
1534
+ ALL_EFFORT_LEVELS,
1476
1535
  COMPLETED_RE,
1477
1536
  DEFAULT_RETRIES,
1478
1537
  DEFAULT_RETRY_DELAY,
1479
- THINKING_LEVELS,
1538
+ EFFORT_LADDERS,
1480
1539
  TICKET_RE,
1481
1540
  TOOL_USE_RE,
1482
1541
  checkItems,
1483
1542
  createPiStreamFormatter,
1484
1543
  dryRun,
1485
1544
  dryRunIsolated,
1486
- escalateThinking,
1545
+ escalateEffort,
1487
1546
  findReadyTickets,
1488
1547
  formatErrorMessage,
1489
1548
  formatStreamLine,