/** * Hierarchy Builder Service * * Handles project/board hierarchy resolution for living docs sync. * Extracted from living-docs-sync.ts for better separation of concerns. * * Responsibilities: * - Resolve project path for increments * - Detect multi-project mode * - Match project names with fuzzy logic * - Handle 2-level structures (project/board) * * @module core/living-docs/sync-helpers/hierarchy-builder * @since v1.0.115 */ import { Logger } from '../../../utils/logger.js'; /** * Multi-project detection result */ export interface MultiProjectDetection { isMultiProject: boolean; projects: Array<{ id: string; name: string; source: string; }>; detectionReason: string; } /** * Hierarchy builder options */ export interface HierarchyBuilderOptions { logger?: Logger; } /** * Hierarchy Builder - Handles project/board hierarchy resolution */ export declare class HierarchyBuilder { private projectRoot; private logger; constructor(projectRoot: string, options?: HierarchyBuilderOptions); /** * Detect if multi-project mode is enabled * * Checks config.json for: * - umbrella.enabled (multi-repo setup) * - multiProject.enabled (explicit multi-project) * - Multiple board/area mappings in sync profiles * - Multiple folders in specs directory * * @returns Detection result with projects and reason */ detectMultiProjectMode(): Promise; /** * Find the best matching project path in existing specs structure * * Searches for: * 1. Direct match: specs/{project}/ * 2. Hierarchical match: specs/{org}/{project}/ * 3. Fuzzy match: specs/{org}/{similar-project}/ * * @param specsBase - Base specs folder path * @param projectName - Project name to search for * @returns Full relative path or null */ findBestProjectMatch(specsBase: string, projectName: string): Promise; /** * Compare project names with fuzzy matching * * Handles common variations: * - "operation" vs "operations" * - "service" vs "services" * - Different separators (hyphen vs underscore) * * @param existing - Existing folder name * @param target - Target project name to match * @returns true if names match (exact or fuzzy) */ projectNamesMatch(existing: string, target: string): boolean; /** * Validate and normalize a project/board name * * SECURITY: Prevents path traversal and validates format * * @param rawName - Raw name to validate * @param fieldType - Type of field for logging * @returns Normalized name or null if invalid */ validateAndNormalizeName(rawName: string, fieldType: 'project' | 'board'): string | null; /** * Get list of available projects from specs folder * * @returns Array of project folder names */ getAvailableProjects(): Promise; /** * Check if a path represents a 2-level structure (project/board) * * @param projectPath - Path to check * @returns true if 2-level structure */ is2LevelPath(projectPath: string): boolean; /** * Split a 2-level path into project and board * * @param fullPath - Full path (e.g., "acme/digital-ops") * @returns Object with project and board */ splitPath(fullPath: string): { project: string; board: string | null; }; } //# sourceMappingURL=hierarchy-builder.d.ts.map