padrone 1.2.0 → 1.3.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["JS_RESERVED"],"sources":["../../src/codegen/code-builder.ts","../../src/codegen/parsers/fish.ts","../../src/codegen/parsers/help.ts","../../src/codegen/parsers/merge.ts","../../src/codegen/parsers/zsh.ts","../../src/codegen/discovery.ts","../../src/codegen/file-emitter.ts","../../src/codegen/generators/barrel-file.ts","../../src/codegen/schema-to-code.ts","../../src/codegen/generators/command-file.ts","../../src/codegen/generators/command-tree.ts","../../src/codegen/template.ts"],"sourcesContent":["import type { CodeBuilder, CodeBuildResult } from './types.ts';\n\ninterface ImportEntry {\n specifiers: Set<string>;\n defaultSpecifier?: string;\n typeOnly: boolean;\n}\n\ninterface CodeLine {\n type: 'line' | 'raw' | 'block-open' | 'block-close';\n content: string;\n}\n\nclass CodeBuilderImpl implements CodeBuilder {\n private imports = new Map<string, ImportEntry>();\n private lines: CodeLine[] = [];\n private indent: number;\n\n constructor(indent = 0) {\n this.indent = indent;\n }\n\n import(specifier: string | string[], source: string): CodeBuilder {\n const specs = Array.isArray(specifier) ? specifier : [specifier];\n const existing = this.imports.get(source);\n if (existing) {\n for (const s of specs) existing.specifiers.add(s);\n // If we're adding a value import and existing was type-only, downgrade to value\n existing.typeOnly = false;\n } else {\n this.imports.set(source, { specifiers: new Set(specs), typeOnly: false });\n }\n return this;\n }\n\n importDefault(name: string, source: string): CodeBuilder {\n const existing = this.imports.get(source);\n if (existing) {\n existing.defaultSpecifier = name;\n existing.typeOnly = false;\n } else {\n this.imports.set(source, { specifiers: new Set(), defaultSpecifier: name, typeOnly: false });\n }\n return this;\n }\n\n importType(specifier: string | string[], source: string): CodeBuilder {\n const specs = Array.isArray(specifier) ? specifier : [specifier];\n const existing = this.imports.get(source);\n if (existing) {\n for (const s of specs) existing.specifiers.add(s);\n // Don't downgrade: if existing is value import, keep it as value\n } else {\n this.imports.set(source, { specifiers: new Set(specs), typeOnly: true });\n }\n return this;\n }\n\n line(code?: string): CodeBuilder {\n this.lines.push({ type: 'line', content: code ?? '' });\n return this;\n }\n\n block(\n openOrBuilder: string | ((b: CodeBuilder) => CodeBuilder),\n builderOrClose?: string | ((b: CodeBuilder) => CodeBuilder),\n closeOrBuilder?: string | ((b: CodeBuilder) => CodeBuilder),\n ): CodeBuilder {\n let open: string | undefined;\n let close: string | undefined;\n let builder: (b: CodeBuilder) => CodeBuilder;\n\n if (typeof openOrBuilder === 'function') {\n // block(builder)\n builder = openOrBuilder;\n } else if (typeof builderOrClose === 'function') {\n // block(open, builder, close?)\n open = openOrBuilder;\n builder = builderOrClose;\n close = typeof closeOrBuilder === 'string' ? closeOrBuilder : undefined;\n } else if (typeof closeOrBuilder === 'function') {\n // block(open, close, builder)\n open = openOrBuilder;\n close = typeof builderOrClose === 'string' ? builderOrClose : undefined;\n builder = closeOrBuilder;\n } else {\n throw new Error('Invalid block() arguments');\n }\n\n // Always push block-open to increment indent\n this.lines.push({ type: 'block-open', content: open ?? '' });\n\n const inner = new CodeBuilderImpl(this.indent + 1);\n builder(inner);\n\n // Merge inner imports into ours\n for (const [source, entry] of inner.imports) {\n const existing = this.imports.get(source);\n if (existing) {\n for (const s of entry.specifiers) existing.specifiers.add(s);\n if (entry.defaultSpecifier) existing.defaultSpecifier = entry.defaultSpecifier;\n if (!entry.typeOnly) existing.typeOnly = false;\n } else {\n this.imports.set(source, {\n specifiers: new Set(entry.specifiers),\n defaultSpecifier: entry.defaultSpecifier,\n typeOnly: entry.typeOnly,\n });\n }\n }\n\n // Merge inner lines with extra indentation\n for (const line of inner.lines) {\n this.lines.push(line);\n }\n\n // Always push block-close to decrement indent\n this.lines.push({ type: 'block-close', content: close ?? '' });\n\n return this;\n }\n\n comment(text: string): CodeBuilder {\n this.lines.push({ type: 'line', content: `// ${text}` });\n return this;\n }\n\n docComment(text: string): CodeBuilder {\n const lines = text.split('\\n');\n if (lines.length === 1) {\n this.lines.push({ type: 'line', content: `/** ${text} */` });\n } else {\n this.lines.push({ type: 'line', content: '/**' });\n for (const line of lines) {\n this.lines.push({ type: 'line', content: ` * ${line}` });\n }\n this.lines.push({ type: 'line', content: ' */' });\n }\n return this;\n }\n\n todoComment(text: string): CodeBuilder {\n this.lines.push({ type: 'line', content: `// TODO: ${text}` });\n return this;\n }\n\n raw(code: string): CodeBuilder {\n this.lines.push({ type: 'raw', content: code });\n return this;\n }\n\n build(): CodeBuildResult {\n const parts: string[] = [];\n\n // Emit imports first\n if (this.imports.size > 0) {\n const typeImports: string[] = [];\n const valueImports: string[] = [];\n\n for (const [source, entry] of this.imports) {\n const specs = [...entry.specifiers].sort();\n const namedPart =\n specs.length > 0 ? (specs.length === 1 && !specs[0]!.includes(' ') ? `{ ${specs[0]} }` : `{ ${specs.join(', ')} }`) : null;\n const specStr = entry.defaultSpecifier\n ? namedPart\n ? `${entry.defaultSpecifier}, ${namedPart}`\n : entry.defaultSpecifier\n : namedPart!;\n\n const line = entry.typeOnly ? `import type ${specStr} from '${source}'` : `import ${specStr} from '${source}'`;\n\n if (entry.typeOnly) {\n typeImports.push(line);\n } else {\n valueImports.push(line);\n }\n }\n\n // Value imports first, then type imports\n parts.push([...valueImports, ...typeImports].join('\\n'));\n parts.push('');\n }\n\n // Emit code lines\n let currentIndent = this.indent;\n for (const line of this.lines) {\n if (line.type === 'raw') {\n parts.push(line.content);\n } else if (line.type === 'block-open') {\n if (line.content) {\n const indent = ' '.repeat(currentIndent);\n parts.push(`${indent}${line.content}`);\n }\n currentIndent++;\n } else if (line.type === 'block-close') {\n currentIndent--;\n if (line.content) {\n const indent = ' '.repeat(currentIndent);\n parts.push(`${indent}${line.content}`);\n }\n } else {\n // Regular line\n if (line.content === '') {\n parts.push('');\n } else {\n const indent = ' '.repeat(currentIndent);\n parts.push(`${indent}${line.content}`);\n }\n }\n }\n\n return {\n text: parts.join('\\n'),\n imports: new Map(\n [...this.imports].map(([source, entry]) => [source, { specifiers: new Set(entry.specifiers), typeOnly: entry.typeOnly }]),\n ),\n };\n }\n}\n\n/**\n * Create a new CodeBuilder for constructing TypeScript source files.\n */\nexport function createCodeBuilder(): CodeBuilder {\n return new CodeBuilderImpl();\n}\n","import type { CommandMeta, FieldMeta } from '../types.ts';\n\n/**\n * Parse fish shell completion scripts into CommandMeta.\n *\n * Fish completions use the `complete` builtin:\n * complete -c <command> -s <short> -l <long> -d <description> -a <arguments> -r -f\n */\nexport function parseFishCompletions(text: string): CommandMeta {\n const lines = text.split('\\n');\n const result: CommandMeta = {\n name: '',\n arguments: [],\n subcommands: [],\n };\n\n const subcommandMap = new Map<string, CommandMeta>();\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) continue;\n\n // Match: complete -c <command> [options]\n const completeMatch = trimmed.match(/^complete\\s+/);\n if (!completeMatch) continue;\n\n const parts = parseCompleteLine(trimmed);\n if (!parts) continue;\n\n // Set root command name\n if (!result.name && parts.command) {\n result.name = parts.command;\n }\n\n // If this completion has a condition like \"__fish_seen_subcommand_from <sub>\"\n // it belongs to a subcommand\n const subcommandCondition = parts.condition?.match(/__fish_seen_subcommand_from\\s+(\\S+)/);\n if (subcommandCondition) {\n const subName = subcommandCondition[1]!;\n let sub = subcommandMap.get(subName);\n if (!sub) {\n sub = { name: subName, arguments: [] };\n subcommandMap.set(subName, sub);\n }\n\n if (parts.longFlag || parts.shortFlag) {\n const field = completionToField(parts);\n if (field) sub.arguments!.push(field);\n }\n continue;\n }\n\n // If this defines a subcommand (has -a with no flags)\n if (parts.arguments && !parts.longFlag && !parts.shortFlag) {\n // Arguments list could be subcommand names\n const names = parts.arguments.split(/\\s+/);\n for (const name of names) {\n if (!name || name.startsWith('(')) continue;\n if (!subcommandMap.has(name)) {\n subcommandMap.set(name, {\n name,\n description: parts.description,\n arguments: [],\n });\n } else if (parts.description) {\n subcommandMap.get(name)!.description = parts.description;\n }\n }\n continue;\n }\n\n // Global option\n if (parts.longFlag || parts.shortFlag) {\n const field = completionToField(parts);\n if (field) result.arguments!.push(field);\n }\n }\n\n // Add subcommands\n for (const sub of subcommandMap.values()) {\n if (sub.arguments!.length === 0) delete sub.arguments;\n result.subcommands!.push(sub);\n }\n\n if (result.arguments!.length === 0) delete result.arguments;\n if (result.subcommands!.length === 0) delete result.subcommands;\n\n return result;\n}\n\ninterface CompleteParts {\n command?: string;\n shortFlag?: string;\n longFlag?: string;\n description?: string;\n arguments?: string;\n condition?: string;\n requiresArg?: boolean;\n noFiles?: boolean;\n}\n\nfunction parseCompleteLine(line: string): CompleteParts | null {\n const parts: CompleteParts = {};\n\n // Extract -c <command>\n const cmdMatch = line.match(/-c\\s+(\\S+)/);\n if (cmdMatch) parts.command = cmdMatch[1];\n\n // Extract -s <short>\n const shortMatch = line.match(/-s\\s+(\\S+)/);\n if (shortMatch) parts.shortFlag = shortMatch[1];\n\n // Extract -l <long>\n const longMatch = line.match(/-l\\s+(\\S+)/);\n if (longMatch) parts.longFlag = longMatch[1];\n\n // Extract -d '<description>' or -d \"<description>\"\n const descMatch = line.match(/-d\\s+['\"]([^'\"]+)['\"]/) || line.match(/-d\\s+(\\S+)/);\n if (descMatch) parts.description = descMatch[1];\n\n // Extract -a '<arguments>'\n const argsMatch = line.match(/-a\\s+['\"]([^'\"]+)['\"]/) || line.match(/-a\\s+(\\S+)/);\n if (argsMatch) parts.arguments = argsMatch[1];\n\n // Extract -n '<condition>'\n const condMatch = line.match(/-n\\s+['\"]([^'\"]+)['\"]/) || line.match(/-n\\s+(\\S+)/);\n if (condMatch) parts.condition = condMatch[1];\n\n // -r means requires argument\n parts.requiresArg = /-r\\b/.test(line);\n // -f means no file completion\n parts.noFiles = /-f\\b/.test(line);\n\n return parts;\n}\n\nfunction completionToField(parts: CompleteParts): FieldMeta | null {\n const name = parts.longFlag ? parts.longFlag.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase()) : parts.shortFlag || '';\n\n if (!name) return null;\n\n let type: FieldMeta['type'] = parts.requiresArg ? 'string' : 'boolean';\n let enumValues: string[] | undefined;\n\n // If -a provides specific values, treat as enum\n if (parts.arguments) {\n const values = parts.arguments.split(/\\s+/).filter((v) => !v.startsWith('('));\n if (values.length > 0 && values.length <= 20) {\n enumValues = values;\n type = 'enum';\n }\n }\n\n const aliases = parts.shortFlag && parts.longFlag ? [`-${parts.shortFlag}`] : undefined;\n\n return {\n name,\n type,\n description: parts.description,\n aliases,\n enumValues,\n };\n}\n","import type { CommandMeta, FieldMeta } from '../types.ts';\n\ninterface ParseHelpOptions {\n /** Name to use for the root command if not detected from the help text */\n name?: string;\n}\n\ntype Section = 'none' | 'usage' | 'commands' | 'options' | 'arguments' | 'positional' | 'aliases' | 'skip';\n\n/**\n * Parse --help text output into CommandMeta.\n * Handles common styles: GNU coreutils, Go cobra, Python argparse, Node commander/yargs, gh CLI.\n */\nexport function parseHelpOutput(text: string, options?: ParseHelpOptions): CommandMeta {\n const lines = text.split('\\n');\n const result: CommandMeta = {\n name: options?.name || '',\n arguments: [],\n positionals: [],\n subcommands: [],\n };\n\n let section: Section = 'none';\n\n // Try to extract name from USAGE line\n // Matches: \"Usage: mycli\", \"USAGE\\n gh <command>\", \"Usage:\\n myapp deploy [flags]\"\n const usageMatch = text.match(/^[Uu](?:SAGE|sage):?\\s*(\\S+)/m) || text.match(/^USAGE\\n\\s+(\\S+)/m);\n if (usageMatch && !result.name) {\n result.name = usageMatch[1]!;\n }\n\n // Extract description from lines before first section header\n const descriptionLines: string[] = [];\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed) {\n if (descriptionLines.length > 0) break;\n continue;\n }\n if (isSectionHeader(trimmed)) break;\n if (descriptionLines.length === 0 || descriptionLines.length > 0) {\n descriptionLines.push(trimmed);\n }\n }\n if (descriptionLines.length > 0) {\n result.description = descriptionLines.join(' ');\n }\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n const trimmed = line.trim();\n\n if (!trimmed) continue;\n\n // Detect section headers\n const sectionType = detectSection(trimmed);\n if (sectionType) {\n section = sectionType;\n continue;\n }\n\n // Parse content based on current section\n switch (section) {\n case 'commands': {\n const cmd = parseCommandLine(line);\n if (cmd) {\n result.subcommands!.push(cmd);\n }\n break;\n }\n case 'options': {\n const field = parseOptionLine(line);\n if (field) {\n result.arguments!.push(field);\n }\n break;\n }\n case 'arguments':\n case 'positional': {\n const field = parsePositionalLine(line);\n if (field) {\n result.positionals!.push(field);\n }\n break;\n }\n case 'aliases': {\n const aliasMatch = trimmed.match(/^\\S+(?:\\s+\\S+)*$/);\n if (aliasMatch) {\n // Extract alias from lines like \"gh pr ls\" — the last word is the alias name\n const parts = trimmed.split(/\\s+/);\n if (parts.length >= 2) {\n const alias = parts[parts.length - 1]!;\n if (!result.aliases) result.aliases = [];\n result.aliases.push(alias);\n }\n }\n break;\n }\n // 'skip', 'usage', 'none' — do nothing\n }\n }\n\n // Clean up empty arrays\n if (result.arguments!.length === 0) delete result.arguments;\n if (result.positionals!.length === 0) delete result.positionals;\n if (result.subcommands!.length === 0) delete result.subcommands;\n if (result.aliases?.length === 0) delete result.aliases;\n\n return result;\n}\n\nfunction isSectionHeader(line: string): boolean {\n // \"USAGE\", \"FLAGS\", \"CORE COMMANDS\", \"Options:\", \"Available Commands:\"\n return /^[A-Z][A-Za-z\\s]*:?\\s*$/i.test(line) || /^[A-Z][A-Z\\s]+$/i.test(line);\n}\n\nfunction detectSection(line: string): Section | null {\n const lower = line.toLowerCase().replace(/:$/, '').trim();\n\n // Commands: \"commands\", \"available commands\", \"subcommands\",\n // and gh-style: \"core commands\", \"general commands\", \"additional commands\", etc.\n // Match anything ending in \"commands\" or \"subcommands\", but NOT \"alias commands\"\n if (/^(?:available\\s+)?(?:commands|subcommands)$/.test(lower)) return 'commands';\n if (/^(?:\\w+\\s+)*commands$/.test(lower) && !/alias/.test(lower)) return 'commands';\n\n // Options/Flags: \"options\", \"flags\", \"global options\", \"inherited flags\"\n if (/^(?:global\\s+|inherited\\s+)?(?:options|flags)$/.test(lower)) return 'options';\n\n // Positional arguments\n if (/^(?:positional\\s+)?(?:arguments|args|positionals)$/.test(lower)) return 'positional';\n\n // Aliases section\n if (/^alias(?:es)?(?:\\s+commands)?$/.test(lower)) return 'aliases';\n\n // Usage section\n if (lower === 'usage') return 'usage';\n\n // Sections to skip entirely\n if (/^(?:help\\s+topics|examples?|learn\\s+more|json\\s+fields|see\\s+also|notes?)$/.test(lower)) return 'skip';\n\n return null;\n}\n\nfunction parseCommandLine(line: string): CommandMeta | null {\n // Pattern: \" command-name: Description text\" (gh-style with colon)\n const colonMatch = line.match(/^\\s{2,}([\\w][\\w-]*):?\\s{2,}(.+)$/);\n if (colonMatch) {\n const name = colonMatch[1]!.replace(/:$/, '');\n return {\n name,\n description: colonMatch[2]!.trim(),\n };\n }\n\n // Pattern: \" command-name\" (no description)\n const nameOnly = line.match(/^\\s{2,}([\\w][\\w-]*):?\\s*$/);\n if (nameOnly) {\n return { name: nameOnly[1]!.replace(/:$/, '') };\n }\n\n return null;\n}\n\nfunction parseOptionLine(line: string): FieldMeta | null {\n // Try cobra-style first: \" -s, --flag type Description\" or \" --flag type Description\"\n // The type hint can be a bare word (string, int) or a complex placeholder ([HOST/]OWNER/REPO)\n // but NOT angle-bracket values like <string> (those fall through to GNU pattern)\n const cobraMatch = line.match(/^\\s{2,}(?:(-\\w),\\s+)?(-{1,2}[\\w-]+)(?:\\s+([^\\s<>]+))?\\s{2,}(.+)$/);\n\n if (cobraMatch) {\n const shortFlag = cobraMatch[1];\n const longFlag = cobraMatch[2]!;\n const typeHint = cobraMatch[3];\n const description = cobraMatch[4]?.trim();\n\n const name = normalizeOptionName(longFlag);\n const aliases = shortFlag ? [normalizeAlias(shortFlag)] : undefined;\n\n const { type, ambiguous } = resolveType(typeHint);\n\n const { defaultValue, resolvedType } = extractDefault(description, type, ambiguous);\n const { enumValues, resolvedType: finalType } = extractEnum(description, resolvedType);\n\n return reconcileField({\n name,\n type: finalType,\n description,\n required: type === 'boolean' ? undefined : true,\n aliases,\n default: defaultValue,\n enumValues,\n ambiguous: ambiguous || undefined,\n });\n }\n\n // GNU/argparse-style: \" -s, --long-name <value> Description\"\n // \" --long-name=<value> Description\"\n const gnuMatch = line.match(/^\\s{2,}(?:(-\\w),?\\s+)?(-{1,2}[\\w-]+)(?:\\s*[=\\s]\\s*(?:<([^>]+)>|\\[([^\\]]+)\\]|(\\w+)))?\\s{2,}(.+)$/);\n\n if (gnuMatch) {\n const shortFlag = gnuMatch[1];\n const longFlag = gnuMatch[2]!;\n const valueName = gnuMatch[3] || gnuMatch[4] || gnuMatch[5];\n const description = gnuMatch[6]?.trim();\n\n const name = normalizeOptionName(longFlag);\n const aliases = shortFlag ? [normalizeAlias(shortFlag)] : undefined;\n\n const { type, ambiguous } = resolveType(valueName);\n\n const { defaultValue, resolvedType } = extractDefault(description, type, ambiguous);\n const { enumValues, resolvedType: finalType } = extractEnum(description, resolvedType);\n\n // [value] means optional, <value> means required\n const required = !gnuMatch[4];\n\n return reconcileField({\n name,\n type: finalType,\n description,\n required: finalType === 'boolean' ? undefined : required,\n aliases,\n default: defaultValue,\n enumValues,\n ambiguous: ambiguous || undefined,\n });\n }\n\n // Simplest pattern: \" --name Description\"\n const simple = line.match(/^\\s{2,}(-{1,2}[\\w-]+)\\s{2,}(.+)$/);\n if (simple) {\n const name = normalizeOptionName(simple[1]!);\n return {\n name,\n type: 'boolean',\n description: simple[2]!.trim(),\n };\n }\n\n return null;\n}\n\n/**\n * Resolve a type hint string to a FieldMeta type.\n */\nfunction resolveType(hint: string | undefined): { type: FieldMeta['type']; ambiguous: boolean } {\n if (!hint) return { type: 'boolean', ambiguous: false };\n\n const lower = hint.toLowerCase();\n\n if (/^(num|number|int|integer|port|count|float|duration)$/.test(lower)) {\n return { type: 'number', ambiguous: false };\n }\n if (/^(str|string|text|name|path|file|dir|url|host|query|expression|template)$/.test(lower)) {\n return { type: 'string', ambiguous: false };\n }\n if (/^(bool|boolean)$/.test(lower)) {\n return { type: 'boolean', ambiguous: false };\n }\n if (/^(strings|fields)$/.test(lower)) {\n return { type: 'array', ambiguous: false };\n }\n\n // Unknown type hint — default to string but mark ambiguous\n return { type: 'string', ambiguous: true };\n}\n\n/**\n * Extract default value from description text.\n */\nfunction extractDefault(\n description: string | undefined,\n type: FieldMeta['type'],\n ambiguous: boolean,\n): { defaultValue: unknown; resolvedType: FieldMeta['type'] } {\n let resolvedType = type;\n let defaultValue: unknown;\n\n const defaultMatch = description?.match(/\\(default[:\\s]+([^)]+)\\)/i) || description?.match(/\\[default[:\\s]+([^\\]]+)\\]/i);\n if (defaultMatch) {\n const raw = defaultMatch[1]!.trim();\n if (raw === 'true' || raw === 'false') {\n defaultValue = raw === 'true';\n resolvedType = 'boolean';\n } else if (/^\\d+$/.test(raw)) {\n defaultValue = parseInt(raw, 10);\n if (resolvedType === 'string' && !ambiguous) resolvedType = 'number';\n } else if (/^\\d+\\.\\d+$/.test(raw)) {\n defaultValue = parseFloat(raw);\n if (resolvedType === 'string' && !ambiguous) resolvedType = 'number';\n } else {\n defaultValue = raw.replace(/^[\"']|[\"']$/g, '');\n }\n }\n\n return { defaultValue, resolvedType };\n}\n\n/**\n * Extract enum values from description text.\n */\nfunction extractEnum(\n description: string | undefined,\n type: FieldMeta['type'],\n): { enumValues: string[] | undefined; resolvedType: FieldMeta['type'] } {\n // Explicit choices: (choices: a, b, c) or (one of: a|b|c)\n const choiceMatch = description?.match(/\\((?:one of|choices?)[:\\s]+([^)]+)\\)/i);\n if (choiceMatch) {\n const values = choiceMatch[1]!.split(/[,|]/).map((v) => v.trim().replace(/^[\"']|[\"']$/g, ''));\n return { enumValues: values, resolvedType: 'enum' };\n }\n\n // Inline enum in description: {open|closed|merged|all} (gh-style)\n const inlineMatch = description?.match(/\\{(\\w+(?:\\|[\\w-]+)+)\\}/);\n if (inlineMatch) {\n const values = inlineMatch[1]!.split('|');\n return { enumValues: values, resolvedType: 'enum' };\n }\n\n return { enumValues: undefined, resolvedType: type };\n}\n\n/**\n * Fix up a parsed field for edge cases:\n * - Enum default not in the listed values → add it\n * - Default value type doesn't match declared type → reset to type default + mark ambiguous\n */\nfunction reconcileField(field: FieldMeta): FieldMeta {\n // If enum has a default that isn't in the value list, add it\n if (field.type === 'enum' && field.enumValues && field.default !== undefined) {\n const defStr = String(field.default);\n if (!field.enumValues.includes(defStr)) {\n field.enumValues = [...field.enumValues, defStr];\n }\n }\n\n // If the default value doesn't match the declared type, reset + mark ambiguous\n if (field.default !== undefined) {\n if (field.type === 'boolean' && typeof field.default !== 'boolean') {\n field.default = false;\n field.ambiguous = true;\n } else if (field.type === 'number' && typeof field.default !== 'number') {\n field.default = 0;\n field.ambiguous = true;\n }\n }\n\n return field;\n}\n\nfunction parsePositionalLine(line: string): FieldMeta | null {\n // Pattern: \" <name> Description\"\n // Pattern: \" name Description\"\n const match = line.match(/^\\s{2,}<?(\\w[\\w-]*)>?\\s{2,}(.+)$/);\n if (!match) return null;\n\n return {\n name: match[1]!,\n type: 'string',\n description: match[2]!.trim(),\n positional: true,\n ambiguous: true,\n };\n}\n\n/**\n * Strip leading dashes from a flag name, preserving kebab-case.\n */\nfunction normalizeOptionName(flag: string): string {\n return flag.replace(/^-+/, '');\n}\n\n/**\n * Strip leading dash from a short alias flag (e.g. '-v' → 'v').\n */\nfunction normalizeAlias(alias: string): string {\n return alias.replace(/^-/, '');\n}\n","import type { CommandMeta, FieldMeta } from '../types.ts';\n\n/**\n * Deep-merge multiple CommandMeta from different sources.\n * Deduplicates fields, resolves conflicts, and combines subcommands.\n *\n * Later sources take precedence for descriptions and types,\n * unless the earlier source was more specific (non-ambiguous).\n */\nexport function mergeCommandMeta(...sources: CommandMeta[]): CommandMeta {\n if (sources.length === 0) {\n return { name: '' };\n }\n\n if (sources.length === 1) {\n return sources[0]!;\n }\n\n const result: CommandMeta = { name: '' };\n\n for (const source of sources) {\n // Name: first non-empty wins\n if (source.name && !result.name) {\n result.name = source.name;\n }\n\n // Description: last non-empty wins\n if (source.description) {\n result.description = source.description;\n }\n\n // Aliases: merge and deduplicate\n if (source.aliases) {\n result.aliases = [...new Set([...(result.aliases || []), ...source.aliases])];\n }\n\n // Examples: merge and deduplicate\n if (source.examples) {\n result.examples = [...new Set([...(result.examples || []), ...source.examples])];\n }\n\n // Deprecated: last truthy wins\n if (source.deprecated !== undefined) {\n result.deprecated = source.deprecated;\n }\n\n // Arguments: merge by name\n if (source.arguments) {\n result.arguments = mergeFields(result.arguments || [], source.arguments);\n }\n\n // Positionals: merge by name\n if (source.positionals) {\n result.positionals = mergeFields(result.positionals || [], source.positionals);\n }\n\n // Subcommands: merge recursively by name\n if (source.subcommands) {\n result.subcommands = mergeSubcommands(result.subcommands || [], source.subcommands);\n }\n }\n\n // Clean up empty arrays\n if (result.aliases?.length === 0) delete result.aliases;\n if (result.examples?.length === 0) delete result.examples;\n if (result.arguments?.length === 0) delete result.arguments;\n if (result.positionals?.length === 0) delete result.positionals;\n if (result.subcommands?.length === 0) delete result.subcommands;\n\n return result;\n}\n\n/**\n * Merge two arrays of FieldMeta by name.\n * Later fields take precedence unless earlier was non-ambiguous.\n */\nfunction mergeFields(existing: FieldMeta[], incoming: FieldMeta[]): FieldMeta[] {\n const map = new Map<string, FieldMeta>();\n\n for (const field of existing) {\n map.set(field.name, { ...field });\n }\n\n for (const field of incoming) {\n const prev = map.get(field.name);\n if (!prev) {\n map.set(field.name, { ...field });\n continue;\n }\n\n // Merge the fields\n const merged: FieldMeta = { ...prev };\n\n // Type: prefer non-ambiguous source\n if (field.type !== 'unknown') {\n if (prev.ambiguous || !field.ambiguous) {\n merged.type = field.type;\n merged.ambiguous = field.ambiguous;\n }\n }\n\n // Description: last non-empty wins\n if (field.description) {\n merged.description = field.description;\n }\n\n // Default: last non-undefined wins\n if (field.default !== undefined) {\n merged.default = field.default;\n }\n\n // Required: last defined wins\n if (field.required !== undefined) {\n merged.required = field.required;\n }\n\n // Aliases: merge and deduplicate\n if (field.aliases) {\n merged.aliases = [...new Set([...(prev.aliases || []), ...field.aliases])];\n }\n\n // Enum values: merge and deduplicate\n if (field.enumValues) {\n merged.enumValues = [...new Set([...(prev.enumValues || []), ...field.enumValues])];\n }\n\n // Items: last non-empty wins\n if (field.items) {\n merged.items = field.items;\n }\n\n map.set(field.name, merged);\n }\n\n return [...map.values()];\n}\n\n/**\n * Merge two arrays of CommandMeta by name, recursively.\n */\nfunction mergeSubcommands(existing: CommandMeta[], incoming: CommandMeta[]): CommandMeta[] {\n const map = new Map<string, CommandMeta>();\n\n for (const cmd of existing) {\n map.set(cmd.name, cmd);\n }\n\n for (const cmd of incoming) {\n const prev = map.get(cmd.name);\n if (!prev) {\n map.set(cmd.name, cmd);\n } else {\n map.set(cmd.name, mergeCommandMeta(prev, cmd));\n }\n }\n\n return [...map.values()];\n}\n","import type { CommandMeta, FieldMeta } from '../types.ts';\n\n/**\n * Parse zsh completion function definitions into CommandMeta.\n *\n * Zsh completions typically use _arguments or compadd:\n * _arguments \\\n * '-v[verbose mode]' \\\n * '--output=[output file]:filename:_files' \\\n * '1:command:(start stop restart)'\n */\nexport function parseZshCompletions(text: string): CommandMeta {\n const result: CommandMeta = {\n name: '',\n arguments: [],\n positionals: [],\n subcommands: [],\n };\n\n // Try to detect command name from function name: _command() or #compdef command\n const compdefMatch = text.match(/#compdef\\s+(\\S+)/);\n if (compdefMatch) {\n result.name = compdefMatch[1]!;\n } else {\n const funcMatch = text.match(/^_(\\w+)\\s*\\(\\)/m);\n if (funcMatch) {\n result.name = funcMatch[1]!;\n }\n }\n\n // Find _arguments blocks\n const argumentsBlocks = findArgumentsBlocks(text);\n\n for (const block of argumentsBlocks) {\n const specs = parseArgumentSpecs(block);\n for (const spec of specs) {\n if (spec.positional) {\n result.positionals!.push(spec);\n } else {\n result.arguments!.push(spec);\n }\n }\n }\n\n // Find subcommand definitions from case statements or _describe\n const subcommands = findSubcommands(text);\n result.subcommands!.push(...subcommands);\n\n if (result.arguments!.length === 0) delete result.arguments;\n if (result.positionals!.length === 0) delete result.positionals;\n if (result.subcommands!.length === 0) delete result.subcommands;\n\n return result;\n}\n\n/**\n * Extract _arguments blocks from zsh completion text.\n * Handles backslash continuation lines.\n */\nfunction findArgumentsBlocks(text: string): string[] {\n const blocks: string[] = [];\n\n // Join continuation lines\n const joined = text.replace(/\\\\\\n\\s*/g, ' ');\n const lines = joined.split('\\n');\n\n for (const line of lines) {\n const match = line.match(/_arguments\\s+(.+)/);\n if (match) {\n blocks.push(match[1]!);\n }\n }\n\n return blocks;\n}\n\n/**\n * Parse individual argument specs from an _arguments line.\n */\nfunction parseArgumentSpecs(block: string): FieldMeta[] {\n const results: FieldMeta[] = [];\n\n // Split into individual specs (quoted strings)\n const specs = extractQuotedStrings(block);\n\n for (const spec of specs) {\n const field = parseZshSpec(spec);\n if (field) results.push(field);\n }\n\n return results;\n}\n\n/**\n * Extract single-quoted strings from an _arguments block.\n */\nfunction extractQuotedStrings(text: string): string[] {\n const strings: string[] = [];\n const regex = /'([^']+)'/g;\n let match: RegExpExecArray | null;\n\n while ((match = regex.exec(text)) !== null) {\n strings.push(match[1]!);\n }\n\n return strings;\n}\n\n/**\n * Parse a single zsh argument spec.\n *\n * Formats:\n * '-v[verbose mode]' → boolean flag\n * '--output=[output file]:filename:_files' → string with value\n * '(-v --verbose)'{-v,--verbose}'[verbose mode]' → flag with aliases\n * '*--flag[repeatable]' → array\n * '1:command:(start stop restart)' → positional enum\n * ':filename:_files' → positional\n */\nfunction parseZshSpec(spec: string): FieldMeta | null {\n // Positional argument: 'N:description:action' or ':description:action'\n const positionalMatch = spec.match(/^(\\d+)?:([^:]*):(.*)$/);\n if (positionalMatch) {\n const description = positionalMatch[2] || undefined;\n\n // Check for enum values in (val1 val2 val3)\n const enumMatch = positionalMatch[3]?.match(/^\\(([^)]+)\\)$/);\n if (enumMatch) {\n const values = enumMatch[1]!.split(/\\s+/);\n return {\n name: description?.toLowerCase().replace(/\\s+/g, '_') || `arg${positionalMatch[1] || '0'}`,\n type: 'enum',\n enumValues: values,\n description,\n positional: true,\n };\n }\n\n return {\n name: description?.toLowerCase().replace(/\\s+/g, '_') || `arg${positionalMatch[1] || '0'}`,\n type: 'string',\n description,\n positional: true,\n ambiguous: true,\n };\n }\n\n // Flag argument\n const repeatable = spec.startsWith('*');\n const flagSpec = repeatable ? spec.slice(1) : spec;\n\n // Extract flag name and description\n // Pattern: --flag=[description]:value_description:action\n // Pattern: -f[description]\n const flagMatch = flagSpec.match(/^(-{1,2}[\\w-]+)(?:=?)(?:\\[([^\\]]*)\\])?(?::([^:]*):?(.*))?$/);\n if (!flagMatch) return null;\n\n const rawName = flagMatch[1]!;\n const description = flagMatch[2] || undefined;\n const valueName = flagMatch[3] || undefined;\n\n const name = rawName.replace(/^-+/, '').replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n const hasValue = rawName.includes('=') || !!valueName;\n let type: FieldMeta['type'] = hasValue ? 'string' : 'boolean';\n\n if (repeatable) type = 'array';\n\n // Check for enum values\n let enumValues: string[] | undefined;\n if (flagMatch[4]) {\n const enumMatch = flagMatch[4].match(/^\\(([^)]+)\\)$/);\n if (enumMatch) {\n enumValues = enumMatch[1]!.split(/\\s+/);\n type = 'enum';\n }\n }\n\n return {\n name,\n type,\n description,\n enumValues,\n };\n}\n\n/**\n * Find subcommand definitions from _describe calls or case statements.\n */\nfunction findSubcommands(text: string): CommandMeta[] {\n const subcommands: CommandMeta[] = [];\n const seen = new Set<string>();\n\n // Look for _describe patterns: _describe 'command' commands\n // where commands is an array like: ('start:start the service' 'stop:stop the service')\n const describeRegex = /\\(([^)]+)\\)/g;\n const joined = text.replace(/\\\\\\n\\s*/g, ' ');\n\n // Look for arrays of 'name:description' patterns near _describe\n let match: RegExpExecArray | null;\n while ((match = describeRegex.exec(joined)) !== null) {\n const content = match[1]!;\n const entries = content.match(/'([^']+)'/g) || content.match(/\"([^\"]+)\"/g);\n if (!entries) continue;\n\n for (const entry of entries) {\n const clean = entry.replace(/^['\"]|['\"]$/g, '');\n const parts = clean.split(':');\n if (parts.length >= 2 && /^[\\w-]+$/.test(parts[0]!)) {\n const name = parts[0]!;\n if (seen.has(name)) continue;\n seen.add(name);\n subcommands.push({\n name,\n description: parts.slice(1).join(':'),\n });\n }\n }\n }\n\n return subcommands;\n}\n","import { parseFishCompletions } from './parsers/fish.ts';\nimport { parseHelpOutput } from './parsers/help.ts';\nimport { mergeCommandMeta } from './parsers/merge.ts';\nimport { parseZshCompletions } from './parsers/zsh.ts';\nimport type { CommandMeta, GeneratorLogger } from './types.ts';\n\nexport type DiscoverySource = 'help' | 'fish' | 'zsh';\n\nexport interface DiscoveryOptions {\n /** The command to discover (e.g. 'gh', 'docker', 'kubectl'). */\n command: string;\n /** Which parsing sources to use. Default: ['help'] */\n sources?: DiscoverySource[];\n /** Max subcommand depth. 0 = root only, undefined = unlimited. */\n depth?: number;\n /** Delay in ms between help invocations. Default: 50 */\n delay?: number;\n /** Logger for progress reporting. */\n log?: GeneratorLogger;\n /** Timeout per help invocation in ms. Default: 10000 */\n timeout?: number;\n}\n\nexport interface DiscoveryResult {\n /** The discovered command tree. */\n command: CommandMeta;\n /** Number of help invocations made. */\n invocations: number;\n /** Errors encountered (non-fatal). */\n warnings: string[];\n}\n\n/**\n * Discover CLI structure by running --help recursively and optionally\n * parsing shell completion scripts.\n */\nexport async function discoverCli(options: DiscoveryOptions): Promise<DiscoveryResult> {\n const { command, sources = ['help'], depth, delay = 50, log, timeout = 10000 } = options;\n\n const warnings: string[] = [];\n let invocations = 0;\n\n const results: CommandMeta[] = [];\n\n // Source 1: --help recursive crawl\n if (sources.includes('help')) {\n log?.info(`Discovering ${command} via --help...`);\n const helpResult = await crawlHelp(command, [], {\n depth,\n delay,\n timeout,\n log,\n onInvocation: () => {\n invocations++;\n },\n onWarning: (msg) => {\n warnings.push(msg);\n },\n });\n results.push(helpResult);\n }\n\n // Source 2: Fish completions\n if (sources.includes('fish')) {\n log?.info(`Parsing fish completions for ${command}...`);\n const fishText = await getCompletionScript(command, 'fish', timeout);\n if (fishText) {\n results.push(parseFishCompletions(fishText));\n } else {\n warnings.push('Could not obtain fish completion script');\n }\n }\n\n // Source 3: Zsh completions\n if (sources.includes('zsh')) {\n log?.info(`Parsing zsh completions for ${command}...`);\n const zshText = await getCompletionScript(command, 'zsh', timeout);\n if (zshText) {\n results.push(parseZshCompletions(zshText));\n } else {\n warnings.push('Could not obtain zsh completion script');\n }\n }\n\n const merged = results.length > 0 ? mergeCommandMeta(...results) : { name: command };\n\n // Ensure the root has the correct name\n if (!merged.name) merged.name = command;\n\n return { command: merged, invocations, warnings };\n}\n\ninterface CrawlOptions {\n depth?: number;\n delay: number;\n timeout: number;\n log?: GeneratorLogger;\n onInvocation: () => void;\n onWarning: (msg: string) => void;\n}\n\n/**\n * Breadth-first crawl of --help output.\n */\nasync function crawlHelp(command: string, prefixArgs: string[], options: CrawlOptions): Promise<CommandMeta> {\n const fullCmd = [command, ...prefixArgs].join(' ');\n\n options.onInvocation();\n const helpText = await runHelp(command, prefixArgs, options.timeout);\n\n if (!helpText) {\n options.onWarning(`No help output from: ${fullCmd} --help`);\n return { name: prefixArgs[prefixArgs.length - 1] || command };\n }\n\n const name = prefixArgs[prefixArgs.length - 1] || command;\n const parsed = parseHelpOutput(helpText, { name });\n\n options.log?.info(` ${fullCmd}: ${parsed.subcommands?.length || 0} subcommands, ${parsed.arguments?.length || 0} options`);\n\n // Recurse into subcommands breadth-first\n const currentDepth = prefixArgs.length;\n if (parsed.subcommands && parsed.subcommands.length > 0 && (options.depth === undefined || currentDepth < options.depth)) {\n const resolvedSubs: CommandMeta[] = [];\n\n for (const sub of parsed.subcommands) {\n if (options.delay > 0) {\n await sleep(options.delay);\n }\n const resolved = await crawlHelp(command, [...prefixArgs, sub.name], options);\n // Preserve description from parent's subcommand list if child didn't have one\n if (!resolved.description && sub.description) {\n resolved.description = sub.description;\n }\n resolvedSubs.push(resolved);\n }\n\n parsed.subcommands = resolvedSubs;\n }\n\n return parsed;\n}\n\n/**\n * Run `<cmd> --help` or `<cmd> help` and return combined stdout+stderr.\n */\nasync function runHelp(command: string, args: string[], timeout: number): Promise<string | null> {\n // Try --help first\n let result = await runCommand(command, [...args, '--help'], timeout);\n if (result) return result;\n\n // Some CLIs use `help <cmd>` instead\n if (args.length > 0) {\n result = await runCommand(command, ['help', ...args], timeout);\n if (result) return result;\n }\n\n return null;\n}\n\n/**\n * Run a command and return its combined output, or null on failure.\n */\nasync function runCommand(command: string, args: string[], timeout: number): Promise<string | null> {\n try {\n const proc = Bun.spawn([command, ...args], {\n stdout: 'pipe',\n stderr: 'pipe',\n stdin: 'ignore',\n });\n\n const timer = setTimeout(() => proc.kill(), timeout);\n\n const [_exitCode, stdoutBuf, stderrBuf] = await Promise.all([\n proc.exited,\n new Response(proc.stdout).arrayBuffer(),\n new Response(proc.stderr).arrayBuffer(),\n ]);\n\n clearTimeout(timer);\n\n const stdout = new TextDecoder().decode(stdoutBuf).trim();\n const stderr = new TextDecoder().decode(stderrBuf).trim();\n\n // Some CLIs output help to stderr, some exit non-zero on --help\n const combined = stdout || stderr;\n if (!combined) return null;\n\n // Basic sanity check: help text usually has some structure\n if (combined.length < 10) return null;\n\n return combined;\n } catch {\n return null;\n }\n}\n\n/**\n * Try to get a shell completion script for a command.\n * Checks both `<cmd> completion <shell>` and well-known file paths.\n */\nasync function getCompletionScript(command: string, shell: 'fish' | 'zsh', timeout: number): Promise<string | null> {\n // Try `<cmd> completion <shell>`\n const completionArgs = ['completion', shell];\n let result = await runCommand(command, completionArgs, timeout);\n if (result) return result;\n\n // Try `<cmd> completions <shell>`\n result = await runCommand(command, ['completions', shell], timeout);\n if (result) return result;\n\n // Try reading from well-known paths\n const paths =\n shell === 'fish'\n ? [`/usr/share/fish/vendor_completions.d/${command}.fish`, `/usr/local/share/fish/vendor_completions.d/${command}.fish`]\n : [`/usr/share/zsh/site-functions/_${command}`, `/usr/local/share/zsh/site-functions/_${command}`];\n\n for (const path of paths) {\n try {\n const file = Bun.file(path);\n if (await file.exists()) {\n return await file.text();\n }\n } catch {}\n }\n\n return null;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport type { CodeBuildResult, EmitResult, FileEmitter, FileEmitterOptions } from './types.ts';\n\ninterface QueuedFile {\n path: string;\n content: string;\n}\n\nclass FileEmitterImpl implements FileEmitter {\n private files: QueuedFile[] = [];\n private options: FileEmitterOptions;\n\n constructor(options: FileEmitterOptions) {\n this.options = options;\n }\n\n addFile(path: string, content: string | CodeBuildResult): void {\n const text = typeof content === 'string' ? content : content.text;\n const fullContent = this.options.header ? `${this.options.header}\\n\\n${text}` : text;\n\n this.files.push({ path, content: fullContent });\n }\n\n async emit(): Promise<EmitResult> {\n const result: EmitResult = {\n written: [],\n skipped: [],\n errors: [],\n };\n\n const outDir = resolve(this.options.outDir);\n\n for (const file of this.files) {\n const fullPath = join(outDir, file.path);\n\n try {\n // Check if file already exists\n if (existsSync(fullPath) && !this.options.overwrite) {\n result.skipped.push(file.path);\n continue;\n }\n\n if (this.options.dryRun) {\n result.written.push(file.path);\n continue;\n }\n\n // Ensure directory exists\n const dir = dirname(fullPath);\n mkdirSync(dir, { recursive: true });\n\n // Write the file\n writeFileSync(fullPath, file.content, 'utf-8');\n result.written.push(file.path);\n } catch (err) {\n result.errors.push({\n file: file.path,\n error: err instanceof Error ? err : new Error(String(err)),\n });\n }\n }\n\n return result;\n }\n}\n\n/**\n * Create a FileEmitter for writing multiple generated files to disk.\n */\nexport function createFileEmitter(options: FileEmitterOptions): FileEmitter {\n return new FileEmitterImpl(options);\n}\n","import type { CodeBuilder, GeneratorContext } from '../types.ts';\n\n/**\n * Generate an index.ts barrel file that re-exports all given files.\n */\nexport function generateBarrelFile(files: string[], ctx: GeneratorContext): CodeBuilder {\n const code = ctx.createCodeBuilder();\n\n for (const file of files) {\n // Strip .ts extension for the import path and ensure relative path\n const importPath = file.startsWith('./') ? file : `./${file}`;\n code.line(`export * from '${importPath}'`);\n }\n\n return code;\n}\n","import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { FieldMeta } from './types.ts';\n\ninterface SchemaToCodeResult {\n /** The generated Zod source code */\n code: string;\n /** Imports needed (e.g. ['z']) */\n imports: string[];\n}\n\n/**\n * Convert a JSON Schema property to Zod code.\n */\nfunction jsonSchemaPropertyToZod(prop: Record<string, any>, required: boolean, ambiguous?: boolean): string {\n let code: string;\n\n const type = prop.type as string | undefined;\n const enumValues = prop.enum as unknown[] | undefined;\n\n if (enumValues && enumValues.length > 0) {\n const values = enumValues.map((v) => JSON.stringify(v)).join(', ');\n code = `z.enum([${values}])`;\n } else if (type === 'string') {\n code = 'z.string()';\n } else if (type === 'number' || type === 'integer') {\n code = 'z.number()';\n } else if (type === 'boolean') {\n code = 'z.boolean()';\n } else if (type === 'array') {\n const items = prop.items as Record<string, any> | undefined;\n const itemCode = items ? jsonSchemaPropertyToZod(items, true) : 'z.unknown()';\n code = `${itemCode}.array()`;\n } else {\n code = 'z.unknown()';\n }\n\n if (prop.default !== undefined) {\n code += `.default(${JSON.stringify(prop.default)})`;\n } else if (!required) {\n code += '.optional()';\n }\n\n if (prop.description) {\n code += `.describe(${JSON.stringify(prop.description)})`;\n }\n\n if (ambiguous) {\n code += ' /* TODO: verify type */';\n }\n\n return code;\n}\n\n/**\n * Generate Zod source code from a Standard Schema instance by introspecting\n * its `~standard.jsonSchema` interface.\n */\nexport function schemaToCode(schema: StandardSchemaV1): SchemaToCodeResult {\n try {\n const jsonSchema = (schema as any)['~standard'].jsonSchema.input({ target: 'draft-2020-12' }) as Record<string, any>;\n return jsonSchemaToCode(jsonSchema);\n } catch {\n return { code: 'z.unknown()', imports: ['z'] };\n }\n}\n\nfunction jsonSchemaToCode(jsonSchema: Record<string, any>): SchemaToCodeResult {\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n const properties = jsonSchema.properties as Record<string, any>;\n const required = new Set((jsonSchema.required as string[]) || []);\n\n const entries = Object.entries(properties).map(([key, prop]) => {\n const isRequired = required.has(key);\n const zodCode = jsonSchemaPropertyToZod(prop as Record<string, any>, isRequired);\n return ` ${key}: ${zodCode},`;\n });\n\n const code = `z.object({\\n${entries.join('\\n')}\\n})`;\n return { code, imports: ['z'] };\n }\n\n // Fallback for non-object schemas\n const code = jsonSchemaPropertyToZod(jsonSchema, true);\n return { code, imports: ['z'] };\n}\n\n/**\n * Build a real Zod schema from FieldMeta objects.\n * Returns the schema as Zod source code, since we can't dynamically import Zod here\n * (codegen has no runtime dependency on padrone's main entry point).\n */\nexport function fieldMetaToCode(fields: FieldMeta[]): SchemaToCodeResult {\n const entries = fields.map((field) => {\n let code: string;\n\n switch (field.type) {\n case 'string':\n code = 'z.string()';\n break;\n case 'number':\n code = 'z.number()';\n break;\n case 'boolean':\n code = 'z.boolean()';\n break;\n case 'array': {\n const itemType = field.items || 'string';\n const itemCode = itemType === 'number' ? 'z.number()' : 'z.string()';\n code = `${itemCode}.array()`;\n break;\n }\n case 'enum':\n if (field.enumValues && field.enumValues.length > 0) {\n const values = field.enumValues.map((v) => JSON.stringify(v)).join(', ');\n code = `z.enum([${values}])`;\n } else {\n code = 'z.string()';\n }\n break;\n default:\n code = 'z.unknown()';\n break;\n }\n\n if (field.default !== undefined) {\n code += `.default(${JSON.stringify(field.default)})`;\n } else if (!field.required) {\n code += '.optional()';\n }\n\n if (field.description) {\n code += `.describe(${JSON.stringify(field.description)})`;\n }\n\n if (field.ambiguous) {\n code += ' /* TODO: verify type */';\n }\n\n const key = needsQuoting(field.name) ? JSON.stringify(field.name) : field.name;\n return ` ${key}: ${code},`;\n });\n\n const code = `z.object({\\n${entries.join('\\n')}\\n})`;\n return { code, imports: ['z'] };\n}\n\nconst JS_RESERVED = new Set([\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'export',\n 'extends',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'import',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'super',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'yield',\n 'class',\n 'const',\n 'enum',\n 'let',\n 'static',\n 'implements',\n 'interface',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'await',\n 'async',\n]);\n\n/** Returns true if the name needs quoting to be a valid JS object key. */\nfunction needsQuoting(name: string): boolean {\n if (JS_RESERVED.has(name)) return true;\n // Must be a valid identifier: starts with letter/$/_, contains only word chars\n return !/^[a-zA-Z_$][\\w$]*$/.test(name);\n}\n","import { fieldMetaToCode } from '../schema-to-code.ts';\nimport type { CodeBuilder, CommandMeta, FieldMeta, GeneratorContext } from '../types.ts';\n\nconst JS_RESERVED = new Set([\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'export',\n 'extends',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'import',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'super',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'yield',\n 'class',\n 'const',\n 'enum',\n 'let',\n 'static',\n 'implements',\n 'interface',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'await',\n 'async',\n]);\n\n/** Convert a command name to a safe JS identifier (camelCase, reserved-word-safe). */\nexport function toSafeIdentifier(name: string): string {\n const camel = name.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n if (/^\\d/.test(camel)) return `_${camel}`;\n if (JS_RESERVED.has(camel)) return `_${camel}`;\n return camel;\n}\n\n/** Build the exported function name for a command (e.g. 'repo' → 'repoCommand'). */\nexport function toCommandFunctionName(name: string): string {\n return `${toSafeIdentifier(name)}Command`;\n}\n\nexport interface CommandFileOptions {\n /** Wrap config: generates .wrap() instead of .action(). */\n wrap?: {\n /** The external command to wrap (e.g. 'gh'). */\n command: string;\n /** Fixed args preceding the options (e.g. ['pr', 'list']). */\n args?: string[];\n };\n /** Subcommand references to wire into this command via .command() calls. */\n subcommands?: { name: string; varName: string; importPath: string; aliases?: string[] }[];\n}\n\n/**\n * Generate a single Padrone command file from a CommandMeta.\n * Produces a named function that chains .configure(), .arguments(), and .wrap() or .action().\n */\nexport function generateCommandFile(command: CommandMeta, ctx: GeneratorContext, options?: CommandFileOptions): CodeBuilder {\n const code = ctx.createCodeBuilder();\n\n const hasArgs = (command.arguments && command.arguments.length > 0) || (command.positionals && command.positionals.length > 0);\n\n if (hasArgs) {\n code.import('z', 'zod/v4');\n }\n\n code.importType('AnyPadroneBuilder', 'padrone');\n\n // Import subcommand modules\n if (options?.subcommands) {\n for (const sub of options.subcommands) {\n code.import([sub.varName], sub.importPath);\n }\n }\n\n code.line();\n\n if (command.deprecated) {\n const msg = typeof command.deprecated === 'string' ? command.deprecated : 'This command is deprecated';\n code.comment(`@deprecated ${msg}`);\n }\n\n const fnName = toCommandFunctionName(command.name);\n code.line(`export function ${fnName}<T extends AnyPadroneBuilder>(cmd: T) {`);\n code.line(` return cmd`);\n\n // .configure()\n const configParts: string[] = [];\n if (command.description) {\n configParts.push(`description: ${JSON.stringify(command.description)}`);\n }\n if (command.deprecated) {\n configParts.push(`deprecated: ${typeof command.deprecated === 'string' ? JSON.stringify(command.deprecated) : 'true'}`);\n }\n if (configParts.length > 0) {\n code.line(` .configure({ ${configParts.join(', ')} })`);\n }\n\n // .arguments()\n if (hasArgs) {\n const allFields = [...(command.arguments || []), ...(command.positionals || [])];\n const schemaCode = fieldMetaToCode(allFields);\n\n const positionalNames = (command.positionals || []).map((p) => (p.type === 'array' ? `'...${p.name}'` : `'${p.name}'`));\n const fieldsMap = buildFieldsMap(allFields);\n const hasMetaOptions = positionalNames.length > 0 || fieldsMap;\n\n if (hasMetaOptions) {\n code.line(` .arguments(${schemaCode.code}, {`);\n if (positionalNames.length > 0) {\n code.line(` positional: [${positionalNames.join(', ')}],`);\n }\n if (fieldsMap) {\n code.line(` fields: ${fieldsMap},`);\n }\n code.line(` })`);\n } else {\n code.line(` .arguments(${schemaCode.code})`);\n }\n }\n\n // .command() calls for subcommands\n if (options?.subcommands) {\n for (const sub of options.subcommands) {\n const nameArg =\n sub.aliases && sub.aliases.length > 0\n ? `[${JSON.stringify(sub.name)}, ${sub.aliases.map((a) => JSON.stringify(a)).join(', ')}]`\n : JSON.stringify(sub.name);\n code.line(` .command(${nameArg}, ${sub.varName})`);\n }\n }\n\n // .wrap() or .action()\n if (options?.wrap) {\n const wrapParts: string[] = [];\n wrapParts.push(`command: ${JSON.stringify(options.wrap.command)}`);\n if (options.wrap.args && options.wrap.args.length > 0) {\n wrapParts.push(`args: [${options.wrap.args.map((a) => JSON.stringify(a)).join(', ')}]`);\n }\n code.line(` .wrap({ ${wrapParts.join(', ')} })`);\n } else {\n code.line(` .action((args) => { /* TODO */ })`);\n }\n\n code.line(`}`);\n\n return code;\n}\n\nfunction buildFieldsMap(fields: FieldMeta[]): string | null {\n const entries: string[] = [];\n for (const field of fields) {\n if (field.aliases && field.aliases.length > 0) {\n const alias =\n field.aliases.length === 1 ? JSON.stringify(field.aliases[0]) : `[${field.aliases.map((a) => JSON.stringify(a)).join(', ')}]`;\n const key = /^[a-zA-Z_$][\\w$]*$/.test(field.name) ? field.name : JSON.stringify(field.name);\n entries.push(`${key}: { alias: ${alias} }`);\n }\n }\n if (entries.length === 0) return null;\n return `{ ${entries.join(', ')} }`;\n}\n","import { fieldMetaToCode } from '../schema-to-code.ts';\nimport type { CommandMeta, GeneratorContext } from '../types.ts';\nimport type { CommandFileOptions } from './command-file.ts';\nimport { generateCommandFile, toCommandFunctionName } from './command-file.ts';\n\nexport interface CommandTreeOptions {\n /** When set, generates .wrap() calls instead of .action(). */\n wrap?: {\n /** The external command being wrapped (e.g. 'gh'). */\n command: string;\n };\n}\n\n/**\n * Walk a CommandMeta tree and emit one file per command plus a root program file.\n * Maps nested subcommands to a directory structure.\n */\nexport function generateCommandTree(root: CommandMeta, ctx: GeneratorContext, options?: CommandTreeOptions): void {\n const rootImports: { name: string; varName: string; path: string; aliases?: string[] }[] = [];\n\n // Recursively generate command files (depth-first so children exist before parents)\n function walkCommands(cmd: CommandMeta, dirPath: string, parentArgs: string[]): void {\n if (cmd === root) {\n for (const sub of cmd.subcommands || []) {\n walkCommands(sub, 'commands', []);\n }\n return;\n }\n\n const filePath = `${dirPath}/${cmd.name}.ts`;\n\n // Recurse into subcommands first so we can reference them\n const childRefs: { name: string; varName: string; importPath: string; aliases?: string[] }[] = [];\n if (cmd.subcommands && cmd.subcommands.length > 0) {\n for (const sub of cmd.subcommands) {\n walkCommands(sub, `${dirPath}/${cmd.name}`, [...parentArgs, cmd.name]);\n childRefs.push({\n name: sub.name,\n varName: toCommandFunctionName(sub.name),\n importPath: `./${cmd.name}/${sub.name}.ts`,\n aliases: sub.aliases,\n });\n }\n }\n\n const fileOptions: CommandFileOptions = {};\n if (options?.wrap) {\n fileOptions.wrap = { command: options.wrap.command, args: [...parentArgs, cmd.name] };\n }\n if (childRefs.length > 0) {\n fileOptions.subcommands = childRefs;\n }\n\n const code = generateCommandFile(cmd, ctx, Object.keys(fileOptions).length > 0 ? fileOptions : undefined);\n ctx.emitter.addFile(filePath, code.build());\n\n rootImports.push({\n name: cmd.name,\n varName: toCommandFunctionName(cmd.name),\n path: `./${filePath.replace(/\\.ts$/, '.ts')}`,\n aliases: cmd.aliases,\n });\n }\n\n walkCommands(root, '', []);\n\n // Generate root program.ts\n const program = ctx.createCodeBuilder();\n\n const rootHasArgs = (root.arguments && root.arguments.length > 0) || (root.positionals && root.positionals.length > 0);\n if (rootHasArgs) {\n program.import('z', 'zod/v4');\n }\n program.import(['createPadrone'], 'padrone');\n\n // Only import direct children of root\n const directChildren = rootImports.filter((imp) => imp.path.split('/').length <= 3);\n for (const imp of directChildren) {\n program.import([imp.varName], imp.path);\n }\n\n program.line();\n program.line(`const program = createPadrone(${JSON.stringify(root.name)})`);\n\n // .configure()\n const configParts: string[] = [];\n if (root.description) {\n configParts.push(`description: ${JSON.stringify(root.description)}`);\n }\n if (configParts.length > 0) {\n program.line(` .configure({ ${configParts.join(', ')} })`);\n }\n\n // Root arguments (for programs that have options at the root level)\n if (rootHasArgs) {\n const allFields = [...(root.arguments || []), ...(root.positionals || [])];\n const schemaCode = fieldMetaToCode(allFields);\n program.line(` .arguments(${schemaCode.code})`);\n }\n\n // Chain .command() calls for direct children\n for (const imp of directChildren) {\n const nameArg =\n imp.aliases && imp.aliases.length > 0\n ? `[${JSON.stringify(imp.name)}, ${imp.aliases.map((a) => JSON.stringify(a)).join(', ')}]`\n : JSON.stringify(imp.name);\n program.line(` .command(${nameArg}, ${imp.varName})`);\n }\n\n // If root has no subcommands, add .wrap() or .action()\n if (directChildren.length === 0 && options?.wrap) {\n program.line(` .wrap({ command: ${JSON.stringify(options.wrap.command)} })`);\n }\n\n program.line();\n program.line(`export default program`);\n\n ctx.emitter.addFile('program.ts', program.build());\n\n // Generate index.ts\n const index = ctx.createCodeBuilder();\n index.line(`export { default } from './program.ts'`);\n ctx.emitter.addFile('index.ts', index.build());\n}\n","/**\n * Lightweight string template engine.\n *\n * Syntax:\n * - `{{var}}` — interpolation\n * - `{{#arr}}...{{/arr}}` — iteration (`.` refers to current item)\n * - `{{#bool}}...{{/bool}}` — conditional blocks\n * - `{{>partial}}` — include a named sub-template\n */\n\ntype TemplateRenderer = (data: Record<string, unknown>, partials?: Record<string, string>) => string;\n\n/**\n * Compile a template string into a reusable render function.\n */\nexport function template(text: string): TemplateRenderer {\n return (data: Record<string, unknown>, partials?: Record<string, string>) => {\n return render(text, data, partials);\n };\n}\n\nfunction render(text: string, data: Record<string, unknown>, partials?: Record<string, string>): string {\n let result = text;\n\n // Process block sections: {{#key}}...{{/key}}\n result = result.replace(/\\{\\{#(\\w+)\\}\\}([\\s\\S]*?)\\{\\{\\/\\1\\}\\}/g, (_match, key: string, body: string) => {\n const value = data[key];\n\n if (value === undefined || value === null || value === false) {\n return '';\n }\n\n if (Array.isArray(value)) {\n return value\n .map((item) => {\n if (typeof item === 'object' && item !== null) {\n return render(body, item as Record<string, unknown>, partials);\n }\n // For primitive items, replace {{.}} with the item value\n return body.replace(/\\{\\{\\.\\}\\}/g, String(item));\n })\n .join('');\n }\n\n // Truthy conditional\n if (typeof value === 'object') {\n return render(body, value as Record<string, unknown>, partials);\n }\n return render(body, data, partials);\n });\n\n // Process partials: {{>partialName}}\n if (partials) {\n result = result.replace(/\\{\\{>(\\w+)\\}\\}/g, (_match, name: string) => {\n const partialText = partials[name];\n if (!partialText) return '';\n return render(partialText, data, partials);\n });\n }\n\n // Process interpolation: {{var}}\n result = result.replace(/\\{\\{(\\w+)\\}\\}/g, (_match, key: string) => {\n const value = data[key];\n if (value === undefined || value === null) return '';\n return String(value);\n });\n\n return result;\n}\n"],"mappings":";;;AAaA,IAAM,kBAAN,MAAM,gBAAuC;CAC3C,0BAAkB,IAAI,KAA0B;CAChD,QAA4B,EAAE;CAC9B;CAEA,YAAY,SAAS,GAAG;AACtB,OAAK,SAAS;;CAGhB,OAAO,WAA8B,QAA6B;EAChE,MAAM,QAAQ,MAAM,QAAQ,UAAU,GAAG,YAAY,CAAC,UAAU;EAChE,MAAM,WAAW,KAAK,QAAQ,IAAI,OAAO;AACzC,MAAI,UAAU;AACZ,QAAK,MAAM,KAAK,MAAO,UAAS,WAAW,IAAI,EAAE;AAEjD,YAAS,WAAW;QAEpB,MAAK,QAAQ,IAAI,QAAQ;GAAE,YAAY,IAAI,IAAI,MAAM;GAAE,UAAU;GAAO,CAAC;AAE3E,SAAO;;CAGT,cAAc,MAAc,QAA6B;EACvD,MAAM,WAAW,KAAK,QAAQ,IAAI,OAAO;AACzC,MAAI,UAAU;AACZ,YAAS,mBAAmB;AAC5B,YAAS,WAAW;QAEpB,MAAK,QAAQ,IAAI,QAAQ;GAAE,4BAAY,IAAI,KAAK;GAAE,kBAAkB;GAAM,UAAU;GAAO,CAAC;AAE9F,SAAO;;CAGT,WAAW,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codegen/parsers/help.ts","../../src/codegen/parsers/merge.ts","../../src/codegen/parsers/zsh.ts","../../src/codegen/discovery.ts","../../src/codegen/file-emitter.ts","../../src/codegen/generators/barrel-file.ts","../../src/codegen/schema-to-code.ts","../../src/codegen/generators/command-file.ts","../../src/codegen/generators/command-tree.ts","../../src/codegen/template.ts"],"sourcesContent":["import type { CodeBuilder, CodeBuildResult } from './types.ts';\n\ninterface ImportEntry {\n specifiers: Set<string>;\n defaultSpecifier?: string;\n typeOnly: boolean;\n}\n\ninterface CodeLine {\n type: 'line' | 'raw' | 'block-open' | 'block-close';\n content: string;\n}\n\nclass CodeBuilderImpl implements CodeBuilder {\n private imports = new Map<string, ImportEntry>();\n private lines: CodeLine[] = [];\n private indent: number;\n\n constructor(indent = 0) {\n this.indent = indent;\n }\n\n import(specifier: string | string[], source: string): CodeBuilder {\n const specs = Array.isArray(specifier) ? specifier : [specifier];\n const existing = this.imports.get(source);\n if (existing) {\n for (const s of specs) existing.specifiers.add(s);\n // If we're adding a value import and existing was type-only, downgrade to value\n existing.typeOnly = false;\n } else {\n this.imports.set(source, { specifiers: new Set(specs), typeOnly: false });\n }\n return this;\n }\n\n importDefault(name: string, source: string): CodeBuilder {\n const existing = this.imports.get(source);\n if (existing) {\n existing.defaultSpecifier = name;\n existing.typeOnly = false;\n } else {\n this.imports.set(source, { specifiers: new Set(), defaultSpecifier: name, typeOnly: false });\n }\n return this;\n }\n\n importType(specifier: string | string[], source: string): CodeBuilder {\n const specs = Array.isArray(specifier) ? specifier : [specifier];\n const existing = this.imports.get(source);\n if (existing) {\n for (const s of specs) existing.specifiers.add(s);\n // Don't downgrade: if existing is value import, keep it as value\n } else {\n this.imports.set(source, { specifiers: new Set(specs), typeOnly: true });\n }\n return this;\n }\n\n line(code?: string): CodeBuilder {\n this.lines.push({ type: 'line', content: code ?? '' });\n return this;\n }\n\n block(\n openOrBuilder: string | ((b: CodeBuilder) => CodeBuilder),\n builderOrClose?: string | ((b: CodeBuilder) => CodeBuilder),\n closeOrBuilder?: string | ((b: CodeBuilder) => CodeBuilder),\n ): CodeBuilder {\n let open: string | undefined;\n let close: string | undefined;\n let builder: (b: CodeBuilder) => CodeBuilder;\n\n if (typeof openOrBuilder === 'function') {\n // block(builder)\n builder = openOrBuilder;\n } else if (typeof builderOrClose === 'function') {\n // block(open, builder, close?)\n open = openOrBuilder;\n builder = builderOrClose;\n close = typeof closeOrBuilder === 'string' ? closeOrBuilder : undefined;\n } else if (typeof closeOrBuilder === 'function') {\n // block(open, close, builder)\n open = openOrBuilder;\n close = typeof builderOrClose === 'string' ? builderOrClose : undefined;\n builder = closeOrBuilder;\n } else {\n throw new Error('Invalid block() arguments');\n }\n\n // Always push block-open to increment indent\n this.lines.push({ type: 'block-open', content: open ?? '' });\n\n const inner = new CodeBuilderImpl(this.indent + 1);\n builder(inner);\n\n // Merge inner imports into ours\n for (const [source, entry] of inner.imports) {\n const existing = this.imports.get(source);\n if (existing) {\n for (const s of entry.specifiers) existing.specifiers.add(s);\n if (entry.defaultSpecifier) existing.defaultSpecifier = entry.defaultSpecifier;\n if (!entry.typeOnly) existing.typeOnly = false;\n } else {\n this.imports.set(source, {\n specifiers: new Set(entry.specifiers),\n defaultSpecifier: entry.defaultSpecifier,\n typeOnly: entry.typeOnly,\n });\n }\n }\n\n // Merge inner lines with extra indentation\n for (const line of inner.lines) {\n this.lines.push(line);\n }\n\n // Always push block-close to decrement indent\n this.lines.push({ type: 'block-close', content: close ?? '' });\n\n return this;\n }\n\n comment(text: string): CodeBuilder {\n this.lines.push({ type: 'line', content: `// ${text}` });\n return this;\n }\n\n docComment(text: string): CodeBuilder {\n const lines = text.split('\\n');\n if (lines.length === 1) {\n this.lines.push({ type: 'line', content: `/** ${text} */` });\n } else {\n this.lines.push({ type: 'line', content: '/**' });\n for (const line of lines) {\n this.lines.push({ type: 'line', content: ` * ${line}` });\n }\n this.lines.push({ type: 'line', content: ' */' });\n }\n return this;\n }\n\n todoComment(text: string): CodeBuilder {\n this.lines.push({ type: 'line', content: `// TODO: ${text}` });\n return this;\n }\n\n raw(code: string): CodeBuilder {\n this.lines.push({ type: 'raw', content: code });\n return this;\n }\n\n build(): CodeBuildResult {\n const parts: string[] = [];\n\n // Emit imports first\n if (this.imports.size > 0) {\n const typeImports: string[] = [];\n const valueImports: string[] = [];\n\n for (const [source, entry] of this.imports) {\n const specs = [...entry.specifiers].sort();\n const namedPart =\n specs.length > 0 ? (specs.length === 1 && !specs[0]!.includes(' ') ? `{ ${specs[0]} }` : `{ ${specs.join(', ')} }`) : null;\n const specStr = entry.defaultSpecifier\n ? namedPart\n ? `${entry.defaultSpecifier}, ${namedPart}`\n : entry.defaultSpecifier\n : namedPart!;\n\n const line = entry.typeOnly ? `import type ${specStr} from '${source}'` : `import ${specStr} from '${source}'`;\n\n if (entry.typeOnly) {\n typeImports.push(line);\n } else {\n valueImports.push(line);\n }\n }\n\n // Value imports first, then type imports\n parts.push([...valueImports, ...typeImports].join('\\n'));\n parts.push('');\n }\n\n // Emit code lines\n let currentIndent = this.indent;\n for (const line of this.lines) {\n if (line.type === 'raw') {\n parts.push(line.content);\n } else if (line.type === 'block-open') {\n if (line.content) {\n const indent = ' '.repeat(currentIndent);\n parts.push(`${indent}${line.content}`);\n }\n currentIndent++;\n } else if (line.type === 'block-close') {\n currentIndent--;\n if (line.content) {\n const indent = ' '.repeat(currentIndent);\n parts.push(`${indent}${line.content}`);\n }\n } else {\n // Regular line\n if (line.content === '') {\n parts.push('');\n } else {\n const indent = ' '.repeat(currentIndent);\n parts.push(`${indent}${line.content}`);\n }\n }\n }\n\n return {\n text: parts.join('\\n'),\n imports: new Map(\n [...this.imports].map(([source, entry]) => [source, { specifiers: new Set(entry.specifiers), typeOnly: entry.typeOnly }]),\n ),\n };\n }\n}\n\n/**\n * Create a new CodeBuilder for constructing TypeScript source files.\n */\nexport function createCodeBuilder(): CodeBuilder {\n return new CodeBuilderImpl();\n}\n","import type { CommandMeta, FieldMeta } from '../types.ts';\n\n/**\n * Parse fish shell completion scripts into CommandMeta.\n *\n * Fish completions use the `complete` builtin:\n * complete -c <command> -s <short> -l <long> -d <description> -a <arguments> -r -f\n */\nexport function parseFishCompletions(text: string): CommandMeta {\n const lines = text.split('\\n');\n const result: CommandMeta = {\n name: '',\n arguments: [],\n subcommands: [],\n };\n\n const subcommandMap = new Map<string, CommandMeta>();\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith('#')) continue;\n\n // Match: complete -c <command> [options]\n const completeMatch = trimmed.match(/^complete\\s+/);\n if (!completeMatch) continue;\n\n const parts = parseCompleteLine(trimmed);\n if (!parts) continue;\n\n // Set root command name\n if (!result.name && parts.command) {\n result.name = parts.command;\n }\n\n // If this completion has a condition like \"__fish_seen_subcommand_from <sub>\"\n // it belongs to a subcommand\n const subcommandCondition = parts.condition?.match(/__fish_seen_subcommand_from\\s+(\\S+)/);\n if (subcommandCondition) {\n const subName = subcommandCondition[1]!;\n let sub = subcommandMap.get(subName);\n if (!sub) {\n sub = { name: subName, arguments: [] };\n subcommandMap.set(subName, sub);\n }\n\n if (parts.longFlag || parts.shortFlag) {\n const field = completionToField(parts);\n if (field) sub.arguments!.push(field);\n }\n continue;\n }\n\n // If this defines a subcommand (has -a with no flags)\n if (parts.arguments && !parts.longFlag && !parts.shortFlag) {\n // Arguments list could be subcommand names\n const names = parts.arguments.split(/\\s+/);\n for (const name of names) {\n if (!name || name.startsWith('(')) continue;\n if (!subcommandMap.has(name)) {\n subcommandMap.set(name, {\n name,\n description: parts.description,\n arguments: [],\n });\n } else if (parts.description) {\n subcommandMap.get(name)!.description = parts.description;\n }\n }\n continue;\n }\n\n // Global option\n if (parts.longFlag || parts.shortFlag) {\n const field = completionToField(parts);\n if (field) result.arguments!.push(field);\n }\n }\n\n // Add subcommands\n for (const sub of subcommandMap.values()) {\n if (sub.arguments!.length === 0) delete sub.arguments;\n result.subcommands!.push(sub);\n }\n\n if (result.arguments!.length === 0) delete result.arguments;\n if (result.subcommands!.length === 0) delete result.subcommands;\n\n return result;\n}\n\ninterface CompleteParts {\n command?: string;\n shortFlag?: string;\n longFlag?: string;\n description?: string;\n arguments?: string;\n condition?: string;\n requiresArg?: boolean;\n noFiles?: boolean;\n}\n\nfunction parseCompleteLine(line: string): CompleteParts | null {\n const parts: CompleteParts = {};\n\n // Extract -c <command>\n const cmdMatch = line.match(/-c\\s+(\\S+)/);\n if (cmdMatch) parts.command = cmdMatch[1];\n\n // Extract -s <short>\n const shortMatch = line.match(/-s\\s+(\\S+)/);\n if (shortMatch) parts.shortFlag = shortMatch[1];\n\n // Extract -l <long>\n const longMatch = line.match(/-l\\s+(\\S+)/);\n if (longMatch) parts.longFlag = longMatch[1];\n\n // Extract -d '<description>' or -d \"<description>\"\n const descMatch = line.match(/-d\\s+['\"]([^'\"]+)['\"]/) || line.match(/-d\\s+(\\S+)/);\n if (descMatch) parts.description = descMatch[1];\n\n // Extract -a '<arguments>'\n const argsMatch = line.match(/-a\\s+['\"]([^'\"]+)['\"]/) || line.match(/-a\\s+(\\S+)/);\n if (argsMatch) parts.arguments = argsMatch[1];\n\n // Extract -n '<condition>'\n const condMatch = line.match(/-n\\s+['\"]([^'\"]+)['\"]/) || line.match(/-n\\s+(\\S+)/);\n if (condMatch) parts.condition = condMatch[1];\n\n // -r means requires argument\n parts.requiresArg = /-r\\b/.test(line);\n // -f means no file completion\n parts.noFiles = /-f\\b/.test(line);\n\n return parts;\n}\n\nfunction completionToField(parts: CompleteParts): FieldMeta | null {\n const name = parts.longFlag ? parts.longFlag.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase()) : parts.shortFlag || '';\n\n if (!name) return null;\n\n let type: FieldMeta['type'] = parts.requiresArg ? 'string' : 'boolean';\n let enumValues: string[] | undefined;\n\n // If -a provides specific values, treat as enum\n if (parts.arguments) {\n const values = parts.arguments.split(/\\s+/).filter((v) => !v.startsWith('('));\n if (values.length > 0 && values.length <= 20) {\n enumValues = values;\n type = 'enum';\n }\n }\n\n const aliases = parts.shortFlag && parts.longFlag ? [`-${parts.shortFlag}`] : undefined;\n\n return {\n name,\n type,\n description: parts.description,\n aliases,\n enumValues,\n };\n}\n","import type { CommandMeta, FieldMeta } from '../types.ts';\n\ninterface ParseHelpOptions {\n /** Name to use for the root command if not detected from the help text */\n name?: string;\n}\n\ntype Section = 'none' | 'usage' | 'commands' | 'options' | 'arguments' | 'positional' | 'aliases' | 'skip';\n\n/**\n * Parse --help text output into CommandMeta.\n * Handles common styles: GNU coreutils, Go cobra, Python argparse, Node commander/yargs, gh CLI.\n */\nexport function parseHelpOutput(text: string, options?: ParseHelpOptions): CommandMeta {\n const lines = text.split('\\n');\n const result: CommandMeta = {\n name: options?.name || '',\n arguments: [],\n positionals: [],\n subcommands: [],\n };\n\n let section: Section = 'none';\n\n // Try to extract name from USAGE line\n // Matches: \"Usage: mycli\", \"USAGE\\n gh <command>\", \"Usage:\\n myapp deploy [flags]\"\n const usageMatch = text.match(/^[Uu](?:SAGE|sage):?\\s*(\\S+)/m) || text.match(/^USAGE\\n\\s+(\\S+)/m);\n if (usageMatch && !result.name) {\n result.name = usageMatch[1]!;\n }\n\n // Extract description from lines before first section header\n const descriptionLines: string[] = [];\n for (const line of lines) {\n const trimmed = line.trim();\n if (!trimmed) {\n if (descriptionLines.length > 0) break;\n continue;\n }\n if (isSectionHeader(trimmed)) break;\n if (descriptionLines.length === 0 || descriptionLines.length > 0) {\n descriptionLines.push(trimmed);\n }\n }\n if (descriptionLines.length > 0) {\n result.description = descriptionLines.join(' ');\n }\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n const trimmed = line.trim();\n\n if (!trimmed) continue;\n\n // Detect section headers\n const sectionType = detectSection(trimmed);\n if (sectionType) {\n section = sectionType;\n continue;\n }\n\n // Parse content based on current section\n switch (section) {\n case 'commands': {\n const cmd = parseCommandLine(line);\n if (cmd) {\n result.subcommands!.push(cmd);\n }\n break;\n }\n case 'options': {\n const field = parseOptionLine(line);\n if (field) {\n result.arguments!.push(field);\n }\n break;\n }\n case 'arguments':\n case 'positional': {\n const field = parsePositionalLine(line);\n if (field) {\n result.positionals!.push(field);\n }\n break;\n }\n case 'aliases': {\n const aliasMatch = trimmed.match(/^\\S+(?:\\s+\\S+)*$/);\n if (aliasMatch) {\n // Extract alias from lines like \"gh pr ls\" — the last word is the alias name\n const parts = trimmed.split(/\\s+/);\n if (parts.length >= 2) {\n const alias = parts[parts.length - 1]!;\n if (!result.aliases) result.aliases = [];\n result.aliases.push(alias);\n }\n }\n break;\n }\n // 'skip', 'usage', 'none' — do nothing\n }\n }\n\n // Clean up empty arrays\n if (result.arguments!.length === 0) delete result.arguments;\n if (result.positionals!.length === 0) delete result.positionals;\n if (result.subcommands!.length === 0) delete result.subcommands;\n if (result.aliases?.length === 0) delete result.aliases;\n\n return result;\n}\n\nfunction isSectionHeader(line: string): boolean {\n // \"USAGE\", \"FLAGS\", \"CORE COMMANDS\", \"Options:\", \"Available Commands:\"\n return /^[A-Z][A-Za-z\\s]*:?\\s*$/i.test(line) || /^[A-Z][A-Z\\s]+$/i.test(line);\n}\n\nfunction detectSection(line: string): Section | null {\n const lower = line.toLowerCase().replace(/:$/, '').trim();\n\n // Commands: \"commands\", \"available commands\", \"subcommands\",\n // and gh-style: \"core commands\", \"general commands\", \"additional commands\", etc.\n // Match anything ending in \"commands\" or \"subcommands\", but NOT \"alias commands\"\n if (/^(?:available\\s+)?(?:commands|subcommands)$/.test(lower)) return 'commands';\n if (/^(?:\\w+\\s+)*commands$/.test(lower) && !/alias/.test(lower)) return 'commands';\n\n // Options/Flags: \"options\", \"flags\", \"global options\", \"inherited flags\"\n if (/^(?:global\\s+|inherited\\s+)?(?:options|flags)$/.test(lower)) return 'options';\n\n // Positional arguments\n if (/^(?:positional\\s+)?(?:arguments|args|positionals)$/.test(lower)) return 'positional';\n\n // Aliases section\n if (/^alias(?:es)?(?:\\s+commands)?$/.test(lower)) return 'aliases';\n\n // Usage section\n if (lower === 'usage') return 'usage';\n\n // Sections to skip entirely\n if (/^(?:help\\s+topics|examples?|learn\\s+more|json\\s+fields|see\\s+also|notes?)$/.test(lower)) return 'skip';\n\n return null;\n}\n\nfunction parseCommandLine(line: string): CommandMeta | null {\n // Pattern: \" command-name: Description text\" (gh-style with colon)\n const colonMatch = line.match(/^\\s{2,}([\\w][\\w-]*):?\\s{2,}(.+)$/);\n if (colonMatch) {\n const name = colonMatch[1]!.replace(/:$/, '');\n return {\n name,\n description: colonMatch[2]!.trim(),\n };\n }\n\n // Pattern: \" command-name\" (no description)\n const nameOnly = line.match(/^\\s{2,}([\\w][\\w-]*):?\\s*$/);\n if (nameOnly) {\n return { name: nameOnly[1]!.replace(/:$/, '') };\n }\n\n return null;\n}\n\nfunction parseOptionLine(line: string): FieldMeta | null {\n // Try cobra-style first: \" -s, --flag type Description\" or \" --flag type Description\"\n // The type hint can be a bare word (string, int) or a complex placeholder ([HOST/]OWNER/REPO)\n // but NOT angle-bracket values like <string> (those fall through to GNU pattern)\n const cobraMatch = line.match(/^\\s{2,}(?:(-\\w),\\s+)?(-{1,2}[\\w-]+)(?:\\s+([^\\s<>]+))?\\s{2,}(.+)$/);\n\n if (cobraMatch) {\n const shortFlag = cobraMatch[1];\n const longFlag = cobraMatch[2]!;\n const typeHint = cobraMatch[3];\n const description = cobraMatch[4]?.trim();\n\n const name = normalizeOptionName(longFlag);\n const aliases = shortFlag ? [normalizeAlias(shortFlag)] : undefined;\n\n const { type, ambiguous } = resolveType(typeHint);\n\n const { defaultValue, resolvedType } = extractDefault(description, type, ambiguous);\n const { enumValues, resolvedType: finalType } = extractEnum(description, resolvedType);\n\n return reconcileField({\n name,\n type: finalType,\n description,\n required: type === 'boolean' ? undefined : true,\n aliases,\n default: defaultValue,\n enumValues,\n ambiguous: ambiguous || undefined,\n });\n }\n\n // GNU/argparse-style: \" -s, --long-name <value> Description\"\n // \" --long-name=<value> Description\"\n const gnuMatch = line.match(/^\\s{2,}(?:(-\\w),?\\s+)?(-{1,2}[\\w-]+)(?:\\s*[=\\s]\\s*(?:<([^>]+)>|\\[([^\\]]+)\\]|(\\w+)))?\\s{2,}(.+)$/);\n\n if (gnuMatch) {\n const shortFlag = gnuMatch[1];\n const longFlag = gnuMatch[2]!;\n const valueName = gnuMatch[3] || gnuMatch[4] || gnuMatch[5];\n const description = gnuMatch[6]?.trim();\n\n const name = normalizeOptionName(longFlag);\n const aliases = shortFlag ? [normalizeAlias(shortFlag)] : undefined;\n\n const { type, ambiguous } = resolveType(valueName);\n\n const { defaultValue, resolvedType } = extractDefault(description, type, ambiguous);\n const { enumValues, resolvedType: finalType } = extractEnum(description, resolvedType);\n\n // [value] means optional, <value> means required\n const required = !gnuMatch[4];\n\n return reconcileField({\n name,\n type: finalType,\n description,\n required: finalType === 'boolean' ? undefined : required,\n aliases,\n default: defaultValue,\n enumValues,\n ambiguous: ambiguous || undefined,\n });\n }\n\n // Simplest pattern: \" --name Description\"\n const simple = line.match(/^\\s{2,}(-{1,2}[\\w-]+)\\s{2,}(.+)$/);\n if (simple) {\n const name = normalizeOptionName(simple[1]!);\n return {\n name,\n type: 'boolean',\n description: simple[2]!.trim(),\n };\n }\n\n return null;\n}\n\n/**\n * Resolve a type hint string to a FieldMeta type.\n */\nfunction resolveType(hint: string | undefined): { type: FieldMeta['type']; ambiguous: boolean } {\n if (!hint) return { type: 'boolean', ambiguous: false };\n\n const lower = hint.toLowerCase();\n\n if (/^(num|number|int|integer|port|count|float|duration)$/.test(lower)) {\n return { type: 'number', ambiguous: false };\n }\n if (/^(str|string|text|name|path|file|dir|url|host|query|expression|template)$/.test(lower)) {\n return { type: 'string', ambiguous: false };\n }\n if (/^(bool|boolean)$/.test(lower)) {\n return { type: 'boolean', ambiguous: false };\n }\n if (/^(strings|fields)$/.test(lower)) {\n return { type: 'array', ambiguous: false };\n }\n\n // Unknown type hint — default to string but mark ambiguous\n return { type: 'string', ambiguous: true };\n}\n\n/**\n * Extract default value from description text.\n */\nfunction extractDefault(\n description: string | undefined,\n type: FieldMeta['type'],\n ambiguous: boolean,\n): { defaultValue: unknown; resolvedType: FieldMeta['type'] } {\n let resolvedType = type;\n let defaultValue: unknown;\n\n const defaultMatch = description?.match(/\\(default[:\\s]+([^)]+)\\)/i) || description?.match(/\\[default[:\\s]+([^\\]]+)\\]/i);\n if (defaultMatch) {\n const raw = defaultMatch[1]!.trim();\n if (raw === 'true' || raw === 'false') {\n defaultValue = raw === 'true';\n resolvedType = 'boolean';\n } else if (/^\\d+$/.test(raw)) {\n defaultValue = parseInt(raw, 10);\n if (resolvedType === 'string' && !ambiguous) resolvedType = 'number';\n } else if (/^\\d+\\.\\d+$/.test(raw)) {\n defaultValue = parseFloat(raw);\n if (resolvedType === 'string' && !ambiguous) resolvedType = 'number';\n } else {\n defaultValue = raw.replace(/^[\"']|[\"']$/g, '');\n }\n }\n\n return { defaultValue, resolvedType };\n}\n\n/**\n * Extract enum values from description text.\n */\nfunction extractEnum(\n description: string | undefined,\n type: FieldMeta['type'],\n): { enumValues: string[] | undefined; resolvedType: FieldMeta['type'] } {\n // Explicit choices: (choices: a, b, c) or (one of: a|b|c)\n const choiceMatch = description?.match(/\\((?:one of|choices?)[:\\s]+([^)]+)\\)/i);\n if (choiceMatch) {\n const values = choiceMatch[1]!.split(/[,|]/).map((v) => v.trim().replace(/^[\"']|[\"']$/g, ''));\n return { enumValues: values, resolvedType: 'enum' };\n }\n\n // Inline enum in description: {open|closed|merged|all} (gh-style)\n const inlineMatch = description?.match(/\\{(\\w+(?:\\|[\\w-]+)+)\\}/);\n if (inlineMatch) {\n const values = inlineMatch[1]!.split('|');\n return { enumValues: values, resolvedType: 'enum' };\n }\n\n return { enumValues: undefined, resolvedType: type };\n}\n\n/**\n * Fix up a parsed field for edge cases:\n * - Enum default not in the listed values → add it\n * - Default value type doesn't match declared type → reset to type default + mark ambiguous\n */\nfunction reconcileField(field: FieldMeta): FieldMeta {\n // If enum has a default that isn't in the value list, add it\n if (field.type === 'enum' && field.enumValues && field.default !== undefined) {\n const defStr = String(field.default);\n if (!field.enumValues.includes(defStr)) {\n field.enumValues = [...field.enumValues, defStr];\n }\n }\n\n // If the default value doesn't match the declared type, reset + mark ambiguous\n if (field.default !== undefined) {\n if (field.type === 'boolean' && typeof field.default !== 'boolean') {\n field.default = false;\n field.ambiguous = true;\n } else if (field.type === 'number' && typeof field.default !== 'number') {\n field.default = 0;\n field.ambiguous = true;\n }\n }\n\n return field;\n}\n\nfunction parsePositionalLine(line: string): FieldMeta | null {\n // Pattern: \" <name> Description\"\n // Pattern: \" name Description\"\n const match = line.match(/^\\s{2,}<?(\\w[\\w-]*)>?\\s{2,}(.+)$/);\n if (!match) return null;\n\n return {\n name: match[1]!,\n type: 'string',\n description: match[2]!.trim(),\n positional: true,\n ambiguous: true,\n };\n}\n\n/**\n * Strip leading dashes from a flag name, preserving kebab-case.\n */\nfunction normalizeOptionName(flag: string): string {\n return flag.replace(/^-+/, '');\n}\n\n/**\n * Strip leading dash from a short alias flag (e.g. '-v' → 'v').\n */\nfunction normalizeAlias(alias: string): string {\n return alias.replace(/^-/, '');\n}\n","import type { CommandMeta, FieldMeta } from '../types.ts';\n\n/**\n * Deep-merge multiple CommandMeta from different sources.\n * Deduplicates fields, resolves conflicts, and combines subcommands.\n *\n * Later sources take precedence for descriptions and types,\n * unless the earlier source was more specific (non-ambiguous).\n */\nexport function mergeCommandMeta(...sources: CommandMeta[]): CommandMeta {\n if (sources.length === 0) {\n return { name: '' };\n }\n\n if (sources.length === 1) {\n return sources[0]!;\n }\n\n const result: CommandMeta = { name: '' };\n\n for (const source of sources) {\n // Name: first non-empty wins\n if (source.name && !result.name) {\n result.name = source.name;\n }\n\n // Description: last non-empty wins\n if (source.description) {\n result.description = source.description;\n }\n\n // Aliases: merge and deduplicate\n if (source.aliases) {\n result.aliases = [...new Set([...(result.aliases || []), ...source.aliases])];\n }\n\n // Examples: merge and deduplicate\n if (source.examples) {\n result.examples = [...new Set([...(result.examples || []), ...source.examples])];\n }\n\n // Deprecated: last truthy wins\n if (source.deprecated !== undefined) {\n result.deprecated = source.deprecated;\n }\n\n // Arguments: merge by name\n if (source.arguments) {\n result.arguments = mergeFields(result.arguments || [], source.arguments);\n }\n\n // Positionals: merge by name\n if (source.positionals) {\n result.positionals = mergeFields(result.positionals || [], source.positionals);\n }\n\n // Subcommands: merge recursively by name\n if (source.subcommands) {\n result.subcommands = mergeSubcommands(result.subcommands || [], source.subcommands);\n }\n }\n\n // Clean up empty arrays\n if (result.aliases?.length === 0) delete result.aliases;\n if (result.examples?.length === 0) delete result.examples;\n if (result.arguments?.length === 0) delete result.arguments;\n if (result.positionals?.length === 0) delete result.positionals;\n if (result.subcommands?.length === 0) delete result.subcommands;\n\n return result;\n}\n\n/**\n * Merge two arrays of FieldMeta by name.\n * Later fields take precedence unless earlier was non-ambiguous.\n */\nfunction mergeFields(existing: FieldMeta[], incoming: FieldMeta[]): FieldMeta[] {\n const map = new Map<string, FieldMeta>();\n\n for (const field of existing) {\n map.set(field.name, { ...field });\n }\n\n for (const field of incoming) {\n const prev = map.get(field.name);\n if (!prev) {\n map.set(field.name, { ...field });\n continue;\n }\n\n // Merge the fields\n const merged: FieldMeta = { ...prev };\n\n // Type: prefer non-ambiguous source\n if (field.type !== 'unknown') {\n if (prev.ambiguous || !field.ambiguous) {\n merged.type = field.type;\n merged.ambiguous = field.ambiguous;\n }\n }\n\n // Description: last non-empty wins\n if (field.description) {\n merged.description = field.description;\n }\n\n // Default: last non-undefined wins\n if (field.default !== undefined) {\n merged.default = field.default;\n }\n\n // Required: last defined wins\n if (field.required !== undefined) {\n merged.required = field.required;\n }\n\n // Aliases: merge and deduplicate\n if (field.aliases) {\n merged.aliases = [...new Set([...(prev.aliases || []), ...field.aliases])];\n }\n\n // Enum values: merge and deduplicate\n if (field.enumValues) {\n merged.enumValues = [...new Set([...(prev.enumValues || []), ...field.enumValues])];\n }\n\n // Items: last non-empty wins\n if (field.items) {\n merged.items = field.items;\n }\n\n map.set(field.name, merged);\n }\n\n return [...map.values()];\n}\n\n/**\n * Merge two arrays of CommandMeta by name, recursively.\n */\nfunction mergeSubcommands(existing: CommandMeta[], incoming: CommandMeta[]): CommandMeta[] {\n const map = new Map<string, CommandMeta>();\n\n for (const cmd of existing) {\n map.set(cmd.name, cmd);\n }\n\n for (const cmd of incoming) {\n const prev = map.get(cmd.name);\n if (!prev) {\n map.set(cmd.name, cmd);\n } else {\n map.set(cmd.name, mergeCommandMeta(prev, cmd));\n }\n }\n\n return [...map.values()];\n}\n","import type { CommandMeta, FieldMeta } from '../types.ts';\n\n/**\n * Parse zsh completion function definitions into CommandMeta.\n *\n * Zsh completions typically use _arguments or compadd:\n * _arguments \\\n * '-v[verbose mode]' \\\n * '--output=[output file]:filename:_files' \\\n * '1:command:(start stop restart)'\n */\nexport function parseZshCompletions(text: string): CommandMeta {\n const result: CommandMeta = {\n name: '',\n arguments: [],\n positionals: [],\n subcommands: [],\n };\n\n // Try to detect command name from function name: _command() or #compdef command\n const compdefMatch = text.match(/#compdef\\s+(\\S+)/);\n if (compdefMatch) {\n result.name = compdefMatch[1]!;\n } else {\n const funcMatch = text.match(/^_(\\w+)\\s*\\(\\)/m);\n if (funcMatch) {\n result.name = funcMatch[1]!;\n }\n }\n\n // Find _arguments blocks\n const argumentsBlocks = findArgumentsBlocks(text);\n\n for (const block of argumentsBlocks) {\n const specs = parseArgumentSpecs(block);\n for (const spec of specs) {\n if (spec.positional) {\n result.positionals!.push(spec);\n } else {\n result.arguments!.push(spec);\n }\n }\n }\n\n // Find subcommand definitions from case statements or _describe\n const subcommands = findSubcommands(text);\n result.subcommands!.push(...subcommands);\n\n if (result.arguments!.length === 0) delete result.arguments;\n if (result.positionals!.length === 0) delete result.positionals;\n if (result.subcommands!.length === 0) delete result.subcommands;\n\n return result;\n}\n\n/**\n * Extract _arguments blocks from zsh completion text.\n * Handles backslash continuation lines.\n */\nfunction findArgumentsBlocks(text: string): string[] {\n const blocks: string[] = [];\n\n // Join continuation lines\n const joined = text.replace(/\\\\\\n\\s*/g, ' ');\n const lines = joined.split('\\n');\n\n for (const line of lines) {\n const match = line.match(/_arguments\\s+(.+)/);\n if (match) {\n blocks.push(match[1]!);\n }\n }\n\n return blocks;\n}\n\n/**\n * Parse individual argument specs from an _arguments line.\n */\nfunction parseArgumentSpecs(block: string): FieldMeta[] {\n const results: FieldMeta[] = [];\n\n // Split into individual specs (quoted strings)\n const specs = extractQuotedStrings(block);\n\n for (const spec of specs) {\n const field = parseZshSpec(spec);\n if (field) results.push(field);\n }\n\n return results;\n}\n\n/**\n * Extract single-quoted strings from an _arguments block.\n */\nfunction extractQuotedStrings(text: string): string[] {\n const strings: string[] = [];\n const regex = /'([^']+)'/g;\n let match: RegExpExecArray | null;\n\n while ((match = regex.exec(text)) !== null) {\n strings.push(match[1]!);\n }\n\n return strings;\n}\n\n/**\n * Parse a single zsh argument spec.\n *\n * Formats:\n * '-v[verbose mode]' → boolean flag\n * '--output=[output file]:filename:_files' → string with value\n * '(-v --verbose)'{-v,--verbose}'[verbose mode]' → flag with aliases\n * '*--flag[repeatable]' → array\n * '1:command:(start stop restart)' → positional enum\n * ':filename:_files' → positional\n */\nfunction parseZshSpec(spec: string): FieldMeta | null {\n // Positional argument: 'N:description:action' or ':description:action'\n const positionalMatch = spec.match(/^(\\d+)?:([^:]*):(.*)$/);\n if (positionalMatch) {\n const description = positionalMatch[2] || undefined;\n\n // Check for enum values in (val1 val2 val3)\n const enumMatch = positionalMatch[3]?.match(/^\\(([^)]+)\\)$/);\n if (enumMatch) {\n const values = enumMatch[1]!.split(/\\s+/);\n return {\n name: description?.toLowerCase().replace(/\\s+/g, '_') || `arg${positionalMatch[1] || '0'}`,\n type: 'enum',\n enumValues: values,\n description,\n positional: true,\n };\n }\n\n return {\n name: description?.toLowerCase().replace(/\\s+/g, '_') || `arg${positionalMatch[1] || '0'}`,\n type: 'string',\n description,\n positional: true,\n ambiguous: true,\n };\n }\n\n // Flag argument\n const repeatable = spec.startsWith('*');\n const flagSpec = repeatable ? spec.slice(1) : spec;\n\n // Extract flag name and description\n // Pattern: --flag=[description]:value_description:action\n // Pattern: -f[description]\n const flagMatch = flagSpec.match(/^(-{1,2}[\\w-]+)(?:=?)(?:\\[([^\\]]*)\\])?(?::([^:]*):?(.*))?$/);\n if (!flagMatch) return null;\n\n const rawName = flagMatch[1]!;\n const description = flagMatch[2] || undefined;\n const valueName = flagMatch[3] || undefined;\n\n const name = rawName.replace(/^-+/, '').replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n const hasValue = rawName.includes('=') || !!valueName;\n let type: FieldMeta['type'] = hasValue ? 'string' : 'boolean';\n\n if (repeatable) type = 'array';\n\n // Check for enum values\n let enumValues: string[] | undefined;\n if (flagMatch[4]) {\n const enumMatch = flagMatch[4].match(/^\\(([^)]+)\\)$/);\n if (enumMatch) {\n enumValues = enumMatch[1]!.split(/\\s+/);\n type = 'enum';\n }\n }\n\n return {\n name,\n type,\n description,\n enumValues,\n };\n}\n\n/**\n * Find subcommand definitions from _describe calls or case statements.\n */\nfunction findSubcommands(text: string): CommandMeta[] {\n const subcommands: CommandMeta[] = [];\n const seen = new Set<string>();\n\n // Look for _describe patterns: _describe 'command' commands\n // where commands is an array like: ('start:start the service' 'stop:stop the service')\n const describeRegex = /\\(([^)]+)\\)/g;\n const joined = text.replace(/\\\\\\n\\s*/g, ' ');\n\n // Look for arrays of 'name:description' patterns near _describe\n let match: RegExpExecArray | null;\n while ((match = describeRegex.exec(joined)) !== null) {\n const content = match[1]!;\n const entries = content.match(/'([^']+)'/g) || content.match(/\"([^\"]+)\"/g);\n if (!entries) continue;\n\n for (const entry of entries) {\n const clean = entry.replace(/^['\"]|['\"]$/g, '');\n const parts = clean.split(':');\n if (parts.length >= 2 && /^[\\w-]+$/.test(parts[0]!)) {\n const name = parts[0]!;\n if (seen.has(name)) continue;\n seen.add(name);\n subcommands.push({\n name,\n description: parts.slice(1).join(':'),\n });\n }\n }\n }\n\n return subcommands;\n}\n","import { parseFishCompletions } from './parsers/fish.ts';\nimport { parseHelpOutput } from './parsers/help.ts';\nimport { mergeCommandMeta } from './parsers/merge.ts';\nimport { parseZshCompletions } from './parsers/zsh.ts';\nimport type { CommandMeta, GeneratorLogger } from './types.ts';\n\nexport type DiscoverySource = 'help' | 'fish' | 'zsh';\n\nexport interface DiscoveryOptions {\n /** The command to discover (e.g. 'gh', 'docker', 'kubectl'). */\n command: string;\n /** Which parsing sources to use. Default: ['help'] */\n sources?: DiscoverySource[];\n /** Max subcommand depth. 0 = root only, undefined = unlimited. */\n depth?: number;\n /** Delay in ms between help invocations. Default: 50 */\n delay?: number;\n /** Logger for progress reporting. */\n log?: GeneratorLogger;\n /** Timeout per help invocation in ms. Default: 10000 */\n timeout?: number;\n}\n\nexport interface DiscoveryResult {\n /** The discovered command tree. */\n command: CommandMeta;\n /** Number of help invocations made. */\n invocations: number;\n /** Errors encountered (non-fatal). */\n warnings: string[];\n}\n\n/**\n * Discover CLI structure by running --help recursively and optionally\n * parsing shell completion scripts.\n */\nexport async function discoverCli(options: DiscoveryOptions): Promise<DiscoveryResult> {\n const { command, sources = ['help'], depth, delay = 50, log, timeout = 10000 } = options;\n\n const warnings: string[] = [];\n let invocations = 0;\n\n const results: CommandMeta[] = [];\n\n // Source 1: --help recursive crawl\n if (sources.includes('help')) {\n log?.info(`Discovering ${command} via --help...`);\n const helpResult = await crawlHelp(command, [], {\n depth,\n delay,\n timeout,\n log,\n onInvocation: () => {\n invocations++;\n },\n onWarning: (msg) => {\n warnings.push(msg);\n },\n });\n results.push(helpResult);\n }\n\n // Source 2: Fish completions\n if (sources.includes('fish')) {\n log?.info(`Parsing fish completions for ${command}...`);\n const fishText = await getCompletionScript(command, 'fish', timeout);\n if (fishText) {\n results.push(parseFishCompletions(fishText));\n } else {\n warnings.push('Could not obtain fish completion script');\n }\n }\n\n // Source 3: Zsh completions\n if (sources.includes('zsh')) {\n log?.info(`Parsing zsh completions for ${command}...`);\n const zshText = await getCompletionScript(command, 'zsh', timeout);\n if (zshText) {\n results.push(parseZshCompletions(zshText));\n } else {\n warnings.push('Could not obtain zsh completion script');\n }\n }\n\n const merged = results.length > 0 ? mergeCommandMeta(...results) : { name: command };\n\n // Ensure the root has the correct name\n if (!merged.name) merged.name = command;\n\n return { command: merged, invocations, warnings };\n}\n\ninterface CrawlOptions {\n depth?: number;\n delay: number;\n timeout: number;\n log?: GeneratorLogger;\n onInvocation: () => void;\n onWarning: (msg: string) => void;\n}\n\n/**\n * Breadth-first crawl of --help output.\n */\nasync function crawlHelp(command: string, prefixArgs: string[], options: CrawlOptions): Promise<CommandMeta> {\n const fullCmd = [command, ...prefixArgs].join(' ');\n\n options.onInvocation();\n const helpText = await runHelp(command, prefixArgs, options.timeout);\n\n if (!helpText) {\n options.onWarning(`No help output from: ${fullCmd} --help`);\n return { name: prefixArgs[prefixArgs.length - 1] || command };\n }\n\n const name = prefixArgs[prefixArgs.length - 1] || command;\n const parsed = parseHelpOutput(helpText, { name });\n\n options.log?.info(` ${fullCmd}: ${parsed.subcommands?.length || 0} subcommands, ${parsed.arguments?.length || 0} options`);\n\n // Recurse into subcommands breadth-first\n const currentDepth = prefixArgs.length;\n if (parsed.subcommands && parsed.subcommands.length > 0 && (options.depth === undefined || currentDepth < options.depth)) {\n const resolvedSubs: CommandMeta[] = [];\n\n for (const sub of parsed.subcommands) {\n if (options.delay > 0) {\n await sleep(options.delay);\n }\n const resolved = await crawlHelp(command, [...prefixArgs, sub.name], options);\n // Preserve description from parent's subcommand list if child didn't have one\n if (!resolved.description && sub.description) {\n resolved.description = sub.description;\n }\n resolvedSubs.push(resolved);\n }\n\n parsed.subcommands = resolvedSubs;\n }\n\n return parsed;\n}\n\n/**\n * Run `<cmd> --help` or `<cmd> help` and return combined stdout+stderr.\n */\nasync function runHelp(command: string, args: string[], timeout: number): Promise<string | null> {\n // Try --help first\n let result = await runCommand(command, [...args, '--help'], timeout);\n if (result) return result;\n\n // Some CLIs use `help <cmd>` instead\n if (args.length > 0) {\n result = await runCommand(command, ['help', ...args], timeout);\n if (result) return result;\n }\n\n return null;\n}\n\n/**\n * Run a command and return its combined output, or null on failure.\n */\nasync function runCommand(command: string, args: string[], timeout: number): Promise<string | null> {\n try {\n const proc = Bun.spawn([command, ...args], {\n stdout: 'pipe',\n stderr: 'pipe',\n stdin: 'ignore',\n });\n\n const timer = setTimeout(() => proc.kill(), timeout);\n\n const [_exitCode, stdoutBuf, stderrBuf] = await Promise.all([\n proc.exited,\n new Response(proc.stdout).arrayBuffer(),\n new Response(proc.stderr).arrayBuffer(),\n ]);\n\n clearTimeout(timer);\n\n const stdout = new TextDecoder().decode(stdoutBuf).trim();\n const stderr = new TextDecoder().decode(stderrBuf).trim();\n\n // Some CLIs output help to stderr, some exit non-zero on --help\n const combined = stdout || stderr;\n if (!combined) return null;\n\n // Basic sanity check: help text usually has some structure\n if (combined.length < 10) return null;\n\n return combined;\n } catch {\n return null;\n }\n}\n\n/**\n * Try to get a shell completion script for a command.\n * Checks both `<cmd> completion <shell>` and well-known file paths.\n */\nasync function getCompletionScript(command: string, shell: 'fish' | 'zsh', timeout: number): Promise<string | null> {\n // Try `<cmd> completion <shell>`\n const completionArgs = ['completion', shell];\n let result = await runCommand(command, completionArgs, timeout);\n if (result) return result;\n\n // Try `<cmd> completions <shell>`\n result = await runCommand(command, ['completions', shell], timeout);\n if (result) return result;\n\n // Try reading from well-known paths\n const paths =\n shell === 'fish'\n ? [`/usr/share/fish/vendor_completions.d/${command}.fish`, `/usr/local/share/fish/vendor_completions.d/${command}.fish`]\n : [`/usr/share/zsh/site-functions/_${command}`, `/usr/local/share/zsh/site-functions/_${command}`];\n\n for (const path of paths) {\n try {\n const file = Bun.file(path);\n if (await file.exists()) {\n return await file.text();\n }\n } catch {}\n }\n\n return null;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport type { CodeBuildResult, EmitResult, FileEmitter, FileEmitterOptions } from './types.ts';\n\ninterface QueuedFile {\n path: string;\n content: string;\n}\n\nclass FileEmitterImpl implements FileEmitter {\n private files: QueuedFile[] = [];\n private options: FileEmitterOptions;\n\n constructor(options: FileEmitterOptions) {\n this.options = options;\n }\n\n addFile(path: string, content: string | CodeBuildResult): void {\n const text = typeof content === 'string' ? content : content.text;\n const fullContent = this.options.header ? `${this.options.header}\\n\\n${text}` : text;\n\n this.files.push({ path, content: fullContent });\n }\n\n async emit(): Promise<EmitResult> {\n const result: EmitResult = {\n written: [],\n skipped: [],\n errors: [],\n };\n\n const outDir = resolve(this.options.outDir);\n\n for (const file of this.files) {\n const fullPath = join(outDir, file.path);\n\n try {\n // Check if file already exists\n if (existsSync(fullPath) && !this.options.overwrite) {\n result.skipped.push(file.path);\n continue;\n }\n\n if (this.options.dryRun) {\n result.written.push(file.path);\n continue;\n }\n\n // Ensure directory exists\n const dir = dirname(fullPath);\n mkdirSync(dir, { recursive: true });\n\n // Write the file\n writeFileSync(fullPath, file.content, 'utf-8');\n result.written.push(file.path);\n } catch (err) {\n result.errors.push({\n file: file.path,\n error: err instanceof Error ? err : new Error(String(err)),\n });\n }\n }\n\n return result;\n }\n}\n\n/**\n * Create a FileEmitter for writing multiple generated files to disk.\n */\nexport function createFileEmitter(options: FileEmitterOptions): FileEmitter {\n return new FileEmitterImpl(options);\n}\n","import type { CodeBuilder, GeneratorContext } from '../types.ts';\n\n/**\n * Generate an index.ts barrel file that re-exports all given files.\n */\nexport function generateBarrelFile(files: string[], ctx: GeneratorContext): CodeBuilder {\n const code = ctx.createCodeBuilder();\n\n for (const file of files) {\n // Strip .ts extension for the import path and ensure relative path\n const importPath = file.startsWith('./') ? file : `./${file}`;\n code.line(`export * from '${importPath}'`);\n }\n\n return code;\n}\n","import type { StandardSchemaV1 } from '@standard-schema/spec';\nimport type { FieldMeta } from './types.ts';\n\ninterface SchemaToCodeResult {\n /** The generated Zod source code */\n code: string;\n /** Imports needed (e.g. ['z']) */\n imports: string[];\n}\n\n/**\n * Convert a JSON Schema property to Zod code.\n */\nfunction jsonSchemaPropertyToZod(prop: Record<string, any>, required: boolean, ambiguous?: boolean): string {\n let code: string;\n\n const type = prop.type as string | undefined;\n const enumValues = prop.enum as unknown[] | undefined;\n\n if (enumValues && enumValues.length > 0) {\n const values = enumValues.map((v) => JSON.stringify(v)).join(', ');\n code = `z.enum([${values}])`;\n } else if (type === 'string') {\n code = 'z.string()';\n } else if (type === 'number' || type === 'integer') {\n code = 'z.number()';\n } else if (type === 'boolean') {\n code = 'z.boolean()';\n } else if (type === 'array') {\n const items = prop.items as Record<string, any> | undefined;\n const itemCode = items ? jsonSchemaPropertyToZod(items, true) : 'z.unknown()';\n code = `${itemCode}.array()`;\n } else {\n code = 'z.unknown()';\n }\n\n if (prop.default !== undefined) {\n code += `.default(${JSON.stringify(prop.default)})`;\n } else if (!required) {\n code += '.optional()';\n }\n\n if (prop.description) {\n code += `.describe(${JSON.stringify(prop.description)})`;\n }\n\n if (ambiguous) {\n code += ' /* TODO: verify type */';\n }\n\n return code;\n}\n\n/**\n * Generate Zod source code from a Standard Schema instance by introspecting\n * its `~standard.jsonSchema` interface.\n */\nexport function schemaToCode(schema: StandardSchemaV1): SchemaToCodeResult {\n try {\n const jsonSchema = (schema as any)['~standard'].jsonSchema.input({ target: 'draft-2020-12' }) as Record<string, any>;\n return jsonSchemaToCode(jsonSchema);\n } catch {\n return { code: 'z.unknown()', imports: ['z'] };\n }\n}\n\nfunction jsonSchemaToCode(jsonSchema: Record<string, any>): SchemaToCodeResult {\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n const properties = jsonSchema.properties as Record<string, any>;\n const required = new Set((jsonSchema.required as string[]) || []);\n\n const entries = Object.entries(properties).map(([key, prop]) => {\n const isRequired = required.has(key);\n const zodCode = jsonSchemaPropertyToZod(prop as Record<string, any>, isRequired);\n return ` ${key}: ${zodCode},`;\n });\n\n const code = `z.object({\\n${entries.join('\\n')}\\n})`;\n return { code, imports: ['z'] };\n }\n\n // Fallback for non-object schemas\n const code = jsonSchemaPropertyToZod(jsonSchema, true);\n return { code, imports: ['z'] };\n}\n\n/**\n * Build a real Zod schema from FieldMeta objects.\n * Returns the schema as Zod source code, since we can't dynamically import Zod here\n * (codegen has no runtime dependency on padrone's main entry point).\n */\nexport function fieldMetaToCode(fields: FieldMeta[]): SchemaToCodeResult {\n const entries = fields.map((field) => {\n let code: string;\n\n switch (field.type) {\n case 'string':\n code = 'z.string()';\n break;\n case 'number':\n code = 'z.number()';\n break;\n case 'boolean':\n code = 'z.boolean()';\n break;\n case 'array': {\n const itemType = field.items || 'string';\n const itemCode = itemType === 'number' ? 'z.number()' : 'z.string()';\n code = `${itemCode}.array()`;\n break;\n }\n case 'enum':\n if (field.enumValues && field.enumValues.length > 0) {\n const values = field.enumValues.map((v) => JSON.stringify(v)).join(', ');\n code = `z.enum([${values}])`;\n } else {\n code = 'z.string()';\n }\n break;\n default:\n code = 'z.unknown()';\n break;\n }\n\n if (field.default !== undefined) {\n code += `.default(${JSON.stringify(field.default)})`;\n } else if (!field.required) {\n code += '.optional()';\n }\n\n if (field.description) {\n code += `.describe(${JSON.stringify(field.description)})`;\n }\n\n if (field.ambiguous) {\n code += ' /* TODO: verify type */';\n }\n\n const key = needsQuoting(field.name) ? JSON.stringify(field.name) : field.name;\n return ` ${key}: ${code},`;\n });\n\n const code = `z.object({\\n${entries.join('\\n')}\\n})`;\n return { code, imports: ['z'] };\n}\n\nconst JS_RESERVED = new Set([\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'export',\n 'extends',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'import',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'super',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'yield',\n 'class',\n 'const',\n 'enum',\n 'let',\n 'static',\n 'implements',\n 'interface',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'await',\n 'async',\n]);\n\n/** Returns true if the name needs quoting to be a valid JS object key. */\nfunction needsQuoting(name: string): boolean {\n if (JS_RESERVED.has(name)) return true;\n // Must be a valid identifier: starts with letter/$/_, contains only word chars\n return !/^[a-zA-Z_$][\\w$]*$/.test(name);\n}\n","import { fieldMetaToCode } from '../schema-to-code.ts';\nimport type { CodeBuilder, CommandMeta, FieldMeta, GeneratorContext } from '../types.ts';\n\nconst JS_RESERVED = new Set([\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'export',\n 'extends',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'import',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'super',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'yield',\n 'class',\n 'const',\n 'enum',\n 'let',\n 'static',\n 'implements',\n 'interface',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'await',\n 'async',\n]);\n\n/** Convert a command name to a safe JS identifier (camelCase, reserved-word-safe). */\nexport function toSafeIdentifier(name: string): string {\n const camel = name.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());\n if (/^\\d/.test(camel)) return `_${camel}`;\n if (JS_RESERVED.has(camel)) return `_${camel}`;\n return camel;\n}\n\n/** Build the exported function name for a command (e.g. 'repo' → 'repoCommand'). */\nexport function toCommandFunctionName(name: string): string {\n return `${toSafeIdentifier(name)}Command`;\n}\n\nexport interface CommandFileOptions {\n /** Wrap config: generates .wrap() instead of .action(). */\n wrap?: {\n /** The external command to wrap (e.g. 'gh'). */\n command: string;\n /** Fixed args preceding the options (e.g. ['pr', 'list']). */\n args?: string[];\n };\n /** Subcommand references to wire into this command via .command() calls. */\n subcommands?: { name: string; varName: string; importPath: string; aliases?: string[] }[];\n}\n\n/**\n * Generate a single Padrone command file from a CommandMeta.\n * Produces a named function that chains .configure(), .arguments(), and .wrap() or .action().\n */\nexport function generateCommandFile(command: CommandMeta, ctx: GeneratorContext, options?: CommandFileOptions): CodeBuilder {\n const code = ctx.createCodeBuilder();\n\n const hasArgs = (command.arguments && command.arguments.length > 0) || (command.positionals && command.positionals.length > 0);\n\n if (hasArgs) {\n code.import('z', 'zod/v4');\n }\n\n code.importType('AnyPadroneBuilder', 'padrone');\n\n // Import subcommand modules\n if (options?.subcommands) {\n for (const sub of options.subcommands) {\n code.import([sub.varName], sub.importPath);\n }\n }\n\n code.line();\n\n if (command.deprecated) {\n const msg = typeof command.deprecated === 'string' ? command.deprecated : 'This command is deprecated';\n code.comment(`@deprecated ${msg}`);\n }\n\n const fnName = toCommandFunctionName(command.name);\n code.line(`export function ${fnName}<T extends AnyPadroneBuilder>(cmd: T) {`);\n code.line(` return cmd`);\n\n // .configure()\n const configParts: string[] = [];\n if (command.description) {\n configParts.push(`description: ${JSON.stringify(command.description)}`);\n }\n if (command.deprecated) {\n configParts.push(`deprecated: ${typeof command.deprecated === 'string' ? JSON.stringify(command.deprecated) : 'true'}`);\n }\n if (configParts.length > 0) {\n code.line(` .configure({ ${configParts.join(', ')} })`);\n }\n\n // .arguments()\n if (hasArgs) {\n const allFields = [...(command.arguments || []), ...(command.positionals || [])];\n const schemaCode = fieldMetaToCode(allFields);\n\n const positionalNames = (command.positionals || []).map((p) => (p.type === 'array' ? `'...${p.name}'` : `'${p.name}'`));\n const fieldsMap = buildFieldsMap(allFields);\n const hasMetaOptions = positionalNames.length > 0 || fieldsMap;\n\n if (hasMetaOptions) {\n code.line(` .arguments(${schemaCode.code}, {`);\n if (positionalNames.length > 0) {\n code.line(` positional: [${positionalNames.join(', ')}],`);\n }\n if (fieldsMap) {\n code.line(` fields: ${fieldsMap},`);\n }\n code.line(` })`);\n } else {\n code.line(` .arguments(${schemaCode.code})`);\n }\n }\n\n // .command() calls for subcommands\n if (options?.subcommands) {\n for (const sub of options.subcommands) {\n const nameArg =\n sub.aliases && sub.aliases.length > 0\n ? `[${JSON.stringify(sub.name)}, ${sub.aliases.map((a) => JSON.stringify(a)).join(', ')}]`\n : JSON.stringify(sub.name);\n code.line(` .command(${nameArg}, ${sub.varName})`);\n }\n }\n\n // .wrap() or .action()\n if (options?.wrap) {\n const wrapParts: string[] = [];\n wrapParts.push(`command: ${JSON.stringify(options.wrap.command)}`);\n if (options.wrap.args && options.wrap.args.length > 0) {\n wrapParts.push(`args: [${options.wrap.args.map((a) => JSON.stringify(a)).join(', ')}]`);\n }\n code.line(` .wrap({ ${wrapParts.join(', ')} })`);\n } else {\n code.line(` .action((args) => { /* TODO */ })`);\n }\n\n code.line(`}`);\n\n return code;\n}\n\nfunction buildFieldsMap(fields: FieldMeta[]): string | null {\n const entries: string[] = [];\n for (const field of fields) {\n if (field.aliases && field.aliases.length > 0) {\n // Split into flags (single-char) and aliases (multi-char)\n const singleChar = field.aliases.filter((a) => a.replace(/^-+/, '').length === 1).map((a) => a.replace(/^-+/, ''));\n const multiChar = field.aliases.filter((a) => a.replace(/^-+/, '').length > 1).map((a) => a.replace(/^-+/, ''));\n\n const key = /^[a-zA-Z_$][\\w$]*$/.test(field.name) ? field.name : JSON.stringify(field.name);\n const parts: string[] = [];\n if (singleChar.length > 0) {\n const flags = singleChar.length === 1 ? JSON.stringify(singleChar[0]) : `[${singleChar.map((a) => JSON.stringify(a)).join(', ')}]`;\n parts.push(`flags: ${flags}`);\n }\n if (multiChar.length > 0) {\n const alias = multiChar.length === 1 ? JSON.stringify(multiChar[0]) : `[${multiChar.map((a) => JSON.stringify(a)).join(', ')}]`;\n parts.push(`alias: ${alias}`);\n }\n if (parts.length > 0) {\n entries.push(`${key}: { ${parts.join(', ')} }`);\n }\n }\n }\n if (entries.length === 0) return null;\n return `{ ${entries.join(', ')} }`;\n}\n","import { fieldMetaToCode } from '../schema-to-code.ts';\nimport type { CommandMeta, GeneratorContext } from '../types.ts';\nimport type { CommandFileOptions } from './command-file.ts';\nimport { generateCommandFile, toCommandFunctionName } from './command-file.ts';\n\nexport interface CommandTreeOptions {\n /** When set, generates .wrap() calls instead of .action(). */\n wrap?: {\n /** The external command being wrapped (e.g. 'gh'). */\n command: string;\n };\n}\n\n/**\n * Walk a CommandMeta tree and emit one file per command plus a root program file.\n * Maps nested subcommands to a directory structure.\n */\nexport function generateCommandTree(root: CommandMeta, ctx: GeneratorContext, options?: CommandTreeOptions): void {\n const rootImports: { name: string; varName: string; path: string; aliases?: string[] }[] = [];\n\n // Recursively generate command files (depth-first so children exist before parents)\n function walkCommands(cmd: CommandMeta, dirPath: string, parentArgs: string[]): void {\n if (cmd === root) {\n for (const sub of cmd.subcommands || []) {\n walkCommands(sub, 'commands', []);\n }\n return;\n }\n\n const filePath = `${dirPath}/${cmd.name}.ts`;\n\n // Recurse into subcommands first so we can reference them\n const childRefs: { name: string; varName: string; importPath: string; aliases?: string[] }[] = [];\n if (cmd.subcommands && cmd.subcommands.length > 0) {\n for (const sub of cmd.subcommands) {\n walkCommands(sub, `${dirPath}/${cmd.name}`, [...parentArgs, cmd.name]);\n childRefs.push({\n name: sub.name,\n varName: toCommandFunctionName(sub.name),\n importPath: `./${cmd.name}/${sub.name}.ts`,\n aliases: sub.aliases,\n });\n }\n }\n\n const fileOptions: CommandFileOptions = {};\n if (options?.wrap) {\n fileOptions.wrap = { command: options.wrap.command, args: [...parentArgs, cmd.name] };\n }\n if (childRefs.length > 0) {\n fileOptions.subcommands = childRefs;\n }\n\n const code = generateCommandFile(cmd, ctx, Object.keys(fileOptions).length > 0 ? fileOptions : undefined);\n ctx.emitter.addFile(filePath, code.build());\n\n rootImports.push({\n name: cmd.name,\n varName: toCommandFunctionName(cmd.name),\n path: `./${filePath.replace(/\\.ts$/, '.ts')}`,\n aliases: cmd.aliases,\n });\n }\n\n walkCommands(root, '', []);\n\n // Generate root program.ts\n const program = ctx.createCodeBuilder();\n\n const rootHasArgs = (root.arguments && root.arguments.length > 0) || (root.positionals && root.positionals.length > 0);\n if (rootHasArgs) {\n program.import('z', 'zod/v4');\n }\n program.import(['createPadrone'], 'padrone');\n\n // Only import direct children of root\n const directChildren = rootImports.filter((imp) => imp.path.split('/').length <= 3);\n for (const imp of directChildren) {\n program.import([imp.varName], imp.path);\n }\n\n program.line();\n program.line(`const program = createPadrone(${JSON.stringify(root.name)})`);\n\n // .configure()\n const configParts: string[] = [];\n if (root.description) {\n configParts.push(`description: ${JSON.stringify(root.description)}`);\n }\n if (configParts.length > 0) {\n program.line(` .configure({ ${configParts.join(', ')} })`);\n }\n\n // Root arguments (for programs that have options at the root level)\n if (rootHasArgs) {\n const allFields = [...(root.arguments || []), ...(root.positionals || [])];\n const schemaCode = fieldMetaToCode(allFields);\n program.line(` .arguments(${schemaCode.code})`);\n }\n\n // Chain .command() calls for direct children\n for (const imp of directChildren) {\n const nameArg =\n imp.aliases && imp.aliases.length > 0\n ? `[${JSON.stringify(imp.name)}, ${imp.aliases.map((a) => JSON.stringify(a)).join(', ')}]`\n : JSON.stringify(imp.name);\n program.line(` .command(${nameArg}, ${imp.varName})`);\n }\n\n // If root has no subcommands, add .wrap() or .action()\n if (directChildren.length === 0 && options?.wrap) {\n program.line(` .wrap({ command: ${JSON.stringify(options.wrap.command)} })`);\n }\n\n program.line();\n program.line(`export default program`);\n\n ctx.emitter.addFile('program.ts', program.build());\n\n // Generate index.ts\n const index = ctx.createCodeBuilder();\n index.line(`export { default } from './program.ts'`);\n ctx.emitter.addFile('index.ts', index.build());\n}\n","/**\n * Lightweight string template engine.\n *\n * Syntax:\n * - `{{var}}` — interpolation\n * - `{{#arr}}...{{/arr}}` — iteration (`.` refers to current item)\n * - `{{#bool}}...{{/bool}}` — conditional blocks\n * - `{{>partial}}` — include a named sub-template\n */\n\ntype TemplateRenderer = (data: Record<string, unknown>, partials?: Record<string, string>) => string;\n\n/**\n * Compile a template string into a reusable render function.\n */\nexport function template(text: string): TemplateRenderer {\n return (data: Record<string, unknown>, partials?: Record<string, string>) => {\n return render(text, data, partials);\n };\n}\n\nfunction render(text: string, data: Record<string, unknown>, partials?: Record<string, string>): string {\n let result = text;\n\n // Process block sections: {{#key}}...{{/key}}\n result = result.replace(/\\{\\{#(\\w+)\\}\\}([\\s\\S]*?)\\{\\{\\/\\1\\}\\}/g, (_match, key: string, body: string) => {\n const value = data[key];\n\n if (value === undefined || value === null || value === false) {\n return '';\n }\n\n if (Array.isArray(value)) {\n return value\n .map((item) => {\n if (typeof item === 'object' && item !== null) {\n return render(body, item as Record<string, unknown>, partials);\n }\n // For primitive items, replace {{.}} with the item value\n return body.replace(/\\{\\{\\.\\}\\}/g, String(item));\n })\n .join('');\n }\n\n // Truthy conditional\n if (typeof value === 'object') {\n return render(body, value as Record<string, unknown>, partials);\n }\n return render(body, data, partials);\n });\n\n // Process partials: {{>partialName}}\n if (partials) {\n result = result.replace(/\\{\\{>(\\w+)\\}\\}/g, (_match, name: string) => {\n const partialText = partials[name];\n if (!partialText) return '';\n return render(partialText, data, partials);\n });\n }\n\n // Process interpolation: {{var}}\n result = result.replace(/\\{\\{(\\w+)\\}\\}/g, (_match, key: string) => {\n const value = data[key];\n if (value === undefined || value === null) return '';\n return String(value);\n });\n\n return result;\n}\n"],"mappings":";;;AAaA,IAAM,kBAAN,MAAM,gBAAuC;CAC3C,0BAAkB,IAAI,KAA0B;CAChD,QAA4B,EAAE;CAC9B;CAEA,YAAY,SAAS,GAAG;AACtB,OAAK,SAAS;;CAGhB,OAAO,WAA8B,QAA6B;EAChE,MAAM,QAAQ,MAAM,QAAQ,UAAU,GAAG,YAAY,CAAC,UAAU;EAChE,MAAM,WAAW,KAAK,QAAQ,IAAI,OAAO;AACzC,MAAI,UAAU;AACZ,QAAK,MAAM,KAAK,MAAO,UAAS,WAAW,IAAI,EAAE;AAEjD,YAAS,WAAW;QAEpB,MAAK,QAAQ,IAAI,QAAQ;GAAE,YAAY,IAAI,IAAI,MAAM;GAAE,UAAU;GAAO,CAAC;AAE3E,SAAO;;CAGT,cAAc,MAAc,QAA6B;EACvD,MAAM,WAAW,KAAK,QAAQ,IAAI,OAAO;AACzC,MAAI,UAAU;AACZ,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,UAAU,MACrD,QAAO;AAGT,MAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MACJ,KAAK,SAAS;AACb,OAAI,OAAO,SAAS,YAAY,SAAS,KACvC,QAAO,OAAO,MAAM,MAAiC,SAAS;AAGhE,UAAO,KAAK,QAAQ,eAAe,OAAO,KAAK,CAAC;IAChD,CACD,KAAK,GAAG;AAIb,MAAI,OAAO,UAAU,SACnB,QAAO,OAAO,MAAM,OAAkC,SAAS;AAEjE,SAAO,OAAO,MAAM,MAAM,SAAS;GACnC;AAGF,KAAI,SACF,UAAS,OAAO,QAAQ,oBAAoB,QAAQ,SAAiB;EACnE,MAAM,cAAc,SAAS;AAC7B,MAAI,CAAC,YAAa,QAAO;AACzB,SAAO,OAAO,aAAa,MAAM,SAAS;GAC1C;AAIJ,UAAS,OAAO,QAAQ,mBAAmB,QAAQ,QAAgB;EACjE,MAAM,QAAQ,KAAK;AACnB,MAAI,UAAU,KAAA,KAAa,UAAU,KAAM,QAAO;AAClD,SAAO,OAAO,MAAM;GACpB;AAEF,QAAO"}
@@ -1,4 +1,4 @@
1
- import { n as AnyPadroneCommand } from "./types-qrtt0135.mjs";
1
+ import { n as AnyPadroneCommand } from "./types-BS7RP5Ls.mjs";
2
2
 
3
3
  //#region src/shell-utils.d.ts
4
4
  type ShellType = 'bash' | 'zsh' | 'fish' | 'powershell';
@@ -1,5 +1,5 @@
1
1
  import { t as __require } from "./chunk-y_GBKt04.mjs";
2
- import { r as extractSchemaMetadata } from "./args-CKNh7Dm9.mjs";
2
+ import { i as extractSchemaMetadata } from "./args-DFEI7_G_.mjs";
3
3
  //#region src/shell-utils.ts
4
4
  /**
5
5
  * Detects the current shell from environment variables and process info.
@@ -91,7 +91,7 @@ function extractArguments(cmd) {
91
91
  if (!cmd.argsSchema) return argList;
92
92
  try {
93
93
  const argsMeta = cmd.meta?.fields;
94
- const { aliases } = extractSchemaMetadata(cmd.argsSchema, argsMeta);
94
+ const { aliases } = extractSchemaMetadata(cmd.argsSchema, argsMeta, cmd.meta?.autoAlias);
95
95
  const aliasToArgument = {};
96
96
  for (const [arg, alias] of Object.entries(aliases)) aliasToArgument[alias] = arg;
97
97
  const jsonSchema = cmd.argsSchema["~standard"].jsonSchema.input({ target: "draft-2020-12" });