claude-yes 1.14.1 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.ts +49 -39
- package/dist/cli.js +5354 -244
- package/dist/index.js +7 -4
- package/index.ts +12 -3
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -5088,15 +5088,17 @@ class TerminalTextRender {
|
|
|
5088
5088
|
}
|
|
5089
5089
|
|
|
5090
5090
|
// index.ts
|
|
5091
|
+
import { writeFile } from "fs/promises";
|
|
5091
5092
|
async function claudeYes({
|
|
5092
5093
|
continueOnCrash,
|
|
5093
5094
|
exitOnIdle,
|
|
5094
5095
|
claudeArgs = [],
|
|
5095
5096
|
cwd = process.cwd(),
|
|
5096
|
-
removeControlCharactersFromStdout = false
|
|
5097
|
+
removeControlCharactersFromStdout = false,
|
|
5098
|
+
logFile
|
|
5097
5099
|
} = {}) {
|
|
5098
|
-
const
|
|
5099
|
-
const idleTimeout = typeof exitOnIdle === "number" ? exitOnIdle :
|
|
5100
|
+
const defaultIdleTimeout = 60000;
|
|
5101
|
+
const idleTimeout = typeof exitOnIdle === "number" ? exitOnIdle : defaultIdleTimeout;
|
|
5100
5102
|
console.log("⭐ Starting claude, automatically responding to yes/no prompts...");
|
|
5101
5103
|
console.log("⚠️ 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.");
|
|
5102
5104
|
process.stdin.setRawMode?.(true);
|
|
@@ -5170,7 +5172,7 @@ async function claudeYes({
|
|
|
5170
5172
|
const ttr = new TerminalTextRender;
|
|
5171
5173
|
const idleWatcher = createIdleWatcher(async () => {
|
|
5172
5174
|
if (exitOnIdle) {
|
|
5173
|
-
if (ttr.render().match(/esc to interrupt|to run in background/)) {
|
|
5175
|
+
if (ttr.render().replace(/\s+/g, " ").match(/esc to interrupt|to run in background/)) {
|
|
5174
5176
|
console.warn("[CLAUDE-YES] Claude is idle, but seems still working, not exiting yet");
|
|
5175
5177
|
} else {
|
|
5176
5178
|
console.warn("[CLAUDE-YES] Claude is idle, exiting...");
|
|
@@ -5192,6 +5194,7 @@ async function claudeYes({
|
|
|
5192
5194
|
return;
|
|
5193
5195
|
}
|
|
5194
5196
|
}).run()).replaceAll(/.*(?:\r\n?|\r?\n)/g, (line) => prefix + line).map((e) => removeControlCharactersFromStdout ? removeControlCharacters(e) : e).to(fromWritable(process.stdout));
|
|
5197
|
+
logFile && await writeFile(logFile, ttr.render());
|
|
5195
5198
|
return ttr.render();
|
|
5196
5199
|
}
|
|
5197
5200
|
export {
|
package/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { createIdleWatcher } from './createIdleWatcher';
|
|
|
4
4
|
import { removeControlCharacters } from './removeControlCharacters';
|
|
5
5
|
import { sleepms } from './utils';
|
|
6
6
|
import { TerminalTextRender } from 'terminal-render';
|
|
7
|
+
import { writeFile } from 'fs/promises';
|
|
7
8
|
// for debug only
|
|
8
9
|
// if (import.meta.main) await main();
|
|
9
10
|
// async function main() {
|
|
@@ -33,16 +34,18 @@ export default async function claudeYes({
|
|
|
33
34
|
cwd = process.cwd(),
|
|
34
35
|
// removeControlCharactersFromStdout = !process.stdout.isTTY,
|
|
35
36
|
removeControlCharactersFromStdout = false,
|
|
37
|
+
logFile,
|
|
36
38
|
}: {
|
|
37
39
|
continueOnCrash?: boolean;
|
|
38
40
|
exitOnIdle?: boolean | number;
|
|
39
41
|
claudeArgs?: string[];
|
|
40
42
|
cwd?: string;
|
|
41
43
|
removeControlCharactersFromStdout?: boolean;
|
|
44
|
+
logFile?: string;
|
|
42
45
|
} = {}) {
|
|
43
|
-
const
|
|
46
|
+
const defaultIdleTimeout = 60e3;
|
|
44
47
|
const idleTimeout =
|
|
45
|
-
typeof exitOnIdle === 'number' ? exitOnIdle :
|
|
48
|
+
typeof exitOnIdle === 'number' ? exitOnIdle : defaultIdleTimeout;
|
|
46
49
|
|
|
47
50
|
console.log(
|
|
48
51
|
'⭐ Starting claude, automatically responding to yes/no prompts...'
|
|
@@ -146,7 +149,12 @@ export default async function claudeYes({
|
|
|
146
149
|
const ttr = new TerminalTextRender();
|
|
147
150
|
const idleWatcher = createIdleWatcher(async () => {
|
|
148
151
|
if (exitOnIdle) {
|
|
149
|
-
if (
|
|
152
|
+
if (
|
|
153
|
+
ttr
|
|
154
|
+
.render()
|
|
155
|
+
.replace(/\s+/g, ' ')
|
|
156
|
+
.match(/esc to interrupt|to run in background/)
|
|
157
|
+
) {
|
|
150
158
|
console.warn(
|
|
151
159
|
'[CLAUDE-YES] Claude is idle, but seems still working, not exiting yet'
|
|
152
160
|
);
|
|
@@ -189,6 +197,7 @@ export default async function claudeYes({
|
|
|
189
197
|
)
|
|
190
198
|
.to(fromWritable(process.stdout));
|
|
191
199
|
|
|
200
|
+
logFile && (await writeFile(logFile, ttr.render()));
|
|
192
201
|
return ttr.render(); // return full rendered logs
|
|
193
202
|
}
|
|
194
203
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-yes",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"homepage": "https://github.com/snomiao/claude-yes#readme",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "snomiao <snomiao@gmail.com>",
|
|
@@ -35,14 +35,13 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/bun": "^1.2.18",
|
|
37
37
|
"@types/jest": "^30.0.0",
|
|
38
|
-
"@types/minimist": "^1.2.5",
|
|
39
38
|
"@types/node": "^24.0.10",
|
|
39
|
+
"@types/yargs": "^17.0.33",
|
|
40
40
|
"enhanced-ms": "^4.1.0",
|
|
41
41
|
"execa": "^9.6.0",
|
|
42
42
|
"from-node-stream": "^0.0.11",
|
|
43
43
|
"husky": "^9.1.7",
|
|
44
44
|
"lint-staged": "^16.1.4",
|
|
45
|
-
"minimist": "^1.2.8",
|
|
46
45
|
"prettier": "^3.6.2",
|
|
47
46
|
"semantic-release": "^24.2.6",
|
|
48
47
|
"sflow": "^1.20.2",
|
|
@@ -63,7 +62,8 @@
|
|
|
63
62
|
"dependencies": {
|
|
64
63
|
"bun-pty": "^0.3.2",
|
|
65
64
|
"node-pty": "^1.0.0",
|
|
66
|
-
"terminal-render": "^1.1.0"
|
|
65
|
+
"terminal-render": "^1.1.0",
|
|
66
|
+
"yargs": "^18.0.0"
|
|
67
67
|
},
|
|
68
68
|
"lint-staged": {
|
|
69
69
|
"*.{ts,js,json,md}": [
|