@rockcarver/frodo-cli 5.0.0-17 → 5.0.0-18
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 +15 -0
- package/dist/{EntityPickers-BBaotoyf.cjs → EntityPickers-Bf6jtoEv.cjs} +70 -43
- package/dist/EntityPickers-Bf6jtoEv.cjs.map +1 -0
- package/dist/{EscapableSelectPrompt-7MN9qBZW.cjs → EscapableSelectPrompt-CUNQdpTZ.cjs} +7 -2
- package/dist/{EscapableSelectPrompt-7MN9qBZW.cjs.map → EscapableSelectPrompt-CUNQdpTZ.cjs.map} +1 -1
- package/dist/{FrodoCommand-CiPz4vNf.cjs → FrodoCommand-D6wEggWy.cjs} +6 -6
- package/dist/{FrodoCommand-CiPz4vNf.cjs.map → FrodoCommand-D6wEggWy.cjs.map} +1 -1
- package/dist/{RealmPickers-eE__OjpO.cjs → RealmPickers-BFkBQzs2.cjs} +4 -4
- package/dist/{RealmPickers-eE__OjpO.cjs.map → RealmPickers-BFkBQzs2.cjs.map} +1 -1
- package/dist/{ResolveInteractiveInputs-nHHYA9VO.cjs → ResolveInteractiveInputs-Dto6u7DS.cjs} +46 -12
- package/dist/{ResolveInteractiveInputs-nHHYA9VO.cjs.map → ResolveInteractiveInputs-Dto6u7DS.cjs.map} +1 -1
- package/dist/app.cjs +25 -95
- package/dist/app.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/EntityPickers-BBaotoyf.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_Console = require("./Console-CwDdIYJS.cjs");
|
|
3
|
-
const require_EscapableSelectPrompt = require("./EscapableSelectPrompt-
|
|
3
|
+
const require_EscapableSelectPrompt = require("./EscapableSelectPrompt-CUNQdpTZ.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-
|
|
153
|
+
const { livePositionalPreviewFor, runInvocationEditorForCommand } = await Promise.resolve().then(() => require("./ResolveInteractiveInputs-Dto6u7DS.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-
|
|
183
|
+
const { setPositionalValueForCommand } = await Promise.resolve().then(() => require("./ResolveInteractiveInputs-Dto6u7DS.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-
|
|
226
|
+
//# sourceMappingURL=RealmPickers-BFkBQzs2.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealmPickers-eE__OjpO.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,SAAS,KAAK,MAAM,IACpC;AACF;AAEA,SAAgB,gBACd,SACA,MACoB;CACpB,MAAM,QAAQ,gBAAgB,SAAS,IAAI;CAC3C,IAAI,UAAU,IAAI,OAAO,KAAA;CACzB,MAAM,QAAQ,QAAQ,gBAAgB;CACtC,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ,KAAA;AACjE;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,mBACd,SACA,MACA,OACM;CACN,MAAM,QAAQ,g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,IAAI,OAAO,UAAU,GAAG;CAExB,MAAM,UAAUD,gBAAAA,MAAM,SAAS;CAe/B,IAAI;CACJ,SAAS;EACP,MAAM,EAAE,0BAA0B,kCAChC,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,yCAAA,CAAA,CAAA,CAAA,MAAA,MAAA,EAAA,gCAAA;EACR,MAAM,SAAS,MAAME,8BAAAA,gBAAwB;GAC3C,SAAS,4BAA4B,QAAQ;GAC7C,SAAS;GACT,MAAMC,8BAAAA,oBAAoB,OAAO;GAIjC,SAAS,yBAAyB,SAAS,OAAO;GAClD,SAAS,OAAO,KAAK,WAAW;IAC9B,OAAO,MAAM;IACb,MAAM,MAAM;IACZ,aAAa,MAAM,SAAS,KAAA,IAAY;GAC1C,EAAE;EACJ,CAAC;EACD,IAAI,WAAWC,8BAAAA,UAAU,MAAMC,8BAAAA;EAC/B,IAAI,WAAWC,8BAAAA,OAAO;GAKpB,MAAM,8BAA8B,OAAO;GAC3C;EACF;EACA,SAAS;EACT;CACF;CACA,IAAI,WAAWC,8BAAAA,QAAQ;EAMrB,gBAAA,eAAe,6BAA6B,QAAQ,EAAE;EACtD;CACF;CACA,IAAI,CAAC,UAAU,WAAW,SAAS;EAKjC,gBAAA,eAAe,6BAA6B,QAAQ,EAAE;EACtD;CACF;CACA,gBAAA,MAAM,SAAS,MAAM;CAWrB;EACE,MAAM,EAAE,iCACN,MAAA,QAAA,QAAA,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
|
+
{"version":3,"file":"RealmPickers-BFkBQzs2.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,SAAS,KAAK,MAAM,IACpC;AACF;AAEA,SAAgB,gBACd,SACA,MACoB;CACpB,MAAM,QAAQ,gBAAgB,SAAS,IAAI;CAC3C,IAAI,UAAU,IAAI,OAAO,KAAA;CACzB,MAAM,QAAQ,QAAQ,gBAAgB;CACtC,OAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ,KAAA;AACjE;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,mBACd,S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time = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_Console = require("./Console-CwDdIYJS.cjs");
|
|
3
|
-
const require_EscapableSelectPrompt = require("./EscapableSelectPrompt-
|
|
3
|
+
const require_EscapableSelectPrompt = require("./EscapableSelectPrompt-CUNQdpTZ.cjs");
|
|
4
4
|
const require_AuthoringPrintState = require("./AuthoringPrintState-vyWOD1Wt.cjs");
|
|
5
|
-
const require_EntityPickers = require("./EntityPickers-
|
|
5
|
+
const require_EntityPickers = require("./EntityPickers-Bf6jtoEv.cjs");
|
|
6
6
|
const require_DefaultsStore = require("./DefaultsStore-Cb7yMNHY.cjs");
|
|
7
|
-
const require_RealmPickers = require("./RealmPickers-
|
|
7
|
+
const require_RealmPickers = require("./RealmPickers-BFkBQzs2.cjs");
|
|
8
8
|
let path = require("path");
|
|
9
9
|
path = require_rolldown_runtime.__toESM(path, 1);
|
|
10
10
|
let fs = require("fs");
|
|
@@ -1330,7 +1330,10 @@ async function resolveInteractiveInputs(command) {
|
|
|
1330
1330
|
const unsatisfied = findUnsatisfiedOneOfGroups(command);
|
|
1331
1331
|
if (unsatisfied.length > 0) throwOneOfUnsatisfied(command, unsatisfied[0]);
|
|
1332
1332
|
}
|
|
1333
|
-
if (!await collectSecretsByPrompt(command, violations, (message) => require_EntityPickers.promptPassword({
|
|
1333
|
+
if (!await collectSecretsByPrompt(command, violations, (message) => require_EntityPickers.promptPassword({
|
|
1334
|
+
message,
|
|
1335
|
+
preview: () => commandPreviewFor(command) ?? ""
|
|
1336
|
+
}))) failFirstPendingSecret(command, violations, (flags) => throwMissingMandatory(command, flags));
|
|
1334
1337
|
if (explicitlyInteractive) await runInvocationEditor(command);
|
|
1335
1338
|
require_EscapableSelectPrompt.assertNoConflicts(command);
|
|
1336
1339
|
assertNoPendingSecrets(command);
|
|
@@ -1486,6 +1489,21 @@ function liveOptionPreviewFor(command, optionName, toValue) {
|
|
|
1486
1489
|
return liveOptionPreview(command, optionName, () => commandReadinessFor(command), toValue);
|
|
1487
1490
|
}
|
|
1488
1491
|
/**
|
|
1492
|
+
* The footer of a text prompt that collects the value of an option: the
|
|
1493
|
+
* command with the text typed so far shadowed in, as the pickers do with the
|
|
1494
|
+
* highlighted value (record 0019). Every prompt that asks for a value passes
|
|
1495
|
+
* one, so a typed value is framed like a picked one.
|
|
1496
|
+
*/
|
|
1497
|
+
function typedOptionPreviewFor(command, optionName) {
|
|
1498
|
+
const live = liveOptionPreviewFor(command, optionName);
|
|
1499
|
+
return live ? (typed) => live(typed.trim()) : void 0;
|
|
1500
|
+
}
|
|
1501
|
+
/** The footer of a text prompt that collects a positional argument; see typedOptionPreviewFor. */
|
|
1502
|
+
function typedPositionalPreviewFor(command, positionalName) {
|
|
1503
|
+
const live = livePositionalPreviewFor(command, positionalName);
|
|
1504
|
+
return live ? (typed) => live(typed.trim()) : void 0;
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1489
1507
|
* Prompts for a value from a closed choice set. A ONE-item set auto-commits
|
|
1490
1508
|
* (a single choice is no choice; commander would accept only that value
|
|
1491
1509
|
* anyway -- the plan's single-option refinement); otherwise a searchable
|
|
@@ -1559,7 +1577,10 @@ async function resolveMandatoryOptions(command) {
|
|
|
1559
1577
|
if (choice === require_EscapableSelectPrompt.ESCAPE) return false;
|
|
1560
1578
|
value = choice;
|
|
1561
1579
|
} else {
|
|
1562
|
-
const answer = await require_EntityPickers.promptInput({
|
|
1580
|
+
const answer = await require_EntityPickers.promptInput({
|
|
1581
|
+
message: `Enter a value for ${option.flags}:`,
|
|
1582
|
+
preview: typedOptionPreviewFor(command, option.attributeName())
|
|
1583
|
+
});
|
|
1563
1584
|
if (!answer) return false;
|
|
1564
1585
|
value = answer;
|
|
1565
1586
|
}
|
|
@@ -1637,7 +1658,10 @@ async function resolveOneOfGroups(command) {
|
|
|
1637
1658
|
commitOrFail(command, chosen.option, value);
|
|
1638
1659
|
} else if (!/<[^>]+>|\[[^\]]+\]/.test(chosen.option.flags)) commitOrFail(command, chosen.option, true);
|
|
1639
1660
|
else {
|
|
1640
|
-
const answer = await require_EntityPickers.promptInput({
|
|
1661
|
+
const answer = await require_EntityPickers.promptInput({
|
|
1662
|
+
message: `Enter a value for ${chosen.option.flags}:`,
|
|
1663
|
+
preview: typedOptionPreviewFor(command, chosen.name)
|
|
1664
|
+
});
|
|
1641
1665
|
if (!answer) return false;
|
|
1642
1666
|
commitOrFail(command, chosen.option, answer);
|
|
1643
1667
|
}
|
|
@@ -1704,12 +1728,18 @@ async function resolveConnectionArgs(command) {
|
|
|
1704
1728
|
});
|
|
1705
1729
|
if (choice === require_EscapableSelectPrompt.ESCAPE) return false;
|
|
1706
1730
|
if (choice === ENTER_MANUALLY) {
|
|
1707
|
-
const answer = await require_EntityPickers.promptInput({
|
|
1731
|
+
const answer = await require_EntityPickers.promptInput({
|
|
1732
|
+
message: "AM base URL (or profile alias/substring):",
|
|
1733
|
+
preview: typedPositionalPreviewFor(command, "host")
|
|
1734
|
+
});
|
|
1708
1735
|
if (!answer) return false;
|
|
1709
1736
|
picked = answer;
|
|
1710
1737
|
} else picked = choice;
|
|
1711
1738
|
} else {
|
|
1712
|
-
const answer = await require_EntityPickers.promptInput({
|
|
1739
|
+
const answer = await require_EntityPickers.promptInput({
|
|
1740
|
+
message: "AM base URL:",
|
|
1741
|
+
preview: typedPositionalPreviewFor(command, "host")
|
|
1742
|
+
});
|
|
1713
1743
|
if (!answer) return false;
|
|
1714
1744
|
picked = answer;
|
|
1715
1745
|
}
|
|
@@ -1878,7 +1908,8 @@ async function runInvocationEditor(command) {
|
|
|
1878
1908
|
}
|
|
1879
1909
|
const answer = await require_EntityPickers.promptInput({
|
|
1880
1910
|
message: `Enter a value for ${option.flags}:`,
|
|
1881
|
-
default: currentText
|
|
1911
|
+
default: currentText,
|
|
1912
|
+
preview: typedOptionPreviewFor(command, attributeName)
|
|
1882
1913
|
});
|
|
1883
1914
|
if (!answer) return void 0;
|
|
1884
1915
|
if (!commitInEditor(command, option, answer)) return void 0;
|
|
@@ -1937,7 +1968,10 @@ async function runInvocationEditor(command) {
|
|
|
1937
1968
|
const pickedOption = command.options.find((candidate) => candidate.attributeName() === attributeName);
|
|
1938
1969
|
if (pickedOption && require_DefaultsStore.isSecretOption(pickedOption)) {
|
|
1939
1970
|
if (!(command.getOptionValueSource(attributeName) === "cli" && command.getOptionValue(attributeName) !== void 0)) {
|
|
1940
|
-
const answer = await require_EntityPickers.promptPassword({
|
|
1971
|
+
const answer = await require_EntityPickers.promptPassword({
|
|
1972
|
+
message: `Enter a value for ${pickedOption.flags} (input is hidden):`,
|
|
1973
|
+
preview: () => commandPreviewFor(command) ?? ""
|
|
1974
|
+
});
|
|
1941
1975
|
if (answer && commitInEditor(command, pickedOption, answer)) require_Console.verboseMessage(`Using ${pickedOption.flags}.`);
|
|
1942
1976
|
}
|
|
1943
1977
|
continue;
|
|
@@ -1955,7 +1989,7 @@ async function runInvocationEditor(command) {
|
|
|
1955
1989
|
require_Console.verboseMessage(`Using ${option.flags}.`);
|
|
1956
1990
|
}
|
|
1957
1991
|
if (picked.length > 0) {
|
|
1958
|
-
const { replayEditorOptionStates } = await Promise.resolve().then(() => require("./FrodoCommand-
|
|
1992
|
+
const { replayEditorOptionStates } = await Promise.resolve().then(() => require("./FrodoCommand-D6wEggWy.cjs")).then((n) => n.FrodoCommand_exports);
|
|
1959
1993
|
replayEditorOptionStates(command);
|
|
1960
1994
|
}
|
|
1961
1995
|
if (savingDefaults && Object.keys(committed).length > 0) {
|
|
@@ -2033,4 +2067,4 @@ Object.defineProperty(exports, "setGuidedMode", {
|
|
|
2033
2067
|
}
|
|
2034
2068
|
});
|
|
2035
2069
|
|
|
2036
|
-
//# sourceMappingURL=ResolveInteractiveInputs-
|
|
2070
|
+
//# sourceMappingURL=ResolveInteractiveInputs-Dto6u7DS.cjs.map
|