import type { CategoryConfig } from './category-config.js'; import type { PluginMeta } from './plugin-config.js'; type PromptBase = { key: string; message: string; }; type PromptChoice = { name: string; value: T; }; type InputPrompt = PromptBase & { type: 'input'; default: string; }; type SelectPrompt = PromptBase & { type: 'select'; choices: PromptChoice[]; default: T; }; type CheckboxPrompt = PromptBase & { type: 'checkbox'; choices: PromptChoice[]; default: T[]; }; type ConfirmPrompt = PromptBase & { type: 'confirm'; default: boolean; }; /** Declarative prompt definition used to collect plugin-specific options. */ export type PluginPromptDescriptor = InputPrompt | SelectPrompt | CheckboxPrompt | ConfirmPrompt; /** A single value in the answers record produced by plugin prompts. */ export type PluginAnswer = string | string[] | boolean; export type ImportDeclarationStructure = { moduleSpecifier: string; defaultImport?: string; namedImports?: string[]; isTypeOnly?: boolean; }; export type PluginDeclarationStructure = { identifier: string; expression: string; }; type CategoryCodegenRefs = { refs: CategoryConfig['refs']; } | { refsExpression: string; }; export type CategoryCodegenConfig = CategoryCodegenRefs & Pick; export type PluginCodegenResult = { imports: ImportDeclarationStructure[]; pluginDeclaration?: PluginDeclarationStructure; pluginInit: string[]; categories?: CategoryCodegenConfig[]; }; /** Minimal file system abstraction passed to plugin bindings. */ export type PluginSetupTree = { read: (path: string) => Promise; write: (path: string, content: string) => Promise; }; /** * Defines how a plugin integrates with the setup wizard. * * Each supported plugin provides a binding that controls: * - Pre-selection: `isRecommended` detects if the plugin is relevant for the repository * - Configuration: `prompts` collect plugin-specific options interactively * - Code generation: `generateConfig` produces the import and initialization code */ export type PluginSetupBinding = { slug: PluginMeta['slug']; title: PluginMeta['title']; packageName: NonNullable; scope?: 'project' | 'root'; prompts?: (targetDir: string) => Promise; isRecommended?: (targetDir: string) => Promise; generateConfig: (answers: Record, tree: PluginSetupTree) => PluginCodegenResult | Promise; }; export {};