padrone 1.0.0-beta.2

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/index.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["colors","lines: string[]","lineParts: string[]","parts: string[]","envParts: string[]","configParts: string[]","exampleParts: string[]","aliases: Record<string, string>","envBindings: Record<string, string[]>","configKeys: Record<string, string>","current: unknown","args: HelpArgumentInfo[]","result: HelpOptionInfo[]","helpInfo: HelpInfo","optMap: Record<string, HelpOptionInfo>","tokens: string[]","inQuote: '\"' | \"'\" | '`' | null","result: ParsePart[]","pendingValue: ParseParts['option'] | ParseParts['alias'] | undefined","items: string[]","find: AnyPadroneProgram['find']","curCommand: AnyPadroneCommand | undefined","rawOptions: Record<string, unknown>","parse: AnyPadroneProgram['parse']","stringify: AnyPadroneProgram['stringify']","parts: string[]","validFormats: FormatLevel[]","cli: AnyPadroneProgram['cli']","run: AnyPadroneProgram['run']","tool: AnyPadroneProgram['tool']"],"sources":["../src/colorizer.ts","../src/formatter.ts","../src/options.ts","../src/utils.ts","../src/help.ts","../src/parse.ts","../src/create.ts","../src/index.ts"],"sourcesContent":["// ANSI color codes\nconst colors = {\n reset: '\\x1b[0m',\n bold: '\\x1b[1m',\n dim: '\\x1b[2m',\n italic: '\\x1b[3m',\n underline: '\\x1b[4m',\n strikethrough: '\\x1b[9m',\n cyan: '\\x1b[36m',\n green: '\\x1b[32m',\n yellow: '\\x1b[33m',\n blue: '\\x1b[34m',\n magenta: '\\x1b[35m',\n gray: '\\x1b[90m',\n};\n\nexport type Colorizer = {\n command: (text: string) => string;\n option: (text: string) => string;\n type: (text: string) => string;\n description: (text: string) => string;\n label: (text: string) => string;\n meta: (text: string) => string;\n example: (text: string) => string;\n exampleValue: (text: string) => string;\n deprecated: (text: string) => string;\n};\n\nexport function createColorizer(): Colorizer {\n return {\n command: (text: string) => `${colors.cyan}${colors.bold}${text}${colors.reset}`,\n option: (text: string) => `${colors.green}${text}${colors.reset}`,\n type: (text: string) => `${colors.yellow}${text}${colors.reset}`,\n description: (text: string) => `${colors.dim}${text}${colors.reset}`,\n label: (text: string) => `${colors.bold}${text}${colors.reset}`,\n meta: (text: string) => `${colors.gray}${text}${colors.reset}`,\n example: (text: string) => `${colors.underline}${text}${colors.reset}`,\n exampleValue: (text: string) => `${colors.italic}${text}${colors.reset}`,\n deprecated: (text: string) => `${colors.strikethrough}${colors.gray}${text}${colors.reset}`,\n };\n}\n","import { createColorizer } from './colorizer';\n\nexport type HelpFormat = 'text' | 'ansi' | 'console' | 'markdown' | 'html' | 'json';\nexport type HelpDetail = 'minimal' | 'standard' | 'full';\n\n// ============================================================================\n// Help Info Types (shared with help.ts)\n// ============================================================================\n\n/**\n * Information about a single positional argument.\n */\nexport type HelpArgumentInfo = {\n name: string;\n description?: string;\n optional: boolean;\n default?: unknown;\n type?: string;\n};\n\n/**\n * Information about a single option/flag.\n */\nexport type HelpOptionInfo = {\n name: string;\n description?: string;\n optional: boolean;\n default?: unknown;\n type?: string;\n enum?: string[];\n aliases?: string[];\n deprecated?: boolean | string;\n hidden?: boolean;\n examples?: unknown[];\n /** Environment variable(s) this option can be set from */\n env?: string | string[];\n /** Whether this option is an array type (shown as <type...>) */\n variadic?: boolean;\n /** Whether this option is a boolean (shown as --[no-]option) */\n negatable?: boolean;\n /** Config file key that maps to this option */\n configKey?: string;\n};\n\n/**\n * Information about a subcommand (minimal info for listing).\n */\nexport type HelpSubcommandInfo = {\n name: string;\n title?: string;\n description?: string;\n deprecated?: boolean | string;\n hidden?: boolean;\n};\n\n/**\n * Comprehensive JSON structure for help information.\n * This is the single source of truth that all formatters use.\n */\nexport type HelpInfo = {\n /** The full command name (e.g., \"cli serve\" or \"<root>\") */\n name: string;\n /** Short title for the command */\n title?: string;\n /** Command description */\n description?: string;\n /** Whether the command is deprecated */\n deprecated?: boolean | string;\n /** Whether the command is hidden */\n hidden?: boolean;\n /** Usage string parts for flexible formatting */\n usage: {\n command: string;\n hasSubcommands: boolean;\n hasArguments: boolean;\n hasOptions: boolean;\n };\n /** List of subcommands */\n subcommands?: HelpSubcommandInfo[];\n /** Positional arguments */\n arguments?: HelpArgumentInfo[];\n /** Options/flags (only visible ones, hidden filtered out) */\n options?: HelpOptionInfo[];\n /** Full help info for nested commands (used in 'full' detail mode) */\n nestedCommands?: HelpInfo[];\n};\n\n// ============================================================================\n// Formatter Interface\n// ============================================================================\n\n/**\n * A formatter that takes the entire HelpInfo structure and produces formatted output.\n */\nexport type Formatter = {\n /** Format the entire help info structure into a string */\n format: (info: HelpInfo) => string;\n};\n\n// ============================================================================\n// Internal Styling Types\n// ============================================================================\n\n/**\n * Internal styling functions used by formatters.\n * These handle the visual styling of individual text elements.\n */\ntype Styler = {\n command: (text: string) => string;\n option: (text: string) => string;\n type: (text: string) => string;\n description: (text: string) => string;\n label: (text: string) => string;\n meta: (text: string) => string;\n example: (text: string) => string;\n exampleValue: (text: string) => string;\n deprecated: (text: string) => string;\n};\n\n/**\n * Layout configuration for formatters.\n */\ntype LayoutConfig = {\n newline: string;\n indent: (level: number) => string;\n join: (parts: string[]) => string;\n wrapDocument?: (content: string) => string;\n usageLabel: string;\n};\n\n// ============================================================================\n// Styler Factories\n// ============================================================================\n\nfunction createTextStyler(): Styler {\n return {\n command: (text) => text,\n option: (text) => text,\n type: (text) => text,\n description: (text) => text,\n label: (text) => text,\n meta: (text) => text,\n example: (text) => text,\n exampleValue: (text) => text,\n deprecated: (text) => text,\n };\n}\n\nfunction createAnsiStyler(): Styler {\n const colorizer = createColorizer();\n return {\n command: colorizer.command,\n option: colorizer.option,\n type: colorizer.type,\n description: colorizer.description,\n label: colorizer.label,\n meta: colorizer.meta,\n example: colorizer.example,\n exampleValue: colorizer.exampleValue,\n deprecated: colorizer.deprecated,\n };\n}\n\nfunction createConsoleStyler(): Styler {\n const colors = {\n reset: '\\x1b[0m',\n bold: '\\x1b[1m',\n dim: '\\x1b[2m',\n italic: '\\x1b[3m',\n underline: '\\x1b[4m',\n strikethrough: '\\x1b[9m',\n cyan: '\\x1b[36m',\n green: '\\x1b[32m',\n yellow: '\\x1b[33m',\n gray: '\\x1b[90m',\n };\n return {\n command: (text) => `${colors.cyan}${colors.bold}${text}${colors.reset}`,\n option: (text) => `${colors.green}${text}${colors.reset}`,\n type: (text) => `${colors.yellow}${text}${colors.reset}`,\n description: (text) => `${colors.dim}${text}${colors.reset}`,\n label: (text) => `${colors.bold}${text}${colors.reset}`,\n meta: (text) => `${colors.gray}${text}${colors.reset}`,\n example: (text) => `${colors.underline}${text}${colors.reset}`,\n exampleValue: (text) => `${colors.italic}${text}${colors.reset}`,\n deprecated: (text) => `${colors.strikethrough}${colors.gray}${text}${colors.reset}`,\n };\n}\n\nfunction createMarkdownStyler(): Styler {\n return {\n command: (text) => `**${text}**`,\n option: (text) => `\\`${text}\\``,\n type: (text) => `\\`${text}\\``,\n description: (text) => text,\n label: (text) => `### ${text}`,\n meta: (text) => `*${text}*`,\n example: (text) => `**${text}**`,\n exampleValue: (text) => `\\`${text}\\``,\n deprecated: (text) => `~~${text}~~`,\n };\n}\n\nfunction escapeHtml(text: string): string {\n return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g, '&quot;').replace(/'/g, '&#039;');\n}\n\nfunction createHtmlStyler(): Styler {\n return {\n command: (text) => `<strong style=\"color: #00bcd4;\">${escapeHtml(text)}</strong>`,\n option: (text) => `<code style=\"color: #4caf50;\">${escapeHtml(text)}</code>`,\n type: (text) => `<code style=\"color: #ff9800;\">${escapeHtml(text)}</code>`,\n description: (text) => `<span style=\"color: #666;\">${escapeHtml(text)}</span>`,\n label: (text) => `<h3>${escapeHtml(text)}</h3>`,\n meta: (text) => `<span style=\"color: #999;\">${escapeHtml(text)}</span>`,\n example: (text) => `<strong style=\"text-decoration: underline;\">${escapeHtml(text)}</strong>`,\n exampleValue: (text) => `<em>${escapeHtml(text)}</em>`,\n deprecated: (text) => `<del style=\"color: #999;\">${escapeHtml(text)}</del>`,\n };\n}\n\n// ============================================================================\n// Layout Configurations\n// ============================================================================\n\nfunction createTextLayout(): LayoutConfig {\n return {\n newline: '\\n',\n indent: (level) => ' '.repeat(level),\n join: (parts) => parts.filter(Boolean).join(' '),\n usageLabel: 'Usage:',\n };\n}\n\nfunction createMarkdownLayout(): LayoutConfig {\n return {\n newline: '\\n\\n',\n indent: (level) => {\n if (level === 0) return '';\n if (level === 1) return ' ';\n return ' ';\n },\n join: (parts) => parts.filter(Boolean).join(' '),\n usageLabel: 'Usage:',\n };\n}\n\nfunction createHtmlLayout(): LayoutConfig {\n return {\n newline: '<br>',\n indent: (level) => '&nbsp;&nbsp;'.repeat(level),\n join: (parts) => parts.filter(Boolean).join(' '),\n wrapDocument: (content) => `<div style=\"font-family: monospace; line-height: 1.6;\">${content}</div>`,\n usageLabel: '<strong>Usage:</strong>',\n };\n}\n\n// ============================================================================\n// Generic Formatter Implementation\n// ============================================================================\n\n/**\n * Creates a formatter that uses the given styler and layout configuration.\n */\nfunction createGenericFormatter(styler: Styler, layout: LayoutConfig): Formatter {\n const { newline, indent, join, wrapDocument, usageLabel } = layout;\n\n function formatUsageSection(info: HelpInfo): string[] {\n const usageParts: string[] = [\n styler.command(info.usage.command),\n info.usage.hasSubcommands ? styler.meta('[command]') : '',\n info.usage.hasArguments ? styler.meta('[args...]') : '',\n info.usage.hasOptions ? styler.meta('[options]') : '',\n ];\n return [`${usageLabel} ${join(usageParts)}`];\n }\n\n function formatSubcommandsSection(info: HelpInfo): string[] {\n const lines: string[] = [];\n const subcommands = info.subcommands!;\n\n lines.push(styler.label('Commands:'));\n\n const maxNameLength = Math.max(...subcommands.map((c) => c.name.length));\n for (const subCmd of subcommands) {\n const padding = ' '.repeat(Math.max(0, maxNameLength - subCmd.name.length + 2));\n const isDeprecated = !!subCmd.deprecated;\n const commandName = isDeprecated ? styler.deprecated(subCmd.name) : styler.command(subCmd.name);\n const lineParts: string[] = [commandName, padding];\n\n // Use title if available, otherwise use description\n const displayText = subCmd.title ?? subCmd.description;\n if (displayText) {\n lineParts.push(isDeprecated ? styler.deprecated(displayText) : styler.description(displayText));\n }\n if (isDeprecated) {\n const deprecatedMeta =\n typeof subCmd.deprecated === 'string' ? styler.meta(` (deprecated: ${subCmd.deprecated})`) : styler.meta(' (deprecated)');\n lineParts.push(deprecatedMeta);\n }\n lines.push(indent(1) + lineParts.join(''));\n }\n\n lines.push('');\n lines.push(styler.meta(`Run \"${info.name} [command] --help\" for more information on a command.`));\n\n return lines;\n }\n\n function formatArgumentsSection(info: HelpInfo): string[] {\n const lines: string[] = [];\n const args = info.arguments!;\n\n lines.push(styler.label('Arguments:'));\n\n for (const arg of args) {\n const parts: string[] = [styler.option(arg.name)];\n if (arg.optional) parts.push(styler.meta('(optional)'));\n if (arg.default !== undefined) parts.push(styler.meta(`(default: ${String(arg.default)})`));\n lines.push(indent(1) + join(parts));\n\n if (arg.description) {\n lines.push(indent(2) + styler.description(arg.description));\n }\n }\n\n return lines;\n }\n\n function formatOptionsSection(info: HelpInfo): string[] {\n const lines: string[] = [];\n const options = info.options!;\n\n lines.push(styler.label('Options:'));\n\n const maxNameLength = Math.max(...options.map((opt) => opt.name.length));\n\n for (const opt of options) {\n // Format option name: --[no-]option for booleans, --option otherwise\n const optionName = opt.negatable ? `--[no-]${opt.name}` : `--${opt.name}`;\n const aliasNames = opt.aliases && opt.aliases.length > 0 ? opt.aliases.map((a) => `-${a}`).join(', ') : '';\n const fullOptionName = aliasNames ? `${optionName}, ${aliasNames}` : optionName;\n const padding = ' '.repeat(Math.max(0, maxNameLength - opt.name.length + 2));\n const isDeprecated = !!opt.deprecated;\n const formattedOptionName = isDeprecated ? styler.deprecated(fullOptionName) : styler.option(fullOptionName);\n\n const parts: string[] = [formattedOptionName];\n if (opt.type) parts.push(styler.type(`<${opt.type}>`));\n if (opt.optional && !opt.deprecated) parts.push(styler.meta('(optional)'));\n if (opt.default !== undefined) parts.push(styler.meta(`(default: ${String(opt.default)})`));\n if (opt.enum) parts.push(styler.meta(`(choices: ${opt.enum.join(', ')})`));\n if (opt.variadic) parts.push(styler.meta('(repeatable)'));\n if (isDeprecated) {\n const deprecatedMeta =\n typeof opt.deprecated === 'string' ? styler.meta(`(deprecated: ${opt.deprecated})`) : styler.meta('(deprecated)');\n parts.push(deprecatedMeta);\n }\n\n const description = opt.description ? styler.description(opt.description) : '';\n lines.push(indent(1) + join(parts) + padding + description);\n\n // Environment variable line\n if (opt.env) {\n const envVars = typeof opt.env === 'string' ? [opt.env] : opt.env;\n const envParts: string[] = [styler.example('Env:'), styler.exampleValue(envVars.join(', '))];\n lines.push(indent(3) + join(envParts));\n }\n\n // Config key line\n if (opt.configKey) {\n const configParts: string[] = [styler.example('Config:'), styler.exampleValue(opt.configKey)];\n lines.push(indent(3) + join(configParts));\n }\n\n // Examples line\n if (opt.examples && opt.examples.length > 0) {\n const exampleValues = opt.examples.map((example) => (typeof example === 'string' ? example : JSON.stringify(example))).join(', ');\n const exampleParts: string[] = [styler.example('Example:'), styler.exampleValue(exampleValues)];\n lines.push(indent(3) + join(exampleParts));\n }\n }\n\n return lines;\n }\n\n return {\n format(info: HelpInfo): string {\n const lines: string[] = [];\n\n // Show deprecation warning at the top if command is deprecated\n if (info.deprecated) {\n const deprecationMessage =\n typeof info.deprecated === 'string' ? `⚠️ This command is deprecated: ${info.deprecated}` : '⚠️ This command is deprecated';\n lines.push(styler.deprecated(deprecationMessage));\n lines.push('');\n }\n\n // Usage section\n lines.push(...formatUsageSection(info));\n lines.push('');\n\n // Title section (if present, shows a short summary line)\n if (info.title) {\n lines.push(styler.label(info.title));\n lines.push('');\n }\n\n // Description section (if present)\n if (info.description) {\n lines.push(styler.description(info.description));\n lines.push('');\n }\n\n // Subcommands section\n if (info.subcommands && info.subcommands.length > 0) {\n lines.push(...formatSubcommandsSection(info));\n lines.push('');\n }\n\n // Arguments section\n if (info.arguments && info.arguments.length > 0) {\n lines.push(...formatArgumentsSection(info));\n lines.push('');\n }\n\n // Options section\n if (info.options && info.options.length > 0) {\n lines.push(...formatOptionsSection(info));\n lines.push('');\n }\n\n // Nested commands section (full detail mode)\n if (info.nestedCommands?.length) {\n lines.push(styler.label('Subcommand Details:'));\n lines.push('');\n for (const nestedCmd of info.nestedCommands) {\n lines.push(styler.meta('─'.repeat(60)));\n lines.push(this.format(nestedCmd));\n }\n }\n\n const result = lines.join(newline);\n return wrapDocument ? wrapDocument(result) : result;\n },\n };\n}\n\n// ============================================================================\n// JSON Formatter\n// ============================================================================\n\nfunction createJsonFormatter(): Formatter {\n return {\n format(info: HelpInfo): string {\n return JSON.stringify(info, null, 2);\n },\n };\n}\n\n// ============================================================================\n// Formatter Factory\n// ============================================================================\n\nfunction shouldUseAnsi(): boolean {\n if (typeof process === 'undefined') return false;\n if (process.env.NO_COLOR) return false;\n if (process.env.CI) return false;\n if (process.stdout && typeof process.stdout.isTTY === 'boolean') return process.stdout.isTTY;\n return false;\n}\n\n// ============================================================================\n// Minimal Formatter\n// ============================================================================\n\n/**\n * Creates a minimal formatter that outputs just a single-line usage string.\n */\nfunction createMinimalFormatter(): Formatter {\n return {\n format(info: HelpInfo): string {\n const parts: string[] = [info.usage.command];\n if (info.usage.hasSubcommands) parts.push('[command]');\n if (info.usage.hasArguments) parts.push('[args...]');\n if (info.usage.hasOptions) parts.push('[options]');\n return parts.join(' ');\n },\n };\n}\n\nexport function createFormatter(format: HelpFormat | 'auto', detail: HelpDetail = 'standard'): Formatter {\n if (detail === 'minimal') return createMinimalFormatter();\n if (format === 'json') return createJsonFormatter();\n if (format === 'ansi' || (format === 'auto' && shouldUseAnsi())) return createGenericFormatter(createAnsiStyler(), createTextLayout());\n if (format === 'console') return createGenericFormatter(createConsoleStyler(), createTextLayout());\n if (format === 'markdown') return createGenericFormatter(createMarkdownStyler(), createMarkdownLayout());\n if (format === 'html') return createGenericFormatter(createHtmlStyler(), createHtmlLayout());\n return createGenericFormatter(createTextStyler(), createTextLayout());\n}\n","import type { StandardJSONSchemaV1 } from '@standard-schema/spec';\n\nexport interface PadroneOptionsMeta {\n description?: string;\n alias?: string[] | string;\n deprecated?: boolean | string;\n hidden?: boolean;\n examples?: unknown[];\n /**\n * Environment variable name(s) to bind this option to.\n * Can be a single string or array of env var names (checked in order).\n */\n env?: string | string[];\n /**\n * Key path in config file that maps to this option.\n * Supports dot notation for nested keys (e.g., 'server.port').\n */\n configKey?: string;\n}\n\ntype PositionalArgs<TObj> =\n TObj extends Record<string, any>\n ? {\n [K in keyof TObj]: TObj[K] extends Array<any> ? `...${K & string}` : K & string;\n }[keyof TObj]\n : string;\n\n/**\n * Meta configuration for options including positional arguments.\n * The `positional` array defines which options are positional arguments and their order.\n * Use '...name' prefix to indicate variadic (rest) arguments, matching JS/TS rest syntax.\n *\n * @example\n * ```ts\n * .options(schema, {\n * positional: ['source', '...files', 'dest'], // '...files' is variadic\n * })\n * ```\n */\nexport interface PadroneMeta<TObj = Record<string, any>> {\n /**\n * Array of option names that should be treated as positional arguments.\n * Order in array determines position. Use '...name' prefix for variadic args.\n * @example ['source', '...files', 'dest'] - 'files' captures multiple values\n */\n positional?: PositionalArgs<TObj>[];\n /**\n * Per-option metadata.\n */\n options?: { [K in keyof TObj]?: PadroneOptionsMeta };\n}\n\n/**\n * Parse positional configuration to extract names and variadic info.\n */\nexport function parsePositionalConfig(positional: string[]): { name: string; variadic: boolean }[] {\n return positional.map((p) => {\n const isVariadic = p.startsWith('...');\n const name = isVariadic ? p.slice(3) : p;\n return { name, variadic: isVariadic };\n });\n}\n\n/**\n * Result type for extractSchemaMetadata function.\n */\ninterface SchemaMetadataResult {\n aliases: Record<string, string>;\n envBindings: Record<string, string[]>;\n configKeys: Record<string, string>;\n}\n\n/**\n * Extract all option metadata from schema and meta in a single pass.\n * This consolidates aliases, env bindings, and config keys extraction.\n */\nexport function extractSchemaMetadata(\n schema: StandardJSONSchemaV1,\n meta?: Record<string, PadroneOptionsMeta | undefined>,\n): SchemaMetadataResult {\n const aliases: Record<string, string> = {};\n const envBindings: Record<string, string[]> = {};\n const configKeys: Record<string, string> = {};\n\n // Extract from meta object\n if (meta) {\n for (const [key, value] of Object.entries(meta)) {\n if (!value) continue;\n\n // Extract aliases\n if (value.alias) {\n const list = typeof value.alias === 'string' ? [value.alias] : value.alias;\n for (const aliasKey of list) {\n if (typeof aliasKey === 'string' && aliasKey && aliasKey !== key) {\n aliases[aliasKey] = key;\n }\n }\n }\n\n // Extract env bindings\n if (value.env) {\n envBindings[key] = typeof value.env === 'string' ? [value.env] : value.env;\n }\n\n // Extract config keys\n if (value.configKey) {\n configKeys[key] = value.configKey;\n }\n }\n }\n\n // Extract from JSON schema properties\n try {\n const jsonSchema = schema['~standard'].jsonSchema.input({ target: 'draft-2020-12' }) as Record<string, any>;\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n for (const [propertyName, propertySchema] of Object.entries(jsonSchema.properties as Record<string, any>)) {\n if (!propertySchema) continue;\n\n // Extract aliases from schema\n const propAlias = propertySchema.alias;\n if (propAlias) {\n const list = typeof propAlias === 'string' ? [propAlias] : propAlias;\n if (Array.isArray(list)) {\n for (const aliasKey of list) {\n if (typeof aliasKey === 'string' && aliasKey && aliasKey !== propertyName && !(aliasKey in aliases)) {\n aliases[aliasKey] = propertyName;\n }\n }\n }\n }\n\n // Extract env bindings from schema\n if (propertySchema.env && !(propertyName in envBindings)) {\n const envVars = typeof propertySchema.env === 'string' ? [propertySchema.env] : propertySchema.env;\n if (Array.isArray(envVars)) {\n envBindings[propertyName] = envVars;\n }\n }\n\n // Extract config keys from schema\n if (propertySchema.configKey && !(propertyName in configKeys)) {\n configKeys[propertyName] = propertySchema.configKey;\n }\n }\n }\n } catch {\n // Ignore errors from JSON schema generation\n }\n\n return { aliases, envBindings, configKeys };\n}\n\nfunction preprocessAliases(data: Record<string, unknown>, aliases: Record<string, string>): Record<string, unknown> {\n const result = { ...data };\n\n for (const [aliasKey, fullOptionName] of Object.entries(aliases)) {\n if (aliasKey in data && aliasKey !== fullOptionName) {\n const aliasValue = data[aliasKey];\n // Prefer full option name if it exists\n if (!(fullOptionName in result)) result[fullOptionName] = aliasValue;\n delete result[aliasKey];\n }\n }\n\n return result;\n}\n\n/**\n * Apply environment variable values to options.\n * CLI values take precedence over environment variables.\n */\nfunction applyEnvBindings(\n data: Record<string, unknown>,\n envBindings: Record<string, string[]>,\n env: Record<string, string | undefined> = typeof process !== 'undefined' ? process.env : {},\n): Record<string, unknown> {\n const result = { ...data };\n\n for (const [optionName, envVars] of Object.entries(envBindings)) {\n // Only apply env var if option wasn't already set\n if (optionName in result && result[optionName] !== undefined) continue;\n\n for (const envVar of envVars) {\n const envValue = env[envVar];\n if (envValue !== undefined) {\n // Try to parse the value intelligently\n result[optionName] = parseEnvValue(envValue);\n break;\n }\n }\n }\n\n return result;\n}\n\n/**\n * Parse an environment variable value, attempting to convert to appropriate types.\n */\nfunction parseEnvValue(value: string): unknown {\n // Handle boolean-like values\n const lowerValue = value.toLowerCase();\n if (lowerValue === 'true' || lowerValue === '1' || lowerValue === 'yes') return true;\n if (lowerValue === 'false' || lowerValue === '0' || lowerValue === 'no') return false;\n\n // Handle numeric values\n if (/^-?\\d+$/.test(value)) return Number.parseInt(value, 10);\n if (/^-?\\d+\\.\\d+$/.test(value)) return Number.parseFloat(value);\n\n // Handle arrays (comma-separated)\n if (value.includes(',')) {\n return value.split(',').map((v) => parseEnvValue(v.trim()));\n }\n\n return value;\n}\n\n/**\n * Get a nested value from an object using dot notation.\n */\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split('.');\n let current: unknown = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return undefined;\n if (typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[part];\n }\n\n return current;\n}\n\n/**\n * Apply config file values to options.\n * CLI values and env values take precedence over config file values.\n */\nfunction applyConfigValues(\n data: Record<string, unknown>,\n configKeys: Record<string, string>,\n configData: Record<string, unknown>,\n): Record<string, unknown> {\n const result = { ...data };\n\n for (const [optionName, configKey] of Object.entries(configKeys)) {\n // Only apply config value if option wasn't already set\n if (optionName in result && result[optionName] !== undefined) continue;\n\n const configValue = getNestedValue(configData, configKey);\n if (configValue !== undefined) {\n result[optionName] = configValue;\n }\n }\n\n return result;\n}\n\ninterface ParseOptionsContext {\n aliases?: Record<string, string>;\n envBindings?: Record<string, string[]>;\n configKeys?: Record<string, string>;\n configData?: Record<string, unknown>;\n env?: Record<string, string | undefined>;\n}\n\n/**\n * Combined preprocessing of options with all features.\n * Precedence order (highest to lowest): CLI args > env vars > config file\n */\nexport function preprocessOptions(data: Record<string, unknown>, ctx: ParseOptionsContext): Record<string, unknown> {\n let result = { ...data };\n\n // 1. Apply aliases first\n if (ctx.aliases && Object.keys(ctx.aliases).length > 0) {\n result = preprocessAliases(result, ctx.aliases);\n }\n\n // 2. Apply environment variables (higher precedence than config)\n // These only apply if CLI didn't set the option\n if (ctx.envBindings && Object.keys(ctx.envBindings).length > 0) {\n result = applyEnvBindings(result, ctx.envBindings, ctx.env);\n }\n\n // 3. Apply config file values (lowest precedence)\n // These only apply if neither CLI nor env set the option\n if (ctx.configKeys && ctx.configData) {\n result = applyConfigValues(result, ctx.configKeys, ctx.configData);\n }\n\n return result;\n}\n","import type { AnyPadroneCommand } from './types';\n\nexport function getRootCommand(cmd: AnyPadroneCommand): AnyPadroneCommand {\n let current = cmd;\n while (current.parent) current = current.parent;\n return current;\n}\n\n/**\n * Attempts to get the version from various sources:\n * 1. Explicit version set on the command\n * 2. npm_package_version environment variable (set by npm/yarn/pnpm when running scripts)\n * 3. package.json in current or parent directories\n * @param explicitVersion - Version explicitly set via .version()\n * @returns The version string or '0.0.0' if not found\n */\nexport function getVersion(explicitVersion?: string): string {\n // 1. Use explicit version if provided\n if (explicitVersion) return explicitVersion;\n\n // 2. Check npm_package_version env var (set by npm/yarn/pnpm during script execution)\n if (typeof process !== 'undefined' && process.env?.npm_package_version) {\n return process.env.npm_package_version;\n }\n\n // 3. Try to read from package.json\n if (typeof process !== 'undefined') {\n try {\n const fs = require('node:fs');\n const path = require('node:path');\n let dir = process.cwd();\n\n // Walk up the directory tree looking for package.json\n for (let i = 0; i < 10; i++) {\n const pkgPath = path.join(dir, 'package.json');\n if (fs.existsSync(pkgPath)) {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));\n if (pkg.version) return pkg.version;\n }\n const parentDir = path.dirname(dir);\n if (parentDir === dir) break; // Reached root\n dir = parentDir;\n }\n } catch {\n // Ignore errors (e.g., fs not available in browser)\n }\n }\n\n return '0.0.0';\n}\n\n/**\n * Loads and parses a config file from the given path.\n * Supports JSON, JSONC (JSON with comments), and attempts to parse other formats.\n * @param configPath - Path to the config file\n * @returns Parsed config data or undefined if loading fails\n */\nexport function loadConfigFile(configPath: string): Record<string, unknown> | undefined {\n if (typeof process === 'undefined') return undefined;\n\n try {\n const fs = require('node:fs');\n const path = require('node:path');\n\n // Resolve to absolute path\n const absolutePath = path.isAbsolute(configPath) ? configPath : path.resolve(process.cwd(), configPath);\n\n if (!fs.existsSync(absolutePath)) {\n console.error(`Config file not found: ${absolutePath}`);\n return undefined;\n }\n\n const getContent = () => fs.readFileSync(absolutePath, 'utf-8');\n const ext = path.extname(absolutePath).toLowerCase();\n\n if (ext === '.yaml' || ext === '.yml') {\n return Bun.YAML.parse(getContent()) as any;\n }\n\n if (ext === '.toml') {\n return Bun.TOML.parse(getContent()) as any;\n }\n\n if (ext === '.json') {\n return JSON.parse(getContent());\n }\n\n if (ext === '.js' || ext === '.cjs' || ext === '.mjs' || ext === '.ts' || ext === '.cts' || ext === '.mts') {\n // For JS files, require them\n return require(absolutePath);\n }\n\n // For unknown extensions, try to parse as JSON\n try {\n return JSON.parse(getContent());\n } catch {\n console.error(`Unable to parse config file: ${absolutePath}`);\n return undefined;\n }\n } catch (error) {\n console.error(`Error loading config file: ${error}`);\n return undefined;\n }\n}\n\n/**\n * Searches for a config file from a list of possible file names.\n * Searches in the current working directory.\n * @param configFiles - Array of possible config file names to search for\n * @returns The path to the first found config file, or undefined if none found\n */\nexport function findConfigFile(configFiles: string[]): string | undefined {\n if (typeof process === 'undefined' || !configFiles?.length) return undefined;\n\n try {\n const fs = require('node:fs');\n const path = require('node:path');\n const cwd = process.cwd();\n\n for (const configFile of configFiles) {\n const configPath = path.isAbsolute(configFile) ? configFile : path.resolve(cwd, configFile);\n if (fs.existsSync(configPath)) {\n return configPath;\n }\n }\n } catch {\n // Ignore errors (e.g., fs not available in browser)\n }\n\n return undefined;\n}\n","import type { StandardJSONSchemaV1 } from '@standard-schema/spec';\nimport { createFormatter, type HelpArgumentInfo, type HelpDetail, type HelpFormat, type HelpInfo, type HelpOptionInfo } from './formatter';\nimport { extractSchemaMetadata, type PadroneMeta, parsePositionalConfig } from './options';\nimport type { AnyPadroneCommand } from './types';\nimport { getRootCommand } from './utils';\n\nexport type HelpOptions = {\n format?: HelpFormat | 'auto';\n detail?: HelpDetail;\n};\n\n/**\n * Extract positional arguments info from schema based on meta.positional config.\n */\nfunction extractPositionalArgsInfo(\n schema: StandardJSONSchemaV1,\n meta?: PadroneMeta,\n): { args: HelpArgumentInfo[]; positionalNames: Set<string> } {\n const args: HelpArgumentInfo[] = [];\n const positionalNames = new Set<string>();\n\n if (!schema || !meta?.positional || meta.positional.length === 0) {\n return { args, positionalNames };\n }\n\n const positionalConfig = parsePositionalConfig(meta.positional);\n\n try {\n const jsonSchema = schema['~standard'].jsonSchema.input({ target: 'draft-2020-12' }) as Record<string, any>;\n\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n const properties = jsonSchema.properties as Record<string, any>;\n const required = (jsonSchema.required as string[]) || [];\n\n for (const { name, variadic } of positionalConfig) {\n const prop = properties[name];\n if (!prop) continue;\n\n positionalNames.add(name);\n const optMeta = meta.options?.[name];\n\n args.push({\n name: variadic ? `...${name}` : name,\n description: optMeta?.description ?? prop.description,\n optional: !required.includes(name),\n default: prop.default,\n type: variadic ? `array<${prop.items?.type || 'string'}>` : prop.type,\n });\n }\n }\n } catch {\n // Fallback to empty result if toJSONSchema fails\n }\n\n return { args, positionalNames };\n}\n\nfunction extractOptionsInfo(schema: StandardJSONSchemaV1, meta?: PadroneMeta, positionalNames?: Set<string>) {\n const result: HelpOptionInfo[] = [];\n if (!schema) return result;\n\n const vendor = schema['~standard'].vendor;\n if (!vendor.includes('zod')) return result;\n\n const optionsMeta = meta?.options;\n\n try {\n const jsonSchema = schema['~standard'].jsonSchema.input({ target: 'draft-2020-12' }) as Record<string, any>;\n\n // Handle object: z.object({ key: z.string(), ... })\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n const properties = jsonSchema.properties as Record<string, any>;\n const required = (jsonSchema.required as string[]) || [];\n const propertyNames = new Set(Object.keys(properties));\n\n // Helper to check if a negated version of an option exists\n const hasExplicitNegation = (key: string): boolean => {\n // Check for noVerbose style (camelCase)\n const camelNegated = `no${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n if (propertyNames.has(camelNegated)) return true;\n // Check for no-verbose style (kebab-case, though rare in JS)\n const kebabNegated = `no-${key}`;\n if (propertyNames.has(kebabNegated)) return true;\n return false;\n };\n\n // Helper to check if this option is itself a negation of another option\n const isNegationOf = (key: string): boolean => {\n // Check for noVerbose -> verbose (camelCase)\n if (key.startsWith('no') && key.length > 2 && key[2] === key[2]?.toUpperCase()) {\n const positiveKey = key.charAt(2).toLowerCase() + key.slice(3);\n if (propertyNames.has(positiveKey)) return true;\n }\n // Check for no-verbose -> verbose (kebab-case)\n if (key.startsWith('no-')) {\n const positiveKey = key.slice(3);\n if (propertyNames.has(positiveKey)) return true;\n }\n return false;\n };\n\n for (const [key, prop] of Object.entries(properties)) {\n // Skip positional arguments - they are shown in arguments section\n if (positionalNames?.has(key)) continue;\n\n const isOptional = !required.includes(key);\n const enumValues = prop.enum as string[] | undefined;\n const optMeta = optionsMeta?.[key];\n const propType = prop.type as string;\n\n // Booleans are negatable unless there's an explicit noOption property\n // or this option is itself a negation of another option\n const isNegatable = propType === 'boolean' && !hasExplicitNegation(key) && !isNegationOf(key);\n\n result.push({\n name: key,\n description: optMeta?.description ?? prop.description,\n optional: isOptional,\n default: prop.default,\n type: propType,\n enum: enumValues,\n deprecated: optMeta?.deprecated ?? prop?.deprecated,\n hidden: optMeta?.hidden ?? prop?.hidden,\n examples: optMeta?.examples ?? prop?.examples,\n env: optMeta?.env ?? prop?.env,\n variadic: propType === 'array', // Arrays are always variadic\n negatable: isNegatable,\n configKey: optMeta?.configKey ?? prop?.configKey,\n });\n }\n }\n } catch {\n // Fallback to empty result if toJSONSchema fails\n }\n\n return result;\n}\n\n// ============================================================================\n// Core Help Info Builder\n// ============================================================================\n\n/**\n * Builds a comprehensive HelpInfo structure from a command.\n * This is the single source of truth that all formatters use.\n * @param cmd - The command to build help info for\n * @param detail - The level of detail ('minimal', 'standard', or 'full')\n */\nfunction getHelpInfo(cmd: AnyPadroneCommand, detail: HelpOptions['detail'] = 'standard'): HelpInfo {\n const rootCmd = getRootCommand(cmd);\n const commandName = cmd.path || cmd.name || 'program';\n\n // Extract positional args from options schema based on meta.positional\n const { args: positionalArgs, positionalNames } = cmd.options\n ? extractPositionalArgsInfo(cmd.options, cmd.meta)\n : { args: [], positionalNames: new Set<string>() };\n\n const hasArguments = positionalArgs.length > 0;\n\n const helpInfo: HelpInfo = {\n name: commandName,\n title: cmd.title,\n description: cmd.description,\n deprecated: cmd.deprecated,\n hidden: cmd.hidden,\n usage: {\n command: rootCmd === cmd ? commandName : `${rootCmd.name} ${commandName}`,\n hasSubcommands: !!(cmd.commands && cmd.commands.length > 0),\n hasArguments,\n hasOptions: !!cmd.options,\n },\n };\n\n // Build subcommands info (filter out hidden commands unless showing full detail)\n if (cmd.commands && cmd.commands.length > 0) {\n const visibleCommands = detail === 'full' ? cmd.commands : cmd.commands.filter((c) => !c.hidden);\n helpInfo.subcommands = visibleCommands.map((c) => ({\n name: c.name,\n title: c.title,\n description: c.description,\n deprecated: c.deprecated,\n hidden: c.hidden,\n }));\n\n // In 'full' detail mode, recursively build help for all nested commands\n if (detail === 'full') {\n helpInfo.nestedCommands = visibleCommands.map((c) => getHelpInfo(c, 'full'));\n }\n }\n\n // Build arguments info from positional options\n if (hasArguments) {\n helpInfo.arguments = positionalArgs;\n }\n\n // Build options info with aliases (excluding positional args)\n if (cmd.options) {\n const optionsInfo = extractOptionsInfo(cmd.options, cmd.meta, positionalNames);\n const optMap: Record<string, HelpOptionInfo> = Object.fromEntries(optionsInfo.map((opt) => [opt.name, opt]));\n\n // Merge aliases into options\n const { aliases } = extractSchemaMetadata(cmd.options, cmd.meta?.options);\n for (const [alias, name] of Object.entries(aliases)) {\n const opt = optMap[name];\n if (!opt) continue;\n opt.aliases = [...(opt.aliases || []), alias];\n }\n\n // Filter out hidden options\n const visibleOptions = optionsInfo.filter((opt) => !opt.hidden);\n if (visibleOptions.length > 0) {\n helpInfo.options = visibleOptions;\n }\n }\n\n return helpInfo;\n}\n\n// ============================================================================\n// Main Entry Point\n// ============================================================================\n\nexport function generateHelp(rootCommand: AnyPadroneCommand, commandObj: AnyPadroneCommand = rootCommand, options?: HelpOptions): string {\n const helpInfo = getHelpInfo(commandObj, options?.detail);\n const formatter = createFormatter(options?.format ?? 'auto', options?.detail);\n return formatter.format(helpInfo);\n}\n","type ParseParts = {\n /**\n * An alphanumeric term representing a command, subcommand, or positional argument.\n * Note that a term can be ambiguous until fully matched within the command hierarchy.\n * We cannot fully distinguish between a nested command or a positional argument until\n * the command structure is known.\n */\n term: {\n type: 'term';\n value: string;\n };\n /**\n * A positional argument provided to the command.\n * Unlike `term`, this is definitively an argument. This can be determined when\n * the argument is non-alphanumeric, like a path or a number.\n */\n arg: {\n type: 'arg';\n value: string;\n };\n /**\n * An option provided to the command, prefixed with `--`.\n * If the option has an `=` sign, the value after it is used as the option's value.\n * Otherwise, the value is obtained from the next part or set to `true` if no value is provided.\n */\n option: {\n type: 'option';\n key: string;\n value?: string | string[];\n negated?: boolean;\n };\n /**\n * An alias option provided to the command, prefixed with `-`.\n * Which option it maps to cannot be determined until the command structure is known.\n */\n alias: {\n type: 'alias';\n key: string;\n value?: string | string[];\n };\n};\n\ntype ParsePart = ParseParts[keyof ParseParts];\n\n/**\n * Tokenizes input string respecting quoted strings and bracket arrays.\n * Supports single quotes, double quotes, backticks, and square brackets.\n */\nfunction tokenizeInput(input: string): string[] {\n const tokens: string[] = [];\n let current = '';\n let inQuote: '\"' | \"'\" | '`' | null = null;\n let bracketDepth = 0;\n let i = 0;\n\n while (i < input.length) {\n const char = input[i];\n\n if (inQuote) {\n // Check for escape sequences within quotes\n if (char === '\\\\' && i + 1 < input.length) {\n const nextChar = input[i + 1];\n // Handle escape sequences\n if (nextChar === inQuote || nextChar === '\\\\') {\n current += nextChar;\n i += 2;\n continue;\n }\n }\n\n if (char === inQuote) {\n // End of quoted string\n inQuote = null;\n } else {\n current += char;\n }\n } else if (char === '[') {\n bracketDepth++;\n current += char;\n } else if (char === ']') {\n bracketDepth = Math.max(0, bracketDepth - 1);\n current += char;\n } else if (bracketDepth > 0) {\n // Inside brackets - include everything including spaces\n current += char;\n } else if (char === '\"' || char === \"'\" || char === '`') {\n // Start of quoted string\n inQuote = char;\n } else if (char === ' ' || char === '\\t') {\n // Whitespace outside quotes and brackets - end current token\n if (current) {\n tokens.push(current);\n current = '';\n }\n } else {\n current += char;\n }\n i++;\n }\n\n // Add the last token if any\n if (current) {\n tokens.push(current);\n }\n\n return tokens;\n}\n\nexport function parseCliInputToParts(input: string): ParsePart[] {\n const parts = tokenizeInput(input.trim());\n const result: ParsePart[] = [];\n\n let pendingValue: ParseParts['option'] | ParseParts['alias'] | undefined;\n let allowTerm = true;\n\n for (const part of parts) {\n if (!part) continue;\n const wasPending = pendingValue;\n pendingValue = undefined;\n\n if (part.startsWith('--no-') && part.length > 5) {\n // Negated boolean option (--no-verbose)\n const key = part.slice(5);\n const p = { type: 'option' as const, key, value: undefined, negated: true };\n result.push(p);\n } else if (part.startsWith('--')) {\n const [key = '', value] = splitOptionValue(part.slice(2));\n\n const p = { type: 'option' as const, key, value };\n if (typeof value === 'undefined') pendingValue = p;\n result.push(p);\n } else if (part.startsWith('-') && part.length > 1 && !/^-\\d/.test(part)) {\n // Short option (but not negative numbers like -5)\n const [key = '', value] = splitOptionValue(part.slice(1));\n\n const p = { type: 'alias' as const, key, value };\n if (typeof value === 'undefined') pendingValue = p;\n result.push(p);\n } else if (wasPending) {\n wasPending.value = part;\n } else if (/^[a-zA-Z0-9_-]+$/.test(part) && allowTerm) {\n result.push({ type: 'term', value: part });\n } else {\n result.push({ type: 'arg', value: part });\n allowTerm = false;\n }\n }\n return result;\n}\n\n/**\n * Split option key and value, handling quoted values after =.\n */\nfunction splitOptionValue(str: string): [string, string | string[] | undefined] {\n const eqIndex = str.indexOf('=');\n if (eqIndex === -1) return [str, undefined];\n\n const key = str.slice(0, eqIndex);\n let value = str.slice(eqIndex + 1);\n\n // Remove surrounding quotes from value if present\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\")) ||\n (value.startsWith('`') && value.endsWith('`'))\n ) {\n value = value.slice(1, -1);\n return [key, value];\n }\n\n // Handle array syntax: [a,b,c] -> ['a', 'b', 'c']\n if (value.startsWith('[') && value.endsWith(']')) {\n const inner = value.slice(1, -1);\n if (inner === '') return [key, []];\n const items = parseArrayItems(inner);\n return [key, items];\n }\n\n return [key, value];\n}\n\n/**\n * Parse comma-separated items, respecting quotes within items.\n */\nfunction parseArrayItems(input: string): string[] {\n const items: string[] = [];\n let current = '';\n let inQuote: '\"' | \"'\" | '`' | null = null;\n let i = 0;\n\n while (i < input.length) {\n const char = input[i];\n\n if (inQuote) {\n if (char === '\\\\' && i + 1 < input.length && input[i + 1] === inQuote) {\n current += input[i + 1];\n i += 2;\n continue;\n }\n if (char === inQuote) {\n inQuote = null;\n } else {\n current += char;\n }\n } else if (char === '\"' || char === \"'\" || char === '`') {\n inQuote = char;\n } else if (char === ',') {\n items.push(current.trim());\n current = '';\n } else {\n current += char;\n }\n i++;\n }\n\n // Add the last item\n if (current || items.length > 0) {\n items.push(current.trim());\n }\n\n return items;\n}\n","import type { Schema } from 'ai';\nimport { generateHelp } from './help';\nimport { extractSchemaMetadata, parsePositionalConfig, preprocessOptions } from './options';\nimport { parseCliInputToParts } from './parse';\nimport type { AnyPadroneCommand, AnyPadroneProgram, PadroneAPI, PadroneCommand, PadroneCommandBuilder, PadroneProgram } from './types';\nimport { findConfigFile, getVersion, loadConfigFile } from './utils';\n\nconst commandSymbol = Symbol('padrone_command');\n\nconst noop = <TRes>() => undefined as TRes;\n\nexport function createPadroneCommandBuilder<TBuilder extends PadroneProgram = PadroneProgram>(\n existingCommand: AnyPadroneCommand,\n): TBuilder & { [commandSymbol]: AnyPadroneCommand } {\n function findCommandByName(name: string, commands?: AnyPadroneCommand[]): AnyPadroneCommand | undefined {\n if (!commands) return undefined;\n\n const foundByName = commands.find((cmd) => cmd.name === name);\n if (foundByName) return foundByName;\n\n for (const cmd of commands) {\n if (cmd.commands && name.startsWith(`${cmd.name} `)) {\n const subCommandName = name.slice(cmd.name.length + 1);\n const subCommand = findCommandByName(subCommandName, cmd.commands);\n if (subCommand) return subCommand;\n }\n }\n return undefined;\n }\n\n const find: AnyPadroneProgram['find'] = (command) => {\n return findCommandByName(command, existingCommand.commands) as ReturnType<AnyPadroneProgram['find']>;\n };\n\n /**\n * Parses CLI input to find the command and extract raw options without validation.\n */\n const parseCommand = (input: string | undefined) => {\n input ??= typeof process !== 'undefined' ? (process.argv.slice(2).join(' ') as any) : undefined;\n if (!input) return { command: existingCommand, rawOptions: {} as Record<string, unknown>, args: [] as string[] };\n\n const parts = parseCliInputToParts(input);\n\n const terms = parts.filter((p) => p.type === 'term').map((p) => p.value);\n const args = parts.filter((p) => p.type === 'arg').map((p) => p.value);\n\n let curCommand: AnyPadroneCommand | undefined = existingCommand;\n\n // If the first term is the program name, skip it\n if (terms[0] === existingCommand.name) terms.shift();\n\n for (let i = 0; i < terms.length; i++) {\n const term = terms[i] || '';\n const found = findCommandByName(term, curCommand.commands);\n\n if (found) {\n curCommand = found;\n } else {\n args.unshift(...terms.slice(i));\n break;\n }\n }\n\n if (!curCommand) return { command: existingCommand, rawOptions: {} as Record<string, unknown>, args };\n\n // Extract option metadata from the nested options object in meta\n const optionsMeta = curCommand.meta?.options;\n const schemaMetadata = curCommand.options\n ? extractSchemaMetadata(curCommand.options, optionsMeta)\n : { aliases: {}, envBindings: {}, configKeys: {} };\n const { aliases } = schemaMetadata;\n\n // Get array options from schema (arrays are always variadic)\n const arrayOptions = new Set<string>();\n if (curCommand.options) {\n try {\n const jsonSchema = curCommand.options['~standard'].jsonSchema.input({ target: 'draft-2020-12' }) as Record<string, any>;\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n for (const [key, prop] of Object.entries(jsonSchema.properties as Record<string, any>)) {\n if (prop?.type === 'array') arrayOptions.add(key);\n }\n }\n } catch {\n // Ignore schema parsing errors\n }\n }\n\n const opts = parts.filter((p) => p.type === 'option' || p.type === 'alias');\n const rawOptions: Record<string, unknown> = {};\n\n for (const opt of opts) {\n const key = opt.type === 'alias' ? aliases[opt.key] || opt.key : opt.key;\n\n // Handle negated boolean options (--no-verbose)\n if (opt.type === 'option' && opt.negated) {\n rawOptions[key] = false;\n continue;\n }\n\n const value = opt.value ?? true;\n\n // Handle array options - accumulate values into arrays (arrays are always variadic)\n if (arrayOptions.has(key)) {\n if (key in rawOptions) {\n const existing = rawOptions[key];\n if (Array.isArray(existing)) {\n if (Array.isArray(value)) {\n existing.push(...value);\n } else {\n existing.push(value);\n }\n } else {\n if (Array.isArray(value)) {\n rawOptions[key] = [existing, ...value];\n } else {\n rawOptions[key] = [existing, value];\n }\n }\n } else {\n rawOptions[key] = Array.isArray(value) ? value : [value];\n }\n } else {\n rawOptions[key] = value;\n }\n }\n\n return { command: curCommand, rawOptions, args };\n };\n\n /**\n * Validates raw options against the command's schema and applies preprocessing.\n */\n const validateOptions = (\n command: AnyPadroneCommand,\n rawOptions: Record<string, unknown>,\n args: string[],\n parseOptions?: { env?: Record<string, string | undefined>; configData?: Record<string, unknown> },\n ) => {\n // Extract option metadata for preprocessing\n const optionsMeta = command.meta?.options;\n const schemaMetadata = command.options\n ? extractSchemaMetadata(command.options, optionsMeta)\n : { aliases: {}, envBindings: {}, configKeys: {} };\n const { envBindings, configKeys } = schemaMetadata;\n\n // Apply preprocessing (env and config bindings)\n const preprocessedOptions = preprocessOptions(rawOptions, {\n aliases: {}, // Already resolved aliases in parseCommand\n envBindings,\n configKeys,\n configData: parseOptions?.configData,\n env: parseOptions?.env,\n });\n\n // Parse positional configuration\n const positionalConfig = command.meta?.positional ? parsePositionalConfig(command.meta.positional) : [];\n\n // Map positional arguments to their named options\n if (positionalConfig.length > 0) {\n let argIndex = 0;\n for (const { name, variadic } of positionalConfig) {\n if (argIndex >= args.length) break;\n\n if (variadic) {\n // Collect remaining args (but leave room for non-variadic args after)\n const remainingPositionals = positionalConfig.slice(positionalConfig.indexOf({ name, variadic }) + 1);\n const nonVariadicAfter = remainingPositionals.filter((p) => !p.variadic).length;\n const variadicEnd = args.length - nonVariadicAfter;\n preprocessedOptions[name] = args.slice(argIndex, variadicEnd);\n argIndex = variadicEnd;\n } else {\n preprocessedOptions[name] = args[argIndex];\n argIndex++;\n }\n }\n }\n\n const optionsParsed = command.options ? command.options['~standard'].validate(preprocessedOptions) : { value: preprocessedOptions };\n\n if (optionsParsed instanceof Promise) {\n throw new Error('Async validation is not supported. Schema validate() must return a synchronous result.');\n }\n\n // Return undefined for options when there's no schema and no meaningful options\n const hasOptions = command.options || Object.keys(preprocessedOptions).length > 0;\n\n return {\n options: optionsParsed.issues ? undefined : hasOptions ? (optionsParsed.value as any) : undefined,\n optionsResult: optionsParsed as any,\n };\n };\n\n const parse: AnyPadroneProgram['parse'] = (input, parseOptions) => {\n const { command, rawOptions, args } = parseCommand(input);\n const { options, optionsResult } = validateOptions(command, rawOptions, args, parseOptions);\n\n return {\n command: command as any,\n options,\n optionsResult,\n };\n };\n\n const stringify: AnyPadroneProgram['stringify'] = (command = '' as any, options) => {\n const commandObj = typeof command === 'string' ? findCommandByName(command, existingCommand.commands) : (command as AnyPadroneCommand);\n if (!commandObj) throw new Error(`Command \"${command ?? ''}\" not found`);\n\n const parts: string[] = [];\n\n if (commandObj.path) parts.push(commandObj.path);\n\n // Get positional config to determine which options are positional\n const positionalConfig = commandObj.meta?.positional ? parsePositionalConfig(commandObj.meta.positional) : [];\n const positionalNames = new Set(positionalConfig.map((p) => p.name));\n\n // Output positional arguments first in order\n if (options && typeof options === 'object') {\n for (const { name, variadic } of positionalConfig) {\n const value = (options as Record<string, unknown>)[name];\n if (value === undefined) continue;\n\n if (variadic && Array.isArray(value)) {\n for (const v of value) {\n const vStr = String(v);\n if (vStr.includes(' ')) parts.push(`\"${vStr}\"`);\n else parts.push(vStr);\n }\n } else {\n const argStr = String(value);\n if (argStr.includes(' ')) parts.push(`\"${argStr}\"`);\n else parts.push(argStr);\n }\n }\n\n // Output remaining options (non-positional)\n for (const [key, value] of Object.entries(options)) {\n if (value === undefined || positionalNames.has(key)) continue;\n\n if (typeof value === 'boolean') {\n if (value) parts.push(`--${key}`);\n else parts.push(`--no-${key}`);\n } else if (Array.isArray(value)) {\n // Handle variadic options - output each value separately\n for (const v of value) {\n const vStr = String(v);\n if (vStr.includes(' ')) parts.push(`--${key}=\"${vStr}\"`);\n else parts.push(`--${key}=${vStr}`);\n }\n } else if (typeof value === 'string') {\n if (value.includes(' ')) parts.push(`--${key}=\"${value}\"`);\n else parts.push(`--${key}=${value}`);\n } else {\n parts.push(`--${key}=${value}`);\n }\n }\n }\n\n return parts.join(' ');\n };\n\n type DetailLevel = 'minimal' | 'standard' | 'full';\n type FormatLevel = 'text' | 'ansi' | 'console' | 'markdown' | 'html' | 'json' | 'auto';\n\n /**\n * Check if help or version flags/commands are present in the input.\n * Returns the appropriate action to take, or null if normal execution should proceed.\n */\n const checkBuiltinCommands = (\n input: string | undefined,\n ): { type: 'help'; command?: AnyPadroneCommand; detail?: DetailLevel; format?: FormatLevel } | { type: 'version' } | null => {\n if (!input) return null;\n\n const parts = parseCliInputToParts(input);\n const terms = parts.filter((p) => p.type === 'term').map((p) => p.value);\n const opts = parts.filter((p) => p.type === 'option' || p.type === 'alias');\n\n // Check for --help, -h flags (these take precedence over commands)\n const hasHelpFlag = opts.some((p) => (p.type === 'option' && p.key === 'help') || (p.type === 'alias' && p.key === 'h'));\n\n // Extract detail level from --detail=<level> or -d <level>\n const getDetailLevel = (): DetailLevel | undefined => {\n for (const opt of opts) {\n if (opt.type === 'option' && opt.key === 'detail' && typeof opt.value === 'string') {\n if (opt.value === 'minimal' || opt.value === 'standard' || opt.value === 'full') {\n return opt.value;\n }\n }\n if (opt.type === 'alias' && opt.key === 'd' && typeof opt.value === 'string') {\n if (opt.value === 'minimal' || opt.value === 'standard' || opt.value === 'full') {\n return opt.value;\n }\n }\n }\n return undefined;\n };\n const detail = getDetailLevel();\n\n // Extract format from --format=<value> or -f <value>\n const getFormat = (): FormatLevel | undefined => {\n const validFormats: FormatLevel[] = ['text', 'ansi', 'console', 'markdown', 'html', 'json', 'auto'];\n for (const opt of opts) {\n if (opt.type === 'option' && opt.key === 'format' && typeof opt.value === 'string') {\n if (validFormats.includes(opt.value as FormatLevel)) {\n return opt.value as FormatLevel;\n }\n }\n if (opt.type === 'alias' && opt.key === 'f' && typeof opt.value === 'string') {\n if (validFormats.includes(opt.value as FormatLevel)) {\n return opt.value as FormatLevel;\n }\n }\n }\n return undefined;\n };\n const format = getFormat();\n\n // Check for --version, -v, -V flags\n const hasVersionFlag = opts.some(\n (p) => (p.type === 'option' && p.key === 'version') || (p.type === 'alias' && (p.key === 'v' || p.key === 'V')),\n );\n\n // If the first term is the program name, skip it\n const normalizedTerms = [...terms];\n if (normalizedTerms[0] === existingCommand.name) normalizedTerms.shift();\n\n // Check if user has defined 'help' or 'version' commands (they take precedence)\n const userHelpCommand = findCommandByName('help', existingCommand.commands);\n const userVersionCommand = findCommandByName('version', existingCommand.commands);\n\n // Check for 'help' command (only if user hasn't defined one)\n if (!userHelpCommand && normalizedTerms[0] === 'help') {\n // help <command> - get help for specific command\n const commandName = normalizedTerms.slice(1).join(' ');\n const targetCommand = commandName ? findCommandByName(commandName, existingCommand.commands) : undefined;\n return { type: 'help', command: targetCommand, detail, format };\n }\n\n // Check for 'version' command (only if user hasn't defined one)\n if (!userVersionCommand && normalizedTerms[0] === 'version') {\n return { type: 'version' };\n }\n\n // Handle help flag - find the command being requested\n if (hasHelpFlag) {\n // Filter out help-related terms and flags to find the target command\n const commandTerms = normalizedTerms.filter((t) => t !== 'help');\n const commandName = commandTerms.join(' ');\n const targetCommand = commandName ? findCommandByName(commandName, existingCommand.commands) : undefined;\n return { type: 'help', command: targetCommand, detail, format };\n }\n\n // Handle version flag (only for root command, i.e., no subcommand terms)\n if (hasVersionFlag && normalizedTerms.length === 0) {\n return { type: 'version' };\n }\n\n return null;\n };\n\n /**\n * Extract the config file path from --config=<path> or -c <path> flags.\n */\n const extractConfigPath = (input: string | undefined): string | undefined => {\n if (!input) return undefined;\n\n const parts = parseCliInputToParts(input);\n const opts = parts.filter((p) => p.type === 'option' || p.type === 'alias');\n\n for (const opt of opts) {\n if (opt.type === 'option' && opt.key === 'config' && typeof opt.value === 'string') {\n return opt.value;\n }\n if (opt.type === 'alias' && opt.key === 'c' && typeof opt.value === 'string') {\n return opt.value;\n }\n }\n return undefined;\n };\n\n const cli: AnyPadroneProgram['cli'] = (input, cliOptions) => {\n // Resolve input from process.argv if not provided\n const resolvedInput = input ?? (typeof process !== 'undefined' ? (process.argv.slice(2).join(' ') as any) : undefined);\n\n // Check for built-in help/version commands and flags\n const builtin = checkBuiltinCommands(resolvedInput);\n\n if (builtin) {\n if (builtin.type === 'help') {\n const helpText = generateHelp(existingCommand, builtin.command ?? existingCommand, {\n detail: builtin.detail,\n format: builtin.format,\n });\n console.log(helpText);\n return {\n command: existingCommand,\n args: undefined,\n options: undefined,\n result: helpText,\n } as any;\n }\n\n if (builtin.type === 'version') {\n const version = getVersion(existingCommand.version);\n console.log(version);\n return {\n command: existingCommand,\n options: undefined,\n result: version,\n } as any;\n }\n }\n\n // Parse the command first (without validating options)\n const { command, rawOptions, args } = parseCommand(resolvedInput);\n\n // Extract config file path from --config or -c flag\n const configPath = extractConfigPath(resolvedInput);\n\n // Resolve config files: command's own configFiles > inherited from parent/root\n // undefined = inherit, empty array = no config files (explicit opt-out)\n const resolveConfigFiles = (cmd: AnyPadroneCommand): string[] | undefined => {\n if (cmd.configFiles !== undefined) return cmd.configFiles;\n if (cmd.parent) return resolveConfigFiles(cmd.parent);\n return undefined;\n };\n const effectiveConfigFiles = resolveConfigFiles(command);\n\n // Determine config data: explicit --config flag > auto-discovered config > provided configData\n let configData = cliOptions?.configData;\n if (configPath) {\n // Explicit config path takes precedence\n configData = loadConfigFile(configPath);\n } else if (effectiveConfigFiles?.length) {\n // Search for config files if configFiles is configured (inherited or own)\n const foundConfigPath = findConfigFile(effectiveConfigFiles);\n if (foundConfigPath) {\n configData = loadConfigFile(foundConfigPath) ?? configData;\n }\n }\n\n // Validate options with config data\n const { options, optionsResult } = validateOptions(command, rawOptions, args, {\n ...cliOptions,\n configData,\n });\n\n const res = run(command, options) as any;\n return {\n ...res,\n optionsResult,\n };\n };\n\n const run: AnyPadroneProgram['run'] = (command, options) => {\n const commandObj = typeof command === 'string' ? findCommandByName(command, existingCommand.commands) : (command as AnyPadroneCommand);\n if (!commandObj) throw new Error(`Command \"${command ?? ''}\" not found`);\n if (!commandObj.handler) throw new Error(`Command \"${commandObj.path}\" has no handler`);\n\n const result = commandObj.handler(options as any);\n\n return {\n command: commandObj as any,\n options: options as any,\n result,\n };\n };\n\n const tool: AnyPadroneProgram['tool'] = () => {\n return {\n type: 'function',\n name: existingCommand.name,\n description: generateHelp(existingCommand, undefined, { format: 'text', detail: 'full' }),\n strict: true,\n inputExamples: [{ input: { command: '<command> [args...] [options...]' } }],\n inputSchema: {\n [Symbol.for('vercel.ai.schema') as keyof Schema & symbol]: true,\n jsonSchema: {\n type: 'object',\n properties: { command: { type: 'string' } },\n additionalProperties: false,\n },\n _type: undefined as unknown as { command: string },\n validate: (value) => {\n const command = (value as any)?.command;\n if (typeof command === 'string') return { success: true, value: { command } };\n return { success: false, error: new Error('Expected an object with command property as string.') };\n },\n } satisfies Schema<{ command: string }> as Schema<{ command: string }>,\n title: existingCommand.description,\n needsApproval: (input) => {\n const { command, options } = parse(input.command);\n if (typeof command.needsApproval === 'function') return command.needsApproval(options);\n return !!command.needsApproval;\n },\n execute: (input) => {\n return cli(input.command).result;\n },\n };\n };\n\n return {\n configure(config) {\n return createPadroneCommandBuilder({ ...existingCommand, ...config }) as any;\n },\n options(options, meta) {\n return createPadroneCommandBuilder({ ...existingCommand, options, meta }) as any;\n },\n action(handler = noop) {\n return createPadroneCommandBuilder({ ...existingCommand, handler }) as any;\n },\n command: <TName extends string, TCommand extends PadroneCommand<TName, string, any, any, any>>(\n name: TName,\n builderFn?: (builder: PadroneCommandBuilder<TName>) => PadroneCommandBuilder,\n ) => {\n const initialCommand = {\n name,\n path: existingCommand.path ? `${existingCommand.path} ${name}` : name,\n parent: existingCommand,\n '~types': {} as any,\n } satisfies PadroneCommand<TName, any>;\n const builder = createPadroneCommandBuilder(initialCommand);\n\n const commandObj = ((builderFn?.(builder as any) as typeof builder)?.[commandSymbol] as TCommand) ?? initialCommand;\n return createPadroneCommandBuilder({ ...existingCommand, commands: [...(existingCommand.commands || []), commandObj] }) as any;\n },\n\n run,\n find,\n parse,\n stringify,\n cli,\n tool,\n\n api() {\n function buildApi(command: AnyPadroneCommand) {\n const runCommand = ((options) => run(command, options).result) as PadroneAPI<AnyPadroneCommand>;\n if (!command.commands) return runCommand;\n for (const cmd of command.commands) runCommand[cmd.name] = buildApi(cmd);\n return runCommand;\n }\n\n return buildApi(existingCommand);\n },\n\n help(command, options) {\n const commandObj = !command\n ? existingCommand\n : typeof command === 'string'\n ? findCommandByName(command, existingCommand.commands)\n : (command as AnyPadroneCommand);\n if (!commandObj) throw new Error(`Command \"${command ?? ''}\" not found`);\n return generateHelp(existingCommand, commandObj, options);\n },\n\n '~types': {} as any,\n\n [commandSymbol]: existingCommand,\n } satisfies AnyPadroneProgram & { [commandSymbol]: AnyPadroneCommand } as unknown as TBuilder & { [commandSymbol]: AnyPadroneCommand };\n}\n","import { createPadroneCommandBuilder } from './create';\nimport type { PadroneCommand, PadroneProgram } from './types';\n\nexport function createPadrone(name: string): PadroneProgram {\n return createPadroneCommandBuilder({ name, path: '', commands: [] } as PadroneCommand) as PadroneProgram;\n}\n\nexport type { HelpArgumentInfo, HelpFormat, HelpInfo, HelpOptionInfo, HelpSubcommandInfo } from './formatter';\nexport type { HelpOptions } from './help';\nexport type { PadroneOptionsMeta } from './options';\n// Re-export types for consumers\nexport type {\n AnyPadroneCommand,\n AnyPadroneProgram,\n PadroneCommand,\n PadroneCommandBuilder,\n PadroneCommandConfig,\n PadroneCommandResult,\n PadroneParseOptions,\n PadroneParseResult,\n PadroneProgram,\n} from './types';\n"],"mappings":";;;;;;;AACA,MAAM,SAAS;CACb,OAAO;CACP,MAAM;CACN,KAAK;CACL,QAAQ;CACR,WAAW;CACX,eAAe;CACf,MAAM;CACN,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACP;AAcD,SAAgB,kBAA6B;AAC3C,QAAO;EACL,UAAU,SAAiB,GAAG,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO;EACxE,SAAS,SAAiB,GAAG,OAAO,QAAQ,OAAO,OAAO;EAC1D,OAAO,SAAiB,GAAG,OAAO,SAAS,OAAO,OAAO;EACzD,cAAc,SAAiB,GAAG,OAAO,MAAM,OAAO,OAAO;EAC7D,QAAQ,SAAiB,GAAG,OAAO,OAAO,OAAO,OAAO;EACxD,OAAO,SAAiB,GAAG,OAAO,OAAO,OAAO,OAAO;EACvD,UAAU,SAAiB,GAAG,OAAO,YAAY,OAAO,OAAO;EAC/D,eAAe,SAAiB,GAAG,OAAO,S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,CAAC,WAAY,OAAM,IAAI,MAAM,YAAY,WAAW,GAAG,aAAa;AACxE,UAAO,aAAa,iBAAiB,YAAY,QAAQ;;EAG3D,UAAU,EAAE;GAEX,gBAAgB;EAClB;;;;;AC1iBH,SAAgB,cAAc,MAA8B;AAC1D,QAAO,4BAA4B;EAAE;EAAM,MAAM;EAAI,UAAU,EAAE;EAAE,CAAmB"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "padrone",
3
+ "version": "1.0.0-beta.2",
4
+ "description": "Create type-safe, interactive CLI apps with Zod schemas",
5
+ "keywords": [
6
+ "cli",
7
+ "command-line",
8
+ "zod",
9
+ "typescript",
10
+ "type-safe",
11
+ "parser",
12
+ "arguments",
13
+ "options",
14
+ "ai",
15
+ "vercel-ai",
16
+ "standard-schema"
17
+ ],
18
+ "homepage": "https://gkurt.com/padrone/",
19
+ "bugs": {
20
+ "url": "https://github.com/KurtGokhan/padrone/issues"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/KurtGokhan/padrone.git",
25
+ "directory": "packages/padrone"
26
+ },
27
+ "license": "MIT",
28
+ "author": {
29
+ "name": "Gokhan Kurt",
30
+ "email": "krtgkn@gmail.com",
31
+ "url": "https://gkurt.com"
32
+ },
33
+ "type": "module",
34
+ "exports": {
35
+ ".": {
36
+ "import": {
37
+ "types": "./index.d.mts",
38
+ "default": "./index.mjs"
39
+ },
40
+ "source": "./src/index.ts"
41
+ }
42
+ },
43
+ "main": "./index.mjs",
44
+ "module": "./index.mjs",
45
+ "types": "./index.d.mts",
46
+ "dependencies": {
47
+ "@standard-schema/spec": "^1.1.0"
48
+ },
49
+ "peerDependencies": {
50
+ "ai": "5 || 6",
51
+ "zod": "^3.25.0 || ^4.0.0"
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "ai": {
55
+ "optional": true
56
+ },
57
+ "zod": {
58
+ "optional": true
59
+ }
60
+ },
61
+ "engines": {
62
+ "node": ">=18"
63
+ }
64
+ }
@@ -0,0 +1,41 @@
1
+ // ANSI color codes
2
+ const colors = {
3
+ reset: '\x1b[0m',
4
+ bold: '\x1b[1m',
5
+ dim: '\x1b[2m',
6
+ italic: '\x1b[3m',
7
+ underline: '\x1b[4m',
8
+ strikethrough: '\x1b[9m',
9
+ cyan: '\x1b[36m',
10
+ green: '\x1b[32m',
11
+ yellow: '\x1b[33m',
12
+ blue: '\x1b[34m',
13
+ magenta: '\x1b[35m',
14
+ gray: '\x1b[90m',
15
+ };
16
+
17
+ export type Colorizer = {
18
+ command: (text: string) => string;
19
+ option: (text: string) => string;
20
+ type: (text: string) => string;
21
+ description: (text: string) => string;
22
+ label: (text: string) => string;
23
+ meta: (text: string) => string;
24
+ example: (text: string) => string;
25
+ exampleValue: (text: string) => string;
26
+ deprecated: (text: string) => string;
27
+ };
28
+
29
+ export function createColorizer(): Colorizer {
30
+ return {
31
+ command: (text: string) => `${colors.cyan}${colors.bold}${text}${colors.reset}`,
32
+ option: (text: string) => `${colors.green}${text}${colors.reset}`,
33
+ type: (text: string) => `${colors.yellow}${text}${colors.reset}`,
34
+ description: (text: string) => `${colors.dim}${text}${colors.reset}`,
35
+ label: (text: string) => `${colors.bold}${text}${colors.reset}`,
36
+ meta: (text: string) => `${colors.gray}${text}${colors.reset}`,
37
+ example: (text: string) => `${colors.underline}${text}${colors.reset}`,
38
+ exampleValue: (text: string) => `${colors.italic}${text}${colors.reset}`,
39
+ deprecated: (text: string) => `${colors.strikethrough}${colors.gray}${text}${colors.reset}`,
40
+ };
41
+ }