claude-yes 1.22.0 → 1.23.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/dist/claude-yes.js +24 -12
- package/dist/cli.js +24 -12
- package/dist/cli.js.map +3 -3
- package/dist/codex-yes.js +24 -12
- package/dist/copilot-yes.js +24 -12
- package/dist/cursor-yes.js +24 -12
- package/dist/gemini-yes.js +24 -12
- package/dist/grok-yes.js +24 -12
- package/dist/index.js +24 -12
- package/dist/index.js.map +3 -3
- package/index.ts +32 -41
- package/package.json +3 -2
package/dist/claude-yes.js
CHANGED
|
@@ -25,11 +25,12 @@ import { hideBin } from "yargs/helpers";
|
|
|
25
25
|
|
|
26
26
|
// dist/index.js
|
|
27
27
|
import { fromReadable, fromWritable } from "from-node-stream";
|
|
28
|
-
import { appendFile, mkdir, writeFile } from "fs/promises";
|
|
28
|
+
import { appendFile, mkdir, rm, writeFile } from "fs/promises";
|
|
29
29
|
import path from "path";
|
|
30
30
|
import DIE from "phpdie";
|
|
31
31
|
import sflow from "sflow";
|
|
32
32
|
import { TerminalTextRender } from "terminal-render";
|
|
33
|
+
import tsaComposer from "tsa-composer";
|
|
33
34
|
class IdleWaiter {
|
|
34
35
|
lastActivityTime = Date.now();
|
|
35
36
|
checkInterval = 100;
|
|
@@ -75,7 +76,7 @@ var CLI_CONFIGURES = {
|
|
|
75
76
|
},
|
|
76
77
|
claude: {
|
|
77
78
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
78
|
-
ready: [
|
|
79
|
+
ready: [/\? for shortcuts/],
|
|
79
80
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
80
81
|
fatal: [
|
|
81
82
|
/No conversation found to continue/,
|
|
@@ -92,8 +93,8 @@ var CLI_CONFIGURES = {
|
|
|
92
93
|
install: "npm install -g @openai/codex-cli",
|
|
93
94
|
ready: [/⏎ send/],
|
|
94
95
|
enter: [
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
/> 1. Yes, allow Codex to work in this folder/,
|
|
97
|
+
/▌ > 1. Approve and run now/
|
|
97
98
|
],
|
|
98
99
|
fatal: [/Error: The cursor position could not be read within/],
|
|
99
100
|
ensureArgs: (args) => {
|
|
@@ -128,6 +129,11 @@ async function claudeYes({
|
|
|
128
129
|
removeControlCharactersFromStdout = false,
|
|
129
130
|
verbose = false
|
|
130
131
|
} = {}) {
|
|
132
|
+
await rm("agent-yes.log").catch(() => null);
|
|
133
|
+
const yesLog = tsaComposer()(async function yesLog(msg) {
|
|
134
|
+
await appendFile("agent-yes.log", `${msg}
|
|
135
|
+
`).catch(() => null);
|
|
136
|
+
});
|
|
131
137
|
const continueArgs = {
|
|
132
138
|
codex: "resume --last".split(" "),
|
|
133
139
|
claude: "--continue".split(" "),
|
|
@@ -195,8 +201,6 @@ async function claudeYes({
|
|
|
195
201
|
console.log("[${cli}-yes] ${cli} is idle, exiting...");
|
|
196
202
|
await exitAgent();
|
|
197
203
|
});
|
|
198
|
-
console.log(`[${cli}-yes] Started ${cli} with args: ${[cliCommand, ...cliArgs].join(" ")}`);
|
|
199
|
-
shell.write("\x1B[1;1R");
|
|
200
204
|
sflow(fromReadable(process.stdin)).map((buffer) => buffer.toString()).by({
|
|
201
205
|
writable: new WritableStream({
|
|
202
206
|
write: async (data) => {
|
|
@@ -209,29 +213,34 @@ async function claudeYes({
|
|
|
209
213
|
terminalRender.write(text);
|
|
210
214
|
if (process.stdin.isTTY)
|
|
211
215
|
return;
|
|
212
|
-
if (text.includes("\x1B[6n"))
|
|
216
|
+
if (!text.includes("\x1B[6n"))
|
|
213
217
|
return;
|
|
214
218
|
const { col, row } = terminalRender.getCursorPosition();
|
|
215
219
|
console.log(`[${cli}-yes] Responding cursor position: row=${row}, col=${col}`);
|
|
216
220
|
shell.write(`\x1B[${row};${col}R`);
|
|
217
|
-
}).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll("\r", "")).forEach((e2) =>
|
|
218
|
-
`)).forEach(async (e2, i) => {
|
|
221
|
+
}).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll("\r", "")).lines({ EOL: "NONE" }).forEach((e2) => yesLog`output|${e2}`).forEach(async (e2, i) => {
|
|
219
222
|
const conf = CLI_CONFIGURES[cli] || null;
|
|
220
223
|
if (!conf)
|
|
221
224
|
return;
|
|
222
225
|
if (conf.ready?.some((rx) => e2.match(rx))) {
|
|
226
|
+
await yesLog`ready |${e2}`;
|
|
223
227
|
if (cli === "gemini" && i <= 80)
|
|
224
228
|
return;
|
|
225
229
|
stdinReady.ready();
|
|
226
230
|
}
|
|
227
231
|
if (conf.enter?.some((rx) => e2.match(rx))) {
|
|
232
|
+
await yesLog`enter |${e2}`;
|
|
228
233
|
await sendEnter(300);
|
|
234
|
+
return;
|
|
229
235
|
}
|
|
230
236
|
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
237
|
+
await yesLog`fatal |${e2}`;
|
|
231
238
|
isFatal = true;
|
|
232
239
|
await exitAgent();
|
|
233
240
|
}
|
|
234
241
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
242
|
+
if (cli === "codex")
|
|
243
|
+
shell.write(`\x1B[1;1R`);
|
|
235
244
|
if (prompt)
|
|
236
245
|
await sendMessage(prompt);
|
|
237
246
|
const exitCode = await pendingExitCode.promise;
|
|
@@ -247,11 +256,12 @@ async function claudeYes({
|
|
|
247
256
|
const st = Date.now();
|
|
248
257
|
await idleWaiter.wait(waitms);
|
|
249
258
|
const et = Date.now();
|
|
250
|
-
|
|
259
|
+
await yesLog`sendEn| idleWaiter.wait(${String(waitms)}) took ${String(et - st)}ms`;
|
|
251
260
|
shell.write("\r");
|
|
252
261
|
}
|
|
253
262
|
async function sendMessage(message) {
|
|
254
263
|
await stdinReady.wait();
|
|
264
|
+
await yesLog`send |${message}`;
|
|
255
265
|
shell.write(message);
|
|
256
266
|
idleWaiter.ping();
|
|
257
267
|
await sendEnter();
|
|
@@ -271,8 +281,10 @@ async function claudeYes({
|
|
|
271
281
|
]);
|
|
272
282
|
}
|
|
273
283
|
function getTerminalDimensions() {
|
|
284
|
+
if (!process.stdout.isTTY)
|
|
285
|
+
return { cols: 80, rows: 30 };
|
|
274
286
|
return {
|
|
275
|
-
cols: process.stdout.columns,
|
|
287
|
+
cols: Math.min(Math.max(20, process.stdout.columns), 80),
|
|
276
288
|
rows: process.stdout.rows
|
|
277
289
|
};
|
|
278
290
|
}
|
|
@@ -338,5 +350,5 @@ var { exitCode, logs } = await claudeYes({
|
|
|
338
350
|
});
|
|
339
351
|
process.exit(exitCode ?? 1);
|
|
340
352
|
|
|
341
|
-
//# debugId=
|
|
353
|
+
//# debugId=FE903BBCCEA75D2B64756E2164756E21
|
|
342
354
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js
CHANGED
|
@@ -25,11 +25,12 @@ import { hideBin } from "yargs/helpers";
|
|
|
25
25
|
|
|
26
26
|
// dist/index.js
|
|
27
27
|
import { fromReadable, fromWritable } from "from-node-stream";
|
|
28
|
-
import { appendFile, mkdir, writeFile } from "fs/promises";
|
|
28
|
+
import { appendFile, mkdir, rm, writeFile } from "fs/promises";
|
|
29
29
|
import path from "path";
|
|
30
30
|
import DIE from "phpdie";
|
|
31
31
|
import sflow from "sflow";
|
|
32
32
|
import { TerminalTextRender } from "terminal-render";
|
|
33
|
+
import tsaComposer from "tsa-composer";
|
|
33
34
|
class IdleWaiter {
|
|
34
35
|
lastActivityTime = Date.now();
|
|
35
36
|
checkInterval = 100;
|
|
@@ -75,7 +76,7 @@ var CLI_CONFIGURES = {
|
|
|
75
76
|
},
|
|
76
77
|
claude: {
|
|
77
78
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
78
|
-
ready: [
|
|
79
|
+
ready: [/\? for shortcuts/],
|
|
79
80
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
80
81
|
fatal: [
|
|
81
82
|
/No conversation found to continue/,
|
|
@@ -92,8 +93,8 @@ var CLI_CONFIGURES = {
|
|
|
92
93
|
install: "npm install -g @openai/codex-cli",
|
|
93
94
|
ready: [/⏎ send/],
|
|
94
95
|
enter: [
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
/> 1. Yes, allow Codex to work in this folder/,
|
|
97
|
+
/▌ > 1. Approve and run now/
|
|
97
98
|
],
|
|
98
99
|
fatal: [/Error: The cursor position could not be read within/],
|
|
99
100
|
ensureArgs: (args) => {
|
|
@@ -128,6 +129,11 @@ async function claudeYes({
|
|
|
128
129
|
removeControlCharactersFromStdout = false,
|
|
129
130
|
verbose = false
|
|
130
131
|
} = {}) {
|
|
132
|
+
await rm("agent-yes.log").catch(() => null);
|
|
133
|
+
const yesLog = tsaComposer()(async function yesLog(msg) {
|
|
134
|
+
await appendFile("agent-yes.log", `${msg}
|
|
135
|
+
`).catch(() => null);
|
|
136
|
+
});
|
|
131
137
|
const continueArgs = {
|
|
132
138
|
codex: "resume --last".split(" "),
|
|
133
139
|
claude: "--continue".split(" "),
|
|
@@ -195,8 +201,6 @@ async function claudeYes({
|
|
|
195
201
|
console.log("[${cli}-yes] ${cli} is idle, exiting...");
|
|
196
202
|
await exitAgent();
|
|
197
203
|
});
|
|
198
|
-
console.log(`[${cli}-yes] Started ${cli} with args: ${[cliCommand, ...cliArgs].join(" ")}`);
|
|
199
|
-
shell.write("\x1B[1;1R");
|
|
200
204
|
sflow(fromReadable(process.stdin)).map((buffer) => buffer.toString()).by({
|
|
201
205
|
writable: new WritableStream({
|
|
202
206
|
write: async (data) => {
|
|
@@ -209,29 +213,34 @@ async function claudeYes({
|
|
|
209
213
|
terminalRender.write(text);
|
|
210
214
|
if (process.stdin.isTTY)
|
|
211
215
|
return;
|
|
212
|
-
if (text.includes("\x1B[6n"))
|
|
216
|
+
if (!text.includes("\x1B[6n"))
|
|
213
217
|
return;
|
|
214
218
|
const { col, row } = terminalRender.getCursorPosition();
|
|
215
219
|
console.log(`[${cli}-yes] Responding cursor position: row=${row}, col=${col}`);
|
|
216
220
|
shell.write(`\x1B[${row};${col}R`);
|
|
217
|
-
}).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll("\r", "")).forEach((e2) =>
|
|
218
|
-
`)).forEach(async (e2, i) => {
|
|
221
|
+
}).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll("\r", "")).lines({ EOL: "NONE" }).forEach((e2) => yesLog`output|${e2}`).forEach(async (e2, i) => {
|
|
219
222
|
const conf = CLI_CONFIGURES[cli] || null;
|
|
220
223
|
if (!conf)
|
|
221
224
|
return;
|
|
222
225
|
if (conf.ready?.some((rx) => e2.match(rx))) {
|
|
226
|
+
await yesLog`ready |${e2}`;
|
|
223
227
|
if (cli === "gemini" && i <= 80)
|
|
224
228
|
return;
|
|
225
229
|
stdinReady.ready();
|
|
226
230
|
}
|
|
227
231
|
if (conf.enter?.some((rx) => e2.match(rx))) {
|
|
232
|
+
await yesLog`enter |${e2}`;
|
|
228
233
|
await sendEnter(300);
|
|
234
|
+
return;
|
|
229
235
|
}
|
|
230
236
|
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
237
|
+
await yesLog`fatal |${e2}`;
|
|
231
238
|
isFatal = true;
|
|
232
239
|
await exitAgent();
|
|
233
240
|
}
|
|
234
241
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
242
|
+
if (cli === "codex")
|
|
243
|
+
shell.write(`\x1B[1;1R`);
|
|
235
244
|
if (prompt)
|
|
236
245
|
await sendMessage(prompt);
|
|
237
246
|
const exitCode = await pendingExitCode.promise;
|
|
@@ -247,11 +256,12 @@ async function claudeYes({
|
|
|
247
256
|
const st = Date.now();
|
|
248
257
|
await idleWaiter.wait(waitms);
|
|
249
258
|
const et = Date.now();
|
|
250
|
-
|
|
259
|
+
await yesLog`sendEn| idleWaiter.wait(${String(waitms)}) took ${String(et - st)}ms`;
|
|
251
260
|
shell.write("\r");
|
|
252
261
|
}
|
|
253
262
|
async function sendMessage(message) {
|
|
254
263
|
await stdinReady.wait();
|
|
264
|
+
await yesLog`send |${message}`;
|
|
255
265
|
shell.write(message);
|
|
256
266
|
idleWaiter.ping();
|
|
257
267
|
await sendEnter();
|
|
@@ -271,8 +281,10 @@ async function claudeYes({
|
|
|
271
281
|
]);
|
|
272
282
|
}
|
|
273
283
|
function getTerminalDimensions() {
|
|
284
|
+
if (!process.stdout.isTTY)
|
|
285
|
+
return { cols: 80, rows: 30 };
|
|
274
286
|
return {
|
|
275
|
-
cols: process.stdout.columns,
|
|
287
|
+
cols: Math.min(Math.max(20, process.stdout.columns), 80),
|
|
276
288
|
rows: process.stdout.rows
|
|
277
289
|
};
|
|
278
290
|
}
|
|
@@ -338,5 +350,5 @@ var { exitCode, logs } = await claudeYes({
|
|
|
338
350
|
});
|
|
339
351
|
process.exit(exitCode ?? 1);
|
|
340
352
|
|
|
341
|
-
//# debugId=
|
|
353
|
+
//# debugId=FE903BBCCEA75D2B64756E2164756E21
|
|
342
354
|
//# 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 { appendFile, 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: [\n /\\b▌ \\> 1\\. Approve and run now/,\n /\\b\\> 1\\. Yes, allow Codex to work in this folder/\n ],\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 console.log(`[${cli}-yes] Started ${cli} with args: ${[cliCommand, ...cliArgs].join(\" \")}`);\n shell.write(\"\\x1B[1;1R\");\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 { col, row } = terminalRender.getCursorPosition();\n console.log(`[${cli}-yes] Responding cursor position: row=${row}, col=${col}`);\n shell.write(`\\x1B[${row};${col}R`);\n }).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll(\"\\r\", \"\")).forEach((e2) => appendFile(\"io.log\", \"output|\" + JSON.stringify(e2) + `\n`)).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 }\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=725F10399412016964756E2164756E21\n//# sourceMappingURL=index.js.map\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 { appendFile, mkdir, rm, writeFile } from \"fs/promises\";\nimport path from \"path\";\nimport DIE from \"phpdie\";\nimport sflow from \"sflow\";\nimport { TerminalTextRender } from \"terminal-render\";\nimport tsaComposer from \"tsa-composer\";\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: [/\\? for shortcuts/],\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: [\n /> 1. Yes, allow Codex to work in this folder/,\n /▌ > 1. Approve and run now/\n ],\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 await rm(\"agent-yes.log\").catch(() => null);\n const yesLog = tsaComposer()(async function yesLog(msg) {\n await appendFile(\"agent-yes.log\", `${msg}\n`).catch(() => null);\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 { col, row } = terminalRender.getCursorPosition();\n console.log(`[${cli}-yes] Responding cursor position: row=${row}, col=${col}`);\n shell.write(`\\x1B[${row};${col}R`);\n }).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll(\"\\r\", \"\")).lines({ EOL: \"NONE\" }).forEach((e2) => yesLog`output|${e2}`).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 await yesLog`ready |${e2}`;\n if (cli === \"gemini\" && i <= 80)\n return;\n stdinReady.ready();\n }\n if (conf.enter?.some((rx) => e2.match(rx))) {\n await yesLog`enter |${e2}`;\n await sendEnter(300);\n return;\n }\n if (conf.fatal?.some((rx) => e2.match(rx))) {\n await yesLog`fatal |${e2}`;\n isFatal = true;\n await exitAgent();\n }\n }).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);\n if (cli === \"codex\")\n shell.write(`\\x1B[1;1R`);\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 await yesLog`sendEn| idleWaiter.wait(${String(waitms)}) took ${String(et - st)}ms`;\n shell.write(\"\\r\");\n }\n async function sendMessage(message) {\n await stdinReady.wait();\n await yesLog`send |${message}`;\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 if (!process.stdout.isTTY)\n return { cols: 80, rows: 30 };\n return {\n cols: Math.min(Math.max(20, process.stdout.columns), 80),\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=D97240F2071C1DE564756E2164756E21\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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AAQ,IAAI;AACtC,IAAI,iBAAqC;AACzC,IAAI,kBAA4B,CAAC;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": "FE903BBCCEA75D2B64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/codex-yes.js
CHANGED
|
@@ -25,11 +25,12 @@ import { hideBin } from "yargs/helpers";
|
|
|
25
25
|
|
|
26
26
|
// dist/index.js
|
|
27
27
|
import { fromReadable, fromWritable } from "from-node-stream";
|
|
28
|
-
import { appendFile, mkdir, writeFile } from "fs/promises";
|
|
28
|
+
import { appendFile, mkdir, rm, writeFile } from "fs/promises";
|
|
29
29
|
import path from "path";
|
|
30
30
|
import DIE from "phpdie";
|
|
31
31
|
import sflow from "sflow";
|
|
32
32
|
import { TerminalTextRender } from "terminal-render";
|
|
33
|
+
import tsaComposer from "tsa-composer";
|
|
33
34
|
class IdleWaiter {
|
|
34
35
|
lastActivityTime = Date.now();
|
|
35
36
|
checkInterval = 100;
|
|
@@ -75,7 +76,7 @@ var CLI_CONFIGURES = {
|
|
|
75
76
|
},
|
|
76
77
|
claude: {
|
|
77
78
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
78
|
-
ready: [
|
|
79
|
+
ready: [/\? for shortcuts/],
|
|
79
80
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
80
81
|
fatal: [
|
|
81
82
|
/No conversation found to continue/,
|
|
@@ -92,8 +93,8 @@ var CLI_CONFIGURES = {
|
|
|
92
93
|
install: "npm install -g @openai/codex-cli",
|
|
93
94
|
ready: [/⏎ send/],
|
|
94
95
|
enter: [
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
/> 1. Yes, allow Codex to work in this folder/,
|
|
97
|
+
/▌ > 1. Approve and run now/
|
|
97
98
|
],
|
|
98
99
|
fatal: [/Error: The cursor position could not be read within/],
|
|
99
100
|
ensureArgs: (args) => {
|
|
@@ -128,6 +129,11 @@ async function claudeYes({
|
|
|
128
129
|
removeControlCharactersFromStdout = false,
|
|
129
130
|
verbose = false
|
|
130
131
|
} = {}) {
|
|
132
|
+
await rm("agent-yes.log").catch(() => null);
|
|
133
|
+
const yesLog = tsaComposer()(async function yesLog(msg) {
|
|
134
|
+
await appendFile("agent-yes.log", `${msg}
|
|
135
|
+
`).catch(() => null);
|
|
136
|
+
});
|
|
131
137
|
const continueArgs = {
|
|
132
138
|
codex: "resume --last".split(" "),
|
|
133
139
|
claude: "--continue".split(" "),
|
|
@@ -195,8 +201,6 @@ async function claudeYes({
|
|
|
195
201
|
console.log("[${cli}-yes] ${cli} is idle, exiting...");
|
|
196
202
|
await exitAgent();
|
|
197
203
|
});
|
|
198
|
-
console.log(`[${cli}-yes] Started ${cli} with args: ${[cliCommand, ...cliArgs].join(" ")}`);
|
|
199
|
-
shell.write("\x1B[1;1R");
|
|
200
204
|
sflow(fromReadable(process.stdin)).map((buffer) => buffer.toString()).by({
|
|
201
205
|
writable: new WritableStream({
|
|
202
206
|
write: async (data) => {
|
|
@@ -209,29 +213,34 @@ async function claudeYes({
|
|
|
209
213
|
terminalRender.write(text);
|
|
210
214
|
if (process.stdin.isTTY)
|
|
211
215
|
return;
|
|
212
|
-
if (text.includes("\x1B[6n"))
|
|
216
|
+
if (!text.includes("\x1B[6n"))
|
|
213
217
|
return;
|
|
214
218
|
const { col, row } = terminalRender.getCursorPosition();
|
|
215
219
|
console.log(`[${cli}-yes] Responding cursor position: row=${row}, col=${col}`);
|
|
216
220
|
shell.write(`\x1B[${row};${col}R`);
|
|
217
|
-
}).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll("\r", "")).forEach((e2) =>
|
|
218
|
-
`)).forEach(async (e2, i) => {
|
|
221
|
+
}).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll("\r", "")).lines({ EOL: "NONE" }).forEach((e2) => yesLog`output|${e2}`).forEach(async (e2, i) => {
|
|
219
222
|
const conf = CLI_CONFIGURES[cli] || null;
|
|
220
223
|
if (!conf)
|
|
221
224
|
return;
|
|
222
225
|
if (conf.ready?.some((rx) => e2.match(rx))) {
|
|
226
|
+
await yesLog`ready |${e2}`;
|
|
223
227
|
if (cli === "gemini" && i <= 80)
|
|
224
228
|
return;
|
|
225
229
|
stdinReady.ready();
|
|
226
230
|
}
|
|
227
231
|
if (conf.enter?.some((rx) => e2.match(rx))) {
|
|
232
|
+
await yesLog`enter |${e2}`;
|
|
228
233
|
await sendEnter(300);
|
|
234
|
+
return;
|
|
229
235
|
}
|
|
230
236
|
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
237
|
+
await yesLog`fatal |${e2}`;
|
|
231
238
|
isFatal = true;
|
|
232
239
|
await exitAgent();
|
|
233
240
|
}
|
|
234
241
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
242
|
+
if (cli === "codex")
|
|
243
|
+
shell.write(`\x1B[1;1R`);
|
|
235
244
|
if (prompt)
|
|
236
245
|
await sendMessage(prompt);
|
|
237
246
|
const exitCode = await pendingExitCode.promise;
|
|
@@ -247,11 +256,12 @@ async function claudeYes({
|
|
|
247
256
|
const st = Date.now();
|
|
248
257
|
await idleWaiter.wait(waitms);
|
|
249
258
|
const et = Date.now();
|
|
250
|
-
|
|
259
|
+
await yesLog`sendEn| idleWaiter.wait(${String(waitms)}) took ${String(et - st)}ms`;
|
|
251
260
|
shell.write("\r");
|
|
252
261
|
}
|
|
253
262
|
async function sendMessage(message) {
|
|
254
263
|
await stdinReady.wait();
|
|
264
|
+
await yesLog`send |${message}`;
|
|
255
265
|
shell.write(message);
|
|
256
266
|
idleWaiter.ping();
|
|
257
267
|
await sendEnter();
|
|
@@ -271,8 +281,10 @@ async function claudeYes({
|
|
|
271
281
|
]);
|
|
272
282
|
}
|
|
273
283
|
function getTerminalDimensions() {
|
|
284
|
+
if (!process.stdout.isTTY)
|
|
285
|
+
return { cols: 80, rows: 30 };
|
|
274
286
|
return {
|
|
275
|
-
cols: process.stdout.columns,
|
|
287
|
+
cols: Math.min(Math.max(20, process.stdout.columns), 80),
|
|
276
288
|
rows: process.stdout.rows
|
|
277
289
|
};
|
|
278
290
|
}
|
|
@@ -338,5 +350,5 @@ var { exitCode, logs } = await claudeYes({
|
|
|
338
350
|
});
|
|
339
351
|
process.exit(exitCode ?? 1);
|
|
340
352
|
|
|
341
|
-
//# debugId=
|
|
353
|
+
//# debugId=FE903BBCCEA75D2B64756E2164756E21
|
|
342
354
|
//# sourceMappingURL=cli.js.map
|
package/dist/copilot-yes.js
CHANGED
|
@@ -25,11 +25,12 @@ import { hideBin } from "yargs/helpers";
|
|
|
25
25
|
|
|
26
26
|
// dist/index.js
|
|
27
27
|
import { fromReadable, fromWritable } from "from-node-stream";
|
|
28
|
-
import { appendFile, mkdir, writeFile } from "fs/promises";
|
|
28
|
+
import { appendFile, mkdir, rm, writeFile } from "fs/promises";
|
|
29
29
|
import path from "path";
|
|
30
30
|
import DIE from "phpdie";
|
|
31
31
|
import sflow from "sflow";
|
|
32
32
|
import { TerminalTextRender } from "terminal-render";
|
|
33
|
+
import tsaComposer from "tsa-composer";
|
|
33
34
|
class IdleWaiter {
|
|
34
35
|
lastActivityTime = Date.now();
|
|
35
36
|
checkInterval = 100;
|
|
@@ -75,7 +76,7 @@ var CLI_CONFIGURES = {
|
|
|
75
76
|
},
|
|
76
77
|
claude: {
|
|
77
78
|
install: "npm install -g @anthropic-ai/claude-code",
|
|
78
|
-
ready: [
|
|
79
|
+
ready: [/\? for shortcuts/],
|
|
79
80
|
enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
|
|
80
81
|
fatal: [
|
|
81
82
|
/No conversation found to continue/,
|
|
@@ -92,8 +93,8 @@ var CLI_CONFIGURES = {
|
|
|
92
93
|
install: "npm install -g @openai/codex-cli",
|
|
93
94
|
ready: [/⏎ send/],
|
|
94
95
|
enter: [
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
/> 1. Yes, allow Codex to work in this folder/,
|
|
97
|
+
/▌ > 1. Approve and run now/
|
|
97
98
|
],
|
|
98
99
|
fatal: [/Error: The cursor position could not be read within/],
|
|
99
100
|
ensureArgs: (args) => {
|
|
@@ -128,6 +129,11 @@ async function claudeYes({
|
|
|
128
129
|
removeControlCharactersFromStdout = false,
|
|
129
130
|
verbose = false
|
|
130
131
|
} = {}) {
|
|
132
|
+
await rm("agent-yes.log").catch(() => null);
|
|
133
|
+
const yesLog = tsaComposer()(async function yesLog(msg) {
|
|
134
|
+
await appendFile("agent-yes.log", `${msg}
|
|
135
|
+
`).catch(() => null);
|
|
136
|
+
});
|
|
131
137
|
const continueArgs = {
|
|
132
138
|
codex: "resume --last".split(" "),
|
|
133
139
|
claude: "--continue".split(" "),
|
|
@@ -195,8 +201,6 @@ async function claudeYes({
|
|
|
195
201
|
console.log("[${cli}-yes] ${cli} is idle, exiting...");
|
|
196
202
|
await exitAgent();
|
|
197
203
|
});
|
|
198
|
-
console.log(`[${cli}-yes] Started ${cli} with args: ${[cliCommand, ...cliArgs].join(" ")}`);
|
|
199
|
-
shell.write("\x1B[1;1R");
|
|
200
204
|
sflow(fromReadable(process.stdin)).map((buffer) => buffer.toString()).by({
|
|
201
205
|
writable: new WritableStream({
|
|
202
206
|
write: async (data) => {
|
|
@@ -209,29 +213,34 @@ async function claudeYes({
|
|
|
209
213
|
terminalRender.write(text);
|
|
210
214
|
if (process.stdin.isTTY)
|
|
211
215
|
return;
|
|
212
|
-
if (text.includes("\x1B[6n"))
|
|
216
|
+
if (!text.includes("\x1B[6n"))
|
|
213
217
|
return;
|
|
214
218
|
const { col, row } = terminalRender.getCursorPosition();
|
|
215
219
|
console.log(`[${cli}-yes] Responding cursor position: row=${row}, col=${col}`);
|
|
216
220
|
shell.write(`\x1B[${row};${col}R`);
|
|
217
|
-
}).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll("\r", "")).forEach((e2) =>
|
|
218
|
-
`)).forEach(async (e2, i) => {
|
|
221
|
+
}).forkTo((e) => e.map((e2) => removeControlCharacters(e2)).map((e2) => e2.replaceAll("\r", "")).lines({ EOL: "NONE" }).forEach((e2) => yesLog`output|${e2}`).forEach(async (e2, i) => {
|
|
219
222
|
const conf = CLI_CONFIGURES[cli] || null;
|
|
220
223
|
if (!conf)
|
|
221
224
|
return;
|
|
222
225
|
if (conf.ready?.some((rx) => e2.match(rx))) {
|
|
226
|
+
await yesLog`ready |${e2}`;
|
|
223
227
|
if (cli === "gemini" && i <= 80)
|
|
224
228
|
return;
|
|
225
229
|
stdinReady.ready();
|
|
226
230
|
}
|
|
227
231
|
if (conf.enter?.some((rx) => e2.match(rx))) {
|
|
232
|
+
await yesLog`enter |${e2}`;
|
|
228
233
|
await sendEnter(300);
|
|
234
|
+
return;
|
|
229
235
|
}
|
|
230
236
|
if (conf.fatal?.some((rx) => e2.match(rx))) {
|
|
237
|
+
await yesLog`fatal |${e2}`;
|
|
231
238
|
isFatal = true;
|
|
232
239
|
await exitAgent();
|
|
233
240
|
}
|
|
234
241
|
}).run()).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout)).then(() => null);
|
|
242
|
+
if (cli === "codex")
|
|
243
|
+
shell.write(`\x1B[1;1R`);
|
|
235
244
|
if (prompt)
|
|
236
245
|
await sendMessage(prompt);
|
|
237
246
|
const exitCode = await pendingExitCode.promise;
|
|
@@ -247,11 +256,12 @@ async function claudeYes({
|
|
|
247
256
|
const st = Date.now();
|
|
248
257
|
await idleWaiter.wait(waitms);
|
|
249
258
|
const et = Date.now();
|
|
250
|
-
|
|
259
|
+
await yesLog`sendEn| idleWaiter.wait(${String(waitms)}) took ${String(et - st)}ms`;
|
|
251
260
|
shell.write("\r");
|
|
252
261
|
}
|
|
253
262
|
async function sendMessage(message) {
|
|
254
263
|
await stdinReady.wait();
|
|
264
|
+
await yesLog`send |${message}`;
|
|
255
265
|
shell.write(message);
|
|
256
266
|
idleWaiter.ping();
|
|
257
267
|
await sendEnter();
|
|
@@ -271,8 +281,10 @@ async function claudeYes({
|
|
|
271
281
|
]);
|
|
272
282
|
}
|
|
273
283
|
function getTerminalDimensions() {
|
|
284
|
+
if (!process.stdout.isTTY)
|
|
285
|
+
return { cols: 80, rows: 30 };
|
|
274
286
|
return {
|
|
275
|
-
cols: process.stdout.columns,
|
|
287
|
+
cols: Math.min(Math.max(20, process.stdout.columns), 80),
|
|
276
288
|
rows: process.stdout.rows
|
|
277
289
|
};
|
|
278
290
|
}
|
|
@@ -338,5 +350,5 @@ var { exitCode, logs } = await claudeYes({
|
|
|
338
350
|
});
|
|
339
351
|
process.exit(exitCode ?? 1);
|
|
340
352
|
|
|
341
|
-
//# debugId=
|
|
353
|
+
//# debugId=FE903BBCCEA75D2B64756E2164756E21
|
|
342
354
|
//# sourceMappingURL=cli.js.map
|