claude-yes 1.20.0 → 1.21.1

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.
@@ -68,21 +68,29 @@ function removeControlCharacters(str) {
68
68
  return str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
69
69
  }
70
70
  var CLI_CONFIGURES = {
71
+ grok: {
72
+ install: "npm install -g @vibe-kit/grok-cli",
73
+ ready: [/^ │ ❯ /],
74
+ enter: [/^ 1. Yes/]
75
+ },
71
76
  claude: {
72
- ready: /^> /,
77
+ install: "npm install -g @anthropic-ai/claude-code",
78
+ ready: [/^> /],
73
79
  enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
74
80
  fatal: [
75
81
  /No conversation found to continue/,
76
- /⎿ {2}Claude usage limit reached\./
82
+ /⎿ Claude usage limit reached\./
77
83
  ]
78
84
  },
79
85
  gemini: {
80
- ready: /Type your message/,
86
+ install: "npm install -g @google/gemini-cli",
87
+ ready: [/Type your message/],
81
88
  enter: [/│ ● 1. Yes, allow once/],
82
89
  fatal: []
83
90
  },
84
91
  codex: {
85
- ready: /⏎ send/,
92
+ install: "npm install -g @openai/codex-cli",
93
+ ready: [/⏎ send/],
86
94
  enter: [/ > 1. Approve/, /> 1. Yes, allow Codex to work in this folder/],
87
95
  fatal: [/Error: The cursor position could not be read within/],
88
96
  ensureArgs: (args) => {
@@ -92,15 +100,17 @@ var CLI_CONFIGURES = {
92
100
  }
93
101
  },
94
102
  copilot: {
95
- ready: /^ > /,
103
+ install: "npm install -g @github/copilot",
104
+ ready: [/^ > /],
96
105
  enter: [/ │ ❯ 1. Yes, proceed/, /❯ 1. Yes/],
97
106
  fatal: []
98
107
  },
99
108
  cursor: {
109
+ install: "open https://cursor.com/ja/docs/cli/installation",
100
110
  binary: "cursor-agent",
101
- ready: /\/ commands/,
111
+ ready: [/\/ commands/],
102
112
  enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
103
- fatal: []
113
+ fatal: [/^ Error: You've hit your usage limit/]
104
114
  }
105
115
  };
106
116
  async function claudeYes({
@@ -135,7 +145,12 @@ async function claudeYes({
135
145
  const cliConf = CLI_CONFIGURES[cli] || {};
136
146
  cliArgs = cliConf.ensureArgs?.(cliArgs) ?? cliArgs;
137
147
  const cliCommand = cliConf?.binary || cli;
138
- let shell = pty.spawn(cliCommand, cliArgs, getPtyOptions());
148
+ let shell = tryCatch(() => pty.spawn(cliCommand, cliArgs, getPtyOptions()), (error) => {
149
+ console.error(`Fatal: Failed to start ${cliCommand}.`);
150
+ if (cliConf?.install)
151
+ console.error(`If you did not installed it yet, Please install it first: ${cliConf.install}`);
152
+ throw error;
153
+ });
139
154
  const pendingExitCode = Promise.withResolvers();
140
155
  let pendingExitCodeValue = null;
141
156
  async function onData(data) {
@@ -151,7 +166,6 @@ async function claudeYes({
151
166
  return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
152
167
  }
153
168
  if (isFatal) {
154
- console.log(`${cli} crashed with "No conversation found to continue", exiting...`);
155
169
  return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
156
170
  }
157
171
  console.log(`${cli} crashed, restarting...`);
@@ -202,35 +216,20 @@ async function claudeYes({
202
216
  const conf = CLI_CONFIGURES[cli] || null;
203
217
  if (!conf)
204
218
  return;
205
- try {
206
- if (conf.ready) {
207
- if (cli === "gemini" && conf.ready instanceof RegExp) {
208
- if (e2.match(conf.ready) && i > 80)
209
- return stdinReady.ready();
210
- } else if (e2.match(conf.ready)) {
211
- return stdinReady.ready();
212
- }
213
- }
214
- if (conf.enter && Array.isArray(conf.enter)) {
215
- for (const rx of conf.enter) {
216
- if (e2.match(rx))
217
- return await sendEnter();
218
- }
219
- }
220
- if (conf.fatal && Array.isArray(conf.fatal)) {
221
- for (const rx of conf.fatal) {
222
- if (e2.match(rx))
223
- return isFatal = true;
224
- }
225
- }
226
- } catch (err) {
227
- return;
219
+ if (conf.ready?.some((rx) => e2.match(rx))) {
220
+ if (cli === "gemini" && i <= 80)
221
+ return;
222
+ stdinReady.ready();
223
+ }
224
+ if (conf.enter?.some((rx) => e2.match(rx)))
225
+ await sendEnter(300);
226
+ if (conf.fatal?.some((rx) => e2.match(rx))) {
227
+ isFatal = true;
228
+ await exitAgent();
228
229
  }
229
230
  }).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
230
231
  if (prompt)
231
- (async () => {
232
- await sendMessage(prompt);
233
- })();
232
+ await sendMessage(prompt);
234
233
  const exitCode = await pendingExitCode.promise;
235
234
  console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
236
235
  if (logFile) {
@@ -269,11 +268,18 @@ async function claudeYes({
269
268
  }
270
269
  function getTerminalDimensions() {
271
270
  return {
272
- cols: Math.max(process.stdout.columns, 80),
271
+ cols: process.stdout.columns,
273
272
  rows: process.stdout.rows
274
273
  };
275
274
  }
276
275
  }
276
+ function tryCatch(fn, catchFn) {
277
+ try {
278
+ return fn();
279
+ } catch (error) {
280
+ return catchFn(error);
281
+ }
282
+ }
277
283
 
278
284
  // cli.ts
279
285
  var argv = yargs(hideBin(process.argv)).usage("Usage: $0 [options] [claude 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("continue-on-crash", {
@@ -328,5 +334,5 @@ var { exitCode, logs } = await claudeYes({
328
334
  });
329
335
  process.exit(exitCode ?? 1);
330
336
 
331
- //# debugId=0E9D5C1D34AAD47764756E2164756E21
337
+ //# debugId=7D0CC0B4FDA115C064756E2164756E21
332
338
  //# sourceMappingURL=cli.js.map
@@ -68,21 +68,29 @@ function removeControlCharacters(str) {
68
68
  return str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
69
69
  }
70
70
  var CLI_CONFIGURES = {
71
+ grok: {
72
+ install: "npm install -g @vibe-kit/grok-cli",
73
+ ready: [/^ │ ❯ /],
74
+ enter: [/^ 1. Yes/]
75
+ },
71
76
  claude: {
72
- ready: /^> /,
77
+ install: "npm install -g @anthropic-ai/claude-code",
78
+ ready: [/^> /],
73
79
  enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
74
80
  fatal: [
75
81
  /No conversation found to continue/,
76
- /⎿ {2}Claude usage limit reached\./
82
+ /⎿ Claude usage limit reached\./
77
83
  ]
78
84
  },
79
85
  gemini: {
80
- ready: /Type your message/,
86
+ install: "npm install -g @google/gemini-cli",
87
+ ready: [/Type your message/],
81
88
  enter: [/│ ● 1. Yes, allow once/],
82
89
  fatal: []
83
90
  },
84
91
  codex: {
85
- ready: /⏎ send/,
92
+ install: "npm install -g @openai/codex-cli",
93
+ ready: [/⏎ send/],
86
94
  enter: [/ > 1. Approve/, /> 1. Yes, allow Codex to work in this folder/],
87
95
  fatal: [/Error: The cursor position could not be read within/],
88
96
  ensureArgs: (args) => {
@@ -92,15 +100,17 @@ var CLI_CONFIGURES = {
92
100
  }
93
101
  },
94
102
  copilot: {
95
- ready: /^ > /,
103
+ install: "npm install -g @github/copilot",
104
+ ready: [/^ > /],
96
105
  enter: [/ │ ❯ 1. Yes, proceed/, /❯ 1. Yes/],
97
106
  fatal: []
98
107
  },
99
108
  cursor: {
109
+ install: "open https://cursor.com/ja/docs/cli/installation",
100
110
  binary: "cursor-agent",
101
- ready: /\/ commands/,
111
+ ready: [/\/ commands/],
102
112
  enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
103
- fatal: []
113
+ fatal: [/^ Error: You've hit your usage limit/]
104
114
  }
105
115
  };
106
116
  async function claudeYes({
@@ -135,7 +145,12 @@ async function claudeYes({
135
145
  const cliConf = CLI_CONFIGURES[cli] || {};
136
146
  cliArgs = cliConf.ensureArgs?.(cliArgs) ?? cliArgs;
137
147
  const cliCommand = cliConf?.binary || cli;
138
- let shell = pty.spawn(cliCommand, cliArgs, getPtyOptions());
148
+ let shell = tryCatch(() => pty.spawn(cliCommand, cliArgs, getPtyOptions()), (error) => {
149
+ console.error(`Fatal: Failed to start ${cliCommand}.`);
150
+ if (cliConf?.install)
151
+ console.error(`If you did not installed it yet, Please install it first: ${cliConf.install}`);
152
+ throw error;
153
+ });
139
154
  const pendingExitCode = Promise.withResolvers();
140
155
  let pendingExitCodeValue = null;
141
156
  async function onData(data) {
@@ -151,7 +166,6 @@ async function claudeYes({
151
166
  return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
152
167
  }
153
168
  if (isFatal) {
154
- console.log(`${cli} crashed with "No conversation found to continue", exiting...`);
155
169
  return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
156
170
  }
157
171
  console.log(`${cli} crashed, restarting...`);
@@ -202,35 +216,20 @@ async function claudeYes({
202
216
  const conf = CLI_CONFIGURES[cli] || null;
203
217
  if (!conf)
204
218
  return;
205
- try {
206
- if (conf.ready) {
207
- if (cli === "gemini" && conf.ready instanceof RegExp) {
208
- if (e2.match(conf.ready) && i > 80)
209
- return stdinReady.ready();
210
- } else if (e2.match(conf.ready)) {
211
- return stdinReady.ready();
212
- }
213
- }
214
- if (conf.enter && Array.isArray(conf.enter)) {
215
- for (const rx of conf.enter) {
216
- if (e2.match(rx))
217
- return await sendEnter();
218
- }
219
- }
220
- if (conf.fatal && Array.isArray(conf.fatal)) {
221
- for (const rx of conf.fatal) {
222
- if (e2.match(rx))
223
- return isFatal = true;
224
- }
225
- }
226
- } catch (err) {
227
- return;
219
+ if (conf.ready?.some((rx) => e2.match(rx))) {
220
+ if (cli === "gemini" && i <= 80)
221
+ return;
222
+ stdinReady.ready();
223
+ }
224
+ if (conf.enter?.some((rx) => e2.match(rx)))
225
+ await sendEnter(300);
226
+ if (conf.fatal?.some((rx) => e2.match(rx))) {
227
+ isFatal = true;
228
+ await exitAgent();
228
229
  }
229
230
  }).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
230
231
  if (prompt)
231
- (async () => {
232
- await sendMessage(prompt);
233
- })();
232
+ await sendMessage(prompt);
234
233
  const exitCode = await pendingExitCode.promise;
235
234
  console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
236
235
  if (logFile) {
@@ -269,11 +268,18 @@ async function claudeYes({
269
268
  }
270
269
  function getTerminalDimensions() {
271
270
  return {
272
- cols: Math.max(process.stdout.columns, 80),
271
+ cols: process.stdout.columns,
273
272
  rows: process.stdout.rows
274
273
  };
275
274
  }
276
275
  }
276
+ function tryCatch(fn, catchFn) {
277
+ try {
278
+ return fn();
279
+ } catch (error) {
280
+ return catchFn(error);
281
+ }
282
+ }
277
283
 
278
284
  // cli.ts
279
285
  var argv = yargs(hideBin(process.argv)).usage("Usage: $0 [options] [claude 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("continue-on-crash", {
@@ -328,5 +334,5 @@ var { exitCode, logs } = await claudeYes({
328
334
  });
329
335
  process.exit(exitCode ?? 1);
330
336
 
331
- //# debugId=0E9D5C1D34AAD47764756E2164756E21
337
+ //# debugId=7D0CC0B4FDA115C064756E2164756E21
332
338
  //# sourceMappingURL=cli.js.map
@@ -68,21 +68,29 @@ function removeControlCharacters(str) {
68
68
  return str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
69
69
  }
70
70
  var CLI_CONFIGURES = {
71
+ grok: {
72
+ install: "npm install -g @vibe-kit/grok-cli",
73
+ ready: [/^ │ ❯ /],
74
+ enter: [/^ 1. Yes/]
75
+ },
71
76
  claude: {
72
- ready: /^> /,
77
+ install: "npm install -g @anthropic-ai/claude-code",
78
+ ready: [/^> /],
73
79
  enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
74
80
  fatal: [
75
81
  /No conversation found to continue/,
76
- /⎿ {2}Claude usage limit reached\./
82
+ /⎿ Claude usage limit reached\./
77
83
  ]
78
84
  },
79
85
  gemini: {
80
- ready: /Type your message/,
86
+ install: "npm install -g @google/gemini-cli",
87
+ ready: [/Type your message/],
81
88
  enter: [/│ ● 1. Yes, allow once/],
82
89
  fatal: []
83
90
  },
84
91
  codex: {
85
- ready: /⏎ send/,
92
+ install: "npm install -g @openai/codex-cli",
93
+ ready: [/⏎ send/],
86
94
  enter: [/ > 1. Approve/, /> 1. Yes, allow Codex to work in this folder/],
87
95
  fatal: [/Error: The cursor position could not be read within/],
88
96
  ensureArgs: (args) => {
@@ -92,15 +100,17 @@ var CLI_CONFIGURES = {
92
100
  }
93
101
  },
94
102
  copilot: {
95
- ready: /^ > /,
103
+ install: "npm install -g @github/copilot",
104
+ ready: [/^ > /],
96
105
  enter: [/ │ ❯ 1. Yes, proceed/, /❯ 1. Yes/],
97
106
  fatal: []
98
107
  },
99
108
  cursor: {
109
+ install: "open https://cursor.com/ja/docs/cli/installation",
100
110
  binary: "cursor-agent",
101
- ready: /\/ commands/,
111
+ ready: [/\/ commands/],
102
112
  enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
103
- fatal: []
113
+ fatal: [/^ Error: You've hit your usage limit/]
104
114
  }
105
115
  };
106
116
  async function claudeYes({
@@ -135,7 +145,12 @@ async function claudeYes({
135
145
  const cliConf = CLI_CONFIGURES[cli] || {};
136
146
  cliArgs = cliConf.ensureArgs?.(cliArgs) ?? cliArgs;
137
147
  const cliCommand = cliConf?.binary || cli;
138
- let shell = pty.spawn(cliCommand, cliArgs, getPtyOptions());
148
+ let shell = tryCatch(() => pty.spawn(cliCommand, cliArgs, getPtyOptions()), (error) => {
149
+ console.error(`Fatal: Failed to start ${cliCommand}.`);
150
+ if (cliConf?.install)
151
+ console.error(`If you did not installed it yet, Please install it first: ${cliConf.install}`);
152
+ throw error;
153
+ });
139
154
  const pendingExitCode = Promise.withResolvers();
140
155
  let pendingExitCodeValue = null;
141
156
  async function onData(data) {
@@ -151,7 +166,6 @@ async function claudeYes({
151
166
  return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
152
167
  }
153
168
  if (isFatal) {
154
- console.log(`${cli} crashed with "No conversation found to continue", exiting...`);
155
169
  return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
156
170
  }
157
171
  console.log(`${cli} crashed, restarting...`);
@@ -202,35 +216,20 @@ async function claudeYes({
202
216
  const conf = CLI_CONFIGURES[cli] || null;
203
217
  if (!conf)
204
218
  return;
205
- try {
206
- if (conf.ready) {
207
- if (cli === "gemini" && conf.ready instanceof RegExp) {
208
- if (e2.match(conf.ready) && i > 80)
209
- return stdinReady.ready();
210
- } else if (e2.match(conf.ready)) {
211
- return stdinReady.ready();
212
- }
213
- }
214
- if (conf.enter && Array.isArray(conf.enter)) {
215
- for (const rx of conf.enter) {
216
- if (e2.match(rx))
217
- return await sendEnter();
218
- }
219
- }
220
- if (conf.fatal && Array.isArray(conf.fatal)) {
221
- for (const rx of conf.fatal) {
222
- if (e2.match(rx))
223
- return isFatal = true;
224
- }
225
- }
226
- } catch (err) {
227
- return;
219
+ if (conf.ready?.some((rx) => e2.match(rx))) {
220
+ if (cli === "gemini" && i <= 80)
221
+ return;
222
+ stdinReady.ready();
223
+ }
224
+ if (conf.enter?.some((rx) => e2.match(rx)))
225
+ await sendEnter(300);
226
+ if (conf.fatal?.some((rx) => e2.match(rx))) {
227
+ isFatal = true;
228
+ await exitAgent();
228
229
  }
229
230
  }).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
230
231
  if (prompt)
231
- (async () => {
232
- await sendMessage(prompt);
233
- })();
232
+ await sendMessage(prompt);
234
233
  const exitCode = await pendingExitCode.promise;
235
234
  console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
236
235
  if (logFile) {
@@ -269,11 +268,18 @@ async function claudeYes({
269
268
  }
270
269
  function getTerminalDimensions() {
271
270
  return {
272
- cols: Math.max(process.stdout.columns, 80),
271
+ cols: process.stdout.columns,
273
272
  rows: process.stdout.rows
274
273
  };
275
274
  }
276
275
  }
276
+ function tryCatch(fn, catchFn) {
277
+ try {
278
+ return fn();
279
+ } catch (error) {
280
+ return catchFn(error);
281
+ }
282
+ }
277
283
 
278
284
  // cli.ts
279
285
  var argv = yargs(hideBin(process.argv)).usage("Usage: $0 [options] [claude 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("continue-on-crash", {
@@ -328,5 +334,5 @@ var { exitCode, logs } = await claudeYes({
328
334
  });
329
335
  process.exit(exitCode ?? 1);
330
336
 
331
- //# debugId=0E9D5C1D34AAD47764756E2164756E21
337
+ //# debugId=7D0CC0B4FDA115C064756E2164756E21
332
338
  //# sourceMappingURL=cli.js.map