@ncoderz/awa 1.8.0 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/config.ts","../src/types/index.ts","../src/utils/fs.ts","../src/utils/logger.ts"],"sourcesContent":["// @awa-component: CFG-ConfigLoader\n// @awa-component: MULTI-TargetResolver\n// @awa-impl: CFG-1_AC-1\n// @awa-impl: CFG-1_AC-2\n// @awa-impl: CFG-1_AC-3\n// @awa-impl: CFG-1_AC-4\n// @awa-impl: CFG-2_AC-1\n// @awa-impl: CFG-2_AC-2\n// @awa-impl: CFG-2_AC-3\n// @awa-impl: CFG-3_AC-1\n// @awa-impl: CFG-3_AC-2\n// @awa-impl: CFG-3_AC-3\n// @awa-impl: CFG-3_AC-4\n// @awa-impl: CFG-3_AC-5\n// @awa-impl: CFG-3_AC-6\n// @awa-impl: CFG-3_AC-7\n// @awa-impl: CFG-3_AC-8\n// @awa-impl: CFG-3_AC-9\n// @awa-impl: CFG-3_AC-10\n// @awa-impl: CFG-4_AC-1\n// @awa-impl: CFG-4_AC-2\n// @awa-impl: CFG-4_AC-3\n// @awa-impl: CFG-4_AC-4\n// @awa-impl: CFG-5_AC-1\n// @awa-impl: CFG-6_AC-1\n// @awa-impl: CFG-6_AC-2\n// @awa-impl: CLI-1_AC-4\n// @awa-impl: CLI-2_AC-2\n// @awa-impl: CLI-2_AC-3\n// @awa-impl: CLI-2_AC-4\n// @awa-impl: CLI-4_AC-3\n// @awa-impl: CLI-7_AC-2\n// @awa-impl: CFG-7_AC-1\n// @awa-impl: CFG-7_AC-2\n// @awa-impl: CFG-7_AC-3\n// @awa-impl: CFG-7_AC-4\n// @awa-impl: CFG-9_AC-1\n// @awa-impl: CFG-9_AC-2\n// @awa-impl: CFG-9_AC-3\n// @awa-impl: CFG-11_AC-1\n// @awa-impl: CFG-11_AC-2\n// @awa-impl: CFG-11_AC-3\n// @awa-impl: MULTI-1_AC-1\n// @awa-impl: MULTI-2_AC-1\n// @awa-impl: MULTI-3_AC-1\n// @awa-impl: MULTI-5_AC-2\n\nimport { homedir } from 'node:os';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\n\nimport { parse } from 'smol-toml';\n\nimport {\n ConfigError,\n type FileConfig,\n type PresetDefinitions,\n type RawCliOptions,\n type ResolvedOptions,\n type TargetConfig,\n type UpdateCheckConfig,\n} from '../types/index.js';\nimport { pathExists, readTextFile } from '../utils/fs.js';\nimport { logger } from '../utils/logger.js';\n\nconst DEFAULT_CONFIG_PATH = '.awa.toml';\n\nexport class ConfigLoader {\n private isLocalTemplateSource(source: string): boolean {\n if (source.startsWith('.') || source.startsWith('/') || source.startsWith('~')) {\n return true;\n }\n return /^[a-zA-Z]:/.test(source);\n }\n\n private resolvePathFromConfigDir(value: string, configDir: string): string {\n if (isAbsolute(value) || value.startsWith('~')) {\n return value;\n }\n return resolve(configDir, value);\n }\n\n private normalizeConfigPaths(config: FileConfig, configPath: string): FileConfig {\n const configDir = dirname(configPath);\n\n if (config.output !== undefined) {\n config.output = this.resolvePathFromConfigDir(config.output, configDir);\n }\n\n if (config.template !== undefined && this.isLocalTemplateSource(config.template)) {\n config.template = this.resolvePathFromConfigDir(config.template, configDir);\n }\n\n if (config.overlay !== undefined) {\n config.overlay = config.overlay.map((overlaySource) =>\n this.isLocalTemplateSource(overlaySource)\n ? this.resolvePathFromConfigDir(overlaySource, configDir)\n : overlaySource,\n );\n }\n\n if (config.targets !== undefined) {\n for (const target of Object.values(config.targets)) {\n if (target.output !== undefined) {\n target.output = this.resolvePathFromConfigDir(target.output, configDir);\n }\n\n if (target.template !== undefined && this.isLocalTemplateSource(target.template)) {\n target.template = this.resolvePathFromConfigDir(target.template, configDir);\n }\n }\n }\n\n return config;\n }\n\n private async discoverConfigPath(startDir: string): Promise<string | null> {\n const homeDir = resolve(homedir());\n let currentDir = resolve(startDir);\n\n while (true) {\n const candidatePath = join(currentDir, DEFAULT_CONFIG_PATH);\n if (await pathExists(candidatePath)) {\n return candidatePath;\n }\n\n const gitMarker = join(currentDir, '.git');\n if (await pathExists(gitMarker)) {\n return null;\n }\n\n const parentDir = dirname(currentDir);\n if (parentDir === currentDir || currentDir === homeDir) {\n return null;\n }\n\n currentDir = parentDir;\n }\n }\n\n // @awa-impl: CFG-1_AC-1, CFG-1_AC-2, CFG-1_AC-3, CFG-1_AC-4\n async load(configPath: string | null): Promise<FileConfig | null> {\n let pathToLoad: string | null;\n\n if (configPath) {\n pathToLoad = isAbsolute(configPath) ? configPath : resolve(process.cwd(), configPath);\n const exists = await pathExists(pathToLoad);\n if (!exists) {\n throw new ConfigError(\n `Configuration file not found: ${configPath}`,\n 'FILE_NOT_FOUND',\n configPath,\n );\n }\n } else {\n pathToLoad = await this.discoverConfigPath(process.cwd());\n }\n\n // No config found via auto-discovery\n if (!pathToLoad) {\n return null;\n }\n\n // If explicit path provided but doesn't exist, error\n if (configPath && !(await pathExists(pathToLoad))) {\n throw new ConfigError(\n `Configuration file not found: ${configPath}`,\n 'FILE_NOT_FOUND',\n configPath,\n );\n }\n\n // Read and parse TOML\n try {\n const content = await readTextFile(pathToLoad);\n const parsed = parse(content) as Record<string, unknown>;\n\n // Validate and extract known options\n const config: FileConfig = {};\n\n if (parsed.output !== undefined) {\n if (typeof parsed.output !== 'string') {\n throw new ConfigError(\n `Invalid type for 'output': expected string, got ${typeof parsed.output}`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config.output = parsed.output;\n }\n\n if (parsed.template !== undefined) {\n if (typeof parsed.template !== 'string') {\n throw new ConfigError(\n `Invalid type for 'template': expected string, got ${typeof parsed.template}`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config.template = parsed.template;\n }\n\n if (parsed.features !== undefined) {\n if (\n !Array.isArray(parsed.features) ||\n !parsed.features.every((f) => typeof f === 'string')\n ) {\n throw new ConfigError(\n `Invalid type for 'features': expected array of strings`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config.features = parsed.features;\n }\n\n if (parsed.preset !== undefined) {\n if (!Array.isArray(parsed.preset) || !parsed.preset.every((p) => typeof p === 'string')) {\n throw new ConfigError(\n `Invalid type for 'preset': expected array of strings`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config.preset = parsed.preset;\n }\n\n if (parsed['remove-features'] !== undefined) {\n if (\n !Array.isArray(parsed['remove-features']) ||\n !parsed['remove-features'].every((f) => typeof f === 'string')\n ) {\n throw new ConfigError(\n `Invalid type for 'remove-features': expected array of strings`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config['remove-features'] = parsed['remove-features'];\n }\n\n if (parsed.force !== undefined) {\n if (typeof parsed.force !== 'boolean') {\n throw new ConfigError(\n `Invalid type for 'force': expected boolean, got ${typeof parsed.force}`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config.force = parsed.force;\n }\n\n if (parsed['dry-run'] !== undefined) {\n if (typeof parsed['dry-run'] !== 'boolean') {\n throw new ConfigError(\n `Invalid type for 'dry-run': expected boolean, got ${typeof parsed['dry-run']}`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config['dry-run'] = parsed['dry-run'];\n }\n\n if (parsed.delete !== undefined) {\n if (typeof parsed.delete !== 'boolean') {\n throw new ConfigError(\n `Invalid type for 'delete': expected boolean, got ${typeof parsed.delete}`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config.delete = parsed.delete;\n }\n\n if (parsed.refresh !== undefined) {\n if (typeof parsed.refresh !== 'boolean') {\n throw new ConfigError(\n `Invalid type for 'refresh': expected boolean, got ${typeof parsed.refresh}`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config.refresh = parsed.refresh;\n }\n\n if (parsed.presets !== undefined) {\n if (\n parsed.presets === null ||\n typeof parsed.presets !== 'object' ||\n Array.isArray(parsed.presets)\n ) {\n throw new ConfigError(\n `Invalid type for 'presets': expected table of string arrays`,\n 'INVALID_PRESET',\n pathToLoad,\n );\n }\n\n const defs: PresetDefinitions = {};\n for (const [presetName, value] of Object.entries(\n parsed.presets as Record<string, unknown>,\n )) {\n if (!Array.isArray(value) || !value.every((v) => typeof v === 'string')) {\n throw new ConfigError(\n `Invalid preset '${presetName}': expected array of strings`,\n 'INVALID_PRESET',\n pathToLoad,\n );\n }\n defs[presetName] = value as string[];\n }\n\n config.presets = defs;\n }\n\n if (parsed['list-unknown'] !== undefined) {\n if (typeof parsed['list-unknown'] !== 'boolean') {\n throw new ConfigError(\n `Invalid type for 'list-unknown': expected boolean, got ${typeof parsed['list-unknown']}`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config['list-unknown'] = parsed['list-unknown'];\n }\n\n // @awa-impl: CLI-31_AC-1\n // Pass through [check] table as-is for check command to process\n if (parsed.check !== undefined) {\n if (\n parsed.check === null ||\n typeof parsed.check !== 'object' ||\n Array.isArray(parsed.check)\n ) {\n throw new ConfigError(\n `Invalid type for 'check': expected table`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config.check = parsed.check as Record<string, unknown>;\n }\n\n // @awa-impl: OVL-8_AC-1\n if (parsed.overlay !== undefined) {\n if (!Array.isArray(parsed.overlay) || !parsed.overlay.every((o) => typeof o === 'string')) {\n throw new ConfigError(\n `Invalid type for 'overlay': expected array of strings`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n config.overlay = parsed.overlay;\n }\n\n if (parsed['update-check'] !== undefined) {\n if (\n parsed['update-check'] === null ||\n typeof parsed['update-check'] !== 'object' ||\n Array.isArray(parsed['update-check'])\n ) {\n throw new ConfigError(\n `Invalid type for 'update-check': expected table`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n\n const raw = parsed['update-check'] as Record<string, unknown>;\n const updateCheckConfig: UpdateCheckConfig = {};\n\n if (raw.enabled !== undefined) {\n if (typeof raw.enabled !== 'boolean') {\n throw new ConfigError(\n `Invalid type for 'update-check.enabled': expected boolean, got ${typeof raw.enabled}`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n updateCheckConfig.enabled = raw.enabled;\n }\n\n if (raw.interval !== undefined) {\n if (typeof raw.interval !== 'number') {\n throw new ConfigError(\n `Invalid type for 'update-check.interval': expected number, got ${typeof raw.interval}`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n updateCheckConfig.interval = raw.interval;\n }\n\n config['update-check'] = updateCheckConfig;\n }\n\n // Parse [targets.*] sections\n if (parsed.targets !== undefined) {\n if (\n parsed.targets === null ||\n typeof parsed.targets !== 'object' ||\n Array.isArray(parsed.targets)\n ) {\n throw new ConfigError(\n `Invalid type for 'targets': expected table of target sections`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n\n const targets: Record<string, TargetConfig> = {};\n for (const [targetName, targetValue] of Object.entries(\n parsed.targets as Record<string, unknown>,\n )) {\n if (\n targetValue === null ||\n typeof targetValue !== 'object' ||\n Array.isArray(targetValue)\n ) {\n throw new ConfigError(\n `Invalid target '${targetName}': expected table`,\n 'INVALID_TYPE',\n pathToLoad,\n );\n }\n targets[targetName] = this.parseTargetSection(\n targetValue as Record<string, unknown>,\n targetName,\n pathToLoad,\n );\n }\n config.targets = targets;\n }\n\n // Warn about unknown options\n const knownKeys = new Set([\n 'output',\n 'template',\n 'features',\n 'preset',\n 'remove-features',\n 'presets',\n 'force',\n 'dry-run',\n 'delete',\n 'refresh',\n 'list-unknown',\n 'check',\n 'targets',\n 'overlay',\n 'update-check',\n ]);\n for (const key of Object.keys(parsed)) {\n if (!knownKeys.has(key)) {\n logger.warn(`Unknown configuration option: '${key}'`);\n }\n }\n\n return this.normalizeConfigPaths(config, pathToLoad);\n } catch (error) {\n if (error instanceof ConfigError) {\n throw error;\n }\n\n // TOML parsing error\n throw new ConfigError(\n `Failed to parse TOML configuration: ${error instanceof Error ? error.message : String(error)}`,\n 'PARSE_ERROR',\n pathToLoad,\n );\n }\n }\n\n // @awa-impl: CFG-4_AC-1, CFG-4_AC-2, CFG-4_AC-3, CFG-4_AC-4\n // @awa-impl: CLI-2_AC-2, CLI-2_AC-3, CLI-2_AC-4\n merge(cli: RawCliOptions, file: FileConfig | null): ResolvedOptions {\n // CLI arguments override file config values\n // Output can come from CLI (positional argument) or config file\n\n // @awa-impl: CLI-2_AC-2, CLI-2_AC-3\n const output = cli.output ?? file?.output;\n\n // @awa-impl: CLI-1_AC-4, CLI-2_AC-4\n if (!output) {\n throw new ConfigError(\n 'Output directory is required. Provide it as a positional argument or in the config file.',\n 'MISSING_OUTPUT',\n null,\n );\n }\n\n const template = cli.template ?? file?.template ?? null;\n\n // Features: CLI completely replaces config (no merge)\n const features = cli.features ?? file?.features ?? [];\n\n const preset = cli.preset ?? file?.preset ?? [];\n const removeFeatures = cli.removeFeatures ?? file?.['remove-features'] ?? [];\n const presets = file?.presets ?? {};\n\n const force = cli.force ?? file?.force ?? false;\n const dryRun = cli.dryRun ?? file?.['dry-run'] ?? false;\n const enableDelete = cli.delete ?? file?.delete ?? false;\n const refresh = cli.refresh ?? file?.refresh ?? false;\n const listUnknown = cli.listUnknown ?? file?.['list-unknown'] ?? false;\n const overlay = cli.overlay ?? file?.overlay ?? [];\n const json = cli.json ?? false;\n const summary = cli.summary ?? false;\n\n return {\n output,\n template,\n features,\n preset,\n removeFeatures,\n force,\n dryRun,\n delete: enableDelete,\n refresh,\n presets,\n listUnknown,\n overlay,\n json,\n summary,\n };\n }\n\n // Parse a [targets.<name>] section, validating allowed keys and types\n private parseTargetSection(\n section: Record<string, unknown>,\n targetName: string,\n configPath: string,\n ): TargetConfig {\n const target: TargetConfig = {};\n const allowedKeys = new Set(['output', 'template', 'features', 'preset', 'remove-features']);\n\n for (const key of Object.keys(section)) {\n if (!allowedKeys.has(key)) {\n logger.warn(`Unknown option in target '${targetName}': '${key}'`);\n }\n }\n\n if (section.output !== undefined) {\n if (typeof section.output !== 'string') {\n throw new ConfigError(\n `Invalid type for 'targets.${targetName}.output': expected string, got ${typeof section.output}`,\n 'INVALID_TYPE',\n configPath,\n );\n }\n target.output = section.output;\n }\n\n if (section.template !== undefined) {\n if (typeof section.template !== 'string') {\n throw new ConfigError(\n `Invalid type for 'targets.${targetName}.template': expected string, got ${typeof section.template}`,\n 'INVALID_TYPE',\n configPath,\n );\n }\n target.template = section.template;\n }\n\n if (section.features !== undefined) {\n if (\n !Array.isArray(section.features) ||\n !section.features.every((f) => typeof f === 'string')\n ) {\n throw new ConfigError(\n `Invalid type for 'targets.${targetName}.features': expected array of strings`,\n 'INVALID_TYPE',\n configPath,\n );\n }\n target.features = section.features;\n }\n\n if (section.preset !== undefined) {\n if (!Array.isArray(section.preset) || !section.preset.every((p) => typeof p === 'string')) {\n throw new ConfigError(\n `Invalid type for 'targets.${targetName}.preset': expected array of strings`,\n 'INVALID_TYPE',\n configPath,\n );\n }\n target.preset = section.preset;\n }\n\n if (section['remove-features'] !== undefined) {\n if (\n !Array.isArray(section['remove-features']) ||\n !section['remove-features'].every((f) => typeof f === 'string')\n ) {\n throw new ConfigError(\n `Invalid type for 'targets.${targetName}.remove-features': expected array of strings`,\n 'INVALID_TYPE',\n configPath,\n );\n }\n target['remove-features'] = section['remove-features'];\n }\n\n return target;\n }\n\n // Resolve a target by merging target config with root config (target overrides root via nullish coalescing)\n resolveTarget(targetName: string, fileConfig: FileConfig): FileConfig {\n const targets = fileConfig.targets;\n if (!targets || Object.keys(targets).length === 0) {\n throw new ConfigError(\n 'No targets defined in configuration. Add [targets.<name>] sections to .awa.toml.',\n 'NO_TARGETS',\n null,\n );\n }\n\n const target = targets[targetName];\n if (!target) {\n throw new ConfigError(\n `Unknown target: '${targetName}'. Available targets: ${Object.keys(targets).join(', ')}`,\n 'UNKNOWN_TARGET',\n null,\n );\n }\n\n // Merge: target fields override root (nullish coalescing — target value ?? root value)\n return {\n ...fileConfig,\n output: target.output ?? fileConfig.output,\n template: target.template ?? fileConfig.template,\n features: target.features ?? fileConfig.features,\n preset: target.preset ?? fileConfig.preset,\n 'remove-features': target['remove-features'] ?? fileConfig['remove-features'],\n targets: undefined, // Don't propagate targets into resolved config\n };\n }\n\n // Get all target names from config\n getTargetNames(fileConfig: FileConfig | null): string[] {\n if (!fileConfig?.targets) {\n return [];\n }\n return Object.keys(fileConfig.targets);\n }\n}\n\nexport const configLoader = new ConfigLoader();\n","// @awa-component: GEN-CoreTypes\n\n// Custom error classes for diff operations\nexport class DiffError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DiffError';\n }\n}\n\n// RawCliOptions - CLI argument parser output\nexport interface RawCliOptions {\n output?: string; // Optional positional argument (required if not in config)\n template?: string;\n features?: string[];\n preset?: string[];\n removeFeatures?: string[];\n force?: boolean;\n dryRun?: boolean;\n delete?: boolean;\n config?: string;\n refresh?: boolean;\n listUnknown?: boolean;\n all?: boolean;\n allTargets?: boolean;\n target?: string;\n watch?: boolean;\n overlay?: string[];\n json?: boolean;\n summary?: boolean;\n}\n\n// PresetDefinitions - Named feature bundles\nexport interface PresetDefinitions {\n [presetName: string]: string[];\n}\n\n// TargetConfig - Per-target configuration (generation-related fields only, no boolean flags)\nexport interface TargetConfig {\n output?: string;\n template?: string;\n features?: string[];\n preset?: string[];\n 'remove-features'?: string[];\n}\n\n// UpdateCheckConfig - Update check configuration\nexport interface UpdateCheckConfig {\n enabled?: boolean;\n interval?: number;\n}\n\n// FileConfig - TOML configuration file structure\nexport interface FileConfig {\n output?: string;\n template?: string;\n features?: string[];\n preset?: string[];\n 'remove-features'?: string[];\n force?: boolean;\n 'dry-run'?: boolean;\n delete?: boolean;\n refresh?: boolean;\n presets?: PresetDefinitions;\n 'list-unknown'?: boolean;\n check?: Record<string, unknown>;\n targets?: Record<string, TargetConfig>;\n overlay?: string[];\n 'update-check'?: UpdateCheckConfig;\n}\n\n// ResolvedOptions - Fully resolved configuration with defaults applied\nexport interface ResolvedOptions {\n readonly output: string;\n readonly template: string | null;\n readonly features: readonly string[];\n readonly preset: readonly string[];\n readonly removeFeatures: readonly string[];\n readonly force: boolean;\n readonly dryRun: boolean;\n readonly delete: boolean;\n readonly refresh: boolean;\n readonly presets: PresetDefinitions;\n readonly listUnknown: boolean;\n readonly overlay: readonly string[];\n readonly json: boolean;\n readonly summary: boolean;\n}\n\n// TemplateSourceType - Template source type detection\nexport type TemplateSourceType = 'local' | 'git' | 'bundled';\n\n// ResolvedTemplate - Template source resolution result\nexport interface ResolvedTemplate {\n type: TemplateSourceType;\n localPath: string;\n source: string;\n}\n\n// TemplateContext - Context passed to template engine\nexport interface TemplateContext {\n features: string[];\n version?: string;\n}\n\n// RenderResult - Template rendering output\nexport interface RenderResult {\n content: string;\n isEmpty: boolean;\n isEmptyFileMarker: boolean;\n}\n\n// FileAction - Tagged union for file operations\nexport type FileAction =\n | { type: 'create'; sourcePath: string; outputPath: string }\n | { type: 'overwrite'; sourcePath: string; outputPath: string }\n | { type: 'skip-user'; sourcePath: string; outputPath: string }\n | { type: 'skip-empty'; sourcePath: string; outputPath: string }\n | { type: 'skip-equal'; sourcePath: string; outputPath: string }\n | { type: 'delete'; outputPath: string };\n\n// GenerationResult - Aggregated generation outcome\nexport interface GenerationResult {\n readonly actions: readonly FileAction[];\n readonly created: number;\n readonly overwritten: number;\n readonly deleted: number;\n readonly skipped: number;\n readonly skippedEmpty: number;\n readonly skippedUser: number;\n readonly skippedEqual: number;\n}\n\n// GenerateOptions - File generation parameters\nexport interface GenerateOptions {\n templatePath: string;\n outputPath: string;\n features: string[];\n force: boolean;\n dryRun: boolean;\n delete: boolean;\n}\n\n// ConflictChoice - User choice for conflict resolution\nexport type ConflictChoice = 'overwrite' | 'skip';\n\n// ConflictItem - Individual file conflict for batch resolution\nexport interface ConflictItem {\n outputPath: string;\n sourcePath: string;\n newContent: string;\n existingContent: string;\n}\n\n// BatchConflictResolution - Result of batch conflict resolution\nexport interface BatchConflictResolution {\n overwrite: string[]; // List of output paths to overwrite\n skip: string[]; // List of output paths to skip\n equal: string[]; // List of output paths skipped because content is identical\n}\n\n// TemplateFile - Template file metadata\nexport interface TemplateFile {\n path: string;\n absolutePath: string;\n isPartial: boolean;\n}\n\n// DiffOptions - Diff operation parameters\nexport interface DiffOptions {\n templatePath: string;\n targetPath: string;\n features: string[];\n listUnknown: boolean;\n}\n\n// FileDiffStatus - File comparison status\nexport type FileDiffStatus =\n | 'identical'\n | 'modified'\n | 'new'\n | 'extra'\n | 'binary-differs'\n | 'delete-listed';\n\n// FileDiff - Comparison result for a single file\nexport interface FileDiff {\n relativePath: string;\n status: FileDiffStatus;\n unifiedDiff?: string; // Present only for 'modified' text files\n}\n\n// DiffResult - Aggregated diff outcome\nexport interface DiffResult {\n files: FileDiff[];\n identical: number;\n modified: number;\n newFiles: number;\n extraFiles: number;\n binaryDiffers: number;\n deleteListed: number;\n hasDifferences: boolean;\n}\n\n// CachedTemplate - Cached Git template metadata\nexport interface CachedTemplate {\n source: string;\n localPath: string;\n fetchedAt: Date;\n ref?: string;\n}\n\n// JSON output types for --json flag\n// @awa-impl: JSON-3_AC-1\nexport interface GenerationActionJSON {\n type: string;\n path: string;\n}\n\nexport interface GenerationJSON {\n actions: GenerationActionJSON[];\n counts: {\n created: number;\n overwritten: number;\n skipped: number;\n deleted: number;\n };\n}\n\n// @awa-impl: JSON-4_AC-1\nexport interface DiffFileJSON {\n path: string;\n status: string;\n diff?: string;\n}\n\nexport interface DiffJSON {\n diffs: DiffFileJSON[];\n counts: {\n changed: number;\n new: number;\n matching: number;\n deleted: number;\n };\n}\n\n// Custom error types\nexport class ConfigError extends Error {\n constructor(\n message: string,\n public code:\n | 'FILE_NOT_FOUND'\n | 'PARSE_ERROR'\n | 'INVALID_TYPE'\n | 'MISSING_OUTPUT'\n | 'INVALID_PRESET'\n | 'UNKNOWN_PRESET'\n | 'UNKNOWN_TARGET'\n | 'NO_TARGETS',\n public filePath?: string | null,\n ) {\n super(message);\n this.name = 'ConfigError';\n }\n}\n\nexport class TemplateError extends Error {\n constructor(\n message: string,\n public code: 'SOURCE_NOT_FOUND' | 'FETCH_FAILED' | 'RENDER_ERROR',\n public source?: string,\n ) {\n super(message);\n this.name = 'TemplateError';\n }\n}\n\nexport class GenerationError extends Error {\n constructor(\n message: string,\n public code: 'PERMISSION_DENIED' | 'DISK_FULL',\n ) {\n super(message);\n this.name = 'GenerationError';\n }\n}\n","// @awa-component: GEN-FileSystem\n// @awa-impl: GEN-1_AC-1, GEN-1_AC-2\n\nimport { mkdir, readdir, readFile, rm, stat, writeFile } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nexport async function ensureDir(dirPath: string): Promise<void> {\n await mkdir(dirPath, { recursive: true });\n}\n\nexport async function pathExists(path: string): Promise<boolean> {\n try {\n await stat(path);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function isDirectory(path: string): Promise<boolean> {\n try {\n const stats = await stat(path);\n return stats.isDirectory();\n } catch {\n return false;\n }\n}\n\nexport async function readTextFile(path: string): Promise<string> {\n return readFile(path, 'utf-8');\n}\n\nexport async function readBinaryFile(path: string): Promise<Buffer> {\n return readFile(path);\n}\n\nexport async function writeTextFile(path: string, content: string): Promise<void> {\n await ensureDir(dirname(path));\n await writeFile(path, content, 'utf-8');\n}\n\nexport async function* walkDirectory(dir: string): AsyncGenerator<string> {\n const entries = await readdir(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n\n if (entry.isDirectory()) {\n // Skip directories starting with underscore\n if (entry.name.startsWith('_')) {\n continue;\n }\n yield* walkDirectory(fullPath);\n } else if (entry.isFile()) {\n // Skip files starting with underscore\n if (entry.name.startsWith('_')) {\n continue;\n }\n yield fullPath;\n }\n }\n}\n\nexport function getCacheDir(): string {\n return join(homedir(), '.cache', 'awa', 'templates');\n}\n\nexport function getTemplateDir(): string {\n // In built dist, we need to go up from dist/index.js to project root\n // In development, we're in src/utils/fs.ts\n const currentFile = fileURLToPath(import.meta.url);\n const currentDir = dirname(currentFile);\n\n // Check if we're in dist/ or src/\n if (currentDir.includes('/dist')) {\n // In dist: go up one level to project root\n return join(dirname(currentDir), 'templates');\n }\n\n // In src: go up two levels to project root\n return join(currentDir, '..', '..', 'templates');\n}\n\nexport async function rmDir(dirPath: string): Promise<void> {\n await rm(dirPath, { recursive: true, force: true });\n}\n\nexport async function deleteFile(filePath: string): Promise<void> {\n await rm(filePath, { force: true });\n}\n","// @awa-component: GEN-Logger\n// @awa-impl: CLI-6_AC-3\n// @awa-impl: GEN-6_AC-4\n// @awa-impl: GEN-7_AC-1\n// @awa-impl: GEN-7_AC-2\n// @awa-impl: GEN-7_AC-3\n// @awa-impl: GEN-7_AC-4\n// @awa-impl: GEN-9_AC-1\n// @awa-impl: GEN-9_AC-2\n// @awa-impl: GEN-9_AC-3\n// @awa-impl: GEN-9_AC-4\n// @awa-impl: GEN-9_AC-5\n// @awa-impl: GEN-9_AC-6\n// @awa-impl: GEN-9_AC-7\n// @awa-impl: GEN-9_AC-8\n// @awa-impl: GEN-11_AC-1\n// @awa-impl: GEN-11_AC-2\n// @awa-impl: GEN-11_AC-4\n// @awa-impl: TPL-7_AC-3\n\nimport chalk from 'chalk';\n\nimport type { DiffResult, FileAction, GenerationResult } from '../types/index.js';\n\nexport class Logger {\n info(message: string): void {\n console.log(chalk.blue('ℹ'), message);\n }\n\n success(message: string): void {\n console.log(chalk.green('✔'), message);\n }\n\n warn(message: string): void {\n console.warn(chalk.yellow('⚠'), message);\n }\n\n error(message: string): void {\n console.error(chalk.red('✖'), message);\n }\n\n fileAction(action: FileAction): void {\n const { type, outputPath } = action;\n\n switch (type) {\n case 'create':\n console.log(chalk.green(' + '), chalk.dim(outputPath));\n break;\n case 'overwrite':\n console.log(chalk.yellow(' ~ '), chalk.dim(outputPath));\n break;\n case 'skip-user':\n console.log(chalk.blue(' - '), chalk.dim(outputPath), chalk.dim('(skipped)'));\n break;\n case 'skip-empty':\n console.log(chalk.dim(' · '), chalk.dim(outputPath), chalk.dim('(empty)'));\n break;\n case 'skip-equal':\n console.log(chalk.dim(' = '), chalk.dim(outputPath), chalk.dim('(unchanged)'));\n break;\n case 'delete':\n console.log(chalk.red(' ✖ '), chalk.dim(outputPath), chalk.red('(deleted)'));\n break;\n }\n }\n\n // @awa-impl: GEN-9_AC-1, GEN-9_AC-2, GEN-9_AC-3, GEN-9_AC-4, GEN-9_AC-5, GEN-9_AC-6\n summary(result: GenerationResult): void {\n console.log('');\n console.log(chalk.bold('Summary:'));\n\n // @awa-impl: GEN-9_AC-6\n // Check if no files were created, overwritten, or deleted\n if (result.created === 0 && result.overwritten === 0 && result.deleted === 0) {\n console.log(chalk.yellow(' ⚠ No files were created, overwritten, or deleted'));\n }\n\n if (result.created > 0) {\n console.log(chalk.green(` Created: ${result.created}`));\n }\n\n if (result.overwritten > 0) {\n console.log(chalk.yellow(` Overwritten: ${result.overwritten}`));\n }\n\n if (result.deleted > 0) {\n console.log(chalk.red(` Deleted: ${result.deleted}`));\n }\n\n if (result.skippedEqual > 0) {\n console.log(chalk.dim(` Skipped (equal): ${result.skippedEqual}`));\n }\n\n if (result.skippedUser > 0) {\n console.log(chalk.blue(` Skipped (user): ${result.skippedUser}`));\n }\n\n console.log('');\n }\n\n // @awa-impl: DIFF-4_AC-3\n diffLine(line: string, type: 'add' | 'remove' | 'context'): void {\n switch (type) {\n case 'add':\n console.log(chalk.green(line));\n break;\n case 'remove':\n console.log(chalk.red(line));\n break;\n case 'context':\n console.log(chalk.dim(line));\n break;\n }\n }\n\n // @awa-impl: DIFF-4_AC-4, DIFF-4_AC-5\n diffSummary(result: DiffResult): void {\n console.log('');\n\n const filesCompared =\n result.identical +\n result.modified +\n result.newFiles +\n result.extraFiles +\n result.binaryDiffers +\n result.deleteListed;\n const differences =\n result.modified +\n result.newFiles +\n result.extraFiles +\n result.binaryDiffers +\n result.deleteListed;\n\n // @awa-impl: DIFF-4_AC-5\n console.log(chalk.bold(`${filesCompared} files compared, ${differences} differences`));\n\n if (!result.hasDifferences) {\n // @awa-impl: DIFF-4_AC-4\n console.log(chalk.green('✔ No differences found'));\n }\n\n // @awa-impl: DIFF-4_AC-5\n console.log(chalk.bold('Summary:'));\n console.log(chalk.dim(` Identical: ${result.identical}`));\n\n if (result.modified > 0) {\n console.log(chalk.yellow(` Modified: ${result.modified}`));\n }\n\n if (result.newFiles > 0) {\n console.log(chalk.green(` New: ${result.newFiles}`));\n }\n\n if (result.extraFiles > 0) {\n console.log(chalk.red(` Extra: ${result.extraFiles}`));\n }\n\n if (result.binaryDiffers > 0) {\n console.log(chalk.red(` Binary differs: ${result.binaryDiffers}`));\n }\n\n if (result.deleteListed > 0) {\n console.log(chalk.red(` Delete listed: ${result.deleteListed}`));\n }\n\n console.log('');\n }\n}\n\nexport const logger = new Logger();\n"],"mappings":";;;AA+CA,SAAS,WAAAA,gBAAe;AACxB,SAAS,WAAAC,UAAS,YAAY,QAAAC,OAAM,eAAe;AAEnD,SAAS,aAAa;;;AC/Cf,IAAM,YAAN,cAAwB,MAAM;AAAA,EACnC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AA+OO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACrC,YACE,SACO,MASA,UACP;AACA,UAAM,OAAO;AAXN;AASA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YACE,SACO,MACA,QACP;AACA,UAAM,OAAO;AAHN;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,YACE,SACO,MACP;AACA,UAAM,OAAO;AAFN;AAGP,SAAK,OAAO;AAAA,EACd;AACF;;;AC1RA,SAAS,OAAO,SAAS,UAAU,IAAI,MAAM,iBAAiB;AAC9D,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAE9B,eAAsB,UAAU,SAAgC;AAC9D,QAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;AAC1C;AAEA,eAAsB,WAAW,MAAgC;AAC/D,MAAI;AACF,UAAM,K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AACjC,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI;AAAA,QACR,oBAAoB,UAAU,yBAAyB,OAAO,KAAK,OAAO,EAAE,KAAK,IAAI,CAAC;AAAA,QACtF;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAGA,WAAO;AAAA,MACL,GAAG;AAAA,MACH,QAAQ,OAAO,UAAU,WAAW;AAAA,MACpC,UAAU,OAAO,YAAY,WAAW;AAAA,MACxC,UAAU,OAAO,YAAY,WAAW;AAAA,MACxC,QAAQ,OAAO,UAAU,WAAW;AAAA,MACpC,mBAAmB,OAAO,iBAAiB,KAAK,WAAW,iBAAiB;AAAA,MAC5E,SAAS;AAAA;AAAA,IACX;AAAA,EACF;AAAA;AAAA,EAGA,eAAe,YAAyC;AACtD,QAAI,CAAC,YAAY,SAAS;AACxB,aAAO,CAAC;AAAA,IACV;AACA,WAAO,OAAO,KAAK,WAAW,OAAO;AAAA,EACvC;AACF;AAEO,IAAM,eAAe,IAAI,aAAa;","names":["homedir","dirname","join","dirname","homedir","join"]}
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  ConfigLoader,
4
4
  configLoader
5
- } from "./chunk-LRQWZCYL.js";
5
+ } from "./chunk-GOIBZQFJ.js";
6
6
  export {
7
7
  ConfigLoader,
8
8
  configLoader
9
9
  };
10
- //# sourceMappingURL=config-EJIXC7D7.js.map
10
+ //# sourceMappingURL=config-SJLBJX77.js.map
package/dist/index.js CHANGED
@@ -2,13 +2,15 @@
2
2
  import {
3
3
  DEFAULT_CHECK_CONFIG,
4
4
  collectFiles,
5
+ findSpecFiles,
6
+ hasAnySpecFile,
5
7
  matchSimpleGlob,
6
8
  parseSpecs,
7
9
  propagate,
8
10
  renumberCommand,
9
11
  scan,
10
12
  scanMarkers
11
- } from "./chunk-WGGMDWBE.js";
13
+ } from "./chunk-FGJMXOYA.js";
12
14
  import {
13
15
  ConfigError,
14
16
  DiffError,
@@ -26,7 +28,7 @@ import {
26
28
  rmDir,
27
29
  walkDirectory,
28
30
  writeTextFile
29
- } from "./chunk-LRQWZCYL.js";
31
+ } from "./chunk-GOIBZQFJ.js";
30
32
 
31
33
  // src/cli/index.ts
32
34
  import { Command, Option } from "commander";
@@ -34,7 +36,7 @@ import { Command, Option } from "commander";
34
36
  // src/_generated/package_info.ts
35
37
  var PACKAGE_INFO = {
36
38
  "name": "@ncoderz/awa",
37
- "version": "1.8.0",
39
+ "version": "1.8.2",
38
40
  "author": "Richard Sewell <richard.sewell@ncoderz.com>",
39
41
  "license": "BSD-3-Clause",
40
42
  "description": "awa is an Agent Workflow for AIs. It is also a CLI tool to powerfully manage agent workflow files using templates."
@@ -3569,9 +3571,6 @@ function validateMerge(sourceCode, targetCode) {
3569
3571
  }
3570
3572
  }
3571
3573
 
3572
- // src/core/recode/map-builder.ts
3573
- import { basename as basename6 } from "path";
3574
-
3575
3574
  // src/core/recode/types.ts
3576
3575
  var RecodeError = class extends Error {
3577
3576
  errorCode;
@@ -3588,37 +3587,43 @@ function buildRecodeMap(sourceCode, targetCode, specs) {
3588
3587
  throw new RecodeError("SOURCE_NOT_FOUND", `No spec files found for source code: ${sourceCode}`);
3589
3588
  }
3590
3589
  const entries = /* @__PURE__ */ new Map();
3591
- const sourceReq = findSpecFile(specs.specFiles, sourceCode, "REQ");
3592
- if (sourceReq) {
3593
- const targetReq = findSpecFile(specs.specFiles, targetCode, "REQ");
3594
- const reqOffset = targetReq ? findHighestReqNumber(targetReq) : 0;
3595
- buildRequirementEntries(sourceCode, targetCode, sourceReq, reqOffset, entries);
3590
+ const sourceReqs = findSpecFiles(specs.specFiles, sourceCode, "REQ");
3591
+ if (sourceReqs.length > 0) {
3592
+ const targetReqs = findSpecFiles(specs.specFiles, targetCode, "REQ");
3593
+ const reqOffset = findHighestReqNumber(targetReqs);
3594
+ buildRequirementEntries(sourceCode, targetCode, sourceReqs, reqOffset, entries);
3596
3595
  }
3597
- const sourceDesign = findSpecFile(specs.specFiles, sourceCode, "DESIGN");
3598
- const targetDesign = findSpecFile(specs.specFiles, targetCode, "DESIGN");
3599
- if (sourceDesign) {
3600
- const propOffset = targetDesign ? findHighestPropertyNumber(targetDesign) : 0;
3601
- buildPropertyEntries(sourceCode, targetCode, sourceDesign, propOffset, entries);
3596
+ const sourceDesigns = findSpecFiles(specs.specFiles, sourceCode, "DESIGN");
3597
+ const targetDesigns = findSpecFiles(specs.specFiles, targetCode, "DESIGN");
3598
+ if (sourceDesigns.length > 0) {
3599
+ const propOffset = findHighestPropertyNumber(targetDesigns);
3600
+ buildPropertyEntries(sourceCode, targetCode, sourceDesigns, propOffset, entries);
3602
3601
  }
3603
- if (sourceDesign) {
3604
- buildComponentEntries(sourceCode, targetCode, sourceDesign, entries);
3602
+ if (sourceDesigns.length > 0) {
3603
+ buildComponentEntries(sourceCode, targetCode, sourceDesigns, entries);
3605
3604
  }
3606
3605
  const noChange = entries.size === 0;
3607
3606
  const map = { code: sourceCode, entries };
3608
3607
  return { map, noChange };
3609
3608
  }
3610
- function buildRequirementEntries(_sourceCode, targetCode, sourceReq, reqOffset, entries) {
3609
+ function buildRequirementEntries(_sourceCode, targetCode, sourceReqs, reqOffset, entries) {
3611
3610
  const topLevelReqs = [];
3612
3611
  const subReqsByParent = /* @__PURE__ */ new Map();
3613
- for (const id of sourceReq.requirementIds) {
3614
- if (id.includes(".")) {
3615
- const dotIdx = id.lastIndexOf(".");
3616
- const parent = id.slice(0, dotIdx);
3617
- const subs = subReqsByParent.get(parent) ?? [];
3618
- subs.push(id);
3619
- subReqsByParent.set(parent, subs);
3620
- } else {
3621
- topLevelReqs.push(id);
3612
+ const allAcIds = [];
3613
+ for (const sourceReq of sourceReqs) {
3614
+ for (const id of sourceReq.requirementIds) {
3615
+ if (id.includes(".")) {
3616
+ const dotIdx = id.lastIndexOf(".");
3617
+ const parent = id.slice(0, dotIdx);
3618
+ const subs = subReqsByParent.get(parent) ?? [];
3619
+ subs.push(id);
3620
+ subReqsByParent.set(parent, subs);
3621
+ } else {
3622
+ topLevelReqs.push(id);
3623
+ }
3624
+ }
3625
+ for (const acId of sourceReq.acIds) {
3626
+ allAcIds.push(acId);
3622
3627
  }
3623
3628
  }
3624
3629
  const reqNumberMap = /* @__PURE__ */ new Map();
@@ -3642,7 +3647,7 @@ function buildRequirementEntries(_sourceCode, targetCode, sourceReq, reqOffset,
3642
3647
  }
3643
3648
  }
3644
3649
  const acsByParent = /* @__PURE__ */ new Map();
3645
- for (const acId of sourceReq.acIds) {
3650
+ for (const acId of allAcIds) {
3646
3651
  const parent = acId.split("_AC-")[0];
3647
3652
  const acs = acsByParent.get(parent) ?? [];
3648
3653
  acs.push(acId);
@@ -3658,59 +3663,54 @@ function buildRequirementEntries(_sourceCode, targetCode, sourceReq, reqOffset,
3658
3663
  }
3659
3664
  }
3660
3665
  }
3661
- function buildPropertyEntries(_sourceCode, targetCode, sourceDesign, propOffset, entries) {
3662
- for (let i = 0; i < sourceDesign.propertyIds.length; i++) {
3663
- const oldId = sourceDesign.propertyIds[i];
3664
- const newNum = propOffset + i + 1;
3665
- const newId = `${targetCode}_P-${newNum}`;
3666
- entries.set(oldId, newId);
3666
+ function buildPropertyEntries(_sourceCode, targetCode, sourceDesigns, propOffset, entries) {
3667
+ let counter = 0;
3668
+ for (const sourceDesign of sourceDesigns) {
3669
+ for (const oldId of sourceDesign.propertyIds) {
3670
+ counter++;
3671
+ const newId = `${targetCode}_P-${propOffset + counter}`;
3672
+ entries.set(oldId, newId);
3673
+ }
3667
3674
  }
3668
3675
  }
3669
- function buildComponentEntries(sourceCode, targetCode, sourceDesign, entries) {
3670
- for (const compName of sourceDesign.componentNames) {
3671
- const prefix = `${sourceCode}-`;
3672
- if (compName.startsWith(prefix)) {
3673
- const suffix = compName.slice(prefix.length);
3674
- entries.set(compName, `${targetCode}-${suffix}`);
3676
+ function buildComponentEntries(sourceCode, targetCode, sourceDesigns, entries) {
3677
+ for (const sourceDesign of sourceDesigns) {
3678
+ for (const compName of sourceDesign.componentNames) {
3679
+ const prefix = `${sourceCode}-`;
3680
+ if (compName.startsWith(prefix)) {
3681
+ const suffix = compName.slice(prefix.length);
3682
+ entries.set(compName, `${targetCode}-${suffix}`);
3683
+ }
3675
3684
  }
3676
3685
  }
3677
3686
  }
3678
- function findHighestReqNumber(reqFile) {
3687
+ function findHighestReqNumber(reqFiles) {
3679
3688
  let max = 0;
3680
- for (const id of reqFile.requirementIds) {
3681
- if (id.includes(".")) continue;
3682
- const match = id.match(/-(\d+)$/);
3683
- if (match) {
3684
- const num = Number.parseInt(match[1], 10);
3685
- if (num > max) max = num;
3689
+ for (const reqFile of reqFiles) {
3690
+ for (const id of reqFile.requirementIds) {
3691
+ if (id.includes(".")) continue;
3692
+ const match = id.match(/-(\d+)$/);
3693
+ if (match) {
3694
+ const num = Number.parseInt(match[1], 10);
3695
+ if (num > max) max = num;
3696
+ }
3686
3697
  }
3687
3698
  }
3688
3699
  return max;
3689
3700
  }
3690
- function findHighestPropertyNumber(designFile) {
3701
+ function findHighestPropertyNumber(designFiles) {
3691
3702
  let max = 0;
3692
- for (const id of designFile.propertyIds) {
3693
- const match = id.match(/_P-(\d+)$/);
3694
- if (match) {
3695
- const num = Number.parseInt(match[1], 10);
3696
- if (num > max) max = num;
3703
+ for (const designFile of designFiles) {
3704
+ for (const id of designFile.propertyIds) {
3705
+ const match = id.match(/_P-(\d+)$/);
3706
+ if (match) {
3707
+ const num = Number.parseInt(match[1], 10);
3708
+ if (num > max) max = num;
3709
+ }
3697
3710
  }
3698
3711
  }
3699
3712
  return max;
3700
3713
  }
3701
- function findSpecFile(specFiles, code, prefix) {
3702
- return specFiles.find((sf) => {
3703
- const name = basename6(sf.filePath);
3704
- return name.startsWith(`${prefix}-${code}-`);
3705
- });
3706
- }
3707
- var SPEC_PREFIXES = ["FEAT", "REQ", "DESIGN", "EXAMPLE", "API", "TASK"];
3708
- function hasAnySpecFile(specFiles, code) {
3709
- return specFiles.some((sf) => {
3710
- const name = basename6(sf.filePath);
3711
- return SPEC_PREFIXES.some((prefix) => name.startsWith(`${prefix}-${code}-`));
3712
- });
3713
- }
3714
3714
 
3715
3715
  // src/commands/merge.ts
3716
3716
  async function mergeCommand(options) {
@@ -3764,7 +3764,7 @@ async function mergeCommand(options) {
3764
3764
  return 2;
3765
3765
  }
3766
3766
  if (options.renumber && !dryRun && !noChange) {
3767
- const { renumberCommand: renumberCommand2 } = await import("./renumber-ZCI2H5HZ.js");
3767
+ const { renumberCommand: renumberCommand2 } = await import("./renumber-OJS767K3.js");
3768
3768
  await renumberCommand2({
3769
3769
  code: options.targetCode,
3770
3770
  dryRun: false,
@@ -3948,7 +3948,7 @@ import { intro as intro4, outro as outro4 } from "@clack/prompts";
3948
3948
 
3949
3949
  // src/core/template-test/fixture-loader.ts
3950
3950
  import { readdir as readdir2 } from "fs/promises";
3951
- import { basename as basename7, extname as extname2, join as join10 } from "path";
3951
+ import { basename as basename6, extname as extname2, join as join10 } from "path";
3952
3952
  import { parse } from "smol-toml";
3953
3953
  async function discoverFixtures(templatePath) {
3954
3954
  const testsDir = join10(templatePath, "_tests");
@@ -3970,7 +3970,7 @@ async function discoverFixtures(templatePath) {
3970
3970
  async function parseFixture(filePath) {
3971
3971
  const content = await readTextFile(filePath);
3972
3972
  const parsed = parse(content);
3973
- const name = basename7(filePath, extname2(filePath));
3973
+ const name = basename6(filePath, extname2(filePath));
3974
3974
  const features = toStringArray2(parsed.features) ?? [];
3975
3975
  const preset = toStringArray2(parsed.preset) ?? [];
3976
3976
  const removeFeatures = toStringArray2(parsed["remove-features"]) ?? [];
@@ -5393,6 +5393,15 @@ async function writeCache(latestVersion) {
5393
5393
  }
5394
5394
  }
5395
5395
 
5396
+ // src/cli/option-source.ts
5397
+ function cliProvidedOption(command, options, key) {
5398
+ const source = command.getOptionValueSource(key);
5399
+ if (source === "cli" || source === "env") {
5400
+ return options[key];
5401
+ }
5402
+ return void 0;
5403
+ }
5404
+
5396
5405
  // src/cli/index.ts
5397
5406
  var version = PACKAGE_INFO.version;
5398
5407
  var program = new Command();
@@ -5411,24 +5420,25 @@ function configureGenerateCommand(cmd) {
5411
5420
  ).option("-c, --config <path>", "Path to configuration file").option("--refresh", "Force refresh of cached Git templates", false).option("--all-targets", "Process all named targets from config", false).option("--target <name>", "Process a specific named target from config").option(
5412
5421
  "--overlay <path...>",
5413
5422
  "Overlay directory paths applied over base template (repeatable)"
5414
- ).option("--json", "Output results as JSON (implies --dry-run)", false).option("--summary", "Output compact one-line summary", false).action(async (output, options) => {
5423
+ ).option("--json", "Output results as JSON (implies --dry-run)", false).option("--summary", "Output compact one-line summary", false).action(async (output, options, command) => {
5424
+ const allTargets = cliProvidedOption(command, options, "allTargets");
5415
5425
  const cliOptions = {
5416
5426
  output,
5417
- template: options.template,
5418
- features: options.features,
5419
- preset: options.preset,
5420
- removeFeatures: options.removeFeatures,
5421
- force: options.force,
5422
- dryRun: options.dryRun,
5423
- delete: options.delete,
5424
- config: options.config,
5425
- refresh: options.refresh,
5426
- all: options.allTargets,
5427
- allTargets: options.allTargets,
5428
- target: options.target,
5429
- overlay: options.overlay || [],
5430
- json: options.json,
5431
- summary: options.summary
5427
+ template: cliProvidedOption(command, options, "template"),
5428
+ features: cliProvidedOption(command, options, "features"),
5429
+ preset: cliProvidedOption(command, options, "preset"),
5430
+ removeFeatures: cliProvidedOption(command, options, "removeFeatures"),
5431
+ force: cliProvidedOption(command, options, "force"),
5432
+ dryRun: cliProvidedOption(command, options, "dryRun"),
5433
+ delete: cliProvidedOption(command, options, "delete"),
5434
+ config: cliProvidedOption(command, options, "config"),
5435
+ refresh: cliProvidedOption(command, options, "refresh"),
5436
+ all: allTargets,
5437
+ allTargets,
5438
+ target: cliProvidedOption(command, options, "target"),
5439
+ overlay: cliProvidedOption(command, options, "overlay"),
5440
+ json: cliProvidedOption(command, options, "json"),
5441
+ summary: cliProvidedOption(command, options, "summary")
5432
5442
  };
5433
5443
  await generateCommand(cliOptions);
5434
5444
  });
@@ -5438,24 +5448,25 @@ configureGenerateCommand(program.command("init"));
5438
5448
  template.command("diff").description("Compare template output with existing target directory").argument("[target]", "Target directory to compare against (optional if specified in config)").option("-t, --template <source>", "Template source (local path or Git repository)").option("-f, --features <flag...>", "Feature flags (can be specified multiple times)").option("--preset <name...>", "Preset names to enable (can be specified multiple times)").option(
5439
5449
  "--remove-features <flag...>",
5440
5450
  "Feature flags to remove (can be specified multiple times)"
5441
- ).option("-c, --config <path>", "Path to configuration file").option("--refresh", "Force refresh of cached Git templates", false).option("--list-unknown", "Include target-only files in diff results", false).option("--all-targets", "Process all named targets from config", false).option("--target <name>", "Process a specific named target from config").option("-w, --watch", "Watch template directory for changes and re-run diff", false).option("--overlay <path...>", "Overlay directory paths applied over base template (repeatable)").option("--json", "Output results as JSON", false).option("--summary", "Output compact one-line summary", false).action(async (target, options) => {
5451
+ ).option("-c, --config <path>", "Path to configuration file").option("--refresh", "Force refresh of cached Git templates", false).option("--list-unknown", "Include target-only files in diff results", false).option("--all-targets", "Process all named targets from config", false).option("--target <name>", "Process a specific named target from config").option("-w, --watch", "Watch template directory for changes and re-run diff", false).option("--overlay <path...>", "Overlay directory paths applied over base template (repeatable)").option("--json", "Output results as JSON", false).option("--summary", "Output compact one-line summary", false).action(async (target, options, command) => {
5452
+ const allTargets = cliProvidedOption(command, options, "allTargets");
5442
5453
  const cliOptions = {
5443
5454
  output: target,
5444
5455
  // Use target as output for consistency
5445
- template: options.template,
5446
- features: options.features,
5447
- preset: options.preset,
5448
- removeFeatures: options.removeFeatures,
5449
- config: options.config,
5450
- refresh: options.refresh,
5451
- listUnknown: options.listUnknown,
5452
- all: options.allTargets,
5453
- allTargets: options.allTargets,
5454
- target: options.target,
5455
- watch: options.watch,
5456
- overlay: options.overlay || [],
5457
- json: options.json,
5458
- summary: options.summary
5456
+ template: cliProvidedOption(command, options, "template"),
5457
+ features: cliProvidedOption(command, options, "features"),
5458
+ preset: cliProvidedOption(command, options, "preset"),
5459
+ removeFeatures: cliProvidedOption(command, options, "removeFeatures"),
5460
+ config: cliProvidedOption(command, options, "config"),
5461
+ refresh: cliProvidedOption(command, options, "refresh"),
5462
+ listUnknown: cliProvidedOption(command, options, "listUnknown"),
5463
+ all: allTargets,
5464
+ allTargets,
5465
+ target: cliProvidedOption(command, options, "target"),
5466
+ watch: cliProvidedOption(command, options, "watch"),
5467
+ overlay: cliProvidedOption(command, options, "overlay"),
5468
+ json: cliProvidedOption(command, options, "json"),
5469
+ summary: cliProvidedOption(command, options, "summary")
5459
5470
  };
5460
5471
  const exitCode = await diffCommand(cliOptions);
5461
5472
  process.exit(exitCode);
@@ -5475,41 +5486,41 @@ program.command("check").description(
5475
5486
  ).option(
5476
5487
  "--no-fix",
5477
5488
  "Skip regeneration of Requirements Traceability sections in DESIGN and TASK files"
5478
- ).action(async (options) => {
5489
+ ).action(async (options, command) => {
5479
5490
  const cliOptions = {
5480
- config: options.config,
5481
- specIgnore: options.specIgnore,
5482
- codeIgnore: options.codeIgnore,
5483
- format: options.format,
5484
- json: options.json,
5485
- summary: options.summary,
5486
- allowWarnings: options.allowWarnings,
5487
- specOnly: options.specOnly,
5488
- fix: options.fix
5491
+ config: cliProvidedOption(command, options, "config"),
5492
+ specIgnore: cliProvidedOption(command, options, "specIgnore"),
5493
+ codeIgnore: cliProvidedOption(command, options, "codeIgnore"),
5494
+ format: cliProvidedOption(command, options, "format"),
5495
+ json: cliProvidedOption(command, options, "json"),
5496
+ summary: cliProvidedOption(command, options, "summary"),
5497
+ allowWarnings: cliProvidedOption(command, options, "allowWarnings"),
5498
+ specOnly: cliProvidedOption(command, options, "specOnly"),
5499
+ fix: cliProvidedOption(command, options, "fix")
5489
5500
  };
5490
5501
  const exitCode = await checkCommand(cliOptions);
5491
5502
  process.exit(exitCode);
5492
5503
  });
5493
- template.command("features").description("Discover feature flags available in a template").option("-t, --template <source>", "Template source (local path or Git repository)").option("-c, --config <path>", "Path to configuration file").option("--refresh", "Force refresh of cached Git templates", false).option("--overlay <path...>", "Overlay directory paths applied over base template (repeatable)").option("--json", "Output results as JSON", false).option("--summary", "Output compact one-line summary", false).action(async (options) => {
5504
+ template.command("features").description("Discover feature flags available in a template").option("-t, --template <source>", "Template source (local path or Git repository)").option("-c, --config <path>", "Path to configuration file").option("--refresh", "Force refresh of cached Git templates", false).option("--overlay <path...>", "Overlay directory paths applied over base template (repeatable)").option("--json", "Output results as JSON", false).option("--summary", "Output compact one-line summary", false).action(async (options, command) => {
5494
5505
  const exitCode = await featuresCommand({
5495
- template: options.template,
5496
- config: options.config,
5497
- refresh: options.refresh,
5498
- json: options.json,
5499
- summary: options.summary,
5500
- overlay: options.overlay || []
5506
+ template: cliProvidedOption(command, options, "template"),
5507
+ config: cliProvidedOption(command, options, "config"),
5508
+ refresh: cliProvidedOption(command, options, "refresh"),
5509
+ json: cliProvidedOption(command, options, "json"),
5510
+ summary: cliProvidedOption(command, options, "summary"),
5511
+ overlay: cliProvidedOption(command, options, "overlay")
5501
5512
  });
5502
5513
  process.exit(exitCode);
5503
5514
  });
5504
- template.command("test").description("Run template test fixtures to verify expected output").option("-t, --template <source>", "Template source (local path or Git repository)").option("-c, --config <path>", "Path to configuration file").option("--update-snapshots", "Update stored snapshots with current rendered output", false).option("--refresh", "Force refresh of cached Git templates", false).option("--overlay <path...>", "Overlay directory paths applied over base template (repeatable)").option("--json", "Output results as JSON", false).option("--summary", "Output compact one-line summary", false).action(async (options) => {
5515
+ template.command("test").description("Run template test fixtures to verify expected output").option("-t, --template <source>", "Template source (local path or Git repository)").option("-c, --config <path>", "Path to configuration file").option("--update-snapshots", "Update stored snapshots with current rendered output", false).option("--refresh", "Force refresh of cached Git templates", false).option("--overlay <path...>", "Overlay directory paths applied over base template (repeatable)").option("--json", "Output results as JSON", false).option("--summary", "Output compact one-line summary", false).action(async (options, command) => {
5505
5516
  const testOptions = {
5506
- template: options.template,
5507
- config: options.config,
5508
- updateSnapshots: options.updateSnapshots,
5509
- refresh: options.refresh,
5510
- json: options.json,
5511
- summary: options.summary,
5512
- overlay: options.overlay || []
5517
+ template: cliProvidedOption(command, options, "template"),
5518
+ config: cliProvidedOption(command, options, "config"),
5519
+ updateSnapshots: cliProvidedOption(command, options, "updateSnapshots") ?? false,
5520
+ refresh: cliProvidedOption(command, options, "refresh"),
5521
+ json: cliProvidedOption(command, options, "json"),
5522
+ summary: cliProvidedOption(command, options, "summary"),
5523
+ overlay: cliProvidedOption(command, options, "overlay")
5513
5524
  };
5514
5525
  const exitCode = await testCommand(testOptions);
5515
5526
  process.exit(exitCode);
@@ -5545,13 +5556,18 @@ function configureTraceCommand(cmd) {
5545
5556
  }
5546
5557
  configureTraceCommand(spec.command("trace"));
5547
5558
  function configureRenumberCommand(cmd) {
5548
- return cmd.description("Renumber traceability IDs to match document order").argument("[code]", "Feature code to renumber (e.g. CHK, TRC)").option("--all", "Renumber all feature codes", false).option("--dry-run", "Preview changes without modifying files", false).option("--json", "Output results as JSON", false).option("-c, --config <path>", "Path to configuration file").action(async (code, options) => {
5559
+ return cmd.description("Renumber traceability IDs to match document order").argument("[code]", "Feature code to renumber (e.g. CHK, TRC)").option("--all", "Renumber all feature codes", false).option("--dry-run", "Preview changes without modifying files", false).option("--json", "Output results as JSON", false).option(
5560
+ "--expand-unambiguous-ids",
5561
+ "Expand unambiguous malformed ID shorthand (slash ranges, dot-dot ranges) before renumbering",
5562
+ false
5563
+ ).option("-c, --config <path>", "Path to configuration file").action(async (code, options) => {
5549
5564
  const renumberOptions = {
5550
5565
  code,
5551
5566
  all: options.all,
5552
5567
  dryRun: options.dryRun,
5553
5568
  json: options.json,
5554
- config: options.config
5569
+ config: options.config,
5570
+ expandUnambiguousIds: options.expandUnambiguousIds
5555
5571
  };
5556
5572
  const exitCode = await renumberCommand(renumberOptions);
5557
5573
  process.exit(exitCode);
@@ -5601,7 +5617,7 @@ var isDisabledByEnv = !!process.env.NO_UPDATE_NOTIFIER;
5601
5617
  if (!isJsonOrSummary && isTTY && !isDisabledByEnv) {
5602
5618
  updateCheckPromise = (async () => {
5603
5619
  try {
5604
- const { configLoader: configLoader2 } = await import("./config-EJIXC7D7.js");
5620
+ const { configLoader: configLoader2 } = await import("./config-SJLBJX77.js");
5605
5621
  const configPath = process.argv.indexOf("-c") !== -1 ? process.argv[process.argv.indexOf("-c") + 1] : process.argv.indexOf("--config") !== -1 ? process.argv[process.argv.indexOf("--config") + 1] : void 0;
5606
5622
  const fileConfig = await configLoader2.load(configPath ?? null);
5607
5623
  const updateCheckConfig = fileConfig?.["update-check"];