/**
 * User Story Completion Detector
 *
 * Detects when user stories become fully complete (all ACs satisfied)
 * and triggers living docs + external tool sync.
 *
 * CRITICAL: This module enables automatic US-level sync cascade:
 * Task completion → AC marking → US detection → Living docs sync → External tools sync
 *
 * Architecture:
 * - Parses spec.md to extract all ACs
 * - Groups ACs by user story (AC-US1-01 → US-001)
 * - Detects which USs have ALL ACs marked [x]
 * - Tracks completion state to prevent re-sync
 *
 * Integration:
 * - Called by consolidated-sync.js after AC sync
 * - Returns newly completed USs (state transition detection)
 * - Living docs sync handles external tool updates
 */
import { Logger } from '../utils/logger.js';
/**
 * User Story completion data
 */
export interface UserStoryCompletion {
    usId: string;
    title: string;
    totalACs: number;
    completedACs: number;
    percentage: number;
    isComplete: boolean;
    status: string;
    acIds: string[];
    completedAcIds: string[];
    wasAlreadyComplete: boolean;
}
/**
 * User Story Completion Detector
 *
 * Detects when user stories transition from incomplete to complete
 * and triggers sync cascade.
 */
export declare class USCompletionDetector {
    private projectRoot;
    private logger;
    constructor(projectRoot: string, options?: {
        logger?: Logger;
    });
    /**
     * Detect user story completions for an increment
     *
     * @param incrementId - Increment ID (e.g., "0053-safe-feature-deletion")
     * @returns Array of user story completion data
     */
    detectCompletions(incrementId: string): Promise<UserStoryCompletion[]>;
    /**
     * Get only NEWLY completed user stories (state transition detection)
     *
     * @param incrementId - Increment ID
     * @returns Array of newly completed user stories (excludes already-complete USs)
     */
    getNewlyCompletedUSs(incrementId: string): Promise<UserStoryCompletion[]>;
    /**
     * Parse spec.md to extract all acceptance criteria
     *
     * @param incrementId - Increment ID
     * @returns Array of AC data
     */
    private parseSpecACs;
    /**
     * Group ACs by user story
     *
     * @param acs - Array of AC data
     * @returns Map of US-ID to array of ACs
     */
    private groupACsByUserStory;
    /**
     * Calculate completion status for each user story
     *
     * @param usGroups - Map of US-ID to array of ACs
     * @returns Array of user story completion data
     */
    private calculateCompletions;
    /**
     * Calculate user story status based on AC completion
     *
     * Status mapping (Universal 5-level hierarchy - Level 2):
     * - 0% complete → "not_started"
     * - 1-99% complete → "in_progress"
     * - 100% complete → "completed"
     *
     * @param percentage - Completion percentage (0-100)
     * @param completedACs - Number of completed ACs
     * @returns User story status
     */
    private calculateUSStatus;
    /**
     * Extract user story title from ACs or generate default
     *
     * @param usId - User story ID
     * @param acs - Array of ACs for this user story
     * @returns User story title
     */
    private extractUSTitle;
    /**
     * Load previous completion state from disk
     *
     * @param incrementId - Increment ID
     * @returns Set of previously completed US IDs
     */
    private loadCompletionState;
    /**
     * Save completion state to disk
     *
     * @param incrementId - Increment ID
     * @param completions - Array of user story completion data
     */
    saveCompletionState(incrementId: string, completions: UserStoryCompletion[]): Promise<void>;
    /**
     * Check if file exists
     */
    private fileExists;
}
//# sourceMappingURL=us-completion-detector.d.ts.map