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.
Files changed (44) hide show
  1. package/dist/cli.js +253 -95
  2. package/dist/cli.js.map +3 -3
  3. package/dist/commands/close-session.js +4 -0
  4. package/dist/commands/close-session.js.map +2 -2
  5. package/dist/commands/create-session.js +4 -0
  6. package/dist/commands/create-session.js.map +2 -2
  7. package/dist/commands/fill.js +4 -0
  8. package/dist/commands/fill.js.map +2 -2
  9. package/dist/commands/get-session.js +4 -0
  10. package/dist/commands/get-session.js.map +2 -2
  11. package/dist/commands/index.js +13 -14
  12. package/dist/commands/index.js.map +3 -3
  13. package/dist/commands/install.js +13 -14
  14. package/dist/commands/install.js.map +3 -3
  15. package/dist/commands/installer.js +9 -14
  16. package/dist/commands/installer.js.map +3 -3
  17. package/dist/commands/list-sessions.js +4 -0
  18. package/dist/commands/list-sessions.js.map +2 -2
  19. package/dist/commands/press-key.js +4 -0
  20. package/dist/commands/press-key.js.map +2 -2
  21. package/dist/commands/read-history.js +4 -0
  22. package/dist/commands/read-history.js.map +2 -2
  23. package/dist/commands/read-screen.js +4 -0
  24. package/dist/commands/read-screen.js.map +2 -2
  25. package/dist/commands/resize.js +4 -0
  26. package/dist/commands/resize.js.map +2 -2
  27. package/dist/commands/runtime.js.map +1 -1
  28. package/dist/commands/screenshot.js +4 -0
  29. package/dist/commands/screenshot.js.map +2 -2
  30. package/dist/commands/send-signal.js +4 -0
  31. package/dist/commands/send-signal.js.map +2 -2
  32. package/dist/commands/type.js +4 -0
  33. package/dist/commands/type.js.map +2 -2
  34. package/dist/commands/uninstall.js +4 -1
  35. package/dist/commands/uninstall.js.map +3 -3
  36. package/dist/commands/wait-for-exit.js +4 -0
  37. package/dist/commands/wait-for-exit.js.map +2 -2
  38. package/dist/commands/wait-for.js +4 -0
  39. package/dist/commands/wait-for.js.map +2 -2
  40. package/dist/testing/cli-repl.js +253 -95
  41. package/dist/testing/cli-repl.js.map +3 -3
  42. package/dist/testing/qa-cli.js +253 -95
  43. package/dist/testing/qa-cli.js.map +3 -3
  44. package/package.json +2 -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
- formatHelpFieldFlags(field, globalLongOptionFlags),
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 getVisibleChildren(group, scope).map((child) => ({
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 getVisibleChildren(node, scope)) {
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(breadcrumb, rootUsageName, "[command] [OPTIONS]"),
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
- parent.addCommand(child, isDefault ? { isDefault: true } : void 0);
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
- if (error3 instanceof UserError) {
16774
- logger2.error(
16775
- appendUsagePointer(error3.message, {
16776
- rootUsageName: options.rootUsageName,
16777
- commandPath: options.commandPath
16778
- })
16779
- );
16780
- process.exitCode = 1;
16781
- return;
16782
- }
16783
- if (error3 instanceof Error && error3.name === "ToolcraftBugError") {
16784
- logger2.error(
16785
- `toolcraft hit an internal invariant: ${error3.message}
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.code === "commander.unknownCommand") {
16801
- logger2.error(
16802
- appendUsagePointer(
16803
- formatUnknownCommandError(error3, options.program, options.argv ?? process.argv),
16804
- {
16805
- rootUsageName: options.rootUsageName,
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.code === "commander.unknownOption") {
16813
- const argv = options.argv ?? process.argv;
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(formatUnknownOptionError(error3, options.program, argv), {
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
- logger2.error(
16823
- appendUsagePointer(formatCommanderErrorMessage(error3), {
16824
- rootUsageName: options.rootUsageName,
16825
- commandPath: options.commandPath.length > 0 ? options.commandPath : findCurrentCommanderCommandPath(options.program, options.argv ?? process.argv)
16826
- })
16827
- );
16828
- return;
16829
- }
16830
- if (isHttpErrorLike(error3)) {
16831
- renderHttpError(error3, options);
16832
- process.exitCode = 1;
16833
- return;
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
  }
@@ -17040,15 +17195,16 @@ function configureCommanderSuggestionOutput(command) {
17040
17195
  }
17041
17196
  async function runCLI(roots, options = {}) {
17042
17197
  enableSourceMaps();
17043
- const normalizedRoot = normalizeRoots(roots, process.argv);
17198
+ const argv = [...options.argv ?? process.argv];
17199
+ const normalizedRoot = normalizeRoots(roots, argv);
17044
17200
  const root = options.approvals === true ? mergeApprovalsGroup(normalizedRoot) : normalizedRoot;
17045
17201
  await resolveMcpProxies(root, { projectRoot: options.projectRoot });
17046
17202
  const casing = options.casing ?? "kebab";
17047
17203
  const services = options.services ?? {};
17048
17204
  const runtimeOptions = options.humanInLoop ?? {};
17049
17205
  const runtimeFetch = options.fetch ?? globalThis.fetch;
17050
- const version = options.version ?? findEntrypointPackageMetadata(process.argv[1])?.version;
17051
- const rootUsageName = options.rootUsageName ?? inferProgramName(process.argv);
17206
+ const version = options.version ?? findEntrypointPackageMetadata(argv[1])?.version;
17207
+ const rootUsageName = options.rootUsageName ?? inferProgramName(argv);
17052
17208
  const controls = resolveCLIControls(options.controls);
17053
17209
  const servicesWithBuiltIns = {
17054
17210
  ...services,
@@ -17059,8 +17215,8 @@ async function runCLI(roots, options = {}) {
17059
17215
  apiVersion: options.apiVersion
17060
17216
  };
17061
17217
  validateServices(services);
17062
- if (hasHelpFlag(process.argv)) {
17063
- await renderGeneratedHelp(root, process.argv, { ...options, version });
17218
+ if (hasHelpFlag(argv)) {
17219
+ await renderGeneratedHelp(root, argv, { ...options, version });
17064
17220
  return;
17065
17221
  }
17066
17222
  const program = new CommanderCommand();
@@ -17078,6 +17234,11 @@ async function runCLI(roots, options = {}) {
17078
17234
  if (version !== void 0) {
17079
17235
  program.version(version, "--version");
17080
17236
  }
17237
+ Reflect.set(
17238
+ program,
17239
+ "_toolcraftReservedChildNames",
17240
+ root.children.filter((child) => !isNodeVisibleInScope(child, "cli")).flatMap((child) => getNodeCommandNames(child))
17241
+ );
17081
17242
  let lastActionCommand;
17082
17243
  let resolvedCommandPath = "";
17083
17244
  let errorReportContext;
@@ -17114,7 +17275,7 @@ async function runCLI(roots, options = {}) {
17114
17275
  addCommanderChild(program, command, isDefaultChild, rootChildNames);
17115
17276
  }
17116
17277
  configureCommanderSuggestionOutput(program);
17117
- const unknownCommand = findUnknownCommanderCommand(program, process.argv);
17278
+ const unknownCommand = findUnknownCommanderCommand(program, argv);
17118
17279
  if (unknownCommand !== void 0) {
17119
17280
  createLogger().error(
17120
17281
  appendUsagePointer(
@@ -17129,7 +17290,7 @@ async function runCLI(roots, options = {}) {
17129
17290
  return;
17130
17291
  }
17131
17292
  try {
17132
- await program.parseAsync(process.argv);
17293
+ await program.parseAsync(argv);
17133
17294
  } catch (error3) {
17134
17295
  if (error3 instanceof ApprovalDeclinedError) {
17135
17296
  renderApprovalDeclined(error3);
@@ -17137,7 +17298,7 @@ async function runCLI(roots, options = {}) {
17137
17298
  }
17138
17299
  const resolvedFlags = lastActionCommand ? getResolvedFlags(lastActionCommand) : void 0;
17139
17300
  const report = await writeErrorReport({
17140
- argv: process.argv,
17301
+ argv,
17141
17302
  command: errorReportContext?.command,
17142
17303
  commandPath: errorReportContext?.commandPath ?? resolvedCommandPath,
17143
17304
  env: process.env,
@@ -17152,13 +17313,15 @@ async function runCLI(roots, options = {}) {
17152
17313
  process.stderr.write(`Saved error report to ${report.displayPath}
17153
17314
  `);
17154
17315
  }
17155
- handleRunError(error3, {
17156
- debugStackMode: resolvedFlags !== void 0 ? resolveDebugStackMode(resolvedFlags.debug) : getDebugStackModeFromArgv(process.argv),
17157
- verbose: resolvedFlags ? Boolean(resolvedFlags.verbose) : process.argv.includes("--verbose"),
17316
+ await handleRunError(error3, {
17317
+ debugStackMode: resolvedFlags !== void 0 ? resolveDebugStackMode(resolvedFlags.debug) : getDebugStackModeFromArgv(argv),
17318
+ output: resolvedFlags !== void 0 ? resolveOutput(resolvedFlags) : resolveOutputFromArgv(argv),
17319
+ verbose: resolvedFlags ? Boolean(resolvedFlags.verbose) : argv.includes("--verbose"),
17158
17320
  program,
17159
- argv: process.argv,
17321
+ argv,
17160
17322
  rootUsageName,
17161
- commandPath: resolvedCommandPath
17323
+ commandPath: resolvedCommandPath,
17324
+ userErrorPattern: errorReportContext?.params === void 0 ? "usage" : "runtime-user"
17162
17325
  });
17163
17326
  }
17164
17327
  }
@@ -20521,7 +20684,6 @@ import path22 from "node:path";
20521
20684
  import os3 from "node:os";
20522
20685
  import path23 from "node:path";
20523
20686
  import * as nodeFs2 from "node:fs/promises";
20524
- import { readFile as readFile7 } from "node:fs/promises";
20525
20687
  var DEFAULT_INSTALL_AGENT = "claude-code";
20526
20688
  var DEFAULT_INSTALL_SCOPE = "local";
20527
20689
  var TERMINAL_PILOT_SKILL_NAME = "terminal-pilot";
@@ -20564,19 +20726,15 @@ async function loadTerminalPilotTemplate() {
20564
20726
  if (terminalPilotTemplateCache !== void 0) {
20565
20727
  return terminalPilotTemplateCache;
20566
20728
  }
20567
- const candidates = [
20568
- new URL("./templates/terminal-pilot.md", import.meta.url),
20569
- new URL("../templates/terminal-pilot.md", import.meta.url),
20570
- new URL("../../../agent-skill-config/src/templates/terminal-pilot.md", import.meta.url)
20571
- ];
20572
- for (const candidate of candidates) {
20573
- try {
20574
- terminalPilotTemplateCache = await readFile7(candidate, "utf8");
20575
- return terminalPilotTemplateCache;
20576
- } catch (error3) {
20577
- if (!isNotFoundError2(error3)) {
20578
- throw error3;
20579
- }
20729
+ try {
20730
+ terminalPilotTemplateCache = await nodeFs2.readFile(
20731
+ new URL("../templates/terminal-pilot.md", import.meta.url),
20732
+ "utf8"
20733
+ );
20734
+ return terminalPilotTemplateCache;
20735
+ } catch (error3) {
20736
+ if (!isNotFoundError2(error3)) {
20737
+ throw error3;
20580
20738
  }
20581
20739
  }
20582
20740
  throw new UserError("terminal-pilot skill template is missing.");