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.
- package/README.md +26 -0
- package/dist/claude-yes.js +43 -37
- package/dist/cli.js +43 -37
- package/dist/cli.js.map +3 -3
- package/dist/codex-yes.js +43 -37
- package/dist/copilot-yes.js +43 -37
- package/dist/cursor-yes.js +43 -37
- package/dist/gemini-yes.js +43 -37
- package/dist/grok-yes.js +338 -0
- package/dist/index.js +43 -37
- package/dist/index.js.map +3 -3
- package/index.ts +58 -57
- package/package.json +14 -13
- package/postbuild.ts +10 -1
package/README.md
CHANGED
|
@@ -42,6 +42,11 @@ Learn more: https://www.anthropic.com/claude-code
|
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
### Cursor
|
|
45
|
+
### Grok
|
|
46
|
+
```bash
|
|
47
|
+
npm install -g @vibe-kit/grok-cli
|
|
48
|
+
```
|
|
49
|
+
Learn more: https://github.com/vibe-kit/grok-cli
|
|
45
50
|
```bash
|
|
46
51
|
# Install Cursor agent CLI
|
|
47
52
|
# Check Cursor's documentation for installation instructions
|
|
@@ -81,6 +86,26 @@ claude-yes --cli=codex "refactor this function"
|
|
|
81
86
|
claude-yes --cli=copilot "generate unit tests"
|
|
82
87
|
|
|
83
88
|
# Use Cursor
|
|
89
|
+
# Use Grok
|
|
90
|
+
**Direct Commands:**
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Use Codex directly
|
|
94
|
+
codex-yes "refactor this function"
|
|
95
|
+
|
|
96
|
+
# Use Grok directly
|
|
97
|
+
grok-yes "help me with this code"
|
|
98
|
+
|
|
99
|
+
# Use Copilot directly
|
|
100
|
+
copilot-yes "generate unit tests"
|
|
101
|
+
|
|
102
|
+
# Use Cursor directly
|
|
103
|
+
cursor-yes "optimize performance"
|
|
104
|
+
|
|
105
|
+
# Use Gemini directly
|
|
106
|
+
gemini-yes "debug this code"
|
|
107
|
+
```
|
|
108
|
+
claude-yes --cli=grok "help me with this code"
|
|
84
109
|
claude-yes --cli=cursor "optimize performance"
|
|
85
110
|
```
|
|
86
111
|
|
|
@@ -103,6 +128,7 @@ claude-code-execute claude-yes "your task here"
|
|
|
103
128
|
| Codex | `codex` | Microsoft's Codex CLI |
|
|
104
129
|
| Copilot | `copilot` | GitHub Copilot CLI |
|
|
105
130
|
| Cursor | `cursor` | Cursor agent CLI |
|
|
131
|
+
| Grok | `grok` | Vibe Kit\'s Grok CLI |
|
|
106
132
|
|
|
107
133
|
The tool will:
|
|
108
134
|
|
package/dist/claude-yes.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
/⎿
|
|
82
|
+
/⎿ Claude usage limit reached\./
|
|
77
83
|
]
|
|
78
84
|
},
|
|
79
85
|
gemini: {
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
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:
|
|
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=
|
|
337
|
+
//# debugId=7D0CC0B4FDA115C064756E2164756E21
|
|
332
338
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
/⎿
|
|
82
|
+
/⎿ Claude usage limit reached\./
|
|
77
83
|
]
|
|
78
84
|
},
|
|
79
85
|
gemini: {
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
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:
|
|
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=
|
|
337
|
+
//# debugId=7D0CC0B4FDA115C064756E2164756E21
|
|
332
338
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"sources": ["../cli.ts", "index.js"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"#!/usr/bin/env node\nimport enhancedMs from 'enhanced-ms';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport claudeYes from '.';\n\n// cli entry point\nconst argv = yargs(hideBin(process.argv))\n .usage('Usage: $0 [options] [claude args] [--] [prompts...]')\n .example(\n '$0 --exit-on-idle=30s --continue-on-crash \"help me solve all todos in my codebase\"',\n 'Run Claude with a 30 seconds idle timeout and continue on crash',\n )\n .option('continue-on-crash', {\n type: 'boolean',\n default: true,\n description:\n 'spawn Claude with --continue if it crashes, only works for claude',\n })\n .option('log-file', {\n type: 'string',\n description: 'Log file to write to',\n })\n .option('cli', {\n type: 'string',\n description:\n 'Claude CLI command, e.g. \"claude,gemini,codex,cursor,copilot\", default is \"claude\"',\n })\n .option('prompt', {\n type: 'string',\n description: 'Prompt to send to Claude',\n alias: 'p',\n })\n .option('verbose', {\n type: 'boolean',\n description: 'Enable verbose logging',\n default: false,\n })\n .option('exit-on-idle', {\n type: 'string',\n description: 'Exit after a period of inactivity, e.g., \"5s\" or \"1m\"',\n })\n .parserConfiguration({\n 'unknown-options-as-args': true,\n 'halt-at-non-option': true,\n })\n .parseSync();\n\n// detect cli name for cli, while package.json have multiple bin link: {\"claude-yes\": \"cli.js\", \"codex-yes\": \"cli.js\", \"gemini-yes\": \"cli.js\"}\nif (!argv.cli) {\n const cliName = process.argv[1]?.split('/').pop()?.split('-')[0];\n argv.cli = cliName || 'claude';\n}\n\n// Support: everything after a literal `--` is a prompt string. Example:\n// claude-yes --exit-on-idle=30s -- \"help me refactor this\"\n// In that example the prompt will be `help me refactor this` and won't be\n// passed as args to the underlying CLI binary.\nconst rawArgs = process.argv.slice(2);\nconst dashIndex = rawArgs.indexOf('--');\nlet promptFromDash: string | undefined = undefined;\nlet cliArgsForSpawn: string[] = [];\nif (dashIndex !== -1) {\n // join everything after `--` into a single prompt string\n const after = rawArgs.slice(dashIndex + 1);\n promptFromDash = after.join(' ');\n // use everything before `--` as the cli args\n cliArgsForSpawn = rawArgs.slice(0, dashIndex).map(String);\n} else {\n // fallback to yargs parsed positional args when `--` is not used\n cliArgsForSpawn = argv._.map((e) => String(e));\n}\n\nconsole.clear();\nconst { exitCode, logs } = await claudeYes({\n cli: argv.cli,\n // prefer explicit --prompt / -p; otherwise use the text after `--` if present\n prompt: argv.prompt || promptFromDash,\n exitOnIdle: argv.exitOnIdle ? enhancedMs(argv.exitOnIdle) : undefined,\n cliArgs: cliArgsForSpawn,\n continueOnCrash: argv.continueOnCrash,\n logFile: argv.logFile,\n verbose: argv.verbose,\n});\n\nprocess.exit(exitCode ?? 1);\n",
|
|
6
|
-
"import { createRequire } from \"node:module\";\nvar __create = Object.create;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __toESM = (mod, isNodeMode, target) => {\n target = mod != null ? __create(__getProtoOf(mod)) : {};\n const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target;\n for (let key of __getOwnPropNames(mod))\n if (!__hasOwnProp.call(to, key))\n __defProp(to, key, {\n get: () => mod[key],\n enumerable: true\n });\n return to;\n};\nvar __require = /* @__PURE__ */ createRequire(import.meta.url);\n\n// index.ts\nimport { fromReadable, fromWritable } from \"from-node-stream\";\nimport { mkdir, writeFile } from \"fs/promises\";\nimport path from \"path\";\nimport DIE from \"phpdie\";\nimport sflow from \"sflow\";\nimport { TerminalTextRender } from \"terminal-render\";\n\n// idleWaiter.ts\nclass IdleWaiter {\n lastActivityTime = Date.now();\n checkInterval = 100;\n constructor() {\n this.ping();\n }\n ping() {\n this.lastActivityTime = Date.now();\n return this;\n }\n async wait(ms) {\n while (this.lastActivityTime >= Date.now() - ms)\n await new Promise((resolve) => setTimeout(resolve, this.checkInterval));\n }\n}\n\n// ReadyManager.ts\nclass ReadyManager {\n isReady = false;\n readyQueue = [];\n wait() {\n if (this.isReady)\n return;\n return new Promise((resolve) => this.readyQueue.push(resolve));\n }\n unready() {\n this.isReady = false;\n }\n ready() {\n this.isReady = true;\n if (!this.readyQueue.length)\n return;\n this.readyQueue.splice(0).map((resolve) => resolve());\n }\n}\n\n// removeControlCharacters.ts\nfunction removeControlCharacters(str) {\n return str.replace(/[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, \"\");\n}\n\n// index.ts\nvar CLI_CONFIGURES = {\n claude: {\n ready: /^>
|
|
6
|
+
"import { createRequire } from \"node:module\";\nvar __create = Object.create;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __toESM = (mod, isNodeMode, target) => {\n target = mod != null ? __create(__getProtoOf(mod)) : {};\n const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target;\n for (let key of __getOwnPropNames(mod))\n if (!__hasOwnProp.call(to, key))\n __defProp(to, key, {\n get: () => mod[key],\n enumerable: true\n });\n return to;\n};\nvar __require = /* @__PURE__ */ createRequire(import.meta.url);\n\n// index.ts\nimport { fromReadable, fromWritable } from \"from-node-stream\";\nimport { mkdir, writeFile } from \"fs/promises\";\nimport path from \"path\";\nimport DIE from \"phpdie\";\nimport sflow from \"sflow\";\nimport { TerminalTextRender } from \"terminal-render\";\n\n// idleWaiter.ts\nclass IdleWaiter {\n lastActivityTime = Date.now();\n checkInterval = 100;\n constructor() {\n this.ping();\n }\n ping() {\n this.lastActivityTime = Date.now();\n return this;\n }\n async wait(ms) {\n while (this.lastActivityTime >= Date.now() - ms)\n await new Promise((resolve) => setTimeout(resolve, this.checkInterval));\n }\n}\n\n// ReadyManager.ts\nclass ReadyManager {\n isReady = false;\n readyQueue = [];\n wait() {\n if (this.isReady)\n return;\n return new Promise((resolve) => this.readyQueue.push(resolve));\n }\n unready() {\n this.isReady = false;\n }\n ready() {\n this.isReady = true;\n if (!this.readyQueue.length)\n return;\n this.readyQueue.splice(0).map((resolve) => resolve());\n }\n}\n\n// removeControlCharacters.ts\nfunction removeControlCharacters(str) {\n return str.replace(/[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, \"\");\n}\n\n// index.ts\nvar CLI_CONFIGURES = {\n grok: {\n install: \"npm install -g @vibe-kit/grok-cli\",\n ready: [/^ │ ❯ /],\n enter: [/^ 1. Yes/]\n },\n claude: {\n install: \"npm install -g @anthropic-ai/claude-code\",\n ready: [/^> /],\n enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],\n fatal: [\n /No conversation found to continue/,\n /⎿ Claude usage limit reached\\./\n ]\n },\n gemini: {\n install: \"npm install -g @google/gemini-cli\",\n ready: [/Type your message/],\n enter: [/│ ● 1. Yes, allow once/],\n fatal: []\n },\n codex: {\n install: \"npm install -g @openai/codex-cli\",\n ready: [/⏎ send/],\n enter: [/ > 1. Approve/, /> 1. Yes, allow Codex to work in this folder/],\n fatal: [/Error: The cursor position could not be read within/],\n ensureArgs: (args) => {\n if (!args.includes(\"--search\"))\n return [\"--search\", ...args];\n return args;\n }\n },\n copilot: {\n install: \"npm install -g @github/copilot\",\n ready: [/^ > /],\n enter: [/ │ ❯ 1. Yes, proceed/, /❯ 1. Yes/],\n fatal: []\n },\n cursor: {\n install: \"open https://cursor.com/ja/docs/cli/installation\",\n binary: \"cursor-agent\",\n ready: [/\\/ commands/],\n enter: [/→ Run \\(once\\) \\(y\\) \\(enter\\)/, /▶ \\[a\\] Trust this workspace/],\n fatal: [/^ Error: You've hit your usage limit/]\n }\n};\nasync function claudeYes({\n cli = \"claude\",\n cliArgs = [],\n prompt,\n continueOnCrash,\n cwd,\n env,\n exitOnIdle,\n logFile,\n removeControlCharactersFromStdout = false,\n verbose = false\n} = {}) {\n const continueArgs = {\n codex: \"resume --last\".split(\" \"),\n claude: \"--continue\".split(\" \"),\n gemini: []\n };\n process.stdin.setRawMode?.(true);\n let isFatal = false;\n const stdinReady = new ReadyManager;\n const shellOutputStream = new TransformStream;\n const outputWriter = shellOutputStream.writable.getWriter();\n const pty = await import(\"node-pty\").catch(async () => await import(\"bun-pty\")).catch(async () => DIE(\"Please install node-pty or bun-pty, run this: bun install bun-pty\"));\n const getPtyOptions = () => ({\n name: \"xterm-color\",\n ...getTerminalDimensions(),\n cwd: cwd ?? process.cwd(),\n env: env ?? process.env\n });\n const cliConf = CLI_CONFIGURES[cli] || {};\n cliArgs = cliConf.ensureArgs?.(cliArgs) ?? cliArgs;\n const cliCommand = cliConf?.binary || cli;\n let shell = tryCatch(() => pty.spawn(cliCommand, cliArgs, getPtyOptions()), (error) => {\n console.error(`Fatal: Failed to start ${cliCommand}.`);\n if (cliConf?.install)\n console.error(`If you did not installed it yet, Please install it first: ${cliConf.install}`);\n throw error;\n });\n const pendingExitCode = Promise.withResolvers();\n let pendingExitCodeValue = null;\n async function onData(data) {\n await outputWriter.write(data);\n }\n shell.onData(onData);\n shell.onExit(function onExit({ exitCode: exitCode2 }) {\n stdinReady.unready();\n const agentCrashed = exitCode2 !== 0;\n const continueArg = continueArgs[cli];\n if (agentCrashed && continueOnCrash && continueArg) {\n if (!continueArg) {\n return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(\", \")} currently, not ${cli}`);\n }\n if (isFatal) {\n return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);\n }\n console.log(`${cli} crashed, restarting...`);\n shell = pty.spawn(cli, continueArg, getPtyOptions());\n shell.onData(onData);\n shell.onExit(onExit);\n return;\n }\n return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);\n });\n process.stdout.on(\"resize\", () => {\n const { cols, rows } = getTerminalDimensions();\n shell.resize(cols, rows);\n });\n const terminalRender = new TerminalTextRender;\n const isStillWorkingQ = () => terminalRender.render().replace(/\\s+/g, \" \").match(/esc to interrupt|to run in background/);\n const idleWaiter = new IdleWaiter;\n if (exitOnIdle)\n idleWaiter.wait(exitOnIdle).then(async () => {\n if (isStillWorkingQ()) {\n console.log(\"[${cli}-yes] ${cli} is idle, but seems still working, not exiting yet\");\n return;\n }\n console.log(\"[${cli}-yes] ${cli} is idle, exiting...\");\n await exitAgent();\n });\n sflow(fromReadable(process.stdin)).map((buffer) => buffer.toString()).by({\n writable: new WritableStream({\n write: async (data) => {\n await stdinReady.wait();\n shell.write(data);\n }\n }),\n readable: shellOutputStream.readable\n }).forEach(() => idleWaiter.ping()).forEach((text) => {\n terminalRender.write(text);\n if (process.stdin.isTTY)\n return;\n if (text.includes(\"\\x1B[6n\"))\n return;\n const rendered = terminalRender.render();\n const row = rendered.split(`\n`).length + 1;\n const col = (rendered.split(`\n`).slice(-1)[0]?.length || 0) + 1;\n shell.write(`\\x1B[${row};${col}R`);\n }).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll(\"\\r\", \"\")).lines({ EOL: \"NONE\" }).forEach(async (e2, i) => {\n const conf = CLI_CONFIGURES[cli] || null;\n if (!conf)\n return;\n if (conf.ready?.some((rx) => e2.match(rx))) {\n if (cli === \"gemini\" && i <= 80)\n return;\n stdinReady.ready();\n }\n if (conf.enter?.some((rx) => e2.match(rx)))\n await sendEnter(300);\n if (conf.fatal?.some((rx) => e2.match(rx))) {\n isFatal = true;\n await exitAgent();\n }\n }).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);\n if (prompt)\n await sendMessage(prompt);\n const exitCode = await pendingExitCode.promise;\n console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);\n if (logFile) {\n verbose && console.log(`[${cli}-yes] Writing rendered logs to ${logFile}`);\n const logFilePath = path.resolve(logFile);\n await mkdir(path.dirname(logFilePath), { recursive: true }).catch(() => null);\n await writeFile(logFilePath, terminalRender.render());\n }\n return { exitCode, logs: terminalRender.render() };\n async function sendEnter(waitms = 1000) {\n const st = Date.now();\n await idleWaiter.wait(waitms);\n const et = Date.now();\n process.stdout.write(`\\ridleWaiter.wait(${waitms}) took ${et - st}ms\\r`);\n shell.write(\"\\r\");\n }\n async function sendMessage(message) {\n await stdinReady.wait();\n shell.write(message);\n idleWaiter.ping();\n await sendEnter();\n }\n async function exitAgent() {\n continueOnCrash = false;\n await sendMessage(\"/exit\");\n let exited = false;\n await Promise.race([\n pendingExitCode.promise.then(() => exited = true),\n new Promise((resolve) => setTimeout(() => {\n if (exited)\n return;\n shell.kill();\n resolve();\n }, 5000))\n ]);\n }\n function getTerminalDimensions() {\n return {\n cols: process.stdout.columns,\n rows: process.stdout.rows\n };\n }\n}\nfunction tryCatch(fn, catchFn) {\n try {\n return fn();\n } catch (error) {\n return catchFn(error);\n }\n}\nexport {\n removeControlCharacters,\n claudeYes as default,\n CLI_CONFIGURES\n};\n\n//# debugId=8E417C3F5F6C5D9864756E2164756E21\n//# sourceMappingURL=index.js.map\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AACA;AACA;AACA;;;ACiBA;AACA;AACA;AACA;AACA;AACA;AAGA,MAAM,WAAW;AAAA,EACf,mBAAmB,KAAK,IAAI;AAAA,EAC5B,gBAAgB;AAAA,EAChB,WA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064756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/codex-yes.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
/⎿
|
|
82
|
+
/⎿ Claude usage limit reached\./
|
|
77
83
|
]
|
|
78
84
|
},
|
|
79
85
|
gemini: {
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
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:
|
|
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=
|
|
337
|
+
//# debugId=7D0CC0B4FDA115C064756E2164756E21
|
|
332
338
|
//# sourceMappingURL=cli.js.map
|