claude-yes 1.12.0-beta.1 → 1.12.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/dist/cli.js +0 -9
- package/dist/index.js +0 -9
- package/index.ts +18 -18
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5076,15 +5076,6 @@ function sleepms(ms) {
|
|
|
5076
5076
|
}
|
|
5077
5077
|
|
|
5078
5078
|
// index.ts
|
|
5079
|
-
if (__require.main == __require.module)
|
|
5080
|
-
await main();
|
|
5081
|
-
async function main() {
|
|
5082
|
-
await claudeYes({
|
|
5083
|
-
continueOnCrash: true,
|
|
5084
|
-
exitOnIdle: 1e4,
|
|
5085
|
-
claudeArgs: ["say hello and exit"]
|
|
5086
|
-
});
|
|
5087
|
-
}
|
|
5088
5079
|
async function claudeYes({
|
|
5089
5080
|
continueOnCrash,
|
|
5090
5081
|
exitOnIdle,
|
package/dist/index.js
CHANGED
|
@@ -4856,15 +4856,6 @@ function sleepms(ms) {
|
|
|
4856
4856
|
}
|
|
4857
4857
|
|
|
4858
4858
|
// index.ts
|
|
4859
|
-
if (__require.main == __require.module)
|
|
4860
|
-
await main();
|
|
4861
|
-
async function main() {
|
|
4862
|
-
await claudeYes({
|
|
4863
|
-
continueOnCrash: true,
|
|
4864
|
-
exitOnIdle: 1e4,
|
|
4865
|
-
claudeArgs: ["say hello and exit"]
|
|
4866
|
-
});
|
|
4867
|
-
}
|
|
4868
4859
|
async function claudeYes({
|
|
4869
4860
|
continueOnCrash,
|
|
4870
4861
|
exitOnIdle,
|
package/index.ts
CHANGED
|
@@ -4,15 +4,15 @@ import { createIdleWatcher } from "./createIdleWatcher";
|
|
|
4
4
|
import { removeControlCharacters } from "./removeControlCharacters";
|
|
5
5
|
import { sleepms } from "./utils";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
7
|
+
// for debug only
|
|
8
|
+
// if (import.meta.main) await main();
|
|
9
|
+
// async function main() {
|
|
10
|
+
// await claudeYes({
|
|
11
|
+
// continueOnCrash: true,
|
|
12
|
+
// exitOnIdle: 10000,
|
|
13
|
+
// claudeArgs: ["say hello and exit"]
|
|
14
|
+
// })
|
|
15
|
+
// }
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Main function to run Claude with automatic yes/no respojnses
|
|
@@ -41,10 +41,10 @@ export default async function claudeYes({
|
|
|
41
41
|
typeof exitOnIdle === "number" ? exitOnIdle : defaultTimeout;
|
|
42
42
|
|
|
43
43
|
console.log(
|
|
44
|
-
"⭐ Starting claude, automatically responding to yes/no prompts..."
|
|
44
|
+
"⭐ Starting claude, automatically responding to yes/no prompts...",
|
|
45
45
|
);
|
|
46
46
|
console.log(
|
|
47
|
-
"⚠️ 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."
|
|
47
|
+
"⚠️ 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.",
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
process.stdin.setRawMode?.(true); //must be called any stdout/stdin usage
|
|
@@ -55,8 +55,8 @@ export default async function claudeYes({
|
|
|
55
55
|
const shellOutputStream = new TransformStream<string, string>();
|
|
56
56
|
const outputWriter = shellOutputStream.writable.getWriter();
|
|
57
57
|
const pty = globalThis.Bun
|
|
58
|
-
? await import(
|
|
59
|
-
: await import(
|
|
58
|
+
? await import("bun-pty")
|
|
59
|
+
: await import("node-pty");
|
|
60
60
|
let shell = pty.spawn("claude", claudeArgs, {
|
|
61
61
|
name: "xterm-color",
|
|
62
62
|
cols: process.stdout.columns - PREFIXLENGTH,
|
|
@@ -77,7 +77,7 @@ export default async function claudeYes({
|
|
|
77
77
|
if (continueOnCrash && exitCode !== 0) {
|
|
78
78
|
if (errorNoConversation) {
|
|
79
79
|
console.log(
|
|
80
|
-
'Claude crashed with "No conversation found to continue", exiting...'
|
|
80
|
+
'Claude crashed with "No conversation found to continue", exiting...',
|
|
81
81
|
);
|
|
82
82
|
void process.exit(exitCode);
|
|
83
83
|
}
|
|
@@ -112,7 +112,7 @@ export default async function claudeYes({
|
|
|
112
112
|
shell.onExit(() => {
|
|
113
113
|
resolve();
|
|
114
114
|
exited = true;
|
|
115
|
-
})
|
|
115
|
+
}),
|
|
116
116
|
), // resolve when shell exits
|
|
117
117
|
// if shell doesn't exit in 5 seconds, kill it
|
|
118
118
|
new Promise<void>((resolve) =>
|
|
@@ -120,7 +120,7 @@ export default async function claudeYes({
|
|
|
120
120
|
if (exited) return; // if shell already exited, do nothing
|
|
121
121
|
shell.kill(); // kill the shell process if it doesn't exit in time
|
|
122
122
|
resolve();
|
|
123
|
-
}, 5000)
|
|
123
|
+
}, 5000),
|
|
124
124
|
), // 5 seconds timeout
|
|
125
125
|
]);
|
|
126
126
|
};
|
|
@@ -134,7 +134,7 @@ export default async function claudeYes({
|
|
|
134
134
|
const shellStdio = {
|
|
135
135
|
writable: new WritableStream<string>({
|
|
136
136
|
write: (data) => shell.write(data),
|
|
137
|
-
close: () => {
|
|
137
|
+
close: () => {},
|
|
138
138
|
}),
|
|
139
139
|
readable: shellOutputStream.readable,
|
|
140
140
|
};
|
|
@@ -167,7 +167,7 @@ export default async function claudeYes({
|
|
|
167
167
|
}
|
|
168
168
|
})
|
|
169
169
|
// .forEach(e => appendFile('.cache/io.log', "output|" + JSON.stringify(e) + '\n')) // for debugging
|
|
170
|
-
.run()
|
|
170
|
+
.run(),
|
|
171
171
|
)
|
|
172
172
|
.replaceAll(/.*(?:\r\n?|\r?\n)/g, (line) => prefix + line) // add prefix
|
|
173
173
|
.forEach(() => idleWatcher.ping()) // ping the idle watcher on output for last active time to keep track of claude status
|