/**
 * External Issue Auto-Creator
 *
 * Automatically creates external issues (GitHub/JIRA/ADO) for increments
 * when they don't have linked issues.
 *
 * TRIGGER POINTS:
 * 1. After increment creation (post-increment-planning hook)
 * 2. During sync-progress if issue is missing
 * 3. On status change (active → completed)
 *
 * SAFETY FEATURES:
 * - 3-layer idempotency (frontmatter → metadata → API)
 * - Duplicate detection before creation
 * - Rate limiting (circuit breaker)
 * - Non-blocking (failures don't crash the workflow)
 *
 * @see ADR-0139 (Unified Post-Increment GitHub Sync)
 */
import { Logger } from '../utils/logger.js';
export interface ExternalIssueAutoCreatorOptions {
    projectRoot: string;
    logger?: Logger;
}
export interface AutoCreateResult {
    success: boolean;
    provider: 'github' | 'jira' | 'ado' | 'none';
    issueNumber?: number | string;
    issueUrl?: string;
    error?: string;
    skipped?: boolean;
    skipReason?: string;
}
export interface IncrementInfo {
    id: string;
    featureId: string;
    title: string;
    status: string;
    origin?: 'external' | 'internal';
    userStories: Array<{
        id: string;
        title: string;
        description?: string;
        project?: string;
    }>;
}
/**
 * Auto-creates external issues for increments
 *
 * Usage:
 * ```typescript
 * const creator = new ExternalIssueAutoCreator({ projectRoot: process.cwd() });
 * const result = await creator.createForIncrement('0001-feature');
 * ```
 */
export declare class ExternalIssueAutoCreator {
    private projectRoot;
    private logger;
    private configManager;
    private _defaultBranch;
    constructor(options: ExternalIssueAutoCreatorOptions);
    /**
     * Resolve increment directory from a short or full ID.
     * Handles "0421" → "0421-umbrella-docs-update" prefix matching.
     */
    private resolveIncrementDir;
    private detectDefaultBranch;
    private getDefaultBranch;
    /**
     * Create external issues for an increment (if configured and not already created)
     *
     * This method:
     * 1. Checks if auto-create is enabled in config
     * 2. Detects which provider to use (GitHub/JIRA/ADO)
     * 3. Checks if issues already exist (3-layer idempotency)
     * 4. Creates issues if missing
     * 5. Updates metadata with issue links
     */
    createForIncrement(incrementId: string, targetProvider?: 'github' | 'jira' | 'ado'): Promise<AutoCreateResult>;
    /**
     * Check if auto-create is enabled in config
     *
     * Checks (in order):
     * 1. sync.autoCreateOnIncrement (new, explicit)
     * 2. sync.autoSync (legacy)
     * 3. sync.settings.canUpsertInternalItems (legacy)
     */
    private isAutoCreateEnabled;
    /**
     * Detect which provider to use for external sync
     *
     * Priority:
     * 1. GitHub (if sync.github.enabled = true)
     * 2. JIRA (if sync.jira.enabled = true)
     * 3. ADO (if sync.ado.enabled = true)
     * 4. GitHub (if issueTracker.provider = 'github')
     * 5. JIRA (if issueTracker.provider = 'jira')
     * 6. ADO (if issueTracker.provider = 'ado')
     */
    private detectProvider;
    /**
     * Load increment information from spec.md and metadata.json
     */
    private loadIncrementInfo;
    /**
     * Parse user stories from spec.md body
     */
    private parseUserStories;
    /**
     * Format issue title for external tools.
     * Internal increments: [FS-XXX][US-YYY] Title
     * External imports: plain title (preserve original)
     */
    private formatIssueTitle;
    private formatEpicTitle;
    /**
     * Convert ADO API URL to browser-friendly URL.
     * API: https://dev.azure.com/org/project/_apis/wit/workItems/39
     * Browser: https://dev.azure.com/org/project/_workitems/edit/39
     */
    private toAdoBrowserUrl;
    /**
     * Check if increment already has external issue linked
     *
     * Checks:
     * 1. metadata.json github/jira/ado fields
     * 2. spec.md frontmatter external links
     */
    private checkExistingIssue;
    /**
     * Create GitHub issues for the increment
     */
    private createGitHubIssues;
    /**
     * Create JIRA issues for the increment
     */
    private createJiraIssues;
    /**
     * Create Azure DevOps work items for the increment
     */
    private createAdoIssues;
    /**
     * Detect GitHub repo from config
     */
    private detectGitHubRepo;
    /**
     * Build GitHub issue body for a user story
     */
    private buildGitHubIssueBody;
    /**
     * Build GitHub issue body for feature-level issue
     */
    private buildFeatureLevelIssueBody;
    /**
     * Build JIRA Epic description
     */
    private buildJiraEpicDescription;
    /**
     * Build ADO work item description
     */
    private buildAdoDescription;
    /**
     * Update metadata.json with GitHub issue
     */
    private updateMetadataWithGitHubIssue;
    /**
     * Update metadata.json with JIRA issue
     */
    private updateMetadataWithJiraIssue;
    /**
     * Update metadata.json with ADO work item
     */
    private updateMetadataWithAdoWorkItem;
}
/**
 * Convenience function to auto-create issues for an increment
 *
 * @param targetProvider - Optional: force creation for a specific provider.
 *   Without this, detectProvider() picks the highest-priority enabled provider.
 *   Use this when you know which provider you want (e.g., JIRA section of sync-progress).
 */
export declare function autoCreateExternalIssue(projectRoot: string, incrementId: string, logger?: Logger, targetProvider?: 'github' | 'jira' | 'ado'): Promise<AutoCreateResult>;
//# sourceMappingURL=external-issue-auto-creator.d.ts.map