terminal-pilot 0.0.31 → 0.0.33
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 +253 -95
- package/dist/cli.js.map +3 -3
- 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 +13 -14
- package/dist/commands/index.js.map +3 -3
- package/dist/commands/install.js +13 -14
- package/dist/commands/install.js.map +3 -3
- package/dist/commands/installer.js +9 -14
- package/dist/commands/installer.js.map +3 -3
- 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 -1
- package/dist/commands/uninstall.js.map +3 -3
- 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 +253 -95
- package/dist/testing/cli-repl.js.map +3 -3
- package/dist/testing/qa-cli.js +253 -95
- package/dist/testing/qa-cli.js.map +3 -3
- package/package.json +2 -1
package/dist/testing/cli-repl.js
CHANGED
|
@@ -3742,6 +3742,7 @@ function createBaseCommand(config2) {
|
|
|
3742
3742
|
kind: "command",
|
|
3743
3743
|
name: config2.name,
|
|
3744
3744
|
description: config2.description,
|
|
3745
|
+
hidden: config2.hidden ?? false,
|
|
3745
3746
|
examples: cloneCommandExamples(config2.examples),
|
|
3746
3747
|
aliases: [...config2.aliases ?? []],
|
|
3747
3748
|
positional: [...config2.positional ?? []],
|
|
@@ -3758,6 +3759,7 @@ function createBaseCommand(config2) {
|
|
|
3758
3759
|
Object.defineProperty(command, commandConfigSymbol, {
|
|
3759
3760
|
value: {
|
|
3760
3761
|
scope: cloneScope(config2.scope),
|
|
3762
|
+
hidden: config2.hidden ?? false,
|
|
3761
3763
|
examples: cloneCommandExamples(config2.examples),
|
|
3762
3764
|
result: config2.result,
|
|
3763
3765
|
humanInLoop: config2.humanInLoop,
|
|
@@ -3808,6 +3810,7 @@ function materializeCommand(command, inherited) {
|
|
|
3808
3810
|
kind: "command",
|
|
3809
3811
|
name: command.name,
|
|
3810
3812
|
description: command.description,
|
|
3813
|
+
hidden: internal.hidden,
|
|
3811
3814
|
examples: cloneCommandExamples(internal.examples),
|
|
3812
3815
|
aliases: [...command.aliases],
|
|
3813
3816
|
positional: [...command.positional],
|
|
@@ -3824,6 +3827,7 @@ function materializeCommand(command, inherited) {
|
|
|
3824
3827
|
Object.defineProperty(materialized, commandConfigSymbol, {
|
|
3825
3828
|
value: {
|
|
3826
3829
|
scope: cloneScope(internal.scope),
|
|
3830
|
+
hidden: internal.hidden,
|
|
3827
3831
|
examples: cloneCommandExamples(internal.examples),
|
|
3828
3832
|
result: internal.result,
|
|
3829
3833
|
humanInLoop: internal.humanInLoop,
|
|
@@ -12542,6 +12546,7 @@ function createProxyCommand(parent, tool, commandName, connection) {
|
|
|
12542
12546
|
kind: "command",
|
|
12543
12547
|
name: commandName,
|
|
12544
12548
|
description: tool.description,
|
|
12549
|
+
hidden: false,
|
|
12545
12550
|
examples: [],
|
|
12546
12551
|
aliases: [],
|
|
12547
12552
|
positional: [],
|
|
@@ -14621,6 +14626,14 @@ function isNodeVisibleInScope(node, scope) {
|
|
|
14621
14626
|
function getVisibleChildren(group, scope) {
|
|
14622
14627
|
return group.children.filter((child) => isNodeVisibleInScope(child, scope));
|
|
14623
14628
|
}
|
|
14629
|
+
function getHelpChildren(group, scope) {
|
|
14630
|
+
return getVisibleChildren(group, scope).filter((child) => {
|
|
14631
|
+
if (child.kind === "command") {
|
|
14632
|
+
return child.hidden !== true;
|
|
14633
|
+
}
|
|
14634
|
+
return true;
|
|
14635
|
+
});
|
|
14636
|
+
}
|
|
14624
14637
|
function findVisibleChild(group, token, scope) {
|
|
14625
14638
|
return getVisibleChildren(group, scope).find(
|
|
14626
14639
|
(child) => child.name === token || child.aliases.includes(token)
|
|
@@ -14767,6 +14780,26 @@ function describeHelpValueToken(schema, field) {
|
|
|
14767
14780
|
}
|
|
14768
14781
|
return describeFieldNameValueToken(field.displayPath, field.optionFlag) ?? "value";
|
|
14769
14782
|
}
|
|
14783
|
+
function formatCompactEnumSignatureToken(schema) {
|
|
14784
|
+
if (schema.kind !== "enum" || schema.values.length < 2 || schema.values.length > 3) {
|
|
14785
|
+
return void 0;
|
|
14786
|
+
}
|
|
14787
|
+
const tokens = schema.values.map((value) => String(value));
|
|
14788
|
+
const compact = tokens.every(
|
|
14789
|
+
(token) => token.length > 0 && token.length <= 24 && token.trim() === token && !token.includes("|") && !token.includes(" ") && !token.includes("\n") && !token.includes("\r") && !token.includes(" ")
|
|
14790
|
+
);
|
|
14791
|
+
return compact ? tokens.join("|") : void 0;
|
|
14792
|
+
}
|
|
14793
|
+
function formatCommandParameterFieldFlags(field, globalLongOptionFlags) {
|
|
14794
|
+
if (field.positionalIndex !== void 0 || field.schema.kind === "boolean") {
|
|
14795
|
+
return formatHelpFieldFlags(field, globalLongOptionFlags);
|
|
14796
|
+
}
|
|
14797
|
+
const enumToken = formatCompactEnumSignatureToken(field.schema);
|
|
14798
|
+
if (enumToken !== void 0) {
|
|
14799
|
+
return `${formatOptionFlags(field, globalLongOptionFlags)} ${enumToken}`;
|
|
14800
|
+
}
|
|
14801
|
+
return formatHelpFieldFlags(field, globalLongOptionFlags);
|
|
14802
|
+
}
|
|
14770
14803
|
function describeDynamicFieldType(field) {
|
|
14771
14804
|
if (field.schema.kind === "record") {
|
|
14772
14805
|
const valueSchema = unwrapOptional2(field.schema.value);
|
|
@@ -14934,7 +14967,7 @@ function formatCommandParameterTokens(command, casing, globalLongOptionFlags) {
|
|
|
14934
14967
|
const fields = assignPositionals(collected.fields, command.positional);
|
|
14935
14968
|
return fields.filter((field) => field.global !== true).map(
|
|
14936
14969
|
(field) => wrapOptionalCommandParameterToken(
|
|
14937
|
-
|
|
14970
|
+
formatCommandParameterFieldFlags(field, globalLongOptionFlags),
|
|
14938
14971
|
field.positionalIndex === void 0 && (field.optional || field.hasDefault)
|
|
14939
14972
|
)
|
|
14940
14973
|
).concat(
|
|
@@ -14948,7 +14981,7 @@ function formatCommandRowName(node, casing, globalLongOptionFlags) {
|
|
|
14948
14981
|
return name;
|
|
14949
14982
|
}
|
|
14950
14983
|
function formatCommandRows(group, scope, casing, globalLongOptionFlags) {
|
|
14951
|
-
return
|
|
14984
|
+
return getHelpChildren(group, scope).map((child) => ({
|
|
14952
14985
|
name: formatCommandRowName(child, casing, globalLongOptionFlags),
|
|
14953
14986
|
description: child.description ?? ""
|
|
14954
14987
|
}));
|
|
@@ -14992,7 +15025,7 @@ function collectSchemaGlobalFieldRows(group, scope, casing, globalLongOptionFlag
|
|
|
14992
15025
|
}
|
|
14993
15026
|
return;
|
|
14994
15027
|
}
|
|
14995
|
-
for (const child of
|
|
15028
|
+
for (const child of getHelpChildren(node, scope)) {
|
|
14996
15029
|
visit(child);
|
|
14997
15030
|
}
|
|
14998
15031
|
};
|
|
@@ -15015,6 +15048,17 @@ function buildUsageLine(breadcrumb, rootUsageName, suffix) {
|
|
|
15015
15048
|
const tokens = [rootUsageName, subPath, suffix].filter((segment) => segment.length > 0);
|
|
15016
15049
|
return tokens.join(" ");
|
|
15017
15050
|
}
|
|
15051
|
+
function formatGroupUsageSuffix(group, scope, casing, globalLongOptionFlags) {
|
|
15052
|
+
if (group.default !== void 0 && group.default.hidden === true && group.default.scope.includes(scope)) {
|
|
15053
|
+
const parameterTokens = formatCommandParameterTokens(
|
|
15054
|
+
group.default,
|
|
15055
|
+
casing,
|
|
15056
|
+
globalLongOptionFlags
|
|
15057
|
+
);
|
|
15058
|
+
return ["[command]", "[OPTIONS]", ...parameterTokens].join(" ");
|
|
15059
|
+
}
|
|
15060
|
+
return "[command] [OPTIONS]";
|
|
15061
|
+
}
|
|
15018
15062
|
function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUsageName, isRoot) {
|
|
15019
15063
|
const sections = [];
|
|
15020
15064
|
const globalLongOptionFlags = getGlobalLongOptionFlags(
|
|
@@ -15048,7 +15092,11 @@ ${builtInLine}`
|
|
|
15048
15092
|
return renderHelpDocument({
|
|
15049
15093
|
breadcrumb,
|
|
15050
15094
|
rootUsageName,
|
|
15051
|
-
usageLine: buildUsageLine(
|
|
15095
|
+
usageLine: buildUsageLine(
|
|
15096
|
+
breadcrumb,
|
|
15097
|
+
rootUsageName,
|
|
15098
|
+
formatGroupUsageSuffix(group, scope, casing, globalLongOptionFlags)
|
|
15099
|
+
),
|
|
15052
15100
|
description: group.description,
|
|
15053
15101
|
requiresAuth: group.requires?.auth === true,
|
|
15054
15102
|
sections
|
|
@@ -15157,6 +15205,8 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15157
15205
|
return null;
|
|
15158
15206
|
}
|
|
15159
15207
|
const command = new CommanderCommand(node.name);
|
|
15208
|
+
Reflect.set(command, "_toolcraftHidden", node.hidden);
|
|
15209
|
+
Reflect.set(command, "_toolcraftOriginalName", node.name);
|
|
15160
15210
|
const collected = collectFields(node.params, casing, globalLongOptionFlags);
|
|
15161
15211
|
const fields = assignPositionals(collected.fields, node.positional);
|
|
15162
15212
|
validateUniqueOptionFlags(fields, globalLongOptionFlags);
|
|
@@ -15200,6 +15250,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15200
15250
|
if (!isNodeVisibleInScope(node, "cli")) {
|
|
15201
15251
|
return null;
|
|
15202
15252
|
}
|
|
15253
|
+
const reservedChildNames = node.children.filter((child) => !isNodeVisibleInScope(child, "cli")).flatMap((child) => getNodeCommandNames(child));
|
|
15203
15254
|
const visibleChildren = node.children.map(
|
|
15204
15255
|
(child) => createNodeCommand(
|
|
15205
15256
|
child,
|
|
@@ -15212,6 +15263,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15212
15263
|
)
|
|
15213
15264
|
).filter((child) => child !== null);
|
|
15214
15265
|
const group = new CommanderCommand(node.name);
|
|
15266
|
+
Reflect.set(group, "_toolcraftReservedChildNames", reservedChildNames);
|
|
15215
15267
|
if (node.description !== void 0) {
|
|
15216
15268
|
group.description(node.description);
|
|
15217
15269
|
}
|
|
@@ -15226,7 +15278,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
|
|
|
15226
15278
|
return group;
|
|
15227
15279
|
}
|
|
15228
15280
|
function addCommanderChild(parent, child, isDefault, siblingNames) {
|
|
15229
|
-
if (isDefault && child.name().length === 0) {
|
|
15281
|
+
if (isDefault && (child.name().length === 0 || isToolcraftHiddenCommander(child))) {
|
|
15230
15282
|
let internalName = "__toolcraft_default__";
|
|
15231
15283
|
let suffix = 2;
|
|
15232
15284
|
while (siblingNames.has(internalName)) {
|
|
@@ -15234,10 +15286,37 @@ function addCommanderChild(parent, child, isDefault, siblingNames) {
|
|
|
15234
15286
|
suffix += 1;
|
|
15235
15287
|
}
|
|
15236
15288
|
child.name(internalName);
|
|
15289
|
+
Reflect.set(
|
|
15290
|
+
parent,
|
|
15291
|
+
"_toolcraftHiddenDefaultNames",
|
|
15292
|
+
getToolcraftHiddenDefaultNames(parent).concat([
|
|
15293
|
+
...new Set([Reflect.get(child, "_toolcraftOriginalName"), ...child.aliases()].filter(
|
|
15294
|
+
(name) => typeof name === "string" && name.length > 0
|
|
15295
|
+
))
|
|
15296
|
+
])
|
|
15297
|
+
);
|
|
15237
15298
|
parent.addCommand(child, { hidden: true, isDefault: true });
|
|
15238
15299
|
return;
|
|
15239
15300
|
}
|
|
15240
|
-
|
|
15301
|
+
const options = {
|
|
15302
|
+
...isDefault ? { isDefault: true } : {},
|
|
15303
|
+
...isToolcraftHiddenCommander(child) ? { hidden: true } : {}
|
|
15304
|
+
};
|
|
15305
|
+
parent.addCommand(child, Object.keys(options).length > 0 ? options : void 0);
|
|
15306
|
+
}
|
|
15307
|
+
function isToolcraftHiddenCommander(command) {
|
|
15308
|
+
return Reflect.get(command, "_toolcraftHidden") === true;
|
|
15309
|
+
}
|
|
15310
|
+
function getToolcraftHiddenDefaultNames(command) {
|
|
15311
|
+
const value = Reflect.get(command, "_toolcraftHiddenDefaultNames");
|
|
15312
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
15313
|
+
}
|
|
15314
|
+
function getToolcraftReservedChildNames(command) {
|
|
15315
|
+
const value = Reflect.get(command, "_toolcraftReservedChildNames");
|
|
15316
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
15317
|
+
}
|
|
15318
|
+
function getNodeCommandNames(node) {
|
|
15319
|
+
return [node.name, ...node.aliases].filter((name) => name.length > 0);
|
|
15241
15320
|
}
|
|
15242
15321
|
function addGlobalOptions(command, presetsEnabled, controls) {
|
|
15243
15322
|
const options = [];
|
|
@@ -15399,6 +15478,37 @@ function resolveOutput(resolvedFlags) {
|
|
|
15399
15478
|
}
|
|
15400
15479
|
return "rich";
|
|
15401
15480
|
}
|
|
15481
|
+
function resolveOutputFromArgv(argv) {
|
|
15482
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
15483
|
+
const token = argv[index] ?? "";
|
|
15484
|
+
if (token === "--json") {
|
|
15485
|
+
return "json";
|
|
15486
|
+
}
|
|
15487
|
+
if (token === "--md" || token === "--markdown") {
|
|
15488
|
+
return "md";
|
|
15489
|
+
}
|
|
15490
|
+
if (token === "--output") {
|
|
15491
|
+
const value = argv[index + 1];
|
|
15492
|
+
if (value === "rich" || value === "md" || value === "json") {
|
|
15493
|
+
return value;
|
|
15494
|
+
}
|
|
15495
|
+
if (value === "markdown") {
|
|
15496
|
+
return "md";
|
|
15497
|
+
}
|
|
15498
|
+
continue;
|
|
15499
|
+
}
|
|
15500
|
+
if (token.startsWith("--output=")) {
|
|
15501
|
+
const value = token.slice("--output=".length);
|
|
15502
|
+
if (value === "rich" || value === "md" || value === "json") {
|
|
15503
|
+
return value;
|
|
15504
|
+
}
|
|
15505
|
+
if (value === "markdown") {
|
|
15506
|
+
return "md";
|
|
15507
|
+
}
|
|
15508
|
+
}
|
|
15509
|
+
}
|
|
15510
|
+
return "rich";
|
|
15511
|
+
}
|
|
15402
15512
|
var DESIGN_SYSTEM_OUTPUT_BY_MODE = {
|
|
15403
15513
|
rich: "terminal",
|
|
15404
15514
|
md: "markdown",
|
|
@@ -15920,6 +16030,44 @@ function renderApprovalDeclined(error3) {
|
|
|
15920
16030
|
logger2.error(error3.message);
|
|
15921
16031
|
process.exitCode = 1;
|
|
15922
16032
|
}
|
|
16033
|
+
function renderCliErrorPattern(pattern) {
|
|
16034
|
+
const logger2 = createLogger();
|
|
16035
|
+
if (pattern.kind === "usage") {
|
|
16036
|
+
logger2.error(
|
|
16037
|
+
appendUsagePointer(pattern.message, {
|
|
16038
|
+
rootUsageName: pattern.rootUsageName,
|
|
16039
|
+
commandPath: pattern.commandPath
|
|
16040
|
+
})
|
|
16041
|
+
);
|
|
16042
|
+
process.exitCode = 1;
|
|
16043
|
+
return;
|
|
16044
|
+
}
|
|
16045
|
+
if (pattern.kind === "runtime-user") {
|
|
16046
|
+
logger2.error(pattern.message);
|
|
16047
|
+
process.exitCode = 1;
|
|
16048
|
+
return;
|
|
16049
|
+
}
|
|
16050
|
+
if (pattern.kind === "toolcraft-bug") {
|
|
16051
|
+
logger2.error(
|
|
16052
|
+
`toolcraft hit an internal invariant: ${pattern.error.message}
|
|
16053
|
+
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.`
|
|
16054
|
+
);
|
|
16055
|
+
if (pattern.debugStackMode !== void 0 && pattern.error.stack) {
|
|
16056
|
+
process.stderr.write(`${formatDebugStack(pattern.error.stack, pattern.debugStackMode)}
|
|
16057
|
+
`);
|
|
16058
|
+
}
|
|
16059
|
+
process.exitCode = 1;
|
|
16060
|
+
return;
|
|
16061
|
+
}
|
|
16062
|
+
logger2.error(
|
|
16063
|
+
pattern.debugStackMode !== void 0 ? pattern.message : `${pattern.message} Use --debug for a stack trace.`
|
|
16064
|
+
);
|
|
16065
|
+
if (pattern.debugStackMode !== void 0 && pattern.stack !== void 0) {
|
|
16066
|
+
process.stderr.write(`${formatDebugStack(pattern.stack, pattern.debugStackMode)}
|
|
16067
|
+
`);
|
|
16068
|
+
}
|
|
16069
|
+
process.exitCode = 1;
|
|
16070
|
+
}
|
|
15923
16071
|
function validateServices(services) {
|
|
15924
16072
|
for (const name of Object.keys(services)) {
|
|
15925
16073
|
if (RESERVED_SERVICE_NAMES.has(name)) {
|
|
@@ -16840,79 +16988,79 @@ function renderHttpError(error3, options) {
|
|
|
16840
16988
|
`);
|
|
16841
16989
|
}
|
|
16842
16990
|
}
|
|
16843
|
-
function handleRunError(error3, options) {
|
|
16991
|
+
async function handleRunError(error3, options) {
|
|
16844
16992
|
const logger2 = createLogger();
|
|
16845
|
-
|
|
16846
|
-
|
|
16847
|
-
|
|
16848
|
-
|
|
16849
|
-
|
|
16850
|
-
|
|
16851
|
-
|
|
16852
|
-
|
|
16853
|
-
|
|
16854
|
-
|
|
16855
|
-
|
|
16856
|
-
|
|
16857
|
-
|
|
16858
|
-
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.`
|
|
16859
|
-
);
|
|
16860
|
-
if (options.debugStackMode !== void 0 && error3.stack) {
|
|
16861
|
-
process.stderr.write(`${formatDebugStack(error3.stack, options.debugStackMode)}
|
|
16862
|
-
`);
|
|
16863
|
-
}
|
|
16864
|
-
process.exitCode = 1;
|
|
16865
|
-
return;
|
|
16866
|
-
}
|
|
16867
|
-
if (error3 instanceof CommanderError2) {
|
|
16868
|
-
process.exitCode = error3.exitCode;
|
|
16869
|
-
if (error3.code === "commander.helpDisplayed" || error3.code === "commander.version") {
|
|
16993
|
+
await withOutputFormat2(options.output, async () => {
|
|
16994
|
+
if (error3 instanceof UserError) {
|
|
16995
|
+
renderCliErrorPattern(
|
|
16996
|
+
options.userErrorPattern === "usage" ? {
|
|
16997
|
+
kind: "usage",
|
|
16998
|
+
message: error3.message,
|
|
16999
|
+
rootUsageName: options.rootUsageName,
|
|
17000
|
+
commandPath: options.commandPath
|
|
17001
|
+
} : {
|
|
17002
|
+
kind: "runtime-user",
|
|
17003
|
+
message: error3.message
|
|
17004
|
+
}
|
|
17005
|
+
);
|
|
16870
17006
|
return;
|
|
16871
17007
|
}
|
|
16872
|
-
if (error3.
|
|
16873
|
-
|
|
16874
|
-
|
|
16875
|
-
|
|
16876
|
-
|
|
16877
|
-
|
|
16878
|
-
commandPath: options.commandPath
|
|
16879
|
-
}
|
|
16880
|
-
)
|
|
16881
|
-
);
|
|
17008
|
+
if (error3 instanceof Error && error3.name === "ToolcraftBugError") {
|
|
17009
|
+
renderCliErrorPattern({
|
|
17010
|
+
kind: "toolcraft-bug",
|
|
17011
|
+
error: error3,
|
|
17012
|
+
debugStackMode: options.debugStackMode
|
|
17013
|
+
});
|
|
16882
17014
|
return;
|
|
16883
17015
|
}
|
|
16884
|
-
if (error3
|
|
16885
|
-
|
|
17016
|
+
if (error3 instanceof CommanderError2) {
|
|
17017
|
+
process.exitCode = error3.exitCode;
|
|
17018
|
+
if (error3.code === "commander.helpDisplayed" || error3.code === "commander.version") {
|
|
17019
|
+
return;
|
|
17020
|
+
}
|
|
17021
|
+
if (error3.code === "commander.unknownCommand") {
|
|
17022
|
+
logger2.error(
|
|
17023
|
+
appendUsagePointer(
|
|
17024
|
+
formatUnknownCommandError(error3, options.program, options.argv ?? process.argv),
|
|
17025
|
+
{
|
|
17026
|
+
rootUsageName: options.rootUsageName,
|
|
17027
|
+
commandPath: options.commandPath
|
|
17028
|
+
}
|
|
17029
|
+
)
|
|
17030
|
+
);
|
|
17031
|
+
return;
|
|
17032
|
+
}
|
|
17033
|
+
if (error3.code === "commander.unknownOption") {
|
|
17034
|
+
const argv = options.argv ?? process.argv;
|
|
17035
|
+
logger2.error(
|
|
17036
|
+
appendUsagePointer(formatUnknownOptionError(error3, options.program, argv), {
|
|
17037
|
+
rootUsageName: options.rootUsageName,
|
|
17038
|
+
commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, argv)
|
|
17039
|
+
})
|
|
17040
|
+
);
|
|
17041
|
+
return;
|
|
17042
|
+
}
|
|
16886
17043
|
logger2.error(
|
|
16887
|
-
appendUsagePointer(
|
|
17044
|
+
appendUsagePointer(formatCommanderErrorMessage(error3), {
|
|
16888
17045
|
rootUsageName: options.rootUsageName,
|
|
16889
|
-
commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, argv)
|
|
17046
|
+
commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, options.argv ?? process.argv)
|
|
16890
17047
|
})
|
|
16891
17048
|
);
|
|
16892
17049
|
return;
|
|
16893
17050
|
}
|
|
16894
|
-
|
|
16895
|
-
|
|
16896
|
-
|
|
16897
|
-
|
|
16898
|
-
|
|
16899
|
-
);
|
|
16900
|
-
|
|
16901
|
-
|
|
16902
|
-
|
|
16903
|
-
|
|
16904
|
-
|
|
16905
|
-
|
|
16906
|
-
}
|
|
16907
|
-
const message2 = error3 instanceof Error ? error3.message : String(error3);
|
|
16908
|
-
logger2.error(
|
|
16909
|
-
options.debugStackMode !== void 0 ? message2 : `${message2} Use --debug for a stack trace.`
|
|
16910
|
-
);
|
|
16911
|
-
if (options.debugStackMode !== void 0 && error3 instanceof Error && error3.stack) {
|
|
16912
|
-
process.stderr.write(`${formatDebugStack(error3.stack, options.debugStackMode)}
|
|
16913
|
-
`);
|
|
16914
|
-
}
|
|
16915
|
-
process.exitCode = 1;
|
|
17051
|
+
if (isHttpErrorLike(error3)) {
|
|
17052
|
+
renderHttpError(error3, options);
|
|
17053
|
+
process.exitCode = 1;
|
|
17054
|
+
return;
|
|
17055
|
+
}
|
|
17056
|
+
const message2 = error3 instanceof Error ? error3.message : String(error3);
|
|
17057
|
+
renderCliErrorPattern({
|
|
17058
|
+
kind: "unexpected",
|
|
17059
|
+
message: message2,
|
|
17060
|
+
stack: error3 instanceof Error ? error3.stack : void 0,
|
|
17061
|
+
debugStackMode: options.debugStackMode
|
|
17062
|
+
});
|
|
17063
|
+
});
|
|
16916
17064
|
}
|
|
16917
17065
|
function formatCommanderErrorMessage(error3) {
|
|
16918
17066
|
return error3.message.startsWith("error:") ? error3.message : `error: ${error3.message}`;
|
|
@@ -17076,6 +17224,13 @@ function findUnknownCommanderCommand(program, argv) {
|
|
|
17076
17224
|
}
|
|
17077
17225
|
continue;
|
|
17078
17226
|
}
|
|
17227
|
+
if (getToolcraftHiddenDefaultNames(current).includes(token) || getToolcraftReservedChildNames(current).includes(token)) {
|
|
17228
|
+
return {
|
|
17229
|
+
input: token,
|
|
17230
|
+
currentCommand: current,
|
|
17231
|
+
commandPath: pathSegments.join(" ")
|
|
17232
|
+
};
|
|
17233
|
+
}
|
|
17079
17234
|
if (current.commands.length === 0 || getDefaultCommanderCommandName(current) !== void 0) {
|
|
17080
17235
|
return void 0;
|
|
17081
17236
|
}
|
|
@@ -17112,15 +17267,16 @@ function configureCommanderSuggestionOutput(command) {
|
|
|
17112
17267
|
}
|
|
17113
17268
|
async function runCLI(roots, options = {}) {
|
|
17114
17269
|
enableSourceMaps();
|
|
17115
|
-
const
|
|
17270
|
+
const argv = [...options.argv ?? process.argv];
|
|
17271
|
+
const normalizedRoot = normalizeRoots(roots, argv);
|
|
17116
17272
|
const root = options.approvals === true ? mergeApprovalsGroup(normalizedRoot) : normalizedRoot;
|
|
17117
17273
|
await resolveMcpProxies(root, { projectRoot: options.projectRoot });
|
|
17118
17274
|
const casing = options.casing ?? "kebab";
|
|
17119
17275
|
const services = options.services ?? {};
|
|
17120
17276
|
const runtimeOptions = options.humanInLoop ?? {};
|
|
17121
17277
|
const runtimeFetch = options.fetch ?? globalThis.fetch;
|
|
17122
|
-
const version = options.version ?? findEntrypointPackageMetadata(
|
|
17123
|
-
const rootUsageName = options.rootUsageName ?? inferProgramName(
|
|
17278
|
+
const version = options.version ?? findEntrypointPackageMetadata(argv[1])?.version;
|
|
17279
|
+
const rootUsageName = options.rootUsageName ?? inferProgramName(argv);
|
|
17124
17280
|
const controls = resolveCLIControls(options.controls);
|
|
17125
17281
|
const servicesWithBuiltIns = {
|
|
17126
17282
|
...services,
|
|
@@ -17131,8 +17287,8 @@ async function runCLI(roots, options = {}) {
|
|
|
17131
17287
|
apiVersion: options.apiVersion
|
|
17132
17288
|
};
|
|
17133
17289
|
validateServices(services);
|
|
17134
|
-
if (hasHelpFlag(
|
|
17135
|
-
await renderGeneratedHelp(root,
|
|
17290
|
+
if (hasHelpFlag(argv)) {
|
|
17291
|
+
await renderGeneratedHelp(root, argv, { ...options, version });
|
|
17136
17292
|
return;
|
|
17137
17293
|
}
|
|
17138
17294
|
const program = new CommanderCommand();
|
|
@@ -17150,6 +17306,11 @@ async function runCLI(roots, options = {}) {
|
|
|
17150
17306
|
if (version !== void 0) {
|
|
17151
17307
|
program.version(version, "--version");
|
|
17152
17308
|
}
|
|
17309
|
+
Reflect.set(
|
|
17310
|
+
program,
|
|
17311
|
+
"_toolcraftReservedChildNames",
|
|
17312
|
+
root.children.filter((child) => !isNodeVisibleInScope(child, "cli")).flatMap((child) => getNodeCommandNames(child))
|
|
17313
|
+
);
|
|
17153
17314
|
let lastActionCommand;
|
|
17154
17315
|
let resolvedCommandPath = "";
|
|
17155
17316
|
let errorReportContext;
|
|
@@ -17186,7 +17347,7 @@ async function runCLI(roots, options = {}) {
|
|
|
17186
17347
|
addCommanderChild(program, command, isDefaultChild, rootChildNames);
|
|
17187
17348
|
}
|
|
17188
17349
|
configureCommanderSuggestionOutput(program);
|
|
17189
|
-
const unknownCommand = findUnknownCommanderCommand(program,
|
|
17350
|
+
const unknownCommand = findUnknownCommanderCommand(program, argv);
|
|
17190
17351
|
if (unknownCommand !== void 0) {
|
|
17191
17352
|
createLogger().error(
|
|
17192
17353
|
appendUsagePointer(
|
|
@@ -17201,7 +17362,7 @@ async function runCLI(roots, options = {}) {
|
|
|
17201
17362
|
return;
|
|
17202
17363
|
}
|
|
17203
17364
|
try {
|
|
17204
|
-
await program.parseAsync(
|
|
17365
|
+
await program.parseAsync(argv);
|
|
17205
17366
|
} catch (error3) {
|
|
17206
17367
|
if (error3 instanceof ApprovalDeclinedError) {
|
|
17207
17368
|
renderApprovalDeclined(error3);
|
|
@@ -17209,7 +17370,7 @@ async function runCLI(roots, options = {}) {
|
|
|
17209
17370
|
}
|
|
17210
17371
|
const resolvedFlags = lastActionCommand ? getResolvedFlags(lastActionCommand) : void 0;
|
|
17211
17372
|
const report = await writeErrorReport({
|
|
17212
|
-
argv
|
|
17373
|
+
argv,
|
|
17213
17374
|
command: errorReportContext?.command,
|
|
17214
17375
|
commandPath: errorReportContext?.commandPath ?? resolvedCommandPath,
|
|
17215
17376
|
env: process.env,
|
|
@@ -17224,13 +17385,15 @@ async function runCLI(roots, options = {}) {
|
|
|
17224
17385
|
process.stderr.write(`Saved error report to ${report.displayPath}
|
|
17225
17386
|
`);
|
|
17226
17387
|
}
|
|
17227
|
-
handleRunError(error3, {
|
|
17228
|
-
debugStackMode: resolvedFlags !== void 0 ? resolveDebugStackMode(resolvedFlags.debug) : getDebugStackModeFromArgv(
|
|
17229
|
-
|
|
17388
|
+
await handleRunError(error3, {
|
|
17389
|
+
debugStackMode: resolvedFlags !== void 0 ? resolveDebugStackMode(resolvedFlags.debug) : getDebugStackModeFromArgv(argv),
|
|
17390
|
+
output: resolvedFlags !== void 0 ? resolveOutput(resolvedFlags) : resolveOutputFromArgv(argv),
|
|
17391
|
+
verbose: resolvedFlags ? Boolean(resolvedFlags.verbose) : argv.includes("--verbose"),
|
|
17230
17392
|
program,
|
|
17231
|
-
argv
|
|
17393
|
+
argv,
|
|
17232
17394
|
rootUsageName,
|
|
17233
|
-
commandPath: resolvedCommandPath
|
|
17395
|
+
commandPath: resolvedCommandPath,
|
|
17396
|
+
userErrorPattern: errorReportContext?.params === void 0 ? "usage" : "runtime-user"
|
|
17234
17397
|
});
|
|
17235
17398
|
}
|
|
17236
17399
|
}
|
|
@@ -20527,7 +20690,6 @@ import path22 from "node:path";
|
|
|
20527
20690
|
import os3 from "node:os";
|
|
20528
20691
|
import path23 from "node:path";
|
|
20529
20692
|
import * as nodeFs2 from "node:fs/promises";
|
|
20530
|
-
import { readFile as readFile7 } from "node:fs/promises";
|
|
20531
20693
|
var DEFAULT_INSTALL_AGENT = "claude-code";
|
|
20532
20694
|
var DEFAULT_INSTALL_SCOPE = "local";
|
|
20533
20695
|
var TERMINAL_PILOT_SKILL_NAME = "terminal-pilot";
|
|
@@ -20570,19 +20732,15 @@ async function loadTerminalPilotTemplate() {
|
|
|
20570
20732
|
if (terminalPilotTemplateCache !== void 0) {
|
|
20571
20733
|
return terminalPilotTemplateCache;
|
|
20572
20734
|
}
|
|
20573
|
-
|
|
20574
|
-
|
|
20575
|
-
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
} catch (error3) {
|
|
20583
|
-
if (!isNotFoundError2(error3)) {
|
|
20584
|
-
throw error3;
|
|
20585
|
-
}
|
|
20735
|
+
try {
|
|
20736
|
+
terminalPilotTemplateCache = await nodeFs2.readFile(
|
|
20737
|
+
new URL("../templates/terminal-pilot.md", import.meta.url),
|
|
20738
|
+
"utf8"
|
|
20739
|
+
);
|
|
20740
|
+
return terminalPilotTemplateCache;
|
|
20741
|
+
} catch (error3) {
|
|
20742
|
+
if (!isNotFoundError2(error3)) {
|
|
20743
|
+
throw error3;
|
|
20586
20744
|
}
|
|
20587
20745
|
}
|
|
20588
20746
|
throw new UserError("terminal-pilot skill template is missing.");
|