claude-yes 1.24.2 → 1.26.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
@@ -5263,6 +5263,74 @@ class TerminalTextRender {
5263
5263
  }
5264
5264
  }
5265
5265
 
5266
+ // ts/defineConfig.ts
5267
+ async function defineCliYesConfig(cfg) {
5268
+ if (typeof cfg === "function")
5269
+ cfg = await cfg({ clis: {} });
5270
+ return cfg;
5271
+ }
5272
+
5273
+ // cli-yes.config.ts
5274
+ process.env.VERBOSE && console.log("loading cli-yes.config.ts from " + import.meta.url);
5275
+ var cli_yes_config_default = defineCliYesConfig({
5276
+ clis: {
5277
+ qwen: {
5278
+ install: "npm install -g @qwen-code/qwen-code@latest",
5279
+ version: "qwen --version"
5280
+ },
5281
+ grok: {
5282
+ install: "npm install -g @vibe-kit/grok-cli",
5283
+ ready: [/^ │ ❯ /],
5284
+ enter: [/^ 1. Yes/]
5285
+ },
5286
+ claude: {
5287
+ promptArg: "first-arg",
5288
+ install: "npm install -g @anthropic-ai/claude-code",
5289
+ restoreArgs: ["--continue"],
5290
+ ready: [/\? for shortcuts/],
5291
+ enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
5292
+ fatal: [
5293
+ /No conversation found to continue/,
5294
+ /⎿ Claude usage limit reached\./,
5295
+ /^error: unknown option/
5296
+ ],
5297
+ defaultArgs: ["--model=sonnet"]
5298
+ },
5299
+ gemini: {
5300
+ install: "npm install -g @google/gemini-cli",
5301
+ ready: [/Type your message/],
5302
+ enter: [/│ ● 1. Yes, allow once/],
5303
+ fatal: []
5304
+ },
5305
+ codex: {
5306
+ promptArg: "first-arg",
5307
+ install: "npm install -g @openai/codex-cli",
5308
+ ready: [/⏎ send/],
5309
+ enter: [
5310
+ /> 1. Yes, allow Codex to work in this folder/,
5311
+ /> 1. Approve and run now/
5312
+ ],
5313
+ fatal: [/Error: The cursor position could not be read within/],
5314
+ defaultArgs: ["--search"],
5315
+ noEOL: true
5316
+ },
5317
+ copilot: {
5318
+ promptArg: "--prompt",
5319
+ install: "npm install -g @github/copilot",
5320
+ ready: [/^ +> /, /Ctrl\+c Exit/],
5321
+ enter: [/ │ ❯ 1. Yes, proceed/, /❯ 1. Yes/],
5322
+ fatal: []
5323
+ },
5324
+ cursor: {
5325
+ install: "open https://cursor.com/ja/docs/cli/installation",
5326
+ binary: "cursor-agent",
5327
+ ready: [/\/ commands/],
5328
+ enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
5329
+ fatal: [/^ Error: You've hit your usage limit/]
5330
+ }
5331
+ }
5332
+ });
5333
+
5266
5334
  // ts/idleWaiter.ts
5267
5335
  class IdleWaiter {
5268
5336
  lastActivityTime = Date.now();
@@ -5516,95 +5584,106 @@ function shouldUseLock(cwd) {
5516
5584
  return true;
5517
5585
  }
5518
5586
 
5519
- // ts/index.ts
5520
- var CLI_CONFIGURES = {
5521
- grok: {
5522
- install: "npm install -g @vibe-kit/grok-cli",
5523
- ready: [/^ /],
5524
- enter: [/^ 1. Yes/]
5525
- },
5526
- claude: {
5527
- install: "npm install -g @anthropic-ai/claude-code",
5528
- ready: [/\? for shortcuts/],
5529
- enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
5530
- fatal: [
5531
- /No conversation found to continue/,
5532
- /⎿ Claude usage limit reached\./
5533
- ]
5534
- },
5535
- gemini: {
5536
- install: "npm install -g @google/gemini-cli",
5537
- ready: [/Type your message/],
5538
- enter: [/│ ● 1. Yes, allow once/],
5539
- fatal: []
5540
- },
5541
- codex: {
5542
- install: "npm install -g @openai/codex-cli",
5543
- ready: [/⏎ send/],
5544
- enter: [
5545
- /> 1. Yes, allow Codex to work in this folder/,
5546
- /> 1. Approve and run now/
5547
- ],
5548
- fatal: [/Error: The cursor position could not be read within/],
5549
- ensureArgs: (args) => {
5550
- if (!args.includes("--search"))
5551
- return ["--search", ...args];
5552
- return args;
5587
+ // ts/tryCatch.ts
5588
+ function catcher(catchFn, fn) {
5589
+ if (!fn)
5590
+ return (fn2) => catcher(catchFn, fn2);
5591
+ return (...args) => {
5592
+ try {
5593
+ return fn(...args);
5594
+ } catch (error) {
5595
+ return catchFn(error);
5553
5596
  }
5554
- },
5555
- copilot: {
5556
- install: "npm install -g @github/copilot",
5557
- ready: [/^ +> /, /Ctrl\+c Exit/],
5558
- enter: [/ │ ❯ 1. Yes, proceed/, /❯ 1. Yes/],
5559
- fatal: []
5560
- },
5561
- cursor: {
5562
- install: "open https://cursor.com/ja/docs/cli/installation",
5563
- binary: "cursor-agent",
5564
- ready: [/\/ commands/],
5565
- enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
5566
- fatal: [/^ Error: You've hit your usage limit/]
5567
- }
5568
- };
5569
- async function claudeYes({
5570
- cli = "claude",
5597
+ };
5598
+ }
5599
+
5600
+ // ts/yesLog.ts
5601
+ import { appendFileSync, rmSync } from "node:fs";
5602
+
5603
+ // node_modules/tsa-composer/dist/index.js
5604
+ function tsaStringJoiner(tsa, ...slots) {
5605
+ return [tsa.reduce((acc, s, i) => acc + s + (slots[i] ?? ""), "")];
5606
+ }
5607
+ function tsaComposer(parse, fn) {
5608
+ if (!parse)
5609
+ return tsaComposer(tsaStringJoiner);
5610
+ if (!fn)
5611
+ return (fn2) => tsaComposer(parse, fn2);
5612
+ const composedFn = function(...args) {
5613
+ const [tsa, ...slots] = args;
5614
+ if (!isTSA(tsa))
5615
+ return fn(...args);
5616
+ return fn(...parse(tsa, ...slots));
5617
+ };
5618
+ Object.setPrototypeOf(composedFn, fn);
5619
+ Object.getOwnPropertyNames(fn).forEach((prop2) => {
5620
+ if (prop2 !== "length" && prop2 !== "name" && prop2 !== "prototype") {
5621
+ Object.defineProperty(composedFn, prop2, Object.getOwnPropertyDescriptor(fn, prop2));
5622
+ }
5623
+ });
5624
+ return composedFn;
5625
+ }
5626
+ function isTSA(tsa) {
5627
+ return Array.isArray(tsa) && "raw" in tsa && Array.isArray(tsa.raw);
5628
+ }
5629
+
5630
+ // ts/yesLog.ts
5631
+ var initial = true;
5632
+ var yesLog = tsaComposer()(catcher((error) => {
5633
+ console.error("yesLog error:", error);
5634
+ }, function yesLog2(msg) {
5635
+ if (!process.env.VERBOSE)
5636
+ return;
5637
+ if (initial)
5638
+ rmSync("./agent-yes.log");
5639
+ initial = false;
5640
+ appendFileSync("./agent-yes.log", `${msg}
5641
+ `);
5642
+ }));
5643
+
5644
+ // ts/index.ts
5645
+ var config = await cli_yes_config_default;
5646
+ var CLIS_CONFIG = config.clis;
5647
+ var SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
5648
+ async function cliYes({
5649
+ cli,
5571
5650
  cliArgs = [],
5572
5651
  prompt,
5652
+ robust = true,
5573
5653
  cwd,
5574
5654
  env,
5575
5655
  exitOnIdle,
5576
5656
  logFile,
5577
5657
  removeControlCharactersFromStdout = false,
5578
5658
  verbose = false,
5579
- disableLock = false
5580
- } = {}) {
5581
- const continueArgs = {
5582
- codex: "resume --last".split(" "),
5583
- claude: "--continue".split(" "),
5584
- gemini: []
5585
- };
5659
+ queue = true
5660
+ }) {
5661
+ if (!cli)
5662
+ throw new Error(`cli is required`);
5663
+ const conf = CLIS_CONFIG[cli] || phpdie_default2(`Unsupported cli tool: ${cli}`);
5586
5664
  const workingDir = cwd ?? process.cwd();
5587
- if (!disableLock && shouldUseLock(workingDir)) {
5588
- await acquireLock(workingDir, prompt ?? "Interactive session");
5589
- }
5590
- const cleanupLock = async () => {
5591
- if (!disableLock && shouldUseLock(workingDir)) {
5592
- await releaseLock().catch(() => null);
5665
+ if (queue) {
5666
+ if (queue && shouldUseLock(workingDir)) {
5667
+ await acquireLock(workingDir, prompt ?? "Interactive session");
5593
5668
  }
5594
- };
5595
- process.on("exit", () => {
5596
- if (!disableLock) {
5597
- releaseLock().catch(() => null);
5598
- }
5599
- });
5600
- process.on("SIGINT", async () => {
5601
- await cleanupLock();
5602
- process.exit(130);
5603
- });
5604
- process.on("SIGTERM", async () => {
5605
- await cleanupLock();
5606
- process.exit(143);
5607
- });
5669
+ const cleanupLock = async () => {
5670
+ if (queue && shouldUseLock(workingDir)) {
5671
+ await releaseLock().catch(() => null);
5672
+ }
5673
+ };
5674
+ process.on("exit", () => {
5675
+ if (queue)
5676
+ releaseLock().catch(() => null);
5677
+ });
5678
+ process.on("SIGINT", async (code) => {
5679
+ await cleanupLock();
5680
+ process.exit(code);
5681
+ });
5682
+ process.on("SIGTERM", async (code) => {
5683
+ await cleanupLock();
5684
+ process.exit(code);
5685
+ });
5686
+ }
5608
5687
  process.stdin.setRawMode?.(true);
5609
5688
  let isFatal = false;
5610
5689
  const stdinReady = new ReadyManager;
@@ -5618,27 +5697,57 @@ async function claudeYes({
5618
5697
  cwd: cwd ?? process.cwd(),
5619
5698
  env: env ?? process.env
5620
5699
  });
5621
- const cliConf = CLI_CONFIGURES[cli] || {};
5622
- cliArgs = cliConf.ensureArgs?.(cliArgs) ?? cliArgs;
5700
+ const cliConf = CLIS_CONFIG[cli] || {};
5701
+ cliArgs = cliConf.defaultArgs ? [...cliConf.defaultArgs, ...cliArgs] : cliArgs;
5702
+ if (prompt && cliConf.promptArg) {
5703
+ if (cliConf.promptArg === "first-arg") {
5704
+ cliArgs = [prompt, ...cliArgs];
5705
+ prompt = undefined;
5706
+ } else if (cliConf.promptArg === "last-arg") {
5707
+ cliArgs = [...cliArgs, prompt];
5708
+ prompt = undefined;
5709
+ } else if (cliConf.promptArg.startsWith("--")) {
5710
+ cliArgs = [cliConf.promptArg, prompt, ...cliArgs];
5711
+ prompt = undefined;
5712
+ } else {
5713
+ console.warn(`Unknown promptArg format: ${cliConf.promptArg}`);
5714
+ }
5715
+ }
5623
5716
  const cliCommand = cliConf?.binary || cli;
5624
- let shell = tryCatch(() => pty.spawn(cliCommand, cliArgs, getPtyOptions()), (error) => {
5717
+ let shell = catcher((error) => {
5625
5718
  console.error(`Fatal: Failed to start ${cliCommand}.`);
5626
- if (cliConf?.install)
5719
+ if (cliConf?.install && isCommandNotFoundError(error))
5627
5720
  console.error(`If you did not installed it yet, Please install it first: ${cliConf.install}`);
5628
5721
  throw error;
5629
- });
5722
+ function isCommandNotFoundError(e) {
5723
+ if (e instanceof Error) {
5724
+ return e.message.includes("command not found") || e.message.includes("ENOENT") || e.message.includes("spawn");
5725
+ }
5726
+ return false;
5727
+ }
5728
+ }, () => pty.spawn(cliCommand, cliArgs, getPtyOptions()))();
5630
5729
  const pendingExitCode = Promise.withResolvers();
5631
5730
  let pendingExitCodeValue = null;
5632
5731
  async function onData(data) {
5633
- nextStdout.ready();
5634
5732
  await outputWriter.write(data);
5635
5733
  }
5636
5734
  shell.onData(onData);
5637
5735
  shell.onExit(function onExit({ exitCode: exitCode2 }) {
5638
- nextStdout.ready();
5639
5736
  stdinReady.unready();
5640
5737
  const agentCrashed = exitCode2 !== 0;
5641
- const continueArg = continueArgs[cli];
5738
+ if (agentCrashed && robust && conf?.restoreArgs) {
5739
+ if (!conf.restoreArgs) {
5740
+ return console.warn(`robust is only supported for ${Object.entries(CLIS_CONFIG).filter(([_, v]) => v.restoreArgs).map(([k]) => k).join(", ")} currently, not ${cli}`);
5741
+ }
5742
+ if (isFatal) {
5743
+ return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
5744
+ }
5745
+ console.log(`${cli} crashed, restarting...`);
5746
+ shell = pty.spawn(cli, conf.restoreArgs, getPtyOptions());
5747
+ shell.onData(onData);
5748
+ shell.onExit(onExit);
5749
+ return;
5750
+ }
5642
5751
  return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
5643
5752
  });
5644
5753
  process.stdout.on("resize", () => {
@@ -5665,7 +5774,7 @@ async function claudeYes({
5665
5774
  }
5666
5775
  }),
5667
5776
  readable: shellOutputStream.readable
5668
- }).forEach(() => idleWaiter.ping()).forEach((text) => {
5777
+ }).forEach(() => idleWaiter.ping()).forEach(() => nextStdout.ready()).forEach(async (text) => {
5669
5778
  terminalRender.write(text);
5670
5779
  if (process.stdin.isTTY)
5671
5780
  return;
@@ -5673,24 +5782,25 @@ async function claudeYes({
5673
5782
  return;
5674
5783
  const { col, row } = terminalRender.getCursorPosition();
5675
5784
  shell.write(`\x1B[${row};${col}R`);
5785
+ await yesLog`cursor|respond position: row=${String(row)}, col=${String(col)}`;
5676
5786
  }).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll("\r", "")).by((s) => {
5677
- if (cli === "codex")
5787
+ if (conf.noEOL)
5678
5788
  return s;
5679
5789
  return s.lines({ EOL: "NONE" });
5680
- }).forEach(async (e2, i) => {
5681
- const conf = CLI_CONFIGURES[cli] || null;
5682
- if (!conf)
5683
- return;
5790
+ }).forEach((e2) => yesLog`output|${e2}`).forEach(async (e2, i) => {
5684
5791
  if (conf.ready?.some((rx) => e2.match(rx))) {
5792
+ await yesLog`ready |${e2}`;
5685
5793
  if (cli === "gemini" && i <= 80)
5686
5794
  return;
5687
5795
  stdinReady.ready();
5688
5796
  }
5689
5797
  if (conf.enter?.some((rx) => e2.match(rx))) {
5798
+ await yesLog`enter |${e2}`;
5690
5799
  await sendEnter(300);
5691
5800
  return;
5692
5801
  }
5693
5802
  if (conf.fatal?.some((rx) => e2.match(rx))) {
5803
+ await yesLog`fatal |${e2}`;
5694
5804
  isFatal = true;
5695
5805
  await exitAgent();
5696
5806
  }
@@ -5701,7 +5811,7 @@ async function claudeYes({
5701
5811
  await sendMessage(prompt);
5702
5812
  const exitCode = await pendingExitCode.promise;
5703
5813
  console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
5704
- if (!disableLock && shouldUseLock(workingDir)) {
5814
+ if (queue && shouldUseLock(workingDir)) {
5705
5815
  await updateCurrentTaskStatus(exitCode === 0 ? "completed" : "failed").catch(() => null);
5706
5816
  await releaseLock().catch(() => null);
5707
5817
  }
@@ -5716,17 +5826,33 @@ async function claudeYes({
5716
5826
  const st = Date.now();
5717
5827
  await idleWaiter.wait(waitms);
5718
5828
  const et = Date.now();
5829
+ await yesLog`sendEn| idleWaiter.wait(${String(waitms)}) took ${String(et - st)}ms`;
5830
+ nextStdout.unready();
5719
5831
  shell.write("\r");
5832
+ await Promise.race([
5833
+ nextStdout.wait(),
5834
+ new Promise((resolve) => setTimeout(() => {
5835
+ if (!nextStdout.ready) {
5836
+ shell.write("\r");
5837
+ }
5838
+ resolve();
5839
+ }, 1000))
5840
+ ]);
5720
5841
  }
5721
5842
  async function sendMessage(message) {
5722
5843
  await stdinReady.wait();
5723
- shell.write(message);
5844
+ yesLog`send |${message}`;
5724
5845
  nextStdout.unready();
5846
+ shell.write(message);
5725
5847
  idleWaiter.ping();
5848
+ yesLog`waiting next stdout|${message}`;
5726
5849
  await nextStdout.wait();
5727
- await sendEnter();
5850
+ yesLog`sending enter`;
5851
+ await sendEnter(1000);
5852
+ yesLog`sent enter`;
5728
5853
  }
5729
5854
  async function exitAgent() {
5855
+ robust = false;
5730
5856
  await sendMessage("/exit");
5731
5857
  let exited = false;
5732
5858
  await Promise.race([
@@ -5748,14 +5874,6 @@ async function claudeYes({
5748
5874
  };
5749
5875
  }
5750
5876
  }
5751
- function tryCatch(fn, catchFn) {
5752
- try {
5753
- return fn();
5754
- } catch (error) {
5755
- return catchFn(error);
5756
- }
5757
- }
5758
-
5759
5877
  // node_modules/enhanced-ms/dist/index.js
5760
5878
  var units = {
5761
5879
  nanosecond: 0.000001,
@@ -7917,23 +8035,23 @@ class YargsParser {
7917
8035
  const configPath = argv2[configKey] || configLookup[configKey];
7918
8036
  if (configPath) {
7919
8037
  try {
7920
- let config = null;
8038
+ let config2 = null;
7921
8039
  const resolvedConfigPath = mixin2.resolve(mixin2.cwd(), configPath);
7922
8040
  const resolveConfig = flags.configs[configKey];
7923
8041
  if (typeof resolveConfig === "function") {
7924
8042
  try {
7925
- config = resolveConfig(resolvedConfigPath);
8043
+ config2 = resolveConfig(resolvedConfigPath);
7926
8044
  } catch (e) {
7927
- config = e;
8045
+ config2 = e;
7928
8046
  }
7929
- if (config instanceof Error) {
7930
- error = config;
8047
+ if (config2 instanceof Error) {
8048
+ error = config2;
7931
8049
  return;
7932
8050
  }
7933
8051
  } else {
7934
- config = mixin2.require(resolvedConfigPath);
8052
+ config2 = mixin2.require(resolvedConfigPath);
7935
8053
  }
7936
- setConfigObject(config);
8054
+ setConfigObject(config2);
7937
8055
  } catch (ex) {
7938
8056
  if (ex.name === "PermissionDenied")
7939
8057
  error = ex;
@@ -7943,9 +8061,9 @@ class YargsParser {
7943
8061
  }
7944
8062
  });
7945
8063
  }
7946
- function setConfigObject(config, prev) {
7947
- Object.keys(config).forEach(function(key) {
7948
- const value = config[key];
8064
+ function setConfigObject(config2, prev) {
8065
+ Object.keys(config2).forEach(function(key) {
8066
+ const value = config2[key];
7949
8067
  const fullKey = prev ? prev + "." + key : key;
7950
8068
  if (typeof value === "object" && value !== null && !Array.isArray(value) && configuration["dot-notation"]) {
7951
8069
  setConfigObject(value, fullKey);
@@ -9114,11 +9232,11 @@ class CommandInstance {
9114
9232
  });
9115
9233
  if (!unparsed.length)
9116
9234
  return;
9117
- const config = Object.assign({}, options.configuration, {
9235
+ const config2 = Object.assign({}, options.configuration, {
9118
9236
  "populate--": false
9119
9237
  });
9120
9238
  const parsed = this.shim.Parser.detailed(unparsed, Object.assign({}, options, {
9121
- configuration: config
9239
+ configuration: config2
9122
9240
  }));
9123
9241
  if (parsed.error) {
9124
9242
  yargs.getInternalMethods().getUsageInstance().fail(parsed.error.message, parsed.error);
@@ -10343,31 +10461,31 @@ ${customMsgs.join(`
10343
10461
  // node_modules/yargs/build/lib/utils/apply-extends.js
10344
10462
  var previouslyVisitedConfigs = [];
10345
10463
  var shim2;
10346
- function applyExtends(config, cwd, mergeExtends, _shim) {
10464
+ function applyExtends(config2, cwd, mergeExtends, _shim) {
10347
10465
  shim2 = _shim;
10348
10466
  let defaultConfig = {};
10349
- if (Object.prototype.hasOwnProperty.call(config, "extends")) {
10350
- if (typeof config.extends !== "string")
10467
+ if (Object.prototype.hasOwnProperty.call(config2, "extends")) {
10468
+ if (typeof config2.extends !== "string")
10351
10469
  return defaultConfig;
10352
- const isPath = /\.json|\..*rc$/.test(config.extends);
10470
+ const isPath = /\.json|\..*rc$/.test(config2.extends);
10353
10471
  let pathToDefault = null;
10354
10472
  if (!isPath) {
10355
10473
  try {
10356
- pathToDefault = import.meta.resolve(config.extends);
10474
+ pathToDefault = import.meta.resolve(config2.extends);
10357
10475
  } catch (_err) {
10358
- return config;
10476
+ return config2;
10359
10477
  }
10360
10478
  } else {
10361
- pathToDefault = getPathToDefaultConfig(cwd, config.extends);
10479
+ pathToDefault = getPathToDefaultConfig(cwd, config2.extends);
10362
10480
  }
10363
10481
  checkForCircularExtends(pathToDefault);
10364
10482
  previouslyVisitedConfigs.push(pathToDefault);
10365
- defaultConfig = isPath ? JSON.parse(shim2.readFileSync(pathToDefault, "utf8")) : _shim.require(config.extends);
10366
- delete config.extends;
10483
+ defaultConfig = isPath ? JSON.parse(shim2.readFileSync(pathToDefault, "utf8")) : _shim.require(config2.extends);
10484
+ delete config2.extends;
10367
10485
  defaultConfig = applyExtends(defaultConfig, shim2.path.dirname(pathToDefault), mergeExtends, shim2);
10368
10486
  }
10369
10487
  previouslyVisitedConfigs = [];
10370
- return mergeExtends ? mergeDeep(defaultConfig, config) : Object.assign({}, defaultConfig, config);
10488
+ return mergeExtends ? mergeDeep(defaultConfig, config2) : Object.assign({}, defaultConfig, config2);
10371
10489
  }
10372
10490
  function checkForCircularExtends(cfgPath) {
10373
10491
  if (previouslyVisitedConfigs.indexOf(cfgPath) > -1) {
@@ -11149,9 +11267,9 @@ class YargsInstance {
11149
11267
  }
11150
11268
  return maybePromise;
11151
11269
  }
11152
- parserConfiguration(config) {
11153
- argsert("<object>", [config], arguments.length);
11154
- __classPrivateFieldSet(this, _YargsInstance_parserConfig, config, "f");
11270
+ parserConfiguration(config2) {
11271
+ argsert("<object>", [config2], arguments.length);
11272
+ __classPrivateFieldSet(this, _YargsInstance_parserConfig, config2, "f");
11155
11273
  return this;
11156
11274
  }
11157
11275
  pkgConf(key, rootPath) {
@@ -11323,9 +11441,9 @@ class YargsInstance {
11323
11441
  return this;
11324
11442
  }
11325
11443
  }
11326
- usageConfiguration(config) {
11327
- argsert("<object>", [config], arguments.length);
11328
- __classPrivateFieldSet(this, _YargsInstance_usageConfig, config, "f");
11444
+ usageConfiguration(config2) {
11445
+ argsert("<object>", [config2], arguments.length);
11446
+ __classPrivateFieldSet(this, _YargsInstance_usageConfig, config2, "f");
11329
11447
  return this;
11330
11448
  }
11331
11449
  version(opt, msg, ver) {
@@ -11732,11 +11850,11 @@ class YargsInstance {
11732
11850
  __classPrivateFieldGet(this, _YargsInstance_options, "f").__ = __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__;
11733
11851
  __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration = this[kGetParserConfiguration]();
11734
11852
  const populateDoubleDash = !!__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration["populate--"];
11735
- const config = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, {
11853
+ const config2 = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, {
11736
11854
  "populate--": true
11737
11855
  });
11738
11856
  const parsed = __classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.detailed(args, Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f"), {
11739
- configuration: { "parse-positional-numbers": false, ...config }
11857
+ configuration: { "parse-positional-numbers": false, ...config2 }
11740
11858
  }));
11741
11859
  const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"));
11742
11860
  let argvPromise = undefined;
@@ -11903,49 +12021,82 @@ function isYargsInstance(y) {
11903
12021
  var Yargs = YargsFactory(esm_default);
11904
12022
  var yargs_default = Yargs;
11905
12023
 
12024
+ // ts/parseCliArgs.ts
12025
+ function parseCliArgs(argv) {
12026
+ const cliName = ((e) => {
12027
+ if (e === "cli" || e === "cli.ts")
12028
+ return;
12029
+ return e;
12030
+ })(argv[1]?.split("/").pop()?.split("-")[0]);
12031
+ const parsedArgv = yargs_default(hideBin(argv)).usage("Usage: $0 [cli] [cli-yes args] [agent-cli args] [--] [prompts...]").example("$0 claude --idle=30s -- solve all todos in my codebase, commit one by one", "Run Claude with a 30 seconds idle timeout, and the prompt is everything after `--`").option("robust", {
12032
+ type: "boolean",
12033
+ default: true,
12034
+ description: "re-spawn Claude with --continue if it crashes, only works for claude yet",
12035
+ alias: "r"
12036
+ }).option("logFile", {
12037
+ type: "string",
12038
+ description: "Rendered log file to write to."
12039
+ }).option("prompt", {
12040
+ type: "string",
12041
+ description: "Prompt to send to Claude (also can be passed after --)",
12042
+ alias: "p"
12043
+ }).option("verbose", {
12044
+ type: "boolean",
12045
+ description: "Enable verbose logging, will emit ./agent-yes.log",
12046
+ default: false
12047
+ }).option("exit-on-idle", {
12048
+ type: "string",
12049
+ description: 'Exit after a period of inactivity, e.g., "5s" or "1m"',
12050
+ deprecated: "use --idle instead",
12051
+ default: "60s",
12052
+ alias: "e"
12053
+ }).option("idle", {
12054
+ type: "string",
12055
+ description: 'Exit after a period of inactivity, e.g., "5s" or "1m"',
12056
+ alias: "i"
12057
+ }).option("queue", {
12058
+ type: "boolean",
12059
+ description: "Queue Agent when spawning multiple agents in the same directory/repo, can be disabled with --no-queue",
12060
+ default: true
12061
+ }).positional("cli", {
12062
+ describe: "The AI CLI to run, e.g., claude, codex, copilot, cursor, gemini",
12063
+ type: "string",
12064
+ choices: SUPPORTED_CLIS,
12065
+ demandOption: false,
12066
+ default: cliName
12067
+ }).help().version().parserConfiguration({
12068
+ "unknown-options-as-args": true,
12069
+ "halt-at-non-option": true
12070
+ }).parseSync();
12071
+ const optionalIndex = (e) => 0 <= e ? e : undefined;
12072
+ const rawArgs = argv.slice(2);
12073
+ const cliArgIndex = optionalIndex(rawArgs.indexOf(String(parsedArgv._[0])));
12074
+ const dashIndex = optionalIndex(rawArgs.indexOf("--"));
12075
+ const cliArgsForSpawn = parsedArgv._[0] ? rawArgs.slice(cliArgIndex ?? 0, dashIndex ?? undefined) : [];
12076
+ const dashPrompt = dashIndex ? rawArgs.slice(dashIndex + 1).join(" ") : undefined;
12077
+ return {
12078
+ cli: cliName || parsedArgv.cli || parsedArgv._[0]?.toString()?.replace?.(/-yes$/, ""),
12079
+ cliArgs: cliArgsForSpawn,
12080
+ prompt: [parsedArgv.prompt, dashPrompt].join(" ").trim() || undefined,
12081
+ exitOnIdle: Number((parsedArgv.idle || parsedArgv.exitOnIdle)?.replace(/.*/, (e) => String(index_default(e))) || 0),
12082
+ queue: parsedArgv.queue,
12083
+ robust: parsedArgv.robust,
12084
+ logFile: parsedArgv.logFile,
12085
+ verbose: parsedArgv.verbose
12086
+ };
12087
+ }
12088
+
11906
12089
  // ts/cli.ts
11907
- var argv = yargs_default(hideBin(process.argv)).usage("Usage: $0 [options] [agent-cli args] [--] [prompts...]").example('$0 --exit-on-idle=30s --continue-on-crash "help me solve all todos in my codebase"', "Run Claude with a 30 seconds idle timeout and continue on crash").option("log-file", {
11908
- type: "string",
11909
- description: "Log file to write to"
11910
- }).option("prompt", {
11911
- type: "string",
11912
- description: "Prompt to send to Claude",
11913
- alias: "p"
11914
- }).option("verbose", {
11915
- type: "boolean",
11916
- description: "Enable verbose logging",
11917
- default: false
11918
- }).option("exit-on-idle", {
11919
- type: "string",
11920
- description: 'Exit after a period of inactivity, e.g., "5s" or "1m"',
11921
- alias: "e"
11922
- }).option("disable-lock", {
11923
- type: "boolean",
11924
- description: "Disable the running lock feature that prevents concurrent agents in the same directory/repo",
11925
- default: false
11926
- }).help().version().parserConfiguration({
11927
- "unknown-options-as-args": true,
11928
- "halt-at-non-option": true
11929
- }).parseSync();
11930
- console.log(argv);
11931
- var cliName = process.argv[1]?.split("/").pop()?.split("-")[0];
11932
- var rawArgs = process.argv.slice(2);
11933
- var cliArgIndex = rawArgs.indexOf(String(argv._[0]));
11934
- var dashIndex = rawArgs.indexOf("--");
11935
- var cliArgsForSpawn = rawArgs.slice(cliArgIndex === -1 ? 0 : cliArgIndex, dashIndex === -1 ? undefined : dashIndex);
11936
- var promptFromDash = rawArgs.slice(dashIndex + 1).join(" ");
11937
- console.log({ rawArgs, cliArgsForSpawn, promptFromDash });
11938
- console.clear();
11939
- var { exitCode } = await claudeYes({
11940
- cli: cliName,
11941
- prompt: argv.prompt || promptFromDash,
11942
- exitOnIdle: argv.exitOnIdle ? index_default(argv.exitOnIdle) : undefined,
11943
- cliArgs: cliArgsForSpawn,
11944
- logFile: argv.logFile,
11945
- verbose: argv.verbose,
11946
- disableLock: argv.disableLock
11947
- });
12090
+ var config2 = parseCliArgs(process.argv);
12091
+ if (!config2.cli) {
12092
+ phpdie_default2("missing cli def");
12093
+ }
12094
+ if (config2.verbose) {
12095
+ process.env.VERBOSE = "true";
12096
+ console.log(config2);
12097
+ }
12098
+ var { exitCode } = await cliYes(config2);
11948
12099
  process.exit(exitCode ?? 1);
11949
12100
 
11950
- //# debugId=D317BFA79BAAFAA464756E2164756E21
12101
+ //# debugId=E45F0C460719CB9D64756E2164756E21
11951
12102
  //# sourceMappingURL=cli.js.map