context-mode 2.1.7 → 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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.zcode-plugin/plugin.json +1 -1
- package/README.md +72 -72
- package/SHA256SUMS +16 -16
- package/cli.mjs +771 -577
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +89 -89
- package/opencode/plugin.js +442 -229
- package/package.json +1 -1
- package/pi/index.js +298 -123
- package/qwen-extension.json +1 -1
- package/run.mjs +65 -25
- package/search.mjs +65 -25
- package/server.mjs +202 -74
package/cli.mjs
CHANGED
|
@@ -1,90 +1,10 @@
|
|
|
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";
|
|
@@ -563,6 +483,14 @@ var V1_SCRIPT_NAMES = Object.freeze([
|
|
|
563
483
|
var V1_HOOK_COMMAND = "context-mode hook";
|
|
564
484
|
var V1_CODEX_HOOK_COMMAND = "context-mode hook codex";
|
|
565
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
|
+
]);
|
|
566
494
|
var V1_CACHE_HEAL_NAME = "context-mode-cache-heal";
|
|
567
495
|
var V1_CACHE_HEAL_EXTS = Object.freeze([".mjs", ".sh"]);
|
|
568
496
|
var V1_STATUSLINE_COMMAND = "context-mode statusline";
|
|
@@ -609,6 +537,8 @@ var HOOKS_KEY = "hooks";
|
|
|
609
537
|
var STATUS_LINE_KEY = "statusLine";
|
|
610
538
|
var PI_PACKAGES_KEY = "packages";
|
|
611
539
|
var OPENCODE_PLUGIN_KEY = "plugin";
|
|
540
|
+
var OPENCODE_PLUGINS_KEY = "plugins";
|
|
541
|
+
var OPENCODE_PACKAGE_FIELD = "package";
|
|
612
542
|
var OPENCODE_NPM_SPEC_PREFIX = `${SERVER_KEY}@`;
|
|
613
543
|
var NPM_VERSION_SEP = "@";
|
|
614
544
|
var OPENCODE_NPM_LATEST = `${OPENCODE_NPM_SPEC_PREFIX}latest`;
|
|
@@ -616,7 +546,6 @@ var PI_NPM_LATEST = `${V1_PI_PACKAGE}${NPM_VERSION_SEP}latest`;
|
|
|
616
546
|
var V1_DATA_DIR_NAME = "context-mode";
|
|
617
547
|
var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
|
|
618
548
|
var V1_SESSIONS_DIR_NAME = "sessions";
|
|
619
|
-
var V1_SCRIPT_EXT = ".mjs";
|
|
620
549
|
var V1_BIN_COMMAND = SERVER_KEY;
|
|
621
550
|
var VSCODE_MCP_SERVERS_KEY = "servers";
|
|
622
551
|
var ZCODE_EVENTS_KEY = "events";
|
|
@@ -632,7 +561,7 @@ var V1_REASON = Object.freeze({
|
|
|
632
561
|
cacheHealFile: "old context-mode cache-heal script file",
|
|
633
562
|
statusLine: "old context-mode statusLine (context-mode statusline): report only, never removed",
|
|
634
563
|
mcpEntry: "old context-mode MCP entry mcpServers.context-mode",
|
|
635
|
-
codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex
|
|
564
|
+
codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex/<event>.mjs",
|
|
636
565
|
codexToml: "old context-mode config.toml [mcp_servers.context-mode*] section",
|
|
637
566
|
hookFile: "old context-mode hook file context-mode.json (runs context-mode hook)",
|
|
638
567
|
vscodeMcp: "old context-mode MCP entry servers.context-mode in .vscode/mcp.json: report only, never removed",
|
|
@@ -667,6 +596,7 @@ var MCP_COMMAND_FIELD = "command";
|
|
|
667
596
|
var MCP_ARGS_FIELD = "args";
|
|
668
597
|
var MCP_ENV_FIELD = "env";
|
|
669
598
|
var MCP_ENV_VARS_FIELD = "env_vars";
|
|
599
|
+
var MCP_TOOLS_FIELD = "tools";
|
|
670
600
|
var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
|
|
671
601
|
var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
|
|
672
602
|
var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);
|
|
@@ -1472,6 +1402,7 @@ function readResult6(p3) {
|
|
|
1472
1402
|
const text2 = p3.content === void 0 ? "" : typeof p3.content === "string" ? p3.content : JSON.stringify(p3.content);
|
|
1473
1403
|
const info = { isError: p3.isError === true, bytes: Buffer.byteLength(text2), text: text2 };
|
|
1474
1404
|
if (typeof p3.exitCode === "number") info.exitCode = p3.exitCode;
|
|
1405
|
+
if (p3.keep === true) info.keep = true;
|
|
1475
1406
|
return info;
|
|
1476
1407
|
}
|
|
1477
1408
|
function decode9(raw) {
|
|
@@ -1548,6 +1479,11 @@ function decode10(raw) {
|
|
|
1548
1479
|
const event = Object.prototype.hasOwnProperty.call(OPENCODE_EVENTS, native) ? OPENCODE_EVENTS[native] : void 0;
|
|
1549
1480
|
if (event === void 0) throw new Error("opencode: unknown hook event " + String(p3.type));
|
|
1550
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");
|
|
1551
1487
|
if (event === "UserPromptSubmit" && typeof p3.message === "string") ev.prompt = p3.message;
|
|
1552
1488
|
if (event === "PreToolUse" || event === "PostToolUse") {
|
|
1553
1489
|
const name = String(p3.tool ?? "");
|
|
@@ -1568,7 +1504,7 @@ function encode10(ev, d, _extra) {
|
|
|
1568
1504
|
if (ev.event !== "PreToolUse") return { stdout: "", exitCode: 0 };
|
|
1569
1505
|
return { stdout: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason, exitCode: 2 };
|
|
1570
1506
|
case "replace":
|
|
1571
|
-
return { stdout: "", exitCode: 0 };
|
|
1507
|
+
return { stdout: ev.event === "PostToolUse" ? d.output : "", exitCode: 0 };
|
|
1572
1508
|
}
|
|
1573
1509
|
}
|
|
1574
1510
|
|
|
@@ -1773,7 +1709,7 @@ var ADAPTERS = Object.freeze([
|
|
|
1773
1709
|
}
|
|
1774
1710
|
]);
|
|
1775
1711
|
var BY_ID = new Map(ADAPTERS.map((r2) => [r2.id, r2]));
|
|
1776
|
-
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"]);
|
|
1777
1713
|
function hasReplace(row) {
|
|
1778
1714
|
return REPLACE_ROWS.has(row.id);
|
|
1779
1715
|
}
|
|
@@ -2108,8 +2044,8 @@ __export(dist_exports, {
|
|
|
2108
2044
|
// node_modules/@clack/core/dist/index.mjs
|
|
2109
2045
|
import { styleText } from "node:util";
|
|
2110
2046
|
import { stdout, stdin } from "node:process";
|
|
2111
|
-
import * as
|
|
2112
|
-
import
|
|
2047
|
+
import * as f$1 from "node:readline";
|
|
2048
|
+
import f__default from "node:readline";
|
|
2113
2049
|
|
|
2114
2050
|
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
2115
2051
|
var getCodePointsLength = /* @__PURE__ */ (() => {
|
|
@@ -2197,7 +2133,7 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
|
|
|
2197
2133
|
if (index >= length) {
|
|
2198
2134
|
break outer;
|
|
2199
2135
|
}
|
|
2200
|
-
for (let i2 = 0,
|
|
2136
|
+
for (let i2 = 0, l = PARSE_BLOCKS.length; i2 < l; i2++) {
|
|
2201
2137
|
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
|
|
2202
2138
|
BLOCK_RE.lastIndex = index;
|
|
2203
2139
|
if (BLOCK_RE.test(input)) {
|
|
@@ -2447,25 +2383,77 @@ function wrapAnsi(string, columns, options) {
|
|
|
2447
2383
|
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
|
|
2448
2384
|
}
|
|
2449
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
|
+
|
|
2450
2439
|
// node_modules/@clack/core/dist/index.mjs
|
|
2451
|
-
var import_sisteransi = __toESM(require_src(), 1);
|
|
2452
2440
|
import { ReadStream } from "node:tty";
|
|
2453
|
-
function findCursor(
|
|
2454
|
-
if (!
|
|
2455
|
-
return
|
|
2456
|
-
const t2 =
|
|
2457
|
-
return
|
|
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;
|
|
2458
2446
|
}
|
|
2459
|
-
function findTextCursor(
|
|
2447
|
+
function findTextCursor(o2, s, l, i2) {
|
|
2460
2448
|
const t2 = i2.split(`
|
|
2461
2449
|
`);
|
|
2462
|
-
let n3 = 0, e =
|
|
2450
|
+
let n3 = 0, e = o2;
|
|
2463
2451
|
for (const r2 of t2) {
|
|
2464
2452
|
if (e <= r2.length)
|
|
2465
2453
|
break;
|
|
2466
2454
|
e -= r2.length + 1, n3++;
|
|
2467
2455
|
}
|
|
2468
|
-
for (n3 = Math.max(0, Math.min(t2.length - 1, n3 +
|
|
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; )
|
|
2469
2457
|
n3--, e += t2[n3].length + 1;
|
|
2470
2458
|
for (; e > t2[n3].length && n3 < t2.length - 1; )
|
|
2471
2459
|
e -= t2[n3].length + 1, n3++;
|
|
@@ -2580,42 +2568,42 @@ function block({
|
|
|
2580
2568
|
overwrite: o2 = true,
|
|
2581
2569
|
hideCursor: n3 = true
|
|
2582
2570
|
} = {}) {
|
|
2583
|
-
const s =
|
|
2571
|
+
const s = f$1.createInterface({
|
|
2584
2572
|
input: e,
|
|
2585
2573
|
output: r2,
|
|
2586
2574
|
prompt: "",
|
|
2587
2575
|
tabSize: 1
|
|
2588
2576
|
});
|
|
2589
|
-
|
|
2590
|
-
const t2 = (
|
|
2591
|
-
const
|
|
2592
|
-
if (isActionKey([
|
|
2593
|
-
n3 && r2.write(
|
|
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);
|
|
2594
2582
|
return;
|
|
2595
2583
|
}
|
|
2596
2584
|
if (!o2) return;
|
|
2597
|
-
const
|
|
2598
|
-
|
|
2599
|
-
|
|
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, () => {
|
|
2600
2588
|
e.once("keypress", t2);
|
|
2601
2589
|
});
|
|
2602
2590
|
});
|
|
2603
2591
|
};
|
|
2604
|
-
return n3 && r2.write(
|
|
2605
|
-
e.off("keypress", t2), n3 && r2.write(
|
|
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();
|
|
2606
2594
|
};
|
|
2607
2595
|
}
|
|
2608
2596
|
var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
|
|
2609
2597
|
var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
2610
2598
|
function wrapTextWithPrefix(e, r2, o2, n3 = o2, s = o2, t2) {
|
|
2611
|
-
const
|
|
2612
|
-
return wrapAnsi(r2,
|
|
2599
|
+
const l = getColumns(e ?? stdout), i2 = dist_default2(o2);
|
|
2600
|
+
return wrapAnsi(r2, l - i2, {
|
|
2613
2601
|
hard: true,
|
|
2614
2602
|
trim: false
|
|
2615
2603
|
}).split(`
|
|
2616
|
-
`).map((c3,
|
|
2617
|
-
const
|
|
2618
|
-
return
|
|
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}`;
|
|
2619
2607
|
}).join(`
|
|
2620
2608
|
`);
|
|
2621
2609
|
}
|
|
@@ -2626,7 +2614,7 @@ function runValidation(e, a2) {
|
|
|
2626
2614
|
}
|
|
2627
2615
|
return e(a2);
|
|
2628
2616
|
}
|
|
2629
|
-
var
|
|
2617
|
+
var C$1 = class C {
|
|
2630
2618
|
input;
|
|
2631
2619
|
output;
|
|
2632
2620
|
_abortSignal;
|
|
@@ -2708,16 +2696,16 @@ var y = class {
|
|
|
2708
2696
|
{ once: true }
|
|
2709
2697
|
);
|
|
2710
2698
|
}
|
|
2711
|
-
this.rl =
|
|
2699
|
+
this.rl = f__default.createInterface({
|
|
2712
2700
|
input: this.input,
|
|
2713
2701
|
tabSize: 2,
|
|
2714
2702
|
prompt: "",
|
|
2715
2703
|
escapeCodeTimeout: 50,
|
|
2716
2704
|
terminal: true
|
|
2717
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", () => {
|
|
2718
|
-
this.output.write(
|
|
2706
|
+
this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
|
|
2719
2707
|
}), this.once("cancel", () => {
|
|
2720
|
-
this.output.write(
|
|
2708
|
+
this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
|
|
2721
2709
|
});
|
|
2722
2710
|
});
|
|
2723
2711
|
}
|
|
@@ -2754,18 +2742,18 @@ var y = class {
|
|
|
2754
2742
|
`), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
2755
2743
|
}
|
|
2756
2744
|
restoreCursor() {
|
|
2757
|
-
const t2 = wrapAnsi(this._prevFrame,
|
|
2745
|
+
const t2 = wrapAnsi(this._prevFrame, getColumns(this.output), { hard: true, trim: false }).split(`
|
|
2758
2746
|
`).length - 1;
|
|
2759
|
-
this.output.write(
|
|
2747
|
+
this.output.write(cursor.move(-999, t2 * -1));
|
|
2760
2748
|
}
|
|
2761
2749
|
render() {
|
|
2762
|
-
const t2 = wrapAnsi(this._render(this) ?? "",
|
|
2750
|
+
const t2 = wrapAnsi(this._render(this) ?? "", getColumns(this.output), {
|
|
2763
2751
|
hard: true,
|
|
2764
2752
|
trim: false
|
|
2765
2753
|
});
|
|
2766
2754
|
if (t2 !== this._prevFrame) {
|
|
2767
2755
|
if (this.state === "initial")
|
|
2768
|
-
this.output.write(
|
|
2756
|
+
this.output.write(cursor.hide);
|
|
2769
2757
|
else {
|
|
2770
2758
|
const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
|
|
2771
2759
|
if (this.restoreCursor(), e) {
|
|
@@ -2776,46 +2764,46 @@ var y = class {
|
|
|
2776
2764
|
return;
|
|
2777
2765
|
}
|
|
2778
2766
|
if (e.lines.length === 1) {
|
|
2779
|
-
this.output.write(
|
|
2767
|
+
this.output.write(cursor.move(0, n3 - r2)), this.output.write(erase.lines(1));
|
|
2780
2768
|
const o2 = t2.split(`
|
|
2781
2769
|
`);
|
|
2782
|
-
this.output.write(o2[n3]), this._prevFrame = t2, this.output.write(
|
|
2770
|
+
this.output.write(o2[n3]), this._prevFrame = t2, this.output.write(cursor.move(0, o2.length - n3 - 1));
|
|
2783
2771
|
return;
|
|
2784
2772
|
} else if (e.lines.length > 1) {
|
|
2785
2773
|
if (s < r2)
|
|
2786
2774
|
n3 = s;
|
|
2787
2775
|
else {
|
|
2788
2776
|
const h2 = n3 - r2;
|
|
2789
|
-
h2 > 0 && this.output.write(
|
|
2777
|
+
h2 > 0 && this.output.write(cursor.move(0, h2));
|
|
2790
2778
|
}
|
|
2791
|
-
this.output.write(
|
|
2792
|
-
const
|
|
2779
|
+
this.output.write(erase.down());
|
|
2780
|
+
const m3 = t2.split(`
|
|
2793
2781
|
`).slice(n3);
|
|
2794
|
-
this.output.write(
|
|
2782
|
+
this.output.write(m3.join(`
|
|
2795
2783
|
`)), this._prevFrame = t2;
|
|
2796
2784
|
return;
|
|
2797
2785
|
}
|
|
2798
2786
|
}
|
|
2799
|
-
this.output.write(
|
|
2787
|
+
this.output.write(erase.down());
|
|
2800
2788
|
}
|
|
2801
2789
|
this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
|
|
2802
2790
|
}
|
|
2803
2791
|
}
|
|
2804
2792
|
};
|
|
2805
|
-
function p$1(
|
|
2806
|
-
if (
|
|
2793
|
+
function p$1(l, e) {
|
|
2794
|
+
if (l === void 0 || e.length === 0)
|
|
2807
2795
|
return 0;
|
|
2808
|
-
const i2 = e.findIndex((s) => s.value ===
|
|
2796
|
+
const i2 = e.findIndex((s) => s.value === l);
|
|
2809
2797
|
return i2 !== -1 ? i2 : 0;
|
|
2810
2798
|
}
|
|
2811
|
-
function m(
|
|
2812
|
-
return (e.label ?? String(e.value)).toLowerCase().includes(
|
|
2799
|
+
function m(l, e) {
|
|
2800
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
|
|
2813
2801
|
}
|
|
2814
|
-
function g(
|
|
2802
|
+
function g(l, e) {
|
|
2815
2803
|
if (e)
|
|
2816
|
-
return
|
|
2804
|
+
return l ? e : e[0];
|
|
2817
2805
|
}
|
|
2818
|
-
var T$1 = class T extends
|
|
2806
|
+
var T$1 = class T extends C$1 {
|
|
2819
2807
|
filteredOptions;
|
|
2820
2808
|
multiple;
|
|
2821
2809
|
isNavigating = false;
|
|
@@ -2857,11 +2845,11 @@ var T$1 = class T extends y {
|
|
|
2857
2845
|
return e === " " || this.multiple && this.isNavigating && t2.name === "space" && e !== void 0 && e !== "";
|
|
2858
2846
|
}
|
|
2859
2847
|
#u(e, t2) {
|
|
2860
|
-
const i2 = t2.name === "up", s = t2.name === "down", n3 = t2.name === "return", r2 = this.userInput === "" || this.userInput === " ",
|
|
2861
|
-
(o2) => !o2.disabled && (this.#t ? this.#t(
|
|
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)
|
|
2862
2850
|
);
|
|
2863
2851
|
if (t2.name === "tab" && r2 && c3) {
|
|
2864
|
-
this.userInput === " " && this._clearUserInput(), this._setUserInput(
|
|
2852
|
+
this.userInput === " " && this._clearUserInput(), this._setUserInput(u4, true), this.isNavigating = false;
|
|
2865
2853
|
return;
|
|
2866
2854
|
}
|
|
2867
2855
|
if (t2.name === "tab" && this.#l && !this.multiple && this.focusedValue !== void 0) {
|
|
@@ -2889,7 +2877,7 @@ var T$1 = class T extends y {
|
|
|
2889
2877
|
}
|
|
2890
2878
|
}
|
|
2891
2879
|
};
|
|
2892
|
-
var r = class extends
|
|
2880
|
+
var r = class extends C$1 {
|
|
2893
2881
|
get cursor() {
|
|
2894
2882
|
return this.value ? 0 : 1;
|
|
2895
2883
|
}
|
|
@@ -2900,7 +2888,7 @@ var r = class extends y {
|
|
|
2900
2888
|
super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
|
|
2901
2889
|
this.value = this._value;
|
|
2902
2890
|
}), this.on("confirm", (i2) => {
|
|
2903
|
-
this.output.write(
|
|
2891
|
+
this.output.write(cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
|
|
2904
2892
|
}), this.on("cursor", () => {
|
|
2905
2893
|
this.value = !this.value;
|
|
2906
2894
|
});
|
|
@@ -2935,7 +2923,7 @@ function f(r2) {
|
|
|
2935
2923
|
day: p(r2.day)
|
|
2936
2924
|
};
|
|
2937
2925
|
}
|
|
2938
|
-
function c(r2, t2) {
|
|
2926
|
+
function c$1(r2, t2) {
|
|
2939
2927
|
return new Date(r2 || 2001, t2 || 1, 0).getDate();
|
|
2940
2928
|
}
|
|
2941
2929
|
function b(r2) {
|
|
@@ -2945,7 +2933,7 @@ function b(r2) {
|
|
|
2945
2933
|
if (!(n3.getUTCFullYear() !== t2 || n3.getUTCMonth() !== i2 - 1 || n3.getUTCDate() !== s))
|
|
2946
2934
|
return { year: t2, month: i2, day: s };
|
|
2947
2935
|
}
|
|
2948
|
-
function
|
|
2936
|
+
function C2(r2) {
|
|
2949
2937
|
const t2 = b(r2);
|
|
2950
2938
|
return t2 ? new Date(Date.UTC(t2.year, t2.month - 1, t2.day)) : void 0;
|
|
2951
2939
|
}
|
|
@@ -2964,10 +2952,10 @@ function T2(r2, t2, i2, s) {
|
|
|
2964
2952
|
max: e && t2.year === e.year ? e.month : 12
|
|
2965
2953
|
} : {
|
|
2966
2954
|
min: n3 && t2.year === n3.year && t2.month === n3.month ? n3.day : 1,
|
|
2967
|
-
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)
|
|
2968
2956
|
};
|
|
2969
2957
|
}
|
|
2970
|
-
var U = class extends
|
|
2958
|
+
var U = class extends C$1 {
|
|
2971
2959
|
#i;
|
|
2972
2960
|
#o;
|
|
2973
2961
|
#t;
|
|
@@ -2996,7 +2984,7 @@ var U = class extends y {
|
|
|
2996
2984
|
return this.#i.map((i2) => t2[i2.type]).join(this.#o);
|
|
2997
2985
|
}
|
|
2998
2986
|
#r() {
|
|
2999
|
-
this._setUserInput(this.#l(this.#t)), this._setValue(
|
|
2987
|
+
this._setUserInput(this.#l(this.#t)), this._setValue(C2(this.#t) ?? void 0);
|
|
3000
2988
|
}
|
|
3001
2989
|
constructor(t2) {
|
|
3002
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 ? {
|
|
@@ -3004,7 +2992,7 @@ var U = class extends y {
|
|
|
3004
2992
|
month: String(e.getUTCMonth() + 1).padStart(2, "0"),
|
|
3005
2993
|
day: String(e.getUTCDate()).padStart(2, "0")
|
|
3006
2994
|
} : { year: "____", month: "__", day: "__" }, o2 = n3.map((a2) => m3[a2.type]).join(s);
|
|
3007
|
-
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,
|
|
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));
|
|
3008
2996
|
}
|
|
3009
2997
|
#a() {
|
|
3010
2998
|
const t2 = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i2 = this.#i[t2];
|
|
@@ -3084,33 +3072,33 @@ var U = class extends y {
|
|
|
3084
3072
|
return;
|
|
3085
3073
|
}
|
|
3086
3074
|
this.#n && !m3 && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
|
|
3087
|
-
const o2 = this.#t[e.type], a2 = o2.indexOf("_"),
|
|
3088
|
-
if (
|
|
3089
|
-
let
|
|
3090
|
-
if (
|
|
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")) {
|
|
3091
3079
|
const h2 = Number.parseInt(t2, 10);
|
|
3092
|
-
|
|
3080
|
+
l = `0${t2}`, D = h2 <= (e.type === "month" ? 1 : 2);
|
|
3093
3081
|
}
|
|
3094
|
-
if (e.type === "year" && (
|
|
3095
|
-
const h2 = { ...this.#t, [e.type]:
|
|
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);
|
|
3096
3084
|
if (d) {
|
|
3097
3085
|
this.inlineError = d;
|
|
3098
3086
|
return;
|
|
3099
3087
|
}
|
|
3100
3088
|
}
|
|
3101
|
-
this.inlineError = "", this.#t[e.type] =
|
|
3102
|
-
const
|
|
3103
|
-
if (
|
|
3104
|
-
const { year: h2, month: 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);
|
|
3105
3093
|
this.#t = {
|
|
3106
3094
|
year: String(Math.max(0, Math.min(9999, h2))).padStart(4, "0"),
|
|
3107
3095
|
month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
|
|
3108
|
-
day: String(Math.max(1, Math.min(g2,
|
|
3096
|
+
day: String(Math.max(1, Math.min(g2, y.day))).padStart(2, "0")
|
|
3109
3097
|
};
|
|
3110
3098
|
}
|
|
3111
3099
|
this.#r();
|
|
3112
|
-
const S =
|
|
3113
|
-
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(
|
|
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);
|
|
3114
3102
|
}
|
|
3115
3103
|
}
|
|
3116
3104
|
#g(t2, i2) {
|
|
@@ -3123,62 +3111,64 @@ var U = class extends y {
|
|
|
3123
3111
|
#p(t2) {
|
|
3124
3112
|
const { year: i2, month: s, day: n3 } = f(this.#t);
|
|
3125
3113
|
if (i2 && s && n3) {
|
|
3126
|
-
const e = c(i2, s);
|
|
3114
|
+
const e = c$1(i2, s);
|
|
3127
3115
|
this.#t = {
|
|
3128
3116
|
...this.#t,
|
|
3129
3117
|
day: String(Math.min(n3, e)).padStart(2, "0")
|
|
3130
3118
|
};
|
|
3131
3119
|
}
|
|
3132
|
-
this.value =
|
|
3120
|
+
this.value = C2(this.#t) ?? t2.defaultValue ?? void 0;
|
|
3133
3121
|
}
|
|
3134
3122
|
};
|
|
3135
|
-
var u$
|
|
3123
|
+
var u$1 = class u extends C$1 {
|
|
3136
3124
|
options;
|
|
3137
3125
|
cursor = 0;
|
|
3138
|
-
#
|
|
3126
|
+
#e;
|
|
3139
3127
|
getGroupItems(t2) {
|
|
3140
|
-
return this.options.filter((
|
|
3128
|
+
return this.options.filter((i2) => i2.group === t2);
|
|
3141
3129
|
}
|
|
3142
3130
|
isGroupSelected(t2) {
|
|
3143
|
-
const
|
|
3144
|
-
return e === void 0 ? false :
|
|
3131
|
+
const i2 = this.getGroupItems(t2), e = this.value;
|
|
3132
|
+
return e === void 0 ? false : i2.every((s) => e.includes(s.value));
|
|
3145
3133
|
}
|
|
3146
3134
|
toggleValue() {
|
|
3147
3135
|
const t2 = this.options[this.cursor];
|
|
3148
3136
|
if (t2 !== void 0)
|
|
3149
3137
|
if (this.value === void 0 && (this.value = []), t2.group === true) {
|
|
3150
|
-
const
|
|
3151
|
-
this.isGroupSelected(
|
|
3152
|
-
(s) => e.findIndex((
|
|
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
|
|
3153
3141
|
) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
|
|
3154
3142
|
} else {
|
|
3155
|
-
const
|
|
3156
|
-
this.value =
|
|
3143
|
+
const i2 = this.value.includes(t2.value);
|
|
3144
|
+
this.value = i2 ? this.value.filter((e) => e !== t2.value) : [...this.value, t2.value];
|
|
3157
3145
|
}
|
|
3158
3146
|
}
|
|
3159
3147
|
constructor(t2) {
|
|
3160
3148
|
super(t2, false);
|
|
3161
|
-
const { options:
|
|
3162
|
-
this.#
|
|
3149
|
+
const { options: i2 } = t2;
|
|
3150
|
+
this.#e = t2.selectableGroups !== false, this.options = Object.entries(i2).flatMap(([e, s]) => [
|
|
3163
3151
|
{ value: e, group: true, label: e },
|
|
3164
|
-
...s.map((
|
|
3152
|
+
...s.map((r2) => ({ ...r2, group: e }))
|
|
3165
3153
|
]), this.value = [...t2.initialValues ?? []], this.cursor = Math.max(
|
|
3166
3154
|
this.options.findIndex(({ value: e }) => e === t2.cursorAt),
|
|
3167
|
-
this.#
|
|
3168
|
-
), this.on("
|
|
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) => {
|
|
3169
3159
|
switch (e) {
|
|
3170
3160
|
case "left":
|
|
3171
3161
|
case "up": {
|
|
3172
3162
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
3173
3163
|
const s = this.options[this.cursor]?.group === true;
|
|
3174
|
-
!this.#
|
|
3164
|
+
!this.#e && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
3175
3165
|
break;
|
|
3176
3166
|
}
|
|
3177
3167
|
case "down":
|
|
3178
3168
|
case "right": {
|
|
3179
3169
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
3180
3170
|
const s = this.options[this.cursor]?.group === true;
|
|
3181
|
-
!this.#
|
|
3171
|
+
!this.#e && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
3182
3172
|
break;
|
|
3183
3173
|
}
|
|
3184
3174
|
case "space":
|
|
@@ -3189,7 +3179,7 @@ var u$2 = class u extends y {
|
|
|
3189
3179
|
}
|
|
3190
3180
|
};
|
|
3191
3181
|
var o = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
|
|
3192
|
-
var h = class extends
|
|
3182
|
+
var h = class extends C$1 {
|
|
3193
3183
|
#t = false;
|
|
3194
3184
|
#s;
|
|
3195
3185
|
focused = "editor";
|
|
@@ -3283,7 +3273,7 @@ ${i2}` : `${s}${styleText("inverse", r2)}${i2}`;
|
|
|
3283
3273
|
});
|
|
3284
3274
|
}
|
|
3285
3275
|
};
|
|
3286
|
-
var a = class extends
|
|
3276
|
+
var a = class extends C$1 {
|
|
3287
3277
|
options;
|
|
3288
3278
|
cursor = 0;
|
|
3289
3279
|
get _value() {
|
|
@@ -3314,8 +3304,8 @@ var a = class extends y {
|
|
|
3314
3304
|
this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt),
|
|
3315
3305
|
0
|
|
3316
3306
|
);
|
|
3317
|
-
this.cursor = this.options[i2]?.disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2,
|
|
3318
|
-
|
|
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();
|
|
3319
3309
|
}), this.on("cursor", (t2) => {
|
|
3320
3310
|
switch (t2) {
|
|
3321
3311
|
case "left":
|
|
@@ -3333,7 +3323,7 @@ var a = class extends y {
|
|
|
3333
3323
|
});
|
|
3334
3324
|
}
|
|
3335
3325
|
};
|
|
3336
|
-
var
|
|
3326
|
+
var u2 = class extends C$1 {
|
|
3337
3327
|
_mask = "\u2022";
|
|
3338
3328
|
get cursor() {
|
|
3339
3329
|
return this._cursor;
|
|
@@ -3361,7 +3351,7 @@ var u$1 = class u2 extends y {
|
|
|
3361
3351
|
});
|
|
3362
3352
|
}
|
|
3363
3353
|
};
|
|
3364
|
-
var n$1 = class n extends
|
|
3354
|
+
var n$1 = class n extends C$1 {
|
|
3365
3355
|
options;
|
|
3366
3356
|
cursor = 0;
|
|
3367
3357
|
get _selectedValue() {
|
|
@@ -3389,24 +3379,24 @@ var n$1 = class n extends y {
|
|
|
3389
3379
|
});
|
|
3390
3380
|
}
|
|
3391
3381
|
};
|
|
3392
|
-
var
|
|
3382
|
+
var c = class extends C$1 {
|
|
3393
3383
|
options;
|
|
3394
3384
|
cursor = 0;
|
|
3395
3385
|
constructor(t2) {
|
|
3396
3386
|
super(t2, false), this.options = t2.options;
|
|
3397
|
-
const s = t2.caseSensitive === true, i2 = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase());
|
|
3398
|
-
this.cursor =
|
|
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) => {
|
|
3399
3389
|
if (!e)
|
|
3400
3390
|
return;
|
|
3401
3391
|
const o2 = s ? e : e.toLowerCase();
|
|
3402
3392
|
if (!i2.includes(o2))
|
|
3403
3393
|
return;
|
|
3404
|
-
const
|
|
3405
|
-
|
|
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"));
|
|
3406
3396
|
});
|
|
3407
3397
|
}
|
|
3408
3398
|
};
|
|
3409
|
-
var n2 = class extends
|
|
3399
|
+
var n2 = class extends C$1 {
|
|
3410
3400
|
get userInputWithCursor() {
|
|
3411
3401
|
if (this.state === "submit")
|
|
3412
3402
|
return this.userInput;
|
|
@@ -3434,7 +3424,6 @@ var n2 = class extends y {
|
|
|
3434
3424
|
// node_modules/@clack/prompts/dist/index.mjs
|
|
3435
3425
|
import { styleText as styleText2, stripVTControlCharacters } from "node:util";
|
|
3436
3426
|
import process$1 from "node:process";
|
|
3437
|
-
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
3438
3427
|
import { existsSync, lstatSync, readdirSync } from "node:fs";
|
|
3439
3428
|
import { dirname, join } from "node:path";
|
|
3440
3429
|
function isUnicodeSupported() {
|
|
@@ -3445,8 +3434,8 @@ function isUnicodeSupported() {
|
|
|
3445
3434
|
}
|
|
3446
3435
|
var unicode = isUnicodeSupported();
|
|
3447
3436
|
var isCI = () => process.env.CI === "true";
|
|
3448
|
-
var isTTY = (
|
|
3449
|
-
var unicodeOr = (
|
|
3437
|
+
var isTTY = (e) => e.isTTY === true;
|
|
3438
|
+
var unicodeOr = (e, o2) => unicode ? e : o2;
|
|
3450
3439
|
var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
|
|
3451
3440
|
var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
|
|
3452
3441
|
var S_STEP_ERROR = unicodeOr("\u25B2", "x");
|
|
@@ -3472,8 +3461,8 @@ var S_INFO = unicodeOr("\u25CF", "\u2022");
|
|
|
3472
3461
|
var S_SUCCESS = unicodeOr("\u25C6", "*");
|
|
3473
3462
|
var S_WARN = unicodeOr("\u25B2", "!");
|
|
3474
3463
|
var S_ERROR = unicodeOr("\u25A0", "x");
|
|
3475
|
-
var symbol = (
|
|
3476
|
-
switch (
|
|
3464
|
+
var symbol = (e) => {
|
|
3465
|
+
switch (e) {
|
|
3477
3466
|
case "initial":
|
|
3478
3467
|
case "active":
|
|
3479
3468
|
return styleText2("cyan", S_STEP_ACTIVE);
|
|
@@ -3487,8 +3476,8 @@ var symbol = (o2) => {
|
|
|
3487
3476
|
return styleText2("dim", S_STEP_ACTIVE);
|
|
3488
3477
|
}
|
|
3489
3478
|
};
|
|
3490
|
-
var symbolBar = (
|
|
3491
|
-
switch (
|
|
3479
|
+
var symbolBar = (e) => {
|
|
3480
|
+
switch (e) {
|
|
3492
3481
|
case "initial":
|
|
3493
3482
|
case "active":
|
|
3494
3483
|
return styleText2("cyan", S_BAR);
|
|
@@ -3500,49 +3489,50 @@ var symbolBar = (o2) => {
|
|
|
3500
3489
|
return styleText2("green", S_BAR);
|
|
3501
3490
|
}
|
|
3502
3491
|
};
|
|
3503
|
-
function formatInstructionFooter(o2,
|
|
3504
|
-
const
|
|
3505
|
-
|
|
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;
|
|
3506
3496
|
}
|
|
3507
|
-
var
|
|
3497
|
+
var E$1 = (l, e, w, p3, b3, C4 = false) => {
|
|
3508
3498
|
let r2 = e, O = 0;
|
|
3509
|
-
if (
|
|
3499
|
+
if (C4)
|
|
3510
3500
|
for (let i2 = p3 - 1; i2 >= w; i2--) {
|
|
3511
|
-
const m3 =
|
|
3501
|
+
const m3 = l[i2];
|
|
3512
3502
|
if (m3 && (r2 -= m3.length), O++, r2 <= b3) break;
|
|
3513
3503
|
}
|
|
3514
3504
|
else
|
|
3515
3505
|
for (let i2 = w; i2 < p3; i2++) {
|
|
3516
|
-
const m3 =
|
|
3506
|
+
const m3 = l[i2];
|
|
3517
3507
|
if (m3 && (r2 -= m3.length), O++, r2 <= b3) break;
|
|
3518
3508
|
}
|
|
3519
3509
|
return { lineCount: r2, removals: O };
|
|
3520
3510
|
};
|
|
3521
3511
|
var limitOptions = ({
|
|
3522
|
-
cursor:
|
|
3512
|
+
cursor: l,
|
|
3523
3513
|
options: e,
|
|
3524
3514
|
style: w,
|
|
3525
3515
|
output: p3 = process.stdout,
|
|
3526
3516
|
maxItems: b3 = Number.POSITIVE_INFINITY,
|
|
3527
|
-
columnPadding:
|
|
3517
|
+
columnPadding: C4 = 0,
|
|
3528
3518
|
rowPadding: r2 = 4
|
|
3529
3519
|
}) => {
|
|
3530
|
-
const i2 = getColumns(p3) -
|
|
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);
|
|
3531
3521
|
let f2 = 0;
|
|
3532
|
-
|
|
3533
|
-
Math.min(
|
|
3522
|
+
l >= a2 - 3 && (f2 = Math.max(
|
|
3523
|
+
Math.min(l - a2 + 3, e.length - a2),
|
|
3534
3524
|
0
|
|
3535
3525
|
));
|
|
3536
3526
|
let d = a2 < e.length && f2 > 0, c3 = a2 < e.length && f2 + a2 < e.length;
|
|
3537
|
-
const
|
|
3527
|
+
const I = Math.min(
|
|
3538
3528
|
f2 + a2,
|
|
3539
3529
|
e.length
|
|
3540
3530
|
), s = [];
|
|
3541
3531
|
let g2 = 0;
|
|
3542
3532
|
d && g2++, c3 && g2++;
|
|
3543
|
-
const T3 = f2 + (d ? 1 : 0),
|
|
3544
|
-
for (let t2 = T3; t2 <
|
|
3545
|
-
const n3 = e[t2], o2 = n3 ? w(n3, t2 ===
|
|
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, {
|
|
3546
3536
|
hard: true,
|
|
3547
3537
|
trim: false
|
|
3548
3538
|
}).split(`
|
|
@@ -3551,17 +3541,17 @@ var limitOptions = ({
|
|
|
3551
3541
|
}
|
|
3552
3542
|
if (g2 > v) {
|
|
3553
3543
|
let t2 = 0, n3 = 0, o2 = g2;
|
|
3554
|
-
const h2 =
|
|
3555
|
-
let
|
|
3556
|
-
const L = () =>
|
|
3544
|
+
const h2 = l - T3;
|
|
3545
|
+
let u4 = v;
|
|
3546
|
+
const L = () => E$1(s, o2, 0, h2, u4), y = () => E$1(
|
|
3557
3547
|
s,
|
|
3558
3548
|
o2,
|
|
3559
3549
|
h2 + 1,
|
|
3560
3550
|
s.length,
|
|
3561
|
-
|
|
3551
|
+
u4,
|
|
3562
3552
|
true
|
|
3563
3553
|
);
|
|
3564
|
-
d ? ({ lineCount: o2, removals: t2 } = L(), o2 >
|
|
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));
|
|
3565
3555
|
}
|
|
3566
3556
|
const x2 = [];
|
|
3567
3557
|
d && x2.push(M2);
|
|
@@ -3587,7 +3577,7 @@ function j(t2, c3) {
|
|
|
3587
3577
|
}
|
|
3588
3578
|
var autocomplete = (t2) => new T$1({
|
|
3589
3579
|
options: t2.options,
|
|
3590
|
-
initialValue: t2.initialValue ? [t2.initialValue] : void 0,
|
|
3580
|
+
initialValue: t2.initialValue !== void 0 ? [t2.initialValue] : void 0,
|
|
3591
3581
|
initialUserInput: t2.initialUserInput,
|
|
3592
3582
|
placeholder: t2.placeholder,
|
|
3593
3583
|
completeOnTab: t2.completeOnTab,
|
|
@@ -3597,11 +3587,11 @@ var autocomplete = (t2) => new T$1({
|
|
|
3597
3587
|
output: t2.output,
|
|
3598
3588
|
validate: t2.validate,
|
|
3599
3589
|
render() {
|
|
3600
|
-
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, $ = (
|
|
3601
|
-
const a2 = E(
|
|
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})`) : "";
|
|
3602
3592
|
switch (s) {
|
|
3603
3593
|
case "active":
|
|
3604
|
-
return `${styleText2("green", S_RADIO_ACTIVE)} ${a2}${
|
|
3594
|
+
return `${styleText2("green", S_RADIO_ACTIVE)} ${a2}${u4}`;
|
|
3605
3595
|
case "inactive":
|
|
3606
3596
|
return `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a2)}`;
|
|
3607
3597
|
case "disabled":
|
|
@@ -3610,33 +3600,33 @@ var autocomplete = (t2) => new T$1({
|
|
|
3610
3600
|
};
|
|
3611
3601
|
switch (this.state) {
|
|
3612
3602
|
case "submit": {
|
|
3613
|
-
const
|
|
3603
|
+
const l = j(this.selectedValues, o2), s = l.length > 0 ? ` ${styleText2("dim", l.map(E).join(", "))}` : "", a2 = n3 ? styleText2("gray", S_BAR) : "";
|
|
3614
3604
|
return `${i2.join(`
|
|
3615
3605
|
`)}
|
|
3616
3606
|
${a2}${s}`;
|
|
3617
3607
|
}
|
|
3618
3608
|
case "cancel": {
|
|
3619
|
-
const
|
|
3609
|
+
const l = r2 ? ` ${styleText2(["strikethrough", "dim"], r2)}` : "", s = n3 ? styleText2("gray", S_BAR) : "";
|
|
3620
3610
|
return `${i2.join(`
|
|
3621
3611
|
`)}
|
|
3622
|
-
${s}${
|
|
3612
|
+
${s}${l}`;
|
|
3623
3613
|
}
|
|
3624
3614
|
default: {
|
|
3625
|
-
const
|
|
3626
|
-
let
|
|
3615
|
+
const l = this.state === "error" ? "yellow" : "cyan", s = n3 ? `${styleText2(l, S_BAR)} ` : "", a2 = n3 ? styleText2(l, S_BAR_END) : "";
|
|
3616
|
+
let u4 = "";
|
|
3627
3617
|
if (this.isNavigating || p3) {
|
|
3628
3618
|
const d = p3 ? m3 : r2;
|
|
3629
|
-
|
|
3619
|
+
u4 = d !== "" ? ` ${styleText2("dim", d)}` : "";
|
|
3630
3620
|
} else
|
|
3631
|
-
|
|
3621
|
+
u4 = ` ${this.userInputWithCursor}`;
|
|
3632
3622
|
const V = this.filteredOptions.length !== o2.length ? styleText2(
|
|
3633
3623
|
"dim",
|
|
3634
3624
|
` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
|
|
3635
|
-
) : "", b3 = this.filteredOptions.length === 0 && r2 ? [`${s}${styleText2("yellow", "No matches found")}`] : [],
|
|
3625
|
+
) : "", b3 = this.filteredOptions.length === 0 && r2 ? [`${s}${styleText2("yellow", "No matches found")}`] : [], y = this.state === "error" ? [`${s}${styleText2("yellow", this.error)}`] : [];
|
|
3636
3626
|
n3 && i2.push(`${s.trimEnd()}`), i2.push(
|
|
3637
|
-
`${s}${styleText2("dim", "Search:")}${
|
|
3627
|
+
`${s}${styleText2("dim", "Search:")}${u4}${V}`,
|
|
3638
3628
|
...b3,
|
|
3639
|
-
...
|
|
3629
|
+
...y
|
|
3640
3630
|
);
|
|
3641
3631
|
const S = [
|
|
3642
3632
|
`${styleText2("dim", "\u2191/\u2193")} to select`,
|
|
@@ -3668,8 +3658,8 @@ ${s}${l2}`;
|
|
|
3668
3658
|
}).prompt();
|
|
3669
3659
|
var autocompleteMultiselect = (t2) => {
|
|
3670
3660
|
const c3 = (i2, r2, o2, m3) => {
|
|
3671
|
-
const p3 = o2.includes(i2.value), $ = i2.label ?? String(i2.value ?? ""),
|
|
3672
|
-
return i2.disabled ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${styleText2(["strikethrough", "gray"], $)}` : r2 ? `${s} ${$}${
|
|
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", $)}`;
|
|
3673
3663
|
}, n3 = new T$1({
|
|
3674
3664
|
options: t2.options,
|
|
3675
3665
|
multiple: true,
|
|
@@ -3686,7 +3676,7 @@ var autocompleteMultiselect = (t2) => {
|
|
|
3686
3676
|
render() {
|
|
3687
3677
|
const i2 = t2.withGuide ?? settings.withGuide, r2 = `${i2 ? `${styleText2("gray", S_BAR)}
|
|
3688
3678
|
` : ""}${symbol(this.state)} ${t2.message}
|
|
3689
|
-
`, o2 = this.userInput, m3 = t2.placeholder, p3 = o2 === "" && m3 !== void 0, $ = this.isNavigating || p3 ? styleText2("dim", p3 ? m3 : o2) : this.userInputWithCursor,
|
|
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(
|
|
3690
3680
|
"dim",
|
|
3691
3681
|
` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`
|
|
3692
3682
|
) : "";
|
|
@@ -3702,18 +3692,18 @@ var autocompleteMultiselect = (t2) => {
|
|
|
3702
3692
|
o2
|
|
3703
3693
|
)}`;
|
|
3704
3694
|
default: {
|
|
3705
|
-
const a2 = this.state === "error" ? "yellow" : "cyan",
|
|
3695
|
+
const a2 = this.state === "error" ? "yellow" : "cyan", u4 = i2 ? `${styleText2(a2, S_BAR)} ` : "", V = i2 ? styleText2(a2, S_BAR_END) : "", b3 = [
|
|
3706
3696
|
`${styleText2("dim", "\u2191/\u2193")} to navigate`,
|
|
3707
3697
|
`${styleText2("dim", this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
|
|
3708
3698
|
`${styleText2("dim", "Enter:")} confirm`,
|
|
3709
3699
|
`${styleText2("dim", "Type:")} to search`
|
|
3710
|
-
],
|
|
3700
|
+
], y = this.filteredOptions.length === 0 && o2 ? [`${u4}${styleText2("yellow", "No matches found")}`] : [], S = this.state === "error" ? [`${u4}${styleText2("yellow", this.error)}`] : [], g2 = [
|
|
3711
3701
|
...`${r2}${i2 ? styleText2(a2, S_BAR) : ""}`.split(`
|
|
3712
3702
|
`),
|
|
3713
|
-
`${
|
|
3714
|
-
...
|
|
3703
|
+
`${u4}${styleText2("dim", "Search:")} ${$}${s}`,
|
|
3704
|
+
...y,
|
|
3715
3705
|
...S
|
|
3716
|
-
], O = [`${
|
|
3706
|
+
], O = [`${u4}${b3.join(" \u2022 ")}`, V], d = limitOptions({
|
|
3717
3707
|
cursor: this.cursor,
|
|
3718
3708
|
options: this.filteredOptions,
|
|
3719
3709
|
style: (f2, L) => c3(f2, L, this.selectedValues, this.focusedValue),
|
|
@@ -3723,7 +3713,7 @@ var autocompleteMultiselect = (t2) => {
|
|
|
3723
3713
|
});
|
|
3724
3714
|
return [
|
|
3725
3715
|
...g2,
|
|
3726
|
-
...d.map((f2) => `${
|
|
3716
|
+
...d.map((f2) => `${u4}${f2}`),
|
|
3727
3717
|
...O
|
|
3728
3718
|
].join(`
|
|
3729
3719
|
`);
|
|
@@ -3746,12 +3736,12 @@ function A$1(n3, e, t2, o2) {
|
|
|
3746
3736
|
}
|
|
3747
3737
|
var U2 = (n3) => n3;
|
|
3748
3738
|
var box = (n3 = "", e = "", t2) => {
|
|
3749
|
-
const o2 = t2?.output ?? process.stdout, i2 = getColumns(o2), R2 = 1 * 2,
|
|
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;
|
|
3750
3740
|
let r2 = Math.floor(i2 * w) - x2;
|
|
3751
3741
|
if (t2?.width === "auto") {
|
|
3752
3742
|
const c3 = n3.split(`
|
|
3753
3743
|
`);
|
|
3754
|
-
let s = B +
|
|
3744
|
+
let s = B + u4 * 2;
|
|
3755
3745
|
for (const G of c3) {
|
|
3756
3746
|
const P3 = dist_default2(G) + h2 * 2;
|
|
3757
3747
|
P3 > s && (s = P3);
|
|
@@ -3759,11 +3749,11 @@ var box = (n3 = "", e = "", t2) => {
|
|
|
3759
3749
|
const g2 = s + R2;
|
|
3760
3750
|
g2 < r2 && (r2 = g2);
|
|
3761
3751
|
}
|
|
3762
|
-
r2 % 2 !== 0 && (r2 <
|
|
3763
|
-
const d = r2 - R2, T3 = d -
|
|
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(
|
|
3764
3754
|
dist_default2(S),
|
|
3765
3755
|
d,
|
|
3766
|
-
|
|
3756
|
+
u4,
|
|
3767
3757
|
t2?.titleAlign
|
|
3768
3758
|
), L = wrapAnsi(n3, d - h2 * 2, {
|
|
3769
3759
|
hard: true,
|
|
@@ -3800,11 +3790,11 @@ var confirm = (e) => {
|
|
|
3800
3790
|
output: e.output,
|
|
3801
3791
|
initialValue: e.initialValue ?? true,
|
|
3802
3792
|
render() {
|
|
3803
|
-
const i2 = e.withGuide ?? settings.withGuide,
|
|
3793
|
+
const i2 = e.withGuide ?? settings.withGuide, u4 = `${symbol(this.state)} `, l = i2 ? `${styleText2("gray", S_BAR)} ` : "", f2 = wrapTextWithPrefix(
|
|
3804
3794
|
e.output,
|
|
3805
3795
|
e.message,
|
|
3806
|
-
|
|
3807
|
-
|
|
3796
|
+
l,
|
|
3797
|
+
u4
|
|
3808
3798
|
), s = `${i2 ? `${styleText2("gray", S_BAR)}
|
|
3809
3799
|
` : ""}${f2}
|
|
3810
3800
|
`, c3 = this.value ? a2 : o2;
|
|
@@ -3847,7 +3837,7 @@ var date = (e) => {
|
|
|
3847
3837
|
render() {
|
|
3848
3838
|
const t2 = (e?.withGuide ?? settings.withGuide) !== false, i2 = `${`${t2 ? `${styleText2("gray", S_BAR)}
|
|
3849
3839
|
` : ""}${symbol(this.state)} `}${e.message}
|
|
3850
|
-
`,
|
|
3840
|
+
`, l = this.state !== "initial" ? this.state : "active", d = b2(this, l), c3 = this.value instanceof Date ? this.formattedValue : "";
|
|
3851
3841
|
switch (this.state) {
|
|
3852
3842
|
case "error": {
|
|
3853
3843
|
const a2 = this.error ? ` ${styleText2("yellow", this.error)}` : "", s = t2 ? `${styleText2("yellow", S_BAR)} ` : "", f2 = t2 ? styleText2("yellow", S_BAR_END) : "";
|
|
@@ -3881,9 +3871,9 @@ function b2(e, r2) {
|
|
|
3881
3871
|
if (r2 === "submit" || r2 === "cancel")
|
|
3882
3872
|
return e.formattedValue;
|
|
3883
3873
|
const i2 = styleText2("gray", e.separator);
|
|
3884
|
-
return e.segments.map((
|
|
3885
|
-
const c3 = d === o2.segmentIndex && !["submit", "cancel"].includes(r2), a2 = p2[
|
|
3886
|
-
return x(t2[
|
|
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 });
|
|
3887
3877
|
}).join(i2);
|
|
3888
3878
|
}
|
|
3889
3879
|
function x(e, r2) {
|
|
@@ -3914,22 +3904,22 @@ var MULTISELECT_INSTRUCTIONS = [
|
|
|
3914
3904
|
`${styleText2("dim", "Space:")} select`,
|
|
3915
3905
|
`${styleText2("dim", "Enter:")} confirm`
|
|
3916
3906
|
];
|
|
3917
|
-
var m2 = (
|
|
3918
|
-
`).map((d) =>
|
|
3907
|
+
var m2 = (n3, u4) => n3.split(`
|
|
3908
|
+
`).map((d) => u4(d)).join(`
|
|
3919
3909
|
`);
|
|
3920
|
-
var multiselect = (
|
|
3921
|
-
const
|
|
3910
|
+
var multiselect = (n3) => {
|
|
3911
|
+
const u4 = (t2, a2) => {
|
|
3922
3912
|
const r2 = t2.label ?? String(t2.value);
|
|
3923
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))}`;
|
|
3924
|
-
}, d =
|
|
3914
|
+
}, d = n3.required ?? true, x2 = n3.showInstructions ?? true;
|
|
3925
3915
|
return new a({
|
|
3926
|
-
options:
|
|
3927
|
-
signal:
|
|
3928
|
-
input:
|
|
3929
|
-
output:
|
|
3930
|
-
initialValues:
|
|
3916
|
+
options: n3.options,
|
|
3917
|
+
signal: n3.signal,
|
|
3918
|
+
input: n3.input,
|
|
3919
|
+
output: n3.output,
|
|
3920
|
+
initialValues: n3.initialValues,
|
|
3931
3921
|
required: d,
|
|
3932
|
-
cursorAt:
|
|
3922
|
+
cursorAt: n3.cursorAt,
|
|
3933
3923
|
validate(t2) {
|
|
3934
3924
|
if (d && (t2 === void 0 || t2.length === 0))
|
|
3935
3925
|
return `Please select at least one option.
|
|
@@ -3945,75 +3935,75 @@ ${styleText2(
|
|
|
3945
3935
|
)}`;
|
|
3946
3936
|
},
|
|
3947
3937
|
render() {
|
|
3948
|
-
const t2 =
|
|
3949
|
-
|
|
3950
|
-
|
|
3938
|
+
const t2 = n3.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(
|
|
3939
|
+
n3.output,
|
|
3940
|
+
n3.message,
|
|
3951
3941
|
t2 ? `${symbolBar(this.state)} ` : "",
|
|
3952
3942
|
`${symbol(this.state)} `
|
|
3953
3943
|
), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
|
|
3954
3944
|
` : ""}${a2}
|
|
3955
|
-
`, o2 = this.value ?? [], g2 = (
|
|
3956
|
-
if (
|
|
3957
|
-
return
|
|
3958
|
-
const s = o2.includes(
|
|
3959
|
-
return
|
|
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");
|
|
3960
3950
|
};
|
|
3961
3951
|
switch (this.state) {
|
|
3962
3952
|
case "submit": {
|
|
3963
|
-
const
|
|
3964
|
-
|
|
3965
|
-
|
|
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,
|
|
3966
3956
|
t2 ? `${styleText2("gray", S_BAR)} ` : ""
|
|
3967
3957
|
);
|
|
3968
|
-
return `${r2}${
|
|
3958
|
+
return `${r2}${l}`;
|
|
3969
3959
|
}
|
|
3970
3960
|
case "cancel": {
|
|
3971
|
-
const
|
|
3972
|
-
if (
|
|
3961
|
+
const i2 = this.options.filter(({ value: s }) => o2.includes(s)).map((s) => u4(s, "cancelled")).join(styleText2("dim", ", "));
|
|
3962
|
+
if (i2.trim() === "")
|
|
3973
3963
|
return `${r2}${styleText2("gray", S_BAR)}`;
|
|
3974
|
-
const
|
|
3975
|
-
|
|
3976
|
-
|
|
3964
|
+
const l = wrapTextWithPrefix(
|
|
3965
|
+
n3.output,
|
|
3966
|
+
i2,
|
|
3977
3967
|
t2 ? `${styleText2("gray", S_BAR)} ` : ""
|
|
3978
3968
|
);
|
|
3979
|
-
return `${r2}${
|
|
3969
|
+
return `${r2}${l}${t2 ? `
|
|
3980
3970
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
3981
3971
|
}
|
|
3982
3972
|
case "error": {
|
|
3983
|
-
const
|
|
3973
|
+
const i2 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l = this.error.split(`
|
|
3984
3974
|
`).map(
|
|
3985
3975
|
($, v) => v === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", $)}` : ` ${$}`
|
|
3986
3976
|
).join(`
|
|
3987
3977
|
`), s = r2.split(`
|
|
3988
|
-
`).length, h2 =
|
|
3978
|
+
`).length, h2 = l.split(`
|
|
3989
3979
|
`).length + 1;
|
|
3990
|
-
return `${r2}${
|
|
3991
|
-
output:
|
|
3980
|
+
return `${r2}${i2}${limitOptions({
|
|
3981
|
+
output: n3.output,
|
|
3992
3982
|
options: this.options,
|
|
3993
3983
|
cursor: this.cursor,
|
|
3994
|
-
maxItems:
|
|
3995
|
-
columnPadding:
|
|
3984
|
+
maxItems: n3.maxItems,
|
|
3985
|
+
columnPadding: i2.length,
|
|
3996
3986
|
rowPadding: s + h2,
|
|
3997
3987
|
style: g2
|
|
3998
3988
|
}).join(`
|
|
3999
|
-
${
|
|
4000
|
-
${
|
|
3989
|
+
${i2}`)}
|
|
3990
|
+
${l}
|
|
4001
3991
|
`;
|
|
4002
3992
|
}
|
|
4003
3993
|
default: {
|
|
4004
|
-
const
|
|
4005
|
-
`).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(`
|
|
4006
3996
|
`), $ = s.length + 1;
|
|
4007
|
-
return `${r2}${
|
|
4008
|
-
output:
|
|
3997
|
+
return `${r2}${i2}${limitOptions({
|
|
3998
|
+
output: n3.output,
|
|
4009
3999
|
options: this.options,
|
|
4010
4000
|
cursor: this.cursor,
|
|
4011
|
-
maxItems:
|
|
4012
|
-
columnPadding:
|
|
4013
|
-
rowPadding:
|
|
4001
|
+
maxItems: n3.maxItems,
|
|
4002
|
+
columnPadding: i2.length,
|
|
4003
|
+
rowPadding: l + $,
|
|
4014
4004
|
style: g2
|
|
4015
4005
|
}).join(`
|
|
4016
|
-
${
|
|
4006
|
+
${i2}`)}
|
|
4017
4007
|
${h2}
|
|
4018
4008
|
`;
|
|
4019
4009
|
}
|
|
@@ -4021,83 +4011,83 @@ ${h2}
|
|
|
4021
4011
|
}
|
|
4022
4012
|
}).prompt();
|
|
4023
4013
|
};
|
|
4024
|
-
var groupMultiselect = (
|
|
4025
|
-
const { selectableGroups: f2 = true, groupSpacing: x2 = 0 } =
|
|
4026
|
-
const a2 = n3.label ?? String(n3.value), t2 = typeof n3.group == "string",
|
|
4027
|
-
let
|
|
4028
|
-
t2 && (f2 ? (
|
|
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 = " ");
|
|
4029
4019
|
let i2 = "";
|
|
4030
4020
|
if (x2 > 0 && !t2 && (i2 = `
|
|
4031
|
-
`.repeat(x2)),
|
|
4021
|
+
`.repeat(x2)), l === "active")
|
|
4032
4022
|
return wrapTextWithPrefix(
|
|
4033
|
-
|
|
4023
|
+
r2.output,
|
|
4034
4024
|
`${a2}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`,
|
|
4035
|
-
`${i2}${styleText2("dim",
|
|
4036
|
-
`${i2}${styleText2("dim",
|
|
4025
|
+
`${i2}${styleText2("dim", o2)} `,
|
|
4026
|
+
`${i2}${styleText2("dim", o2)}${styleText2("cyan", S_CHECKBOX_ACTIVE)} `,
|
|
4037
4027
|
`${i2}${styleText2("dim", c3)} `
|
|
4038
4028
|
);
|
|
4039
|
-
if (
|
|
4029
|
+
if (l === "group-active")
|
|
4040
4030
|
return wrapTextWithPrefix(
|
|
4041
|
-
|
|
4031
|
+
r2.output,
|
|
4042
4032
|
a2,
|
|
4043
|
-
`${i2}${
|
|
4044
|
-
`${i2}${
|
|
4033
|
+
`${i2}${o2} `,
|
|
4034
|
+
`${i2}${o2}${styleText2("cyan", S_CHECKBOX_ACTIVE)} `,
|
|
4045
4035
|
`${i2}${c3} `,
|
|
4046
4036
|
(m3) => styleText2("dim", m3)
|
|
4047
4037
|
);
|
|
4048
|
-
if (
|
|
4038
|
+
if (l === "group-active-selected")
|
|
4049
4039
|
return wrapTextWithPrefix(
|
|
4050
|
-
|
|
4040
|
+
r2.output,
|
|
4051
4041
|
a2,
|
|
4052
|
-
`${i2}${
|
|
4053
|
-
`${i2}${
|
|
4042
|
+
`${i2}${o2} `,
|
|
4043
|
+
`${i2}${o2}${styleText2("green", S_CHECKBOX_SELECTED)} `,
|
|
4054
4044
|
`${i2}${c3} `,
|
|
4055
4045
|
(m3) => styleText2("dim", m3)
|
|
4056
4046
|
);
|
|
4057
|
-
if (
|
|
4047
|
+
if (l === "selected") {
|
|
4058
4048
|
const m3 = t2 || f2 ? styleText2("green", S_CHECKBOX_SELECTED) : "";
|
|
4059
4049
|
return wrapTextWithPrefix(
|
|
4060
|
-
|
|
4050
|
+
r2.output,
|
|
4061
4051
|
`${a2}${n3.hint ? ` (${n3.hint})` : ""}`,
|
|
4062
|
-
`${i2}${styleText2("dim",
|
|
4063
|
-
`${i2}${styleText2("dim",
|
|
4052
|
+
`${i2}${styleText2("dim", o2)} `,
|
|
4053
|
+
`${i2}${styleText2("dim", o2)}${m3} `,
|
|
4064
4054
|
`${i2}${styleText2("dim", c3)} `,
|
|
4065
|
-
(
|
|
4055
|
+
(I) => styleText2("dim", I)
|
|
4066
4056
|
);
|
|
4067
4057
|
}
|
|
4068
|
-
if (
|
|
4058
|
+
if (l === "cancelled")
|
|
4069
4059
|
return `${styleText2(["strikethrough", "dim"], a2)}`;
|
|
4070
|
-
if (
|
|
4060
|
+
if (l === "active-selected")
|
|
4071
4061
|
return wrapTextWithPrefix(
|
|
4072
|
-
|
|
4062
|
+
r2.output,
|
|
4073
4063
|
`${a2}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`,
|
|
4074
|
-
`${i2}${styleText2("dim",
|
|
4075
|
-
`${i2}${styleText2("dim",
|
|
4064
|
+
`${i2}${styleText2("dim", o2)} `,
|
|
4065
|
+
`${i2}${styleText2("dim", o2)}${styleText2("green", S_CHECKBOX_SELECTED)} `,
|
|
4076
4066
|
`${i2}${styleText2("dim", c3)} `
|
|
4077
4067
|
);
|
|
4078
|
-
if (
|
|
4068
|
+
if (l === "submitted")
|
|
4079
4069
|
return `${styleText2("dim", a2)}`;
|
|
4080
4070
|
const h2 = t2 || f2 ? styleText2("dim", S_CHECKBOX_INACTIVE) : "";
|
|
4081
4071
|
return wrapTextWithPrefix(
|
|
4082
|
-
|
|
4072
|
+
r2.output,
|
|
4083
4073
|
a2,
|
|
4084
|
-
`${i2}${styleText2("dim",
|
|
4085
|
-
`${i2}${styleText2("dim",
|
|
4074
|
+
`${i2}${styleText2("dim", o2)} `,
|
|
4075
|
+
`${i2}${styleText2("dim", o2)}${h2} `,
|
|
4086
4076
|
`${i2}${styleText2("dim", c3)} `,
|
|
4087
4077
|
(m3) => styleText2("dim", m3)
|
|
4088
4078
|
);
|
|
4089
|
-
},
|
|
4090
|
-
return new u$
|
|
4091
|
-
options:
|
|
4092
|
-
signal:
|
|
4093
|
-
input:
|
|
4094
|
-
output:
|
|
4095
|
-
initialValues:
|
|
4096
|
-
required:
|
|
4097
|
-
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,
|
|
4098
4088
|
selectableGroups: f2,
|
|
4099
4089
|
validate(n3) {
|
|
4100
|
-
if (
|
|
4090
|
+
if (y && (n3 === void 0 || n3.length === 0))
|
|
4101
4091
|
return `Please select at least one option.
|
|
4102
4092
|
${styleText2(
|
|
4103
4093
|
"reset",
|
|
@@ -4111,58 +4101,58 @@ ${styleText2(
|
|
|
4111
4101
|
)}`;
|
|
4112
4102
|
},
|
|
4113
4103
|
render() {
|
|
4114
|
-
const n3 =
|
|
4115
|
-
` : ""}${symbol(this.state)} ${
|
|
4116
|
-
`, p3 = this.value ?? [], a2 = (t2,
|
|
4117
|
-
const
|
|
4118
|
-
return !
|
|
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);
|
|
4119
4109
|
};
|
|
4120
4110
|
switch (this.state) {
|
|
4121
4111
|
case "submit": {
|
|
4122
|
-
const t2 = this.options.filter(({ value:
|
|
4123
|
-
return `${
|
|
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}`;
|
|
4124
4114
|
}
|
|
4125
4115
|
case "cancel": {
|
|
4126
|
-
const t2 = this.options.filter(({ value:
|
|
4127
|
-
return `${
|
|
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 ? `
|
|
4128
4118
|
${styleText2("gray", S_BAR)}` : ""}` : ""}`;
|
|
4129
4119
|
}
|
|
4130
4120
|
case "error": {
|
|
4131
|
-
const t2 = n3 ? `${styleText2("yellow", S_BAR)} ` : "",
|
|
4121
|
+
const t2 = n3 ? `${styleText2("yellow", S_BAR)} ` : "", u4 = this.error.split(`
|
|
4132
4122
|
`).map(
|
|
4133
4123
|
(i2, h2) => h2 === 0 ? `${n3 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", i2)}` : ` ${i2}`
|
|
4134
4124
|
).join(`
|
|
4135
|
-
`),
|
|
4136
|
-
`).length,
|
|
4125
|
+
`), s = l.split(`
|
|
4126
|
+
`).length, o2 = u4.split(`
|
|
4137
4127
|
`).length + 1, c3 = limitOptions({
|
|
4138
|
-
output:
|
|
4128
|
+
output: r2.output,
|
|
4139
4129
|
options: this.options,
|
|
4140
4130
|
cursor: this.cursor,
|
|
4141
|
-
maxItems:
|
|
4131
|
+
maxItems: r2.maxItems,
|
|
4142
4132
|
columnPadding: t2.length,
|
|
4143
|
-
rowPadding:
|
|
4133
|
+
rowPadding: s + o2,
|
|
4144
4134
|
style: a2
|
|
4145
4135
|
}).join(`
|
|
4146
4136
|
${t2}`);
|
|
4147
|
-
return `${
|
|
4148
|
-
${
|
|
4137
|
+
return `${l}${t2}${c3}
|
|
4138
|
+
${u4}
|
|
4149
4139
|
`;
|
|
4150
4140
|
}
|
|
4151
4141
|
default: {
|
|
4152
|
-
const t2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "",
|
|
4153
|
-
`).length,
|
|
4154
|
-
`), c3 =
|
|
4155
|
-
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,
|
|
4156
4146
|
options: this.options,
|
|
4157
4147
|
cursor: this.cursor,
|
|
4158
|
-
maxItems:
|
|
4148
|
+
maxItems: r2.maxItems,
|
|
4159
4149
|
columnPadding: t2.length,
|
|
4160
|
-
rowPadding:
|
|
4150
|
+
rowPadding: u4 + c3,
|
|
4161
4151
|
style: a2
|
|
4162
4152
|
}).join(`
|
|
4163
4153
|
${t2}`);
|
|
4164
|
-
return `${
|
|
4165
|
-
${
|
|
4154
|
+
return `${l}${t2}${i2}
|
|
4155
|
+
${o2}
|
|
4166
4156
|
`;
|
|
4167
4157
|
}
|
|
4168
4158
|
}
|
|
@@ -4174,19 +4164,19 @@ var log = {
|
|
|
4174
4164
|
symbol: e = styleText2("gray", S_BAR),
|
|
4175
4165
|
secondarySymbol: r2 = styleText2("gray", S_BAR),
|
|
4176
4166
|
output: m3 = process.stdout,
|
|
4177
|
-
spacing:
|
|
4167
|
+
spacing: l = 1,
|
|
4178
4168
|
withGuide: c3
|
|
4179
4169
|
} = {}) => {
|
|
4180
|
-
const t2 = [], o2 = c3 ?? settings.withGuide, f2 = o2 ? r2 : "", O = o2 ? `${e} ` : "",
|
|
4181
|
-
for (let i2 = 0; 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++)
|
|
4182
4172
|
t2.push(f2);
|
|
4183
4173
|
const g2 = Array.isArray(s) ? s : s.split(`
|
|
4184
4174
|
`);
|
|
4185
4175
|
if (g2.length > 0) {
|
|
4186
|
-
const [i2, ...
|
|
4176
|
+
const [i2, ...y] = g2;
|
|
4187
4177
|
i2.length > 0 ? t2.push(`${O}${i2}`) : t2.push(o2 ? e : "");
|
|
4188
|
-
for (const p3 of
|
|
4189
|
-
p3.length > 0 ? t2.push(`${
|
|
4178
|
+
for (const p3 of y)
|
|
4179
|
+
p3.length > 0 ? t2.push(`${u4}${p3}`) : t2.push(o2 ? r2 : "");
|
|
4190
4180
|
}
|
|
4191
4181
|
m3.write(`${t2.join(`
|
|
4192
4182
|
`)}
|
|
@@ -4245,57 +4235,57 @@ var multiline = (e) => new h({
|
|
|
4245
4235
|
`, h2 = e.placeholder && e.placeholder.length > 0 ? (
|
|
4246
4236
|
// biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
|
|
4247
4237
|
styleText2("inverse", e.placeholder[0]) + styleText2("dim", e.placeholder.slice(1))
|
|
4248
|
-
) : styleText2(["inverse", "hidden"], "_"), a2 = this.userInput ? this.userInputWithCursor : h2,
|
|
4238
|
+
) : styleText2(["inverse", "hidden"], "_"), a2 = this.userInput ? this.userInputWithCursor : h2, l = this.value ?? "", d = e.showSubmit ? `
|
|
4249
4239
|
${styleText2(this.focused === "submit" ? "cyan" : "dim", "[ submit ]")}` : "";
|
|
4250
4240
|
switch (this.state) {
|
|
4251
4241
|
case "error": {
|
|
4252
|
-
const n3 = `${styleText2("yellow", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(e.output, a2, n3, void 0) : a2,
|
|
4242
|
+
const n3 = `${styleText2("yellow", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(e.output, a2, n3, void 0) : a2, u4 = styleText2("yellow", S_BAR_END);
|
|
4253
4243
|
return `${o2}${r2}
|
|
4254
|
-
${
|
|
4244
|
+
${u4} ${styleText2("yellow", this.error)}${d}
|
|
4255
4245
|
`;
|
|
4256
4246
|
}
|
|
4257
4247
|
case "submit": {
|
|
4258
4248
|
const n3 = `${styleText2("gray", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(
|
|
4259
4249
|
e.output,
|
|
4260
|
-
|
|
4250
|
+
l,
|
|
4261
4251
|
n3,
|
|
4262
4252
|
void 0,
|
|
4263
4253
|
void 0,
|
|
4264
|
-
(
|
|
4265
|
-
) :
|
|
4254
|
+
(u4) => styleText2("dim", u4)
|
|
4255
|
+
) : l ? styleText2("dim", l) : "";
|
|
4266
4256
|
return `${o2}${r2}`;
|
|
4267
4257
|
}
|
|
4268
4258
|
case "cancel": {
|
|
4269
4259
|
const n3 = `${styleText2("gray", S_BAR)} `, r2 = i2 ? wrapTextWithPrefix(
|
|
4270
4260
|
e.output,
|
|
4271
|
-
|
|
4261
|
+
l,
|
|
4272
4262
|
n3,
|
|
4273
4263
|
void 0,
|
|
4274
4264
|
void 0,
|
|
4275
|
-
(
|
|
4276
|
-
) :
|
|
4265
|
+
(u4) => styleText2(["strikethrough", "dim"], u4)
|
|
4266
|
+
) : l ? styleText2(["strikethrough", "dim"], l) : "";
|
|
4277
4267
|
return `${o2}${r2}`;
|
|
4278
4268
|
}
|
|
4279
4269
|
default: {
|
|
4280
|
-
const n3 = i2 ? `${styleText2("cyan", S_BAR)} ` : "", r2 = i2 ? styleText2("cyan", S_BAR_END) : "",
|
|
4281
|
-
return `${o2}${
|
|
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}
|
|
4282
4272
|
${r2}${d}
|
|
4283
4273
|
`;
|
|
4284
4274
|
}
|
|
4285
4275
|
}
|
|
4286
4276
|
}
|
|
4287
4277
|
}).prompt();
|
|
4288
|
-
var W
|
|
4289
|
-
var
|
|
4278
|
+
var W = (o2) => o2;
|
|
4279
|
+
var C3 = (o2, e, s) => {
|
|
4290
4280
|
const a2 = {
|
|
4291
4281
|
hard: true,
|
|
4292
4282
|
trim: false
|
|
4293
4283
|
}, i2 = wrapAnsi(o2, e, a2).split(`
|
|
4294
|
-
`), c3 = i2.reduce((n3, t2) => Math.max(dist_default2(t2), n3), 0),
|
|
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);
|
|
4295
4285
|
return wrapAnsi(o2, g2, a2);
|
|
4296
4286
|
};
|
|
4297
4287
|
var note = (o2 = "", e = "", s) => {
|
|
4298
|
-
const a2 = s?.output ?? process$1.stdout, i2 = s?.withGuide ?? settings.withGuide, c3 = s?.format ?? W
|
|
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(`
|
|
4299
4289
|
`).map(c3), ""], n3 = dist_default2(e), t2 = Math.max(
|
|
4300
4290
|
g2.reduce((m3, F) => {
|
|
4301
4291
|
const O = dist_default2(F);
|
|
@@ -4317,7 +4307,7 @@ ${styleText2("gray", l$1 + S_BAR_H.repeat(t2 + 2) + S_CORNER_BOTTOM_RIGHT)}
|
|
|
4317
4307
|
`
|
|
4318
4308
|
);
|
|
4319
4309
|
};
|
|
4320
|
-
var password = (e) => new
|
|
4310
|
+
var password = (e) => new u2({
|
|
4321
4311
|
validate: e.validate,
|
|
4322
4312
|
mask: e.mask ?? S_PASSWORD_MASK,
|
|
4323
4313
|
signal: e.signal,
|
|
@@ -4374,17 +4364,18 @@ var path = (e) => {
|
|
|
4374
4364
|
return [];
|
|
4375
4365
|
try {
|
|
4376
4366
|
let i2;
|
|
4377
|
-
|
|
4378
|
-
|
|
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;
|
|
4379
4370
|
return readdirSync(i2).map((r2) => {
|
|
4380
|
-
const n3 = join(i2, r2),
|
|
4371
|
+
const n3 = join(i2, r2), l = lstatSync(n3);
|
|
4381
4372
|
return {
|
|
4382
4373
|
name: r2,
|
|
4383
4374
|
path: n3,
|
|
4384
|
-
isDirectory:
|
|
4375
|
+
isDirectory: l.isDirectory()
|
|
4385
4376
|
};
|
|
4386
4377
|
}).filter(
|
|
4387
|
-
({ path: r2, isDirectory: n3 }) => r2.startsWith(
|
|
4378
|
+
({ path: r2, isDirectory: n3 }) => r2.startsWith(m3) && (n3 || !e.directory)
|
|
4388
4379
|
).map((r2) => ({
|
|
4389
4380
|
value: r2.path
|
|
4390
4381
|
}));
|
|
@@ -4394,87 +4385,106 @@ var path = (e) => {
|
|
|
4394
4385
|
}
|
|
4395
4386
|
});
|
|
4396
4387
|
};
|
|
4397
|
-
var
|
|
4388
|
+
var Y = 3e4;
|
|
4389
|
+
var Z = (c3) => styleText2("magenta", c3);
|
|
4398
4390
|
var spinner = ({
|
|
4399
|
-
indicator:
|
|
4400
|
-
onCancel:
|
|
4391
|
+
indicator: c3 = "dots",
|
|
4392
|
+
onCancel: b3,
|
|
4401
4393
|
output: n3 = process.stdout,
|
|
4402
|
-
cancelMessage:
|
|
4403
|
-
errorMessage:
|
|
4404
|
-
frames:
|
|
4405
|
-
delay:
|
|
4406
|
-
signal:
|
|
4407
|
-
...
|
|
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
|
|
4408
4400
|
} = {}) => {
|
|
4409
|
-
const
|
|
4410
|
-
let
|
|
4411
|
-
const
|
|
4412
|
-
const
|
|
4413
|
-
|
|
4414
|
-
},
|
|
4415
|
-
process.on("uncaughtExceptionMonitor",
|
|
4416
|
-
},
|
|
4417
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
4418
|
-
},
|
|
4419
|
-
if (
|
|
4420
|
-
|
|
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(`
|
|
4421
4413
|
`);
|
|
4422
|
-
const
|
|
4414
|
+
const s = wrapAnsi(v, y, {
|
|
4423
4415
|
hard: true,
|
|
4424
4416
|
trim: false
|
|
4425
4417
|
}).split(`
|
|
4426
4418
|
`);
|
|
4427
|
-
|
|
4428
|
-
},
|
|
4429
|
-
const
|
|
4430
|
-
return
|
|
4431
|
-
}, N =
|
|
4432
|
-
|
|
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}
|
|
4433
4429
|
`);
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4430
|
+
}, Y);
|
|
4431
|
+
return;
|
|
4432
|
+
}
|
|
4433
|
+
x2 = block({ output: n3 }), N && n3.write(`${styleText2("gray", S_BAR)}
|
|
4434
|
+
`);
|
|
4435
|
+
let s = 0, i2 = 0;
|
|
4436
|
+
I = setInterval(() => {
|
|
4437
|
+
if (u4 && r2 === v)
|
|
4437
4438
|
return;
|
|
4438
|
-
|
|
4439
|
-
const
|
|
4440
|
-
let
|
|
4441
|
-
if (
|
|
4442
|
-
|
|
4443
|
-
else if (
|
|
4444
|
-
|
|
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)}`;
|
|
4445
4446
|
else {
|
|
4446
|
-
const
|
|
4447
|
-
|
|
4447
|
+
const j2 = ".".repeat(Math.floor(i2)).slice(0, 3);
|
|
4448
|
+
o2 = `${t2} ${r2}${j2}`;
|
|
4448
4449
|
}
|
|
4449
|
-
const
|
|
4450
|
+
const D = wrapAnsi(o2, y, {
|
|
4450
4451
|
hard: true,
|
|
4451
4452
|
trim: false
|
|
4452
4453
|
});
|
|
4453
|
-
n3.write(
|
|
4454
|
-
},
|
|
4455
|
-
},
|
|
4456
|
-
if (
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
`)
|
|
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
|
+
}
|
|
4462
4472
|
};
|
|
4463
4473
|
return {
|
|
4464
4474
|
start: P3,
|
|
4465
|
-
stop: (e = "") =>
|
|
4475
|
+
stop: (e = "") => m3(e, 0),
|
|
4466
4476
|
message: (e = "") => {
|
|
4467
|
-
|
|
4477
|
+
r2 = L(e ?? r2);
|
|
4468
4478
|
},
|
|
4469
|
-
cancel: (e = "") =>
|
|
4470
|
-
error: (e = "") =>
|
|
4471
|
-
clear: () =>
|
|
4479
|
+
cancel: (e = "") => m3(e, 1),
|
|
4480
|
+
error: (e = "") => m3(e, 2),
|
|
4481
|
+
clear: () => m3("", 0, true),
|
|
4472
4482
|
get isCancelled() {
|
|
4473
|
-
return
|
|
4483
|
+
return l;
|
|
4474
4484
|
}
|
|
4475
4485
|
};
|
|
4476
4486
|
};
|
|
4477
|
-
var
|
|
4487
|
+
var u3 = {
|
|
4478
4488
|
light: unicodeOr("\u2500", "-"),
|
|
4479
4489
|
heavy: unicodeOr("\u2501", "="),
|
|
4480
4490
|
block: unicodeOr("\u2588", "#")
|
|
@@ -4487,7 +4497,7 @@ function progress({
|
|
|
4487
4497
|
} = {}) {
|
|
4488
4498
|
const r2 = spinner(x2);
|
|
4489
4499
|
let a2 = 0, n3 = "";
|
|
4490
|
-
const c3 = Math.max(1, d),
|
|
4500
|
+
const c3 = Math.max(1, d), l = Math.max(1, v), S = (t2) => {
|
|
4491
4501
|
switch (t2) {
|
|
4492
4502
|
case "initial":
|
|
4493
4503
|
case "active":
|
|
@@ -4501,8 +4511,8 @@ function progress({
|
|
|
4501
4511
|
return (e) => styleText2("magenta", e);
|
|
4502
4512
|
}
|
|
4503
4513
|
}, p3 = (t2, e) => {
|
|
4504
|
-
const m3 = Math.floor(a2 / c3 *
|
|
4505
|
-
return `${S(t2)(
|
|
4514
|
+
const m3 = Math.floor(a2 / c3 * l);
|
|
4515
|
+
return `${S(t2)(u3[o2].repeat(m3))}${styleText2("dim", u3[o2].repeat(l - m3))} ${e}`;
|
|
4506
4516
|
}, h2 = (t2 = "") => {
|
|
4507
4517
|
n3 = t2, r2.start(p3("initial", t2));
|
|
4508
4518
|
}, g2 = (t2 = 1, e) => {
|
|
@@ -4515,7 +4525,9 @@ function progress({
|
|
|
4515
4525
|
error: r2.error,
|
|
4516
4526
|
clear: r2.clear,
|
|
4517
4527
|
advance: g2,
|
|
4518
|
-
isCancelled
|
|
4528
|
+
get isCancelled() {
|
|
4529
|
+
return r2.isCancelled;
|
|
4530
|
+
},
|
|
4519
4531
|
message: (t2) => g2(0, t2)
|
|
4520
4532
|
};
|
|
4521
4533
|
}
|
|
@@ -4557,7 +4569,7 @@ var select = (t2) => {
|
|
|
4557
4569
|
t2.message,
|
|
4558
4570
|
s,
|
|
4559
4571
|
m3
|
|
4560
|
-
),
|
|
4572
|
+
), u4 = `${n3 ? `${styleText2("gray", S_BAR)}
|
|
4561
4573
|
` : ""}${i2}
|
|
4562
4574
|
`;
|
|
4563
4575
|
switch (this.state) {
|
|
@@ -4567,7 +4579,7 @@ var select = (t2) => {
|
|
|
4567
4579
|
o2(this.options[this.cursor], "selected"),
|
|
4568
4580
|
r2
|
|
4569
4581
|
);
|
|
4570
|
-
return `${
|
|
4582
|
+
return `${u4}${a2}`;
|
|
4571
4583
|
}
|
|
4572
4584
|
case "cancel": {
|
|
4573
4585
|
const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
|
|
@@ -4575,14 +4587,14 @@ var select = (t2) => {
|
|
|
4575
4587
|
o2(this.options[this.cursor], "cancelled"),
|
|
4576
4588
|
r2
|
|
4577
4589
|
);
|
|
4578
|
-
return `${
|
|
4590
|
+
return `${u4}${a2}${n3 ? `
|
|
4579
4591
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
4580
4592
|
}
|
|
4581
4593
|
default: {
|
|
4582
|
-
const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 =
|
|
4583
|
-
`).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(`
|
|
4584
4596
|
`), b3 = p3.length + 1;
|
|
4585
|
-
return `${
|
|
4597
|
+
return `${u4}${r2}${limitOptions({
|
|
4586
4598
|
output: t2.output,
|
|
4587
4599
|
cursor: this.cursor,
|
|
4588
4600
|
options: this.options,
|
|
@@ -4599,36 +4611,36 @@ ${f2}
|
|
|
4599
4611
|
}
|
|
4600
4612
|
}).prompt();
|
|
4601
4613
|
};
|
|
4602
|
-
var selectKey = (
|
|
4614
|
+
var selectKey = (i2) => {
|
|
4603
4615
|
const c3 = (e, a2 = "inactive") => {
|
|
4604
4616
|
if (e === void 0)
|
|
4605
4617
|
return "";
|
|
4606
4618
|
const n3 = e.label ?? String(e.value);
|
|
4607
|
-
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})`)}` : ""}`;
|
|
4608
4620
|
};
|
|
4609
|
-
return new
|
|
4610
|
-
options:
|
|
4611
|
-
signal:
|
|
4612
|
-
input:
|
|
4613
|
-
output:
|
|
4614
|
-
initialValue:
|
|
4615
|
-
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,
|
|
4616
4628
|
render() {
|
|
4617
|
-
const e =
|
|
4618
|
-
` : ""}${symbol(this.state)} ${
|
|
4629
|
+
const e = i2.withGuide ?? settings.withGuide, a2 = `${e ? `${styleText2("gray", S_BAR)}
|
|
4630
|
+
` : ""}${symbol(this.state)} ${i2.message}
|
|
4619
4631
|
`;
|
|
4620
4632
|
switch (this.state) {
|
|
4621
4633
|
case "submit": {
|
|
4622
|
-
const n3 = e ? `${styleText2("gray", S_BAR)} ` : "", r2 = this.options.find((
|
|
4623
|
-
|
|
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,
|
|
4624
4636
|
c3(r2, "selected"),
|
|
4625
4637
|
n3
|
|
4626
4638
|
);
|
|
4627
|
-
return `${a2}${
|
|
4639
|
+
return `${a2}${u4}`;
|
|
4628
4640
|
}
|
|
4629
4641
|
case "cancel": {
|
|
4630
4642
|
const n3 = e ? `${styleText2("gray", S_BAR)} ` : "", r2 = wrapTextWithPrefix(
|
|
4631
|
-
|
|
4643
|
+
i2.output,
|
|
4632
4644
|
c3(this.options[0], "cancelled"),
|
|
4633
4645
|
n3
|
|
4634
4646
|
);
|
|
@@ -4636,15 +4648,18 @@ var selectKey = (t2) => {
|
|
|
4636
4648
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
4637
4649
|
}
|
|
4638
4650
|
default: {
|
|
4639
|
-
const n3 = e ? `${styleText2("cyan", S_BAR)} ` : "", r2 = e ? styleText2("cyan", S_BAR_END) : "",
|
|
4640
|
-
(
|
|
4641
|
-
|
|
4642
|
-
c3(
|
|
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
|
+
),
|
|
4643
4658
|
n3
|
|
4644
4659
|
)
|
|
4645
4660
|
).join(`
|
|
4646
4661
|
`);
|
|
4647
|
-
return `${a2}${
|
|
4662
|
+
return `${a2}${u4}
|
|
4648
4663
|
${r2}
|
|
4649
4664
|
`;
|
|
4650
4665
|
}
|
|
@@ -4654,9 +4669,9 @@ ${r2}
|
|
|
4654
4669
|
};
|
|
4655
4670
|
var i = `${styleText2("gray", S_BAR)} `;
|
|
4656
4671
|
var stream = {
|
|
4657
|
-
message: async (e, { symbol:
|
|
4672
|
+
message: async (e, { symbol: l = styleText2("gray", S_BAR) } = {}) => {
|
|
4658
4673
|
process.stdout.write(`${styleText2("gray", S_BAR)}
|
|
4659
|
-
${
|
|
4674
|
+
${l} `);
|
|
4660
4675
|
let s = 3;
|
|
4661
4676
|
for await (let r2 of e) {
|
|
4662
4677
|
r2 = r2.replace(/\n/g, `
|
|
@@ -4687,11 +4702,11 @@ var tasks = async (o2, e) => {
|
|
|
4687
4702
|
s.stop(n3 || t2.title);
|
|
4688
4703
|
}
|
|
4689
4704
|
};
|
|
4690
|
-
var A = (
|
|
4691
|
-
var taskLog = (
|
|
4692
|
-
const 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);
|
|
4693
4708
|
r2.write(`${i2}
|
|
4694
|
-
`), r2.write(`${styleText2("green", S_STEP_SUBMIT)} ${
|
|
4709
|
+
`), r2.write(`${styleText2("green", S_STEP_SUBMIT)} ${l.title}
|
|
4695
4710
|
`);
|
|
4696
4711
|
for (let e = 0; e < p3; e++)
|
|
4697
4712
|
r2.write(`${i2}
|
|
@@ -4719,7 +4734,7 @@ ${t2.header}`);
|
|
|
4719
4734
|
`).reduce((b3, w) => w === "" ? b3 + 1 : b3 + Math.ceil((w.length + k) / O), 0);
|
|
4720
4735
|
s += E2;
|
|
4721
4736
|
}
|
|
4722
|
-
s > 0 && (s += 1, r2.write(
|
|
4737
|
+
s > 0 && (s += 1, r2.write(erase.lines(s)));
|
|
4723
4738
|
}, h2 = (e, s, t2) => {
|
|
4724
4739
|
const o2 = t2 ? `${e.full}
|
|
4725
4740
|
${e.value}` : e.value;
|
|
@@ -4749,9 +4764,9 @@ ${e.value}` : e.value;
|
|
|
4749
4764
|
}
|
|
4750
4765
|
}, L = (e, s, t2) => {
|
|
4751
4766
|
if (f2(false), (t2?.raw !== true || !v) && e.value !== "" && (e.value += `
|
|
4752
|
-
`), e.value += A(s), v = t2?.raw === true,
|
|
4767
|
+
`), e.value += A(s), v = t2?.raw === true, l.limit !== void 0) {
|
|
4753
4768
|
const o2 = e.value.split(`
|
|
4754
|
-
`), a2 = o2.length -
|
|
4769
|
+
`), a2 = o2.length - l.limit;
|
|
4755
4770
|
if (a2 > 0) {
|
|
4756
4771
|
const g2 = o2.splice(0, a2);
|
|
4757
4772
|
m3 && (e.full += (e.full === "" ? "" : `
|
|
@@ -4761,12 +4776,12 @@ ${e.value}` : e.value;
|
|
|
4761
4776
|
e.value = o2.join(`
|
|
4762
4777
|
`);
|
|
4763
4778
|
}
|
|
4764
|
-
d &&
|
|
4765
|
-
},
|
|
4779
|
+
d && y();
|
|
4780
|
+
}, y = () => {
|
|
4766
4781
|
for (const e of n3)
|
|
4767
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);
|
|
4768
4783
|
}, B = (e, s) => {
|
|
4769
|
-
f2(false), e.result = s, d &&
|
|
4784
|
+
f2(false), e.result = s, d && y();
|
|
4770
4785
|
};
|
|
4771
4786
|
return {
|
|
4772
4787
|
message(e, s) {
|
|
@@ -4813,7 +4828,7 @@ var text = (t2) => new n2({
|
|
|
4813
4828
|
signal: t2.signal,
|
|
4814
4829
|
input: t2.input,
|
|
4815
4830
|
render() {
|
|
4816
|
-
const r2 = t2?.withGuide ?? settings.withGuide,
|
|
4831
|
+
const r2 = t2?.withGuide ?? settings.withGuide, l = `${`${r2 ? `${styleText2("gray", S_BAR)}
|
|
4817
4832
|
` : ""}${symbol(this.state)} `}${t2.message}
|
|
4818
4833
|
`, d = t2.placeholder && t2.placeholder.length > 0 ? (
|
|
4819
4834
|
// biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
|
|
@@ -4822,29 +4837,29 @@ var text = (t2) => new n2({
|
|
|
4822
4837
|
switch (this.state) {
|
|
4823
4838
|
case "validating": {
|
|
4824
4839
|
const n3 = r2 ? `${styleText2("cyan", S_BAR)} ` : "", i2 = r2 ? styleText2("cyan", S_BAR_END) : "", c3 = styleText2("dim", o2), $ = styleText2("dim", "Validating...");
|
|
4825
|
-
return `${
|
|
4840
|
+
return `${l}${n3}${c3}
|
|
4826
4841
|
${i2} ${$}
|
|
4827
4842
|
`;
|
|
4828
4843
|
}
|
|
4829
4844
|
case "error": {
|
|
4830
4845
|
const n3 = this.error ? ` ${styleText2("yellow", this.error)}` : "", i2 = r2 ? `${styleText2("yellow", S_BAR)} ` : "", c3 = r2 ? styleText2("yellow", S_BAR_END) : "";
|
|
4831
|
-
return `${
|
|
4846
|
+
return `${l.trim()}
|
|
4832
4847
|
${i2}${o2}
|
|
4833
4848
|
${c3}${n3}
|
|
4834
4849
|
`;
|
|
4835
4850
|
}
|
|
4836
4851
|
case "submit": {
|
|
4837
4852
|
const n3 = s ? `${r2 ? " " : ""}${styleText2("dim", s)}` : "", i2 = r2 ? styleText2("gray", S_BAR) : "";
|
|
4838
|
-
return `${
|
|
4853
|
+
return `${l}${i2}${n3}`;
|
|
4839
4854
|
}
|
|
4840
4855
|
case "cancel": {
|
|
4841
4856
|
const n3 = s ? ` ${styleText2(["strikethrough", "dim"], s)}` : "", i2 = r2 ? styleText2("gray", S_BAR) : "";
|
|
4842
|
-
return `${
|
|
4857
|
+
return `${l}${i2}${n3}${s.trim() ? `
|
|
4843
4858
|
${i2}` : ""}`;
|
|
4844
4859
|
}
|
|
4845
4860
|
default: {
|
|
4846
4861
|
const n3 = r2 ? `${styleText2("cyan", S_BAR)} ` : "", i2 = r2 ? styleText2("cyan", S_BAR_END) : "";
|
|
4847
|
-
return `${
|
|
4862
|
+
return `${l}${n3}${o2}
|
|
4848
4863
|
${i2}
|
|
4849
4864
|
`;
|
|
4850
4865
|
}
|
|
@@ -5020,17 +5035,17 @@ import { closeSync as closeSync2, existsSync as existsSync10, fstatSync, mkdirSy
|
|
|
5020
5035
|
import { delimiter, join as join11 } from "node:path";
|
|
5021
5036
|
|
|
5022
5037
|
// src/core/hooks/fallback.ts
|
|
5023
|
-
import { join as join5, resolve as
|
|
5038
|
+
import { join as join5, resolve as resolve4 } from "node:path";
|
|
5024
5039
|
|
|
5025
5040
|
// src/core/policy/read-media.ts
|
|
5026
5041
|
import { extname } from "node:path";
|
|
5027
5042
|
var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
|
|
5028
5043
|
|
|
5029
5044
|
// src/core/policy/own-file.ts
|
|
5030
|
-
import { extname as extname2, join as join4 } from "node:path";
|
|
5045
|
+
import { extname as extname2, join as join4, resolve as resolve3 } from "node:path";
|
|
5031
5046
|
|
|
5032
5047
|
// src/core/project/contain.ts
|
|
5033
|
-
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";
|
|
5034
5049
|
var { lstatSync: lstatSync2, realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
|
|
5035
5050
|
function components(p3) {
|
|
5036
5051
|
return p3.split(sep).filter((c3) => c3 !== "");
|
|
@@ -5058,8 +5073,8 @@ function nodeTooOld(version) {
|
|
|
5058
5073
|
const b3 = NODE_MIN.split(".");
|
|
5059
5074
|
for (let i2 = 0; i2 < b3.length; i2++) {
|
|
5060
5075
|
const x2 = Number(a2[i2] ?? 0) || 0;
|
|
5061
|
-
const
|
|
5062
|
-
if (x2 !==
|
|
5076
|
+
const y = Number(b3[i2]);
|
|
5077
|
+
if (x2 !== y) return x2 < y;
|
|
5063
5078
|
}
|
|
5064
5079
|
return false;
|
|
5065
5080
|
}
|
|
@@ -5155,7 +5170,7 @@ var { existsSync: existsSync3, linkSync, mkdirSync: mkdirSync2, rmSync } = proce
|
|
|
5155
5170
|
|
|
5156
5171
|
// src/core/ops/doctor-config.ts
|
|
5157
5172
|
import { existsSync as existsSync9, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
|
|
5158
|
-
import { dirname as dirname7, join as join10 } from "node:path";
|
|
5173
|
+
import { dirname as dirname7, isAbsolute as isAbsolute3, join as join10, resolve as resolve5 } from "node:path";
|
|
5159
5174
|
|
|
5160
5175
|
// src/core/ops/host-text.ts
|
|
5161
5176
|
var BOM_CODE = 65279;
|
|
@@ -6381,8 +6396,8 @@ function isNonEOL(cp) {
|
|
|
6381
6396
|
function isNonAscii(cp) {
|
|
6382
6397
|
return CodePoint.PAD <= cp && cp <= CodePoint.CP_D7FF || CodePoint.CP_E000 <= cp && cp <= CodePoint.CP_10FFFF;
|
|
6383
6398
|
}
|
|
6384
|
-
function isValidDate(
|
|
6385
|
-
if (
|
|
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));
|
|
6386
6401
|
return false;
|
|
6387
6402
|
}
|
|
6388
6403
|
function isValidTime(h2, m3, s) {
|
|
@@ -7299,6 +7314,23 @@ function atomicWriteFile(file, text2, opts = {}) {
|
|
|
7299
7314
|
import { existsSync as existsSync4 } from "node:fs";
|
|
7300
7315
|
import { dirname as dirname4, join as join6 } from "node:path";
|
|
7301
7316
|
import { fileURLToPath } from "node:url";
|
|
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;
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
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;
|
|
7333
|
+
}
|
|
7302
7334
|
|
|
7303
7335
|
// src/core/ops/host-config.ts
|
|
7304
7336
|
function stripJsonComments(text2) {
|
|
@@ -7654,6 +7686,9 @@ function ownMcpValue(agent, node, server) {
|
|
|
7654
7686
|
if (mcp === void 0) return void 0;
|
|
7655
7687
|
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent] };
|
|
7656
7688
|
}
|
|
7689
|
+
function opencodePluginFile() {
|
|
7690
|
+
return ownBundleDir();
|
|
7691
|
+
}
|
|
7657
7692
|
function applyEdits(agent, path15, text2, format, wanted) {
|
|
7658
7693
|
const parsed = parseHostConfig(agent, path15, text2, format);
|
|
7659
7694
|
let out2 = text2;
|
|
@@ -7775,7 +7810,7 @@ function flatCommands(events2, prefix) {
|
|
|
7775
7810
|
return out2;
|
|
7776
7811
|
}
|
|
7777
7812
|
var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
|
|
7778
|
-
var isCodexScript = (cmd) =>
|
|
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)));
|
|
7779
7814
|
function dataDir(dir, reason, out2) {
|
|
7780
7815
|
if (existsSync6(dir)) out2.push(finding(dir, "", reason));
|
|
7781
7816
|
}
|
|
@@ -7823,8 +7858,7 @@ function scanCodex(agentHome, out2) {
|
|
|
7823
7858
|
const config = readTomlValue(tomlFile);
|
|
7824
7859
|
for (const span of readTomlTables(tomlFile)) {
|
|
7825
7860
|
if (span.path[0] !== V1_TOML_SECTION_ROOT || span.path[1] !== SERVER_KEY) continue;
|
|
7826
|
-
if (
|
|
7827
|
-
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;
|
|
7828
7862
|
out2.push(finding(tomlFile, span.header.trim(), V1_REASON.codexToml));
|
|
7829
7863
|
}
|
|
7830
7864
|
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out2);
|
|
@@ -7987,7 +8021,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
7987
8021
|
|
|
7988
8022
|
// src/core/ops/plugin-root.ts
|
|
7989
8023
|
import { existsSync as existsSync7, readdirSync as readdirSync4, readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
7990
|
-
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";
|
|
7991
8025
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7992
8026
|
|
|
7993
8027
|
// src/setup/pi-gate.ts
|
|
@@ -8092,6 +8126,7 @@ function piSettingsGate(env, home, pkgDir, cwd) {
|
|
|
8092
8126
|
|
|
8093
8127
|
// src/core/ops/doctor-config.ts
|
|
8094
8128
|
var [PART_MCP, PART_HOOKS, PART_TIMEOUT] = D3_PARTS;
|
|
8129
|
+
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
8095
8130
|
function composeMatcher(row, event) {
|
|
8096
8131
|
let prefix = "";
|
|
8097
8132
|
for (const ch of row.toolNamePrefix) prefix += REGEX_SPECIAL_CHARS.includes(ch) ? REGEX_ESCAPE + ch : ch;
|
|
@@ -8101,6 +8136,118 @@ function composeMatcher(row, event) {
|
|
|
8101
8136
|
return MATCHER_OPEN + alts.join(MATCHER_ALT) + MATCHER_CLOSE;
|
|
8102
8137
|
}
|
|
8103
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
|
+
}
|
|
8104
8251
|
|
|
8105
8252
|
// src/core/ops/doctor-issue.ts
|
|
8106
8253
|
function formUrl(title, summary) {
|
|
@@ -8377,6 +8524,8 @@ function hookInstallFor(ctx, row, command) {
|
|
|
8377
8524
|
kind: "plugin-list",
|
|
8378
8525
|
file: path4.join(opencodeDirOf(ctx.env, ctx.home), OPENCODE_BASE_CONFIG_FILE),
|
|
8379
8526
|
key: ["plugin"],
|
|
8527
|
+
worktree: ctx.cwd ?? process.cwd(),
|
|
8528
|
+
// D-R54-OC-PLUGINS-DIR-1: <project>/.opencode/plugins
|
|
8380
8529
|
entry: ctx.pkgDir
|
|
8381
8530
|
};
|
|
8382
8531
|
}
|
|
@@ -8890,14 +9039,14 @@ async function listPluginHooks(env, pluginId, cwd) {
|
|
|
8890
9039
|
function askPluginHooks(env, pluginId, cwd) {
|
|
8891
9040
|
const bin = whichBin("codex", env);
|
|
8892
9041
|
if (!bin) return Promise.resolve({ kind: "absent" });
|
|
8893
|
-
return new Promise((
|
|
9042
|
+
return new Promise((resolve6) => {
|
|
8894
9043
|
let asked;
|
|
8895
9044
|
const done_ = (hooks) => hooks === void 0 ? { kind: "silent" } : { kind: "list", hooks, codexHome: asked };
|
|
8896
9045
|
let f2;
|
|
8897
9046
|
try {
|
|
8898
9047
|
f2 = spawnForm(bin, ["app-server"], env);
|
|
8899
9048
|
} catch {
|
|
8900
|
-
|
|
9049
|
+
resolve6({ kind: "silent" });
|
|
8901
9050
|
return;
|
|
8902
9051
|
}
|
|
8903
9052
|
const child = spawn(f2.command, f2.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f2.windowsVerbatimArguments, windowsHide: true });
|
|
@@ -8907,7 +9056,7 @@ function askPluginHooks(env, pluginId, cwd) {
|
|
|
8907
9056
|
let result;
|
|
8908
9057
|
const settle = () => {
|
|
8909
9058
|
clearTimeout(grace);
|
|
8910
|
-
|
|
9059
|
+
resolve6(done_(result));
|
|
8911
9060
|
};
|
|
8912
9061
|
let grace;
|
|
8913
9062
|
const finish2 = (v) => {
|
|
@@ -9046,12 +9195,12 @@ function frame(buf) {
|
|
|
9046
9195
|
function listCopilotHooks(env, file, cwd) {
|
|
9047
9196
|
const bin = whichBin("copilot", env);
|
|
9048
9197
|
if (!bin) return Promise.resolve(void 0);
|
|
9049
|
-
return new Promise((
|
|
9198
|
+
return new Promise((resolve6) => {
|
|
9050
9199
|
let f2;
|
|
9051
9200
|
try {
|
|
9052
9201
|
f2 = spawnForm(bin, ["--server", "--stdio", "--no-auto-update"], env);
|
|
9053
9202
|
} catch {
|
|
9054
|
-
|
|
9203
|
+
resolve6(void 0);
|
|
9055
9204
|
return;
|
|
9056
9205
|
}
|
|
9057
9206
|
const child = spawn2(f2.command, f2.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f2.windowsVerbatimArguments, windowsHide: true });
|
|
@@ -9063,7 +9212,7 @@ function listCopilotHooks(env, file, cwd) {
|
|
|
9063
9212
|
clearTimeout(timer);
|
|
9064
9213
|
child.stdin.destroy();
|
|
9065
9214
|
child.kill();
|
|
9066
|
-
|
|
9215
|
+
resolve6(v);
|
|
9067
9216
|
};
|
|
9068
9217
|
const timer = setTimeout(() => finish2(void 0), ASK_TIMEOUT_MS2);
|
|
9069
9218
|
child.on("error", () => finish2(void 0));
|
|
@@ -9117,9 +9266,9 @@ function sampleText() {
|
|
|
9117
9266
|
const lines = [];
|
|
9118
9267
|
let bytes = 0;
|
|
9119
9268
|
for (let i2 = 0; bytes < SAMPLE_BYTES; i2++) {
|
|
9120
|
-
const
|
|
9121
|
-
lines.push(
|
|
9122
|
-
bytes +=
|
|
9269
|
+
const l = "context-mode doctor sample line " + i2;
|
|
9270
|
+
lines.push(l);
|
|
9271
|
+
bytes += l.length + 1;
|
|
9123
9272
|
}
|
|
9124
9273
|
return lines.join("\n") + "\n";
|
|
9125
9274
|
}
|
|
@@ -9139,7 +9288,7 @@ function hookSample(id, cwd, text2) {
|
|
|
9139
9288
|
case "pi":
|
|
9140
9289
|
return { effect, payload: { type: event, sessionId: SAMPLE_SESSION, cwd, toolName: tool, input: command, content: text2, isError: false } };
|
|
9141
9290
|
case "opencode":
|
|
9142
|
-
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 } : {} } };
|
|
9143
9292
|
case "codex":
|
|
9144
9293
|
case "qwen":
|
|
9145
9294
|
case "vscode":
|
|
@@ -9149,7 +9298,7 @@ function hookSample(id, cwd, text2) {
|
|
|
9149
9298
|
}
|
|
9150
9299
|
}
|
|
9151
9300
|
function sampleVerdict(id, effect, text2, a2) {
|
|
9152
|
-
const noProject = a2.stderr.split("\n").find((
|
|
9301
|
+
const noProject = a2.stderr.split("\n").find((l) => l.startsWith(NO_PROJECT_LINE));
|
|
9153
9302
|
if (noProject !== void 0) return "NO_PROJECT: the hook did not resolve the project (" + noProject.trim() + ")";
|
|
9154
9303
|
if (a2.status === null) return "hook did not finish";
|
|
9155
9304
|
if (a2.status !== 0 && a2.status !== DENY_EXIT) return `hook exited ${a2.status}: ${a2.stderr.trim()}`;
|
|
@@ -9372,9 +9521,8 @@ function planCodexTrust(row, edits, hooksFile, file, command, env) {
|
|
|
9372
9521
|
prior.changes.push(...changes);
|
|
9373
9522
|
} else edits.push({ file, before: text2, after: res.text, changes });
|
|
9374
9523
|
}
|
|
9375
|
-
var NATIVE_PLUGIN_PREFIX = "context-mode@";
|
|
9376
9524
|
function isNativeSpec(e) {
|
|
9377
|
-
return
|
|
9525
|
+
return isNativeOpencodeEntry(e, OPENCODE_PLUGIN_KEY);
|
|
9378
9526
|
}
|
|
9379
9527
|
function isStaleOwnPlugin(e, entry2) {
|
|
9380
9528
|
if (typeof e !== "string" || e === entry2 || !path12.isAbsolute(e)) return false;
|
|
@@ -9390,10 +9538,31 @@ function wantedPluginList(list2, entry2, nativeElsewhere = false) {
|
|
|
9390
9538
|
const kept = list2.filter((e) => !(native && e === entry2) && !isStaleOwnPlugin(e, entry2));
|
|
9391
9539
|
return native || kept.includes(entry2) ? kept : [...kept, entry2];
|
|
9392
9540
|
}
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
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;
|
|
9397
9566
|
}
|
|
9398
9567
|
function pluginListIssue(h2) {
|
|
9399
9568
|
const text2 = readOr(h2.file);
|
|
@@ -9406,7 +9575,10 @@ function pluginListIssue(h2) {
|
|
|
9406
9575
|
}
|
|
9407
9576
|
const cur = isObj5(doc) ? doc[h2.key[0]] : void 0;
|
|
9408
9577
|
const list2 = Array.isArray(cur) ? cur : [];
|
|
9409
|
-
|
|
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`;
|
|
9410
9582
|
const stale = list2.find((e) => isStaleOwnPlugin(e, h2.entry));
|
|
9411
9583
|
if (stale !== void 0) return `${h2.file}: plugin file missing, so OpenCode never loads the hooks (${String(stale)}); run: context-mode setup`;
|
|
9412
9584
|
return void 0;
|
|
@@ -9433,7 +9605,7 @@ function planHookInstall(row, edits, env) {
|
|
|
9433
9605
|
planJsonKeys(row, edits, h2.file, fileFormat(row, h2.file), (doc) => {
|
|
9434
9606
|
const cur = doc[h2.key[0]];
|
|
9435
9607
|
const list2 = Array.isArray(cur) ? cur : [];
|
|
9436
|
-
const want = wantedPluginList(list2, h2.entry, nativePluginsKey(doc));
|
|
9608
|
+
const want = wantedPluginList(list2, h2.entry, nativePluginsKey(doc, h2.file));
|
|
9437
9609
|
if (cur === void 0 && want.length === 0) return [];
|
|
9438
9610
|
return [[h2.key, want.length === list2.length && want.every((e, i2) => e === list2[i2]) ? list2 : want]];
|
|
9439
9611
|
});
|
|
@@ -9497,54 +9669,66 @@ function statusOf(row, text2) {
|
|
|
9497
9669
|
}
|
|
9498
9670
|
return void 0;
|
|
9499
9671
|
}
|
|
9500
|
-
function
|
|
9672
|
+
function opencodeVersion(bin, env) {
|
|
9501
9673
|
const r2 = runBin(bin, ["--version"], env);
|
|
9502
9674
|
const text2 = `${r2.stdout}${r2.stderr}`;
|
|
9503
9675
|
const digits = text2.split("").filter((c3) => c3 >= "0" && c3 <= "9" || c3 === ".").join("");
|
|
9504
|
-
|
|
9676
|
+
if (!digits.split(".")[0]) return { error: `${bin} --version printed no version: ${text2.trim().split("\n")[0] ?? ""}` };
|
|
9677
|
+
return { major: Number(digits.split(".")[0]) };
|
|
9505
9678
|
}
|
|
9506
|
-
function
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
const
|
|
9513
|
-
|
|
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;
|
|
9514
9690
|
try {
|
|
9515
|
-
|
|
9691
|
+
out2 = JSON.parse(`${r2.stdout}`);
|
|
9516
9692
|
} catch {
|
|
9517
|
-
|
|
9693
|
+
out2 = void 0;
|
|
9518
9694
|
}
|
|
9519
|
-
if (r2.status !== 0) return { name: "list", ok: false, detail: `${what} exited ${r2.status}: ${
|
|
9520
|
-
if (
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
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"}` };
|
|
9701
|
+
}
|
|
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"}` };
|
|
9524
9706
|
}
|
|
9707
|
+
var HOST_BROKEN_PREFIX = "host broken: run ";
|
|
9525
9708
|
var HOST_BROKEN = {
|
|
9526
|
-
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
|
+
]
|
|
9527
9713
|
};
|
|
9528
|
-
var HOST_BROKEN_PREFIX = "host broken: run ";
|
|
9529
9714
|
function hostBroken(bin, out2) {
|
|
9530
|
-
const b3 = HOST_BROKEN[bin];
|
|
9531
|
-
if (!b3
|
|
9532
|
-
|
|
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()})`;
|
|
9533
9719
|
}
|
|
9534
9720
|
function listState(row, env) {
|
|
9535
|
-
|
|
9536
|
-
if (!
|
|
9721
|
+
const l = row.listCommand;
|
|
9722
|
+
if (!l || !hostBin(l.bin, env).file) return { status: void 0 };
|
|
9537
9723
|
if (row.id === "opencode") {
|
|
9538
|
-
const
|
|
9539
|
-
|
|
9540
|
-
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 };
|
|
9541
9726
|
}
|
|
9542
|
-
const
|
|
9543
|
-
const r2 = runBin(l2.bin, l2.args, env);
|
|
9727
|
+
const r2 = runBin(l.bin, l.args, env);
|
|
9544
9728
|
const out2 = `${r2.stdout}${r2.stderr}`;
|
|
9545
9729
|
const ok = r2.status === 0 && out2.includes("context-mode");
|
|
9546
|
-
const check = { name: "list", ok, detail: ok ? void 0 : `${
|
|
9547
|
-
return { check, status: r2.status === 0 ? statusOf(row, `${r2.stdout}`) : void 0, broken: r2.status === 0 ? void 0 : hostBroken(
|
|
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) };
|
|
9548
9732
|
}
|
|
9549
9733
|
var DISABLE_ALL_HOOKS = "disableAllHooks";
|
|
9550
9734
|
var SETTINGS_FILES = ["settings.json", "settings.local.json"];
|
|
@@ -9625,7 +9809,7 @@ function degradedDetail(node, env) {
|
|
|
9625
9809
|
return `only ctx_doctor is served: ${D2_SQLITE_DETAIL} under ${node}${v ? ` ${v}` : ""}. Fix: ${D2_SQLITE_FIX}`;
|
|
9626
9810
|
}
|
|
9627
9811
|
function mcpCheck(cmd, env) {
|
|
9628
|
-
return new Promise((
|
|
9812
|
+
return new Promise((resolve6) => {
|
|
9629
9813
|
const child = spawn3(cmd[0], cmd.slice(1), { env, stdio: ["pipe", "pipe", "ignore"], detached: process.platform !== "win32", windowsHide: true });
|
|
9630
9814
|
const reap = () => {
|
|
9631
9815
|
child.kill();
|
|
@@ -9637,7 +9821,7 @@ function mcpCheck(cmd, env) {
|
|
|
9637
9821
|
clearTimeout(timer);
|
|
9638
9822
|
process.off("exit", reap);
|
|
9639
9823
|
child.kill();
|
|
9640
|
-
|
|
9824
|
+
resolve6({ name: "mcp", ok, detail });
|
|
9641
9825
|
};
|
|
9642
9826
|
const timer = setTimeout(() => done(false, "no MCP answer before timeout"), VERIFY_TIMEOUT_MS);
|
|
9643
9827
|
child.on("error", (e) => done(false, e.message));
|
|
@@ -9730,6 +9914,7 @@ function ownConfigEdits(row, c3, text2) {
|
|
|
9730
9914
|
const ownEnv = value[MCP_ENV_FIELD];
|
|
9731
9915
|
if (isObj5(userEnv) || isObj5(ownEnv)) value[MCP_ENV_FIELD] = { ...isObj5(userEnv) ? userEnv : {}, ...isObj5(ownEnv) ? ownEnv : {} };
|
|
9732
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];
|
|
9733
9918
|
return [[c3.key, value], ...edits.slice(1)];
|
|
9734
9919
|
}
|
|
9735
9920
|
function parseCheck(row) {
|
|
@@ -9746,10 +9931,10 @@ function parseCheck(row) {
|
|
|
9746
9931
|
function hookRegisteredCheck(row, env, list2) {
|
|
9747
9932
|
const h2 = row.hookInstall;
|
|
9748
9933
|
if (h2.kind === "package") {
|
|
9749
|
-
const
|
|
9750
|
-
if (!
|
|
9751
|
-
if (!list2) return { name: "hook-registered", ok: false, detail: `${
|
|
9752
|
-
return { name: "hook-registered", ok: list2.ok, detail: list2.ok ? void 0 : `${
|
|
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})` };
|
|
9753
9938
|
}
|
|
9754
9939
|
const edits = [];
|
|
9755
9940
|
try {
|
|
@@ -9757,7 +9942,8 @@ function hookRegisteredCheck(row, env, list2) {
|
|
|
9757
9942
|
} catch (e) {
|
|
9758
9943
|
return { name: "hook-registered", ok: false, detail: e.message };
|
|
9759
9944
|
}
|
|
9760
|
-
|
|
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 };
|
|
9761
9947
|
const trust = h2.kind === "file" ? h2.trust : void 0;
|
|
9762
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` };
|
|
9763
9949
|
const issue = h2.kind === "plugin-list" ? pluginListIssue(h2) : h2.kind === "file" && row.id === "kiro" ? kiroDisabledIssue(h2) : void 0;
|
|
@@ -10051,13 +10237,13 @@ async function verifyRow(row, ctx) {
|
|
|
10051
10237
|
const env = ctx.env;
|
|
10052
10238
|
const checks = [parseCheck(row)];
|
|
10053
10239
|
const ls = listState(row, env);
|
|
10054
|
-
const
|
|
10055
|
-
if (
|
|
10240
|
+
const l = ls.check;
|
|
10241
|
+
if (l) checks.push(l);
|
|
10056
10242
|
const cp = copyCheck(row, ctx.pkgDir);
|
|
10057
10243
|
if (cp) checks.push(cp);
|
|
10058
10244
|
checks.push(await mcpCheck(row.serverCommand, env));
|
|
10059
10245
|
if (row.hookCommand) checks.push(hookCheck(row, env));
|
|
10060
|
-
checks.push(hookRegisteredCheck(row, env,
|
|
10246
|
+
checks.push(hookRegisteredCheck(row, env, l));
|
|
10061
10247
|
const en = hookEnabledCheck(row, ls.status);
|
|
10062
10248
|
if (en) checks.push(en);
|
|
10063
10249
|
if (row.copilotSettings) checks.push(await copilotEnabledCheck(row, ctx));
|
|
@@ -10140,7 +10326,7 @@ function detectAgents(reg, ctx) {
|
|
|
10140
10326
|
return reg.filter((r2) => existsSync17(agentHomeDir(r2.id, ctx)) || r2.listCommand && which(r2.listCommand.bin, ctx.env)).map((r2) => r2.id);
|
|
10141
10327
|
}
|
|
10142
10328
|
async function runSetup(opts) {
|
|
10143
|
-
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 };
|
|
10144
10330
|
const runId = opts.runId ?? (/* @__PURE__ */ new Date()).toISOString().split(":").join("-").split(".").join("-");
|
|
10145
10331
|
const reg = buildRegistry(ctx);
|
|
10146
10332
|
const nodeVersion = opts.nodeVersion ?? process.version;
|
|
@@ -10235,19 +10421,22 @@ async function setupRow(row, ctx, run, dryRun) {
|
|
|
10235
10421
|
if (w) res.checks = res.checks.map((c3) => c3.name === "copy" ? w : c3);
|
|
10236
10422
|
}
|
|
10237
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 };
|
|
10238
10426
|
if (bad.length) throw new Error(bad.map((c3) => `${c3.name}: ${c3.detail}`).join("; "));
|
|
10239
10427
|
} catch (e) {
|
|
10428
|
+
const fix = fixLineOf(row);
|
|
10240
10429
|
run.rollback(row.id, ctx.env);
|
|
10241
10430
|
const broken = row.cli ? hostBroken(row.cli.bin, e.message) : void 0;
|
|
10242
10431
|
if (broken) return { ...res, status: "SKIPPED", reason: broken };
|
|
10243
|
-
return { ...res, status: "FAIL", reason: e.message, rolledBack: true };
|
|
10432
|
+
return { ...res, status: "FAIL", reason: e.message, rolledBack: true, ...fix ? { fix } : {} };
|
|
10244
10433
|
}
|
|
10245
10434
|
return res;
|
|
10246
10435
|
}
|
|
10247
10436
|
var V1_FORM_REASON = "old context-mode entry, run: context-mode setup";
|
|
10248
10437
|
var NOT_SET_UP_REASON = "not set up, run context-mode setup";
|
|
10249
10438
|
async function runDoctor(opts) {
|
|
10250
|
-
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 };
|
|
10251
10440
|
const reg = buildRegistry(ctx);
|
|
10252
10441
|
for (const f2 of ["server.mjs", "hook.mjs"]) {
|
|
10253
10442
|
if (!existsSync17(path12.join(ctx.pkgDir, f2))) return { exitCode: 1, agents: [], error: `preflight: ${path12.join(ctx.pkgDir, f2)} is missing` };
|
|
@@ -10282,6 +10471,8 @@ async function runDoctor(opts) {
|
|
|
10282
10471
|
if (bad.length) {
|
|
10283
10472
|
res.status = "FAIL";
|
|
10284
10473
|
res.reason = bad.map((c3) => `${c3.name}: ${c3.detail}`).join("; ");
|
|
10474
|
+
const fix = fixLineOf(row);
|
|
10475
|
+
if (fix) res.fix = fix;
|
|
10285
10476
|
}
|
|
10286
10477
|
}
|
|
10287
10478
|
}
|
|
@@ -10294,7 +10485,10 @@ function notSetUpReason(row, res, env) {
|
|
|
10294
10485
|
const h2 = row.hookInstall;
|
|
10295
10486
|
const missing = row.id === "opencode" && h2.kind === "plugin-list" && res.changes.some((c3) => c3.path === h2.key[0]);
|
|
10296
10487
|
const oc2 = missing && hostBin("opencode", env).file !== void 0 && opencodeMajor("opencode", env) >= 2;
|
|
10297
|
-
|
|
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;
|
|
10298
10492
|
if (row.id === "gemini" && hostBin("gemini", env).file !== void 0) return `${NOT_SET_UP_REASON}, or run: ${NATIVE_INSTALL.gemini[0]}`;
|
|
10299
10493
|
return NOT_SET_UP_REASON;
|
|
10300
10494
|
}
|
|
@@ -10445,7 +10639,7 @@ function table(agents) {
|
|
|
10445
10639
|
return [`${"AGENT".padEnd(13)} STATUS DETAIL`, ...rows].join("\n");
|
|
10446
10640
|
}
|
|
10447
10641
|
function failLines(agents) {
|
|
10448
|
-
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)}`);
|
|
10449
10643
|
}
|
|
10450
10644
|
function verboseLines(agents) {
|
|
10451
10645
|
return agents.flatMap((a2) => a2.checks.map((c3) => ` ${a2.id} ${c3.warn ? "WARN" : c3.ok ? "ok " : "FAIL"} ${c3.name}${c3.detail ? `: ${c3.detail}` : ""}`));
|
|
@@ -10613,9 +10807,9 @@ async function finish(ui, command, res, writeReport) {
|
|
|
10613
10807
|
if (ui.f.json) out(JSON.stringify({ command, ...res }));
|
|
10614
10808
|
else if (ui.clack) ui.clack.note(table(res.agents), "Summary");
|
|
10615
10809
|
else out(table(res.agents));
|
|
10616
|
-
if (ui.f.verbose && !ui.f.json) for (const
|
|
10810
|
+
if (ui.f.verbose && !ui.f.json) for (const l of verboseLines(res.agents)) err(l);
|
|
10617
10811
|
if (res.error) err(`FAIL ${command}: ${res.error}. Fix: context-mode ${command}${command === "setup" ? " --repair" : ""}`);
|
|
10618
|
-
for (const
|
|
10812
|
+
for (const l of failLines(res.agents)) err(l);
|
|
10619
10813
|
if (res.exitCode !== EXIT_OK) await report(ui, command, res, writeReport);
|
|
10620
10814
|
return res.exitCode;
|
|
10621
10815
|
}
|
|
@@ -10753,7 +10947,7 @@ async function doctor(ui) {
|
|
|
10753
10947
|
const p3 = ui.clack;
|
|
10754
10948
|
if (!p3 || code === EXIT_OK) return code;
|
|
10755
10949
|
let worst = code;
|
|
10756
|
-
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)) {
|
|
10757
10951
|
const ok = await p3.confirm({ message: `Fix ${a2.id} now? (runs ${fixFor(a2.id)})`, initialValue: true });
|
|
10758
10952
|
if (p3.isCancel(ok)) return EXIT_SIGINT;
|
|
10759
10953
|
if (!ok) continue;
|