nightralph 0.0.27 → 0.0.29

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/index.js CHANGED
@@ -1359,7 +1359,32 @@ function getProviderArgs(cmd) {
1359
1359
  return PROVIDER_ARGS[name] ?? [];
1360
1360
  }
1361
1361
  __name(getProviderArgs, "getProviderArgs");
1362
- var THINKING_LEVELS = [
1362
+ var EFFORT_LADDERS = {
1363
+ pi: [
1364
+ "off",
1365
+ "minimal",
1366
+ "low",
1367
+ "medium",
1368
+ "high",
1369
+ "xhigh",
1370
+ "max"
1371
+ ],
1372
+ claude: [
1373
+ "low",
1374
+ "medium",
1375
+ "high",
1376
+ "xhigh",
1377
+ "max"
1378
+ ],
1379
+ codex: [
1380
+ "minimal",
1381
+ "low",
1382
+ "medium",
1383
+ "high",
1384
+ "xhigh"
1385
+ ]
1386
+ };
1387
+ var ALL_EFFORT_LEVELS = [
1363
1388
  "off",
1364
1389
  "minimal",
1365
1390
  "low",
@@ -1368,12 +1393,14 @@ var THINKING_LEVELS = [
1368
1393
  "xhigh",
1369
1394
  "max"
1370
1395
  ];
1371
- function escalateThinking(level) {
1396
+ function escalateEffort(provider, level) {
1372
1397
  if (!level) return "high";
1373
- const i = THINKING_LEVELS.indexOf(level);
1374
- return THINKING_LEVELS[Math.min(i + 1, THINKING_LEVELS.length - 1)];
1398
+ const ladder = EFFORT_LADDERS[provider];
1399
+ const i = ladder.indexOf(level);
1400
+ if (i === -1) return level;
1401
+ return ladder[Math.min(i + 1, ladder.length - 1)];
1375
1402
  }
1376
- __name(escalateThinking, "escalateThinking");
1403
+ __name(escalateEffort, "escalateEffort");
1377
1404
  function formatStreamLine(line) {
1378
1405
  let obj;
1379
1406
  try {
@@ -1515,8 +1542,21 @@ function spawnAgent(opts) {
1515
1542
  const providerName = basename2(opts.agentCmd);
1516
1543
  const isClaude = providerName === "claude";
1517
1544
  const isPi = providerName === "pi";
1518
- if (isPi && opts.thinking) {
1519
- args.push("--thinking", opts.thinking);
1545
+ if (opts.effort && providerName in EFFORT_LADDERS) {
1546
+ const ladder = EFFORT_LADDERS[providerName];
1547
+ if (!ladder.includes(opts.effort)) {
1548
+ if (opts.onLine) {
1549
+ opts.onLine(
1550
+ `Warning: effort '${opts.effort}' not supported by ${providerName}, skipping`
1551
+ );
1552
+ }
1553
+ } else if (isPi) {
1554
+ args.push("--thinking", opts.effort);
1555
+ } else if (isClaude) {
1556
+ args.push("--effort", opts.effort);
1557
+ } else if (providerName === "codex") {
1558
+ args.push("-e", opts.effort);
1559
+ }
1520
1560
  }
1521
1561
  const prefix = opts.label ? ` [${opts.label}] ` : " ";
1522
1562
  let promptFile = null;
@@ -1747,7 +1787,7 @@ Prompt for first ready ticket (${firstReady[0].filename}):
1747
1787
  Test command: ${opts.testCmd ?? "(none)"}`
1748
1788
  );
1749
1789
  console.log(
1750
- `Thinking: ${opts.thinking ?? "(provider default)"}`
1790
+ `Effort: ${opts.effort ?? "(provider default)"}`
1751
1791
  );
1752
1792
  console.log(
1753
1793
  `Retries: ${opts.retries ?? DEFAULT_RETRIES}`
@@ -1876,7 +1916,7 @@ async function respawnAndRetryMerge(opts) {
1876
1916
  return mergeResult.success;
1877
1917
  }
1878
1918
  __name(respawnAndRetryMerge, "respawnAndRetryMerge");
1879
- var DEFAULT_RETRIES = 2;
1919
+ var DEFAULT_RETRIES = 3;
1880
1920
  var DEFAULT_RETRY_DELAY = 30;
1881
1921
  function retryDelayFor(base, attempt) {
1882
1922
  return base * 2 ** (attempt - 2);
@@ -1924,7 +1964,7 @@ async function runTicketAttempt(opts) {
1924
1964
  cwd: worktree.worktreePath,
1925
1965
  label: ticket.filename.replace(/\.md$/, ""),
1926
1966
  maxTurns: opts.maxTurns,
1927
- thinking: opts.thinking,
1967
+ effort: opts.effort,
1928
1968
  onLine: /* @__PURE__ */ __name((line) => d.log(line), "onLine")
1929
1969
  });
1930
1970
  if (agentResult.timedOut) {
@@ -2003,8 +2043,9 @@ __name(runTicketAttempt, "runTicketAttempt");
2003
2043
  async function runTicketAttempts(opts) {
2004
2044
  const { ticket, d } = opts;
2005
2045
  const maxAttempts = opts.retries + 1;
2006
- const isPi = basename2(opts.agentCmd) === "pi";
2007
- let thinking = opts.thinking;
2046
+ const providerName = basename2(opts.agentCmd);
2047
+ const isKnown = providerName in EFFORT_LADDERS;
2048
+ let effort = opts.effort;
2008
2049
  let outcome = {
2009
2050
  kind: "no-commits",
2010
2051
  worktreePath: "",
@@ -2014,10 +2055,15 @@ async function runTicketAttempts(opts) {
2014
2055
  if (attempt === 1) {
2015
2056
  d.log(` Starting ${ticket.filename}`);
2016
2057
  } else {
2017
- thinking = escalateThinking(thinking);
2058
+ if (isKnown) {
2059
+ effort = escalateEffort(
2060
+ providerName,
2061
+ effort
2062
+ );
2063
+ }
2018
2064
  const delay = retryDelayFor(opts.retryDelay, attempt);
2019
2065
  d.log(
2020
- ` ${ticket.filename}: retrying (attempt ${attempt}/${maxAttempts}` + (isPi ? `, thinking ${thinking}` : "") + (delay > 0 ? `, waiting ${delay}s` : "") + ")"
2066
+ ` ${ticket.filename}: retrying (attempt ${attempt}/${maxAttempts}` + (isKnown && effort ? `, effort ${effort}` : "") + (delay > 0 ? `, waiting ${delay}s` : "") + ")"
2021
2067
  );
2022
2068
  if (delay > 0) await sleep(delay * 1e3);
2023
2069
  }
@@ -2025,7 +2071,7 @@ async function runTicketAttempts(opts) {
2025
2071
  outcome = await runTicketAttempt({
2026
2072
  ...opts,
2027
2073
  attempt,
2028
- thinking
2074
+ effort
2029
2075
  });
2030
2076
  } catch (error) {
2031
2077
  d.log(
@@ -2058,12 +2104,13 @@ function runProgress(tickets) {
2058
2104
  };
2059
2105
  }
2060
2106
  __name(runProgress, "runProgress");
2061
- async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, display, maxTurns, thinking, retries, retryDelay) {
2107
+ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, display, maxTurns, effort, retries, retryDelay) {
2062
2108
  mkdirSync2(logsDir, { recursive: true });
2063
2109
  const d = display ?? createDisplay();
2064
2110
  const maxAttempts = (retries ?? DEFAULT_RETRIES) + 1;
2065
2111
  const delayBase = retryDelay ?? 0;
2066
- const isPi = basename2(agentCmd) === "pi";
2112
+ const providerName = basename2(agentCmd);
2113
+ const isKnown = providerName in EFFORT_LADDERS;
2067
2114
  let totalWaves = 0;
2068
2115
  for (const _ of simulateWaves(tickets)) totalWaves++;
2069
2116
  let totalCompleted = 0;
@@ -2101,7 +2148,7 @@ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, di
2101
2148
  );
2102
2149
  d.setTicketStatus(t.num, "in-progress");
2103
2150
  d.log(` Starting ${t.filename}`);
2104
- let level = thinking;
2151
+ let level = effort;
2105
2152
  let result = await spawnAgent({
2106
2153
  prompt,
2107
2154
  agentCmd,
@@ -2110,14 +2157,19 @@ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, di
2110
2157
  logPath: attemptLogPath(logsDir, t, 1, ".log"),
2111
2158
  label,
2112
2159
  maxTurns,
2113
- thinking: level,
2160
+ effort: level,
2114
2161
  onLine: /* @__PURE__ */ __name((line) => d.log(line), "onLine")
2115
2162
  });
2116
2163
  for (let attempt = 2; result.exitCode !== 0 && !result.timedOut && attempt <= maxAttempts; attempt++) {
2117
- level = escalateThinking(level);
2164
+ if (isKnown) {
2165
+ level = escalateEffort(
2166
+ providerName,
2167
+ level
2168
+ );
2169
+ }
2118
2170
  const delay = retryDelayFor(delayBase, attempt);
2119
2171
  d.log(
2120
- ` ${t.filename}: agent exited ${result.exitCode}; retrying (attempt ${attempt}/${maxAttempts}` + (isPi ? `, thinking ${level}` : "") + (delay > 0 ? `, waiting ${delay}s` : "") + ")"
2172
+ ` ${t.filename}: agent exited ${result.exitCode}; retrying (attempt ${attempt}/${maxAttempts}` + (isKnown && level ? `, effort ${level}` : "") + (delay > 0 ? `, waiting ${delay}s` : "") + ")"
2121
2173
  );
2122
2174
  if (delay > 0) await sleep(delay * 1e3);
2123
2175
  result = await spawnAgent({
@@ -2133,7 +2185,7 @@ async function runWaves(tickets, specBody, agentCmd, model, timeout, logsDir, di
2133
2185
  ),
2134
2186
  label,
2135
2187
  maxTurns,
2136
- thinking: level,
2188
+ effort: level,
2137
2189
  onLine: /* @__PURE__ */ __name((line) => d.log(line), "onLine")
2138
2190
  });
2139
2191
  }
@@ -2251,7 +2303,7 @@ async function runWavesIsolated(opts) {
2251
2303
  logsDir: opts.logsDir,
2252
2304
  testCmd: opts.testCmd,
2253
2305
  maxTurns: opts.maxTurns,
2254
- thinking: opts.thinking,
2306
+ effort: opts.effort,
2255
2307
  retries,
2256
2308
  retryDelay,
2257
2309
  d
@@ -2662,14 +2714,14 @@ yargs(hideBin(process.argv)).scriptName("nightralph").usage("$0 <command>").comm
2662
2714
  }).option("max-turns", {
2663
2715
  type: "number",
2664
2716
  describe: "Max agentic turns per ticket (forwarded to the agent CLI)"
2665
- }).option("thinking", {
2717
+ }).option("effort", {
2666
2718
  type: "string",
2667
- choices: THINKING_LEVELS,
2668
- describe: "Starting thinking level for the pi provider. Omitted = pi's default. Retries step up from here."
2719
+ choices: ALL_EFFORT_LEVELS,
2720
+ describe: "Starting effort level. Omitted = provider default. Retries step up from here."
2669
2721
  }).option("retries", {
2670
2722
  type: "number",
2671
2723
  default: DEFAULT_RETRIES,
2672
- describe: "Extra attempts per ticket after a failed run, each with a higher thinking level (pi). 0 disables retries."
2724
+ describe: "Extra attempts per ticket after a failed run, each with a higher effort level. 0 disables retries."
2673
2725
  }).option("retry-delay", {
2674
2726
  type: "number",
2675
2727
  default: DEFAULT_RETRY_DELAY,
@@ -2685,7 +2737,7 @@ yargs(hideBin(process.argv)).scriptName("nightralph").usage("$0 <command>").comm
2685
2737
  testCmd: argv.testCmd,
2686
2738
  stopOnConflict: argv.X,
2687
2739
  maxTurns: argv.maxTurns ?? argv.turns,
2688
- thinking: argv.thinking,
2740
+ effort: argv.effort,
2689
2741
  retries: argv.retries,
2690
2742
  retryDelay: argv.retryDelay
2691
2743
  });
@@ -2768,7 +2820,7 @@ async function runExecute(argv) {
2768
2820
  conflictStrategy,
2769
2821
  progressPath,
2770
2822
  testCmd,
2771
- thinking: argv.thinking,
2823
+ effort: argv.effort,
2772
2824
  retries: argv.retries,
2773
2825
  retryDelay: argv.retryDelay
2774
2826
  });
@@ -2800,7 +2852,7 @@ async function runExecute(argv) {
2800
2852
  display,
2801
2853
  testCmd,
2802
2854
  maxTurns: argv.maxTurns,
2803
- thinking: argv.thinking,
2855
+ effort: argv.effort,
2804
2856
  retries: argv.retries,
2805
2857
  retryDelay: argv.retryDelay
2806
2858
  });
@@ -2814,7 +2866,7 @@ async function runExecute(argv) {
2814
2866
  logsDir,
2815
2867
  display,
2816
2868
  argv.maxTurns,
2817
- argv.thinking,
2869
+ argv.effort,
2818
2870
  argv.retries,
2819
2871
  argv.retryDelay
2820
2872
  );