@rockcarver/frodo-cli 5.0.0-15 → 5.0.0-16

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/CHANGELOG.md CHANGED
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## [v5.0.0-15] - 2026-10-28
11
+
12
+ ### Added
13
+ - Introduced `frodo esv secret version prune`, which deletes all versions of a secret except the active one. This command is cloud-only and wraps the library's `pruneVersionsOfSecret` method. (#972)
14
+ - Added `-u, --custom-relationships` option to `frodo config-manager pull managed-objects`, allowing the export of custom relationship property schemas. (#975)
15
+ - Implemented `-u, --dump` option for `frodo config-manager pull variables` to output variable values to the console. (#964)
16
+
17
+ ### Changed
18
+ - `frodo esv secret version prune -a` now displays a plan of the secrets it will affect and prompts for confirmation before deleting old versions. This change prevents accidental deletion of secret versions. (#982)
19
+ - Commands now set the exit code and return instead of calling `process.exit()`, aligning with the newly added record 0033. This change affects 31 commands that previously used `process.exit()`. (#980)
20
+
21
+ ### Removed
22
+ - Removed the `-r, --realm` flag from `frodo config-manager pull` commands to eliminate redundancy, as Frodo already includes realm as a built-in argument. (#961)
23
+ - Removed the dead `-a` option from `frodo esv secret version delete`. (#972)
24
+
25
+ ### Fixed
26
+ - Resolved issues with `frodo config-manager pull all` and `pull all-static` commands, ensuring proper handling of org privileges, realm, and error conditions. (#976)
27
+ - Fixed the `authz policy import` command to allow the `-i` and `--set-id` options to be used together, restoring intended functionality. (#969)
28
+ - Corrected the conflicts on `esv secret version delete` by reverting the `-i/-a` conflicts. (#969)
29
+
30
+ ### Security
31
+ - Updated `frodo-lib` to version 5.0.0-15, which includes a fix for the browser-login callback check that previously rejected a valid redirect. (#981)
32
+
10
33
  ## [v5.0.0-14] - 2026-10-26
11
34
 
12
35
  ### Added
@@ -3097,6 +3120,7 @@ Frodo CLI 2.x automatically refreshes session and access tokens before they expi
3097
3120
  - Fixed problem with adding connection profiles
3098
3121
  - Miscellaneous bug fixes
3099
3122
 
3123
+ [v5.0.0-15]: https://github.com/rockcarver/frodo-cli/compare/v5.0.0-14...v5.0.0-15
3100
3124
  [v5.0.0-14]: https://github.com/rockcarver/frodo-cli/compare/v5.0.0-13...v5.0.0-14
3101
3125
  [v5.0.0-13]: https://github.com/rockcarver/frodo-cli/compare/v5.0.0-12...v5.0.0-13
3102
3126
  [v5.0.0-12]: https://github.com/rockcarver/frodo-cli/compare/v5.0.0-11...v5.0.0-12
@@ -5,6 +5,66 @@ let fs = require("fs");
5
5
  fs = require_rolldown_runtime.__toESM(fs, 1);
6
6
  let os = require("os");
7
7
  os = require_rolldown_runtime.__toESM(os, 1);
8
+ //#region src/utils/interactive/SecretOptions.ts
9
+ /** How a secret value is shown wherever the command is printed. */
10
+ const SECRET_MASK = "********";
11
+ /** Appended to the description of every secret option, so all of them say the same. */
12
+ const SECRET_OPTION_HELP = "Without a value, it is asked for (input hidden) or, when input is piped, read from stdin.";
13
+ /**
14
+ * The marker lives under a symbol on the option itself, as an own enumerable
15
+ * property: FrodoCommand clones shared options with `{ ...option }`, which
16
+ * keeps own properties and would lose a class.
17
+ */
18
+ const SECRET_KEY = Symbol.for("frodo.secretOption");
19
+ /** Marks an option as secret. Returns the same option. */
20
+ function markSecret(option) {
21
+ option[SECRET_KEY] = true;
22
+ return option;
23
+ }
24
+ /** Whether the option was declared as a secret option. */
25
+ function isSecretOption(option) {
26
+ return option[SECRET_KEY] === true;
27
+ }
28
+ /** The long flag as typed (`--password`), or the whole flags string without one. */
29
+ function longFlagOf(option) {
30
+ return option.flags.split(/[, ]+/).find((token) => token.startsWith("--")) ?? option.flags;
31
+ }
32
+ /**
33
+ * The secret options still waiting for a value, in declaration order: the
34
+ * ones used bare, plus the mandatory ones that were left out altogether
35
+ * (`mandatoryViolations` holds the flags of the deferred mandatory options).
36
+ */
37
+ function pendingSecretOptions(command, mandatoryViolations = []) {
38
+ return command.options.filter((option) => {
39
+ if (!isSecretOption(option)) return false;
40
+ const value = command.getOptionValue(option.attributeName());
41
+ if (value === true) return true;
42
+ return value === void 0 && mandatoryViolations.includes(option.flags);
43
+ });
44
+ }
45
+ /** Commander-shaped error for a secret that was given without a value and cannot be asked for. */
46
+ function secretNeedsValueMessage(option) {
47
+ return `error: option '${option.flags}' was given without a value, and there is no way to ask for it here. Pipe the value on stdin, or give it as ${longFlagOf(option)} <value>.`;
48
+ }
49
+ /** Commander-shaped error for a bare secret whose prompt was declined (Escape or an empty answer). */
50
+ function secretDeclinedMessage(option) {
51
+ return `error: option '${option.flags}' was given without a value.`;
52
+ }
53
+ /** Commander-shaped error for several bare secrets when stdin is the only source. */
54
+ function secretsShareStdinMessage(options) {
55
+ return `error: ${options.map((option) => `'${longFlagOf(option)}'`).join(" and ")} were given without a value, but stdin can supply only one. Give the others on the command line.`;
56
+ }
57
+ /** Commander-shaped error for a bare secret when stdin was piped but empty. */
58
+ function secretStdinEmptyMessage(option) {
59
+ return `error: option '${option.flags}' was given without a value, and nothing was piped on stdin.`;
60
+ }
61
+ /** Drops one trailing line break (`\n` or `\r\n`) from piped input, and nothing else: a secret may end in a space. */
62
+ function stripTrailingNewline(text) {
63
+ return text.replace(/\r?\n$/, "");
64
+ }
65
+ /** The code of the errors above. */
66
+ const SECRET_VALUE_MISSING_CODE = "frodo.secretValueMissing";
67
+ //#endregion
8
68
  //#region src/utils/interactive/DefaultsStore.ts
9
69
  var DefaultsStore_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
10
70
  applicableCommandDefaults: () => applicableCommandDefaults,
@@ -79,9 +139,11 @@ function readCommandDefaults(command) {
79
139
  function saveCommandDefaults(command, values) {
80
140
  const store = readDefaultsStore();
81
141
  const key = commandStoreKey(command);
142
+ const secrets = new Set(command.options.filter(isSecretOption).map((o) => o.attributeName()));
143
+ const safe = Object.fromEntries(Object.entries(values).filter(([name]) => !secrets.has(name)));
82
144
  store[key] = {
83
145
  ...store[key] ?? {},
84
- ...values
146
+ ...safe
85
147
  };
86
148
  writeDefaultsStore(store);
87
149
  }
@@ -104,7 +166,7 @@ function clearDefaultsByPath(commandPath) {
104
166
  */
105
167
  function applicableCommandDefaults(command) {
106
168
  const persisted = readCommandDefaults(command);
107
- const known = new Set(command.options.map((option) => option.attributeName()));
169
+ const known = new Set(command.options.filter((option) => !isSecretOption(option)).map((option) => option.attributeName()));
108
170
  return Object.fromEntries(Object.entries(persisted).filter(([name]) => known.has(name)));
109
171
  }
110
172
  /**
@@ -127,6 +189,24 @@ Object.defineProperty(exports, "DefaultsStore_exports", {
127
189
  return DefaultsStore_exports;
128
190
  }
129
191
  });
192
+ Object.defineProperty(exports, "SECRET_MASK", {
193
+ enumerable: true,
194
+ get: function() {
195
+ return SECRET_MASK;
196
+ }
197
+ });
198
+ Object.defineProperty(exports, "SECRET_OPTION_HELP", {
199
+ enumerable: true,
200
+ get: function() {
201
+ return SECRET_OPTION_HELP;
202
+ }
203
+ });
204
+ Object.defineProperty(exports, "SECRET_VALUE_MISSING_CODE", {
205
+ enumerable: true,
206
+ get: function() {
207
+ return SECRET_VALUE_MISSING_CODE;
208
+ }
209
+ });
130
210
  Object.defineProperty(exports, "applicableCommandDefaults", {
131
211
  enumerable: true,
132
212
  get: function() {
@@ -139,17 +219,65 @@ Object.defineProperty(exports, "clearDefaultsByPath", {
139
219
  return clearDefaultsByPath;
140
220
  }
141
221
  });
222
+ Object.defineProperty(exports, "isSecretOption", {
223
+ enumerable: true,
224
+ get: function() {
225
+ return isSecretOption;
226
+ }
227
+ });
228
+ Object.defineProperty(exports, "markSecret", {
229
+ enumerable: true,
230
+ get: function() {
231
+ return markSecret;
232
+ }
233
+ });
142
234
  Object.defineProperty(exports, "optionMissingUserValue", {
143
235
  enumerable: true,
144
236
  get: function() {
145
237
  return optionMissingUserValue;
146
238
  }
147
239
  });
240
+ Object.defineProperty(exports, "pendingSecretOptions", {
241
+ enumerable: true,
242
+ get: function() {
243
+ return pendingSecretOptions;
244
+ }
245
+ });
148
246
  Object.defineProperty(exports, "readDefaultsStore", {
149
247
  enumerable: true,
150
248
  get: function() {
151
249
  return readDefaultsStore;
152
250
  }
153
251
  });
252
+ Object.defineProperty(exports, "secretDeclinedMessage", {
253
+ enumerable: true,
254
+ get: function() {
255
+ return secretDeclinedMessage;
256
+ }
257
+ });
258
+ Object.defineProperty(exports, "secretNeedsValueMessage", {
259
+ enumerable: true,
260
+ get: function() {
261
+ return secretNeedsValueMessage;
262
+ }
263
+ });
264
+ Object.defineProperty(exports, "secretStdinEmptyMessage", {
265
+ enumerable: true,
266
+ get: function() {
267
+ return secretStdinEmptyMessage;
268
+ }
269
+ });
270
+ Object.defineProperty(exports, "secretsShareStdinMessage", {
271
+ enumerable: true,
272
+ get: function() {
273
+ return secretsShareStdinMessage;
274
+ }
275
+ });
276
+ Object.defineProperty(exports, "stripTrailingNewline", {
277
+ enumerable: true,
278
+ get: function() {
279
+ return stripTrailingNewline;
280
+ }
281
+ });
154
282
 
155
- //# sourceMappingURL=DefaultsStore-RlEkAWqT.cjs.map
283
+ //# sourceMappingURL=DefaultsStore-Cb7yMNHY.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultsStore-Cb7yMNHY.cjs","names":[],"sources":["../src/utils/interactive/SecretOptions.ts","../src/utils/interactive/DefaultsStore.ts"],"sourcesContent":["/**\n * Options whose value is a secret (a password, a client secret) and that may\n * be given without a value, so that frodo asks for it instead of the command\n * line carrying it (issue about `frodo conn set --password`, cli record 0034).\n *\n * Commander gives an optional-value option (`--password [password]`) the value\n * `true` when it is used bare, and the command then used `true` as the secret.\n * A real value of a secret option is always a string, so on a marked option\n * `true` can only mean \"used bare\": the resolver replaces it with what the\n * user types (or what arrives on stdin) before the action runs, and it never\n * reaches frodo-lib. The mark also drives everything else that must treat a\n * secret differently: it is masked in the command preview, never saved as a\n * default, and asked for without echo in the editor.\n *\n * Zero-import (commander types only), like EditableOptions and\n * PositionalArgs: the resolver, the preview and the defaults store all read it\n * without pulling in frodo-lib. The class that commands declare is\n * `SecretOption` in FrodoCommand.ts.\n */\n\nimport type { Command, Option } from 'commander';\n\n/** How a secret value is shown wherever the command is printed. */\nexport const SECRET_MASK = '********';\n\n/** Appended to the description of every secret option, so all of them say the same. */\nexport const SECRET_OPTION_HELP =\n 'Without a value, it is asked for (input hidden) or, when input is piped, read from stdin.';\n\n/**\n * The marker lives under a symbol on the option itself, as an own enumerable\n * property: FrodoCommand clones shared options with `{ ...option }`, which\n * keeps own properties and would lose a class.\n */\nconst SECRET_KEY = Symbol.for('frodo.secretOption');\n\n/** Marks an option as secret. Returns the same option. */\nexport function markSecret<T extends Option>(option: T): T {\n (option as unknown as Record<symbol, boolean>)[SECRET_KEY] = true;\n return option;\n}\n\n/** Whether the option was declared as a secret option. */\nexport function isSecretOption(option: Option): boolean {\n return (option as unknown as Record<symbol, boolean>)[SECRET_KEY] === true;\n}\n\n/** The long flag as typed (`--password`), or the whole flags string without one. */\nfunction longFlagOf(option: Option): string {\n return (\n option.flags.split(/[, ]+/).find((token) => token.startsWith('--')) ??\n option.flags\n );\n}\n\n/**\n * The secret options still waiting for a value, in declaration order: the\n * ones used bare, plus the mandatory ones that were left out altogether\n * (`mandatoryViolations` holds the flags of the deferred mandatory options).\n */\nexport function pendingSecretOptions(\n command: Command,\n mandatoryViolations: string[] = []\n): Option[] {\n return command.options.filter((option) => {\n if (!isSecretOption(option)) return false;\n const value = command.getOptionValue(option.attributeName());\n if (value === true) return true;\n return value === undefined && mandatoryViolations.includes(option.flags);\n });\n}\n\n/** Commander-shaped error for a secret that was given without a value and cannot be asked for. */\nexport function secretNeedsValueMessage(option: Option): string {\n return `error: option '${option.flags}' was given without a value, and there is no way to ask for it here. Pipe the value on stdin, or give it as ${longFlagOf(option)} <value>.`;\n}\n\n/** Commander-shaped error for a bare secret whose prompt was declined (Escape or an empty answer). */\nexport function secretDeclinedMessage(option: Option): string {\n return `error: option '${option.flags}' was given without a value.`;\n}\n\n/** Commander-shaped error for several bare secrets when stdin is the only source. */\nexport function secretsShareStdinMessage(options: Option[]): string {\n return `error: ${options.map((option) => `'${longFlagOf(option)}'`).join(' and ')} were given without a value, but stdin can supply only one. Give the others on the command line.`;\n}\n\n/** Commander-shaped error for a bare secret when stdin was piped but empty. */\nexport function secretStdinEmptyMessage(option: Option): string {\n return `error: option '${option.flags}' was given without a value, and nothing was piped on stdin.`;\n}\n\n/** Drops one trailing line break (`\\n` or `\\r\\n`) from piped input, and nothing else: a secret may end in a space. */\nexport function stripTrailingNewline(text: string): string {\n return text.replace(/\\r?\\n$/, '');\n}\n\n/** The code of the errors above. */\nexport const SECRET_VALUE_MISSING_CODE = 'frodo.secretValueMissing';\n","import fs from 'fs';\nimport os from 'os';\nimport path from 'path';\nimport type { Command, Option } from 'commander';\nimport { isSecretOption } from './SecretOptions';\n\n/**\n * Persistent per-command defaults (docs/INTERACTIVE-COMMANDS.md):\n * values committed through the invocation editor with --save-defaults\n * land here and become the starting values for FUTURE runs of the same\n * command. Deliberately a sibling of SettingsStore (plain user\n * preferences, not secrets; corrupt file = empty, never a failure):\n * ~/.frodo/Defaults.json, keyed by the command's full path\n * (\"journey list\"), then by the option's attributeName:\n *\n * { \"journey list\": { \"long\": true }, \"esv secret list\": { \"flat\": \"all\" } }\n *\n * PRECEDENCE (the plan's chain: explicit CLI flag > env var > persisted\n * default > built-in default) is enforced by the RESOLUTION PASS, not\n * here -- this module only reads/writes the store. The pass applies a\n * persisted value only when the option has no value from flag or env\n * (source undefined or 'default'), writing it with source 'cli': a\n * persisted default is user-authored configuration -- the serializer's\n * \"only user-provided tokens\" rule and the editor's (current: x)\n * display must both see it as real input.\n */\n\nconst DEFAULTS_FILENAME = 'Defaults.json';\n\n/** A single command's persisted defaults: attributeName -> value. */\nexport type CommandDefaults = Record<string, unknown>;\n\n/** The whole store: full command path -> that command's defaults. */\nexport type DefaultsStore = Record<string, CommandDefaults>;\n\n/**\n * Test seam: overrides the ~/.frodo base directory for the duration of\n * a test (jest workers share process.env.HOME, and os.homedir() can\n * cache -- an env fiddle in one test leaks into its siblings).\n * Production callers never touch this.\n */\nlet baseDirOverride: string | undefined;\n\n/** FOR TESTS ONLY: redirects the store's base directory (undefined = ~/.frodo). */\nexport function setDefaultsBaseDirForTests(dir: string | undefined): void {\n baseDirOverride = dir;\n}\n\nexport function getDefaultsPath(): string {\n return path.join(\n baseDirOverride ?? path.join(os.homedir(), '.frodo'),\n DEFAULTS_FILENAME\n );\n}\n\n/** Reads the store; missing/corrupt file = empty store. */\nexport function readDefaultsStore(): DefaultsStore {\n try {\n const parsed = JSON.parse(fs.readFileSync(getDefaultsPath(), 'utf8'));\n return typeof parsed === 'object' && parsed !== null ? parsed : {};\n } catch {\n return {};\n }\n}\n\n/** Writes the store (creating ~/.frodo as needed). */\nexport function writeDefaultsStore(store: DefaultsStore): void {\n const file = getDefaultsPath();\n fs.mkdirSync(path.dirname(file), { recursive: true });\n fs.writeFileSync(file, JSON.stringify(store, null, 2));\n}\n\n/**\n * The `frodo x y z` path of the command (root name + ancestors + this) --\n * the store's key. Matches CommandPreview's commandPath; duplicated here\n * to keep this module free of the preview graph (the store must load in\n * tests that mock frodo-lib wholesale, same constraint as the other\n * zero-import modules in this directory).\n */\nexport function commandStoreKey(command: Command): string {\n const names: string[] = [];\n for (\n let cursor: Command | undefined = command;\n cursor;\n cursor = cursor.parent\n ) {\n names.unshift(cursor.name());\n }\n return names.join(' ');\n}\n\n/** The persisted defaults for one command (empty when none). */\nexport function readCommandDefaults(command: Command): CommandDefaults {\n return readDefaultsStore()[commandStoreKey(command)] ?? {};\n}\n\n/**\n * Merges `values` into the command's persisted defaults (a partial\n * save: only the options committed this session change).\n */\nexport function saveCommandDefaults(\n command: Command,\n values: CommandDefaults\n): void {\n const store = readDefaultsStore();\n const key = commandStoreKey(command);\n // A secret is never written to disk, whatever the editor committed.\n const secrets = new Set(\n command.options.filter(isSecretOption).map((o) => o.attributeName())\n );\n const safe = Object.fromEntries(\n Object.entries(values).filter(([name]) => !secrets.has(name))\n );\n store[key] = { ...(store[key] ?? {}), ...safe };\n writeDefaultsStore(store);\n}\n\n/** Drops one command's defaults entirely (frodo settings defaults --clear). */\nexport function clearCommandDefaults(command: Command): void {\n const store = readDefaultsStore();\n delete store[commandStoreKey(command)];\n writeDefaultsStore(store);\n}\n\n/**\n * Drops one command's defaults by its verbatim store path -- the\n * `frodo settings defaults --clear <path>` form. Path-keyed (not\n * Command-keyed) on purpose: clearing must work even when the command's\n * option set changed since the save.\n */\nexport function clearDefaultsByPath(commandPath: string): void {\n const store = readDefaultsStore();\n delete store[commandPath];\n writeDefaultsStore(store);\n}\n\n/**\n * The persisted values that still make sense for this command: keys the\n * command actually declares as options (the store outlives code -- a\n * removed or renamed option's stale entry is skipped, not applied).\n * Returns attributeName -> value.\n */\nexport function applicableCommandDefaults(command: Command): CommandDefaults {\n const persisted = readCommandDefaults(command);\n const known = new Set(\n command.options\n .filter((option) => !isSecretOption(option))\n .map((option) => option.attributeName())\n );\n return Object.fromEntries(\n Object.entries(persisted).filter(([name]) => known.has(name))\n );\n}\n\n/**\n * Whether `option` may take a persisted default this invocation: it has\n * NO value from flag or env. Commander source semantics: an untouched\n * option with a built-in default reads (value, 'default'); one without\n * any default reads (undefined, undefined). Both mean \"the user did not\n * provide anything\" -- the persisted default may fill the gap. Anything\n * else ('cli', 'env', 'config'...) means the user (or this pass) already\n * authored a value -- the persisted default must NOT override it.\n */\nexport function optionMissingUserValue(\n command: Command,\n option: Option\n): boolean {\n const source = command.getOptionValueSource(option.attributeName());\n return source === undefined || source === 'default';\n}\n"],"mappings":";;;;;;;;;AAuBA,MAAa,cAAc;;AAG3B,MAAa,qBACX;;;;;;AAOF,MAAM,aAAa,OAAO,IAAI,oBAAoB;;AAGlD,SAAgB,WAA6B,QAAc;CACzD,OAA+C,cAAc;CAC7D,OAAO;AACT;;AAGA,SAAgB,eAAe,QAAyB;CACtD,OAAQ,OAA8C,gBAAgB;AACxE;;AAGA,SAAS,WAAW,QAAwB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,OAAO,YACZ,OAAO,QAAQ,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,MAAM,IAAI,IAAI,CAAC,CAC9D;AACF;;;;;;;;;;AAWA,SAAgB,uBACd,SACA,QACS;CACT,MAAM,SAAS,QAAQ,qBAAqB,OAAO,cAAc,CAAC;CAClE,OAAO,WAAW,KAAA,KAAa,WAAW;AAC5C"}
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
2
2
  const require_Console = require("./Console-BwGVpCp2.cjs");
3
- const require_EscapableSelectPrompt = require("./EscapableSelectPrompt-Qp8BKiAa.cjs");
3
+ const require_EscapableSelectPrompt = require("./EscapableSelectPrompt-DCkRKbxL.cjs");
4
4
  //#region src/utils/interactive/EntityPickers.ts
5
5
  var EntityPickers_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
6
6
  deferEntityPicks: () => deferEntityPicks,
@@ -51,6 +51,11 @@ async function resolveEntityPicks(command) {
51
51
  if (!require_EscapableSelectPrompt.canPrompt()) return true;
52
52
  for (const pick of getEntityPicks(command)) {
53
53
  if (command.getOptionValue(pick.name)) continue;
54
+ const [blocker] = require_EscapableSelectPrompt.blockersOf(command, pick.name, pick.scopedBy);
55
+ if (blocker) {
56
+ require_Console.verboseMessage(`Not offering a ${pick.kind} to pick: it cannot be used with ${blocker.flags}.`);
57
+ continue;
58
+ }
54
59
  let entities;
55
60
  try {
56
61
  entities = await pick.load();
@@ -65,7 +70,7 @@ async function resolveEntityPicks(command) {
65
70
  }
66
71
  let chosen;
67
72
  for (;;) {
68
- const { liveOptionPreviewFor } = await Promise.resolve().then(() => require("./ResolveInteractiveInputs-BZUtDvaq.cjs")).then((n) => n.ResolveInteractiveInputs_exports);
73
+ const { liveOptionPreviewFor } = await Promise.resolve().then(() => require("./ResolveInteractiveInputs-up9YUHQr.cjs")).then((n) => n.ResolveInteractiveInputs_exports);
69
74
  chosen = await require_EscapableSelectPrompt.escapableSelect({
70
75
  message: pick.message ?? `Select ${pick.kind} to act on:`,
71
76
  hint: require_EscapableSelectPrompt.editableOptionsHint(command),
@@ -80,7 +85,7 @@ async function resolveEntityPicks(command) {
80
85
  })
81
86
  });
82
87
  if (chosen !== require_EscapableSelectPrompt.RIGHT) break;
83
- const { runInvocationEditorForCommand } = await Promise.resolve().then(() => require("./ResolveInteractiveInputs-BZUtDvaq.cjs")).then((n) => n.ResolveInteractiveInputs_exports);
88
+ const { runInvocationEditorForCommand } = await Promise.resolve().then(() => require("./ResolveInteractiveInputs-up9YUHQr.cjs")).then((n) => n.ResolveInteractiveInputs_exports);
84
89
  await runInvocationEditorForCommand(command);
85
90
  }
86
91
  if (chosen === require_EscapableSelectPrompt.EXIT_ALL) {
@@ -102,7 +107,13 @@ async function resolveEntityPicks(command) {
102
107
  return true;
103
108
  }
104
109
  function apply(command, pick, entity) {
105
- command.setOptionValueWithSource(pick.name, pick.label(entity), "cli");
110
+ const result = require_EscapableSelectPrompt.commitOption(command, pick.name, pick.label(entity), { consume: pick.scopedBy });
111
+ if (result.status === "blocked") {
112
+ const option = command.options.find((candidate) => candidate.attributeName() === pick.name);
113
+ if (option) require_EscapableSelectPrompt.failWithConflict(command, option, result.blockedBy);
114
+ return;
115
+ }
116
+ for (const dropped of result.cleared) require_Console.verboseMessage(`Dropped ${dropped.flags}: it cannot be used with the ${pick.kind} that was picked.`);
106
117
  }
107
118
  //#endregion
108
119
  Object.defineProperty(exports, "EntityPickers_exports", {
@@ -142,4 +153,4 @@ Object.defineProperty(exports, "resolveEntityPicks", {
142
153
  }
143
154
  });
144
155
 
145
- //# sourceMappingURL=EntityPickers-NlzD18p4.cjs.map
156
+ //# sourceMappingURL=EntityPickers-DTtIJ6xb.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityPickers-DTtIJ6xb.cjs","names":["canPrompt","blockersOf","escapableSelect","editableOptionsHint","RIGHT","EXIT_ALL","EXIT_ALL_SIGNAL","ESCAPE","commitOption"],"sources":["../src/utils/interactive/EntityPickers.ts"],"sourcesContent":["/**\n * Entity pickers (docs/INTERACTIVE-COMMANDS.md, post-auth pickers).\n *\n * A command whose target-entity option (`-i/--secret-id`, `-i/--tree-id`\n * etc.) was left unspecified can offer a dropdown populated from the live\n * system -- a PingAM server, a PingIDM instance, or an Identity Cloud\n * tenant, whichever the command targets -- instead of failing or forcing\n * `-a`. The data source is per-command: the spec's `load` is whatever read\n * function the command family's ops layer provides (`frodo.authn.journey\n * .readJourneys` for PingAM, `frodo.cloud.secret.readSecrets` for cloud,\n * and so on), so each picker is deployment-type-correct by construction;\n * nothing here assumes a particular deployment type.\n *\n * The flow spans two stages:\n *\n * 1. SETUP: the command declares its specs with `deferEntityPicks(command,\n * [...])`. The resolver (ResolveInteractiveInputs) reads the registry to\n * learn which options are entity-pickable, and when such an option is\n * the missing half of a mandatory/one-of rule, it SKIPS the free-text\n * value step for it (asking the user to type an id by hand would defeat\n * the picker's purpose) and leaves the option unset.\n *\n * 2. ACTION BODY: after `getTokens()` succeeds (the loaders need tokens),\n * the command calls `resolveEntityPicks(command)`, which runs the\n * dropdown for every still-unspecified pickable option. A prompt only\n * happens when the gate allows prompting (canPrompt()), the option is\n * still unspecified, and the loader returned at least one entity. Every\n * other path is a no-op, so non-interactive behavior stays\n * byte-identical: no TTY, `--no-prompt`, FRODO_NO_PROMPT, FRODO_TEST,\n * or an empty system all leave `options.<name>` untouched and the\n * action proceeds exactly as before (usually to its existing \"required\"\n * error).\n *\n * Escape backs out of a picker without setting anything -- callers treat\n * that as \"declined to run\" and return (same shape as a failed\n * getTokens()). A returned `false` from `resolveEntityPicks` is the\n * caller's signal to stop -- that includes a failing loader, which must\n * never read as \"picks satisfied\" (the delete-family actions'\n * `(options.all || (await resolveEntityPicks(command)))` would otherwise\n * fall through to delete-all on a transient read error).\n */\n\nimport { Command } from 'commander';\nimport { printError, verboseMessage } from '../Console';\nimport { editableOptionsHint } from './EditableOptions';\nimport { escapableSelect, ESCAPE, RIGHT } from './EscapableSelectPrompt';\nimport { EXIT_ALL, EXIT_ALL_SIGNAL } from './ExitAll';\nimport { blockersOf, commitOption, failWithConflict } from './OptionConflicts';\nimport { canPrompt } from './PromptGateState';\n\n/**\n * Loads the candidate entities for a picker. Returns the raw skeletons;\n * `label`/`description` turn an entity into the picker row. A failing load\n * (host unreachable, permission denied) DECLINES the pick: resolveEntityPicks\n * returns false so the command stops instead of falling through to its\n * destructive --all branch.\n */\nexport type EntityPickLoader<T> = () => Promise<T[]>;\n\n/**\n * The registry-facing shape of an entity pick spec: the entity type is\n * erased (functions accept `any`) so heterogenous spec lists type-check.\n * `entityPick<T>` keeps the typed surface for call sites; the erasure only\n * widens what the registry stores.\n */\nexport type EntityPickSpec<T = any> = {\n /**\n * Attribute name of the option being filled (e.g. `secretId`). The value\n * written back is the entity's rendered label -- for every current\n * command family, the option wants the entity id/name, so the label IS\n * the value (loaders are expected to feed the label with the id).\n */\n name: string;\n /** Loads the candidates from the live system. */\n load: EntityPickLoader<T>;\n /** Renders an entity as both the picker row label and the option value. */\n label: (entity: T) => string;\n /** Optional second line shown as the row's dimmed description. */\n description?: (entity: T) => string | undefined;\n /** Prompt message; defaults to \"Select <entity kind>:\". */\n message?: string;\n /** Noun for the default message, e.g. \"secret\". */\n kind: string;\n /**\n * Attribute names of options the loader reads to narrow the list (`-c`\n * narrows the mappings that are offered). They conflict with the picked\n * option on the command line, so the pick replaces them: once it is made\n * they are dropped from the command, and the command that runs (and its\n * preview) is the one you could type again.\n */\n scopedBy?: string[];\n};\n\nconst pendingEntityPicks = new WeakMap<Command, EntityPickSpec<unknown>[]>();\n\n/**\n * Registers entity pickers on a command. Called from the command's setup\n * (module scope of the command file) so the resolver can consult the\n * registry and the action body can run the picks with one bare call.\n * `T` defaults to unknown, so heterogenous spec lists type-check.\n */\nexport function deferEntityPicks(\n command: Command,\n picks: EntityPickSpec[]\n): void {\n pendingEntityPicks.set(command, [\n ...(pendingEntityPicks.get(command) ?? []),\n ...picks,\n ]);\n}\n\n/**\n * The entity pickers registered on a command (empty when none). Read by\n * ResolveInteractiveInputs to know which options it should NOT free-text\n * prompt for -- those belong to the post-auth dropdown.\n */\nexport function getEntityPicks(command: Command): EntityPickSpec<unknown>[] {\n return pendingEntityPicks.get(command) ?? [];\n}\n\n/**\n * Whether the named option has an entity picker registered on this\n * command. Convenience for the resolver's value steps.\n */\nexport function hasEntityPick(command: Command, name: string): boolean {\n return getEntityPicks(command).some((pick) => pick.name === name);\n}\n\n/**\n * Defines an entity picker for one option. The returned spec is registered\n * via `deferEntityPicks`.\n */\nexport function entityPick<T>(spec: EntityPickSpec<T>): EntityPickSpec<T> {\n return spec;\n}\n\n/**\n * Runs every entity pick registered for this command whose option is still\n * unspecified. No-op when prompting is disallowed. Returns false when the\n * user escaped the picker -- the caller should return without running the\n * action's body (same shape as a failed getTokens()).\n */\nexport async function resolveEntityPicks(command: Command): Promise<boolean> {\n if (!canPrompt()) return true;\n for (const pick of getEntityPicks(command)) {\n // Commands branch on the RAW option value (options.secretId); writing\n // through setOptionValueWithSource keeps both that object and the\n // resolver's own getOptionValue reads consistent.\n if (command.getOptionValue(pick.name)) continue;\n // An option the user gave cannot be combined with the one this pick\n // fills (`-a` with `-i`): picking would build a command the CLI rejects.\n const [blocker] = blockersOf(command, pick.name, pick.scopedBy);\n if (blocker) {\n verboseMessage(\n `Not offering a ${pick.kind} to pick: it cannot be used with ${blocker.flags}.`\n );\n continue;\n }\n let entities: unknown[];\n try {\n entities = await pick.load();\n } catch (error) {\n // Loader failure is a DECLINED pick, not a satisfied one: returning\n // true here lets `(options.all || (await resolveEntityPicks(...)))`\n // fall through to the destructive --all branch (real incident\n // 2026-10-14: a transient 400 on the secrets-list read made\n // `esv secret delete` run delete-all on a live tenant). False =\n // \"stop without running the action body\", same contract as escape.\n printError(error as Error, `Error reading ${pick.kind}s`);\n return false;\n }\n if (entities.length === 0) return true;\n if (entities.length === 1) {\n // Single-option paradigm (gap-fill prompts): one candidate is no\n // choice -- auto-select it, mirroring the single-profile host\n // picker and the single-child stub auto-descend.\n apply(command, pick, entities[0]);\n continue;\n }\n // The → key (armed by the hint) opens the invocation\n // editor, then re-prompts this picker -- discover-and-edit without\n // leaving the flow. Editorial loop, ESCAPE still declines the pick.\n let chosen: unknown | typeof ESCAPE | typeof RIGHT;\n for (;;) {\n const { liveOptionPreviewFor } =\n await import('../../cli/ResolveInteractiveInputs');\n chosen = await escapableSelect<unknown>({\n message: pick.message ?? `Select ${pick.kind} to act on:`,\n hint: editableOptionsHint(command),\n // LIVE footer: the highlighted entity's label (the exact value\n // the real apply writes) shadows the target option per render,\n // so the footer shows the command gaining that pick BEFORE\n // <enter> commits. `pick.label` maps entity -> option value --\n // the same mapping the committed apply uses. An empty filtered\n // list highlights nothing: the callback then renders the\n // committed state (undefined -> undefined) instead of crashing\n // on the spec's `entity._id`-style label.\n preview: liveOptionPreviewFor(command, pick.name, (entity) =>\n entity === undefined ? undefined : pick.label(entity)\n ),\n choices: entities.map((entity) => {\n const description = pick.description?.(entity);\n return {\n value: entity,\n name: pick.label(entity),\n ...(description !== undefined ? { description } : {}),\n };\n }),\n });\n if (chosen !== RIGHT) break;\n const { runInvocationEditorForCommand } =\n await import('../../cli/ResolveInteractiveInputs');\n await runInvocationEditorForCommand(command);\n }\n if (chosen === EXIT_ALL) {\n // Exit-all: revoke the deferred authoring print (nothing may be\n // left behind for an abandoned flow) and THROW the unwind signal\n // -- it propagates through the action body to app.ts's top-level\n // handler, ending the session from any nesting depth.\n const { revokeAuthoringPrint } = await import('./AuthoringPrintState');\n revokeAuthoringPrint();\n throw EXIT_ALL_SIGNAL;\n }\n if (chosen === ESCAPE) {\n // User declined to run (single ESC): revoke the deferred authoring\n // print so the postAction fallback (non-auth commands' flush site)\n // leaves nothing behind for an abandoned flow -- same contract as\n // the one-of error path skipping postAction entirely.\n const { revokeAuthoringPrint } = await import('./AuthoringPrintState');\n revokeAuthoringPrint();\n return false;\n }\n apply(command, pick, chosen);\n }\n // The deferred authoring print: this\n // function is the flush site for commands whose entity picks are the\n // last command-mutating interactive step. Two shapes exist: pick-first\n // (`(pick) && (await getTokens())` -- picks run BEFORE auth) and\n // pick-after-auth (esv variable set, secret store mapping delete --\n // picks run AFTER auth). In both, flushing HERE puts the eventual\n // command directly above the action's results. Gated on auth already\n // having succeeded: a pick-first flow whose auth then fails must not\n // print (the command never ran). When auth has NOT succeeded yet, the\n // getTokens wrapper flushes instead (no picks pending -> it doesn't\n // skip). Non-interactive sessions (canPrompt false, early return)\n // never reach this.\n {\n const { authSucceededForFlush, flushAuthoringPrint } =\n await import('./AuthoringPrintState');\n if (authSucceededForFlush()) {\n flushAuthoringPrint();\n }\n }\n return true;\n}\n\nfunction apply(\n command: Command,\n pick: EntityPickSpec<unknown>,\n entity: unknown\n): void {\n const result = commitOption(command, pick.name, pick.label(entity), {\n consume: pick.scopedBy,\n });\n if (result.status === 'blocked') {\n const option = command.options.find(\n (candidate) => candidate.attributeName() === pick.name\n );\n if (option) failWithConflict(command, option, result.blockedBy);\n return;\n }\n for (const dropped of result.cleared) {\n verboseMessage(\n `Dropped ${dropped.flags}: it cannot be used with the ${pick.kind} that was picked.`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AA6FA,MAAM,qCAAqB,IAAI,QAA4C;;;;;;;AAQ3E,SAAgB,iBACd,SACA,OACM;CACN,mBAAmB,IAAI,SAAS,CAC9B,GAAI,mBAAmB,IAAI,OAAO,KAAK,CAAC,GACxC,GAAG,KACL,CAAC;AACH;;;;;;AAOA,SAAgB,eAAe,SAA6C;CAC1E,OAAO,mBAAmB,IAAI,OAAO,KAAK,CAAC;AAC7C;;;;;AAMA,SAAgB,cAAc,SAAkB,MAAuB;CACrE,OAAO,eAAe,OAAO,CAAC,CAAC,MAAM,SAAS,KAAK,SAAS,IAAI;AAClE;;;;;AAMA,SAAgB,WAAc,MAA4C;CACxE,OAAO;AACT;;;;;;;AAQA,eAAsB,mBAAmB,SAAoC;CAC3E,IAAI,CAACA,8BAAAA,UAAU,GA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,8BAA8B,OAAO;EAC7C;EACA,IAAI,WAAWC,8BAAAA,UAAU;GAKvB,MAAM,EAAE,yBAAyB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oCAAA,CAAA,CAAA,CAAA,MAAA,MAAA,EAAA,2BAAA;GACvC,qBAAqB;GACrB,MAAMC,8BAAAA;EACR;EACA,IAAI,WAAWC,8BAAAA,QAAQ;GAKrB,MAAM,EAAE,yBAAyB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oCAAA,CAAA,CAAA,CAAA,MAAA,MAAA,EAAA,2BAAA;GACvC,qBAAqB;GACrB,OAAO;EACT;EACA,MAAM,SAAS,MAAM,MAAM;CAC7B;CAaA;EACE,MAAM,EAAE,uBAAuB,wBAC7B,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oCAAA,CAAA,CAAA,CAAA,MAAA,MAAA,EAAA,2BAAA;EACR,IAAI,sBAAsB,GACxB,oBAAoB;CAExB;CACA,OAAO;AACT;AAEA,SAAS,MACP,SACA,MACA,QACM;CACN,MAAM,SAASC,8BAAAA,aAAa,SAAS,KAAK,MAAM,KAAK,MAAM,MAAM,GAAG,EAClE,SAAS,KAAK,SAChB,CAAC;CACD,IAAI,OAAO,WAAW,WAAW;EAC/B,MAAM,SAAS,QAAQ,QAAQ,MAC5B,cAAc,UAAU,cAAc,MAAM,KAAK,IACpD;EACA,IAAI,QAAQ,8BAAA,iBAAiB,SAAS,QAAQ,OAAO,SAAS;EAC9D;CACF;CACA,KAAK,MAAM,WAAW,OAAO,SAC3B,gBAAA,eACE,WAAW,QAAQ,MAAM,+BAA+B,KAAK,KAAK,kBACpE;AAEJ"}
@@ -163,15 +163,167 @@ function canPrompt() {
163
163
  return !!process.stdin.isTTY && !!process.stdout.isTTY;
164
164
  }
165
165
  //#endregion
166
+ //#region src/utils/interactive/OptionConflicts.ts
167
+ /** The option names (attribute names) the resolver itself has set, per command. */
168
+ const resolverSet = /* @__PURE__ */ new WeakMap();
169
+ /** The code commander uses for a parse-time conflict; the safety net keeps it. */
170
+ const CONFLICTING_OPTION_CODE = "commander.conflictingOption";
171
+ /**
172
+ * The attribute names `.conflicts()` registered on an option. Commander
173
+ * keeps them in `conflictsWith` but its type declarations leave the
174
+ * property out; this is the one place that says so.
175
+ */
176
+ function declaredConflicts(option) {
177
+ return option.conflictsWith;
178
+ }
179
+ /** The option with this attribute name (the first one, when a negatable pair shares it). */
180
+ function optionOf(command, attribute) {
181
+ return command.options.find((option) => option.attributeName() === attribute);
182
+ }
183
+ /**
184
+ * Whether the option holds a value that commander counts for conflicts: one
185
+ * that is defined and did not come from the default (command line, env, or a
186
+ * value the resolver committed). Mirrors Command#_checkForConflictingLocalOptions.
187
+ */
188
+ function isActive(command, attribute) {
189
+ return command.getOptionValue(attribute) !== void 0 && command.getOptionValueSource(attribute) !== "default";
190
+ }
191
+ /**
192
+ * The options that conflict with `attribute`, from either side's
193
+ * declaration (record 0032 asks for both, but a conflict declared on one
194
+ * side still fires in commander).
195
+ */
196
+ function conflictsOf(command, attribute) {
197
+ const own = optionOf(command, attribute);
198
+ const found = /* @__PURE__ */ new Map();
199
+ for (const option of command.options) {
200
+ const name = option.attributeName();
201
+ if (name === attribute || found.has(name)) continue;
202
+ if (declaredConflicts(option).includes(attribute) || own !== void 0 && declaredConflicts(own).includes(name)) found.set(name, option);
203
+ }
204
+ return [...found.values()];
205
+ }
206
+ /** The conflicting options that currently hold a value. */
207
+ function activeConflicts(command, attribute) {
208
+ return conflictsOf(command, attribute).filter((option) => isActive(command, option.attributeName()));
209
+ }
210
+ /**
211
+ * The conflicting options that stand in the way for good: active, and typed
212
+ * by the user (command line or environment) rather than set by the resolver.
213
+ */
214
+ function blockersOf(command, attribute, ignore = []) {
215
+ const set = resolverSet.get(command);
216
+ return activeConflicts(command, attribute).filter((option) => !ignore.includes(option.attributeName()) && !set?.has(option.attributeName()));
217
+ }
218
+ /**
219
+ * Splits one-of / all-of group members into the ones the user can still
220
+ * pick and the ones hidden by an option already given.
221
+ */
222
+ function selectableMembers(command, members) {
223
+ const selectable = [];
224
+ const hidden = [];
225
+ for (const name of members) {
226
+ const option = optionOf(command, name);
227
+ const [blockedBy] = blockersOf(command, name);
228
+ if (option && blockedBy) hidden.push({
229
+ option,
230
+ blockedBy
231
+ });
232
+ else selectable.push(name);
233
+ }
234
+ return {
235
+ selectable,
236
+ hidden
237
+ };
238
+ }
239
+ /**
240
+ * The only way the resolver sets an option. Returns what happened instead
241
+ * of throwing, so the caller can word the refusal for its own prompt.
242
+ */
243
+ function commitOption(command, attribute, value, { replace = true, consume = [] } = {}) {
244
+ const set = resolverSet.get(command) ?? /* @__PURE__ */ new Set();
245
+ const active = activeConflicts(command, attribute);
246
+ const blocking = active.filter((option) => {
247
+ const name = option.attributeName();
248
+ if (consume.includes(name)) return false;
249
+ return !replace || !set.has(name);
250
+ });
251
+ if (blocking.length > 0) return {
252
+ status: "blocked",
253
+ blockedBy: blocking[0]
254
+ };
255
+ for (const option of active) {
256
+ const name = option.attributeName();
257
+ const fallback = Array.isArray(option.defaultValue) ? [...option.defaultValue] : option.defaultValue;
258
+ command.setOptionValueWithSource(name, fallback, "default");
259
+ set.delete(name);
260
+ }
261
+ command.setOptionValueWithSource(attribute, value, "cli");
262
+ set.add(attribute);
263
+ resolverSet.set(command, set);
264
+ return {
265
+ status: "committed",
266
+ cleared: active
267
+ };
268
+ }
269
+ /** How commander words one side of a conflict (see Command#_conflictingOption). */
270
+ function describeSide(command, option) {
271
+ const attribute = option.attributeName();
272
+ const value = command.getOptionValue(attribute);
273
+ const negated = command.options.find((candidate) => candidate.negate && candidate.attributeName() === attribute);
274
+ const best = negated && value === false ? negated : command.options.find((candidate) => !candidate.negate && candidate.attributeName() === attribute) ?? option;
275
+ return command.getOptionValueSource(attribute) === "env" && best.envVar ? `environment variable '${best.envVar}'` : `option '${best.flags}'`;
276
+ }
277
+ /** Commander's own text for a conflict, so the refusal reads like the parse-time one. */
278
+ function conflictMessage(command, option, other) {
279
+ return `error: ${describeSide(command, option)} cannot be used with ${describeSide(command, other)}`;
280
+ }
281
+ /** Ends the command the way commander does for a conflict. */
282
+ function failWithConflict(command, option, other) {
283
+ command.error(conflictMessage(command, option, other), { code: CONFLICTING_OPTION_CODE });
284
+ }
285
+ /**
286
+ * The safety net, run once the resolver is done: whatever happened on the
287
+ * way, no two active options may conflict. Throws commander's error for the
288
+ * first pair it finds.
289
+ */
290
+ function assertNoConflicts(command) {
291
+ for (const option of command.options) {
292
+ const attribute = option.attributeName();
293
+ if (!isActive(command, attribute)) continue;
294
+ const [other] = activeConflicts(command, attribute);
295
+ if (other) failWithConflict(command, option, other);
296
+ }
297
+ }
298
+ /** One line for a picker or the editor: what it leaves out, and why. */
299
+ function hiddenNote(hidden) {
300
+ return `Not offered, because it cannot be combined with an option already given: ${hidden.map(({ option, blockedBy }) => `${option.flags} (with ${blockedBy.flags})`).join(", ")}.`;
301
+ }
302
+ //#endregion
166
303
  //#region src/utils/interactive/EditableOptions.ts
167
304
  /**
168
305
  * The command's editable options for this invocation -- the exact
169
306
  * candidate list the invocation editor offers: options not yet valued,
170
307
  * PLUS already-valued ones (editing what was given
171
308
  * is the point of an editor; the value step pre-fills the current
172
- * value). Non-editable machinery (help/version/prompting) never counts.
309
+ * value). Non-editable machinery (help/version/prompting) never counts,
310
+ * and neither does an option that cannot be combined with one the user
311
+ * already gave (a command line the CLI would reject, issue #967).
173
312
  */
174
313
  function editableOptionalOptions(command) {
314
+ const { selectable } = selectableMembers(command, machineryFree(command).map((option) => option.attributeName()));
315
+ return machineryFree(command).filter((option) => selectable.includes(option.attributeName()));
316
+ }
317
+ /**
318
+ * The options the editor would offer if nothing conflicted, and the ones
319
+ * it leaves out because an option the user already gave cannot be combined
320
+ * with them (cli record 0032, issue #967).
321
+ */
322
+ function editableOptionsHiddenByConflicts(command) {
323
+ return selectableMembers(command, machineryFree(command).map((option) => option.attributeName())).hidden;
324
+ }
325
+ /** The command's options minus the help/version/prompting machinery. */
326
+ function machineryFree(command) {
175
327
  return command.options.filter((option) => {
176
328
  if (option.name() === "help" || option.name() === "help-more" || option.name() === "help-all" || option.name() === "version" || option.name() === "prompt" || option.name() === "no-prompt" || option.name() === "edit" || option.name() === "save-defaults") return false;
177
329
  return true;
@@ -2260,12 +2412,30 @@ Object.defineProperty(exports, "armEscapeGrace", {
2260
2412
  return armEscapeGrace;
2261
2413
  }
2262
2414
  });
2415
+ Object.defineProperty(exports, "assertNoConflicts", {
2416
+ enumerable: true,
2417
+ get: function() {
2418
+ return assertNoConflicts;
2419
+ }
2420
+ });
2421
+ Object.defineProperty(exports, "blockersOf", {
2422
+ enumerable: true,
2423
+ get: function() {
2424
+ return blockersOf;
2425
+ }
2426
+ });
2263
2427
  Object.defineProperty(exports, "canPrompt", {
2264
2428
  enumerable: true,
2265
2429
  get: function() {
2266
2430
  return canPrompt;
2267
2431
  }
2268
2432
  });
2433
+ Object.defineProperty(exports, "commitOption", {
2434
+ enumerable: true,
2435
+ get: function() {
2436
+ return commitOption;
2437
+ }
2438
+ });
2269
2439
  Object.defineProperty(exports, "createPrompt", {
2270
2440
  enumerable: true,
2271
2441
  get: function() {
@@ -2296,6 +2466,12 @@ Object.defineProperty(exports, "editableOptionalOptions", {
2296
2466
  return editableOptionalOptions;
2297
2467
  }
2298
2468
  });
2469
+ Object.defineProperty(exports, "editableOptionsHiddenByConflicts", {
2470
+ enumerable: true,
2471
+ get: function() {
2472
+ return editableOptionsHiddenByConflicts;
2473
+ }
2474
+ });
2299
2475
  Object.defineProperty(exports, "editableOptionsHint", {
2300
2476
  enumerable: true,
2301
2477
  get: function() {
@@ -2308,6 +2484,12 @@ Object.defineProperty(exports, "escapableSelect", {
2308
2484
  return escapableSelect;
2309
2485
  }
2310
2486
  });
2487
+ Object.defineProperty(exports, "failWithConflict", {
2488
+ enumerable: true,
2489
+ get: function() {
2490
+ return failWithConflict;
2491
+ }
2492
+ });
2311
2493
  Object.defineProperty(exports, "firstLine", {
2312
2494
  enumerable: true,
2313
2495
  get: function() {
@@ -2326,6 +2508,12 @@ Object.defineProperty(exports, "frameStatusTitle", {
2326
2508
  return frameStatusTitle;
2327
2509
  }
2328
2510
  });
2511
+ Object.defineProperty(exports, "hiddenNote", {
2512
+ enumerable: true,
2513
+ get: function() {
2514
+ return hiddenNote;
2515
+ }
2516
+ });
2329
2517
  Object.defineProperty(exports, "isDownKey", {
2330
2518
  enumerable: true,
2331
2519
  get: function() {
@@ -2398,6 +2586,12 @@ Object.defineProperty(exports, "renderNavigationMenu", {
2398
2586
  return renderNavigationMenu;
2399
2587
  }
2400
2588
  });
2589
+ Object.defineProperty(exports, "selectableMembers", {
2590
+ enumerable: true,
2591
+ get: function() {
2592
+ return selectableMembers;
2593
+ }
2594
+ });
2401
2595
  Object.defineProperty(exports, "setNeverPrompt", {
2402
2596
  enumerable: true,
2403
2597
  get: function() {
@@ -2489,4 +2683,4 @@ Object.defineProperty(exports, "wrapLine", {
2489
2683
  }
2490
2684
  });
2491
2685
 
2492
- //# sourceMappingURL=EscapableSelectPrompt-Qp8BKiAa.cjs.map
2686
+ //# sourceMappingURL=EscapableSelectPrompt-DCkRKbxL.cjs.map