/**
 * External Tool Resolver Service (v1.0.31+ - ADR-0211)
 *
 * Single source of truth for external tool selection.
 * Resolves which sync profile an increment should use based on:
 * 1. Explicit syncTarget in metadata (highest priority)
 * 2. Project mapping from spec.md **Project**: field
 * 3. Default profile from config (fallback)
 *
 * @module core/sync/external-tool-resolver
 */
import { SyncTarget, SyncTargetDerivation, ExternalToolValidationResult } from '../types/increment-metadata.js';
import { SyncProfile, SyncProvider } from '../types/sync-profile.js';
import { Logger } from '../../utils/logger.js';
/**
 * Project mapping configuration (from config.json)
 * Maps SpecWeave project IDs to external tool targets
 */
export interface ProjectMapping {
    github?: {
        owner: string;
        repo: string;
        profileId?: string;
    };
    jira?: {
        project: string;
        board?: string;
        profileId?: string;
    };
    ado?: {
        project: string;
        areaPath?: string;
        profileId?: string;
    };
}
export interface ProjectMappings {
    [projectId: string]: ProjectMapping;
}
/**
 * Resolution result with full context
 */
export interface ResolutionResult {
    /** Resolved sync target */
    syncTarget: SyncTarget | null;
    /** Full profile configuration (if resolved) */
    profile: SyncProfile | null;
    /** Resolution path for debugging */
    resolutionPath: string[];
    /** Any warnings during resolution */
    warnings: string[];
}
/**
 * External Tool Resolver
 *
 * Provides unified external tool selection logic.
 * Use this service instead of scattered logic throughout the codebase.
 */
export declare class ExternalToolResolver {
    private projectRoot;
    private configPath;
    private config;
    private logger;
    constructor(projectRoot: string, options?: {
        logger?: Logger;
    });
    /**
     * Load configuration from disk
     */
    private loadConfig;
    /**
     * Get sync configuration
     */
    private getSyncConfig;
    /**
     * Get workspace configuration
     */
    private getWorkspaceConfig;
    /**
     * Convert WorkspaceRepoSync to ProjectMapping-compatible format for profile matching
     */
    private convertWorkspaceSyncToMapping;
    /**
     * Resolve external tool for an increment
     *
     * Resolution priority:
     * 1. Explicit syncTarget in metadata
     * 2. Project mapping from spec.md **Project**: field
     * 3. Default profile from config
     *
     * @param incrementId - Increment ID (e.g., "0142-feature")
     * @param projectId - Optional project ID from spec.md (for priority 2)
     * @returns Resolution result with sync target and profile
     */
    resolveForIncrement(incrementId: string, projectId?: string): Promise<ResolutionResult>;
    /**
     * Resolve external tool for a specific project ID
     *
     * Looks up project in workspace.repos and resolves to a profile.
     * Falls back to workspace.rootRepo when projectId matches workspace.name.
     *
     * @param projectId - SpecWeave project ID (e.g., "frontend-app")
     * @returns Resolution result
     */
    resolveForProject(projectId: string): Promise<ResolutionResult>;
    /**
     * Resolve for a specific provider (e.g., "get me the GitHub profile")
     *
     * @param provider - Provider type
     * @param projectId - Optional project ID for project-specific profile
     * @returns Resolution result
     */
    resolveForProvider(provider: SyncProvider, projectId?: string): Promise<ResolutionResult>;
    /**
     * Validate external tool configuration for an increment
     *
     * Call this at increment start to fail fast if config is missing.
     *
     * @param incrementId - Increment ID
     * @param projectId - Project ID from spec.md
     * @returns Validation result
     */
    validateIncrementConfig(incrementId: string, projectId?: string): Promise<ExternalToolValidationResult>;
    /**
     * Validate profile configuration completeness
     */
    private validateProfileConfig;
    /**
     * Check if authentication is configured for a provider
     */
    private checkAuthentication;
    /**
     * Load increment metadata
     */
    private loadIncrementMetadata;
    /**
     * Get profile by ID
     */
    private getProfileById;
    /**
     * Find profile matching a project mapping
     */
    private findProfileByMapping;
    /**
     * Create a sync target for saving to metadata
     *
     * @param profileId - Profile ID
     * @param provider - Provider type
     * @param derivedFrom - How it was determined
     * @param sourceProjectId - Optional source project
     * @returns SyncTarget object
     */
    static createSyncTarget(profileId: string, provider: SyncProvider, derivedFrom: SyncTargetDerivation, sourceProjectId?: string): SyncTarget;
    /**
     * Check if any external tool is configured
     */
    hasExternalToolConfigured(): Promise<boolean>;
    /**
     * Get all configured providers
     */
    getConfiguredProviders(): Promise<SyncProvider[]>;
    /**
     * Get summary of external tool configuration
     */
    getConfigSummary(): Promise<{
        hasConfig: boolean;
        providers: SyncProvider[];
        profileCount: number;
        defaultProfile?: string;
        projectMappingCount: number;
    }>;
}
/**
 * Factory function for creating ExternalToolResolver
 */
export declare function createExternalToolResolver(projectRoot: string, logger?: Logger): ExternalToolResolver;
//# sourceMappingURL=external-tool-resolver.d.ts.map