@codeharbor/agent-playbook 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +39 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeharbor/agent-playbook",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "One-click installer and workflow fixer for agent-playbook across Claude Code and Codex.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
package/src/cli.js CHANGED
@@ -352,7 +352,16 @@ function createOverwriteState(options) {
352
352
  function promptYesNo(question, defaultYes) {
353
353
  const suffix = defaultYes ? "[Y/n]" : "[y/N]";
354
354
  process.stdout.write(`${question} ${suffix} `);
355
- const answer = readLineSync().toLowerCase();
355
+ let answer = "";
356
+ try {
357
+ answer = readLineSync().toLowerCase();
358
+ } catch (error) {
359
+ if (error && error.code === "EAGAIN") {
360
+ console.error("Warning: unable to read prompt input; skipping overwrite.");
361
+ return defaultYes;
362
+ }
363
+ throw error;
364
+ }
356
365
  if (!answer) {
357
366
  return defaultYes;
358
367
  }
@@ -362,8 +371,29 @@ function promptYesNo(question, defaultYes) {
362
371
  function readLineSync() {
363
372
  const buffer = Buffer.alloc(1024);
364
373
  let input = "";
374
+ const ttyPath = process.platform === "win32" ? null : "/dev/tty";
375
+ let fd = 0;
376
+ let shouldClose = false;
377
+
378
+ if (ttyPath) {
379
+ try {
380
+ fd = fs.openSync(ttyPath, "r");
381
+ shouldClose = true;
382
+ } catch (error) {
383
+ fd = 0;
384
+ }
385
+ }
386
+
365
387
  while (true) {
366
- const bytes = fs.readSync(0, buffer, 0, buffer.length, null);
388
+ let bytes = 0;
389
+ try {
390
+ bytes = fs.readSync(fd, buffer, 0, buffer.length, null);
391
+ } catch (error) {
392
+ if (error && error.code === "EAGAIN") {
393
+ continue;
394
+ }
395
+ throw error;
396
+ }
367
397
  if (bytes <= 0) {
368
398
  break;
369
399
  }
@@ -372,6 +402,13 @@ function readLineSync() {
372
402
  break;
373
403
  }
374
404
  }
405
+ if (shouldClose) {
406
+ try {
407
+ fs.closeSync(fd);
408
+ } catch (error) {
409
+ return input.trim();
410
+ }
411
+ }
375
412
  return input.trim();
376
413
  }
377
414