claude-yes 1.73.0 → 1.74.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.
@@ -38,6 +38,30 @@
38
38
  }
39
39
  },
40
40
  "definitions": {
41
+ "RegexSource": {
42
+ "description": "Regex source as a raw pattern string or a structured object with explicit flags",
43
+ "oneOf": [
44
+ {
45
+ "type": "string",
46
+ "description": "Regex pattern source text"
47
+ },
48
+ {
49
+ "type": "object",
50
+ "properties": {
51
+ "pattern": {
52
+ "type": "string",
53
+ "description": "Regex pattern source text"
54
+ },
55
+ "flags": {
56
+ "type": "string",
57
+ "description": "Regex flags such as 'm' or 'im'"
58
+ }
59
+ },
60
+ "required": ["pattern"],
61
+ "additionalProperties": false
62
+ }
63
+ ]
64
+ },
41
65
  "AgentCliConfig": {
42
66
  "type": "object",
43
67
  "description": "Configuration for a specific CLI tool",
@@ -77,17 +101,17 @@
77
101
  },
78
102
  "ready": {
79
103
  "type": "array",
80
- "items": { "type": "string" },
104
+ "items": { "$ref": "#/definitions/RegexSource" },
81
105
  "description": "Regex patterns to detect when CLI is ready for input. Set to [] to disable ready check."
82
106
  },
83
107
  "fatal": {
84
108
  "type": "array",
85
- "items": { "type": "string" },
109
+ "items": { "$ref": "#/definitions/RegexSource" },
86
110
  "description": "Regex patterns to detect fatal errors that should stop execution"
87
111
  },
88
112
  "working": {
89
113
  "type": "array",
90
- "items": { "type": "string" },
114
+ "items": { "$ref": "#/definitions/RegexSource" },
91
115
  "description": "Regex patterns to detect when CLI is currently processing"
92
116
  },
93
117
  "exitCommands": {
@@ -106,12 +130,12 @@
106
130
  },
107
131
  "enter": {
108
132
  "type": "array",
109
- "items": { "type": "string" },
133
+ "items": { "$ref": "#/definitions/RegexSource" },
110
134
  "description": "Regex patterns that trigger automatic Enter key press"
111
135
  },
112
136
  "enterExclude": {
113
137
  "type": "array",
114
- "items": { "type": "string" },
138
+ "items": { "$ref": "#/definitions/RegexSource" },
115
139
  "description": "Regex patterns to exclude from auto-enter (even if 'enter' matches)"
116
140
  },
117
141
  "typingRespond": {
@@ -119,7 +143,7 @@
119
143
  "description": "Map of responses to type when specific patterns are matched",
120
144
  "additionalProperties": {
121
145
  "type": "array",
122
- "items": { "type": "string" },
146
+ "items": { "$ref": "#/definitions/RegexSource" },
123
147
  "description": "Regex patterns that trigger this response"
124
148
  },
125
149
  "examples": [
@@ -134,7 +158,7 @@
134
158
  },
135
159
  "restartWithoutContinueArg": {
136
160
  "type": "array",
137
- "items": { "type": "string" },
161
+ "items": { "$ref": "#/definitions/RegexSource" },
138
162
  "description": "Regex patterns for errors that require restart WITHOUT continue args"
139
163
  },
140
164
  "bunx": {
@@ -155,7 +179,7 @@
155
179
  },
156
180
  "updateAvailable": {
157
181
  "type": "array",
158
- "items": { "type": "string" },
182
+ "items": { "$ref": "#/definitions/RegexSource" },
159
183
  "description": "Regex patterns to detect update available messages"
160
184
  }
161
185
  },
@@ -0,0 +1,154 @@
1
+ clis:
2
+ claude:
3
+ promptArg: last-arg
4
+ systemPrompt: --append-system-prompt
5
+ install:
6
+ powershell: 'powershell -Command "irm https://claude.ai/install.ps1 | iex"'
7
+ bash: "curl -fsSL https://claude.ai/install.sh | bash"
8
+ npm: "npm i -g @anthropic-ai/claude-code@latest"
9
+ ready:
10
+ - '\? for shortcuts'
11
+ - ' Try "'
12
+ - '^\? for shortcuts'
13
+ - "^>[  ]"
14
+ - "──────────+"
15
+ working:
16
+ - esc to interrupt
17
+ - to run in background
18
+ typingRespond:
19
+ "1\n":
20
+ - '│ Do you want to use this API key\?'
21
+ enter:
22
+ - pattern: ' > 1\. Yes, I trust this folder'
23
+ flags: m
24
+ - pattern: '❯ ?1\. ?Dark mode ?✔'
25
+ flags: m
26
+ - pattern: '❯ ?1\. ?Yes'
27
+ flags: m
28
+ - pattern: '^.{0,4} ?1\. ?Dark mode ?✔'
29
+ flags: m
30
+ - pattern: '^.{0,4} ?1\. ?Yes'
31
+ flags: m
32
+ - pattern: Press Enter to continue
33
+ flags: m
34
+ fatal:
35
+ - Claude usage limit reached
36
+ - "^error: unknown option"
37
+ restoreArgs:
38
+ - --continue
39
+ restartWithoutContinueArg:
40
+ - No conversation found to continue
41
+ exitCommands:
42
+ - /exit
43
+ bunx: true
44
+ defaultArgs: []
45
+
46
+ gemini:
47
+ install:
48
+ npm: "npm install -g @google/gemini-cli@latest"
49
+ ready:
50
+ - Type your message
51
+ enter:
52
+ - "│ ● 1. Yes, allow once"
53
+ - "│ ● 1. Allow once"
54
+ - "│ ● 1. Allow once"
55
+ fatal:
56
+ - Error resuming session
57
+ - No previous sessions found for this project\.
58
+ restoreArgs:
59
+ - --resume
60
+ restartWithoutContinueArg:
61
+ - Error resuming session
62
+ - No previous sessions found for this project\.
63
+ exitCommands:
64
+ - /chat save ${PWD}
65
+ - /quit
66
+
67
+ codex:
68
+ promptArg: first-arg
69
+ install:
70
+ npm: "npm install -g @openai/codex@latest"
71
+ updateAvailable:
72
+ - "^✨⬆️ Update available!"
73
+ ready:
74
+ - ⏎ send
75
+ - "› "
76
+ - '\? for shortcuts'
77
+ enter:
78
+ - "> 1. Yes,"
79
+ - "> 1. Yes, allow Codex to work in this folder"
80
+ - "> 1. Approve and run now"
81
+ fatal:
82
+ - "Error: The cursor position could not be read within"
83
+ defaultArgs:
84
+ - --search
85
+ noEOL: true
86
+
87
+ qwen:
88
+ install:
89
+ npm: "npm install -g @qwen-code/qwen-code@latest"
90
+ version: qwen --version
91
+
92
+ grok:
93
+ install:
94
+ npm: "npm install -g @vibe-kit/grok-cli@latest"
95
+ ready:
96
+ - "^ │ ❯ +"
97
+ enter:
98
+ - "^ 1. Yes"
99
+
100
+ copilot:
101
+ promptArg: -i
102
+ install:
103
+ npm: "npm install -g @github/copilot"
104
+ ready:
105
+ - "^ +> "
106
+ - Ctrl\+c Exit
107
+ enter:
108
+ - " │ ❯ +1. Yes, proceed"
109
+ - " ❯ +1. Yes"
110
+ system: "IMPORTANT: USE TOOLS TO RESEARCH/EXPLORE/WORKAROUND your self, except you need approve on DESTRUCTIVE OPERATIONS, DONT ASK QUESTIONS ON USERS REQUEST, JUST SOLVE IT."
111
+ fatal: []
112
+
113
+ cursor:
114
+ install:
115
+ bash: open https://cursor.com/ja/docs/cli/installation
116
+ binary: cursor-agent
117
+ bunx: true
118
+ ready:
119
+ - / commands
120
+ enter:
121
+ - '→ Run \(once\) \(y\) \(enter\)'
122
+ - '▶ \[a\] Trust this workspace'
123
+ fatal:
124
+ - "Error: You've hit your usage limit"
125
+
126
+ auggie:
127
+ help: https://docs.augmentcode.com/cli/overview
128
+ install:
129
+ npm: "npm install -g @augmentcode/auggie"
130
+ promptArg: first-arg
131
+ ready:
132
+ - " > "
133
+ - '\? to show shortcuts'
134
+ typingRespond:
135
+ "y\n":
136
+ - '\[Y\] Enable indexing - Unlock full workspace understanding'
137
+ enter: []
138
+ fatal: []
139
+
140
+ amp:
141
+ help: https://ampcode.com/
142
+ install:
143
+ bash: "curl -fsSL https://ampcode.com/install.sh | bash"
144
+ npm: "npm i -g @sourcegraph/amp"
145
+ enter:
146
+ - "^.{0,4} Approve "
147
+
148
+ opencode:
149
+ help: https://opencode.ai/
150
+ install:
151
+ bash: "curl -fsSL https://opencode.ai/install | bash"
152
+ npm: "npm i -g opencode-ai"
153
+ enter: []
154
+ ready: []
@@ -0,0 +1,11 @@
1
+ import { t as CLIS_CONFIG } from "./ts-C8vuG5y-.js";
2
+ import "./logger-B9h0djqx.js";
3
+ import "./pidStore-CHLHMBEM.js";
4
+ import "./globalPidIndex-DNEh8a_O.js";
5
+
6
+ //#region ts/SUPPORTED_CLIS.ts
7
+ const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
8
+
9
+ //#endregion
10
+ export { SUPPORTED_CLIS };
11
+ //# sourceMappingURL=SUPPORTED_CLIS-BCn8YIi2.js.map
@@ -1,7 +1,8 @@
1
- import { t as logger } from "./logger-CX77vJDA.js";
1
+ import { n as logger } from "./logger-B9h0djqx.js";
2
2
  import os from "node:os";
3
3
  import { access, mkdir, readFile, writeFile } from "node:fs/promises";
4
4
  import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
5
6
  import { parse } from "yaml";
6
7
 
7
8
  //#region ts/defineConfig.ts
@@ -10,6 +11,68 @@ async function defineCliYesConfig(cfg) {
10
11
  return cfg;
11
12
  }
12
13
 
14
+ //#endregion
15
+ //#region ts/configShared.ts
16
+ function compileRegexSource(source) {
17
+ if (source instanceof RegExp) return source;
18
+ if (typeof source === "string") return new RegExp(source);
19
+ return new RegExp(source.pattern, source.flags ?? "");
20
+ }
21
+ function compileRegexList(sources) {
22
+ return sources?.map((source) => compileRegexSource(source));
23
+ }
24
+ function compileTypingRespond(typingRespond) {
25
+ if (!typingRespond) return void 0;
26
+ return Object.fromEntries(Object.entries(typingRespond).map(([message, patterns]) => [message, patterns.map(compileRegexSource)]));
27
+ }
28
+ function normalizeCliConfig(raw) {
29
+ const { ready, fatal, working, enter, enterExclude, typingRespond, restartWithoutContinueArg, updateAvailable, exitCommands, exitCommand, ...rest } = raw;
30
+ return {
31
+ ...rest,
32
+ ready: compileRegexList(ready),
33
+ fatal: compileRegexList(fatal),
34
+ working: compileRegexList(working),
35
+ enter: compileRegexList(enter),
36
+ enterExclude: compileRegexList(enterExclude),
37
+ typingRespond: compileTypingRespond(typingRespond),
38
+ restartWithoutContinueArg: compileRegexList(restartWithoutContinueArg),
39
+ updateAvailable: compileRegexList(updateAvailable),
40
+ exitCommands: exitCommands ?? exitCommand
41
+ };
42
+ }
43
+ function normalizeAgentYesConfig(raw) {
44
+ const normalized = {};
45
+ if (raw.configDir !== void 0) normalized.configDir = raw.configDir;
46
+ if (raw.logsDir !== void 0) normalized.logsDir = raw.logsDir;
47
+ if (raw.clis) normalized.clis = Object.fromEntries(Object.entries(raw.clis).map(([name, cliConfig]) => [name, normalizeCliConfig(cliConfig)]));
48
+ return normalized;
49
+ }
50
+ async function fileExists$1(filepath) {
51
+ try {
52
+ await access(filepath);
53
+ return true;
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
58
+ async function findSharedCliDefaultsPath(fromUrl = import.meta.url) {
59
+ let currentDir = path.dirname(fileURLToPath(fromUrl));
60
+ while (true) {
61
+ const candidate = path.resolve(currentDir, "default.config.yaml");
62
+ if (await fileExists$1(candidate)) return candidate;
63
+ const parent = path.dirname(currentDir);
64
+ if (parent === currentDir) break;
65
+ currentDir = parent;
66
+ }
67
+ throw new Error("Unable to locate default.config.yaml from current package path");
68
+ }
69
+ async function loadSharedCliDefaults(fromUrl = import.meta.url) {
70
+ const filepath = await findSharedCliDefaultsPath(fromUrl);
71
+ const parsed = parse(await readFile(filepath, "utf8"));
72
+ if (!parsed || typeof parsed !== "object") throw new Error(`Invalid shared CLI defaults file: ${filepath}`);
73
+ return normalizeAgentYesConfig(parsed).clis ?? {};
74
+ }
75
+
13
76
  //#endregion
14
77
  //#region ts/utils.ts
15
78
  function deepMixin(target, source, ...more) {
@@ -51,12 +114,18 @@ async function fileExists(filepath) {
51
114
  async function parseConfigFile(filepath) {
52
115
  const content = await readFile(filepath, "utf-8");
53
116
  const ext = path.extname(filepath).toLowerCase();
117
+ let parsed;
54
118
  switch (ext) {
55
- case ".json": return JSON.parse(content);
119
+ case ".json":
120
+ parsed = JSON.parse(content);
121
+ break;
56
122
  case ".yml":
57
- case ".yaml": return parse(content) ?? {};
123
+ case ".yaml":
124
+ parsed = parse(content) ?? {};
125
+ break;
58
126
  default: throw new Error(`Unsupported config file extension: ${ext}`);
59
127
  }
128
+ return normalizeAgentYesConfig(parsed);
60
129
  }
61
130
  /**
62
131
  * Find config file in a directory (checks all supported extensions)
@@ -209,127 +278,14 @@ const legacyConfigs = await Promise.all([
209
278
  import(path.resolve(process.cwd(), ".agent-yes/config.ts")).catch(() => ({ default: {} })).then((mod) => mod.default)
210
279
  ]);
211
280
  var agent_yes_config_default = deepMixin(await getDefaultConfig(), cascadingConfig, ...legacyConfigs);
212
- function getDefaultConfig() {
281
+ async function getDefaultConfig() {
213
282
  return defineCliYesConfig({
214
283
  configDir,
215
284
  logsDir: configDir && path.resolve(configDir, "logs"),
216
- clis: {
217
- claude: {
218
- promptArg: "last-arg",
219
- systemPrompt: "--append-system-prompt",
220
- install: {
221
- powershell: "powershell -Command \"irm https://claude.ai/install.ps1 | iex\"",
222
- bash: "curl -fsSL https://claude.ai/install.sh | bash",
223
- npm: "npm i -g @anthropic-ai/claude-code@latest"
224
- },
225
- ready: [
226
- /\? for shortcuts/,
227
- /\u00A0Try "/,
228
- /^\? for shortcuts/,
229
- /^>[ \u00A0]/,
230
- /──────────+/
231
- ],
232
- working: [/esc to interrupt/, /to run in background/],
233
- typingRespond: { "1\n": [/│ Do you want to use this API key\?/] },
234
- enter: [
235
- / > 1. Yes, I trust this folder/m,
236
- /❯ ?1\. ?Dark mode ?✔/m,
237
- /❯ ?1\. ?Yes/m,
238
- /^.{0,4} ?1\. ?Dark mode ?✔/m,
239
- /^.{0,4} ?1\. ?Yes/m,
240
- /Press Enter to continue…/m
241
- ],
242
- fatal: [
243
- /⎿ Claude usage limit reached\./,
244
- /^error: unknown option/,
245
- /No conversation found to continue/
246
- ],
247
- restoreArgs: ["--continue"],
248
- exitCommand: ["/exit"],
249
- bunx: true,
250
- defaultArgs: []
251
- },
252
- gemini: {
253
- install: "npm install -g @google/gemini-cli@latest",
254
- ready: [/Type your message/],
255
- enter: [
256
- /│ ● 1. Yes, allow once/,
257
- /│ ● 1. Allow once/,
258
- /│ ● 1. Allow once/
259
- ],
260
- fatal: [/Error resuming session/, /No previous sessions found for this project./],
261
- restoreArgs: ["--resume"],
262
- exitCommand: ["/chat save ${PWD}", "/quit"]
263
- },
264
- codex: {
265
- promptArg: "first-arg",
266
- install: "npm install -g @openai/codex@latest",
267
- updateAvailable: [/^✨⬆️ Update available!/],
268
- ready: [/⏎ send/, /\? for shortcuts/],
269
- enter: [
270
- /> 1. Yes,/,
271
- /> 1. Yes, allow Codex to work in this folder/,
272
- /> 1. Approve and run now/
273
- ],
274
- fatal: [/Error: The cursor position could not be read within/],
275
- defaultArgs: ["--search"],
276
- noEOL: true
277
- },
278
- qwen: {
279
- install: "npm install -g @qwen-code/qwen-code@latest",
280
- version: "qwen --version"
281
- },
282
- grok: {
283
- install: "npm install -g @vibe-kit/grok-cli@latest",
284
- ready: [/^ │ ❯ +/],
285
- enter: [/^ 1. Yes/]
286
- },
287
- copilot: {
288
- promptArg: "-i",
289
- install: "npm install -g @github/copilot",
290
- ready: [/^ +> /, /Ctrl\+c Exit/],
291
- enter: [/ │ ❯ +1. Yes, proceed/, / ❯ +1. Yes/],
292
- system: "IMPORTANT: USE TOOLS TO RESEARCH/EXPLORE/WORKAROUND your self, except you need approve on DESTRUCTIVE OPERATIONS, DONT ASK QUESTIONS ON USERS REQUEST, JUST SOLVE IT.",
293
- fatal: []
294
- },
295
- cursor: {
296
- install: "open https://cursor.com/ja/docs/cli/installation",
297
- binary: "cursor-agent",
298
- bunx: true,
299
- ready: [/\/ commands/],
300
- enter: [/→ Run \(once\) \(y\) \(enter\)/, /▶ \[a\] Trust this workspace/],
301
- fatal: [/^ Error: You've hit your usage limit/]
302
- },
303
- auggie: {
304
- help: "https://docs.augmentcode.com/cli/overview",
305
- install: "npm install -g @augmentcode/auggie",
306
- promptArg: "first-arg",
307
- ready: [/ > /, /\? to show shortcuts/],
308
- typingRespond: { "y\n": [/\[Y\] Enable indexing - Unlock full workspace understanding/] },
309
- enter: [],
310
- fatal: []
311
- },
312
- amp: {
313
- help: "https://ampcode.com/",
314
- install: {
315
- bash: "curl -fsSL https://ampcode.com/install.sh | bash",
316
- npm: "npm i -g @sourcegraph/amp"
317
- },
318
- enter: [/^.{0,4} Approve /]
319
- },
320
- opencode: {
321
- help: "https://opencode.ai/",
322
- install: {
323
- bash: "curl -fsSL https://opencode.ai/install | bash",
324
- npm: "npm i -g opencode-ai"
325
- },
326
- enter: [],
327
- ready: []
328
- }
329
- }
285
+ clis: await loadSharedCliDefaults(import.meta.url)
330
286
  });
331
287
  }
332
288
 
333
289
  //#endregion
334
290
  export { agent_yes_config_default as default };
335
- //# sourceMappingURL=agent-yes.config-CtQprJrA.js.map
291
+ //# sourceMappingURL=agent-yes.config-1LMoK18R.js.map
package/dist/cli.js CHANGED
@@ -1,23 +1,22 @@
1
1
  #!/usr/bin/env bun
2
- import { c as PidStore, o as name, s as version, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-DgHs-Q6i.js";
3
- import { t as logger } from "./logger-CX77vJDA.js";
2
+ import { n as logger } from "./logger-B9h0djqx.js";
3
+ import { n as version, t as name } from "./package-Bn0B_jWZ.js";
4
4
  import { argv } from "process";
5
5
  import { execFileSync, spawn } from "child_process";
6
6
  import ms from "ms";
7
7
  import yargs from "yargs";
8
8
  import { hideBin } from "yargs/helpers";
9
- import { execaCommand } from "execa";
9
+ import { existsSync, lstatSync, mkdirSync, readlinkSync, unlinkSync } from "fs";
10
10
  import { chmod, copyFile, mkdir, readFile, writeFile } from "fs/promises";
11
- import path from "path";
12
11
  import { homedir } from "os";
13
- import { existsSync, lstatSync, mkdirSync, readlinkSync, unlinkSync } from "fs";
12
+ import path from "path";
14
13
 
15
14
  //#region ts/parseCliArgs.ts
16
15
  /**
17
16
  * Parse CLI arguments the same way cli.ts does
18
17
  * This is a test helper that mirrors the parsing logic in cli.ts
19
18
  */
20
- function parseCliArgs(argv) {
19
+ function parseCliArgs(argv, supportedClis) {
21
20
  const scriptBaseName = argv[1]?.split(/[/\\]/).at(-1)?.replace(/(\.[jt]s)?$/, "") || "";
22
21
  const CLI_ALIASES = { cy: "claude" };
23
22
  const cliName = (() => {
@@ -129,7 +128,7 @@ function parseCliArgs(argv) {
129
128
  }).positional("cli", {
130
129
  describe: "The AI CLI to run, e.g., claude, codex, copilot, cursor, gemini",
131
130
  type: "string",
132
- choices: SUPPORTED_CLIS,
131
+ choices: supportedClis,
133
132
  demandOption: false,
134
133
  default: cliName
135
134
  }).help().version(false).option("version", {
@@ -301,6 +300,7 @@ async function runInstall(latestVersion) {
301
300
  const installCmd = detectPackageManager() === "bun" ? `bun add -g agent-yes@${latestVersion}` : `npm install -g agent-yes@${latestVersion}`;
302
301
  process.stderr.write(`\x1b[33m[agent-yes] Updating ${version} → ${latestVersion}…\x1b[0m\n`);
303
302
  try {
303
+ const { execaCommand } = await import("execa");
304
304
  await execaCommand(installCmd, { stdio: "inherit" });
305
305
  process.stderr.write(`\x1b[32m[agent-yes] Updated to ${latestVersion}\x1b[0m\n`);
306
306
  return true;
@@ -627,16 +627,30 @@ function buildRustArgs(argv, cliFromScript, supportedClis) {
627
627
 
628
628
  //#endregion
629
629
  //#region ts/cli.ts
630
+ {
631
+ const rawArgs = process.argv.slice(2);
632
+ if (rawArgs[0] === "-v" || rawArgs.includes("--version")) {
633
+ console.log(versionString());
634
+ process.exit(0);
635
+ }
636
+ }
637
+ {
638
+ const { isSubcommand, runSubcommand } = await import("./subcommands-CR1i1sjy.js");
639
+ if (isSubcommand(process.argv[2])) {
640
+ const code = await runSubcommand(process.argv);
641
+ process.exit(code ?? 0);
642
+ }
643
+ }
630
644
  await checkAndAutoUpdate();
631
645
  logger.info(versionString());
632
646
  const config = parseCliArgs(process.argv);
633
647
  if (config.tray) {
634
- const { startTray } = await import("./tray-CPpdxTV-.js");
648
+ const { startTray } = await import("./tray-D5deJPjk.js");
635
649
  await startTray();
636
650
  await new Promise(() => {});
637
651
  }
638
652
  {
639
- const { ensureTray } = await import("./tray-CPpdxTV-.js");
653
+ const { ensureTray } = await import("./tray-D5deJPjk.js");
640
654
  ensureTray();
641
655
  }
642
656
  if (config.useRust) {
@@ -650,6 +664,7 @@ if (config.useRust) {
650
664
  }
651
665
  }
652
666
  if (rustBinary) {
667
+ const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-BCn8YIi2.js");
653
668
  const rustArgs = buildRustArgs(process.argv, config.cli, SUPPORTED_CLIS);
654
669
  if (config.verbose) {
655
670
  console.log(`[rust] Using binary: ${rustBinary}`);
@@ -679,6 +694,7 @@ if (config.showVersion) {
679
694
  process.exit(0);
680
695
  }
681
696
  if (config.appendPrompt) {
697
+ const { PidStore } = await import("./pidStore-DR1yPY3t.js");
682
698
  const ipcPath = await PidStore.findActiveFifo(process.cwd());
683
699
  if (!ipcPath) {
684
700
  console.error("No active agent with IPC found in current directory.");
@@ -0,0 +1,103 @@
1
+ import { n as logger } from "./logger-B9h0djqx.js";
2
+ import { appendFile, mkdir, readFile } from "fs/promises";
3
+ import { homedir } from "os";
4
+ import path from "path";
5
+ import { lock } from "proper-lockfile";
6
+
7
+ //#region ts/globalPidIndex.ts
8
+ const GLOBAL_DIR = path.join(homedir(), ".agent-yes");
9
+ const GLOBAL_FILE = path.join(GLOBAL_DIR, "pids.jsonl");
10
+ async function ensureDir() {
11
+ await mkdir(GLOBAL_DIR, { recursive: true });
12
+ }
13
+ async function withLock(fn) {
14
+ await ensureDir();
15
+ let release;
16
+ try {
17
+ release = await lock(GLOBAL_DIR, {
18
+ lockfilePath: GLOBAL_FILE + ".lock",
19
+ retries: {
20
+ retries: 5,
21
+ minTimeout: 50,
22
+ maxTimeout: 500
23
+ }
24
+ });
25
+ return await fn();
26
+ } finally {
27
+ await release?.();
28
+ }
29
+ }
30
+ /** Append one full record line. Caller must provide all required fields. */
31
+ async function appendGlobalPid(record) {
32
+ try {
33
+ await withLock(async () => {
34
+ await appendFile(GLOBAL_FILE, JSON.stringify(record) + "\n");
35
+ });
36
+ } catch (error) {
37
+ logger.debug("[globalPidIndex] append failed:", error);
38
+ }
39
+ }
40
+ /** Append a partial status update by pid (status, exit_code, exit_reason). */
41
+ async function updateGlobalPidStatus(pid, patch) {
42
+ try {
43
+ await withLock(async () => {
44
+ const existing = (await readGlobalPidsRaw()).find((r) => r.pid === pid);
45
+ if (!existing) return;
46
+ const merged = {
47
+ ...existing,
48
+ ...patch
49
+ };
50
+ await appendFile(GLOBAL_FILE, JSON.stringify(merged) + "\n");
51
+ });
52
+ } catch (error) {
53
+ logger.debug("[globalPidIndex] updateStatus failed:", error);
54
+ }
55
+ }
56
+ /**
57
+ * Read the file once without merge logic — internal helper for status updates.
58
+ */
59
+ async function readGlobalPidsRaw() {
60
+ let raw;
61
+ try {
62
+ raw = await readFile(GLOBAL_FILE, "utf-8");
63
+ } catch (err) {
64
+ if (err.code === "ENOENT") return [];
65
+ throw err;
66
+ }
67
+ const merged = /* @__PURE__ */ new Map();
68
+ for (const line of raw.split("\n")) {
69
+ const trimmed = line.trim();
70
+ if (!trimmed) continue;
71
+ try {
72
+ const doc = JSON.parse(trimmed);
73
+ if (typeof doc.pid !== "number") continue;
74
+ const prev = merged.get(doc.pid);
75
+ merged.set(doc.pid, prev ? {
76
+ ...prev,
77
+ ...doc
78
+ } : doc);
79
+ } catch {}
80
+ }
81
+ return Array.from(merged.values());
82
+ }
83
+ /**
84
+ * Read all records, last-line-per-pid wins (events get merged).
85
+ * Optionally filter to live processes only.
86
+ */
87
+ async function readGlobalPids(opts = {}) {
88
+ const records = await readGlobalPidsRaw();
89
+ if (!opts.liveOnly) return records;
90
+ return records.filter((r) => r.status !== "exited" && isProcessAlive(r.pid));
91
+ }
92
+ function isProcessAlive(pid) {
93
+ try {
94
+ process.kill(pid, 0);
95
+ return true;
96
+ } catch {
97
+ return false;
98
+ }
99
+ }
100
+
101
+ //#endregion
102
+ export { readGlobalPids as n, updateGlobalPidStatus as r, appendGlobalPid as t };
103
+ //# sourceMappingURL=globalPidIndex-DNEh8a_O.js.map
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
- import { a as AgentContext, i as config, l as removeControlCharacters, n as CLIS_CONFIG, r as agentYes } from "./SUPPORTED_CLIS-DgHs-Q6i.js";
2
- import "./logger-CX77vJDA.js";
1
+ import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-C8vuG5y-.js";
2
+ import "./logger-B9h0djqx.js";
3
+ import "./pidStore-CHLHMBEM.js";
4
+ import "./globalPidIndex-DNEh8a_O.js";
3
5
 
4
6
  export { AgentContext, CLIS_CONFIG, config, agentYes as default, removeControlCharacters };