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/cli.js
CHANGED
|
@@ -3670,6 +3670,7 @@ function createBaseCommand(config2) {
|
|
|
3670
3670
|
kind: "command",
|
|
3671
3671
|
name: config2.name,
|
|
3672
3672
|
description: config2.description,
|
|
3673
|
+
hidden: config2.hidden ?? false,
|
|
3673
3674
|
examples: cloneCommandExamples(config2.examples),
|
|
3674
3675
|
aliases: [...config2.aliases ?? []],
|
|
3675
3676
|
positional: [...config2.positional ?? []],
|
|
@@ -3686,6 +3687,7 @@ function createBaseCommand(config2) {
|
|
|
3686
3687
|
Object.defineProperty(command, commandConfigSymbol, {
|
|
3687
3688
|
value: {
|
|
3688
3689
|
scope: cloneScope(config2.scope),
|
|
3690
|
+
hidden: config2.hidden ?? false,
|
|
3689
3691
|
examples: cloneCommandExamples(config2.examples),
|
|
3690
3692
|
result: config2.result,
|
|
3691
3693
|
humanInLoop: config2.humanInLoop,
|
|
@@ -3736,6 +3738,7 @@ function materializeCommand(command, inherited) {
|
|
|
3736
3738
|
kind: "command",
|
|
3737
3739
|
name: command.name,
|
|
3738
3740
|
description: command.description,
|
|
3741
|
+
hidden: internal.hidden,
|
|
3739
3742
|
examples: cloneCommandExamples(internal.examples),
|
|
3740
3743
|
aliases: [...command.aliases],
|
|
3741
3744
|
positional: [...command.positional],
|
|
@@ -3752,6 +3755,7 @@ function materializeCommand(command, inherited) {
|
|
|
3752
3755
|
Object.defineProperty(materialized, commandConfigSymbol, {
|
|
3753
3756
|
value: {
|
|
3754
3757
|
scope: cloneScope(internal.scope),
|
|
3758
|
+
hidden: internal.hidden,
|
|
3755
3759
|
examples: cloneCommandExamples(internal.examples),
|
|
3756
3760
|
result: internal.result,
|
|
3757
3761
|
humanInLoop: internal.humanInLoop,
|
|
@@ -12470,6 +12474,7 @@ function createProxyCommand(parent, tool, commandName, connection) {
|
|
|
12470
12474
|
kind: "command",
|
|
12471
12475
|
name: commandName,
|
|
12472
12476
|
description: tool.description,
|
|
12477
|
+
hidden: false,
|
|
12473
12478
|
examples: [],
|
|
12474
12479
|
aliases: [],
|
|
12475
12480
|
positional: [],
|
|
@@ -14549,6 +14554,14 @@ function isNodeVisibleInScope(node, scope) {
|
|
|
14549
14554
|
function getVisibleChildren(group, scope) {
|
|
14550
14555
|
return group.children.filter((child) => isNodeVisibleInScope(child, scope));
|
|
14551
14556
|
}
|
|
14557
|
+
function getHelpChildren(group, scope) {
|
|
14558
|
+
return getVisibleChildren(group, scope).filter((child) => {
|
|
14559
|
+
if (child.kind === "command") {
|
|
14560
|
+
return child.hidden !== true;
|
|
14561
|
+
}
|
|
14562
|
+
return true;
|
|
14563
|
+
});
|
|
14564
|
+
}
|
|
14552
14565
|
function findVisibleChild(group, token, scope) {
|
|
14553
14566
|
return getVisibleChildren(group, scope).find(
|
|
14554
14567
|
(child) => child.name === token || child.aliases.includes(token)
|
|
@@ -14695,6 +14708,26 @@ function describeHelpValueToken(schema, field) {
|
|
|
14695
14708
|
}
|
|
14696
14709
|
return describeFieldNameValueToken(field.displayPath, field.optionFlag) ?? "value";
|
|
14697
14710
|
}
|
|
14711
|
+
function formatCompactEnumSignatureToken(schema) {
|
|
14712
|
+
if (schema.kind !== "enum" || schema.values.length < 2 || schema.values.length > 3) {
|
|
14713
|
+
return void 0;
|
|
14714
|
+
}
|
|
14715
|
+
const tokens = schema.values.map((value) => String(value));
|
|
14716
|
+
const compact = tokens.every(
|
|
14717
|
+
(token) => token.length > 0 && token.length <= 24 && token.trim() === token && !token.includes("|") && !token.includes(" ") && !token.includes("\n") && !token.includes("\r") && !token.includes(" ")
|
|
14718
|
+
);
|
|
14719
|
+
return compact ? tokens.join("|") : void 0;
|
|
14720
|
+
}
|
|
14721
|
+
function formatCommandParameterFieldFlags(field, globalLongOptionFlags) {
|
|
14722
|
+
if (field.positionalIndex !== void 0 || field.schema.kind === "boolean") {
|
|
14723
|
+
return formatHelpFieldFlags(field, globalLongOptionFlags);
|
|
14724
|
+
}
|
|
14725
|
+
const enumToken = formatCompactEnumSignatureToken(field.schema);
|
|
14726
|
+
if (enumToken !== void 0) {
|
|
14727
|
+
return `${formatOptionFlags(field, globalLongOptionFlags)} ${enumToken}`;
|
|
14728
|
+
}
|
|
14729
|
+
return formatHelpFieldFlags(field, globalLongOptionFlags);
|
|
14730
|
+
}
|
|
14698
14731
|
function describeDynamicFieldType(field) {
|
|
14699
14732
|
if (field.schema.kind === "record") {
|
|
14700
14733
|
const valueSchema = unwrapOptional2(field.schema.value);
|
|
@@ -14862,7 +14895,7 @@ function formatCommandParameterTokens(command, casing, globalLongOptionFlags) {
|
|
|
14862
14895
|
const fields = assignPositionals(collected.fields, command.positional);
|
|
14863
14896
|
return fields.filter((field) => field.global !== true).map(
|
|
14864
14897
|
(field) => wrapOptionalCommandParameterToken(
|
|
14865
|
-
|
|
14898
|
+
formatCommandParameterFieldFlags(field, globalLongOptionFlags),
|
|
14866
14899
|
field.positionalIndex === void 0 && (field.optional || field.hasDefault)
|
|
14867
14900
|
)
|
|
14868
14901
|
).concat(
|
|
@@ -14876,7 +14909,7 @@ function formatCommandRowName(node, casing, globalLongOptionFlags) {
|
|
|
14876
14909
|
return name;
|
|
14877
14910
|
}
|
|
14878
14911
|
function formatCommandRows(group, scope, casing, globalLongOptionFlags) {
|
|
14879
|
-
return
|
|
14912
|
+
return getHelpChildren(group, scope).map((child) => ({
|
|
14880
14913
|
name: formatCommandRowName(child, casing, globalLongOptionFlags),
|
|
14881
14914
|
description: child.description ?? ""
|
|
14882
14915
|
}));
|
|
@@ -14920,7 +14953,7 @@ function collectSchemaGlobalFieldRows(group, scope, casing, globalLongOptionFlag
|
|
|
14920
14953
|
}
|
|
14921
14954
|
return;
|
|
14922
14955
|
}
|
|
14923
|
-
for (const child of
|
|
14956
|
+
for (const child of getHelpChildren(node, scope)) {
|
|
14924
14957
|
visit(child);
|
|
14925
14958
|
}
|
|
14926
14959
|
};
|
|
@@ -14943,6 +14976,17 @@ function buildUsageLine(breadcrumb, rootUsageName, suffix) {
|
|
|
14943
14976
|
const tokens = [rootUsageName, subPath, suffix].filter((segment) => segment.length > 0);
|
|
14944
14977
|
return tokens.join(" ");
|
|
14945
14978
|
}
|
|
14979
|
+
function formatGroupUsageSuffix(group, scope, casing, globalLongOptionFlags) {
|
|
14980
|
+
if (group.default !== void 0 && group.default.hidden === true && group.default.scope.includes(scope)) {
|
|
14981
|
+
const parameterTokens = formatCommandParameterTokens(
|
|
14982
|
+
group.default,
|
|
14983
|
+
casing,
|
|
14984
|
+
globalLongOptionFlags
|
|
14985
|
+
);
|
|
14986
|
+
return ["[command]", "[OPTIONS]", ...parameterTokens].join(" ");
|
|
14987
|
+
}
|
|
14988
|
+
return "[command] [OPTIONS]";
|
|
14989
|
+
}
|
|
14946
14990
|
function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUsageName, isRoot) {
|
|
14947
14991
|
const sections = [];
|
|
14948
14992
|
const globalLongOptionFlags = getGlobalLongOptionFlags(
|
|
@@ -14976,7 +15020,11 @@ ${builtInLine}`
|
|
|
14976
15020
|
return renderHelpDocument({
|
|
14977
15021
|
breadcrumb,
|
|
14978
15022
|
rootUsageName,
|
|
14979
|
-
usageLine: buildUsageLine(
|
|
15023
|
+
usageLine: buildUsageLine(
|
|
15024
|
+
breadcrumb,
|
|
15025
|
+
rootUsageName,
|
|
15026
|
+
formatGroupUsageSuffix(group, scope, casing, globalLongOptionFlags)
|
|
15027
|
+
),
|
|
14980
15028
|
description: group.description,
|
|
14981
15029
|
requiresAuth: group.requires?.auth === true,
|
|
14982
15030
|
sections
|
|
@@ -15085,6 +15133,8 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15085
15133
|
return null;
|
|
15086
15134
|
}
|
|
15087
15135
|
const command = new CommanderCommand(node.name);
|
|
15136
|
+
Reflect.set(command, "_toolcraftHidden", node.hidden);
|
|
15137
|
+
Reflect.set(command, "_toolcraftOriginalName", node.name);
|
|
15088
15138
|
const collected = collectFields(node.params, casing, globalLongOptionFlags);
|
|
15089
15139
|
const fields = assignPositionals(collected.fields, node.positional);
|
|
15090
15140
|
validateUniqueOptionFlags(fields, globalLongOptionFlags);
|
|
@@ -15128,6 +15178,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15128
15178
|
if (!isNodeVisibleInScope(node, "cli")) {
|
|
15129
15179
|
return null;
|
|
15130
15180
|
}
|
|
15181
|
+
const reservedChildNames = node.children.filter((child) => !isNodeVisibleInScope(child, "cli")).flatMap((child) => getNodeCommandNames(child));
|
|
15131
15182
|
const visibleChildren = node.children.map(
|
|
15132
15183
|
(child) => createNodeCommand(
|
|
15133
15184
|
child,
|
|
@@ -15140,6 +15191,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15140
15191
|
)
|
|
15141
15192
|
).filter((child) => child !== null);
|
|
15142
15193
|
const group = new CommanderCommand(node.name);
|
|
15194
|
+
Reflect.set(group, "_toolcraftReservedChildNames", reservedChildNames);
|
|
15143
15195
|
if (node.description !== void 0) {
|
|
15144
15196
|
group.description(node.description);
|
|
15145
15197
|
}
|
|
@@ -15154,7 +15206,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15154
15206
|
return group;
|
|
15155
15207
|
}
|
|
15156
15208
|
function addCommanderChild(parent, child, isDefault, siblingNames) {
|
|
15157
|
-
if (isDefault && child.name().length === 0) {
|
|
15209
|
+
if (isDefault && (child.name().length === 0 || isToolcraftHiddenCommander(child))) {
|
|
15158
15210
|
let internalName = "__toolcraft_default__";
|
|
15159
15211
|
let suffix = 2;
|
|
15160
15212
|
while (siblingNames.has(internalName)) {
|
|
@@ -15162,10 +15214,37 @@ function addCommanderChild(parent, child, isDefault, siblingNames) {
|
|
|
15162
15214
|
suffix += 1;
|
|
15163
15215
|
}
|
|
15164
15216
|
child.name(internalName);
|
|
15217
|
+
Reflect.set(
|
|
15218
|
+
parent,
|
|
15219
|
+
"_toolcraftHiddenDefaultNames",
|
|
15220
|
+
getToolcraftHiddenDefaultNames(parent).concat([
|
|
15221
|
+
...new Set([Reflect.get(child, "_toolcraftOriginalName"), ...child.aliases()].filter(
|
|
15222
|
+
(name) => typeof name === "string" && name.length > 0
|
|
15223
|
+
))
|
|
15224
|
+
])
|
|
15225
|
+
);
|
|
15165
15226
|
parent.addCommand(child, { hidden: true, isDefault: true });
|
|
15166
15227
|
return;
|
|
15167
15228
|
}
|
|
15168
|
-
|
|
15229
|
+
const options = {
|
|
15230
|
+
...isDefault ? { isDefault: true } : {},
|
|
15231
|
+
...isToolcraftHiddenCommander(child) ? { hidden: true } : {}
|
|
15232
|
+
};
|
|
15233
|
+
parent.addCommand(child, Object.keys(options).length > 0 ? options : void 0);
|
|
15234
|
+
}
|
|
15235
|
+
function isToolcraftHiddenCommander(command) {
|
|
15236
|
+
return Reflect.get(command, "_toolcraftHidden") === true;
|
|
15237
|
+
}
|
|
15238
|
+
function getToolcraftHiddenDefaultNames(command) {
|
|
15239
|
+
const value = Reflect.get(command, "_toolcraftHiddenDefaultNames");
|
|
15240
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
15241
|
+
}
|
|
15242
|
+
function getToolcraftReservedChildNames(command) {
|
|
15243
|
+
const value = Reflect.get(command, "_toolcraftReservedChildNames");
|
|
15244
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
15245
|
+
}
|
|
15246
|
+
function getNodeCommandNames(node) {
|
|
15247
|
+
return [node.name, ...node.aliases].filter((name) => name.length > 0);
|
|
15169
15248
|
}
|
|
15170
15249
|
function addGlobalOptions(command, presetsEnabled, controls) {
|
|
15171
15250
|
const options = [];
|
|
@@ -15327,6 +15406,37 @@ function resolveOutput(resolvedFlags) {
|
|
|
15327
15406
|
}
|
|
15328
15407
|
return "rich";
|
|
15329
15408
|
}
|
|
15409
|
+
function resolveOutputFromArgv(argv) {
|
|
15410
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
15411
|
+
const token = argv[index] ?? "";
|
|
15412
|
+
if (token === "--json") {
|
|
15413
|
+
return "json";
|
|
15414
|
+
}
|
|
15415
|
+
if (token === "--md" || token === "--markdown") {
|
|
15416
|
+
return "md";
|
|
15417
|
+
}
|
|
15418
|
+
if (token === "--output") {
|
|
15419
|
+
const value = argv[index + 1];
|
|
15420
|
+
if (value === "rich" || value === "md" || value === "json") {
|
|
15421
|
+
return value;
|
|
15422
|
+
}
|
|
15423
|
+
if (value === "markdown") {
|
|
15424
|
+
return "md";
|
|
15425
|
+
}
|
|
15426
|
+
continue;
|
|
15427
|
+
}
|
|
15428
|
+
if (token.startsWith("--output=")) {
|
|
15429
|
+
const value = token.slice("--output=".length);
|
|
15430
|
+
if (value === "rich" || value === "md" || value === "json") {
|
|
15431
|
+
return value;
|
|
15432
|
+
}
|
|
15433
|
+
if (value === "markdown") {
|
|
15434
|
+
return "md";
|
|
15435
|
+
}
|
|
15436
|
+
}
|
|
15437
|
+
}
|
|
15438
|
+
return "rich";
|
|
15439
|
+
}
|
|
15330
15440
|
var DESIGN_SYSTEM_OUTPUT_BY_MODE = {
|
|
15331
15441
|
rich: "terminal",
|
|
15332
15442
|
md: "markdown",
|
|
@@ -15848,6 +15958,44 @@ function renderApprovalDeclined(error3) {
|
|
|
15848
15958
|
logger2.error(error3.message);
|
|
15849
15959
|
process.exitCode = 1;
|
|
15850
15960
|
}
|
|
15961
|
+
function renderCliErrorPattern(pattern) {
|
|
15962
|
+
const logger2 = createLogger();
|
|
15963
|
+
if (pattern.kind === "usage") {
|
|
15964
|
+
logger2.error(
|
|
15965
|
+
appendUsagePointer(pattern.message, {
|
|
15966
|
+
rootUsageName: pattern.rootUsageName,
|
|
15967
|
+
commandPath: pattern.commandPath
|
|
15968
|
+
})
|
|
15969
|
+
);
|
|
15970
|
+
process.exitCode = 1;
|
|
15971
|
+
return;
|
|
15972
|
+
}
|
|
15973
|
+
if (pattern.kind === "runtime-user") {
|
|
15974
|
+
logger2.error(pattern.message);
|
|
15975
|
+
process.exitCode = 1;
|
|
15976
|
+
return;
|
|
15977
|
+
}
|
|
15978
|
+
if (pattern.kind === "toolcraft-bug") {
|
|
15979
|
+
logger2.error(
|
|
15980
|
+
`toolcraft hit an internal invariant: ${pattern.error.message}
|
|
15981
|
+
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.`
|
|
15982
|
+
);
|
|
15983
|
+
if (pattern.debugStackMode !== void 0 && pattern.error.stack) {
|
|
15984
|
+
process.stderr.write(`${formatDebugStack(pattern.error.stack, pattern.debugStackMode)}
|
|
15985
|
+
`);
|
|
15986
|
+
}
|
|
15987
|
+
process.exitCode = 1;
|
|
15988
|
+
return;
|
|
15989
|
+
}
|
|
15990
|
+
logger2.error(
|
|
15991
|
+
pattern.debugStackMode !== void 0 ? pattern.message : `${pattern.message} Use --debug for a stack trace.`
|
|
15992
|
+
);
|
|
15993
|
+
if (pattern.debugStackMode !== void 0 && pattern.stack !== void 0) {
|
|
15994
|
+
process.stderr.write(`${formatDebugStack(pattern.stack, pattern.debugStackMode)}
|
|
15995
|
+
`);
|
|
15996
|
+
}
|
|
15997
|
+
process.exitCode = 1;
|
|
15998
|
+
}
|
|
15851
15999
|
function validateServices(services) {
|
|
15852
16000
|
for (const name of Object.keys(services)) {
|
|
15853
16001
|
if (RESERVED_SERVICE_NAMES.has(name)) {
|
|
@@ -16768,79 +16916,79 @@ function renderHttpError(error3, options) {
|
|
|
16768
16916
|
`);
|
|
16769
16917
|
}
|
|
16770
16918
|
}
|
|
16771
|
-
function handleRunError(error3, options) {
|
|
16919
|
+
async function handleRunError(error3, options) {
|
|
16772
16920
|
const logger2 = createLogger();
|
|
16773
|
-
|
|
16774
|
-
|
|
16775
|
-
|
|
16776
|
-
|
|
16777
|
-
|
|
16778
|
-
|
|
16779
|
-
|
|
16780
|
-
|
|
16781
|
-
|
|
16782
|
-
|
|
16783
|
-
|
|
16784
|
-
|
|
16785
|
-
|
|
16786
|
-
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.`
|
|
16787
|
-
);
|
|
16788
|
-
if (options.debugStackMode !== void 0 && error3.stack) {
|
|
16789
|
-
process.stderr.write(`${formatDebugStack(error3.stack, options.debugStackMode)}
|
|
16790
|
-
`);
|
|
16791
|
-
}
|
|
16792
|
-
process.exitCode = 1;
|
|
16793
|
-
return;
|
|
16794
|
-
}
|
|
16795
|
-
if (error3 instanceof CommanderError2) {
|
|
16796
|
-
process.exitCode = error3.exitCode;
|
|
16797
|
-
if (error3.code === "commander.helpDisplayed" || error3.code === "commander.version") {
|
|
16921
|
+
await withOutputFormat2(options.output, async () => {
|
|
16922
|
+
if (error3 instanceof UserError) {
|
|
16923
|
+
renderCliErrorPattern(
|
|
16924
|
+
options.userErrorPattern === "usage" ? {
|
|
16925
|
+
kind: "usage",
|
|
16926
|
+
message: error3.message,
|
|
16927
|
+
rootUsageName: options.rootUsageName,
|
|
16928
|
+
commandPath: options.commandPath
|
|
16929
|
+
} : {
|
|
16930
|
+
kind: "runtime-user",
|
|
16931
|
+
message: error3.message
|
|
16932
|
+
}
|
|
16933
|
+
);
|
|
16798
16934
|
return;
|
|
16799
16935
|
}
|
|
16800
|
-
if (error3.
|
|
16801
|
-
|
|
16802
|
-
|
|
16803
|
-
|
|
16804
|
-
|
|
16805
|
-
|
|
16806
|
-
commandPath: options.commandPath
|
|
16807
|
-
}
|
|
16808
|
-
)
|
|
16809
|
-
);
|
|
16936
|
+
if (error3 instanceof Error && error3.name === "ToolcraftBugError") {
|
|
16937
|
+
renderCliErrorPattern({
|
|
16938
|
+
kind: "toolcraft-bug",
|
|
16939
|
+
error: error3,
|
|
16940
|
+
debugStackMode: options.debugStackMode
|
|
16941
|
+
});
|
|
16810
16942
|
return;
|
|
16811
16943
|
}
|
|
16812
|
-
if (error3
|
|
16813
|
-
|
|
16944
|
+
if (error3 instanceof CommanderError2) {
|
|
16945
|
+
process.exitCode = error3.exitCode;
|
|
16946
|
+
if (error3.code === "commander.helpDisplayed" || error3.code === "commander.version") {
|
|
16947
|
+
return;
|
|
16948
|
+
}
|
|
16949
|
+
if (error3.code === "commander.unknownCommand") {
|
|
16950
|
+
logger2.error(
|
|
16951
|
+
appendUsagePointer(
|
|
16952
|
+
formatUnknownCommandError(error3, options.program, options.argv ?? process.argv),
|
|
16953
|
+
{
|
|
16954
|
+
rootUsageName: options.rootUsageName,
|
|
16955
|
+
commandPath: options.commandPath
|
|
16956
|
+
}
|
|
16957
|
+
)
|
|
16958
|
+
);
|
|
16959
|
+
return;
|
|
16960
|
+
}
|
|
16961
|
+
if (error3.code === "commander.unknownOption") {
|
|
16962
|
+
const argv = options.argv ?? process.argv;
|
|
16963
|
+
logger2.error(
|
|
16964
|
+
appendUsagePointer(formatUnknownOptionError(error3, options.program, argv), {
|
|
16965
|
+
rootUsageName: options.rootUsageName,
|
|
16966
|
+
commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, argv)
|
|
16967
|
+
})
|
|
16968
|
+
);
|
|
16969
|
+
return;
|
|
16970
|
+
}
|
|
16814
16971
|
logger2.error(
|
|
16815
|
-
appendUsagePointer(
|
|
16972
|
+
appendUsagePointer(formatCommanderErrorMessage(error3), {
|
|
16816
16973
|
rootUsageName: options.rootUsageName,
|
|
16817
|
-
commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, argv)
|
|
16974
|
+
commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, options.argv ?? process.argv)
|
|
16818
16975
|
})
|
|
16819
16976
|
);
|
|
16820
16977
|
return;
|
|
16821
16978
|
}
|
|
16822
|
-
|
|
16823
|
-
|
|
16824
|
-
|
|
16825
|
-
|
|
16826
|
-
|
|
16827
|
-
);
|
|
16828
|
-
|
|
16829
|
-
|
|
16830
|
-
|
|
16831
|
-
|
|
16832
|
-
|
|
16833
|
-
|
|
16834
|
-
}
|
|
16835
|
-
const message2 = error3 instanceof Error ? error3.message : String(error3);
|
|
16836
|
-
logger2.error(
|
|
16837
|
-
options.debugStackMode !== void 0 ? message2 : `${message2} Use --debug for a stack trace.`
|
|
16838
|
-
);
|
|
16839
|
-
if (options.debugStackMode !== void 0 && error3 instanceof Error && error3.stack) {
|
|
16840
|
-
process.stderr.write(`${formatDebugStack(error3.stack, options.debugStackMode)}
|
|
16841
|
-
`);
|
|
16842
|
-
}
|
|
16843
|
-
process.exitCode = 1;
|
|
16979
|
+
if (isHttpErrorLike(error3)) {
|
|
16980
|
+
renderHttpError(error3, options);
|
|
16981
|
+
process.exitCode = 1;
|
|
16982
|
+
return;
|
|
16983
|
+
}
|
|
16984
|
+
const message2 = error3 instanceof Error ? error3.message : String(error3);
|
|
16985
|
+
renderCliErrorPattern({
|
|
16986
|
+
kind: "unexpected",
|
|
16987
|
+
message: message2,
|
|
16988
|
+
stack: error3 instanceof Error ? error3.stack : void 0,
|
|
16989
|
+
debugStackMode: options.debugStackMode
|
|
16990
|
+
});
|
|
16991
|
+
});
|
|
16844
16992
|
}
|
|
16845
16993
|
function formatCommanderErrorMessage(error3) {
|
|
16846
16994
|
return error3.message.startsWith("error:") ? error3.message : `error: ${error3.message}`;
|
|
@@ -17004,6 +17152,13 @@ function findUnknownCommanderCommand(program, argv) {
|
|
|
17004
17152
|
}
|
|
17005
17153
|
continue;
|
|
17006
17154
|
}
|
|
17155
|
+
if (getToolcraftHiddenDefaultNames(current).includes(token) || getToolcraftReservedChildNames(current).includes(token)) {
|
|
17156
|
+
return {
|
|
17157
|
+
input: token,
|
|
17158
|
+
currentCommand: current,
|
|
17159
|
+
commandPath: pathSegments.join(" ")
|
|
17160
|
+
};
|
|
17161
|
+
}
|
|
17007
17162
|
if (current.commands.length === 0 || getDefaultCommanderCommandName(current) !== void 0) {
|
|
17008
17163
|
return void 0;
|
|
17009
17164
|
}
|
|
@@ -17078,6 +17233,11 @@ async function runCLI(roots, options = {}) {
|
|
|
17078
17233
|
if (version !== void 0) {
|
|
17079
17234
|
program.version(version, "--version");
|
|
17080
17235
|
}
|
|
17236
|
+
Reflect.set(
|
|
17237
|
+
program,
|
|
17238
|
+
"_toolcraftReservedChildNames",
|
|
17239
|
+
root.children.filter((child) => !isNodeVisibleInScope(child, "cli")).flatMap((child) => getNodeCommandNames(child))
|
|
17240
|
+
);
|
|
17081
17241
|
let lastActionCommand;
|
|
17082
17242
|
let resolvedCommandPath = "";
|
|
17083
17243
|
let errorReportContext;
|
|
@@ -17152,13 +17312,15 @@ async function runCLI(roots, options = {}) {
|
|
|
17152
17312
|
process.stderr.write(`Saved error report to ${report.displayPath}
|
|
17153
17313
|
`);
|
|
17154
17314
|
}
|
|
17155
|
-
handleRunError(error3, {
|
|
17315
|
+
await handleRunError(error3, {
|
|
17156
17316
|
debugStackMode: resolvedFlags !== void 0 ? resolveDebugStackMode(resolvedFlags.debug) : getDebugStackModeFromArgv(process.argv),
|
|
17317
|
+
output: resolvedFlags !== void 0 ? resolveOutput(resolvedFlags) : resolveOutputFromArgv(process.argv),
|
|
17157
17318
|
verbose: resolvedFlags ? Boolean(resolvedFlags.verbose) : process.argv.includes("--verbose"),
|
|
17158
17319
|
program,
|
|
17159
17320
|
argv: process.argv,
|
|
17160
17321
|
rootUsageName,
|
|
17161
|
-
commandPath: resolvedCommandPath
|
|
17322
|
+
commandPath: resolvedCommandPath,
|
|
17323
|
+
userErrorPattern: errorReportContext?.params === void 0 ? "usage" : "runtime-user"
|
|
17162
17324
|
});
|
|
17163
17325
|
}
|
|
17164
17326
|
}
|