terminal-pilot 0.0.27 → 0.0.28
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/dist/cli.js +849 -145
- package/dist/cli.js.map +4 -4
- package/dist/commands/close-session.js +14 -0
- package/dist/commands/close-session.js.map +2 -2
- package/dist/commands/create-session.js +14 -0
- package/dist/commands/create-session.js.map +2 -2
- package/dist/commands/fill.js +14 -0
- package/dist/commands/fill.js.map +2 -2
- package/dist/commands/get-session.js +14 -0
- package/dist/commands/get-session.js.map +2 -2
- package/dist/commands/index.js +114 -59
- package/dist/commands/index.js.map +4 -4
- package/dist/commands/install.js +98 -43
- package/dist/commands/install.js.map +4 -4
- package/dist/commands/installer.js +78 -37
- package/dist/commands/installer.js.map +4 -4
- package/dist/commands/list-sessions.js +14 -0
- package/dist/commands/list-sessions.js.map +2 -2
- package/dist/commands/press-key.js +14 -0
- package/dist/commands/press-key.js.map +2 -2
- package/dist/commands/read-history.js +14 -0
- package/dist/commands/read-history.js.map +2 -2
- package/dist/commands/read-screen.js +14 -0
- package/dist/commands/read-screen.js.map +2 -2
- package/dist/commands/resize.js +14 -0
- package/dist/commands/resize.js.map +2 -2
- package/dist/commands/runtime.js.map +1 -1
- package/dist/commands/screenshot.js +14 -0
- package/dist/commands/screenshot.js.map +2 -2
- package/dist/commands/send-signal.js +14 -0
- package/dist/commands/send-signal.js.map +2 -2
- package/dist/commands/type.js +14 -0
- package/dist/commands/type.js.map +2 -2
- package/dist/commands/uninstall.js +92 -37
- package/dist/commands/uninstall.js.map +4 -4
- package/dist/commands/wait-for-exit.js +14 -0
- package/dist/commands/wait-for-exit.js.map +2 -2
- package/dist/commands/wait-for.js +14 -0
- package/dist/commands/wait-for.js.map +2 -2
- package/dist/testing/cli-repl.js +854 -150
- package/dist/testing/cli-repl.js.map +4 -4
- package/dist/testing/qa-cli.js +854 -150
- package/dist/testing/qa-cli.js.map +4 -4
- package/package.json +3 -2
package/dist/testing/qa-cli.js
CHANGED
|
@@ -144,12 +144,12 @@ var styleNames = Object.keys(ansiStyles);
|
|
|
144
144
|
function replaceAll(value, search, replacement) {
|
|
145
145
|
return value.split(search).join(replacement);
|
|
146
146
|
}
|
|
147
|
-
function applyStyles(
|
|
147
|
+
function applyStyles(text4, styles) {
|
|
148
148
|
if (!supportsColor() || styles.length === 0) {
|
|
149
|
-
return
|
|
149
|
+
return text4;
|
|
150
150
|
}
|
|
151
151
|
const open = styles.map((style) => style.open).join("");
|
|
152
|
-
const output =
|
|
152
|
+
const output = text4.includes(reset) ? replaceAll(text4, reset, `${reset}${open}`) : text4;
|
|
153
153
|
return `${open}${output}${reset}`;
|
|
154
154
|
}
|
|
155
155
|
function clampRgb(value) {
|
|
@@ -193,7 +193,7 @@ function bgRgbStyle(red, green, blue) {
|
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
function createColor(styles = []) {
|
|
196
|
-
const builder = ((
|
|
196
|
+
const builder = ((text4) => applyStyles(String(text4), styles));
|
|
197
197
|
for (const name of styleNames) {
|
|
198
198
|
Object.defineProperty(builder, name, {
|
|
199
199
|
configurable: true,
|
|
@@ -275,24 +275,24 @@ function createPalette(activeBrand, mode) {
|
|
|
275
275
|
const number2 = isPurple ? color.hex("#0077cc") : active2;
|
|
276
276
|
return withStyles(
|
|
277
277
|
{
|
|
278
|
-
header: (
|
|
279
|
-
divider: (
|
|
280
|
-
prompt: (
|
|
281
|
-
number: (
|
|
282
|
-
intro: (
|
|
278
|
+
header: (text4) => active2.bold(text4),
|
|
279
|
+
divider: (text4) => color.hex("#666666")(text4),
|
|
280
|
+
prompt: (text4) => prompt2.bold(text4),
|
|
281
|
+
number: (text4) => number2.bold(text4),
|
|
282
|
+
intro: (text4) => color.bgHex(activeBrand.primary).white(` ${getThemeConfig().label} - ${text4} `),
|
|
283
283
|
get resolvedSymbol() {
|
|
284
284
|
return active2("\u25C7");
|
|
285
285
|
},
|
|
286
286
|
get errorSymbol() {
|
|
287
287
|
return color.hex("#cc0000")("\u25A0");
|
|
288
288
|
},
|
|
289
|
-
accent: (
|
|
290
|
-
muted: (
|
|
291
|
-
success: (
|
|
292
|
-
warning: (
|
|
293
|
-
error: (
|
|
294
|
-
info: (
|
|
295
|
-
badge: (
|
|
289
|
+
accent: (text4) => prompt2.bold(text4),
|
|
290
|
+
muted: (text4) => color.hex("#666666")(text4),
|
|
291
|
+
success: (text4) => color.hex("#008800")(text4),
|
|
292
|
+
warning: (text4) => color.hex("#cc6600")(text4),
|
|
293
|
+
error: (text4) => color.hex("#cc0000")(text4),
|
|
294
|
+
info: (text4) => active2(text4),
|
|
295
|
+
badge: (text4) => color.bgHex("#cc6600").white(` ${text4} `)
|
|
296
296
|
},
|
|
297
297
|
{
|
|
298
298
|
accent: { fg: isPurple ? "#006699" : activeBrand.primary, bold: true },
|
|
@@ -311,24 +311,24 @@ function createPalette(activeBrand, mode) {
|
|
|
311
311
|
const number = isPurple ? color.cyanBright : active;
|
|
312
312
|
return withStyles(
|
|
313
313
|
{
|
|
314
|
-
header: (
|
|
315
|
-
divider: (
|
|
316
|
-
prompt: (
|
|
317
|
-
number: (
|
|
318
|
-
intro: (
|
|
314
|
+
header: (text4) => activeBright.bold(text4),
|
|
315
|
+
divider: (text4) => color.dim(text4),
|
|
316
|
+
prompt: (text4) => prompt(text4),
|
|
317
|
+
number: (text4) => number(text4),
|
|
318
|
+
intro: (text4) => activeBackground.white(` ${getThemeConfig().label} - ${text4} `),
|
|
319
319
|
get resolvedSymbol() {
|
|
320
320
|
return active("\u25C7");
|
|
321
321
|
},
|
|
322
322
|
get errorSymbol() {
|
|
323
323
|
return color.red("\u25A0");
|
|
324
324
|
},
|
|
325
|
-
accent: (
|
|
326
|
-
muted: (
|
|
327
|
-
success: (
|
|
328
|
-
warning: (
|
|
329
|
-
error: (
|
|
330
|
-
info: (
|
|
331
|
-
badge: (
|
|
325
|
+
accent: (text4) => prompt(text4),
|
|
326
|
+
muted: (text4) => color.dim(text4),
|
|
327
|
+
success: (text4) => color.green(text4),
|
|
328
|
+
warning: (text4) => color.yellow(text4),
|
|
329
|
+
error: (text4) => color.red(text4),
|
|
330
|
+
info: (text4) => active(text4),
|
|
331
|
+
badge: (text4) => color.bgYellow.black(` ${text4} `)
|
|
332
332
|
},
|
|
333
333
|
{
|
|
334
334
|
accent: { fg: isPurple ? "cyan" : activeBrand.primary, bold: true },
|
|
@@ -345,11 +345,11 @@ var light = createPalette(brands.purple, "light");
|
|
|
345
345
|
|
|
346
346
|
// ../toolcraft-design/src/tokens/typography.ts
|
|
347
347
|
var typography = {
|
|
348
|
-
bold: (
|
|
349
|
-
dim: (
|
|
350
|
-
italic: (
|
|
351
|
-
underline: (
|
|
352
|
-
strikethrough: (
|
|
348
|
+
bold: (text4) => color.bold(text4),
|
|
349
|
+
dim: (text4) => color.dim(text4),
|
|
350
|
+
italic: (text4) => color.italic(text4),
|
|
351
|
+
underline: (text4) => color.underline(text4),
|
|
352
|
+
strikethrough: (text4) => color.strikethrough(text4)
|
|
353
353
|
};
|
|
354
354
|
|
|
355
355
|
// ../toolcraft-design/src/tokens/widths.ts
|
|
@@ -620,7 +620,7 @@ function renderMarkdownInline2(value) {
|
|
|
620
620
|
return stripAnsi2(value).replaceAll("\r\n", " ").replaceAll("\n", " ").replaceAll("\r", " ");
|
|
621
621
|
}
|
|
622
622
|
function writeTerminalMessage(msg, {
|
|
623
|
-
symbol = color.gray("\u2502"),
|
|
623
|
+
symbol: symbol2 = color.gray("\u2502"),
|
|
624
624
|
secondarySymbol = color.gray("\u2502"),
|
|
625
625
|
spacing: spacing2 = 1,
|
|
626
626
|
withGuide = true
|
|
@@ -628,7 +628,7 @@ function writeTerminalMessage(msg, {
|
|
|
628
628
|
const lines = [];
|
|
629
629
|
const showGuide = withGuide !== false;
|
|
630
630
|
const contentLines = msg.split("\n");
|
|
631
|
-
const prefix = showGuide ? `${
|
|
631
|
+
const prefix = showGuide ? `${symbol2} ` : "";
|
|
632
632
|
const continuationPrefix = showGuide ? `${secondarySymbol} ` : "";
|
|
633
633
|
const emptyGuide = showGuide ? secondarySymbol : "";
|
|
634
634
|
for (let index = 0; index < spacing2; index += 1) {
|
|
@@ -642,7 +642,7 @@ function writeTerminalMessage(msg, {
|
|
|
642
642
|
if (firstLine.length > 0) {
|
|
643
643
|
lines.push(`${prefix}${firstLine}`);
|
|
644
644
|
} else {
|
|
645
|
-
lines.push(showGuide ?
|
|
645
|
+
lines.push(showGuide ? symbol2 : "");
|
|
646
646
|
}
|
|
647
647
|
for (const line of continuationLines) {
|
|
648
648
|
if (line.length > 0) {
|
|
@@ -792,12 +792,12 @@ function createLogger(emitter) {
|
|
|
792
792
|
log.message(`${label}
|
|
793
793
|
${value}`, { symbol: symbols.errorResolved });
|
|
794
794
|
},
|
|
795
|
-
message(message2,
|
|
795
|
+
message(message2, symbol2) {
|
|
796
796
|
if (emitter) {
|
|
797
797
|
emitter(message2);
|
|
798
798
|
return;
|
|
799
799
|
}
|
|
800
|
-
log.message(message2, { symbol:
|
|
800
|
+
log.message(message2, { symbol: symbol2 ?? color.gray("\u2502") });
|
|
801
801
|
}
|
|
802
802
|
};
|
|
803
803
|
}
|
|
@@ -1600,18 +1600,18 @@ function getStandalone(template, tagStart, tagEnd, kind) {
|
|
|
1600
1600
|
if (!isWhitespace3(template.slice(lineStart, tagStart))) {
|
|
1601
1601
|
return void 0;
|
|
1602
1602
|
}
|
|
1603
|
-
let
|
|
1604
|
-
while (
|
|
1605
|
-
|
|
1603
|
+
let cursor2 = tagEnd;
|
|
1604
|
+
while (cursor2 < template.length && (template[cursor2] === " " || template[cursor2] === " ")) {
|
|
1605
|
+
cursor2 += 1;
|
|
1606
1606
|
}
|
|
1607
|
-
if (template.startsWith("\r\n",
|
|
1608
|
-
return { lineStart, nextIndex:
|
|
1607
|
+
if (template.startsWith("\r\n", cursor2)) {
|
|
1608
|
+
return { lineStart, nextIndex: cursor2 + 2 };
|
|
1609
1609
|
}
|
|
1610
|
-
if (template[
|
|
1611
|
-
return { lineStart, nextIndex:
|
|
1610
|
+
if (template[cursor2] === "\n") {
|
|
1611
|
+
return { lineStart, nextIndex: cursor2 + 1 };
|
|
1612
1612
|
}
|
|
1613
|
-
if (
|
|
1614
|
-
return { lineStart, nextIndex:
|
|
1613
|
+
if (cursor2 === template.length) {
|
|
1614
|
+
return { lineStart, nextIndex: cursor2 };
|
|
1615
1615
|
}
|
|
1616
1616
|
return void 0;
|
|
1617
1617
|
}
|
|
@@ -1709,13 +1709,13 @@ function lookup(context, name) {
|
|
|
1709
1709
|
if (name === ".") {
|
|
1710
1710
|
return { hit: true, value: callLambda(context.view, context.view) };
|
|
1711
1711
|
}
|
|
1712
|
-
let
|
|
1713
|
-
while (
|
|
1714
|
-
const result = name.includes(".") ? lookupDotted(
|
|
1712
|
+
let cursor2 = context;
|
|
1713
|
+
while (cursor2 !== void 0) {
|
|
1714
|
+
const result = name.includes(".") ? lookupDotted(cursor2.view, name) : lookupName(cursor2.view, name);
|
|
1715
1715
|
if (result.hit) {
|
|
1716
|
-
return { hit: true, value: callLambda(result.value,
|
|
1716
|
+
return { hit: true, value: callLambda(result.value, cursor2.view) };
|
|
1717
1717
|
}
|
|
1718
|
-
|
|
1718
|
+
cursor2 = cursor2.parent;
|
|
1719
1719
|
}
|
|
1720
1720
|
return { hit: false, value: void 0 };
|
|
1721
1721
|
}
|
|
@@ -1879,6 +1879,12 @@ function hasProperty(value, key2) {
|
|
|
1879
1879
|
import { spawn } from "node:child_process";
|
|
1880
1880
|
import process2 from "node:process";
|
|
1881
1881
|
|
|
1882
|
+
// ../frontmatter/src/parse.ts
|
|
1883
|
+
import { LineCounter, parse, parseDocument } from "yaml";
|
|
1884
|
+
|
|
1885
|
+
// ../frontmatter/src/stringify.ts
|
|
1886
|
+
import { stringify } from "yaml";
|
|
1887
|
+
|
|
1882
1888
|
// ../toolcraft-design/src/acp/writer.ts
|
|
1883
1889
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
1884
1890
|
var storage = new AsyncLocalStorage2();
|
|
@@ -1899,11 +1905,629 @@ var REGION_MODAL = 1 << 4;
|
|
|
1899
1905
|
var REGION_TOAST = 1 << 5;
|
|
1900
1906
|
var REGION_ALL = REGION_HEADER | REGION_LIST | REGION_DETAIL | REGION_FOOTER | REGION_MODAL | REGION_TOAST;
|
|
1901
1907
|
|
|
1902
|
-
// ../toolcraft-design/src/prompts/
|
|
1903
|
-
|
|
1908
|
+
// ../toolcraft-design/src/prompts/interactive/glyphs.ts
|
|
1909
|
+
function supportsUnicode() {
|
|
1910
|
+
if (!process.platform.startsWith("win")) {
|
|
1911
|
+
return process.env.TERM !== "linux";
|
|
1912
|
+
}
|
|
1913
|
+
return Boolean(
|
|
1914
|
+
process.env.CI || process.env.WT_SESSION || process.env.TERMINUS_SUBLIME || process.env.ConEmuTask === "{cmd::Cmder}" || process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm"
|
|
1915
|
+
);
|
|
1916
|
+
}
|
|
1917
|
+
var UNICODE = supportsUnicode();
|
|
1918
|
+
function glyph(unicode, ascii) {
|
|
1919
|
+
return UNICODE ? unicode : ascii;
|
|
1920
|
+
}
|
|
1921
|
+
var GLYPHS = {
|
|
1922
|
+
stepActive: glyph("\u25C6", "*"),
|
|
1923
|
+
stepCancel: glyph("\u25A0", "x"),
|
|
1924
|
+
stepError: glyph("\u25B2", "x"),
|
|
1925
|
+
stepSubmit: glyph("\u25C7", "o"),
|
|
1926
|
+
barStart: glyph("\u250C", "T"),
|
|
1927
|
+
bar: glyph("\u2502", "|"),
|
|
1928
|
+
barEnd: glyph("\u2514", "-"),
|
|
1929
|
+
radioActive: glyph("\u25CF", ">"),
|
|
1930
|
+
radioInactive: glyph("\u25CB", " "),
|
|
1931
|
+
checkboxActive: glyph("\u25FB", "[ ]"),
|
|
1932
|
+
checkboxSelected: glyph("\u25FC", "[+]"),
|
|
1933
|
+
checkboxInactive: glyph("\u25FB", "[ ]"),
|
|
1934
|
+
passwordMask: glyph("\u2022", "*"),
|
|
1935
|
+
ellipsis: "..."
|
|
1936
|
+
};
|
|
1937
|
+
function symbol(state) {
|
|
1938
|
+
if (state === "cancel") return color.red(GLYPHS.stepCancel);
|
|
1939
|
+
if (state === "error") return color.yellow(GLYPHS.stepError);
|
|
1940
|
+
if (state === "submit") return color.green(GLYPHS.stepSubmit);
|
|
1941
|
+
return color.cyan(GLYPHS.stepActive);
|
|
1942
|
+
}
|
|
1943
|
+
function symbolBar(state) {
|
|
1944
|
+
if (state === "cancel") return color.red(GLYPHS.bar);
|
|
1945
|
+
if (state === "error") return color.yellow(GLYPHS.bar);
|
|
1946
|
+
if (state === "submit") return color.green(GLYPHS.bar);
|
|
1947
|
+
return color.cyan(GLYPHS.bar);
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
// ../toolcraft-design/src/prompts/interactive/core.ts
|
|
1951
|
+
import { EventEmitter } from "node:events";
|
|
1952
|
+
import * as readline2 from "node:readline";
|
|
1953
|
+
|
|
1954
|
+
// ../toolcraft-design/src/prompts/interactive/cancel-symbol.ts
|
|
1955
|
+
var CANCEL = /* @__PURE__ */ Symbol.for("poe.cancel");
|
|
1956
|
+
function isCancel(value) {
|
|
1957
|
+
return value === CANCEL;
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
// ../toolcraft-design/src/prompts/interactive/keys.ts
|
|
1961
|
+
var aliases = {
|
|
1962
|
+
k: "up",
|
|
1963
|
+
j: "down",
|
|
1964
|
+
h: "left",
|
|
1965
|
+
l: "right"
|
|
1966
|
+
};
|
|
1967
|
+
var keyActions = {
|
|
1968
|
+
up: "up",
|
|
1969
|
+
down: "down",
|
|
1970
|
+
left: "left",
|
|
1971
|
+
right: "right",
|
|
1972
|
+
space: "space",
|
|
1973
|
+
return: "enter",
|
|
1974
|
+
enter: "enter",
|
|
1975
|
+
escape: "cancel"
|
|
1976
|
+
};
|
|
1977
|
+
function mapKey(name, char) {
|
|
1978
|
+
if (char === "") {
|
|
1979
|
+
return "cancel";
|
|
1980
|
+
}
|
|
1981
|
+
if (char === " ") {
|
|
1982
|
+
return "space";
|
|
1983
|
+
}
|
|
1984
|
+
if (!name) {
|
|
1985
|
+
return void 0;
|
|
1986
|
+
}
|
|
1987
|
+
return keyActions[name] ?? aliases[name];
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
// ../toolcraft-design/src/prompts/interactive/wrap.ts
|
|
1991
|
+
import { wrapAnsi } from "fast-wrap-ansi";
|
|
1992
|
+
import stringWidth from "fast-string-width";
|
|
1993
|
+
function getColumns(output) {
|
|
1994
|
+
return Math.max(1, output.columns ?? 80);
|
|
1995
|
+
}
|
|
1996
|
+
function getRows(output) {
|
|
1997
|
+
return Math.max(1, output.rows ?? 20);
|
|
1998
|
+
}
|
|
1999
|
+
function wrapFrame(output, frame) {
|
|
2000
|
+
return wrapAnsi(frame, getColumns(output), { hard: true, trim: false });
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
// ../toolcraft-design/src/prompts/interactive/core.ts
|
|
2004
|
+
var cursor = {
|
|
2005
|
+
hide: "\x1B[?25l",
|
|
2006
|
+
show: "\x1B[?25h",
|
|
2007
|
+
move: (x, y) => {
|
|
2008
|
+
let output = "";
|
|
2009
|
+
if (x < 0) output += `\x1B[${-x}D`;
|
|
2010
|
+
if (x > 0) output += `\x1B[${x}C`;
|
|
2011
|
+
if (y < 0) output += `\x1B[${-y}A`;
|
|
2012
|
+
if (y > 0) output += `\x1B[${y}B`;
|
|
2013
|
+
return output;
|
|
2014
|
+
}
|
|
2015
|
+
};
|
|
2016
|
+
var erase = {
|
|
2017
|
+
down: "\x1B[J"
|
|
2018
|
+
};
|
|
2019
|
+
var Prompt = class extends EventEmitter {
|
|
2020
|
+
state = "initial";
|
|
2021
|
+
value;
|
|
2022
|
+
error = "";
|
|
2023
|
+
userInput = "";
|
|
2024
|
+
_cursor = 0;
|
|
2025
|
+
input;
|
|
2026
|
+
output;
|
|
2027
|
+
renderFrame;
|
|
2028
|
+
validate;
|
|
2029
|
+
signal;
|
|
2030
|
+
trackValue;
|
|
2031
|
+
previousFrame = "";
|
|
2032
|
+
readlineInterface;
|
|
2033
|
+
abortListener;
|
|
2034
|
+
closed = false;
|
|
2035
|
+
constructor(opts, trackValue = true) {
|
|
2036
|
+
super();
|
|
2037
|
+
this.input = opts.input ?? process.stdin;
|
|
2038
|
+
this.output = opts.output ?? process.stdout;
|
|
2039
|
+
this.renderFrame = opts.render;
|
|
2040
|
+
this.validate = opts.validate;
|
|
2041
|
+
this.signal = opts.signal;
|
|
2042
|
+
this.value = opts.initialValue;
|
|
2043
|
+
this.trackValue = trackValue;
|
|
2044
|
+
this.userInput = opts.initialUserInput ?? "";
|
|
2045
|
+
this._cursor = this.userInput.length;
|
|
2046
|
+
}
|
|
2047
|
+
get cursor() {
|
|
2048
|
+
return this._cursor;
|
|
2049
|
+
}
|
|
2050
|
+
prompt() {
|
|
2051
|
+
if (this.signal?.aborted) {
|
|
2052
|
+
this.state = "cancel";
|
|
2053
|
+
return Promise.resolve(CANCEL);
|
|
2054
|
+
}
|
|
2055
|
+
if (this.input.isTTY !== true) {
|
|
2056
|
+
return this.promptNonTty();
|
|
2057
|
+
}
|
|
2058
|
+
return new Promise((resolve) => {
|
|
2059
|
+
const onSubmit = (value) => resolve(value);
|
|
2060
|
+
const onCancel = () => resolve(CANCEL);
|
|
2061
|
+
this.once("submit", onSubmit);
|
|
2062
|
+
this.once("cancel", onCancel);
|
|
2063
|
+
this.abortListener = () => {
|
|
2064
|
+
this.state = "cancel";
|
|
2065
|
+
this.emit("finalize");
|
|
2066
|
+
this.render();
|
|
2067
|
+
this.close();
|
|
2068
|
+
};
|
|
2069
|
+
this.signal?.addEventListener("abort", this.abortListener, { once: true });
|
|
2070
|
+
this.readlineInterface = readline2.createInterface({
|
|
2071
|
+
input: this.input,
|
|
2072
|
+
output: void 0,
|
|
2073
|
+
tabSize: 2,
|
|
2074
|
+
prompt: "",
|
|
2075
|
+
escapeCodeTimeout: 50,
|
|
2076
|
+
terminal: true
|
|
2077
|
+
});
|
|
2078
|
+
readline2.emitKeypressEvents(this.input, this.readlineInterface);
|
|
2079
|
+
this.readlineInterface.prompt();
|
|
2080
|
+
this.input.on("keypress", this.onKeypress);
|
|
2081
|
+
if (this.input.setRawMode) {
|
|
2082
|
+
this.input.setRawMode(true);
|
|
2083
|
+
}
|
|
2084
|
+
this.output.on("resize", this.render);
|
|
2085
|
+
this.render();
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
promptNonTty() {
|
|
2089
|
+
return Promise.reject(new Error("Interactive prompt requires a TTY. Set POE_NO_PROMPT=1 to accept defaults non-interactively."));
|
|
2090
|
+
}
|
|
2091
|
+
readNonTtyLine() {
|
|
2092
|
+
return new Promise((resolve) => {
|
|
2093
|
+
const rl = readline2.createInterface({ input: this.input, terminal: false });
|
|
2094
|
+
let settled = false;
|
|
2095
|
+
const settle = (value) => {
|
|
2096
|
+
if (settled) {
|
|
2097
|
+
return;
|
|
2098
|
+
}
|
|
2099
|
+
settled = true;
|
|
2100
|
+
rl.close();
|
|
2101
|
+
resolve(value);
|
|
2102
|
+
};
|
|
2103
|
+
rl.once("line", settle);
|
|
2104
|
+
rl.once("close", () => settle(rl.line));
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
setValue(value) {
|
|
2108
|
+
this.value = value;
|
|
2109
|
+
this.emit("value", value);
|
|
2110
|
+
}
|
|
2111
|
+
setError(message2) {
|
|
2112
|
+
this.error = message2;
|
|
2113
|
+
}
|
|
2114
|
+
setUserInput(value) {
|
|
2115
|
+
this.userInput = value;
|
|
2116
|
+
this._cursor = Math.min(this._cursor, this.userInput.length);
|
|
2117
|
+
this.emit("userInput", this.userInput);
|
|
2118
|
+
}
|
|
2119
|
+
clearUserInput() {
|
|
2120
|
+
this.userInput = "";
|
|
2121
|
+
this._cursor = 0;
|
|
2122
|
+
this.emit("userInput", this.userInput);
|
|
2123
|
+
}
|
|
2124
|
+
onKeypress = (char, key2 = {}) => {
|
|
2125
|
+
let action = mapKey(key2.name, char);
|
|
2126
|
+
if (this.trackValue && char && char >= " " && key2.name !== "return" && key2.name !== "enter" && key2.name !== "escape") {
|
|
2127
|
+
action = void 0;
|
|
2128
|
+
}
|
|
2129
|
+
if (this.trackValue && action !== "enter") {
|
|
2130
|
+
this.updateTrackedInput(char, key2, action);
|
|
2131
|
+
}
|
|
2132
|
+
if (this.state === "error") {
|
|
2133
|
+
this.state = "active";
|
|
2134
|
+
this.error = "";
|
|
2135
|
+
}
|
|
2136
|
+
if (!this.trackValue && action) {
|
|
2137
|
+
this.emit("cursor", action);
|
|
2138
|
+
} else if (this.trackValue && action && action !== "enter") {
|
|
2139
|
+
this.emit("cursor", action);
|
|
2140
|
+
}
|
|
2141
|
+
if (char && /^[yn]$/i.test(char)) {
|
|
2142
|
+
this.emit("confirm", char.toLowerCase() === "y");
|
|
2143
|
+
}
|
|
2144
|
+
if (char) {
|
|
2145
|
+
this.emit("key", char.toLowerCase(), key2);
|
|
2146
|
+
}
|
|
2147
|
+
if (action === "enter") {
|
|
2148
|
+
const error3 = this.validate?.(this.value);
|
|
2149
|
+
if (error3) {
|
|
2150
|
+
this.error = error3 instanceof Error ? error3.message : error3;
|
|
2151
|
+
this.state = "error";
|
|
2152
|
+
} else {
|
|
2153
|
+
this.state = "submit";
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
if (action === "cancel") {
|
|
2157
|
+
this.state = "cancel";
|
|
2158
|
+
}
|
|
2159
|
+
if (this.state === "submit" || this.state === "cancel") {
|
|
2160
|
+
this.emit("finalize");
|
|
2161
|
+
}
|
|
2162
|
+
this.render();
|
|
2163
|
+
if (this.state === "submit" || this.state === "cancel") {
|
|
2164
|
+
this.close();
|
|
2165
|
+
}
|
|
2166
|
+
};
|
|
2167
|
+
updateTrackedInput(char, key2, action) {
|
|
2168
|
+
if (key2.ctrl) {
|
|
2169
|
+
if (key2.name === "a") {
|
|
2170
|
+
this._cursor = 0;
|
|
2171
|
+
return;
|
|
2172
|
+
}
|
|
2173
|
+
if (key2.name === "e") {
|
|
2174
|
+
this._cursor = this.userInput.length;
|
|
2175
|
+
return;
|
|
2176
|
+
}
|
|
2177
|
+
if (key2.name === "u") {
|
|
2178
|
+
this.userInput = this.userInput.slice(this._cursor);
|
|
2179
|
+
this._cursor = 0;
|
|
2180
|
+
this.emit("userInput", this.userInput);
|
|
2181
|
+
return;
|
|
2182
|
+
}
|
|
2183
|
+
if (key2.name === "k") {
|
|
2184
|
+
this.userInput = this.userInput.slice(0, this._cursor);
|
|
2185
|
+
this.emit("userInput", this.userInput);
|
|
2186
|
+
return;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
if (action === "left") {
|
|
2190
|
+
this._cursor = Math.max(0, this._cursor - 1);
|
|
2191
|
+
return;
|
|
2192
|
+
}
|
|
2193
|
+
if (action === "right") {
|
|
2194
|
+
this._cursor = Math.min(this.userInput.length, this._cursor + 1);
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2197
|
+
if (action === "cancel" || action === "up" || action === "down" || action === "space") {
|
|
2198
|
+
return;
|
|
2199
|
+
}
|
|
2200
|
+
if (key2.name === "backspace" || char === "\b" || char === "\x7F") {
|
|
2201
|
+
if (this._cursor > 0) {
|
|
2202
|
+
this.userInput = `${this.userInput.slice(0, this._cursor - 1)}${this.userInput.slice(this._cursor)}`;
|
|
2203
|
+
this._cursor -= 1;
|
|
2204
|
+
this.emit("userInput", this.userInput);
|
|
2205
|
+
}
|
|
2206
|
+
return;
|
|
2207
|
+
}
|
|
2208
|
+
if (key2.name === "delete") {
|
|
2209
|
+
if (this._cursor < this.userInput.length) {
|
|
2210
|
+
this.userInput = `${this.userInput.slice(0, this._cursor)}${this.userInput.slice(this._cursor + 1)}`;
|
|
2211
|
+
this.emit("userInput", this.userInput);
|
|
2212
|
+
}
|
|
2213
|
+
return;
|
|
2214
|
+
}
|
|
2215
|
+
if (!char || char < " " || key2.ctrl) {
|
|
2216
|
+
return;
|
|
2217
|
+
}
|
|
2218
|
+
this.userInput = `${this.userInput.slice(0, this._cursor)}${char}${this.userInput.slice(this._cursor)}`;
|
|
2219
|
+
this._cursor += char.length;
|
|
2220
|
+
this.emit("userInput", this.userInput);
|
|
2221
|
+
}
|
|
2222
|
+
render = () => {
|
|
2223
|
+
if (this.closed) {
|
|
2224
|
+
return;
|
|
2225
|
+
}
|
|
2226
|
+
const frame = wrapFrame(this.output, this.renderFrame(this) ?? "");
|
|
2227
|
+
if (frame === this.previousFrame) {
|
|
2228
|
+
return;
|
|
2229
|
+
}
|
|
2230
|
+
if (!this.previousFrame) {
|
|
2231
|
+
this.output.write(`${cursor.hide}${frame}`);
|
|
2232
|
+
this.previousFrame = frame;
|
|
2233
|
+
if (this.state === "initial") {
|
|
2234
|
+
this.state = "active";
|
|
2235
|
+
}
|
|
2236
|
+
return;
|
|
2237
|
+
}
|
|
2238
|
+
const previousLineCount = this.previousFrame.split("\n").length - 1;
|
|
2239
|
+
this.output.write(`${cursor.move(-999, -previousLineCount)}${erase.down}${frame}`);
|
|
2240
|
+
this.previousFrame = frame;
|
|
2241
|
+
};
|
|
2242
|
+
close() {
|
|
2243
|
+
if (this.closed) {
|
|
2244
|
+
return;
|
|
2245
|
+
}
|
|
2246
|
+
this.closed = true;
|
|
2247
|
+
this.input.removeListener("keypress", this.onKeypress);
|
|
2248
|
+
this.output.removeListener("resize", this.render);
|
|
2249
|
+
if (this.abortListener) {
|
|
2250
|
+
this.signal?.removeEventListener("abort", this.abortListener);
|
|
2251
|
+
}
|
|
2252
|
+
this.output.write(`${cursor.show}
|
|
2253
|
+
`);
|
|
2254
|
+
if (!process.platform.startsWith("win") && this.input.setRawMode) {
|
|
2255
|
+
this.input.setRawMode(false);
|
|
2256
|
+
}
|
|
2257
|
+
this.readlineInterface?.close();
|
|
2258
|
+
this.input.unpipe?.();
|
|
2259
|
+
if (this.state === "cancel") {
|
|
2260
|
+
this.emit("cancel");
|
|
2261
|
+
} else {
|
|
2262
|
+
this.emit("submit", this.value);
|
|
2263
|
+
}
|
|
2264
|
+
this.removeAllListeners();
|
|
2265
|
+
}
|
|
2266
|
+
};
|
|
2267
|
+
|
|
2268
|
+
// ../toolcraft-design/src/prompts/interactive/confirm.ts
|
|
2269
|
+
var ConfirmPrompt = class extends Prompt {
|
|
2270
|
+
constructor(opts) {
|
|
2271
|
+
super({
|
|
2272
|
+
...opts,
|
|
2273
|
+
initialValue: opts.initialValue ?? true,
|
|
2274
|
+
render: (prompt) => renderConfirmPrompt(prompt, opts)
|
|
2275
|
+
}, false);
|
|
2276
|
+
this.on("confirm", (value) => {
|
|
2277
|
+
this.setValue(value);
|
|
2278
|
+
this.state = "submit";
|
|
2279
|
+
this.emit("finalize");
|
|
2280
|
+
this.render();
|
|
2281
|
+
this.close();
|
|
2282
|
+
});
|
|
2283
|
+
this.on("cursor", (action) => {
|
|
2284
|
+
if (action === "up" || action === "down" || action === "left" || action === "right") {
|
|
2285
|
+
this.setValue(!this.value);
|
|
2286
|
+
}
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
promptNonTty() {
|
|
2290
|
+
if (process.env.POE_NO_PROMPT === "1") {
|
|
2291
|
+
return Promise.resolve(this.value ?? true);
|
|
2292
|
+
}
|
|
2293
|
+
return super.promptNonTty();
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2296
|
+
function choices(value) {
|
|
2297
|
+
const yes = value ? `${color.green(GLYPHS.radioActive)} ${color.bold("Yes")}` : `${color.dim(GLYPHS.radioInactive)} ${color.dim("Yes")}`;
|
|
2298
|
+
const no = value ? `${color.dim(GLYPHS.radioInactive)} ${color.dim("No")}` : `${color.green(GLYPHS.radioActive)} ${color.bold("No")}`;
|
|
2299
|
+
return `${yes} ${color.dim("/")} ${no}`;
|
|
2300
|
+
}
|
|
2301
|
+
function renderConfirmPrompt(prompt, opts) {
|
|
2302
|
+
if (prompt.state === "submit") {
|
|
2303
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${opts.message}
|
|
2304
|
+
${color.gray(GLYPHS.bar)} ${color.dim(prompt.value ? "Yes" : "No")}
|
|
2305
|
+
${color.green(GLYPHS.barEnd)}`;
|
|
2306
|
+
}
|
|
2307
|
+
if (prompt.state === "cancel") {
|
|
2308
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${opts.message}
|
|
2309
|
+
${color.gray(GLYPHS.bar)} ${color.dim.strikethrough(prompt.value ? "Yes" : "No")}
|
|
2310
|
+
${color.red(GLYPHS.barEnd)}`;
|
|
2311
|
+
}
|
|
2312
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${opts.message}
|
|
2313
|
+
${symbolBar(prompt.state)} ${choices(prompt.value)}
|
|
2314
|
+
${color.cyan(GLYPHS.barEnd)}`;
|
|
2315
|
+
}
|
|
2316
|
+
function confirmPrompt(opts) {
|
|
2317
|
+
return new ConfirmPrompt(opts).prompt();
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
// ../toolcraft-design/src/prompts/interactive/pagination.ts
|
|
2321
|
+
import { wrapAnsi as wrapAnsi2 } from "fast-wrap-ansi";
|
|
2322
|
+
function countLines(values) {
|
|
2323
|
+
return values.reduce((sum, value) => sum + value.split("\n").length, 0);
|
|
2324
|
+
}
|
|
2325
|
+
function trimToRows(values, cursorOffset, rows, hasTop, hasBottom) {
|
|
2326
|
+
const output = [...values];
|
|
2327
|
+
while (countLines(output) > rows && output.length > 1) {
|
|
2328
|
+
const removeFromTop = hasTop && cursorOffset > 0;
|
|
2329
|
+
const removeFromBottom = hasBottom && cursorOffset < output.length - 1;
|
|
2330
|
+
if (removeFromTop) {
|
|
2331
|
+
output.shift();
|
|
2332
|
+
cursorOffset -= 1;
|
|
2333
|
+
} else if (removeFromBottom) {
|
|
2334
|
+
output.pop();
|
|
2335
|
+
} else {
|
|
2336
|
+
output.pop();
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
return output;
|
|
2340
|
+
}
|
|
2341
|
+
function limitOptions(opts) {
|
|
2342
|
+
const {
|
|
2343
|
+
cursor: cursor2,
|
|
2344
|
+
options,
|
|
2345
|
+
style,
|
|
2346
|
+
output,
|
|
2347
|
+
maxItems = Number.POSITIVE_INFINITY,
|
|
2348
|
+
columnPadding = 0,
|
|
2349
|
+
rowPadding = 4
|
|
2350
|
+
} = opts;
|
|
2351
|
+
if (options.length === 0) {
|
|
2352
|
+
return [];
|
|
2353
|
+
}
|
|
2354
|
+
const columns = Math.max(1, getColumns(output) - columnPadding);
|
|
2355
|
+
const rowBudget = Math.max(getRows(output) - rowPadding, 0);
|
|
2356
|
+
const visibleCount = Math.max(Math.min(maxItems, rowBudget), 5);
|
|
2357
|
+
const cappedVisibleCount = Math.min(visibleCount, options.length);
|
|
2358
|
+
let start = 0;
|
|
2359
|
+
if (cursor2 >= cappedVisibleCount - 3) {
|
|
2360
|
+
start = Math.max(Math.min(cursor2 - cappedVisibleCount + 3, options.length - cappedVisibleCount), 0);
|
|
2361
|
+
}
|
|
2362
|
+
const hasTopMarker = cappedVisibleCount < options.length && start > 0;
|
|
2363
|
+
const hasBottomMarker = cappedVisibleCount < options.length && start + cappedVisibleCount < options.length;
|
|
2364
|
+
const visible = options.slice(start, start + cappedVisibleCount).map((option, index) => wrapAnsi2(style(option, start + index === cursor2), columns, { hard: true, trim: false }));
|
|
2365
|
+
const trimmed = trimToRows(
|
|
2366
|
+
visible,
|
|
2367
|
+
Math.max(cursor2 - start, 0),
|
|
2368
|
+
Math.max(rowBudget - Number(hasTopMarker) - Number(hasBottomMarker), 1),
|
|
2369
|
+
hasTopMarker,
|
|
2370
|
+
hasBottomMarker
|
|
2371
|
+
);
|
|
2372
|
+
if (hasTopMarker) {
|
|
2373
|
+
trimmed.unshift(color.dim(GLYPHS.ellipsis));
|
|
2374
|
+
}
|
|
2375
|
+
if (hasBottomMarker) {
|
|
2376
|
+
trimmed.push(color.dim(GLYPHS.ellipsis));
|
|
2377
|
+
}
|
|
2378
|
+
return trimmed;
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
// ../toolcraft-design/src/prompts/interactive/select.ts
|
|
2382
|
+
var SelectPrompt = class extends Prompt {
|
|
2383
|
+
options;
|
|
2384
|
+
constructor(opts) {
|
|
2385
|
+
if (opts.options.length === 0) {
|
|
2386
|
+
throw new Error("Select prompt requires at least one option.");
|
|
2387
|
+
}
|
|
2388
|
+
if (opts.options.every((option) => option.disabled)) {
|
|
2389
|
+
throw new Error("Select prompt requires at least one enabled option.");
|
|
2390
|
+
}
|
|
2391
|
+
const initialIndex = Math.max(opts.options.findIndex((option) => option.value === opts.initialValue), 0);
|
|
2392
|
+
const cursor2 = findNonDisabled(initialIndex, 1, opts.options);
|
|
2393
|
+
super({
|
|
2394
|
+
...opts,
|
|
2395
|
+
initialValue: opts.options[cursor2]?.value,
|
|
2396
|
+
render: (prompt) => renderSelectPrompt(prompt, opts)
|
|
2397
|
+
}, false);
|
|
2398
|
+
this.options = opts.options;
|
|
2399
|
+
this._cursor = cursor2;
|
|
2400
|
+
this.setValue(this.options[this._cursor]?.value);
|
|
2401
|
+
this.on("cursor", (action) => {
|
|
2402
|
+
if (action === "up" || action === "left") {
|
|
2403
|
+
this._cursor = findNonDisabled(this._cursor - 1, -1, this.options);
|
|
2404
|
+
} else if (action === "down" || action === "right") {
|
|
2405
|
+
this._cursor = findNonDisabled(this._cursor + 1, 1, this.options);
|
|
2406
|
+
}
|
|
2407
|
+
this.setValue(this.options[this._cursor]?.value);
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
get visibleOptions() {
|
|
2411
|
+
return this.options;
|
|
2412
|
+
}
|
|
2413
|
+
promptNonTty() {
|
|
2414
|
+
if (process.env.POE_NO_PROMPT === "1") {
|
|
2415
|
+
return Promise.resolve(this.value);
|
|
2416
|
+
}
|
|
2417
|
+
return super.promptNonTty();
|
|
2418
|
+
}
|
|
2419
|
+
};
|
|
2420
|
+
function findNonDisabled(start, direction, options) {
|
|
2421
|
+
if (options.every((option) => option.disabled)) {
|
|
2422
|
+
return start;
|
|
2423
|
+
}
|
|
2424
|
+
let index = start;
|
|
2425
|
+
for (let checked = 0; checked < options.length; checked += 1) {
|
|
2426
|
+
index = (index + options.length) % options.length;
|
|
2427
|
+
if (!options[index]?.disabled) {
|
|
2428
|
+
return index;
|
|
2429
|
+
}
|
|
2430
|
+
index += direction;
|
|
2431
|
+
}
|
|
2432
|
+
return start;
|
|
2433
|
+
}
|
|
2434
|
+
function renderOption(option, active, submitted, cancelled) {
|
|
2435
|
+
const hint = option.hint ? color.dim(` (${option.hint})`) : "";
|
|
2436
|
+
if (submitted) return color.dim(option.label);
|
|
2437
|
+
if (cancelled) return color.dim.strikethrough(option.label);
|
|
2438
|
+
if (option.disabled) return `${color.gray(GLYPHS.radioInactive)} ${color.gray.strikethrough(option.label)}${hint}`;
|
|
2439
|
+
if (active) return `${color.green(GLYPHS.radioActive)} ${option.label}${hint}`;
|
|
2440
|
+
return `${color.dim(GLYPHS.radioInactive)} ${color.dim(option.label)}${hint}`;
|
|
2441
|
+
}
|
|
2442
|
+
function renderSelectPrompt(prompt, opts) {
|
|
2443
|
+
if (prompt.state === "submit" || prompt.state === "cancel") {
|
|
2444
|
+
const option = prompt.visibleOptions[prompt.cursor];
|
|
2445
|
+
const rendered = option ? renderOption(option, false, prompt.state === "submit", prompt.state === "cancel") : "";
|
|
2446
|
+
const end = prompt.state === "submit" ? color.green(GLYPHS.barEnd) : color.red(GLYPHS.barEnd);
|
|
2447
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${opts.message}
|
|
2448
|
+
${color.gray(GLYPHS.bar)} ${rendered}
|
|
2449
|
+
${end}`;
|
|
2450
|
+
}
|
|
2451
|
+
const lines = limitOptions({
|
|
2452
|
+
cursor: prompt.cursor,
|
|
2453
|
+
options: prompt.visibleOptions,
|
|
2454
|
+
output: opts.output ?? process.stdout,
|
|
2455
|
+
maxItems: opts.maxItems,
|
|
2456
|
+
columnPadding: 3,
|
|
2457
|
+
style: (option, active) => renderOption(option, active, false, false)
|
|
2458
|
+
}).map((line) => `${color.cyan(GLYPHS.bar)} ${line}`);
|
|
2459
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${opts.message}
|
|
2460
|
+
${lines.join("\n")}
|
|
2461
|
+
${color.cyan(GLYPHS.barEnd)}`;
|
|
2462
|
+
}
|
|
2463
|
+
function selectPrompt(opts) {
|
|
2464
|
+
return new SelectPrompt(opts).prompt();
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
// ../toolcraft-design/src/prompts/interactive/text.ts
|
|
2468
|
+
var TextPrompt = class extends Prompt {
|
|
2469
|
+
constructor(opts) {
|
|
2470
|
+
const initialUserInput = opts.initialValue ?? "";
|
|
2471
|
+
super({
|
|
2472
|
+
...opts,
|
|
2473
|
+
initialValue: initialUserInput,
|
|
2474
|
+
initialUserInput,
|
|
2475
|
+
render: (prompt) => renderTextPrompt(prompt, opts),
|
|
2476
|
+
validate: opts.validate
|
|
2477
|
+
});
|
|
2478
|
+
this.on("userInput", (value) => this.setValue(value));
|
|
2479
|
+
this.on("finalize", () => {
|
|
2480
|
+
if (this.state === "submit") {
|
|
2481
|
+
this.setValue(this.value || opts.defaultValue || "");
|
|
2482
|
+
}
|
|
2483
|
+
});
|
|
2484
|
+
}
|
|
2485
|
+
get userInputWithCursor() {
|
|
2486
|
+
if (this.state === "submit") {
|
|
2487
|
+
return this.userInput;
|
|
2488
|
+
}
|
|
2489
|
+
const before = this.userInput.slice(0, this.cursor);
|
|
2490
|
+
const current = this.userInput[this.cursor];
|
|
2491
|
+
const after = this.userInput.slice(this.cursor + 1);
|
|
2492
|
+
if (current) {
|
|
2493
|
+
return `${before}${color.inverse(current)}${after}`;
|
|
2494
|
+
}
|
|
2495
|
+
return `${before}${color.inverse("\u2588")}`;
|
|
2496
|
+
}
|
|
2497
|
+
promptNonTty() {
|
|
2498
|
+
return this.readNonTtyLine();
|
|
2499
|
+
}
|
|
2500
|
+
};
|
|
2501
|
+
function renderHeader2(prompt, message2) {
|
|
2502
|
+
return `${color.gray(GLYPHS.barStart)} ${symbol(prompt.state)} ${message2}`;
|
|
2503
|
+
}
|
|
2504
|
+
function renderTextPrompt(prompt, opts) {
|
|
2505
|
+
const value = prompt.value ?? "";
|
|
2506
|
+
if (prompt.state === "submit") {
|
|
2507
|
+
return `${renderHeader2(prompt, opts.message)}
|
|
2508
|
+
${color.gray(GLYPHS.bar)} ${color.dim(value)}
|
|
2509
|
+
${color.green(GLYPHS.barEnd)}`;
|
|
2510
|
+
}
|
|
2511
|
+
if (prompt.state === "cancel") {
|
|
2512
|
+
return `${renderHeader2(prompt, opts.message)}
|
|
2513
|
+
${color.gray(GLYPHS.bar)} ${color.dim.strikethrough(value)}
|
|
2514
|
+
${color.red(GLYPHS.barEnd)}`;
|
|
2515
|
+
}
|
|
2516
|
+
const input = prompt.userInput.length > 0 ? prompt.userInputWithCursor : opts.placeholder ? `${color.inverse(opts.placeholder[0] ?? " ")}${color.dim(opts.placeholder.slice(1))}` : color.inverse("_");
|
|
2517
|
+
if (prompt.state === "error") {
|
|
2518
|
+
return `${renderHeader2(prompt, opts.message)}
|
|
2519
|
+
${symbolBar(prompt.state)} ${input}
|
|
2520
|
+
${color.yellow(GLYPHS.barEnd)} ${color.yellow(prompt.error)}`;
|
|
2521
|
+
}
|
|
2522
|
+
return `${renderHeader2(prompt, opts.message)}
|
|
2523
|
+
${symbolBar(prompt.state)} ${input}
|
|
2524
|
+
${color.cyan(GLYPHS.barEnd)}`;
|
|
2525
|
+
}
|
|
2526
|
+
function textPrompt(opts) {
|
|
2527
|
+
return new TextPrompt(opts).prompt();
|
|
2528
|
+
}
|
|
1904
2529
|
|
|
1905
2530
|
// ../toolcraft-design/src/prompts/primitives/cancel.ts
|
|
1906
|
-
import { isCancel } from "@clack/prompts";
|
|
1907
2531
|
function cancel(msg = "") {
|
|
1908
2532
|
if (resolveOutputFormat() !== "terminal") {
|
|
1909
2533
|
return;
|
|
@@ -1966,14 +2590,14 @@ function note(message2, title) {
|
|
|
1966
2590
|
var SPINNER_FRAMES = Object.freeze(["\u25D2", "\u25D0", "\u25D3", "\u25D1"]);
|
|
1967
2591
|
|
|
1968
2592
|
// ../toolcraft-design/src/prompts/index.ts
|
|
1969
|
-
async function
|
|
1970
|
-
return
|
|
2593
|
+
async function select(opts) {
|
|
2594
|
+
return selectPrompt(opts);
|
|
1971
2595
|
}
|
|
1972
|
-
async function
|
|
1973
|
-
return
|
|
2596
|
+
async function text2(opts) {
|
|
2597
|
+
return textPrompt(opts);
|
|
1974
2598
|
}
|
|
1975
|
-
async function
|
|
1976
|
-
return
|
|
2599
|
+
async function confirm(opts) {
|
|
2600
|
+
return confirmPrompt(opts);
|
|
1977
2601
|
}
|
|
1978
2602
|
|
|
1979
2603
|
// ../toolcraft/src/index.ts
|
|
@@ -2348,6 +2972,12 @@ function cloneRequires(requires) {
|
|
|
2348
2972
|
function cloneStringArray(values) {
|
|
2349
2973
|
return values === void 0 ? void 0 : [...values];
|
|
2350
2974
|
}
|
|
2975
|
+
function cloneCommandExamples(examples) {
|
|
2976
|
+
return (examples ?? []).map((example) => ({
|
|
2977
|
+
title: example.title,
|
|
2978
|
+
params: { ...example.params }
|
|
2979
|
+
}));
|
|
2980
|
+
}
|
|
2351
2981
|
function cloneStringRecord(values) {
|
|
2352
2982
|
return values === void 0 ? void 0 : { ...values };
|
|
2353
2983
|
}
|
|
@@ -2612,9 +3242,11 @@ function createBaseCommand(config2) {
|
|
|
2612
3242
|
kind: "command",
|
|
2613
3243
|
name: config2.name,
|
|
2614
3244
|
description: config2.description,
|
|
3245
|
+
examples: cloneCommandExamples(config2.examples),
|
|
2615
3246
|
aliases: [...config2.aliases ?? []],
|
|
2616
3247
|
positional: [...config2.positional ?? []],
|
|
2617
3248
|
params: config2.params,
|
|
3249
|
+
result: config2.result,
|
|
2618
3250
|
secrets: cloneSecrets(config2.secrets),
|
|
2619
3251
|
scope: resolveCommandScope(config2.scope, void 0),
|
|
2620
3252
|
confirm: config2.confirm ?? false,
|
|
@@ -2626,6 +3258,8 @@ function createBaseCommand(config2) {
|
|
|
2626
3258
|
Object.defineProperty(command, commandConfigSymbol, {
|
|
2627
3259
|
value: {
|
|
2628
3260
|
scope: cloneScope(config2.scope),
|
|
3261
|
+
examples: cloneCommandExamples(config2.examples),
|
|
3262
|
+
result: config2.result,
|
|
2629
3263
|
humanInLoop: config2.humanInLoop,
|
|
2630
3264
|
secrets: cloneSecrets(config2.secrets),
|
|
2631
3265
|
requires: cloneRequires(config2.requires),
|
|
@@ -2674,9 +3308,11 @@ function materializeCommand(command, inherited) {
|
|
|
2674
3308
|
kind: "command",
|
|
2675
3309
|
name: command.name,
|
|
2676
3310
|
description: command.description,
|
|
3311
|
+
examples: cloneCommandExamples(internal.examples),
|
|
2677
3312
|
aliases: [...command.aliases],
|
|
2678
3313
|
positional: [...command.positional],
|
|
2679
3314
|
params: command.params,
|
|
3315
|
+
result: internal.result,
|
|
2680
3316
|
secrets: mergeSecrets(inherited.secrets, internal.secrets),
|
|
2681
3317
|
scope: resolveCommandScope(internal.scope, inherited.scope),
|
|
2682
3318
|
confirm: command.confirm,
|
|
@@ -2688,6 +3324,8 @@ function materializeCommand(command, inherited) {
|
|
|
2688
3324
|
Object.defineProperty(materialized, commandConfigSymbol, {
|
|
2689
3325
|
value: {
|
|
2690
3326
|
scope: cloneScope(internal.scope),
|
|
3327
|
+
examples: cloneCommandExamples(internal.examples),
|
|
3328
|
+
result: internal.result,
|
|
2691
3329
|
humanInLoop: internal.humanInLoop,
|
|
2692
3330
|
secrets: cloneSecrets(internal.secrets),
|
|
2693
3331
|
requires: cloneRequires(internal.requires),
|
|
@@ -2929,7 +3567,7 @@ var AnchorNotFoundError = class extends Error {
|
|
|
2929
3567
|
};
|
|
2930
3568
|
|
|
2931
3569
|
// ../task-list/src/backends/gh-issues-client.ts
|
|
2932
|
-
import { text as
|
|
3570
|
+
import { text as text3 } from "node:stream/consumers";
|
|
2933
3571
|
|
|
2934
3572
|
// ../process-runner/src/docker/context.ts
|
|
2935
3573
|
import { execSync } from "node:child_process";
|
|
@@ -3138,8 +3776,8 @@ async function resolveAuth(options) {
|
|
|
3138
3776
|
stderr: "pipe"
|
|
3139
3777
|
});
|
|
3140
3778
|
const [stdout, , result] = await Promise.all([
|
|
3141
|
-
handle.stdout === null ? Promise.resolve("") :
|
|
3142
|
-
handle.stderr === null ? Promise.resolve("") :
|
|
3779
|
+
handle.stdout === null ? Promise.resolve("") : text3(handle.stdout),
|
|
3780
|
+
handle.stderr === null ? Promise.resolve("") : text3(handle.stderr),
|
|
3143
3781
|
handle.result
|
|
3144
3782
|
]);
|
|
3145
3783
|
const token = stdout.trim();
|
|
@@ -4338,7 +4976,7 @@ function parseQualifiedId(qualifiedId, listName) {
|
|
|
4338
4976
|
|
|
4339
4977
|
// ../task-list/src/backends/markdown-dir.ts
|
|
4340
4978
|
import path7 from "node:path";
|
|
4341
|
-
import { parseDocument, stringify } from "yaml";
|
|
4979
|
+
import { parseDocument as parseDocument2, stringify as stringify2 } from "yaml";
|
|
4342
4980
|
|
|
4343
4981
|
// ../task-list/src/schema/task.schema.json
|
|
4344
4982
|
var task_schema_default = {
|
|
@@ -4529,7 +5167,7 @@ function splitTaskDocument(content, filePath, mode) {
|
|
|
4529
5167
|
};
|
|
4530
5168
|
}
|
|
4531
5169
|
function readFrontmatter(frontmatterContent, filePath) {
|
|
4532
|
-
const document =
|
|
5170
|
+
const document = parseDocument2(frontmatterContent);
|
|
4533
5171
|
if (document.errors.length > 0) {
|
|
4534
5172
|
throw malformedTask(filePath, "frontmatter");
|
|
4535
5173
|
}
|
|
@@ -4599,7 +5237,7 @@ function createTask(list, id, frontmatter, body, mode, sourcePath) {
|
|
|
4599
5237
|
}
|
|
4600
5238
|
function serializeTaskDocument(frontmatter, description) {
|
|
4601
5239
|
return `---
|
|
4602
|
-
${
|
|
5240
|
+
${stringify2(frontmatter)}---
|
|
4603
5241
|
|
|
4604
5242
|
${description}`;
|
|
4605
5243
|
}
|
|
@@ -5337,7 +5975,7 @@ async function markdownDirBackend(deps) {
|
|
|
5337
5975
|
|
|
5338
5976
|
// ../task-list/src/backends/yaml-file.ts
|
|
5339
5977
|
import path8 from "node:path";
|
|
5340
|
-
import { isMap, parseDocument as
|
|
5978
|
+
import { isMap, parseDocument as parseDocument3 } from "yaml";
|
|
5341
5979
|
|
|
5342
5980
|
// ../task-list/src/schema/store.schema.json
|
|
5343
5981
|
var store_schema_default = {
|
|
@@ -5514,7 +6152,7 @@ function buildFiredTaskRecord(existing, to, metadataPatch) {
|
|
|
5514
6152
|
function parseStoreDocument(filePath, content) {
|
|
5515
6153
|
let document;
|
|
5516
6154
|
try {
|
|
5517
|
-
document =
|
|
6155
|
+
document = parseDocument3(content, { keepSourceTokens: true, prettyErrors: false });
|
|
5518
6156
|
} catch {
|
|
5519
6157
|
throw malformedStore(filePath, "yaml");
|
|
5520
6158
|
}
|
|
@@ -5691,7 +6329,7 @@ async function ensureStorePath(deps) {
|
|
|
5691
6329
|
deps.fs,
|
|
5692
6330
|
deps.path,
|
|
5693
6331
|
serializeDocument(
|
|
5694
|
-
|
|
6332
|
+
parseDocument3(
|
|
5695
6333
|
[
|
|
5696
6334
|
`$schema: ${STORE_SCHEMA_ID}`,
|
|
5697
6335
|
`kind: ${STORE_KIND}`,
|
|
@@ -7695,8 +8333,8 @@ function validateAuthorizationCallbackBinding(callback, expected) {
|
|
|
7695
8333
|
function createAuthorizationError(error3, description) {
|
|
7696
8334
|
return new Error(`OAuth authorization failed: ${error3} \u2014 ${description}`);
|
|
7697
8335
|
}
|
|
7698
|
-
function escapeHtml2(
|
|
7699
|
-
return
|
|
8336
|
+
function escapeHtml2(text4) {
|
|
8337
|
+
return text4.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
7700
8338
|
}
|
|
7701
8339
|
function buildSuccessPage(landingPage) {
|
|
7702
8340
|
const title = landingPage?.title ?? "Connected";
|
|
@@ -10243,6 +10881,9 @@ function isCallToolResult(value) {
|
|
|
10243
10881
|
if (!isObjectRecord5(value) || !Array.isArray(value.content)) {
|
|
10244
10882
|
return false;
|
|
10245
10883
|
}
|
|
10884
|
+
if (value.structuredContent !== void 0 && !isObjectRecord5(value.structuredContent)) {
|
|
10885
|
+
return false;
|
|
10886
|
+
}
|
|
10246
10887
|
if (value.isError !== void 0 && typeof value.isError !== "boolean") {
|
|
10247
10888
|
return false;
|
|
10248
10889
|
}
|
|
@@ -10982,13 +11623,13 @@ var proxyNodeSymbol = /* @__PURE__ */ Symbol("toolcraft.mcpProxyNode");
|
|
|
10982
11623
|
var proxyConnectionSymbol = /* @__PURE__ */ Symbol("toolcraft.mcpProxyConnection");
|
|
10983
11624
|
var shutdownDisposers = /* @__PURE__ */ new Set();
|
|
10984
11625
|
function getInternalGroupConfig2(group) {
|
|
10985
|
-
const
|
|
11626
|
+
const symbol2 = Object.getOwnPropertySymbols(group).find(
|
|
10986
11627
|
(candidate) => candidate.description === GROUP_CONFIG_SYMBOL_DESCRIPTION
|
|
10987
11628
|
);
|
|
10988
|
-
if (
|
|
11629
|
+
if (symbol2 === void 0) {
|
|
10989
11630
|
return {};
|
|
10990
11631
|
}
|
|
10991
|
-
return group[
|
|
11632
|
+
return group[symbol2] ?? {};
|
|
10992
11633
|
}
|
|
10993
11634
|
function isProxyNode(node) {
|
|
10994
11635
|
return node[proxyNodeSymbol] === true;
|
|
@@ -11035,23 +11676,38 @@ function createProxyCommand(parent, tool, commandName, connection) {
|
|
|
11035
11676
|
if (params17.kind !== "object") {
|
|
11036
11677
|
throw new Error(`upstream tool "${tool.name}" must define an object input schema`);
|
|
11037
11678
|
}
|
|
11679
|
+
const result = tool.outputSchema === void 0 ? void 0 : convertJsonSchema(tool.outputSchema);
|
|
11680
|
+
if (result !== void 0 && result.kind !== "object") {
|
|
11681
|
+
throw new Error(`upstream tool "${tool.name}" must define an object output schema`);
|
|
11682
|
+
}
|
|
11038
11683
|
return markProxyNode({
|
|
11039
11684
|
kind: "command",
|
|
11040
11685
|
name: commandName,
|
|
11041
11686
|
description: tool.description,
|
|
11687
|
+
examples: [],
|
|
11042
11688
|
aliases: [],
|
|
11043
11689
|
positional: [],
|
|
11044
11690
|
params: params17,
|
|
11691
|
+
...result === void 0 ? {} : { result },
|
|
11045
11692
|
secrets: cloneSecrets2(parent.secrets),
|
|
11046
11693
|
scope: cloneScope2(parent.scope) ?? ["cli", "sdk"],
|
|
11047
11694
|
confirm: false,
|
|
11048
11695
|
requires: parent.requires,
|
|
11049
11696
|
handler: async (ctx) => {
|
|
11050
11697
|
const client = await ensureConnected(connection);
|
|
11051
|
-
|
|
11698
|
+
const toolResult = await client.callTool({
|
|
11052
11699
|
name: tool.name,
|
|
11053
11700
|
arguments: ctx.params
|
|
11054
11701
|
});
|
|
11702
|
+
if (result === void 0) {
|
|
11703
|
+
return toolResult;
|
|
11704
|
+
}
|
|
11705
|
+
if (toolResult.structuredContent === void 0) {
|
|
11706
|
+
throw new Error(
|
|
11707
|
+
`upstream tool "${tool.name}" declared outputSchema but returned no structuredContent`
|
|
11708
|
+
);
|
|
11709
|
+
}
|
|
11710
|
+
return toolResult.structuredContent;
|
|
11055
11711
|
},
|
|
11056
11712
|
render: void 0
|
|
11057
11713
|
});
|
|
@@ -11182,12 +11838,12 @@ async function fetchCache(name, config2) {
|
|
|
11182
11838
|
try {
|
|
11183
11839
|
logger2.info(`MCP ${name}: listing tools`);
|
|
11184
11840
|
const tools = [];
|
|
11185
|
-
let
|
|
11841
|
+
let cursor2;
|
|
11186
11842
|
do {
|
|
11187
|
-
const page = await client.listTools(
|
|
11843
|
+
const page = await client.listTools(cursor2 === void 0 ? {} : { cursor: cursor2 });
|
|
11188
11844
|
tools.push(...page.tools);
|
|
11189
|
-
|
|
11190
|
-
} while (
|
|
11845
|
+
cursor2 = page.nextCursor;
|
|
11846
|
+
} while (cursor2 !== void 0);
|
|
11191
11847
|
logger2.info(`MCP ${name}: found ${tools.length} tools`);
|
|
11192
11848
|
const upstream = client.serverInfo ?? {
|
|
11193
11849
|
name,
|
|
@@ -11961,8 +12617,8 @@ function extractMcpPayload(envelope) {
|
|
|
11961
12617
|
return structuredContent;
|
|
11962
12618
|
}
|
|
11963
12619
|
if (Array.isArray(envelope.content)) {
|
|
11964
|
-
const
|
|
11965
|
-
return
|
|
12620
|
+
const text4 = envelope.content.filter(isMcpTextContent).map((block) => block.text).join("\n");
|
|
12621
|
+
return text4.length > 0 ? text4 : void 0;
|
|
11966
12622
|
}
|
|
11967
12623
|
return void 0;
|
|
11968
12624
|
}
|
|
@@ -12520,6 +13176,7 @@ function collectFields(schema, casing, globalLongOptionFlags, path25 = [], inher
|
|
|
12520
13176
|
globalLongOptionFlags
|
|
12521
13177
|
),
|
|
12522
13178
|
optionFlag: toOptionFlag([...nextPath, childSchema.discriminator], casing),
|
|
13179
|
+
longAliases: [],
|
|
12523
13180
|
shortFlag: void 0,
|
|
12524
13181
|
schema: createSyntheticEnumSchema(branchIds),
|
|
12525
13182
|
description: childSchema.description,
|
|
@@ -12573,6 +13230,7 @@ function collectFields(schema, casing, globalLongOptionFlags, path25 = [], inher
|
|
|
12573
13230
|
globalLongOptionFlags
|
|
12574
13231
|
),
|
|
12575
13232
|
optionFlag: toOptionFlag(controlPath, casing),
|
|
13233
|
+
longAliases: [],
|
|
12576
13234
|
shortFlag: void 0,
|
|
12577
13235
|
schema: createSyntheticEnumSchema(branchIds),
|
|
12578
13236
|
description: childSchema.description,
|
|
@@ -12655,6 +13313,9 @@ function collectFields(schema, casing, globalLongOptionFlags, path25 = [], inher
|
|
|
12655
13313
|
optionAttribute: toOptionAttribute(nextPath, casing),
|
|
12656
13314
|
commanderOptionAttribute: toCommanderOptionAttribute(nextPath, casing, globalLongOptionFlags),
|
|
12657
13315
|
optionFlag: toOptionFlag(nextPath, casing),
|
|
13316
|
+
longAliases: [...childSchema.cliAliases ?? []].map(
|
|
13317
|
+
(alias) => alias.startsWith("--") ? alias : `--${alias}`
|
|
13318
|
+
),
|
|
12658
13319
|
shortFlag: childSchema.short,
|
|
12659
13320
|
schema: childSchema,
|
|
12660
13321
|
description: childSchema.description,
|
|
@@ -12713,9 +13374,9 @@ function formatOptionFlags(field, globalLongOptionFlags) {
|
|
|
12713
13374
|
return `-${field.shortFlag}`;
|
|
12714
13375
|
}
|
|
12715
13376
|
if (field.shortFlag === void 0) {
|
|
12716
|
-
return field.optionFlag;
|
|
13377
|
+
return [field.optionFlag, ...field.longAliases].join(", ");
|
|
12717
13378
|
}
|
|
12718
|
-
return `-${field.shortFlag},
|
|
13379
|
+
return [`-${field.shortFlag}`, field.optionFlag, ...field.longAliases].join(", ");
|
|
12719
13380
|
}
|
|
12720
13381
|
function formatPositionalToken(field) {
|
|
12721
13382
|
const optionalPositional = field.optional || field.hasDefault;
|
|
@@ -12995,24 +13656,34 @@ function getGlobalLongOptionFlags(presetsEnabled, versionEnabled, controls) {
|
|
|
12995
13656
|
}
|
|
12996
13657
|
return new Set(flags);
|
|
12997
13658
|
}
|
|
12998
|
-
function validateUniqueOptionFlags(fields) {
|
|
13659
|
+
function validateUniqueOptionFlags(fields, globalLongOptionFlags) {
|
|
12999
13660
|
const fieldsByFlag = /* @__PURE__ */ new Map();
|
|
13000
13661
|
for (const field of fields) {
|
|
13001
13662
|
if (field.positionalIndex !== void 0) {
|
|
13002
13663
|
continue;
|
|
13003
13664
|
}
|
|
13004
|
-
const
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13665
|
+
for (const flag of [field.optionFlag, ...field.longAliases]) {
|
|
13666
|
+
if (globalLongOptionFlags.has(flag)) {
|
|
13667
|
+
if (flag === field.optionFlag && field.shortFlag !== void 0) {
|
|
13668
|
+
continue;
|
|
13669
|
+
}
|
|
13670
|
+
throw new UserError(
|
|
13671
|
+
`Parameter "${field.displayPath}" uses reserved CLI flag "${flag}". Add a short flag or rename the parameter.`
|
|
13672
|
+
);
|
|
13673
|
+
}
|
|
13674
|
+
const existing = fieldsByFlag.get(flag);
|
|
13675
|
+
if (existing !== void 0) {
|
|
13676
|
+
throw new UserError(
|
|
13677
|
+
`Parameters "${existing.displayPath}" and "${field.displayPath}" use conflicting CLI flag "${flag}".`
|
|
13678
|
+
);
|
|
13679
|
+
}
|
|
13680
|
+
fieldsByFlag.set(flag, field);
|
|
13009
13681
|
}
|
|
13010
|
-
fieldsByFlag.set(field.optionFlag, field);
|
|
13011
13682
|
}
|
|
13012
13683
|
}
|
|
13013
13684
|
function createCommanderOption(flags, description, field) {
|
|
13014
13685
|
const option = new Option(flags, description);
|
|
13015
|
-
if (field.commanderOptionAttribute !== field.optionAttribute) {
|
|
13686
|
+
if (field.commanderOptionAttribute !== field.optionAttribute || field.longAliases.length > 0) {
|
|
13016
13687
|
option.attributeName = () => field.commanderOptionAttribute;
|
|
13017
13688
|
}
|
|
13018
13689
|
return option;
|
|
@@ -13333,6 +14004,26 @@ function formatSecretDescription(secret) {
|
|
|
13333
14004
|
}
|
|
13334
14005
|
return secret.optional === true ? "Optional secret" : "Required secret";
|
|
13335
14006
|
}
|
|
14007
|
+
function formatExampleValue(value) {
|
|
14008
|
+
if (typeof value === "string" && value.length > 0 && !value.includes(" ")) {
|
|
14009
|
+
return value;
|
|
14010
|
+
}
|
|
14011
|
+
return JSON.stringify(value);
|
|
14012
|
+
}
|
|
14013
|
+
function formatExampleCommand(breadcrumb, rootUsageName, params17) {
|
|
14014
|
+
const commandPath = buildUsageLine(breadcrumb, rootUsageName, "");
|
|
14015
|
+
const flags = Object.entries(params17).map(([key2, value]) => {
|
|
14016
|
+
const flag = `--${key2}`;
|
|
14017
|
+
return typeof value === "boolean" ? value ? flag : `--no-${key2}` : `${flag} ${formatExampleValue(value)}`;
|
|
14018
|
+
});
|
|
14019
|
+
return [commandPath, ...flags].filter((token) => token.length > 0).join(" ");
|
|
14020
|
+
}
|
|
14021
|
+
function formatExampleRows(examples, breadcrumb, rootUsageName) {
|
|
14022
|
+
return examples.map(
|
|
14023
|
+
(example) => `${example.title}
|
|
14024
|
+
${formatExampleCommand(breadcrumb, rootUsageName, example.params)}`
|
|
14025
|
+
);
|
|
14026
|
+
}
|
|
13336
14027
|
function wrapOptionalCommandParameterToken(token, optional) {
|
|
13337
14028
|
return optional ? `[${token}]` : token;
|
|
13338
14029
|
}
|
|
@@ -13491,6 +14182,12 @@ ${formatHelpOptionList(optionRows)}`);
|
|
|
13491
14182
|
${formatHelpOptionList(secretRows)}`
|
|
13492
14183
|
);
|
|
13493
14184
|
}
|
|
14185
|
+
if (command.examples.length > 0) {
|
|
14186
|
+
sections.push(
|
|
14187
|
+
`${text.sectionHeader("Examples")}
|
|
14188
|
+
${formatExampleRows(command.examples, breadcrumb, rootUsageName).join("\n")}`
|
|
14189
|
+
);
|
|
14190
|
+
}
|
|
13494
14191
|
const positionalFields = fields.filter((f) => f.positionalIndex !== void 0);
|
|
13495
14192
|
const usageSuffix = positionalFields.length > 0 ? `[OPTIONS] ${positionalFields.map(formatPositionalToken).join(" ")}` : "[OPTIONS]";
|
|
13496
14193
|
return renderHelpDocument({
|
|
@@ -13566,7 +14263,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
13566
14263
|
const command = new CommanderCommand(node.name);
|
|
13567
14264
|
const collected = collectFields(node.params, casing, globalLongOptionFlags);
|
|
13568
14265
|
const fields = assignPositionals(collected.fields, node.positional);
|
|
13569
|
-
validateUniqueOptionFlags(fields);
|
|
14266
|
+
validateUniqueOptionFlags(fields, globalLongOptionFlags);
|
|
13570
14267
|
if (node.description !== void 0) {
|
|
13571
14268
|
command.description(node.description);
|
|
13572
14269
|
}
|
|
@@ -13697,26 +14394,26 @@ function parseDebugStackMode(value) {
|
|
|
13697
14394
|
);
|
|
13698
14395
|
}
|
|
13699
14396
|
function setNestedValue(target, path25, value) {
|
|
13700
|
-
let
|
|
14397
|
+
let cursor2 = target;
|
|
13701
14398
|
for (let index = 0; index < path25.length - 1; index += 1) {
|
|
13702
14399
|
const segment = path25[index] ?? "";
|
|
13703
|
-
const existing = Object.prototype.hasOwnProperty.call(
|
|
14400
|
+
const existing = Object.prototype.hasOwnProperty.call(cursor2, segment) ? cursor2[segment] : void 0;
|
|
13704
14401
|
if (typeof existing === "object" && existing !== null) {
|
|
13705
|
-
|
|
14402
|
+
cursor2 = existing;
|
|
13706
14403
|
continue;
|
|
13707
14404
|
}
|
|
13708
14405
|
const next = {};
|
|
13709
|
-
Object.defineProperty(
|
|
14406
|
+
Object.defineProperty(cursor2, segment, {
|
|
13710
14407
|
value: next,
|
|
13711
14408
|
enumerable: true,
|
|
13712
14409
|
configurable: true,
|
|
13713
14410
|
writable: true
|
|
13714
14411
|
});
|
|
13715
|
-
|
|
14412
|
+
cursor2 = next;
|
|
13716
14413
|
}
|
|
13717
14414
|
const leaf = path25[path25.length - 1];
|
|
13718
14415
|
if (leaf !== void 0) {
|
|
13719
|
-
Object.defineProperty(
|
|
14416
|
+
Object.defineProperty(cursor2, leaf, {
|
|
13720
14417
|
value,
|
|
13721
14418
|
enumerable: true,
|
|
13722
14419
|
configurable: true,
|
|
@@ -13750,7 +14447,7 @@ async function promptForField(field) {
|
|
|
13750
14447
|
label: enumOptionLabel(schema, value),
|
|
13751
14448
|
value
|
|
13752
14449
|
}));
|
|
13753
|
-
const selected = await
|
|
14450
|
+
const selected = await select({
|
|
13754
14451
|
message: field.description ?? fieldPromptLabel(field),
|
|
13755
14452
|
options,
|
|
13756
14453
|
initialValue: field.hasDefault ? field.defaultValue : void 0
|
|
@@ -13762,7 +14459,7 @@ async function promptForField(field) {
|
|
|
13762
14459
|
return selected;
|
|
13763
14460
|
}
|
|
13764
14461
|
if (field.schema.kind === "boolean") {
|
|
13765
|
-
const selected = await
|
|
14462
|
+
const selected = await confirm({
|
|
13766
14463
|
message: fieldPromptLabel(field),
|
|
13767
14464
|
initialValue: field.hasDefault ? Boolean(field.defaultValue) : void 0
|
|
13768
14465
|
});
|
|
@@ -13772,7 +14469,7 @@ async function promptForField(field) {
|
|
|
13772
14469
|
}
|
|
13773
14470
|
return selected;
|
|
13774
14471
|
}
|
|
13775
|
-
const entered = await
|
|
14472
|
+
const entered = await text2({
|
|
13776
14473
|
message: fieldPromptLabel(field),
|
|
13777
14474
|
initialValue: field.hasDefault && field.defaultValue !== void 0 ? formatResolvedValue(field.defaultValue) : void 0
|
|
13778
14475
|
});
|
|
@@ -14247,12 +14944,12 @@ function createFixtureEnvValues(command) {
|
|
|
14247
14944
|
}
|
|
14248
14945
|
return values;
|
|
14249
14946
|
}
|
|
14250
|
-
async function resolveFixtureRuntime(command, services, requirementOptions) {
|
|
14947
|
+
async function resolveFixtureRuntime(command, services, requirementOptions, runtimeFetch) {
|
|
14251
14948
|
const selector = process.env.TOOLCRAFT_FIXTURE;
|
|
14252
14949
|
if (selector === void 0 || selector.length === 0) {
|
|
14253
14950
|
return {
|
|
14254
14951
|
env: createEnv2(),
|
|
14255
|
-
fetch:
|
|
14952
|
+
fetch: runtimeFetch,
|
|
14256
14953
|
fs: createFs2(),
|
|
14257
14954
|
isFixture: false,
|
|
14258
14955
|
requirementOptions,
|
|
@@ -14391,22 +15088,22 @@ function consumeFieldValue(args, index, schema, label, inlineValue) {
|
|
|
14391
15088
|
if (schema.kind === "array") {
|
|
14392
15089
|
const values = [];
|
|
14393
15090
|
let nextIndex = index;
|
|
14394
|
-
let
|
|
14395
|
-
while (
|
|
14396
|
-
const token = args[
|
|
15091
|
+
let cursor2 = index + 1;
|
|
15092
|
+
while (cursor2 < args.length) {
|
|
15093
|
+
const token = args[cursor2] ?? "";
|
|
14397
15094
|
if (token.startsWith("-")) {
|
|
14398
15095
|
break;
|
|
14399
15096
|
}
|
|
14400
15097
|
const parsed = parseArrayValue(token, schema, label);
|
|
14401
15098
|
if (parsed === null) {
|
|
14402
15099
|
return {
|
|
14403
|
-
nextIndex:
|
|
15100
|
+
nextIndex: cursor2,
|
|
14404
15101
|
value: null
|
|
14405
15102
|
};
|
|
14406
15103
|
}
|
|
14407
15104
|
values.push(...parsed);
|
|
14408
|
-
nextIndex =
|
|
14409
|
-
|
|
15105
|
+
nextIndex = cursor2;
|
|
15106
|
+
cursor2 += 1;
|
|
14410
15107
|
}
|
|
14411
15108
|
if (values.length === 0) {
|
|
14412
15109
|
throw new InvalidArgumentError(`option '${label}' argument missing`);
|
|
@@ -14939,7 +15636,7 @@ function getResolvedFlags(command) {
|
|
|
14939
15636
|
const flags = command.optsWithGlobals();
|
|
14940
15637
|
return flags;
|
|
14941
15638
|
}
|
|
14942
|
-
async function executeCommand(state, services, requirementOptions, runtimeOptions, onErrorReportContext) {
|
|
15639
|
+
async function executeCommand(state, services, requirementOptions, runtimeFetch, runtimeOptions, onErrorReportContext) {
|
|
14943
15640
|
const logger2 = createLogger();
|
|
14944
15641
|
const primitives = {
|
|
14945
15642
|
logger: logger2,
|
|
@@ -14951,7 +15648,12 @@ async function executeCommand(state, services, requirementOptions, runtimeOption
|
|
|
14951
15648
|
const resolvedFlags = optionValues;
|
|
14952
15649
|
const output = resolveOutput(resolvedFlags);
|
|
14953
15650
|
const shouldPrompt = !resolvedFlags.yes && Boolean(process.stdin.isTTY);
|
|
14954
|
-
const runtime = await resolveFixtureRuntime(
|
|
15651
|
+
const runtime = await resolveFixtureRuntime(
|
|
15652
|
+
state.command,
|
|
15653
|
+
services,
|
|
15654
|
+
requirementOptions,
|
|
15655
|
+
runtimeFetch
|
|
15656
|
+
);
|
|
14955
15657
|
const preflightContext = {
|
|
14956
15658
|
...runtime.services,
|
|
14957
15659
|
secrets: runtime.secrets,
|
|
@@ -14994,7 +15696,7 @@ async function executeCommand(state, services, requirementOptions, runtimeOption
|
|
|
14994
15696
|
logger2.resolved(field.displayPath, formatResolvedValue(value));
|
|
14995
15697
|
}
|
|
14996
15698
|
}
|
|
14997
|
-
const proceed = await
|
|
15699
|
+
const proceed = await confirm({
|
|
14998
15700
|
message: "Proceed?",
|
|
14999
15701
|
initialValue: true
|
|
15000
15702
|
});
|
|
@@ -15482,6 +16184,7 @@ async function runCLI(roots, options = {}) {
|
|
|
15482
16184
|
const casing = options.casing ?? "kebab";
|
|
15483
16185
|
const services = options.services ?? {};
|
|
15484
16186
|
const runtimeOptions = options.humanInLoop ?? {};
|
|
16187
|
+
const runtimeFetch = options.fetch ?? globalThis.fetch;
|
|
15485
16188
|
const version = options.version ?? findEntrypointPackageMetadata(process.argv[1])?.version;
|
|
15486
16189
|
const rootUsageName = options.rootUsageName ?? inferProgramName(process.argv);
|
|
15487
16190
|
const controls = resolveCLIControls(options.controls);
|
|
@@ -15523,6 +16226,7 @@ async function runCLI(roots, options = {}) {
|
|
|
15523
16226
|
state,
|
|
15524
16227
|
servicesWithBuiltIns,
|
|
15525
16228
|
requirementOptions,
|
|
16229
|
+
runtimeFetch,
|
|
15526
16230
|
runtimeOptions,
|
|
15527
16231
|
(context) => {
|
|
15528
16232
|
errorReportContext = context;
|
|
@@ -15601,7 +16305,7 @@ async function runCLI(roots, options = {}) {
|
|
|
15601
16305
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
15602
16306
|
|
|
15603
16307
|
// src/terminal-session.ts
|
|
15604
|
-
import { EventEmitter } from "node:events";
|
|
16308
|
+
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
15605
16309
|
import { accessSync, chmodSync, constants } from "node:fs";
|
|
15606
16310
|
import { createRequire } from "node:module";
|
|
15607
16311
|
import { dirname, join } from "node:path";
|
|
@@ -16426,12 +17130,12 @@ var TerminalScreen = class {
|
|
|
16426
17130
|
constructor({
|
|
16427
17131
|
lines,
|
|
16428
17132
|
rawLines,
|
|
16429
|
-
cursor,
|
|
17133
|
+
cursor: cursor2,
|
|
16430
17134
|
size
|
|
16431
17135
|
}) {
|
|
16432
17136
|
this.lines = Object.freeze(lines.map((line) => stripAnsi(line)));
|
|
16433
17137
|
this.rawLines = Object.freeze([...rawLines]);
|
|
16434
|
-
this.cursor = Object.freeze({ ...
|
|
17138
|
+
this.cursor = Object.freeze({ ...cursor2 });
|
|
16435
17139
|
this.size = Object.freeze({ ...size });
|
|
16436
17140
|
Object.freeze(this);
|
|
16437
17141
|
}
|
|
@@ -16467,7 +17171,7 @@ var TerminalSession = class {
|
|
|
16467
17171
|
exitCode = null;
|
|
16468
17172
|
pty;
|
|
16469
17173
|
terminal;
|
|
16470
|
-
emitter = new
|
|
17174
|
+
emitter = new EventEmitter2();
|
|
16471
17175
|
exitPromise;
|
|
16472
17176
|
rawBuffer = "";
|
|
16473
17177
|
lastDataAt = Date.now();
|
|
@@ -16515,14 +17219,14 @@ var TerminalSession = class {
|
|
|
16515
17219
|
});
|
|
16516
17220
|
});
|
|
16517
17221
|
}
|
|
16518
|
-
async type(
|
|
16519
|
-
for (const character of
|
|
17222
|
+
async type(text4) {
|
|
17223
|
+
for (const character of text4) {
|
|
16520
17224
|
await this.send(character);
|
|
16521
17225
|
await sleep(TYPE_DELAY_MS);
|
|
16522
17226
|
}
|
|
16523
17227
|
}
|
|
16524
|
-
async fill(
|
|
16525
|
-
await this.send(
|
|
17228
|
+
async fill(text4) {
|
|
17229
|
+
await this.send(text4.replace(/\r?\n/g, "\r"));
|
|
16526
17230
|
}
|
|
16527
17231
|
async press(key2) {
|
|
16528
17232
|
await this.send(keyToSequence(key2));
|
|
@@ -16744,25 +17448,25 @@ function splitHistoryLines(input) {
|
|
|
16744
17448
|
function normalizeHistoryBuffer(input) {
|
|
16745
17449
|
let output = "";
|
|
16746
17450
|
let line = "";
|
|
16747
|
-
let
|
|
17451
|
+
let cursor2 = 0;
|
|
16748
17452
|
for (const character of input) {
|
|
16749
17453
|
if (character === "\r") {
|
|
16750
|
-
|
|
17454
|
+
cursor2 = 0;
|
|
16751
17455
|
continue;
|
|
16752
17456
|
}
|
|
16753
17457
|
if (character === "\b") {
|
|
16754
|
-
|
|
17458
|
+
cursor2 = Math.max(0, cursor2 - 1);
|
|
16755
17459
|
continue;
|
|
16756
17460
|
}
|
|
16757
17461
|
if (character === "\n") {
|
|
16758
17462
|
output += `${line}
|
|
16759
17463
|
`;
|
|
16760
17464
|
line = "";
|
|
16761
|
-
|
|
17465
|
+
cursor2 = 0;
|
|
16762
17466
|
continue;
|
|
16763
17467
|
}
|
|
16764
|
-
line = `${line.slice(0,
|
|
16765
|
-
|
|
17468
|
+
line = `${line.slice(0, cursor2)}${character}${line.slice(cursor2 + 1)}`;
|
|
17469
|
+
cursor2 += 1;
|
|
16766
17470
|
}
|
|
16767
17471
|
return output + line;
|
|
16768
17472
|
}
|
|
@@ -17481,7 +18185,7 @@ function detectIndent(content) {
|
|
|
17481
18185
|
}
|
|
17482
18186
|
return " ";
|
|
17483
18187
|
}
|
|
17484
|
-
function
|
|
18188
|
+
function parse4(content) {
|
|
17485
18189
|
if (!content || content.trim() === "") {
|
|
17486
18190
|
return {};
|
|
17487
18191
|
}
|
|
@@ -17606,7 +18310,7 @@ function applyObjectUpdate(content, path25, current, next) {
|
|
|
17606
18310
|
return result;
|
|
17607
18311
|
}
|
|
17608
18312
|
var jsonFormat = {
|
|
17609
|
-
parse:
|
|
18313
|
+
parse: parse4,
|
|
17610
18314
|
serialize,
|
|
17611
18315
|
serializeUpdate,
|
|
17612
18316
|
merge,
|
|
@@ -17618,7 +18322,7 @@ import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
|
|
|
17618
18322
|
function isConfigObject2(value) {
|
|
17619
18323
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17620
18324
|
}
|
|
17621
|
-
function
|
|
18325
|
+
function parse5(content) {
|
|
17622
18326
|
if (!content || content.trim() === "") {
|
|
17623
18327
|
return {};
|
|
17624
18328
|
}
|
|
@@ -17684,7 +18388,7 @@ function prune2(obj, shape) {
|
|
|
17684
18388
|
return { changed, result };
|
|
17685
18389
|
}
|
|
17686
18390
|
var tomlFormat = {
|
|
17687
|
-
parse:
|
|
18391
|
+
parse: parse5,
|
|
17688
18392
|
serialize: serialize2,
|
|
17689
18393
|
merge: merge2,
|
|
17690
18394
|
prune: prune2
|
|
@@ -17695,7 +18399,7 @@ import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
|
17695
18399
|
function isConfigObject3(value) {
|
|
17696
18400
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17697
18401
|
}
|
|
17698
|
-
function
|
|
18402
|
+
function parse6(content) {
|
|
17699
18403
|
if (!content || content.trim() === "") {
|
|
17700
18404
|
return {};
|
|
17701
18405
|
}
|
|
@@ -17761,7 +18465,7 @@ function prune3(obj, shape) {
|
|
|
17761
18465
|
return { changed, result };
|
|
17762
18466
|
}
|
|
17763
18467
|
var yamlFormat = {
|
|
17764
|
-
parse:
|
|
18468
|
+
parse: parse6,
|
|
17765
18469
|
serialize: serialize3,
|
|
17766
18470
|
merge: merge3,
|
|
17767
18471
|
prune: prune3
|
|
@@ -19022,17 +19726,17 @@ function colorsEqual(left, right) {
|
|
|
19022
19726
|
}
|
|
19023
19727
|
return false;
|
|
19024
19728
|
}
|
|
19025
|
-
function pushRun(runs, style,
|
|
19026
|
-
if (
|
|
19729
|
+
function pushRun(runs, style, text4) {
|
|
19730
|
+
if (text4.length === 0) {
|
|
19027
19731
|
return;
|
|
19028
19732
|
}
|
|
19029
19733
|
const previous = runs.at(-1);
|
|
19030
|
-
if (previous &&
|
|
19031
|
-
previous.text +=
|
|
19734
|
+
if (previous && text4 !== "\n" && previous.text !== "\n" && stylesEqual(previous, style)) {
|
|
19735
|
+
previous.text += text4;
|
|
19032
19736
|
return;
|
|
19033
19737
|
}
|
|
19034
19738
|
runs.push({
|
|
19035
|
-
text:
|
|
19739
|
+
text: text4,
|
|
19036
19740
|
fg: style.fg,
|
|
19037
19741
|
bg: style.bg,
|
|
19038
19742
|
bold: style.bold,
|
|
@@ -19362,10 +20066,10 @@ function parseAnsi2(input) {
|
|
|
19362
20066
|
continue;
|
|
19363
20067
|
}
|
|
19364
20068
|
const codePoint = input.codePointAt(index);
|
|
19365
|
-
const
|
|
19366
|
-
lines[row][column] = { text:
|
|
20069
|
+
const text4 = codePoint === void 0 ? "" : String.fromCodePoint(codePoint);
|
|
20070
|
+
lines[row][column] = { text: text4, style: cloneStyle(style) };
|
|
19367
20071
|
column += 1;
|
|
19368
|
-
index +=
|
|
20072
|
+
index += text4.length;
|
|
19369
20073
|
}
|
|
19370
20074
|
return buildRuns(lines, lineBreakStyles);
|
|
19371
20075
|
}
|
|
@@ -19776,10 +20480,10 @@ function measureLines(lines) {
|
|
|
19776
20480
|
0
|
|
19777
20481
|
);
|
|
19778
20482
|
}
|
|
19779
|
-
function displayWidth3(
|
|
20483
|
+
function displayWidth3(text4, startColumn = 0) {
|
|
19780
20484
|
const segmenter = new Intl.Segmenter();
|
|
19781
20485
|
let column = startColumn;
|
|
19782
|
-
for (const { segment } of segmenter.segment(
|
|
20486
|
+
for (const { segment } of segmenter.segment(text4)) {
|
|
19783
20487
|
if (segment === " ") {
|
|
19784
20488
|
column += 8 - column % 8;
|
|
19785
20489
|
continue;
|
|
@@ -19872,8 +20576,8 @@ function renderRun(run) {
|
|
|
19872
20576
|
if (run.dim) {
|
|
19873
20577
|
attributes.push('opacity="0.7"');
|
|
19874
20578
|
}
|
|
19875
|
-
const
|
|
19876
|
-
return `<tspan ${attributes.join(" ")}>${escapeXmlText(
|
|
20579
|
+
const text4 = run.conceal ? " ".repeat(displayWidth3(run.text)) : run.text;
|
|
20580
|
+
return `<tspan ${attributes.join(" ")}>${escapeXmlText(text4)}</tspan>`;
|
|
19877
20581
|
}
|
|
19878
20582
|
function renderWindowControls() {
|
|
19879
20583
|
return [
|
|
@@ -20218,15 +20922,15 @@ function toText(chunk) {
|
|
|
20218
20922
|
}
|
|
20219
20923
|
return String(chunk);
|
|
20220
20924
|
}
|
|
20221
|
-
function normalizeOutput(
|
|
20222
|
-
return stripAnsi(
|
|
20925
|
+
function normalizeOutput(text4) {
|
|
20926
|
+
return stripAnsi(text4).replaceAll("\r", "").trim();
|
|
20223
20927
|
}
|
|
20224
|
-
function canParseJson(
|
|
20225
|
-
if (
|
|
20928
|
+
function canParseJson(text4) {
|
|
20929
|
+
if (text4.length === 0) {
|
|
20226
20930
|
return false;
|
|
20227
20931
|
}
|
|
20228
20932
|
try {
|
|
20229
|
-
JSON.parse(
|
|
20933
|
+
JSON.parse(text4);
|
|
20230
20934
|
return true;
|
|
20231
20935
|
} catch {
|
|
20232
20936
|
return false;
|