/**
 * Global Command Deduplication System
 *
 * Prevents ANY command/tool from being invoked twice within a configurable time window.
 * Tracks all SlashCommand, Write, Edit, and other tool invocations.
 *
 * Architecture:
 * - File-based cache: `.specweave/state/command-invocations.json`
 * - Hash-based deduplication: command + args → unique fingerprint
 * - Time-windowed checks: Configurable window (default: 1000ms)
 * - Automatic cleanup: Removes old entries to prevent bloat
 *
 * Usage:
 * ```typescript
 * import { CommandDeduplicator } from './command-deduplicator.js';
 *
 * const dedup = new CommandDeduplicator();
 * const isDuplicate = await dedup.checkDuplicate('sw:do', ['0031']);
 *
 * if (isDuplicate) {
 *   console.log('⚠️  Duplicate invocation blocked!');
 *   return;
 * }
 *
 * await dedup.recordInvocation('sw:do', ['0031']);
 * // ... execute command
 * ```
 *
 * @module core/deduplication
 */
/**
 * Invocation record stored in cache
 */
export interface InvocationRecord {
    /** Unique fingerprint of command + args */
    fingerprint: string;
    /** Command name (e.g., 'sw:do') */
    command: string;
    /** Command arguments */
    args: string[];
    /** Timestamp when invoked (ms since epoch) */
    timestamp: number;
    /** Human-readable timestamp */
    date: string;
}
/**
 * Cache structure
 */
export interface InvocationCache {
    /** List of invocation records */
    invocations: InvocationRecord[];
    /** Last cleanup timestamp */
    lastCleanup: number;
    /** Total invocations tracked */
    totalInvocations: number;
    /** Total duplicates blocked */
    totalDuplicatesBlocked: number;
}
/**
 * Configuration for deduplication
 */
export interface DeduplicationConfig {
    /** Time window in milliseconds to check for duplicates (default: 1000ms) */
    windowMs?: number;
    /** Path to cache file (default: .specweave/state/command-invocations.json) */
    cachePath?: string;
    /** Maximum cache entries before cleanup (default: 1000) */
    maxCacheSize?: number;
    /** Enable debug logging (default: false) */
    debug?: boolean;
    /** Cleanup interval in milliseconds (default: 60000ms = 1 minute) */
    cleanupIntervalMs?: number;
}
/**
 * Global command deduplication system
 */
export declare class CommandDeduplicator {
    private projectRoot;
    private config;
    private cache;
    private lastCleanupCheck;
    /**
     * Create new deduplicator instance
     *
     * @param config - Configuration options
     * @param projectRoot - Project root directory (default: process.cwd())
     */
    constructor(config?: DeduplicationConfig, projectRoot?: string);
    /**
     * Check if command invocation is a duplicate
     *
     * @param command - Command name (e.g., 'sw:do')
     * @param args - Command arguments
     * @returns true if duplicate detected, false otherwise
     */
    checkDuplicate(command: string, args?: string[]): Promise<boolean>;
    /**
     * Record command invocation
     *
     * @param command - Command name
     * @param args - Command arguments
     */
    recordInvocation(command: string, args?: string[]): Promise<void>;
    /**
     * Create unique fingerprint for command + args
     *
     * @param command - Command name
     * @param args - Command arguments
     * @returns SHA256 hash of command + args
     */
    private createFingerprint;
    /**
     * Load cache from disk
     *
     * @returns Invocation cache
     */
    private loadCache;
    /**
     * Save cache to disk
     */
    private saveCache;
    /**
     * Clean up old invocation records
     *
     * Removes records older than 10x the deduplication window to prevent cache bloat.
     */
    private cleanup;
    /**
     * Get statistics about deduplication
     *
     * @returns Statistics object
     */
    getStats(): {
        totalInvocations: number;
        totalDuplicatesBlocked: number;
        currentCacheSize: number;
        lastCleanup: string;
    };
    /**
     * Clear all cached invocations (useful for testing)
     */
    clear(): Promise<void>;
}
/**
 * Get global deduplicator instance
 *
 * @param config - Configuration (only used on first call)
 * @returns Global deduplicator instance
 */
export declare function getGlobalDeduplicator(config?: DeduplicationConfig): CommandDeduplicator;
/**
 * Convenience function: Check if command is duplicate
 *
 * @param command - Command name
 * @param args - Command arguments
 * @returns true if duplicate, false otherwise
 */
export declare function isDuplicate(command: string, args?: string[]): Promise<boolean>;
/**
 * Convenience function: Record command invocation
 *
 * @param command - Command name
 * @param args - Command arguments
 */
export declare function recordCommand(command: string, args?: string[]): Promise<void>;
//# sourceMappingURL=command-deduplicator.d.ts.map