toolcraft 0.0.52 → 0.0.54

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 CHANGED
@@ -735,6 +735,14 @@ function isNodeVisibleInScope(node, scope) {
735
735
  function getVisibleChildren(group, scope) {
736
736
  return group.children.filter((child) => isNodeVisibleInScope(child, scope));
737
737
  }
738
+ function getHelpChildren(group, scope) {
739
+ return getVisibleChildren(group, scope).filter((child) => {
740
+ if (child.kind === "command") {
741
+ return child.hidden !== true;
742
+ }
743
+ return true;
744
+ });
745
+ }
738
746
  function findVisibleChild(group, token, scope) {
739
747
  return getVisibleChildren(group, scope).find((child) => child.name === token || child.aliases.includes(token));
740
748
  }
@@ -879,6 +887,31 @@ function describeHelpValueToken(schema, field) {
879
887
  }
880
888
  return describeFieldNameValueToken(field.displayPath, field.optionFlag) ?? "value";
881
889
  }
890
+ function formatCompactEnumSignatureToken(schema) {
891
+ if (schema.kind !== "enum" || schema.values.length < 2 || schema.values.length > 3) {
892
+ return undefined;
893
+ }
894
+ const tokens = schema.values.map((value) => String(value));
895
+ const compact = tokens.every((token) => token.length > 0 &&
896
+ token.length <= 24 &&
897
+ token.trim() === token &&
898
+ !token.includes("|") &&
899
+ !token.includes("\t") &&
900
+ !token.includes("\n") &&
901
+ !token.includes("\r") &&
902
+ !token.includes(" "));
903
+ return compact ? tokens.join("|") : undefined;
904
+ }
905
+ function formatCommandParameterFieldFlags(field, globalLongOptionFlags) {
906
+ if (field.positionalIndex !== undefined || field.schema.kind === "boolean") {
907
+ return formatHelpFieldFlags(field, globalLongOptionFlags);
908
+ }
909
+ const enumToken = formatCompactEnumSignatureToken(field.schema);
910
+ if (enumToken !== undefined) {
911
+ return `${formatOptionFlags(field, globalLongOptionFlags)} ${enumToken}`;
912
+ }
913
+ return formatHelpFieldFlags(field, globalLongOptionFlags);
914
+ }
882
915
  function describeDynamicFieldType(field) {
883
916
  if (field.schema.kind === "record") {
884
917
  const valueSchema = unwrapOptional(field.schema.value);
@@ -1027,7 +1060,7 @@ function formatCommandParameterTokens(command, casing, globalLongOptionFlags) {
1027
1060
  const fields = assignPositionals(collected.fields, command.positional);
1028
1061
  return fields
1029
1062
  .filter((field) => field.global !== true)
1030
- .map((field) => wrapOptionalCommandParameterToken(formatHelpFieldFlags(field, globalLongOptionFlags), field.positionalIndex === undefined && (field.optional || field.hasDefault)))
1063
+ .map((field) => wrapOptionalCommandParameterToken(formatCommandParameterFieldFlags(field, globalLongOptionFlags), field.positionalIndex === undefined && (field.optional || field.hasDefault)))
1031
1064
  .concat(collected.dynamicFields.flatMap((field) => formatCommandDynamicParameterTokens(field, casing)));
1032
1065
  }
1033
1066
  function formatCommandRowName(node, casing, globalLongOptionFlags) {
@@ -1039,7 +1072,7 @@ function formatCommandRowName(node, casing, globalLongOptionFlags) {
1039
1072
  return name;
1040
1073
  }
1041
1074
  function formatCommandRows(group, scope, casing, globalLongOptionFlags) {
1042
- return getVisibleChildren(group, scope).map((child) => ({
1075
+ return getHelpChildren(group, scope).map((child) => ({
1043
1076
  name: formatCommandRowName(child, casing, globalLongOptionFlags),
1044
1077
  description: child.description ?? ""
1045
1078
  }));
@@ -1083,7 +1116,7 @@ function collectSchemaGlobalFieldRows(group, scope, casing, globalLongOptionFlag
1083
1116
  }
1084
1117
  return;
1085
1118
  }
1086
- for (const child of getVisibleChildren(node, scope)) {
1119
+ for (const child of getHelpChildren(node, scope)) {
1087
1120
  visit(child);
1088
1121
  }
1089
1122
  };
@@ -1110,6 +1143,15 @@ function buildUsageLine(breadcrumb, rootUsageName, suffix) {
1110
1143
  const tokens = [rootUsageName, subPath, suffix].filter((segment) => segment.length > 0);
1111
1144
  return tokens.join(" ");
1112
1145
  }
1146
+ function formatGroupUsageSuffix(group, scope, casing, globalLongOptionFlags) {
1147
+ if (group.default !== undefined &&
1148
+ group.default.hidden === true &&
1149
+ group.default.scope.includes(scope)) {
1150
+ const parameterTokens = formatCommandParameterTokens(group.default, casing, globalLongOptionFlags);
1151
+ return ["[command]", "[OPTIONS]", ...parameterTokens].join(" ");
1152
+ }
1153
+ return "[command] [OPTIONS]";
1154
+ }
1113
1155
  function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUsageName, isRoot) {
1114
1156
  const sections = [];
1115
1157
  const globalLongOptionFlags = getGlobalLongOptionFlags(globalOptions.presetsEnabled, globalOptions.showVersion, globalOptions.controls);
@@ -1130,7 +1172,7 @@ function renderGroupHelp(group, breadcrumb, scope, casing, globalOptions, rootUs
1130
1172
  return renderHelpDocument({
1131
1173
  breadcrumb,
1132
1174
  rootUsageName,
1133
- usageLine: buildUsageLine(breadcrumb, rootUsageName, "[command] [OPTIONS]"),
1175
+ usageLine: buildUsageLine(breadcrumb, rootUsageName, formatGroupUsageSuffix(group, scope, casing, globalLongOptionFlags)),
1134
1176
  description: group.description,
1135
1177
  requiresAuth: group.requires?.auth === true,
1136
1178
  sections
@@ -1220,6 +1262,8 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
1220
1262
  return null;
1221
1263
  }
1222
1264
  const command = new CommanderCommand(node.name);
1265
+ Reflect.set(command, "_toolcraftHidden", node.hidden);
1266
+ Reflect.set(command, "_toolcraftOriginalName", node.name);
1223
1267
  const collected = collectFields(node.params, casing, globalLongOptionFlags);
1224
1268
  const fields = assignPositionals(collected.fields, node.positional);
1225
1269
  validateUniqueOptionFlags(fields, globalLongOptionFlags);
@@ -1263,10 +1307,14 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
1263
1307
  if (!isNodeVisibleInScope(node, "cli")) {
1264
1308
  return null;
1265
1309
  }
1310
+ const reservedChildNames = node.children
1311
+ .filter((child) => !isNodeVisibleInScope(child, "cli"))
1312
+ .flatMap((child) => getNodeCommandNames(child));
1266
1313
  const visibleChildren = node.children
1267
1314
  .map((child) => createNodeCommand(child, casing, globalLongOptionFlags, execute, presetsEnabled, controls, nextPathSegments))
1268
1315
  .filter((child) => child !== null);
1269
1316
  const group = new CommanderCommand(node.name);
1317
+ Reflect.set(group, "_toolcraftReservedChildNames", reservedChildNames);
1270
1318
  if (node.description !== undefined) {
1271
1319
  group.description(node.description);
1272
1320
  }
@@ -1283,7 +1331,7 @@ function createNodeCommand(node, casing, globalLongOptionFlags, execute, presets
1283
1331
  return group;
1284
1332
  }
1285
1333
  function addCommanderChild(parent, child, isDefault, siblingNames) {
1286
- if (isDefault && child.name().length === 0) {
1334
+ if (isDefault && (child.name().length === 0 || isToolcraftHiddenCommander(child))) {
1287
1335
  let internalName = "__toolcraft_default__";
1288
1336
  let suffix = 2;
1289
1337
  while (siblingNames.has(internalName)) {
@@ -1291,10 +1339,33 @@ function addCommanderChild(parent, child, isDefault, siblingNames) {
1291
1339
  suffix += 1;
1292
1340
  }
1293
1341
  child.name(internalName);
1342
+ Reflect.set(parent, "_toolcraftHiddenDefaultNames", getToolcraftHiddenDefaultNames(parent).concat([
1343
+ ...new Set([Reflect.get(child, "_toolcraftOriginalName"), ...child.aliases()].filter((name) => typeof name === "string" && name.length > 0))
1344
+ ]));
1294
1345
  parent.addCommand(child, { hidden: true, isDefault: true });
1295
1346
  return;
1296
1347
  }
1297
- parent.addCommand(child, isDefault ? { isDefault: true } : undefined);
1348
+ const options = {
1349
+ ...(isDefault ? { isDefault: true } : {}),
1350
+ ...(isToolcraftHiddenCommander(child) ? { hidden: true } : {})
1351
+ };
1352
+ parent.addCommand(child, Object.keys(options).length > 0 ? options : undefined);
1353
+ }
1354
+ function isToolcraftHiddenCommander(command) {
1355
+ return Reflect.get(command, "_toolcraftHidden") === true;
1356
+ }
1357
+ function getToolcraftHiddenDefaultNames(command) {
1358
+ const value = Reflect.get(command, "_toolcraftHiddenDefaultNames");
1359
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
1360
+ }
1361
+ function getToolcraftReservedChildNames(command) {
1362
+ const value = Reflect.get(command, "_toolcraftReservedChildNames");
1363
+ return Array.isArray(value)
1364
+ ? value.filter((item) => typeof item === "string")
1365
+ : [];
1366
+ }
1367
+ function getNodeCommandNames(node) {
1368
+ return [node.name, ...node.aliases].filter((name) => name.length > 0);
1298
1369
  }
1299
1370
  function addGlobalOptions(command, presetsEnabled, controls) {
1300
1371
  const options = [];
@@ -3003,6 +3074,14 @@ function findUnknownCommanderCommand(program, argv) {
3003
3074
  }
3004
3075
  continue;
3005
3076
  }
3077
+ if (getToolcraftHiddenDefaultNames(current).includes(token) ||
3078
+ getToolcraftReservedChildNames(current).includes(token)) {
3079
+ return {
3080
+ input: token,
3081
+ currentCommand: current,
3082
+ commandPath: pathSegments.join(" ")
3083
+ };
3084
+ }
3006
3085
  if (current.commands.length === 0 || getDefaultCommanderCommandName(current) !== undefined) {
3007
3086
  return undefined;
3008
3087
  }
@@ -3073,6 +3152,9 @@ export async function runCLI(roots, options = {}) {
3073
3152
  if (version !== undefined) {
3074
3153
  program.version(version, "--version");
3075
3154
  }
3155
+ Reflect.set(program, "_toolcraftReservedChildNames", root.children
3156
+ .filter((child) => !isNodeVisibleInScope(child, "cli"))
3157
+ .flatMap((child) => getNodeCommandNames(child)));
3076
3158
  let lastActionCommand;
3077
3159
  let resolvedCommandPath = "";
3078
3160
  let errorReportContext;
package/dist/index.d.ts CHANGED
@@ -99,6 +99,7 @@ export type HandlerContext<TParamsSchema extends ObjectSchema<any> = AnyObjectSc
99
99
  export interface CommandConfig<TServices extends object, TParamsSchema extends ObjectSchema<any>, TSecrets extends SecretDeclarations | undefined, TResult> {
100
100
  name: string;
101
101
  description?: string;
102
+ hidden?: boolean;
102
103
  examples?: CommandExample[];
103
104
  aliases?: string[];
104
105
  positional?: string[];
@@ -116,6 +117,7 @@ export interface Command<TServices extends object = EmptyServices, TParamsSchema
116
117
  kind: "command";
117
118
  name: string;
118
119
  description?: string;
120
+ hidden: boolean;
119
121
  examples: CommandExample[];
120
122
  aliases: string[];
121
123
  positional: string[];
package/dist/index.js CHANGED
@@ -292,6 +292,7 @@ function createBaseCommand(config) {
292
292
  kind: "command",
293
293
  name: config.name,
294
294
  description: config.description,
295
+ hidden: config.hidden ?? false,
295
296
  examples: cloneCommandExamples(config.examples),
296
297
  aliases: [...(config.aliases ?? [])],
297
298
  positional: [...(config.positional ?? [])],
@@ -308,6 +309,7 @@ function createBaseCommand(config) {
308
309
  Object.defineProperty(command, commandConfigSymbol, {
309
310
  value: {
310
311
  scope: cloneScope(config.scope),
312
+ hidden: config.hidden ?? false,
311
313
  examples: cloneCommandExamples(config.examples),
312
314
  result: config.result,
313
315
  humanInLoop: config.humanInLoop,
@@ -358,6 +360,7 @@ function materializeCommand(command, inherited) {
358
360
  kind: "command",
359
361
  name: command.name,
360
362
  description: command.description,
363
+ hidden: internal.hidden,
361
364
  examples: cloneCommandExamples(internal.examples),
362
365
  aliases: [...command.aliases],
363
366
  positional: [...command.positional],
@@ -374,6 +377,7 @@ function materializeCommand(command, inherited) {
374
377
  Object.defineProperty(materialized, commandConfigSymbol, {
375
378
  value: {
376
379
  scope: cloneScope(internal.scope),
380
+ hidden: internal.hidden,
377
381
  examples: cloneCommandExamples(internal.examples),
378
382
  result: internal.result,
379
383
  humanInLoop: internal.humanInLoop,
package/dist/mcp-proxy.js CHANGED
@@ -78,6 +78,7 @@ function createProxyCommand(parent, tool, commandName, connection) {
78
78
  kind: "command",
79
79
  name: commandName,
80
80
  description: tool.description,
81
+ hidden: false,
81
82
  examples: [],
82
83
  aliases: [],
83
84
  positional: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  "postpack": "node ../../scripts/manage-bundled-workspace-deps.mjs cleanup . toolcraft-design @poe-code/frontmatter @poe-code/agent-mcp-config @poe-code/agent-human-in-loop @poe-code/task-list @poe-code/agent-defs @poe-code/config-mutations @poe-code/process-runner tiny-mcp-client mcp-oauth auth-store"
48
48
  },
49
49
  "dependencies": {
50
- "toolcraft-schema": "0.0.52",
50
+ "toolcraft-schema": "0.0.54",
51
51
  "commander": "^14.0.3",
52
52
  "fast-string-width": "^3.0.2",
53
53
  "fast-wrap-ansi": "^0.2.0",