/**
 * Feature & Epic Archiver - Smart archiving system for features and epics
 *
 * v5.0.0 - Unified Project Structure
 * Features now live directly in project folders: {project}/FS-XXX/
 * No more separate _features folder.
 *
 * Works in tandem with IncrementArchiver to maintain consistency between
 * increments, features, and epics. When an increment is archived, its
 * associated feature is automatically archived if all increments for
 * that feature are archived.
 */
interface LinkUpdate {
    file: string;
    oldLink: string;
    newLink: string;
    lineNumber: number;
}
export interface FeatureArchiveOptions {
    dryRun?: boolean;
    updateLinks?: boolean;
    preserveActiveFeatures?: boolean;
    archiveOrphanedFeatures?: boolean;
    archiveOrphanedEpics?: boolean;
    forceArchiveWhenAllIncrementsArchived?: boolean;
    customReason?: string;
}
export interface FeatureArchiveResult {
    archivedFeatures: string[];
    archivedEpics: string[];
    updatedLinks: LinkUpdate[];
    errors: string[];
}
export declare class FeatureArchiver {
    private rootDir;
    private specsDir;
    private epicsDir;
    private incrementArchiver;
    private hierarchyMapper;
    private featureIdManager;
    constructor(rootDir: string);
    /**
     * Archive features and epics based on increment archive status
     */
    archiveFeatures(options?: FeatureArchiveOptions): Promise<FeatureArchiveResult>;
    /**
     * Identify features that should be archived
     * v5.0.0: Features now live in {project}/FS-XXX/, archives go to {project}/_archive/FS-XXX/
     */
    private identifyFeaturesToArchive;
    /**
     * Identify epics that should be archived
     */
    private identifyEpicsToArchive;
    /**
     * Execute an archive operation
     */
    private executeArchiveOperation;
    /**
     * Archive all project folders containing this feature
     * v5.0.0: Features live directly in {project}/FS-XXX/, archived to {project}/_archive/FS-XXX/
     */
    private archiveProjectSpecificFolders;
    /**
     * Update all links to archived items
     */
    private updateAllLinks;
    /**
     * Update links in a single file
     * v5.0.0: Features live in {project}/FS-XXX/, no more _features folder
     */
    private updateLinksInFile;
    /**
     * Get all features (just IDs, for backward compatibility)
     * v5.0.0: Scans project folders for FS-* directories
     */
    private getAllFeatures;
    /**
     * Get all feature locations with project context
     * v5.0.0: Features live in {project}/FS-XXX/
     * @returns Array of { featureId, projectId, featurePath }
     */
    private getAllFeatureLocations;
    /**
     * Get all epics
     */
    private getAllEpics;
    /**
     * Get increments linked to a feature
     *
     * v0.30.0 CRITICAL FIX: Parse FEATURE.md Implementation History as PRIMARY SOURCE
     *
     * The old algorithm searched increments → features (backwards!)
     * This caused bugs when increments were renamed (0060 → 0088)
     *
     * NEW algorithm: Parse FEATURE.md → extract increment names from Implementation History
     * Fallback: metadata.json feature_id → spec.md feature_id → auto-inference
     *
     * Implementation History table format:
     * | [0082-unified-sync-orchestration](../../../../increments/0082-.../spec.md) | ✅ completed | 2025-12-01 |
     */
    private getLinkedIncrements;
    /**
     * Infer feature ID from increment number
     *
     * Examples:
     * - "0041-living-docs-test-fixes" → "FS-041"
     * - "0123-my-feature" → "FS-123"
     * - "0111E-external-issue" → "FS-111E" (external increment → external feature)
     * - "temp-experiment" → null (no number)
     *
     * CRITICAL (v0.33.0): External increments (with E suffix like 0111E-...)
     * MUST map to external features (FS-111E), not internal ones (FS-111).
     */
    private inferFeatureIdFromIncrement;
    /**
     * Get features linked to an epic
     * v5.0.0: Features live in {project}/FS-XXX/
     */
    private getLinkedFeatures;
    /**
     * Check if all features are archived
     * v5.0.0: Features live in {project}/FS-XXX/, archives in {project}/_archive/FS-XXX/
     */
    private areAllFeaturesArchived;
    /**
     * Check if feature has active projects
     * v5.0.0: Features live in {project}/FS-XXX/
     */
    private hasActiveProjects;
    /**
     * Ensure archive directories exist
     * v5.0.0: No more _features folder - archives go to {project}/_archive/
     */
    private ensureArchiveDirectories;
    /**
     * Validate and repair feature ID mismatches
     *
     * v0.30.0 CRITICAL: Enforces 1:1 mapping between increment numbers and feature IDs
     *
     * Rules:
     * 1. Feature ID MUST match increment number (0088 → FS-088)
     * 2. If FEATURE.md references a different increment, rename the feature folder
     *
     * This prevents orphan features when increments are renumbered.
     */
    private validateAndRepairFeatureIds;
    /**
     * Write archive metadata to track when/why item was archived (AC-US13-06, AC-US13-07)
     */
    private writeArchiveMetadata;
    /**
     * Restore an epic from archive
     */
    restoreEpic(epicId: string): Promise<void>;
    /**
     * Update links for restored epic
     */
    private updateLinksForRestoredEpic;
    /**
     * Restore a feature from archive
     * v5.0.0: Features live in {project}/FS-XXX/, archives in {project}/_archive/FS-XXX/
     */
    restoreFeature(featureId: string): Promise<void>;
    /**
     * Update links for restored feature
     * v5.0.0: Features live in {project}/FS-XXX/, no _features folder
     */
    private updateLinksForRestoredFeature;
    /**
     * Get archive statistics
     * v5.0.0: Features live in {project}/FS-XXX/, no _features folder
     */
    getArchiveStats(): Promise<{
        features: {
            active: number;
            archived: number;
        };
        epics: {
            active: number;
            archived: number;
        };
        projects: {
            [key: string]: {
                active: number;
                archived: number;
            };
        };
    }>;
    /**
     * Archive external living docs features (FS-XXXE folders) on demand
     *
     * CRITICAL (v0.30.12): External items (imported from ADO/JIRA/GitHub) should
     * NEVER be auto-archived during import. Archive is user-initiated only via:
     * - sw:archive --external
     * - sw:archive --external --older-than 90
     * - sw:archive --external FS-001E FS-002E
     *
     * External features are identified by the 'E' suffix (e.g., FS-001E, FS-042E).
     * They are NOT linked to increments (increments are source of truth for NEW features).
     *
     * @param options - Archive options for external features
     * @returns Archive result
     */
    archiveExternalFeatures(options?: {
        featureIds?: string[];
        olderThanDays?: number;
        keepLast?: number;
        dryRun?: boolean;
        updateLinks?: boolean;
    }): Promise<FeatureArchiveResult>;
    /**
     * Get all external features (FS-XXXE pattern)
     *
     * External features have the 'E' suffix indicating they were imported
     * from external tools (ADO, JIRA, GitHub) rather than created from increments.
     */
    private getAllExternalFeatures;
    /**
     * Scan a directory for external features (FS-*E pattern)
     */
    private scanForExternalFeatures;
    /**
     * Get the age of an external feature in days
     *
     * Reads the FEATURE.md creation date or falls back to filesystem mtime.
     */
    private getExternalFeatureAge;
    /**
     * Clean up feature folder duplicates
     * v5.0.0: Features live in {project}/FS-XXX/, archives in {project}/_archive/FS-XXX/
     *
     * Removes active folders that are ALSO in archive (keeps archive version as source of truth)
     * CRITICAL: Fixes bug where living docs sync recreates archived feature folders
     *
     * See: ULTRATHINK-ARCHIVE-REORGANIZATION-BUG.md for root cause analysis
     */
    cleanupDuplicates(): Promise<{
        cleaned: string[];
        errors: string[];
    }>;
    /**
     * Clean up project-specific folder duplicates for a feature
     * v5.0.0: Features live in {project}/FS-XXX/, archives in {project}/_archive/FS-XXX/
     *
     * BUGFIX (v0.26.12): Now respects hasActiveIncrements to decide which duplicate to remove
     *
     * @param featureId - The feature ID to clean up
     * @param result - The result object to track cleaned folders and errors
     * @param hasActiveIncrements - If true, keep active folder; if false, keep archive
     * @returns true if duplicates were found, false otherwise
     */
    private cleanupProjectSpecificDuplicates;
}
export {};
//# sourceMappingURL=feature-archiver.d.ts.map