feat: streamline wizard selection prompts

This commit is contained in:
Peter Steinberger
2026-01-12 05:08:07 +00:00
parent abdf4c30b2
commit 873cee6947
5 changed files with 270 additions and 85 deletions

View File

@@ -3,7 +3,6 @@ import path from "node:path";
import {
confirm as clackConfirm,
intro as clackIntro,
multiselect as clackMultiselect,
outro as clackOutro,
select as clackSelect,
text as clackText,
@@ -41,7 +40,7 @@ import {
applyAuthChoice,
resolvePreferredProviderForAuthChoice,
} from "./auth-choice.js";
import { buildAuthChoiceOptions } from "./auth-choice-options.js";
import { promptAuthChoiceGrouped } from "./auth-choice-prompt.js";
import {
DEFAULT_GATEWAY_DAEMON_RUNTIME,
GATEWAY_DAEMON_RUNTIME_OPTIONS,
@@ -64,7 +63,6 @@ import {
import { setupProviders } from "./onboard-providers.js";
import { promptRemoteGatewayConfig } from "./onboard-remote.js";
import { setupSkills } from "./onboard-skills.js";
import type { AuthChoice } from "./onboard-types.js";
import { ensureSystemdUserLingerInteractive } from "./systemd-linger.js";
export const CONFIGURE_WIZARD_SECTIONS = [
@@ -110,16 +108,92 @@ const select = <T>(params: Parameters<typeof clackSelect<T>>[0]) =>
: { ...opt, hint: stylePromptHint(opt.hint) },
),
});
const multiselect = <T>(params: Parameters<typeof clackMultiselect<T>>[0]) =>
clackMultiselect({
...params,
message: stylePromptMessage(params.message),
options: params.options.map((opt) =>
opt.hint === undefined
? opt
: { ...opt, hint: stylePromptHint(opt.hint) },
),
});
const CONFIGURE_SECTION_OPTIONS: {
value: WizardSection;
label: string;
hint: string;
}[] = [
{
value: "workspace",
label: "Workspace",
hint: "Set default workspace + ensure sessions",
},
{
value: "model",
label: "Model/auth",
hint: "Pick model + auth profile sources",
},
{
value: "gateway",
label: "Gateway config",
hint: "Port/bind/auth/control UI settings",
},
{
value: "daemon",
label: "Gateway daemon",
hint: "Install/manage the background service",
},
{
value: "providers",
label: "Providers",
hint: "Link WhatsApp/Telegram/etc and defaults",
},
{
value: "skills",
label: "Skills",
hint: "Install/enable workspace skills",
},
{
value: "health",
label: "Health check",
hint: "Run gateway + provider checks",
},
];
async function promptConfigureSections(
runtime: RuntimeEnv,
): Promise<WizardSection[]> {
const selected: WizardSection[] = [];
let remaining = CONFIGURE_SECTION_OPTIONS.slice();
let addMore = true;
while (addMore && remaining.length > 0) {
const choice = guardCancel(
await select<WizardSection>({
message:
selected.length === 0
? "Select a section to configure"
: "Select another section to configure",
options: remaining,
initialValue: remaining[0]?.value,
}),
runtime,
) as WizardSection;
if (!selected.includes(choice)) {
selected.push(choice);
}
remaining = CONFIGURE_SECTION_OPTIONS.filter(
(option) => !selected.includes(option.value),
);
if (remaining.length === 0) {
break;
}
addMore = guardCancel(
await confirm({
message: "Configure another section?",
initialValue: false,
}),
runtime,
);
}
return selected;
}
async function promptGatewayConfig(
cfg: ClawdbotConfig,
@@ -294,15 +368,13 @@ async function promptAuthConfig(
runtime: RuntimeEnv,
prompter: WizardPrompter,
): Promise<ClawdbotConfig> {
const authChoice: AuthChoice = await prompter.select({
message: "Model/auth choice",
options: buildAuthChoiceOptions({
store: ensureAuthProfileStore(undefined, {
allowKeychainPrompt: false,
}),
includeSkip: true,
includeClaudeCliIfMissing: true,
const authChoice = await promptAuthChoiceGrouped({
prompter,
store: ensureAuthProfileStore(undefined, {
allowKeychainPrompt: false,
}),
includeSkip: true,
includeClaudeCliIfMissing: true,
});
let next = cfg;
@@ -596,49 +668,7 @@ export async function runConfigureWizard(
const selected = opts.sections
? opts.sections
: (guardCancel(
await multiselect({
message: "Select sections to configure",
options: [
{
value: "workspace",
label: "Workspace",
hint: "Set default workspace + ensure sessions",
},
{
value: "model",
label: "Model/auth",
hint: "Pick model + auth profile sources",
},
{
value: "gateway",
label: "Gateway config",
hint: "Port/bind/auth/control UI settings",
},
{
value: "daemon",
label: "Gateway daemon",
hint: "Install/manage the background service",
},
{
value: "providers",
label: "Providers",
hint: "Link WhatsApp/Telegram/etc and defaults",
},
{
value: "skills",
label: "Skills",
hint: "Install/enable workspace skills",
},
{
value: "health",
label: "Health check",
hint: "Run gateway + provider checks",
},
],
}),
runtime,
) as WizardSection[]);
: await promptConfigureSections(runtime);
if (!selected || selected.length === 0) {
outro("No changes selected.");