import { Inquirerer } from 'inquirerer'; import { Question } from 'inquirerer'; /** * Configuration for TemplateScaffolder instance */ export interface TemplateScaffolderConfig { /** * Tool name used for cache directory naming (e.g., 'my-cli' -> ~/.my-cli/cache) */ toolName: string; /** * Default template repository URL or path. * Used when scaffold() is called without specifying a template. */ defaultRepo?: string; /** * Default branch to use when cloning repositories */ defaultBranch?: string; /** * Cache time-to-live in milliseconds. * Cached templates older than this will be re-cloned. * Default: no expiration */ ttlMs?: number; /** * Base directory for cache storage. * Useful for tests to avoid touching the real home directory. */ cacheBaseDir?: string; } /** * Options for a single scaffold operation */ export interface ScaffoldOptions { /** * Template repository URL, local path, or org/repo shorthand. * If not provided, uses the defaultRepo from config. */ template?: string; /** * Branch to clone (for remote repositories) */ branch?: string; /** * Subdirectory within the template repository to use as the template root. * Can be a direct path or a variant name that gets resolved via .boilerplates.json */ fromPath?: string; /** * Whether to use .boilerplates.json for path resolution fallback. * When true (default), if fromPath doesn't exist directly, the resolver * will check .boilerplates.json for a base directory to prepend. * When false, .boilerplates.json is ignored and fromPath is used as-is. * @default true */ useBoilerplatesConfig?: boolean; /** * Output directory for the generated project */ outputDir: string; /** * Pre-populated answers to skip prompting for known values */ answers?: Record; /** * Disable TTY mode for non-interactive environments */ noTty?: boolean; /** * Optional Prompter instance to reuse for prompting. * If provided, the caller retains ownership and is responsible for closing it. * If not provided, a new instance will be created and closed automatically. */ prompter?: Inquirerer; } /** * Result of a scaffold operation */ export interface ScaffoldResult { /** * Path to the generated output directory */ outputDir: string; /** * Whether a cached template was used */ cacheUsed: boolean; /** * Whether the cache was expired and refreshed */ cacheExpired: boolean; /** * Path to the cached/cloned template directory */ templateDir: string; /** * The resolved fromPath used for template processing */ fromPath?: string; /** * Questions loaded from .boilerplate.json, if any */ questions?: Question[]; /** * Answers collected during prompting */ answers: Record; } /** * Root configuration for a boilerplates repository. * Stored in `.boilerplates.json` at the repository root. */ export interface BoilerplatesConfig { /** * Default directory containing boilerplate templates (e.g., "templates", "boilerplates") */ dir?: string; } /** * Declares a skill to install after scaffolding completes. * Used with the agentskills.io CLI (`npx skills add --skill `). */ export interface BoilerplateSkill { /** GitHub repository in org/repo format, or a full URL */ source: string; /** Skill name(s) to install from the source */ skills: string[]; } /** * Configuration for a single boilerplate template. * Stored in `.boilerplate.json` within each template directory. */ export interface BoilerplateConfig { /** * Optional type identifier for the boilerplate */ type?: string; /** * Questions to prompt the user during scaffolding */ questions?: Question[]; /** * Skills to install after scaffolding completes. * Each entry specifies a source repository and skill names to install. * Non-fatal: callers should handle install failures gracefully. */ skills?: BoilerplateSkill[]; } /** * Options for inspecting a template without scaffolding. * Used to read template metadata before deciding how to handle it. */ export interface InspectOptions { /** * Template repository URL, local path, or org/repo shorthand. * If not provided, uses the defaultRepo from config. */ template?: string; /** * Branch to clone (for remote repositories) */ branch?: string; /** * Subdirectory within the template repository to inspect. * Can be a direct path or a variant name that gets resolved via .boilerplates.json */ fromPath?: string; /** * Whether to use .boilerplates.json for path resolution fallback. * When true (default), if fromPath doesn't exist directly, the resolver * will check .boilerplates.json for a base directory to prepend. * When false, .boilerplates.json is ignored and fromPath is used as-is. * @default true */ useBoilerplatesConfig?: boolean; } /** * Result of inspecting a template. * Contains metadata about the template without copying any files. */ export interface InspectResult { /** * Path to the cached/cloned template directory */ templateDir: string; /** * The resolved fromPath after .boilerplates.json resolution */ resolvedFromPath?: string; /** * Full path to the resolved template directory */ resolvedTemplatePath: string; /** * Whether a cached template was used */ cacheUsed: boolean; /** * Whether the cache was expired and refreshed */ cacheExpired: boolean; /** * The .boilerplate.json configuration from the template, if present */ config: BoilerplateConfig | null; }