claude-yes 1.21.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 +10 -10
- package/dist/cli.js +10 -10
- package/dist/cli.js.map +3 -3
- package/dist/codex-yes.js +10 -10
- package/dist/copilot-yes.js +10 -10
- package/dist/cursor-yes.js +10 -10
- package/dist/gemini-yes.js +10 -10
- package/dist/grok-yes.js +338 -0
- package/dist/index.js +10 -10
- package/dist/index.js.map +3 -3
- package/index.ts +14 -25
- 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
|
@@ -70,7 +70,8 @@ function removeControlCharacters(str) {
|
|
|
70
70
|
var CLI_CONFIGURES = {
|
|
71
71
|
grok: {
|
|
72
72
|
install: "npm install -g @vibe-kit/grok-cli",
|
|
73
|
-
ready: [/^
|
|
73
|
+
ready: [/^ │ ❯ /],
|
|
74
|
+
enter: [/^ 1. Yes/]
|
|
74
75
|
},
|
|
75
76
|
claude: {
|
|
76
77
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
@@ -78,7 +79,7 @@ var CLI_CONFIGURES = {
|
|
|
78
79
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
79
80
|
fatal: [
|
|
80
81
|
/No conversation found to continue/,
|
|
81
|
-
/⎿
|
|
82
|
+
/⎿ Claude usage limit reached\./
|
|
82
83
|
]
|
|
83
84
|
},
|
|
84
85
|
gemini: {
|
|
@@ -109,7 +110,7 @@ var CLI_CONFIGURES = {
|
|
|
109
110
|
binary: "cursor-agent",
|
|
110
111
|
ready: [/\/ commands/],
|
|
111
112
|
enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
|
|
112
|
-
fatal: []
|
|
113
|
+
fatal: [/^ Error: You've hit your usage limit/]
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
async function claudeYes({
|
|
@@ -165,7 +166,6 @@ async function claudeYes({
|
|
|
165
166
|
return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
|
|
166
167
|
}
|
|
167
168
|
if (isFatal) {
|
|
168
|
-
console.log(`${cli} crashed with "No conversation found to continue", exiting...`);
|
|
169
169
|
return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
|
|
170
170
|
}
|
|
171
171
|
console.log(`${cli} crashed, restarting...`);
|
|
@@ -223,13 +223,13 @@ async function claudeYes({
|
|
|
223
223
|
}
|
|
224
224
|
if (conf.enter?.some((rx) => e2.match(rx)))
|
|
225
225
|
await sendEnter(300);
|
|
226
|
-
if (conf.fatal?.some((rx) => e2.match(rx)))
|
|
226
|
+
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
227
227
|
isFatal = true;
|
|
228
|
+
await exitAgent();
|
|
229
|
+
}
|
|
228
230
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
229
231
|
if (prompt)
|
|
230
|
-
|
|
231
|
-
await sendMessage(prompt);
|
|
232
|
-
})();
|
|
232
|
+
await sendMessage(prompt);
|
|
233
233
|
const exitCode = await pendingExitCode.promise;
|
|
234
234
|
console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
|
|
235
235
|
if (logFile) {
|
|
@@ -268,7 +268,7 @@ async function claudeYes({
|
|
|
268
268
|
}
|
|
269
269
|
function getTerminalDimensions() {
|
|
270
270
|
return {
|
|
271
|
-
cols:
|
|
271
|
+
cols: process.stdout.columns,
|
|
272
272
|
rows: process.stdout.rows
|
|
273
273
|
};
|
|
274
274
|
}
|
|
@@ -334,5 +334,5 @@ var { exitCode, logs } = await claudeYes({
|
|
|
334
334
|
});
|
|
335
335
|
process.exit(exitCode ?? 1);
|
|
336
336
|
|
|
337
|
-
//# debugId=
|
|
337
|
+
//# debugId=7D0CC0B4FDA115C064756E2164756E21
|
|
338
338
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js
CHANGED
|
@@ -70,7 +70,8 @@ function removeControlCharacters(str) {
|
|
|
70
70
|
var CLI_CONFIGURES = {
|
|
71
71
|
grok: {
|
|
72
72
|
install: "npm install -g @vibe-kit/grok-cli",
|
|
73
|
-
ready: [/^
|
|
73
|
+
ready: [/^ │ ❯ /],
|
|
74
|
+
enter: [/^ 1. Yes/]
|
|
74
75
|
},
|
|
75
76
|
claude: {
|
|
76
77
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
@@ -78,7 +79,7 @@ var CLI_CONFIGURES = {
|
|
|
78
79
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
79
80
|
fatal: [
|
|
80
81
|
/No conversation found to continue/,
|
|
81
|
-
/⎿
|
|
82
|
+
/⎿ Claude usage limit reached\./
|
|
82
83
|
]
|
|
83
84
|
},
|
|
84
85
|
gemini: {
|
|
@@ -109,7 +110,7 @@ var CLI_CONFIGURES = {
|
|
|
109
110
|
binary: "cursor-agent",
|
|
110
111
|
ready: [/\/ commands/],
|
|
111
112
|
enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
|
|
112
|
-
fatal: []
|
|
113
|
+
fatal: [/^ Error: You've hit your usage limit/]
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
async function claudeYes({
|
|
@@ -165,7 +166,6 @@ async function claudeYes({
|
|
|
165
166
|
return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
|
|
166
167
|
}
|
|
167
168
|
if (isFatal) {
|
|
168
|
-
console.log(`${cli} crashed with "No conversation found to continue", exiting...`);
|
|
169
169
|
return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
|
|
170
170
|
}
|
|
171
171
|
console.log(`${cli} crashed, restarting...`);
|
|
@@ -223,13 +223,13 @@ async function claudeYes({
|
|
|
223
223
|
}
|
|
224
224
|
if (conf.enter?.some((rx) => e2.match(rx)))
|
|
225
225
|
await sendEnter(300);
|
|
226
|
-
if (conf.fatal?.some((rx) => e2.match(rx)))
|
|
226
|
+
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
227
227
|
isFatal = true;
|
|
228
|
+
await exitAgent();
|
|
229
|
+
}
|
|
228
230
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
229
231
|
if (prompt)
|
|
230
|
-
|
|
231
|
-
await sendMessage(prompt);
|
|
232
|
-
})();
|
|
232
|
+
await sendMessage(prompt);
|
|
233
233
|
const exitCode = await pendingExitCode.promise;
|
|
234
234
|
console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
|
|
235
235
|
if (logFile) {
|
|
@@ -268,7 +268,7 @@ async function claudeYes({
|
|
|
268
268
|
}
|
|
269
269
|
function getTerminalDimensions() {
|
|
270
270
|
return {
|
|
271
|
-
cols:
|
|
271
|
+
cols: process.stdout.columns,
|
|
272
272
|
rows: process.stdout.rows
|
|
273
273
|
};
|
|
274
274
|
}
|
|
@@ -334,5 +334,5 @@ var { exitCode, logs } = await claudeYes({
|
|
|
334
334
|
});
|
|
335
335
|
process.exit(exitCode ?? 1);
|
|
336
336
|
|
|
337
|
-
//# debugId=
|
|
337
|
+
//# debugId=7D0CC0B4FDA115C064756E2164756E21
|
|
338
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 grok: {\n install: \"npm install -g @vibe-kit/grok-cli\",\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,WAAW,GAAG;AAAA,IACZ,KAAK,KAAK;AAAA;AAAA,EAEZ,IAAI,GAAG;AAAA,IACL,KAAK,mBAAmB,KAAK,IAAI;AAAA,IACjC,OAAO;AAAA;AAAA,OAEH,KAAI,CAAC,IAAI;AAAA,IACb,OAAO,KAAK,oBAAoB,KAAK,IAAI,IAAI;AAAA,MAC3C,MAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,KAAK,aAAa,CAAC;AAAA;AAE5E;AAAA;AAGA,MAAM,aAAa;AAAA,EACjB,UAAU;AAAA,EACV,aAAa,CAAC;AAAA,EACd,IAAI,GAAG;AAAA,IACL,IAAI,KAAK;AAAA,MACP;AAAA,IACF,OAAO,IAAI,QAAQ,CAAC,YAAY,KAAK,WAAW,KAAK,OAAO,CAAC;AAAA;AAAA,EAE/D,OAAO,GAAG;AAAA,IACR,KAAK,UAAU;AAAA;AAAA,EAEjB,KAAK,GAAG;AAAA,IACN,KAAK,UAAU;AAAA,IACf,IAAI,CAAC,KAAK,WAAW;AAAA,MACnB;AAAA,IACF,KAA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;AACjC,IAAI,cAAc,IAAI;AAAA,EAEpB,MAAM,QAAQ,QAAQ,MAAM,YAAY,CAAC;AAAA,EACzC,iBAAiB,MAAM,KAAK,GAAG;AAAA,EAE/B,kBAAkB,QAAQ,MAAM,GAAG,SAAS,EAAE,IAAI,MAAM;AAC1D,EAAO;AAAA,EAEL,kBAAkB,KAAK,EAAE,IAAI,CAAC,MAAM,OAAO,CAAC,CAAC;AAAA;AAG/C,QAAQ,MAAM;AACd,MAAQ,UAAU,SAAS,MAAM,UAAU;AAAA,EACzC,KAAK,KAAK;AAAA,EAEV,QAAQ,KAAK,UAAU;AAAA,EACvB,YAAY,KAAK,aAAa,WAAW,KAAK,UAAU,IAAI;AAAA,EAC5D,SAAS;AAAA,EACT,iBAAiB,KAAK;AAAA,EACtB,SAAS,KAAK;AAAA,EACd,SAAS,KAAK;AAChB,CAAC;AAED,QAAQ,KAAK,YAAY,CAAC;",
|
|
9
|
+
"debugId": "7D0CC0B4FDA115C064756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/codex-yes.js
CHANGED
|
@@ -70,7 +70,8 @@ function removeControlCharacters(str) {
|
|
|
70
70
|
var CLI_CONFIGURES = {
|
|
71
71
|
grok: {
|
|
72
72
|
install: "npm install -g @vibe-kit/grok-cli",
|
|
73
|
-
ready: [/^
|
|
73
|
+
ready: [/^ │ ❯ /],
|
|
74
|
+
enter: [/^ 1. Yes/]
|
|
74
75
|
},
|
|
75
76
|
claude: {
|
|
76
77
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
@@ -78,7 +79,7 @@ var CLI_CONFIGURES = {
|
|
|
78
79
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
79
80
|
fatal: [
|
|
80
81
|
/No conversation found to continue/,
|
|
81
|
-
/⎿
|
|
82
|
+
/⎿ Claude usage limit reached\./
|
|
82
83
|
]
|
|
83
84
|
},
|
|
84
85
|
gemini: {
|
|
@@ -109,7 +110,7 @@ var CLI_CONFIGURES = {
|
|
|
109
110
|
binary: "cursor-agent",
|
|
110
111
|
ready: [/\/ commands/],
|
|
111
112
|
enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
|
|
112
|
-
fatal: []
|
|
113
|
+
fatal: [/^ Error: You've hit your usage limit/]
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
async function claudeYes({
|
|
@@ -165,7 +166,6 @@ async function claudeYes({
|
|
|
165
166
|
return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
|
|
166
167
|
}
|
|
167
168
|
if (isFatal) {
|
|
168
|
-
console.log(`${cli} crashed with "No conversation found to continue", exiting...`);
|
|
169
169
|
return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
|
|
170
170
|
}
|
|
171
171
|
console.log(`${cli} crashed, restarting...`);
|
|
@@ -223,13 +223,13 @@ async function claudeYes({
|
|
|
223
223
|
}
|
|
224
224
|
if (conf.enter?.some((rx) => e2.match(rx)))
|
|
225
225
|
await sendEnter(300);
|
|
226
|
-
if (conf.fatal?.some((rx) => e2.match(rx)))
|
|
226
|
+
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
227
227
|
isFatal = true;
|
|
228
|
+
await exitAgent();
|
|
229
|
+
}
|
|
228
230
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
229
231
|
if (prompt)
|
|
230
|
-
|
|
231
|
-
await sendMessage(prompt);
|
|
232
|
-
})();
|
|
232
|
+
await sendMessage(prompt);
|
|
233
233
|
const exitCode = await pendingExitCode.promise;
|
|
234
234
|
console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
|
|
235
235
|
if (logFile) {
|
|
@@ -268,7 +268,7 @@ async function claudeYes({
|
|
|
268
268
|
}
|
|
269
269
|
function getTerminalDimensions() {
|
|
270
270
|
return {
|
|
271
|
-
cols:
|
|
271
|
+
cols: process.stdout.columns,
|
|
272
272
|
rows: process.stdout.rows
|
|
273
273
|
};
|
|
274
274
|
}
|
|
@@ -334,5 +334,5 @@ var { exitCode, logs } = await claudeYes({
|
|
|
334
334
|
});
|
|
335
335
|
process.exit(exitCode ?? 1);
|
|
336
336
|
|
|
337
|
-
//# debugId=
|
|
337
|
+
//# debugId=7D0CC0B4FDA115C064756E2164756E21
|
|
338
338
|
//# sourceMappingURL=cli.js.map
|
package/dist/copilot-yes.js
CHANGED
|
@@ -70,7 +70,8 @@ function removeControlCharacters(str) {
|
|
|
70
70
|
var CLI_CONFIGURES = {
|
|
71
71
|
grok: {
|
|
72
72
|
install: "npm install -g @vibe-kit/grok-cli",
|
|
73
|
-
ready: [/^
|
|
73
|
+
ready: [/^ │ ❯ /],
|
|
74
|
+
enter: [/^ 1. Yes/]
|
|
74
75
|
},
|
|
75
76
|
claude: {
|
|
76
77
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
@@ -78,7 +79,7 @@ var CLI_CONFIGURES = {
|
|
|
78
79
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
79
80
|
fatal: [
|
|
80
81
|
/No conversation found to continue/,
|
|
81
|
-
/⎿
|
|
82
|
+
/⎿ Claude usage limit reached\./
|
|
82
83
|
]
|
|
83
84
|
},
|
|
84
85
|
gemini: {
|
|
@@ -109,7 +110,7 @@ var CLI_CONFIGURES = {
|
|
|
109
110
|
binary: "cursor-agent",
|
|
110
111
|
ready: [/\/ commands/],
|
|
111
112
|
enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
|
|
112
|
-
fatal: []
|
|
113
|
+
fatal: [/^ Error: You've hit your usage limit/]
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
async function claudeYes({
|
|
@@ -165,7 +166,6 @@ async function claudeYes({
|
|
|
165
166
|
return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
|
|
166
167
|
}
|
|
167
168
|
if (isFatal) {
|
|
168
|
-
console.log(`${cli} crashed with "No conversation found to continue", exiting...`);
|
|
169
169
|
return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
|
|
170
170
|
}
|
|
171
171
|
console.log(`${cli} crashed, restarting...`);
|
|
@@ -223,13 +223,13 @@ async function claudeYes({
|
|
|
223
223
|
}
|
|
224
224
|
if (conf.enter?.some((rx) => e2.match(rx)))
|
|
225
225
|
await sendEnter(300);
|
|
226
|
-
if (conf.fatal?.some((rx) => e2.match(rx)))
|
|
226
|
+
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
227
227
|
isFatal = true;
|
|
228
|
+
await exitAgent();
|
|
229
|
+
}
|
|
228
230
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
229
231
|
if (prompt)
|
|
230
|
-
|
|
231
|
-
await sendMessage(prompt);
|
|
232
|
-
})();
|
|
232
|
+
await sendMessage(prompt);
|
|
233
233
|
const exitCode = await pendingExitCode.promise;
|
|
234
234
|
console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
|
|
235
235
|
if (logFile) {
|
|
@@ -268,7 +268,7 @@ async function claudeYes({
|
|
|
268
268
|
}
|
|
269
269
|
function getTerminalDimensions() {
|
|
270
270
|
return {
|
|
271
|
-
cols:
|
|
271
|
+
cols: process.stdout.columns,
|
|
272
272
|
rows: process.stdout.rows
|
|
273
273
|
};
|
|
274
274
|
}
|
|
@@ -334,5 +334,5 @@ var { exitCode, logs } = await claudeYes({
|
|
|
334
334
|
});
|
|
335
335
|
process.exit(exitCode ?? 1);
|
|
336
336
|
|
|
337
|
-
//# debugId=
|
|
337
|
+
//# debugId=7D0CC0B4FDA115C064756E2164756E21
|
|
338
338
|
//# sourceMappingURL=cli.js.map
|
package/dist/cursor-yes.js
CHANGED
|
@@ -70,7 +70,8 @@ function removeControlCharacters(str) {
|
|
|
70
70
|
var CLI_CONFIGURES = {
|
|
71
71
|
grok: {
|
|
72
72
|
install: "npm install -g @vibe-kit/grok-cli",
|
|
73
|
-
ready: [/^
|
|
73
|
+
ready: [/^ │ ❯ /],
|
|
74
|
+
enter: [/^ 1. Yes/]
|
|
74
75
|
},
|
|
75
76
|
claude: {
|
|
76
77
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
@@ -78,7 +79,7 @@ var CLI_CONFIGURES = {
|
|
|
78
79
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
79
80
|
fatal: [
|
|
80
81
|
/No conversation found to continue/,
|
|
81
|
-
/⎿
|
|
82
|
+
/⎿ Claude usage limit reached\./
|
|
82
83
|
]
|
|
83
84
|
},
|
|
84
85
|
gemini: {
|
|
@@ -109,7 +110,7 @@ var CLI_CONFIGURES = {
|
|
|
109
110
|
binary: "cursor-agent",
|
|
110
111
|
ready: [/\/ commands/],
|
|
111
112
|
enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
|
|
112
|
-
fatal: []
|
|
113
|
+
fatal: [/^ Error: You've hit your usage limit/]
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
async function claudeYes({
|
|
@@ -165,7 +166,6 @@ async function claudeYes({
|
|
|
165
166
|
return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
|
|
166
167
|
}
|
|
167
168
|
if (isFatal) {
|
|
168
|
-
console.log(`${cli} crashed with "No conversation found to continue", exiting...`);
|
|
169
169
|
return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
|
|
170
170
|
}
|
|
171
171
|
console.log(`${cli} crashed, restarting...`);
|
|
@@ -223,13 +223,13 @@ async function claudeYes({
|
|
|
223
223
|
}
|
|
224
224
|
if (conf.enter?.some((rx) => e2.match(rx)))
|
|
225
225
|
await sendEnter(300);
|
|
226
|
-
if (conf.fatal?.some((rx) => e2.match(rx)))
|
|
226
|
+
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
227
227
|
isFatal = true;
|
|
228
|
+
await exitAgent();
|
|
229
|
+
}
|
|
228
230
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
229
231
|
if (prompt)
|
|
230
|
-
|
|
231
|
-
await sendMessage(prompt);
|
|
232
|
-
})();
|
|
232
|
+
await sendMessage(prompt);
|
|
233
233
|
const exitCode = await pendingExitCode.promise;
|
|
234
234
|
console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
|
|
235
235
|
if (logFile) {
|
|
@@ -268,7 +268,7 @@ async function claudeYes({
|
|
|
268
268
|
}
|
|
269
269
|
function getTerminalDimensions() {
|
|
270
270
|
return {
|
|
271
|
-
cols:
|
|
271
|
+
cols: process.stdout.columns,
|
|
272
272
|
rows: process.stdout.rows
|
|
273
273
|
};
|
|
274
274
|
}
|
|
@@ -334,5 +334,5 @@ var { exitCode, logs } = await claudeYes({
|
|
|
334
334
|
});
|
|
335
335
|
process.exit(exitCode ?? 1);
|
|
336
336
|
|
|
337
|
-
//# debugId=
|
|
337
|
+
//# debugId=7D0CC0B4FDA115C064756E2164756E21
|
|
338
338
|
//# sourceMappingURL=cli.js.map
|
package/dist/gemini-yes.js
CHANGED
|
@@ -70,7 +70,8 @@ function removeControlCharacters(str) {
|
|
|
70
70
|
var CLI_CONFIGURES = {
|
|
71
71
|
grok: {
|
|
72
72
|
install: "npm install -g @vibe-kit/grok-cli",
|
|
73
|
-
ready: [/^
|
|
73
|
+
ready: [/^ │ ❯ /],
|
|
74
|
+
enter: [/^ 1. Yes/]
|
|
74
75
|
},
|
|
75
76
|
claude: {
|
|
76
77
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
@@ -78,7 +79,7 @@ var CLI_CONFIGURES = {
|
|
|
78
79
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
79
80
|
fatal: [
|
|
80
81
|
/No conversation found to continue/,
|
|
81
|
-
/⎿
|
|
82
|
+
/⎿ Claude usage limit reached\./
|
|
82
83
|
]
|
|
83
84
|
},
|
|
84
85
|
gemini: {
|
|
@@ -109,7 +110,7 @@ var CLI_CONFIGURES = {
|
|
|
109
110
|
binary: "cursor-agent",
|
|
110
111
|
ready: [/\/ commands/],
|
|
111
112
|
enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
|
|
112
|
-
fatal: []
|
|
113
|
+
fatal: [/^ Error: You've hit your usage limit/]
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
async function claudeYes({
|
|
@@ -165,7 +166,6 @@ async function claudeYes({
|
|
|
165
166
|
return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
|
|
166
167
|
}
|
|
167
168
|
if (isFatal) {
|
|
168
|
-
console.log(`${cli} crashed with "No conversation found to continue", exiting...`);
|
|
169
169
|
return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
|
|
170
170
|
}
|
|
171
171
|
console.log(`${cli} crashed, restarting...`);
|
|
@@ -223,13 +223,13 @@ async function claudeYes({
|
|
|
223
223
|
}
|
|
224
224
|
if (conf.enter?.some((rx) => e2.match(rx)))
|
|
225
225
|
await sendEnter(300);
|
|
226
|
-
if (conf.fatal?.some((rx) => e2.match(rx)))
|
|
226
|
+
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
227
227
|
isFatal = true;
|
|
228
|
+
await exitAgent();
|
|
229
|
+
}
|
|
228
230
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
229
231
|
if (prompt)
|
|
230
|
-
|
|
231
|
-
await sendMessage(prompt);
|
|
232
|
-
})();
|
|
232
|
+
await sendMessage(prompt);
|
|
233
233
|
const exitCode = await pendingExitCode.promise;
|
|
234
234
|
console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
|
|
235
235
|
if (logFile) {
|
|
@@ -268,7 +268,7 @@ async function claudeYes({
|
|
|
268
268
|
}
|
|
269
269
|
function getTerminalDimensions() {
|
|
270
270
|
return {
|
|
271
|
-
cols:
|
|
271
|
+
cols: process.stdout.columns,
|
|
272
272
|
rows: process.stdout.rows
|
|
273
273
|
};
|
|
274
274
|
}
|
|
@@ -334,5 +334,5 @@ var { exitCode, logs } = await claudeYes({
|
|
|
334
334
|
});
|
|
335
335
|
process.exit(exitCode ?? 1);
|
|
336
336
|
|
|
337
|
-
//# debugId=
|
|
337
|
+
//# debugId=7D0CC0B4FDA115C064756E2164756E21
|
|
338
338
|
//# sourceMappingURL=cli.js.map
|
package/dist/grok-yes.js
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
9
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
|
+
for (let key of __getOwnPropNames(mod))
|
|
12
|
+
if (!__hasOwnProp.call(to, key))
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: () => mod[key],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
20
|
+
|
|
21
|
+
// cli.ts
|
|
22
|
+
import enhancedMs from "enhanced-ms";
|
|
23
|
+
import yargs from "yargs";
|
|
24
|
+
import { hideBin } from "yargs/helpers";
|
|
25
|
+
|
|
26
|
+
// dist/index.js
|
|
27
|
+
import { fromReadable, fromWritable } from "from-node-stream";
|
|
28
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
29
|
+
import path from "path";
|
|
30
|
+
import DIE from "phpdie";
|
|
31
|
+
import sflow from "sflow";
|
|
32
|
+
import { TerminalTextRender } from "terminal-render";
|
|
33
|
+
class IdleWaiter {
|
|
34
|
+
lastActivityTime = Date.now();
|
|
35
|
+
checkInterval = 100;
|
|
36
|
+
constructor() {
|
|
37
|
+
this.ping();
|
|
38
|
+
}
|
|
39
|
+
ping() {
|
|
40
|
+
this.lastActivityTime = Date.now();
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
async wait(ms) {
|
|
44
|
+
while (this.lastActivityTime >= Date.now() - ms)
|
|
45
|
+
await new Promise((resolve) => setTimeout(resolve, this.checkInterval));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class ReadyManager {
|
|
50
|
+
isReady = false;
|
|
51
|
+
readyQueue = [];
|
|
52
|
+
wait() {
|
|
53
|
+
if (this.isReady)
|
|
54
|
+
return;
|
|
55
|
+
return new Promise((resolve) => this.readyQueue.push(resolve));
|
|
56
|
+
}
|
|
57
|
+
unready() {
|
|
58
|
+
this.isReady = false;
|
|
59
|
+
}
|
|
60
|
+
ready() {
|
|
61
|
+
this.isReady = true;
|
|
62
|
+
if (!this.readyQueue.length)
|
|
63
|
+
return;
|
|
64
|
+
this.readyQueue.splice(0).map((resolve) => resolve());
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function removeControlCharacters(str) {
|
|
68
|
+
return str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, "");
|
|
69
|
+
}
|
|
70
|
+
var CLI_CONFIGURES = {
|
|
71
|
+
grok: {
|
|
72
|
+
install: "npm install -g @vibe-kit/grok-cli",
|
|
73
|
+
ready: [/^ │ ❯ /],
|
|
74
|
+
enter: [/^ 1. Yes/]
|
|
75
|
+
},
|
|
76
|
+
claude: {
|
|
77
|
+
install: "npm install -g @anthropic-ai/claude-code",
|
|
78
|
+
ready: [/^> /],
|
|
79
|
+
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
80
|
+
fatal: [
|
|
81
|
+
/No conversation found to continue/,
|
|
82
|
+
/⎿ Claude usage limit reached\./
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
gemini: {
|
|
86
|
+
install: "npm install -g @google/gemini-cli",
|
|
87
|
+
ready: [/Type your message/],
|
|
88
|
+
enter: [/│ ● 1. Yes, allow once/],
|
|
89
|
+
fatal: []
|
|
90
|
+
},
|
|
91
|
+
codex: {
|
|
92
|
+
install: "npm install -g @openai/codex-cli",
|
|
93
|
+
ready: [/⏎ send/],
|
|
94
|
+
enter: [/ > 1. Approve/, /> 1. Yes, allow Codex to work in this folder/],
|
|
95
|
+
fatal: [/Error: The cursor position could not be read within/],
|
|
96
|
+
ensureArgs: (args) => {
|
|
97
|
+
if (!args.includes("--search"))
|
|
98
|
+
return ["--search", ...args];
|
|
99
|
+
return args;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
copilot: {
|
|
103
|
+
install: "npm install -g @github/copilot",
|
|
104
|
+
ready: [/^ > /],
|
|
105
|
+
enter: [/ │ ❯ 1. Yes, proceed/, /❯ 1. Yes/],
|
|
106
|
+
fatal: []
|
|
107
|
+
},
|
|
108
|
+
cursor: {
|
|
109
|
+
install: "open https://cursor.com/ja/docs/cli/installation",
|
|
110
|
+
binary: "cursor-agent",
|
|
111
|
+
ready: [/\/ commands/],
|
|
112
|
+
enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
|
|
113
|
+
fatal: [/^ Error: You've hit your usage limit/]
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
async function claudeYes({
|
|
117
|
+
cli = "claude",
|
|
118
|
+
cliArgs = [],
|
|
119
|
+
prompt,
|
|
120
|
+
continueOnCrash,
|
|
121
|
+
cwd,
|
|
122
|
+
env,
|
|
123
|
+
exitOnIdle,
|
|
124
|
+
logFile,
|
|
125
|
+
removeControlCharactersFromStdout = false,
|
|
126
|
+
verbose = false
|
|
127
|
+
} = {}) {
|
|
128
|
+
const continueArgs = {
|
|
129
|
+
codex: "resume --last".split(" "),
|
|
130
|
+
claude: "--continue".split(" "),
|
|
131
|
+
gemini: []
|
|
132
|
+
};
|
|
133
|
+
process.stdin.setRawMode?.(true);
|
|
134
|
+
let isFatal = false;
|
|
135
|
+
const stdinReady = new ReadyManager;
|
|
136
|
+
const shellOutputStream = new TransformStream;
|
|
137
|
+
const outputWriter = shellOutputStream.writable.getWriter();
|
|
138
|
+
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"));
|
|
139
|
+
const getPtyOptions = () => ({
|
|
140
|
+
name: "xterm-color",
|
|
141
|
+
...getTerminalDimensions(),
|
|
142
|
+
cwd: cwd ?? process.cwd(),
|
|
143
|
+
env: env ?? process.env
|
|
144
|
+
});
|
|
145
|
+
const cliConf = CLI_CONFIGURES[cli] || {};
|
|
146
|
+
cliArgs = cliConf.ensureArgs?.(cliArgs) ?? cliArgs;
|
|
147
|
+
const cliCommand = cliConf?.binary || cli;
|
|
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
|
+
});
|
|
154
|
+
const pendingExitCode = Promise.withResolvers();
|
|
155
|
+
let pendingExitCodeValue = null;
|
|
156
|
+
async function onData(data) {
|
|
157
|
+
await outputWriter.write(data);
|
|
158
|
+
}
|
|
159
|
+
shell.onData(onData);
|
|
160
|
+
shell.onExit(function onExit({ exitCode: exitCode2 }) {
|
|
161
|
+
stdinReady.unready();
|
|
162
|
+
const agentCrashed = exitCode2 !== 0;
|
|
163
|
+
const continueArg = continueArgs[cli];
|
|
164
|
+
if (agentCrashed && continueOnCrash && continueArg) {
|
|
165
|
+
if (!continueArg) {
|
|
166
|
+
return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
|
|
167
|
+
}
|
|
168
|
+
if (isFatal) {
|
|
169
|
+
return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
|
|
170
|
+
}
|
|
171
|
+
console.log(`${cli} crashed, restarting...`);
|
|
172
|
+
shell = pty.spawn(cli, continueArg, getPtyOptions());
|
|
173
|
+
shell.onData(onData);
|
|
174
|
+
shell.onExit(onExit);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
|
|
178
|
+
});
|
|
179
|
+
process.stdout.on("resize", () => {
|
|
180
|
+
const { cols, rows } = getTerminalDimensions();
|
|
181
|
+
shell.resize(cols, rows);
|
|
182
|
+
});
|
|
183
|
+
const terminalRender = new TerminalTextRender;
|
|
184
|
+
const isStillWorkingQ = () => terminalRender.render().replace(/\s+/g, " ").match(/esc to interrupt|to run in background/);
|
|
185
|
+
const idleWaiter = new IdleWaiter;
|
|
186
|
+
if (exitOnIdle)
|
|
187
|
+
idleWaiter.wait(exitOnIdle).then(async () => {
|
|
188
|
+
if (isStillWorkingQ()) {
|
|
189
|
+
console.log("[${cli}-yes] ${cli} is idle, but seems still working, not exiting yet");
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
console.log("[${cli}-yes] ${cli} is idle, exiting...");
|
|
193
|
+
await exitAgent();
|
|
194
|
+
});
|
|
195
|
+
sflow(fromReadable(process.stdin)).map((buffer) => buffer.toString()).by({
|
|
196
|
+
writable: new WritableStream({
|
|
197
|
+
write: async (data) => {
|
|
198
|
+
await stdinReady.wait();
|
|
199
|
+
shell.write(data);
|
|
200
|
+
}
|
|
201
|
+
}),
|
|
202
|
+
readable: shellOutputStream.readable
|
|
203
|
+
}).forEach(() => idleWaiter.ping()).forEach((text) => {
|
|
204
|
+
terminalRender.write(text);
|
|
205
|
+
if (process.stdin.isTTY)
|
|
206
|
+
return;
|
|
207
|
+
if (text.includes("\x1B[6n"))
|
|
208
|
+
return;
|
|
209
|
+
const rendered = terminalRender.render();
|
|
210
|
+
const row = rendered.split(`
|
|
211
|
+
`).length + 1;
|
|
212
|
+
const col = (rendered.split(`
|
|
213
|
+
`).slice(-1)[0]?.length || 0) + 1;
|
|
214
|
+
shell.write(`\x1B[${row};${col}R`);
|
|
215
|
+
}).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll("\r", "")).lines({ EOL: "NONE" }).forEach(async (e2, i) => {
|
|
216
|
+
const conf = CLI_CONFIGURES[cli] || null;
|
|
217
|
+
if (!conf)
|
|
218
|
+
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();
|
|
229
|
+
}
|
|
230
|
+
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
231
|
+
if (prompt)
|
|
232
|
+
await sendMessage(prompt);
|
|
233
|
+
const exitCode = await pendingExitCode.promise;
|
|
234
|
+
console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
|
|
235
|
+
if (logFile) {
|
|
236
|
+
verbose && console.log(`[${cli}-yes] Writing rendered logs to ${logFile}`);
|
|
237
|
+
const logFilePath = path.resolve(logFile);
|
|
238
|
+
await mkdir(path.dirname(logFilePath), { recursive: true }).catch(() => null);
|
|
239
|
+
await writeFile(logFilePath, terminalRender.render());
|
|
240
|
+
}
|
|
241
|
+
return { exitCode, logs: terminalRender.render() };
|
|
242
|
+
async function sendEnter(waitms = 1000) {
|
|
243
|
+
const st = Date.now();
|
|
244
|
+
await idleWaiter.wait(waitms);
|
|
245
|
+
const et = Date.now();
|
|
246
|
+
process.stdout.write(`\ridleWaiter.wait(${waitms}) took ${et - st}ms\r`);
|
|
247
|
+
shell.write("\r");
|
|
248
|
+
}
|
|
249
|
+
async function sendMessage(message) {
|
|
250
|
+
await stdinReady.wait();
|
|
251
|
+
shell.write(message);
|
|
252
|
+
idleWaiter.ping();
|
|
253
|
+
await sendEnter();
|
|
254
|
+
}
|
|
255
|
+
async function exitAgent() {
|
|
256
|
+
continueOnCrash = false;
|
|
257
|
+
await sendMessage("/exit");
|
|
258
|
+
let exited = false;
|
|
259
|
+
await Promise.race([
|
|
260
|
+
pendingExitCode.promise.then(() => exited = true),
|
|
261
|
+
new Promise((resolve) => setTimeout(() => {
|
|
262
|
+
if (exited)
|
|
263
|
+
return;
|
|
264
|
+
shell.kill();
|
|
265
|
+
resolve();
|
|
266
|
+
}, 5000))
|
|
267
|
+
]);
|
|
268
|
+
}
|
|
269
|
+
function getTerminalDimensions() {
|
|
270
|
+
return {
|
|
271
|
+
cols: process.stdout.columns,
|
|
272
|
+
rows: process.stdout.rows
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function tryCatch(fn, catchFn) {
|
|
277
|
+
try {
|
|
278
|
+
return fn();
|
|
279
|
+
} catch (error) {
|
|
280
|
+
return catchFn(error);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// cli.ts
|
|
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", {
|
|
286
|
+
type: "boolean",
|
|
287
|
+
default: true,
|
|
288
|
+
description: "spawn Claude with --continue if it crashes, only works for claude"
|
|
289
|
+
}).option("log-file", {
|
|
290
|
+
type: "string",
|
|
291
|
+
description: "Log file to write to"
|
|
292
|
+
}).option("cli", {
|
|
293
|
+
type: "string",
|
|
294
|
+
description: 'Claude CLI command, e.g. "claude,gemini,codex,cursor,copilot", default is "claude"'
|
|
295
|
+
}).option("prompt", {
|
|
296
|
+
type: "string",
|
|
297
|
+
description: "Prompt to send to Claude",
|
|
298
|
+
alias: "p"
|
|
299
|
+
}).option("verbose", {
|
|
300
|
+
type: "boolean",
|
|
301
|
+
description: "Enable verbose logging",
|
|
302
|
+
default: false
|
|
303
|
+
}).option("exit-on-idle", {
|
|
304
|
+
type: "string",
|
|
305
|
+
description: 'Exit after a period of inactivity, e.g., "5s" or "1m"'
|
|
306
|
+
}).parserConfiguration({
|
|
307
|
+
"unknown-options-as-args": true,
|
|
308
|
+
"halt-at-non-option": true
|
|
309
|
+
}).parseSync();
|
|
310
|
+
if (!argv.cli) {
|
|
311
|
+
const cliName = process.argv[1]?.split("/").pop()?.split("-")[0];
|
|
312
|
+
argv.cli = cliName || "claude";
|
|
313
|
+
}
|
|
314
|
+
var rawArgs = process.argv.slice(2);
|
|
315
|
+
var dashIndex = rawArgs.indexOf("--");
|
|
316
|
+
var promptFromDash = undefined;
|
|
317
|
+
var cliArgsForSpawn = [];
|
|
318
|
+
if (dashIndex !== -1) {
|
|
319
|
+
const after = rawArgs.slice(dashIndex + 1);
|
|
320
|
+
promptFromDash = after.join(" ");
|
|
321
|
+
cliArgsForSpawn = rawArgs.slice(0, dashIndex).map(String);
|
|
322
|
+
} else {
|
|
323
|
+
cliArgsForSpawn = argv._.map((e) => String(e));
|
|
324
|
+
}
|
|
325
|
+
console.clear();
|
|
326
|
+
var { exitCode, logs } = await claudeYes({
|
|
327
|
+
cli: argv.cli,
|
|
328
|
+
prompt: argv.prompt || promptFromDash,
|
|
329
|
+
exitOnIdle: argv.exitOnIdle ? enhancedMs(argv.exitOnIdle) : undefined,
|
|
330
|
+
cliArgs: cliArgsForSpawn,
|
|
331
|
+
continueOnCrash: argv.continueOnCrash,
|
|
332
|
+
logFile: argv.logFile,
|
|
333
|
+
verbose: argv.verbose
|
|
334
|
+
});
|
|
335
|
+
process.exit(exitCode ?? 1);
|
|
336
|
+
|
|
337
|
+
//# debugId=7D0CC0B4FDA115C064756E2164756E21
|
|
338
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,8 @@ function removeControlCharacters(str) {
|
|
|
71
71
|
var CLI_CONFIGURES = {
|
|
72
72
|
grok: {
|
|
73
73
|
install: "npm install -g @vibe-kit/grok-cli",
|
|
74
|
-
ready: [/^
|
|
74
|
+
ready: [/^ │ ❯ /],
|
|
75
|
+
enter: [/^ 1. Yes/]
|
|
75
76
|
},
|
|
76
77
|
claude: {
|
|
77
78
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
@@ -79,7 +80,7 @@ var CLI_CONFIGURES = {
|
|
|
79
80
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
80
81
|
fatal: [
|
|
81
82
|
/No conversation found to continue/,
|
|
82
|
-
/⎿
|
|
83
|
+
/⎿ Claude usage limit reached\./
|
|
83
84
|
]
|
|
84
85
|
},
|
|
85
86
|
gemini: {
|
|
@@ -110,7 +111,7 @@ var CLI_CONFIGURES = {
|
|
|
110
111
|
binary: "cursor-agent",
|
|
111
112
|
ready: [/\/ commands/],
|
|
112
113
|
enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
|
|
113
|
-
fatal: []
|
|
114
|
+
fatal: [/^ Error: You've hit your usage limit/]
|
|
114
115
|
}
|
|
115
116
|
};
|
|
116
117
|
async function claudeYes({
|
|
@@ -166,7 +167,6 @@ async function claudeYes({
|
|
|
166
167
|
return console.warn(`continueOnCrash is only supported for ${Object.keys(continueArgs).join(", ")} currently, not ${cli}`);
|
|
167
168
|
}
|
|
168
169
|
if (isFatal) {
|
|
169
|
-
console.log(`${cli} crashed with "No conversation found to continue", exiting...`);
|
|
170
170
|
return pendingExitCode.resolve(pendingExitCodeValue = exitCode2);
|
|
171
171
|
}
|
|
172
172
|
console.log(`${cli} crashed, restarting...`);
|
|
@@ -224,13 +224,13 @@ async function claudeYes({
|
|
|
224
224
|
}
|
|
225
225
|
if (conf.enter?.some((rx) => e2.match(rx)))
|
|
226
226
|
await sendEnter(300);
|
|
227
|
-
if (conf.fatal?.some((rx) => e2.match(rx)))
|
|
227
|
+
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
228
228
|
isFatal = true;
|
|
229
|
+
await exitAgent();
|
|
230
|
+
}
|
|
229
231
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
230
232
|
if (prompt)
|
|
231
|
-
|
|
232
|
-
await sendMessage(prompt);
|
|
233
|
-
})();
|
|
233
|
+
await sendMessage(prompt);
|
|
234
234
|
const exitCode = await pendingExitCode.promise;
|
|
235
235
|
console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
|
|
236
236
|
if (logFile) {
|
|
@@ -269,7 +269,7 @@ async function claudeYes({
|
|
|
269
269
|
}
|
|
270
270
|
function getTerminalDimensions() {
|
|
271
271
|
return {
|
|
272
|
-
cols:
|
|
272
|
+
cols: process.stdout.columns,
|
|
273
273
|
rows: process.stdout.rows
|
|
274
274
|
};
|
|
275
275
|
}
|
|
@@ -287,5 +287,5 @@ export {
|
|
|
287
287
|
CLI_CONFIGURES
|
|
288
288
|
};
|
|
289
289
|
|
|
290
|
-
//# debugId=
|
|
290
|
+
//# debugId=8E417C3F5F6C5D9864756E2164756E21
|
|
291
291
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../index.ts", "../idleWaiter.ts", "../ReadyManager.ts", "../removeControlCharacters.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { 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';\nimport { IdleWaiter } from './idleWaiter';\nimport { ReadyManager } from './ReadyManager';\nimport { removeControlCharacters } from './removeControlCharacters';\n\nexport const CLI_CONFIGURES: Record<\n string,\n {\n install?: string; // hint user for install command if not installed\n binary?: string; // actual binary name if different from cli\n ready?: RegExp[]; // regex matcher for stdin ready, or line index for gemini\n enter?: RegExp[]; // array of regex to match for sending Enter\n fatal?: RegExp[]; // array of regex to match for fatal errors\n ensureArgs?: (args: string[]) => string[]; // function to ensure certain args are present\n }\n> = {\n grok: {\n install: 'npm install -g @vibe-kit/grok-cli',\n ready: [/^ +│ ❯ /],\n },\n claude: {\n install: 'npm install -g @anthropic-ai/claude-code',\n ready: [/^> /], // regex matcher for stdin ready,\n enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],\n fatal: [\n /No conversation found to continue/,\n /⎿ {2}Claude usage limit reached\\./,\n ],\n },\n gemini: {\n install: 'npm install -g @google/gemini-cli',\n // match the agent prompt after initial lines; handled by index logic using line index\n ready: [/Type your message/], // used with line index check\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 // add to codex --search by default when not provided by the user\n ensureArgs: (args: string[]) => {\n if (!args.includes('--search')) 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 // map logical \"cursor\" cli name to actual binary name\n binary: 'cursor-agent',\n ready: [/\\/ commands/],\n enter: [/→ Run \\(once\\) \\(y\\) \\(enter\\)/, /▶ \\[a\\] Trust this workspace/],\n fatal: [],\n },\n};\n/**\n * Main function to run Claude with automatic yes/no responses\n * @param options Configuration options\n * @param options.continueOnCrash - If true, automatically restart Claude when it crashes:\n * 1. Shows message 'Claude crashed, restarting..'\n * 2. Spawns a new 'claude --continue' process\n * 3. Re-attaches the new process to the shell stdio (pipes new process stdin/stdout)\n * 4. If it crashes with \"No conversation found to continue\", exits the process\n * @param options.exitOnIdle - Exit when Claude is idle. Boolean or timeout in milliseconds, recommended 5000 - 60000, default is false\n * @param options.claudeArgs - Additional arguments to pass to the Claude CLI\n * @param options.removeControlCharactersFromStdout - Remove ANSI control characters from stdout. Defaults to !process.stdout.isTTY\n *\n * @example\n * ```typescript\n * import claudeYes from 'claude-yes';\n * await claudeYes({\n * prompt: 'help me solve all todos in my codebase',\n *\n * // optional\n * cli: 'claude',\n * cliArgs: ['--verbose'], // additional args to pass to claude\n * exitOnIdle: 30000, // exit after 30 seconds of idle\n * continueOnCrash: true, // restart if claude crashes, default is true\n * logFile: 'claude.log', // save logs to file\n * });\n * ```\n */\nexport default async function claudeYes({\n cli = 'claude',\n cliArgs = [],\n prompt,\n continueOnCrash,\n cwd,\n env,\n exitOnIdle,\n logFile,\n removeControlCharactersFromStdout = false, // = !process.stdout.isTTY,\n verbose = false,\n}: {\n cli?: (string & {}) | keyof typeof CLI_CONFIGURES;\n cliArgs?: string[];\n prompt?: string;\n continueOnCrash?: boolean;\n cwd?: string;\n env?: Record<string, string>;\n exitOnIdle?: number;\n logFile?: string;\n removeControlCharactersFromStdout?: boolean;\n verbose?: boolean;\n} = {}) {\n const continueArgs = {\n codex: 'resume --last'.split(' '),\n claude: '--continue'.split(' '),\n gemini: [], // not possible yet\n };\n\n // if (verbose) {\n // console.log('calling claudeYes: ', {\n // cli,\n // continueOnCrash,\n // exitOnIdle,\n // cliArgs,\n // cwd,\n // removeControlCharactersFromStdout,\n // logFile,\n // verbose,\n // });\n // }\n // console.log(\n // `⭐ Starting ${cli}, automatically responding to yes/no prompts...`\n // );\n // console.log(\n // '⚠️ Important Security Warning: Only run this on trusted repositories. This tool automatically responds to prompts and can execute commands without user confirmation. Be aware of potential prompt injection attacks where malicious code or instructions could be embedded in files or user inputs to manipulate the automated responses.'\n // );\n\n process.stdin.setRawMode?.(true); // must be called any stdout/stdin usage\n let isFatal = false; // match 'No conversation found to continue'\n const stdinReady = new ReadyManager();\n\n const shellOutputStream = new TransformStream<string, string>();\n const outputWriter = shellOutputStream.writable.getWriter();\n // const pty = await import('node-pty');\n\n // its recommened to use bun-pty in windows\n const pty = await import('node-pty')\n .catch(async () => await import('bun-pty'))\n .catch(async () =>\n DIE('Please install node-pty or bun-pty, run this: bun install bun-pty'),\n );\n\n const getPtyOptions = () => ({\n name: 'xterm-color',\n ...getTerminalDimensions(),\n cwd: cwd ?? process.cwd(),\n env: env ?? (process.env as Record<string, string>),\n });\n\n // Apply CLI specific configurations (moved to CLI_CONFIGURES)\n const cliConf = (CLI_CONFIGURES as Record<string, any>)[cli] || {};\n cliArgs = cliConf.ensureArgs?.(cliArgs) ?? cliArgs;\n const cliCommand = cliConf?.binary || cli;\n\n let shell = tryCatch(\n () => pty.spawn(cliCommand, cliArgs, getPtyOptions()),\n (error: unknown) => {\n console.error(`Fatal: Failed to start ${cliCommand}.`);\n if (cliConf?.install)\n console.error(\n `If you did not installed it yet, Please install it first: ${cliConf.install}`,\n );\n throw error;\n },\n );\n const pendingExitCode = Promise.withResolvers<number | null>();\n let pendingExitCodeValue = null;\n\n // TODO handle error if claude is not installed, show msg:\n // npm install -g @anthropic-ai/claude-code\n\n async function onData(data: string) {\n // append data to the buffer, so we can process it later\n await outputWriter.write(data);\n }\n\n shell.onData(onData);\n shell.onExit(function onExit({ exitCode }) {\n stdinReady.unready(); // start buffer stdin\n const agentCrashed = exitCode !== 0;\n const continueArg = (continueArgs as Record<string, string[]>)[cli];\n\n if (agentCrashed && continueOnCrash && continueArg) {\n if (!continueArg) {\n return console.warn(\n `continueOnCrash is only supported for ${Object.keys(continueArgs).join(', ')} currently, not ${cli}`,\n );\n }\n if (isFatal) {\n console.log(\n `${cli} crashed with \"No conversation found to continue\", exiting...`,\n );\n return pendingExitCode.resolve((pendingExitCodeValue = exitCode));\n }\n console.log(`${cli} crashed, restarting...`);\n\n shell = pty.spawn(cli, continueArg, getPtyOptions());\n shell.onData(onData);\n shell.onExit(onExit);\n return;\n }\n return pendingExitCode.resolve((pendingExitCodeValue = exitCode));\n });\n\n // when current tty resized, resize the pty\n process.stdout.on('resize', () => {\n const { cols, rows } = getTerminalDimensions(); // minimum 80 columns to avoid layout issues\n shell.resize(cols, rows); // minimum 80 columns to avoid layout issues\n });\n\n const terminalRender = new TerminalTextRender();\n const isStillWorkingQ = () =>\n terminalRender\n .render()\n .replace(/\\s+/g, ' ')\n .match(/esc to interrupt|to run in background/);\n\n const idleWaiter = new IdleWaiter();\n if (exitOnIdle)\n idleWaiter.wait(exitOnIdle).then(async () => {\n if (isStillWorkingQ()) {\n console.log(\n '[${cli}-yes] ${cli} is idle, but seems still working, not exiting yet',\n );\n return;\n }\n\n console.log('[${cli}-yes] ${cli} is idle, exiting...');\n await exitAgent();\n });\n\n // Message streaming\n sflow(fromReadable<Buffer>(process.stdin))\n .map((buffer) => buffer.toString())\n // .map((e) => e.replaceAll('\\x1a', '')) // remove ctrl+z from user's input (seems bug)\n // .forEach(e => appendFile('.cache/io.log', \"input |\" + JSON.stringify(e) + '\\n')) // for debugging\n // pipe\n .by({\n writable: new WritableStream<string>({\n write: async (data) => {\n await stdinReady.wait();\n // await idleWaiter.wait(20); // wait for idle for 200ms to avoid messing up claude's input\n shell.write(data);\n },\n }),\n readable: shellOutputStream.readable,\n })\n .forEach(() => idleWaiter.ping())\n .forEach((text) => {\n terminalRender.write(text);\n // todo: .onStatus((msg)=> shell.write(msg))\n if (process.stdin.isTTY) return; // only handle it when stdin is not tty\n if (text.includes('\\u001b[6n')) return; // only asked\n\n // todo: use terminalRender API to get cursor position when new version is available\n // xterm replies CSI row; column R if asked cursor position\n // https://en.wikipedia.org/wiki/ANSI_escape_code#:~:text=citation%20needed%5D-,xterm%20replies,-CSI%20row%C2%A0%3B\n // when agent asking position, respond with row; col\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(`\\u001b[${row};${col}R`);\n })\n\n // auto-response\n .forkTo((e) =>\n e\n .map((e) => removeControlCharacters(e))\n .map((e) => e.replaceAll('\\r', '')) // remove carriage return\n .lines({ EOL: 'NONE' })\n // Generic auto-response handler driven by CLI_CONFIGURES\n .forEach(async (e, i) => {\n const conf =\n CLI_CONFIGURES[cli as keyof typeof CLI_CONFIGURES] || null;\n if (!conf) return;\n\n // ready matcher: if matched, mark stdin ready\n if (conf.ready?.some((rx: RegExp) => e.match(rx))) {\n if (cli === 'gemini' && i <= 80) return; // gemini initial noise, only after many lines\n stdinReady.ready();\n }\n\n // enter matchers: send Enter when any enter regex matches\n if (conf.enter?.some((rx: RegExp) => e.match(rx)))\n await sendEnter(300); // send Enter after 300ms idle wait\n\n // fatal matchers: set isFatal flag when matched\n if (conf.fatal?.some((rx: RegExp) => e.match(rx))) isFatal = true;\n })\n // .forEach(e => appendFile('.cache/io.log', \"output|\" + JSON.stringify(e) + '\\n')) // for debugging\n .run(),\n )\n .map((e) =>\n removeControlCharactersFromStdout ? removeControlCharacters(e) : e,\n )\n .to(fromWritable(process.stdout))\n .then(() => null); // run it immediately without await\n\n // wait for cli ready and send prompt if provided\n if (prompt)\n (async () => {\n // console.log(`[${cli}-yes] Ready to send prompt to ${cli}: ${prompt}`);\n // idleWaiter.ping();\n // console.log(\n // 'await idleWaiter.wait(1000); // wait a bit for claude to start'\n // );\n // await idleWaiter.wait(1000); // wait a bit for claude to start\n // console.log('await stdinReady.wait();');\n // await stdinReady.wait();\n // console.log(`[${cli}-yes] Waiting for ${cli} to be ready...`);\n // console.log('await idleWaiter.wait(200);');\n // await idleWaiter.wait(200);\n // console.log(`[${cli}-yes] Sending prompt to ${cli}: ${prompt}`);\n await sendMessage(prompt);\n })();\n\n const exitCode = await pendingExitCode.promise; // wait for the shell to exit\n console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);\n\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(\n () => null,\n );\n await writeFile(logFilePath, terminalRender.render());\n }\n\n return { exitCode, logs: terminalRender.render() };\n\n async function sendEnter(waitms = 1000) {\n // wait for idle for a bit to let agent cli finish rendering\n const st = Date.now();\n\n await idleWaiter.wait(waitms);\n const et = Date.now();\n process.stdout.write(`\\ridleWaiter.wait(${waitms}) took ${et - st}ms\\r`);\n\n shell.write('\\r');\n }\n\n async function sendMessage(message: string) {\n await stdinReady.wait();\n // show in-place message: write msg and move cursor back start\n shell.write(message);\n idleWaiter.ping(); // just sent a message, wait for echo\n await sendEnter();\n }\n\n async function exitAgent() {\n continueOnCrash = false;\n // send exit command to the shell, must sleep a bit to avoid claude treat it as pasted input\n await sendMessage('/exit');\n\n // wait for shell to exit or kill it with a timeout\n let exited = false;\n await Promise.race([\n pendingExitCode.promise.then(() => (exited = true)), // resolve when shell exits\n\n // if shell doesn't exit in 5 seconds, kill it\n new Promise<void>((resolve) =>\n setTimeout(() => {\n if (exited) return; // if shell already exited, do nothing\n shell.kill(); // kill the shell process if it doesn't exit in time\n resolve();\n }, 5000),\n ), // 5 seconds timeout\n ]);\n }\n\n function getTerminalDimensions() {\n return {\n cols: Math.max(process.stdout.columns, 80),\n rows: process.stdout.rows,\n };\n }\n}\n\nexport { removeControlCharacters };\n\nfunction tryCatch<T, R>(fn: () => T, catchFn: (error: unknown) => R): T | R {\n try {\n return fn();\n } catch (error) {\n return catchFn(error);\n }\n}\n",
|
|
5
|
+
"import { 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';\nimport { IdleWaiter } from './idleWaiter';\nimport { ReadyManager } from './ReadyManager';\nimport { removeControlCharacters } from './removeControlCharacters';\n\nexport const CLI_CONFIGURES: Record<\n string,\n {\n install?: string; // hint user for install command if not installed\n binary?: string; // actual binary name if different from cli\n ready?: RegExp[]; // regex matcher for stdin ready, or line index for gemini\n enter?: RegExp[]; // array of regex to match for sending Enter\n fatal?: RegExp[]; // array of regex to match for fatal errors\n ensureArgs?: (args: string[]) => string[]; // function to ensure certain args are present\n }\n> = {\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: [/^> /], // regex matcher for stdin 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 // match the agent prompt after initial lines; handled by index logic using line index\n ready: [/Type your message/], // used with line index check\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 // add to codex --search by default when not provided by the user\n ensureArgs: (args: string[]) => {\n if (!args.includes('--search')) 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 // map logical \"cursor\" cli name to actual binary name\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};\n/**\n * Main function to run Claude with automatic yes/no responses\n * @param options Configuration options\n * @param options.continueOnCrash - If true, automatically restart Claude when it crashes:\n * 1. Shows message 'Claude crashed, restarting..'\n * 2. Spawns a new 'claude --continue' process\n * 3. Re-attaches the new process to the shell stdio (pipes new process stdin/stdout)\n * 4. If it crashes with \"No conversation found to continue\", exits the process\n * @param options.exitOnIdle - Exit when Claude is idle. Boolean or timeout in milliseconds, recommended 5000 - 60000, default is false\n * @param options.claudeArgs - Additional arguments to pass to the Claude CLI\n * @param options.removeControlCharactersFromStdout - Remove ANSI control characters from stdout. Defaults to !process.stdout.isTTY\n *\n * @example\n * ```typescript\n * import claudeYes from 'claude-yes';\n * await claudeYes({\n * prompt: 'help me solve all todos in my codebase',\n *\n * // optional\n * cli: 'claude',\n * cliArgs: ['--verbose'], // additional args to pass to claude\n * exitOnIdle: 30000, // exit after 30 seconds of idle\n * continueOnCrash: true, // restart if claude crashes, default is true\n * logFile: 'claude.log', // save logs to file\n * });\n * ```\n */\nexport default async function claudeYes({\n cli = 'claude',\n cliArgs = [],\n prompt,\n continueOnCrash,\n cwd,\n env,\n exitOnIdle,\n logFile,\n removeControlCharactersFromStdout = false, // = !process.stdout.isTTY,\n verbose = false,\n}: {\n cli?: (string & {}) | keyof typeof CLI_CONFIGURES;\n cliArgs?: string[];\n prompt?: string;\n continueOnCrash?: boolean;\n cwd?: string;\n env?: Record<string, string>;\n exitOnIdle?: number;\n logFile?: string;\n removeControlCharactersFromStdout?: boolean;\n verbose?: boolean;\n} = {}) {\n const continueArgs = {\n codex: 'resume --last'.split(' '),\n claude: '--continue'.split(' '),\n gemini: [], // not possible yet\n };\n\n // if (verbose) {\n // console.log('calling claudeYes: ', {\n // cli,\n // continueOnCrash,\n // exitOnIdle,\n // cliArgs,\n // cwd,\n // removeControlCharactersFromStdout,\n // logFile,\n // verbose,\n // });\n // }\n // console.log(\n // `⭐ Starting ${cli}, automatically responding to yes/no prompts...`\n // );\n // console.log(\n // '⚠️ Important Security Warning: Only run this on trusted repositories. This tool automatically responds to prompts and can execute commands without user confirmation. Be aware of potential prompt injection attacks where malicious code or instructions could be embedded in files or user inputs to manipulate the automated responses.'\n // );\n\n process.stdin.setRawMode?.(true); // must be called any stdout/stdin usage\n let isFatal = false; // when true, do not restart on crash, and exit agent\n const stdinReady = new ReadyManager();\n\n const shellOutputStream = new TransformStream<string, string>();\n const outputWriter = shellOutputStream.writable.getWriter();\n // const pty = await import('node-pty');\n\n // its recommened to use bun-pty in windows\n const pty = await import('node-pty')\n .catch(async () => await import('bun-pty'))\n .catch(async () =>\n DIE('Please install node-pty or bun-pty, run this: bun install bun-pty'),\n );\n\n const getPtyOptions = () => ({\n name: 'xterm-color',\n ...getTerminalDimensions(),\n cwd: cwd ?? process.cwd(),\n env: env ?? (process.env as Record<string, string>),\n });\n\n // Apply CLI specific configurations (moved to CLI_CONFIGURES)\n const cliConf = (CLI_CONFIGURES as Record<string, any>)[cli] || {};\n cliArgs = cliConf.ensureArgs?.(cliArgs) ?? cliArgs;\n const cliCommand = cliConf?.binary || cli;\n\n let shell = tryCatch(\n () => pty.spawn(cliCommand, cliArgs, getPtyOptions()),\n (error: unknown) => {\n console.error(`Fatal: Failed to start ${cliCommand}.`);\n if (cliConf?.install)\n console.error(\n `If you did not installed it yet, Please install it first: ${cliConf.install}`,\n );\n throw error;\n },\n );\n const pendingExitCode = Promise.withResolvers<number | null>();\n let pendingExitCodeValue = null;\n\n // TODO handle error if claude is not installed, show msg:\n // npm install -g @anthropic-ai/claude-code\n\n async function onData(data: string) {\n // append data to the buffer, so we can process it later\n await outputWriter.write(data);\n }\n\n shell.onData(onData);\n shell.onExit(function onExit({ exitCode }) {\n stdinReady.unready(); // start buffer stdin\n const agentCrashed = exitCode !== 0;\n const continueArg = (continueArgs as Record<string, string[]>)[cli];\n\n if (agentCrashed && continueOnCrash && continueArg) {\n if (!continueArg) {\n return console.warn(\n `continueOnCrash is only supported for ${Object.keys(continueArgs).join(', ')} currently, not ${cli}`,\n );\n }\n if (isFatal) {\n return pendingExitCode.resolve((pendingExitCodeValue = exitCode));\n }\n\n console.log(`${cli} crashed, restarting...`);\n\n shell = pty.spawn(cli, continueArg, getPtyOptions());\n shell.onData(onData);\n shell.onExit(onExit);\n return;\n }\n return pendingExitCode.resolve((pendingExitCodeValue = exitCode));\n });\n\n // when current tty resized, resize the pty\n process.stdout.on('resize', () => {\n const { cols, rows } = getTerminalDimensions(); // minimum 80 columns to avoid layout issues\n shell.resize(cols, rows); // minimum 80 columns to avoid layout issues\n });\n\n const terminalRender = new TerminalTextRender();\n const isStillWorkingQ = () =>\n terminalRender\n .render()\n .replace(/\\s+/g, ' ')\n .match(/esc to interrupt|to run in background/);\n\n const idleWaiter = new IdleWaiter();\n if (exitOnIdle)\n idleWaiter.wait(exitOnIdle).then(async () => {\n if (isStillWorkingQ()) {\n console.log(\n '[${cli}-yes] ${cli} is idle, but seems still working, not exiting yet',\n );\n return;\n }\n\n console.log('[${cli}-yes] ${cli} is idle, exiting...');\n await exitAgent();\n });\n\n // Message streaming\n sflow(fromReadable<Buffer>(process.stdin))\n .map((buffer) => buffer.toString())\n // .map((e) => e.replaceAll('\\x1a', '')) // remove ctrl+z from user's input (seems bug)\n // .forEach(e => appendFile('.cache/io.log', \"input |\" + JSON.stringify(e) + '\\n')) // for debugging\n // pipe\n .by({\n writable: new WritableStream<string>({\n write: async (data) => {\n await stdinReady.wait();\n // await idleWaiter.wait(20); // wait for idle for 200ms to avoid messing up claude's input\n shell.write(data);\n },\n }),\n readable: shellOutputStream.readable,\n })\n .forEach(() => idleWaiter.ping())\n .forEach((text) => {\n terminalRender.write(text);\n // todo: .onStatus((msg)=> shell.write(msg))\n if (process.stdin.isTTY) return; // only handle it when stdin is not tty\n if (text.includes('\\u001b[6n')) return; // only asked\n\n // todo: use terminalRender API to get cursor position when new version is available\n // xterm replies CSI row; column R if asked cursor position\n // https://en.wikipedia.org/wiki/ANSI_escape_code#:~:text=citation%20needed%5D-,xterm%20replies,-CSI%20row%C2%A0%3B\n // when agent asking position, respond with row; col\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(`\\u001b[${row};${col}R`);\n })\n\n // auto-response\n .forkTo((e) =>\n e\n .map((e) => removeControlCharacters(e))\n .map((e) => e.replaceAll('\\r', '')) // remove carriage return\n .lines({ EOL: 'NONE' })\n // Generic auto-response handler driven by CLI_CONFIGURES\n .forEach(async (e, i) => {\n const conf =\n CLI_CONFIGURES[cli as keyof typeof CLI_CONFIGURES] || null;\n if (!conf) return;\n\n // ready matcher: if matched, mark stdin ready\n if (conf.ready?.some((rx: RegExp) => e.match(rx))) {\n if (cli === 'gemini' && i <= 80) return; // gemini initial noise, only after many lines\n stdinReady.ready();\n }\n\n // enter matchers: send Enter when any enter regex matches\n if (conf.enter?.some((rx: RegExp) => e.match(rx)))\n await sendEnter(300); // send Enter after 300ms idle wait\n\n // fatal matchers: set isFatal flag when matched\n if (conf.fatal?.some((rx: RegExp) => e.match(rx))) {\n isFatal = true;\n await exitAgent();\n }\n })\n // .forEach(e => appendFile('.cache/io.log', \"output|\" + JSON.stringify(e) + '\\n')) // for debugging\n .run(),\n )\n .map((e) =>\n removeControlCharactersFromStdout ? removeControlCharacters(e) : e,\n )\n .to(fromWritable(process.stdout))\n .then(() => null); // run it immediately without await\n\n // wait for cli ready and send prompt if provided\n if (prompt) await sendMessage(prompt);\n\n const exitCode = await pendingExitCode.promise; // wait for the shell to exit\n console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);\n\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(\n () => null,\n );\n await writeFile(logFilePath, terminalRender.render());\n }\n\n return { exitCode, logs: terminalRender.render() };\n\n async function sendEnter(waitms = 1000) {\n // wait for idle for a bit to let agent cli finish rendering\n const st = Date.now();\n\n await idleWaiter.wait(waitms);\n const et = Date.now();\n process.stdout.write(`\\ridleWaiter.wait(${waitms}) took ${et - st}ms\\r`);\n\n shell.write('\\r');\n }\n\n async function sendMessage(message: string) {\n await stdinReady.wait();\n // show in-place message: write msg and move cursor back start\n shell.write(message);\n idleWaiter.ping(); // just sent a message, wait for echo\n await sendEnter();\n }\n\n async function exitAgent() {\n continueOnCrash = false;\n // send exit command to the shell, must sleep a bit to avoid claude treat it as pasted input\n await sendMessage('/exit');\n\n // wait for shell to exit or kill it with a timeout\n let exited = false;\n await Promise.race([\n pendingExitCode.promise.then(() => (exited = true)), // resolve when shell exits\n\n // if shell doesn't exit in 5 seconds, kill it\n new Promise<void>((resolve) =>\n setTimeout(() => {\n if (exited) return; // if shell already exited, do nothing\n shell.kill(); // kill the shell process if it doesn't exit in time\n resolve();\n }, 5000),\n ), // 5 seconds timeout\n ]);\n }\n\n function getTerminalDimensions() {\n return {\n // TODO: enforce minimum cols/rows to avoid layout issues\n // cols: Math.max(process.stdout.columns, 80),\n cols: process.stdout.columns,\n rows: process.stdout.rows,\n };\n }\n}\n\nexport { removeControlCharacters };\n\nfunction tryCatch<T, R>(fn: () => T, catchFn: (error: unknown) => R): T | R {\n try {\n return fn();\n } catch (error) {\n return catchFn(error);\n }\n}\n",
|
|
6
6
|
"/**\n * A utility class to wait for idle periods based on activity pings.\n *\n * @example\n * const idleWaiter = new IdleWaiter();\n *\n * // Somewhere in your code, when activity occurs:\n * idleWaiter.ping();\n *\n * // To wait for an idle period of 5 seconds:\n * await idleWaiter.wait(5000);\n * console.log('System has been idle for 5 seconds');\n */\nexport class IdleWaiter {\n lastActivityTime = Date.now();\n checkInterval = 100; // Default check interval in milliseconds\n\n constructor() {\n this.ping();\n }\n\n ping() {\n this.lastActivityTime = Date.now();\n return this;\n }\n\n async wait(ms: number) {\n while (this.lastActivityTime >= Date.now() - ms)\n await new Promise((resolve) => setTimeout(resolve, this.checkInterval));\n }\n}\n",
|
|
7
7
|
"export class ReadyManager {\n private isReady = false;\n private readyQueue: (() => void)[] = [];\n wait() {\n if (this.isReady) return;\n return new Promise<void>((resolve) => this.readyQueue.push(resolve));\n }\n unready() {\n this.isReady = false;\n }\n ready() {\n this.isReady = true;\n if (!this.readyQueue.length) return; // check len for performance\n this.readyQueue.splice(0).map((resolve) => resolve());\n }\n}\n",
|
|
8
8
|
"export function removeControlCharacters(str: string): string {\n // Matches control characters in the C0 and C1 ranges, including Delete (U+007F)\n return str.replace(\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n '',\n );\n}\n"
|
|
9
9
|
],
|
|
10
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;;ACQO,MAAM,WAAW;AAAA,EACtB,mBAAmB,KAAK,IAAI;AAAA,EAC5B,gBAAgB;AAAA,EAEhB,WAAW,GAAG;AAAA,IACZ,KAAK,KAAK;AAAA;AAAA,EAGZ,IAAI,GAAG;AAAA,IACL,KAAK,mBAAmB,KAAK,IAAI;AAAA,IACjC,OAAO;AAAA;AAAA,OAGH,KAAI,CAAC,IAAY;AAAA,IACrB,OAAO,KAAK,oBAAoB,KAAK,IAAI,IAAI;AAAA,MAC3C,MAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,KAAK,aAAa,CAAC;AAAA;AAE5E;;;AC9BO,MAAM,aAAa;AAAA,EAChB,UAAU;AAAA,EACV,aAA6B,CAAC;AAAA,EACtC,IAAI,GAAG;AAAA,IACL,IAAI,KAAK;AAAA,MAAS;AAAA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AA,IAElB,MAAM,YAAY,OAAO;AAAA,IAGzB,IAAI,SAAS;AAAA,IACb,MAAM,QAAQ,KAAK;AAAA,MACjB,gBAAgB,QAAQ,KAAK,MAAO,SAAS,IAAK;AAAA,MAGlD,IAAI,QAAc,CAAC,YACjB,WAAW,MAAM;AAAA,QACf,IAAI;AAAA,UAAQ;AAAA,QACZ,MAAM,KAAK;AAAA,QACX,QAAQ;AAAA,SACP,IAAI,CACT;AAAA,IACF,CAAC;AAAA;AAAA,EAGH,SAAS,qBAAqB,GAAG;AAAA,IAC/B,OAAO;AAAA,MAGL,MAAM,QAAQ,OAAO;AAAA,MACrB,MAAM,QAAQ,OAAO;AAAA,IACvB;AAAA;AAAA;AAMJ,SAAS,QAAc,CAAC,IAAa,SAAuC;AAAA,EAC1E,IAAI;AAAA,IACF,OAAO,GAAG;AAAA,IACV,OAAO,OAAO;AAAA,IACd,OAAO,QAAQ,KAAK;AAAA;AAAA;",
|
|
11
|
+
"debugId": "8E417C3F5F6C5D9864756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
package/index.ts
CHANGED
|
@@ -21,7 +21,8 @@ export const CLI_CONFIGURES: Record<
|
|
|
21
21
|
> = {
|
|
22
22
|
grok: {
|
|
23
23
|
install: 'npm install -g @vibe-kit/grok-cli',
|
|
24
|
-
ready: [/^
|
|
24
|
+
ready: [/^ │ ❯ /],
|
|
25
|
+
enter: [/^ 1. Yes/],
|
|
25
26
|
},
|
|
26
27
|
claude: {
|
|
27
28
|
install: 'npm install -g @anthropic-ai/claude-code',
|
|
@@ -29,7 +30,7 @@ export const CLI_CONFIGURES: Record<
|
|
|
29
30
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
30
31
|
fatal: [
|
|
31
32
|
/No conversation found to continue/,
|
|
32
|
-
/⎿
|
|
33
|
+
/⎿ Claude usage limit reached\./,
|
|
33
34
|
],
|
|
34
35
|
},
|
|
35
36
|
gemini: {
|
|
@@ -62,7 +63,7 @@ export const CLI_CONFIGURES: Record<
|
|
|
62
63
|
binary: 'cursor-agent',
|
|
63
64
|
ready: [/\/ commands/],
|
|
64
65
|
enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
|
|
65
|
-
fatal: [],
|
|
66
|
+
fatal: [/^ Error: You've hit your usage limit/],
|
|
66
67
|
},
|
|
67
68
|
};
|
|
68
69
|
/**
|
|
@@ -141,7 +142,7 @@ export default async function claudeYes({
|
|
|
141
142
|
// );
|
|
142
143
|
|
|
143
144
|
process.stdin.setRawMode?.(true); // must be called any stdout/stdin usage
|
|
144
|
-
let isFatal = false; //
|
|
145
|
+
let isFatal = false; // when true, do not restart on crash, and exit agent
|
|
145
146
|
const stdinReady = new ReadyManager();
|
|
146
147
|
|
|
147
148
|
const shellOutputStream = new TransformStream<string, string>();
|
|
@@ -202,11 +203,9 @@ export default async function claudeYes({
|
|
|
202
203
|
);
|
|
203
204
|
}
|
|
204
205
|
if (isFatal) {
|
|
205
|
-
console.log(
|
|
206
|
-
`${cli} crashed with "No conversation found to continue", exiting...`,
|
|
207
|
-
);
|
|
208
206
|
return pendingExitCode.resolve((pendingExitCodeValue = exitCode));
|
|
209
207
|
}
|
|
208
|
+
|
|
210
209
|
console.log(`${cli} crashed, restarting...`);
|
|
211
210
|
|
|
212
211
|
shell = pty.spawn(cli, continueArg, getPtyOptions());
|
|
@@ -300,7 +299,10 @@ export default async function claudeYes({
|
|
|
300
299
|
await sendEnter(300); // send Enter after 300ms idle wait
|
|
301
300
|
|
|
302
301
|
// fatal matchers: set isFatal flag when matched
|
|
303
|
-
if (conf.fatal?.some((rx: RegExp) => e.match(rx)))
|
|
302
|
+
if (conf.fatal?.some((rx: RegExp) => e.match(rx))) {
|
|
303
|
+
isFatal = true;
|
|
304
|
+
await exitAgent();
|
|
305
|
+
}
|
|
304
306
|
})
|
|
305
307
|
// .forEach(e => appendFile('.cache/io.log', "output|" + JSON.stringify(e) + '\n')) // for debugging
|
|
306
308
|
.run(),
|
|
@@ -312,22 +314,7 @@ export default async function claudeYes({
|
|
|
312
314
|
.then(() => null); // run it immediately without await
|
|
313
315
|
|
|
314
316
|
// wait for cli ready and send prompt if provided
|
|
315
|
-
if (prompt)
|
|
316
|
-
(async () => {
|
|
317
|
-
// console.log(`[${cli}-yes] Ready to send prompt to ${cli}: ${prompt}`);
|
|
318
|
-
// idleWaiter.ping();
|
|
319
|
-
// console.log(
|
|
320
|
-
// 'await idleWaiter.wait(1000); // wait a bit for claude to start'
|
|
321
|
-
// );
|
|
322
|
-
// await idleWaiter.wait(1000); // wait a bit for claude to start
|
|
323
|
-
// console.log('await stdinReady.wait();');
|
|
324
|
-
// await stdinReady.wait();
|
|
325
|
-
// console.log(`[${cli}-yes] Waiting for ${cli} to be ready...`);
|
|
326
|
-
// console.log('await idleWaiter.wait(200);');
|
|
327
|
-
// await idleWaiter.wait(200);
|
|
328
|
-
// console.log(`[${cli}-yes] Sending prompt to ${cli}: ${prompt}`);
|
|
329
|
-
await sendMessage(prompt);
|
|
330
|
-
})();
|
|
317
|
+
if (prompt) await sendMessage(prompt);
|
|
331
318
|
|
|
332
319
|
const exitCode = await pendingExitCode.promise; // wait for the shell to exit
|
|
333
320
|
console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
|
|
@@ -385,7 +372,9 @@ export default async function claudeYes({
|
|
|
385
372
|
|
|
386
373
|
function getTerminalDimensions() {
|
|
387
374
|
return {
|
|
388
|
-
|
|
375
|
+
// TODO: enforce minimum cols/rows to avoid layout issues
|
|
376
|
+
// cols: Math.max(process.stdout.columns, 80),
|
|
377
|
+
cols: process.stdout.columns,
|
|
389
378
|
rows: process.stdout.rows,
|
|
390
379
|
};
|
|
391
380
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-yes",
|
|
3
|
-
"version": "1.21.
|
|
4
|
-
"description": "A wrapper tool that automates interactions with
|
|
3
|
+
"version": "1.21.1",
|
|
4
|
+
"description": "A wrapper tool that automates interactions with various AI CLI tools by automatically handling common prompts and responses.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
|
7
7
|
"ai",
|
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
"bin": {
|
|
34
34
|
"claude-yes": "dist/claude-yes.js",
|
|
35
35
|
"codex-yes": "dist/codex-yes.js",
|
|
36
|
-
"
|
|
36
|
+
"copilot-yes": "dist/copilot-yes.js",
|
|
37
37
|
"cursor-yes": "dist/cursor-yes.js",
|
|
38
|
-
"
|
|
38
|
+
"gemini-yes": "dist/gemini-yes.js",
|
|
39
|
+
"grok-yes": "dist/grok-yes.js"
|
|
39
40
|
},
|
|
40
41
|
"directories": {
|
|
41
42
|
"doc": "docs"
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"build": "bun build index.ts cli.ts --packages=external --outdir=dist --target=node --sourcemap",
|
|
49
50
|
"postbuild": "bun ./postbuild.ts",
|
|
50
51
|
"dev": "tsx index.ts",
|
|
51
|
-
"fmt": "bunx @biomejs/biome check --fix",
|
|
52
|
+
"fmt": "bunx @biomejs/biome check --fix && bunx sort-package-json",
|
|
52
53
|
"prepack": "bun run build",
|
|
53
54
|
"prepare": "bunx husky",
|
|
54
55
|
"test": "vitest"
|
|
@@ -58,6 +59,11 @@
|
|
|
58
59
|
"bunx @biomejs/biome check --fix"
|
|
59
60
|
]
|
|
60
61
|
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"bun-pty": "^0.3.2",
|
|
64
|
+
"p-map": "^7.0.3",
|
|
65
|
+
"phpdie": "^1.7.0"
|
|
66
|
+
},
|
|
61
67
|
"devDependencies": {
|
|
62
68
|
"@biomejs/biome": "^2.2.5",
|
|
63
69
|
"@types/bun": "^1.2.18",
|
|
@@ -73,18 +79,13 @@
|
|
|
73
79
|
"semantic-release": "^24.2.6",
|
|
74
80
|
"sflow": "^1.20.2",
|
|
75
81
|
"strip-ansi-control-characters": "^2.0.0",
|
|
76
|
-
"terminal-render": "^1.
|
|
82
|
+
"terminal-render": "^1.2.0",
|
|
77
83
|
"tsx": "^4.20.3",
|
|
78
84
|
"vitest": "^3.2.4",
|
|
79
85
|
"yargs": "^18.0.0"
|
|
80
86
|
},
|
|
81
87
|
"peerDependencies": {
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
},
|
|
85
|
-
"dependencies": {
|
|
86
|
-
"bun-pty": "^0.3.2",
|
|
87
|
-
"p-map": "^7.0.3",
|
|
88
|
-
"phpdie": "^1.7.0"
|
|
88
|
+
"node-pty": "^1.0.0",
|
|
89
|
+
"typescript": "^5.8.3"
|
|
89
90
|
}
|
|
90
91
|
}
|
package/postbuild.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
#! /usr/bin/env bun
|
|
2
|
+
import { execaCommand } from 'execa';
|
|
2
3
|
import { copyFile } from 'fs/promises';
|
|
4
|
+
import { CLI_CONFIGURES } from '.';
|
|
3
5
|
import * as pkg from './package.json';
|
|
4
6
|
|
|
5
7
|
const src = 'dist/cli.js';
|
|
6
|
-
await Promise.all(
|
|
8
|
+
await Promise.all(
|
|
9
|
+
Object.keys(CLI_CONFIGURES).map(async (cli) => {
|
|
10
|
+
const dst = `dist/${cli}-yes.js`;
|
|
11
|
+
if (!pkg.bin?.[cli as keyof typeof pkg.bin])
|
|
12
|
+
await execaCommand(`npm pkg set bin.${cli}-yes=${dst}`);
|
|
13
|
+
await copyFile(src, dst);
|
|
14
|
+
}),
|
|
15
|
+
);
|