@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.
@@ -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/PositionalArgs.ts
5
5
  /**
6
6
  * Index of the default positional argument of that name on this command
@@ -150,7 +150,7 @@ async function resolveRealmPick(command) {
150
150
  const current = require_Console.state.getRealm();
151
151
  let choice;
152
152
  for (;;) {
153
- const { livePositionalPreviewFor, runInvocationEditorForCommand } = await Promise.resolve().then(() => require("./ResolveInteractiveInputs-BZUtDvaq.cjs")).then((n) => n.ResolveInteractiveInputs_exports);
153
+ const { livePositionalPreviewFor, runInvocationEditorForCommand } = await Promise.resolve().then(() => require("./ResolveInteractiveInputs-up9YUHQr.cjs")).then((n) => n.ResolveInteractiveInputs_exports);
154
154
  const answer = await require_EscapableSelectPrompt.escapableSelect({
155
155
  message: `Choose a realm (default: ${current}):`,
156
156
  default: current,
@@ -180,7 +180,7 @@ async function resolveRealmPick(command) {
180
180
  }
181
181
  require_Console.state.setRealm(choice);
182
182
  {
183
- const { setPositionalValueForCommand } = await Promise.resolve().then(() => require("./ResolveInteractiveInputs-BZUtDvaq.cjs")).then((n) => n.ResolveInteractiveInputs_exports);
183
+ const { setPositionalValueForCommand } = await Promise.resolve().then(() => require("./ResolveInteractiveInputs-up9YUHQr.cjs")).then((n) => n.ResolveInteractiveInputs_exports);
184
184
  setPositionalValueForCommand(command, "realm", choice.replace(/^\//, ""));
185
185
  }
186
186
  require_Console.verboseMessage(`Using realm ${choice}.`);
@@ -223,4 +223,4 @@ Object.defineProperty(exports, "setPositionalValue", {
223
223
  }
224
224
  });
225
225
 
226
- //# sourceMappingURL=RealmPickers-egCrSB9q.cjs.map
226
+ //# sourceMappingURL=RealmPickers-CU6P0yV8.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RealmPickers-egCrSB9q.cjs","names":["state","canPrompt","escapableSelect","editableOptionsHint","EXIT_ALL","EXIT_ALL_SIGNAL","RIGHT","ESCAPE"],"sources":["../src/utils/interactive/PositionalArgs.ts","../src/utils/interactive/RealmPickers.ts"],"sourcesContent":["/**\n * Positional-argument read/write helpers, split from\n * ResolveInteractiveInputs.ts into a zero-import module (the\n * CommandPreview/ActiveActionCommandState pattern): pure commander, no\n * frodo-lib, so both the resolver and the unit tests (which cannot import\n * the resolver's frodo-lib-heavy graph under this Jest setup -- see\n * src/app.commandWiring.test.ts's header comment) and the post-auth realm\n * picker's write-back share one implementation.\n */\n\nimport type { Command } from 'commander';\n\n/**\n * Index of the default positional argument of that name on this command\n * (commands omit default args via the FrodoCommand omits list, so the\n * index differs per command), or -1 when the command doesn't declare it.\n */\nexport function positionalIndex(command: Command, name: string): number {\n return command.registeredArguments.findIndex(\n (argument) => argument.name() === name\n );\n}\n\nexport function positionalValue(\n command: Command,\n name: string\n): string | undefined {\n const index = positionalIndex(command, name);\n if (index === -1) return undefined;\n const value = command.processedArgs?.[index];\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\n/**\n * Writes `value` into BOTH surfaces the CLI reads for a positional:\n *\n * - `processedArgs` is what the action handler's positional parameters\n * are sliced from (commander's action() wrapper slices\n * this.processedArgs).\n * - `args` (raw, options-removed user args) is what\n * handleDefaultArgsAndOpts iterates to copy default arguments into\n * frodo-lib state INSIDE the action body -- it does NOT read\n * processedArgs, so a processedArgs-only injection would be\n * overwritten with `undefined` the moment the action starts.\n * Verified against commander's _processArguments (fills processedArgs\n * from args, never writes back) and this repo's\n * handleDefaultArgsAndOpts (iterates command.args).\n *\n * `args` holds only user-supplied positional values; a gap-fill by\n * definition fills a position the user left empty, so extending/padding\n * with the injected value is safe. Pad with nulls for any inner\n * positions the user skipped (rare: inner default args are optional),\n * since args is positional.\n */\nexport function setPositionalValue(\n command: Command,\n name: string,\n value: string\n): void {\n const index = positionalIndex(command, name);\n if (index === -1) return;\n if (command.processedArgs) {\n command.processedArgs[index] = value;\n }\n if (Array.isArray(command.args)) {\n while (command.args.length < index) {\n command.args.push(null);\n }\n if (index === command.args.length) {\n command.args.push(value);\n } else if (command.args[index] == null) {\n command.args[index] = value;\n }\n }\n}\n","/**\n * Realm picker (docs/INTERACTIVE-COMMANDS.md, post-auth pickers).\n *\n * After authentication succeeds, a command whose realm argument was left\n * at its default can offer a dropdown of the target system's realms --\n * but ONLY when the system actually has more than one (a single-realm\n * tenant has no choice to offer; the default is already correct). The\n * pick fires from the getTokens wrapper (AuthenticateOps) immediately\n * after auth succeeds, so every command gets it without per-command\n * wiring; a prompt only happens when\n *\n * - the gate allows prompting (canPrompt()),\n * - the command declares a realm positional argument,\n * - a required connection input or option prompted the user to complete the\n * command,\n * - the user did not name a realm explicitly (argument value or\n * FRODO_REALM -- recorded by `noteRealmProvenance` during the\n * resolution pass, BEFORE frodo-lib maps the sentinel default to the\n * deployment type's realm during auth), and\n * - the target system reports more than one realm.\n *\n * Every other path is a no-op. Escape declines the offer and keeps the\n * deployment-type default -- unlike the entity pickers there is no\n * \"wrong\" continuation to protect here (the default is a valid choice),\n * so backing out just means \"keep the default\".\n *\n * The loader failing (permission denied on realm listing, older servers,\n * classic deployments where the endpoint differs) is swallowed and the\n * default kept: the command is about to run against the default realm\n * exactly as it did before the interactive layer existed.\n */\n\nimport { state } from '@rockcarver/frodo-lib';\nimport { Command } from 'commander';\nimport { verboseMessage } from '../Console';\nimport { editableOptionsHint } from './EditableOptions';\nimport { escapableSelect, ESCAPE, RIGHT } from './EscapableSelectPrompt';\nimport { EXIT_ALL, EXIT_ALL_SIGNAL } from './ExitAll';\nimport { positionalValue } from './PositionalArgs';\nimport { canPrompt } from './PromptGateState';\n\n/** frodo-lib's sentinel default for \"no realm chosen yet\". */\nconst DEFAULT_REALM_KEY = '__default__realm__';\n\n/** Cache of the realms read during this invocation (one fetch per run). */\nlet cachedRealms: { name: string; active: boolean }[] | undefined;\n\n/**\n * Whether the current invocation's realm was user-specified. Captured by\n * `noteRealmProvenance` during the resolution pass -- it CANNOT be\n * re-derived after auth, because frodo-lib's determineDefaultRealm\n * replaces the sentinel default with the deployment type's realm (alpha\n * or /) during _getTokens, making a user choice and a mapped default\n * indistinguishable afterwards.\n */\nlet realmUserSpecified = false;\nlet requiredInputPrompted = false;\n\n/** Records whether required input prompted during resolution. */\nexport function noteRequiredInputPrompted(prompted: boolean): void {\n requiredInputPrompted = prompted;\n}\n\n/** Whether required connection input prompted in the current invocation. */\nexport function requiredInputPromptedForTests(): boolean {\n return requiredInputPrompted;\n}\n\n/**\n * Records whether this invocation's realm came from the user (positional\n * argument value or FRODO_REALM) as opposed to the sentinel default.\n * Called by the resolution pass BEFORE auth -- see the `realmUserSpecified`\n * doc for why the timing matters.\n *\n * The realm positional is read from the command's processed arguments: it\n * only reaches frodo-lib's state later, when the action body runs\n * `handleDefaultArgsAndOpts`, so `state.getRealm()` alone cannot see a realm\n * the user typed (the picker then opened for `frodo journey list <host>\n * /alpha`). FRODO_REALM is the positional's default, so it counts through the\n * same read.\n *\n * @param command the command being run; omit it to judge by the state alone\n */\nexport function noteRealmProvenance(command?: Command): void {\n const realm =\n (command ? positionalValue(command, 'realm') : undefined) ??\n state.getRealm();\n realmUserSpecified = !!realm && realm !== DEFAULT_REALM_KEY;\n}\n\n/** What `noteRealmProvenance` last recorded (for tests: the flag is module-private). */\nexport function realmUserSpecifiedForTests(): boolean {\n return realmUserSpecified;\n}\n\n/** Test hygiene: clears the per-invocation provenance + realm cache. */\nexport function resetRealmPickerStateForTests(): void {\n realmUserSpecified = false;\n requiredInputPrompted = false;\n cachedRealms = undefined;\n}\n\n/**\n * Offers the realm dropdown for `command`'s realm argument when the\n * conditions in the module doc hold. Called by the getTokens wrapper\n * after a successful login. Never throws; on any problem it simply keeps\n * the default.\n */\nexport async function resolveRealmPick(command: Command): Promise<void> {\n if (!canPrompt()) return;\n if (!command.registeredArguments.some((a) => a.name() === 'realm')) return;\n if (realmUserSpecified) return;\n if (!requiredInputPrompted) return;\n\n let realms: { name: string; active: boolean }[];\n try {\n if (!cachedRealms) {\n // Via the memoized ops helper: shares one fetch with commands that\n // read realms themselves (frodo realm list), keeping Polly's\n // order-matched replay intact (recordings have one entry for the\n // endpoint) and halving the latency when both run.\n const { readRealmsCached } = await import('../../ops/RealmOps');\n const skeletons = await readRealmsCached();\n cachedRealms = skeletons.map((realm) => ({\n name: realm.name ?? realm._id ?? '',\n active: realm.active ?? true,\n }));\n }\n realms = cachedRealms;\n } catch {\n return; // can't list realms: keep the default\n }\n if (realms.length <= 1) return;\n\n const current = state.getRealm();\n // The picker runs POST-AUTH, so `current` is already frodo-lib's mapped\n // deployment default (alpha on cloud, / on classic/forgeops) -- passing\n // it as the select's default pre-highlights the TRUE default instead of\n // the first row, so a bare <enter> means \"keep the deployment default\".\n // The default may legitimately be absent from the list (the realms\n // endpoint never returns the root realm, so on classic/forgeops \"/\" has\n // no row): escapableSelect falls back to the first row in that case.\n // → (armed by the hint) opens the invocation editor, then\n // re-prompts this picker; ESCAPE keeps the default as before; EXIT_ALL\n // THROWS the unwind signal (the session ends even though auth already\n // succeeded -- the gesture means \"leave everything\", from any depth,\n // per docs/INTERACTIVE-COMMANDS.md).\n // The loop's exit type is string | typeof ESCAPE (the RIGHT case loops;\n // EXIT_ALL never resolves out of the loop -- it throws).\n let choice: string | typeof ESCAPE;\n for (;;) {\n const { livePositionalPreviewFor, runInvocationEditorForCommand } =\n await import('../../cli/ResolveInteractiveInputs');\n const answer = await escapableSelect<string>({\n message: `Choose a realm (default: ${current}):`,\n default: current,\n hint: editableOptionsHint(command),\n // LIVE footer: the highlighted realm shadows the realm positional\n // per render, so the footer's realm token moves with the cursor\n // BEFORE <enter> commits (live preview).\n preview: livePositionalPreviewFor(command, 'realm'),\n choices: realms.map((realm) => ({\n value: realm.name,\n name: realm.name,\n description: realm.active ? undefined : 'inactive',\n })),\n });\n if (answer === EXIT_ALL) throw EXIT_ALL_SIGNAL;\n if (answer === RIGHT) {\n // The hint advertised the editor, so → must open it (this branch\n // used to just re-prompt, making the key look dead). The editor\n // throws EXIT_ALL_SIGNAL on a double-ESC; a plain return loops\n // back here and the user can still ESC the picker.\n await runInvocationEditorForCommand(command);\n continue;\n }\n choice = answer;\n break;\n }\n if (choice === ESCAPE) {\n // Backed out: keep the deployment default (the pre-interactive\n // behavior), AND say so -- a silent return after the frame erased\n // left the terminal idle with no explanation (user report\n // 2026-10-13: \"the picker wasn't active\" -- the prompt had actually\n // concluded; nothing showed why nothing then happened).\n verboseMessage(`Keeping the default realm ${current}.`);\n return;\n }\n if (!choice || choice === current) {\n // <enter> on the already-highlighted default: an explicit \"keep\n // it\". The pick is DONE -- do NOT loop back into another picker\n // instance (the old silent re-prompt read as a dead screen: the\n // prompt concluded and nothing re-appeared).\n verboseMessage(`Keeping the default realm ${current}.`);\n return;\n }\n state.setRealm(choice);\n // Write the picked realm back into the command's realm positional so the\n // deferred authoring print (flushed at the action's postAction hook, see\n // FrodoCommand/AuthoringPrintState) shows the command EXACTLY as it ran\n // -- the printed realm token matches state.getRealm() token for token.\n // Without this, a non-default pick would print the (sentinel-translated)\n // positional while the action actually runs in `choice`. The CLI\n // positional convention is the plain name (no leading slash) -- the\n // exact value the user would type -- and handleDefaultArgsAndOpts\n // re-feeds it into state.setRealm inside the action body, so the value\n // must be positional-shaped, not state-shaped.\n {\n const { setPositionalValueForCommand } =\n await import('../../cli/ResolveInteractiveInputs');\n setPositionalValueForCommand(command, 'realm', choice.replace(/^\\//, ''));\n }\n verboseMessage(`Using realm ${choice}.`);\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,gBAAgB,SAAkB,MAAsB;CACtE,OAAO,QAAQ,oBAAoB,WAChC,aAAa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yCAAA,CAAA,CAAA,CAAA,MAAA,MAAA,EAAA,gCAAA;EACR,6BAA6B,SAAS,SAAS,OAAO,QAAQ,OAAO,EAAE,CAAC;CAC1E;CACA,gBAAA,eAAe,eAAe,OAAO,EAAE;AACzC"}
1
+ {"version":3,"file":"RealmPickers-CU6P0yV8.cjs","names":["state","canPrompt","escapableSelect","editableOptionsHint","EXIT_ALL","EXIT_ALL_SIGNAL","RIGHT","ESCAPE"],"sources":["../src/utils/interactive/PositionalArgs.ts","../src/utils/interactive/RealmPickers.ts"],"sourcesContent":["/**\n * Positional-argument read/write helpers, split from\n * ResolveInteractiveInputs.ts into a zero-import module (the\n * CommandPreview/ActiveActionCommandState pattern): pure commander, no\n * frodo-lib, so both the resolver and the unit tests (which cannot import\n * the resolver's frodo-lib-heavy graph under this Jest setup -- see\n * src/app.commandWiring.test.ts's header comment) and the post-auth realm\n * picker's write-back share one implementation.\n */\n\nimport type { Command } from 'commander';\n\n/**\n * Index of the default positional argument of that name on this command\n * (commands omit default args via the FrodoCommand omits list, so the\n * index differs per command), or -1 when the command doesn't declare it.\n */\nexport function positionalIndex(command: Command, name: string): number {\n return command.registeredArguments.findIndex(\n (argument) => argument.name() === name\n );\n}\n\nexport function positionalValue(\n command: Command,\n name: string\n): string | undefined {\n const index = positionalIndex(command, name);\n if (index === -1) return undefined;\n const value = command.processedArgs?.[index];\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\n/**\n * Writes `value` into BOTH surfaces the CLI reads for a positional:\n *\n * - `processedArgs` is what the action handler's positional parameters\n * are sliced from (commander's action() wrapper slices\n * this.processedArgs).\n * - `args` (raw, options-removed user args) is what\n * handleDefaultArgsAndOpts iterates to copy default arguments into\n * frodo-lib state INSIDE the action body -- it does NOT read\n * processedArgs, so a processedArgs-only injection would be\n * overwritten with `undefined` the moment the action starts.\n * Verified against commander's _processArguments (fills processedArgs\n * from args, never writes back) and this repo's\n * handleDefaultArgsAndOpts (iterates command.args).\n *\n * `args` holds only user-supplied positional values; a gap-fill by\n * definition fills a position the user left empty, so extending/padding\n * with the injected value is safe. Pad with nulls for any inner\n * positions the user skipped (rare: inner default args are optional),\n * since args is positional.\n */\nexport function setPositionalValue(\n command: Command,\n name: string,\n value: string\n): void {\n const index = positionalIndex(command, name);\n if (index === -1) return;\n if (command.processedArgs) {\n command.processedArgs[index] = value;\n }\n if (Array.isArray(command.args)) {\n while (command.args.length < index) {\n command.args.push(null);\n }\n if (index === command.args.length) {\n command.args.push(value);\n } else if (command.args[index] == null) {\n command.args[index] = value;\n }\n }\n}\n","/**\n * Realm picker (docs/INTERACTIVE-COMMANDS.md, post-auth pickers).\n *\n * After authentication succeeds, a command whose realm argument was left\n * at its default can offer a dropdown of the target system's realms --\n * but ONLY when the system actually has more than one (a single-realm\n * tenant has no choice to offer; the default is already correct). The\n * pick fires from the getTokens wrapper (AuthenticateOps) immediately\n * after auth succeeds, so every command gets it without per-command\n * wiring; a prompt only happens when\n *\n * - the gate allows prompting (canPrompt()),\n * - the command declares a realm positional argument,\n * - a required connection input or option prompted the user to complete the\n * command,\n * - the user did not name a realm explicitly (argument value or\n * FRODO_REALM -- recorded by `noteRealmProvenance` during the\n * resolution pass, BEFORE frodo-lib maps the sentinel default to the\n * deployment type's realm during auth), and\n * - the target system reports more than one realm.\n *\n * Every other path is a no-op. Escape declines the offer and keeps the\n * deployment-type default -- unlike the entity pickers there is no\n * \"wrong\" continuation to protect here (the default is a valid choice),\n * so backing out just means \"keep the default\".\n *\n * The loader failing (permission denied on realm listing, older servers,\n * classic deployments where the endpoint differs) is swallowed and the\n * default kept: the command is about to run against the default realm\n * exactly as it did before the interactive layer existed.\n */\n\nimport { state } from '@rockcarver/frodo-lib';\nimport { Command } from 'commander';\nimport { verboseMessage } from '../Console';\nimport { editableOptionsHint } from './EditableOptions';\nimport { escapableSelect, ESCAPE, RIGHT } from './EscapableSelectPrompt';\nimport { EXIT_ALL, EXIT_ALL_SIGNAL } from './ExitAll';\nimport { positionalValue } from './PositionalArgs';\nimport { canPrompt } from './PromptGateState';\n\n/** frodo-lib's sentinel default for \"no realm chosen yet\". */\nconst DEFAULT_REALM_KEY = '__default__realm__';\n\n/** Cache of the realms read during this invocation (one fetch per run). */\nlet cachedRealms: { name: string; active: boolean }[] | undefined;\n\n/**\n * Whether the current invocation's realm was user-specified. Captured by\n * `noteRealmProvenance` during the resolution pass -- it CANNOT be\n * re-derived after auth, because frodo-lib's determineDefaultRealm\n * replaces the sentinel default with the deployment type's realm (alpha\n * or /) during _getTokens, making a user choice and a mapped default\n * indistinguishable afterwards.\n */\nlet realmUserSpecified = false;\nlet requiredInputPrompted = false;\n\n/** Records whether required input prompted during resolution. */\nexport function noteRequiredInputPrompted(prompted: boolean): void {\n requiredInputPrompted = prompted;\n}\n\n/** Whether required connection input prompted in the current invocation. */\nexport function requiredInputPromptedForTests(): boolean {\n return requiredInputPrompted;\n}\n\n/**\n * Records whether this invocation's realm came from the user (positional\n * argument value or FRODO_REALM) as opposed to the sentinel default.\n * Called by the resolution pass BEFORE auth -- see the `realmUserSpecified`\n * doc for why the timing matters.\n *\n * The realm positional is read from the command's processed arguments: it\n * only reaches frodo-lib's state later, when the action body runs\n * `handleDefaultArgsAndOpts`, so `state.getRealm()` alone cannot see a realm\n * the user typed (the picker then opened for `frodo journey list <host>\n * /alpha`). FRODO_REALM is the positional's default, so it counts through the\n * same read.\n *\n * @param command the command being run; omit it to judge by the state alone\n */\nexport function noteRealmProvenance(command?: Command): void {\n const realm =\n (command ? positionalValue(command, 'realm') : undefined) ??\n state.getRealm();\n realmUserSpecified = !!realm && realm !== DEFAULT_REALM_KEY;\n}\n\n/** What `noteRealmProvenance` last recorded (for tests: the flag is module-private). */\nexport function realmUserSpecifiedForTests(): boolean {\n return realmUserSpecified;\n}\n\n/** Test hygiene: clears the per-invocation provenance + realm cache. */\nexport function resetRealmPickerStateForTests(): void {\n realmUserSpecified = false;\n requiredInputPrompted = false;\n cachedRealms = undefined;\n}\n\n/**\n * Offers the realm dropdown for `command`'s realm argument when the\n * conditions in the module doc hold. Called by the getTokens wrapper\n * after a successful login. Never throws; on any problem it simply keeps\n * the default.\n */\nexport async function resolveRealmPick(command: Command): Promise<void> {\n if (!canPrompt()) return;\n if (!command.registeredArguments.some((a) => a.name() === 'realm')) return;\n if (realmUserSpecified) return;\n if (!requiredInputPrompted) return;\n\n let realms: { name: string; active: boolean }[];\n try {\n if (!cachedRealms) {\n // Via the memoized ops helper: shares one fetch with commands that\n // read realms themselves (frodo realm list), keeping Polly's\n // order-matched replay intact (recordings have one entry for the\n // endpoint) and halving the latency when both run.\n const { readRealmsCached } = await import('../../ops/RealmOps');\n const skeletons = await readRealmsCached();\n cachedRealms = skeletons.map((realm) => ({\n name: realm.name ?? realm._id ?? '',\n active: realm.active ?? true,\n }));\n }\n realms = cachedRealms;\n } catch {\n return; // can't list realms: keep the default\n }\n if (realms.length <= 1) return;\n\n const current = state.getRealm();\n // The picker runs POST-AUTH, so `current` is already frodo-lib's mapped\n // deployment default (alpha on cloud, / on classic/forgeops) -- passing\n // it as the select's default pre-highlights the TRUE default instead of\n // the first row, so a bare <enter> means \"keep the deployment default\".\n // The default may legitimately be absent from the list (the realms\n // endpoint never returns the root realm, so on classic/forgeops \"/\" has\n // no row): escapableSelect falls back to the first row in that case.\n // → (armed by the hint) opens the invocation editor, then\n // re-prompts this picker; ESCAPE keeps the default as before; EXIT_ALL\n // THROWS the unwind signal (the session ends even though auth already\n // succeeded -- the gesture means \"leave everything\", from any depth,\n // per docs/INTERACTIVE-COMMANDS.md).\n // The loop's exit type is string | typeof ESCAPE (the RIGHT case loops;\n // EXIT_ALL never resolves out of the loop -- it throws).\n let choice: string | typeof ESCAPE;\n for (;;) {\n const { livePositionalPreviewFor, runInvocationEditorForCommand } =\n await import('../../cli/ResolveInteractiveInputs');\n const answer = await escapableSelect<string>({\n message: `Choose a realm (default: ${current}):`,\n default: current,\n hint: editableOptionsHint(command),\n // LIVE footer: the highlighted realm shadows the realm positional\n // per render, so the footer's realm token moves with the cursor\n // BEFORE <enter> commits (live preview).\n preview: livePositionalPreviewFor(command, 'realm'),\n choices: realms.map((realm) => ({\n value: realm.name,\n name: realm.name,\n description: realm.active ? undefined : 'inactive',\n })),\n });\n if (answer === EXIT_ALL) throw EXIT_ALL_SIGNAL;\n if (answer === RIGHT) {\n // The hint advertised the editor, so → must open it (this branch\n // used to just re-prompt, making the key look dead). The editor\n // throws EXIT_ALL_SIGNAL on a double-ESC; a plain return loops\n // back here and the user can still ESC the picker.\n await runInvocationEditorForCommand(command);\n continue;\n }\n choice = answer;\n break;\n }\n if (choice === ESCAPE) {\n // Backed out: keep the deployment default (the pre-interactive\n // behavior), AND say so -- a silent return after the frame erased\n // left the terminal idle with no explanation (user report\n // 2026-10-13: \"the picker wasn't active\" -- the prompt had actually\n // concluded; nothing showed why nothing then happened).\n verboseMessage(`Keeping the default realm ${current}.`);\n return;\n }\n if (!choice || choice === current) {\n // <enter> on the already-highlighted default: an explicit \"keep\n // it\". The pick is DONE -- do NOT loop back into another picker\n // instance (the old silent re-prompt read as a dead screen: the\n // prompt concluded and nothing re-appeared).\n verboseMessage(`Keeping the default realm ${current}.`);\n return;\n }\n state.setRealm(choice);\n // Write the picked realm back into the command's realm positional so the\n // deferred authoring print (flushed at the action's postAction hook, see\n // FrodoCommand/AuthoringPrintState) shows the command EXACTLY as it ran\n // -- the printed realm token matches state.getRealm() token for token.\n // Without this, a non-default pick would print the (sentinel-translated)\n // positional while the action actually runs in `choice`. The CLI\n // positional convention is the plain name (no leading slash) -- the\n // exact value the user would type -- and handleDefaultArgsAndOpts\n // re-feeds it into state.setRealm inside the action body, so the value\n // must be positional-shaped, not state-shaped.\n {\n const { setPositionalValueForCommand } =\n await import('../../cli/ResolveInteractiveInputs');\n setPositionalValueForCommand(command, 'realm', choice.replace(/^\\//, ''));\n }\n verboseMessage(`Using realm ${choice}.`);\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,gBAAgB,SAAkB,MAAsB;CACtE,OAAO,Q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,CAAA,CAAA,WAAA,QAAM,yCAAA,CAAA,CAAA,CAAA,MAAA,MAAA,EAAA,gCAAA;EACR,6BAA6B,SAAS,SAAS,OAAO,QAAQ,OAAO,EAAE,CAAC;CAC1E;CACA,gBAAA,eAAe,eAAe,OAAO,EAAE;AACzC"}
@@ -1,16 +1,88 @@
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
  const require_AuthoringPrintState = require("./AuthoringPrintState-vyWOD1Wt.cjs");
5
- const require_EntityPickers = require("./EntityPickers-NlzD18p4.cjs");
6
- const require_DefaultsStore = require("./DefaultsStore-RlEkAWqT.cjs");
7
- const require_RealmPickers = require("./RealmPickers-egCrSB9q.cjs");
5
+ const require_EntityPickers = require("./EntityPickers-DTtIJ6xb.cjs");
6
+ const require_DefaultsStore = require("./DefaultsStore-Cb7yMNHY.cjs");
7
+ const require_RealmPickers = require("./RealmPickers-CU6P0yV8.cjs");
8
8
  let path = require("path");
9
9
  path = require_rolldown_runtime.__toESM(path, 1);
10
10
  let fs = require("fs");
11
11
  fs = require_rolldown_runtime.__toESM(fs, 1);
12
12
  let os = require("os");
13
13
  os = require_rolldown_runtime.__toESM(os, 1);
14
+ let node_fs = require("node:fs");
15
+ //#region src/utils/StdinSync.ts
16
+ /**
17
+ * The only place in the CLI that reads fd 0 synchronously (an ESLint rule
18
+ * keeps it that way, see `eslint.config.mjs`).
19
+ *
20
+ * Why every synchronous read of standard input needs the same care: the
21
+ * first access to the `process.stdin` getter anywhere in the process -- even
22
+ * just `process.stdin.isTTY`, as `canPrompt()` and the terminal background
23
+ * detection do -- makes libuv switch fd 0 to non-blocking mode. A plain
24
+ * `readSync(0)` then throws EAGAIN whenever no data has arrived yet: at a
25
+ * prompt because the user has not typed, on a pipe because the producer is
26
+ * slower than the CLI (frodo-cli#887 and its sibling,
27
+ * `config-manager push raw --stdin`). So EAGAIN is not an error here, it is
28
+ * "no input yet": wait a moment and ask again. Any other error is real and
29
+ * propagates.
30
+ *
31
+ * This is safe next to a resumed `process.stdin` too: the loops below never
32
+ * yield to the event loop, so libuv cannot read the data away from us.
33
+ */
34
+ /** How long to wait before asking fd 0 again after EAGAIN. */
35
+ const RETRY_DELAY_MS = 20;
36
+ /** How much of a pipe is read per call when reading it to its end. */
37
+ const PIPE_CHUNK_BYTES = 65536;
38
+ /** Blocks the thread for `ms` without spinning the CPU. */
39
+ function sleepSync(ms) {
40
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
41
+ }
42
+ /**
43
+ * One read from fd 0 that waits for input: fills `buffer` with whatever
44
+ * arrives first (a typed line at a prompt, the next piece of a pipe) and
45
+ * returns the number of bytes read; 0 means end of input.
46
+ *
47
+ * Besides returning 0, end of input can surface as an error with code `EOF`
48
+ * (what Node raises for a closed pipe on Windows, and what `readline-sync`
49
+ * handled the same way): it is mapped to 0 here too. That mapping is not
50
+ * exercised on a real Windows console by the tests.
51
+ *
52
+ * @param {Buffer} buffer where the bytes are put; its length is the most that is read
53
+ * @returns {number} the number of bytes read, 0 at end of input
54
+ */
55
+ function readStdinChunkSync(buffer) {
56
+ for (;;) try {
57
+ return (0, node_fs.readSync)(0, buffer, 0, buffer.length, null);
58
+ } catch (error) {
59
+ const code = error.code;
60
+ if (code === "EAGAIN") {
61
+ sleepSync(RETRY_DELAY_MS);
62
+ continue;
63
+ }
64
+ if (code === "EOF") return 0;
65
+ throw error;
66
+ }
67
+ }
68
+ /**
69
+ * Everything on standard input up to its end, as UTF-8 text. Waits for a
70
+ * slow producer (EAGAIN between chunks is normal on a pipe), and decodes
71
+ * once at the end so a multi-byte character split across two chunks stays
72
+ * intact.
73
+ *
74
+ * @returns {string} all of stdin
75
+ */
76
+ function readStdinToEndSync() {
77
+ const chunks = [];
78
+ for (;;) {
79
+ const buffer = Buffer.alloc(PIPE_CHUNK_BYTES);
80
+ const bytesRead = readStdinChunkSync(buffer);
81
+ if (bytesRead === 0) break;
82
+ chunks.push(buffer.subarray(0, bytesRead));
83
+ }
84
+ return Buffer.concat(chunks).toString("utf8");
85
+ }
14
86
  /**
15
87
  * Read a line of free-form text. Paste-safe and editable (the readline
16
88
  * buffer does the editing; the prompt only reads it), unlike accumulating
@@ -21,6 +93,14 @@ async function promptInput(config) {
21
93
  return runTextPrompt(config, { suppress: false });
22
94
  }
23
95
  /**
96
+ * Read a line of text without echoing it (passwords, passphrases, and
97
+ * similar secrets). Same result contract as `promptInput`.
98
+ */
99
+ async function promptPassword(config) {
100
+ if (!require_EscapableSelectPrompt.canPrompt()) return void 0;
101
+ return runTextPrompt(config, { suppress: true });
102
+ }
103
+ /**
24
104
  * Terminal conditions outside the user's in-prompt choices: stdin EOF
25
105
  * (Ctrl-D, e.g. the driver's shutdown write) and Ctrl-C both reject the
26
106
  * prompt with @inquirer/core's ExitPromptError. For gap-fills both mean
@@ -165,7 +245,10 @@ function serializeCommand(command) {
165
245
  const value = command.getOptionValue(option.attributeName());
166
246
  if (value === void 0 || value === "" || !option.negate && value === false) continue;
167
247
  if (command.getOptionValueSource(option.attributeName()) === "default") continue;
168
- if (value === true || option.negate) parts.push(option.flags.split(/[, ]+/)[0]);
248
+ if (require_DefaultsStore.isSecretOption(option)) {
249
+ const longFlag = option.flags.split(/[, ]+/).find((token) => token.startsWith("--"));
250
+ parts.push(value === true ? longFlag ?? option.flags : `${longFlag ?? option.flags} ${require_DefaultsStore.SECRET_MASK}`);
251
+ } else if (value === true || option.negate) parts.push(option.flags.split(/[, ]+/)[0]);
169
252
  else if (Array.isArray(value)) {
170
253
  const longFlag = option.flags.split(/[, ]+/).find((token) => token.startsWith("--"));
171
254
  for (const entry of value) parts.push(`${longFlag ?? option.flags} ${String(entry)}`);
@@ -1053,6 +1136,67 @@ const escapableMultiSelect = ((config) => {
1053
1136
  return escapableMultiSelectImpl(config, { clearPromptOnDone: true });
1054
1137
  });
1055
1138
  //#endregion
1139
+ //#region src/utils/interactive/SecretCollector.ts
1140
+ /** Ends the command like commander does for an option without its value. */
1141
+ function fail(command, message) {
1142
+ command.error(message, { code: require_DefaultsStore.SECRET_VALUE_MISSING_CODE });
1143
+ }
1144
+ /** Writes a collected value, or ends the command on a conflict. */
1145
+ function commitSecret(command, option, value) {
1146
+ const result = require_EscapableSelectPrompt.commitOption(command, option.attributeName(), value);
1147
+ if (result.status === "blocked") require_EscapableSelectPrompt.failWithConflict(command, option, result.blockedBy);
1148
+ }
1149
+ /**
1150
+ * Asks for each pending secret. `ask` resolves with the typed value, `''`
1151
+ * when the user declined (Escape or an empty answer), or `undefined` when the
1152
+ * gate refused to prompt. Returns false as soon as one is declined; the
1153
+ * caller then ends the command with the error for what is still missing.
1154
+ */
1155
+ async function collectSecretsByPrompt(command, mandatoryViolations, ask) {
1156
+ for (const option of require_DefaultsStore.pendingSecretOptions(command, mandatoryViolations)) {
1157
+ const answer = await ask(`Enter a value for ${option.flags} (input is hidden):`);
1158
+ if (!answer) return false;
1159
+ commitSecret(command, option, answer);
1160
+ }
1161
+ return true;
1162
+ }
1163
+ /**
1164
+ * The non-interactive way: the value of the one pending secret comes from
1165
+ * stdin. Fails, before reading anything, when there is more than one pending
1166
+ * secret or when stdin is a terminal. Fails after reading when nothing was
1167
+ * piped. Does nothing when no secret is pending.
1168
+ */
1169
+ function collectSecretsFromStdin(command, stdin) {
1170
+ const pending = require_DefaultsStore.pendingSecretOptions(command);
1171
+ if (pending.length === 0) return;
1172
+ if (pending.length > 1) fail(command, require_DefaultsStore.secretsShareStdinMessage(pending));
1173
+ const [option] = pending;
1174
+ if (stdin.isTTY) fail(command, require_DefaultsStore.secretNeedsValueMessage(option));
1175
+ const value = require_DefaultsStore.stripTrailingNewline(stdin.read());
1176
+ if (value.length === 0) fail(command, require_DefaultsStore.secretStdinEmptyMessage(option));
1177
+ commitSecret(command, option, value);
1178
+ }
1179
+ /**
1180
+ * Ends the command when a secret option still holds its marker, so that the
1181
+ * marker can never reach frodo-lib as a password. Used after the pass, and
1182
+ * wherever the pass gives up before it has asked.
1183
+ */
1184
+ function assertNoPendingSecrets(command) {
1185
+ const [option] = require_DefaultsStore.pendingSecretOptions(command);
1186
+ if (option) fail(command, require_DefaultsStore.secretNeedsValueMessage(option));
1187
+ }
1188
+ /**
1189
+ * Ends the command for the first secret that is still missing after the user
1190
+ * declined a prompt (or gave up an earlier one): a mandatory one that was left
1191
+ * out gets commander's own message, a bare one the "without a value" error.
1192
+ */
1193
+ function failFirstPendingSecret(command, mandatoryViolations, missingMandatory) {
1194
+ const [option] = require_DefaultsStore.pendingSecretOptions(command, mandatoryViolations);
1195
+ if (!option) return;
1196
+ if (command.getOptionValue(option.attributeName()) === void 0) missingMandatory(option.flags);
1197
+ fail(command, require_DefaultsStore.secretDeclinedMessage(option));
1198
+ }
1199
+ //#endregion
1056
1200
  //#region src/utils/SettingsStore.ts
1057
1201
  const SETTINGS_FILENAME = "Settings.json";
1058
1202
  function getSettingsPath() {
@@ -1230,6 +1374,10 @@ async function resolveInteractiveInputs(command) {
1230
1374
  if (violations.length > 0) throwMissingMandatory(command, violations[0]);
1231
1375
  const unsatisfiedGroups = findUnsatisfiedOneOfGroups(command);
1232
1376
  if (unsatisfiedGroups.length > 0) throwOneOfUnsatisfied(command, unsatisfiedGroups[0]);
1377
+ collectSecretsFromStdin(command, {
1378
+ isTTY: !!process.stdin.isTTY,
1379
+ read: readStdinToEndSync
1380
+ });
1233
1381
  return;
1234
1382
  }
1235
1383
  applyPersistedDefaults(command);
@@ -1245,13 +1393,17 @@ async function resolveInteractiveInputs(command) {
1245
1393
  const mandatoryResolved = connectionResolved ? await resolveMandatoryOptions(command) : false;
1246
1394
  if (!connectionResolved || !mandatoryResolved) {
1247
1395
  if (violations.length > 0) throwMissingMandatory(command, violations[0]);
1396
+ assertNoPendingSecrets(command);
1248
1397
  return;
1249
1398
  }
1250
1399
  if (!await resolveOneOfGroups(command)) {
1251
1400
  const unsatisfied = findUnsatisfiedOneOfGroups(command);
1252
1401
  if (unsatisfied.length > 0) throwOneOfUnsatisfied(command, unsatisfied[0]);
1253
1402
  }
1403
+ if (!await collectSecretsByPrompt(command, violations, (message) => promptPassword({ message }))) failFirstPendingSecret(command, violations, (flags) => throwMissingMandatory(command, flags));
1254
1404
  if (explicitlyInteractive) await runInvocationEditor(command);
1405
+ require_EscapableSelectPrompt.assertNoConflicts(command);
1406
+ assertNoPendingSecrets(command);
1255
1407
  require_AuthoringPrintState.armAuthoringPrint();
1256
1408
  require_AuthoringPrintState.setAuthoringPrintFlush(() => {
1257
1409
  if (require_EscapableSelectPrompt.promptsRendered() === 0 && !explicitlyInteractive) return;
@@ -1427,6 +1579,32 @@ async function selectFromChoices(command, message, choices, optionName) {
1427
1579
  });
1428
1580
  }
1429
1581
  /**
1582
+ * Sets an option through the conflict check (issue #967). A conflict with
1583
+ * something the user gave ends the command with commander's own error, as
1584
+ * if it had been typed that way; a conflicting value the resolver set
1585
+ * earlier (a saved default, an earlier pick) is replaced, and says so in
1586
+ * verbose output.
1587
+ */
1588
+ function commitOrFail(command, option, value) {
1589
+ const result = require_EscapableSelectPrompt.commitOption(command, option.attributeName(), value);
1590
+ if (result.status === "blocked") require_EscapableSelectPrompt.failWithConflict(command, option, result.blockedBy);
1591
+ for (const replaced of result.cleared) require_Console.verboseMessage(`Replaced ${replaced.flags}, which cannot be used with ${option.flags}.`);
1592
+ }
1593
+ /**
1594
+ * The editor's variant of commitOrFail: a conflict is not fatal there. It
1595
+ * says which option stands in the way and leaves the option unset, so the
1596
+ * user can pick something else. Returns whether the value was set.
1597
+ */
1598
+ function commitInEditor(command, option, value) {
1599
+ const result = require_EscapableSelectPrompt.commitOption(command, option.attributeName(), value);
1600
+ if (result.status === "blocked") {
1601
+ require_Console.printMessage(`${option.flags} was not set: it cannot be used with ${result.blockedBy.flags}.`, "info");
1602
+ return false;
1603
+ }
1604
+ for (const replaced of result.cleared) require_Console.verboseMessage(`Replaced ${replaced.flags}, which cannot be used with ${option.flags}.`);
1605
+ return true;
1606
+ }
1607
+ /**
1430
1608
  * Prompts for each deferred mandatory option violation. Options with a
1431
1609
  * closed value set (commander `choices()`) get a dropdown; everything
1432
1610
  * else free text. Returns false as soon as the user declines one (Escape
@@ -1440,6 +1618,7 @@ async function resolveMandatoryOptions(command) {
1440
1618
  });
1441
1619
  if (!option) throwMissingMandatory(command, violation);
1442
1620
  const attributeName = option.attributeName();
1621
+ if (require_DefaultsStore.isSecretOption(option)) continue;
1443
1622
  if (require_EntityPickers.hasEntityPick(command, attributeName)) {
1444
1623
  require_Console.verboseMessage(`${option.flags} will be offered from the target system after login.`);
1445
1624
  continue;
@@ -1454,7 +1633,7 @@ async function resolveMandatoryOptions(command) {
1454
1633
  if (!answer) return false;
1455
1634
  value = answer;
1456
1635
  }
1457
- command.setOptionValueWithSource(attributeName, value, "cli");
1636
+ commitOrFail(command, option, value);
1458
1637
  require_Console.verboseMessage(`Using ${value} for ${option.flags}.`);
1459
1638
  }
1460
1639
  return true;
@@ -1498,22 +1677,26 @@ async function resolveOneOfGroups(command) {
1498
1677
  } : void 0;
1499
1678
  }).filter((member) => member !== void 0);
1500
1679
  if (memberOptions.length === 0) continue;
1680
+ const { selectable, hidden } = require_EscapableSelectPrompt.selectableMembers(command, memberOptions.map((member) => member.name));
1681
+ if (hidden.length > 0) require_Console.printMessage(require_EscapableSelectPrompt.hiddenNote(hidden), "info");
1682
+ if (selectable.length === 0) require_EscapableSelectPrompt.failWithConflict(command, hidden[0].option, hidden[0].blockedBy);
1683
+ const offered = memberOptions.filter((member) => selectable.includes(member.name));
1501
1684
  const picked = await selectWithEditorRouting(command, {
1502
1685
  message: `Choose ${group.purpose ?? "what to act on"}:`,
1503
1686
  ...commandReadinessFor(command) ? { preview: (highlighted) => {
1504
- const member = memberOptions.find((candidate) => candidate.name === highlighted);
1687
+ const member = offered.find((candidate) => candidate.name === highlighted);
1505
1688
  const readiness = commandReadinessFor(command);
1506
1689
  if (!member || !readiness) return readiness ? renderCommandPreview(command, readiness) : "";
1507
1690
  const isBoolean = !/<[^>]+>|\[[^\]]+\]/.test(member.option.flags);
1508
1691
  return liveOptionPreview(command, member.name, () => commandReadinessFor(command), isBoolean ? () => true : () => void 0)(highlighted);
1509
1692
  } } : {},
1510
- choices: memberOptions.map((member) => ({
1693
+ choices: offered.map((member) => ({
1511
1694
  value: member.name,
1512
1695
  name: `${member.option.flags}${member.option.description ? ` -- ${member.option.description}` : ""}`
1513
1696
  }))
1514
1697
  });
1515
1698
  if (picked === require_EscapableSelectPrompt.ESCAPE) return false;
1516
- const chosen = memberOptions.find((member) => member.name === picked);
1699
+ const chosen = offered.find((member) => member.name === picked);
1517
1700
  if (require_EntityPickers.hasEntityPick(command, chosen.name)) {
1518
1701
  require_Console.verboseMessage(`${chosen.option.flags} will be offered from the target system after login.`);
1519
1702
  continue;
@@ -1521,12 +1704,12 @@ async function resolveOneOfGroups(command) {
1521
1704
  if (chosen.option.argChoices && chosen.option.argChoices.length > 0) {
1522
1705
  const value = await selectFromChoices(command, `Choose a value for ${chosen.option.flags}:`, chosen.option.argChoices, chosen.name);
1523
1706
  if (value === require_EscapableSelectPrompt.ESCAPE) return false;
1524
- command.setOptionValueWithSource(chosen.name, value, "cli");
1525
- } else if (!/<[^>]+>|\[[^\]]+\]/.test(chosen.option.flags)) command.setOptionValueWithSource(chosen.name, true, "cli");
1707
+ commitOrFail(command, chosen.option, value);
1708
+ } else if (!/<[^>]+>|\[[^\]]+\]/.test(chosen.option.flags)) commitOrFail(command, chosen.option, true);
1526
1709
  else {
1527
1710
  const answer = await promptInput({ message: `Enter a value for ${chosen.option.flags}:` });
1528
1711
  if (!answer) return false;
1529
- command.setOptionValueWithSource(chosen.name, answer, "cli");
1712
+ commitOrFail(command, chosen.option, answer);
1530
1713
  }
1531
1714
  require_Console.verboseMessage(`Using ${chosen.option.flags}.`);
1532
1715
  }
@@ -1719,13 +1902,20 @@ function applyPersistedDefaults(command) {
1719
1902
  const value = persisted[option.attributeName()];
1720
1903
  if (value === void 0) continue;
1721
1904
  if (!require_DefaultsStore.optionMissingUserValue(command, option)) continue;
1905
+ if (require_DefaultsStore.isSecretOption(option)) continue;
1722
1906
  const collectsArrays = Array.isArray(command.getOptionValue(option.attributeName())) || Array.isArray(option.defaultValue);
1723
1907
  if (Array.isArray(value) !== collectsArrays) continue;
1724
- command.setOptionValueWithSource(option.attributeName(), value, "cli");
1908
+ const result = require_EscapableSelectPrompt.commitOption(command, option.attributeName(), value, { replace: false });
1909
+ if (result.status === "blocked") {
1910
+ require_Console.verboseMessage(`Skipping saved default ${option.flags}: it cannot be used with ${result.blockedBy.flags}.`);
1911
+ continue;
1912
+ }
1725
1913
  require_Console.verboseMessage(`Using saved default ${option.flags} ${String(value)} (frodo settings defaults to change).`);
1726
1914
  }
1727
1915
  }
1728
1916
  async function runInvocationEditor(command) {
1917
+ const hiddenByConflicts = require_EscapableSelectPrompt.editableOptionsHiddenByConflicts(command);
1918
+ if (hiddenByConflicts.length > 0) require_Console.printMessage(require_EscapableSelectPrompt.hiddenNote(hiddenByConflicts), "info");
1729
1919
  const candidates = require_EscapableSelectPrompt.editableOptionalOptions(command);
1730
1920
  if (candidates.length === 0) {
1731
1921
  require_Console.verboseMessage("No optional options left to edit.");
@@ -1749,11 +1939,11 @@ async function runInvocationEditor(command) {
1749
1939
  });
1750
1940
  if (value === require_EscapableSelectPrompt.EXIT_ALL) return require_EscapableSelectPrompt.EXIT_ALL;
1751
1941
  if (value === require_EscapableSelectPrompt.ESCAPE || value === require_EscapableSelectPrompt.RIGHT) return void 0;
1752
- command.setOptionValueWithSource(attributeName, value, "cli");
1942
+ if (!commitInEditor(command, option, value)) return void 0;
1753
1943
  return value;
1754
1944
  }
1755
1945
  if (!/<[^>]+>|\[[^\]]+\]/.test(option.flags)) {
1756
- command.setOptionValueWithSource(attributeName, true, "cli");
1946
+ if (!commitInEditor(command, option, true)) return void 0;
1757
1947
  return true;
1758
1948
  }
1759
1949
  const answer = await promptInput({
@@ -1761,7 +1951,7 @@ async function runInvocationEditor(command) {
1761
1951
  default: currentText
1762
1952
  });
1763
1953
  if (!answer) return void 0;
1764
- command.setOptionValueWithSource(attributeName, answer, "cli");
1954
+ if (!commitInEditor(command, option, answer)) return void 0;
1765
1955
  return answer;
1766
1956
  };
1767
1957
  const committed = {};
@@ -1774,7 +1964,7 @@ async function runInvocationEditor(command) {
1774
1964
  })(),
1775
1965
  needsValue: (attributeName) => {
1776
1966
  const option = command.options.find((candidate) => candidate.attributeName() === attributeName);
1777
- return !!option && /<[^>]+>|\[[^\]]+\]/.test(option.flags);
1967
+ return !!option && !require_DefaultsStore.isSecretOption(option) && /<[^>]+>|\[[^\]]+\]/.test(option.flags);
1778
1968
  },
1779
1969
  choicesFor: (attributeName) => {
1780
1970
  const option = command.options.find((candidate) => candidate.attributeName() === attributeName);
@@ -1789,17 +1979,16 @@ async function runInvocationEditor(command) {
1789
1979
  onValue: (attributeName, value) => {
1790
1980
  const option = command.options.find((candidate) => candidate.attributeName() === attributeName);
1791
1981
  if (!option) return;
1792
- if (Array.isArray(option.defaultValue)) {
1793
- const existing = command.getOptionValue(attributeName);
1794
- command.setOptionValueWithSource(attributeName, [...Array.isArray(existing) ? existing : [], value], "cli");
1795
- } else command.setOptionValueWithSource(attributeName, value, "cli");
1982
+ const collectsArrays = Array.isArray(option.defaultValue);
1983
+ const existing = command.getOptionValue(attributeName);
1984
+ if (!commitInEditor(command, option, collectsArrays ? [...Array.isArray(existing) ? existing : [], value] : value)) return;
1796
1985
  committed[attributeName] = command.getOptionValue(attributeName);
1797
1986
  require_Console.verboseMessage(`Using ${option.flags} ${value}.`);
1798
1987
  },
1799
1988
  groups: require_EscapableSelectPrompt.editableOptionGroups(candidates),
1800
1989
  choices: require_EscapableSelectPrompt.sortEditableOptions(candidates).map((option) => {
1801
1990
  const current = command.getOptionValue(option.attributeName());
1802
- const sourced = current === void 0 || current === false ? void 0 : command.getOptionValueSource(option.attributeName()) === "default" ? ` (default: ${current})` : ` (current: ${current})`;
1991
+ const sourced = current === void 0 || current === false ? void 0 : require_DefaultsStore.isSecretOption(option) ? " (set)" : command.getOptionValueSource(option.attributeName()) === "default" ? ` (default: ${current})` : ` (current: ${current})`;
1803
1992
  return {
1804
1993
  value: option.attributeName(),
1805
1994
  name: option.flags,
@@ -1815,6 +2004,14 @@ async function runInvocationEditor(command) {
1815
2004
  }
1816
2005
  const savingDefaults = command.getOptionValue("saveDefaults") === true && command.getOptionValueSource("saveDefaults") === "cli";
1817
2006
  for (const attributeName of picked) {
2007
+ const pickedOption = command.options.find((candidate) => candidate.attributeName() === attributeName);
2008
+ if (pickedOption && require_DefaultsStore.isSecretOption(pickedOption)) {
2009
+ if (!(command.getOptionValueSource(attributeName) === "cli" && command.getOptionValue(attributeName) !== void 0)) {
2010
+ const answer = await promptPassword({ message: `Enter a value for ${pickedOption.flags} (input is hidden):` });
2011
+ if (answer && commitInEditor(command, pickedOption, answer)) require_Console.verboseMessage(`Using ${pickedOption.flags}.`);
2012
+ }
2013
+ continue;
2014
+ }
1818
2015
  if (command.getOptionValueSource(attributeName) === "cli" && command.getOptionValue(attributeName) !== void 0) {
1819
2016
  const option = command.options.find((candidate) => candidate.attributeName() === attributeName);
1820
2017
  require_Console.verboseMessage(`Using ${option.flags}.`);
@@ -1828,11 +2025,11 @@ async function runInvocationEditor(command) {
1828
2025
  require_Console.verboseMessage(`Using ${option.flags}.`);
1829
2026
  }
1830
2027
  if (picked.length > 0) {
1831
- const { replayEditorOptionStates } = await Promise.resolve().then(() => require("./FrodoCommand-Cs3PkII9.cjs")).then((n) => n.FrodoCommand_exports);
2028
+ const { replayEditorOptionStates } = await Promise.resolve().then(() => require("./FrodoCommand-DV3xmgo5.cjs")).then((n) => n.FrodoCommand_exports);
1832
2029
  replayEditorOptionStates(command);
1833
2030
  }
1834
2031
  if (savingDefaults && Object.keys(committed).length > 0) {
1835
- const { saveCommandDefaults } = await Promise.resolve().then(() => require("./DefaultsStore-RlEkAWqT.cjs")).then((n) => n.DefaultsStore_exports);
2032
+ const { saveCommandDefaults } = await Promise.resolve().then(() => require("./DefaultsStore-Cb7yMNHY.cjs")).then((n) => n.DefaultsStore_exports);
1836
2033
  saveCommandDefaults(command, committed);
1837
2034
  require_Console.successMessage(`Saved ${Object.keys(committed).length} option${Object.keys(committed).length === 1 ? "" : "s"} as defaults for '${commandStorePath(command)}'.`);
1838
2035
  }
@@ -1881,6 +2078,18 @@ Object.defineProperty(exports, "readSettings", {
1881
2078
  return readSettings;
1882
2079
  }
1883
2080
  });
2081
+ Object.defineProperty(exports, "readStdinChunkSync", {
2082
+ enumerable: true,
2083
+ get: function() {
2084
+ return readStdinChunkSync;
2085
+ }
2086
+ });
2087
+ Object.defineProperty(exports, "readStdinToEndSync", {
2088
+ enumerable: true,
2089
+ get: function() {
2090
+ return readStdinToEndSync;
2091
+ }
2092
+ });
1884
2093
  Object.defineProperty(exports, "resolveInteractiveInputs", {
1885
2094
  enumerable: true,
1886
2095
  get: function() {
@@ -1894,4 +2103,4 @@ Object.defineProperty(exports, "setGuidedMode", {
1894
2103
  }
1895
2104
  });
1896
2105
 
1897
- //# sourceMappingURL=ResolveInteractiveInputs-BZUtDvaq.cjs.map
2106
+ //# sourceMappingURL=ResolveInteractiveInputs-up9YUHQr.cjs.map