terminal-pilot 0.0.31 → 0.0.32
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 +232 -70
- package/dist/cli.js.map +2 -2
- package/dist/commands/close-session.js +4 -0
- package/dist/commands/close-session.js.map +2 -2
- package/dist/commands/create-session.js +4 -0
- package/dist/commands/create-session.js.map +2 -2
- package/dist/commands/fill.js +4 -0
- package/dist/commands/fill.js.map +2 -2
- package/dist/commands/get-session.js +4 -0
- package/dist/commands/get-session.js.map +2 -2
- package/dist/commands/index.js +4 -0
- package/dist/commands/index.js.map +2 -2
- package/dist/commands/install.js +4 -0
- package/dist/commands/install.js.map +2 -2
- package/dist/commands/installer.js.map +1 -1
- package/dist/commands/list-sessions.js +4 -0
- package/dist/commands/list-sessions.js.map +2 -2
- package/dist/commands/press-key.js +4 -0
- package/dist/commands/press-key.js.map +2 -2
- package/dist/commands/read-history.js +4 -0
- package/dist/commands/read-history.js.map +2 -2
- package/dist/commands/read-screen.js +4 -0
- package/dist/commands/read-screen.js.map +2 -2
- package/dist/commands/resize.js +4 -0
- package/dist/commands/resize.js.map +2 -2
- package/dist/commands/runtime.js.map +1 -1
- package/dist/commands/screenshot.js +4 -0
- package/dist/commands/screenshot.js.map +2 -2
- package/dist/commands/send-signal.js +4 -0
- package/dist/commands/send-signal.js.map +2 -2
- package/dist/commands/type.js +4 -0
- package/dist/commands/type.js.map +2 -2
- package/dist/commands/uninstall.js +4 -0
- package/dist/commands/uninstall.js.map +2 -2
- package/dist/commands/wait-for-exit.js +4 -0
- package/dist/commands/wait-for-exit.js.map +2 -2
- package/dist/commands/wait-for.js +4 -0
- package/dist/commands/wait-for.js.map +2 -2
- package/dist/testing/cli-repl.js +232 -70
- package/dist/testing/cli-repl.js.map +2 -2
- package/dist/testing/qa-cli.js +232 -70
- package/dist/testing/qa-cli.js.map +2 -2
- package/package.json +1 -1
package/dist/testing/qa-cli.js
CHANGED
|
@@ -3749,6 +3749,7 @@ function createBaseCommand(config2) {
|
|
|
3749
3749
|
kind: "command",
|
|
3750
3750
|
name: config2.name,
|
|
3751
3751
|
description: config2.description,
|
|
3752
|
+
hidden: config2.hidden ?? false,
|
|
3752
3753
|
examples: cloneCommandExamples(config2.examples),
|
|
3753
3754
|
aliases: [...config2.aliases ?? []],
|
|
3754
3755
|
positional: [...config2.positional ?? []],
|
|
@@ -3765,6 +3766,7 @@ function createBaseCommand(config2) {
|
|
|
3765
3766
|
Object.defineProperty(command, commandConfigSymbol, {
|
|
3766
3767
|
value: {
|
|
3767
3768
|
scope: cloneScope(config2.scope),
|
|
3769
|
+
hidden: config2.hidden ?? false,
|
|
3768
3770
|
examples: cloneCommandExamples(config2.examples),
|
|
3769
3771
|
result: config2.result,
|
|
3770
3772
|
humanInLoop: config2.humanInLoop,
|
|
@@ -3815,6 +3817,7 @@ function materializeCommand(command, inherited) {
|
|
|
3815
3817
|
kind: "command",
|
|
3816
3818
|
name: command.name,
|
|
3817
3819
|
description: command.description,
|
|
3820
|
+
hidden: internal.hidden,
|
|
3818
3821
|
examples: cloneCommandExamples(internal.examples),
|
|
3819
3822
|
aliases: [...command.aliases],
|
|
3820
3823
|
positional: [...command.positional],
|
|
@@ -3831,6 +3834,7 @@ function materializeCommand(command, inherited) {
|
|
|
3831
3834
|
Object.defineProperty(materialized, commandConfigSymbol, {
|
|
3832
3835
|
value: {
|
|
3833
3836
|
scope: cloneScope(internal.scope),
|
|
3837
|
+
hidden: internal.hidden,
|
|
3834
3838
|
examples: cloneCommandExamples(internal.examples),
|
|
3835
3839
|
result: internal.result,
|
|
3836
3840
|
humanInLoop: internal.humanInLoop,
|
|
@@ -12549,6 +12553,7 @@ function createProxyCommand(parent, tool, commandName, connection) {
|
|
|
12549
12553
|
kind: "command",
|
|
12550
12554
|
name: commandName,
|
|
12551
12555
|
description: tool.description,
|
|
12556
|
+
hidden: false,
|
|
12552
12557
|
examples: [],
|
|
12553
12558
|
aliases: [],
|
|
12554
12559
|
positional: [],
|
|
@@ -14628,6 +14633,14 @@ function isNodeVisibleInScope(node, scope) {
|
|
|
14628
14633
|
function getVisibleChildren(group, scope) {
|
|
14629
14634
|
return group.children.filter((child) => isNodeVisibleInScope(child, scope));
|
|
14630
14635
|
}
|
|
14636
|
+
function getHelpChildren(group, scope) {
|
|
14637
|
+
return getVisibleChildren(group, scope).filter((child) => {
|
|
14638
|
+
if (child.kind === "command") {
|
|
14639
|
+
return child.hidden !== true;
|
|
14640
|
+
}
|
|
14641
|
+
return true;
|
|
14642
|
+
});
|
|
14643
|
+
}
|
|
14631
14644
|
function findVisibleChild(group, token, scope) {
|
|
14632
14645
|
return getVisibleChildren(group, scope).find(
|
|
14633
14646
|
(child) => child.name === token || child.aliases.includes(token)
|
|
@@ -14774,6 +14787,26 @@ function describeHelpValueToken(schema, field) {
|
|
|
14774
14787
|
}
|
|
14775
14788
|
return describeFieldNameValueToken(field.displayPath, field.optionFlag) ?? "value";
|
|
14776
14789
|
}
|
|
14790
|
+
function formatCompactEnumSignatureToken(schema) {
|
|
14791
|
+
if (schema.kind !== "enum" || schema.values.length < 2 || schema.values.length > 3) {
|
|
14792
|
+
return void 0;
|
|
14793
|
+
}
|
|
14794
|
+
const tokens = schema.values.map((value) => String(value));
|
|
14795
|
+
const compact = tokens.every(
|
|
14796
|
+
(token) => token.length > 0 && token.length <= 24 && token.trim() === token && !token.includes("|") && !token.includes(" ") && !token.includes("\n") && !token.includes("\r") && !token.includes(" ")
|
|
14797
|
+
);
|
|
14798
|
+
return compact ? tokens.join("|") : void 0;
|
|
14799
|
+
}
|
|
14800
|
+
function formatCommandParameterFieldFlags(field, globalLongOptionFlags) {
|
|
14801
|
+
if (field.positionalIndex !== void 0 || field.schema.kind === "boolean") {
|
|
14802
|
+
return formatHelpFieldFlags(field, globalLongOptionFlags);
|
|
14803
|
+
}
|
|
14804
|
+
const enumToken = formatCompactEnumSignatureToken(field.schema);
|
|
14805
|
+
if (enumToken !== void 0) {
|
|
14806
|
+
return `${formatOptionFlags(field, globalLongOptionFlags)} ${enumToken}`;
|
|
14807
|
+
}
|
|
14808
|
+
return formatHelpFieldFlags(field, globalLongOptionFlags);
|
|
14809
|
+
}
|
|
14777
14810
|
function describeDynamicFieldType(field) {
|
|
14778
14811
|
if (field.schema.kind === "record") {
|
|
14779
14812
|
const valueSchema = unwrapOptional2(field.schema.value);
|
|
@@ -14941,7 +14974,7 @@ function formatCommandParameterTokens(command, casing, globalLongOptionFlags) {
|
|
|
14941
14974
|
const fields = assignPositionals(collected.fields, command.positional);
|
|
14942
14975
|
return fields.filter((field) => field.global !== true).map(
|
|
14943
14976
|
(field) => wrapOptionalCommandParameterToken(
|
|
14944
|
-
|
|
14977
|
+
formatCommandParameterFieldFlags(field, globalLongOptionFlags),
|
|
14945
14978
|
field.positionalIndex === void 0 && (field.optional || field.hasDefault)
|
|
14946
14979
|
)
|
|
14947
14980
|
).concat(
|
|
@@ -14955,7 +14988,7 @@ function formatCommandRowName(node, casing, globalLongOptionFlags) {
|
|
|
14955
14988
|
return name;
|
|
14956
14989
|
}
|
|
14957
14990
|
function formatCommandRows(group, scope, casing, globalLongOptionFlags) {
|
|
14958
|
-
return
|
|
14991
|
+
return getHelpChildren(group, scope).map((child) => ({
|
|
14959
14992
|
name: formatCommandRowName(child, casing, globalLongOptionFlags),
|
|
14960
14993
|
description: child.description ?? ""
|
|
14961
14994
|
}));
|
|
@@ -14999,7 +15032,7 @@ function collectSchemaGlobalFieldRows(group, scope, casing, globalLongOptionFlag
|
|
|
14999
15032
|
}
|
|
15000
15033
|
return;
|
|
15001
15034
|
}
|
|
15002
|
-
for (const child of
|
|
15035
|
+
for (const child of getHelpChildren(node, scope)) {
|
|
15003
15036
|
visit(child);
|
|
15004
15037
|
}
|
|
15005
15038
|
};
|
|
@@ -15022,6 +15055,17 @@ function buildUsageLine(breadcrumb, rootUsageName, suffix) {
|
|
|
15022
15055
|
const tokens = [rootUsageName, subPath, suffix].filter((segment) => segment.length > 0);
|
|
15023
15056
|
return tokens.join(" ");
|
|
15024
15057
|
}
|
|
15058
|
+
function formatGroupUsageSuffix(group, scope, casing, globalLongOptionFlags) {
|
|
15059
|
+
if (group.default !== void 0 && group.default.hidden === true && group.default.scope.includes(scope)) {
|
|
15060
|
+
const parameterTokens = formatCommandParameterTokens(
|
|
15061
|
+
group.default,
|
|
15062
|
+
casing,
|
|
15063
|
+
globalLongOptionFlags
|
|
15064
|
+
);
|
|
15065
|
+
return ["[command]", "[OPTIONS]", ...parameterTokens].join(" ");
|
|
15066
|
+
}
|
|
15067
|
+
return "[command] [OPTIONS]";
|
|
15068
|
+
}
|
|
15025
15069
|
function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUsageName, isRoot) {
|
|
15026
15070
|
const sections = [];
|
|
15027
15071
|
const globalLongOptionFlags = getGlobalLongOptionFlags(
|
|
@@ -15055,7 +15099,11 @@ ${builtInLine}`
|
|
|
15055
15099
|
return renderHelpDocument({
|
|
15056
15100
|
breadcrumb,
|
|
15057
15101
|
rootUsageName,
|
|
15058
|
-
usageLine: buildUsageLine(
|
|
15102
|
+
usageLine: buildUsageLine(
|
|
15103
|
+
breadcrumb,
|
|
15104
|
+
rootUsageName,
|
|
15105
|
+
formatGroupUsageSuffix(group, scope, casing, globalLongOptionFlags)
|
|
15106
|
+
),
|
|
15059
15107
|
description: group.description,
|
|
15060
15108
|
requiresAuth: group.requires?.auth === true,
|
|
15061
15109
|
sections
|
|
@@ -15164,6 +15212,8 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15164
15212
|
return null;
|
|
15165
15213
|
}
|
|
15166
15214
|
const command = new CommanderCommand(node.name);
|
|
15215
|
+
Reflect.set(command, "_toolcraftHidden", node.hidden);
|
|
15216
|
+
Reflect.set(command, "_toolcraftOriginalName", node.name);
|
|
15167
15217
|
const collected = collectFields(node.params, casing, globalLongOptionFlags);
|
|
15168
15218
|
const fields = assignPositionals(collected.fields, node.positional);
|
|
15169
15219
|
validateUniqueOptionFlags(fields, globalLongOptionFlags);
|
|
@@ -15207,6 +15257,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15207
15257
|
if (!isNodeVisibleInScope(node, "cli")) {
|
|
15208
15258
|
return null;
|
|
15209
15259
|
}
|
|
15260
|
+
const reservedChildNames = node.children.filter((child) => !isNodeVisibleInScope(child, "cli")).flatMap((child) => getNodeCommandNames(child));
|
|
15210
15261
|
const visibleChildren = node.children.map(
|
|
15211
15262
|
(child) => createNodeCommand(
|
|
15212
15263
|
child,
|
|
@@ -15219,6 +15270,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15219
15270
|
)
|
|
15220
15271
|
).filter((child) => child !== null);
|
|
15221
15272
|
const group = new CommanderCommand(node.name);
|
|
15273
|
+
Reflect.set(group, "_toolcraftReservedChildNames", reservedChildNames);
|
|
15222
15274
|
if (node.description !== void 0) {
|
|
15223
15275
|
group.description(node.description);
|
|
15224
15276
|
}
|
|
@@ -15233,7 +15285,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15233
15285
|
return group;
|
|
15234
15286
|
}
|
|
15235
15287
|
function addCommanderChild(parent, child, isDefault, siblingNames) {
|
|
15236
|
-
if (isDefault && child.name().length === 0) {
|
|
15288
|
+
if (isDefault && (child.name().length === 0 || isToolcraftHiddenCommander(child))) {
|
|
15237
15289
|
let internalName = "__toolcraft_default__";
|
|
15238
15290
|
let suffix = 2;
|
|
15239
15291
|
while (siblingNames.has(internalName)) {
|
|
@@ -15241,10 +15293,37 @@ function addCommanderChild(parent, child, isDefault, siblingNames) {
|
|
|
15241
15293
|
suffix += 1;
|
|
15242
15294
|
}
|
|
15243
15295
|
child.name(internalName);
|
|
15296
|
+
Reflect.set(
|
|
15297
|
+
parent,
|
|
15298
|
+
"_toolcraftHiddenDefaultNames",
|
|
15299
|
+
getToolcraftHiddenDefaultNames(parent).concat([
|
|
15300
|
+
...new Set([Reflect.get(child, "_toolcraftOriginalName"), ...child.aliases()].filter(
|
|
15301
|
+
(name) => typeof name === "string" && name.length > 0
|
|
15302
|
+
))
|
|
15303
|
+
])
|
|
15304
|
+
);
|
|
15244
15305
|
parent.addCommand(child, { hidden: true, isDefault: true });
|
|
15245
15306
|
return;
|
|
15246
15307
|
}
|
|
15247
|
-
|
|
15308
|
+
const options = {
|
|
15309
|
+
...isDefault ? { isDefault: true } : {},
|
|
15310
|
+
...isToolcraftHiddenCommander(child) ? { hidden: true } : {}
|
|
15311
|
+
};
|
|
15312
|
+
parent.addCommand(child, Object.keys(options).length > 0 ? options : void 0);
|
|
15313
|
+
}
|
|
15314
|
+
function isToolcraftHiddenCommander(command) {
|
|
15315
|
+
return Reflect.get(command, "_toolcraftHidden") === true;
|
|
15316
|
+
}
|
|
15317
|
+
function getToolcraftHiddenDefaultNames(command) {
|
|
15318
|
+
const value = Reflect.get(command, "_toolcraftHiddenDefaultNames");
|
|
15319
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
15320
|
+
}
|
|
15321
|
+
function getToolcraftReservedChildNames(command) {
|
|
15322
|
+
const value = Reflect.get(command, "_toolcraftReservedChildNames");
|
|
15323
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
15324
|
+
}
|
|
15325
|
+
function getNodeCommandNames(node) {
|
|
15326
|
+
return [node.name, ...node.aliases].filter((name) => name.length > 0);
|
|
15248
15327
|
}
|
|
15249
15328
|
function addGlobalOptions(command, presetsEnabled, controls) {
|
|
15250
15329
|
const options = [];
|
|
@@ -15406,6 +15485,37 @@ function resolveOutput(resolvedFlags) {
|
|
|
15406
15485
|
}
|
|
15407
15486
|
return "rich";
|
|
15408
15487
|
}
|
|
15488
|
+
function resolveOutputFromArgv(argv) {
|
|
15489
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
15490
|
+
const token = argv[index] ?? "";
|
|
15491
|
+
if (token === "--json") {
|
|
15492
|
+
return "json";
|
|
15493
|
+
}
|
|
15494
|
+
if (token === "--md" || token === "--markdown") {
|
|
15495
|
+
return "md";
|
|
15496
|
+
}
|
|
15497
|
+
if (token === "--output") {
|
|
15498
|
+
const value = argv[index + 1];
|
|
15499
|
+
if (value === "rich" || value === "md" || value === "json") {
|
|
15500
|
+
return value;
|
|
15501
|
+
}
|
|
15502
|
+
if (value === "markdown") {
|
|
15503
|
+
return "md";
|
|
15504
|
+
}
|
|
15505
|
+
continue;
|
|
15506
|
+
}
|
|
15507
|
+
if (token.startsWith("--output=")) {
|
|
15508
|
+
const value = token.slice("--output=".length);
|
|
15509
|
+
if (value === "rich" || value === "md" || value === "json") {
|
|
15510
|
+
return value;
|
|
15511
|
+
}
|
|
15512
|
+
if (value === "markdown") {
|
|
15513
|
+
return "md";
|
|
15514
|
+
}
|
|
15515
|
+
}
|
|
15516
|
+
}
|
|
15517
|
+
return "rich";
|
|
15518
|
+
}
|
|
15409
15519
|
var DESIGN_SYSTEM_OUTPUT_BY_MODE = {
|
|
15410
15520
|
rich: "terminal",
|
|
15411
15521
|
md: "markdown",
|
|
@@ -15927,6 +16037,44 @@ function renderApprovalDeclined(error3) {
|
|
|
15927
16037
|
logger2.error(error3.message);
|
|
15928
16038
|
process.exitCode = 1;
|
|
15929
16039
|
}
|
|
16040
|
+
function renderCliErrorPattern(pattern) {
|
|
16041
|
+
const logger2 = createLogger();
|
|
16042
|
+
if (pattern.kind === "usage") {
|
|
16043
|
+
logger2.error(
|
|
16044
|
+
appendUsagePointer(pattern.message, {
|
|
16045
|
+
rootUsageName: pattern.rootUsageName,
|
|
16046
|
+
commandPath: pattern.commandPath
|
|
16047
|
+
})
|
|
16048
|
+
);
|
|
16049
|
+
process.exitCode = 1;
|
|
16050
|
+
return;
|
|
16051
|
+
}
|
|
16052
|
+
if (pattern.kind === "runtime-user") {
|
|
16053
|
+
logger2.error(pattern.message);
|
|
16054
|
+
process.exitCode = 1;
|
|
16055
|
+
return;
|
|
16056
|
+
}
|
|
16057
|
+
if (pattern.kind === "toolcraft-bug") {
|
|
16058
|
+
logger2.error(
|
|
16059
|
+
`toolcraft hit an internal invariant: ${pattern.error.message}
|
|
16060
|
+
This is a bug in toolcraft or in the command definition; it cannot be worked around by changing argv. Re-run with --debug for a stack trace and file an issue.`
|
|
16061
|
+
);
|
|
16062
|
+
if (pattern.debugStackMode !== void 0 && pattern.error.stack) {
|
|
16063
|
+
process.stderr.write(`${formatDebugStack(pattern.error.stack, pattern.debugStackMode)}
|
|
16064
|
+
`);
|
|
16065
|
+
}
|
|
16066
|
+
process.exitCode = 1;
|
|
16067
|
+
return;
|
|
16068
|
+
}
|
|
16069
|
+
logger2.error(
|
|
16070
|
+
pattern.debugStackMode !== void 0 ? pattern.message : `${pattern.message} Use --debug for a stack trace.`
|
|
16071
|
+
);
|
|
16072
|
+
if (pattern.debugStackMode !== void 0 && pattern.stack !== void 0) {
|
|
16073
|
+
process.stderr.write(`${formatDebugStack(pattern.stack, pattern.debugStackMode)}
|
|
16074
|
+
`);
|
|
16075
|
+
}
|
|
16076
|
+
process.exitCode = 1;
|
|
16077
|
+
}
|
|
15930
16078
|
function validateServices(services) {
|
|
15931
16079
|
for (const name of Object.keys(services)) {
|
|
15932
16080
|
if (RESERVED_SERVICE_NAMES.has(name)) {
|
|
@@ -16847,79 +16995,79 @@ function renderHttpError(error3, options) {
|
|
|
16847
16995
|
`);
|
|
16848
16996
|
}
|
|
16849
16997
|
}
|
|
16850
|
-
function handleRunError(error3, options) {
|
|
16998
|
+
async function handleRunError(error3, options) {
|
|
16851
16999
|
const logger2 = createLogger();
|
|
16852
|
-
|
|
16853
|
-
|
|
16854
|
-
|
|
16855
|
-
|
|
16856
|
-
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
|
|
16865
|
-
This is a bug in toolcraft or in the command definition; it cannot be worked around by changing argv. Re-run with --debug for a stack trace and file an issue.`
|
|
16866
|
-
);
|
|
16867
|
-
if (options.debugStackMode !== void 0 && error3.stack) {
|
|
16868
|
-
process.stderr.write(`${formatDebugStack(error3.stack, options.debugStackMode)}
|
|
16869
|
-
`);
|
|
16870
|
-
}
|
|
16871
|
-
process.exitCode = 1;
|
|
16872
|
-
return;
|
|
16873
|
-
}
|
|
16874
|
-
if (error3 instanceof CommanderError2) {
|
|
16875
|
-
process.exitCode = error3.exitCode;
|
|
16876
|
-
if (error3.code === "commander.helpDisplayed" || error3.code === "commander.version") {
|
|
17000
|
+
await withOutputFormat2(options.output, async () => {
|
|
17001
|
+
if (error3 instanceof UserError) {
|
|
17002
|
+
renderCliErrorPattern(
|
|
17003
|
+
options.userErrorPattern === "usage" ? {
|
|
17004
|
+
kind: "usage",
|
|
17005
|
+
message: error3.message,
|
|
17006
|
+
rootUsageName: options.rootUsageName,
|
|
17007
|
+
commandPath: options.commandPath
|
|
17008
|
+
} : {
|
|
17009
|
+
kind: "runtime-user",
|
|
17010
|
+
message: error3.message
|
|
17011
|
+
}
|
|
17012
|
+
);
|
|
16877
17013
|
return;
|
|
16878
17014
|
}
|
|
16879
|
-
if (error3.
|
|
16880
|
-
|
|
16881
|
-
|
|
16882
|
-
|
|
16883
|
-
|
|
16884
|
-
|
|
16885
|
-
commandPath: options.commandPath
|
|
16886
|
-
}
|
|
16887
|
-
)
|
|
16888
|
-
);
|
|
17015
|
+
if (error3 instanceof Error && error3.name === "ToolcraftBugError") {
|
|
17016
|
+
renderCliErrorPattern({
|
|
17017
|
+
kind: "toolcraft-bug",
|
|
17018
|
+
error: error3,
|
|
17019
|
+
debugStackMode: options.debugStackMode
|
|
17020
|
+
});
|
|
16889
17021
|
return;
|
|
16890
17022
|
}
|
|
16891
|
-
if (error3
|
|
16892
|
-
|
|
17023
|
+
if (error3 instanceof CommanderError2) {
|
|
17024
|
+
process.exitCode = error3.exitCode;
|
|
17025
|
+
if (error3.code === "commander.helpDisplayed" || error3.code === "commander.version") {
|
|
17026
|
+
return;
|
|
17027
|
+
}
|
|
17028
|
+
if (error3.code === "commander.unknownCommand") {
|
|
17029
|
+
logger2.error(
|
|
17030
|
+
appendUsagePointer(
|
|
17031
|
+
formatUnknownCommandError(error3, options.program, options.argv ?? process.argv),
|
|
17032
|
+
{
|
|
17033
|
+
rootUsageName: options.rootUsageName,
|
|
17034
|
+
commandPath: options.commandPath
|
|
17035
|
+
}
|
|
17036
|
+
)
|
|
17037
|
+
);
|
|
17038
|
+
return;
|
|
17039
|
+
}
|
|
17040
|
+
if (error3.code === "commander.unknownOption") {
|
|
17041
|
+
const argv = options.argv ?? process.argv;
|
|
17042
|
+
logger2.error(
|
|
17043
|
+
appendUsagePointer(formatUnknownOptionError(error3, options.program, argv), {
|
|
17044
|
+
rootUsageName: options.rootUsageName,
|
|
17045
|
+
commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, argv)
|
|
17046
|
+
})
|
|
17047
|
+
);
|
|
17048
|
+
return;
|
|
17049
|
+
}
|
|
16893
17050
|
logger2.error(
|
|
16894
|
-
appendUsagePointer(
|
|
17051
|
+
appendUsagePointer(formatCommanderErrorMessage(error3), {
|
|
16895
17052
|
rootUsageName: options.rootUsageName,
|
|
16896
|
-
commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, argv)
|
|
17053
|
+
commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, options.argv ?? process.argv)
|
|
16897
17054
|
})
|
|
16898
17055
|
);
|
|
16899
17056
|
return;
|
|
16900
17057
|
}
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
);
|
|
16907
|
-
|
|
16908
|
-
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
16912
|
-
|
|
16913
|
-
}
|
|
16914
|
-
const message2 = error3 instanceof Error ? error3.message : String(error3);
|
|
16915
|
-
logger2.error(
|
|
16916
|
-
options.debugStackMode !== void 0 ? message2 : `${message2} Use --debug for a stack trace.`
|
|
16917
|
-
);
|
|
16918
|
-
if (options.debugStackMode !== void 0 && error3 instanceof Error && error3.stack) {
|
|
16919
|
-
process.stderr.write(`${formatDebugStack(error3.stack, options.debugStackMode)}
|
|
16920
|
-
`);
|
|
16921
|
-
}
|
|
16922
|
-
process.exitCode = 1;
|
|
17058
|
+
if (isHttpErrorLike(error3)) {
|
|
17059
|
+
renderHttpError(error3, options);
|
|
17060
|
+
process.exitCode = 1;
|
|
17061
|
+
return;
|
|
17062
|
+
}
|
|
17063
|
+
const message2 = error3 instanceof Error ? error3.message : String(error3);
|
|
17064
|
+
renderCliErrorPattern({
|
|
17065
|
+
kind: "unexpected",
|
|
17066
|
+
message: message2,
|
|
17067
|
+
stack: error3 instanceof Error ? error3.stack : void 0,
|
|
17068
|
+
debugStackMode: options.debugStackMode
|
|
17069
|
+
});
|
|
17070
|
+
});
|
|
16923
17071
|
}
|
|
16924
17072
|
function formatCommanderErrorMessage(error3) {
|
|
16925
17073
|
return error3.message.startsWith("error:") ? error3.message : `error: ${error3.message}`;
|
|
@@ -17083,6 +17231,13 @@ function findUnknownCommanderCommand(program, argv) {
|
|
|
17083
17231
|
}
|
|
17084
17232
|
continue;
|
|
17085
17233
|
}
|
|
17234
|
+
if (getToolcraftHiddenDefaultNames(current).includes(token) || getToolcraftReservedChildNames(current).includes(token)) {
|
|
17235
|
+
return {
|
|
17236
|
+
input: token,
|
|
17237
|
+
currentCommand: current,
|
|
17238
|
+
commandPath: pathSegments.join(" ")
|
|
17239
|
+
};
|
|
17240
|
+
}
|
|
17086
17241
|
if (current.commands.length === 0 || getDefaultCommanderCommandName(current) !== void 0) {
|
|
17087
17242
|
return void 0;
|
|
17088
17243
|
}
|
|
@@ -17157,6 +17312,11 @@ async function runCLI(roots, options = {}) {
|
|
|
17157
17312
|
if (version !== void 0) {
|
|
17158
17313
|
program.version(version, "--version");
|
|
17159
17314
|
}
|
|
17315
|
+
Reflect.set(
|
|
17316
|
+
program,
|
|
17317
|
+
"_toolcraftReservedChildNames",
|
|
17318
|
+
root.children.filter((child) => !isNodeVisibleInScope(child, "cli")).flatMap((child) => getNodeCommandNames(child))
|
|
17319
|
+
);
|
|
17160
17320
|
let lastActionCommand;
|
|
17161
17321
|
let resolvedCommandPath = "";
|
|
17162
17322
|
let errorReportContext;
|
|
@@ -17231,13 +17391,15 @@ async function runCLI(roots, options = {}) {
|
|
|
17231
17391
|
process.stderr.write(`Saved error report to ${report.displayPath}
|
|
17232
17392
|
`);
|
|
17233
17393
|
}
|
|
17234
|
-
handleRunError(error3, {
|
|
17394
|
+
await handleRunError(error3, {
|
|
17235
17395
|
debugStackMode: resolvedFlags !== void 0 ? resolveDebugStackMode(resolvedFlags.debug) : getDebugStackModeFromArgv(process.argv),
|
|
17396
|
+
output: resolvedFlags !== void 0 ? resolveOutput(resolvedFlags) : resolveOutputFromArgv(process.argv),
|
|
17236
17397
|
verbose: resolvedFlags ? Boolean(resolvedFlags.verbose) : process.argv.includes("--verbose"),
|
|
17237
17398
|
program,
|
|
17238
17399
|
argv: process.argv,
|
|
17239
17400
|
rootUsageName,
|
|
17240
|
-
commandPath: resolvedCommandPath
|
|
17401
|
+
commandPath: resolvedCommandPath,
|
|
17402
|
+
userErrorPattern: errorReportContext?.params === void 0 ? "usage" : "runtime-user"
|
|
17241
17403
|
});
|
|
17242
17404
|
}
|
|
17243
17405
|
}
|