claude-yes 1.162.0 → 1.165.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.
@@ -1,8 +1,8 @@
1
- import { t as CLIS_CONFIG } from "./ts--UKFJGU-.js";
1
+ import { t as CLIS_CONFIG } from "./ts-jDEwTsVt.js";
2
2
 
3
3
  //#region ts/SUPPORTED_CLIS.ts
4
4
  const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
5
5
 
6
6
  //#endregion
7
7
  export { SUPPORTED_CLIS as t };
8
- //# sourceMappingURL=SUPPORTED_CLIS-BNLYYzBZ.js.map
8
+ //# sourceMappingURL=SUPPORTED_CLIS-H7IIw10E.js.map
@@ -0,0 +1,8 @@
1
+ import "./ts-jDEwTsVt.js";
2
+ import "./logger-CDIsZ-Pp.js";
3
+ import "./versionChecker-C0UJyFcN.js";
4
+ import "./pidStore-BfoBWUjc.js";
5
+ import "./globalPidIndex-DlmmJlO8.js";
6
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-H7IIw10E.js";
7
+
8
+ export { SUPPORTED_CLIS };
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  import { t as invokedCliName } from "./invokedCli-uqM2YYA7.js";
3
3
  import { n as logger } from "./logger-CDIsZ-Pp.js";
4
- import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-DJObC8O_.js";
4
+ import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-C0UJyFcN.js";
5
5
  import { argv } from "process";
6
6
  import { execFileSync, spawn } from "child_process";
7
7
  import ms from "ms";
@@ -481,7 +481,7 @@ function buildRustArgs(argv, cliFromScript, supportedClis) {
481
481
  const rawArg = process.argv[2];
482
482
  const managerCommands = !invokedCliName(process.argv);
483
483
  const isHelpFlag = rawArg === "-h" || rawArg === "--help";
484
- const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-DeW-4FGU.js");
484
+ const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-CIFWi9vq.js");
485
485
  if (isHelpFlag && process.argv.length === 3) {
486
486
  cmdHelp(managerCommands);
487
487
  process.exit(0);
@@ -514,7 +514,7 @@ if (config.useRust) {
514
514
  }
515
515
  }
516
516
  if (rustBinary) {
517
- const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-C9TQK7ME.js");
517
+ const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-dBgLp3mi.js");
518
518
  const rustArgs = buildRustArgs(process.argv, config.cli, SUPPORTED_CLIS);
519
519
  if (config.verbose) {
520
520
  console.log(`[rust] Using binary: ${rustBinary}`);
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts--UKFJGU-.js";
1
+ import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-jDEwTsVt.js";
2
2
  import "./logger-CDIsZ-Pp.js";
3
- import "./versionChecker-DJObC8O_.js";
3
+ import "./versionChecker-C0UJyFcN.js";
4
4
  import "./pidStore-BfoBWUjc.js";
5
5
  import "./globalPidIndex-DlmmJlO8.js";
6
6
 
@@ -1,9 +1,9 @@
1
- import "./ts--UKFJGU-.js";
1
+ import "./ts-jDEwTsVt.js";
2
2
  import "./logger-CDIsZ-Pp.js";
3
- import "./versionChecker-DJObC8O_.js";
3
+ import "./versionChecker-C0UJyFcN.js";
4
4
  import "./pidStore-BfoBWUjc.js";
5
5
  import "./globalPidIndex-DlmmJlO8.js";
6
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-BNLYYzBZ.js";
6
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-H7IIw10E.js";
7
7
  import { o as resolveSpawnCwd } from "./workspaceConfig-B0Q9-q2B.js";
8
8
  import { createHash } from "node:crypto";
9
9
 
@@ -141,4 +141,4 @@ async function cmdSchedule(rest) {
141
141
 
142
142
  //#endregion
143
143
  export { cmdSchedule };
144
- //# sourceMappingURL=schedule-DzFEVEoq.js.map
144
+ //# sourceMappingURL=schedule-BobQwIBS.js.map
@@ -1,16 +1,16 @@
1
- import "./ts--UKFJGU-.js";
1
+ import "./ts-jDEwTsVt.js";
2
2
  import "./logger-CDIsZ-Pp.js";
3
- import { r as getInstalledPackage } from "./versionChecker-DJObC8O_.js";
3
+ import { r as getInstalledPackage } from "./versionChecker-C0UJyFcN.js";
4
4
  import "./pidStore-BfoBWUjc.js";
5
5
  import { a as updateGlobalPidStatus } from "./globalPidIndex-DlmmJlO8.js";
6
6
  import { t as pgidForWrapper } from "./reaper-C-eWAxIj.js";
7
7
  import "./configShared-CEyhl0WH.js";
8
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-BNLYYzBZ.js";
8
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-H7IIw10E.js";
9
9
  import "./e2e-Bfw7qL9O.js";
10
10
  import "./webrtcLink-CBZkZ-LT.js";
11
11
  import "./remotes-DBCvpp3B.js";
12
12
  import { a as isProvisionAllowed, i as hasSpawnHook, n as getSpawnHook, o as resolveSpawnCwd, t as getProvisionRoot } from "./workspaceConfig-B0Q9-q2B.js";
13
- import { D as writeToIpc, T as snapshotStatus, _ as readPtysize, b as resolveOne, c as extractTaskCounts, g as readNotes, i as controlCodeFromName, m as listRecords, o as deriveLiveStatus, v as renderRawLog } from "./subcommands-CKMEWv6U.js";
13
+ import { A as writeToIpc, D as snapshotStatus, S as resolveOne, b as renderRawLog, c as extractNeedsInput, h as listRecords, i as controlCodeFromName, l as extractTaskCounts, o as deriveLiveStatus, v as readNotes, y as readPtysize } from "./subcommands-DtwxPMYe.js";
14
14
  import yargs from "yargs";
15
15
  import { mkdir, open, readFile, stat, unlink, writeFile } from "fs/promises";
16
16
  import { homedir, hostname, userInfo } from "os";
@@ -625,6 +625,24 @@ Options:
625
625
  return null;
626
626
  }
627
627
  };
628
+ const niCache = /* @__PURE__ */ new Map();
629
+ const logNeedsInput = async (logFile, cli) => {
630
+ if (!logFile) return null;
631
+ try {
632
+ const { size, mtimeMs } = await stat(logFile);
633
+ const hit = niCache.get(logFile);
634
+ if (hit && hit.size === size && hit.mtimeMs === mtimeMs) return hit.question;
635
+ const question = (await extractNeedsInput(logFile, cli))?.question ?? null;
636
+ niCache.set(logFile, {
637
+ size,
638
+ mtimeMs,
639
+ question
640
+ });
641
+ return question;
642
+ } catch {
643
+ return null;
644
+ }
645
+ };
628
646
  const GIT_DEBOUNCE_MS = 800;
629
647
  const GIT_SAFETY_MS = 6e4;
630
648
  const runGit = async (args, cwd) => {
@@ -643,17 +661,43 @@ Options:
643
661
  }
644
662
  };
645
663
  const parseGitStatus = (out) => {
646
- const lines = out.split("\n");
647
- const h = /^## (.+)$/.exec(lines[0] ?? "")?.[1] ?? "";
648
- const unborn = /^No commits yet on (.+)$/.exec(h);
649
- const branch = unborn ? unborn[1] : /^(.+?)(?:\.\.\.|\s|$)/.exec(h)?.[1] || null;
650
- const ahead = Number(/\bahead (\d+)/.exec(h)?.[1] ?? 0);
651
- const behind = Number(/\bbehind (\d+)/.exec(h)?.[1] ?? 0);
652
- const changed = lines.slice(1).filter((l) => l.trim().length > 0).length;
664
+ let branch = null;
665
+ let ahead = 0;
666
+ let behind = 0;
667
+ let changed = 0;
668
+ let pins = 0;
669
+ let subDirty = 0;
670
+ for (const line of out.split("\n")) {
671
+ if (line.length === 0) continue;
672
+ if (line[0] === "#") {
673
+ const head = /^# branch\.head (.+)$/.exec(line);
674
+ if (head) {
675
+ branch = head[1] === "(detached)" ? null : head[1];
676
+ continue;
677
+ }
678
+ const ab = /^# branch\.ab \+(\d+) -(\d+)/.exec(line);
679
+ if (ab) {
680
+ ahead = Number(ab[1]);
681
+ behind = Number(ab[2]);
682
+ }
683
+ continue;
684
+ }
685
+ const type = line[0];
686
+ if (type === "?") changed++;
687
+ else if (type === "u") changed++;
688
+ else if (type === "1" || type === "2") {
689
+ const sub = line.split(" ")[2] ?? "N...";
690
+ if (sub[0] === "S") if (sub[1] === "C") pins++;
691
+ else subDirty++;
692
+ else changed++;
693
+ }
694
+ }
653
695
  return {
654
696
  branch,
655
697
  dirty: changed > 0,
656
698
  changed,
699
+ pins,
700
+ subDirty,
657
701
  ahead,
658
702
  behind
659
703
  };
@@ -676,7 +720,7 @@ Options:
676
720
  try {
677
721
  const out = await runGit([
678
722
  "status",
679
- "--porcelain",
723
+ "--porcelain=v2",
680
724
  "--branch"
681
725
  ], root);
682
726
  if (out != null) rw.val = parseGitStatus(out);
@@ -717,9 +761,11 @@ Options:
717
761
  };
718
762
  const withMeta = async (r) => {
719
763
  const status = await deriveLiveStatus(r);
764
+ const question = status !== "exited" && !r.unresponsive ? await logNeedsInput(r.log_file, r.cli) : null;
720
765
  return {
721
766
  ...r,
722
- status: status !== "exited" && r.unresponsive ? "stuck" : status,
767
+ status: status === "exited" ? status : r.unresponsive ? "stuck" : question ? "needs_input" : status,
768
+ question,
723
769
  title: await logTitle(r.log_file),
724
770
  git: status === "exited" ? null : await gitStatus(r.cwd),
725
771
  tasks: status === "exited" ? null : await logTasks(r.log_file)
@@ -1396,4 +1442,4 @@ Options:
1396
1442
 
1397
1443
  //#endregion
1398
1444
  export { cmdServe };
1399
- //# sourceMappingURL=serve-BFnjq7JW.js.map
1445
+ //# sourceMappingURL=serve-DzOWMI_8.js.map
@@ -32,7 +32,7 @@ async function cmdSetup(rest) {
32
32
  if (!existsSync(abs)) process.stderr.write(` note: that directory doesn't exist yet — create it, or agents spawned there will fail\n`);
33
33
  if (noShare) return 0;
34
34
  process.stdout.write(`\nsharing this machine to agent-yes.com…\n`);
35
- const { cmdServe } = await import("./serve-BFnjq7JW.js");
35
+ const { cmdServe } = await import("./serve-DzOWMI_8.js");
36
36
  return cmdServe([
37
37
  "install",
38
38
  "--share",
@@ -42,4 +42,4 @@ async function cmdSetup(rest) {
42
42
 
43
43
  //#endregion
44
44
  export { cmdSetup };
45
- //# sourceMappingURL=setup-BmUQ_Zbt.js.map
45
+ //# sourceMappingURL=setup-tVfp7djj.js.map
@@ -0,0 +1,9 @@
1
+ import "./logger-CDIsZ-Pp.js";
2
+ import "./globalPidIndex-DlmmJlO8.js";
3
+ import "./configShared-CEyhl0WH.js";
4
+ import "./e2e-Bfw7qL9O.js";
5
+ import "./webrtcLink-CBZkZ-LT.js";
6
+ import "./remotes-DBCvpp3B.js";
7
+ import { A as writeToIpc, C as resolveReadWindow, D as snapshotStatus, E as runSubcommand, O as stopTipForCli, S as resolveOne, T as restartHintLines, _ as menuSelectKeys, a as cursorAbs, b as renderRawLog, c as extractNeedsInput, d as isAgentStuck, f as isExitRequest, g as matchKeyword, h as listRecords, i as controlCodeFromName, k as writeKeysPaced, l as extractTaskCounts, m as isSubcommand, n as READ_PAGE_DEFAULT, o as deriveLiveStatus, p as isPidAlive, r as cmdHelp, s as extractMenu, t as GRACEFUL_EXIT_COMMANDS, u as finalizedLines, v as readNotes, w as resolveResumeArgs, x as renderRawLogLines, y as readPtysize } from "./subcommands-DtwxPMYe.js";
8
+
9
+ export { cmdHelp, isSubcommand, runSubcommand };
@@ -183,6 +183,43 @@ function classifyNeedsInput(lines, cfg) {
183
183
  const end = Math.min(lines.length, last + 6);
184
184
  return { question: lines.slice(start, end).map((l) => l.trim()).filter((l) => l && !isChromeLine(l)).join(" • ").slice(0, 400) };
185
185
  }
186
+ const OPTION_LINE = /^[\s❯›>▶◉○●·*\-]*?(\d+)\.\s/;
187
+ /**
188
+ * Parse the selection menu a `needs_input` agent is parked on into a cursor
189
+ * position + the available option numbers, so a caller can compute how far the
190
+ * cursor must move (Down/Up) to reach a target option. Returns null when the
191
+ * screen isn't a menu (delegates that judgement to {@link classifyNeedsInput},
192
+ * so `working` still wins) or no numbered cursor line is found. Pure — the
193
+ * `ay select` action reuses the exact detection `ay ls` renders with.
194
+ */
195
+ function parseMenu(lines, cfg) {
196
+ const ni = classifyNeedsInput(lines, cfg);
197
+ if (!ni) return null;
198
+ const patterns = cfg.needsInput ?? [];
199
+ let cursorLine = -1;
200
+ for (let i = 0; i < lines.length; i++) if (patterns.some((re) => reTest(re, lines[i]))) cursorLine = i;
201
+ if (cursorLine < 0) return null;
202
+ const cm = /(\d+)\./.exec(lines[cursorLine]);
203
+ if (!cm) return null;
204
+ const cursor = parseInt(cm[1], 10);
205
+ const start = Math.max(0, cursorLine - 12);
206
+ const end = Math.min(lines.length, cursorLine + 12);
207
+ const options = [];
208
+ for (let i = start; i < end; i++) {
209
+ const m = OPTION_LINE.exec(lines[i]);
210
+ if (m) {
211
+ const v = parseInt(m[1], 10);
212
+ if (!options.includes(v)) options.push(v);
213
+ }
214
+ }
215
+ if (!options.includes(cursor)) options.push(cursor);
216
+ options.sort((a, b) => a - b);
217
+ return {
218
+ cursor,
219
+ options,
220
+ question: ni.question
221
+ };
222
+ }
186
223
  /**
187
224
  * True when the rendered screen still shows a "busy" marker (config `working`,
188
225
  * e.g. claude's `esc to interrupt`). Paired with a long-quiet log this is the
@@ -500,6 +537,8 @@ const SUBCOMMANDS = new Set([
500
537
  "tail",
501
538
  "head",
502
539
  "send",
540
+ "key",
541
+ "select",
503
542
  "spawn",
504
543
  "attach",
505
544
  "stop",
@@ -549,6 +588,8 @@ async function runSubcommand(argv) {
549
588
  case "tail": return await cmdRead(rest, { mode: "tail" });
550
589
  case "head": return await cmdRead(rest, { mode: "head" });
551
590
  case "send": return await cmdSend(rest);
591
+ case "key": return await cmdKey(rest);
592
+ case "select": return await cmdSelect(rest);
552
593
  case "spawn": return await cmdSpawn(rest);
553
594
  case "attach": return await cmdAttach(rest);
554
595
  case "stop": return await cmdStop(rest);
@@ -556,15 +597,15 @@ async function runSubcommand(argv) {
556
597
  case "restart": return await cmdRestart(rest);
557
598
  case "note": return await cmdNote(rest);
558
599
  case "serve": {
559
- const { cmdServe } = await import("./serve-BFnjq7JW.js");
600
+ const { cmdServe } = await import("./serve-DzOWMI_8.js");
560
601
  return cmdServe(rest);
561
602
  }
562
603
  case "setup": {
563
- const { cmdSetup } = await import("./setup-BmUQ_Zbt.js");
604
+ const { cmdSetup } = await import("./setup-tVfp7djj.js");
564
605
  return cmdSetup(rest);
565
606
  }
566
607
  case "schedule": {
567
- const { cmdSchedule } = await import("./schedule-DzFEVEoq.js");
608
+ const { cmdSchedule } = await import("./schedule-BobQwIBS.js");
568
609
  return cmdSchedule(rest);
569
610
  }
570
611
  case "remote": {
@@ -585,7 +626,7 @@ async function runSubcommand(argv) {
585
626
  }
586
627
  function cmdHelp(managerCommands = true) {
587
628
  const setupLine = managerCommands ? ` ay setup guided setup: pick a workspace, share to agent-yes.com\n` : ``;
588
- process.stdout.write("ay - agent-yes CLI\n\nManagement:\n ay ls [keyword] list running agents\n ay tail [-f] [-n N] <keyword> last N lines (96), -f to follow\n ay read <keyword> [page opts] paginate: --last/--head N, --range A:B,\n --before-line L [--limit N]\n ay cat <keyword> full log\n ay head <keyword> first N lines\n ay send <keyword> <msg> send a message\n ay attach <keyword> interactive attach (detach: Ctrl-\\)\n ay stop <keyword> graceful shutdown (/exit for claude/codex)\n ay exit <keyword> [reason] graceful shutdown, recording who/why (= 'ay send <kw> exit')\n ay restart <keyword> [--fresh] stop (if live) + relaunch resuming the session; --fresh replays the prompt\n ay status <keyword> agent status snapshot\n ay result <keyword> [--wait] pull an agent's structured result envelope\n ay result set '<json>' (inside an agent) deposit your result envelope\n ay reap kill process groups leaked by dead agents\n\nRemote:\n" + setupLine + " ay schedule <when> <cli> -- <msg> run an agent on a schedule (HH:MM or cron)\n ay serve [--port N] start HTTP API server (prints token)\n ay serve status show serve daemon/server status\n ay remote add <alias> http://<token>@<host>:<port>\n ay remote ls / rm <alias> manage saved remotes\n ay ls <token>@<host>:<port> connect inline (no alias needed)\n ay send <token>@<host>:<port>:<kw> <msg>\n\nRun an agent:\n ay [claude|codex|gemini|...] [options] -- [prompt]\n ay claude -- \"fix the bug in auth.ts\"\n ay claude --help full agent-runner options\n\nLabs (examples at https://github.com/snomiao/agent-yes/tree/main/lab):\n local-role-play/ designer + builder on one machine\n http-remote/ ay serve remote access demo\n p2p-pairing/ libp2p P2P (needs: cargo build --features swarm)\n");
629
+ process.stdout.write("ay - agent-yes CLI\n\nManagement:\n ay ls [keyword] list running agents\n ay tail [-f] [-n N] <keyword> last N lines (96), -f to follow\n ay read <keyword> [page opts] paginate: --last/--head N, --range A:B,\n --before-line L [--limit N]\n ay cat <keyword> full log\n ay head <keyword> first N lines\n ay send <keyword> <msg> send a message\n ay key <keyword> <key...> send raw keystrokes (down/up/enter/esc/…) — drives menus\n ay select <keyword> <N> pick option N of a needs_input selection menu\n ay attach <keyword> interactive attach (detach: Ctrl-\\)\n ay stop <keyword> graceful shutdown (/exit for claude/codex)\n ay exit <keyword> [reason] graceful shutdown, recording who/why (= 'ay send <kw> exit')\n ay restart <keyword> [--fresh] stop (if live) + relaunch resuming the session; --fresh replays the prompt\n ay status <keyword> agent status snapshot\n ay result <keyword> [--wait] pull an agent's structured result envelope\n ay result set '<json>' (inside an agent) deposit your result envelope\n ay reap kill process groups leaked by dead agents\n\nRemote:\n" + setupLine + " ay schedule <when> <cli> -- <msg> run an agent on a schedule (HH:MM or cron)\n ay serve [--port N] start HTTP API server (prints token)\n ay serve status show serve daemon/server status\n ay remote add <alias> http://<token>@<host>:<port>\n ay remote ls / rm <alias> manage saved remotes\n ay ls <token>@<host>:<port> connect inline (no alias needed)\n ay send <token>@<host>:<port>:<kw> <msg>\n\nRun an agent:\n ay [claude|codex|gemini|...] [options] -- [prompt]\n ay claude -- \"fix the bug in auth.ts\"\n ay claude --help full agent-runner options\n\nLabs (examples at https://github.com/snomiao/agent-yes/tree/main/lab):\n local-role-play/ designer + builder on one machine\n http-remote/ ay serve remote access demo\n p2p-pairing/ libp2p P2P (needs: cargo build --features swarm)\n");
589
630
  return 0;
590
631
  }
591
632
  function matchKeyword(record, keyword) {
@@ -1895,6 +1936,71 @@ async function cmdSpawn(rest) {
1895
1936
  prompt: prompt || void 0
1896
1937
  });
1897
1938
  }
1939
+ /**
1940
+ * Shared safety gate for every command that writes to a live agent's stdin
1941
+ * (`send`, `key`, `select`): refuse a self-targeting loop, and require that THIS
1942
+ * sender actually looked at THIS target recently — an agent is blocked, an
1943
+ * interactive human is only warned — unless `force`. Returns the sender context
1944
+ * so a caller can reuse it (e.g. `send`'s `[from …]` prefix). Extracted from
1945
+ * cmdSend so the action commands enforce the identical guard.
1946
+ */
1947
+ async function enforceSendGuards(record, force) {
1948
+ const sender = await senderContext();
1949
+ if (sender.agent && sender.agent.pid === record.pid && !force) throw new Error(`refusing to send to yourself (pid ${record.pid}) — pass --force if you really mean it.`);
1950
+ const last = await lastReadAt(sender.key, record.pid);
1951
+ if (!(last !== null && Date.now() - last <= READ_WINDOW_MS) && !force) {
1952
+ const ago = last === null ? "never read" : `last read ${Math.round((Date.now() - last) / 1e3)}s ago`;
1953
+ const what = `pid ${record.pid} (${record.cli}, ${shortenPath(record.cwd)}) — ${ago}, not within ${READ_WINDOW_MS / 1e3}s`;
1954
+ if (sender.agent) throw new Error(`${what}.\n Confirm it's the right agent first: ay tail ${record.pid}\n then resend, or pass --force to override.`);
1955
+ process.stderr.write(`warning: ${what} — make sure this is the agent you meant (ay tail ${record.pid}).\n`);
1956
+ }
1957
+ return sender;
1958
+ }
1959
+ const KEY_PACE_MS = 40;
1960
+ /**
1961
+ * The named-key sequence that moves a menu cursor from `cursor` to option
1962
+ * `target` and confirms: |Δ| Downs (target below) or Ups (target above), then
1963
+ * Enter. Pure so the arrow arithmetic is unit-tested independent of any live PTY.
1964
+ */
1965
+ function menuSelectKeys(cursor, target) {
1966
+ const delta = target - cursor;
1967
+ return [...Array(Math.abs(delta)).fill(delta > 0 ? "down" : "up"), "enter"];
1968
+ }
1969
+ /** Write each already-encoded key sequence to the FIFO with a pace gap between
1970
+ * them (no gap after the last). Raw bytes, no `[from]` framing, no auto-Enter. */
1971
+ async function writeKeysPaced(fifoPath, byteSeqs, paceMs) {
1972
+ for (let i = 0; i < byteSeqs.length; i++) {
1973
+ if (byteSeqs[i] === "") continue;
1974
+ await writeToIpc(fifoPath, byteSeqs[i]);
1975
+ if (i < byteSeqs.length - 1 && paceMs > 0) await new Promise((r) => setTimeout(r, paceMs));
1976
+ }
1977
+ }
1978
+ /**
1979
+ * The selection menu a needs_input agent is parked on, or null when it isn't on
1980
+ * one. Mirrors extractNeedsInput (same 32 KB tail render + config patterns) but
1981
+ * returns the cursor position + option numbers so `ay select` can compute the
1982
+ * cursor delta.
1983
+ */
1984
+ async function extractMenu(logPath, cli) {
1985
+ const cfg = (await cliDefaults())[cli];
1986
+ if (!cfg?.needsInput?.length) return null;
1987
+ const lines = await renderLogTailLines(logPath, 40);
1988
+ if (!lines) return null;
1989
+ return parseMenu(lines, {
1990
+ needsInput: cfg.needsInput,
1991
+ working: cfg.working
1992
+ });
1993
+ }
1994
+ /** Poll until the agent is no longer parked on a menu (selection accepted → it
1995
+ * resumed / moved on) or the deadline passes. Returns true if it cleared. */
1996
+ async function waitForNeedsInputClear(record, timeoutMs) {
1997
+ const deadline = Date.now() + timeoutMs;
1998
+ while (Date.now() < deadline) {
1999
+ await new Promise((r) => setTimeout(r, 250));
2000
+ if ((await snapshotStatus(record)).state !== "needs_input") return true;
2001
+ }
2002
+ return false;
2003
+ }
1898
2004
  async function cmdSend(rest) {
1899
2005
  const argv = await yargs(rest).usage("Usage: ay send <keyword> <msg|-> [options]").option("code", {
1900
2006
  type: "string",
@@ -1941,16 +2047,7 @@ async function cmdSend(rest) {
1941
2047
  for await (const chunk of process.stdin) chunks.push(chunk);
1942
2048
  body = Buffer.concat(chunks).toString("utf-8").trimEnd();
1943
2049
  } else body = rawMessage;
1944
- const sender = await senderContext();
1945
- const force = Boolean(argv.force) || process.env.AGENT_YES_FORCE_SEND === "1";
1946
- if (sender.agent && sender.agent.pid === record.pid && !force) throw new Error(`refusing to send to yourself (pid ${record.pid}) — pass --force if you really mean it.`);
1947
- const last = await lastReadAt(sender.key, record.pid);
1948
- if (!(last !== null && Date.now() - last <= READ_WINDOW_MS) && !force) {
1949
- const ago = last === null ? "never read" : `last read ${Math.round((Date.now() - last) / 1e3)}s ago`;
1950
- const what = `pid ${record.pid} (${record.cli}, ${shortenPath(record.cwd)}) — ${ago}, not within ${READ_WINDOW_MS / 1e3}s`;
1951
- if (sender.agent) throw new Error(`${what}.\n Confirm it's the right agent first: ay tail ${record.pid}\n then resend, or pass --force to override.`);
1952
- process.stderr.write(`warning: ${what} — make sure this is the agent you meant (ay tail ${record.pid}).\n`);
1953
- }
2050
+ const sender = await enforceSendGuards(record, Boolean(argv.force) || process.env.AGENT_YES_FORCE_SEND === "1");
1954
2051
  if (isExitRequest(body)) {
1955
2052
  const reason = sender.agent ? `requested by ${sender.agent.cli} #${sender.agent.pid} @ ${shortenPath(sender.agent.cwd)}` : `requested via 'ay send ${keyword} exit'`;
1956
2053
  const { strategy } = await gracefulExitAgent(record, reason);
@@ -1973,6 +2070,104 @@ async function cmdSend(rest) {
1973
2070
  }
1974
2071
  return 0;
1975
2072
  }
2073
+ async function resolveWritableAgent(keyword, opts) {
2074
+ const record = await resolveOne(keyword, opts);
2075
+ if (!record.fifo_file) throw new Error(`pid ${record.pid}: no fifo_file recorded — this agent didn't register a stdin FIFO (an older agent, or one not started with --stdpush). Restarting it (ay restart ${record.pid}) re-registers one.`);
2076
+ return record;
2077
+ }
2078
+ async function cmdKey(rest) {
2079
+ const argv = await yargs(rest).usage("Usage: ay key <keyword> <key...> [options]\n\nSend raw named keystrokes to a live agent's TUI — no message framing, no\nauto-Enter. Drives selection menus and other interactive prompts that a\nplain `ay send` (text + Enter) can't. Keys are paced so the CLI registers\neach as a discrete event, not a paste.\n\nKeys: up down left right enter esc tab space backspace delete home end\n pageup pagedown ctrl-c ctrl-d ctrl-y raw:0xNN\n\nExamples:\n ay key 1234 down down enter # move the menu cursor down twice, confirm\n ay key 1234 esc # dismiss a menu\n ay key 1234 raw:0x1b # a literal ESC byte").option("pace", {
2080
+ type: "number",
2081
+ default: KEY_PACE_MS,
2082
+ description: "ms between keystrokes"
2083
+ }).option("all", {
2084
+ type: "boolean",
2085
+ default: false,
2086
+ description: "Include exited agents"
2087
+ }).option("latest", {
2088
+ type: "boolean",
2089
+ default: false,
2090
+ description: "Use most recent match"
2091
+ }).option("cwd", {
2092
+ type: "string",
2093
+ description: "Restrict to agents under this dir"
2094
+ }).option("force", {
2095
+ type: "boolean",
2096
+ default: false,
2097
+ description: "Skip the recency/self-send guard (also: AGENT_YES_FORCE_SEND=1)"
2098
+ }).help(false).version(false).exitProcess(false).parseAsync();
2099
+ const keyword = argv._[0] !== void 0 ? String(argv._[0]) : void 0;
2100
+ const keyNames = argv._.slice(1).map(String);
2101
+ if (!keyword || keyNames.length === 0) throw new Error("usage: ay key <keyword> <key...> (e.g. ay key 1234 down down enter)");
2102
+ const byteSeqs = keyNames.map((n) => controlCodeFromName(n.toLowerCase()));
2103
+ const record = await resolveWritableAgent(keyword, {
2104
+ all: argv.all,
2105
+ active: false,
2106
+ json: false,
2107
+ latest: argv.latest,
2108
+ cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
2109
+ });
2110
+ await enforceSendGuards(record, Boolean(argv.force) || process.env.AGENT_YES_FORCE_SEND === "1");
2111
+ await writeKeysPaced(record.fifo_file, byteSeqs, Math.max(0, argv.pace));
2112
+ process.stdout.write(`sent to pid ${record.pid} (${record.cli}): ${keyNames.join(" ")}\n`);
2113
+ return 0;
2114
+ }
2115
+ async function cmdSelect(rest) {
2116
+ const argv = await yargs(rest).usage("Usage: ay select <keyword> <N> [options]\n\nPick option N of the selection menu a needs_input agent is parked on.\nRe-parses the live menu (the same ❯-cursor detection `ay ls` uses), computes\nhow far the cursor must move, and sends that many Down/Up keys + Enter — so\nit's robust to a pre-highlighted default (never assumes the cursor starts at 1)\nand doesn't rely on numeric hotkeys (arrow-driven menus ignore them).\n\nExamples:\n ay select 1234 2 # choose option 2\n ay select 1234 2 --wait # …and block until the menu clears").option("pace", {
2117
+ type: "number",
2118
+ default: KEY_PACE_MS,
2119
+ description: "ms between keystrokes"
2120
+ }).option("wait", {
2121
+ type: "boolean",
2122
+ default: false,
2123
+ description: "Block until the agent leaves needs_input (or --timeout)"
2124
+ }).option("timeout", {
2125
+ type: "number",
2126
+ default: 10,
2127
+ description: "Seconds to wait with --wait"
2128
+ }).option("all", {
2129
+ type: "boolean",
2130
+ default: false,
2131
+ description: "Include exited agents"
2132
+ }).option("latest", {
2133
+ type: "boolean",
2134
+ default: false,
2135
+ description: "Use most recent match"
2136
+ }).option("cwd", {
2137
+ type: "string",
2138
+ description: "Restrict to agents under this dir"
2139
+ }).option("force", {
2140
+ type: "boolean",
2141
+ default: false,
2142
+ description: "Skip the recency/self-send guard (also: AGENT_YES_FORCE_SEND=1)"
2143
+ }).help(false).version(false).exitProcess(false).parseAsync();
2144
+ const keyword = argv._[0] !== void 0 ? String(argv._[0]) : void 0;
2145
+ const n = Number(argv._[1]);
2146
+ if (!keyword || !Number.isInteger(n) || n < 1) throw new Error("usage: ay select <keyword> <N> (N = the 1-based option number to choose)");
2147
+ const record = await resolveWritableAgent(keyword, {
2148
+ all: argv.all,
2149
+ active: false,
2150
+ json: false,
2151
+ latest: argv.latest,
2152
+ cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null
2153
+ });
2154
+ if (!record.log_file) throw new Error(`pid ${record.pid}: no log_file recorded — can't read the menu to select from.`);
2155
+ await enforceSendGuards(record, Boolean(argv.force) || process.env.AGENT_YES_FORCE_SEND === "1");
2156
+ const menu = await extractMenu(record.log_file, record.cli);
2157
+ if (!menu) throw new Error(`pid ${record.pid} (${record.cli}) is not parked on a selection menu (not needs_input).\n Check with: ay status ${record.pid}`);
2158
+ if (menu.options.length > 0 && !menu.options.includes(n)) throw new Error(`option ${n} is out of range — this menu offers ${menu.options.join(", ")}.`);
2159
+ const byteSeqs = menuSelectKeys(menu.cursor, n).map((k) => controlCodeFromName(k));
2160
+ await writeKeysPaced(record.fifo_file, byteSeqs, Math.max(0, argv.pace));
2161
+ const delta = n - menu.cursor;
2162
+ const moved = delta === 0 ? "cursor already there" : `${Math.abs(delta)}× ${delta > 0 ? "down" : "up"}`;
2163
+ process.stdout.write(`pid ${record.pid} (${record.cli}): selected option ${n} (${moved} + enter)\n`);
2164
+ if (argv.wait) {
2165
+ const ok = await waitForNeedsInputClear(record, Math.max(1, argv.timeout) * 1e3);
2166
+ process.stdout.write(ok ? ` menu cleared — selection accepted.\n` : ` still needs_input after ${argv.timeout}s — re-check with 'ay status ${record.pid}'.\n`);
2167
+ return ok ? 0 : 1;
2168
+ }
2169
+ return 0;
2170
+ }
1976
2171
  function stopTipForCli(cli, pid) {
1977
2172
  const cmd = GRACEFUL_EXIT_COMMANDS[cli];
1978
2173
  if (cmd) return ` tip: ${cli} ignores a single Ctrl+C — try 'ay stop ${pid}' (sends '${cmd}') or double Ctrl+C.\n`;
@@ -2000,12 +2195,27 @@ function controlCodeFromName(name) {
2000
2195
  case "ctrl\\":
2001
2196
  case "ctrl-backslash": return "";
2002
2197
  case "tab": return " ";
2198
+ case "up": return "\x1B[A";
2199
+ case "down": return "\x1B[B";
2200
+ case "right": return "\x1B[C";
2201
+ case "left": return "\x1B[D";
2202
+ case "home": return "\x1B[H";
2203
+ case "end": return "\x1B[F";
2204
+ case "pageup":
2205
+ case "pgup": return "\x1B[5~";
2206
+ case "pagedown":
2207
+ case "pgdn": return "\x1B[6~";
2208
+ case "space": return " ";
2209
+ case "backspace":
2210
+ case "bs": return "";
2211
+ case "delete":
2212
+ case "del": return "\x1B[3~";
2003
2213
  case "none":
2004
2214
  case "": return "";
2005
2215
  default:
2006
2216
  const m = /^raw:0x([0-9a-f]+)$/i.exec(name);
2007
2217
  if (m) return String.fromCharCode(parseInt(m[1], 16));
2008
- throw new Error(`unknown --code=${name}`);
2218
+ throw new Error(`unknown key/code: ${name}`);
2009
2219
  }
2010
2220
  }
2011
2221
  async function writeToIpc(ipcPath, payload) {
@@ -2794,5 +3004,5 @@ async function cmdResultSet(rest) {
2794
3004
  }
2795
3005
 
2796
3006
  //#endregion
2797
- export { restartHintLines as C, writeToIpc as D, stopTipForCli as E, resolveResumeArgs as S, snapshotStatus as T, readPtysize as _, cursorAbs as a, resolveOne as b, extractTaskCounts as c, isExitRequest as d, isPidAlive as f, readNotes as g, matchKeyword as h, controlCodeFromName as i, finalizedLines as l, listRecords as m, READ_PAGE_DEFAULT as n, deriveLiveStatus as o, isSubcommand as p, cmdHelp as r, extractNeedsInput as s, GRACEFUL_EXIT_COMMANDS as t, isAgentStuck as u, renderRawLog as v, runSubcommand as w, resolveReadWindow as x, renderRawLogLines as y };
2798
- //# sourceMappingURL=subcommands-CKMEWv6U.js.map
3007
+ export { writeToIpc as A, resolveReadWindow as C, snapshotStatus as D, runSubcommand as E, stopTipForCli as O, resolveOne as S, restartHintLines as T, menuSelectKeys as _, cursorAbs as a, renderRawLog as b, extractNeedsInput as c, isAgentStuck as d, isExitRequest as f, matchKeyword as g, listRecords as h, controlCodeFromName as i, writeKeysPaced as k, extractTaskCounts as l, isSubcommand as m, READ_PAGE_DEFAULT as n, deriveLiveStatus as o, isPidAlive as p, cmdHelp as r, extractMenu as s, GRACEFUL_EXIT_COMMANDS as t, finalizedLines as u, readNotes as v, resolveResumeArgs as w, renderRawLogLines as x, readPtysize as y };
3008
+ //# sourceMappingURL=subcommands-DtwxPMYe.js.map
@@ -1,5 +1,5 @@
1
1
  import { n as logger, t as addTransport } from "./logger-CDIsZ-Pp.js";
2
- import { r as getInstalledPackage } from "./versionChecker-DJObC8O_.js";
2
+ import { r as getInstalledPackage } from "./versionChecker-C0UJyFcN.js";
3
3
  import { t as agentYesHome } from "./agentYesHome-_eJa3DaX.js";
4
4
  import { i as shouldUseLock, r as releaseLock, t as acquireLock } from "./runningLock-V4qvXgAw.js";
5
5
  import { t as PidStore } from "./pidStore-BfoBWUjc.js";
@@ -1803,4 +1803,4 @@ function sleep(ms) {
1803
1803
 
1804
1804
  //#endregion
1805
1805
  export { removeControlCharacters as a, AgentContext as i, agentYes as n, config as r, CLIS_CONFIG as t };
1806
- //# sourceMappingURL=ts--UKFJGU-.js.map
1806
+ //# sourceMappingURL=ts-jDEwTsVt.js.map
@@ -7,7 +7,7 @@ import { fileURLToPath } from "url";
7
7
 
8
8
  //#region package.json
9
9
  var name = "claude-yes";
10
- var version = "1.162.0";
10
+ var version = "1.165.0";
11
11
 
12
12
  //#endregion
13
13
  //#region ts/versionChecker.ts
@@ -215,4 +215,4 @@ async function displayVersion() {
215
215
 
216
216
  //#endregion
217
217
  export { versionString as i, displayVersion as n, getInstalledPackage as r, checkAndAutoUpdate as t };
218
- //# sourceMappingURL=versionChecker-DJObC8O_.js.map
218
+ //# sourceMappingURL=versionChecker-C0UJyFcN.js.map
@@ -153,14 +153,19 @@ export function tagsFor(e) {
153
153
  }
154
154
 
155
155
  // Compact git indicator from the record's `git` snapshot (server-side
156
- // `git status --porcelain --branch`): "±3" changed files, "↑1" ahead, "↓2"
157
- // behind. Returns "" when there's no git info or the tree is clean and in sync,
158
- // so a tidy repo adds no noise. Branch itself is shown via the path identity.
156
+ // `git status --porcelain=v2 --branch`): "±3" real changed files, "2"
157
+ // submodule pin-bumps, "⊙1" submodule internal dirt, "↑1" ahead, "↓2" behind.
158
+ // Pins/sub-dirt are split out of "±" so submodule drift (constant in a repo with
159
+ // many submodules) never buries the real file edits. Returns "" when there's no
160
+ // git info or the tree is clean and in sync, so a tidy repo adds no noise. Branch
161
+ // itself is shown via the path identity.
159
162
  export function gitLabel(e) {
160
163
  const g = e.git;
161
164
  if (!g) return "";
162
165
  const parts = [];
163
166
  if (g.changed > 0) parts.push("±" + g.changed);
167
+ if (g.pins > 0) parts.push("⑂" + g.pins);
168
+ if (g.subDirty > 0) parts.push("⊙" + g.subDirty);
164
169
  if (g.ahead > 0) parts.push("↑" + g.ahead);
165
170
  if (g.behind > 0) parts.push("↓" + g.behind);
166
171
  return parts.join(" ");
@@ -521,10 +526,21 @@ export function fitTransform(gridW, gridH, paneW, paneH) {
521
526
 
522
527
  // Browser-tab title: "<glyph> <selected agent title> - agent-yes", or the bare
523
528
  // console title when nothing is selected (blank/whitespace name). The leading
524
- // glyph mirrors the agent's status dot — active, idle, exited — so the tab
525
- // shows liveness at a glance; an unknown status adds no glyph.
529
+ // glyph mirrors the agent's status dot — needs_input ("your turn"), stuck,
530
+ // ● active, ○ idle, ✗ exited — so the tab shows liveness at a glance even in a
531
+ // background tab; an unknown status adds no glyph.
526
532
  export function statusGlyph(status) {
527
- return status === "active" ? "●" : status === "idle" ? "○" : status === "exited" ? "✗" : "";
533
+ return status === "needs_input"
534
+ ? "⌨"
535
+ : status === "stuck"
536
+ ? "⚠"
537
+ : status === "active"
538
+ ? "●"
539
+ : status === "idle"
540
+ ? "○"
541
+ : status === "exited"
542
+ ? "✗"
543
+ : "";
528
544
  }
529
545
  export function docTitle(name, status) {
530
546
  const n = name && String(name).trim();