@uniformdev/transformer 1.1.1 → 1.1.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/propagate-root-component-property.ts","../../src/core/services/file-system.service.ts","../../src/core/errors.ts","../../src/core/services/component.service.ts","../../src/core/services/composition.service.ts","../../src/core/services/property-propagator.service.ts","../../src/cli/logger.ts","../../src/cli/commands/find-composition-pattern-candidates.ts","../../src/core/services/pattern-analyzer.service.ts","../../src/cli/commands/unpack-serialization.ts","../../src/core/services/serialization-packer.service.ts","../../src/cli/commands/pack-serialization.ts","../../src/cli/commands/rename-slot.ts","../../src/core/services/slot-renamer.service.ts","../../src/cli/commands/rename-component.ts","../../src/core/services/component-renamer.service.ts","../../src/cli/commands/add-component.ts","../../src/core/services/component-adder.service.ts","../../src/cli/commands/add-component-pattern.ts","../../src/cli/commands/propagate-root-component-slot.ts","../../src/core/services/slot-propagator.service.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { createPropagateRootComponentPropertyCommand } from './commands/propagate-root-component-property.js';\nimport { createFindCompositionPatternCandidatesCommand } from './commands/find-composition-pattern-candidates.js';\nimport { createUnpackSerializationCommand } from './commands/unpack-serialization.js';\nimport { createPackSerializationCommand } from './commands/pack-serialization.js';\nimport { createRenameSlotCommand } from './commands/rename-slot.js';\nimport { createRenameComponentCommand } from './commands/rename-component.js';\nimport { createAddComponentCommand } from './commands/add-component.js';\nimport { createAddComponentPatternCommand } from './commands/add-component-pattern.js';\nimport { createPropagateRootComponentSlotCommand } from './commands/propagate-root-component-slot.js';\n\nconst program = new Command();\n\nprogram\n .name('uniform-transform')\n .description('CLI tool for transforming Uniform.dev serialization files offline')\n .version('1.0.0');\n\n// Global options\nprogram\n .requiredOption('--rootDir <path>', 'Path to the serialization project root')\n .option('--what-if', 'Dry run mode - preview changes without modifying files', false)\n .option('--strict', 'Enable strict mode for case-sensitive matching', false)\n .option('--compositionsDir <dir>', 'Compositions directory name', 'composition')\n .option('--componentsDir <dir>', 'Components directory name', 'component')\n .option('--contentTypesDir <dir>', 'Content types directory name', 'contentType')\n .option('--assetsDir <dir>', 'Assets directory name', 'asset')\n .option('--categoriesDir <dir>', 'Categories directory name', 'category')\n .option('--componentPatternsDir <dir>', 'Component patterns directory name', 'componentPattern')\n .option(\n '--compositionPatternsDir <dir>',\n 'Composition patterns directory name',\n 'compositionPattern'\n )\n .option('--dataTypesDir <dir>', 'Data types directory name', 'dataType')\n .option('--entriesDir <dir>', 'Entries directory name', 'entry')\n .option('--filesDir <dir>', 'Files directory name', 'files')\n .option('--previewUrlsDir <dir>', 'Preview URLs directory name', 'previewUrl')\n .option('--previewViewportsDir <dir>', 'Preview viewports directory name', 'previewViewport')\n .option(\n '--projectMapDefinitionsDir <dir>',\n 'Project map definitions directory name',\n 'projectMapDefinition'\n )\n .option('--projectMapNodesDir <dir>', 'Project map nodes directory name', 'projectMapNode')\n .option('--quirksDir <dir>', 'Quirks directory name', 'quirk');\n\n// Add commands\nprogram.addCommand(createPropagateRootComponentPropertyCommand());\nprogram.addCommand(createFindCompositionPatternCandidatesCommand());\nprogram.addCommand(createUnpackSerializationCommand());\nprogram.addCommand(createPackSerializationCommand());\nprogram.addCommand(createRenameSlotCommand());\nprogram.addCommand(createRenameComponentCommand());\nprogram.addCommand(createAddComponentCommand());\nprogram.addCommand(createAddComponentPatternCommand());\nprogram.addCommand(createPropagateRootComponentSlotCommand());\n\nprogram.parse();\n","import { Command } from 'commander';\nimport { PropagateRootComponentPropertyOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { CompositionService } from '../../core/services/composition.service.js';\nimport { PropertyPropagatorService } from '../../core/services/property-propagator.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createPropagateRootComponentPropertyCommand(): Command {\n const command = new Command('propagate-root-component-property');\n\n command\n .description(\n 'Copies property definitions from a composition type\\'s root component to a target component type, then propagates the actual values across all matching compositions.'\n )\n .option('--compositionType <type>', 'The composition type to process (e.g., HomePage)')\n .option('--property <properties>', 'Pipe-separated list of properties and/or groups to copy')\n .option(\n '--targetComponentType <type>',\n 'The component type that will receive the copied properties'\n )\n .option(\n '--targetGroup <group>',\n 'The group name on the target component where properties will be placed'\n )\n .option(\n '--deleteSourceParameter',\n 'Delete the original parameters from the source component after propagation'\n )\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'compositionType', flag: '--compositionType' },\n { name: 'property', flag: '--property' },\n { name: 'targetComponentType', flag: '--targetComponentType' },\n { name: 'targetGroup', flag: '--targetGroup' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: PropagateRootComponentPropertyOptions = {\n ...globalOpts,\n compositionType: opts.compositionType,\n property: opts.property,\n targetComponentType: opts.targetComponentType,\n targetGroup: opts.targetGroup,\n deleteSourceParameter: opts.deleteSourceParameter,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const compositionService = new CompositionService(fileSystem);\n const propagator = new PropertyPropagatorService(\n fileSystem,\n componentService,\n compositionService,\n logger\n );\n\n try {\n const result = await propagator.propagate({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionType: options.compositionType,\n property: options.property,\n targetComponentType: options.targetComponentType,\n targetGroup: options.targetGroup,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n deleteSourceParameter: options.deleteSourceParameter ?? false,\n });\n\n logger.success(\n `Modified ${result.modifiedComponents} component, ${result.modifiedCompositions} compositions`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { glob } from 'glob';\nimport * as YAML from 'yaml';\nimport { InvalidYamlError, FileNotFoundError } from '../errors.js';\n\nexport class FileSystemService {\n private isJsonFile(filePath: string): boolean {\n return filePath.toLowerCase().endsWith('.json');\n }\n\n async readFile<T>(filePath: string): Promise<T> {\n if (!fs.existsSync(filePath)) {\n throw new FileNotFoundError(filePath);\n }\n\n try {\n const content = fs.readFileSync(filePath, 'utf-8');\n if (this.isJsonFile(filePath)) {\n return JSON.parse(content) as T;\n }\n return YAML.parse(content) as T;\n } catch (error) {\n if (error instanceof FileNotFoundError) {\n throw error;\n }\n const message = error instanceof Error ? error.message : String(error);\n throw new InvalidYamlError(filePath, message);\n }\n }\n\n async writeFile<T>(filePath: string, data: T): Promise<void> {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n let content: string;\n if (this.isJsonFile(filePath)) {\n content = JSON.stringify(data, null, 2);\n } else {\n content = YAML.stringify(data, {\n lineWidth: 0,\n defaultKeyType: 'PLAIN',\n defaultStringType: 'QUOTE_DOUBLE',\n });\n }\n fs.writeFileSync(filePath, content, 'utf-8');\n }\n\n async readYamlFile<T>(filePath: string): Promise<T> {\n return this.readFile<T>(filePath);\n }\n\n async writeYamlFile<T>(filePath: string, data: T): Promise<void> {\n return this.writeFile(filePath, data);\n }\n\n async findFiles(directory: string, pattern: string): Promise<string[]> {\n const fullPattern = path.join(directory, pattern).replace(/\\\\/g, '/');\n return glob(fullPattern);\n }\n\n async fileExists(filePath: string): Promise<boolean> {\n return fs.existsSync(filePath);\n }\n\n resolvePath(...segments: string[]): string {\n return path.resolve(...segments);\n }\n\n joinPath(...segments: string[]): string {\n return path.join(...segments);\n }\n\n getBasename(filePath: string, ext?: string): string {\n return path.basename(filePath, ext);\n }\n\n async renameFile(oldPath: string, newPath: string): Promise<void> {\n fs.renameSync(oldPath, newPath);\n }\n\n deleteFile(filePath: string): void {\n fs.unlinkSync(filePath);\n }\n\n getExtension(filePath: string): string {\n return path.extname(filePath);\n }\n\n getDirname(filePath: string): string {\n return path.dirname(filePath);\n }\n}\n","export class TransformError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TransformError';\n }\n}\n\nexport class ComponentNotFoundError extends TransformError {\n constructor(componentType: string, path?: string) {\n const pathInfo = path ? ` (searched: ${path})` : '';\n super(`Component not found: ${componentType}${pathInfo}`);\n this.name = 'ComponentNotFoundError';\n }\n}\n\nexport class PropertyNotFoundError extends TransformError {\n constructor(propertyName: string, componentType: string) {\n super(`Property \"${propertyName}\" not found on component \"${componentType}\"`);\n this.name = 'PropertyNotFoundError';\n }\n}\n\nexport class InvalidYamlError extends TransformError {\n constructor(filePath: string, details?: string) {\n const detailsInfo = details ? `: ${details}` : '';\n super(`Invalid YAML file: ${filePath}${detailsInfo}`);\n this.name = 'InvalidYamlError';\n }\n}\n\nexport class FileNotFoundError extends TransformError {\n constructor(filePath: string) {\n super(`File not found: ${filePath}`);\n this.name = 'FileNotFoundError';\n }\n}\n\nexport class DuplicateIdError extends TransformError {\n constructor(id: string, arrayProperty: string, filePath: string) {\n super(`Duplicate id \"${id}\" in array \"${arrayProperty}\" of file: ${filePath}`);\n this.name = 'DuplicateIdError';\n }\n}\n\nexport class ComponentAlreadyExistsError extends TransformError {\n constructor(componentType: string, path?: string) {\n const pathInfo = path ? ` (searched: ${path})` : '';\n super(`Component type \"${componentType}\" already exists${pathInfo}`);\n this.name = 'ComponentAlreadyExistsError';\n }\n}\n\nexport class SlotNotFoundError extends TransformError {\n constructor(slotId: string, componentType: string) {\n super(`Slot \"${slotId}\" does not exist on component \"${componentType}\"`);\n this.name = 'SlotNotFoundError';\n }\n}\n\nexport class SlotAlreadyExistsError extends TransformError {\n constructor(slotId: string, componentType: string) {\n super(`Slot \"${slotId}\" already exists on component \"${componentType}\"`);\n this.name = 'SlotAlreadyExistsError';\n }\n}\n","import { ComponentDefinition, Parameter, SlotDefinition } from '../types/index.js';\nimport { ComponentNotFoundError, PropertyNotFoundError } from '../errors.js';\nimport { FileSystemService } from './file-system.service.js';\n\nexport interface FindOptions {\n strict?: boolean;\n}\n\nexport class ComponentService {\n constructor(private fileSystem: FileSystemService) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async loadComponent(\n componentsDir: string,\n componentType: string,\n options: FindOptions = {}\n ): Promise<{ component: ComponentDefinition; filePath: string }> {\n const { strict = false } = options;\n\n // First try exact match\n const jsonPath = this.fileSystem.joinPath(componentsDir, `${componentType}.json`);\n const yamlPath = this.fileSystem.joinPath(componentsDir, `${componentType}.yaml`);\n const ymlPath = this.fileSystem.joinPath(componentsDir, `${componentType}.yml`);\n\n if (await this.fileSystem.fileExists(jsonPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(jsonPath);\n return { component, filePath: jsonPath };\n }\n if (await this.fileSystem.fileExists(yamlPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(yamlPath);\n return { component, filePath: yamlPath };\n }\n if (await this.fileSystem.fileExists(ymlPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(ymlPath);\n return { component, filePath: ymlPath };\n }\n\n // If not strict, try case-insensitive search\n if (!strict) {\n const files = await this.fileSystem.findFiles(componentsDir, '*.{json,yaml,yml}');\n for (const filePath of files) {\n const basename = this.fileSystem.getBasename(filePath);\n const nameWithoutExt = basename.replace(/\\.(json|yaml|yml)$/i, '');\n if (nameWithoutExt.toLowerCase() === componentType.toLowerCase()) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(filePath);\n return { component, filePath };\n }\n }\n }\n\n throw new ComponentNotFoundError(componentType, componentsDir);\n }\n\n async saveComponent(filePath: string, component: ComponentDefinition): Promise<void> {\n await this.fileSystem.writeFile(filePath, component);\n }\n\n findParameter(\n component: ComponentDefinition,\n parameterName: string,\n options: FindOptions = {}\n ): Parameter | undefined {\n const { strict = false } = options;\n return component.parameters?.find((p) => this.compareIds(p.id, parameterName, strict));\n }\n\n isGroupParameter(parameter: Parameter): boolean {\n return parameter.type === 'group';\n }\n\n resolveGroupParameters(\n component: ComponentDefinition,\n groupParameter: Parameter,\n options: FindOptions = {}\n ): Parameter[] {\n if (!this.isGroupParameter(groupParameter)) {\n return [groupParameter];\n }\n\n const childrenIds = groupParameter.typeConfig?.childrenParams ?? [];\n const resolved: Parameter[] = [];\n\n for (const childId of childrenIds) {\n const childParam = this.findParameter(component, childId, options);\n if (childParam) {\n resolved.push(childParam);\n }\n }\n\n return resolved;\n }\n\n resolveProperties(\n component: ComponentDefinition,\n propertyNames: string[],\n options: FindOptions = {}\n ): { parameters: Parameter[]; notFound: string[] } {\n const parameters: Parameter[] = [];\n const notFound: string[] = [];\n const seenIds = new Set<string>();\n\n for (const name of propertyNames) {\n const param = this.findParameter(component, name, options);\n if (!param) {\n notFound.push(name);\n continue;\n }\n\n if (this.isGroupParameter(param)) {\n const groupParams = this.resolveGroupParameters(component, param, options);\n for (const gp of groupParams) {\n if (!seenIds.has(gp.id)) {\n seenIds.add(gp.id);\n parameters.push(gp);\n }\n }\n } else {\n if (!seenIds.has(param.id)) {\n seenIds.add(param.id);\n parameters.push(param);\n }\n }\n }\n\n return { parameters, notFound };\n }\n\n addParameterToComponent(\n component: ComponentDefinition,\n parameter: Parameter,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n component.parameters = [];\n }\n\n const existingIndex = component.parameters.findIndex((p) =>\n this.compareIds(p.id, parameter.id, strict)\n );\n if (existingIndex >= 0) {\n component.parameters[existingIndex] = { ...parameter };\n } else {\n component.parameters.push({ ...parameter });\n }\n\n return component;\n }\n\n ensureGroupExists(\n component: ComponentDefinition,\n groupId: string,\n groupName?: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n component.parameters = [];\n }\n\n const existing = component.parameters.find((p) => this.compareIds(p.id, groupId, strict));\n if (existing) {\n return component;\n }\n\n const groupParam: Parameter = {\n id: groupId,\n name: groupName ?? groupId,\n type: 'group',\n typeConfig: {\n childrenParams: [],\n },\n };\n\n component.parameters.push(groupParam);\n return component;\n }\n\n addParameterToGroup(\n component: ComponentDefinition,\n groupId: string,\n parameterId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n const group = component.parameters?.find((p) => this.compareIds(p.id, groupId, strict));\n if (!group || !this.isGroupParameter(group)) {\n throw new PropertyNotFoundError(groupId, component.id);\n }\n\n if (!group.typeConfig) {\n group.typeConfig = { childrenParams: [] };\n }\n if (!group.typeConfig.childrenParams) {\n group.typeConfig.childrenParams = [];\n }\n\n // Check if already exists (case-insensitive if not strict)\n const alreadyExists = group.typeConfig.childrenParams.some((id) =>\n this.compareIds(id, parameterId, strict)\n );\n\n if (!alreadyExists) {\n group.typeConfig.childrenParams.push(parameterId);\n }\n\n return component;\n }\n\n removeParameter(\n component: ComponentDefinition,\n parameterId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n return component;\n }\n\n component.parameters = component.parameters.filter(\n (p) => !this.compareIds(p.id, parameterId, strict)\n );\n\n // Also remove from any groups that reference this parameter\n for (const param of component.parameters) {\n if (this.isGroupParameter(param) && param.typeConfig?.childrenParams) {\n param.typeConfig.childrenParams = param.typeConfig.childrenParams.filter(\n (id) => !this.compareIds(id, parameterId, strict)\n );\n }\n }\n\n return component;\n }\n\n removeEmptyGroups(component: ComponentDefinition): ComponentDefinition {\n if (!component.parameters) {\n return component;\n }\n\n component.parameters = component.parameters.filter((p) => {\n if (!this.isGroupParameter(p)) {\n return true;\n }\n const children = p.typeConfig?.childrenParams ?? [];\n return children.length > 0;\n });\n\n return component;\n }\n\n // Slot methods\n\n findSlot(\n component: ComponentDefinition,\n slotId: string,\n options: FindOptions = {}\n ): SlotDefinition | undefined {\n const { strict = false } = options;\n return component.slots?.find((s) => this.compareIds(s.id, slotId, strict));\n }\n\n addSlot(component: ComponentDefinition, slot: SlotDefinition): ComponentDefinition {\n if (!component.slots) {\n component.slots = [];\n }\n component.slots.push({ ...slot });\n return component;\n }\n\n updateSlotAllowedComponents(\n component: ComponentDefinition,\n slotId: string,\n allowedComponents: string[],\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n const slot = component.slots?.find((s) => this.compareIds(s.id, slotId, strict));\n if (slot) {\n slot.allowedComponents = allowedComponents;\n }\n return component;\n }\n\n removeSlot(\n component: ComponentDefinition,\n slotId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.slots) {\n return component;\n }\n component.slots = component.slots.filter((s) => !this.compareIds(s.id, slotId, strict));\n return component;\n }\n}\n","import { Composition, ComponentInstance, ParameterValue } from '../types/index.js';\nimport { FileSystemService } from './file-system.service.js';\n\nexport interface FindOptions {\n strict?: boolean;\n}\n\nexport interface FoundComponentInstance {\n instance: ComponentInstance;\n instanceId: string;\n path: string[];\n}\n\nexport class CompositionService {\n constructor(private fileSystem: FileSystemService) {}\n\n private compareTypes(type1: string, type2: string, strict: boolean): boolean {\n if (strict) {\n return type1 === type2;\n }\n return type1.toLowerCase() === type2.toLowerCase();\n }\n\n async loadComposition(filePath: string): Promise<Composition> {\n return this.fileSystem.readFile<Composition>(filePath);\n }\n\n async saveComposition(filePath: string, composition: Composition): Promise<void> {\n await this.fileSystem.writeFile(filePath, composition);\n }\n\n async findCompositionsByType(\n compositionsDir: string,\n compositionType: string,\n options: FindOptions = {}\n ): Promise<{ composition: Composition; filePath: string }[]> {\n const { strict = false } = options;\n const files = await this.fileSystem.findFiles(compositionsDir, '**/*.{json,yaml,yml}');\n const results: { composition: Composition; filePath: string }[] = [];\n\n for (const filePath of files) {\n try {\n const composition = await this.loadComposition(filePath);\n if (\n composition.composition?.type &&\n this.compareTypes(composition.composition.type, compositionType, strict)\n ) {\n results.push({ composition, filePath });\n }\n } catch {\n // Skip invalid files\n }\n }\n\n return results;\n }\n\n findComponentInstances(\n composition: Composition,\n componentType: string,\n options: FindOptions = {}\n ): FoundComponentInstance[] {\n const { strict = false } = options;\n const results: FoundComponentInstance[] = [];\n this.searchSlots(composition.composition.slots ?? {}, componentType, [], results, strict);\n return results;\n }\n\n private searchSlots(\n slots: Record<string, ComponentInstance[]>,\n componentType: string,\n currentPath: string[],\n results: FoundComponentInstance[],\n strict: boolean\n ): void {\n for (const [slotName, instances] of Object.entries(slots)) {\n if (!Array.isArray(instances)) continue;\n\n for (let i = 0; i < instances.length; i++) {\n const instance = instances[i];\n const instancePath = [...currentPath, slotName, String(i)];\n\n if (this.compareTypes(instance.type, componentType, strict)) {\n const instanceId = instance._id ?? `${componentType}-${results.length}`;\n results.push({\n instance,\n instanceId,\n path: instancePath,\n });\n }\n\n if (instance.slots) {\n this.searchSlots(instance.slots, componentType, instancePath, results, strict);\n }\n }\n }\n }\n\n getRootOverrides(composition: Composition): Record<string, ParameterValue> {\n const rootId = composition.composition._id;\n // Check _overrides first (newer format), then fall back to direct parameters (older format)\n const overrides = composition.composition._overrides?.[rootId]?.parameters;\n if (overrides && Object.keys(overrides).length > 0) {\n return overrides;\n }\n // Fall back to direct parameters on the composition root\n return (composition.composition as { parameters?: Record<string, ParameterValue> }).parameters ?? {};\n }\n\n getInstanceOverrides(\n composition: Composition,\n instanceId: string\n ): Record<string, ParameterValue> {\n return composition.composition._overrides?.[instanceId]?.parameters ?? {};\n }\n\n setInstanceOverride(\n composition: Composition,\n instanceId: string,\n parameterId: string,\n value: ParameterValue\n ): Composition {\n if (!composition.composition._overrides) {\n composition.composition._overrides = {};\n }\n if (!composition.composition._overrides[instanceId]) {\n composition.composition._overrides[instanceId] = {};\n }\n if (!composition.composition._overrides[instanceId].parameters) {\n composition.composition._overrides[instanceId].parameters = {};\n }\n\n composition.composition._overrides[instanceId].parameters![parameterId] = value;\n return composition;\n }\n\n setInstanceOverrides(\n composition: Composition,\n instanceId: string,\n parameters: Record<string, ParameterValue>\n ): Composition {\n for (const [paramId, value] of Object.entries(parameters)) {\n this.setInstanceOverride(composition, instanceId, paramId, value);\n }\n return composition;\n }\n\n /**\n * Sets parameters directly on a component instance (preferred approach).\n * This modifies the instance object in-place.\n */\n setInstanceParameters(\n instance: ComponentInstance,\n parameters: Record<string, ParameterValue>\n ): void {\n if (!instance.parameters) {\n instance.parameters = {};\n }\n for (const [paramId, value] of Object.entries(parameters)) {\n instance.parameters[paramId] = value;\n }\n }\n\n /**\n * Deletes parameters from root overrides.\n * Returns true if any parameters were deleted.\n */\n deleteRootOverrides(\n composition: Composition,\n parameterIds: string[],\n options: FindOptions = {}\n ): boolean {\n const { strict = false } = options;\n const rootId = composition.composition._id;\n let deleted = false;\n\n // Check _overrides first (newer format)\n const overrides = composition.composition._overrides?.[rootId]?.parameters;\n if (overrides) {\n for (const paramId of parameterIds) {\n for (const key of Object.keys(overrides)) {\n if (strict ? key === paramId : key.toLowerCase() === paramId.toLowerCase()) {\n delete overrides[key];\n deleted = true;\n }\n }\n }\n }\n\n // Also check direct parameters on root (older format)\n const rootParams = (composition.composition as { parameters?: Record<string, ParameterValue> })\n .parameters;\n if (rootParams) {\n for (const paramId of parameterIds) {\n for (const key of Object.keys(rootParams)) {\n if (strict ? key === paramId : key.toLowerCase() === paramId.toLowerCase()) {\n delete rootParams[key];\n deleted = true;\n }\n }\n }\n }\n\n return deleted;\n }\n}\n","import { ParameterValue } from '../types/index.js';\nimport { PropertyNotFoundError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { CompositionService } from './composition.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface PropagateOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionType: string;\n property: string;\n targetComponentType: string;\n targetGroup: string;\n whatIf: boolean;\n strict: boolean;\n deleteSourceParameter: boolean;\n}\n\nexport interface PropagateResult {\n modifiedComponents: number;\n modifiedCompositions: number;\n propagatedInstances: number;\n}\n\nexport class PropertyPropagatorService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private compositionService: CompositionService,\n private logger: Logger\n ) {}\n\n async propagate(options: PropagateOptions): Promise<PropagateResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionType,\n property,\n targetComponentType,\n targetGroup,\n whatIf,\n strict,\n deleteSourceParameter,\n } = options;\n\n const findOptions = { strict };\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n\n // Step 1: Load source component (compositionType)\n this.logger.info(`Loading component: ${compositionType}`);\n const { component: sourceComponent, filePath: sourceFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, compositionType, findOptions);\n\n // Step 2: Load target component\n this.logger.info(`Loading component: ${targetComponentType}`);\n const { component: targetComponent, filePath: targetFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, targetComponentType, findOptions);\n\n // Step 3: Parse and resolve properties\n const propertyNames = property.split('|').map((p) => p.trim());\n const { parameters: resolvedParams, notFound } = this.componentService.resolveProperties(\n sourceComponent,\n propertyNames,\n findOptions\n );\n\n if (notFound.length > 0) {\n throw new PropertyNotFoundError(notFound.join(', '), compositionType);\n }\n\n const resolvedNames = resolvedParams.map((p) => p.id);\n const groupSources = propertyNames.filter((name) => {\n const param = this.componentService.findParameter(sourceComponent, name, findOptions);\n return param && this.componentService.isGroupParameter(param);\n });\n\n if (groupSources.length > 0) {\n this.logger.info(\n `Resolved properties: ${resolvedNames.join(', ')} (from ${groupSources.join(', ')})`\n );\n } else {\n this.logger.info(`Resolved properties: ${resolvedNames.join(', ')}`);\n }\n\n // Step 4: Modify target component\n let modifiedComponent = { ...targetComponent };\n let componentModified = false;\n\n // Ensure target group exists\n const existingGroup = this.componentService.findParameter(\n modifiedComponent,\n targetGroup,\n findOptions\n );\n if (!existingGroup) {\n this.logger.action(whatIf, 'CREATE', `Group \"${targetGroup}\" on ${targetComponentType}`);\n modifiedComponent = this.componentService.ensureGroupExists(\n modifiedComponent,\n targetGroup,\n undefined,\n findOptions\n );\n componentModified = true;\n }\n\n // Copy parameter definitions to target\n for (const param of resolvedParams) {\n const existingParam = this.componentService.findParameter(\n modifiedComponent,\n param.id,\n findOptions\n );\n if (!existingParam) {\n this.logger.action(\n whatIf,\n 'COPY',\n `Parameter \"${param.id}\" → ${targetComponentType}.${targetGroup}`\n );\n modifiedComponent = this.componentService.addParameterToComponent(\n modifiedComponent,\n param,\n findOptions\n );\n modifiedComponent = this.componentService.addParameterToGroup(\n modifiedComponent,\n targetGroup,\n param.id,\n findOptions\n );\n componentModified = true;\n } else {\n this.logger.info(`Parameter \"${param.id}\" already exists on ${targetComponentType}`);\n // Ensure it's in the group\n const group = this.componentService.findParameter(\n modifiedComponent,\n targetGroup,\n findOptions\n );\n if (group && this.componentService.isGroupParameter(group)) {\n // Check if param is already in group (case-insensitive if not strict)\n const isInGroup = group.typeConfig?.childrenParams?.some((id) =>\n strict ? id === param.id : id.toLowerCase() === param.id.toLowerCase()\n );\n if (!isInGroup) {\n modifiedComponent = this.componentService.addParameterToGroup(\n modifiedComponent,\n targetGroup,\n param.id,\n findOptions\n );\n componentModified = true;\n }\n }\n }\n }\n\n // Save modified component\n if (componentModified && !whatIf) {\n await this.componentService.saveComponent(targetFilePath, modifiedComponent);\n }\n\n // Step 5: Propagate values in compositions\n const compositions = await this.compositionService.findCompositionsByType(\n fullCompositionsDir,\n compositionType,\n findOptions\n );\n\n let modifiedCompositions = 0;\n let propagatedInstances = 0;\n\n for (const { composition, filePath } of compositions) {\n const rootOverrides = this.compositionService.getRootOverrides(composition);\n const instances = this.compositionService.findComponentInstances(\n composition,\n targetComponentType,\n findOptions\n );\n\n if (instances.length === 0) {\n continue;\n }\n\n // Build the values to propagate\n const valuesToPropagate: Record<string, ParameterValue> = {};\n for (const param of resolvedParams) {\n if (rootOverrides[param.id]) {\n valuesToPropagate[param.id] = rootOverrides[param.id];\n }\n }\n\n if (Object.keys(valuesToPropagate).length === 0) {\n continue;\n }\n\n let compositionModified = false;\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n const instanceUpdates: string[] = [];\n\n for (const { instance, instanceId } of instances) {\n const instanceName = instance._id ?? instanceId;\n // Set parameters directly on the instance (preferred over _overrides)\n this.compositionService.setInstanceParameters(instance, valuesToPropagate);\n compositionModified = true;\n propagatedInstances++;\n instanceUpdates.push(\n `${targetComponentType} \"${instanceName}\": ${Object.keys(valuesToPropagate).join(', ')}`\n );\n }\n\n if (compositionModified) {\n this.logger.action(whatIf, 'UPDATE', `composition/${relativePath}`);\n for (const update of instanceUpdates) {\n this.logger.detail(`→ ${update}`);\n }\n\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n modifiedCompositions++;\n }\n }\n\n // Step 6: Delete source parameters if requested\n let sourceComponentModified = false;\n if (deleteSourceParameter) {\n let modifiedSource = { ...sourceComponent };\n\n // Delete the resolved parameters from source component\n for (const param of resolvedParams) {\n this.logger.action(whatIf, 'DELETE', `Parameter \"${param.id}\" from ${compositionType}`);\n modifiedSource = this.componentService.removeParameter(modifiedSource, param.id, findOptions);\n sourceComponentModified = true;\n }\n\n // Also delete any groups that are now empty\n const beforeGroupCount = modifiedSource.parameters?.filter((p) =>\n this.componentService.isGroupParameter(p)\n ).length ?? 0;\n modifiedSource = this.componentService.removeEmptyGroups(modifiedSource);\n const afterGroupCount = modifiedSource.parameters?.filter((p) =>\n this.componentService.isGroupParameter(p)\n ).length ?? 0;\n if (afterGroupCount < beforeGroupCount) {\n const removedCount = beforeGroupCount - afterGroupCount;\n this.logger.action(\n whatIf,\n 'DELETE',\n `${removedCount} empty group(s) from ${compositionType}`\n );\n }\n\n if (sourceComponentModified && !whatIf) {\n await this.componentService.saveComponent(sourceFilePath, modifiedSource);\n }\n\n // Delete parameter values from root overrides in compositions\n for (const { composition, filePath } of compositions) {\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n const deleted = this.compositionService.deleteRootOverrides(\n composition,\n resolvedNames,\n findOptions\n );\n if (deleted) {\n this.logger.action(whatIf, 'DELETE', `Root overrides from composition/${relativePath}`);\n this.logger.detail(`→ Removed: ${resolvedNames.join(', ')}`);\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n }\n }\n }\n\n return {\n modifiedComponents: (componentModified ? 1 : 0) + (sourceComponentModified ? 1 : 0),\n modifiedCompositions,\n propagatedInstances,\n };\n }\n}\n","import chalk from 'chalk';\n\nexport class Logger {\n info(message: string): void {\n console.log(`${chalk.blue('[INFO]')} ${message}`);\n }\n\n success(message: string): void {\n console.log(`${chalk.green('[DONE]')} ${message}`);\n }\n\n error(message: string): void {\n console.log(`${chalk.red('[ERROR]')} ${message}`);\n }\n\n warn(message: string): void {\n console.log(`${chalk.yellow('[WARN]')} ${message}`);\n }\n\n action(whatIf: boolean, actionType: string, message: string): void {\n const prefix = whatIf ? chalk.yellow('[WOULD]') : chalk.green(`[${actionType}]`);\n console.log(`${prefix} ${message}`);\n }\n\n detail(message: string): void {\n console.log(` ${chalk.gray(message)}`);\n }\n}\n","import { Command } from 'commander';\nimport { CompositionPatternCandidatesOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { CompositionService } from '../../core/services/composition.service.js';\nimport { PatternAnalyzerService } from '../../core/services/pattern-analyzer.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nfunction createSilentLogger(): Logger {\n return {\n info: () => {},\n success: () => {},\n error: () => {},\n warn: () => {},\n action: () => {},\n detail: () => {},\n } as Logger;\n}\n\nexport function createFindCompositionPatternCandidatesCommand(): Command {\n const command = new Command('find-composition-pattern-candidates');\n\n command\n .description(\n 'Analyzes all compositions to identify groups with identical structural patterns—same component types arranged in the same slot hierarchy—regardless of parameter values.'\n )\n .option(\n '--minGroupSize <size>',\n 'Minimum number of compositions required to form a pattern candidate group',\n '2'\n )\n .option(\n '--depth <levels>',\n 'How many levels deep to compare (0 = unlimited, 1 = root only, 2 = root + children)',\n '0'\n )\n .option(\n '--threshold <count>',\n 'Number of component differences allowed while still matching (0 = exact match)',\n '0'\n )\n .option('--format <format>', 'Output format: text or json', 'text')\n .option('--brief', 'Skip structure and composition details in text output')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n\n // Validate minGroupSize\n const minGroupSize = parseInt(opts.minGroupSize, 10);\n if (isNaN(minGroupSize) || minGroupSize < 2) {\n console.error('error: --minGroupSize must be a number >= 2');\n process.exit(1);\n }\n\n // Validate depth\n const depth = parseInt(opts.depth, 10);\n if (isNaN(depth) || depth < 0) {\n console.error('error: --depth must be a number >= 0');\n process.exit(1);\n }\n\n // Validate threshold\n const threshold = parseInt(opts.threshold, 10);\n if (isNaN(threshold) || threshold < 0) {\n console.error('error: --threshold must be a number >= 0');\n process.exit(1);\n }\n\n // Validate format\n if (opts.format !== 'text' && opts.format !== 'json') {\n console.error('error: --format must be \"text\" or \"json\"');\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: CompositionPatternCandidatesOptions = {\n ...globalOpts,\n minGroupSize: parseInt(opts.minGroupSize, 10),\n depth: parseInt(opts.depth, 10),\n threshold: parseInt(opts.threshold, 10),\n format: opts.format as 'text' | 'json',\n brief: opts.brief ?? false,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const compositionService = new CompositionService(fileSystem);\n\n try {\n // Use a silent logger for JSON output to avoid polluting the JSON\n const analysisLogger = options.format === 'json' ? createSilentLogger() : logger;\n const analyzer = new PatternAnalyzerService(fileSystem, compositionService, analysisLogger);\n\n const result = await analyzer.analyze({\n rootDir: options.rootDir,\n compositionsDir: options.compositionsDir,\n projectMapNodesDir: options.projectMapNodesDir,\n minGroupSize: options.minGroupSize,\n depth: options.depth,\n threshold: options.threshold,\n strict: options.strict ?? false,\n });\n\n if (options.format === 'json') {\n console.log(analyzer.formatJsonOutput(result));\n } else {\n console.log(analyzer.formatTextOutput(result, { brief: options.brief }));\n }\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { Composition, ComponentInstance } from '../types/index.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { CompositionService } from './composition.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface CompositionInfo {\n id: string;\n name: string;\n projectMapNodeSlug: string;\n filePath: string;\n componentAnalysis?: ComponentAnalysis;\n}\n\nexport interface ComponentAnalysis {\n componentsUsed: string[];\n reusedComponents: string[];\n newComponents: string[];\n cumulativeComponentCount: number;\n progressionPercentage: number;\n}\n\nexport interface PatternGroup {\n name: string;\n structureDescription: string;\n fingerprint: string;\n compositions: CompositionInfo[];\n componentAnalysis?: ComponentAnalysis;\n}\n\nexport interface PatternAnalysisResult {\n summary: {\n totalCompositions: number;\n uniquePatterns: number;\n compositionsInGroups: number;\n uniqueCompositions: number;\n totalUniqueComponents: number;\n };\n patterns: PatternGroup[];\n uniqueCompositions: CompositionInfo[];\n}\n\nexport interface ProjectMapNode {\n id: string;\n path?: string;\n slug?: string;\n compositionId?: string;\n [key: string]: unknown;\n}\n\nexport interface AnalyzeOptions {\n rootDir: string;\n compositionsDir: string;\n projectMapNodesDir: string;\n minGroupSize: number;\n depth: number;\n threshold: number;\n strict?: boolean;\n}\n\n/**\n * Represents a parsed component node for structural comparison.\n */\ninterface ComponentNode {\n type: string;\n slots: Map<string, ComponentNode[]>;\n}\n\nexport class PatternAnalyzerService {\n constructor(\n private fileSystem: FileSystemService,\n private compositionService: CompositionService,\n private logger: Logger\n ) {}\n\n async analyze(options: AnalyzeOptions): Promise<PatternAnalysisResult> {\n const { rootDir, compositionsDir, projectMapNodesDir, minGroupSize, depth, threshold } = options;\n\n const compositionsPath = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const projectMapNodesPath = this.fileSystem.resolvePath(rootDir, projectMapNodesDir);\n\n // Load project map nodes for slug resolution\n const projectMapNodes = await this.loadProjectMapNodes(projectMapNodesPath);\n\n // Load all compositions\n const compositionFiles = await this.fileSystem.findFiles(\n compositionsPath,\n '**/*.{json,yaml,yml}'\n );\n\n this.logger.info(`Found ${compositionFiles.length} composition files`);\n\n // Load and validate all compositions\n const loadedCompositions: { composition: Composition; filePath: string; fingerprint: string }[] = [];\n\n for (const filePath of compositionFiles) {\n try {\n const composition = await this.compositionService.loadComposition(filePath);\n\n if (!composition.composition?.type) {\n this.logger.warn(`Skipping ${filePath}: missing composition type`);\n continue;\n }\n\n const fingerprint = this.generateFingerprint(composition, depth);\n loadedCompositions.push({ composition, filePath, fingerprint });\n } catch (error) {\n this.logger.warn(\n `Skipping ${filePath}: ${error instanceof Error ? error.message : 'invalid file'}`\n );\n }\n }\n\n // Group compositions based on threshold\n let groups: { composition: Composition; filePath: string; fingerprint: string }[][];\n\n if (threshold === 0) {\n // Exact matching: group by fingerprint\n const fingerprintGroups = new Map<\n string,\n { composition: Composition; filePath: string; fingerprint: string }[]\n >();\n\n for (const item of loadedCompositions) {\n if (!fingerprintGroups.has(item.fingerprint)) {\n fingerprintGroups.set(item.fingerprint, []);\n }\n fingerprintGroups.get(item.fingerprint)!.push(item);\n }\n\n groups = Array.from(fingerprintGroups.values());\n } else {\n // Fuzzy matching: use Union-Find to cluster compositions within threshold distance\n groups = this.clusterByThreshold(loadedCompositions, threshold, depth);\n }\n\n // Calculate total unique components across ALL compositions\n const allCompositions = loadedCompositions.map((item) => item.composition);\n const allComponentTypes = this.extractComponentTypesFromCompositions(allCompositions);\n const totalUniqueComponents = allComponentTypes.size;\n\n // Build pattern groups (with temporary names using just root type)\n const patterns: PatternGroup[] = [];\n const rootTypeCounts = new Map<string, number>();\n const uniqueCompositionsList: CompositionInfo[] = [];\n // Store composition objects for unique compositions to compute component analysis later\n const uniqueCompositionsData: { info: CompositionInfo; composition: Composition }[] = [];\n // Store composition objects for each pattern to compute component analysis later\n const patternCompositionsData: Map<PatternGroup, Composition[]> = new Map();\n\n for (const group of groups) {\n if (group.length < minGroupSize) {\n // Collect unique compositions (those in groups smaller than minGroupSize)\n for (const { composition, filePath } of group) {\n const info: CompositionInfo = {\n id: composition.composition._id ?? 'unknown',\n name: this.getCompositionName(composition),\n projectMapNodeSlug: this.resolveProjectMapSlug(composition, projectMapNodes),\n filePath,\n };\n uniqueCompositionsList.push(info);\n uniqueCompositionsData.push({ info, composition });\n }\n continue;\n }\n\n // Sort by composition ID alphabetically\n group.sort((a, b) => {\n const idA = a.composition.composition._id ?? '';\n const idB = b.composition.composition._id ?? '';\n return idA.localeCompare(idB);\n });\n\n const firstComposition = group[0].composition;\n const rootType = firstComposition.composition.type;\n const firstName = this.getCompositionName(firstComposition);\n\n // Count patterns per root type\n rootTypeCounts.set(rootType, (rootTypeCounts.get(rootType) ?? 0) + 1);\n\n const structureDescription = this.generateStructureDescription(firstComposition);\n\n const compositions: CompositionInfo[] = group.map(({ composition, filePath }) => ({\n id: composition.composition._id ?? 'unknown',\n name: this.getCompositionName(composition),\n projectMapNodeSlug: this.resolveProjectMapSlug(composition, projectMapNodes),\n filePath,\n }));\n\n // Use first composition's fingerprint as the group fingerprint\n const fingerprint = group[0].fingerprint;\n\n const patternGroup = {\n name: rootType, // Temporary name, will be updated below if disambiguation needed\n structureDescription,\n fingerprint,\n compositions,\n _rootType: rootType,\n _firstName: firstName,\n } as PatternGroup & { _rootType: string; _firstName: string };\n\n patterns.push(patternGroup);\n\n // Store all composition objects for this pattern (needed for component analysis with threshold)\n patternCompositionsData.set(patternGroup, group.map((g) => g.composition));\n }\n\n // Update pattern names: only add composition name suffix when multiple patterns share same root type\n for (const pattern of patterns) {\n const p = pattern as PatternGroup & { _rootType: string; _firstName: string };\n if (rootTypeCounts.get(p._rootType)! > 1) {\n pattern.name = `${p._rootType}-${p._firstName}`;\n }\n // Clean up temporary properties\n delete (pattern as unknown as Record<string, unknown>)._rootType;\n delete (pattern as unknown as Record<string, unknown>)._firstName;\n }\n\n // Sort patterns by group size (descending)\n patterns.sort((a, b) => b.compositions.length - a.compositions.length);\n\n // Compute component analysis for each pattern\n const seenComponents = this.computeComponentAnalysis(\n patterns,\n patternCompositionsData,\n totalUniqueComponents\n );\n\n // Sort unique compositions alphabetically by ID\n uniqueCompositionsList.sort((a, b) => a.id.localeCompare(b.id));\n uniqueCompositionsData.sort((a, b) => a.info.id.localeCompare(b.info.id));\n\n // Compute component analysis for unique compositions (continuing from patterns)\n this.computeUniqueCompositionAnalysis(\n uniqueCompositionsData,\n seenComponents,\n totalUniqueComponents\n );\n\n // Calculate summary\n const totalCompositions = compositionFiles.length;\n const uniquePatterns = patterns.length;\n const compositionsInGroups = patterns.reduce((sum, p) => sum + p.compositions.length, 0);\n const uniqueCompositionsCount = totalCompositions - compositionsInGroups;\n\n return {\n summary: {\n totalCompositions,\n uniquePatterns,\n compositionsInGroups,\n uniqueCompositions: uniqueCompositionsCount,\n totalUniqueComponents,\n },\n patterns,\n uniqueCompositions: uniqueCompositionsList,\n };\n }\n\n /**\n * Clusters compositions using Union-Find algorithm based on structural distance.\n * Compositions with distance <= threshold are grouped together transitively.\n */\n private clusterByThreshold(\n compositions: { composition: Composition; filePath: string; fingerprint: string }[],\n threshold: number,\n depth: number\n ): { composition: Composition; filePath: string; fingerprint: string }[][] {\n const n = compositions.length;\n if (n === 0) return [];\n\n // Parse all compositions into ComponentNode trees for comparison\n const parsedNodes = compositions.map((item) =>\n this.parseCompositionToNode(item.composition, depth)\n );\n\n // Union-Find data structure\n const parent = Array.from({ length: n }, (_, i) => i);\n const rank = Array(n).fill(0);\n\n const find = (x: number): number => {\n if (parent[x] !== x) {\n parent[x] = find(parent[x]);\n }\n return parent[x];\n };\n\n const union = (x: number, y: number): void => {\n const rootX = find(x);\n const rootY = find(y);\n if (rootX !== rootY) {\n if (rank[rootX] < rank[rootY]) {\n parent[rootX] = rootY;\n } else if (rank[rootX] > rank[rootY]) {\n parent[rootY] = rootX;\n } else {\n parent[rootY] = rootX;\n rank[rootX]++;\n }\n }\n };\n\n // Compare all pairs and union those within threshold\n for (let i = 0; i < n; i++) {\n for (let j = i + 1; j < n; j++) {\n // Only compare compositions with the same root type\n if (parsedNodes[i].type !== parsedNodes[j].type) {\n continue;\n }\n\n const distance = this.calculateDistance(parsedNodes[i], parsedNodes[j]);\n if (distance <= threshold) {\n union(i, j);\n }\n }\n }\n\n // Group compositions by their root in Union-Find\n const groups = new Map<number, { composition: Composition; filePath: string; fingerprint: string }[]>();\n for (let i = 0; i < n; i++) {\n const root = find(i);\n if (!groups.has(root)) {\n groups.set(root, []);\n }\n groups.get(root)!.push(compositions[i]);\n }\n\n return Array.from(groups.values());\n }\n\n /**\n * Parses a composition into a ComponentNode tree for structural comparison.\n */\n private parseCompositionToNode(composition: Composition, depth: number): ComponentNode {\n const root = composition.composition;\n const remainingDepth = depth === 0 ? -1 : depth - 1;\n return this.parseInstanceToNode(root.type, root.slots, remainingDepth);\n }\n\n private parseInstanceToNode(\n type: string,\n slots: Record<string, ComponentInstance[]> | undefined,\n remainingDepth: number\n ): ComponentNode {\n const node: ComponentNode = {\n type,\n slots: new Map(),\n };\n\n if (remainingDepth === 0 || !slots || Object.keys(slots).length === 0) {\n return node;\n }\n\n const sortedSlotNames = Object.keys(slots).sort();\n for (const slotName of sortedSlotNames) {\n const instances = slots[slotName];\n if (!Array.isArray(instances)) {\n node.slots.set(slotName, []);\n continue;\n }\n\n const nextDepth = remainingDepth === -1 ? -1 : remainingDepth - 1;\n const childNodes = instances.map((instance) =>\n this.parseInstanceToNode(instance.type, instance.slots, nextDepth)\n );\n node.slots.set(slotName, childNodes);\n }\n\n return node;\n }\n\n /**\n * Calculates the structural distance between two ComponentNode trees.\n * Distance is the number of component differences.\n */\n calculateDistance(node1: ComponentNode, node2: ComponentNode): number {\n let distance = 0;\n\n // Different root types count as a large distance (should not be grouped)\n if (node1.type !== node2.type) {\n return Infinity;\n }\n\n // Get all slot names from both nodes\n const allSlotNames = new Set([...node1.slots.keys(), ...node2.slots.keys()]);\n\n for (const slotName of allSlotNames) {\n const children1 = node1.slots.get(slotName) ?? [];\n const children2 = node2.slots.get(slotName) ?? [];\n\n // Compare children at each position\n const maxLen = Math.max(children1.length, children2.length);\n for (let i = 0; i < maxLen; i++) {\n const child1 = children1[i];\n const child2 = children2[i];\n\n if (!child1 || !child2) {\n // One side is missing a component\n distance++;\n } else if (child1.type !== child2.type) {\n // Different component types at same position\n distance++;\n } else {\n // Same type, compare recursively\n distance += this.calculateDistance(child1, child2);\n }\n }\n }\n\n return distance;\n }\n\n /**\n * Extracts all unique component types from a composition recursively.\n */\n extractComponentTypes(composition: Composition): Set<string> {\n const types = new Set<string>();\n const root = composition.composition;\n types.add(root.type);\n this.collectComponentTypesFromSlots(root.slots, types);\n return types;\n }\n\n /**\n * Helper to recursively collect component types from slots.\n */\n private collectComponentTypesFromSlots(\n slots: Record<string, ComponentInstance[]> | undefined,\n types: Set<string>\n ): void {\n if (!slots) return;\n\n for (const slotName of Object.keys(slots)) {\n const instances = slots[slotName];\n if (!Array.isArray(instances)) continue;\n\n for (const instance of instances) {\n types.add(instance.type);\n this.collectComponentTypesFromSlots(instance.slots, types);\n }\n }\n }\n\n /**\n * Extracts the union of all component types from multiple compositions.\n */\n extractComponentTypesFromCompositions(compositions: Composition[]): Set<string> {\n const types = new Set<string>();\n for (const composition of compositions) {\n const compositionTypes = this.extractComponentTypes(composition);\n for (const type of compositionTypes) {\n types.add(type);\n }\n }\n return types;\n }\n\n /**\n * Computes component analysis for all patterns.\n * Returns the set of seen components for continuation with unique compositions.\n */\n private computeComponentAnalysis(\n patterns: PatternGroup[],\n patternCompositionsData: Map<PatternGroup, Composition[]>,\n totalUniqueComponents: number\n ): Set<string> {\n const seenComponents = new Set<string>();\n\n for (const pattern of patterns) {\n // Get all compositions for this pattern (directly from the map, not by fingerprint lookup)\n const compositions = patternCompositionsData.get(pattern) ?? [];\n const patternComponents = this.extractComponentTypesFromCompositions(compositions);\n const componentsUsed = Array.from(patternComponents).sort();\n\n // Calculate reused vs new components\n const reusedComponents: string[] = [];\n const newComponents: string[] = [];\n\n for (const component of componentsUsed) {\n if (seenComponents.has(component)) {\n reusedComponents.push(component);\n } else {\n newComponents.push(component);\n }\n }\n\n // Add all components to seen set for next pattern\n for (const component of componentsUsed) {\n seenComponents.add(component);\n }\n\n const cumulativeComponentCount = seenComponents.size;\n const progressionPercentage =\n totalUniqueComponents > 0\n ? Math.round((cumulativeComponentCount / totalUniqueComponents) * 100)\n : 0;\n\n pattern.componentAnalysis = {\n componentsUsed,\n reusedComponents: reusedComponents.sort(),\n newComponents: newComponents.sort(),\n cumulativeComponentCount,\n progressionPercentage,\n };\n }\n\n return seenComponents;\n }\n\n /**\n * Computes component analysis for unique compositions.\n * Continues from the seenComponents set populated by pattern analysis.\n */\n private computeUniqueCompositionAnalysis(\n uniqueCompositionsData: { info: CompositionInfo; composition: Composition }[],\n seenComponents: Set<string>,\n totalUniqueComponents: number\n ): void {\n for (const { info, composition } of uniqueCompositionsData) {\n const compositionComponents = this.extractComponentTypes(composition);\n const componentsUsed = Array.from(compositionComponents).sort();\n\n // Calculate reused vs new components\n const reusedComponents: string[] = [];\n const newComponents: string[] = [];\n\n for (const component of componentsUsed) {\n if (seenComponents.has(component)) {\n reusedComponents.push(component);\n } else {\n newComponents.push(component);\n }\n }\n\n // Add all components to seen set for next composition\n for (const component of componentsUsed) {\n seenComponents.add(component);\n }\n\n const cumulativeComponentCount = seenComponents.size;\n const progressionPercentage =\n totalUniqueComponents > 0\n ? Math.round((cumulativeComponentCount / totalUniqueComponents) * 100)\n : 0;\n\n info.componentAnalysis = {\n componentsUsed,\n reusedComponents: reusedComponents.sort(),\n newComponents: newComponents.sort(),\n cumulativeComponentCount,\n progressionPercentage,\n };\n }\n }\n\n /**\n * Generates a structural fingerprint for a composition.\n * The fingerprint captures the component type hierarchy ignoring parameter values.\n * @param depth - How many levels deep to compare. 0 = unlimited, 1 = root only, 2 = root + children, etc.\n */\n generateFingerprint(composition: Composition, depth: number = 0): string {\n const root = composition.composition;\n // depth 1 means root only, so we pass remainingDepth = 0 to stop at root\n // depth 0 means unlimited, so we pass -1 as a special \"unlimited\" marker\n const remainingDepth = depth === 0 ? -1 : depth - 1;\n return this.generateNodeFingerprint(root.type, root.slots, remainingDepth);\n }\n\n private generateNodeFingerprint(\n type: string,\n slots: Record<string, ComponentInstance[]> | undefined,\n remainingDepth: number\n ): string {\n // If remainingDepth is 0, don't go deeper (return just the type)\n // If remainingDepth is -1, it means unlimited depth\n if (remainingDepth === 0 || !slots || Object.keys(slots).length === 0) {\n return type;\n }\n\n // Sort slot names alphabetically for consistent fingerprinting\n const sortedSlotNames = Object.keys(slots).sort();\n\n const slotFingerprints = sortedSlotNames.map((slotName) => {\n const instances = slots[slotName];\n if (!Array.isArray(instances) || instances.length === 0) {\n return `${slotName}:[]`;\n }\n\n const nextDepth = remainingDepth === -1 ? -1 : remainingDepth - 1;\n const instanceFingerprints = instances.map((instance) =>\n this.generateNodeFingerprint(instance.type, instance.slots, nextDepth)\n );\n\n return `${slotName}:[${instanceFingerprints.join(',')}]`;\n });\n\n return `${type}{${slotFingerprints.join(';')}}`;\n }\n\n /**\n * Generates a human-readable structure description.\n */\n generateStructureDescription(composition: Composition): string {\n const root = composition.composition;\n return this.generateNodeDescription(root.type, root.slots, 0);\n }\n\n private generateNodeDescription(\n type: string,\n slots: Record<string, ComponentInstance[]> | undefined,\n depth: number\n ): string {\n if (!slots || Object.keys(slots).length === 0) {\n return type;\n }\n\n const sortedSlotNames = Object.keys(slots).sort();\n\n const slotDescriptions = sortedSlotNames\n .map((slotName) => {\n const instances = slots[slotName];\n if (!Array.isArray(instances) || instances.length === 0) {\n return null;\n }\n\n const instanceTypes = instances.map((instance) => {\n if (instance.slots && Object.keys(instance.slots).length > 0) {\n return this.generateNodeDescription(instance.type, instance.slots, depth + 1);\n }\n return instance.type;\n });\n\n return `${slotName}[${instanceTypes.join(', ')}]`;\n })\n .filter(Boolean);\n\n if (slotDescriptions.length === 0) {\n return type;\n }\n\n return `${type} > ${slotDescriptions.join(' > ')}`;\n }\n\n private getCompositionName(composition: Composition): string {\n // Try common name fields\n const possibleNames = [\n (composition as { name?: string }).name,\n (composition.composition as { _name?: string })._name,\n (composition.composition as { name?: string }).name,\n composition.composition._id,\n ];\n\n for (const name of possibleNames) {\n if (name && typeof name === 'string') {\n return name;\n }\n }\n\n return 'Unnamed';\n }\n\n private async loadProjectMapNodes(\n projectMapNodesPath: string\n ): Promise<Map<string, ProjectMapNode>> {\n const nodes = new Map<string, ProjectMapNode>();\n\n try {\n const exists = await this.fileSystem.fileExists(projectMapNodesPath);\n if (!exists) {\n return nodes;\n }\n\n const files = await this.fileSystem.findFiles(projectMapNodesPath, '**/*.{json,yaml,yml}');\n\n for (const filePath of files) {\n try {\n const node = await this.fileSystem.readFile<ProjectMapNode>(filePath);\n if (node.compositionId) {\n nodes.set(node.compositionId, node);\n }\n if (node.id) {\n nodes.set(node.id, node);\n }\n } catch {\n // Skip invalid files\n }\n }\n } catch {\n // Directory doesn't exist or isn't accessible\n }\n\n return nodes;\n }\n\n private resolveProjectMapSlug(\n composition: Composition,\n nodes: Map<string, ProjectMapNode>\n ): string {\n const compositionId = composition.composition._id;\n if (!compositionId) {\n return '(not mapped)';\n }\n\n const node = nodes.get(compositionId);\n if (!node) {\n return '(not mapped)';\n }\n\n return node.path ?? node.slug ?? '(not mapped)';\n }\n\n formatTextOutput(result: PatternAnalysisResult, options?: { brief?: boolean }): string {\n const brief = options?.brief ?? false;\n const lines: string[] = [];\n const padWidth = String(result.patterns.length).length.toString().length >= 3 ? String(result.patterns.length).length : 3;\n\n lines.push('=== COMPOSITION PATTERN CANDIDATES ===');\n lines.push('');\n lines.push(`Total compositions analyzed: ${result.summary.totalCompositions}`);\n lines.push(`Unique structural patterns found: ${result.summary.uniquePatterns}`);\n\n const percentage =\n result.summary.totalCompositions > 0\n ? Math.round(\n (result.summary.compositionsInGroups / result.summary.totalCompositions) * 100\n )\n : 0;\n lines.push(`Compositions in pattern groups: ${result.summary.compositionsInGroups} (${percentage}%)`);\n lines.push(`Unique compositions (no matches): ${result.summary.uniqueCompositions}`);\n lines.push(`Total unique components: ${result.summary.totalUniqueComponents}`);\n lines.push('');\n\n if (result.patterns.length === 0) {\n lines.push('No pattern candidates found (all compositions have unique structures).');\n return lines.join('\\n');\n }\n\n // Pattern index (summary list)\n lines.push('Pattern candidates index:');\n result.patterns.forEach((pattern, index) => {\n const patternNum = String(index + 1).padStart(padWidth, '0');\n lines.push(` ${patternNum}. ${pattern.name}`);\n lines.push(` (${pattern.compositions.length} compositions)`);\n });\n\n lines.push('');\n lines.push('Pattern candidates:');\n lines.push('');\n\n // Detailed breakdown for each pattern\n result.patterns.forEach((pattern, index) => {\n const patternNum = String(index + 1).padStart(padWidth, '0');\n lines.push(` Pattern ${patternNum}: ${pattern.name} (${pattern.compositions.length} compositions)`);\n\n // Component analysis\n if (pattern.componentAnalysis) {\n const ca = pattern.componentAnalysis;\n const totalComponents = result.summary.totalUniqueComponents;\n lines.push(` Components used: ${ca.componentsUsed.length}/${totalComponents} (${ca.componentsUsed.join(', ')})`);\n lines.push(` Reused components: ${ca.reusedComponents.length}/${ca.componentsUsed.length}${ca.reusedComponents.length > 0 ? ` (${ca.reusedComponents.join(', ')})` : ''}`);\n lines.push(` New components: ${ca.newComponents.length}/${totalComponents} (${ca.newComponents.join(', ')})`);\n lines.push(` Components progression: ${ca.progressionPercentage}% (${ca.cumulativeComponentCount}/${totalComponents})`);\n }\n\n if (!brief) {\n lines.push(' Structure:');\n\n // Generate tree-style structure\n const treeLines = this.generateStructureTree(pattern.structureDescription);\n treeLines.forEach(treeLine => {\n lines.push(` ${treeLine}`);\n });\n\n lines.push('');\n lines.push(' Compositions:');\n\n pattern.compositions.forEach((comp, compIndex) => {\n lines.push(` ${compIndex + 1}. ID: ${comp.id}`);\n lines.push(` Name: ${comp.name}`);\n lines.push(` Node: ${comp.projectMapNodeSlug}`);\n lines.push('');\n });\n }\n\n lines.push('');\n });\n\n // Add unique compositions section at the bottom\n if (result.uniqueCompositions.length > 0) {\n lines.push('');\n lines.push('=== UNIQUE COMPOSITIONS (NO MATCHES) ===');\n lines.push('');\n result.uniqueCompositions.forEach((comp, index) => {\n lines.push(` ${index + 1}. ID: ${comp.id}`);\n lines.push(` Name: ${comp.name}`);\n lines.push(` Node: ${comp.projectMapNodeSlug}`);\n // Component analysis\n if (comp.componentAnalysis) {\n const ca = comp.componentAnalysis;\n const totalComponents = result.summary.totalUniqueComponents;\n lines.push(` Components used: ${ca.componentsUsed.length}/${totalComponents} (${ca.componentsUsed.join(', ')})`);\n lines.push(` Reused components: ${ca.reusedComponents.length}/${ca.componentsUsed.length}${ca.reusedComponents.length > 0 ? ` (${ca.reusedComponents.join(', ')})` : ''}`);\n lines.push(` New components: ${ca.newComponents.length}/${totalComponents} (${ca.newComponents.join(', ')})`);\n lines.push(` Components progression: ${ca.progressionPercentage}% (${ca.cumulativeComponentCount}/${totalComponents})`);\n }\n lines.push('');\n });\n }\n\n return lines.join('\\n');\n }\n\n /**\n * Generates a tree-style representation of the structure description.\n */\n private generateStructureTree(structureDescription: string): string[] {\n const lines: string[] = [];\n this.parseStructureToTree(structureDescription, 0, lines);\n return lines;\n }\n\n private parseStructureToTree(str: string, indent: number, lines: string[]): void {\n const indentStr = ' '.repeat(indent);\n\n // Parse format: \"Type > slot1[Comp1, Comp2 > nested[...]] > slot2[...]\"\n // Or simpler: \"Type\" or \"Type > slot[children]\"\n\n // Find the root type (everything before first \" > \" or the whole string)\n const arrowIndex = str.indexOf(' > ');\n\n if (arrowIndex === -1) {\n // Simple type with no slots\n lines.push(`${indentStr}${str}`);\n return;\n }\n\n const rootType = str.substring(0, arrowIndex);\n lines.push(`${indentStr}${rootType}`);\n\n // Parse the rest (slots)\n const slotsStr = str.substring(arrowIndex + 3);\n this.parseSlotsToTree(slotsStr, indent, lines);\n }\n\n private parseSlotsToTree(str: string, indent: number, lines: string[]): void {\n const indentStr = ' '.repeat(indent);\n\n // Split by \" > \" at the top level (not inside brackets)\n const slots = this.splitTopLevelSlots(str);\n\n for (const slot of slots) {\n // Parse slot format: \"slotName[Component1, Component2]\"\n const bracketStart = slot.indexOf('[');\n if (bracketStart === -1) {\n // No bracket, just a component type\n lines.push(`${indentStr}${slot}`);\n continue;\n }\n\n const slotName = slot.substring(0, bracketStart);\n const bracketEnd = this.findMatchingBracket(slot, bracketStart);\n const contents = slot.substring(bracketStart + 1, bracketEnd);\n\n lines.push(`${indentStr}:${slotName}`);\n\n // Parse contents (comma-separated at top level)\n const components = this.splitTopLevelComponents(contents);\n\n for (const component of components) {\n // Check if component has nested slots\n const compArrow = component.indexOf(' > ');\n if (compArrow !== -1) {\n // Has nested structure\n this.parseStructureToTree(component, indent + 2, lines);\n } else {\n // Simple component\n lines.push(`${indentStr} ${component}`);\n }\n }\n }\n }\n\n private splitTopLevelSlots(str: string): string[] {\n const result: string[] = [];\n let depth = 0;\n let current = '';\n\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n\n if (char === '[') {\n depth++;\n current += char;\n } else if (char === ']') {\n depth--;\n current += char;\n } else if (char === ' ' && str.substring(i, i + 3) === ' > ' && depth === 0) {\n if (current.trim()) {\n result.push(current.trim());\n }\n current = '';\n i += 2; // Skip \" > \"\n } else {\n current += char;\n }\n }\n\n if (current.trim()) {\n result.push(current.trim());\n }\n\n return result;\n }\n\n private splitTopLevelComponents(str: string): string[] {\n const result: string[] = [];\n let depth = 0;\n let current = '';\n\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n\n if (char === '[' || char === '{') {\n depth++;\n current += char;\n } else if (char === ']' || char === '}') {\n depth--;\n current += char;\n } else if (char === ',' && depth === 0) {\n if (current.trim()) {\n result.push(current.trim());\n }\n current = '';\n } else {\n current += char;\n }\n }\n\n if (current.trim()) {\n result.push(current.trim());\n }\n\n return result;\n }\n\n private findMatchingBracket(str: string, start: number): number {\n let depth = 0;\n for (let i = start; i < str.length; i++) {\n if (str[i] === '[') depth++;\n else if (str[i] === ']') {\n depth--;\n if (depth === 0) return i;\n }\n }\n return str.length;\n }\n\n formatJsonOutput(result: PatternAnalysisResult): string {\n // Remove fingerprint and filePath from output (internal use only)\n const cleanedPatterns = result.patterns.map(({ fingerprint: _fingerprint, ...pattern }) => ({\n ...pattern,\n compositions: pattern.compositions.map(({ filePath: _filePath, ...comp }) => comp),\n }));\n\n // Remove filePath from unique compositions\n const cleanedUniqueCompositions = result.uniqueCompositions.map(({ filePath: _filePath, ...comp }) => comp);\n\n return JSON.stringify(\n {\n summary: result.summary,\n patterns: cleanedPatterns,\n uniqueCompositions: cleanedUniqueCompositions,\n },\n null,\n 2\n );\n }\n}\n","import { Command } from 'commander';\nimport { UnpackSerializationOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { SerializationPackerService } from '../../core/services/serialization-packer.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createUnpackSerializationCommand(): Command {\n const command = new Command('unpack-serialization');\n\n command\n .description(\n 'Splits serialization files into skeleton + fragment files keyed by id, enabling clean per-item git diffs.'\n )\n .option('--sourceDir <dir>', 'Directory containing serialization files to unpack')\n .option('--file <path>', 'Single serialization file to unpack')\n .option('--outputDir <dir>', 'Output directory (defaults to same directory as source)')\n .option('--format <format>', 'Output format: yaml or json', 'yaml')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n\n if (!opts.sourceDir && !opts.file) {\n console.error('error: --sourceDir or --file is required');\n process.exit(1);\n }\n\n if (opts.sourceDir && opts.file) {\n console.error('error: --sourceDir and --file are mutually exclusive');\n process.exit(1);\n }\n\n if (opts.format !== 'yaml' && opts.format !== 'json') {\n console.error('error: --format must be \"yaml\" or \"json\"');\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: UnpackSerializationOptions = {\n ...globalOpts,\n sourceDir: opts.sourceDir,\n file: opts.file,\n outputDir: opts.outputDir,\n format: opts.format as 'yaml' | 'json',\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const packer = new SerializationPackerService(fileSystem, logger);\n\n try {\n const result = await packer.unpack({\n sourceDir: options.sourceDir,\n file: options.file,\n outputDir: options.outputDir,\n format: options.format,\n whatIf: options.whatIf ?? false,\n rootDir: options.rootDir,\n });\n\n logger.success(\n `Unpack complete: ${result.processedFiles} file(s) processed, ` +\n `${result.skeletonFilesWritten} skeleton(s), ${result.fragmentFilesWritten} fragment(s)`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\nimport { DuplicateIdError, FileNotFoundError } from '../errors.js';\n\nexport interface UnpackOptions {\n sourceDir?: string;\n file?: string;\n outputDir?: string;\n format: 'yaml' | 'json';\n whatIf: boolean;\n rootDir: string;\n}\n\nexport interface PackOptions {\n sourceDir?: string;\n file?: string;\n outputDir?: string;\n keepFragments?: boolean;\n format: 'yaml' | 'json';\n whatIf: boolean;\n rootDir: string;\n}\n\nexport interface UnpackResult {\n processedFiles: number;\n skeletonFilesWritten: number;\n fragmentFilesWritten: number;\n}\n\nexport interface PackResult {\n processedFiles: number;\n packedFilesWritten: number;\n fragmentsConsumed: number;\n fragmentsDeleted: number;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isSplittableArray(value: unknown): value is Array<Record<string, unknown>> {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => isPlainObject(item) && typeof item.id === 'string')\n );\n}\n\nfunction isStubArray(value: unknown): value is Array<{ id: string }> {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every(\n (item) =>\n isPlainObject(item) && typeof item.id === 'string' && Object.keys(item).length === 1\n )\n );\n}\n\nexport class SerializationPackerService {\n constructor(\n private fileSystem: FileSystemService,\n private logger: Logger\n ) {}\n\n async unpack(options: UnpackOptions): Promise<UnpackResult> {\n const inputFiles = await this.resolveInputFiles(options);\n let skeletonFilesWritten = 0;\n let fragmentFilesWritten = 0;\n\n for (const filePath of inputFiles) {\n const fileName = this.fileSystem.getBasename(filePath);\n\n // Skip fragment files\n if (fileName.includes('!!')) {\n continue;\n }\n\n this.logger.info(`Processing: ${fileName}`);\n\n const data = await this.fileSystem.readFile<unknown>(filePath);\n const skeleton = structuredClone(data);\n const fragments: Array<{ path: string; data: unknown }> = [];\n\n const dir = options.outputDir\n ? this.fileSystem.resolvePath(options.rootDir, options.outputDir)\n : this.fileSystem.getDirname(filePath);\n\n this.walkForUnpack(skeleton, fileName, dir, filePath, fragments, options.format);\n\n if (fragments.length === 0) {\n this.logger.detail('No splittable arrays found, skipping');\n continue;\n }\n\n // Write skeleton\n const skeletonPath = options.outputDir\n ? this.fileSystem.joinPath(dir, fileName)\n : filePath;\n\n this.logger.action(options.whatIf, 'WRITE', `Skeleton: ${this.fileSystem.getBasename(skeletonPath)}`);\n if (!options.whatIf) {\n await this.fileSystem.writeFile(skeletonPath, skeleton);\n }\n skeletonFilesWritten++;\n\n // Write fragments\n for (const fragment of fragments) {\n this.logger.action(options.whatIf, 'WRITE', `Fragment: ${this.fileSystem.getBasename(fragment.path)}`);\n if (!options.whatIf) {\n await this.fileSystem.writeFile(fragment.path, fragment.data);\n }\n fragmentFilesWritten++;\n }\n }\n\n return {\n processedFiles: inputFiles.filter((f) => !this.fileSystem.getBasename(f).includes('!!')).length,\n skeletonFilesWritten,\n fragmentFilesWritten,\n };\n }\n\n async pack(options: PackOptions): Promise<PackResult> {\n const inputFiles = await this.resolveInputFiles(options);\n let packedFilesWritten = 0;\n let fragmentsConsumed = 0;\n let fragmentsDeleted = 0;\n const consumedFragments = new Set<string>();\n\n for (const filePath of inputFiles) {\n const fileName = this.fileSystem.getBasename(filePath);\n\n // Skip fragment files\n if (fileName.includes('!!')) {\n continue;\n }\n\n this.logger.info(`Processing: ${fileName}`);\n\n const data = await this.fileSystem.readFile<unknown>(filePath);\n\n if (!this.hasStubArrays(data)) {\n this.logger.detail('No stub arrays found, skipping');\n continue;\n }\n\n const dir = this.fileSystem.getDirname(filePath);\n const consumed = await this.walkForPack(data, fileName, dir);\n fragmentsConsumed += consumed.length;\n for (const f of consumed) {\n consumedFragments.add(f);\n }\n\n // Write packed file\n const outputPath = options.outputDir\n ? this.fileSystem.joinPath(\n this.fileSystem.resolvePath(options.rootDir, options.outputDir),\n fileName\n )\n : filePath;\n\n this.logger.action(options.whatIf, 'WRITE', `Packed: ${this.fileSystem.getBasename(outputPath)}`);\n if (!options.whatIf) {\n await this.fileSystem.writeFile(outputPath, data);\n }\n packedFilesWritten++;\n\n // Delete consumed fragments\n if (!options.keepFragments) {\n for (const fragmentPath of consumed) {\n this.logger.action(options.whatIf, 'DELETE', `Fragment: ${this.fileSystem.getBasename(fragmentPath)}`);\n if (!options.whatIf) {\n this.fileSystem.deleteFile(fragmentPath);\n }\n fragmentsDeleted++;\n }\n }\n }\n\n // Warn about orphaned fragments\n await this.warnOrphanedFragments(inputFiles, consumedFragments);\n\n return {\n processedFiles: inputFiles.filter((f) => !this.fileSystem.getBasename(f).includes('!!')).length,\n packedFilesWritten,\n fragmentsConsumed,\n fragmentsDeleted,\n };\n }\n\n private walkForUnpack(\n obj: unknown,\n chain: string,\n dir: string,\n sourceFilePath: string,\n fragments: Array<{ path: string; data: unknown }>,\n format: 'yaml' | 'json'\n ): void {\n if (!isPlainObject(obj)) {\n return;\n }\n\n for (const [key, value] of Object.entries(obj)) {\n if (isSplittableArray(value)) {\n // Validate no duplicate IDs\n const ids = value.map((item) => item.id as string);\n const seen = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) {\n throw new DuplicateIdError(id, key, sourceFilePath);\n }\n seen.add(id);\n }\n\n // Replace array with stubs\n const stubs: Array<{ id: string }> = [];\n for (const item of value) {\n const id = item.id as string;\n stubs.push({ id });\n\n const fragmentClone = structuredClone(item);\n const ext = format === 'json' ? '.json' : '.yaml';\n const fragmentFileName = `${chain}!!${key}!!-id!!${id}${ext}`;\n const fragmentPath = this.fileSystem.joinPath(dir, fragmentFileName);\n\n // Recurse into the fragment for nested splittable arrays\n this.walkForUnpack(fragmentClone, fragmentFileName, dir, sourceFilePath, fragments, format);\n\n fragments.push({ path: fragmentPath, data: fragmentClone });\n }\n\n (obj as Record<string, unknown>)[key] = stubs;\n } else if (isPlainObject(value)) {\n this.walkForUnpack(value, chain, dir, sourceFilePath, fragments, format);\n }\n }\n }\n\n private hasStubArrays(obj: unknown): boolean {\n if (!isPlainObject(obj)) {\n return false;\n }\n\n for (const value of Object.values(obj)) {\n if (isStubArray(value)) {\n return true;\n }\n if (isPlainObject(value) && this.hasStubArrays(value)) {\n return true;\n }\n }\n\n return false;\n }\n\n private async walkForPack(\n obj: unknown,\n chain: string,\n dir: string\n ): Promise<string[]> {\n if (!isPlainObject(obj)) {\n return [];\n }\n\n const consumed: string[] = [];\n\n for (const [key, value] of Object.entries(obj)) {\n if (isStubArray(value)) {\n const reassembled: unknown[] = [];\n\n for (const stub of value) {\n const id = stub.id;\n // Try both yaml and json extensions\n let fragmentPath = this.fileSystem.joinPath(dir, `${chain}!!${key}!!-id!!${id}.yaml`);\n let exists = await this.fileSystem.fileExists(fragmentPath);\n\n if (!exists) {\n fragmentPath = this.fileSystem.joinPath(dir, `${chain}!!${key}!!-id!!${id}.json`);\n exists = await this.fileSystem.fileExists(fragmentPath);\n }\n\n if (!exists) {\n throw new FileNotFoundError(fragmentPath);\n }\n\n const fragmentData = await this.fileSystem.readFile<unknown>(fragmentPath);\n consumed.push(fragmentPath);\n\n // Recursively reassemble nested stubs\n const fragmentFileName = this.fileSystem.getBasename(fragmentPath);\n const nestedConsumed = await this.walkForPack(fragmentData, fragmentFileName, dir);\n consumed.push(...nestedConsumed);\n\n reassembled.push(fragmentData);\n }\n\n (obj as Record<string, unknown>)[key] = reassembled;\n } else if (isPlainObject(value)) {\n const nestedConsumed = await this.walkForPack(value, chain, dir);\n consumed.push(...nestedConsumed);\n }\n }\n\n return consumed;\n }\n\n private async warnOrphanedFragments(\n inputFiles: string[],\n consumedFragments: Set<string>\n ): Promise<void> {\n const allFragments = inputFiles.filter((f) => this.fileSystem.getBasename(f).includes('!!'));\n for (const fragmentPath of allFragments) {\n if (!consumedFragments.has(fragmentPath)) {\n this.logger.warn(`Orphaned fragment: ${this.fileSystem.getBasename(fragmentPath)}`);\n }\n }\n }\n\n private async resolveInputFiles(options: { sourceDir?: string; file?: string; rootDir: string }): Promise<string[]> {\n if (options.file) {\n const filePath = this.fileSystem.resolvePath(options.rootDir, options.file);\n return [filePath];\n }\n\n if (options.sourceDir) {\n const dir = this.fileSystem.resolvePath(options.rootDir, options.sourceDir);\n const yamlFiles = await this.fileSystem.findFiles(dir, '*.yaml');\n const jsonFiles = await this.fileSystem.findFiles(dir, '*.json');\n return [...yamlFiles, ...jsonFiles].sort();\n }\n\n return [];\n }\n}\n","import { Command } from 'commander';\nimport { PackSerializationOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { SerializationPackerService } from '../../core/services/serialization-packer.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createPackSerializationCommand(): Command {\n const command = new Command('pack-serialization');\n\n command\n .description(\n 'Reassembles skeleton + fragment files back into complete serialization files.'\n )\n .option('--sourceDir <dir>', 'Directory containing skeleton and fragment files to pack')\n .option('--file <path>', 'Single skeleton file to pack')\n .option('--outputDir <dir>', 'Output directory (defaults to same directory as source)')\n .option('--keepFragments', 'Keep fragment files after packing (default: delete them)')\n .option('--format <format>', 'Output format: yaml or json', 'yaml')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n\n if (!opts.sourceDir && !opts.file) {\n console.error('error: --sourceDir or --file is required');\n process.exit(1);\n }\n\n if (opts.sourceDir && opts.file) {\n console.error('error: --sourceDir and --file are mutually exclusive');\n process.exit(1);\n }\n\n if (opts.format !== 'yaml' && opts.format !== 'json') {\n console.error('error: --format must be \"yaml\" or \"json\"');\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: PackSerializationOptions = {\n ...globalOpts,\n sourceDir: opts.sourceDir,\n file: opts.file,\n outputDir: opts.outputDir,\n keepFragments: opts.keepFragments ?? false,\n format: opts.format as 'yaml' | 'json',\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const packer = new SerializationPackerService(fileSystem, logger);\n\n try {\n const result = await packer.pack({\n sourceDir: options.sourceDir,\n file: options.file,\n outputDir: options.outputDir,\n keepFragments: options.keepFragments,\n format: options.format,\n whatIf: options.whatIf ?? false,\n rootDir: options.rootDir,\n });\n\n logger.success(\n `Pack complete: ${result.processedFiles} file(s) processed, ` +\n `${result.packedFilesWritten} packed, ${result.fragmentsConsumed} fragment(s) consumed, ` +\n `${result.fragmentsDeleted} fragment(s) deleted`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { Command } from 'commander';\nimport { RenameSlotOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { SlotRenamerService } from '../../core/services/slot-renamer.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createRenameSlotCommand(): Command {\n const command = new Command('rename-slot');\n\n command\n .description(\n 'Renames a slot in a component definition and updates all compositions, composition patterns, and component patterns that reference it.'\n )\n .option('--componentType <type>', 'The component type that owns the slot being renamed')\n .option('--slotId <id>', 'The current slot ID to rename')\n .option('--newSlotId <id>', 'The new slot ID')\n .option('--newSlotName <name>', 'New display name for the slot (optional)')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'componentType', flag: '--componentType' },\n { name: 'slotId', flag: '--slotId' },\n { name: 'newSlotId', flag: '--newSlotId' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: RenameSlotOptions = {\n ...globalOpts,\n componentType: opts.componentType,\n slotId: opts.slotId,\n newSlotId: opts.newSlotId,\n newSlotName: opts.newSlotName,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const renamer = new SlotRenamerService(fileSystem, componentService, logger);\n\n try {\n const result = await renamer.rename({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionPatternsDir: options.compositionPatternsDir,\n componentPatternsDir: options.componentPatternsDir,\n componentType: options.componentType,\n slotId: options.slotId,\n newSlotId: options.newSlotId,\n newSlotName: options.newSlotName,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n });\n\n logger.success(\n `Renamed slot: ${result.compositionsModified} composition(s), ` +\n `${result.compositionPatternsModified} composition pattern(s), ` +\n `${result.componentPatternsModified} component pattern(s) updated`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { ComponentInstance, Composition } from '../types/index.js';\nimport { SlotNotFoundError, SlotAlreadyExistsError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface RenameSlotInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n componentType: string;\n slotId: string;\n newSlotId: string;\n newSlotName?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface RenameSlotResult {\n componentDefinitionUpdated: boolean;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesRenamed: number;\n}\n\nexport class SlotRenamerService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async rename(options: RenameSlotInternalOptions): Promise<RenameSlotResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n componentType,\n slotId,\n newSlotId,\n newSlotName,\n whatIf,\n strict,\n } = options;\n\n const findOptions = { strict };\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n\n // Validate: newSlotId must differ from slotId\n if (this.compareIds(slotId, newSlotId, strict)) {\n throw new TransformError('New slot ID is the same as the current slot ID');\n }\n\n // Step 1: Load and validate component definition\n this.logger.info(`Loading component: ${componentType}`);\n const { component, filePath: componentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, componentType, findOptions);\n\n if (!component.slots || component.slots.length === 0) {\n throw new SlotNotFoundError(slotId, componentType);\n }\n\n const slotIndex = component.slots.findIndex((s) =>\n this.compareIds(s.id, slotId, strict)\n );\n if (slotIndex === -1) {\n throw new SlotNotFoundError(slotId, componentType);\n }\n\n const existingNewSlot = component.slots.find((s) =>\n this.compareIds(s.id, newSlotId, strict)\n );\n if (existingNewSlot) {\n throw new SlotAlreadyExistsError(newSlotId, componentType);\n }\n\n // Step 2: Rename the slot in the component definition\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Slot \"${slotId}\" → \"${newSlotId}\" in component/${this.fileSystem.getBasename(componentFilePath)}`\n );\n\n component.slots[slotIndex].id = newSlotId;\n if (newSlotName !== undefined) {\n component.slots[slotIndex].name = newSlotName;\n }\n\n if (!whatIf) {\n await this.componentService.saveComponent(componentFilePath, component);\n }\n\n // Step 3: Rename slot keys in compositions\n const compositionsResult = await this.renameSlotInDirectory(\n fullCompositionsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 4: Rename slot keys in composition patterns\n const compositionPatternsResult = await this.renameSlotInDirectory(\n fullCompositionPatternsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 5: Rename slot keys in component patterns\n const componentPatternsResult = await this.renameSlotInDirectory(\n fullComponentPatternsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n // Summary\n const totalFiles =\n compositionsResult.filesModified +\n compositionPatternsResult.filesModified +\n componentPatternsResult.filesModified;\n const totalInstances =\n compositionsResult.instancesRenamed +\n compositionPatternsResult.instancesRenamed +\n componentPatternsResult.instancesRenamed;\n\n this.logger.info('');\n this.logger.info(\n `Summary: 1 component definition, ${totalFiles} file(s) (${totalInstances} instance(s)) updated.`\n );\n\n return {\n componentDefinitionUpdated: true,\n compositionsModified: compositionsResult.filesModified,\n compositionPatternsModified: compositionPatternsResult.filesModified,\n componentPatternsModified: componentPatternsResult.filesModified,\n instancesRenamed: totalInstances,\n };\n }\n\n private async renameSlotInDirectory(\n directory: string,\n componentType: string,\n oldSlotId: string,\n newSlotId: string,\n whatIf: boolean,\n strict: boolean,\n label: string\n ): Promise<{ filesModified: number; instancesRenamed: number }> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n } catch {\n // Directory may not exist\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n if (files.length === 0) {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n let filesModified = 0;\n let instancesRenamed = 0;\n\n for (const filePath of files) {\n let composition: Composition;\n try {\n composition = await this.fileSystem.readFile<Composition>(filePath);\n } catch {\n continue;\n }\n\n if (!composition?.composition) {\n continue;\n }\n\n const count = this.renameSlotInTree(\n composition.composition,\n componentType,\n oldSlotId,\n newSlotId,\n strict\n );\n\n if (count > 0) {\n const relativePath = filePath.replace(directory, '').replace(/^[/\\\\]/, '');\n this.logger.action(\n whatIf,\n 'UPDATE',\n `${label}/${relativePath} (${count} instance(s) of ${componentType})`\n );\n\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, composition);\n }\n filesModified++;\n instancesRenamed += count;\n }\n }\n\n return { filesModified, instancesRenamed };\n }\n\n private renameSlotInTree(\n node: { type: string; slots?: Record<string, ComponentInstance[]>; [key: string]: unknown },\n componentType: string,\n oldSlotId: string,\n newSlotId: string,\n strict: boolean\n ): number {\n let count = 0;\n\n // Check if this node's type matches the target component type\n if (this.compareIds(node.type, componentType, strict) && node.slots) {\n const result = this.renameSlotKey(node.slots, oldSlotId, newSlotId, strict);\n if (result.renamed) {\n node.slots = result.slots;\n count++;\n }\n }\n\n // Recurse into all slots\n if (node.slots) {\n for (const slotInstances of Object.values(node.slots)) {\n if (!Array.isArray(slotInstances)) continue;\n for (const instance of slotInstances) {\n count += this.renameSlotInTree(instance, componentType, oldSlotId, newSlotId, strict);\n }\n }\n }\n\n return count;\n }\n\n private renameSlotKey(\n slots: Record<string, ComponentInstance[]>,\n oldSlotId: string,\n newSlotId: string,\n strict: boolean\n ): { renamed: boolean; slots: Record<string, ComponentInstance[]> } {\n const matchingKey = Object.keys(slots).find((key) =>\n this.compareIds(key, oldSlotId, strict)\n );\n\n if (!matchingKey) {\n return { renamed: false, slots };\n }\n\n // Rebuild object preserving key order, replacing the old key with the new one\n const newSlots: Record<string, ComponentInstance[]> = {};\n for (const key of Object.keys(slots)) {\n if (key === matchingKey) {\n newSlots[newSlotId] = slots[key];\n } else {\n newSlots[key] = slots[key];\n }\n }\n\n return { renamed: true, slots: newSlots };\n }\n}\n","import { Command } from 'commander';\nimport { RenameComponentOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { ComponentRenamerService } from '../../core/services/component-renamer.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createRenameComponentCommand(): Command {\n const command = new Command('rename-component');\n\n command\n .description(\n 'Renames a component type across definitions, filenames, allowedComponents, and all compositions.'\n )\n .option('--componentType <type>', 'The current component type ID to rename')\n .option('--newComponentType <type>', 'The new component type ID')\n .option('--newComponentName <name>', 'New display name for the component (optional)')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'componentType', flag: '--componentType' },\n { name: 'newComponentType', flag: '--newComponentType' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: RenameComponentOptions = {\n ...globalOpts,\n componentType: opts.componentType,\n newComponentType: opts.newComponentType,\n newComponentName: opts.newComponentName,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const renamer = new ComponentRenamerService(fileSystem, componentService, logger);\n\n try {\n const result = await renamer.rename({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionPatternsDir: options.compositionPatternsDir,\n componentPatternsDir: options.componentPatternsDir,\n componentType: options.componentType,\n newComponentType: options.newComponentType,\n newComponentName: options.newComponentName,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n });\n\n logger.success(\n `Renamed component: ${result.allowedComponentsUpdated} allowedComponents ref(s), ` +\n `${result.compositionsModified} composition(s), ` +\n `${result.compositionPatternsModified} composition pattern(s), ` +\n `${result.componentPatternsModified} component pattern(s) updated`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { ComponentDefinition, ComponentInstance, Composition } from '../types/index.js';\nimport { ComponentAlreadyExistsError, ComponentNotFoundError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface RenameComponentInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n componentType: string;\n newComponentType: string;\n newComponentName?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface RenameComponentResult {\n componentRenamed: boolean;\n fileRenamed: boolean;\n allowedComponentsUpdated: number;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesRenamed: number;\n}\n\nexport class ComponentRenamerService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async rename(options: RenameComponentInternalOptions): Promise<RenameComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n componentType,\n newComponentType,\n newComponentName,\n whatIf,\n strict,\n } = options;\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Validate: newComponentType must differ from componentType\n if (this.compareIds(componentType, newComponentType, strict)) {\n throw new TransformError('New component type is the same as the current component type');\n }\n\n // Step 1: Load and validate source component\n this.logger.info(`Loading component: ${componentType}`);\n const { component, filePath: componentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, componentType, findOptions);\n\n // Step 2: Check target does not already exist\n let targetExists = false;\n try {\n await this.componentService.loadComponent(fullComponentsDir, newComponentType, findOptions);\n targetExists = true;\n } catch (error) {\n if (!(error instanceof ComponentNotFoundError)) {\n throw error;\n }\n }\n if (targetExists) {\n throw new ComponentAlreadyExistsError(newComponentType, fullComponentsDir);\n }\n\n // Step 3: Update the component definition id (and optionally name)\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Component ID \"${componentType}\" → \"${newComponentType}\" in component/${this.fileSystem.getBasename(componentFilePath)}`\n );\n component.id = newComponentType;\n if (newComponentName !== undefined) {\n component.name = newComponentName;\n }\n\n if (!whatIf) {\n await this.componentService.saveComponent(componentFilePath, component);\n }\n\n // Step 4: Rename the component file\n const ext = this.fileSystem.getExtension(componentFilePath);\n const dir = this.fileSystem.getDirname(componentFilePath);\n const newFilePath = this.fileSystem.joinPath(dir, `${newComponentType}${ext}`);\n let fileRenamed = false;\n\n if (componentFilePath !== newFilePath) {\n this.logger.action(\n whatIf,\n 'RENAME',\n `component/${this.fileSystem.getBasename(componentFilePath)} → component/${this.fileSystem.getBasename(newFilePath)}`\n );\n if (!whatIf) {\n await this.fileSystem.renameFile(componentFilePath, newFilePath);\n }\n fileRenamed = true;\n }\n\n // Step 5: Update allowedComponents on other component definitions\n const allowedComponentsUpdated = await this.updateAllowedComponents(\n fullComponentsDir,\n componentType,\n newComponentType,\n componentFilePath,\n whatIf,\n strict\n );\n\n // Step 6: Update type fields in compositions\n const compositionsResult = await this.renameTypeInDirectory(\n fullCompositionsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 7: Update type fields in composition patterns\n const compositionPatternsResult = await this.renameTypeInDirectory(\n fullCompositionPatternsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 8: Update type fields in component patterns\n const componentPatternsResult = await this.renameTypeInDirectory(\n fullComponentPatternsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n // Summary\n const totalCompositionFiles =\n compositionsResult.filesModified +\n compositionPatternsResult.filesModified +\n componentPatternsResult.filesModified;\n const totalInstances =\n compositionsResult.instancesRenamed +\n compositionPatternsResult.instancesRenamed +\n componentPatternsResult.instancesRenamed;\n\n this.logger.info('');\n this.logger.info(\n `Summary: 1 component renamed, ${allowedComponentsUpdated} component(s) with allowedComponents updated, ` +\n `${totalCompositionFiles} composition file(s) (${totalInstances} instance(s)) updated.`\n );\n\n return {\n componentRenamed: true,\n fileRenamed,\n allowedComponentsUpdated,\n compositionsModified: compositionsResult.filesModified,\n compositionPatternsModified: compositionPatternsResult.filesModified,\n componentPatternsModified: componentPatternsResult.filesModified,\n instancesRenamed: totalInstances,\n };\n }\n\n private async updateAllowedComponents(\n componentsDir: string,\n oldType: string,\n newType: string,\n sourceFilePath: string,\n whatIf: boolean,\n strict: boolean\n ): Promise<number> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(componentsDir, '*.{json,yaml,yml}');\n } catch {\n return 0;\n }\n\n let updatedCount = 0;\n\n for (const filePath of files) {\n // Skip the source component file itself (it was already saved with the new id)\n if (filePath === sourceFilePath) continue;\n\n let comp: ComponentDefinition;\n try {\n comp = await this.fileSystem.readFile<ComponentDefinition>(filePath);\n } catch {\n continue;\n }\n\n if (!comp.slots || comp.slots.length === 0) continue;\n\n let fileModified = false;\n for (const slot of comp.slots) {\n if (!slot.allowedComponents) continue;\n\n for (let i = 0; i < slot.allowedComponents.length; i++) {\n if (this.compareIds(slot.allowedComponents[i], oldType, strict)) {\n slot.allowedComponents[i] = newType;\n fileModified = true;\n }\n }\n }\n\n if (fileModified) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `allowedComponents in component/${this.fileSystem.getBasename(filePath)}: ${oldType} → ${newType}`\n );\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, comp);\n }\n updatedCount++;\n }\n }\n\n return updatedCount;\n }\n\n private async renameTypeInDirectory(\n directory: string,\n oldType: string,\n newType: string,\n whatIf: boolean,\n strict: boolean,\n label: string\n ): Promise<{ filesModified: number; instancesRenamed: number }> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n } catch {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n if (files.length === 0) {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n let filesModified = 0;\n let instancesRenamed = 0;\n\n for (const filePath of files) {\n let composition: Composition;\n try {\n composition = await this.fileSystem.readFile<Composition>(filePath);\n } catch {\n continue;\n }\n\n if (!composition?.composition) continue;\n\n const count = this.renameTypeInTree(composition.composition, oldType, newType, strict);\n\n if (count > 0) {\n const relativePath = filePath.replace(directory, '').replace(/^[/\\\\]/, '');\n this.logger.action(\n whatIf,\n 'UPDATE',\n `${label}/${relativePath} (${count} instance(s))`\n );\n\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, composition);\n }\n filesModified++;\n instancesRenamed += count;\n }\n }\n\n return { filesModified, instancesRenamed };\n }\n\n private renameTypeInTree(\n node: { type: string; slots?: Record<string, ComponentInstance[]>; [key: string]: unknown },\n oldType: string,\n newType: string,\n strict: boolean\n ): number {\n let count = 0;\n\n // Check this node's type\n if (this.compareIds(node.type, oldType, strict)) {\n node.type = newType;\n count++;\n }\n\n // Recurse into all slots\n if (node.slots) {\n for (const slotInstances of Object.values(node.slots)) {\n if (!Array.isArray(slotInstances)) continue;\n for (const instance of slotInstances) {\n count += this.renameTypeInTree(instance, oldType, newType, strict);\n }\n }\n }\n\n return count;\n }\n}\n","import { Command } from 'commander';\nimport { AddComponentOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { ComponentAdderService } from '../../core/services/component-adder.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createAddComponentCommand(): Command {\n const command = new Command('add-component');\n\n command\n .description('Adds a component instance to existing component slots across all compositions.')\n .option('--parentComponentType <type>', 'The component type that owns the slot')\n .option('--slot <slotId>', 'The slot ID where the component will be added')\n .option('--newComponentType <type>', 'The component type to add')\n .option('--parameters <params>', 'Pipe-separated parameter assignments (key1:value1|key2:value2)')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'parentComponentType', flag: '--parentComponentType' },\n { name: 'slot', flag: '--slot' },\n { name: 'newComponentType', flag: '--newComponentType' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: AddComponentOptions = {\n ...globalOpts,\n parentComponentType: opts.parentComponentType,\n slot: opts.slot,\n newComponentType: opts.newComponentType,\n parameters: opts.parameters,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const adder = new ComponentAdderService(fileSystem, componentService, logger);\n\n try {\n const result = await adder.addComponent({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionPatternsDir: options.compositionPatternsDir,\n componentPatternsDir: options.componentPatternsDir,\n parentComponentType: options.parentComponentType,\n slot: options.slot,\n newComponentType: options.newComponentType,\n parameters: options.parameters,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n });\n\n logger.success(\n `Added component: ${result.allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${result.instancesAdded} instance(s) added across ` +\n `${result.compositionsModified} composition(s), ` +\n `${result.compositionPatternsModified} composition pattern(s), ` +\n `${result.componentPatternsModified} component pattern(s)`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { randomUUID } from 'node:crypto';\nimport {\n ComponentInstance,\n Composition,\n} from '../types/index.js';\nimport { ComponentNotFoundError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface AddComponentInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n parentComponentType: string;\n slot: string;\n newComponentType?: string;\n componentPatternId?: string;\n parameters?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface AddComponentResult {\n allowedComponentsUpdated: boolean;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesAdded: number;\n}\n\ninterface ComponentPattern {\n componentPatternId: string;\n definition: ComponentInstance;\n [key: string]: unknown;\n}\n\ninterface ParsedParameters {\n [key: string]: string;\n}\n\nexport class ComponentAdderService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n private parseParameters(parameterString?: string): ParsedParameters {\n const result: ParsedParameters = {};\n if (!parameterString) return result;\n\n const pairs = parameterString.split('|');\n for (const pair of pairs) {\n const [key, ...valueParts] = pair.split(':');\n if (key && valueParts.length > 0) {\n result[key.trim()] = valueParts.join(':').trim();\n }\n }\n return result;\n }\n\n private generateId(baseName: string): string {\n return `${baseName}-${randomUUID().slice(0, 8)}`;\n }\n\n private cloneComponentInstance(instance: ComponentInstance): ComponentInstance {\n const clone = JSON.parse(JSON.stringify(instance)) as ComponentInstance;\n\n // Regenerate _id for the root\n if (clone._id) {\n clone._id = this.generateId(clone.type);\n }\n\n // Recursively regenerate _id for nested instances\n if (clone.slots) {\n for (const slotInstances of Object.values(clone.slots)) {\n if (Array.isArray(slotInstances)) {\n for (const nestedInstance of slotInstances) {\n this.regenerateInstanceIds(nestedInstance);\n }\n }\n }\n }\n\n return clone;\n }\n\n private regenerateInstanceIds(instance: ComponentInstance): void {\n if (instance._id) {\n instance._id = this.generateId(instance.type);\n }\n\n if (instance.slots) {\n for (const slotInstances of Object.values(instance.slots)) {\n if (Array.isArray(slotInstances)) {\n for (const nestedInstance of slotInstances) {\n this.regenerateInstanceIds(nestedInstance);\n }\n }\n }\n }\n }\n\n private createComponentInstance(\n componentType: string,\n parameters: ParsedParameters\n ): ComponentInstance {\n const instance: ComponentInstance = {\n type: componentType,\n _id: this.generateId(componentType),\n };\n\n if (Object.keys(parameters).length > 0) {\n instance.parameters = {};\n for (const [key, value] of Object.entries(parameters)) {\n instance.parameters[key] = {\n type: 'text',\n value,\n };\n }\n }\n\n return instance;\n }\n\n private addComponentToSlot(slots: Record<string, ComponentInstance[]>, slotId: string, instance: ComponentInstance): void {\n if (!slots[slotId]) {\n slots[slotId] = [];\n }\n slots[slotId].push(instance);\n }\n\n async addComponent(options: AddComponentInternalOptions): Promise<AddComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n parentComponentType,\n slot,\n newComponentType,\n parameters: paramString,\n whatIf,\n strict,\n } = options;\n\n if (!newComponentType) {\n throw new TransformError('newComponentType is required for add-component');\n }\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Step 1: Load and validate parent component\n this.logger.info(`Loading parent component: ${parentComponentType}`);\n const { component: parentComponent, filePath: parentComponentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);\n\n // Step 2: Find or create slot on parent\n if (!parentComponent.slots) {\n parentComponent.slots = [];\n }\n let slotDef = parentComponent.slots.find((s) =>\n this.compareIds(s.id, slot, strict)\n );\n if (!slotDef) {\n this.logger.info(`Slot \"${slot}\" not found on component \"${parentComponentType}\", creating it`);\n slotDef = { id: slot, name: slot, allowedComponents: [] };\n parentComponent.slots.push(slotDef);\n }\n\n // Step 3: Validate new component type exists\n this.logger.info(`Validating new component: ${newComponentType}`);\n try {\n await this.componentService.loadComponent(fullComponentsDir, newComponentType, findOptions);\n } catch (error) {\n if (error instanceof ComponentNotFoundError) {\n throw new TransformError(\n `Component type \"${newComponentType}\" not found in ${fullComponentsDir}`\n );\n }\n throw error;\n }\n\n // Step 4: Update allowedComponents if needed\n let allowedComponentsUpdated = false;\n const slotIndex = parentComponent.slots?.findIndex((s) =>\n this.compareIds(s.id, slotDef.id, strict)\n );\n if (slotIndex !== undefined && slotIndex >= 0) {\n const actualSlot = parentComponent.slots![slotIndex];\n if (!actualSlot.allowedComponents) {\n actualSlot.allowedComponents = [];\n }\n\n const isAlreadyAllowed = actualSlot.allowedComponents.some((c) =>\n this.compareIds(c, newComponentType, strict)\n );\n\n if (!isAlreadyAllowed) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${newComponentType}\" to allowedComponents for slot \"${slot}\" on component \"${parentComponentType}\"`\n );\n actualSlot.allowedComponents.push(newComponentType);\n if (!whatIf) {\n await this.componentService.saveComponent(parentComponentFilePath, parentComponent);\n }\n allowedComponentsUpdated = true;\n }\n }\n\n // Step 5: Parse parameters\n const parsedParams = this.parseParameters(paramString);\n\n // Step 6: Create the new component instance\n const newInstance = this.createComponentInstance(newComponentType, parsedParams);\n\n // Step 7: Add to compositions\n const compositionsResult = await this.addComponentToDirectory(\n fullCompositionsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 8: Add to composition patterns\n const compositionPatternsResult = await this.addComponentToDirectory(\n fullCompositionPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 9: Add to component patterns\n const componentPatternsResult = await this.addComponentToDirectory(\n fullComponentPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n this.logger.info('');\n this.logger.info(\n `Summary: ${allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${compositionsResult} composition(s), ` +\n `${compositionPatternsResult} composition pattern(s), ` +\n `${componentPatternsResult} component pattern(s) updated. ` +\n `${compositionsResult + compositionPatternsResult + componentPatternsResult} instance(s) added.`\n );\n\n return {\n allowedComponentsUpdated,\n compositionsModified: compositionsResult,\n compositionPatternsModified: compositionPatternsResult,\n componentPatternsModified: componentPatternsResult,\n instancesAdded:\n compositionsResult + compositionPatternsResult + componentPatternsResult,\n };\n }\n\n async addComponentPattern(options: AddComponentInternalOptions): Promise<AddComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n parentComponentType,\n slot,\n componentPatternId,\n whatIf,\n strict,\n } = options;\n\n if (!componentPatternId) {\n throw new TransformError('componentPatternId is required for add-component-pattern');\n }\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Step 1: Load and validate parent component\n this.logger.info(`Loading parent component: ${parentComponentType}`);\n const { component: parentComponent } =\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);\n\n // Step 2: Find or create slot on parent\n if (!parentComponent.slots) {\n parentComponent.slots = [];\n }\n let slotDef = parentComponent.slots.find((s) =>\n this.compareIds(s.id, slot, strict)\n );\n if (!slotDef) {\n this.logger.info(`Slot \"${slot}\" not found on component \"${parentComponentType}\", creating it`);\n slotDef = { id: slot, name: slot, allowedComponents: [] };\n parentComponent.slots.push(slotDef);\n }\n\n // Step 3: Load and validate component pattern\n this.logger.info(`Loading component pattern: ${componentPatternId}`);\n const pattern = await this.loadComponentPattern(\n fullComponentPatternsDir,\n componentPatternId,\n strict\n );\n\n // Step 4: Get the definition from the pattern\n const patternDefinition = pattern.definition;\n if (!patternDefinition || !patternDefinition.type) {\n throw new TransformError(\n `Component pattern \"${componentPatternId}\" has no valid definition or missing type`\n );\n }\n\n // Step 5: Update allowedComponents if needed (using the pattern's definition type)\n let allowedComponentsUpdated = false;\n const componentTypeInPattern = patternDefinition.type;\n const slotIndex = parentComponent.slots?.findIndex((s) =>\n this.compareIds(s.id, slotDef.id, strict)\n );\n if (slotIndex !== undefined && slotIndex >= 0) {\n const actualSlot = parentComponent.slots![slotIndex];\n if (!actualSlot.allowedComponents) {\n actualSlot.allowedComponents = [];\n }\n\n const isAlreadyAllowed = actualSlot.allowedComponents.some((c) =>\n this.compareIds(c, componentTypeInPattern, strict)\n );\n\n if (!isAlreadyAllowed) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${componentTypeInPattern}\" to allowedComponents for slot \"${slot}\" on component \"${parentComponentType}\"`\n );\n actualSlot.allowedComponents.push(componentTypeInPattern);\n if (!whatIf) {\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions)\n .then(({ filePath }) =>\n this.componentService.saveComponent(filePath, parentComponent)\n );\n }\n allowedComponentsUpdated = true;\n }\n }\n\n // Step 6: Create the new component instance from the pattern (with cloned definition)\n const newInstance = this.cloneComponentInstance(patternDefinition);\n\n // Step 7: Add to compositions\n const compositionsResult = await this.addComponentToDirectory(\n fullCompositionsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 8: Add to composition patterns\n const compositionPatternsResult = await this.addComponentToDirectory(\n fullCompositionPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 9: Add to component patterns\n const componentPatternsResult = await this.addComponentToDirectory(\n fullComponentPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n this.logger.info('');\n this.logger.info(\n `Summary: ${allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${compositionsResult} composition(s), ` +\n `${compositionPatternsResult} composition pattern(s), ` +\n `${componentPatternsResult} component pattern(s) updated. ` +\n `${compositionsResult + compositionPatternsResult + componentPatternsResult} instance(s) added.`\n );\n\n return {\n allowedComponentsUpdated,\n compositionsModified: compositionsResult,\n compositionPatternsModified: compositionPatternsResult,\n componentPatternsModified: componentPatternsResult,\n instancesAdded:\n compositionsResult + compositionPatternsResult + componentPatternsResult,\n };\n }\n\n private async loadComponentPattern(\n componentPatternsDir: string,\n patternId: string,\n strict: boolean\n ): Promise<ComponentPattern> {\n // Try exact match first\n const jsonPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.json`);\n const yamlPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.yaml`);\n const ymlPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.yml`);\n\n if (await this.fileSystem.fileExists(jsonPath)) {\n return this.fileSystem.readFile<ComponentPattern>(jsonPath);\n }\n if (await this.fileSystem.fileExists(yamlPath)) {\n return this.fileSystem.readFile<ComponentPattern>(yamlPath);\n }\n if (await this.fileSystem.fileExists(ymlPath)) {\n return this.fileSystem.readFile<ComponentPattern>(ymlPath);\n }\n\n // If not strict, try case-insensitive search\n if (!strict) {\n const files = await this.fileSystem.findFiles(componentPatternsDir, '*.{json,yaml,yml}');\n for (const filePath of files) {\n const basename = this.fileSystem.getBasename(filePath);\n const nameWithoutExt = basename.replace(/\\.(json|yaml|yml)$/i, '');\n if (nameWithoutExt.toLowerCase() === patternId.toLowerCase()) {\n return this.fileSystem.readFile<ComponentPattern>(filePath);\n }\n }\n }\n\n throw new TransformError(`Component pattern \"${patternId}\" not found in ${componentPatternsDir}`);\n }\n\n private async addComponentToDirectory(\n directory: string,\n parentComponentType: string,\n slot: string,\n newInstance: ComponentInstance,\n whatIf: boolean,\n strict: boolean,\n dirType: 'composition' | 'compositionPattern' | 'componentPattern'\n ): Promise<number> {\n const exists = await this.fileSystem.fileExists(directory);\n if (!exists) {\n this.logger.detail(`${dirType} directory does not exist, skipping`);\n return 0;\n }\n\n const files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n let filesModified = 0;\n\n for (const filePath of files) {\n try {\n // Handle both composition and componentPattern formats\n const content = await this.fileSystem.readFile<unknown>(filePath);\n\n // For component patterns, the structure might be different\n let composition: Composition | null = null;\n let isComponentPattern = false;\n\n if (dirType === 'componentPattern' && content && typeof content === 'object' && 'definition' in content) {\n // This is a component pattern\n isComponentPattern = true;\n const pattern = content as ComponentPattern;\n if (pattern.definition && pattern.definition.slots) {\n composition = {\n composition: {\n _id: 'pattern-root',\n type: pattern.definition.type,\n slots: pattern.definition.slots,\n } as any,\n };\n }\n } else {\n // This is a normal composition\n composition = content as Composition;\n }\n\n if (!composition?.composition) {\n continue;\n }\n\n // Find and add to parent component instances\n const rootInstance = composition.composition as any;\n let modified = false;\n\n // Check root instance\n if (this.compareIds(rootInstance.type, parentComponentType, strict)) {\n if (!rootInstance.slots) {\n rootInstance.slots = {};\n }\n\n // Clone the new instance to avoid mutations\n const instanceCopy = JSON.parse(JSON.stringify(newInstance)) as ComponentInstance;\n // Regenerate IDs for this copy to ensure uniqueness\n this.regenerateInstanceIds(instanceCopy);\n this.addComponentToSlot(rootInstance.slots, slot, instanceCopy);\n modified = true;\n }\n\n // Check nested instances\n if (rootInstance.slots) {\n const nestedModified = this.addComponentToNestedSlots(\n rootInstance.slots,\n parentComponentType,\n slot,\n newInstance,\n strict\n );\n if (nestedModified) {\n modified = true;\n }\n }\n\n if (modified) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${newInstance.type}\" to slot \"${slot}\" in ${dirType}/${this.fileSystem.getBasename(filePath)}`\n );\n\n if (!whatIf) {\n if (isComponentPattern && content && typeof content === 'object' && 'definition' in content) {\n // For component patterns, update the definition\n const pattern = content as ComponentPattern;\n if (rootInstance.slots) {\n pattern.definition.slots = rootInstance.slots;\n }\n }\n await this.fileSystem.writeFile(filePath, content);\n }\n\n filesModified++;\n }\n } catch (error) {\n // Skip files that can't be parsed\n if (error instanceof Error && !error.message.includes('skipping')) {\n this.logger.detail(`Skipping ${filePath}: ${error.message}`);\n }\n }\n }\n\n return filesModified;\n }\n\n private addComponentToNestedSlots(\n slots: Record<string, ComponentInstance[]>,\n parentComponentType: string,\n slot: string,\n newInstance: ComponentInstance,\n strict: boolean\n ): boolean {\n let modified = false;\n\n for (const slotInstances of Object.values(slots)) {\n if (!Array.isArray(slotInstances)) continue;\n\n for (const instance of slotInstances) {\n if (this.compareIds(instance.type, parentComponentType, strict)) {\n if (!instance.slots) {\n instance.slots = {};\n }\n\n // Clone the new instance to avoid mutations across multiple matches\n const instanceCopy = JSON.parse(JSON.stringify(newInstance)) as ComponentInstance;\n // Regenerate IDs for this copy to ensure uniqueness\n this.regenerateInstanceIds(instanceCopy);\n this.addComponentToSlot(instance.slots, slot, instanceCopy);\n modified = true;\n }\n\n // Recurse into nested slots\n if (instance.slots) {\n const nestedModified = this.addComponentToNestedSlots(\n instance.slots,\n parentComponentType,\n slot,\n newInstance,\n strict\n );\n if (nestedModified) {\n modified = true;\n }\n }\n }\n }\n\n return modified;\n }\n}\n","import { Command } from 'commander';\nimport { AddComponentPatternOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { ComponentAdderService } from '../../core/services/component-adder.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createAddComponentPatternCommand(): Command {\n const command = new Command('add-component-pattern');\n\n command\n .description('Adds a component pattern instance to existing component slots across all compositions.')\n .option('--parentComponentType <type>', 'The component type that owns the slot')\n .option('--slot <slotId>', 'The slot ID where the component pattern will be added')\n .option('--componentPatternId <id>', 'The component pattern ID to add')\n .option('--parameters <params>', 'Pipe-separated parameter assignments (key1:value1|key2:value2)')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'parentComponentType', flag: '--parentComponentType' },\n { name: 'slot', flag: '--slot' },\n { name: 'componentPatternId', flag: '--componentPatternId' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: AddComponentPatternOptions = {\n ...globalOpts,\n parentComponentType: opts.parentComponentType,\n slot: opts.slot,\n componentPatternId: opts.componentPatternId,\n parameters: opts.parameters,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const adder = new ComponentAdderService(fileSystem, componentService, logger);\n\n try {\n const result = await adder.addComponentPattern({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionPatternsDir: options.compositionPatternsDir,\n componentPatternsDir: options.componentPatternsDir,\n parentComponentType: options.parentComponentType,\n slot: options.slot,\n componentPatternId: options.componentPatternId,\n parameters: options.parameters,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n });\n\n logger.success(\n `Added component pattern: ${result.allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${result.instancesAdded} instance(s) added across ` +\n `${result.compositionsModified} composition(s), ` +\n `${result.compositionPatternsModified} composition pattern(s), ` +\n `${result.componentPatternsModified} component pattern(s)`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { Command } from 'commander';\nimport { PropagateRootComponentSlotOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { CompositionService } from '../../core/services/composition.service.js';\nimport { SlotPropagatorService } from '../../core/services/slot-propagator.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createPropagateRootComponentSlotCommand(): Command {\n const command = new Command('propagate-root-component-slot');\n\n command\n .description(\n \"Copies slot definitions from a composition type's root component to a target component type, then moves all component instances from that slot across all matching compositions.\"\n )\n .option('--compositionType <type>', 'The composition type to process (e.g., HomePage)')\n .option('--slot <slots>', 'Pipe-separated list of slot names to copy from the source component')\n .option(\n '--targetComponentType <type>',\n 'The component type that will receive the copied slots'\n )\n .option(\n '--targetSlot <slot>',\n 'The slot name on the target component where the contents will be placed'\n )\n .option(\n '--deleteSourceSlot',\n 'Delete the original slots from the source component after propagation'\n )\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'compositionType', flag: '--compositionType' },\n { name: 'slot', flag: '--slot' },\n { name: 'targetComponentType', flag: '--targetComponentType' },\n { name: 'targetSlot', flag: '--targetSlot' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: PropagateRootComponentSlotOptions = {\n ...globalOpts,\n compositionType: opts.compositionType,\n slot: opts.slot,\n targetComponentType: opts.targetComponentType,\n targetSlot: opts.targetSlot,\n deleteSourceSlot: opts.deleteSourceSlot,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const compositionService = new CompositionService(fileSystem);\n const propagator = new SlotPropagatorService(\n fileSystem,\n componentService,\n compositionService,\n logger\n );\n\n try {\n const result = await propagator.propagate({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionType: options.compositionType,\n slot: options.slot,\n targetComponentType: options.targetComponentType,\n targetSlot: options.targetSlot,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n deleteSourceSlot: options.deleteSourceSlot ?? false,\n });\n\n logger.success(\n `Modified ${result.modifiedComponents} component(s), ${result.modifiedCompositions} composition(s)`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { ComponentInstance, SlotDefinition } from '../types/index.js';\nimport { PropertyNotFoundError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { CompositionService } from './composition.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface SlotPropagateOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionType: string;\n slot: string;\n targetComponentType: string;\n targetSlot: string;\n whatIf: boolean;\n strict: boolean;\n deleteSourceSlot: boolean;\n}\n\nexport interface SlotPropagateResult {\n modifiedComponents: number;\n modifiedCompositions: number;\n propagatedInstances: number;\n}\n\nexport class SlotPropagatorService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private compositionService: CompositionService,\n private logger: Logger\n ) {}\n\n async propagate(options: SlotPropagateOptions): Promise<SlotPropagateResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionType,\n slot,\n targetComponentType,\n targetSlot,\n whatIf,\n strict,\n deleteSourceSlot,\n } = options;\n\n const findOptions = { strict };\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n\n // Step 1: Load source component (compositionType)\n this.logger.info(`Loading component: ${compositionType}`);\n const { component: sourceComponent, filePath: sourceFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, compositionType, findOptions);\n\n // Step 2: Load target component\n this.logger.info(`Loading component: ${targetComponentType}`);\n const { component: targetComponent, filePath: targetFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, targetComponentType, findOptions);\n\n // Step 3: Parse and resolve slot names\n const slotNames = slot.split('|').map((s) => s.trim());\n const resolvedSlots: SlotDefinition[] = [];\n const notFound: string[] = [];\n\n for (const slotName of slotNames) {\n const slotDef = this.componentService.findSlot(sourceComponent, slotName, findOptions);\n if (slotDef) {\n resolvedSlots.push(slotDef);\n } else {\n notFound.push(slotName);\n }\n }\n\n if (notFound.length > 0) {\n throw new PropertyNotFoundError(`Slot \"${notFound.join(', ')}\"`, compositionType);\n }\n\n const resolvedSlotIds = resolvedSlots.map((s) => s.id);\n this.logger.info(`Resolved slots: ${resolvedSlotIds.join(', ')}`);\n\n // Step 4: Modify target component - add/merge slot definition\n let modifiedComponent = { ...targetComponent };\n let componentModified = false;\n\n const existingSlot = this.componentService.findSlot(modifiedComponent, targetSlot, findOptions);\n if (!existingSlot) {\n // Create new slot with merged allowedComponents from all source slots\n const mergedAllowedComponents = this.mergeAllowedComponents(resolvedSlots);\n this.logger.action(whatIf, 'CREATE', `Slot \"${targetSlot}\" on ${targetComponentType}`);\n modifiedComponent = this.componentService.addSlot(modifiedComponent, {\n id: targetSlot,\n name: targetSlot,\n allowedComponents: mergedAllowedComponents,\n });\n componentModified = true;\n } else {\n // Merge allowedComponents into existing slot\n const mergedAllowedComponents = this.mergeAllowedComponents([existingSlot, ...resolvedSlots]);\n const existingAllowed = existingSlot.allowedComponents ?? [];\n if (mergedAllowedComponents.length > existingAllowed.length) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Slot \"${targetSlot}\" allowedComponents on ${targetComponentType}`\n );\n modifiedComponent = this.componentService.updateSlotAllowedComponents(\n modifiedComponent,\n targetSlot,\n mergedAllowedComponents,\n findOptions\n );\n componentModified = true;\n } else {\n this.logger.info(`Slot \"${targetSlot}\" already exists on ${targetComponentType}`);\n }\n }\n\n // Save modified target component\n if (componentModified && !whatIf) {\n await this.componentService.saveComponent(targetFilePath, modifiedComponent);\n }\n\n // Step 5: Propagate slot contents in compositions\n const compositions = await this.compositionService.findCompositionsByType(\n fullCompositionsDir,\n compositionType,\n findOptions\n );\n\n let modifiedCompositions = 0;\n let propagatedInstances = 0;\n\n for (const { composition, filePath } of compositions) {\n const rootSlots = composition.composition.slots ?? {};\n const instances = this.compositionService.findComponentInstances(\n composition,\n targetComponentType,\n findOptions\n );\n\n if (instances.length === 0) {\n continue;\n }\n\n // Collect all components from source slots\n const componentsToPropagate: ComponentInstance[] = [];\n for (const slotDef of resolvedSlots) {\n const slotContent = rootSlots[slotDef.id] ?? [];\n componentsToPropagate.push(...slotContent);\n }\n\n if (componentsToPropagate.length === 0) {\n continue;\n }\n\n let compositionModified = false;\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n const instanceUpdates: string[] = [];\n\n for (const { instance, instanceId } of instances) {\n const instanceName = instance._id ?? instanceId;\n // Deep clone components to avoid reference issues\n const clonedComponents = this.deepCloneComponents(componentsToPropagate);\n this.addComponentsToInstanceSlot(instance, targetSlot, clonedComponents);\n compositionModified = true;\n propagatedInstances++;\n instanceUpdates.push(\n `${targetComponentType} \"${instanceName}\": ${componentsToPropagate.length} component(s) → ${targetSlot}`\n );\n }\n\n if (compositionModified) {\n this.logger.action(whatIf, 'UPDATE', `composition/${relativePath}`);\n for (const update of instanceUpdates) {\n this.logger.detail(`→ ${update}`);\n }\n\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n modifiedCompositions++;\n }\n }\n\n // Step 6: Delete source slots if requested\n let sourceComponentModified = false;\n if (deleteSourceSlot) {\n let modifiedSource = { ...sourceComponent };\n\n // Delete the resolved slots from source component\n for (const slotDef of resolvedSlots) {\n this.logger.action(whatIf, 'DELETE', `Slot \"${slotDef.id}\" from ${compositionType}`);\n modifiedSource = this.componentService.removeSlot(modifiedSource, slotDef.id, findOptions);\n sourceComponentModified = true;\n }\n\n if (sourceComponentModified && !whatIf) {\n await this.componentService.saveComponent(sourceFilePath, modifiedSource);\n }\n\n // Clear slot contents from root in compositions\n for (const { composition, filePath } of compositions) {\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n let cleared = false;\n\n for (const slotDef of resolvedSlots) {\n if (composition.composition.slots?.[slotDef.id]?.length) {\n composition.composition.slots[slotDef.id] = [];\n cleared = true;\n }\n }\n\n if (cleared) {\n this.logger.action(whatIf, 'CLEAR', `Root slots in composition/${relativePath}`);\n this.logger.detail(`→ Cleared: ${resolvedSlotIds.join(', ')}`);\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n }\n }\n }\n\n return {\n modifiedComponents: (componentModified ? 1 : 0) + (sourceComponentModified ? 1 : 0),\n modifiedCompositions,\n propagatedInstances,\n };\n }\n\n private mergeAllowedComponents(slots: SlotDefinition[]): string[] {\n const allowed = new Set<string>();\n for (const slot of slots) {\n for (const comp of slot.allowedComponents ?? []) {\n allowed.add(comp);\n }\n }\n return Array.from(allowed).sort();\n }\n\n private deepCloneComponents(components: ComponentInstance[]): ComponentInstance[] {\n return JSON.parse(JSON.stringify(components));\n }\n\n private addComponentsToInstanceSlot(\n instance: ComponentInstance,\n slotName: string,\n components: ComponentInstance[]\n ): void {\n if (!instance.slots) {\n instance.slots = {};\n }\n if (!instance.slots[slotName]) {\n instance.slots[slotName] = [];\n }\n instance.slots[slotName].push(...components);\n }\n}\n"],"mappings":";;;AAEA,SAAS,WAAAA,iBAAe;;;ACFxB,SAAS,eAAe;;;ACAxB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,YAAY;AACrB,YAAY,UAAU;;;ACHf,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,yBAAN,cAAqC,eAAe;AAAA,EACzD,YAAY,eAAuBC,OAAe;AAChD,UAAM,WAAWA,QAAO,eAAeA,KAAI,MAAM;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C9D,OAAO,oBAAoB,wBAAwB,OAAO,EAC1D,OAAO,0BAA0B,+BAA+B,YAAY,EAC5E,OAAO,+BAA+B,oCAAoC,iBAAiB,EAC3F;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACF,EACC,OAAO,8BAA8B,oCAAoC,gBAAgB,EACzF,OAAO,qBAAqB,yBAAyB,OAAO;AAG/D,QAAQ,WAAW,4CAA4C,CAAC;AAChE,QAAQ,WAAW,8CAA8C,CAAC;AAClE,QAAQ,WAAW,iCAAiC,CAAC;AACrD,QAAQ,WAAW,+BAA+B,CAAC;AACnD,QAAQ,WAAW,wBAAwB,CAAC;AAC5C,QAAQ,WAAW,6BAA6B,CAAC;AACjD,QAAQ,WAAW,0BAA0B,CAAC;AAC9C,QAAQ,WAAW,iCAAiC,CAAC;AACrD,QAAQ,WAAW,wCAAwC,CAAC;AAE5D,QAAQ,MAAM;","names":["Command","path","basename","Command","Command","Command","Command","Command","Command","Command","Command","Command","Command","Command","basename","Command","Command","Command","Command","Command","Command"]}
1
+ {"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/propagate-root-component-property.ts","../../src/core/services/file-system.service.ts","../../src/core/errors.ts","../../src/core/services/component.service.ts","../../src/core/services/composition.service.ts","../../src/core/services/property-propagator.service.ts","../../src/cli/logger.ts","../../src/cli/commands/find-composition-pattern-candidates.ts","../../src/core/services/pattern-analyzer.service.ts","../../src/cli/commands/unpack-serialization.ts","../../src/core/services/serialization-packer.service.ts","../../src/cli/commands/pack-serialization.ts","../../src/cli/commands/rename-slot.ts","../../src/core/services/slot-renamer.service.ts","../../src/cli/commands/rename-component.ts","../../src/core/services/component-renamer.service.ts","../../src/cli/commands/add-component.ts","../../src/core/services/component-adder.service.ts","../../src/cli/commands/add-component-pattern.ts","../../src/cli/commands/propagate-root-component-slot.ts","../../src/core/services/slot-propagator.service.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { createPropagateRootComponentPropertyCommand } from './commands/propagate-root-component-property.js';\nimport { createFindCompositionPatternCandidatesCommand } from './commands/find-composition-pattern-candidates.js';\nimport { createUnpackSerializationCommand } from './commands/unpack-serialization.js';\nimport { createPackSerializationCommand } from './commands/pack-serialization.js';\nimport { createRenameSlotCommand } from './commands/rename-slot.js';\nimport { createRenameComponentCommand } from './commands/rename-component.js';\nimport { createAddComponentCommand } from './commands/add-component.js';\nimport { createAddComponentPatternCommand } from './commands/add-component-pattern.js';\nimport { createPropagateRootComponentSlotCommand } from './commands/propagate-root-component-slot.js';\n\nconst program = new Command();\n\nprogram\n .name('uniform-transform')\n .description('CLI tool for transforming Uniform.dev serialization files offline')\n .version('1.0.0');\n\n// Global options\nprogram\n .requiredOption('--rootDir <path>', 'Path to the serialization project root')\n .option('--what-if', 'Dry run mode - preview changes without modifying files', false)\n .option('--strict', 'Enable strict mode for case-sensitive matching', false)\n .option('--compositionsDir <dir>', 'Compositions directory name', 'composition')\n .option('--componentsDir <dir>', 'Components directory name', 'component')\n .option('--contentTypesDir <dir>', 'Content types directory name', 'contentType')\n .option('--assetsDir <dir>', 'Assets directory name', 'asset')\n .option('--categoriesDir <dir>', 'Categories directory name', 'category')\n .option('--componentPatternsDir <dir>', 'Component patterns directory name', 'componentPattern')\n .option(\n '--compositionPatternsDir <dir>',\n 'Composition patterns directory name',\n 'compositionPattern'\n )\n .option('--dataTypesDir <dir>', 'Data types directory name', 'dataType')\n .option('--entriesDir <dir>', 'Entries directory name', 'entry')\n .option('--filesDir <dir>', 'Files directory name', 'files')\n .option('--previewUrlsDir <dir>', 'Preview URLs directory name', 'previewUrl')\n .option('--previewViewportsDir <dir>', 'Preview viewports directory name', 'previewViewport')\n .option(\n '--projectMapDefinitionsDir <dir>',\n 'Project map definitions directory name',\n 'projectMapDefinition'\n )\n .option('--projectMapNodesDir <dir>', 'Project map nodes directory name', 'projectMapNode')\n .option('--quirksDir <dir>', 'Quirks directory name', 'quirk');\n\n// Add commands\nprogram.addCommand(createPropagateRootComponentPropertyCommand());\nprogram.addCommand(createFindCompositionPatternCandidatesCommand());\nprogram.addCommand(createUnpackSerializationCommand());\nprogram.addCommand(createPackSerializationCommand());\nprogram.addCommand(createRenameSlotCommand());\nprogram.addCommand(createRenameComponentCommand());\nprogram.addCommand(createAddComponentCommand());\nprogram.addCommand(createAddComponentPatternCommand());\nprogram.addCommand(createPropagateRootComponentSlotCommand());\n\nprogram.parse();\n","import { Command } from 'commander';\nimport { PropagateRootComponentPropertyOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { CompositionService } from '../../core/services/composition.service.js';\nimport { PropertyPropagatorService } from '../../core/services/property-propagator.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createPropagateRootComponentPropertyCommand(): Command {\n const command = new Command('propagate-root-component-property');\n\n command\n .description(\n 'Copies property definitions from a composition type\\'s root component to a target component type, then propagates the actual values across all matching compositions.'\n )\n .option('--compositionType <type>', 'The composition type to process (e.g., HomePage)')\n .option('--property <properties>', 'Pipe-separated list of properties and/or groups to copy')\n .option(\n '--targetComponentType <type>',\n 'The component type that will receive the copied properties'\n )\n .option(\n '--targetGroup <group>',\n 'The group name on the target component where properties will be placed'\n )\n .option(\n '--deleteSourceParameter',\n 'Delete the original parameters from the source component after propagation'\n )\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'compositionType', flag: '--compositionType' },\n { name: 'property', flag: '--property' },\n { name: 'targetComponentType', flag: '--targetComponentType' },\n { name: 'targetGroup', flag: '--targetGroup' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: PropagateRootComponentPropertyOptions = {\n ...globalOpts,\n compositionType: opts.compositionType,\n property: opts.property,\n targetComponentType: opts.targetComponentType,\n targetGroup: opts.targetGroup,\n deleteSourceParameter: opts.deleteSourceParameter,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const compositionService = new CompositionService(fileSystem);\n const propagator = new PropertyPropagatorService(\n fileSystem,\n componentService,\n compositionService,\n logger\n );\n\n try {\n const result = await propagator.propagate({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionType: options.compositionType,\n property: options.property,\n targetComponentType: options.targetComponentType,\n targetGroup: options.targetGroup,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n deleteSourceParameter: options.deleteSourceParameter ?? false,\n });\n\n logger.success(\n `Modified ${result.modifiedComponents} component, ${result.modifiedCompositions} compositions`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { glob } from 'glob';\nimport * as YAML from 'yaml';\nimport { InvalidYamlError, FileNotFoundError } from '../errors.js';\n\nexport class FileSystemService {\n private isJsonFile(filePath: string): boolean {\n return filePath.toLowerCase().endsWith('.json');\n }\n\n async readFile<T>(filePath: string): Promise<T> {\n if (!fs.existsSync(filePath)) {\n throw new FileNotFoundError(filePath);\n }\n\n try {\n const content = fs.readFileSync(filePath, 'utf-8');\n if (this.isJsonFile(filePath)) {\n return JSON.parse(content) as T;\n }\n return YAML.parse(content) as T;\n } catch (error) {\n if (error instanceof FileNotFoundError) {\n throw error;\n }\n const message = error instanceof Error ? error.message : String(error);\n throw new InvalidYamlError(filePath, message);\n }\n }\n\n async writeFile<T>(filePath: string, data: T): Promise<void> {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n let content: string;\n if (this.isJsonFile(filePath)) {\n content = JSON.stringify(data, null, 2);\n } else {\n content = YAML.stringify(data, {\n lineWidth: 0,\n defaultKeyType: 'PLAIN',\n defaultStringType: 'QUOTE_DOUBLE',\n });\n }\n fs.writeFileSync(filePath, content, 'utf-8');\n }\n\n async readYamlFile<T>(filePath: string): Promise<T> {\n return this.readFile<T>(filePath);\n }\n\n async writeYamlFile<T>(filePath: string, data: T): Promise<void> {\n return this.writeFile(filePath, data);\n }\n\n async findFiles(directory: string, pattern: string): Promise<string[]> {\n const fullPattern = path.join(directory, pattern).replace(/\\\\/g, '/');\n return glob(fullPattern);\n }\n\n async fileExists(filePath: string): Promise<boolean> {\n return fs.existsSync(filePath);\n }\n\n resolvePath(...segments: string[]): string {\n return path.resolve(...segments);\n }\n\n joinPath(...segments: string[]): string {\n return path.join(...segments);\n }\n\n getBasename(filePath: string, ext?: string): string {\n return path.basename(filePath, ext);\n }\n\n async renameFile(oldPath: string, newPath: string): Promise<void> {\n fs.renameSync(oldPath, newPath);\n }\n\n deleteFile(filePath: string): void {\n fs.unlinkSync(filePath);\n }\n\n getExtension(filePath: string): string {\n return path.extname(filePath);\n }\n\n getDirname(filePath: string): string {\n return path.dirname(filePath);\n }\n}\n","export class TransformError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'TransformError';\n }\n}\n\nexport class ComponentNotFoundError extends TransformError {\n constructor(componentType: string, path?: string) {\n const pathInfo = path ? ` (searched: ${path})` : '';\n super(`Component not found: ${componentType}${pathInfo}`);\n this.name = 'ComponentNotFoundError';\n }\n}\n\nexport class PropertyNotFoundError extends TransformError {\n constructor(propertyName: string, componentType: string) {\n super(`Property \"${propertyName}\" not found on component \"${componentType}\"`);\n this.name = 'PropertyNotFoundError';\n }\n}\n\nexport class InvalidYamlError extends TransformError {\n constructor(filePath: string, details?: string) {\n const detailsInfo = details ? `: ${details}` : '';\n super(`Invalid YAML file: ${filePath}${detailsInfo}`);\n this.name = 'InvalidYamlError';\n }\n}\n\nexport class FileNotFoundError extends TransformError {\n constructor(filePath: string) {\n super(`File not found: ${filePath}`);\n this.name = 'FileNotFoundError';\n }\n}\n\nexport class DuplicateIdError extends TransformError {\n constructor(id: string, arrayProperty: string, filePath: string) {\n super(`Duplicate id \"${id}\" in array \"${arrayProperty}\" of file: ${filePath}`);\n this.name = 'DuplicateIdError';\n }\n}\n\nexport class ComponentAlreadyExistsError extends TransformError {\n constructor(componentType: string, path?: string) {\n const pathInfo = path ? ` (searched: ${path})` : '';\n super(`Component type \"${componentType}\" already exists${pathInfo}`);\n this.name = 'ComponentAlreadyExistsError';\n }\n}\n\nexport class SlotNotFoundError extends TransformError {\n constructor(slotId: string, componentType: string) {\n super(`Slot \"${slotId}\" does not exist on component \"${componentType}\"`);\n this.name = 'SlotNotFoundError';\n }\n}\n\nexport class SlotAlreadyExistsError extends TransformError {\n constructor(slotId: string, componentType: string) {\n super(`Slot \"${slotId}\" already exists on component \"${componentType}\"`);\n this.name = 'SlotAlreadyExistsError';\n }\n}\n","import { ComponentDefinition, Parameter, SlotDefinition } from '../types/index.js';\nimport { ComponentNotFoundError, PropertyNotFoundError } from '../errors.js';\nimport { FileSystemService } from './file-system.service.js';\n\nexport interface FindOptions {\n strict?: boolean;\n}\n\nexport class ComponentService {\n constructor(private fileSystem: FileSystemService) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async loadComponent(\n componentsDir: string,\n componentType: string,\n options: FindOptions = {}\n ): Promise<{ component: ComponentDefinition; filePath: string }> {\n const { strict = false } = options;\n\n // First try exact match\n const jsonPath = this.fileSystem.joinPath(componentsDir, `${componentType}.json`);\n const yamlPath = this.fileSystem.joinPath(componentsDir, `${componentType}.yaml`);\n const ymlPath = this.fileSystem.joinPath(componentsDir, `${componentType}.yml`);\n\n if (await this.fileSystem.fileExists(jsonPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(jsonPath);\n return { component, filePath: jsonPath };\n }\n if (await this.fileSystem.fileExists(yamlPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(yamlPath);\n return { component, filePath: yamlPath };\n }\n if (await this.fileSystem.fileExists(ymlPath)) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(ymlPath);\n return { component, filePath: ymlPath };\n }\n\n // If not strict, try case-insensitive search\n if (!strict) {\n const files = await this.fileSystem.findFiles(componentsDir, '*.{json,yaml,yml}');\n for (const filePath of files) {\n const basename = this.fileSystem.getBasename(filePath);\n const nameWithoutExt = basename.replace(/\\.(json|yaml|yml)$/i, '');\n if (nameWithoutExt.toLowerCase() === componentType.toLowerCase()) {\n const component = await this.fileSystem.readFile<ComponentDefinition>(filePath);\n return { component, filePath };\n }\n }\n }\n\n throw new ComponentNotFoundError(componentType, componentsDir);\n }\n\n async saveComponent(filePath: string, component: ComponentDefinition): Promise<void> {\n await this.fileSystem.writeFile(filePath, component);\n }\n\n findParameter(\n component: ComponentDefinition,\n parameterName: string,\n options: FindOptions = {}\n ): Parameter | undefined {\n const { strict = false } = options;\n return component.parameters?.find((p) => this.compareIds(p.id, parameterName, strict));\n }\n\n isGroupParameter(parameter: Parameter): boolean {\n return parameter.type === 'group';\n }\n\n resolveGroupParameters(\n component: ComponentDefinition,\n groupParameter: Parameter,\n options: FindOptions = {}\n ): Parameter[] {\n if (!this.isGroupParameter(groupParameter)) {\n return [groupParameter];\n }\n\n const childrenIds = groupParameter.typeConfig?.childrenParams ?? [];\n const resolved: Parameter[] = [];\n\n for (const childId of childrenIds) {\n const childParam = this.findParameter(component, childId, options);\n if (childParam) {\n resolved.push(childParam);\n }\n }\n\n return resolved;\n }\n\n resolveProperties(\n component: ComponentDefinition,\n propertyNames: string[],\n options: FindOptions = {}\n ): { parameters: Parameter[]; notFound: string[] } {\n const parameters: Parameter[] = [];\n const notFound: string[] = [];\n const seenIds = new Set<string>();\n\n for (const name of propertyNames) {\n const param = this.findParameter(component, name, options);\n if (!param) {\n notFound.push(name);\n continue;\n }\n\n if (this.isGroupParameter(param)) {\n const groupParams = this.resolveGroupParameters(component, param, options);\n for (const gp of groupParams) {\n if (!seenIds.has(gp.id)) {\n seenIds.add(gp.id);\n parameters.push(gp);\n }\n }\n } else {\n if (!seenIds.has(param.id)) {\n seenIds.add(param.id);\n parameters.push(param);\n }\n }\n }\n\n return { parameters, notFound };\n }\n\n addParameterToComponent(\n component: ComponentDefinition,\n parameter: Parameter,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n component.parameters = [];\n }\n\n const existingIndex = component.parameters.findIndex((p) =>\n this.compareIds(p.id, parameter.id, strict)\n );\n if (existingIndex >= 0) {\n component.parameters[existingIndex] = { ...parameter };\n } else {\n component.parameters.push({ ...parameter });\n }\n\n return component;\n }\n\n ensureGroupExists(\n component: ComponentDefinition,\n groupId: string,\n groupName?: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n component.parameters = [];\n }\n\n const existing = component.parameters.find((p) => this.compareIds(p.id, groupId, strict));\n if (existing) {\n return component;\n }\n\n const groupParam: Parameter = {\n id: groupId,\n name: groupName ?? groupId,\n type: 'group',\n typeConfig: {\n childrenParams: [],\n },\n };\n\n component.parameters.push(groupParam);\n return component;\n }\n\n addParameterToGroup(\n component: ComponentDefinition,\n groupId: string,\n parameterId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n const group = component.parameters?.find((p) => this.compareIds(p.id, groupId, strict));\n if (!group || !this.isGroupParameter(group)) {\n throw new PropertyNotFoundError(groupId, component.id);\n }\n\n if (!group.typeConfig) {\n group.typeConfig = { childrenParams: [] };\n }\n if (!group.typeConfig.childrenParams) {\n group.typeConfig.childrenParams = [];\n }\n\n // Check if already exists (case-insensitive if not strict)\n const alreadyExists = group.typeConfig.childrenParams.some((id) =>\n this.compareIds(id, parameterId, strict)\n );\n\n if (!alreadyExists) {\n group.typeConfig.childrenParams.push(parameterId);\n }\n\n return component;\n }\n\n removeParameter(\n component: ComponentDefinition,\n parameterId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.parameters) {\n return component;\n }\n\n component.parameters = component.parameters.filter(\n (p) => !this.compareIds(p.id, parameterId, strict)\n );\n\n // Also remove from any groups that reference this parameter\n for (const param of component.parameters) {\n if (this.isGroupParameter(param) && param.typeConfig?.childrenParams) {\n param.typeConfig.childrenParams = param.typeConfig.childrenParams.filter(\n (id) => !this.compareIds(id, parameterId, strict)\n );\n }\n }\n\n return component;\n }\n\n removeEmptyGroups(component: ComponentDefinition): ComponentDefinition {\n if (!component.parameters) {\n return component;\n }\n\n component.parameters = component.parameters.filter((p) => {\n if (!this.isGroupParameter(p)) {\n return true;\n }\n const children = p.typeConfig?.childrenParams ?? [];\n return children.length > 0;\n });\n\n return component;\n }\n\n // Slot methods\n\n findSlot(\n component: ComponentDefinition,\n slotId: string,\n options: FindOptions = {}\n ): SlotDefinition | undefined {\n const { strict = false } = options;\n return component.slots?.find((s) => this.compareIds(s.id, slotId, strict));\n }\n\n addSlot(component: ComponentDefinition, slot: SlotDefinition): ComponentDefinition {\n if (!component.slots) {\n component.slots = [];\n }\n component.slots.push({ ...slot });\n return component;\n }\n\n updateSlotAllowedComponents(\n component: ComponentDefinition,\n slotId: string,\n allowedComponents: string[],\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n const slot = component.slots?.find((s) => this.compareIds(s.id, slotId, strict));\n if (slot) {\n slot.allowedComponents = allowedComponents;\n }\n return component;\n }\n\n removeSlot(\n component: ComponentDefinition,\n slotId: string,\n options: FindOptions = {}\n ): ComponentDefinition {\n const { strict = false } = options;\n if (!component.slots) {\n return component;\n }\n component.slots = component.slots.filter((s) => !this.compareIds(s.id, slotId, strict));\n return component;\n }\n}\n","import { Composition, ComponentInstance, ParameterValue } from '../types/index.js';\nimport { FileSystemService } from './file-system.service.js';\n\nexport interface FindOptions {\n strict?: boolean;\n}\n\nexport interface FoundComponentInstance {\n instance: ComponentInstance;\n instanceId: string;\n path: string[];\n}\n\nexport class CompositionService {\n constructor(private fileSystem: FileSystemService) {}\n\n private compareTypes(type1: string, type2: string, strict: boolean): boolean {\n if (strict) {\n return type1 === type2;\n }\n return type1.toLowerCase() === type2.toLowerCase();\n }\n\n async loadComposition(filePath: string): Promise<Composition> {\n return this.fileSystem.readFile<Composition>(filePath);\n }\n\n async saveComposition(filePath: string, composition: Composition): Promise<void> {\n await this.fileSystem.writeFile(filePath, composition);\n }\n\n async findCompositionsByType(\n compositionsDir: string,\n compositionType: string,\n options: FindOptions = {}\n ): Promise<{ composition: Composition; filePath: string }[]> {\n const { strict = false } = options;\n const files = await this.fileSystem.findFiles(compositionsDir, '**/*.{json,yaml,yml}');\n const results: { composition: Composition; filePath: string }[] = [];\n\n for (const filePath of files) {\n try {\n const composition = await this.loadComposition(filePath);\n if (\n composition.composition?.type &&\n this.compareTypes(composition.composition.type, compositionType, strict)\n ) {\n results.push({ composition, filePath });\n }\n } catch {\n // Skip invalid files\n }\n }\n\n return results;\n }\n\n findComponentInstances(\n composition: Composition,\n componentType: string,\n options: FindOptions = {}\n ): FoundComponentInstance[] {\n const { strict = false } = options;\n const results: FoundComponentInstance[] = [];\n this.searchSlots(composition.composition.slots ?? {}, componentType, [], results, strict);\n return results;\n }\n\n private searchSlots(\n slots: Record<string, ComponentInstance[]>,\n componentType: string,\n currentPath: string[],\n results: FoundComponentInstance[],\n strict: boolean\n ): void {\n for (const [slotName, instances] of Object.entries(slots)) {\n if (!Array.isArray(instances)) continue;\n\n for (let i = 0; i < instances.length; i++) {\n const instance = instances[i];\n const instancePath = [...currentPath, slotName, String(i)];\n\n if (this.compareTypes(instance.type, componentType, strict)) {\n const instanceId = instance._id ?? `${componentType}-${results.length}`;\n results.push({\n instance,\n instanceId,\n path: instancePath,\n });\n }\n\n if (instance.slots) {\n this.searchSlots(instance.slots, componentType, instancePath, results, strict);\n }\n }\n }\n }\n\n getRootOverrides(composition: Composition): Record<string, ParameterValue> {\n const rootId = composition.composition._id;\n // Check _overrides first (newer format), then fall back to direct parameters (older format)\n const overrides = composition.composition._overrides?.[rootId]?.parameters;\n if (overrides && Object.keys(overrides).length > 0) {\n return overrides;\n }\n // Fall back to direct parameters on the composition root\n return (composition.composition as { parameters?: Record<string, ParameterValue> }).parameters ?? {};\n }\n\n getInstanceOverrides(\n composition: Composition,\n instanceId: string\n ): Record<string, ParameterValue> {\n return composition.composition._overrides?.[instanceId]?.parameters ?? {};\n }\n\n setInstanceOverride(\n composition: Composition,\n instanceId: string,\n parameterId: string,\n value: ParameterValue\n ): Composition {\n if (!composition.composition._overrides) {\n composition.composition._overrides = {};\n }\n if (!composition.composition._overrides[instanceId]) {\n composition.composition._overrides[instanceId] = {};\n }\n if (!composition.composition._overrides[instanceId].parameters) {\n composition.composition._overrides[instanceId].parameters = {};\n }\n\n composition.composition._overrides[instanceId].parameters![parameterId] = value;\n return composition;\n }\n\n setInstanceOverrides(\n composition: Composition,\n instanceId: string,\n parameters: Record<string, ParameterValue>\n ): Composition {\n for (const [paramId, value] of Object.entries(parameters)) {\n this.setInstanceOverride(composition, instanceId, paramId, value);\n }\n return composition;\n }\n\n /**\n * Sets parameters directly on a component instance (preferred approach).\n * This modifies the instance object in-place.\n */\n setInstanceParameters(\n instance: ComponentInstance,\n parameters: Record<string, ParameterValue>\n ): void {\n if (!instance.parameters) {\n instance.parameters = {};\n }\n for (const [paramId, value] of Object.entries(parameters)) {\n instance.parameters[paramId] = value;\n }\n }\n\n /**\n * Deletes parameters from root overrides.\n * Returns true if any parameters were deleted.\n */\n deleteRootOverrides(\n composition: Composition,\n parameterIds: string[],\n options: FindOptions = {}\n ): boolean {\n const { strict = false } = options;\n const rootId = composition.composition._id;\n let deleted = false;\n\n // Check _overrides first (newer format)\n const overrides = composition.composition._overrides?.[rootId]?.parameters;\n if (overrides) {\n for (const paramId of parameterIds) {\n for (const key of Object.keys(overrides)) {\n if (strict ? key === paramId : key.toLowerCase() === paramId.toLowerCase()) {\n delete overrides[key];\n deleted = true;\n }\n }\n }\n }\n\n // Also check direct parameters on root (older format)\n const rootParams = (composition.composition as { parameters?: Record<string, ParameterValue> })\n .parameters;\n if (rootParams) {\n for (const paramId of parameterIds) {\n for (const key of Object.keys(rootParams)) {\n if (strict ? key === paramId : key.toLowerCase() === paramId.toLowerCase()) {\n delete rootParams[key];\n deleted = true;\n }\n }\n }\n }\n\n return deleted;\n }\n}\n","import { ParameterValue } from '../types/index.js';\nimport { PropertyNotFoundError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { CompositionService } from './composition.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface PropagateOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionType: string;\n property: string;\n targetComponentType: string;\n targetGroup: string;\n whatIf: boolean;\n strict: boolean;\n deleteSourceParameter: boolean;\n}\n\nexport interface PropagateResult {\n modifiedComponents: number;\n modifiedCompositions: number;\n propagatedInstances: number;\n}\n\nexport class PropertyPropagatorService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private compositionService: CompositionService,\n private logger: Logger\n ) {}\n\n async propagate(options: PropagateOptions): Promise<PropagateResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionType,\n property,\n targetComponentType,\n targetGroup,\n whatIf,\n strict,\n deleteSourceParameter,\n } = options;\n\n const findOptions = { strict };\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n\n // Step 1: Load source component (compositionType)\n this.logger.info(`Loading component: ${compositionType}`);\n const { component: sourceComponent, filePath: sourceFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, compositionType, findOptions);\n\n // Step 2: Load target component\n this.logger.info(`Loading component: ${targetComponentType}`);\n const { component: targetComponent, filePath: targetFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, targetComponentType, findOptions);\n\n // Step 3: Parse and resolve properties\n const propertyNames = property.split('|').map((p) => p.trim());\n const { parameters: resolvedParams, notFound } = this.componentService.resolveProperties(\n sourceComponent,\n propertyNames,\n findOptions\n );\n\n if (notFound.length > 0) {\n throw new PropertyNotFoundError(notFound.join(', '), compositionType);\n }\n\n const resolvedNames = resolvedParams.map((p) => p.id);\n const groupSources = propertyNames.filter((name) => {\n const param = this.componentService.findParameter(sourceComponent, name, findOptions);\n return param && this.componentService.isGroupParameter(param);\n });\n\n if (groupSources.length > 0) {\n this.logger.info(\n `Resolved properties: ${resolvedNames.join(', ')} (from ${groupSources.join(', ')})`\n );\n } else {\n this.logger.info(`Resolved properties: ${resolvedNames.join(', ')}`);\n }\n\n // Step 4: Modify target component\n let modifiedComponent = { ...targetComponent };\n let componentModified = false;\n\n // Ensure target group exists\n const existingGroup = this.componentService.findParameter(\n modifiedComponent,\n targetGroup,\n findOptions\n );\n if (!existingGroup) {\n this.logger.action(whatIf, 'CREATE', `Group \"${targetGroup}\" on ${targetComponentType}`);\n modifiedComponent = this.componentService.ensureGroupExists(\n modifiedComponent,\n targetGroup,\n undefined,\n findOptions\n );\n componentModified = true;\n }\n\n // Copy parameter definitions to target\n for (const param of resolvedParams) {\n const existingParam = this.componentService.findParameter(\n modifiedComponent,\n param.id,\n findOptions\n );\n if (!existingParam) {\n this.logger.action(\n whatIf,\n 'COPY',\n `Parameter \"${param.id}\" → ${targetComponentType}.${targetGroup}`\n );\n modifiedComponent = this.componentService.addParameterToComponent(\n modifiedComponent,\n param,\n findOptions\n );\n modifiedComponent = this.componentService.addParameterToGroup(\n modifiedComponent,\n targetGroup,\n param.id,\n findOptions\n );\n componentModified = true;\n } else {\n this.logger.info(`Parameter \"${param.id}\" already exists on ${targetComponentType}`);\n // Ensure it's in the group\n const group = this.componentService.findParameter(\n modifiedComponent,\n targetGroup,\n findOptions\n );\n if (group && this.componentService.isGroupParameter(group)) {\n // Check if param is already in group (case-insensitive if not strict)\n const isInGroup = group.typeConfig?.childrenParams?.some((id) =>\n strict ? id === param.id : id.toLowerCase() === param.id.toLowerCase()\n );\n if (!isInGroup) {\n modifiedComponent = this.componentService.addParameterToGroup(\n modifiedComponent,\n targetGroup,\n param.id,\n findOptions\n );\n componentModified = true;\n }\n }\n }\n }\n\n // Save modified component\n if (componentModified && !whatIf) {\n await this.componentService.saveComponent(targetFilePath, modifiedComponent);\n }\n\n // Step 5: Propagate values in compositions\n const compositions = await this.compositionService.findCompositionsByType(\n fullCompositionsDir,\n compositionType,\n findOptions\n );\n\n let modifiedCompositions = 0;\n let propagatedInstances = 0;\n\n for (const { composition, filePath } of compositions) {\n const rootOverrides = this.compositionService.getRootOverrides(composition);\n const instances = this.compositionService.findComponentInstances(\n composition,\n targetComponentType,\n findOptions\n );\n\n if (instances.length === 0) {\n continue;\n }\n\n // Build the values to propagate\n const valuesToPropagate: Record<string, ParameterValue> = {};\n for (const param of resolvedParams) {\n if (rootOverrides[param.id]) {\n valuesToPropagate[param.id] = rootOverrides[param.id];\n }\n }\n\n if (Object.keys(valuesToPropagate).length === 0) {\n continue;\n }\n\n let compositionModified = false;\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n const instanceUpdates: string[] = [];\n\n for (const { instance, instanceId } of instances) {\n const instanceName = instance._id ?? instanceId;\n // Set parameters directly on the instance (preferred over _overrides)\n this.compositionService.setInstanceParameters(instance, valuesToPropagate);\n compositionModified = true;\n propagatedInstances++;\n instanceUpdates.push(\n `${targetComponentType} \"${instanceName}\": ${Object.keys(valuesToPropagate).join(', ')}`\n );\n }\n\n if (compositionModified) {\n this.logger.action(whatIf, 'UPDATE', `composition/${relativePath}`);\n for (const update of instanceUpdates) {\n this.logger.detail(`→ ${update}`);\n }\n\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n modifiedCompositions++;\n }\n }\n\n // Step 6: Delete source parameters if requested\n let sourceComponentModified = false;\n if (deleteSourceParameter) {\n let modifiedSource = { ...sourceComponent };\n\n // Delete the resolved parameters from source component\n for (const param of resolvedParams) {\n this.logger.action(whatIf, 'DELETE', `Parameter \"${param.id}\" from ${compositionType}`);\n modifiedSource = this.componentService.removeParameter(modifiedSource, param.id, findOptions);\n sourceComponentModified = true;\n }\n\n // Also delete any groups that are now empty\n const beforeGroupCount = modifiedSource.parameters?.filter((p) =>\n this.componentService.isGroupParameter(p)\n ).length ?? 0;\n modifiedSource = this.componentService.removeEmptyGroups(modifiedSource);\n const afterGroupCount = modifiedSource.parameters?.filter((p) =>\n this.componentService.isGroupParameter(p)\n ).length ?? 0;\n if (afterGroupCount < beforeGroupCount) {\n const removedCount = beforeGroupCount - afterGroupCount;\n this.logger.action(\n whatIf,\n 'DELETE',\n `${removedCount} empty group(s) from ${compositionType}`\n );\n }\n\n if (sourceComponentModified && !whatIf) {\n await this.componentService.saveComponent(sourceFilePath, modifiedSource);\n }\n\n // Delete parameter values from root overrides in compositions\n for (const { composition, filePath } of compositions) {\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n const deleted = this.compositionService.deleteRootOverrides(\n composition,\n resolvedNames,\n findOptions\n );\n if (deleted) {\n this.logger.action(whatIf, 'DELETE', `Root overrides from composition/${relativePath}`);\n this.logger.detail(`→ Removed: ${resolvedNames.join(', ')}`);\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n }\n }\n }\n\n return {\n modifiedComponents: (componentModified ? 1 : 0) + (sourceComponentModified ? 1 : 0),\n modifiedCompositions,\n propagatedInstances,\n };\n }\n}\n","import chalk from 'chalk';\n\nexport class Logger {\n info(message: string): void {\n console.log(`${chalk.blue('[INFO]')} ${message}`);\n }\n\n success(message: string): void {\n console.log(`${chalk.green('[DONE]')} ${message}`);\n }\n\n error(message: string): void {\n console.log(`${chalk.red('[ERROR]')} ${message}`);\n }\n\n warn(message: string): void {\n console.log(`${chalk.yellow('[WARN]')} ${message}`);\n }\n\n action(whatIf: boolean, actionType: string, message: string): void {\n const prefix = whatIf ? chalk.yellow('[WOULD]') : chalk.green(`[${actionType}]`);\n console.log(`${prefix} ${message}`);\n }\n\n detail(message: string): void {\n console.log(` ${chalk.gray(message)}`);\n }\n}\n","import { Command } from 'commander';\nimport { CompositionPatternCandidatesOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { CompositionService } from '../../core/services/composition.service.js';\nimport { PatternAnalyzerService } from '../../core/services/pattern-analyzer.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nfunction createSilentLogger(): Logger {\n return {\n info: () => {},\n success: () => {},\n error: () => {},\n warn: () => {},\n action: () => {},\n detail: () => {},\n } as Logger;\n}\n\nexport function createFindCompositionPatternCandidatesCommand(): Command {\n const command = new Command('find-composition-pattern-candidates');\n\n command\n .description(\n 'Analyzes all compositions to identify groups with identical structural patterns—same component types arranged in the same slot hierarchy—regardless of parameter values.'\n )\n .option(\n '--minGroupSize <size>',\n 'Minimum number of compositions required to form a pattern candidate group',\n '2'\n )\n .option(\n '--depth <levels>',\n 'How many levels deep to compare (0 = unlimited, 1 = root only, 2 = root + children)',\n '0'\n )\n .option(\n '--threshold <count>',\n 'Number of component differences allowed while still matching (0 = exact match)',\n '0'\n )\n .option('--format <format>', 'Output format: text or json', 'text')\n .option('--brief', 'Skip structure and composition details in text output')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n\n // Validate minGroupSize\n const minGroupSize = parseInt(opts.minGroupSize, 10);\n if (isNaN(minGroupSize) || minGroupSize < 2) {\n console.error('error: --minGroupSize must be a number >= 2');\n process.exit(1);\n }\n\n // Validate depth\n const depth = parseInt(opts.depth, 10);\n if (isNaN(depth) || depth < 0) {\n console.error('error: --depth must be a number >= 0');\n process.exit(1);\n }\n\n // Validate threshold\n const threshold = parseInt(opts.threshold, 10);\n if (isNaN(threshold) || threshold < 0) {\n console.error('error: --threshold must be a number >= 0');\n process.exit(1);\n }\n\n // Validate format\n if (opts.format !== 'text' && opts.format !== 'json') {\n console.error('error: --format must be \"text\" or \"json\"');\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: CompositionPatternCandidatesOptions = {\n ...globalOpts,\n minGroupSize: parseInt(opts.minGroupSize, 10),\n depth: parseInt(opts.depth, 10),\n threshold: parseInt(opts.threshold, 10),\n format: opts.format as 'text' | 'json',\n brief: opts.brief ?? false,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const compositionService = new CompositionService(fileSystem);\n\n try {\n // Use a silent logger for JSON output to avoid polluting the JSON\n const analysisLogger = options.format === 'json' ? createSilentLogger() : logger;\n const analyzer = new PatternAnalyzerService(fileSystem, compositionService, analysisLogger);\n\n const result = await analyzer.analyze({\n rootDir: options.rootDir,\n compositionsDir: options.compositionsDir,\n projectMapNodesDir: options.projectMapNodesDir,\n minGroupSize: options.minGroupSize,\n depth: options.depth,\n threshold: options.threshold,\n strict: options.strict ?? false,\n });\n\n if (options.format === 'json') {\n console.log(analyzer.formatJsonOutput(result));\n } else {\n console.log(analyzer.formatTextOutput(result, { brief: options.brief }));\n }\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { Composition, ComponentInstance } from '../types/index.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { CompositionService } from './composition.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface CompositionInfo {\n id: string;\n name: string;\n projectMapNodeSlug: string;\n filePath: string;\n componentAnalysis?: ComponentAnalysis;\n}\n\nexport interface ComponentAnalysis {\n componentsUsed: string[];\n reusedComponents: string[];\n newComponents: string[];\n cumulativeComponentCount: number;\n progressionPercentage: number;\n}\n\nexport interface PatternGroup {\n name: string;\n structureDescription: string;\n fingerprint: string;\n compositions: CompositionInfo[];\n componentAnalysis?: ComponentAnalysis;\n}\n\nexport interface PatternAnalysisResult {\n summary: {\n totalCompositions: number;\n uniquePatterns: number;\n compositionsInGroups: number;\n uniqueCompositions: number;\n totalUniqueComponents: number;\n };\n patterns: PatternGroup[];\n uniqueCompositions: CompositionInfo[];\n}\n\nexport interface ProjectMapNode {\n id: string;\n path?: string;\n slug?: string;\n compositionId?: string;\n [key: string]: unknown;\n}\n\nexport interface AnalyzeOptions {\n rootDir: string;\n compositionsDir: string;\n projectMapNodesDir: string;\n minGroupSize: number;\n depth: number;\n threshold: number;\n strict?: boolean;\n}\n\n/**\n * Represents a parsed component node for structural comparison.\n */\ninterface ComponentNode {\n type: string;\n slots: Map<string, ComponentNode[]>;\n}\n\nexport class PatternAnalyzerService {\n constructor(\n private fileSystem: FileSystemService,\n private compositionService: CompositionService,\n private logger: Logger\n ) {}\n\n async analyze(options: AnalyzeOptions): Promise<PatternAnalysisResult> {\n const { rootDir, compositionsDir, projectMapNodesDir, minGroupSize, depth, threshold } = options;\n\n const compositionsPath = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const projectMapNodesPath = this.fileSystem.resolvePath(rootDir, projectMapNodesDir);\n\n // Load project map nodes for slug resolution\n const projectMapNodes = await this.loadProjectMapNodes(projectMapNodesPath);\n\n // Load all compositions\n const compositionFiles = await this.fileSystem.findFiles(\n compositionsPath,\n '**/*.{json,yaml,yml}'\n );\n\n this.logger.info(`Found ${compositionFiles.length} composition files`);\n\n // Load and validate all compositions\n const loadedCompositions: { composition: Composition; filePath: string; fingerprint: string }[] = [];\n\n for (const filePath of compositionFiles) {\n try {\n const composition = await this.compositionService.loadComposition(filePath);\n\n if (!composition.composition?.type) {\n this.logger.warn(`Skipping ${filePath}: missing composition type`);\n continue;\n }\n\n const fingerprint = this.generateFingerprint(composition, depth);\n loadedCompositions.push({ composition, filePath, fingerprint });\n } catch (error) {\n this.logger.warn(\n `Skipping ${filePath}: ${error instanceof Error ? error.message : 'invalid file'}`\n );\n }\n }\n\n // Group compositions based on threshold\n let groups: { composition: Composition; filePath: string; fingerprint: string }[][];\n\n if (threshold === 0) {\n // Exact matching: group by fingerprint\n const fingerprintGroups = new Map<\n string,\n { composition: Composition; filePath: string; fingerprint: string }[]\n >();\n\n for (const item of loadedCompositions) {\n if (!fingerprintGroups.has(item.fingerprint)) {\n fingerprintGroups.set(item.fingerprint, []);\n }\n fingerprintGroups.get(item.fingerprint)!.push(item);\n }\n\n groups = Array.from(fingerprintGroups.values());\n } else {\n // Fuzzy matching: use Union-Find to cluster compositions within threshold distance\n groups = this.clusterByThreshold(loadedCompositions, threshold, depth);\n }\n\n // Calculate total unique components across ALL compositions\n const allCompositions = loadedCompositions.map((item) => item.composition);\n const allComponentTypes = this.extractComponentTypesFromCompositions(allCompositions);\n const totalUniqueComponents = allComponentTypes.size;\n\n // Build pattern groups (with temporary names using just root type)\n const patterns: PatternGroup[] = [];\n const rootTypeCounts = new Map<string, number>();\n const uniqueCompositionsList: CompositionInfo[] = [];\n // Store composition objects for unique compositions to compute component analysis later\n const uniqueCompositionsData: { info: CompositionInfo; composition: Composition }[] = [];\n // Store composition objects for each pattern to compute component analysis later\n const patternCompositionsData: Map<PatternGroup, Composition[]> = new Map();\n\n for (const group of groups) {\n if (group.length < minGroupSize) {\n // Collect unique compositions (those in groups smaller than minGroupSize)\n for (const { composition, filePath } of group) {\n const info: CompositionInfo = {\n id: composition.composition._id ?? 'unknown',\n name: this.getCompositionName(composition),\n projectMapNodeSlug: this.resolveProjectMapSlug(composition, projectMapNodes),\n filePath,\n };\n uniqueCompositionsList.push(info);\n uniqueCompositionsData.push({ info, composition });\n }\n continue;\n }\n\n // Sort by composition ID alphabetically\n group.sort((a, b) => {\n const idA = a.composition.composition._id ?? '';\n const idB = b.composition.composition._id ?? '';\n return idA.localeCompare(idB);\n });\n\n const firstComposition = group[0].composition;\n const rootType = firstComposition.composition.type;\n const firstName = this.getCompositionName(firstComposition);\n\n // Count patterns per root type\n rootTypeCounts.set(rootType, (rootTypeCounts.get(rootType) ?? 0) + 1);\n\n const structureDescription = this.generateStructureDescription(firstComposition);\n\n const compositions: CompositionInfo[] = group.map(({ composition, filePath }) => ({\n id: composition.composition._id ?? 'unknown',\n name: this.getCompositionName(composition),\n projectMapNodeSlug: this.resolveProjectMapSlug(composition, projectMapNodes),\n filePath,\n }));\n\n // Use first composition's fingerprint as the group fingerprint\n const fingerprint = group[0].fingerprint;\n\n const patternGroup = {\n name: rootType, // Temporary name, will be updated below if disambiguation needed\n structureDescription,\n fingerprint,\n compositions,\n _rootType: rootType,\n _firstName: firstName,\n } as PatternGroup & { _rootType: string; _firstName: string };\n\n patterns.push(patternGroup);\n\n // Store all composition objects for this pattern (needed for component analysis with threshold)\n patternCompositionsData.set(patternGroup, group.map((g) => g.composition));\n }\n\n // Update pattern names: only add composition name suffix when multiple patterns share same root type\n for (const pattern of patterns) {\n const p = pattern as PatternGroup & { _rootType: string; _firstName: string };\n if (rootTypeCounts.get(p._rootType)! > 1) {\n pattern.name = `${p._rootType}-${p._firstName}`;\n }\n // Clean up temporary properties\n delete (pattern as unknown as Record<string, unknown>)._rootType;\n delete (pattern as unknown as Record<string, unknown>)._firstName;\n }\n\n // Sort patterns by group size (descending)\n patterns.sort((a, b) => b.compositions.length - a.compositions.length);\n\n // Compute component analysis for each pattern\n const seenComponents = this.computeComponentAnalysis(\n patterns,\n patternCompositionsData,\n totalUniqueComponents\n );\n\n // Sort unique compositions alphabetically by ID\n uniqueCompositionsList.sort((a, b) => a.id.localeCompare(b.id));\n uniqueCompositionsData.sort((a, b) => a.info.id.localeCompare(b.info.id));\n\n // Compute component analysis for unique compositions (continuing from patterns)\n this.computeUniqueCompositionAnalysis(\n uniqueCompositionsData,\n seenComponents,\n totalUniqueComponents\n );\n\n // Calculate summary\n const totalCompositions = compositionFiles.length;\n const uniquePatterns = patterns.length;\n const compositionsInGroups = patterns.reduce((sum, p) => sum + p.compositions.length, 0);\n const uniqueCompositionsCount = totalCompositions - compositionsInGroups;\n\n return {\n summary: {\n totalCompositions,\n uniquePatterns,\n compositionsInGroups,\n uniqueCompositions: uniqueCompositionsCount,\n totalUniqueComponents,\n },\n patterns,\n uniqueCompositions: uniqueCompositionsList,\n };\n }\n\n /**\n * Clusters compositions using Union-Find algorithm based on structural distance.\n * Compositions with distance <= threshold are grouped together transitively.\n */\n private clusterByThreshold(\n compositions: { composition: Composition; filePath: string; fingerprint: string }[],\n threshold: number,\n depth: number\n ): { composition: Composition; filePath: string; fingerprint: string }[][] {\n const n = compositions.length;\n if (n === 0) return [];\n\n // Parse all compositions into ComponentNode trees for comparison\n const parsedNodes = compositions.map((item) =>\n this.parseCompositionToNode(item.composition, depth)\n );\n\n // Union-Find data structure\n const parent = Array.from({ length: n }, (_, i) => i);\n const rank = Array(n).fill(0);\n\n const find = (x: number): number => {\n if (parent[x] !== x) {\n parent[x] = find(parent[x]);\n }\n return parent[x];\n };\n\n const union = (x: number, y: number): void => {\n const rootX = find(x);\n const rootY = find(y);\n if (rootX !== rootY) {\n if (rank[rootX] < rank[rootY]) {\n parent[rootX] = rootY;\n } else if (rank[rootX] > rank[rootY]) {\n parent[rootY] = rootX;\n } else {\n parent[rootY] = rootX;\n rank[rootX]++;\n }\n }\n };\n\n // Compare all pairs and union those within threshold\n for (let i = 0; i < n; i++) {\n for (let j = i + 1; j < n; j++) {\n // Only compare compositions with the same root type\n if (parsedNodes[i].type !== parsedNodes[j].type) {\n continue;\n }\n\n const distance = this.calculateDistance(parsedNodes[i], parsedNodes[j]);\n if (distance <= threshold) {\n union(i, j);\n }\n }\n }\n\n // Group compositions by their root in Union-Find\n const groups = new Map<number, { composition: Composition; filePath: string; fingerprint: string }[]>();\n for (let i = 0; i < n; i++) {\n const root = find(i);\n if (!groups.has(root)) {\n groups.set(root, []);\n }\n groups.get(root)!.push(compositions[i]);\n }\n\n return Array.from(groups.values());\n }\n\n /**\n * Parses a composition into a ComponentNode tree for structural comparison.\n */\n private parseCompositionToNode(composition: Composition, depth: number): ComponentNode {\n const root = composition.composition;\n const remainingDepth = depth === 0 ? -1 : depth - 1;\n return this.parseInstanceToNode(root.type, root.slots, remainingDepth);\n }\n\n private parseInstanceToNode(\n type: string,\n slots: Record<string, ComponentInstance[]> | undefined,\n remainingDepth: number\n ): ComponentNode {\n const node: ComponentNode = {\n type,\n slots: new Map(),\n };\n\n if (remainingDepth === 0 || !slots || Object.keys(slots).length === 0) {\n return node;\n }\n\n const sortedSlotNames = Object.keys(slots).sort();\n for (const slotName of sortedSlotNames) {\n const instances = slots[slotName];\n if (!Array.isArray(instances)) {\n node.slots.set(slotName, []);\n continue;\n }\n\n const nextDepth = remainingDepth === -1 ? -1 : remainingDepth - 1;\n const childNodes = instances.map((instance) =>\n this.parseInstanceToNode(instance.type, instance.slots, nextDepth)\n );\n node.slots.set(slotName, childNodes);\n }\n\n return node;\n }\n\n /**\n * Calculates the structural distance between two ComponentNode trees.\n * Distance is the number of component differences.\n */\n calculateDistance(node1: ComponentNode, node2: ComponentNode): number {\n let distance = 0;\n\n // Different root types count as a large distance (should not be grouped)\n if (node1.type !== node2.type) {\n return Infinity;\n }\n\n // Get all slot names from both nodes\n const allSlotNames = new Set([...node1.slots.keys(), ...node2.slots.keys()]);\n\n for (const slotName of allSlotNames) {\n const children1 = node1.slots.get(slotName) ?? [];\n const children2 = node2.slots.get(slotName) ?? [];\n\n // Compare children at each position\n const maxLen = Math.max(children1.length, children2.length);\n for (let i = 0; i < maxLen; i++) {\n const child1 = children1[i];\n const child2 = children2[i];\n\n if (!child1 || !child2) {\n // One side is missing a component\n distance++;\n } else if (child1.type !== child2.type) {\n // Different component types at same position\n distance++;\n } else {\n // Same type, compare recursively\n distance += this.calculateDistance(child1, child2);\n }\n }\n }\n\n return distance;\n }\n\n /**\n * Extracts all unique component types from a composition recursively.\n */\n extractComponentTypes(composition: Composition): Set<string> {\n const types = new Set<string>();\n const root = composition.composition;\n types.add(root.type);\n this.collectComponentTypesFromSlots(root.slots, types);\n return types;\n }\n\n /**\n * Helper to recursively collect component types from slots.\n */\n private collectComponentTypesFromSlots(\n slots: Record<string, ComponentInstance[]> | undefined,\n types: Set<string>\n ): void {\n if (!slots) return;\n\n for (const slotName of Object.keys(slots)) {\n const instances = slots[slotName];\n if (!Array.isArray(instances)) continue;\n\n for (const instance of instances) {\n types.add(instance.type);\n this.collectComponentTypesFromSlots(instance.slots, types);\n }\n }\n }\n\n /**\n * Extracts the union of all component types from multiple compositions.\n */\n extractComponentTypesFromCompositions(compositions: Composition[]): Set<string> {\n const types = new Set<string>();\n for (const composition of compositions) {\n const compositionTypes = this.extractComponentTypes(composition);\n for (const type of compositionTypes) {\n types.add(type);\n }\n }\n return types;\n }\n\n /**\n * Computes component analysis for all patterns.\n * Returns the set of seen components for continuation with unique compositions.\n */\n private computeComponentAnalysis(\n patterns: PatternGroup[],\n patternCompositionsData: Map<PatternGroup, Composition[]>,\n totalUniqueComponents: number\n ): Set<string> {\n const seenComponents = new Set<string>();\n\n for (const pattern of patterns) {\n // Get all compositions for this pattern (directly from the map, not by fingerprint lookup)\n const compositions = patternCompositionsData.get(pattern) ?? [];\n const patternComponents = this.extractComponentTypesFromCompositions(compositions);\n const componentsUsed = Array.from(patternComponents).sort();\n\n // Calculate reused vs new components\n const reusedComponents: string[] = [];\n const newComponents: string[] = [];\n\n for (const component of componentsUsed) {\n if (seenComponents.has(component)) {\n reusedComponents.push(component);\n } else {\n newComponents.push(component);\n }\n }\n\n // Add all components to seen set for next pattern\n for (const component of componentsUsed) {\n seenComponents.add(component);\n }\n\n const cumulativeComponentCount = seenComponents.size;\n const progressionPercentage =\n totalUniqueComponents > 0\n ? Math.round((cumulativeComponentCount / totalUniqueComponents) * 100)\n : 0;\n\n pattern.componentAnalysis = {\n componentsUsed,\n reusedComponents: reusedComponents.sort(),\n newComponents: newComponents.sort(),\n cumulativeComponentCount,\n progressionPercentage,\n };\n }\n\n return seenComponents;\n }\n\n /**\n * Computes component analysis for unique compositions.\n * Continues from the seenComponents set populated by pattern analysis.\n */\n private computeUniqueCompositionAnalysis(\n uniqueCompositionsData: { info: CompositionInfo; composition: Composition }[],\n seenComponents: Set<string>,\n totalUniqueComponents: number\n ): void {\n for (const { info, composition } of uniqueCompositionsData) {\n const compositionComponents = this.extractComponentTypes(composition);\n const componentsUsed = Array.from(compositionComponents).sort();\n\n // Calculate reused vs new components\n const reusedComponents: string[] = [];\n const newComponents: string[] = [];\n\n for (const component of componentsUsed) {\n if (seenComponents.has(component)) {\n reusedComponents.push(component);\n } else {\n newComponents.push(component);\n }\n }\n\n // Add all components to seen set for next composition\n for (const component of componentsUsed) {\n seenComponents.add(component);\n }\n\n const cumulativeComponentCount = seenComponents.size;\n const progressionPercentage =\n totalUniqueComponents > 0\n ? Math.round((cumulativeComponentCount / totalUniqueComponents) * 100)\n : 0;\n\n info.componentAnalysis = {\n componentsUsed,\n reusedComponents: reusedComponents.sort(),\n newComponents: newComponents.sort(),\n cumulativeComponentCount,\n progressionPercentage,\n };\n }\n }\n\n /**\n * Generates a structural fingerprint for a composition.\n * The fingerprint captures the component type hierarchy ignoring parameter values.\n * @param depth - How many levels deep to compare. 0 = unlimited, 1 = root only, 2 = root + children, etc.\n */\n generateFingerprint(composition: Composition, depth: number = 0): string {\n const root = composition.composition;\n // depth 1 means root only, so we pass remainingDepth = 0 to stop at root\n // depth 0 means unlimited, so we pass -1 as a special \"unlimited\" marker\n const remainingDepth = depth === 0 ? -1 : depth - 1;\n return this.generateNodeFingerprint(root.type, root.slots, remainingDepth);\n }\n\n private generateNodeFingerprint(\n type: string,\n slots: Record<string, ComponentInstance[]> | undefined,\n remainingDepth: number\n ): string {\n // If remainingDepth is 0, don't go deeper (return just the type)\n // If remainingDepth is -1, it means unlimited depth\n if (remainingDepth === 0 || !slots || Object.keys(slots).length === 0) {\n return type;\n }\n\n // Sort slot names alphabetically for consistent fingerprinting\n const sortedSlotNames = Object.keys(slots).sort();\n\n const slotFingerprints = sortedSlotNames.map((slotName) => {\n const instances = slots[slotName];\n if (!Array.isArray(instances) || instances.length === 0) {\n return `${slotName}:[]`;\n }\n\n const nextDepth = remainingDepth === -1 ? -1 : remainingDepth - 1;\n const instanceFingerprints = instances.map((instance) =>\n this.generateNodeFingerprint(instance.type, instance.slots, nextDepth)\n );\n\n return `${slotName}:[${instanceFingerprints.join(',')}]`;\n });\n\n return `${type}{${slotFingerprints.join(';')}}`;\n }\n\n /**\n * Generates a human-readable structure description.\n */\n generateStructureDescription(composition: Composition): string {\n const root = composition.composition;\n return this.generateNodeDescription(root.type, root.slots, 0);\n }\n\n private generateNodeDescription(\n type: string,\n slots: Record<string, ComponentInstance[]> | undefined,\n depth: number\n ): string {\n if (!slots || Object.keys(slots).length === 0) {\n return type;\n }\n\n const sortedSlotNames = Object.keys(slots).sort();\n\n const slotDescriptions = sortedSlotNames\n .map((slotName) => {\n const instances = slots[slotName];\n if (!Array.isArray(instances) || instances.length === 0) {\n return null;\n }\n\n const instanceTypes = instances.map((instance) => {\n if (instance.slots && Object.keys(instance.slots).length > 0) {\n return this.generateNodeDescription(instance.type, instance.slots, depth + 1);\n }\n return instance.type;\n });\n\n return `${slotName}[${instanceTypes.join(', ')}]`;\n })\n .filter(Boolean);\n\n if (slotDescriptions.length === 0) {\n return type;\n }\n\n return `${type} > ${slotDescriptions.join(' > ')}`;\n }\n\n private getCompositionName(composition: Composition): string {\n // Try common name fields\n const possibleNames = [\n (composition as { name?: string }).name,\n (composition.composition as { _name?: string })._name,\n (composition.composition as { name?: string }).name,\n composition.composition._id,\n ];\n\n for (const name of possibleNames) {\n if (name && typeof name === 'string') {\n return name;\n }\n }\n\n return 'Unnamed';\n }\n\n private async loadProjectMapNodes(\n projectMapNodesPath: string\n ): Promise<Map<string, ProjectMapNode>> {\n const nodes = new Map<string, ProjectMapNode>();\n\n try {\n const exists = await this.fileSystem.fileExists(projectMapNodesPath);\n if (!exists) {\n return nodes;\n }\n\n const files = await this.fileSystem.findFiles(projectMapNodesPath, '**/*.{json,yaml,yml}');\n\n for (const filePath of files) {\n try {\n const node = await this.fileSystem.readFile<ProjectMapNode>(filePath);\n if (node.compositionId) {\n nodes.set(node.compositionId, node);\n }\n if (node.id) {\n nodes.set(node.id, node);\n }\n } catch {\n // Skip invalid files\n }\n }\n } catch {\n // Directory doesn't exist or isn't accessible\n }\n\n return nodes;\n }\n\n private resolveProjectMapSlug(\n composition: Composition,\n nodes: Map<string, ProjectMapNode>\n ): string {\n const compositionId = composition.composition._id;\n if (!compositionId) {\n return '(not mapped)';\n }\n\n const node = nodes.get(compositionId);\n if (!node) {\n return '(not mapped)';\n }\n\n return node.path ?? node.slug ?? '(not mapped)';\n }\n\n formatTextOutput(result: PatternAnalysisResult, options?: { brief?: boolean }): string {\n const brief = options?.brief ?? false;\n const lines: string[] = [];\n const padWidth = String(result.patterns.length).length.toString().length >= 3 ? String(result.patterns.length).length : 3;\n\n lines.push('=== COMPOSITION PATTERN CANDIDATES ===');\n lines.push('');\n lines.push(`Total compositions analyzed: ${result.summary.totalCompositions}`);\n lines.push(`Unique structural patterns found: ${result.summary.uniquePatterns}`);\n\n const percentage =\n result.summary.totalCompositions > 0\n ? Math.round(\n (result.summary.compositionsInGroups / result.summary.totalCompositions) * 100\n )\n : 0;\n lines.push(`Compositions in pattern groups: ${result.summary.compositionsInGroups} (${percentage}%)`);\n lines.push(`Unique compositions (no matches): ${result.summary.uniqueCompositions}`);\n lines.push(`Total unique components: ${result.summary.totalUniqueComponents}`);\n lines.push('');\n\n if (result.patterns.length === 0) {\n lines.push('No pattern candidates found (all compositions have unique structures).');\n return lines.join('\\n');\n }\n\n // Pattern index (summary list)\n lines.push('Pattern candidates index:');\n result.patterns.forEach((pattern, index) => {\n const patternNum = String(index + 1).padStart(padWidth, '0');\n lines.push(` ${patternNum}. ${pattern.name}`);\n lines.push(` (${pattern.compositions.length} compositions)`);\n });\n\n lines.push('');\n lines.push('Pattern candidates:');\n lines.push('');\n\n // Detailed breakdown for each pattern\n result.patterns.forEach((pattern, index) => {\n const patternNum = String(index + 1).padStart(padWidth, '0');\n lines.push(` Pattern ${patternNum}: ${pattern.name} (${pattern.compositions.length} compositions)`);\n\n // Component analysis\n if (pattern.componentAnalysis) {\n const ca = pattern.componentAnalysis;\n const totalComponents = result.summary.totalUniqueComponents;\n lines.push(` Components used: ${ca.componentsUsed.length}/${totalComponents} (${ca.componentsUsed.join(', ')})`);\n lines.push(` Reused components: ${ca.reusedComponents.length}/${ca.componentsUsed.length}${ca.reusedComponents.length > 0 ? ` (${ca.reusedComponents.join(', ')})` : ''}`);\n lines.push(` New components: ${ca.newComponents.length}/${totalComponents} (${ca.newComponents.join(', ')})`);\n lines.push(` Components progression: ${ca.progressionPercentage}% (${ca.cumulativeComponentCount}/${totalComponents})`);\n }\n\n if (!brief) {\n lines.push(' Structure:');\n\n // Generate tree-style structure\n const treeLines = this.generateStructureTree(pattern.structureDescription);\n treeLines.forEach(treeLine => {\n lines.push(` ${treeLine}`);\n });\n\n lines.push('');\n lines.push(' Compositions:');\n\n pattern.compositions.forEach((comp, compIndex) => {\n lines.push(` ${compIndex + 1}. ID: ${comp.id}`);\n lines.push(` Name: ${comp.name}`);\n lines.push(` Node: ${comp.projectMapNodeSlug}`);\n lines.push('');\n });\n }\n\n lines.push('');\n });\n\n // Add unique compositions section at the bottom\n if (result.uniqueCompositions.length > 0) {\n lines.push('');\n lines.push('=== UNIQUE COMPOSITIONS (NO MATCHES) ===');\n lines.push('');\n result.uniqueCompositions.forEach((comp, index) => {\n lines.push(` ${index + 1}. ID: ${comp.id}`);\n lines.push(` Name: ${comp.name}`);\n lines.push(` Node: ${comp.projectMapNodeSlug}`);\n // Component analysis\n if (comp.componentAnalysis) {\n const ca = comp.componentAnalysis;\n const totalComponents = result.summary.totalUniqueComponents;\n lines.push(` Components used: ${ca.componentsUsed.length}/${totalComponents} (${ca.componentsUsed.join(', ')})`);\n lines.push(` Reused components: ${ca.reusedComponents.length}/${ca.componentsUsed.length}${ca.reusedComponents.length > 0 ? ` (${ca.reusedComponents.join(', ')})` : ''}`);\n lines.push(` New components: ${ca.newComponents.length}/${totalComponents} (${ca.newComponents.join(', ')})`);\n lines.push(` Components progression: ${ca.progressionPercentage}% (${ca.cumulativeComponentCount}/${totalComponents})`);\n }\n lines.push('');\n });\n }\n\n return lines.join('\\n');\n }\n\n /**\n * Generates a tree-style representation of the structure description.\n */\n private generateStructureTree(structureDescription: string): string[] {\n const lines: string[] = [];\n this.parseStructureToTree(structureDescription, 0, lines);\n return lines;\n }\n\n private parseStructureToTree(str: string, indent: number, lines: string[]): void {\n const indentStr = ' '.repeat(indent);\n\n // Parse format: \"Type > slot1[Comp1, Comp2 > nested[...]] > slot2[...]\"\n // Or simpler: \"Type\" or \"Type > slot[children]\"\n\n // Find the root type (everything before first \" > \" or the whole string)\n const arrowIndex = str.indexOf(' > ');\n\n if (arrowIndex === -1) {\n // Simple type with no slots\n lines.push(`${indentStr}${str}`);\n return;\n }\n\n const rootType = str.substring(0, arrowIndex);\n lines.push(`${indentStr}${rootType}`);\n\n // Parse the rest (slots)\n const slotsStr = str.substring(arrowIndex + 3);\n this.parseSlotsToTree(slotsStr, indent, lines);\n }\n\n private parseSlotsToTree(str: string, indent: number, lines: string[]): void {\n const indentStr = ' '.repeat(indent);\n\n // Split by \" > \" at the top level (not inside brackets)\n const slots = this.splitTopLevelSlots(str);\n\n for (const slot of slots) {\n // Parse slot format: \"slotName[Component1, Component2]\"\n const bracketStart = slot.indexOf('[');\n if (bracketStart === -1) {\n // No bracket, just a component type\n lines.push(`${indentStr}${slot}`);\n continue;\n }\n\n const slotName = slot.substring(0, bracketStart);\n const bracketEnd = this.findMatchingBracket(slot, bracketStart);\n const contents = slot.substring(bracketStart + 1, bracketEnd);\n\n lines.push(`${indentStr}:${slotName}`);\n\n // Parse contents (comma-separated at top level)\n const components = this.splitTopLevelComponents(contents);\n\n for (const component of components) {\n // Check if component has nested slots\n const compArrow = component.indexOf(' > ');\n if (compArrow !== -1) {\n // Has nested structure\n this.parseStructureToTree(component, indent + 2, lines);\n } else {\n // Simple component\n lines.push(`${indentStr} ${component}`);\n }\n }\n }\n }\n\n private splitTopLevelSlots(str: string): string[] {\n const result: string[] = [];\n let depth = 0;\n let current = '';\n\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n\n if (char === '[') {\n depth++;\n current += char;\n } else if (char === ']') {\n depth--;\n current += char;\n } else if (char === ' ' && str.substring(i, i + 3) === ' > ' && depth === 0) {\n if (current.trim()) {\n result.push(current.trim());\n }\n current = '';\n i += 2; // Skip \" > \"\n } else {\n current += char;\n }\n }\n\n if (current.trim()) {\n result.push(current.trim());\n }\n\n return result;\n }\n\n private splitTopLevelComponents(str: string): string[] {\n const result: string[] = [];\n let depth = 0;\n let current = '';\n\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n\n if (char === '[' || char === '{') {\n depth++;\n current += char;\n } else if (char === ']' || char === '}') {\n depth--;\n current += char;\n } else if (char === ',' && depth === 0) {\n if (current.trim()) {\n result.push(current.trim());\n }\n current = '';\n } else {\n current += char;\n }\n }\n\n if (current.trim()) {\n result.push(current.trim());\n }\n\n return result;\n }\n\n private findMatchingBracket(str: string, start: number): number {\n let depth = 0;\n for (let i = start; i < str.length; i++) {\n if (str[i] === '[') depth++;\n else if (str[i] === ']') {\n depth--;\n if (depth === 0) return i;\n }\n }\n return str.length;\n }\n\n formatJsonOutput(result: PatternAnalysisResult): string {\n // Remove fingerprint and filePath from output (internal use only)\n const cleanedPatterns = result.patterns.map(({ fingerprint: _fingerprint, ...pattern }) => ({\n ...pattern,\n compositions: pattern.compositions.map(({ filePath: _filePath, ...comp }) => comp),\n }));\n\n // Remove filePath from unique compositions\n const cleanedUniqueCompositions = result.uniqueCompositions.map(({ filePath: _filePath, ...comp }) => comp);\n\n return JSON.stringify(\n {\n summary: result.summary,\n patterns: cleanedPatterns,\n uniqueCompositions: cleanedUniqueCompositions,\n },\n null,\n 2\n );\n }\n}\n","import { Command } from 'commander';\nimport { UnpackSerializationOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { SerializationPackerService } from '../../core/services/serialization-packer.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createUnpackSerializationCommand(): Command {\n const command = new Command('unpack-serialization');\n\n command\n .description(\n 'Splits serialization files into skeleton + fragment files keyed by id, enabling clean per-item git diffs.'\n )\n .option('--sourceDir <dir>', 'Directory containing serialization files to unpack')\n .option('--file <path>', 'Single serialization file to unpack')\n .option('--outputDir <dir>', 'Output directory (defaults to same directory as source)')\n .option('--format <format>', 'Output format: yaml or json', 'yaml')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n\n if (!opts.sourceDir && !opts.file) {\n console.error('error: --sourceDir or --file is required');\n process.exit(1);\n }\n\n if (opts.sourceDir && opts.file) {\n console.error('error: --sourceDir and --file are mutually exclusive');\n process.exit(1);\n }\n\n if (opts.format !== 'yaml' && opts.format !== 'json') {\n console.error('error: --format must be \"yaml\" or \"json\"');\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: UnpackSerializationOptions = {\n ...globalOpts,\n sourceDir: opts.sourceDir,\n file: opts.file,\n outputDir: opts.outputDir,\n format: opts.format as 'yaml' | 'json',\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const packer = new SerializationPackerService(fileSystem, logger);\n\n try {\n const result = await packer.unpack({\n sourceDir: options.sourceDir,\n file: options.file,\n outputDir: options.outputDir,\n format: options.format,\n whatIf: options.whatIf ?? false,\n rootDir: options.rootDir,\n });\n\n logger.success(\n `Unpack complete: ${result.processedFiles} file(s) processed, ` +\n `${result.skeletonFilesWritten} skeleton(s), ${result.fragmentFilesWritten} fragment(s)`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\nimport { DuplicateIdError, FileNotFoundError } from '../errors.js';\n\nexport interface UnpackOptions {\n sourceDir?: string;\n file?: string;\n outputDir?: string;\n format: 'yaml' | 'json';\n whatIf: boolean;\n rootDir: string;\n}\n\nexport interface PackOptions {\n sourceDir?: string;\n file?: string;\n outputDir?: string;\n keepFragments?: boolean;\n format: 'yaml' | 'json';\n whatIf: boolean;\n rootDir: string;\n}\n\nexport interface UnpackResult {\n processedFiles: number;\n skeletonFilesWritten: number;\n fragmentFilesWritten: number;\n}\n\nexport interface PackResult {\n processedFiles: number;\n packedFilesWritten: number;\n fragmentsConsumed: number;\n fragmentsDeleted: number;\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isSplittableArray(value: unknown): value is Array<Record<string, unknown>> {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((item) => isPlainObject(item) && typeof item.id === 'string')\n );\n}\n\nfunction isStubArray(value: unknown): value is Array<{ id: string }> {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every(\n (item) =>\n isPlainObject(item) && typeof item.id === 'string' && Object.keys(item).length === 1\n )\n );\n}\n\nexport class SerializationPackerService {\n constructor(\n private fileSystem: FileSystemService,\n private logger: Logger\n ) {}\n\n async unpack(options: UnpackOptions): Promise<UnpackResult> {\n const inputFiles = await this.resolveInputFiles(options);\n let skeletonFilesWritten = 0;\n let fragmentFilesWritten = 0;\n\n for (const filePath of inputFiles) {\n const fileName = this.fileSystem.getBasename(filePath);\n\n // Skip fragment files\n if (fileName.includes('!!')) {\n continue;\n }\n\n this.logger.info(`Processing: ${fileName}`);\n\n const data = await this.fileSystem.readFile<unknown>(filePath);\n const skeleton = structuredClone(data);\n const fragments: Array<{ path: string; data: unknown }> = [];\n\n const dir = options.outputDir\n ? this.fileSystem.resolvePath(options.rootDir, options.outputDir)\n : this.fileSystem.getDirname(filePath);\n\n this.walkForUnpack(skeleton, fileName, dir, filePath, fragments, options.format);\n\n if (fragments.length === 0) {\n this.logger.detail('No splittable arrays found, skipping');\n continue;\n }\n\n // Write skeleton\n const skeletonPath = options.outputDir\n ? this.fileSystem.joinPath(dir, fileName)\n : filePath;\n\n this.logger.action(options.whatIf, 'WRITE', `Skeleton: ${this.fileSystem.getBasename(skeletonPath)}`);\n if (!options.whatIf) {\n await this.fileSystem.writeFile(skeletonPath, skeleton);\n }\n skeletonFilesWritten++;\n\n // Write fragments\n for (const fragment of fragments) {\n this.logger.action(options.whatIf, 'WRITE', `Fragment: ${this.fileSystem.getBasename(fragment.path)}`);\n if (!options.whatIf) {\n await this.fileSystem.writeFile(fragment.path, fragment.data);\n }\n fragmentFilesWritten++;\n }\n }\n\n return {\n processedFiles: inputFiles.filter((f) => !this.fileSystem.getBasename(f).includes('!!')).length,\n skeletonFilesWritten,\n fragmentFilesWritten,\n };\n }\n\n async pack(options: PackOptions): Promise<PackResult> {\n const inputFiles = await this.resolveInputFiles(options);\n let packedFilesWritten = 0;\n let fragmentsConsumed = 0;\n let fragmentsDeleted = 0;\n const consumedFragments = new Set<string>();\n\n for (const filePath of inputFiles) {\n const fileName = this.fileSystem.getBasename(filePath);\n\n // Skip fragment files\n if (fileName.includes('!!')) {\n continue;\n }\n\n this.logger.info(`Processing: ${fileName}`);\n\n const data = await this.fileSystem.readFile<unknown>(filePath);\n\n if (!this.hasStubArrays(data)) {\n this.logger.detail('No stub arrays found, skipping');\n continue;\n }\n\n const dir = this.fileSystem.getDirname(filePath);\n const consumed = await this.walkForPack(data, fileName, dir);\n fragmentsConsumed += consumed.length;\n for (const f of consumed) {\n consumedFragments.add(f);\n }\n\n // Write packed file\n const outputPath = options.outputDir\n ? this.fileSystem.joinPath(\n this.fileSystem.resolvePath(options.rootDir, options.outputDir),\n fileName\n )\n : filePath;\n\n this.logger.action(options.whatIf, 'WRITE', `Packed: ${this.fileSystem.getBasename(outputPath)}`);\n if (!options.whatIf) {\n await this.fileSystem.writeFile(outputPath, data);\n }\n packedFilesWritten++;\n\n // Delete consumed fragments\n if (!options.keepFragments) {\n for (const fragmentPath of consumed) {\n this.logger.action(options.whatIf, 'DELETE', `Fragment: ${this.fileSystem.getBasename(fragmentPath)}`);\n if (!options.whatIf) {\n this.fileSystem.deleteFile(fragmentPath);\n }\n fragmentsDeleted++;\n }\n }\n }\n\n // Warn about orphaned fragments\n await this.warnOrphanedFragments(inputFiles, consumedFragments);\n\n return {\n processedFiles: inputFiles.filter((f) => !this.fileSystem.getBasename(f).includes('!!')).length,\n packedFilesWritten,\n fragmentsConsumed,\n fragmentsDeleted,\n };\n }\n\n private walkForUnpack(\n obj: unknown,\n chain: string,\n dir: string,\n sourceFilePath: string,\n fragments: Array<{ path: string; data: unknown }>,\n format: 'yaml' | 'json'\n ): void {\n if (!isPlainObject(obj)) {\n return;\n }\n\n for (const [key, value] of Object.entries(obj)) {\n if (isSplittableArray(value)) {\n // Validate no duplicate IDs\n const ids = value.map((item) => item.id as string);\n const seen = new Set<string>();\n for (const id of ids) {\n if (seen.has(id)) {\n throw new DuplicateIdError(id, key, sourceFilePath);\n }\n seen.add(id);\n }\n\n // Replace array with stubs\n const stubs: Array<{ id: string }> = [];\n for (const item of value) {\n const id = item.id as string;\n stubs.push({ id });\n\n const fragmentClone = structuredClone(item);\n const ext = format === 'json' ? '.json' : '.yaml';\n const fragmentFileName = `${chain}!!${key}!!-id!!${id}${ext}`;\n const fragmentPath = this.fileSystem.joinPath(dir, fragmentFileName);\n\n // Recurse into the fragment for nested splittable arrays\n this.walkForUnpack(fragmentClone, fragmentFileName, dir, sourceFilePath, fragments, format);\n\n fragments.push({ path: fragmentPath, data: fragmentClone });\n }\n\n (obj as Record<string, unknown>)[key] = stubs;\n } else if (isPlainObject(value)) {\n this.walkForUnpack(value, chain, dir, sourceFilePath, fragments, format);\n }\n }\n }\n\n private hasStubArrays(obj: unknown): boolean {\n if (!isPlainObject(obj)) {\n return false;\n }\n\n for (const value of Object.values(obj)) {\n if (isStubArray(value)) {\n return true;\n }\n if (isPlainObject(value) && this.hasStubArrays(value)) {\n return true;\n }\n }\n\n return false;\n }\n\n private async walkForPack(\n obj: unknown,\n chain: string,\n dir: string\n ): Promise<string[]> {\n if (!isPlainObject(obj)) {\n return [];\n }\n\n const consumed: string[] = [];\n\n for (const [key, value] of Object.entries(obj)) {\n if (isStubArray(value)) {\n const reassembled: unknown[] = [];\n\n for (const stub of value) {\n const id = stub.id;\n // Try both yaml and json extensions\n let fragmentPath = this.fileSystem.joinPath(dir, `${chain}!!${key}!!-id!!${id}.yaml`);\n let exists = await this.fileSystem.fileExists(fragmentPath);\n\n if (!exists) {\n fragmentPath = this.fileSystem.joinPath(dir, `${chain}!!${key}!!-id!!${id}.json`);\n exists = await this.fileSystem.fileExists(fragmentPath);\n }\n\n if (!exists) {\n throw new FileNotFoundError(fragmentPath);\n }\n\n const fragmentData = await this.fileSystem.readFile<unknown>(fragmentPath);\n consumed.push(fragmentPath);\n\n // Recursively reassemble nested stubs\n const fragmentFileName = this.fileSystem.getBasename(fragmentPath);\n const nestedConsumed = await this.walkForPack(fragmentData, fragmentFileName, dir);\n consumed.push(...nestedConsumed);\n\n reassembled.push(fragmentData);\n }\n\n (obj as Record<string, unknown>)[key] = reassembled;\n } else if (isPlainObject(value)) {\n const nestedConsumed = await this.walkForPack(value, chain, dir);\n consumed.push(...nestedConsumed);\n }\n }\n\n return consumed;\n }\n\n private async warnOrphanedFragments(\n inputFiles: string[],\n consumedFragments: Set<string>\n ): Promise<void> {\n const allFragments = inputFiles.filter((f) => this.fileSystem.getBasename(f).includes('!!'));\n for (const fragmentPath of allFragments) {\n if (!consumedFragments.has(fragmentPath)) {\n this.logger.warn(`Orphaned fragment: ${this.fileSystem.getBasename(fragmentPath)}`);\n }\n }\n }\n\n private async resolveInputFiles(options: { sourceDir?: string; file?: string; rootDir: string }): Promise<string[]> {\n if (options.file) {\n const filePath = this.fileSystem.resolvePath(options.rootDir, options.file);\n return [filePath];\n }\n\n if (options.sourceDir) {\n const dir = this.fileSystem.resolvePath(options.rootDir, options.sourceDir);\n const yamlFiles = await this.fileSystem.findFiles(dir, '*.yaml');\n const jsonFiles = await this.fileSystem.findFiles(dir, '*.json');\n return [...yamlFiles, ...jsonFiles].sort();\n }\n\n return [];\n }\n}\n","import { Command } from 'commander';\nimport { PackSerializationOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { SerializationPackerService } from '../../core/services/serialization-packer.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createPackSerializationCommand(): Command {\n const command = new Command('pack-serialization');\n\n command\n .description(\n 'Reassembles skeleton + fragment files back into complete serialization files.'\n )\n .option('--sourceDir <dir>', 'Directory containing skeleton and fragment files to pack')\n .option('--file <path>', 'Single skeleton file to pack')\n .option('--outputDir <dir>', 'Output directory (defaults to same directory as source)')\n .option('--keepFragments', 'Keep fragment files after packing (default: delete them)')\n .option('--format <format>', 'Output format: yaml or json', 'yaml')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n\n if (!opts.sourceDir && !opts.file) {\n console.error('error: --sourceDir or --file is required');\n process.exit(1);\n }\n\n if (opts.sourceDir && opts.file) {\n console.error('error: --sourceDir and --file are mutually exclusive');\n process.exit(1);\n }\n\n if (opts.format !== 'yaml' && opts.format !== 'json') {\n console.error('error: --format must be \"yaml\" or \"json\"');\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: PackSerializationOptions = {\n ...globalOpts,\n sourceDir: opts.sourceDir,\n file: opts.file,\n outputDir: opts.outputDir,\n keepFragments: opts.keepFragments ?? false,\n format: opts.format as 'yaml' | 'json',\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const packer = new SerializationPackerService(fileSystem, logger);\n\n try {\n const result = await packer.pack({\n sourceDir: options.sourceDir,\n file: options.file,\n outputDir: options.outputDir,\n keepFragments: options.keepFragments,\n format: options.format,\n whatIf: options.whatIf ?? false,\n rootDir: options.rootDir,\n });\n\n logger.success(\n `Pack complete: ${result.processedFiles} file(s) processed, ` +\n `${result.packedFilesWritten} packed, ${result.fragmentsConsumed} fragment(s) consumed, ` +\n `${result.fragmentsDeleted} fragment(s) deleted`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { Command } from 'commander';\nimport { RenameSlotOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { SlotRenamerService } from '../../core/services/slot-renamer.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createRenameSlotCommand(): Command {\n const command = new Command('rename-slot');\n\n command\n .description(\n 'Renames a slot in a component definition and updates all compositions, composition patterns, and component patterns that reference it.'\n )\n .option('--componentType <type>', 'The component type that owns the slot being renamed')\n .option('--slotId <id>', 'The current slot ID to rename')\n .option('--newSlotId <id>', 'The new slot ID')\n .option('--newSlotName <name>', 'New display name for the slot (optional)')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'componentType', flag: '--componentType' },\n { name: 'slotId', flag: '--slotId' },\n { name: 'newSlotId', flag: '--newSlotId' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: RenameSlotOptions = {\n ...globalOpts,\n componentType: opts.componentType,\n slotId: opts.slotId,\n newSlotId: opts.newSlotId,\n newSlotName: opts.newSlotName,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const renamer = new SlotRenamerService(fileSystem, componentService, logger);\n\n try {\n const result = await renamer.rename({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionPatternsDir: options.compositionPatternsDir,\n componentPatternsDir: options.componentPatternsDir,\n componentType: options.componentType,\n slotId: options.slotId,\n newSlotId: options.newSlotId,\n newSlotName: options.newSlotName,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n });\n\n logger.success(\n `Renamed slot: ${result.compositionsModified} composition(s), ` +\n `${result.compositionPatternsModified} composition pattern(s), ` +\n `${result.componentPatternsModified} component pattern(s) updated`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { ComponentInstance, Composition } from '../types/index.js';\nimport { SlotNotFoundError, SlotAlreadyExistsError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface RenameSlotInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n componentType: string;\n slotId: string;\n newSlotId: string;\n newSlotName?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface RenameSlotResult {\n componentDefinitionUpdated: boolean;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesRenamed: number;\n}\n\nexport class SlotRenamerService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async rename(options: RenameSlotInternalOptions): Promise<RenameSlotResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n componentType,\n slotId,\n newSlotId,\n newSlotName,\n whatIf,\n strict,\n } = options;\n\n const findOptions = { strict };\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n\n // Validate: newSlotId must differ from slotId\n if (this.compareIds(slotId, newSlotId, strict)) {\n throw new TransformError('New slot ID is the same as the current slot ID');\n }\n\n // Step 1: Load and validate component definition\n this.logger.info(`Loading component: ${componentType}`);\n const { component, filePath: componentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, componentType, findOptions);\n\n if (!component.slots || component.slots.length === 0) {\n throw new SlotNotFoundError(slotId, componentType);\n }\n\n const slotIndex = component.slots.findIndex((s) =>\n this.compareIds(s.id, slotId, strict)\n );\n if (slotIndex === -1) {\n throw new SlotNotFoundError(slotId, componentType);\n }\n\n const existingNewSlot = component.slots.find((s) =>\n this.compareIds(s.id, newSlotId, strict)\n );\n if (existingNewSlot) {\n throw new SlotAlreadyExistsError(newSlotId, componentType);\n }\n\n // Step 2: Rename the slot in the component definition\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Slot \"${slotId}\" → \"${newSlotId}\" in component/${this.fileSystem.getBasename(componentFilePath)}`\n );\n\n component.slots[slotIndex].id = newSlotId;\n if (newSlotName !== undefined) {\n component.slots[slotIndex].name = newSlotName;\n }\n\n if (!whatIf) {\n await this.componentService.saveComponent(componentFilePath, component);\n }\n\n // Step 3: Rename slot keys in compositions\n const compositionsResult = await this.renameSlotInDirectory(\n fullCompositionsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 4: Rename slot keys in composition patterns\n const compositionPatternsResult = await this.renameSlotInDirectory(\n fullCompositionPatternsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 5: Rename slot keys in component patterns\n const componentPatternsResult = await this.renameSlotInDirectory(\n fullComponentPatternsDir,\n componentType,\n slotId,\n newSlotId,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n // Summary\n const totalFiles =\n compositionsResult.filesModified +\n compositionPatternsResult.filesModified +\n componentPatternsResult.filesModified;\n const totalInstances =\n compositionsResult.instancesRenamed +\n compositionPatternsResult.instancesRenamed +\n componentPatternsResult.instancesRenamed;\n\n this.logger.info('');\n this.logger.info(\n `Summary: 1 component definition, ${totalFiles} file(s) (${totalInstances} instance(s)) updated.`\n );\n\n return {\n componentDefinitionUpdated: true,\n compositionsModified: compositionsResult.filesModified,\n compositionPatternsModified: compositionPatternsResult.filesModified,\n componentPatternsModified: componentPatternsResult.filesModified,\n instancesRenamed: totalInstances,\n };\n }\n\n private async renameSlotInDirectory(\n directory: string,\n componentType: string,\n oldSlotId: string,\n newSlotId: string,\n whatIf: boolean,\n strict: boolean,\n label: string\n ): Promise<{ filesModified: number; instancesRenamed: number }> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n } catch {\n // Directory may not exist\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n if (files.length === 0) {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n let filesModified = 0;\n let instancesRenamed = 0;\n\n for (const filePath of files) {\n let composition: Composition;\n try {\n composition = await this.fileSystem.readFile<Composition>(filePath);\n } catch {\n continue;\n }\n\n if (!composition?.composition) {\n continue;\n }\n\n const count = this.renameSlotInTree(\n composition.composition,\n componentType,\n oldSlotId,\n newSlotId,\n strict\n );\n\n if (count > 0) {\n const relativePath = filePath.replace(directory, '').replace(/^[/\\\\]/, '');\n this.logger.action(\n whatIf,\n 'UPDATE',\n `${label}/${relativePath} (${count} instance(s) of ${componentType})`\n );\n\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, composition);\n }\n filesModified++;\n instancesRenamed += count;\n }\n }\n\n return { filesModified, instancesRenamed };\n }\n\n private renameSlotInTree(\n node: { type: string; slots?: Record<string, ComponentInstance[]>; [key: string]: unknown },\n componentType: string,\n oldSlotId: string,\n newSlotId: string,\n strict: boolean\n ): number {\n let count = 0;\n\n // Check if this node's type matches the target component type\n if (this.compareIds(node.type, componentType, strict) && node.slots) {\n const result = this.renameSlotKey(node.slots, oldSlotId, newSlotId, strict);\n if (result.renamed) {\n node.slots = result.slots;\n count++;\n }\n }\n\n // Recurse into all slots\n if (node.slots) {\n for (const slotInstances of Object.values(node.slots)) {\n if (!Array.isArray(slotInstances)) continue;\n for (const instance of slotInstances) {\n count += this.renameSlotInTree(instance, componentType, oldSlotId, newSlotId, strict);\n }\n }\n }\n\n return count;\n }\n\n private renameSlotKey(\n slots: Record<string, ComponentInstance[]>,\n oldSlotId: string,\n newSlotId: string,\n strict: boolean\n ): { renamed: boolean; slots: Record<string, ComponentInstance[]> } {\n const matchingKey = Object.keys(slots).find((key) =>\n this.compareIds(key, oldSlotId, strict)\n );\n\n if (!matchingKey) {\n return { renamed: false, slots };\n }\n\n // Rebuild object preserving key order, replacing the old key with the new one\n const newSlots: Record<string, ComponentInstance[]> = {};\n for (const key of Object.keys(slots)) {\n if (key === matchingKey) {\n newSlots[newSlotId] = slots[key];\n } else {\n newSlots[key] = slots[key];\n }\n }\n\n return { renamed: true, slots: newSlots };\n }\n}\n","import { Command } from 'commander';\nimport { RenameComponentOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { ComponentRenamerService } from '../../core/services/component-renamer.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createRenameComponentCommand(): Command {\n const command = new Command('rename-component');\n\n command\n .description(\n 'Renames a component type across definitions, filenames, allowedComponents, and all compositions.'\n )\n .option('--componentType <type>', 'The current component type ID to rename')\n .option('--newComponentType <type>', 'The new component type ID')\n .option('--newComponentName <name>', 'New display name for the component (optional)')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'componentType', flag: '--componentType' },\n { name: 'newComponentType', flag: '--newComponentType' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: RenameComponentOptions = {\n ...globalOpts,\n componentType: opts.componentType,\n newComponentType: opts.newComponentType,\n newComponentName: opts.newComponentName,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const renamer = new ComponentRenamerService(fileSystem, componentService, logger);\n\n try {\n const result = await renamer.rename({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionPatternsDir: options.compositionPatternsDir,\n componentPatternsDir: options.componentPatternsDir,\n componentType: options.componentType,\n newComponentType: options.newComponentType,\n newComponentName: options.newComponentName,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n });\n\n logger.success(\n `Renamed component: ${result.allowedComponentsUpdated} allowedComponents ref(s), ` +\n `${result.compositionsModified} composition(s), ` +\n `${result.compositionPatternsModified} composition pattern(s), ` +\n `${result.componentPatternsModified} component pattern(s) updated`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { ComponentDefinition, ComponentInstance, Composition } from '../types/index.js';\nimport { ComponentAlreadyExistsError, ComponentNotFoundError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface RenameComponentInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n componentType: string;\n newComponentType: string;\n newComponentName?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface RenameComponentResult {\n componentRenamed: boolean;\n fileRenamed: boolean;\n allowedComponentsUpdated: number;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesRenamed: number;\n}\n\nexport class ComponentRenamerService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n async rename(options: RenameComponentInternalOptions): Promise<RenameComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n componentType,\n newComponentType,\n newComponentName,\n whatIf,\n strict,\n } = options;\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Validate: newComponentType must differ from componentType\n if (this.compareIds(componentType, newComponentType, strict)) {\n throw new TransformError('New component type is the same as the current component type');\n }\n\n // Step 1: Load and validate source component\n this.logger.info(`Loading component: ${componentType}`);\n const { component, filePath: componentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, componentType, findOptions);\n\n // Step 2: Check target does not already exist\n let targetExists = false;\n try {\n await this.componentService.loadComponent(fullComponentsDir, newComponentType, findOptions);\n targetExists = true;\n } catch (error) {\n if (!(error instanceof ComponentNotFoundError)) {\n throw error;\n }\n }\n if (targetExists) {\n throw new ComponentAlreadyExistsError(newComponentType, fullComponentsDir);\n }\n\n // Step 3: Update the component definition id (and optionally name)\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Component ID \"${componentType}\" → \"${newComponentType}\" in component/${this.fileSystem.getBasename(componentFilePath)}`\n );\n component.id = newComponentType;\n if (newComponentName !== undefined) {\n component.name = newComponentName;\n }\n\n if (!whatIf) {\n await this.componentService.saveComponent(componentFilePath, component);\n }\n\n // Step 4: Rename the component file\n const ext = this.fileSystem.getExtension(componentFilePath);\n const dir = this.fileSystem.getDirname(componentFilePath);\n const newFilePath = this.fileSystem.joinPath(dir, `${newComponentType}${ext}`);\n let fileRenamed = false;\n\n if (componentFilePath !== newFilePath) {\n this.logger.action(\n whatIf,\n 'RENAME',\n `component/${this.fileSystem.getBasename(componentFilePath)} → component/${this.fileSystem.getBasename(newFilePath)}`\n );\n if (!whatIf) {\n await this.fileSystem.renameFile(componentFilePath, newFilePath);\n }\n fileRenamed = true;\n }\n\n // Step 5: Update allowedComponents on other component definitions\n const allowedComponentsUpdated = await this.updateAllowedComponents(\n fullComponentsDir,\n componentType,\n newComponentType,\n componentFilePath,\n whatIf,\n strict\n );\n\n // Step 6: Update type fields in compositions\n const compositionsResult = await this.renameTypeInDirectory(\n fullCompositionsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 7: Update type fields in composition patterns\n const compositionPatternsResult = await this.renameTypeInDirectory(\n fullCompositionPatternsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 8: Update type fields in component patterns\n const componentPatternsResult = await this.renameTypeInDirectory(\n fullComponentPatternsDir,\n componentType,\n newComponentType,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n // Summary\n const totalCompositionFiles =\n compositionsResult.filesModified +\n compositionPatternsResult.filesModified +\n componentPatternsResult.filesModified;\n const totalInstances =\n compositionsResult.instancesRenamed +\n compositionPatternsResult.instancesRenamed +\n componentPatternsResult.instancesRenamed;\n\n this.logger.info('');\n this.logger.info(\n `Summary: 1 component renamed, ${allowedComponentsUpdated} component(s) with allowedComponents updated, ` +\n `${totalCompositionFiles} composition file(s) (${totalInstances} instance(s)) updated.`\n );\n\n return {\n componentRenamed: true,\n fileRenamed,\n allowedComponentsUpdated,\n compositionsModified: compositionsResult.filesModified,\n compositionPatternsModified: compositionPatternsResult.filesModified,\n componentPatternsModified: componentPatternsResult.filesModified,\n instancesRenamed: totalInstances,\n };\n }\n\n private async updateAllowedComponents(\n componentsDir: string,\n oldType: string,\n newType: string,\n sourceFilePath: string,\n whatIf: boolean,\n strict: boolean\n ): Promise<number> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(componentsDir, '*.{json,yaml,yml}');\n } catch {\n return 0;\n }\n\n let updatedCount = 0;\n\n for (const filePath of files) {\n // Skip the source component file itself (it was already saved with the new id)\n if (filePath === sourceFilePath) continue;\n\n let comp: ComponentDefinition;\n try {\n comp = await this.fileSystem.readFile<ComponentDefinition>(filePath);\n } catch {\n continue;\n }\n\n if (!comp.slots || comp.slots.length === 0) continue;\n\n let fileModified = false;\n for (const slot of comp.slots) {\n if (!slot.allowedComponents) continue;\n\n for (let i = 0; i < slot.allowedComponents.length; i++) {\n if (this.compareIds(slot.allowedComponents[i], oldType, strict)) {\n slot.allowedComponents[i] = newType;\n fileModified = true;\n }\n }\n }\n\n if (fileModified) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `allowedComponents in component/${this.fileSystem.getBasename(filePath)}: ${oldType} → ${newType}`\n );\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, comp);\n }\n updatedCount++;\n }\n }\n\n return updatedCount;\n }\n\n private async renameTypeInDirectory(\n directory: string,\n oldType: string,\n newType: string,\n whatIf: boolean,\n strict: boolean,\n label: string\n ): Promise<{ filesModified: number; instancesRenamed: number }> {\n let files: string[];\n try {\n files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n } catch {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n if (files.length === 0) {\n return { filesModified: 0, instancesRenamed: 0 };\n }\n\n let filesModified = 0;\n let instancesRenamed = 0;\n\n for (const filePath of files) {\n let composition: Composition;\n try {\n composition = await this.fileSystem.readFile<Composition>(filePath);\n } catch {\n continue;\n }\n\n if (!composition?.composition) continue;\n\n const count = this.renameTypeInTree(composition.composition, oldType, newType, strict);\n\n if (count > 0) {\n const relativePath = filePath.replace(directory, '').replace(/^[/\\\\]/, '');\n this.logger.action(\n whatIf,\n 'UPDATE',\n `${label}/${relativePath} (${count} instance(s))`\n );\n\n if (!whatIf) {\n await this.fileSystem.writeFile(filePath, composition);\n }\n filesModified++;\n instancesRenamed += count;\n }\n }\n\n return { filesModified, instancesRenamed };\n }\n\n private renameTypeInTree(\n node: { type: string; slots?: Record<string, ComponentInstance[]>; [key: string]: unknown },\n oldType: string,\n newType: string,\n strict: boolean\n ): number {\n let count = 0;\n\n // Check this node's type\n if (this.compareIds(node.type, oldType, strict)) {\n node.type = newType;\n count++;\n }\n\n // Recurse into all slots\n if (node.slots) {\n for (const slotInstances of Object.values(node.slots)) {\n if (!Array.isArray(slotInstances)) continue;\n for (const instance of slotInstances) {\n count += this.renameTypeInTree(instance, oldType, newType, strict);\n }\n }\n }\n\n return count;\n }\n}\n","import { Command } from 'commander';\nimport { AddComponentOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { ComponentAdderService } from '../../core/services/component-adder.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createAddComponentCommand(): Command {\n const command = new Command('add-component');\n\n command\n .description('Adds a component instance to existing component slots across all compositions.')\n .option('--parentComponentType <type>', 'The component type that owns the slot')\n .option('--slot <slotId>', 'The slot ID where the component will be added')\n .option('--newComponentType <type>', 'The component type to add')\n .option('--parameters <params>', 'Pipe-separated parameter assignments (key1:value1|key2:value2)')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'parentComponentType', flag: '--parentComponentType' },\n { name: 'slot', flag: '--slot' },\n { name: 'newComponentType', flag: '--newComponentType' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: AddComponentOptions = {\n ...globalOpts,\n parentComponentType: opts.parentComponentType,\n slot: opts.slot,\n newComponentType: opts.newComponentType,\n parameters: opts.parameters,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const adder = new ComponentAdderService(fileSystem, componentService, logger);\n\n try {\n const result = await adder.addComponent({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionPatternsDir: options.compositionPatternsDir,\n componentPatternsDir: options.componentPatternsDir,\n parentComponentType: options.parentComponentType,\n slot: options.slot,\n newComponentType: options.newComponentType,\n parameters: options.parameters,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n });\n\n logger.success(\n `Added component: ${result.allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${result.instancesAdded} instance(s) added across ` +\n `${result.compositionsModified} composition(s), ` +\n `${result.compositionPatternsModified} composition pattern(s), ` +\n `${result.componentPatternsModified} component pattern(s)`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { randomUUID } from 'node:crypto';\nimport {\n ComponentInstance,\n Composition,\n} from '../types/index.js';\nimport { ComponentNotFoundError, TransformError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface AddComponentInternalOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionPatternsDir: string;\n componentPatternsDir: string;\n parentComponentType: string;\n slot: string;\n newComponentType?: string;\n componentPatternId?: string;\n parameters?: string;\n whatIf: boolean;\n strict: boolean;\n}\n\nexport interface AddComponentResult {\n allowedComponentsUpdated: boolean;\n compositionsModified: number;\n compositionPatternsModified: number;\n componentPatternsModified: number;\n instancesAdded: number;\n}\n\ninterface ComponentPattern {\n componentPatternId: string;\n definition: ComponentInstance;\n [key: string]: unknown;\n}\n\ninterface ParsedParameters {\n [key: string]: string;\n}\n\nexport class ComponentAdderService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private logger: Logger\n ) {}\n\n private compareIds(id1: string, id2: string, strict: boolean): boolean {\n if (strict) {\n return id1 === id2;\n }\n return id1.toLowerCase() === id2.toLowerCase();\n }\n\n private parseParameters(parameterString?: string): ParsedParameters {\n const result: ParsedParameters = {};\n if (!parameterString) return result;\n\n const pairs = parameterString.split('|');\n for (const pair of pairs) {\n const [key, ...valueParts] = pair.split(':');\n if (key && valueParts.length > 0) {\n result[key.trim()] = valueParts.join(':').trim();\n }\n }\n return result;\n }\n\n private generateId(baseName: string): string {\n return `${baseName}-${randomUUID().slice(0, 8)}`;\n }\n\n private cloneComponentInstance(instance: ComponentInstance): ComponentInstance {\n const clone = JSON.parse(JSON.stringify(instance)) as ComponentInstance;\n\n // Regenerate _id for the root\n if (clone._id) {\n clone._id = this.generateId(clone.type);\n }\n\n // Recursively regenerate _id for nested instances\n if (clone.slots) {\n for (const slotInstances of Object.values(clone.slots)) {\n if (Array.isArray(slotInstances)) {\n for (const nestedInstance of slotInstances) {\n this.regenerateInstanceIds(nestedInstance);\n }\n }\n }\n }\n\n return clone;\n }\n\n private regenerateInstanceIds(instance: ComponentInstance): void {\n if (instance._id) {\n instance._id = this.generateId(instance.type);\n }\n\n if (instance.slots) {\n for (const slotInstances of Object.values(instance.slots)) {\n if (Array.isArray(slotInstances)) {\n for (const nestedInstance of slotInstances) {\n this.regenerateInstanceIds(nestedInstance);\n }\n }\n }\n }\n }\n\n private createComponentInstance(\n componentType: string,\n parameters: ParsedParameters\n ): ComponentInstance {\n const instance: ComponentInstance = {\n type: componentType,\n _id: this.generateId(componentType),\n };\n\n if (Object.keys(parameters).length > 0) {\n instance.parameters = {};\n for (const [key, value] of Object.entries(parameters)) {\n instance.parameters[key] = {\n type: 'text',\n value,\n };\n }\n }\n\n return instance;\n }\n\n private addComponentToSlot(slots: Record<string, ComponentInstance[]>, slotId: string, instance: ComponentInstance): void {\n if (!slots[slotId]) {\n slots[slotId] = [];\n }\n slots[slotId].push(instance);\n }\n\n async addComponent(options: AddComponentInternalOptions): Promise<AddComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n parentComponentType,\n slot,\n newComponentType,\n parameters: paramString,\n whatIf,\n strict,\n } = options;\n\n if (!newComponentType) {\n throw new TransformError('newComponentType is required for add-component');\n }\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Step 1: Load and validate parent component\n this.logger.info(`Loading parent component: ${parentComponentType}`);\n const { component: parentComponent, filePath: parentComponentFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);\n\n // Step 2: Find or create slot on parent\n if (!parentComponent.slots) {\n parentComponent.slots = [];\n }\n let slotDef = parentComponent.slots.find((s) =>\n this.compareIds(s.id, slot, strict)\n );\n if (!slotDef) {\n this.logger.info(`Slot \"${slot}\" not found on component \"${parentComponentType}\", creating it`);\n slotDef = { id: slot, name: slot, allowedComponents: [] };\n parentComponent.slots.push(slotDef);\n }\n\n // Step 3: Validate new component type exists\n this.logger.info(`Validating new component: ${newComponentType}`);\n try {\n await this.componentService.loadComponent(fullComponentsDir, newComponentType, findOptions);\n } catch (error) {\n if (error instanceof ComponentNotFoundError) {\n throw new TransformError(\n `Component type \"${newComponentType}\" not found in ${fullComponentsDir}`\n );\n }\n throw error;\n }\n\n // Step 4: Update allowedComponents if needed\n let allowedComponentsUpdated = false;\n const slotIndex = parentComponent.slots?.findIndex((s) =>\n this.compareIds(s.id, slotDef.id, strict)\n );\n if (slotIndex !== undefined && slotIndex >= 0) {\n const actualSlot = parentComponent.slots![slotIndex];\n if (!actualSlot.allowedComponents) {\n actualSlot.allowedComponents = [];\n }\n\n const isAlreadyAllowed = actualSlot.allowedComponents.some((c) =>\n this.compareIds(c, newComponentType, strict)\n );\n\n if (!isAlreadyAllowed) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${newComponentType}\" to allowedComponents for slot \"${slot}\" on component \"${parentComponentType}\"`\n );\n actualSlot.allowedComponents.push(newComponentType);\n if (!whatIf) {\n await this.componentService.saveComponent(parentComponentFilePath, parentComponent);\n }\n allowedComponentsUpdated = true;\n }\n }\n\n // Step 5: Parse parameters\n const parsedParams = this.parseParameters(paramString);\n\n // Step 6: Create the new component instance\n const newInstance = this.createComponentInstance(newComponentType, parsedParams);\n\n // Step 7: Add to compositions\n const compositionsResult = await this.addComponentToDirectory(\n fullCompositionsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 8: Add to composition patterns\n const compositionPatternsResult = await this.addComponentToDirectory(\n fullCompositionPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 9: Add to component patterns\n const componentPatternsResult = await this.addComponentToDirectory(\n fullComponentPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n this.logger.info('');\n this.logger.info(\n `Summary: ${allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${compositionsResult} composition(s), ` +\n `${compositionPatternsResult} composition pattern(s), ` +\n `${componentPatternsResult} component pattern(s) updated. ` +\n `${compositionsResult + compositionPatternsResult + componentPatternsResult} instance(s) added.`\n );\n\n return {\n allowedComponentsUpdated,\n compositionsModified: compositionsResult,\n compositionPatternsModified: compositionPatternsResult,\n componentPatternsModified: componentPatternsResult,\n instancesAdded:\n compositionsResult + compositionPatternsResult + componentPatternsResult,\n };\n }\n\n async addComponentPattern(options: AddComponentInternalOptions): Promise<AddComponentResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionPatternsDir,\n componentPatternsDir,\n parentComponentType,\n slot,\n componentPatternId,\n whatIf,\n strict,\n } = options;\n\n if (!componentPatternId) {\n throw new TransformError('componentPatternId is required for add-component-pattern');\n }\n\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n const fullCompositionPatternsDir = this.fileSystem.resolvePath(rootDir, compositionPatternsDir);\n const fullComponentPatternsDir = this.fileSystem.resolvePath(rootDir, componentPatternsDir);\n const findOptions = { strict };\n\n // Step 1: Load and validate parent component\n this.logger.info(`Loading parent component: ${parentComponentType}`);\n const { component: parentComponent } =\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions);\n\n // Step 2: Find or create slot on parent\n if (!parentComponent.slots) {\n parentComponent.slots = [];\n }\n let slotDef = parentComponent.slots.find((s) =>\n this.compareIds(s.id, slot, strict)\n );\n if (!slotDef) {\n this.logger.info(`Slot \"${slot}\" not found on component \"${parentComponentType}\", creating it`);\n slotDef = { id: slot, name: slot, allowedComponents: [] };\n parentComponent.slots.push(slotDef);\n }\n\n // Step 3: Load and validate component pattern\n this.logger.info(`Loading component pattern: ${componentPatternId}`);\n const pattern = await this.loadComponentPattern(\n fullComponentPatternsDir,\n componentPatternId,\n strict\n );\n\n // Step 4: Get the definition from the pattern\n const patternDefinition = pattern.definition;\n if (!patternDefinition || !patternDefinition.type) {\n throw new TransformError(\n `Component pattern \"${componentPatternId}\" has no valid definition or missing type`\n );\n }\n\n // Step 5: Update allowedComponents if needed (using the pattern's definition type)\n let allowedComponentsUpdated = false;\n const componentTypeInPattern = patternDefinition.type;\n const slotIndex = parentComponent.slots?.findIndex((s) =>\n this.compareIds(s.id, slotDef.id, strict)\n );\n if (slotIndex !== undefined && slotIndex >= 0) {\n const actualSlot = parentComponent.slots![slotIndex];\n if (!actualSlot.allowedComponents) {\n actualSlot.allowedComponents = [];\n }\n\n const isAlreadyAllowed = actualSlot.allowedComponents.some((c) =>\n this.compareIds(c, componentTypeInPattern, strict)\n );\n\n if (!isAlreadyAllowed) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${componentTypeInPattern}\" to allowedComponents for slot \"${slot}\" on component \"${parentComponentType}\"`\n );\n actualSlot.allowedComponents.push(componentTypeInPattern);\n if (!whatIf) {\n await this.componentService.loadComponent(fullComponentsDir, parentComponentType, findOptions)\n .then(({ filePath }) =>\n this.componentService.saveComponent(filePath, parentComponent)\n );\n }\n allowedComponentsUpdated = true;\n }\n }\n\n // Step 6: Create the new component instance from the pattern (with cloned definition)\n const newInstance = this.cloneComponentInstance(patternDefinition);\n\n // Step 7: Add to compositions\n const compositionsResult = await this.addComponentToDirectory(\n fullCompositionsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'composition'\n );\n\n // Step 8: Add to composition patterns\n const compositionPatternsResult = await this.addComponentToDirectory(\n fullCompositionPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'compositionPattern'\n );\n\n // Step 9: Add to component patterns\n const componentPatternsResult = await this.addComponentToDirectory(\n fullComponentPatternsDir,\n parentComponentType,\n slot,\n newInstance,\n whatIf,\n strict,\n 'componentPattern'\n );\n\n this.logger.info('');\n this.logger.info(\n `Summary: ${allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${compositionsResult} composition(s), ` +\n `${compositionPatternsResult} composition pattern(s), ` +\n `${componentPatternsResult} component pattern(s) updated. ` +\n `${compositionsResult + compositionPatternsResult + componentPatternsResult} instance(s) added.`\n );\n\n return {\n allowedComponentsUpdated,\n compositionsModified: compositionsResult,\n compositionPatternsModified: compositionPatternsResult,\n componentPatternsModified: componentPatternsResult,\n instancesAdded:\n compositionsResult + compositionPatternsResult + componentPatternsResult,\n };\n }\n\n private async loadComponentPattern(\n componentPatternsDir: string,\n patternId: string,\n strict: boolean\n ): Promise<ComponentPattern> {\n // Try exact match first\n const jsonPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.json`);\n const yamlPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.yaml`);\n const ymlPath = this.fileSystem.joinPath(componentPatternsDir, `${patternId}.yml`);\n\n let raw: Record<string, unknown> | undefined;\n\n if (await this.fileSystem.fileExists(jsonPath)) {\n raw = await this.fileSystem.readFile<Record<string, unknown>>(jsonPath);\n } else if (await this.fileSystem.fileExists(yamlPath)) {\n raw = await this.fileSystem.readFile<Record<string, unknown>>(yamlPath);\n } else if (await this.fileSystem.fileExists(ymlPath)) {\n raw = await this.fileSystem.readFile<Record<string, unknown>>(ymlPath);\n }\n\n // If not strict, try case-insensitive search\n if (!raw && !strict) {\n const files = await this.fileSystem.findFiles(componentPatternsDir, '*.{json,yaml,yml}');\n for (const filePath of files) {\n const basename = this.fileSystem.getBasename(filePath);\n const nameWithoutExt = basename.replace(/\\.(json|yaml|yml)$/i, '');\n if (nameWithoutExt.toLowerCase() === patternId.toLowerCase()) {\n raw = await this.fileSystem.readFile<Record<string, unknown>>(filePath);\n break;\n }\n }\n }\n\n if (!raw) {\n throw new TransformError(`Component pattern \"${patternId}\" not found in ${componentPatternsDir}`);\n }\n\n return this.normalizeComponentPattern(raw, patternId);\n }\n\n private normalizeComponentPattern(\n raw: Record<string, unknown>,\n patternId: string\n ): ComponentPattern {\n // Native format: { componentPatternId, definition: { type, ... } }\n if (raw.definition && typeof raw.definition === 'object' && (raw.definition as ComponentInstance).type) {\n return raw as unknown as ComponentPattern;\n }\n\n // Uniform export format: { composition: { type, _id, ... }, pattern: true }\n if (raw.composition && typeof raw.composition === 'object' && (raw.composition as ComponentInstance).type) {\n const composition = raw.composition as ComponentInstance;\n return {\n componentPatternId: patternId,\n definition: composition,\n };\n }\n\n return raw as unknown as ComponentPattern;\n }\n\n private async addComponentToDirectory(\n directory: string,\n parentComponentType: string,\n slot: string,\n newInstance: ComponentInstance,\n whatIf: boolean,\n strict: boolean,\n dirType: 'composition' | 'compositionPattern' | 'componentPattern'\n ): Promise<number> {\n const exists = await this.fileSystem.fileExists(directory);\n if (!exists) {\n this.logger.detail(`${dirType} directory does not exist, skipping`);\n return 0;\n }\n\n const files = await this.fileSystem.findFiles(directory, '**/*.{json,yaml,yml}');\n let filesModified = 0;\n\n for (const filePath of files) {\n try {\n // Handle both composition and componentPattern formats\n const content = await this.fileSystem.readFile<unknown>(filePath);\n\n // For component patterns, the structure might be different\n let composition: Composition | null = null;\n let isComponentPattern = false;\n\n if (dirType === 'componentPattern' && content && typeof content === 'object' && 'definition' in content) {\n // This is a component pattern\n isComponentPattern = true;\n const pattern = content as ComponentPattern;\n if (pattern.definition && pattern.definition.slots) {\n composition = {\n composition: {\n _id: 'pattern-root',\n type: pattern.definition.type,\n slots: pattern.definition.slots,\n } as any,\n };\n }\n } else {\n // This is a normal composition\n composition = content as Composition;\n }\n\n if (!composition?.composition) {\n continue;\n }\n\n // Find and add to parent component instances\n const rootInstance = composition.composition as any;\n let modified = false;\n\n // Check root instance\n if (this.compareIds(rootInstance.type, parentComponentType, strict)) {\n if (!rootInstance.slots) {\n rootInstance.slots = {};\n }\n\n // Clone the new instance to avoid mutations\n const instanceCopy = JSON.parse(JSON.stringify(newInstance)) as ComponentInstance;\n // Regenerate IDs for this copy to ensure uniqueness\n this.regenerateInstanceIds(instanceCopy);\n this.addComponentToSlot(rootInstance.slots, slot, instanceCopy);\n modified = true;\n }\n\n // Check nested instances\n if (rootInstance.slots) {\n const nestedModified = this.addComponentToNestedSlots(\n rootInstance.slots,\n parentComponentType,\n slot,\n newInstance,\n strict\n );\n if (nestedModified) {\n modified = true;\n }\n }\n\n if (modified) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Adding \"${newInstance.type}\" to slot \"${slot}\" in ${dirType}/${this.fileSystem.getBasename(filePath)}`\n );\n\n if (!whatIf) {\n if (isComponentPattern && content && typeof content === 'object' && 'definition' in content) {\n // For component patterns, update the definition\n const pattern = content as ComponentPattern;\n if (rootInstance.slots) {\n pattern.definition.slots = rootInstance.slots;\n }\n }\n await this.fileSystem.writeFile(filePath, content);\n }\n\n filesModified++;\n }\n } catch (error) {\n // Skip files that can't be parsed\n if (error instanceof Error && !error.message.includes('skipping')) {\n this.logger.detail(`Skipping ${filePath}: ${error.message}`);\n }\n }\n }\n\n return filesModified;\n }\n\n private addComponentToNestedSlots(\n slots: Record<string, ComponentInstance[]>,\n parentComponentType: string,\n slot: string,\n newInstance: ComponentInstance,\n strict: boolean\n ): boolean {\n let modified = false;\n\n for (const slotInstances of Object.values(slots)) {\n if (!Array.isArray(slotInstances)) continue;\n\n for (const instance of slotInstances) {\n if (this.compareIds(instance.type, parentComponentType, strict)) {\n if (!instance.slots) {\n instance.slots = {};\n }\n\n // Clone the new instance to avoid mutations across multiple matches\n const instanceCopy = JSON.parse(JSON.stringify(newInstance)) as ComponentInstance;\n // Regenerate IDs for this copy to ensure uniqueness\n this.regenerateInstanceIds(instanceCopy);\n this.addComponentToSlot(instance.slots, slot, instanceCopy);\n modified = true;\n }\n\n // Recurse into nested slots\n if (instance.slots) {\n const nestedModified = this.addComponentToNestedSlots(\n instance.slots,\n parentComponentType,\n slot,\n newInstance,\n strict\n );\n if (nestedModified) {\n modified = true;\n }\n }\n }\n }\n\n return modified;\n }\n}\n","import { Command } from 'commander';\nimport { AddComponentPatternOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { ComponentAdderService } from '../../core/services/component-adder.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createAddComponentPatternCommand(): Command {\n const command = new Command('add-component-pattern');\n\n command\n .description('Adds a component pattern instance to existing component slots across all compositions.')\n .option('--parentComponentType <type>', 'The component type that owns the slot')\n .option('--slot <slotId>', 'The slot ID where the component pattern will be added')\n .option('--componentPatternId <id>', 'The component pattern ID to add')\n .option('--parameters <params>', 'Pipe-separated parameter assignments (key1:value1|key2:value2)')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'parentComponentType', flag: '--parentComponentType' },\n { name: 'slot', flag: '--slot' },\n { name: 'componentPatternId', flag: '--componentPatternId' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: AddComponentPatternOptions = {\n ...globalOpts,\n parentComponentType: opts.parentComponentType,\n slot: opts.slot,\n componentPatternId: opts.componentPatternId,\n parameters: opts.parameters,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const adder = new ComponentAdderService(fileSystem, componentService, logger);\n\n try {\n const result = await adder.addComponentPattern({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionPatternsDir: options.compositionPatternsDir,\n componentPatternsDir: options.componentPatternsDir,\n parentComponentType: options.parentComponentType,\n slot: options.slot,\n componentPatternId: options.componentPatternId,\n parameters: options.parameters,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n });\n\n logger.success(\n `Added component pattern: ${result.allowedComponentsUpdated ? '1 component definition updated, ' : ''}` +\n `${result.instancesAdded} instance(s) added across ` +\n `${result.compositionsModified} composition(s), ` +\n `${result.compositionPatternsModified} composition pattern(s), ` +\n `${result.componentPatternsModified} component pattern(s)`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { Command } from 'commander';\nimport { PropagateRootComponentSlotOptions } from '../../core/types/index.js';\nimport { FileSystemService } from '../../core/services/file-system.service.js';\nimport { ComponentService } from '../../core/services/component.service.js';\nimport { CompositionService } from '../../core/services/composition.service.js';\nimport { SlotPropagatorService } from '../../core/services/slot-propagator.service.js';\nimport { Logger } from '../logger.js';\nimport { TransformError } from '../../core/errors.js';\n\nexport function createPropagateRootComponentSlotCommand(): Command {\n const command = new Command('propagate-root-component-slot');\n\n command\n .description(\n \"Copies slot definitions from a composition type's root component to a target component type, then moves all component instances from that slot across all matching compositions.\"\n )\n .option('--compositionType <type>', 'The composition type to process (e.g., HomePage)')\n .option('--slot <slots>', 'Pipe-separated list of slot names to copy from the source component')\n .option(\n '--targetComponentType <type>',\n 'The component type that will receive the copied slots'\n )\n .option(\n '--targetSlot <slot>',\n 'The slot name on the target component where the contents will be placed'\n )\n .option(\n '--deleteSourceSlot',\n 'Delete the original slots from the source component after propagation'\n )\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts();\n const requiredOptions = [\n { name: 'compositionType', flag: '--compositionType' },\n { name: 'slot', flag: '--slot' },\n { name: 'targetComponentType', flag: '--targetComponentType' },\n { name: 'targetSlot', flag: '--targetSlot' },\n ];\n\n const missing = requiredOptions\n .filter((opt) => !opts[opt.name])\n .map((opt) => opt.flag);\n\n if (missing.length > 0) {\n console.error(`error: missing required options: ${missing.join(', ')}`);\n process.exit(1);\n }\n })\n .action(async (opts, cmd) => {\n const globalOpts = cmd.optsWithGlobals();\n const options: PropagateRootComponentSlotOptions = {\n ...globalOpts,\n compositionType: opts.compositionType,\n slot: opts.slot,\n targetComponentType: opts.targetComponentType,\n targetSlot: opts.targetSlot,\n deleteSourceSlot: opts.deleteSourceSlot,\n };\n\n const logger = new Logger();\n const fileSystem = new FileSystemService();\n const componentService = new ComponentService(fileSystem);\n const compositionService = new CompositionService(fileSystem);\n const propagator = new SlotPropagatorService(\n fileSystem,\n componentService,\n compositionService,\n logger\n );\n\n try {\n const result = await propagator.propagate({\n rootDir: options.rootDir,\n componentsDir: options.componentsDir,\n compositionsDir: options.compositionsDir,\n compositionType: options.compositionType,\n slot: options.slot,\n targetComponentType: options.targetComponentType,\n targetSlot: options.targetSlot,\n whatIf: options.whatIf ?? false,\n strict: options.strict ?? false,\n deleteSourceSlot: options.deleteSourceSlot ?? false,\n });\n\n logger.success(\n `Modified ${result.modifiedComponents} component(s), ${result.modifiedCompositions} composition(s)`\n );\n } catch (error) {\n if (error instanceof TransformError) {\n logger.error(error.message);\n process.exit(1);\n }\n throw error;\n }\n });\n\n return command;\n}\n","import { ComponentInstance, SlotDefinition } from '../types/index.js';\nimport { PropertyNotFoundError } from '../errors.js';\nimport { ComponentService } from './component.service.js';\nimport { CompositionService } from './composition.service.js';\nimport { FileSystemService } from './file-system.service.js';\nimport { Logger } from '../../cli/logger.js';\n\nexport interface SlotPropagateOptions {\n rootDir: string;\n componentsDir: string;\n compositionsDir: string;\n compositionType: string;\n slot: string;\n targetComponentType: string;\n targetSlot: string;\n whatIf: boolean;\n strict: boolean;\n deleteSourceSlot: boolean;\n}\n\nexport interface SlotPropagateResult {\n modifiedComponents: number;\n modifiedCompositions: number;\n propagatedInstances: number;\n}\n\nexport class SlotPropagatorService {\n constructor(\n private fileSystem: FileSystemService,\n private componentService: ComponentService,\n private compositionService: CompositionService,\n private logger: Logger\n ) {}\n\n async propagate(options: SlotPropagateOptions): Promise<SlotPropagateResult> {\n const {\n rootDir,\n componentsDir,\n compositionsDir,\n compositionType,\n slot,\n targetComponentType,\n targetSlot,\n whatIf,\n strict,\n deleteSourceSlot,\n } = options;\n\n const findOptions = { strict };\n const fullComponentsDir = this.fileSystem.resolvePath(rootDir, componentsDir);\n const fullCompositionsDir = this.fileSystem.resolvePath(rootDir, compositionsDir);\n\n // Step 1: Load source component (compositionType)\n this.logger.info(`Loading component: ${compositionType}`);\n const { component: sourceComponent, filePath: sourceFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, compositionType, findOptions);\n\n // Step 2: Load target component\n this.logger.info(`Loading component: ${targetComponentType}`);\n const { component: targetComponent, filePath: targetFilePath } =\n await this.componentService.loadComponent(fullComponentsDir, targetComponentType, findOptions);\n\n // Step 3: Parse and resolve slot names\n const slotNames = slot.split('|').map((s) => s.trim());\n const resolvedSlots: SlotDefinition[] = [];\n const notFound: string[] = [];\n\n for (const slotName of slotNames) {\n const slotDef = this.componentService.findSlot(sourceComponent, slotName, findOptions);\n if (slotDef) {\n resolvedSlots.push(slotDef);\n } else {\n notFound.push(slotName);\n }\n }\n\n if (notFound.length > 0) {\n throw new PropertyNotFoundError(`Slot \"${notFound.join(', ')}\"`, compositionType);\n }\n\n const resolvedSlotIds = resolvedSlots.map((s) => s.id);\n this.logger.info(`Resolved slots: ${resolvedSlotIds.join(', ')}`);\n\n // Step 4: Modify target component - add/merge slot definition\n let modifiedComponent = { ...targetComponent };\n let componentModified = false;\n\n const existingSlot = this.componentService.findSlot(modifiedComponent, targetSlot, findOptions);\n if (!existingSlot) {\n // Create new slot with merged allowedComponents from all source slots\n const mergedAllowedComponents = this.mergeAllowedComponents(resolvedSlots);\n this.logger.action(whatIf, 'CREATE', `Slot \"${targetSlot}\" on ${targetComponentType}`);\n modifiedComponent = this.componentService.addSlot(modifiedComponent, {\n id: targetSlot,\n name: targetSlot,\n allowedComponents: mergedAllowedComponents,\n });\n componentModified = true;\n } else {\n // Merge allowedComponents into existing slot\n const mergedAllowedComponents = this.mergeAllowedComponents([existingSlot, ...resolvedSlots]);\n const existingAllowed = existingSlot.allowedComponents ?? [];\n if (mergedAllowedComponents.length > existingAllowed.length) {\n this.logger.action(\n whatIf,\n 'UPDATE',\n `Slot \"${targetSlot}\" allowedComponents on ${targetComponentType}`\n );\n modifiedComponent = this.componentService.updateSlotAllowedComponents(\n modifiedComponent,\n targetSlot,\n mergedAllowedComponents,\n findOptions\n );\n componentModified = true;\n } else {\n this.logger.info(`Slot \"${targetSlot}\" already exists on ${targetComponentType}`);\n }\n }\n\n // Save modified target component\n if (componentModified && !whatIf) {\n await this.componentService.saveComponent(targetFilePath, modifiedComponent);\n }\n\n // Step 5: Propagate slot contents in compositions\n const compositions = await this.compositionService.findCompositionsByType(\n fullCompositionsDir,\n compositionType,\n findOptions\n );\n\n let modifiedCompositions = 0;\n let propagatedInstances = 0;\n\n for (const { composition, filePath } of compositions) {\n const rootSlots = composition.composition.slots ?? {};\n const instances = this.compositionService.findComponentInstances(\n composition,\n targetComponentType,\n findOptions\n );\n\n if (instances.length === 0) {\n continue;\n }\n\n // Collect all components from source slots\n const componentsToPropagate: ComponentInstance[] = [];\n for (const slotDef of resolvedSlots) {\n const slotContent = rootSlots[slotDef.id] ?? [];\n componentsToPropagate.push(...slotContent);\n }\n\n if (componentsToPropagate.length === 0) {\n continue;\n }\n\n let compositionModified = false;\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n const instanceUpdates: string[] = [];\n\n for (const { instance, instanceId } of instances) {\n const instanceName = instance._id ?? instanceId;\n // Deep clone components to avoid reference issues\n const clonedComponents = this.deepCloneComponents(componentsToPropagate);\n this.addComponentsToInstanceSlot(instance, targetSlot, clonedComponents);\n compositionModified = true;\n propagatedInstances++;\n instanceUpdates.push(\n `${targetComponentType} \"${instanceName}\": ${componentsToPropagate.length} component(s) → ${targetSlot}`\n );\n }\n\n if (compositionModified) {\n this.logger.action(whatIf, 'UPDATE', `composition/${relativePath}`);\n for (const update of instanceUpdates) {\n this.logger.detail(`→ ${update}`);\n }\n\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n modifiedCompositions++;\n }\n }\n\n // Step 6: Delete source slots if requested\n let sourceComponentModified = false;\n if (deleteSourceSlot) {\n let modifiedSource = { ...sourceComponent };\n\n // Delete the resolved slots from source component\n for (const slotDef of resolvedSlots) {\n this.logger.action(whatIf, 'DELETE', `Slot \"${slotDef.id}\" from ${compositionType}`);\n modifiedSource = this.componentService.removeSlot(modifiedSource, slotDef.id, findOptions);\n sourceComponentModified = true;\n }\n\n if (sourceComponentModified && !whatIf) {\n await this.componentService.saveComponent(sourceFilePath, modifiedSource);\n }\n\n // Clear slot contents from root in compositions\n for (const { composition, filePath } of compositions) {\n const relativePath = filePath.replace(fullCompositionsDir, '').replace(/^[/\\\\]/, '');\n let cleared = false;\n\n for (const slotDef of resolvedSlots) {\n if (composition.composition.slots?.[slotDef.id]?.length) {\n composition.composition.slots[slotDef.id] = [];\n cleared = true;\n }\n }\n\n if (cleared) {\n this.logger.action(whatIf, 'CLEAR', `Root slots in composition/${relativePath}`);\n this.logger.detail(`→ Cleared: ${resolvedSlotIds.join(', ')}`);\n if (!whatIf) {\n await this.compositionService.saveComposition(filePath, composition);\n }\n }\n }\n }\n\n return {\n modifiedComponents: (componentModified ? 1 : 0) + (sourceComponentModified ? 1 : 0),\n modifiedCompositions,\n propagatedInstances,\n };\n }\n\n private mergeAllowedComponents(slots: SlotDefinition[]): string[] {\n const allowed = new Set<string>();\n for (const slot of slots) {\n for (const comp of slot.allowedComponents ?? []) {\n allowed.add(comp);\n }\n }\n return Array.from(allowed).sort();\n }\n\n private deepCloneComponents(components: ComponentInstance[]): ComponentInstance[] {\n return JSON.parse(JSON.stringify(components));\n }\n\n private addComponentsToInstanceSlot(\n instance: ComponentInstance,\n slotName: string,\n components: ComponentInstance[]\n ): void {\n if (!instance.slots) {\n instance.slots = {};\n }\n if (!instance.slots[slotName]) {\n instance.slots[slotName] = [];\n }\n instance.slots[slotName].push(...components);\n }\n}\n"],"mappings":";;;AAEA,SAAS,WAAAA,iBAAe;;;ACFxB,SAAS,eAAe;;;ACAxB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,YAAY;AACrB,YAAY,UAAU;;;ACHf,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,yBAAN,cAAqC,eAAe;AAAA,EACzD,YAAY,eAAuBC,OAAe;AAChD,UAAM,WAAWA,QAAO,eAAeA,KAAI,MAAM;AACjD,UAAM,wBAAwB,aAAa,GAAG,QAAQ,EAAE;AACxD,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,wBAAN,cAAoC,eAAe;AAAA,EACxD,YAAY,cAAsB,eAAuB;AACvD,UAAM,aAAa,YAAY,6BAA6B,aAAa,GAAG;AAC5E,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,mBAAN,cAA+B,eAAe;AAAA,EACnD,YAAY,UAA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,gCAAgC,qCAAqC,kBAAkB,EAC9F;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACF,EACC,OAAO,wBAAwB,6BAA6B,UAAU,EACtE,OAAO,sBAAsB,0BAA0B,OAAO,EAC9D,OAAO,oBAAoB,wBAAwB,OAAO,EAC1D,OAAO,0BAA0B,+BAA+B,YAAY,EAC5E,OAAO,+BAA+B,oCAAoC,iBAAiB,EAC3F;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACF,EACC,OAAO,8BAA8B,oCAAoC,gBAAgB,EACzF,OAAO,qBAAqB,yBAAyB,OAAO;AAG/D,QAAQ,WAAW,4CAA4C,CAAC;AAChE,QAAQ,WAAW,8CAA8C,CAAC;AAClE,QAAQ,WAAW,iCAAiC,CAAC;AACrD,QAAQ,WAAW,+BAA+B,CAAC;AACnD,QAAQ,WAAW,wBAAwB,CAAC;AAC5C,QAAQ,WAAW,6BAA6B,CAAC;AACjD,QAAQ,WAAW,0BAA0B,CAAC;AAC9C,QAAQ,WAAW,iCAAiC,CAAC;AACrD,QAAQ,WAAW,wCAAwC,CAAC;AAE5D,QAAQ,MAAM;","names":["Command","path","basename","Command","Command","Command","Command","Command","Command","Command","Command","Command","Command","Command","basename","Command","Command","Command","Command","Command","Command"]}