agent-yes 1.118.0 → 1.118.1

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.
@@ -0,0 +1,8 @@
1
+ import "./ts-DSvAXKGk.js";
2
+ import "./logger-B9h0djqx.js";
3
+ import "./versionChecker-C40LF9-T.js";
4
+ import "./pidStore-B5vBu8Px.js";
5
+ import "./globalPidIndex-gZuTvTBs.js";
6
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-FpD7Ea6s.js";
7
+
8
+ export { SUPPORTED_CLIS };
@@ -1,8 +1,8 @@
1
- import { t as CLIS_CONFIG } from "./ts-DYzATaI_.js";
1
+ import { t as CLIS_CONFIG } from "./ts-DSvAXKGk.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-CrIGjD28.js.map
8
+ //# sourceMappingURL=SUPPORTED_CLIS-FpD7Ea6s.js.map
@@ -288,4 +288,4 @@ async function getDefaultConfig() {
288
288
 
289
289
  //#endregion
290
290
  export { agent_yes_config_default as default };
291
- //# sourceMappingURL=agent-yes.config-1LMoK18R.js.map
291
+ //# sourceMappingURL=agent-yes.config-kmtJKJHk.js.map
@@ -0,0 +1,25 @@
1
+ import { homedir } from "os";
2
+ import path from "path";
3
+
4
+ //#region ts/agentYesHome.ts
5
+ /**
6
+ * Root directory for cross-runtime, machine-global agent-yes state:
7
+ * the pid index (`pids.jsonl`), FIFO/named-pipe IPC endpoints (`fifo/`),
8
+ * winsize signals, notes, and the serve token.
9
+ *
10
+ * Durable per-session *logs* deliberately do NOT live here — they go under
11
+ * `<cwd>/.agent-yes/` so they stay colocated with the project that produced
12
+ * them (see `PidStore`). Only ephemeral IPC + the discovery index are global,
13
+ * which keeps FIFOs on the local home filesystem (reliable `mkfifo`) and lets
14
+ * `ay ls`/`ay attach` find every agent regardless of the caller's cwd.
15
+ *
16
+ * Resolved at call time (not module load) so tests and callers can override
17
+ * via `$AGENT_YES_HOME` without juggling the module cache.
18
+ */
19
+ function agentYesHome() {
20
+ return process.env.AGENT_YES_HOME ?? path.join(homedir(), ".agent-yes");
21
+ }
22
+
23
+ //#endregion
24
+ export { agentYesHome as t };
25
+ //# sourceMappingURL=agentYesHome-BvaUOzCV.js.map
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  import { n as logger } from "./logger-B9h0djqx.js";
3
- import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-D-OYziVA.js";
3
+ import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-C40LF9-T.js";
4
4
  import { argv } from "process";
5
5
  import { execFileSync, spawn } from "child_process";
6
6
  import ms from "ms";
@@ -482,7 +482,7 @@ function buildRustArgs(argv, cliFromScript, supportedClis) {
482
482
  {
483
483
  const rawArg = process.argv[2];
484
484
  const isHelpFlag = rawArg === "-h" || rawArg === "--help";
485
- const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-FtwGxxtc.js");
485
+ const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-Ca1GYIB2.js");
486
486
  if (isHelpFlag && process.argv.length === 3) {
487
487
  cmdHelp();
488
488
  process.exit(0);
@@ -496,12 +496,12 @@ await checkAndAutoUpdate();
496
496
  logger.info(versionString());
497
497
  const config = parseCliArgs(process.argv);
498
498
  if (config.tray) {
499
- const { startTray } = await import("./tray-CWQe9DMY.js");
499
+ const { startTray } = await import("./tray-B8_rx1iu.js");
500
500
  await startTray();
501
501
  await new Promise(() => {});
502
502
  }
503
503
  {
504
- const { ensureTray } = await import("./tray-CWQe9DMY.js");
504
+ const { ensureTray } = await import("./tray-B8_rx1iu.js");
505
505
  ensureTray();
506
506
  }
507
507
  if (config.useRust) {
@@ -515,7 +515,7 @@ if (config.useRust) {
515
515
  }
516
516
  }
517
517
  if (rustBinary) {
518
- const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-BS7EiXxW.js");
518
+ const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-Bx3xCmVR.js");
519
519
  const rustArgs = buildRustArgs(process.argv, config.cli, SUPPORTED_CLIS);
520
520
  if (config.verbose) {
521
521
  console.log(`[rust] Using binary: ${rustBinary}`);
@@ -545,7 +545,7 @@ if (config.showVersion) {
545
545
  process.exit(0);
546
546
  }
547
547
  if (config.appendPrompt) {
548
- const { PidStore } = await import("./pidStore-BLcnCpkX.js");
548
+ const { PidStore } = await import("./pidStore-7y1cTcAE.js");
549
549
  const ipcPath = await PidStore.findActiveFifo(process.cwd());
550
550
  if (!ipcPath) {
551
551
  console.error("No active agent with IPC found in current directory.");
@@ -189,4 +189,4 @@ async function pruneOldLogs(maxAgeMs = retentionMs()) {
189
189
 
190
190
  //#endregion
191
191
  export { updateGlobalPidStatus as a, readGlobalPids as i, maybeCompactGlobalPids as n, pruneOldLogs as r, appendGlobalPid as t };
192
- //# sourceMappingURL=globalPidIndex-yVd3mbsV.js.map
192
+ //# sourceMappingURL=globalPidIndex-gZuTvTBs.js.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-DYzATaI_.js";
1
+ import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-DSvAXKGk.js";
2
2
  import "./logger-B9h0djqx.js";
3
- import "./versionChecker-D-OYziVA.js";
4
- import "./pidStore-BcGnnKQf.js";
5
- import "./globalPidIndex-yVd3mbsV.js";
3
+ import "./versionChecker-C40LF9-T.js";
4
+ import "./pidStore-B5vBu8Px.js";
5
+ import "./globalPidIndex-gZuTvTBs.js";
6
6
 
7
7
  export { AgentContext, CLIS_CONFIG, config, agentYes as default, removeControlCharacters };
@@ -0,0 +1,5 @@
1
+ import "./logger-B9h0djqx.js";
2
+ import { t as PidStore } from "./pidStore-B5vBu8Px.js";
3
+ import "./globalPidIndex-gZuTvTBs.js";
4
+
5
+ export { PidStore };
@@ -1,31 +1,11 @@
1
1
  import { n as logger } from "./logger-B9h0djqx.js";
2
- import { a as updateGlobalPidStatus, n as maybeCompactGlobalPids, r as pruneOldLogs, t as appendGlobalPid } from "./globalPidIndex-yVd3mbsV.js";
2
+ import { t as agentYesHome } from "./agentYesHome-BvaUOzCV.js";
3
+ import { a as updateGlobalPidStatus, n as maybeCompactGlobalPids, r as pruneOldLogs, t as appendGlobalPid } from "./globalPidIndex-gZuTvTBs.js";
3
4
  import { closeSync, existsSync, fsyncSync, openSync } from "fs";
4
5
  import { appendFile, mkdir, readFile, rename, writeFile } from "fs/promises";
5
- import { homedir } from "os";
6
6
  import path from "path";
7
7
  import { lock } from "proper-lockfile";
8
8
 
9
- //#region ts/agentYesHome.ts
10
- /**
11
- * Root directory for cross-runtime, machine-global agent-yes state:
12
- * the pid index (`pids.jsonl`), FIFO/named-pipe IPC endpoints (`fifo/`),
13
- * winsize signals, notes, and the serve token.
14
- *
15
- * Durable per-session *logs* deliberately do NOT live here — they go under
16
- * `<cwd>/.agent-yes/` so they stay colocated with the project that produced
17
- * them (see `PidStore`). Only ephemeral IPC + the discovery index are global,
18
- * which keeps FIFOs on the local home filesystem (reliable `mkfifo`) and lets
19
- * `ay ls`/`ay attach` find every agent regardless of the caller's cwd.
20
- *
21
- * Resolved at call time (not module load) so tests and callers can override
22
- * via `$AGENT_YES_HOME` without juggling the module cache.
23
- */
24
- function agentYesHome() {
25
- return process.env.AGENT_YES_HOME ?? path.join(homedir(), ".agent-yes");
26
- }
27
-
28
- //#endregion
29
9
  //#region ts/JsonlStore.ts
30
10
  /**
31
11
  * A lightweight NeDB-style JSONL persistence layer.
@@ -381,5 +361,5 @@ pid-db/
381
361
  };
382
362
 
383
363
  //#endregion
384
- export { agentYesHome as n, PidStore as t };
385
- //# sourceMappingURL=pidStore-BcGnnKQf.js.map
364
+ export { PidStore as t };
365
+ //# sourceMappingURL=pidStore-B5vBu8Px.js.map
@@ -147,4 +147,4 @@ async function cmdRemote(rest) {
147
147
 
148
148
  //#endregion
149
149
  export { resolveRemoteSpec as a, readRemotes as i, deleteRemoteAlias as n, writeRemoteAlias as o, parseDirectRemoteSpec as r, cmdRemote as t };
150
- //# sourceMappingURL=remotes-C3xPRtfg.js.map
150
+ //# sourceMappingURL=remotes-BufkGk0e.js.map
@@ -1,3 +1,3 @@
1
- import { a as resolveRemoteSpec, i as readRemotes, n as deleteRemoteAlias, o as writeRemoteAlias, r as parseDirectRemoteSpec, t as cmdRemote } from "./remotes-C3xPRtfg.js";
1
+ import { a as resolveRemoteSpec, i as readRemotes, n as deleteRemoteAlias, o as writeRemoteAlias, r as parseDirectRemoteSpec, t as cmdRemote } from "./remotes-BufkGk0e.js";
2
2
 
3
3
  export { cmdRemote };
@@ -1,11 +1,11 @@
1
- import "./ts-DYzATaI_.js";
1
+ import "./ts-DSvAXKGk.js";
2
2
  import "./logger-B9h0djqx.js";
3
- import { r as getInstalledPackage } from "./versionChecker-D-OYziVA.js";
4
- import "./pidStore-BcGnnKQf.js";
5
- import "./globalPidIndex-yVd3mbsV.js";
6
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CrIGjD28.js";
7
- import "./remotes-C3xPRtfg.js";
8
- import { c as listRecords, d as renderRawLog, f as resolveOne, g as writeToIpc, m as snapshotStatus, r as controlCodeFromName, u as readNotes } from "./subcommands-tH8JdrBS.js";
3
+ import { r as getInstalledPackage } from "./versionChecker-C40LF9-T.js";
4
+ import "./pidStore-B5vBu8Px.js";
5
+ import "./globalPidIndex-gZuTvTBs.js";
6
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-FpD7Ea6s.js";
7
+ import "./remotes-BufkGk0e.js";
8
+ import { c as listRecords, d as renderRawLog, f as resolveOne, g as writeToIpc, m as snapshotStatus, r as controlCodeFromName, u as readNotes } from "./subcommands-3oALzYZW.js";
9
9
  import yargs from "yargs";
10
10
  import { mkdir, open, readFile, writeFile } from "fs/promises";
11
11
  import { homedir, hostname, userInfo } from "os";
@@ -758,7 +758,7 @@ Options:
758
758
  const webrtcVal = argv.webrtc ?? argv.share;
759
759
  const explicitUrl = typeof webrtcVal === "string" && webrtcVal.startsWith("webrtc://") ? webrtcVal : void 0;
760
760
  try {
761
- const { startShare, loadOrCreateShareRoom } = await import("./share-DwzKXEsJ.js");
761
+ const { startShare, loadOrCreateShareRoom } = await import("./share-BM-H85FE.js");
762
762
  const { link, close } = await startShare({
763
763
  url: explicitUrl ?? await loadOrCreateShareRoom(),
764
764
  localFetch: apiFetch,
@@ -789,4 +789,4 @@ Options:
789
789
 
790
790
  //#endregion
791
791
  export { cmdServe };
792
- //# sourceMappingURL=serve-uhfwjvBd.js.map
792
+ //# sourceMappingURL=serve-CBvx2LeV.js.map
@@ -0,0 +1,82 @@
1
+ import { t as agentYesHome } from "./agentYesHome-BvaUOzCV.js";
2
+ import { mkdirSync, readFileSync, writeFileSync } from "fs";
3
+ import { homedir } from "os";
4
+ import path from "path";
5
+ import { existsSync as existsSync$1 } from "node:fs";
6
+ import { stdin, stdout } from "node:process";
7
+ import { createInterface } from "node:readline/promises";
8
+
9
+ //#region ts/workspaceConfig.ts
10
+ function configPath() {
11
+ return path.join(agentYesHome(), "config.json");
12
+ }
13
+ function readConfig() {
14
+ try {
15
+ return JSON.parse(readFileSync(configPath(), "utf-8"));
16
+ } catch {
17
+ return {};
18
+ }
19
+ }
20
+ /** Expand a leading `~` (`~` or `~/x`) to an absolute home-based path. */
21
+ function expandTilde(p) {
22
+ const s = p.trim();
23
+ if (s === "~") return homedir();
24
+ if (s.startsWith("~/") || s.startsWith("~\\")) return path.join(homedir(), s.slice(2));
25
+ return s;
26
+ }
27
+ /** The configured workspace root (absolute), or the home dir if unset. */
28
+ function getWorkspaceRoot() {
29
+ const w = readConfig().workspace;
30
+ return w && w.trim() ? w : homedir();
31
+ }
32
+ /** Persist the workspace root, tilde-expanded and resolved to an absolute path. */
33
+ function setWorkspaceRoot(dir) {
34
+ const abs = path.resolve(expandTilde(dir));
35
+ const cfg = readConfig();
36
+ cfg.workspace = abs;
37
+ mkdirSync(agentYesHome(), { recursive: true });
38
+ writeFileSync(configPath(), JSON.stringify(cfg, null, 2));
39
+ return abs;
40
+ }
41
+
42
+ //#endregion
43
+ //#region ts/setup.ts
44
+ async function cmdSetup(rest) {
45
+ if (rest.includes("-h") || rest.includes("--help")) {
46
+ process.stdout.write("Usage: ay setup [workspace-dir] [--no-share] [--port N]\n\nGuided setup:\n 1. pick the workspace root new agents spawn into (default: your home dir)\n 2. share this machine to the agent-yes.com console (a restart-on-boot daemon)\n\nOptions:\n workspace-dir default directory for new agents (skips the prompt)\n --no-share set the workspace only; don't install the share daemon\n --port N HTTP API port for the share daemon (default: 7432)\n");
47
+ return 0;
48
+ }
49
+ const noShare = rest.includes("--no-share");
50
+ const portIdx = rest.indexOf("--port");
51
+ const port = portIdx >= 0 ? rest[portIdx + 1] : void 0;
52
+ let ws = rest.filter((a, i) => !a.startsWith("-") && i !== portIdx + 1)[0];
53
+ if (!ws) {
54
+ const current = getWorkspaceRoot();
55
+ if (stdin.isTTY && stdout.isTTY) {
56
+ const rl = createInterface({
57
+ input: stdin,
58
+ output: stdout
59
+ });
60
+ try {
61
+ ws = (await rl.question(`Workspace root for new agents [${current}]: `)).trim() || current;
62
+ } finally {
63
+ rl.close();
64
+ }
65
+ } else ws = current;
66
+ }
67
+ const abs = setWorkspaceRoot(ws);
68
+ process.stdout.write(`workspace root: ${abs}\n`);
69
+ if (!existsSync$1(abs)) process.stderr.write(` note: that directory doesn't exist yet — create it, or agents spawned there will fail\n`);
70
+ if (noShare) return 0;
71
+ process.stdout.write(`\nsharing this machine to agent-yes.com…\n`);
72
+ const { cmdServe } = await import("./serve-CBvx2LeV.js");
73
+ return cmdServe([
74
+ "install",
75
+ "--share",
76
+ ...port ? ["--port", port] : []
77
+ ]);
78
+ }
79
+
80
+ //#endregion
81
+ export { cmdSetup };
82
+ //# sourceMappingURL=setup-C7BNSEaG.js.map
@@ -215,4 +215,4 @@ async function startShare(opts) {
215
215
 
216
216
  //#endregion
217
217
  export { loadOrCreateShareRoom, startShare };
218
- //# sourceMappingURL=share-DwzKXEsJ.js.map
218
+ //# sourceMappingURL=share-BM-H85FE.js.map
@@ -1,5 +1,5 @@
1
- import { i as readGlobalPids } from "./globalPidIndex-yVd3mbsV.js";
2
- import { a as resolveRemoteSpec, i as readRemotes } from "./remotes-C3xPRtfg.js";
1
+ import { i as readGlobalPids } from "./globalPidIndex-gZuTvTBs.js";
2
+ import { a as resolveRemoteSpec, i as readRemotes } from "./remotes-BufkGk0e.js";
3
3
  import ms from "ms";
4
4
  import yargs from "yargs";
5
5
  import { appendFile, mkdir, open, readFile, stat, writeFile } from "fs/promises";
@@ -231,15 +231,15 @@ async function runSubcommand(argv) {
231
231
  case "restart": return await cmdRestart(rest);
232
232
  case "note": return await cmdNote(rest);
233
233
  case "serve": {
234
- const { cmdServe } = await import("./serve-uhfwjvBd.js");
234
+ const { cmdServe } = await import("./serve-CBvx2LeV.js");
235
235
  return cmdServe(rest);
236
236
  }
237
237
  case "setup": {
238
- const { cmdSetup } = await import("./setup.ts");
238
+ const { cmdSetup } = await import("./setup-C7BNSEaG.js");
239
239
  return cmdSetup(rest);
240
240
  }
241
241
  case "remote": {
242
- const { cmdRemote } = await import("./remotes-C9WMt5PY.js");
242
+ const { cmdRemote } = await import("./remotes-DavR4Hca.js");
243
243
  return cmdRemote(rest);
244
244
  }
245
245
  case "help": return cmdHelp();
@@ -1680,4 +1680,4 @@ async function cmdStatus(rest) {
1680
1680
 
1681
1681
  //#endregion
1682
1682
  export { finalizedLines as a, listRecords as c, renderRawLog as d, resolveOne as f, writeToIpc as g, stopTipForCli as h, cursorAbs as i, matchKeyword as l, snapshotStatus as m, cmdHelp as n, isPidAlive as o, runSubcommand as p, controlCodeFromName as r, isSubcommand as s, GRACEFUL_EXIT_COMMANDS as t, readNotes as u };
1683
- //# sourceMappingURL=subcommands-tH8JdrBS.js.map
1683
+ //# sourceMappingURL=subcommands-3oALzYZW.js.map
@@ -1,6 +1,6 @@
1
1
  import "./logger-B9h0djqx.js";
2
- import "./globalPidIndex-yVd3mbsV.js";
3
- import "./remotes-C3xPRtfg.js";
4
- import { a as finalizedLines, c as listRecords, d as renderRawLog, f as resolveOne, g as writeToIpc, h as stopTipForCli, i as cursorAbs, l as matchKeyword, m as snapshotStatus, n as cmdHelp, o as isPidAlive, p as runSubcommand, r as controlCodeFromName, s as isSubcommand, t as GRACEFUL_EXIT_COMMANDS, u as readNotes } from "./subcommands-tH8JdrBS.js";
2
+ import "./globalPidIndex-gZuTvTBs.js";
3
+ import "./remotes-BufkGk0e.js";
4
+ import { a as finalizedLines, c as listRecords, d as renderRawLog, f as resolveOne, g as writeToIpc, h as stopTipForCli, i as cursorAbs, l as matchKeyword, m as snapshotStatus, n as cmdHelp, o as isPidAlive, p as runSubcommand, r as controlCodeFromName, s as isSubcommand, t as GRACEFUL_EXIT_COMMANDS, u as readNotes } from "./subcommands-3oALzYZW.js";
5
5
 
6
6
  export { cmdHelp, isSubcommand, runSubcommand };
@@ -175,4 +175,4 @@ async function startTray() {
175
175
 
176
176
  //#endregion
177
177
  export { ensureTray, startTray };
178
- //# sourceMappingURL=tray-CWQe9DMY.js.map
178
+ //# sourceMappingURL=tray-B8_rx1iu.js.map
@@ -1,8 +1,9 @@
1
1
  import { n as logger, t as addTransport } from "./logger-B9h0djqx.js";
2
- import { r as getInstalledPackage } from "./versionChecker-D-OYziVA.js";
3
- import { n as agentYesHome, t as PidStore } from "./pidStore-BcGnnKQf.js";
2
+ import { r as getInstalledPackage } from "./versionChecker-C40LF9-T.js";
3
+ import { t as agentYesHome } from "./agentYesHome-BvaUOzCV.js";
4
4
  import { i as shouldUseLock, r as releaseLock, t as acquireLock } from "./runningLock-CJxsoGdb.js";
5
- import { i as readGlobalPids } from "./globalPidIndex-yVd3mbsV.js";
5
+ import { t as PidStore } from "./pidStore-B5vBu8Px.js";
6
+ import { i as readGlobalPids } from "./globalPidIndex-gZuTvTBs.js";
6
7
  import { arch, platform } from "process";
7
8
  import { execSync } from "child_process";
8
9
  import { closeSync, constants, createReadStream, existsSync, mkdirSync, openSync } from "fs";
@@ -1039,7 +1040,7 @@ async function notifyWebhook(status, details, cwd = process.cwd()) {
1039
1040
 
1040
1041
  //#endregion
1041
1042
  //#region ts/index.ts
1042
- const config = await import("./agent-yes.config-1LMoK18R.js").then((mod) => mod.default || mod);
1043
+ const config = await import("./agent-yes.config-kmtJKJHk.js").then((mod) => mod.default || mod);
1043
1044
  const CLIS_CONFIG = config.clis;
1044
1045
  /**
1045
1046
  * Main function to run agent-cli with automatic yes/no responses
@@ -1714,4 +1715,4 @@ function sleep(ms) {
1714
1715
 
1715
1716
  //#endregion
1716
1717
  export { removeControlCharacters as a, AgentContext as i, agentYes as n, config as r, CLIS_CONFIG as t };
1717
- //# sourceMappingURL=ts-DYzATaI_.js.map
1718
+ //# sourceMappingURL=ts-DSvAXKGk.js.map
@@ -7,7 +7,7 @@ import { fileURLToPath } from "url";
7
7
 
8
8
  //#region package.json
9
9
  var name = "agent-yes";
10
- var version = "1.118.0";
10
+ var version = "1.118.1";
11
11
 
12
12
  //#endregion
13
13
  //#region ts/versionChecker.ts
@@ -221,4 +221,4 @@ async function displayVersion() {
221
221
 
222
222
  //#endregion
223
223
  export { versionString as i, displayVersion as n, getInstalledPackage as r, checkAndAutoUpdate as t };
224
- //# sourceMappingURL=versionChecker-D-OYziVA.js.map
224
+ //# sourceMappingURL=versionChecker-C40LF9-T.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-yes",
3
- "version": "1.118.0",
3
+ "version": "1.118.1",
4
4
  "description": "A wrapper tool that automates interactions with various AI CLI tools by automatically handling common prompts and responses.",
5
5
  "keywords": [
6
6
  "ai",
@@ -0,0 +1,42 @@
1
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
+ import { mkdtempSync, rmSync } from "fs";
3
+ import { tmpdir } from "os";
4
+ import path from "path";
5
+ import { cmdSetup } from "./setup.ts";
6
+ import { getWorkspaceRoot } from "./workspaceConfig.ts";
7
+
8
+ // Guards against the regression where `ay setup` was registered + documented but
9
+ // its module was missing ("Cannot find module './setup.ts'"). Exercises the
10
+ // --no-share path only, so no daemon is installed.
11
+ describe("cmdSetup", () => {
12
+ let original: string | undefined;
13
+ let tmp: string;
14
+ beforeEach(() => {
15
+ original = process.env.AGENT_YES_HOME;
16
+ tmp = mkdtempSync(path.join(tmpdir(), "ay-setup-"));
17
+ process.env.AGENT_YES_HOME = tmp;
18
+ });
19
+ afterEach(() => {
20
+ if (original === undefined) delete process.env.AGENT_YES_HOME;
21
+ else process.env.AGENT_YES_HOME = original;
22
+ rmSync(tmp, { recursive: true, force: true });
23
+ });
24
+
25
+ it("--help returns 0 without touching config", async () => {
26
+ expect(await cmdSetup(["--help"])).toBe(0);
27
+ });
28
+
29
+ it("--no-share sets the workspace root and skips the daemon", async () => {
30
+ const dir = path.join(tmp, "myspace");
31
+ const code = await cmdSetup(["--no-share", dir]);
32
+ expect(code).toBe(0);
33
+ expect(getWorkspaceRoot()).toBe(path.resolve(dir));
34
+ });
35
+
36
+ it("--no-share with a --port flag still treats the path as the workspace", async () => {
37
+ const dir = path.join(tmp, "ws");
38
+ const code = await cmdSetup(["--no-share", "--port", "7440", dir]);
39
+ expect(code).toBe(0);
40
+ expect(getWorkspaceRoot()).toBe(path.resolve(dir));
41
+ });
42
+ });
package/ts/setup.ts ADDED
@@ -0,0 +1,67 @@
1
+ import { existsSync } from "node:fs";
2
+ import { stdin, stdout } from "node:process";
3
+ import { createInterface } from "node:readline/promises";
4
+ import { getWorkspaceRoot, setWorkspaceRoot } from "./workspaceConfig.ts";
5
+
6
+ // `ay setup` — guided onboarding. Two steps:
7
+ // 1. choose the workspace root (the default cwd new agents spawn into when the
8
+ // console doesn't pass one — see workspaceConfig), and
9
+ // 2. share this machine to the agent-yes.com console over WebRTC, installed as a
10
+ // restart-on-boot daemon (delegates to `ay serve install --share`).
11
+ //
12
+ // Designed to degrade gracefully: with a TTY it prompts (defaulting to the
13
+ // current/home workspace); piped or in a script it takes the first positional as
14
+ // the workspace and otherwise keeps the current one — never blocking on input.
15
+ export async function cmdSetup(rest: string[]): Promise<number> {
16
+ if (rest.includes("-h") || rest.includes("--help")) {
17
+ process.stdout.write(
18
+ `Usage: ay setup [workspace-dir] [--no-share] [--port N]\n\n` +
19
+ `Guided setup:\n` +
20
+ ` 1. pick the workspace root new agents spawn into (default: your home dir)\n` +
21
+ ` 2. share this machine to the agent-yes.com console (a restart-on-boot daemon)\n\n` +
22
+ `Options:\n` +
23
+ ` workspace-dir default directory for new agents (skips the prompt)\n` +
24
+ ` --no-share set the workspace only; don't install the share daemon\n` +
25
+ ` --port N HTTP API port for the share daemon (default: 7432)\n`,
26
+ );
27
+ return 0;
28
+ }
29
+
30
+ const noShare = rest.includes("--no-share");
31
+ const portIdx = rest.indexOf("--port");
32
+ const port = portIdx >= 0 ? rest[portIdx + 1] : undefined;
33
+ // The workspace is the first non-flag token (and not the value of --port).
34
+ const positional = rest.filter((a, i) => !a.startsWith("-") && i !== portIdx + 1);
35
+
36
+ // 1. Workspace root.
37
+ let ws = positional[0];
38
+ if (!ws) {
39
+ const current = getWorkspaceRoot();
40
+ if (stdin.isTTY && stdout.isTTY) {
41
+ const rl = createInterface({ input: stdin, output: stdout });
42
+ try {
43
+ const ans = (await rl.question(`Workspace root for new agents [${current}]: `)).trim();
44
+ ws = ans || current;
45
+ } finally {
46
+ rl.close();
47
+ }
48
+ } else {
49
+ ws = current; // non-interactive: keep whatever's configured (home by default)
50
+ }
51
+ }
52
+ const abs = setWorkspaceRoot(ws);
53
+ process.stdout.write(`workspace root: ${abs}\n`);
54
+ if (!existsSync(abs)) {
55
+ process.stderr.write(
56
+ ` note: that directory doesn't exist yet — create it, or agents spawned there will fail\n`,
57
+ );
58
+ }
59
+
60
+ if (noShare) return 0;
61
+
62
+ // 2. Share to agent-yes.com as a boot-persistent daemon. `ay serve install`
63
+ // handles oxmgr registration, version roll-forward, and printing the link.
64
+ process.stdout.write(`\nsharing this machine to agent-yes.com…\n`);
65
+ const { cmdServe } = await import("./serve.ts");
66
+ return cmdServe(["install", "--share", ...(port ? ["--port", port] : [])]);
67
+ }
@@ -1,8 +0,0 @@
1
- import "./ts-DYzATaI_.js";
2
- import "./logger-B9h0djqx.js";
3
- import "./versionChecker-D-OYziVA.js";
4
- import "./pidStore-BcGnnKQf.js";
5
- import "./globalPidIndex-yVd3mbsV.js";
6
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CrIGjD28.js";
7
-
8
- export { SUPPORTED_CLIS };
@@ -1,5 +0,0 @@
1
- import "./logger-B9h0djqx.js";
2
- import { t as PidStore } from "./pidStore-BcGnnKQf.js";
3
- import "./globalPidIndex-yVd3mbsV.js";
4
-
5
- export { PidStore };