/**
 * SpecSyncManager - Automatic synchronization of plan.md and tasks.md when spec.md changes
 *
 * Purpose: Maintain consistency in spec-driven development by automatically regenerating
 * downstream artifacts (plan.md, tasks.md) when the source of truth (spec.md) is modified.
 *
 * This enforces the SpecWeave principle: spec.md is the source of truth, all other files derive from it.
 *
 * @module spec-sync-manager
 */
import { Logger } from '../../utils/logger.js';
export interface SpecSyncResult {
    synced: boolean;
    reason: string;
    planRegenerated: boolean;
    tasksRegenerated: boolean;
    changes: string[];
    error?: string;
    regenerationContext?: RegenerationContext;
}
export interface RegenerationContext {
    incrementId: string;
    specPath: string;
    planPath: string;
    tasksPath: string;
    specContent: string;
    oldPlanContent?: string;
    oldTasksContent?: string;
    manualAnnotations: ManualAnnotation[];
}
export interface ManualAnnotation {
    type: 'comment' | 'note' | 'todo';
    line: number;
    content: string;
    context: string;
}
export interface TaskCompletion {
    taskId: string;
    completed: boolean;
    subtasks: SubtaskCompletion[];
}
export interface SubtaskCompletion {
    text: string;
    completed: boolean;
    line: number;
}
export interface SpecChangeDetectionResult {
    specChanged: boolean;
    specModTime: number;
    planModTime: number;
    tasksModTime: number;
    incrementId: string;
    reason: string;
}
export declare class SpecSyncManager {
    private readonly projectRoot;
    private readonly incrementsDir;
    private readonly logger;
    constructor(projectRoot: string, options?: {
        logger?: Logger;
    });
    /**
     * Detect if spec.md was modified after plan.md or tasks.md
     *
     * @param incrementId - Increment to check (e.g., "0039-ultra-smart-next-command")
     * @returns Detection result with modification times and reasoning
     */
    detectSpecChange(incrementId: string): SpecChangeDetectionResult;
    /**
     * Get the currently active increment ID
     *
     * @returns Active increment ID or null if none active
     */
    getActiveIncrementId(): string | null;
    /**
     * Extract manual annotations from markdown content
     *
     * Detects HTML comments with keywords: MANUAL NOTE, TODO, NOTE
     *
     * @param content - Markdown content to analyze
     * @param filePath - File path for context
     * @returns Array of manual annotations
     */
    extractManualAnnotations(content: string, filePath: string): ManualAnnotation[];
    /**
     * Get surrounding context for a line (3 lines before and after)
     *
     * @param lines - All file lines
     * @param lineIndex - Index of target line
     * @returns Context string
     */
    private getLineContext;
    /**
     * Prepare regeneration context for plan.md and tasks.md
     *
     * @param incrementId - Increment ID
     * @returns Regeneration context with all necessary information
     */
    prepareRegenerationContext(incrementId: string): RegenerationContext | null;
    /**
     * Generate diff between old and new plan.md
     *
     * @param oldContent - Original plan.md content
     * @param newContent - Regenerated plan.md content
     * @returns Diff summary with line changes
     */
    generatePlanDiff(oldContent: string, newContent: string): string[];
    /**
     * Parse task completion status from tasks.md
     *
     * Extracts which tasks and subtasks are completed
     *
     * @param tasksContent - tasks.md content
     * @returns Array of task completion records
     */
    parseTaskCompletion(tasksContent: string): TaskCompletion[];
    /**
     * Generate diff between old and new tasks.md
     *
     * @param oldContent - Original tasks.md content
     * @param newContent - Regenerated tasks.md content
     * @returns Diff summary with task changes
     */
    generateTasksDiff(oldContent: string, newContent: string): string[];
    /**
     * Apply completion status from old tasks to new tasks
     *
     * Matches tasks by ID and text similarity, preserves completed checkboxes
     *
     * @param newTasksContent - Regenerated tasks.md content
     * @param oldCompletions - Completion status from old tasks.md
     * @returns Updated tasks.md content with completion status preserved
     */
    applyTaskCompletion(newTasksContent: string, oldCompletions: TaskCompletion[]): string;
    /**
     * Check if two text strings are similar (for matching subtasks)
     *
     * Uses simple comparison: exact match or contains
     *
     * @param text1 - First text
     * @param text2 - Second text
     * @returns True if texts are similar
     */
    private isTextSimilar;
    /**
     * Synchronize plan.md and tasks.md based on spec.md changes
     *
     * This method:
     * 1. Detects if spec.md changed
     * 2. Prepares regeneration context
     * 3. Returns context for Claude Code to invoke Architect Agent
     * 4. Preserves manual annotations
     * 5. Logs changes to metadata
     *
     * @param incrementId - Increment to sync
     * @param skipSync - Skip sync even if spec changed (user override)
     * @returns Sync result with regeneration context
     */
    syncIncrement(incrementId: string, skipSync?: boolean): Promise<SpecSyncResult>;
    /**
     * Log sync event to increment metadata
     *
     * @param incrementId - Increment ID
     * @param detection - Detection result
     */
    private logSyncEvent;
    /**
     * Check if spec sync is needed for the active increment
     *
     * @returns Detection result or null if no active increment
     */
    checkActiveIncrement(): SpecChangeDetectionResult | null;
    /**
     * Get human-readable sync status message
     *
     * @param detection - Detection result
     * @returns Formatted message for user
     */
    formatSyncMessage(detection: SpecChangeDetectionResult): string;
}
//# sourceMappingURL=spec-sync-manager.d.ts.map