poe-code 3.0.194 → 3.0.195

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/index.js CHANGED
@@ -45482,7 +45482,7 @@ function getRequiredBranchFingerprint(branch, casing) {
45482
45482
  const requiredKeys = Object.entries(branch.shape).filter(([, schema]) => schema.kind !== "optional").map(([key2]) => formatSegment2(key2, casing)).sort();
45483
45483
  return requiredKeys.join("+");
45484
45484
  }
45485
- function collectFields(schema, casing, path94 = [], inheritedOptional = false, variantContext) {
45485
+ function collectFields(schema, casing, globalLongOptionFlags, path94 = [], inheritedOptional = false, variantContext) {
45486
45486
  const collected = {
45487
45487
  dynamicFields: [],
45488
45488
  fields: [],
@@ -45494,7 +45494,7 @@ function collectFields(schema, casing, path94 = [], inheritedOptional = false, v
45494
45494
  const childSchema = unwrapOptional3(rawChildSchema);
45495
45495
  const requiredWhenActive = rawChildSchema.kind !== "optional" && childSchema.default === void 0;
45496
45496
  if (childSchema.kind === "object") {
45497
- const nested = collectFields(childSchema, casing, nextPath, runtimeOptional, variantContext);
45497
+ const nested = collectFields(childSchema, casing, globalLongOptionFlags, nextPath, runtimeOptional, variantContext);
45498
45498
  collected.dynamicFields.push(...nested.dynamicFields);
45499
45499
  collected.fields.push(...nested.fields);
45500
45500
  collected.variants.push(...nested.variants);
@@ -45508,7 +45508,7 @@ function collectFields(schema, casing, path94 = [], inheritedOptional = false, v
45508
45508
  path: [...nextPath, childSchema.discriminator],
45509
45509
  displayPath: toDisplayPath3([...nextPath, childSchema.discriminator]),
45510
45510
  optionAttribute: toOptionAttribute([...nextPath, childSchema.discriminator], casing),
45511
- commanderOptionAttribute: toCommanderOptionAttribute([...nextPath, childSchema.discriminator], casing),
45511
+ commanderOptionAttribute: toCommanderOptionAttribute([...nextPath, childSchema.discriminator], casing, globalLongOptionFlags),
45512
45512
  optionFlag: toOptionFlag([...nextPath, childSchema.discriminator], casing),
45513
45513
  shortFlag: void 0,
45514
45514
  schema: createSyntheticEnumSchema(branchIds),
@@ -45521,7 +45521,7 @@ function collectFields(schema, casing, path94 = [], inheritedOptional = false, v
45521
45521
  collected.fields.push(controlField);
45522
45522
  const branches = [];
45523
45523
  for (const [branchId, branchSchema] of Object.entries(childSchema.branches)) {
45524
- const branch = collectFields(branchSchema, casing, nextPath, true, {
45524
+ const branch = collectFields(branchSchema, casing, globalLongOptionFlags, nextPath, true, {
45525
45525
  id: variantId,
45526
45526
  branchId
45527
45527
  });
@@ -45555,7 +45555,7 @@ function collectFields(schema, casing, path94 = [], inheritedOptional = false, v
45555
45555
  path: controlPath,
45556
45556
  displayPath: controlDisplayPath,
45557
45557
  optionAttribute: toOptionAttribute(controlPath, casing),
45558
- commanderOptionAttribute: toCommanderOptionAttribute(controlPath, casing),
45558
+ commanderOptionAttribute: toCommanderOptionAttribute(controlPath, casing, globalLongOptionFlags),
45559
45559
  optionFlag: toOptionFlag(controlPath, casing),
45560
45560
  shortFlag: void 0,
45561
45561
  schema: createSyntheticEnumSchema(branchIds),
@@ -45570,7 +45570,7 @@ function collectFields(schema, casing, path94 = [], inheritedOptional = false, v
45570
45570
  const branches = [];
45571
45571
  childSchema.branches.forEach((branchSchema, index) => {
45572
45572
  const branchId = branchIds[index] ?? "";
45573
- const branch = collectFields(branchSchema, casing, nextPath, true, {
45573
+ const branch = collectFields(branchSchema, casing, globalLongOptionFlags, nextPath, true, {
45574
45574
  id: variantId,
45575
45575
  branchId
45576
45576
  });
@@ -45637,7 +45637,7 @@ function collectFields(schema, casing, path94 = [], inheritedOptional = false, v
45637
45637
  path: nextPath,
45638
45638
  displayPath: toDisplayPath3(nextPath),
45639
45639
  optionAttribute: toOptionAttribute(nextPath, casing),
45640
- commanderOptionAttribute: toCommanderOptionAttribute(nextPath, casing),
45640
+ commanderOptionAttribute: toCommanderOptionAttribute(nextPath, casing, globalLongOptionFlags),
45641
45641
  optionFlag: toOptionFlag(nextPath, casing),
45642
45642
  shortFlag: childSchema.short,
45643
45643
  schema: childSchema,
@@ -45652,10 +45652,10 @@ function collectFields(schema, casing, path94 = [], inheritedOptional = false, v
45652
45652
  }
45653
45653
  return collected;
45654
45654
  }
45655
- function toCommanderOptionAttribute(path94, casing) {
45655
+ function toCommanderOptionAttribute(path94, casing, globalLongOptionFlags) {
45656
45656
  const optionAttribute = toOptionAttribute(path94, casing);
45657
45657
  const optionFlag = toOptionFlag(path94, casing);
45658
- if (!GLOBAL_LONG_OPTION_FLAGS.has(optionFlag)) {
45658
+ if (!globalLongOptionFlags.has(optionFlag)) {
45659
45659
  return optionAttribute;
45660
45660
  }
45661
45661
  return `param_${optionAttribute}`;
@@ -45685,8 +45685,8 @@ function assignPositionals(fields, positional) {
45685
45685
  });
45686
45686
  return fields;
45687
45687
  }
45688
- function formatOptionFlags(field) {
45689
- const collidesWithGlobalFlag = GLOBAL_LONG_OPTION_FLAGS.has(field.optionFlag);
45688
+ function formatOptionFlags(field, globalLongOptionFlags) {
45689
+ const collidesWithGlobalFlag = globalLongOptionFlags.has(field.optionFlag);
45690
45690
  if (collidesWithGlobalFlag) {
45691
45691
  if (field.shortFlag === void 0) {
45692
45692
  throw new UserError(
@@ -45804,9 +45804,9 @@ function parseArrayValue(value, schema, label) {
45804
45804
  }
45805
45805
  return splitArrayInput(value).map((item) => parseScalarValue(item, itemSchema, label));
45806
45806
  }
45807
- function createOption(field) {
45808
- const flags = formatOptionFlags(field);
45809
- const collidesWithGlobalFlag = GLOBAL_LONG_OPTION_FLAGS.has(field.optionFlag);
45807
+ function createOption(field, globalLongOptionFlags) {
45808
+ const flags = formatOptionFlags(field, globalLongOptionFlags);
45809
+ const collidesWithGlobalFlag = globalLongOptionFlags.has(field.optionFlag);
45810
45810
  const commanderValue = (value) => value === null ? NULL_OPTION_VALUE : value;
45811
45811
  if (field.schema.kind === "boolean") {
45812
45812
  if (collidesWithGlobalFlag) {
@@ -45851,6 +45851,9 @@ function createOption(field) {
45851
45851
  );
45852
45852
  return [option];
45853
45853
  }
45854
+ function getGlobalLongOptionFlags(presetsEnabled) {
45855
+ return new Set(presetsEnabled ? ["--preset", ...ALWAYS_GLOBAL_LONG_OPTION_FLAGS] : ALWAYS_GLOBAL_LONG_OPTION_FLAGS);
45856
+ }
45854
45857
  function createCommanderOption(flags, description, field) {
45855
45858
  const option = new Option(flags, description);
45856
45859
  if (field.commanderOptionAttribute !== field.optionAttribute) {
@@ -45944,14 +45947,14 @@ function describeSchemaType(schema) {
45944
45947
  throw new UserError("Unsupported CLI schema kind.");
45945
45948
  }
45946
45949
  }
45947
- function formatHelpFieldFlags(field) {
45950
+ function formatHelpFieldFlags(field, globalLongOptionFlags) {
45948
45951
  if (field.positionalIndex !== void 0) {
45949
45952
  return formatPositionalToken(field);
45950
45953
  }
45951
45954
  if (field.schema.kind === "boolean") {
45952
- return `${formatOptionFlags(field)} [value]`;
45955
+ return `${formatOptionFlags(field, globalLongOptionFlags)} [value]`;
45953
45956
  }
45954
- return `${formatOptionFlags(field)} <${describeSchemaType(field.schema)}>`;
45957
+ return `${formatOptionFlags(field, globalLongOptionFlags)} <${describeSchemaType(field.schema)}>`;
45955
45958
  }
45956
45959
  function appendHelpMetadata(description, metadata) {
45957
45960
  if (metadata.length === 0) {
@@ -46093,18 +46096,31 @@ function formatSecretDescription(secret) {
46093
46096
  }
46094
46097
  return secret.optional === true ? "Optional secret" : "Required secret";
46095
46098
  }
46096
- function formatCommandRows(group, scope) {
46097
- return getVisibleChildren(group, scope).map((child) => ({
46098
- name: child.aliases.length === 0 ? child.name : `${child.name} (${child.aliases.join(", ")})`,
46099
- description: child.description ?? ""
46100
- }));
46099
+ function formatCommandRowName(node, depth) {
46100
+ const name = node.aliases.length === 0 ? node.name : `${node.name} (${node.aliases.join(", ")})`;
46101
+ return `${" ".repeat(depth)}${name}`;
46101
46102
  }
46102
- function formatGlobalOptionRows(showVersion) {
46103
- const rows = [
46104
- {
46103
+ function formatCommandRows(group, scope, depth = 0) {
46104
+ return getVisibleChildren(group, scope).flatMap((child) => {
46105
+ const row = {
46106
+ name: formatCommandRowName(child, depth),
46107
+ description: child.description ?? ""
46108
+ };
46109
+ if (child.kind === "command") {
46110
+ return [row];
46111
+ }
46112
+ return [row, ...formatCommandRows(child, scope, depth + 1)];
46113
+ });
46114
+ }
46115
+ function formatGlobalOptionRows(showVersion, presetsEnabled) {
46116
+ const rows = [];
46117
+ if (presetsEnabled) {
46118
+ rows.push({
46105
46119
  flags: "--preset <path>",
46106
46120
  description: "Load parameter defaults from a JSON file"
46107
- },
46121
+ });
46122
+ }
46123
+ rows.push(
46108
46124
  {
46109
46125
  flags: "--yes",
46110
46126
  description: "Accept defaults, skip prompts"
@@ -46117,7 +46133,7 @@ function formatGlobalOptionRows(showVersion) {
46117
46133
  flags: "-h, --help",
46118
46134
  description: "Show help"
46119
46135
  }
46120
- ];
46136
+ );
46121
46137
  if (showVersion) {
46122
46138
  rows.push({
46123
46139
  flags: "--version",
@@ -46136,7 +46152,7 @@ function buildUsageLine(breadcrumb, rootUsageName, suffix) {
46136
46152
  const subPath = breadcrumb.slice(1).join(" ");
46137
46153
  return subPath ? `${rootUsageName} ${subPath} ${suffix}` : `${rootUsageName} ${suffix}`;
46138
46154
  }
46139
- function renderGroupHelp(group, breadcrumb, scope, showVersion, rootUsageName) {
46155
+ function renderGroupHelp(group, breadcrumb, scope, showVersion, presetsEnabled, rootUsageName) {
46140
46156
  const sections = [];
46141
46157
  const commandRows = formatCommandRows(group, scope);
46142
46158
  if (commandRows.length > 0) {
@@ -46144,7 +46160,7 @@ function renderGroupHelp(group, breadcrumb, scope, showVersion, rootUsageName) {
46144
46160
  ${formatCommandList(commandRows)}`);
46145
46161
  }
46146
46162
  sections.push(`${text.section("Global options:")}
46147
- ${formatOptionList(formatGlobalOptionRows(showVersion))}`);
46163
+ ${formatOptionList(formatGlobalOptionRows(showVersion, presetsEnabled))}`);
46148
46164
  return renderHelpDocument({
46149
46165
  breadcrumb,
46150
46166
  usageLine: buildUsageLine(breadcrumb, rootUsageName, "[options] [command]"),
@@ -46153,12 +46169,13 @@ ${formatOptionList(formatGlobalOptionRows(showVersion))}`);
46153
46169
  sections
46154
46170
  });
46155
46171
  }
46156
- function renderLeafHelp(command, breadcrumb, casing, rootUsageName) {
46172
+ function renderLeafHelp(command, breadcrumb, casing, presetsEnabled, rootUsageName) {
46157
46173
  const sections = [];
46158
- const collected = collectFields(command.params, casing);
46174
+ const globalLongOptionFlags = getGlobalLongOptionFlags(presetsEnabled);
46175
+ const collected = collectFields(command.params, casing, globalLongOptionFlags);
46159
46176
  const fields = assignPositionals(collected.fields, command.positional);
46160
46177
  const optionRows = fields.map((field) => ({
46161
- flags: formatHelpFieldFlags(field),
46178
+ flags: formatHelpFieldFlags(field, globalLongOptionFlags),
46162
46179
  description: formatHelpFieldDescription(field)
46163
46180
  })).concat(collected.dynamicFields.flatMap((field) => formatDynamicHelpFields(field, casing)));
46164
46181
  if (optionRows.length > 0) {
@@ -46166,7 +46183,7 @@ function renderLeafHelp(command, breadcrumb, casing, rootUsageName) {
46166
46183
  ${formatOptionList(optionRows)}`);
46167
46184
  }
46168
46185
  sections.push(`${text.section("Global options:")}
46169
- ${formatOptionList(formatGlobalOptionRows(false))}`);
46186
+ ${formatOptionList(formatGlobalOptionRows(false, presetsEnabled))}`);
46170
46187
  const secretRows = formatSecretRows(command.secrets);
46171
46188
  if (secretRows.length > 0) {
46172
46189
  sections.push(`${text.section("Secrets (via environment):")}
@@ -46205,25 +46222,32 @@ async function renderGeneratedHelp(root, argv, options) {
46205
46222
  const output = resolveHelpOutput(argv);
46206
46223
  const casing = options.casing ?? "kebab";
46207
46224
  await withOutputFormat2(output, async () => {
46208
- const rendered = target.node.kind === "group" ? renderGroupHelp(target.node, target.breadcrumb, "cli", options.version !== void 0, options.rootUsageName) : renderLeafHelp(target.node, target.breadcrumb, casing, options.rootUsageName);
46225
+ const rendered = target.node.kind === "group" ? renderGroupHelp(
46226
+ target.node,
46227
+ target.breadcrumb,
46228
+ "cli",
46229
+ options.version !== void 0,
46230
+ options.presets === true,
46231
+ options.rootUsageName
46232
+ ) : renderLeafHelp(target.node, target.breadcrumb, casing, options.presets === true, options.rootUsageName);
46209
46233
  process.stdout.write(rendered);
46210
46234
  });
46211
46235
  }
46212
- function createNodeCommand(node, casing, execute2, pathSegments = []) {
46236
+ function createNodeCommand(node, casing, globalLongOptionFlags, execute2, presetsEnabled, pathSegments = []) {
46213
46237
  const nextPathSegments = [...pathSegments, node.name];
46214
46238
  if (node.kind === "command") {
46215
46239
  if (!node.scope.includes("cli")) {
46216
46240
  return null;
46217
46241
  }
46218
46242
  const command = new CommanderCommand(node.name);
46219
- const collected = collectFields(node.params, casing);
46243
+ const collected = collectFields(node.params, casing, globalLongOptionFlags);
46220
46244
  const fields = assignPositionals(collected.fields, node.positional);
46221
46245
  if (node.description !== void 0) {
46222
46246
  command.description(node.description);
46223
46247
  }
46224
46248
  node.aliases.forEach((alias) => command.alias(alias));
46225
46249
  command.addHelpCommand(false);
46226
- addGlobalOptions(command);
46250
+ addGlobalOptions(command, presetsEnabled);
46227
46251
  command.allowExcessArguments(true);
46228
46252
  if (collected.dynamicFields.length > 0) {
46229
46253
  command.allowUnknownOption(true);
@@ -46233,7 +46257,7 @@ function createNodeCommand(node, casing, execute2, pathSegments = []) {
46233
46257
  command.argument(formatPositionalToken(field));
46234
46258
  continue;
46235
46259
  }
46236
- for (const option of createOption(field)) {
46260
+ for (const option of createOption(field, globalLongOptionFlags)) {
46237
46261
  command.addOption(option);
46238
46262
  }
46239
46263
  }
@@ -46247,6 +46271,7 @@ function createNodeCommand(node, casing, execute2, pathSegments = []) {
46247
46271
  dynamicFields: collected.dynamicFields,
46248
46272
  fields,
46249
46273
  positionalValues,
46274
+ presetsEnabled,
46250
46275
  rawArgv: actionCommand.args,
46251
46276
  actionCommand,
46252
46277
  variants: collected.variants
@@ -46257,22 +46282,25 @@ function createNodeCommand(node, casing, execute2, pathSegments = []) {
46257
46282
  if (!isNodeVisibleInScope(node, "cli")) {
46258
46283
  return null;
46259
46284
  }
46260
- const visibleChildren = node.children.map((child) => createNodeCommand(child, casing, execute2, nextPathSegments)).filter((child) => child !== null);
46285
+ const visibleChildren = node.children.map((child) => createNodeCommand(child, casing, globalLongOptionFlags, execute2, presetsEnabled, nextPathSegments)).filter((child) => child !== null);
46261
46286
  const group = new CommanderCommand(node.name);
46262
46287
  if (node.description !== void 0) {
46263
46288
  group.description(node.description);
46264
46289
  }
46265
46290
  node.aliases.forEach((alias) => group.alias(alias));
46266
46291
  group.addHelpCommand(false);
46267
- addGlobalOptions(group);
46292
+ addGlobalOptions(group, presetsEnabled);
46268
46293
  for (const child of visibleChildren) {
46269
46294
  const isDefaultChild = node.default !== void 0 && node.default.scope.includes("cli") && (child.name() === node.default.name || child.aliases().includes(node.default.name));
46270
46295
  group.addCommand(child, isDefaultChild ? { isDefault: true } : void 0);
46271
46296
  }
46272
46297
  return group;
46273
46298
  }
46274
- function addGlobalOptions(command) {
46275
- command.option("--preset <path>", "Load parameter defaults from a JSON file.").option("--yes", "Accept defaults and skip prompts.").option("--output <format>", "Output format.", (value) => {
46299
+ function addGlobalOptions(command, presetsEnabled) {
46300
+ if (presetsEnabled) {
46301
+ command.option("--preset <path>", "Load parameter defaults from a JSON file.");
46302
+ }
46303
+ command.option("--yes", "Accept defaults and skip prompts.").option("--output <format>", "Output format.", (value) => {
46276
46304
  if (value === "rich" || value === "md" || value === "json") {
46277
46305
  return value;
46278
46306
  }
@@ -47308,7 +47336,7 @@ async function executeCommand(state, services, requirementOptions, runtimeOption
47308
47336
  optionValues,
47309
47337
  state.rawArgv,
47310
47338
  state.casing,
47311
- resolvedFlags.preset,
47339
+ state.presetsEnabled ? resolvedFlags.preset : void 0,
47312
47340
  shouldPrompt
47313
47341
  );
47314
47342
  const context = {
@@ -47395,7 +47423,9 @@ async function runCLI(roots, options = {}) {
47395
47423
  program.exitOverride();
47396
47424
  program.showHelpAfterError();
47397
47425
  program.addHelpCommand(false);
47398
- addGlobalOptions(program);
47426
+ const presetsEnabled = options.presets === true;
47427
+ const globalLongOptionFlags = getGlobalLongOptionFlags(presetsEnabled);
47428
+ addGlobalOptions(program, presetsEnabled);
47399
47429
  if (version !== void 0) {
47400
47430
  program.version(version, "--version");
47401
47431
  }
@@ -47405,7 +47435,7 @@ async function runCLI(roots, options = {}) {
47405
47435
  await executeCommand(state, servicesWithBuiltIns, requirementOptions, runtimeOptions);
47406
47436
  };
47407
47437
  for (const child of root.children) {
47408
- const command = createNodeCommand(child, casing, execute2);
47438
+ const command = createNodeCommand(child, casing, globalLongOptionFlags, execute2, presetsEnabled);
47409
47439
  if (command === null) {
47410
47440
  continue;
47411
47441
  }
@@ -47425,7 +47455,7 @@ async function runCLI(roots, options = {}) {
47425
47455
  );
47426
47456
  }
47427
47457
  }
47428
- var RESERVED_SERVICE_NAMES2, NULL_OPTION_VALUE, HELP_FLAGS, GLOBAL_LONG_OPTION_FLAGS, DESIGN_SYSTEM_OUTPUT_BY_MODE;
47458
+ var RESERVED_SERVICE_NAMES2, NULL_OPTION_VALUE, HELP_FLAGS, ALWAYS_GLOBAL_LONG_OPTION_FLAGS, DESIGN_SYSTEM_OUTPUT_BY_MODE;
47429
47459
  var init_cli = __esm({
47430
47460
  "packages/toolcraft/src/cli.ts"() {
47431
47461
  "use strict";
@@ -47440,7 +47470,7 @@ var init_cli = __esm({
47440
47470
  RESERVED_SERVICE_NAMES2 = /* @__PURE__ */ new Set(["params", "secrets", "fetch", "fs", "env", "progress"]);
47441
47471
  NULL_OPTION_VALUE = /* @__PURE__ */ Symbol("toolcraft.cli.null");
47442
47472
  HELP_FLAGS = /* @__PURE__ */ new Set(["--help", "-h"]);
47443
- GLOBAL_LONG_OPTION_FLAGS = /* @__PURE__ */ new Set(["--preset", "--yes", "--output", "--verbose"]);
47473
+ ALWAYS_GLOBAL_LONG_OPTION_FLAGS = ["--yes", "--output", "--verbose"];
47444
47474
  DESIGN_SYSTEM_OUTPUT_BY_MODE = {
47445
47475
  rich: "terminal",
47446
47476
  md: "markdown",
@@ -56808,7 +56838,7 @@ var init_package2 = __esm({
56808
56838
  "package.json"() {
56809
56839
  package_default2 = {
56810
56840
  name: "poe-code",
56811
- version: "3.0.194",
56841
+ version: "3.0.195",
56812
56842
  description: "CLI tool to configure Poe API for developer workflows.",
56813
56843
  type: "module",
56814
56844
  main: "./dist/index.js",