import { AutocompletePrompt } from '@clack/core'; import { CANCEL_SYMBOL } from '@clack/core'; import { Readable } from 'node:stream'; import { SpawnSyncOptions } from 'node:child_process'; import { Validate } from '@clack/core'; import { Writable } from 'node:stream'; export declare type Argv = { help?: boolean; dir?: string; template?: string; git?: boolean; override?: boolean; tools?: string | string[]; skill?: string | string[]; packageName?: string; 'package-name'?: string; templateVersion?: string; 'template-version'?: string; }; /** * The `autocomplete` prompt combines a text input with a searchable list of options. * It's perfect for when you have a large list of options and want to help users * find what they're looking for quickly. * * @see https://bomb.sh/docs/clack/packages/prompts/#autocomplete * * @example * ```ts * import { autocomplete } from '@clack/prompts'; * * const framework = await autocomplete({ * message: 'Search for a framework', * options: [ * { value: 'next', label: 'Next.js', hint: 'React framework' }, * { value: 'astro', label: 'Astro', hint: 'Content-focused' }, * { value: 'svelte', label: 'SvelteKit', hint: 'Compile-time framework' }, * { value: 'remix', label: 'Remix', hint: 'Full stack framework' }, * { value: 'nuxt', label: 'Nuxt', hint: 'Vue framework' }, * ], * placeholder: 'Type to search...', * maxItems: 5, * }); * ``` */ export declare const autocomplete: (opts: AutocompleteOptions) => Promise; declare interface AutocompleteOptions extends AutocompleteSharedOptions { /** * The initially selected option from the list. */ initialValue?: Value; /** * The starting value shown in the users input box. */ initialUserInput?: string; /** * When `true`, pressing Tab fills the input with the currently focused * option's value, as if the user had typed it. */ completeOnTab?: boolean; } /** * Options for the {@link autocomplete} prompt. */ declare interface AutocompleteSharedOptions extends CommonOptions { /** * The message or question shown to the user above the input. */ message: string; /** * The options to present, or a function that returns the options to present * allowing for custom search/filtering. * * @see https://bomb.sh/docs/clack/packages/prompts/#dynamic-options-getter */ options: Option_2[] | ((this: AutocompletePrompt>) => Option_2[]); /** * The maximum number of items/options to display in the autocomplete list at once. */ maxItems?: number; /** * Placeholder text displayed when the search field is empty. When set, pressing * tab copies the placeholder into the input. */ placeholder?: string; /** * A function or a [Standard Schema](https://github.com/standard-schema/standard-schema) * that validates user input. If a custom function is given, you should return a `string` or `Error` * to show as a validation error, or `undefined` to accept the result. */ validate?: Validate; /** * Custom filter function to match options against the search input. */ filter?: (search: string, option: Option_2) => boolean; } export declare const BUILTIN_TOOLS: BuiltinToolName[]; export declare type BuiltinToolName = 'eslint' | 'rslint' | 'biome' | 'prettier'; export declare function checkCancel(value: unknown): T; /** * Collect AGENTS.md files from template directories */ export declare function collectAgentsFiles(agentsMdSearchDirs: string[]): string[]; declare interface CommonOptions { input?: Readable; output?: Writable; signal?: AbortSignal; withGuide?: boolean; } declare interface CommonOptions_2 { timeout: number; throwOnError: boolean; nodePath: boolean; } declare interface CommonOutputApi { get pid(): number | undefined; get killed(): boolean; get exitCode(): number | undefined; get signalCode(): string | null; } /** * Copy files from one folder to another. * @param from Source folder * @param to Destination folder * @param version - Optional. The version to update in the package.json. If not provided, version will not be updated. * @param name - Optional. The name to update in the package.json. If not provided, name will not be updated. * @param isMergePackageJson Merge package.json files * @param skipFiles Files to skip */ export declare function copyFolder({ from, to, version, packageName, templateParameters, isMergePackageJson, skipFiles, }: { from: string; to: string; version?: string | Record; packageName?: string; templateParameters?: Record; isMergePackageJson?: boolean; skipFiles?: string[]; }): void; export declare function create({ name, root, templates, skipFiles, getTemplateName, getPackageManager, mapESLintTemplate, mapRslintTemplate, version, banner, noteInformation, git, onGitResolved, builtinTools, extraTools, extraSkills, argv: processArgv, }: { name: string; root: string; skipFiles?: string[]; templates: Template[]; getTemplateName: (argv: Argv) => Promise; /** * Specify the package manager for the selected template. * Return undefined to use the package manager detected from the user agent, * falling back to npm when no user agent is available. */ getPackageManager?: (context: { templateName: string; }) => string | undefined; /** * Map the template name to the ESLint template name. * If not provided, defaults to 'vanilla-ts' for all templates. */ mapESLintTemplate?: (templateName: string, context: { distFolder: string; }) => ESLintTemplateName | null; /** * Map the template name to the Rslint template name. * If not provided, defaults to 'vanilla-ts' for all templates. */ mapRslintTemplate?: (templateName: string, context: { distFolder: string; }) => RslintTemplateName | null; version?: Record | string; /** * The complete text to display in the startup greeting. * Omit this option to use `Create Project`. */ banner?: string; noteInformation?: string[]; /** * Whether to initialize a Git repository by default when the target directory * is not already inside one. Users can opt out with `--no-git`. * * @default true */ git?: boolean; /** * Runs after template files are copied and the optional Git initialization * has been resolved. */ onGitResolved?: (context: GitResolvedContext) => void | Promise; /** * Controls which built-in tools are available. * * Omit this option to enable all built-in tools. Pass an empty array to * disable them, or list the built-in tools that should remain available. * Additional tools are configured separately with `extraTools`. * * @default BUILTIN_TOOLS */ builtinTools?: BuiltinToolName[]; /** * Specify additional tools. */ extraTools?: ExtraTool[]; extraSkills?: ExtraSkill[]; /** * For test purpose, override the default argv (process.argv). */ argv?: string[]; }): Promise; export declare type ESLintTemplateName = 'vanilla-js' | 'vanilla-ts' | 'react-js' | 'react-ts' | 'vue-ts' | 'vue-js' | 'svelte-js' | 'svelte-ts'; declare type ExtraSkill = { value: string; label: string; source: string; skill?: string; /** * Controls whether the skill is shown in the interactive prompt for the * selected template/tools. Explicit `--skill` values and `--help` remain * unfiltered so CLI input stays authoritative and help stays discoverable. */ when?: (context: { templateName: string; tools: string[]; }) => boolean; order?: 'pre' | 'post'; }; declare type ExtraTool = { /** * The value of the multiselect option. */ value: string; /** * The label of the multiselect option. */ label: string; /** * The action to perform when the tool is selected. */ action?: (context: { templateName: string; packageManager: string; distFolder: string; skipFiles: string[]; addAgentsMdSearchDirs: (dir: string) => void; }) => unknown; /** * The custom command to run when the tool is selected. */ command?: string; /** * Specify where to display this tool. * If undefined, the tool will be displayed after built-in tools. */ order?: 'pre' | 'post'; /** * Condition to determine whether this tool should be displayed. * If returns false, the tool will not be shown in the selection. * @default () => true */ when?: (context: { templateName: string; }) => boolean; }; export declare type GitContext = { /** Whether Git initialization is enabled for the generated project. */ gitEnabled: boolean; /** Whether the generated project is the root of its Git worktree. */ isGitRoot: boolean; }; export declare type GitResolvedContext = GitContext & { templateName: string; distFolder: string; }; /** * The `groupMultiselect` prompt extends the {@link multiselect} prompt to allow * arranging distinct Multi-Selects, whilst keeping all of them interactive. * * @see https://bomb.sh/docs/clack/packages/prompts/#group-multiselect * * @example * ```ts * import { groupMultiselect } from '@clack/prompts'; * * const result = await groupMultiselect({ * message: 'Define your project', * options: { * 'Testing': [ * { value: 'Jest', hint: 'JavaScript testing framework' }, * { value: 'Playwright', hint: 'End-to-end testing' }, * ], * 'Language': [ * { value: 'js', label: 'JavaScript', hint: 'Dynamic typing' }, * { value: 'ts', label: 'TypeScript', hint: 'Static typing' }, * ], * }, * }); * ``` * * @param opts The options for the group multiselect prompt */ export declare const groupMultiselect: (opts: GroupMultiSelectOptions) => Promise; /** * Options for the {@link groupMultiselect} prompt. */ declare interface GroupMultiSelectOptions extends CommonOptions { /** * The message or question shown to the user above the input. */ message: string; /** * Grouped options to display. Each key is a group label, and each value is an array of options. */ options: Record[]>; /** * The initially selected option(s). */ initialValues?: Value[]; /** * The maximum number of items/options to display at once. */ maxItems?: number; /** * When `true` at least one option must be selected. * @default true */ required?: boolean; /** * The value the cursor should be positioned at initially. */ cursorAt?: Value; /** * Whether entire groups can be selected at once. * @default true */ selectableGroups?: boolean; /** * Number of blank lines between groups. * @default 0 */ groupSpacing?: number; /** * Show keyboard instructions below the option list. * @default true */ showInstructions?: boolean; } /** * Check if the input is an npm package template */ export declare function isNpmTemplate(templateInput: string): boolean; /** * Merge AGENTS.md files from multiple sources */ export declare function mergeAgentsFiles(agentsFiles: string[]): string; /** * Merge two package.json files and keep the order of keys. * @param targetPackage Path to the base package.json file * @param extraPackage Path to the extra package.json file to merge */ export declare function mergePackageJson(targetPackage: string, extraPackage: string): void; export declare const multiselect: (opts: MultiSelectOptions) => Promise; declare interface MultiSelectOptions extends CommonOptions { message: string; options: Option_2[]; initialValues?: Value[]; maxItems?: number; required?: boolean; cursorAt?: Value; /** * Show keyboard instructions below the option list. * @default true */ showInstructions?: boolean; } declare type Option_2 = Value extends Primitive ? { /** * Internal data for this option. */ value: Value; /** * The optional, user-facing text for this option. * * By default, the `value` is converted to a string. */ label?: string; /** * An optional hint to display to the user when * this option might be selected. * * By default, no `hint` is displayed. */ hint?: string; /** * Whether this option is disabled. * Disabled options are visible but cannot be selected. * * By default, options are not disabled. */ disabled?: boolean; } : { /** * Internal data for this option. */ value: Value; /** * Required. The user-facing text for this option. */ label: string; /** * An optional hint to display to the user when * this option might be selected. * * By default, no `hint` is displayed. */ hint?: string; /** * Whether this option is disabled. * Disabled options are visible but cannot be selected. * * By default, options are not disabled. */ disabled?: boolean; }; declare interface Output { stderr: string; stdout: string; exitCode: number | undefined; } declare interface OutputApiSync extends Iterable, CommonOutputApi {} declare type Primitive = Readonly; /** * Resolve custom template (npm package, GitHub, or local path) */ export declare function resolveCustomTemplate(templateInput: string, version?: string, options?: { forceLatest?: boolean; cacheDir?: string; }): string; /** * Resolve npm template package and return the local path */ export declare function resolveNpmTemplate(packageName: string, version?: string, options?: { forceLatest?: boolean; cacheDir?: string; }): string; export declare type RslintTemplateName = 'vanilla-js' | 'vanilla-ts' | 'react-js' | 'react-ts'; /** * Sanitize package name and version to create a valid cache key */ export declare const sanitizeCacheKey: (packageName: string, version: string) => string; export declare const select: (opts: SelectOptions) => Promise; declare interface SelectOptions extends CommonOptions { message: string; options: Option_2[]; initialValue?: Value; maxItems?: number; /** * Show keyboard instructions below the option list. * @default true */ showInstructions?: boolean; } declare interface SyncOptions extends CommonOptions_2 { nodeOptions: SpawnSyncOptions; } declare type SyncResult = Output & OutputApiSync; export declare type Template = string | { name: string; /** * Create a project using an external CLI or custom generation logic. * Replaces the toolkit's built-in project setup. */ create: (context: TemplateCreateContext) => void | Promise; }; export declare type TemplateCreateContext = { /** Absolute path to the project directory. */ distFolder: string; packageName: string; packageManager: string; gitEnabled: boolean; /** Whether overwriting was requested or confirmed by the user. */ override: boolean; }; /** * The text prompt accepts a single line of text. * * @see https://bomb.sh/docs/clack/packages/prompts/#text-input * * @example * ```ts * import { text } from '@clack/prompts'; * * const name = await text({ * message: 'What is your name?', * placeholder: 'John Doe', * validate: (value) => { * if (!value || value.length < 2) return 'Name must be at least 2 characters'; * return undefined; * }, * }); * ``` */ export declare const text: (opts: TextOptions) => Promise; /** * Options for the {@link text} prompt */ declare interface TextOptions extends CommonOptions { /** * The prompt message or question shown to the user above the input. */ message: string; /** * A visual hint shown when the field has no content. */ placeholder?: string; /** * A fallback value returned when the user provides nothing (empty input). */ defaultValue?: string; /** * The starting value shown when the prompt first renders. * Users can edit this value before submitting. */ initialValue?: string; /** * A function or a [Standard Schema](https://github.com/standard-schema/standard-schema) * that validates user input. If a custom function is given, you should return a `string` or `Error` * to show as a validation error, or `undefined` to accept the result. */ validate?: Validate; } export declare function xSync(command: string, args?: readonly string[], options?: Partial): SyncResult; export { }