context-mode 2.1.6 → 2.1.8

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/cli.mjs CHANGED
@@ -1,94 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import{createRequire as __cmRequire}from"node:module";if(typeof process.getBuiltinModule!=="function")process.getBuiltinModule=(id)=>__cmRequire(import.meta.url)(id);
3
- var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJS = (cb, mod) => function __require() {
10
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
- };
12
4
  var __export = (target, all) => {
13
5
  for (var name in all)
14
6
  __defProp(target, name, { get: all[name], enumerable: true });
15
7
  };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
32
-
33
- // node_modules/sisteransi/src/index.js
34
- var require_src = __commonJS({
35
- "node_modules/sisteransi/src/index.js"(exports, module) {
36
- "use strict";
37
- var ESC2 = "\x1B";
38
- var CSI2 = `${ESC2}[`;
39
- var beep = "\x07";
40
- var cursor3 = {
41
- to(x2, y2) {
42
- if (!y2) return `${CSI2}${x2 + 1}G`;
43
- return `${CSI2}${y2 + 1};${x2 + 1}H`;
44
- },
45
- move(x2, y2) {
46
- let ret = "";
47
- if (x2 < 0) ret += `${CSI2}${-x2}D`;
48
- else if (x2 > 0) ret += `${CSI2}${x2}C`;
49
- if (y2 < 0) ret += `${CSI2}${-y2}A`;
50
- else if (y2 > 0) ret += `${CSI2}${y2}B`;
51
- return ret;
52
- },
53
- up: (count = 1) => `${CSI2}${count}A`,
54
- down: (count = 1) => `${CSI2}${count}B`,
55
- forward: (count = 1) => `${CSI2}${count}C`,
56
- backward: (count = 1) => `${CSI2}${count}D`,
57
- nextLine: (count = 1) => `${CSI2}E`.repeat(count),
58
- prevLine: (count = 1) => `${CSI2}F`.repeat(count),
59
- left: `${CSI2}G`,
60
- hide: `${CSI2}?25l`,
61
- show: `${CSI2}?25h`,
62
- save: `${ESC2}7`,
63
- restore: `${ESC2}8`
64
- };
65
- var scroll = {
66
- up: (count = 1) => `${CSI2}S`.repeat(count),
67
- down: (count = 1) => `${CSI2}T`.repeat(count)
68
- };
69
- var erase3 = {
70
- screen: `${CSI2}2J`,
71
- up: (count = 1) => `${CSI2}1J`.repeat(count),
72
- down: (count = 1) => `${CSI2}J`.repeat(count),
73
- line: `${CSI2}2K`,
74
- lineEnd: `${CSI2}K`,
75
- lineStart: `${CSI2}1K`,
76
- lines(count) {
77
- let clear = "";
78
- for (let i2 = 0; i2 < count; i2++)
79
- clear += this.line + (i2 < count - 1 ? cursor3.up() : "");
80
- if (count)
81
- clear += cursor3.left;
82
- return clear;
83
- }
84
- };
85
- module.exports = { cursor: cursor3, scroll, erase: erase3, beep };
86
- }
87
- });
88
8
 
89
9
  // src/entries/cli.ts
90
10
  import { spawn as spawn4 } from "node:child_process";
91
- import { readFileSync as readFileSync13, realpathSync as realpathSync11 } from "node:fs";
11
+ import { readFileSync as readFileSync14, realpathSync as realpathSync11 } from "node:fs";
92
12
  import path14 from "node:path";
93
13
  import { fileURLToPath as fileURLToPath3 } from "node:url";
94
14
 
@@ -389,6 +309,7 @@ function D2_NODE_DETAIL(version) {
389
309
  var D2_SQLITE_DETAIL = "node:sqlite failed to load";
390
310
  var D2_SQLITE_FIX = "run ctx_doctor";
391
311
  var D3_PARTS = Object.freeze(["MCP entry", "hook entries", "hook timeout"]);
312
+ var PLUGIN_MARKETPLACE_NAME = "context-mode";
392
313
  var AGENT_HOME_DIR = Object.freeze({
393
314
  "claude-code": [".claude"],
394
315
  codex: [".codex"],
@@ -421,6 +342,90 @@ var OPS_SPLIT_FILES = Object.freeze([
421
342
  "v1-remove.ts",
422
343
  "uninstall.ts"
423
344
  ]);
345
+ var unsupported = (h2) => Object.freeze(h2);
346
+ var UNSUPPORTED_HOSTS = Object.freeze([
347
+ unsupported({
348
+ id: "antigravity",
349
+ name: "Antigravity",
350
+ clientNames: ["antigravity", "antigravity-client", "antigravity-cli", "agy"],
351
+ envVars: ["ANTIGRAVITY_CLI_ALIAS"],
352
+ pluginPaths: [[".gemini", "config", "plugins"], [".gemini", "antigravity", "plugins"], [".gemini", "antigravity-cli", "plugins"], [".gemini", "antigravity-ide", "plugins"]],
353
+ configDirs: [".gemini/antigravity", ".gemini/antigravity-cli", ".gemini/config"],
354
+ binaries: ["agy"],
355
+ source: "v1.0.169:src/adapters/client-map.ts:15-17; detect.ts:156,481-483; #1340"
356
+ }),
357
+ unsupported({
358
+ id: "cursor",
359
+ name: "Cursor",
360
+ clientNames: ["cursor-vscode"],
361
+ envVars: ["CURSOR_TRACE_ID", "CURSOR_CLI", "CURSOR_CWD"],
362
+ pluginPaths: [],
363
+ configDirs: [".cursor"],
364
+ binaries: [],
365
+ source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
366
+ }),
367
+ unsupported({
368
+ id: "omp",
369
+ name: "OMP (oh-my-pi)",
370
+ clientNames: ["omp-coding-agent"],
371
+ envVars: [],
372
+ pluginPaths: [],
373
+ configDirs: [".omp"],
374
+ binaries: ["omp"],
375
+ source: "v1.0.169:src/adapters/client-map.ts:37; detect.ts:543 (PI_CODING_AGENT_DIR is not a signal: supported Pi reads it too)"
376
+ }),
377
+ unsupported({
378
+ id: "openclaw",
379
+ name: "OpenClaw",
380
+ clientNames: [],
381
+ envVars: [],
382
+ pluginPaths: [],
383
+ configDirs: [".openclaw"],
384
+ binaries: [],
385
+ source: "v1.0.169:src/adapters/detect.ts:252,575 (the runtime sets no env var)"
386
+ }),
387
+ unsupported({
388
+ id: "kimi",
389
+ name: "Kimi Code",
390
+ clientNames: ["kimi-code", "kimi"],
391
+ envVars: [],
392
+ pluginPaths: [],
393
+ configDirs: [".kimi-code"],
394
+ binaries: ["kimi"],
395
+ source: "v1.0.169:src/adapters/client-map.ts:42-44; detect.ts:567; adapters/kimi/index.ts:127"
396
+ }),
397
+ unsupported({
398
+ id: "kilo",
399
+ name: "Kilo Code",
400
+ clientNames: ["kilo code"],
401
+ envVars: ["KILO", "KILO_PID"],
402
+ pluginPaths: [],
403
+ configDirs: [".config/kilo"],
404
+ binaries: [],
405
+ source: "v1.0.169:src/adapters/client-map.ts:28; detect.ts:170-171,592"
406
+ }),
407
+ unsupported({
408
+ id: "zed",
409
+ name: "Zed",
410
+ clientNames: ["zed"],
411
+ envVars: ["ZED_SESSION_ID", "ZED_TERM"],
412
+ pluginPaths: [],
413
+ configDirs: [".config/zed"],
414
+ binaries: [],
415
+ source: "v1.0.169:src/adapters/client-map.ts:38-39; detect.ts:189-190,616"
416
+ }),
417
+ unsupported({
418
+ id: "jetbrains-copilot",
419
+ name: "JetBrains Copilot",
420
+ clientNames: ["jetbrains client", "intellij idea", "pycharm"],
421
+ envVars: ["IDEA_INITIAL_DIRECTORY"],
422
+ pluginPaths: [],
423
+ configDirs: [".config/JetBrains"],
424
+ binaries: [],
425
+ source: "v1.0.169:src/adapters/client-map.ts:23-25; detect.ts:213,600"
426
+ })
427
+ ]);
428
+ var SUPPORTED_AGENTS_DOCS_URL = "https://github.com/mksglu/context-mode/blob/main/docs/install/README.md";
424
429
  var HOOK_HOST_FILE = Object.freeze({
425
430
  "claude-code": { root: "plugin", file: ["hooks", "claude-code.json"], key: ["hooks"], shape: "nested", timeoutKey: "timeout", matcher: true },
426
431
  codex: { root: "home", file: [".codex", "hooks.json"], key: ["hooks"], shape: "nested", timeoutKey: "timeout", matcher: true },
@@ -478,6 +483,14 @@ var V1_SCRIPT_NAMES = Object.freeze([
478
483
  var V1_HOOK_COMMAND = "context-mode hook";
479
484
  var V1_CODEX_HOOK_COMMAND = "context-mode hook codex";
480
485
  var V1_CODEX_HOOKS_DIR = Object.freeze(["hooks", "codex"]);
486
+ var V1_CODEX_SCRIPT_NAMES = Object.freeze([
487
+ "pretooluse.mjs",
488
+ "posttooluse.mjs",
489
+ "sessionstart.mjs",
490
+ "precompact.mjs",
491
+ "userpromptsubmit.mjs",
492
+ "stop.mjs"
493
+ ]);
481
494
  var V1_CACHE_HEAL_NAME = "context-mode-cache-heal";
482
495
  var V1_CACHE_HEAL_EXTS = Object.freeze([".mjs", ".sh"]);
483
496
  var V1_STATUSLINE_COMMAND = "context-mode statusline";
@@ -524,6 +537,8 @@ var HOOKS_KEY = "hooks";
524
537
  var STATUS_LINE_KEY = "statusLine";
525
538
  var PI_PACKAGES_KEY = "packages";
526
539
  var OPENCODE_PLUGIN_KEY = "plugin";
540
+ var OPENCODE_PLUGINS_KEY = "plugins";
541
+ var OPENCODE_PACKAGE_FIELD = "package";
527
542
  var OPENCODE_NPM_SPEC_PREFIX = `${SERVER_KEY}@`;
528
543
  var NPM_VERSION_SEP = "@";
529
544
  var OPENCODE_NPM_LATEST = `${OPENCODE_NPM_SPEC_PREFIX}latest`;
@@ -531,7 +546,6 @@ var PI_NPM_LATEST = `${V1_PI_PACKAGE}${NPM_VERSION_SEP}latest`;
531
546
  var V1_DATA_DIR_NAME = "context-mode";
532
547
  var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
533
548
  var V1_SESSIONS_DIR_NAME = "sessions";
534
- var V1_SCRIPT_EXT = ".mjs";
535
549
  var V1_BIN_COMMAND = SERVER_KEY;
536
550
  var VSCODE_MCP_SERVERS_KEY = "servers";
537
551
  var ZCODE_EVENTS_KEY = "events";
@@ -547,7 +561,7 @@ var V1_REASON = Object.freeze({
547
561
  cacheHealFile: "old context-mode cache-heal script file",
548
562
  statusLine: "old context-mode statusLine (context-mode statusline): report only, never removed",
549
563
  mcpEntry: "old context-mode MCP entry mcpServers.context-mode",
550
- codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex/*.mjs",
564
+ codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex/<event>.mjs",
551
565
  codexToml: "old context-mode config.toml [mcp_servers.context-mode*] section",
552
566
  hookFile: "old context-mode hook file context-mode.json (runs context-mode hook)",
553
567
  vscodeMcp: "old context-mode MCP entry servers.context-mode in .vscode/mcp.json: report only, never removed",
@@ -582,6 +596,7 @@ var MCP_COMMAND_FIELD = "command";
582
596
  var MCP_ARGS_FIELD = "args";
583
597
  var MCP_ENV_FIELD = "env";
584
598
  var MCP_ENV_VARS_FIELD = "env_vars";
599
+ var MCP_TOOLS_FIELD = "tools";
585
600
  var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
586
601
  var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
587
602
  var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);
@@ -1387,6 +1402,7 @@ function readResult6(p3) {
1387
1402
  const text2 = p3.content === void 0 ? "" : typeof p3.content === "string" ? p3.content : JSON.stringify(p3.content);
1388
1403
  const info = { isError: p3.isError === true, bytes: Buffer.byteLength(text2), text: text2 };
1389
1404
  if (typeof p3.exitCode === "number") info.exitCode = p3.exitCode;
1405
+ if (p3.keep === true) info.keep = true;
1390
1406
  return info;
1391
1407
  }
1392
1408
  function decode9(raw) {
@@ -1463,6 +1479,11 @@ function decode10(raw) {
1463
1479
  const event = Object.prototype.hasOwnProperty.call(OPENCODE_EVENTS, native) ? OPENCODE_EVENTS[native] : void 0;
1464
1480
  if (event === void 0) throw new Error("opencode: unknown hook event " + String(p3.type));
1465
1481
  const ev = { event, agent: "opencode", sessionId: String(p3.sessionID ?? ""), cwd: String(p3.directory ?? "") };
1482
+ if (typeof p3.agentID === "string" && p3.agentID !== "") {
1483
+ ev.agentId = p3.agentID;
1484
+ ev.agentType = p3.agentID;
1485
+ }
1486
+ if (Array.isArray(p3.agentTools)) ev.agentTools = p3.agentTools.filter((t2) => typeof t2 === "string");
1466
1487
  if (event === "UserPromptSubmit" && typeof p3.message === "string") ev.prompt = p3.message;
1467
1488
  if (event === "PreToolUse" || event === "PostToolUse") {
1468
1489
  const name = String(p3.tool ?? "");
@@ -1483,7 +1504,7 @@ function encode10(ev, d, _extra) {
1483
1504
  if (ev.event !== "PreToolUse") return { stdout: "", exitCode: 0 };
1484
1505
  return { stdout: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason, exitCode: 2 };
1485
1506
  case "replace":
1486
- return { stdout: "", exitCode: 0 };
1507
+ return { stdout: ev.event === "PostToolUse" ? d.output : "", exitCode: 0 };
1487
1508
  }
1488
1509
  }
1489
1510
 
@@ -1688,7 +1709,7 @@ var ADAPTERS = Object.freeze([
1688
1709
  }
1689
1710
  ]);
1690
1711
  var BY_ID = new Map(ADAPTERS.map((r2) => [r2.id, r2]));
1691
- var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi"]);
1712
+ var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
1692
1713
  function hasReplace(row) {
1693
1714
  return REPLACE_ROWS.has(row.id);
1694
1715
  }
@@ -1696,10 +1717,51 @@ function getAdapter(id) {
1696
1717
  return BY_ID.get(id);
1697
1718
  }
1698
1719
 
1720
+ // src/core/contracts/agents.ts
1721
+ var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode"];
1722
+
1723
+ // src/core/ops/unsupported-host.ts
1724
+ var SUPPORTED_AGENTS_LINE = `Supported agents: ${AGENT_IDS.join(", ")} (${SUPPORTED_AGENTS_DOCS_URL}).`;
1725
+ function UNSUPPORTED_HOST_LINE(name) {
1726
+ return `${name} is not a supported host today. The MCP server runs here; hooks are not checked. ${SUPPORTED_AGENTS_LINE}`;
1727
+ }
1728
+ function UNSUPPORTED_SETUP_LINE(name) {
1729
+ return `${name} is not a supported host today. Setup writes nothing for it. ${SUPPORTED_AGENTS_LINE}`;
1730
+ }
1731
+ function segmentsOf(dir) {
1732
+ let parts = [dir];
1733
+ for (const sep3 of V1_PATH_SEPS) parts = parts.flatMap((p3) => p3.split(sep3));
1734
+ return parts;
1735
+ }
1736
+ function hasRun(parts, run) {
1737
+ for (let i2 = 0; i2 + run.length <= parts.length; i2++) if (run.every((seg, k) => parts[i2 + k] === seg)) return true;
1738
+ return false;
1739
+ }
1740
+ function unsupportedHostOf(sig) {
1741
+ if (sig.clientName !== void 0 && sig.clientName !== "") {
1742
+ const n3 = sig.clientName.toLowerCase();
1743
+ const hit = UNSUPPORTED_HOSTS.find((h2) => h2.clientNames.includes(n3));
1744
+ if (hit !== void 0) return hit;
1745
+ }
1746
+ if (sig.bundleDir !== void 0) {
1747
+ const parts = segmentsOf(sig.bundleDir);
1748
+ const hit = UNSUPPORTED_HOSTS.find((h2) => h2.pluginPaths.some((p3) => hasRun(parts, p3)));
1749
+ if (hit !== void 0) return hit;
1750
+ }
1751
+ if (sig.clientName !== void 0 && sig.clientName !== "") return void 0;
1752
+ const env = sig.env;
1753
+ if (env === void 0) return void 0;
1754
+ return UNSUPPORTED_HOSTS.find((h2) => h2.envVars.some((v) => env[v] !== void 0 && env[v] !== ""));
1755
+ }
1756
+ function unsupportedHostByName(name) {
1757
+ const n3 = name.toLowerCase();
1758
+ return UNSUPPORTED_HOSTS.find((h2) => h2.id === n3 || h2.clientNames.includes(n3) || h2.binaries.includes(n3));
1759
+ }
1760
+
1699
1761
  // src/cli/args.ts
1700
1762
  var COMMANDS = ["setup", "doctor", "upgrade"];
1701
1763
  var ALL_COMMANDS = ["setup", "doctor", "upgrade", "server", "mcp", "hook", "help"];
1702
- var AGENT_IDS = ADAPTERS.map((a2) => a2.id);
1764
+ var AGENT_IDS2 = ADAPTERS.map((a2) => a2.id);
1703
1765
  var COMMON = ["--help", "-h", "--json", "--yes", "-y", "--no-input", "--debug", "--quiet", "-q", "--verbose", "--no-color", "--agents"];
1704
1766
  var FLAGS = {
1705
1767
  setup: [...COMMON, "--dry-run", "--list", "--remove", "--repair", "--print"],
@@ -1710,6 +1772,11 @@ var VALUE_FLAGS = /* @__PURE__ */ new Set(["--agents", "--tag", "--print"]);
1710
1772
  var TAG_RE = /^[a-z0-9][a-z0-9.+-]*$/i;
1711
1773
  var UsageError = class extends Error {
1712
1774
  };
1775
+ function badAgent(name) {
1776
+ const h2 = unsupportedHostByName(name);
1777
+ if (h2 !== void 0) return new UsageError(UNSUPPORTED_SETUP_LINE(h2.name));
1778
+ return new UsageError(`unknown agent "${name}".${suggest(name, AGENT_IDS2)} ${SUPPORTED_AGENTS_LINE} Run context-mode setup --list.`);
1779
+ }
1713
1780
  function distance(a2, b3) {
1714
1781
  const row = Array.from({ length: b3.length + 1 }, (_2, i2) => i2);
1715
1782
  for (let i2 = 1; i2 <= a2.length; i2++) {
@@ -1794,13 +1861,13 @@ function parseFlags(cmd, argv) {
1794
1861
  f2.tag = value;
1795
1862
  break;
1796
1863
  case "--print":
1797
- if (!AGENT_IDS.includes(value)) throw new UsageError(`unknown agent "${value}".${suggest(value, AGENT_IDS)} Run context-mode setup --list.`);
1864
+ if (!AGENT_IDS2.includes(value)) throw badAgent(value);
1798
1865
  f2.print = value;
1799
1866
  break;
1800
1867
  case "--agents": {
1801
1868
  const ids = value.split(",").map((s) => s.trim()).filter(Boolean);
1802
1869
  for (const id of ids) {
1803
- if (!AGENT_IDS.includes(id)) throw new UsageError(`unknown agent "${id}".${suggest(id, AGENT_IDS)} Run context-mode setup --list.`);
1870
+ if (!AGENT_IDS2.includes(id)) throw badAgent(id);
1804
1871
  }
1805
1872
  f2.agents = [...new Set(ids)];
1806
1873
  break;
@@ -1977,8 +2044,8 @@ __export(dist_exports, {
1977
2044
  // node_modules/@clack/core/dist/index.mjs
1978
2045
  import { styleText } from "node:util";
1979
2046
  import { stdout, stdin } from "node:process";
1980
- import * as l from "node:readline";
1981
- import l__default from "node:readline";
2047
+ import * as f$1 from "node:readline";
2048
+ import f__default from "node:readline";
1982
2049
 
1983
2050
  // node_modules/fast-string-truncated-width/dist/utils.js
1984
2051
  var getCodePointsLength = /* @__PURE__ */ (() => {
@@ -2066,7 +2133,7 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
2066
2133
  if (index >= length) {
2067
2134
  break outer;
2068
2135
  }
2069
- for (let i2 = 0, l2 = PARSE_BLOCKS.length; i2 < l2; i2++) {
2136
+ for (let i2 = 0, l = PARSE_BLOCKS.length; i2 < l; i2++) {
2070
2137
  const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
2071
2138
  BLOCK_RE.lastIndex = index;
2072
2139
  if (BLOCK_RE.test(input)) {
@@ -2316,25 +2383,77 @@ function wrapAnsi(string, columns, options) {
2316
2383
  return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
2317
2384
  }
2318
2385
 
2386
+ // node_modules/sisteransi/dist/index.js
2387
+ var ESC2 = "\x1B";
2388
+ var CSI2 = `${ESC2}[`;
2389
+ var cursor = {
2390
+ to(x2, y) {
2391
+ if (!y)
2392
+ return `${CSI2}${x2 + 1}G`;
2393
+ return `${CSI2}${y + 1};${x2 + 1}H`;
2394
+ },
2395
+ move(x2, y) {
2396
+ let ret = "";
2397
+ if (x2 < 0)
2398
+ ret += `${CSI2}${-x2}D`;
2399
+ else if (x2 > 0)
2400
+ ret += `${CSI2}${x2}C`;
2401
+ if (y < 0)
2402
+ ret += `${CSI2}${-y}A`;
2403
+ else if (y > 0)
2404
+ ret += `${CSI2}${y}B`;
2405
+ return ret;
2406
+ },
2407
+ up: (count = 1) => `${CSI2}${count}A`,
2408
+ down: (count = 1) => `${CSI2}${count}B`,
2409
+ forward: (count = 1) => `${CSI2}${count}C`,
2410
+ backward: (count = 1) => `${CSI2}${count}D`,
2411
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
2412
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
2413
+ left: `${CSI2}G`,
2414
+ hide: `${CSI2}?25l`,
2415
+ show: `${CSI2}?25h`,
2416
+ save: `${ESC2}7`,
2417
+ restore: `${ESC2}8`
2418
+ };
2419
+ var erase = {
2420
+ screen: `${CSI2}2J`,
2421
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
2422
+ down: (count = 1) => `${CSI2}J`.repeat(count),
2423
+ line: `${CSI2}2K`,
2424
+ lineEnd: `${CSI2}K`,
2425
+ lineStart: `${CSI2}1K`,
2426
+ lines(count) {
2427
+ let clear2 = "";
2428
+ for (let i2 = 0; i2 < count; i2++)
2429
+ clear2 += this.line + (i2 < count - 1 ? cursor.up() : "");
2430
+ if (count)
2431
+ clear2 += cursor.left;
2432
+ return clear2;
2433
+ }
2434
+ };
2435
+ var clear = {
2436
+ screen: `${ESC2}c`
2437
+ };
2438
+
2319
2439
  // node_modules/@clack/core/dist/index.mjs
2320
- var import_sisteransi = __toESM(require_src(), 1);
2321
2440
  import { ReadStream } from "node:tty";
2322
- function findCursor(s, o2, l2) {
2323
- if (!l2.some((r2) => !r2.disabled))
2324
- return s;
2325
- const t2 = s + o2, n3 = Math.max(l2.length - 1, 0), e = t2 < 0 ? n3 : t2 > n3 ? 0 : t2;
2326
- return l2[e]?.disabled ? findCursor(e, o2 < 0 ? -1 : 1, l2) : e;
2441
+ function findCursor(o2, s, l) {
2442
+ if (!l.some((r2) => !r2.disabled))
2443
+ return o2;
2444
+ const t2 = o2 + s, n3 = Math.max(l.length - 1, 0), e = t2 < 0 ? n3 : t2 > n3 ? 0 : t2;
2445
+ return l[e]?.disabled ? findCursor(e, s < 0 ? -1 : 1, l) : e;
2327
2446
  }
2328
- function findTextCursor(s, o2, l2, i2) {
2447
+ function findTextCursor(o2, s, l, i2) {
2329
2448
  const t2 = i2.split(`
2330
2449
  `);
2331
- let n3 = 0, e = s;
2450
+ let n3 = 0, e = o2;
2332
2451
  for (const r2 of t2) {
2333
2452
  if (e <= r2.length)
2334
2453
  break;
2335
2454
  e -= r2.length + 1, n3++;
2336
2455
  }
2337
- for (n3 = Math.max(0, Math.min(t2.length - 1, n3 + l2)), e = Math.min(e, t2[n3].length) + o2; e < 0 && n3 > 0; )
2456
+ for (n3 = Math.max(0, Math.min(t2.length - 1, n3 + l)), e = Math.min(e, t2[n3].length) + s; e < 0 && n3 > 0; )
2338
2457
  n3--, e += t2[n3].length + 1;
2339
2458
  for (; e > t2[n3].length && n3 < t2.length - 1; )
2340
2459
  e -= t2[n3].length + 1, n3++;
@@ -2449,42 +2568,42 @@ function block({
2449
2568
  overwrite: o2 = true,
2450
2569
  hideCursor: n3 = true
2451
2570
  } = {}) {
2452
- const s = l.createInterface({
2571
+ const s = f$1.createInterface({
2453
2572
  input: e,
2454
2573
  output: r2,
2455
2574
  prompt: "",
2456
2575
  tabSize: 1
2457
2576
  });
2458
- l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
2459
- const t2 = (f2, { name: a2, sequence: w }) => {
2460
- const c3 = String(f2);
2461
- if (isActionKey([c3, a2, w], "cancel")) {
2462
- n3 && r2.write(import_sisteransi.cursor.show), process.exit(0);
2577
+ f$1.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
2578
+ const t2 = (l, { name: i2, sequence: p3 }) => {
2579
+ const w = String(l);
2580
+ if (isActionKey([w, i2, p3], "cancel")) {
2581
+ n3 && r2.write(cursor.show), process.exit(0);
2463
2582
  return;
2464
2583
  }
2465
2584
  if (!o2) return;
2466
- const i2 = a2 === "return" ? 0 : -1, m3 = a2 === "return" ? -1 : 0;
2467
- l.moveCursor(r2, i2, m3, () => {
2468
- l.clearLine(r2, 1, () => {
2585
+ const c3 = i2 === "return" ? 0 : -1, a2 = i2 === "return" ? -1 : 0;
2586
+ f$1.moveCursor(r2, c3, a2, () => {
2587
+ f$1.clearLine(r2, 1, () => {
2469
2588
  e.once("keypress", t2);
2470
2589
  });
2471
2590
  });
2472
2591
  };
2473
- return n3 && r2.write(import_sisteransi.cursor.hide), e.once("keypress", t2), () => {
2474
- e.off("keypress", t2), n3 && r2.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
2592
+ return n3 && r2.write(cursor.hide), e.once("keypress", t2), () => {
2593
+ e.off("keypress", t2), n3 && r2.write(cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
2475
2594
  };
2476
2595
  }
2477
2596
  var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
2478
2597
  var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
2479
2598
  function wrapTextWithPrefix(e, r2, o2, n3 = o2, s = o2, t2) {
2480
- const f2 = getColumns(e ?? stdout);
2481
- return wrapAnsi(r2, f2 - o2.length, {
2599
+ const l = getColumns(e ?? stdout), i2 = dist_default2(o2);
2600
+ return wrapAnsi(r2, l - i2, {
2482
2601
  hard: true,
2483
2602
  trim: false
2484
2603
  }).split(`
2485
- `).map((c3, i2, m3) => {
2486
- const d = t2 ? t2(c3, i2) : c3;
2487
- return i2 === 0 ? `${n3}${d}` : i2 === m3.length - 1 ? `${s}${d}` : `${o2}${d}`;
2604
+ `).map((c3, a2, g2) => {
2605
+ const m3 = t2 ? t2(c3, a2) : c3;
2606
+ return a2 === 0 ? `${n3}${m3}` : a2 === g2.length - 1 ? `${s}${m3}` : `${o2}${m3}`;
2488
2607
  }).join(`
2489
2608
  `);
2490
2609
  }
@@ -2495,7 +2614,7 @@ function runValidation(e, a2) {
2495
2614
  }
2496
2615
  return e(a2);
2497
2616
  }
2498
- var y = class {
2617
+ var C$1 = class C {
2499
2618
  input;
2500
2619
  output;
2501
2620
  _abortSignal;
@@ -2577,16 +2696,16 @@ var y = class {
2577
2696
  { once: true }
2578
2697
  );
2579
2698
  }
2580
- this.rl = l__default.createInterface({
2699
+ this.rl = f__default.createInterface({
2581
2700
  input: this.input,
2582
2701
  tabSize: 2,
2583
2702
  prompt: "",
2584
2703
  escapeCodeTimeout: 50,
2585
2704
  terminal: true
2586
2705
  }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
2587
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
2706
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
2588
2707
  }), this.once("cancel", () => {
2589
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
2708
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
2590
2709
  });
2591
2710
  });
2592
2711
  }
@@ -2623,18 +2742,18 @@ var y = class {
2623
2742
  `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
2624
2743
  }
2625
2744
  restoreCursor() {
2626
- const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
2745
+ const t2 = wrapAnsi(this._prevFrame, getColumns(this.output), { hard: true, trim: false }).split(`
2627
2746
  `).length - 1;
2628
- this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
2747
+ this.output.write(cursor.move(-999, t2 * -1));
2629
2748
  }
2630
2749
  render() {
2631
- const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
2750
+ const t2 = wrapAnsi(this._render(this) ?? "", getColumns(this.output), {
2632
2751
  hard: true,
2633
2752
  trim: false
2634
2753
  });
2635
2754
  if (t2 !== this._prevFrame) {
2636
2755
  if (this.state === "initial")
2637
- this.output.write(import_sisteransi.cursor.hide);
2756
+ this.output.write(cursor.hide);
2638
2757
  else {
2639
2758
  const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
2640
2759
  if (this.restoreCursor(), e) {
@@ -2645,46 +2764,46 @@ var y = class {
2645
2764
  return;
2646
2765
  }
2647
2766
  if (e.lines.length === 1) {
2648
- this.output.write(import_sisteransi.cursor.move(0, n3 - r2)), this.output.write(import_sisteransi.erase.lines(1));
2767
+ this.output.write(cursor.move(0, n3 - r2)), this.output.write(erase.lines(1));
2649
2768
  const o2 = t2.split(`
2650
2769
  `);
2651
- this.output.write(o2[n3]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o2.length - n3 - 1));
2770
+ this.output.write(o2[n3]), this._prevFrame = t2, this.output.write(cursor.move(0, o2.length - n3 - 1));
2652
2771
  return;
2653
2772
  } else if (e.lines.length > 1) {
2654
2773
  if (s < r2)
2655
2774
  n3 = s;
2656
2775
  else {
2657
2776
  const h2 = n3 - r2;
2658
- h2 > 0 && this.output.write(import_sisteransi.cursor.move(0, h2));
2777
+ h2 > 0 && this.output.write(cursor.move(0, h2));
2659
2778
  }
2660
- this.output.write(import_sisteransi.erase.down());
2661
- const f2 = t2.split(`
2779
+ this.output.write(erase.down());
2780
+ const m3 = t2.split(`
2662
2781
  `).slice(n3);
2663
- this.output.write(f2.join(`
2782
+ this.output.write(m3.join(`
2664
2783
  `)), this._prevFrame = t2;
2665
2784
  return;
2666
2785
  }
2667
2786
  }
2668
- this.output.write(import_sisteransi.erase.down());
2787
+ this.output.write(erase.down());
2669
2788
  }
2670
2789
  this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
2671
2790
  }
2672
2791
  }
2673
2792
  };
2674
- function p$1(l2, e) {
2675
- if (l2 === void 0 || e.length === 0)
2793
+ function p$1(l, e) {
2794
+ if (l === void 0 || e.length === 0)
2676
2795
  return 0;
2677
- const i2 = e.findIndex((s) => s.value === l2);
2796
+ const i2 = e.findIndex((s) => s.value === l);
2678
2797
  return i2 !== -1 ? i2 : 0;
2679
2798
  }
2680
- function m(l2, e) {
2681
- return (e.label ?? String(e.value)).toLowerCase().includes(l2.toLowerCase());
2799
+ function m(l, e) {
2800
+ return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
2682
2801
  }
2683
- function g(l2, e) {
2802
+ function g(l, e) {
2684
2803
  if (e)
2685
- return l2 ? e : e[0];
2804
+ return l ? e : e[0];
2686
2805
  }
2687
- var T$1 = class T extends y {
2806
+ var T$1 = class T extends C$1 {
2688
2807
  filteredOptions;
2689
2808
  multiple;
2690
2809
  isNavigating = false;
@@ -2726,11 +2845,11 @@ var T$1 = class T extends y {
2726
2845
  return e === " " || this.multiple && this.isNavigating && t2.name === "space" && e !== void 0 && e !== "";
2727
2846
  }
2728
2847
  #u(e, t2) {
2729
- const i2 = t2.name === "up", s = t2.name === "down", n3 = t2.name === "return", r2 = this.userInput === "" || this.userInput === " ", u5 = this.#n, d = this.options, c3 = u5 !== void 0 && u5 !== "" && d.some(
2730
- (o2) => !o2.disabled && (this.#t ? this.#t(u5, o2) : true)
2848
+ const i2 = t2.name === "up", s = t2.name === "down", n3 = t2.name === "return", r2 = this.userInput === "" || this.userInput === " ", u4 = this.#n, d = this.options, c3 = u4 !== void 0 && u4 !== "" && d.some(
2849
+ (o2) => !o2.disabled && (this.#t ? this.#t(u4, o2) : true)
2731
2850
  );
2732
2851
  if (t2.name === "tab" && r2 && c3) {
2733
- this.userInput === " " && this._clearUserInput(), this._setUserInput(u5, true), this.isNavigating = false;
2852
+ this.userInput === " " && this._clearUserInput(), this._setUserInput(u4, true), this.isNavigating = false;
2734
2853
  return;
2735
2854
  }
2736
2855
  if (t2.name === "tab" && this.#l && !this.multiple && this.focusedValue !== void 0) {
@@ -2758,7 +2877,7 @@ var T$1 = class T extends y {
2758
2877
  }
2759
2878
  }
2760
2879
  };
2761
- var r = class extends y {
2880
+ var r = class extends C$1 {
2762
2881
  get cursor() {
2763
2882
  return this.value ? 0 : 1;
2764
2883
  }
@@ -2769,7 +2888,7 @@ var r = class extends y {
2769
2888
  super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
2770
2889
  this.value = this._value;
2771
2890
  }), this.on("confirm", (i2) => {
2772
- this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
2891
+ this.output.write(cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
2773
2892
  }), this.on("cursor", () => {
2774
2893
  this.value = !this.value;
2775
2894
  });
@@ -2804,7 +2923,7 @@ function f(r2) {
2804
2923
  day: p(r2.day)
2805
2924
  };
2806
2925
  }
2807
- function c(r2, t2) {
2926
+ function c$1(r2, t2) {
2808
2927
  return new Date(r2 || 2001, t2 || 1, 0).getDate();
2809
2928
  }
2810
2929
  function b(r2) {
@@ -2814,7 +2933,7 @@ function b(r2) {
2814
2933
  if (!(n3.getUTCFullYear() !== t2 || n3.getUTCMonth() !== i2 - 1 || n3.getUTCDate() !== s))
2815
2934
  return { year: t2, month: i2, day: s };
2816
2935
  }
2817
- function C(r2) {
2936
+ function C2(r2) {
2818
2937
  const t2 = b(r2);
2819
2938
  return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : void 0;
2820
2939
  }
@@ -2833,10 +2952,10 @@ function T2(r2, t2, i2, s) {
2833
2952
  max: e && t2.year === e.year ? e.month : 12
2834
2953
  } : {
2835
2954
  min: n3 && t2.year === n3.year && t2.month === n3.month ? n3.day : 1,
2836
- max: e && t2.year === e.year && t2.month === e.month ? e.day : c(t2.year, t2.month)
2955
+ max: e && t2.year === e.year && t2.month === e.month ? e.day : c$1(t2.year, t2.month)
2837
2956
  };
2838
2957
  }
2839
- var U = class extends y {
2958
+ var U = class extends C$1 {
2840
2959
  #i;
2841
2960
  #o;
2842
2961
  #t;
@@ -2865,7 +2984,7 @@ var U = class extends y {
2865
2984
  return this.#i.map((i2) => t2[i2.type]).join(this.#o);
2866
2985
  }
2867
2986
  #r() {
2868
- this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? void 0);
2987
+ this._setUserInput(this.#l(this.#t)), this._setValue(C2(this.#t) ?? void 0);
2869
2988
  }
2870
2989
  constructor(t2) {
2871
2990
  const i2 = t2.format ? { segments: M(t2.format), separator: t2.separator ?? "/" } : P(t2.locale), s = t2.separator ?? i2.separator, n3 = t2.format ? M(t2.format) : i2.segments, e = t2.initialValue ?? t2.defaultValue, m3 = e ? {
@@ -2873,7 +2992,7 @@ var U = class extends y {
2873
2992
  month: String(e.getUTCMonth() + 1).padStart(2, "0"),
2874
2993
  day: String(e.getUTCDate()).padStart(2, "0")
2875
2994
  } : { year: "____", month: "__", day: "__" }, o2 = n3.map((a2) => m3[a2.type]).join(s);
2876
- super({ ...t2, initialUserInput: o2 }, false), this.#i = n3, this.#o = s, this.#t = m3, this.#h = t2.minDate, this.#u = t2.maxDate, this.#r(), this.on("cursor", (a2) => this.#f(a2)), this.on("key", (a2, u5) => this.#y(a2, u5)), this.on("finalize", () => this.#p(t2));
2995
+ super({ ...t2, initialUserInput: o2 }, false), this.#i = n3, this.#o = s, this.#t = m3, this.#h = t2.minDate, this.#u = t2.maxDate, this.#r(), this.on("cursor", (a2) => this.#f(a2)), this.on("key", (a2, u4) => this.#y(a2, u4)), this.on("finalize", () => this.#p(t2));
2877
2996
  }
2878
2997
  #a() {
2879
2998
  const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i2 = this.#i[t2];
@@ -2953,33 +3072,33 @@ var U = class extends y {
2953
3072
  return;
2954
3073
  }
2955
3074
  this.#n && !m3 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
2956
- const o2 = this.#t[e.type], a2 = o2.indexOf("_"), u5 = a2 >= 0 ? a2 : Math.min(this.#e.positionInSegment, e.len - 1);
2957
- if (u5 < 0 || u5 >= e.len) return;
2958
- let l2 = o2.slice(0, u5) + t2 + o2.slice(u5 + 1), D = false;
2959
- if (u5 === 0 && o2 === "__" && (e.type === "month" || e.type === "day")) {
3075
+ const o2 = this.#t[e.type], a2 = o2.indexOf("_"), u4 = a2 >= 0 ? a2 : Math.min(this.#e.positionInSegment, e.len - 1);
3076
+ if (u4 < 0 || u4 >= e.len) return;
3077
+ let l = o2.slice(0, u4) + t2 + o2.slice(u4 + 1), D = false;
3078
+ if (u4 === 0 && o2 === "__" && (e.type === "month" || e.type === "day")) {
2960
3079
  const h2 = Number.parseInt(t2, 10);
2961
- l2 = `0${t2}`, D = h2 <= (e.type === "month" ? 1 : 2);
3080
+ l = `0${t2}`, D = h2 <= (e.type === "month" ? 1 : 2);
2962
3081
  }
2963
- if (e.type === "year" && (l2 = (o2.replace(/_/g, "") + t2).padStart(e.len, "_")), !l2.includes("_")) {
2964
- const h2 = { ...this.#t, [e.type]: l2 }, d = this.#g(h2, e);
3082
+ if (e.type === "year" && (l = (o2.replace(/_/g, "") + t2).padStart(e.len, "_")), !l.includes("_")) {
3083
+ const h2 = { ...this.#t, [e.type]: l }, d = this.#g(h2, e);
2965
3084
  if (d) {
2966
3085
  this.inlineError = d;
2967
3086
  return;
2968
3087
  }
2969
3088
  }
2970
- this.inlineError = "", this.#t[e.type] = l2;
2971
- const y2 = l2.includes("_") ? void 0 : b(this.#t);
2972
- if (y2) {
2973
- const { year: h2, month: d } = y2, g2 = c(h2, d);
3089
+ this.inlineError = "", this.#t[e.type] = l;
3090
+ const y = l.includes("_") ? void 0 : b(this.#t);
3091
+ if (y) {
3092
+ const { year: h2, month: d } = y, g2 = c$1(h2, d);
2974
3093
  this.#t = {
2975
3094
  year: String(Math.max(0, Math.min(9999, h2))).padStart(4, "0"),
2976
3095
  month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
2977
- day: String(Math.max(1, Math.min(g2, y2.day))).padStart(2, "0")
3096
+ day: String(Math.max(1, Math.min(g2, y.day))).padStart(2, "0")
2978
3097
  };
2979
3098
  }
2980
3099
  this.#r();
2981
- const S = l2.indexOf("_");
2982
- D ? (this.#n = true, this.#s = t2) : S >= 0 ? this.#e.positionInSegment = S : a2 >= 0 && n3.index < this.#i.length - 1 ? (this.#e.segmentIndex = n3.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u5 + 1, e.len - 1);
3100
+ const S = l.indexOf("_");
3101
+ D ? (this.#n = true, this.#s = t2) : S >= 0 ? this.#e.positionInSegment = S : a2 >= 0 && n3.index < this.#i.length - 1 ? (this.#e.segmentIndex = n3.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u4 + 1, e.len - 1);
2983
3102
  }
2984
3103
  }
2985
3104
  #g(t2, i2) {
@@ -2992,62 +3111,64 @@ var U = class extends y {
2992
3111
  #p(t2) {
2993
3112
  const { year: i2, month: s, day: n3 } = f(this.#t);
2994
3113
  if (i2 && s && n3) {
2995
- const e = c(i2, s);
3114
+ const e = c$1(i2, s);
2996
3115
  this.#t = {
2997
3116
  ...this.#t,
2998
3117
  day: String(Math.min(n3, e)).padStart(2, "0")
2999
3118
  };
3000
3119
  }
3001
- this.value = C(this.#t) ?? t2.defaultValue ?? void 0;
3120
+ this.value = C2(this.#t) ?? t2.defaultValue ?? void 0;
3002
3121
  }
3003
3122
  };
3004
- var u$2 = class u extends y {
3123
+ var u$1 = class u extends C$1 {
3005
3124
  options;
3006
3125
  cursor = 0;
3007
- #t;
3126
+ #e;
3008
3127
  getGroupItems(t2) {
3009
- return this.options.filter((r2) => r2.group === t2);
3128
+ return this.options.filter((i2) => i2.group === t2);
3010
3129
  }
3011
3130
  isGroupSelected(t2) {
3012
- const r2 = this.getGroupItems(t2), e = this.value;
3013
- return e === void 0 ? false : r2.every((s) => e.includes(s.value));
3131
+ const i2 = this.getGroupItems(t2), e = this.value;
3132
+ return e === void 0 ? false : i2.every((s) => e.includes(s.value));
3014
3133
  }
3015
3134
  toggleValue() {
3016
3135
  const t2 = this.options[this.cursor];
3017
3136
  if (t2 !== void 0)
3018
3137
  if (this.value === void 0 && (this.value = []), t2.group === true) {
3019
- const r2 = t2.value, e = this.getGroupItems(r2);
3020
- this.isGroupSelected(r2) ? this.value = this.value.filter(
3021
- (s) => e.findIndex((i2) => i2.value === s) === -1
3138
+ const i2 = t2.value, e = this.getGroupItems(i2);
3139
+ this.isGroupSelected(i2) ? this.value = this.value.filter(
3140
+ (s) => e.findIndex((r2) => r2.value === s) === -1
3022
3141
  ) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
3023
3142
  } else {
3024
- const r2 = this.value.includes(t2.value);
3025
- this.value = r2 ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
3143
+ const i2 = this.value.includes(t2.value);
3144
+ this.value = i2 ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
3026
3145
  }
3027
3146
  }
3028
3147
  constructor(t2) {
3029
3148
  super(t2, false);
3030
- const { options: r2 } = t2;
3031
- this.#t = t2.selectableGroups !== false, this.options = Object.entries(r2).flatMap(([e, s]) => [
3149
+ const { options: i2 } = t2;
3150
+ this.#e = t2.selectableGroups !== false, this.options = Object.entries(i2).flatMap(([e, s]) => [
3032
3151
  { value: e, group: true, label: e },
3033
- ...s.map((i2) => ({ ...i2, group: e }))
3152
+ ...s.map((r2) => ({ ...r2, group: e }))
3034
3153
  ]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(
3035
3154
  this.options.findIndex(({ value: e }) => e === t2.cursorAt),
3036
- this.#t ? 0 : 1
3037
- ), this.on("cursor", (e) => {
3155
+ this.#e ? 0 : 1
3156
+ ), this.on("key", (e, s) => {
3157
+ s.name === void 0 && e === "\u3000" && this.toggleValue();
3158
+ }), this.on("cursor", (e) => {
3038
3159
  switch (e) {
3039
3160
  case "left":
3040
3161
  case "up": {
3041
3162
  this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
3042
3163
  const s = this.options[this.cursor]?.group === true;
3043
- !this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
3164
+ !this.#e && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
3044
3165
  break;
3045
3166
  }
3046
3167
  case "down":
3047
3168
  case "right": {
3048
3169
  this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
3049
3170
  const s = this.options[this.cursor]?.group === true;
3050
- !this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
3171
+ !this.#e && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
3051
3172
  break;
3052
3173
  }
3053
3174
  case "space":
@@ -3058,7 +3179,7 @@ var u$2 = class u extends y {
3058
3179
  }
3059
3180
  };
3060
3181
  var o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
3061
- var h = class extends y {
3182
+ var h = class extends C$1 {
3062
3183
  #t = false;
3063
3184
  #s;
3064
3185
  focused = "editor";
@@ -3152,7 +3273,7 @@ ${i2}` : `${s}${styleText("inverse", r2)}${i2}`;
3152
3273
  });
3153
3274
  }
3154
3275
  };
3155
- var a = class extends y {
3276
+ var a = class extends C$1 {
3156
3277
  options;
3157
3278
  cursor = 0;
3158
3279
  get _value() {
@@ -3183,8 +3304,8 @@ var a = class extends y {
3183
3304
  this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt),
3184
3305
  0
3185
3306
  );
3186
- this.cursor = this.options[i2]?.disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2, l2) => {
3187
- l2.name === "a" && this.toggleAll(), l2.name === "i" && this.toggleInvert();
3307
+ this.cursor = this.options[i2]?.disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2, s) => {
3308
+ s.name === "a" && this.toggleAll(), s.name === "i" && this.toggleInvert(), s.name === void 0 && t2 === "\u3000" && this.toggleValue();
3188
3309
  }), this.on("cursor", (t2) => {
3189
3310
  switch (t2) {
3190
3311
  case "left":
@@ -3202,7 +3323,7 @@ var a = class extends y {
3202
3323
  });
3203
3324
  }
3204
3325
  };
3205
- var u$1 = class u2 extends y {
3326
+ var u2 = class extends C$1 {
3206
3327
  _mask = "\u2022";
3207
3328
  get cursor() {
3208
3329
  return this._cursor;
@@ -3230,7 +3351,7 @@ var u$1 = class u2 extends y {
3230
3351
  });
3231
3352
  }
3232
3353
  };
3233
- var n$1 = class n extends y {
3354
+ var n$1 = class n extends C$1 {
3234
3355
  options;
3235
3356
  cursor = 0;
3236
3357
  get _selectedValue() {
@@ -3258,24 +3379,24 @@ var n$1 = class n extends y {
3258
3379
  });
3259
3380
  }
3260
3381
  };
3261
- var u3 = class extends y {
3382
+ var c = class extends C$1 {
3262
3383
  options;
3263
3384
  cursor = 0;
3264
3385
  constructor(t2) {
3265
3386
  super(t2, false), this.options = t2.options;
3266
- const s = t2.caseSensitive === true, i2 = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase());
3267
- this.cursor = Math.max(i2.indexOf(t2.initialValue), 0), this.on("key", (e) => {
3387
+ const s = t2.caseSensitive === true, i2 = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase()), n3 = Math.max(i2.indexOf(t2.initialValue), 0);
3388
+ this.cursor = this.options[n3]?.disabled ? 0 : n3, this.on("key", (e) => {
3268
3389
  if (!e)
3269
3390
  return;
3270
3391
  const o2 = s ? e : e.toLowerCase();
3271
3392
  if (!i2.includes(o2))
3272
3393
  return;
3273
- const n3 = this.options.find(({ value: [r2] }) => s ? r2 === o2 : r2?.toLowerCase() === o2);
3274
- n3 && (this.value = n3.value, this.state = "submit", this.emit("submit"));
3394
+ const r2 = this.options.find(({ value: [a2], disabled: u4 }) => u4 ? false : s ? a2 === o2 : a2?.toLowerCase() === o2);
3395
+ r2 && (this.value = r2.value, this.state = "submit", this.emit("submit"));
3275
3396
  });
3276
3397
  }
3277
3398
  };
3278
- var n2 = class extends y {
3399
+ var n2 = class extends C$1 {
3279
3400
  get userInputWithCursor() {
3280
3401
  if (this.state === "submit")
3281
3402
  return this.userInput;
@@ -3303,7 +3424,6 @@ var n2 = class extends y {
3303
3424
  // node_modules/@clack/prompts/dist/index.mjs
3304
3425
  import { styleText as styleText2, stripVTControlCharacters } from "node:util";
3305
3426
  import process$1 from "node:process";
3306
- var import_sisteransi2 = __toESM(require_src(), 1);
3307
3427
  import { existsSync, lstatSync, readdirSync } from "node:fs";
3308
3428
  import { dirname, join } from "node:path";
3309
3429
  function isUnicodeSupported() {
@@ -3314,8 +3434,8 @@ function isUnicodeSupported() {
3314
3434
  }
3315
3435
  var unicode = isUnicodeSupported();
3316
3436
  var isCI = () => process.env.CI === "true";
3317
- var isTTY = (o2) => o2.isTTY === true;
3318
- var unicodeOr = (o2, e) => unicode ? o2 : e;
3437
+ var isTTY = (e) => e.isTTY === true;
3438
+ var unicodeOr = (e, o2) => unicode ? e : o2;
3319
3439
  var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
3320
3440
  var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
3321
3441
  var S_STEP_ERROR = unicodeOr("\u25B2", "x");
@@ -3341,8 +3461,8 @@ var S_INFO = unicodeOr("\u25CF", "\u2022");
3341
3461
  var S_SUCCESS = unicodeOr("\u25C6", "*");
3342
3462
  var S_WARN = unicodeOr("\u25B2", "!");
3343
3463
  var S_ERROR = unicodeOr("\u25A0", "x");
3344
- var symbol = (o2) => {
3345
- switch (o2) {
3464
+ var symbol = (e) => {
3465
+ switch (e) {
3346
3466
  case "initial":
3347
3467
  case "active":
3348
3468
  return styleText2("cyan", S_STEP_ACTIVE);
@@ -3356,8 +3476,8 @@ var symbol = (o2) => {
3356
3476
  return styleText2("dim", S_STEP_ACTIVE);
3357
3477
  }
3358
3478
  };
3359
- var symbolBar = (o2) => {
3360
- switch (o2) {
3479
+ var symbolBar = (e) => {
3480
+ switch (e) {
3361
3481
  case "initial":
3362
3482
  case "active":
3363
3483
  return styleText2("cyan", S_BAR);
@@ -3369,49 +3489,50 @@ var symbolBar = (o2) => {
3369
3489
  return styleText2("green", S_BAR);
3370
3490
  }
3371
3491
  };
3372
- function formatInstructionFooter(o2, e) {
3373
- const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o2.join(" \u2022 ")}`];
3374
- return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
3492
+ function formatInstructionFooter(e, o2, r2) {
3493
+ const s = r2 ? `${styleText2("cyan", S_BAR)} ` : "", n3 = wrapTextWithPrefix(e, o2.join(" \u2022 "), s).split(`
3494
+ `);
3495
+ return r2 && n3.push(styleText2("cyan", S_BAR_END)), n3;
3375
3496
  }
3376
- var I = (l2, e, w, p3, b3, C3 = false) => {
3497
+ var E$1 = (l, e, w, p3, b3, C4 = false) => {
3377
3498
  let r2 = e, O = 0;
3378
- if (C3)
3499
+ if (C4)
3379
3500
  for (let i2 = p3 - 1; i2 >= w; i2--) {
3380
- const m3 = l2[i2];
3501
+ const m3 = l[i2];
3381
3502
  if (m3 && (r2 -= m3.length), O++, r2 <= b3) break;
3382
3503
  }
3383
3504
  else
3384
3505
  for (let i2 = w; i2 < p3; i2++) {
3385
- const m3 = l2[i2];
3506
+ const m3 = l[i2];
3386
3507
  if (m3 && (r2 -= m3.length), O++, r2 <= b3) break;
3387
3508
  }
3388
3509
  return { lineCount: r2, removals: O };
3389
3510
  };
3390
3511
  var limitOptions = ({
3391
- cursor: l2,
3512
+ cursor: l,
3392
3513
  options: e,
3393
3514
  style: w,
3394
3515
  output: p3 = process.stdout,
3395
3516
  maxItems: b3 = Number.POSITIVE_INFINITY,
3396
- columnPadding: C3 = 0,
3517
+ columnPadding: C4 = 0,
3397
3518
  rowPadding: r2 = 4
3398
3519
  }) => {
3399
- const i2 = getColumns(p3) - C3, m3 = getRows(p3), M2 = styleText2("dim", "..."), v = Math.max(m3 - r2, 0), a2 = Math.max(Math.min(b3, v), 5);
3520
+ const i2 = getColumns(p3) - C4, m3 = getRows(p3), M2 = styleText2("dim", "..."), v = Math.max(m3 - r2, 0), a2 = Math.max(Math.min(b3, v), 5);
3400
3521
  let f2 = 0;
3401
- l2 >= a2 - 3 && (f2 = Math.max(
3402
- Math.min(l2 - a2 + 3, e.length - a2),
3522
+ l >= a2 - 3 && (f2 = Math.max(
3523
+ Math.min(l - a2 + 3, e.length - a2),
3403
3524
  0
3404
3525
  ));
3405
3526
  let d = a2 < e.length && f2 > 0, c3 = a2 < e.length && f2 + a2 < e.length;
3406
- const W2 = Math.min(
3527
+ const I = Math.min(
3407
3528
  f2 + a2,
3408
3529
  e.length
3409
3530
  ), s = [];
3410
3531
  let g2 = 0;
3411
3532
  d && g2++, c3 && g2++;
3412
- const T3 = f2 + (d ? 1 : 0), y2 = W2 - (c3 ? 1 : 0);
3413
- for (let t2 = T3; t2 < y2; t2++) {
3414
- const n3 = e[t2], o2 = n3 ? w(n3, t2 === l2) : "", h2 = wrapAnsi(o2, i2, {
3533
+ const T3 = f2 + (d ? 1 : 0), W2 = I - (c3 ? 1 : 0);
3534
+ for (let t2 = T3; t2 < W2; t2++) {
3535
+ const n3 = e[t2], o2 = n3 !== void 0 ? w(n3, t2 === l) : "", h2 = wrapAnsi(o2, i2, {
3415
3536
  hard: true,
3416
3537
  trim: false
3417
3538
  }).split(`
@@ -3420,17 +3541,17 @@ var limitOptions = ({
3420
3541
  }
3421
3542
  if (g2 > v) {
3422
3543
  let t2 = 0, n3 = 0, o2 = g2;
3423
- const h2 = l2 - T3;
3424
- let u5 = v;
3425
- const L = () => I(s, o2, 0, h2, u5), E2 = () => I(
3544
+ const h2 = l - T3;
3545
+ let u4 = v;
3546
+ const L = () => E$1(s, o2, 0, h2, u4), y = () => E$1(
3426
3547
  s,
3427
3548
  o2,
3428
3549
  h2 + 1,
3429
3550
  s.length,
3430
- u5,
3551
+ u4,
3431
3552
  true
3432
3553
  );
3433
- d ? ({ lineCount: o2, removals: t2 } = L(), o2 > u5 && (c3 || (u5 -= 1), { lineCount: o2, removals: n3 } = E2())) : (c3 || (u5 -= 1), { lineCount: o2, removals: n3 } = E2(), o2 > u5 && (u5 -= 1, { lineCount: o2, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n3 > 0 && (c3 = true, s.splice(s.length - n3, n3));
3554
+ d ? ({ lineCount: o2, removals: t2 } = L(), o2 > u4 && (c3 || (u4 -= 1), { lineCount: o2, removals: n3 } = y())) : (c3 || (u4 -= 1), { lineCount: o2, removals: n3 } = y(), o2 > u4 && (u4 -= 1, { lineCount: o2, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n3 > 0 && (c3 = true, s.splice(s.length - n3, n3));
3434
3555
  }
3435
3556
  const x2 = [];
3436
3557
  d && x2.push(M2);
@@ -3456,7 +3577,7 @@ function j(t2, c3) {
3456
3577
  }
3457
3578
  var autocomplete = (t2) => new T$1({
3458
3579
  options: t2.options,
3459
- initialValue: t2.initialValue ? [t2.initialValue] : void 0,
3580
+ initialValue: t2.initialValue !== void 0 ? [t2.initialValue] : void 0,
3460
3581
  initialUserInput: t2.initialUserInput,
3461
3582
  placeholder: t2.placeholder,
3462
3583
  completeOnTab: t2.completeOnTab,
@@ -3466,11 +3587,11 @@ var autocomplete = (t2) => new T$1({
3466
3587
  output: t2.output,
3467
3588
  validate: t2.validate,
3468
3589
  render() {
3469
- const n3 = t2.withGuide ?? settings.withGuide, i2 = n3 ? [`${styleText2("gray", S_BAR)}`, `${symbol(this.state)} ${t2.message}`] : [`${symbol(this.state)} ${t2.message}`], r2 = this.userInput, o2 = this.options, m3 = t2.placeholder, p3 = r2 === "" && m3 !== void 0, $ = (l2, s) => {
3470
- const a2 = E(l2), u5 = l2.hint && l2.value === this.focusedValue ? styleText2("dim", ` (${l2.hint})`) : "";
3590
+ const n3 = t2.withGuide ?? settings.withGuide, i2 = n3 ? [`${styleText2("gray", S_BAR)}`, `${symbol(this.state)} ${t2.message}`] : [`${symbol(this.state)} ${t2.message}`], r2 = this.userInput, o2 = this.options, m3 = t2.placeholder, p3 = r2 === "" && m3 !== void 0, $ = (l, s) => {
3591
+ const a2 = E(l), u4 = l.hint && l.value === this.focusedValue ? styleText2("dim", ` (${l.hint})`) : "";
3471
3592
  switch (s) {
3472
3593
  case "active":
3473
- return `${styleText2("green", S_RADIO_ACTIVE)} ${a2}${u5}`;
3594
+ return `${styleText2("green", S_RADIO_ACTIVE)} ${a2}${u4}`;
3474
3595
  case "inactive":
3475
3596
  return `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a2)}`;
3476
3597
  case "disabled":
@@ -3479,33 +3600,33 @@ var autocomplete = (t2) => new T$1({
3479
3600
  };
3480
3601
  switch (this.state) {
3481
3602
  case "submit": {
3482
- const l2 = j(this.selectedValues, o2), s = l2.length > 0 ? ` ${styleText2("dim", l2.map(E).join(", "))}` : "", a2 = n3 ? styleText2("gray", S_BAR) : "";
3603
+ const l = j(this.selectedValues, o2), s = l.length > 0 ? ` ${styleText2("dim", l.map(E).join(", "))}` : "", a2 = n3 ? styleText2("gray", S_BAR) : "";
3483
3604
  return `${i2.join(`
3484
3605
  `)}
3485
3606
  ${a2}${s}`;
3486
3607
  }
3487
3608
  case "cancel": {
3488
- const l2 = r2 ? ` ${styleText2(["strikethrough", "dim"], r2)}` : "", s = n3 ? styleText2("gray", S_BAR) : "";
3609
+ const l = r2 ? ` ${styleText2(["strikethrough", "dim"], r2)}` : "", s = n3 ? styleText2("gray", S_BAR) : "";
3489
3610
  return `${i2.join(`
3490
3611
  `)}
3491
- ${s}${l2}`;
3612
+ ${s}${l}`;
3492
3613
  }
3493
3614
  default: {
3494
- const l2 = this.state === "error" ? "yellow" : "cyan", s = n3 ? `${styleText2(l2, S_BAR)} ` : "", a2 = n3 ? styleText2(l2, S_BAR_END) : "";
3495
- let u5 = "";
3615
+ const l = this.state === "error" ? "yellow" : "cyan", s = n3 ? `${styleText2(l, S_BAR)} ` : "", a2 = n3 ? styleText2(l, S_BAR_END) : "";
3616
+ let u4 = "";
3496
3617
  if (this.isNavigating || p3) {
3497
3618
  const d = p3 ? m3 : r2;
3498
- u5 = d !== "" ? ` ${styleText2("dim", d)}` : "";
3619
+ u4 = d !== "" ? ` ${styleText2("dim", d)}` : "";
3499
3620
  } else
3500
- u5 = ` ${this.userInputWithCursor}`;
3621
+ u4 = ` ${this.userInputWithCursor}`;
3501
3622
  const V = this.filteredOptions.length !== o2.length ? styleText2(
3502
3623
  "dim",
3503
3624
  ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
3504
- ) : "", b3 = this.filteredOptions.length === 0 && r2 ? [`${s}${styleText2("yellow", "No matches found")}`] : [], y2 = this.state === "error" ? [`${s}${styleText2("yellow", this.error)}`] : [];
3625
+ ) : "", b3 = this.filteredOptions.length === 0 && r2 ? [`${s}${styleText2("yellow", "No matches found")}`] : [], y = this.state === "error" ? [`${s}${styleText2("yellow", this.error)}`] : [];
3505
3626
  n3 && i2.push(`${s.trimEnd()}`), i2.push(
3506
- `${s}${styleText2("dim", "Search:")}${u5}${V}`,
3627
+ `${s}${styleText2("dim", "Search:")}${u4}${V}`,
3507
3628
  ...b3,
3508
- ...y2
3629
+ ...y
3509
3630
  );
3510
3631
  const S = [
3511
3632
  `${styleText2("dim", "\u2191/\u2193")} to select`,
@@ -3537,8 +3658,8 @@ ${s}${l2}`;
3537
3658
  }).prompt();
3538
3659
  var autocompleteMultiselect = (t2) => {
3539
3660
  const c3 = (i2, r2, o2, m3) => {
3540
- const p3 = o2.includes(i2.value), $ = i2.label ?? String(i2.value ?? ""), l2 = i2.hint && m3 !== void 0 && i2.value === m3 ? styleText2("dim", ` (${i2.hint})`) : "", s = p3 ? styleText2("green", S_CHECKBOX_SELECTED) : styleText2("dim", S_CHECKBOX_INACTIVE);
3541
- return i2.disabled ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${styleText2(["strikethrough", "gray"], $)}` : r2 ? `${s} ${$}${l2}` : `${s} ${styleText2("dim", $)}`;
3661
+ const p3 = o2.includes(i2.value), $ = i2.label ?? String(i2.value ?? ""), l = i2.hint && m3 !== void 0 && i2.value === m3 ? styleText2("dim", ` (${i2.hint})`) : "", s = p3 ? styleText2("green", S_CHECKBOX_SELECTED) : styleText2("dim", S_CHECKBOX_INACTIVE);
3662
+ return i2.disabled ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${styleText2(["strikethrough", "gray"], $)}` : r2 ? `${s} ${$}${l}` : `${s} ${styleText2("dim", $)}`;
3542
3663
  }, n3 = new T$1({
3543
3664
  options: t2.options,
3544
3665
  multiple: true,
@@ -3555,7 +3676,7 @@ var autocompleteMultiselect = (t2) => {
3555
3676
  render() {
3556
3677
  const i2 = t2.withGuide ?? settings.withGuide, r2 = `${i2 ? `${styleText2("gray", S_BAR)}
3557
3678
  ` : ""}${symbol(this.state)} ${t2.message}
3558
- `, o2 = this.userInput, m3 = t2.placeholder, p3 = o2 === "" && m3 !== void 0, $ = this.isNavigating || p3 ? styleText2("dim", p3 ? m3 : o2) : this.userInputWithCursor, l2 = this.options, s = this.filteredOptions.length !== l2.length ? styleText2(
3679
+ `, o2 = this.userInput, m3 = t2.placeholder, p3 = o2 === "" && m3 !== void 0, $ = this.isNavigating || p3 ? styleText2("dim", p3 ? m3 : o2) : this.userInputWithCursor, l = this.options, s = this.filteredOptions.length !== l.length ? styleText2(
3559
3680
  "dim",
3560
3681
  ` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
3561
3682
  ) : "";
@@ -3571,18 +3692,18 @@ var autocompleteMultiselect = (t2) => {
3571
3692
  o2
3572
3693
  )}`;
3573
3694
  default: {
3574
- const a2 = this.state === "error" ? "yellow" : "cyan", u5 = i2 ? `${styleText2(a2, S_BAR)} ` : "", V = i2 ? styleText2(a2, S_BAR_END) : "", b3 = [
3695
+ const a2 = this.state === "error" ? "yellow" : "cyan", u4 = i2 ? `${styleText2(a2, S_BAR)} ` : "", V = i2 ? styleText2(a2, S_BAR_END) : "", b3 = [
3575
3696
  `${styleText2("dim", "\u2191/\u2193")} to navigate`,
3576
3697
  `${styleText2("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
3577
3698
  `${styleText2("dim", "Enter:")} confirm`,
3578
3699
  `${styleText2("dim", "Type:")} to search`
3579
- ], y2 = this.filteredOptions.length === 0 && o2 ? [`${u5}${styleText2("yellow", "No matches found")}`] : [], S = this.state === "error" ? [`${u5}${styleText2("yellow", this.error)}`] : [], g2 = [
3700
+ ], y = this.filteredOptions.length === 0 && o2 ? [`${u4}${styleText2("yellow", "No matches found")}`] : [], S = this.state === "error" ? [`${u4}${styleText2("yellow", this.error)}`] : [], g2 = [
3580
3701
  ...`${r2}${i2 ? styleText2(a2, S_BAR) : ""}`.split(`
3581
3702
  `),
3582
- `${u5}${styleText2("dim", "Search:")} ${$}${s}`,
3583
- ...y2,
3703
+ `${u4}${styleText2("dim", "Search:")} ${$}${s}`,
3704
+ ...y,
3584
3705
  ...S
3585
- ], O = [`${u5}${b3.join(" \u2022 ")}`, V], d = limitOptions({
3706
+ ], O = [`${u4}${b3.join(" \u2022 ")}`, V], d = limitOptions({
3586
3707
  cursor: this.cursor,
3587
3708
  options: this.filteredOptions,
3588
3709
  style: (f2, L) => c3(f2, L, this.selectedValues, this.focusedValue),
@@ -3592,7 +3713,7 @@ var autocompleteMultiselect = (t2) => {
3592
3713
  });
3593
3714
  return [
3594
3715
  ...g2,
3595
- ...d.map((f2) => `${u5}${f2}`),
3716
+ ...d.map((f2) => `${u4}${f2}`),
3596
3717
  ...O
3597
3718
  ].join(`
3598
3719
  `);
@@ -3615,12 +3736,12 @@ function A$1(n3, e, t2, o2) {
3615
3736
  }
3616
3737
  var U2 = (n3) => n3;
3617
3738
  var box = (n3 = "", e = "", t2) => {
3618
- const o2 = t2?.output ?? process.stdout, i2 = getColumns(o2), R2 = 1 * 2, u5 = t2?.titlePadding ?? 1, h2 = t2?.contentPadding ?? 2, w = t2?.width === void 0 || t2.width === "auto" ? 1 : Math.min(1, t2.width), m3 = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)} ` : "", b3 = t2?.formatBorder ?? U2, a2 = (t2?.rounded ? K : Q).map(b3), _2 = b3(S_BAR_H), p3 = b3(S_BAR), x2 = dist_default2(m3), B = dist_default2(e), y2 = i2 - x2;
3739
+ const o2 = t2?.output ?? process.stdout, i2 = getColumns(o2), R2 = 1 * 2, u4 = t2?.titlePadding ?? 1, h2 = t2?.contentPadding ?? 2, w = t2?.width === void 0 || t2.width === "auto" ? 1 : Math.min(1, t2.width), m3 = t2?.withGuide ?? settings.withGuide ? `${styleText2("gray", S_BAR)} ` : "", b3 = t2?.formatBorder ?? U2, a2 = (t2?.rounded ? K : Q).map(b3), _2 = b3(S_BAR_H), p3 = b3(S_BAR), x2 = dist_default2(m3), B = dist_default2(e), y = i2 - x2;
3619
3740
  let r2 = Math.floor(i2 * w) - x2;
3620
3741
  if (t2?.width === "auto") {
3621
3742
  const c3 = n3.split(`
3622
3743
  `);
3623
- let s = B + u5 * 2;
3744
+ let s = B + u4 * 2;
3624
3745
  for (const G of c3) {
3625
3746
  const P3 = dist_default2(G) + h2 * 2;
3626
3747
  P3 > s && (s = P3);
@@ -3628,11 +3749,11 @@ var box = (n3 = "", e = "", t2) => {
3628
3749
  const g2 = s + R2;
3629
3750
  g2 < r2 && (r2 = g2);
3630
3751
  }
3631
- r2 % 2 !== 0 && (r2 < y2 ? r2++ : r2--);
3632
- const d = r2 - R2, T3 = d - u5 * 2, S = B > T3 ? `${e.slice(0, T3 - 3)}...` : e, [O, W2] = A$1(
3752
+ r2 % 2 !== 0 && (r2 < y ? r2++ : r2--);
3753
+ const d = r2 - R2, T3 = d - u4 * 2, S = B > T3 ? `${e.slice(0, T3 - 3)}...` : e, [O, W2] = A$1(
3633
3754
  dist_default2(S),
3634
3755
  d,
3635
- u5,
3756
+ u4,
3636
3757
  t2?.titleAlign
3637
3758
  ), L = wrapAnsi(n3, d - h2 * 2, {
3638
3759
  hard: true,
@@ -3669,11 +3790,11 @@ var confirm = (e) => {
3669
3790
  output: e.output,
3670
3791
  initialValue: e.initialValue ?? true,
3671
3792
  render() {
3672
- const i2 = e.withGuide ?? settings.withGuide, u5 = `${symbol(this.state)} `, l2 = i2 ? `${styleText2("gray", S_BAR)} ` : "", f2 = wrapTextWithPrefix(
3793
+ const i2 = e.withGuide ?? settings.withGuide, u4 = `${symbol(this.state)} `, l = i2 ? `${styleText2("gray", S_BAR)} ` : "", f2 = wrapTextWithPrefix(
3673
3794
  e.output,
3674
3795
  e.message,
3675
- l2,
3676
- u5
3796
+ l,
3797
+ u4
3677
3798
  ), s = `${i2 ? `${styleText2("gray", S_BAR)}
3678
3799
  ` : ""}${f2}
3679
3800
  `, c3 = this.value ? a2 : o2;
@@ -3716,7 +3837,7 @@ var date = (e) => {
3716
3837
  render() {
3717
3838
  const t2 = (e?.withGuide ?? settings.withGuide) !== false, i2 = `${`${t2 ? `${styleText2("gray", S_BAR)}
3718
3839
  ` : ""}${symbol(this.state)} `}${e.message}
3719
- `, l2 = this.state !== "initial" ? this.state : "active", d = b2(this, l2), c3 = this.value instanceof Date ? this.formattedValue : "";
3840
+ `, l = this.state !== "initial" ? this.state : "active", d = b2(this, l), c3 = this.value instanceof Date ? this.formattedValue : "";
3720
3841
  switch (this.state) {
3721
3842
  case "error": {
3722
3843
  const a2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", s = t2 ? `${styleText2("yellow", S_BAR)} ` : "", f2 = t2 ? styleText2("yellow", S_BAR_END) : "";
@@ -3750,9 +3871,9 @@ function b2(e, r2) {
3750
3871
  if (r2 === "submit" || r2 === "cancel")
3751
3872
  return e.formattedValue;
3752
3873
  const i2 = styleText2("gray", e.separator);
3753
- return e.segments.map((l2, d) => {
3754
- const c3 = d === o2.segmentIndex && !["submit", "cancel"].includes(r2), a2 = p2[l2.type];
3755
- return x(t2[l2.type], { isActive: c3, label: a2 });
3874
+ return e.segments.map((l, d) => {
3875
+ const c3 = d === o2.segmentIndex && !["submit", "cancel"].includes(r2), a2 = p2[l.type];
3876
+ return x(t2[l.type], { isActive: c3, label: a2 });
3756
3877
  }).join(i2);
3757
3878
  }
3758
3879
  function x(e, r2) {
@@ -3783,22 +3904,22 @@ var MULTISELECT_INSTRUCTIONS = [
3783
3904
  `${styleText2("dim", "Space:")} select`,
3784
3905
  `${styleText2("dim", "Enter:")} confirm`
3785
3906
  ];
3786
- var m2 = (i2, u5) => i2.split(`
3787
- `).map((d) => u5(d)).join(`
3907
+ var m2 = (n3, u4) => n3.split(`
3908
+ `).map((d) => u4(d)).join(`
3788
3909
  `);
3789
- var multiselect = (i2) => {
3790
- const u5 = (t2, a2) => {
3910
+ var multiselect = (n3) => {
3911
+ const u4 = (t2, a2) => {
3791
3912
  const r2 = t2.label ?? String(t2.value);
3792
3913
  return a2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${m2(r2, (o2) => styleText2(["strikethrough", "gray"], o2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : a2 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${m2(r2, (o2) => styleText2("dim", o2))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "cancelled" ? `${m2(r2, (o2) => styleText2(["strikethrough", "dim"], o2))}` : a2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "submitted" ? `${m2(r2, (o2) => styleText2("dim", o2))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${m2(r2, (o2) => styleText2("dim", o2))}`;
3793
- }, d = i2.required ?? true, x2 = i2.showInstructions ?? true;
3914
+ }, d = n3.required ?? true, x2 = n3.showInstructions ?? true;
3794
3915
  return new a({
3795
- options: i2.options,
3796
- signal: i2.signal,
3797
- input: i2.input,
3798
- output: i2.output,
3799
- initialValues: i2.initialValues,
3916
+ options: n3.options,
3917
+ signal: n3.signal,
3918
+ input: n3.input,
3919
+ output: n3.output,
3920
+ initialValues: n3.initialValues,
3800
3921
  required: d,
3801
- cursorAt: i2.cursorAt,
3922
+ cursorAt: n3.cursorAt,
3802
3923
  validate(t2) {
3803
3924
  if (d && (t2 === void 0 || t2.length === 0))
3804
3925
  return `Please select at least one option.
@@ -3814,75 +3935,75 @@ ${styleText2(
3814
3935
  )}`;
3815
3936
  },
3816
3937
  render() {
3817
- const t2 = i2.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(
3818
- i2.output,
3819
- i2.message,
3938
+ const t2 = n3.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(
3939
+ n3.output,
3940
+ n3.message,
3820
3941
  t2 ? `${symbolBar(this.state)} ` : "",
3821
3942
  `${symbol(this.state)} `
3822
3943
  ), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
3823
3944
  ` : ""}${a2}
3824
- `, o2 = this.value ?? [], g2 = (n3, l2) => {
3825
- if (n3.disabled)
3826
- return u5(n3, "disabled");
3827
- const s = o2.includes(n3.value);
3828
- return l2 && s ? u5(n3, "active-selected") : s ? u5(n3, "selected") : u5(n3, l2 ? "active" : "inactive");
3945
+ `, o2 = this.value ?? [], g2 = (i2, l) => {
3946
+ if (i2.disabled)
3947
+ return u4(i2, "disabled");
3948
+ const s = o2.includes(i2.value);
3949
+ return l && s ? u4(i2, "active-selected") : s ? u4(i2, "selected") : u4(i2, l ? "active" : "inactive");
3829
3950
  };
3830
3951
  switch (this.state) {
3831
3952
  case "submit": {
3832
- const n3 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u5(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l2 = wrapTextWithPrefix(
3833
- i2.output,
3834
- n3,
3953
+ const i2 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u4(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l = wrapTextWithPrefix(
3954
+ n3.output,
3955
+ i2,
3835
3956
  t2 ? `${styleText2("gray", S_BAR)} ` : ""
3836
3957
  );
3837
- return `${r2}${l2}`;
3958
+ return `${r2}${l}`;
3838
3959
  }
3839
3960
  case "cancel": {
3840
- const n3 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u5(s, "cancelled")).join(styleText2("dim", ", "));
3841
- if (n3.trim() === "")
3961
+ const i2 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u4(s, "cancelled")).join(styleText2("dim", ", "));
3962
+ if (i2.trim() === "")
3842
3963
  return `${r2}${styleText2("gray", S_BAR)}`;
3843
- const l2 = wrapTextWithPrefix(
3844
- i2.output,
3845
- n3,
3964
+ const l = wrapTextWithPrefix(
3965
+ n3.output,
3966
+ i2,
3846
3967
  t2 ? `${styleText2("gray", S_BAR)} ` : ""
3847
3968
  );
3848
- return `${r2}${l2}${t2 ? `
3969
+ return `${r2}${l}${t2 ? `
3849
3970
  ${styleText2("gray", S_BAR)}` : ""}`;
3850
3971
  }
3851
3972
  case "error": {
3852
- const n3 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l2 = this.error.split(`
3973
+ const i2 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l = this.error.split(`
3853
3974
  `).map(
3854
3975
  ($, v) => v === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", $)}` : ` ${$}`
3855
3976
  ).join(`
3856
3977
  `), s = r2.split(`
3857
- `).length, h2 = l2.split(`
3978
+ `).length, h2 = l.split(`
3858
3979
  `).length + 1;
3859
- return `${r2}${n3}${limitOptions({
3860
- output: i2.output,
3980
+ return `${r2}${i2}${limitOptions({
3981
+ output: n3.output,
3861
3982
  options: this.options,
3862
3983
  cursor: this.cursor,
3863
- maxItems: i2.maxItems,
3864
- columnPadding: n3.length,
3984
+ maxItems: n3.maxItems,
3985
+ columnPadding: i2.length,
3865
3986
  rowPadding: s + h2,
3866
3987
  style: g2
3867
3988
  }).join(`
3868
- ${n3}`)}
3869
- ${l2}
3989
+ ${i2}`)}
3990
+ ${l}
3870
3991
  `;
3871
3992
  }
3872
3993
  default: {
3873
- const n3 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l2 = r2.split(`
3874
- `).length, s = x2 ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
3994
+ const i2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l = r2.split(`
3995
+ `).length, s = x2 ? formatInstructionFooter(n3.output, MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
3875
3996
  `), $ = s.length + 1;
3876
- return `${r2}${n3}${limitOptions({
3877
- output: i2.output,
3997
+ return `${r2}${i2}${limitOptions({
3998
+ output: n3.output,
3878
3999
  options: this.options,
3879
4000
  cursor: this.cursor,
3880
- maxItems: i2.maxItems,
3881
- columnPadding: n3.length,
3882
- rowPadding: l2 + $,
4001
+ maxItems: n3.maxItems,
4002
+ columnPadding: i2.length,
4003
+ rowPadding: l + $,
3883
4004
  style: g2
3884
4005
  }).join(`
3885
- ${n3}`)}
4006
+ ${i2}`)}
3886
4007
  ${h2}
3887
4008
  `;
3888
4009
  }
@@ -3890,83 +4011,83 @@ ${h2}
3890
4011
  }
3891
4012
  }).prompt();
3892
4013
  };
3893
- var groupMultiselect = (o2) => {
3894
- const { selectableGroups: f2 = true, groupSpacing: x2 = 0 } = o2, d = (n3, l2, p3 = []) => {
3895
- const a2 = n3.label ?? String(n3.value), t2 = typeof n3.group == "string", s = t2 && (p3[p3.indexOf(n3) + 1] ?? { group: true }), u5 = t2 && s && s.group === true;
3896
- let r2 = "", c3 = "";
3897
- t2 && (f2 ? (r2 = u5 ? `${S_BAR_END} ` : `${S_BAR} `, c3 = u5 ? " " : `${S_BAR} `) : r2 = " ");
4014
+ var groupMultiselect = (r2) => {
4015
+ const { selectableGroups: f2 = true, groupSpacing: x2 = 0 } = r2, d = (n3, l, p3 = []) => {
4016
+ const a2 = n3.label ?? String(n3.value), t2 = typeof n3.group == "string", u4 = t2 && (p3[p3.indexOf(n3) + 1] ?? { group: true }), s = t2 && u4 && u4.group === true;
4017
+ let o2 = "", c3 = "";
4018
+ t2 && (f2 ? (o2 = s ? `${S_BAR_END} ` : `${S_BAR} `, c3 = s ? " " : `${S_BAR} `) : o2 = " ");
3898
4019
  let i2 = "";
3899
4020
  if (x2 > 0 && !t2 && (i2 = `
3900
- `.repeat(x2)), l2 === "active")
4021
+ `.repeat(x2)), l === "active")
3901
4022
  return wrapTextWithPrefix(
3902
- o2.output,
4023
+ r2.output,
3903
4024
  `${a2}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`,
3904
- `${i2}${styleText2("dim", r2)} `,
3905
- `${i2}${styleText2("dim", r2)}${styleText2("cyan", S_CHECKBOX_ACTIVE)} `,
4025
+ `${i2}${styleText2("dim", o2)} `,
4026
+ `${i2}${styleText2("dim", o2)}${styleText2("cyan", S_CHECKBOX_ACTIVE)} `,
3906
4027
  `${i2}${styleText2("dim", c3)} `
3907
4028
  );
3908
- if (l2 === "group-active")
4029
+ if (l === "group-active")
3909
4030
  return wrapTextWithPrefix(
3910
- o2.output,
4031
+ r2.output,
3911
4032
  a2,
3912
- `${i2}${r2} `,
3913
- `${i2}${r2}${styleText2("cyan", S_CHECKBOX_ACTIVE)} `,
4033
+ `${i2}${o2} `,
4034
+ `${i2}${o2}${styleText2("cyan", S_CHECKBOX_ACTIVE)} `,
3914
4035
  `${i2}${c3} `,
3915
4036
  (m3) => styleText2("dim", m3)
3916
4037
  );
3917
- if (l2 === "group-active-selected")
4038
+ if (l === "group-active-selected")
3918
4039
  return wrapTextWithPrefix(
3919
- o2.output,
4040
+ r2.output,
3920
4041
  a2,
3921
- `${i2}${r2} `,
3922
- `${i2}${r2}${styleText2("green", S_CHECKBOX_SELECTED)} `,
4042
+ `${i2}${o2} `,
4043
+ `${i2}${o2}${styleText2("green", S_CHECKBOX_SELECTED)} `,
3923
4044
  `${i2}${c3} `,
3924
4045
  (m3) => styleText2("dim", m3)
3925
4046
  );
3926
- if (l2 === "selected") {
4047
+ if (l === "selected") {
3927
4048
  const m3 = t2 || f2 ? styleText2("green", S_CHECKBOX_SELECTED) : "";
3928
4049
  return wrapTextWithPrefix(
3929
- o2.output,
4050
+ r2.output,
3930
4051
  `${a2}${n3.hint ? ` (${n3.hint})` : ""}`,
3931
- `${i2}${styleText2("dim", r2)} `,
3932
- `${i2}${styleText2("dim", r2)}${m3} `,
4052
+ `${i2}${styleText2("dim", o2)} `,
4053
+ `${i2}${styleText2("dim", o2)}${m3} `,
3933
4054
  `${i2}${styleText2("dim", c3)} `,
3934
- (I2) => styleText2("dim", I2)
4055
+ (I) => styleText2("dim", I)
3935
4056
  );
3936
4057
  }
3937
- if (l2 === "cancelled")
4058
+ if (l === "cancelled")
3938
4059
  return `${styleText2(["strikethrough", "dim"], a2)}`;
3939
- if (l2 === "active-selected")
4060
+ if (l === "active-selected")
3940
4061
  return wrapTextWithPrefix(
3941
- o2.output,
4062
+ r2.output,
3942
4063
  `${a2}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`,
3943
- `${i2}${styleText2("dim", r2)} `,
3944
- `${i2}${styleText2("dim", r2)}${styleText2("green", S_CHECKBOX_SELECTED)} `,
4064
+ `${i2}${styleText2("dim", o2)} `,
4065
+ `${i2}${styleText2("dim", o2)}${styleText2("green", S_CHECKBOX_SELECTED)} `,
3945
4066
  `${i2}${styleText2("dim", c3)} `
3946
4067
  );
3947
- if (l2 === "submitted")
4068
+ if (l === "submitted")
3948
4069
  return `${styleText2("dim", a2)}`;
3949
4070
  const h2 = t2 || f2 ? styleText2("dim", S_CHECKBOX_INACTIVE) : "";
3950
4071
  return wrapTextWithPrefix(
3951
- o2.output,
4072
+ r2.output,
3952
4073
  a2,
3953
- `${i2}${styleText2("dim", r2)} `,
3954
- `${i2}${styleText2("dim", r2)}${h2} `,
4074
+ `${i2}${styleText2("dim", o2)} `,
4075
+ `${i2}${styleText2("dim", o2)}${h2} `,
3955
4076
  `${i2}${styleText2("dim", c3)} `,
3956
4077
  (m3) => styleText2("dim", m3)
3957
4078
  );
3958
- }, y2 = o2.required ?? true, S = o2.showInstructions ?? true;
3959
- return new u$2({
3960
- options: o2.options,
3961
- signal: o2.signal,
3962
- input: o2.input,
3963
- output: o2.output,
3964
- initialValues: o2.initialValues,
3965
- required: y2,
3966
- cursorAt: o2.cursorAt,
4079
+ }, y = r2.required ?? true, S = r2.showInstructions ?? true;
4080
+ return new u$1({
4081
+ options: r2.options,
4082
+ signal: r2.signal,
4083
+ input: r2.input,
4084
+ output: r2.output,
4085
+ initialValues: r2.initialValues,
4086
+ required: y,
4087
+ cursorAt: r2.cursorAt,
3967
4088
  selectableGroups: f2,
3968
4089
  validate(n3) {
3969
- if (y2 && (n3 === void 0 || n3.length === 0))
4090
+ if (y && (n3 === void 0 || n3.length === 0))
3970
4091
  return `Please select at least one option.
3971
4092
  ${styleText2(
3972
4093
  "reset",
@@ -3980,58 +4101,58 @@ ${styleText2(
3980
4101
  )}`;
3981
4102
  },
3982
4103
  render() {
3983
- const n3 = o2.withGuide ?? settings.withGuide, l2 = `${n3 ? `${styleText2("gray", S_BAR)}
3984
- ` : ""}${symbol(this.state)} ${o2.message}
3985
- `, p3 = this.value ?? [], a2 = (t2, s) => {
3986
- const u5 = this.options, r2 = p3.includes(t2.value) || t2.group === true && this.isGroupSelected(`${t2.value}`);
3987
- return !s && typeof t2.group == "string" && this.options[this.cursor]?.value === t2.group ? d(t2, r2 ? "group-active-selected" : "group-active", u5) : s && r2 ? d(t2, "active-selected", u5) : r2 ? d(t2, "selected", u5) : d(t2, s ? "active" : "inactive", u5);
4104
+ const n3 = r2.withGuide ?? settings.withGuide, l = `${n3 ? `${styleText2("gray", S_BAR)}
4105
+ ` : ""}${symbol(this.state)} ${r2.message}
4106
+ `, p3 = this.value ?? [], a2 = (t2, u4) => {
4107
+ const s = this.options, o2 = p3.includes(t2.value) || t2.group === true && this.isGroupSelected(`${t2.value}`);
4108
+ return !u4 && typeof t2.group == "string" && this.options[this.cursor]?.value === t2.group ? d(t2, o2 ? "group-active-selected" : "group-active", s) : u4 && o2 ? d(t2, "active-selected", s) : o2 ? d(t2, "selected", s) : d(t2, u4 ? "active" : "inactive", s);
3988
4109
  };
3989
4110
  switch (this.state) {
3990
4111
  case "submit": {
3991
- const t2 = this.options.filter(({ value: u5 }) => p3.includes(u5)).map((u5) => d(u5, "submitted")), s = t2.length === 0 ? "" : ` ${t2.join(styleText2("dim", ", "))}`;
3992
- return `${l2}${n3 ? styleText2("gray", S_BAR) : ""}${s}`;
4112
+ const t2 = this.options.filter(({ value: s }) => p3.includes(s)).map((s) => d(s, "submitted")), u4 = t2.length === 0 ? "" : ` ${t2.join(styleText2("dim", ", "))}`;
4113
+ return `${l}${n3 ? styleText2("gray", S_BAR) : ""}${u4}`;
3993
4114
  }
3994
4115
  case "cancel": {
3995
- const t2 = this.options.filter(({ value: s }) => p3.includes(s)).map((s) => d(s, "cancelled")).join(styleText2("dim", ", "));
3996
- return `${l2}${n3 ? `${styleText2("gray", S_BAR)} ` : ""}${t2.trim() ? `${t2}${n3 ? `
4116
+ const t2 = this.options.filter(({ value: u4 }) => p3.includes(u4)).map((u4) => d(u4, "cancelled")).join(styleText2("dim", ", "));
4117
+ return `${l}${n3 ? `${styleText2("gray", S_BAR)} ` : ""}${t2.trim() ? `${t2}${n3 ? `
3997
4118
  ${styleText2("gray", S_BAR)}` : ""}` : ""}`;
3998
4119
  }
3999
4120
  case "error": {
4000
- const t2 = n3 ? `${styleText2("yellow", S_BAR)} ` : "", s = this.error.split(`
4121
+ const t2 = n3 ? `${styleText2("yellow", S_BAR)} ` : "", u4 = this.error.split(`
4001
4122
  `).map(
4002
4123
  (i2, h2) => h2 === 0 ? `${n3 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", i2)}` : ` ${i2}`
4003
4124
  ).join(`
4004
- `), u5 = l2.split(`
4005
- `).length, r2 = s.split(`
4125
+ `), s = l.split(`
4126
+ `).length, o2 = u4.split(`
4006
4127
  `).length + 1, c3 = limitOptions({
4007
- output: o2.output,
4128
+ output: r2.output,
4008
4129
  options: this.options,
4009
4130
  cursor: this.cursor,
4010
- maxItems: o2.maxItems,
4131
+ maxItems: r2.maxItems,
4011
4132
  columnPadding: t2.length,
4012
- rowPadding: u5 + r2,
4133
+ rowPadding: s + o2,
4013
4134
  style: a2
4014
4135
  }).join(`
4015
4136
  ${t2}`);
4016
- return `${l2}${t2}${c3}
4017
- ${s}
4137
+ return `${l}${t2}${c3}
4138
+ ${u4}
4018
4139
  `;
4019
4140
  }
4020
4141
  default: {
4021
- const t2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", s = l2.split(`
4022
- `).length, u5 = S ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], r2 = u5.join(`
4023
- `), c3 = u5.length + 1, i2 = limitOptions({
4024
- output: o2.output,
4142
+ const t2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", u4 = l.split(`
4143
+ `).length, s = S ? formatInstructionFooter(r2.output, MULTISELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], o2 = s.join(`
4144
+ `), c3 = s.length + 1, i2 = limitOptions({
4145
+ output: r2.output,
4025
4146
  options: this.options,
4026
4147
  cursor: this.cursor,
4027
- maxItems: o2.maxItems,
4148
+ maxItems: r2.maxItems,
4028
4149
  columnPadding: t2.length,
4029
- rowPadding: s + c3,
4150
+ rowPadding: u4 + c3,
4030
4151
  style: a2
4031
4152
  }).join(`
4032
4153
  ${t2}`);
4033
- return `${l2}${t2}${i2}
4034
- ${r2}
4154
+ return `${l}${t2}${i2}
4155
+ ${o2}
4035
4156
  `;
4036
4157
  }
4037
4158
  }
@@ -4043,19 +4164,19 @@ var log = {
4043
4164
  symbol: e = styleText2("gray", S_BAR),
4044
4165
  secondarySymbol: r2 = styleText2("gray", S_BAR),
4045
4166
  output: m3 = process.stdout,
4046
- spacing: l2 = 1,
4167
+ spacing: l = 1,
4047
4168
  withGuide: c3
4048
4169
  } = {}) => {
4049
- const t2 = [], o2 = c3 ?? settings.withGuide, f2 = o2 ? r2 : "", O = o2 ? `${e} ` : "", u5 = o2 ? `${r2} ` : "";
4050
- for (let i2 = 0; i2 < l2; i2++)
4170
+ const t2 = [], o2 = c3 ?? settings.withGuide, f2 = o2 ? r2 : "", O = o2 ? `${e} ` : "", u4 = o2 ? `${r2} ` : "";
4171
+ for (let i2 = 0; i2 < l; i2++)
4051
4172
  t2.push(f2);
4052
4173
  const g2 = Array.isArray(s) ? s : s.split(`
4053
4174
  `);
4054
4175
  if (g2.length > 0) {
4055
- const [i2, ...y2] = g2;
4176
+ const [i2, ...y] = g2;
4056
4177
  i2.length > 0 ? t2.push(`${O}${i2}`) : t2.push(o2 ? e : "");
4057
- for (const p3 of y2)
4058
- p3.length > 0 ? t2.push(`${u5}${p3}`) : t2.push(o2 ? r2 : "");
4178
+ for (const p3 of y)
4179
+ p3.length > 0 ? t2.push(`${u4}${p3}`) : t2.push(o2 ? r2 : "");
4059
4180
  }
4060
4181
  m3.write(`${t2.join(`
4061
4182
  `)}
@@ -4114,57 +4235,57 @@ var multiline = (e) => new h({
4114
4235
  `, h2 = e.placeholder && e.placeholder.length > 0 ? (
4115
4236
  // biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
4116
4237
  styleText2("inverse", e.placeholder[0]) + styleText2("dim", e.placeholder.slice(1))
4117
- ) : styleText2(["inverse", "hidden"], "_"), a2 = this.userInput ? this.userInputWithCursor : h2, l2 = this.value ?? "", d = e.showSubmit ? `
4238
+ ) : styleText2(["inverse", "hidden"], "_"), a2 = this.userInput ? this.userInputWithCursor : h2, l = this.value ?? "", d = e.showSubmit ? `
4118
4239
  ${styleText2(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
4119
4240
  switch (this.state) {
4120
4241
  case "error": {
4121
- const n3 = `${styleText2("yellow", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(e.output, a2, n3, void 0) : a2, u5 = styleText2("yellow", S_BAR_END);
4242
+ const n3 = `${styleText2("yellow", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(e.output, a2, n3, void 0) : a2, u4 = styleText2("yellow", S_BAR_END);
4122
4243
  return `${o2}${r2}
4123
- ${u5} ${styleText2("yellow", this.error)}${d}
4244
+ ${u4} ${styleText2("yellow", this.error)}${d}
4124
4245
  `;
4125
4246
  }
4126
4247
  case "submit": {
4127
4248
  const n3 = `${styleText2("gray", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(
4128
4249
  e.output,
4129
- l2,
4250
+ l,
4130
4251
  n3,
4131
4252
  void 0,
4132
4253
  void 0,
4133
- (u5) => styleText2("dim", u5)
4134
- ) : l2 ? styleText2("dim", l2) : "";
4254
+ (u4) => styleText2("dim", u4)
4255
+ ) : l ? styleText2("dim", l) : "";
4135
4256
  return `${o2}${r2}`;
4136
4257
  }
4137
4258
  case "cancel": {
4138
4259
  const n3 = `${styleText2("gray", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(
4139
4260
  e.output,
4140
- l2,
4261
+ l,
4141
4262
  n3,
4142
4263
  void 0,
4143
4264
  void 0,
4144
- (u5) => styleText2(["strikethrough", "dim"], u5)
4145
- ) : l2 ? styleText2(["strikethrough", "dim"], l2) : "";
4265
+ (u4) => styleText2(["strikethrough", "dim"], u4)
4266
+ ) : l ? styleText2(["strikethrough", "dim"], l) : "";
4146
4267
  return `${o2}${r2}`;
4147
4268
  }
4148
4269
  default: {
4149
- const n3 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "", u5 = i2 ? wrapTextWithPrefix(e.output, a2, n3) : a2;
4150
- return `${o2}${u5}
4270
+ const n3 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "", u4 = i2 ? wrapTextWithPrefix(e.output, a2, n3) : a2;
4271
+ return `${o2}${u4}
4151
4272
  ${r2}${d}
4152
4273
  `;
4153
4274
  }
4154
4275
  }
4155
4276
  }
4156
4277
  }).prompt();
4157
- var W$1 = (o2) => o2;
4158
- var C2 = (o2, e, s) => {
4278
+ var W = (o2) => o2;
4279
+ var C3 = (o2, e, s) => {
4159
4280
  const a2 = {
4160
4281
  hard: true,
4161
4282
  trim: false
4162
4283
  }, i2 = wrapAnsi(o2, e, a2).split(`
4163
- `), c3 = i2.reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), u5 = i2.map(s).reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), g2 = e - (u5 - c3);
4284
+ `), c3 = i2.reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), u4 = i2.map(s).reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0), g2 = e - (u4 - c3);
4164
4285
  return wrapAnsi(o2, g2, a2);
4165
4286
  };
4166
4287
  var note = (o2 = "", e = "", s) => {
4167
- const a2 = s?.output ?? process$1.stdout, i2 = s?.withGuide ?? settings.withGuide, c3 = s?.format ?? W$1, g2 = ["", ...C2(o2, getColumns(a2) - 6, c3).split(`
4288
+ const a2 = s?.output ?? process$1.stdout, i2 = s?.withGuide ?? settings.withGuide, c3 = s?.format ?? W, g2 = ["", ...C3(o2, getColumns(a2) - 6, c3).split(`
4168
4289
  `).map(c3), ""], n3 = dist_default2(e), t2 = Math.max(
4169
4290
  g2.reduce((m3, F) => {
4170
4291
  const O = dist_default2(F);
@@ -4186,7 +4307,7 @@ ${styleText2("gray", l$1 + S_BAR_H.repeat(t2 + 2) + S_CORNER_BOTTOM_RIGHT)}
4186
4307
  `
4187
4308
  );
4188
4309
  };
4189
- var password = (e) => new u$1({
4310
+ var password = (e) => new u2({
4190
4311
  validate: e.validate,
4191
4312
  mask: e.mask ?? S_PASSWORD_MASK,
4192
4313
  signal: e.signal,
@@ -4243,17 +4364,18 @@ var path = (e) => {
4243
4364
  return [];
4244
4365
  try {
4245
4366
  let i2;
4246
- existsSync(t2) ? lstatSync(t2).isDirectory() && (!e.directory || t2.endsWith("/")) ? i2 = t2 : i2 = dirname(t2) : i2 = dirname(t2);
4247
- const c3 = t2.length > 1 && t2.endsWith("/") ? t2.slice(0, -1) : t2;
4367
+ const o2 = t2.endsWith("/") || t2.endsWith("\\");
4368
+ existsSync(t2) ? lstatSync(t2).isDirectory() && (!e.directory || o2) ? i2 = t2 : i2 = dirname(t2) : i2 = dirname(t2);
4369
+ const m3 = t2.length > 1 && o2 ? t2.slice(0, -1) : t2;
4248
4370
  return readdirSync(i2).map((r2) => {
4249
- const n3 = join(i2, r2), m3 = lstatSync(n3);
4371
+ const n3 = join(i2, r2), l = lstatSync(n3);
4250
4372
  return {
4251
4373
  name: r2,
4252
4374
  path: n3,
4253
- isDirectory: m3.isDirectory()
4375
+ isDirectory: l.isDirectory()
4254
4376
  };
4255
4377
  }).filter(
4256
- ({ path: r2, isDirectory: n3 }) => r2.startsWith(c3) && (n3 || !e.directory)
4378
+ ({ path: r2, isDirectory: n3 }) => r2.startsWith(m3) && (n3 || !e.directory)
4257
4379
  ).map((r2) => ({
4258
4380
  value: r2.path
4259
4381
  }));
@@ -4263,87 +4385,106 @@ var path = (e) => {
4263
4385
  }
4264
4386
  });
4265
4387
  };
4266
- var W = (l2) => styleText2("magenta", l2);
4388
+ var Y = 3e4;
4389
+ var Z = (c3) => styleText2("magenta", c3);
4267
4390
  var spinner = ({
4268
- indicator: l2 = "dots",
4269
- onCancel: h2,
4391
+ indicator: c3 = "dots",
4392
+ onCancel: b3,
4270
4393
  output: n3 = process.stdout,
4271
- cancelMessage: G,
4272
- errorMessage: O,
4273
- frames: E2 = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
4274
- delay: F = unicode ? 80 : 120,
4275
- signal: m3,
4276
- ...I2
4394
+ cancelMessage: _2,
4395
+ errorMessage: C4,
4396
+ frames: M2 = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
4397
+ delay: O = unicode ? 80 : 120,
4398
+ signal: g2,
4399
+ ...E2
4277
4400
  } = {}) => {
4278
- const u5 = isCI();
4279
- let M2, T3, d = false, S = false, s = "", p3, w = performance.now();
4280
- const x2 = getColumns(n3), k = I2?.styleFrame ?? W, g2 = (e) => {
4281
- const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
4282
- S = e === 1, d && (a2(r2, e), S && typeof h2 == "function" && h2());
4283
- }, f2 = () => g2(2), i2 = () => g2(1), A2 = () => {
4284
- process.on("uncaughtExceptionMonitor", f2), process.on("unhandledRejection", f2), process.on("SIGINT", i2), process.on("SIGTERM", i2), process.on("exit", g2), m3 && m3.addEventListener("abort", i2);
4285
- }, H = () => {
4286
- process.removeListener("uncaughtExceptionMonitor", f2), process.removeListener("unhandledRejection", f2), process.removeListener("SIGINT", i2), process.removeListener("SIGTERM", i2), process.removeListener("exit", g2), m3 && m3.removeEventListener("abort", i2);
4287
- }, y2 = () => {
4288
- if (p3 === void 0) return;
4289
- u5 && n3.write(`
4401
+ const u4 = isCI(), h2 = isAccessible(E2.accessible);
4402
+ let x2, I, p3 = false, l = false, r2 = "", v, w = performance.now();
4403
+ const y = getColumns(n3), F = E2?.styleFrame ?? Z, S = (e) => {
4404
+ const s = e > 1 ? C4 ?? settings.messages.error : _2 ?? settings.messages.cancel;
4405
+ l = e === 1, p3 && (m3(s, e), l && typeof b3 == "function" && b3());
4406
+ }, $ = () => S(2), a2 = () => S(1), H = () => {
4407
+ process.on("uncaughtExceptionMonitor", $), process.on("unhandledRejection", $), process.on("SIGINT", a2), process.on("SIGTERM", a2), process.on("exit", S), g2 && g2.addEventListener("abort", a2);
4408
+ }, B = () => {
4409
+ process.removeListener("uncaughtExceptionMonitor", $), process.removeListener("unhandledRejection", $), process.removeListener("SIGINT", a2), process.removeListener("SIGTERM", a2), process.removeListener("exit", S), g2 && g2.removeEventListener("abort", a2);
4410
+ }, R2 = () => {
4411
+ if (v === void 0) return;
4412
+ u4 && n3.write(`
4290
4413
  `);
4291
- const r2 = wrapAnsi(p3, x2, {
4414
+ const s = wrapAnsi(v, y, {
4292
4415
  hard: true,
4293
4416
  trim: false
4294
4417
  }).split(`
4295
4418
  `);
4296
- r2.length > 1 && n3.write(import_sisteransi2.cursor.up(r2.length - 1)), n3.write(import_sisteransi2.cursor.to(0)), n3.write(import_sisteransi2.erase.down());
4297
- }, C3 = (e) => e.replace(/\.+$/, ""), _2 = (e) => {
4298
- const r2 = (performance.now() - e) / 1e3, t2 = Math.floor(r2 / 60), o2 = Math.floor(r2 % 60);
4299
- return t2 > 0 ? `[${t2}m ${o2}s]` : `[${o2}s]`;
4300
- }, N = I2.withGuide ?? settings.withGuide, P3 = (e = "") => {
4301
- d = true, M2 = block({ output: n3 }), s = C3(e), w = performance.now(), N && n3.write(`${styleText2("gray", S_BAR)}
4419
+ s.length > 1 && n3.write(cursor.up(s.length - 1)), n3.write(cursor.to(0)), n3.write(erase.down());
4420
+ }, L = (e) => e.replace(/\.+$/, ""), T3 = (e) => {
4421
+ const s = (performance.now() - e) / 1e3, i2 = Math.floor(s / 60), t2 = Math.floor(s % 60);
4422
+ return i2 > 0 ? `[${i2}m ${t2}s]` : `[${t2}s]`;
4423
+ }, N = E2.withGuide ?? settings.withGuide, P3 = (e = "") => {
4424
+ if (p3 = true, l = false, r2 = L(e), w = performance.now(), H(), h2) {
4425
+ r2 !== "" && n3.write(`${r2}
4426
+ `), I = setInterval(() => {
4427
+ n3.write(r2 === "" ? `still working
4428
+ ` : `still working: ${r2}
4429
+ `);
4430
+ }, Y);
4431
+ return;
4432
+ }
4433
+ x2 = block({ output: n3 }), N && n3.write(`${styleText2("gray", S_BAR)}
4302
4434
  `);
4303
- let r2 = 0, t2 = 0;
4304
- A2(), T3 = setInterval(() => {
4305
- if (u5 && s === p3)
4435
+ let s = 0, i2 = 0;
4436
+ I = setInterval(() => {
4437
+ if (u4 && r2 === v)
4306
4438
  return;
4307
- y2(), p3 = s;
4308
- const o2 = k(E2[r2]);
4309
- let v;
4310
- if (u5)
4311
- v = `${o2} ${s}...`;
4312
- else if (l2 === "timer")
4313
- v = `${o2} ${s} ${_2(w)}`;
4439
+ R2(), v = r2;
4440
+ const t2 = F(M2[s]);
4441
+ let o2;
4442
+ if (u4)
4443
+ o2 = `${t2} ${r2}...`;
4444
+ else if (c3 === "timer")
4445
+ o2 = `${t2} ${r2} ${T3(w)}`;
4314
4446
  else {
4315
- const B = ".".repeat(Math.floor(t2)).slice(0, 3);
4316
- v = `${o2} ${s}${B}`;
4447
+ const j2 = ".".repeat(Math.floor(i2)).slice(0, 3);
4448
+ o2 = `${t2} ${r2}${j2}`;
4317
4449
  }
4318
- const j2 = wrapAnsi(v, x2, {
4450
+ const D = wrapAnsi(o2, y, {
4319
4451
  hard: true,
4320
4452
  trim: false
4321
4453
  });
4322
- n3.write(j2), r2 = r2 + 1 < E2.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
4323
- }, F);
4324
- }, a2 = (e = "", r2 = 0, t2 = false) => {
4325
- if (!d) return;
4326
- d = false, clearInterval(T3), y2();
4327
- const o2 = r2 === 0 ? styleText2("green", S_STEP_SUBMIT) : r2 === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
4328
- s = e ?? s, t2 || (l2 === "timer" ? n3.write(`${o2} ${s} ${_2(w)}
4329
- `) : n3.write(`${o2} ${s}
4330
- `)), H(), M2();
4454
+ n3.write(D), s = s + 1 < M2.length ? s + 1 : 0, i2 = i2 < 4 ? i2 + 0.125 : 0;
4455
+ }, O);
4456
+ }, m3 = (e = "", s = 0, i2 = false) => {
4457
+ if (p3) {
4458
+ if (p3 = false, l = s === 1, clearInterval(I), h2 || R2(), r2 = e ?? r2, !i2)
4459
+ if (h2) {
4460
+ const t2 = s === 1 ? _2 ?? settings.messages.cancel : s === 2 ? C4 ?? settings.messages.error : "Done", o2 = r2 || t2;
4461
+ c3 === "timer" ? n3.write(`${o2} ${T3(w)}
4462
+ `) : n3.write(`${o2}
4463
+ `);
4464
+ } else {
4465
+ const t2 = s === 0 ? styleText2("green", S_STEP_SUBMIT) : s === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
4466
+ c3 === "timer" ? n3.write(`${t2} ${r2} ${T3(w)}
4467
+ `) : n3.write(`${t2} ${r2}
4468
+ `);
4469
+ }
4470
+ B(), x2?.();
4471
+ }
4331
4472
  };
4332
4473
  return {
4333
4474
  start: P3,
4334
- stop: (e = "") => a2(e, 0),
4475
+ stop: (e = "") => m3(e, 0),
4335
4476
  message: (e = "") => {
4336
- s = C3(e ?? s);
4477
+ r2 = L(e ?? r2);
4337
4478
  },
4338
- cancel: (e = "") => a2(e, 1),
4339
- error: (e = "") => a2(e, 2),
4340
- clear: () => a2("", 0, true),
4479
+ cancel: (e = "") => m3(e, 1),
4480
+ error: (e = "") => m3(e, 2),
4481
+ clear: () => m3("", 0, true),
4341
4482
  get isCancelled() {
4342
- return S;
4483
+ return l;
4343
4484
  }
4344
4485
  };
4345
4486
  };
4346
- var u4 = {
4487
+ var u3 = {
4347
4488
  light: unicodeOr("\u2500", "-"),
4348
4489
  heavy: unicodeOr("\u2501", "="),
4349
4490
  block: unicodeOr("\u2588", "#")
@@ -4356,7 +4497,7 @@ function progress({
4356
4497
  } = {}) {
4357
4498
  const r2 = spinner(x2);
4358
4499
  let a2 = 0, n3 = "";
4359
- const c3 = Math.max(1, d), l2 = Math.max(1, v), S = (t2) => {
4500
+ const c3 = Math.max(1, d), l = Math.max(1, v), S = (t2) => {
4360
4501
  switch (t2) {
4361
4502
  case "initial":
4362
4503
  case "active":
@@ -4370,8 +4511,8 @@ function progress({
4370
4511
  return (e) => styleText2("magenta", e);
4371
4512
  }
4372
4513
  }, p3 = (t2, e) => {
4373
- const m3 = Math.floor(a2 / c3 * l2);
4374
- return `${S(t2)(u4[o2].repeat(m3))}${styleText2("dim", u4[o2].repeat(l2 - m3))} ${e}`;
4514
+ const m3 = Math.floor(a2 / c3 * l);
4515
+ return `${S(t2)(u3[o2].repeat(m3))}${styleText2("dim", u3[o2].repeat(l - m3))} ${e}`;
4375
4516
  }, h2 = (t2 = "") => {
4376
4517
  n3 = t2, r2.start(p3("initial", t2));
4377
4518
  }, g2 = (t2 = 1, e) => {
@@ -4384,7 +4525,9 @@ function progress({
4384
4525
  error: r2.error,
4385
4526
  clear: r2.clear,
4386
4527
  advance: g2,
4387
- isCancelled: r2.isCancelled,
4528
+ get isCancelled() {
4529
+ return r2.isCancelled;
4530
+ },
4388
4531
  message: (t2) => g2(0, t2)
4389
4532
  };
4390
4533
  }
@@ -4426,7 +4569,7 @@ var select = (t2) => {
4426
4569
  t2.message,
4427
4570
  s,
4428
4571
  m3
4429
- ), u5 = `${n3 ? `${styleText2("gray", S_BAR)}
4572
+ ), u4 = `${n3 ? `${styleText2("gray", S_BAR)}
4430
4573
  ` : ""}${i2}
4431
4574
  `;
4432
4575
  switch (this.state) {
@@ -4436,7 +4579,7 @@ var select = (t2) => {
4436
4579
  o2(this.options[this.cursor], "selected"),
4437
4580
  r2
4438
4581
  );
4439
- return `${u5}${a2}`;
4582
+ return `${u4}${a2}`;
4440
4583
  }
4441
4584
  case "cancel": {
4442
4585
  const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
@@ -4444,14 +4587,14 @@ var select = (t2) => {
4444
4587
  o2(this.options[this.cursor], "cancelled"),
4445
4588
  r2
4446
4589
  );
4447
- return `${u5}${a2}${n3 ? `
4590
+ return `${u4}${a2}${n3 ? `
4448
4591
  ${styleText2("gray", S_BAR)}` : ""}`;
4449
4592
  }
4450
4593
  default: {
4451
- const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 = u5.split(`
4452
- `).length, p3 = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], f2 = p3.join(`
4594
+ const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 = u4.split(`
4595
+ `).length, p3 = d ? formatInstructionFooter(t2.output, SELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], f2 = p3.join(`
4453
4596
  `), b3 = p3.length + 1;
4454
- return `${u5}${r2}${limitOptions({
4597
+ return `${u4}${r2}${limitOptions({
4455
4598
  output: t2.output,
4456
4599
  cursor: this.cursor,
4457
4600
  options: this.options,
@@ -4468,36 +4611,36 @@ ${f2}
4468
4611
  }
4469
4612
  }).prompt();
4470
4613
  };
4471
- var selectKey = (t2) => {
4614
+ var selectKey = (i2) => {
4472
4615
  const c3 = (e, a2 = "inactive") => {
4473
4616
  if (e === void 0)
4474
4617
  return "";
4475
4618
  const n3 = e.label ?? String(e.value);
4476
- return a2 === "selected" ? `${styleText2("dim", n3)}` : a2 === "cancelled" ? `${styleText2(["strikethrough", "dim"], n3)}` : a2 === "active" ? `${styleText2(["bgCyan", "gray"], ` ${e.value} `)} ${n3}${e.hint ? ` ${styleText2("dim", `(${e.hint})`)}` : ""}` : `${styleText2(["gray", "bgWhite", "inverse"], ` ${e.value} `)} ${n3}${e.hint ? ` ${styleText2("dim", `(${e.hint})`)}` : ""}`;
4619
+ return a2 === "disabled" ? `${styleText2("dim", ` ${e.value} `)} ${styleText2("gray", n3)}${e.hint ? ` ${styleText2("dim", `(${e.hint})`)}` : ""}` : a2 === "selected" ? `${styleText2("dim", n3)}` : a2 === "cancelled" ? `${styleText2(["strikethrough", "dim"], n3)}` : a2 === "active" ? `${styleText2(["bgCyan", "gray"], ` ${e.value} `)} ${n3}${e.hint ? ` ${styleText2("dim", `(${e.hint})`)}` : ""}` : `${styleText2(["gray", "bgWhite", "inverse"], ` ${e.value} `)} ${n3}${e.hint ? ` ${styleText2("dim", `(${e.hint})`)}` : ""}`;
4477
4620
  };
4478
- return new u3({
4479
- options: t2.options,
4480
- signal: t2.signal,
4481
- input: t2.input,
4482
- output: t2.output,
4483
- initialValue: t2.initialValue,
4484
- caseSensitive: t2.caseSensitive,
4621
+ return new c({
4622
+ options: i2.options,
4623
+ signal: i2.signal,
4624
+ input: i2.input,
4625
+ output: i2.output,
4626
+ initialValue: i2.initialValue,
4627
+ caseSensitive: i2.caseSensitive,
4485
4628
  render() {
4486
- const e = t2.withGuide ?? settings.withGuide, a2 = `${e ? `${styleText2("gray", S_BAR)}
4487
- ` : ""}${symbol(this.state)} ${t2.message}
4629
+ const e = i2.withGuide ?? settings.withGuide, a2 = `${e ? `${styleText2("gray", S_BAR)}
4630
+ ` : ""}${symbol(this.state)} ${i2.message}
4488
4631
  `;
4489
4632
  switch (this.state) {
4490
4633
  case "submit": {
4491
- const n3 = e ? `${styleText2("gray", S_BAR)} ` : "", r2 = this.options.find((u5) => u5.value === this.value) ?? t2.options[0], l2 = wrapTextWithPrefix(
4492
- t2.output,
4634
+ const n3 = e ? `${styleText2("gray", S_BAR)} ` : "", r2 = this.options.find((l) => l.value === this.value) ?? i2.options[0], u4 = wrapTextWithPrefix(
4635
+ i2.output,
4493
4636
  c3(r2, "selected"),
4494
4637
  n3
4495
4638
  );
4496
- return `${a2}${l2}`;
4639
+ return `${a2}${u4}`;
4497
4640
  }
4498
4641
  case "cancel": {
4499
4642
  const n3 = e ? `${styleText2("gray", S_BAR)} ` : "", r2 = wrapTextWithPrefix(
4500
- t2.output,
4643
+ i2.output,
4501
4644
  c3(this.options[0], "cancelled"),
4502
4645
  n3
4503
4646
  );
@@ -4505,15 +4648,18 @@ var selectKey = (t2) => {
4505
4648
  ${styleText2("gray", S_BAR)}` : ""}`;
4506
4649
  }
4507
4650
  default: {
4508
- const n3 = e ? `${styleText2("cyan", S_BAR)} ` : "", r2 = e ? styleText2("cyan", S_BAR_END) : "", l2 = this.options.map(
4509
- (u5, d) => wrapTextWithPrefix(
4510
- t2.output,
4511
- c3(u5, d === this.cursor ? "active" : "inactive"),
4651
+ const n3 = e ? `${styleText2("cyan", S_BAR)} ` : "", r2 = e ? styleText2("cyan", S_BAR_END) : "", u4 = this.options.map(
4652
+ (l, $) => wrapTextWithPrefix(
4653
+ i2.output,
4654
+ c3(
4655
+ l,
4656
+ l.disabled ? "disabled" : $ === this.cursor ? "active" : "inactive"
4657
+ ),
4512
4658
  n3
4513
4659
  )
4514
4660
  ).join(`
4515
4661
  `);
4516
- return `${a2}${l2}
4662
+ return `${a2}${u4}
4517
4663
  ${r2}
4518
4664
  `;
4519
4665
  }
@@ -4523,9 +4669,9 @@ ${r2}
4523
4669
  };
4524
4670
  var i = `${styleText2("gray", S_BAR)} `;
4525
4671
  var stream = {
4526
- message: async (e, { symbol: l2 = styleText2("gray", S_BAR) } = {}) => {
4672
+ message: async (e, { symbol: l = styleText2("gray", S_BAR) } = {}) => {
4527
4673
  process.stdout.write(`${styleText2("gray", S_BAR)}
4528
- ${l2} `);
4674
+ ${l} `);
4529
4675
  let s = 3;
4530
4676
  for await (let r2 of e) {
4531
4677
  r2 = r2.replace(/\n/g, `
@@ -4556,11 +4702,11 @@ var tasks = async (o2, e) => {
4556
4702
  s.stop(n3 || t2.title);
4557
4703
  }
4558
4704
  };
4559
- var A = (l2) => l2.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
4560
- var taskLog = (l2) => {
4561
- const r2 = l2.output ?? process.stdout, O = getColumns(r2), i2 = styleText2("gray", S_BAR), p3 = l2.spacing ?? 1, k = 3, m3 = l2.retainLog === true, d = !isCI() && isTTY(r2);
4705
+ var A = (l) => l.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "");
4706
+ var taskLog = (l) => {
4707
+ const r2 = l.output ?? process.stdout, O = getColumns(r2), i2 = styleText2("gray", S_BAR), p3 = l.spacing ?? 1, k = 3, m3 = l.retainLog === true, d = !isCI() && isTTY(r2);
4562
4708
  r2.write(`${i2}
4563
- `), r2.write(`${styleText2("green", S_STEP_SUBMIT)} ${l2.title}
4709
+ `), r2.write(`${styleText2("green", S_STEP_SUBMIT)} ${l.title}
4564
4710
  `);
4565
4711
  for (let e = 0; e < p3; e++)
4566
4712
  r2.write(`${i2}
@@ -4588,7 +4734,7 @@ ${t2.header}`);
4588
4734
  `).reduce((b3, w) => w === "" ? b3 + 1 : b3 + Math.ceil((w.length + k) / O), 0);
4589
4735
  s += E2;
4590
4736
  }
4591
- s > 0 && (s += 1, r2.write(import_sisteransi2.erase.lines(s)));
4737
+ s > 0 && (s += 1, r2.write(erase.lines(s)));
4592
4738
  }, h2 = (e, s, t2) => {
4593
4739
  const o2 = t2 ? `${e.full}
4594
4740
  ${e.value}` : e.value;
@@ -4618,9 +4764,9 @@ ${e.value}` : e.value;
4618
4764
  }
4619
4765
  }, L = (e, s, t2) => {
4620
4766
  if (f2(false), (t2?.raw !== true || !v) && e.value !== "" && (e.value += `
4621
- `), e.value += A(s), v = t2?.raw === true, l2.limit !== void 0) {
4767
+ `), e.value += A(s), v = t2?.raw === true, l.limit !== void 0) {
4622
4768
  const o2 = e.value.split(`
4623
- `), a2 = o2.length - l2.limit;
4769
+ `), a2 = o2.length - l.limit;
4624
4770
  if (a2 > 0) {
4625
4771
  const g2 = o2.splice(0, a2);
4626
4772
  m3 && (e.full += (e.full === "" ? "" : `
@@ -4630,12 +4776,12 @@ ${e.value}` : e.value;
4630
4776
  e.value = o2.join(`
4631
4777
  `);
4632
4778
  }
4633
- d && y2();
4634
- }, y2 = () => {
4779
+ d && y();
4780
+ }, y = () => {
4635
4781
  for (const e of n3)
4636
4782
  e.result ? e.result.status === "error" ? log.error(e.result.message, { output: r2, secondarySymbol: i2, spacing: 0 }) : log.success(e.result.message, { output: r2, secondarySymbol: i2, spacing: 0 }) : e.value !== "" && h2(e, 0);
4637
4783
  }, B = (e, s) => {
4638
- f2(false), e.result = s, d && y2();
4784
+ f2(false), e.result = s, d && y();
4639
4785
  };
4640
4786
  return {
4641
4787
  message(e, s) {
@@ -4682,7 +4828,7 @@ var text = (t2) => new n2({
4682
4828
  signal: t2.signal,
4683
4829
  input: t2.input,
4684
4830
  render() {
4685
- const r2 = t2?.withGuide ?? settings.withGuide, l2 = `${`${r2 ? `${styleText2("gray", S_BAR)}
4831
+ const r2 = t2?.withGuide ?? settings.withGuide, l = `${`${r2 ? `${styleText2("gray", S_BAR)}
4686
4832
  ` : ""}${symbol(this.state)} `}${t2.message}
4687
4833
  `, d = t2.placeholder && t2.placeholder.length > 0 ? (
4688
4834
  // biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
@@ -4691,29 +4837,29 @@ var text = (t2) => new n2({
4691
4837
  switch (this.state) {
4692
4838
  case "validating": {
4693
4839
  const n3 = r2 ? `${styleText2("cyan", S_BAR)} ` : "", i2 = r2 ? styleText2("cyan", S_BAR_END) : "", c3 = styleText2("dim", o2), $ = styleText2("dim", "Validating...");
4694
- return `${l2}${n3}${c3}
4840
+ return `${l}${n3}${c3}
4695
4841
  ${i2} ${$}
4696
4842
  `;
4697
4843
  }
4698
4844
  case "error": {
4699
4845
  const n3 = this.error ? ` ${styleText2("yellow", this.error)}` : "", i2 = r2 ? `${styleText2("yellow", S_BAR)} ` : "", c3 = r2 ? styleText2("yellow", S_BAR_END) : "";
4700
- return `${l2.trim()}
4846
+ return `${l.trim()}
4701
4847
  ${i2}${o2}
4702
4848
  ${c3}${n3}
4703
4849
  `;
4704
4850
  }
4705
4851
  case "submit": {
4706
4852
  const n3 = s ? `${r2 ? " " : ""}${styleText2("dim", s)}` : "", i2 = r2 ? styleText2("gray", S_BAR) : "";
4707
- return `${l2}${i2}${n3}`;
4853
+ return `${l}${i2}${n3}`;
4708
4854
  }
4709
4855
  case "cancel": {
4710
4856
  const n3 = s ? ` ${styleText2(["strikethrough", "dim"], s)}` : "", i2 = r2 ? styleText2("gray", S_BAR) : "";
4711
- return `${l2}${i2}${n3}${s.trim() ? `
4857
+ return `${l}${i2}${n3}${s.trim() ? `
4712
4858
  ${i2}` : ""}`;
4713
4859
  }
4714
4860
  default: {
4715
4861
  const n3 = r2 ? `${styleText2("cyan", S_BAR)} ` : "", i2 = r2 ? styleText2("cyan", S_BAR_END) : "";
4716
- return `${l2}${n3}${o2}
4862
+ return `${l}${n3}${o2}
4717
4863
  ${i2}
4718
4864
  `;
4719
4865
  }
@@ -4851,6 +4997,11 @@ function claudeDirOf(env, home) {
4851
4997
  const dir = env[CLAUDE_CONFIG_DIR_ENV];
4852
4998
  return dir !== void 0 && dir !== "" ? dir : join2(home, ...AGENT_HOME_DIR["claude-code"]);
4853
4999
  }
5000
+ function claudeProfileEnv(env, platform = process.platform) {
5001
+ const dir = env[CLAUDE_CONFIG_DIR_ENV];
5002
+ if (dir === void 0 || dir === "" || platform === "win32") return "";
5003
+ return `${CLAUDE_CONFIG_DIR_ENV}='${dir.split("'").join(`'"'"'`)}' `;
5004
+ }
4854
5005
  function opencodeDirOf(env, home) {
4855
5006
  const own2 = env[OPENCODE_CONFIG_DIR_ENV];
4856
5007
  if (own2 !== void 0 && own2 !== "") return own2;
@@ -4880,21 +5031,21 @@ function dataRootOf(env, home) {
4880
5031
 
4881
5032
  // src/core/ops/doctor-issue.ts
4882
5033
  import { spawnSync } from "node:child_process";
4883
- import { closeSync as closeSync2, existsSync as existsSync10, fstatSync, mkdirSync as mkdirSync4, openSync as openSync2, readFileSync as readFileSync6, readSync as readSync2, realpathSync as realpathSync5, writeFileSync as writeFileSync2 } from "node:fs";
5034
+ import { closeSync as closeSync2, existsSync as existsSync10, fstatSync, mkdirSync as mkdirSync4, openSync as openSync2, readFileSync as readFileSync7, readSync as readSync2, realpathSync as realpathSync5, writeFileSync as writeFileSync2 } from "node:fs";
4884
5035
  import { delimiter, join as join11 } from "node:path";
4885
5036
 
4886
5037
  // src/core/hooks/fallback.ts
4887
- import { join as join5, resolve as resolve2 } from "node:path";
5038
+ import { join as join5, resolve as resolve4 } from "node:path";
4888
5039
 
4889
5040
  // src/core/policy/read-media.ts
4890
5041
  import { extname } from "node:path";
4891
5042
  var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
4892
5043
 
4893
5044
  // src/core/policy/own-file.ts
4894
- import { extname as extname2, join as join4 } from "node:path";
5045
+ import { extname as extname2, join as join4, resolve as resolve3 } from "node:path";
4895
5046
 
4896
5047
  // src/core/project/contain.ts
4897
- import { dirname as dirname3, join as join3, relative, sep } from "node:path";
5048
+ import { dirname as dirname3, isAbsolute, join as join3, relative, resolve as resolve2, sep } from "node:path";
4898
5049
  var { lstatSync: lstatSync2, realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
4899
5050
  function components(p3) {
4900
5051
  return p3.split(sep).filter((c3) => c3 !== "");
@@ -4922,8 +5073,8 @@ function nodeTooOld(version) {
4922
5073
  const b3 = NODE_MIN.split(".");
4923
5074
  for (let i2 = 0; i2 < b3.length; i2++) {
4924
5075
  const x2 = Number(a2[i2] ?? 0) || 0;
4925
- const y2 = Number(b3[i2]);
4926
- if (x2 !== y2) return x2 < y2;
5076
+ const y = Number(b3[i2]);
5077
+ if (x2 !== y) return x2 < y;
4927
5078
  }
4928
5079
  return false;
4929
5080
  }
@@ -5018,8 +5169,31 @@ CREATE VIRTUAL TABLE line_units USING fts5(
5018
5169
  var { existsSync: existsSync3, linkSync, mkdirSync: mkdirSync2, rmSync } = process.getBuiltinModule("node:fs");
5019
5170
 
5020
5171
  // src/core/ops/doctor-config.ts
5021
- import { existsSync as existsSync9, readdirSync as readdirSync5 } from "node:fs";
5022
- import { join as join10 } from "node:path";
5172
+ import { existsSync as existsSync9, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
5173
+ import { dirname as dirname7, isAbsolute as isAbsolute3, join as join10, resolve as resolve5 } from "node:path";
5174
+
5175
+ // src/core/ops/host-text.ts
5176
+ var BOM_CODE = 65279;
5177
+ var CR_CODE = 13;
5178
+ var CRLF = "\r\n";
5179
+ var LF = "\n";
5180
+ function hostLayout(raw) {
5181
+ let crlf = 0;
5182
+ let lf = 0;
5183
+ for (let i2 = raw.indexOf(LF); i2 >= 0; i2 = raw.indexOf(LF, i2 + 1)) {
5184
+ if (i2 > 0 && raw.charCodeAt(i2 - 1) === CR_CODE) crlf += 1;
5185
+ else lf += 1;
5186
+ }
5187
+ return { bom: raw.length > 0 && raw.charCodeAt(0) === BOM_CODE, crlf: crlf > 0 && crlf >= lf };
5188
+ }
5189
+ function hostText(raw) {
5190
+ const bare = raw.length > 0 && raw.charCodeAt(0) === BOM_CODE ? raw.slice(1) : raw;
5191
+ return bare.indexOf(CRLF) < 0 ? bare : bare.split(CRLF).join(LF);
5192
+ }
5193
+ function withLayout(text2, layout) {
5194
+ const eol = layout.crlf ? text2.split(LF).join(CRLF) : text2;
5195
+ return layout.bom ? String.fromCharCode(BOM_CODE) + eol : eol;
5196
+ }
5023
5197
 
5024
5198
  // src/core/ops/detect-v1.ts
5025
5199
  import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync3, readFileSync as readFileSync3 } from "node:fs";
@@ -6222,8 +6396,8 @@ function isNonEOL(cp) {
6222
6396
  function isNonAscii(cp) {
6223
6397
  return CodePoint.PAD <= cp && cp <= CodePoint.CP_D7FF || CodePoint.CP_E000 <= cp && cp <= CodePoint.CP_10FFFF;
6224
6398
  }
6225
- function isValidDate(y2, m3, d) {
6226
- if (y2 >= 0 && m3 <= 12 && m3 >= 1 && d >= 1) return d <= (m3 === 2 ? y2 & 3 || !(y2 % 25) && y2 & 15 ? 28 : 29 : 30 + (m3 + (m3 >> 3) & 1));
6399
+ function isValidDate(y, m3, d) {
6400
+ if (y >= 0 && m3 <= 12 && m3 >= 1 && d >= 1) return d <= (m3 === 2 ? y & 3 || !(y % 25) && y & 15 ? 28 : 29 : 30 + (m3 + (m3 >> 3) & 1));
6227
6401
  return false;
6228
6402
  }
6229
6403
  function isValidTime(h2, m3, s) {
@@ -7140,28 +7314,22 @@ function atomicWriteFile(file, text2, opts = {}) {
7140
7314
  import { existsSync as existsSync4 } from "node:fs";
7141
7315
  import { dirname as dirname4, join as join6 } from "node:path";
7142
7316
  import { fileURLToPath } from "node:url";
7143
-
7144
- // src/core/ops/host-text.ts
7145
- var BOM_CODE = 65279;
7146
- var CR_CODE = 13;
7147
- var CRLF = "\r\n";
7148
- var LF = "\n";
7149
- function hostLayout(raw) {
7150
- let crlf = 0;
7151
- let lf = 0;
7152
- for (let i2 = raw.indexOf(LF); i2 >= 0; i2 = raw.indexOf(LF, i2 + 1)) {
7153
- if (i2 > 0 && raw.charCodeAt(i2 - 1) === CR_CODE) crlf += 1;
7154
- else lf += 1;
7317
+ function bundleDirOf(argv1, moduleFile) {
7318
+ const own2 = dirname4(argv1);
7319
+ if (existsSync4(join6(own2, SERVER_ENTRY_FILE))) return own2;
7320
+ let dir = dirname4(moduleFile);
7321
+ for (; ; ) {
7322
+ if (existsSync4(join6(dir, SERVER_ENTRY_FILE))) return dir;
7323
+ const up = dirname4(dir);
7324
+ if (up === dir) return own2;
7325
+ dir = up;
7155
7326
  }
7156
- return { bom: raw.length > 0 && raw.charCodeAt(0) === BOM_CODE, crlf: crlf > 0 && crlf >= lf };
7157
7327
  }
7158
- function hostText(raw) {
7159
- const bare = raw.length > 0 && raw.charCodeAt(0) === BOM_CODE ? raw.slice(1) : raw;
7160
- return bare.indexOf(CRLF) < 0 ? bare : bare.split(CRLF).join(LF);
7161
- }
7162
- function withLayout(text2, layout) {
7163
- const eol = layout.crlf ? text2.split(LF).join(CRLF) : text2;
7164
- return layout.bom ? String.fromCharCode(BOM_CODE) + eol : eol;
7328
+ var memo;
7329
+ function ownBundleDir() {
7330
+ const argv1 = process.argv[1] ?? "";
7331
+ if (memo?.argv1 !== argv1) memo = { argv1, dir: bundleDirOf(argv1, fileURLToPath(import.meta.url)) };
7332
+ return memo.dir;
7165
7333
  }
7166
7334
 
7167
7335
  // src/core/ops/host-config.ts
@@ -7518,6 +7686,9 @@ function ownMcpValue(agent, node, server) {
7518
7686
  if (mcp === void 0) return void 0;
7519
7687
  return { ...mcp.fields, [MCP_COMMAND_FIELD]: node, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent] };
7520
7688
  }
7689
+ function opencodePluginFile() {
7690
+ return ownBundleDir();
7691
+ }
7521
7692
  function applyEdits(agent, path15, text2, format, wanted) {
7522
7693
  const parsed = parseHostConfig(agent, path15, text2, format);
7523
7694
  let out2 = text2;
@@ -7639,7 +7810,7 @@ function flatCommands(events2, prefix) {
7639
7810
  return out2;
7640
7811
  }
7641
7812
  var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
7642
- var isCodexScript = (cmd) => cmd.includes(V1_SCRIPT_EXT) && V1_PATH_SEPS.some((sep3) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep3) + sep3));
7813
+ var isCodexScript = (cmd) => V1_PATH_SEPS.some((sep3) => V1_CODEX_SCRIPT_NAMES.some((name) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep3) + sep3 + name)));
7643
7814
  function dataDir(dir, reason, out2) {
7644
7815
  if (existsSync6(dir)) out2.push(finding(dir, "", reason));
7645
7816
  }
@@ -7687,8 +7858,7 @@ function scanCodex(agentHome, out2) {
7687
7858
  const config = readTomlValue(tomlFile);
7688
7859
  for (const span of readTomlTables(tomlFile)) {
7689
7860
  if (span.path[0] !== V1_TOML_SECTION_ROOT || span.path[1] !== SERVER_KEY) continue;
7690
- if (span.path.length === 2 && isV2McpTable(hostConfigValueAt(config, span.path))) continue;
7691
- if (span.path.length === 3 && span.path[2] === MCP_ENV_FIELD && isV2McpTable(hostConfigValueAt(config, span.path.slice(0, 2)))) continue;
7861
+ if (isV2McpTable(hostConfigValueAt(config, span.path.slice(0, 2)))) continue;
7692
7862
  out2.push(finding(tomlFile, span.header.trim(), V1_REASON.codexToml));
7693
7863
  }
7694
7864
  dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out2);
@@ -7851,7 +8021,7 @@ function detectV1(agent, home, scope = {}) {
7851
8021
 
7852
8022
  // src/core/ops/plugin-root.ts
7853
8023
  import { existsSync as existsSync7, readdirSync as readdirSync4, readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
7854
- import { dirname as dirname6, isAbsolute, join as join9, sep as sep2 } from "node:path";
8024
+ import { dirname as dirname6, isAbsolute as isAbsolute2, join as join9, sep as sep2 } from "node:path";
7855
8025
  import { fileURLToPath as fileURLToPath2 } from "node:url";
7856
8026
 
7857
8027
  // src/setup/pi-gate.ts
@@ -7956,6 +8126,7 @@ function piSettingsGate(env, home, pkgDir, cwd) {
7956
8126
 
7957
8127
  // src/core/ops/doctor-config.ts
7958
8128
  var [PART_MCP, PART_HOOKS, PART_TIMEOUT] = D3_PARTS;
8129
+ var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
7959
8130
  function composeMatcher(row, event) {
7960
8131
  let prefix = "";
7961
8132
  for (const ch of row.toolNamePrefix) prefix += REGEX_SPECIAL_CHARS.includes(ch) ? REGEX_ESCAPE + ch : ch;
@@ -7965,6 +8136,118 @@ function composeMatcher(row, event) {
7965
8136
  return MATCHER_OPEN + alts.join(MATCHER_ALT) + MATCHER_CLOSE;
7966
8137
  }
7967
8138
  var CODEX_PLUGIN_KEY = `${SERVER_KEY}@${SERVER_KEY}`;
8139
+ function opencodeEntrySpec(entry2) {
8140
+ return isObject(entry2) ? entry2[OPENCODE_PACKAGE_FIELD] : Array.isArray(entry2) ? entry2[0] : entry2;
8141
+ }
8142
+ function isNativeOpencodeEntry(entry2, key) {
8143
+ const spec = opencodeEntrySpec(entry2);
8144
+ if (typeof spec !== "string") return false;
8145
+ return spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
8146
+ }
8147
+ function stringLiterals(src) {
8148
+ const out2 = [];
8149
+ let i2 = 0;
8150
+ while (i2 < src.length) {
8151
+ const c3 = src[i2];
8152
+ if (c3 === "/" && src[i2 + 1] === "/") {
8153
+ const n3 = src.indexOf("\n", i2);
8154
+ i2 = n3 < 0 ? src.length : n3;
8155
+ continue;
8156
+ }
8157
+ if (c3 === "/" && src[i2 + 1] === "*") {
8158
+ const n3 = src.indexOf("*/", i2 + 2);
8159
+ i2 = n3 < 0 ? src.length : n3 + 2;
8160
+ continue;
8161
+ }
8162
+ if (c3 === '"' || c3 === "'" || c3 === "`") {
8163
+ let j2 = i2 + 1;
8164
+ let s = "";
8165
+ while (j2 < src.length && src[j2] !== c3) {
8166
+ if (src[j2] === "\\") {
8167
+ s += src[j2 + 1] ?? "";
8168
+ j2 += 2;
8169
+ continue;
8170
+ }
8171
+ s += src[j2];
8172
+ j2++;
8173
+ }
8174
+ out2.push(s);
8175
+ i2 = j2 + 1;
8176
+ continue;
8177
+ }
8178
+ i2++;
8179
+ }
8180
+ return out2;
8181
+ }
8182
+ var OPENCODE_PLUGINS_DIR = "plugins";
8183
+ var OPENCODE_PROJECT_DIR = ".opencode";
8184
+ var OPENCODE_PLUGIN_EXTS = [".js", ".mjs", ".ts"];
8185
+ var OPENCODE_PLUGIN_INDEX = "index";
8186
+ var OPENCODE_DIR_FILE_MAX = 64 * 1024;
8187
+ var OWN_PLUGIN_MODULES = [SERVER_KEY, `${SERVER_KEY}/server`];
8188
+ var FILE_URL_PREFIX = "file://";
8189
+ var NODE_MODULES_DIR = "node_modules";
8190
+ var PACKAGE_JSON_FILE = "package.json";
8191
+ var OPENCODE_PACKAGE_DIR_HINT = `${NODE_MODULES_DIR}/${SERVER_KEY}`;
8192
+ function opencodePluginDirs(configDir, worktree) {
8193
+ return [configDir, opencodeProjectDir(worktree)];
8194
+ }
8195
+ function opencodeProjectDir(worktree) {
8196
+ return join10(worktree, OPENCODE_PROJECT_DIR);
8197
+ }
8198
+ function packageResolves(fromDir) {
8199
+ for (let d = fromDir; ; d = dirname7(d)) {
8200
+ if (existsSync9(join10(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
8201
+ if (dirname7(d) === d) return false;
8202
+ }
8203
+ }
8204
+ function opencodeDirPlugins(dirs) {
8205
+ const bundle = opencodePluginFile();
8206
+ const ownFile = join10(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
8207
+ const isModule = (p3) => OWN_PLUGIN_MODULES.includes(p3);
8208
+ const isPath = (p3) => {
8209
+ if (p3 === ownFile || p3 === `${FILE_URL_PREFIX}${ownFile}`) return true;
8210
+ const seg = p3.split("/");
8211
+ const n3 = seg.length;
8212
+ return n3 >= 3 && seg[n3 - 1] === "plugin.js" && seg[n3 - 2] === "opencode" && seg[n3 - 3] === SERVER_KEY;
8213
+ };
8214
+ const out2 = [];
8215
+ for (const dir of dirs) {
8216
+ const pdir = join10(dir, OPENCODE_PLUGINS_DIR);
8217
+ let names;
8218
+ try {
8219
+ names = readdirSync5(pdir);
8220
+ } catch {
8221
+ continue;
8222
+ }
8223
+ for (const name of names) {
8224
+ const loose = OPENCODE_PLUGIN_EXTS.some((x2) => name.endsWith(x2)) ? [join10(pdir, name)] : [];
8225
+ const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x2) => join10(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x2}`))];
8226
+ for (const f2 of files) {
8227
+ let text2;
8228
+ try {
8229
+ const b3 = readFileSync6(f2);
8230
+ if (b3.length > OPENCODE_DIR_FILE_MAX) continue;
8231
+ text2 = b3.toString("utf8");
8232
+ } catch {
8233
+ continue;
8234
+ }
8235
+ const lits = stringLiterals(text2).map((s) => s.split("\\").join("/")).filter((p3) => isModule(p3) || isPath(p3));
8236
+ if (!lits.length) continue;
8237
+ const loads2 = lits.some((p3) => {
8238
+ if (isModule(p3)) return packageResolves(dirname7(f2));
8239
+ const bare = p3.startsWith(FILE_URL_PREFIX) ? p3.slice(FILE_URL_PREFIX.length) : p3;
8240
+ return existsSync9(isAbsolute3(bare) ? bare : resolve5(dirname7(f2), bare));
8241
+ });
8242
+ out2.push({ file: f2, loads: loads2 });
8243
+ }
8244
+ }
8245
+ }
8246
+ return out2;
8247
+ }
8248
+ function opencodeDirPlugin(dirs) {
8249
+ return opencodeDirPlugins(dirs).find((p3) => p3.loads)?.file;
8250
+ }
7968
8251
 
7969
8252
  // src/core/ops/doctor-issue.ts
7970
8253
  function formUrl(title, summary) {
@@ -8188,7 +8471,16 @@ function cliFor(ctx, id) {
8188
8471
  function copyFor(ctx, id) {
8189
8472
  if (id !== "claude-code") return void 0;
8190
8473
  const file = path4.join(claudeDirOf(ctx.env, ctx.home), HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE);
8191
- return { host: "Claude Code", bin: "claude", plugin: PLUGIN_ID, file, refresh: ["plugin", "update", PLUGIN_ID], enable: ["plugin", "enable", PLUGIN_ID] };
8474
+ return {
8475
+ host: "Claude Code",
8476
+ bin: "claude",
8477
+ plugin: PLUGIN_ID,
8478
+ file,
8479
+ refresh: ["plugin", "update", PLUGIN_ID],
8480
+ enable: ["plugin", "enable", PLUGIN_ID],
8481
+ marketplace: ["plugin", "marketplace", "update", PLUGIN_MARKETPLACE_NAME],
8482
+ profile: claudeProfileEnv(ctx.env, ctx.platform ?? process.platform)
8483
+ };
8192
8484
  }
8193
8485
  var LIST = {
8194
8486
  "claude-code": { bin: "claude", args: ["plugin", "list"] },
@@ -8232,6 +8524,8 @@ function hookInstallFor(ctx, row, command) {
8232
8524
  kind: "plugin-list",
8233
8525
  file: path4.join(opencodeDirOf(ctx.env, ctx.home), OPENCODE_BASE_CONFIG_FILE),
8234
8526
  key: ["plugin"],
8527
+ worktree: ctx.cwd ?? process.cwd(),
8528
+ // D-R54-OC-PLUGINS-DIR-1: <project>/.opencode/plugins
8235
8529
  entry: ctx.pkgDir
8236
8530
  };
8237
8531
  }
@@ -8304,7 +8598,7 @@ function assertWritable(row, file) {
8304
8598
  }
8305
8599
 
8306
8600
  // src/setup/gemini-gate.ts
8307
- import { existsSync as existsSync12, readFileSync as readFileSync7 } from "node:fs";
8601
+ import { existsSync as existsSync12, readFileSync as readFileSync8 } from "node:fs";
8308
8602
  import path5 from "node:path";
8309
8603
  var GEMINI_DIR = ".gemini";
8310
8604
  var SETTINGS_FILE2 = "settings.json";
@@ -8326,7 +8620,7 @@ function systemDefaultsPath(env) {
8326
8620
  function load2(file) {
8327
8621
  if (!existsSync12(file)) return void 0;
8328
8622
  try {
8329
- return { file, doc: parseHostConfig(OWN_AGENT, file, hostText(readFileSync7(file, "utf8")), "jsonc") };
8623
+ return { file, doc: parseHostConfig(OWN_AGENT, file, hostText(readFileSync8(file, "utf8")), "jsonc") };
8330
8624
  } catch {
8331
8625
  return void 0;
8332
8626
  }
@@ -8358,7 +8652,7 @@ function geminiSettingsGate(env, home, cwd) {
8358
8652
  }
8359
8653
 
8360
8654
  // src/setup/zcode-gate.ts
8361
- import { existsSync as existsSync13, readFileSync as readFileSync8 } from "node:fs";
8655
+ import { existsSync as existsSync13, readFileSync as readFileSync9 } from "node:fs";
8362
8656
  import path6 from "node:path";
8363
8657
  var OWN_AGENT2 = "zcode";
8364
8658
  var EVENTS = ["SessionStart", "UserPromptSubmit", "PreToolUse", "PermissionRequest", "PostToolUse", "PostToolUseFailure", "Stop"];
@@ -8453,7 +8747,7 @@ function zcodeConfigGate(home) {
8453
8747
  if (!existsSync13(file)) return void 0;
8454
8748
  let doc;
8455
8749
  try {
8456
- doc = parseHostConfig(OWN_AGENT2, file, hostText(readFileSync8(file, "utf8")), "json");
8750
+ doc = parseHostConfig(OWN_AGENT2, file, hostText(readFileSync9(file, "utf8")), "json");
8457
8751
  } catch {
8458
8752
  return void 0;
8459
8753
  }
@@ -8463,7 +8757,7 @@ function zcodeConfigGate(home) {
8463
8757
  }
8464
8758
 
8465
8759
  // src/setup/vscode-gate.ts
8466
- import { existsSync as existsSync14, readFileSync as readFileSync9 } from "node:fs";
8760
+ import { existsSync as existsSync14, readFileSync as readFileSync10 } from "node:fs";
8467
8761
  import path7 from "node:path";
8468
8762
  var SETTINGS_FILE3 = "settings.json";
8469
8763
  var WORKSPACE_DIR = ".vscode";
@@ -8474,7 +8768,7 @@ var MANAGED_KEYS = ["allowManagedHooksOnly", "strictPluginOnlyCustomization"];
8474
8768
  function load3(file) {
8475
8769
  if (!existsSync14(file)) return void 0;
8476
8770
  try {
8477
- return { file, doc: parseHostConfig("vscode", file, hostText(readFileSync9(file, "utf8")), "jsonc") };
8771
+ return { file, doc: parseHostConfig("vscode", file, hostText(readFileSync10(file, "utf8")), "jsonc") };
8478
8772
  } catch {
8479
8773
  return void 0;
8480
8774
  }
@@ -8514,7 +8808,7 @@ function vscodeSettingsGate(env, home, cwd, managedFile = managedSettingsPath(en
8514
8808
  }
8515
8809
 
8516
8810
  // src/setup/qwen-gate.ts
8517
- import { existsSync as existsSync15, readFileSync as readFileSync10 } from "node:fs";
8811
+ import { existsSync as existsSync15, readFileSync as readFileSync11 } from "node:fs";
8518
8812
  import path8 from "node:path";
8519
8813
  var KEY = "disableAllHooks";
8520
8814
  var SETTINGS = "settings.json";
@@ -8533,7 +8827,7 @@ function qwenHooksOff(env, home, cwd = process.cwd(), platform = process.platfor
8533
8827
  if (!existsSync15(file)) continue;
8534
8828
  let value;
8535
8829
  try {
8536
- value = hostConfigValueAt(parseHostConfig("qwen", file, hostText(readFileSync10(file, "utf8")), "jsonc"), [KEY]);
8830
+ value = hostConfigValueAt(parseHostConfig("qwen", file, hostText(readFileSync11(file, "utf8")), "jsonc"), [KEY]);
8537
8831
  } catch {
8538
8832
  continue;
8539
8833
  }
@@ -8745,14 +9039,14 @@ async function listPluginHooks(env, pluginId, cwd) {
8745
9039
  function askPluginHooks(env, pluginId, cwd) {
8746
9040
  const bin = whichBin("codex", env);
8747
9041
  if (!bin) return Promise.resolve({ kind: "absent" });
8748
- return new Promise((resolve3) => {
9042
+ return new Promise((resolve6) => {
8749
9043
  let asked;
8750
9044
  const done_ = (hooks) => hooks === void 0 ? { kind: "silent" } : { kind: "list", hooks, codexHome: asked };
8751
9045
  let f2;
8752
9046
  try {
8753
9047
  f2 = spawnForm(bin, ["app-server"], env);
8754
9048
  } catch {
8755
- resolve3({ kind: "silent" });
9049
+ resolve6({ kind: "silent" });
8756
9050
  return;
8757
9051
  }
8758
9052
  const child = spawn(f2.command, f2.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f2.windowsVerbatimArguments, windowsHide: true });
@@ -8762,7 +9056,7 @@ function askPluginHooks(env, pluginId, cwd) {
8762
9056
  let result;
8763
9057
  const settle = () => {
8764
9058
  clearTimeout(grace);
8765
- resolve3(done_(result));
9059
+ resolve6(done_(result));
8766
9060
  };
8767
9061
  let grace;
8768
9062
  const finish2 = (v) => {
@@ -8901,12 +9195,12 @@ function frame(buf) {
8901
9195
  function listCopilotHooks(env, file, cwd) {
8902
9196
  const bin = whichBin("copilot", env);
8903
9197
  if (!bin) return Promise.resolve(void 0);
8904
- return new Promise((resolve3) => {
9198
+ return new Promise((resolve6) => {
8905
9199
  let f2;
8906
9200
  try {
8907
9201
  f2 = spawnForm(bin, ["--server", "--stdio", "--no-auto-update"], env);
8908
9202
  } catch {
8909
- resolve3(void 0);
9203
+ resolve6(void 0);
8910
9204
  return;
8911
9205
  }
8912
9206
  const child = spawn2(f2.command, f2.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f2.windowsVerbatimArguments, windowsHide: true });
@@ -8918,7 +9212,7 @@ function listCopilotHooks(env, file, cwd) {
8918
9212
  clearTimeout(timer);
8919
9213
  child.stdin.destroy();
8920
9214
  child.kill();
8921
- resolve3(v);
9215
+ resolve6(v);
8922
9216
  };
8923
9217
  const timer = setTimeout(() => finish2(void 0), ASK_TIMEOUT_MS2);
8924
9218
  child.on("error", () => finish2(void 0));
@@ -8953,7 +9247,7 @@ function listCopilotHooks(env, file, cwd) {
8953
9247
 
8954
9248
  // src/setup/engine.ts
8955
9249
  import { spawn as spawn3, spawnSync as spawnSync4 } from "node:child_process";
8956
- import { closeSync as closeSync3, existsSync as existsSync17, mkdirSync as mkdirSync5, mkdtempSync, openSync as openSync3, readFileSync as readFileSync11, readSync as readSync3, readdirSync as readdirSync6, realpathSync as realpathSync9, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync3 } from "node:fs";
9250
+ import { closeSync as closeSync3, existsSync as existsSync17, mkdirSync as mkdirSync5, mkdtempSync, openSync as openSync3, readFileSync as readFileSync12, readSync as readSync3, readdirSync as readdirSync6, realpathSync as realpathSync9, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync3 } from "node:fs";
8957
9251
  import { tmpdir as tmpdir2 } from "node:os";
8958
9252
  import path12 from "node:path";
8959
9253
 
@@ -8972,9 +9266,9 @@ function sampleText() {
8972
9266
  const lines = [];
8973
9267
  let bytes = 0;
8974
9268
  for (let i2 = 0; bytes < SAMPLE_BYTES; i2++) {
8975
- const l2 = "context-mode doctor sample line " + i2;
8976
- lines.push(l2);
8977
- bytes += l2.length + 1;
9269
+ const l = "context-mode doctor sample line " + i2;
9270
+ lines.push(l);
9271
+ bytes += l.length + 1;
8978
9272
  }
8979
9273
  return lines.join("\n") + "\n";
8980
9274
  }
@@ -8994,7 +9288,7 @@ function hookSample(id, cwd, text2) {
8994
9288
  case "pi":
8995
9289
  return { effect, payload: { type: event, sessionId: SAMPLE_SESSION, cwd, toolName: tool, input: command, content: text2, isError: false } };
8996
9290
  case "opencode":
8997
- return { effect, payload: { type: event, sessionID: SAMPLE_SESSION, directory: cwd, tool, args: command } };
9291
+ return { effect, payload: { type: event, sessionID: SAMPLE_SESSION, directory: cwd, tool, args: command, ...effect === "replace" ? { output: text2 } : {} } };
8998
9292
  case "codex":
8999
9293
  case "qwen":
9000
9294
  case "vscode":
@@ -9004,7 +9298,7 @@ function hookSample(id, cwd, text2) {
9004
9298
  }
9005
9299
  }
9006
9300
  function sampleVerdict(id, effect, text2, a2) {
9007
- const noProject = a2.stderr.split("\n").find((l2) => l2.startsWith(NO_PROJECT_LINE));
9301
+ const noProject = a2.stderr.split("\n").find((l) => l.startsWith(NO_PROJECT_LINE));
9008
9302
  if (noProject !== void 0) return "NO_PROJECT: the hook did not resolve the project (" + noProject.trim() + ")";
9009
9303
  if (a2.status === null) return "hook did not finish";
9010
9304
  if (a2.status !== 0 && a2.status !== DENY_EXIT) return `hook exited ${a2.status}: ${a2.stderr.trim()}`;
@@ -9053,7 +9347,7 @@ function owningPackage(dir) {
9053
9347
  const f2 = path12.join(d, "package.json");
9054
9348
  if (existsSync17(f2)) {
9055
9349
  try {
9056
- return String(JSON.parse(hostText(readFileSync11(f2, "utf8"))).name);
9350
+ return String(JSON.parse(hostText(readFileSync12(f2, "utf8"))).name);
9057
9351
  } catch {
9058
9352
  return void 0;
9059
9353
  }
@@ -9086,10 +9380,10 @@ function runBin(bin, args, env, input, timeout = VERIFY_TIMEOUT_MS) {
9086
9380
  return spawnShim(hostBin(bin, env).file ?? bin, args, env, { encoding: "utf8", input, timeout, maxBuffer: Infinity });
9087
9381
  }
9088
9382
  function readOr(file) {
9089
- return existsSync17(file) ? hostText(readFileSync11(file, "utf8")) : void 0;
9383
+ return existsSync17(file) ? hostText(readFileSync12(file, "utf8")) : void 0;
9090
9384
  }
9091
9385
  function readRaw(file) {
9092
- return existsSync17(file) ? readFileSync11(file, "utf8") : void 0;
9386
+ return existsSync17(file) ? readFileSync12(file, "utf8") : void 0;
9093
9387
  }
9094
9388
  var atomicWrite = atomicWriteFile;
9095
9389
  function pidAlive(pid) {
@@ -9227,9 +9521,8 @@ function planCodexTrust(row, edits, hooksFile, file, command, env) {
9227
9521
  prior.changes.push(...changes);
9228
9522
  } else edits.push({ file, before: text2, after: res.text, changes });
9229
9523
  }
9230
- var NATIVE_PLUGIN_PREFIX = "context-mode@";
9231
9524
  function isNativeSpec(e) {
9232
- return typeof e === "string" && e.startsWith(NATIVE_PLUGIN_PREFIX);
9525
+ return isNativeOpencodeEntry(e, OPENCODE_PLUGIN_KEY);
9233
9526
  }
9234
9527
  function isStaleOwnPlugin(e, entry2) {
9235
9528
  if (typeof e !== "string" || e === entry2 || !path12.isAbsolute(e)) return false;
@@ -9245,10 +9538,31 @@ function wantedPluginList(list2, entry2, nativeElsewhere = false) {
9245
9538
  const kept = list2.filter((e) => !(native && e === entry2) && !isStaleOwnPlugin(e, entry2));
9246
9539
  return native || kept.includes(entry2) ? kept : [...kept, entry2];
9247
9540
  }
9248
- var OC2_NATIVE_KEY = "plugins";
9249
- function nativePluginsKey(doc) {
9250
- const v = isObj5(doc) ? doc[OC2_NATIVE_KEY] : void 0;
9251
- return Array.isArray(v) && v.some(isNativeSpec);
9541
+ function nativePluginsKey(doc, file) {
9542
+ const native = (d) => isObj5(d) && [OPENCODE_PLUGINS_KEY, OPENCODE_PLUGIN_KEY].some((k) => {
9543
+ const v = d[k];
9544
+ return Array.isArray(v) && v.some((e) => isNativeOpencodeEntry(e, k));
9545
+ });
9546
+ if (native(doc)) return true;
9547
+ if (opencodeDirPlugin([path12.dirname(file)]) !== void 0) return true;
9548
+ return OPENCODE_CONFIG_FILES.map((n3) => path12.join(path12.dirname(file), n3)).filter((f2) => f2 !== file).some((f2) => {
9549
+ const text2 = readOr(f2);
9550
+ if (text2 === void 0 || text2.trim() === "") return false;
9551
+ try {
9552
+ return native(parseHostConfig("opencode", f2, text2, "jsonc"));
9553
+ } catch {
9554
+ return false;
9555
+ }
9556
+ });
9557
+ }
9558
+ function projectPluginFile(h2) {
9559
+ return opencodeDirPlugin([opencodeProjectDir(h2.worktree)]);
9560
+ }
9561
+ function fixLineOf(row) {
9562
+ const h2 = row.hookInstall;
9563
+ if (h2.kind !== "plugin-list") return void 0;
9564
+ const proj = projectPluginFile(h2);
9565
+ return proj !== void 0 && pluginListIssue(h2)?.startsWith(proj) ? `remove ${proj}` : void 0;
9252
9566
  }
9253
9567
  function pluginListIssue(h2) {
9254
9568
  const text2 = readOr(h2.file);
@@ -9261,7 +9575,10 @@ function pluginListIssue(h2) {
9261
9575
  }
9262
9576
  const cur = isObj5(doc) ? doc[h2.key[0]] : void 0;
9263
9577
  const list2 = Array.isArray(cur) ? cur : [];
9264
- if ((list2.some(isNativeSpec) || nativePluginsKey(doc)) && list2.includes(h2.entry)) return `${h2.file}: context-mode loads twice (native entry and ${h2.entry}), every hook fires twice; run: context-mode setup`;
9578
+ const listed = list2.includes(h2.entry);
9579
+ if (listed && nativePluginsKey(doc, h2.file)) return `${h2.file}: context-mode loads twice (native entry and ${h2.entry}), every hook fires twice; run: context-mode setup`;
9580
+ const proj = listed ? projectPluginFile(h2) : void 0;
9581
+ if (proj !== void 0) return `${proj}: context-mode loads twice in this project (this file and ${h2.entry} in ${h2.file}), every hook fires twice; remove ${proj}, the ${h2.file} entry loads the hooks in every project`;
9265
9582
  const stale = list2.find((e) => isStaleOwnPlugin(e, h2.entry));
9266
9583
  if (stale !== void 0) return `${h2.file}: plugin file missing, so OpenCode never loads the hooks (${String(stale)}); run: context-mode setup`;
9267
9584
  return void 0;
@@ -9288,7 +9605,7 @@ function planHookInstall(row, edits, env) {
9288
9605
  planJsonKeys(row, edits, h2.file, fileFormat(row, h2.file), (doc) => {
9289
9606
  const cur = doc[h2.key[0]];
9290
9607
  const list2 = Array.isArray(cur) ? cur : [];
9291
- const want = wantedPluginList(list2, h2.entry, nativePluginsKey(doc));
9608
+ const want = wantedPluginList(list2, h2.entry, nativePluginsKey(doc, h2.file));
9292
9609
  if (cur === void 0 && want.length === 0) return [];
9293
9610
  return [[h2.key, want.length === list2.length && want.every((e, i2) => e === list2[i2]) ? list2 : want]];
9294
9611
  });
@@ -9299,7 +9616,7 @@ function planSkills(row, edits) {
9299
9616
  if (s.kind !== "dir") return;
9300
9617
  for (const f2 of s.files) {
9301
9618
  if (!existsSync17(f2.src)) throw new Error(`preflight: ${f2.src} is missing`);
9302
- const after = renderSkill(readFileSync11(f2.src, "utf8"), s.prefixes);
9619
+ const after = renderSkill(readFileSync12(f2.src, "utf8"), s.prefixes);
9303
9620
  const before = readRaw(f2.file);
9304
9621
  if (before !== after) edits.push({ plain: true, file: f2.file, before, after, changes: [{ file: f2.file, path: f2.name, before: before === void 0 ? null : "old", after: "SKILL.md" }] });
9305
9622
  }
@@ -9325,7 +9642,7 @@ function planRow(row, listed, stale, env, disabled = false) {
9325
9642
  planHookInstall(row, edits, env);
9326
9643
  planSkills(row, edits);
9327
9644
  const cli = row.config || !row.cli || listed ? [] : row.cli.install;
9328
- const refresh = listed && stale && row.copy ? [row.copy.refresh] : [];
9645
+ const refresh = listed && stale && row.copy ? [row.copy.marketplace, row.copy.refresh] : [];
9329
9646
  if (listed && disabled && row.copy) refresh.push(row.copy.enable);
9330
9647
  return { edits, cli, refresh };
9331
9648
  }
@@ -9352,54 +9669,66 @@ function statusOf(row, text2) {
9352
9669
  }
9353
9670
  return void 0;
9354
9671
  }
9355
- function opencodeMajor(bin, env) {
9672
+ function opencodeVersion(bin, env) {
9356
9673
  const r2 = runBin(bin, ["--version"], env);
9357
9674
  const text2 = `${r2.stdout}${r2.stderr}`;
9358
9675
  const digits = text2.split("").filter((c3) => c3 >= "0" && c3 <= "9" || c3 === ".").join("");
9359
- return Number(digits.split(".")[0]);
9676
+ if (!digits.split(".")[0]) return { error: `${bin} --version printed no version: ${text2.trim().split("\n")[0] ?? ""}` };
9677
+ return { major: Number(digits.split(".")[0]) };
9360
9678
  }
9361
- function opencodeListArgs(major) {
9362
- return major >= 2 ? ["mcp", "list", "--standalone"] : ["mcp", "list", "--pure"];
9363
- }
9364
- var OC2_CONFIG_ARGS = ["debug", "config", "--standalone"];
9365
- function opencode2ListCheck(bin, env) {
9366
- const r2 = runBin(bin, OC2_CONFIG_ARGS, env);
9367
- const what = `${bin} ${OC2_CONFIG_ARGS.join(" ")}`;
9368
- let docs;
9679
+ function opencodeMajor(bin, env) {
9680
+ const v = opencodeVersion(bin, env);
9681
+ return "major" in v ? v.major : Number.NaN;
9682
+ }
9683
+ var OC_CONFIG_ARGS = { 1: ["debug", "config", "--pure"], 2: ["debug", "config", "--standalone"] };
9684
+ function opencodeListCheck(bin, major, env) {
9685
+ const args = major >= 2 ? OC_CONFIG_ARGS[2] : OC_CONFIG_ARGS[1];
9686
+ const r2 = runBin(bin, [...args], env);
9687
+ const what = `${bin} ${args.join(" ")}`;
9688
+ const first = (s) => `${s}`.trim().split("\n")[0] ?? "";
9689
+ let out2;
9369
9690
  try {
9370
- docs = JSON.parse(`${r2.stdout}`);
9691
+ out2 = JSON.parse(`${r2.stdout}`);
9371
9692
  } catch {
9372
- docs = void 0;
9693
+ out2 = void 0;
9694
+ }
9695
+ if (r2.status !== 0) return { name: "list", ok: false, detail: `${what} exited ${r2.status}: ${first(r2.stderr)}` };
9696
+ if (major >= 2) {
9697
+ if (!Array.isArray(out2)) return { name: "list", ok: false, detail: `${what} printed no config list: ${first(r2.stdout)}` };
9698
+ const listed2 = out2.some((d) => isObj5(d) && isObj5(d.info) && isObj5(d.info.mcp) && isObj5(d.info.mcp.servers) && isObj5(d.info.mcp.servers[SERVER_KEY]));
9699
+ const read = out2.filter(isObj5).map((d) => d.path).filter((p3) => typeof p3 === "string");
9700
+ return { name: "list", ok: listed2, detail: listed2 ? void 0 : `${what} does not load mcp.servers.${SERVER_KEY}; it read: ${read.join(", ") || "no config"}` };
9373
9701
  }
9374
- if (r2.status !== 0) return { name: "list", ok: false, detail: `${what} exited ${r2.status}: ${`${r2.stderr}`.trim().split("\n")[0] ?? ""}` };
9375
- if (!Array.isArray(docs)) return { name: "list", ok: false, detail: `${what} printed no config list: ${`${r2.stdout}`.trim().split("\n")[0] ?? ""}` };
9376
- const listed = docs.some((d) => isObj5(d) && isObj5(d.info) && isObj5(d.info.mcp) && isObj5(d.info.mcp.servers) && isObj5(d.info.mcp.servers[SERVER_KEY]));
9377
- const read = docs.filter(isObj5).map((d) => d.path).filter((p3) => typeof p3 === "string");
9378
- return { name: "list", ok: listed, detail: listed ? void 0 : `${what} does not load mcp.servers.${SERVER_KEY}; it read: ${read.join(", ") || "no config"}` };
9702
+ if (!isObj5(out2)) return { name: "list", ok: false, detail: `${what} printed no config: ${first(r2.stdout)}` };
9703
+ const mcp = isObj5(out2.mcp) ? out2.mcp : {};
9704
+ const listed = isObj5(mcp[SERVER_KEY]);
9705
+ return { name: "list", ok: listed, detail: listed ? void 0 : `${what} does not load mcp.${SERVER_KEY}; it loads mcp: ${Object.keys(mcp).join(", ") || "none"}` };
9379
9706
  }
9707
+ var HOST_BROKEN_PREFIX = "host broken: run ";
9380
9708
  var HOST_BROKEN = {
9381
- copilot: { text: "no platform package found", fix: "npm install -g @github/copilot" }
9709
+ copilot: [
9710
+ { text: "no platform package found", prefix: HOST_BROKEN_PREFIX, fix: "npm install -g @github/copilot" },
9711
+ { text: "GitHub Copilot CLI was not found", prefix: "copilot not installed: run ", fix: "npm install -g @github/copilot" }
9712
+ ]
9382
9713
  };
9383
- var HOST_BROKEN_PREFIX = "host broken: run ";
9384
9714
  function hostBroken(bin, out2) {
9385
- const b3 = HOST_BROKEN[bin];
9386
- if (!b3 || !out2.includes(b3.text)) return void 0;
9387
- return `${HOST_BROKEN_PREFIX}${b3.fix} (${out2.trim().split("\n")[0]})`;
9715
+ const b3 = HOST_BROKEN[bin]?.find((e) => out2.includes(e.text));
9716
+ if (!b3) return void 0;
9717
+ const lines = out2.trim().split("\n");
9718
+ return `${b3.prefix}${b3.fix} (${(lines.find((l) => l.includes(b3.text)) ?? lines[0]).trim()})`;
9388
9719
  }
9389
9720
  function listState(row, env) {
9390
- let l0 = row.listCommand;
9391
- if (!l0 || !hostBin(l0.bin, env).file) return { status: void 0 };
9721
+ const l = row.listCommand;
9722
+ if (!l || !hostBin(l.bin, env).file) return { status: void 0 };
9392
9723
  if (row.id === "opencode") {
9393
- const major = opencodeMajor(l0.bin, env);
9394
- if (major >= 2) return { check: opencode2ListCheck(l0.bin, env), status: void 0 };
9395
- l0 = { bin: l0.bin, args: opencodeListArgs(major) };
9724
+ const v = opencodeVersion(l.bin, env);
9725
+ return { check: "major" in v ? opencodeListCheck(l.bin, v.major, env) : { name: "list", ok: false, detail: v.error }, status: void 0 };
9396
9726
  }
9397
- const l2 = l0;
9398
- const r2 = runBin(l2.bin, l2.args, env);
9727
+ const r2 = runBin(l.bin, l.args, env);
9399
9728
  const out2 = `${r2.stdout}${r2.stderr}`;
9400
9729
  const ok = r2.status === 0 && out2.includes("context-mode");
9401
- const check = { name: "list", ok, detail: ok ? void 0 : `${l2.bin} ${l2.args.join(" ")} does not list context-mode` };
9402
- return { check, status: r2.status === 0 ? statusOf(row, `${r2.stdout}`) : void 0, broken: r2.status === 0 ? void 0 : hostBroken(l2.bin, out2) };
9730
+ const check = { name: "list", ok, detail: ok ? void 0 : `${l.bin} ${l.args.join(" ")} does not list context-mode` };
9731
+ return { check, status: r2.status === 0 ? statusOf(row, `${r2.stdout}`) : void 0, broken: r2.status === 0 ? void 0 : hostBroken(l.bin, out2) };
9403
9732
  }
9404
9733
  var DISABLE_ALL_HOOKS = "disableAllHooks";
9405
9734
  var SETTINGS_FILES = ["settings.json", "settings.local.json"];
@@ -9433,13 +9762,16 @@ function hookEnabledCheck(row, status) {
9433
9762
  }
9434
9763
  function packageVersion(pkgDir) {
9435
9764
  try {
9436
- const v = JSON.parse(hostText(readFileSync11(path12.join(pkgDir, "package.json"), "utf8"))).version;
9765
+ const v = JSON.parse(hostText(readFileSync12(path12.join(pkgDir, "package.json"), "utf8"))).version;
9437
9766
  return typeof v === "string" ? v : void 0;
9438
9767
  } catch {
9439
9768
  return void 0;
9440
9769
  }
9441
9770
  }
9442
- function copyCheck(row, pkgDir) {
9771
+ function copyFix(c3) {
9772
+ return `${c3.profile}${c3.bin} ${c3.marketplace.join(" ")} && ${c3.profile}${c3.bin} ${c3.refresh.join(" ")}`;
9773
+ }
9774
+ function staleCopy(row, pkgDir) {
9443
9775
  const c3 = row.copy;
9444
9776
  const pkg = packageVersion(pkgDir);
9445
9777
  const text2 = c3 ? readOr(c3.file) : void 0;
@@ -9449,14 +9781,26 @@ function copyCheck(row, pkgDir) {
9449
9781
  const doc = JSON.parse(text2);
9450
9782
  entries = isObj5(doc) && isObj5(doc.plugins) ? doc.plugins[c3.plugin] : void 0;
9451
9783
  } catch {
9452
- return { name: "copy", ok: false, detail: `${c3.file} is not valid JSON; run ${c3.bin} ${c3.refresh.join(" ")}` };
9784
+ return { name: "copy", ok: false, detail: `${c3.file} is not valid JSON; run ${copyFix(c3)}` };
9453
9785
  }
9454
9786
  if (!Array.isArray(entries)) return void 0;
9455
9787
  const versions = entries.filter(isObj5).map((e) => e.version).filter((v) => typeof v === "string");
9456
9788
  if (!versions.length) return void 0;
9457
9789
  const old = versions.find((v) => v !== pkg);
9458
- if (old === void 0) return { name: "copy", ok: true };
9459
- return { name: "copy", ok: false, detail: `${c3.host} runs context-mode ${old}, the installed package is ${pkg}; run ${c3.bin} ${c3.refresh.join(" ")}` };
9790
+ return old === void 0 ? { name: "copy", ok: true } : { old, pkg };
9791
+ }
9792
+ function copyCheck(row, pkgDir) {
9793
+ const r2 = staleCopy(row, pkgDir);
9794
+ if (r2 === void 0 || "name" in r2) return r2;
9795
+ const c3 = row.copy;
9796
+ return { name: "copy", ok: false, detail: `${c3.host} runs context-mode ${r2.old}, the installed package is ${r2.pkg}; run ${copyFix(c3)}` };
9797
+ }
9798
+ function copyWarn(row, pkgDir, refreshNotes) {
9799
+ const r2 = staleCopy(row, pkgDir);
9800
+ if (r2 === void 0 || "name" in r2) return void 0;
9801
+ const c3 = row.copy;
9802
+ const why = refreshNotes.length ? ` (${refreshNotes.join("; ")})` : "";
9803
+ return { name: "copy", ok: true, warn: true, detail: `${c3.host} still runs context-mode ${r2.old}, the installed package is ${r2.pkg}${why}; run ${copyFix(c3)}` };
9460
9804
  }
9461
9805
  function degradedDetail(node, env) {
9462
9806
  const r2 = spawnSync4(node, ["-p", "process.version"], { env, encoding: "utf8", timeout: VERIFY_TIMEOUT_MS, windowsHide: true });
@@ -9465,7 +9809,7 @@ function degradedDetail(node, env) {
9465
9809
  return `only ctx_doctor is served: ${D2_SQLITE_DETAIL} under ${node}${v ? ` ${v}` : ""}. Fix: ${D2_SQLITE_FIX}`;
9466
9810
  }
9467
9811
  function mcpCheck(cmd, env) {
9468
- return new Promise((resolve3) => {
9812
+ return new Promise((resolve6) => {
9469
9813
  const child = spawn3(cmd[0], cmd.slice(1), { env, stdio: ["pipe", "pipe", "ignore"], detached: process.platform !== "win32", windowsHide: true });
9470
9814
  const reap = () => {
9471
9815
  child.kill();
@@ -9477,7 +9821,7 @@ function mcpCheck(cmd, env) {
9477
9821
  clearTimeout(timer);
9478
9822
  process.off("exit", reap);
9479
9823
  child.kill();
9480
- resolve3({ name: "mcp", ok, detail });
9824
+ resolve6({ name: "mcp", ok, detail });
9481
9825
  };
9482
9826
  const timer = setTimeout(() => done(false, "no MCP answer before timeout"), VERIFY_TIMEOUT_MS);
9483
9827
  child.on("error", (e) => done(false, e.message));
@@ -9570,6 +9914,7 @@ function ownConfigEdits(row, c3, text2) {
9570
9914
  const ownEnv = value[MCP_ENV_FIELD];
9571
9915
  if (isObj5(userEnv) || isObj5(ownEnv)) value[MCP_ENV_FIELD] = { ...isObj5(userEnv) ? userEnv : {}, ...isObj5(ownEnv) ? ownEnv : {} };
9572
9916
  if (Array.isArray(cur[MCP_ENV_VARS_FIELD])) value[MCP_ENV_VARS_FIELD] = cur[MCP_ENV_VARS_FIELD];
9917
+ if (isObj5(cur[MCP_TOOLS_FIELD])) value[MCP_TOOLS_FIELD] = cur[MCP_TOOLS_FIELD];
9573
9918
  return [[c3.key, value], ...edits.slice(1)];
9574
9919
  }
9575
9920
  function parseCheck(row) {
@@ -9586,10 +9931,10 @@ function parseCheck(row) {
9586
9931
  function hookRegisteredCheck(row, env, list2) {
9587
9932
  const h2 = row.hookInstall;
9588
9933
  if (h2.kind === "package") {
9589
- const l2 = row.listCommand;
9590
- if (!l2) return { name: "hook-registered", ok: false, detail: `no list command for ${row.id}` };
9591
- if (!list2) return { name: "hook-registered", ok: false, detail: `${l2.bin} is not on PATH, so the hooks cannot be checked` };
9592
- return { name: "hook-registered", ok: list2.ok, detail: list2.ok ? void 0 : `${l2.bin} ${l2.args.join(" ")} does not list context-mode (hooks ship in ${h2.via})` };
9934
+ const l = row.listCommand;
9935
+ if (!l) return { name: "hook-registered", ok: false, detail: `no list command for ${row.id}` };
9936
+ if (!list2) return { name: "hook-registered", ok: false, detail: `${l.bin} is not on PATH, so the hooks cannot be checked` };
9937
+ return { name: "hook-registered", ok: list2.ok, detail: list2.ok ? void 0 : `${l.bin} ${l.args.join(" ")} does not list context-mode (hooks ship in ${h2.via})` };
9593
9938
  }
9594
9939
  const edits = [];
9595
9940
  try {
@@ -9597,7 +9942,8 @@ function hookRegisteredCheck(row, env, list2) {
9597
9942
  } catch (e) {
9598
9943
  return { name: "hook-registered", ok: false, detail: e.message };
9599
9944
  }
9600
- if (!edits.length) return { name: "hook-registered", ok: true };
9945
+ const kept = !edits.length && h2.kind === "plugin-list" ? pluginListIssue(h2) : void 0;
9946
+ if (!edits.length) return kept === void 0 ? { name: "hook-registered", ok: true } : { name: "hook-registered", ok: false, detail: kept };
9601
9947
  const trust = h2.kind === "file" ? h2.trust : void 0;
9602
9948
  if (trust && edits.every((e) => e.file === trust && e.changes.every((c3) => isTrust(row, c3)))) return { name: "hook-registered", ok: false, detail: `${h2.file}: the context-mode hooks are not trusted in ${trust}; re-run setup` };
9603
9949
  const issue = h2.kind === "plugin-list" ? pluginListIssue(h2) : h2.kind === "file" && row.id === "kiro" ? kiroDisabledIssue(h2) : void 0;
@@ -9659,12 +10005,12 @@ function skillsCheck(row, pkgDir) {
9659
10005
  const own2 = getAdapter(row.id).toolNamePrefix + SKILL_TOOL_STEM;
9660
10006
  const foreign = [...new Set(ADAPTERS.map((r2) => r2.toolNamePrefix + SKILL_TOOL_STEM))].filter((n3) => n3 !== SKILL_TOOL_STEM && n3 !== own2);
9661
10007
  const bad2 = files.filter((f2) => {
9662
- const t2 = readFileSync11(f2, "utf8");
10008
+ const t2 = readFileSync12(f2, "utf8");
9663
10009
  return !t2.includes(own2) && foreign.some((n3) => t2.includes(n3));
9664
10010
  });
9665
10011
  return { name: "skills", ok: bad2.length === 0, detail: bad2.length ? `${bad2.join(", ")} without the ${own2}* tool name` : void 0 };
9666
10012
  }
9667
- const bad = s.files.filter((f2) => readRaw(f2.file) !== (existsSync17(f2.src) ? renderSkill(readFileSync11(f2.src, "utf8"), s.prefixes) : void 0));
10013
+ const bad = s.files.filter((f2) => readRaw(f2.file) !== (existsSync17(f2.src) ? renderSkill(readFileSync12(f2.src, "utf8"), s.prefixes) : void 0));
9668
10014
  return { name: "skills", ok: bad.length === 0, detail: bad.length ? `${bad.map((f2) => f2.file).join(", ")} missing or without the ${s.prefixes.join(" / ") || "plain"} tool prefix` : void 0 };
9669
10015
  }
9670
10016
  var CODEX_CONFIG_FILE2 = "config.toml";
@@ -9891,13 +10237,13 @@ async function verifyRow(row, ctx) {
9891
10237
  const env = ctx.env;
9892
10238
  const checks = [parseCheck(row)];
9893
10239
  const ls = listState(row, env);
9894
- const l2 = ls.check;
9895
- if (l2) checks.push(l2);
10240
+ const l = ls.check;
10241
+ if (l) checks.push(l);
9896
10242
  const cp = copyCheck(row, ctx.pkgDir);
9897
10243
  if (cp) checks.push(cp);
9898
10244
  checks.push(await mcpCheck(row.serverCommand, env));
9899
10245
  if (row.hookCommand) checks.push(hookCheck(row, env));
9900
- checks.push(hookRegisteredCheck(row, env, l2));
10246
+ checks.push(hookRegisteredCheck(row, env, l));
9901
10247
  const en = hookEnabledCheck(row, ls.status);
9902
10248
  if (en) checks.push(en);
9903
10249
  if (row.copilotSettings) checks.push(await copilotEnabledCheck(row, ctx));
@@ -9944,7 +10290,7 @@ function undo(dir, entries, env) {
9944
10290
  continue;
9945
10291
  }
9946
10292
  if (!e.file) continue;
9947
- if (e.existed && e.backup) atomicWrite(e.file, readFileSync11(path12.join(dir, e.backup), "utf8"));
10293
+ if (e.existed && e.backup) atomicWrite(e.file, readFileSync12(path12.join(dir, e.backup), "utf8"));
9948
10294
  else unlinkWithRetry(e.file);
9949
10295
  }
9950
10296
  }
@@ -9959,7 +10305,7 @@ function takeLock(root, runId) {
9959
10305
  if (e.code !== "EEXIST") throw e;
9960
10306
  let pid = 0;
9961
10307
  try {
9962
- pid = Number(JSON.parse(readFileSync11(file, "utf8")).pid);
10308
+ pid = Number(JSON.parse(readFileSync12(file, "utf8")).pid);
9963
10309
  } catch {
9964
10310
  }
9965
10311
  if (pid && pidAlive(pid)) return `setup lock ${file} is held by pid ${pid}; wait for that run or remove the lock`;
@@ -9980,7 +10326,7 @@ function detectAgents(reg, ctx) {
9980
10326
  return reg.filter((r2) => existsSync17(agentHomeDir(r2.id, ctx)) || r2.listCommand && which(r2.listCommand.bin, ctx.env)).map((r2) => r2.id);
9981
10327
  }
9982
10328
  async function runSetup(opts) {
9983
- const ctx = { home: opts.home, pkgDir: opts.pkgDir, env: opts.env };
10329
+ const ctx = { home: opts.home, pkgDir: opts.pkgDir, env: opts.env, cwd: opts.cwd };
9984
10330
  const runId = opts.runId ?? (/* @__PURE__ */ new Date()).toISOString().split(":").join("-").split(".").join("-");
9985
10331
  const reg = buildRegistry(ctx);
9986
10332
  const nodeVersion = opts.nodeVersion ?? process.version;
@@ -10057,27 +10403,40 @@ async function setupRow(row, ctx, run, dryRun) {
10057
10403
  if (!installExitOk(r2.status, r2.status === WIN_EXIT_CRASH && listCheck(row, ctx.env)?.ok === true)) throw new Error(`${row.cli.bin} ${args.join(" ")} exited ${r2.status}: ${`${r2.stderr}`.trim()}`);
10058
10404
  }
10059
10405
  if (plan.cli.length) for (const args of row.cli.remove) run.record({ agent: row.id, undo: { bin: row.cli.bin, args } });
10406
+ const refreshNotes = [];
10060
10407
  for (const args of plan.refresh) {
10061
10408
  const r2 = runBin(row.cli.bin, args, ctx.env, void 0, INSTALL_TIMEOUT_MS);
10062
- if (r2.status !== 0) throw new Error(`${row.cli.bin} ${args.join(" ")} exited ${r2.status}: ${`${r2.stderr}`.trim()}`);
10409
+ const failed = `${row.cli.bin} ${args.join(" ")} exited ${r2.status}: ${`${r2.stderr}`.trim()}`;
10410
+ if (r2.status !== 0 && !isCopyRefresh(row, args)) throw new Error(failed);
10411
+ if (r2.status !== 0) {
10412
+ refreshNotes.push(failed);
10413
+ continue;
10414
+ }
10063
10415
  run.record({ agent: row.id, ran: { bin: row.cli.bin, args } });
10064
10416
  }
10065
10417
  res.changes.push(...await enableCopilotHooks(row, ctx, run));
10066
10418
  res.checks = await verifyRow(row, ctx);
10419
+ if (plan.refresh.length) {
10420
+ const w = copyWarn(row, ctx.pkgDir, refreshNotes);
10421
+ if (w) res.checks = res.checks.map((c3) => c3.name === "copy" ? w : c3);
10422
+ }
10067
10423
  const bad = res.checks.filter((c3) => !c3.ok);
10424
+ const keep = bad.length === 1 && bad[0].name === "hook-registered" ? fixLineOf(row) : void 0;
10425
+ if (keep) return { ...res, status: "FAIL", reason: `${bad[0].name}: ${bad[0].detail}`, fix: keep };
10068
10426
  if (bad.length) throw new Error(bad.map((c3) => `${c3.name}: ${c3.detail}`).join("; "));
10069
10427
  } catch (e) {
10428
+ const fix = fixLineOf(row);
10070
10429
  run.rollback(row.id, ctx.env);
10071
10430
  const broken = row.cli ? hostBroken(row.cli.bin, e.message) : void 0;
10072
10431
  if (broken) return { ...res, status: "SKIPPED", reason: broken };
10073
- return { ...res, status: "FAIL", reason: e.message, rolledBack: true };
10432
+ return { ...res, status: "FAIL", reason: e.message, rolledBack: true, ...fix ? { fix } : {} };
10074
10433
  }
10075
10434
  return res;
10076
10435
  }
10077
10436
  var V1_FORM_REASON = "old context-mode entry, run: context-mode setup";
10078
10437
  var NOT_SET_UP_REASON = "not set up, run context-mode setup";
10079
10438
  async function runDoctor(opts) {
10080
- const ctx = { home: opts.home, pkgDir: opts.pkgDir, env: opts.env };
10439
+ const ctx = { home: opts.home, pkgDir: opts.pkgDir, env: opts.env, cwd: opts.cwd };
10081
10440
  const reg = buildRegistry(ctx);
10082
10441
  for (const f2 of ["server.mjs", "hook.mjs"]) {
10083
10442
  if (!existsSync17(path12.join(ctx.pkgDir, f2))) return { exitCode: 1, agents: [], error: `preflight: ${path12.join(ctx.pkgDir, f2)} is missing` };
@@ -10112,6 +10471,8 @@ async function runDoctor(opts) {
10112
10471
  if (bad.length) {
10113
10472
  res.status = "FAIL";
10114
10473
  res.reason = bad.map((c3) => `${c3.name}: ${c3.detail}`).join("; ");
10474
+ const fix = fixLineOf(row);
10475
+ if (fix) res.fix = fix;
10115
10476
  }
10116
10477
  }
10117
10478
  }
@@ -10124,7 +10485,10 @@ function notSetUpReason(row, res, env) {
10124
10485
  const h2 = row.hookInstall;
10125
10486
  const missing = row.id === "opencode" && h2.kind === "plugin-list" && res.changes.some((c3) => c3.path === h2.key[0]);
10126
10487
  const oc2 = missing && hostBin("opencode", env).file !== void 0 && opencodeMajor("opencode", env) >= 2;
10127
- if (oc2) return `${NOT_SET_UP_REASON}, or run: opencode plugin add context-mode`;
10488
+ const dead = missing ? opencodeDirPlugins(opencodePluginDirs(path12.dirname(h2.file), h2.worktree)).find((p3) => !p3.loads) : void 0;
10489
+ const hint = dead ? `; ${dead.file} loads context-mode once ${OPENCODE_PACKAGE_DIR_HINT} is next to it or above it` : "";
10490
+ if (oc2) return `${NOT_SET_UP_REASON}, or run: opencode plugin add context-mode${hint}`;
10491
+ if (hint) return NOT_SET_UP_REASON + hint;
10128
10492
  if (row.id === "gemini" && hostBin("gemini", env).file !== void 0) return `${NOT_SET_UP_REASON}, or run: ${NATIVE_INSTALL.gemini[0]}`;
10129
10493
  return NOT_SET_UP_REASON;
10130
10494
  }
@@ -10140,7 +10504,12 @@ function isRefresh(row, c3) {
10140
10504
  const r2 = row.copy;
10141
10505
  if (r2 === void 0 || c3.command === void 0) return false;
10142
10506
  const cmd = c3.command.join(" ");
10143
- return cmd === [r2.bin, ...r2.refresh].join(" ") || cmd === [r2.bin, ...r2.enable].join(" ");
10507
+ return isCopyRefresh(row, c3.command.slice(1)) || cmd === [r2.bin, ...r2.enable].join(" ");
10508
+ }
10509
+ function isCopyRefresh(row, args) {
10510
+ const r2 = row.copy;
10511
+ const a2 = args.join(" ");
10512
+ return r2 !== void 0 && (a2 === r2.refresh.join(" ") || a2 === r2.marketplace.join(" "));
10144
10513
  }
10145
10514
  function isTrust(row, c3) {
10146
10515
  const h2 = row.hookInstall;
@@ -10157,7 +10526,7 @@ function runRemove(opts) {
10157
10526
  try {
10158
10527
  const runs = readdirSync6(base).map((r2) => path12.join(base, r2)).filter((d) => existsSync17(path12.join(d, MANIFEST))).sort().reverse();
10159
10528
  for (const dir of runs) {
10160
- const m3 = JSON.parse(readFileSync11(path12.join(dir, MANIFEST), "utf8"));
10529
+ const m3 = JSON.parse(readFileSync12(path12.join(dir, MANIFEST), "utf8"));
10161
10530
  undo(dir, m3.entries, env);
10162
10531
  restored += m3.entries.length;
10163
10532
  renameWithRetry(path12.join(dir, MANIFEST), path12.join(dir, MANIFEST_DONE));
@@ -10169,7 +10538,7 @@ function runRemove(opts) {
10169
10538
  }
10170
10539
 
10171
10540
  // src/setup/print.ts
10172
- import { readFileSync as readFileSync12 } from "node:fs";
10541
+ import { readFileSync as readFileSync13 } from "node:fs";
10173
10542
  var SHELL_SAFE_PUNCT = "@%+=:,./-_";
10174
10543
  function isShellSafe(s) {
10175
10544
  if (s === "") return false;
@@ -10197,7 +10566,7 @@ function printPlan(row, env) {
10197
10566
  else if (h2.kind === "plugin-list") steps.push({ kind: "hook", file: h2.file, block: JSON.stringify({ [h2.key[0]]: [h2.entry] }, null, 2) + "\n" });
10198
10567
  const sk = row.skillInstall;
10199
10568
  if (sk.kind === "dir") {
10200
- for (const f2 of sk.files) steps.push({ kind: "skill", file: f2.file, block: renderSkill(readFileSync12(f2.src, "utf8"), sk.prefixes) });
10569
+ for (const f2 of sk.files) steps.push({ kind: "skill", file: f2.file, block: renderSkill(readFileSync13(f2.src, "utf8"), sk.prefixes) });
10201
10570
  }
10202
10571
  return { agent: row.id, steps, verify: `context-mode doctor --agents ${row.id}` };
10203
10572
  }
@@ -10270,7 +10639,7 @@ function table(agents) {
10270
10639
  return [`${"AGENT".padEnd(13)} STATUS DETAIL`, ...rows].join("\n");
10271
10640
  }
10272
10641
  function failLines(agents) {
10273
- return agents.filter((a2) => a2.status === "FAIL").map((a2) => `FAIL ${a2.id}: ${a2.reason ?? "failed"}. Fix: ${fixFor(a2.id)}`);
10642
+ return agents.filter((a2) => a2.status === "FAIL").map((a2) => `FAIL ${a2.id}: ${a2.reason ?? "failed"}. Fix: ${a2.fix ?? fixFor(a2.id)}`);
10274
10643
  }
10275
10644
  function verboseLines(agents) {
10276
10645
  return agents.flatMap((a2) => a2.checks.map((c3) => ` ${a2.id} ${c3.warn ? "WARN" : c3.ok ? "ok " : "FAIL"} ${c3.name}${c3.detail ? `: ${c3.detail}` : ""}`));
@@ -10438,9 +10807,9 @@ async function finish(ui, command, res, writeReport) {
10438
10807
  if (ui.f.json) out(JSON.stringify({ command, ...res }));
10439
10808
  else if (ui.clack) ui.clack.note(table(res.agents), "Summary");
10440
10809
  else out(table(res.agents));
10441
- if (ui.f.verbose && !ui.f.json) for (const l2 of verboseLines(res.agents)) err(l2);
10810
+ if (ui.f.verbose && !ui.f.json) for (const l of verboseLines(res.agents)) err(l);
10442
10811
  if (res.error) err(`FAIL ${command}: ${res.error}. Fix: context-mode ${command}${command === "setup" ? " --repair" : ""}`);
10443
- for (const l2 of failLines(res.agents)) err(l2);
10812
+ for (const l of failLines(res.agents)) err(l);
10444
10813
  if (res.exitCode !== EXIT_OK) await report(ui, command, res, writeReport);
10445
10814
  return res.exitCode;
10446
10815
  }
@@ -10568,15 +10937,17 @@ async function doctor(ui) {
10568
10937
  }
10569
10938
  });
10570
10939
  spin.stop();
10940
+ const other = res.agents.length === 0 ? unsupportedHostOf({ env: process.env }) : void 0;
10941
+ if (other !== void 0 && !ui.f.json) out(UNSUPPORTED_HOST_LINE(other.name));
10571
10942
  if (!res.agents.length && !res.error && !ui.f.json) {
10572
10943
  out("No agents found. Run context-mode setup --list.");
10573
10944
  return EXIT_OK;
10574
10945
  }
10575
- const code = await finish({ ...ui, clack: void 0 }, "doctor", res, false);
10946
+ const code = await finish({ ...ui, clack: void 0 }, "doctor", other === void 0 ? res : { ...res, unsupportedHost: other.id }, false);
10576
10947
  const p3 = ui.clack;
10577
10948
  if (!p3 || code === EXIT_OK) return code;
10578
10949
  let worst = code;
10579
- for (const a2 of res.agents.filter((x2) => x2.status === "FAIL")) {
10950
+ for (const a2 of res.agents.filter((x2) => x2.status === "FAIL" && x2.fix === void 0)) {
10580
10951
  const ok = await p3.confirm({ message: `Fix ${a2.id} now? (runs ${fixFor(a2.id)})`, initialValue: true });
10581
10952
  if (p3.isCancel(ok)) return EXIT_SIGINT;
10582
10953
  if (!ok) continue;
@@ -10721,7 +11092,7 @@ function main() {
10721
11092
  const dir = path14.dirname(realpathSync11(fileURLToPath3(import.meta.url)));
10722
11093
  let version = "";
10723
11094
  try {
10724
- version = String(JSON.parse(readFileSync13(path14.join(dir, PACKAGE_FILE), "utf8")).version);
11095
+ version = String(JSON.parse(readFileSync14(path14.join(dir, PACKAGE_FILE), "utf8")).version);
10725
11096
  } catch (err2) {
10726
11097
  process.stderr.write(`${SERVER_KEY}: cannot read ${PACKAGE_FILE}: ${err2.message}
10727
11098
  `);