claude-yes 1.17.0 → 1.18.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/idleWaiter.ts ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A utility class to wait for idle periods based on activity pings.
3
+ *
4
+ * @example
5
+ * const idleWaiter = new IdleWaiter();
6
+ *
7
+ * // Somewhere in your code, when activity occurs:
8
+ * idleWaiter.ping();
9
+ *
10
+ * // To wait for an idle period of 5 seconds:
11
+ * await idleWaiter.wait(5000);
12
+ * console.log('System has been idle for 5 seconds');
13
+ */
14
+ export class IdleWaiter {
15
+ lastActivityTime = Date.now();
16
+ checkInterval = 100; // Default check interval in milliseconds
17
+
18
+ constructor() {
19
+ this.ping();
20
+ }
21
+
22
+ ping() {
23
+ this.lastActivityTime = Date.now();
24
+ return this;
25
+ }
26
+
27
+ async wait(ms: number) {
28
+ while (this.lastActivityTime >= Date.now() - ms)
29
+ await new Promise((resolve) => setTimeout(resolve, this.checkInterval));
30
+ }
31
+ }
package/index.ts CHANGED
@@ -1,37 +1,90 @@
1
1
  import { fromReadable, fromWritable } from 'from-node-stream';
2
+ import { mkdir, writeFile } from 'fs/promises';
3
+ import path from 'path';
4
+ import DIE from 'phpdie';
2
5
  import sflow from 'sflow';
3
- import { createIdleWatcher } from './createIdleWatcher';
4
- import { removeControlCharacters } from './removeControlCharacters';
5
- import { sleepms } from './utils';
6
6
  import { TerminalTextRender } from 'terminal-render';
7
- import { writeFile } from 'fs/promises';
8
- import path from 'path';
9
- import { mkdir } from 'fs/promises';
7
+ import { IdleWaiter } from './idleWaiter';
10
8
  import { ReadyManager } from './ReadyManager';
9
+ import { removeControlCharacters } from './removeControlCharacters';
11
10
 
11
+ export const CLI_CONFIGURES = {
12
+ claude: {
13
+ ready: /^> /, // regex matcher for stdin ready,
14
+ enter: [/❯ 1. Yes/, /❯ 1. Dark mode✔/, /Press Enter to continue…/],
15
+ fatal: [
16
+ /No conversation found to continue/,
17
+ /⎿ {2}Claude usage limit reached\./,
18
+ ],
19
+ },
20
+ gemini: {
21
+ // match the agent prompt after initial lines; handled by index logic using line index
22
+ ready: /Type your message/, // used with line index check
23
+ enter: [/│ ● 1. Yes, allow once/],
24
+ },
25
+ codex: {
26
+ ready: /⏎ send/,
27
+ enter: [/ > 1. Approve/, /> 1. Yes, allow Codex to work in this folder/],
28
+ fatal: [/Error: The cursor position could not be read within/],
29
+ // add to codex --search by default when not provided by the user
30
+ ensureArgs: (args: string[]) => {
31
+ if (!args.includes('--search')) return ['--search', ...args];
32
+ return args;
33
+ },
34
+ },
35
+ copilot: {
36
+ ready: /^ > /,
37
+ enter: [/ │ ❯ 1. Yes, proceed/, /❯ 1. Yes/],
38
+ },
39
+ cursor: {
40
+ // map logical "cursor" cli name to actual binary name
41
+ binary: 'cursor-agent',
42
+ ready: /\/ commands/,
43
+ enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
44
+ },
45
+ };
12
46
  /**
13
- * Main function to run Claude with automatic yes/no respojnses
47
+ * Main function to run Claude with automatic yes/no responses
14
48
  * @param options Configuration options
15
49
  * @param options.continueOnCrash - If true, automatically restart Claude when it crashes:
16
50
  * 1. Shows message 'Claude crashed, restarting..'
17
51
  * 2. Spawns a new 'claude --continue' process
18
52
  * 3. Re-attaches the new process to the shell stdio (pipes new process stdin/stdout)
19
53
  * 4. If it crashes with "No conversation found to continue", exits the process
20
- * @param options.exitOnIdle - Exit when Claude is idle. Boolean or timeout in milliseconds
54
+ * @param options.exitOnIdle - Exit when Claude is idle. Boolean or timeout in milliseconds, recommended 5000 - 60000, default is false
21
55
  * @param options.claudeArgs - Additional arguments to pass to the Claude CLI
22
56
  * @param options.removeControlCharactersFromStdout - Remove ANSI control characters from stdout. Defaults to !process.stdout.isTTY
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * import claudeYes from 'claude-yes';
61
+ * await claudeYes({
62
+ * prompt: 'help me solve all todos in my codebase',
63
+ *
64
+ * // optional
65
+ * cli: 'claude',
66
+ * cliArgs: ['--verbose'], // additional args to pass to claude
67
+ * exitOnIdle: 30000, // exit after 30 seconds of idle
68
+ * continueOnCrash: true, // restart if claude crashes, default is true
69
+ * logFile: 'claude.log', // save logs to file
70
+ * });
71
+ * ```
23
72
  */
24
73
  export default async function claudeYes({
25
- claudeArgs = [],
74
+ cli = 'claude',
75
+ cliArgs = [],
76
+ prompt,
26
77
  continueOnCrash,
27
78
  cwd,
28
79
  env,
29
- exitOnIdle = 60e3,
80
+ exitOnIdle,
30
81
  logFile,
31
82
  removeControlCharactersFromStdout = false, // = !process.stdout.isTTY,
32
83
  verbose = false,
33
84
  }: {
34
- claudeArgs?: string[];
85
+ cli?: (string & {}) | keyof typeof CLI_CONFIGURES;
86
+ cliArgs?: string[];
87
+ prompt?: string;
35
88
  continueOnCrash?: boolean;
36
89
  cwd?: string;
37
90
  env?: Record<string, string>;
@@ -40,48 +93,60 @@ export default async function claudeYes({
40
93
  removeControlCharactersFromStdout?: boolean;
41
94
  verbose?: boolean;
42
95
  } = {}) {
43
- if (verbose) {
44
- console.log('calling claudeYes: ', {
45
- continueOnCrash,
46
- exitOnIdle,
47
- claudeArgs,
48
- cwd,
49
- removeControlCharactersFromStdout,
50
- logFile,
51
- verbose,
52
- });
53
- }
54
- console.log(
55
- '⭐ Starting claude, automatically responding to yes/no prompts...'
56
- );
57
- console.log(
58
- '⚠️ 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.'
59
- );
60
-
61
- process.stdin.setRawMode?.(true); //must be called any stdout/stdin usage
62
- const prefix = ''; // "YESC|"
63
- const PREFIXLENGTH = prefix.length;
64
- let errorNoConversation = false; // match 'No conversation found to continue'
65
- const shellReady = new ReadyManager();
96
+ const continueArgs = {
97
+ codex: 'resume --last'.split(' '),
98
+ claude: '--continue'.split(' '),
99
+ gemini: [], // not possible yet
100
+ };
101
+
102
+ // if (verbose) {
103
+ // console.log('calling claudeYes: ', {
104
+ // cli,
105
+ // continueOnCrash,
106
+ // exitOnIdle,
107
+ // cliArgs,
108
+ // cwd,
109
+ // removeControlCharactersFromStdout,
110
+ // logFile,
111
+ // verbose,
112
+ // });
113
+ // }
114
+ // console.log(
115
+ // `⭐ Starting ${cli}, automatically responding to yes/no prompts...`
116
+ // );
117
+ // console.log(
118
+ // '⚠️ 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.'
119
+ // );
120
+
121
+ process.stdin.setRawMode?.(true); // must be called any stdout/stdin usage
122
+ let isFatal = false; // match 'No conversation found to continue'
123
+ const stdinReady = new ReadyManager();
66
124
 
67
125
  const shellOutputStream = new TransformStream<string, string>();
68
126
  const outputWriter = shellOutputStream.writable.getWriter();
69
127
  // const pty = await import('node-pty');
70
128
 
71
- // recommened to use bun pty in windows
72
- const pty = process.versions.bun
73
- ? await import('bun-pty')
74
- : await import('node-pty');
129
+ // its recommened to use bun-pty in windows
130
+ const pty = await import('node-pty')
131
+ .catch(async () => await import('bun-pty'))
132
+ .catch(async () =>
133
+ DIE('Please install node-pty or bun-pty, run this: bun install bun-pty'),
134
+ );
75
135
 
76
136
  const getPtyOptions = () => ({
77
137
  name: 'xterm-color',
78
- cols: process.stdout.columns - PREFIXLENGTH,
79
- rows: process.stdout.rows,
138
+ ...getTerminalDimensions(),
80
139
  cwd: cwd ?? process.cwd(),
81
140
  env: env ?? (process.env as Record<string, string>),
82
141
  });
83
- let shell = pty.spawn('claude', claudeArgs, getPtyOptions());
84
- let pendingExitCode = Promise.withResolvers<number | null>();
142
+
143
+ // Apply CLI specific configurations (moved to CLI_CONFIGURES)
144
+ const cliConf = (CLI_CONFIGURES as Record<string, any>)[cli] || {};
145
+ cliArgs = cliConf.ensureArgs?.(cliArgs) ?? cliArgs;
146
+ const cliCommand = cliConf?.binary || cli;
147
+
148
+ let shell = pty.spawn(cliCommand, cliArgs, getPtyOptions());
149
+ const pendingExitCode = Promise.withResolvers<number | null>();
85
150
  let pendingExitCodeValue = null;
86
151
 
87
152
  // TODO handle error if claude is not installed, show msg:
@@ -90,23 +155,29 @@ export default async function claudeYes({
90
155
  async function onData(data: string) {
91
156
  // append data to the buffer, so we can process it later
92
157
  await outputWriter.write(data);
93
- shellReady.ready(); // shell has output, also means ready for stdin
94
158
  }
95
159
 
96
160
  shell.onData(onData);
97
161
  shell.onExit(function onExit({ exitCode }) {
98
- shellReady.unready(); // start buffer stdin
99
- const claudeCrashed = exitCode !== 0;
100
- if (claudeCrashed && continueOnCrash) {
101
- if (errorNoConversation) {
162
+ stdinReady.unready(); // start buffer stdin
163
+ const agentCrashed = exitCode !== 0;
164
+ const continueArg = (continueArgs as Record<string, string[]>)[cli];
165
+
166
+ if (agentCrashed && continueOnCrash && continueArg) {
167
+ if (!continueArg) {
168
+ return console.warn(
169
+ `continueOnCrash is only supported for ${Object.keys(continueArgs).join(', ')} currently, not ${cli}`,
170
+ );
171
+ }
172
+ if (isFatal) {
102
173
  console.log(
103
- 'Claude crashed with "No conversation found to continue", exiting...'
174
+ `${cli} crashed with "No conversation found to continue", exiting...`,
104
175
  );
105
176
  return pendingExitCode.resolve((pendingExitCodeValue = exitCode));
106
177
  }
107
- console.log('Claude crashed, restarting...');
178
+ console.log(`${cli} crashed, restarting...`);
108
179
 
109
- shell = pty.spawn('claude', ['--continue', 'continue'], getPtyOptions());
180
+ shell = pty.spawn(cli, continueArg, getPtyOptions());
110
181
  shell.onData(onData);
111
182
  shell.onExit(onExit);
112
183
  return;
@@ -114,112 +185,197 @@ export default async function claudeYes({
114
185
  return pendingExitCode.resolve((pendingExitCodeValue = exitCode));
115
186
  });
116
187
 
117
- const exitClaudeCode = async () => {
118
- continueOnCrash = false;
119
- // send exit command to the shell, must sleep a bit to avoid claude treat it as pasted input
120
- await sflow(['\r', '/exit', '\r'])
121
- .forEach(async () => await sleepms(200))
122
- .forEach(async (e) => shell.write(e))
123
- .run();
124
-
125
- // wait for shell to exit or kill it with a timeout
126
- let exited = false;
127
- await Promise.race([
128
- pendingExitCode.promise.then(() => (exited = true)), // resolve when shell exits
129
- // if shell doesn't exit in 5 seconds, kill it
130
- new Promise<void>((resolve) =>
131
- setTimeout(() => {
132
- if (exited) return; // if shell already exited, do nothing
133
- shell.kill(); // kill the shell process if it doesn't exit in time
134
- resolve();
135
- }, 5000)
136
- ), // 5 seconds timeout
137
- ]);
138
- };
139
-
140
188
  // when current tty resized, resize the pty
141
189
  process.stdout.on('resize', () => {
142
- const { columns, rows } = process.stdout;
143
- shell.resize(columns - PREFIXLENGTH, rows);
190
+ const { cols, rows } = getTerminalDimensions(); // minimum 80 columns to avoid layout issues
191
+ shell.resize(cols, rows); // minimum 80 columns to avoid layout issues
144
192
  });
145
193
 
146
- const render = new TerminalTextRender();
147
- const idleWatcher = !exitOnIdle
148
- ? null
149
- : createIdleWatcher(async () => {
150
- if (
151
- render
152
- .render()
153
- .replace(/\s+/g, ' ')
154
- .match(/esc to interrupt|to run in background/)
155
- ) {
156
- console.log(
157
- '[claude-yes] Claude is idle, but seems still working, not exiting yet'
158
- );
159
- } else {
160
- console.log('[claude-yes] Claude is idle, exiting...');
161
- await exitClaudeCode();
162
- }
163
- }, exitOnIdle);
164
- const confirm = async () => {
165
- await sleepms(200);
166
- shell.write('\r');
167
- };
194
+ const terminalRender = new TerminalTextRender();
195
+ const isStillWorkingQ = () =>
196
+ terminalRender
197
+ .render()
198
+ .replace(/\s+/g, ' ')
199
+ .match(/esc to interrupt|to run in background/);
168
200
 
201
+ const idleWaiter = new IdleWaiter();
202
+ if (exitOnIdle)
203
+ idleWaiter.wait(exitOnIdle).then(async () => {
204
+ if (isStillWorkingQ()) {
205
+ console.log(
206
+ '[${cli}-yes] ${cli} is idle, but seems still working, not exiting yet',
207
+ );
208
+ return;
209
+ }
210
+
211
+ console.log('[${cli}-yes] ${cli} is idle, exiting...');
212
+ await exitAgent();
213
+ });
214
+
215
+ // Message streaming
169
216
  sflow(fromReadable<Buffer>(process.stdin))
170
217
  .map((buffer) => buffer.toString())
218
+ // .map((e) => e.replaceAll('\x1a', '')) // remove ctrl+z from user's input (seems bug)
171
219
  // .forEach(e => appendFile('.cache/io.log', "input |" + JSON.stringify(e) + '\n')) // for debugging
172
220
  // pipe
173
221
  .by({
174
222
  writable: new WritableStream<string>({
175
223
  write: async (data) => {
176
- await shellReady.wait();
224
+ await stdinReady.wait();
225
+ // await idleWaiter.wait(20); // wait for idle for 200ms to avoid messing up claude's input
177
226
  shell.write(data);
178
227
  },
179
228
  }),
180
229
  readable: shellOutputStream.readable,
181
230
  })
182
- // handle terminal render
183
- .forEach((text) => render.write(text))
231
+ .forEach(() => idleWaiter.ping())
232
+ .forEach((text) => {
233
+ terminalRender.write(text);
234
+ // todo: .onStatus((msg)=> shell.write(msg))
235
+ if (process.stdin.isTTY) return; // only handle it when stdin is not tty
236
+ if (text.includes('\u001b[6n')) return; // only asked
237
+
238
+ // todo: use terminalRender API to get cursor position when new version is available
239
+ // xterm replies CSI row; column R if asked cursor position
240
+ // https://en.wikipedia.org/wiki/ANSI_escape_code#:~:text=citation%20needed%5D-,xterm%20replies,-CSI%20row%C2%A0%3B
241
+ // when agent asking position, respond with row; col
242
+ const rendered = terminalRender.render();
243
+ const row = rendered.split('\n').length + 1;
244
+ const col = (rendered.split('\n').slice(-1)[0]?.length || 0) + 1;
245
+ shell.write(`\u001b[${row};${col}R`);
246
+ })
184
247
 
185
- // handle idle
186
- .forEach(() => idleWatcher?.ping()) // ping the idle watcher on output for last active time to keep track of claude status
187
248
  // auto-response
188
249
  .forkTo((e) =>
189
250
  e
190
- .map((e) => removeControlCharacters(e as string))
251
+ .map((e) => removeControlCharacters(e))
191
252
  .map((e) => e.replaceAll('\r', '')) // remove carriage return
192
- .forEach(async (e) => {
193
- if (e.match(/❯ 1. Yes/)) return await confirm();
194
- if (e.match(/❯ 1. Dark mode✔|Press Enter to continue…/))
195
- return await confirm();
196
- if (e.match(/No conversation found to continue/)) {
197
- errorNoConversation = true; // set flag to true if error message is found
253
+ .lines({ EOL: 'NONE' })
254
+ // Generic auto-response handler driven by CLI_CONFIGURES
255
+ .forEach(async (e, i) => {
256
+ const conf = (CLI_CONFIGURES as Record<string, any>)[cli] || {};
257
+ if (!conf) return;
258
+
259
+ // ready matcher: if matched, mark stdin ready
260
+ try {
261
+ if (conf.ready) {
262
+ // special-case gemini to avoid initial prompt noise: only after many lines
263
+ if (cli === 'gemini' && conf.ready instanceof RegExp) {
264
+ if (e.match(conf.ready) && i > 80) return stdinReady.ready();
265
+ } else if (e.match(conf.ready)) {
266
+ return stdinReady.ready();
267
+ }
268
+ }
269
+
270
+ // enter matchers: send Enter when any enter regex matches
271
+ if (conf.enter && Array.isArray(conf.enter)) {
272
+ for (const rx of conf.enter) {
273
+ if (e.match(rx)) return await sendEnter();
274
+ }
275
+ } else if (conf.enter && conf.enter instanceof RegExp) {
276
+ if (e.match(conf.enter)) return await sendEnter();
277
+ }
278
+
279
+ // fatal matchers: set isFatal flag when matched
280
+ if (conf.fatal && Array.isArray(conf.fatal)) {
281
+ for (const rx of conf.fatal) {
282
+ if (e.match(rx)) return (isFatal = true);
283
+ }
284
+ } else if (conf.fatal && conf.fatal instanceof RegExp) {
285
+ if (e.match(conf.fatal)) return (isFatal = true);
286
+ }
287
+ } catch (err) {
288
+ // defensive: if e.match throws (e.g., not a string), ignore
198
289
  return;
199
290
  }
200
291
  })
201
292
  // .forEach(e => appendFile('.cache/io.log', "output|" + JSON.stringify(e) + '\n')) // for debugging
202
- .run()
293
+ .run(),
203
294
  )
204
- .replaceAll(/.*(?:\r\n?|\r?\n)/g, (line) => prefix + line) // add prefix
205
295
  .map((e) =>
206
- removeControlCharactersFromStdout ? removeControlCharacters(e) : e
296
+ removeControlCharactersFromStdout ? removeControlCharacters(e) : e,
207
297
  )
208
- .to(fromWritable(process.stdout));
298
+ .to(fromWritable(process.stdout))
299
+ .then(() => null); // run it immediately without await
300
+
301
+ // wait for cli ready and send prompt if provided
302
+ if (prompt)
303
+ (async () => {
304
+ // console.log(`[${cli}-yes] Ready to send prompt to ${cli}: ${prompt}`);
305
+ // idleWaiter.ping();
306
+ // console.log(
307
+ // 'await idleWaiter.wait(1000); // wait a bit for claude to start'
308
+ // );
309
+ // await idleWaiter.wait(1000); // wait a bit for claude to start
310
+ // console.log('await stdinReady.wait();');
311
+ // await stdinReady.wait();
312
+ // console.log(`[${cli}-yes] Waiting for ${cli} to be ready...`);
313
+ // console.log('await idleWaiter.wait(200);');
314
+ // await idleWaiter.wait(200);
315
+ // console.log(`[${cli}-yes] Sending prompt to ${cli}: ${prompt}`);
316
+ await sendMessage(prompt);
317
+ })();
209
318
 
210
319
  const exitCode = await pendingExitCode.promise; // wait for the shell to exit
211
- console.log(`[claude-yes] claude exited with code ${exitCode}`);
320
+ console.log(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
212
321
 
213
322
  if (logFile) {
214
- verbose && console.log(`[claude-yes] Writing rendered logs to ${logFile}`);
323
+ verbose && console.log(`[${cli}-yes] Writing rendered logs to ${logFile}`);
215
324
  const logFilePath = path.resolve(logFile);
216
325
  await mkdir(path.dirname(logFilePath), { recursive: true }).catch(
217
- () => null
326
+ () => null,
218
327
  );
219
- await writeFile(logFilePath, render.render());
328
+ await writeFile(logFilePath, terminalRender.render());
329
+ }
330
+
331
+ return { exitCode, logs: terminalRender.render() };
332
+
333
+ async function sendEnter(waitms = 1000) {
334
+ // wait for idle for a bit to let agent cli finish rendering
335
+ const st = Date.now();
336
+
337
+ await idleWaiter.wait(waitms);
338
+ const et = Date.now();
339
+ process.stdout.write(`\ridleWaiter.wait(${waitms}) took ${et - st}ms\r`);
340
+
341
+ shell.write('\r');
342
+ }
343
+
344
+ async function sendMessage(message: string) {
345
+ await stdinReady.wait();
346
+ // show in-place message: write msg and move cursor back start
347
+ shell.write(message);
348
+ idleWaiter.ping(); // just sent a message, wait for echo
349
+ await sendEnter();
350
+ }
351
+
352
+ async function exitAgent() {
353
+ continueOnCrash = false;
354
+ // send exit command to the shell, must sleep a bit to avoid claude treat it as pasted input
355
+ await sendMessage('/exit');
356
+
357
+ // wait for shell to exit or kill it with a timeout
358
+ let exited = false;
359
+ await Promise.race([
360
+ pendingExitCode.promise.then(() => (exited = true)), // resolve when shell exits
361
+
362
+ // if shell doesn't exit in 5 seconds, kill it
363
+ new Promise<void>((resolve) =>
364
+ setTimeout(() => {
365
+ if (exited) return; // if shell already exited, do nothing
366
+ shell.kill(); // kill the shell process if it doesn't exit in time
367
+ resolve();
368
+ }, 5000),
369
+ ), // 5 seconds timeout
370
+ ]);
220
371
  }
221
372
 
222
- return { exitCode, logs: render.render() };
373
+ function getTerminalDimensions() {
374
+ return {
375
+ cols: Math.max(process.stdout.columns, 80),
376
+ rows: process.stdout.rows,
377
+ };
378
+ }
223
379
  }
224
380
 
225
381
  export { removeControlCharacters };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-yes",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "description": "A wrapper tool that automates interactions with the Claude CLI by automatically handling common prompts and responses.",
5
5
  "keywords": [
6
6
  "claude",
@@ -27,11 +27,15 @@
27
27
  "import": "./dist/index.js",
28
28
  "types": "./index.ts"
29
29
  },
30
- "main": "index.js",
30
+ "main": "dist/index.js",
31
31
  "module": "index.ts",
32
32
  "types": "./index.ts",
33
33
  "bin": {
34
- "claude-yes": "dist/cli.js"
34
+ "claude-yes": "dist/claude-yes.js",
35
+ "codex-yes": "dist/codex-yes.js",
36
+ "gemini-yes": "dist/gemini-yes.js",
37
+ "cursor-yes": "dist/cursor-yes.js",
38
+ "copilot-yes": "dist/copilot-yes.js"
35
39
  },
36
40
  "directories": {
37
41
  "doc": "docs"
@@ -41,22 +45,21 @@
41
45
  "dist"
42
46
  ],
43
47
  "scripts": {
44
- "build": "bun build index.ts cli.ts --outdir=dist --external=node-pty --external=bun-pty --target=node --sourcemap",
48
+ "build": "bun build index.ts cli.ts --packages=external --outdir=dist --target=node --sourcemap",
49
+ "postbuild": "bun ./postbuild.ts",
45
50
  "dev": "tsx index.ts",
46
- "fmt": "prettier -w .",
47
- "prepare": "husky",
51
+ "fmt": "bunx @biomejs/biome check --fix",
52
+ "prepack": "bun run build",
53
+ "prepare": "bunx husky",
48
54
  "test": "vitest"
49
55
  },
50
56
  "lint-staged": {
51
57
  "*.{ts,js,json,md}": [
52
- "prettier --write"
58
+ "bunx @biomejs/biome check --fix"
53
59
  ]
54
60
  },
55
- "dependencies": {
56
- "bun-pty": "^0.3.2",
57
- "node-pty": "^1.0.0"
58
- },
59
61
  "devDependencies": {
62
+ "@biomejs/biome": "^2.2.5",
60
63
  "@types/bun": "^1.2.18",
61
64
  "@types/jest": "^30.0.0",
62
65
  "@types/node": "^24.0.10",
@@ -66,7 +69,6 @@
66
69
  "from-node-stream": "^0.0.11",
67
70
  "husky": "^9.1.7",
68
71
  "lint-staged": "^16.1.4",
69
- "prettier": "^3.6.2",
70
72
  "rambda": "^10.3.2",
71
73
  "semantic-release": "^24.2.6",
72
74
  "sflow": "^1.20.2",
@@ -77,6 +79,12 @@
77
79
  "yargs": "^18.0.0"
78
80
  },
79
81
  "peerDependencies": {
80
- "typescript": "^5.8.3"
82
+ "typescript": "^5.8.3",
83
+ "node-pty": "^1.0.0"
84
+ },
85
+ "dependencies": {
86
+ "bun-pty": "^0.3.2",
87
+ "p-map": "^7.0.3",
88
+ "phpdie": "^1.7.0"
81
89
  }
82
90
  }
package/postbuild.ts ADDED
@@ -0,0 +1,6 @@
1
+ #! /usr/bin/env bun
2
+ import { copyFile } from 'fs/promises';
3
+ import * as pkg from './package.json';
4
+
5
+ const src = 'dist/cli.js';
6
+ await Promise.all(Object.values(pkg.bin).map((dst) => copyFile(src, dst)));
@@ -1,4 +1,7 @@
1
1
  export function removeControlCharacters(str: string): string {
2
- // Matches control characters in the C0 and C1 ranges, including Delete (U+007F)
3
- return str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
2
+ // Matches control characters in the C0 and C1 ranges, including Delete (U+007F)
3
+ return str.replace(
4
+ /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
5
+ '',
6
+ );
4
7
  }
package/sleep.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export function sleep(ms: number) {
2
- return new Promise(resolve => setTimeout(resolve, ms));
2
+ return new Promise((resolve) => setTimeout(resolve, ms));
3
3
  }
package/utils.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export function sleepms(ms: number) {
2
- return new Promise(resolve => setTimeout(resolve, ms));
2
+ return new Promise((resolve) => setTimeout(resolve, ms));
3
3
  }