/**
 * Path utilities for init command
 * Handles finding package root and source directories
 */
import type { ParentSpecweaveFolder, UmbrellaParentResult, SuspiciousPathResult, UmbrellaDiscoveryResult } from './types.js';
import type { WorkspaceConfig } from '../../../core/config/types.js';
/**
 * Find the package root by walking up the directory tree looking for package.json
 * This works reliably on all platforms including Windows with UNC paths
 *
 * @param startDir - Directory to start searching from
 * @returns Path to package root or null if not found
 */
export declare function findPackageRoot(startDir: string): string | null;
/**
 * Find the source directory, trying multiple possible locations
 * Handles both development and installed package scenarios
 * Windows-compatible with proper path normalization
 *
 * @param relativePath - Relative path to find (e.g., 'templates', 'plugins/specweave')
 * @param dirname - Current __dirname value
 * @returns Absolute path to the source directory
 */
export declare function findSourceDir(relativePath: string, dirname: string): string;
/**
 * Detect ALL parent directories that contain .specweave/ folders
 * SpecWeave ONLY supports root-level .specweave/ folders
 * Nested .specweave/ folders are NOT supported
 *
 * EXCEPTION: User-level ~/.specweave is VALID and doesn't block initialization.
 * This is used for global SpecWeave settings (memory, logs, state, skills-cache).
 *
 * @param targetDir - Directory where user wants to initialize
 * @returns Array of paths to parent .specweave/ folders with depth info, or null if none found
 */
export declare function detectNestedSpecweave(targetDir: string): ParentSpecweaveFolder[] | null;
/**
 * Segments that indicate a path is NOT a project root.
 * Used by detectSuspiciousPath() to prevent init in wrong locations.
 */
export declare const SUSPICIOUS_PATH_SEGMENTS: readonly string[];
/**
 * Detect if the target directory is inside an umbrella project.
 * Walks up from targetDir looking for parent .specweave/config.json
 * that indicates an umbrella repo (has repository.umbrellaRepo or
 * a sibling repositories/ directory).
 *
 * @param targetDir - Directory where user wants to initialize
 * @returns UmbrellaParentResult if inside an umbrella, null otherwise
 */
export declare function detectUmbrellaParent(targetDir: string): UmbrellaParentResult | null;
/**
 * Check if a path is inside the OS system temp directory.
 *
 * Uses os.tmpdir() to detect the real system temp dir, avoiding false positives
 * on user-created folders named "temp" or "tmp".
 *
 * @param resolvedPath - Absolute path to check
 * @returns true if the path is the system temp dir or a subdirectory of it
 */
export declare function isSystemTempDir(resolvedPath: string): boolean;
/**
 * Detect if the target directory path contains suspicious segments
 * that indicate it's NOT a project root (e.g., node_modules, dist, .git),
 * or if it's inside the system temp directory.
 *
 * @param targetDir - Directory where user wants to initialize
 * @returns SuspiciousPathResult if suspicious segment found, null otherwise
 */
export declare function detectSuspiciousPath(targetDir: string): SuspiciousPathResult | null;
/**
 * Scan the repositories/ subdirectory to discover child repos in an umbrella structure.
 * Looks for repositories/{org}/{repo}/.git at exactly 2 levels deep.
 *
 * @param targetDir - The project root directory to scan
 * @returns UmbrellaDiscoveryResult if repos found, null otherwise
 */
export declare function scanUmbrellaRepos(targetDir: string): UmbrellaDiscoveryResult | null;
/**
 * Scan the repositories/ subdirectory to discover workspace repos.
 * Alias for scanUmbrellaRepos — new canonical name per workspace config rework.
 *
 * @param targetDir - The project root directory to scan
 * @returns UmbrellaDiscoveryResult if repos found, null otherwise
 */
export declare const scanWorkspaceRepos: typeof scanUmbrellaRepos;
/**
 * Scan for repositories placed directly under repositories/ without an org subfolder.
 *
 * The standard umbrella layout is repositories/{org}/{repo}/.git (2 levels).
 * This function detects the non-standard 1-level pattern: repositories/{repo}/.git.
 * It is called only when scanUmbrellaRepos() returns null (mutually exclusive).
 *
 * @param targetDir - The project root directory to scan
 * @returns Array of misplaced repo names, or empty array if none found
 */
export declare function scanMisplacedRepos(targetDir: string): string[];
/**
 * Build umbrella config fragment from discovered repos.
 * Generates 3-char uppercase prefixes with deduplication (2-char + numeric suffix on collision).
 *
 * @param discovery - Result of scanUmbrellaRepos()
 * @param projectName - Name of the umbrella project
 * @returns Config fragment with umbrella and repository fields
 */
export declare function buildUmbrellaConfig(discovery: UmbrellaDiscoveryResult, projectName: string): {
    umbrella: {
        enabled: true;
        projectName: string;
        childRepos: Array<{
            id: string;
            path: string;
            name: string;
            prefix: string;
        }>;
    };
    repository: {
        umbrellaRepo: true;
    };
};
/**
 * Build workspace config fragment from discovered repos.
 * Returns { workspace: WorkspaceConfig } instead of the legacy { umbrella: UmbrellaConfig }.
 * Each repo gets an empty sync: {} default.
 *
 * @param discovery - Result of scanWorkspaceRepos()
 * @param projectName - Name of the workspace project
 * @returns Config fragment with workspace field
 */
export declare function buildWorkspaceConfig(discovery: UmbrellaDiscoveryResult, projectName: string): {
    workspace: WorkspaceConfig;
    repository: {
        umbrellaRepo: true;
    };
};
/**
 * Count files recursively in a directory
 * Used for logging before deletion
 *
 * @param dir - Directory to count files in
 * @returns Total file count
 */
export declare function countFilesRecursive(dir: string): number;
//# sourceMappingURL=path-utils.d.ts.map