import type { WriteResult } from "../utils/fs.js";
import type { ContextIndexState } from "./context-index.js";
import type { RepoContextOperatorView, RepoContextTreeState } from "./context-tree.js";
export interface RepoMapState {
    artifactType: "kiwi-control/repo-map";
    version: 1;
    generatedAt: string;
    projectType: string;
    summary: string;
    languages: string[];
    entryPoints: string[];
    keyModules: Array<{
        id: string;
        fileCount: number;
        entryPoints: string[];
    }>;
    topReverseDependencyHubs: RepoContextTreeState["topReverseDependencyHubs"];
    filesDiscovered: number;
    importableFiles: number;
    indexedFiles: number;
}
export interface SymbolIndexEntry {
    symbol: string;
    kind: "export" | "local-function";
    file: string;
    moduleGroup: string;
}
export interface SymbolIndexState {
    artifactType: "kiwi-control/symbol-index";
    version: 1;
    generatedAt: string;
    totalFiles: number;
    totalSymbols: number;
    files: Array<{
        file: string;
        moduleGroup: string;
        exports: string[];
        localFunctions: string[];
    }>;
    symbols: SymbolIndexEntry[];
}
export interface DependencyGraphState {
    artifactType: "kiwi-control/dependency-graph";
    version: 1;
    generatedAt: string;
    nodes: Array<{
        file: string;
        moduleGroup: string;
        exports: number;
        localFunctions: number;
        imports: number;
        importedBy: number;
    }>;
    edges: Array<{
        from: string;
        to: string;
        kind: "import" | "call";
    }>;
    fileRelationships: Array<{
        file: string;
        moduleGroup: string;
        imports: string[];
        importedBy: string[];
        callTargets: string[];
        relationships: string[];
    }>;
}
export interface ImpactMapState {
    artifactType: "kiwi-control/impact-map";
    version: 1;
    generatedAt: string;
    changedFiles: string[];
    forwardDependencies: string[];
    reverseDependencies: string[];
    impactedFiles: string[];
    dependencyDistances: Record<string, number>;
    dependencyChains: Record<string, string[]>;
    impactedModules: string[];
    rankedFiles: Array<{
        file: string;
        moduleGroup: string;
        score: number;
        reasons: string[];
        changed: boolean;
        entryPoint: boolean;
        importedByCount: number;
        dependencyDistance: number | null;
    }>;
    rankedModules: Array<{
        id: string;
        score: number;
        changedFiles: string[];
        impactedFiles: string[];
        entryPoints: string[];
        topFiles: string[];
    }>;
    clusters: Array<{
        id: string;
        changedFiles: string[];
        impactedFiles: string[];
        score: number;
        topFiles: string[];
    }>;
}
export interface CompactContextPack {
    artifactType: "kiwi-control/compact-context-pack";
    version: 1;
    generatedAt: string;
    mode: "overview" | "focus" | "changed";
    task: string | null;
    focusFiles: string[];
    missingFocusFiles: string[];
    summary: string;
    files: Array<{
        file: string;
        moduleGroup: string;
        score: number;
        reasons: string[];
        matchedTerms: string[];
        matchedSymbols: string[];
        exports: string[];
        localFunctions: string[];
        imports: string[];
        importedBy: string[];
        callTargets: string[];
    }>;
    dependencyChains: Array<{
        file: string;
        chain: string[];
    }>;
    modules: Array<{
        id: string;
        fileCount: number;
        entryPoints: string[];
        score: number;
        topFiles: string[];
    }>;
    clusters: Array<{
        id: string;
        score: number;
        changedFiles: string[];
        impactedFiles: string[];
        topFiles: string[];
    }>;
}
export interface RepoIntelligenceArtifacts {
    repoMap: RepoMapState;
    symbolIndex: SymbolIndexState;
    dependencyGraph: DependencyGraphState;
    impactMap: ImpactMapState;
    decisionGraph: DecisionGraphState;
    historyGraph: HistoryGraphState;
    reviewGraph: ReviewGraphState;
}
export interface LoadedRepoIntelligenceArtifacts extends RepoIntelligenceArtifacts {
    compactContextPack: CompactContextPack | null;
    reviewContextPack: ReviewContextPack | null;
    agentPack: AgentPackState | null;
    taskPack: TaskPackState | null;
}
export interface RepoIntelligenceSummary {
    available: boolean;
    generatedAt: string | null;
    summary: string | null;
    repoMapPath: string | null;
    symbolIndexPath: string | null;
    dependencyGraphPath: string | null;
    impactMapPath: string | null;
    entryPoints: string[];
    keyModules: Array<{
        id: string;
        fileCount: number;
        entryPoints: string[];
    }>;
    topReverseDependencyHubs: RepoMapState["topReverseDependencyHubs"];
    changedFiles: string[];
    impactedFiles: string[];
    decisionGraphPath: string | null;
    historyGraphPath: string | null;
    reviewGraphPath: string | null;
    importantDecisions: number;
    hotspotFiles: number;
    reviewRiskTargets: number;
    agentPackAvailable: boolean;
    agentPackPath: string | null;
    agentPackSummary: string | null;
    taskPackAvailable: boolean;
    taskPackPath: string | null;
    taskPackTask: string | null;
    taskPackSummary: string | null;
    taskPackFiles: number;
    compactContextPackAvailable: boolean;
    compactContextPackPath: string | null;
    compactContextPackMode: CompactContextPack["mode"] | null;
    compactContextPackTask: string | null;
    compactContextPackSummary: string | null;
    compactContextPackFiles: number;
    reviewContextPackAvailable: boolean;
    reviewContextPackPath: string | null;
    reviewContextPackTask: string | null;
    reviewContextPackSummary: string | null;
    reviewPackAvailable: boolean;
    reviewPackPath: string | null;
    reviewPackSummary: string | null;
}
export interface DecisionGraphState {
    artifactType: "kiwi-control/decision-graph";
    version: 1;
    generatedAt: string;
    currentTask: string | null;
    nodes: Array<{
        id: string;
        kind: "phase" | "checkpoint" | "handoff" | "reconcile" | "focus" | "task-packet-set" | "execution-event" | "runtime-lifecycle" | "open-risk" | "task" | "file" | "module";
        label: string;
        summary: string;
        timestamp: string | null;
        status: string | null;
        task: string | null;
    }>;
    edges: Array<{
        from: string;
        to: string;
        kind: "continues" | "references-task" | "touches-file" | "touches-module" | "points-to-artifact";
    }>;
    importantDecisions: Array<{
        id: string;
        kind: string;
        label: string;
        summary: string;
        status: string | null;
        task: string | null;
        relatedFiles: string[];
        relatedModules: string[];
        nextCommand: string | null;
    }>;
}
export interface HistoryGraphState {
    artifactType: "kiwi-control/history-graph";
    version: 1;
    generatedAt: string;
    commitWindow: number;
    gitHistoryAvailable: boolean;
    commitsAnalyzed: number;
    recentCommits: Array<{
        sha: string;
        authoredAt: string;
        subject: string;
        files: string[];
        modules: string[];
    }>;
    hotspotFiles: Array<{
        file: string;
        moduleGroup: string;
        touches: number;
        commits: number;
        lastTouchedAt: string | null;
    }>;
    hotspotModules: Array<{
        id: string;
        touches: number;
        commits: number;
        files: string[];
        lastTouchedAt: string | null;
    }>;
    repeatedTouchModules: Array<{
        id: string;
        touches: number;
        commits: number;
        files: string[];
    }>;
    changeClusters: Array<{
        id: string;
        commits: number;
        touches: number;
        files: string[];
        modules: string[];
    }>;
}
export interface ReviewGraphState {
    artifactType: "kiwi-control/review-graph";
    version: 1;
    generatedAt: string;
    status: "clear" | "attention";
    globalSignals: Array<{
        signal: string;
        detail: string;
        severity: "info" | "warn" | "high";
    }>;
    fileRisks: Array<{
        file: string;
        moduleGroup: string;
        score: number;
        reasons: string[];
        touches: number;
        failures: number;
        retries: number;
        entryPoint: boolean;
        reverseDependencyHub: boolean;
    }>;
    moduleRisks: Array<{
        id: string;
        score: number;
        reasons: string[];
        touches: number;
        failures: number;
        entryPoints: string[];
        files: string[];
    }>;
    reviewAttention: Array<{
        kind: "file" | "module" | "decision";
        target: string;
        score: number;
        reasons: string[];
    }>;
}
export interface ReviewContextPack {
    artifactType: "kiwi-control/review-context-pack";
    version: 1;
    generatedAt: string;
    summary: string;
    currentTask: string | null;
    readFirst: string[];
    decisions: DecisionGraphState["importantDecisions"];
    hotspots: Array<{
        kind: "file" | "module";
        target: string;
        touches: number;
        commits: number;
    }>;
    reviewAttention: ReviewGraphState["reviewAttention"];
    globalSignals: ReviewGraphState["globalSignals"];
}
export interface AgentPackState {
    artifactType: "kiwi-control/agent-pack";
    version: 1;
    generatedAt: string;
    summary: string;
    readFirst: string[];
    sourceOfTruthNote: string;
    repo: {
        summary: string;
        entryPoints: string[];
        keyModules: RepoMapState["keyModules"];
        topReverseDependencyHubs: RepoMapState["topReverseDependencyHubs"];
    };
    decisions: DecisionGraphState["importantDecisions"];
    hotspots: ReviewContextPack["hotspots"];
    reviewAttention: ReviewGraphState["reviewAttention"];
    packPointers: {
        readySubstrate: string;
        repoMap: string;
        taskPack: string | null;
        reviewContextPack: string;
        compactContextPack: string | null;
        decisionGraph: string;
        historyGraph: string;
        reviewGraph: string;
    };
}
export interface TaskPackState {
    artifactType: "kiwi-control/task-pack";
    version: 1;
    generatedAt: string;
    task: string | null;
    summary: string;
    readFirst: string[];
    sourceOfTruthNote: string;
    focus: {
        mode: CompactContextPack["mode"];
        focusFiles: string[];
        missingFocusFiles: string[];
        files: CompactContextPack["files"];
        modules: CompactContextPack["modules"];
        dependencyChains: CompactContextPack["dependencyChains"];
        clusters: CompactContextPack["clusters"];
    };
    decisions: DecisionGraphState["importantDecisions"];
    reviewAttention: ReviewGraphState["reviewAttention"];
}
export declare function buildRepoIntelligenceArtifacts(options: {
    targetRoot: string;
    tree: RepoContextTreeState;
    view: RepoContextOperatorView;
    index: ContextIndexState;
}): Promise<RepoIntelligenceArtifacts>;
export declare function persistRepoIntelligenceArtifacts(targetRoot: string, artifacts: RepoIntelligenceArtifacts): Promise<WriteResult[]>;
export declare function persistRepoIntelligenceIndexArtifacts(targetRoot: string, index: ContextIndexState): Promise<WriteResult[]>;
export declare function loadRepoIntelligenceArtifacts(targetRoot: string): Promise<LoadedRepoIntelligenceArtifacts | null>;
export declare function loadRepoIntelligenceSummary(targetRoot: string): Promise<RepoIntelligenceSummary>;
export declare function buildCompactContextPack(options: {
    index: ContextIndexState;
    repoMap: RepoMapState;
    impactMap?: ImpactMapState;
    focusTargets?: string[];
    mode?: "overview" | "focus" | "changed";
    task?: string;
    limit?: number;
}): CompactContextPack;
export declare function buildReviewContextPack(options: {
    targetRoot: string;
    decisionGraph: DecisionGraphState;
    historyGraph: HistoryGraphState;
    reviewGraph: ReviewGraphState;
    task?: string | null;
}): ReviewContextPack;
export declare function buildAgentPack(options: {
    repoMap: RepoMapState;
    decisionGraph: DecisionGraphState;
    historyGraph: HistoryGraphState;
    reviewGraph: ReviewGraphState;
    compactContextPack?: CompactContextPack | null;
    reviewContextPack?: ReviewContextPack | null;
}): AgentPackState;
export declare function buildTaskPack(options: {
    compactContextPack: CompactContextPack;
    decisionGraph: DecisionGraphState;
    reviewGraph: ReviewGraphState;
    task?: string | null;
}): TaskPackState;
export declare function persistCompactContextPack(targetRoot: string, compactContextPack: CompactContextPack): Promise<WriteResult>;
export declare function persistReviewContextPack(targetRoot: string, reviewContextPack: ReviewContextPack): Promise<WriteResult>;
export declare function persistAgentPack(targetRoot: string, agentPack: AgentPackState): Promise<WriteResult>;
export declare function persistTaskPack(targetRoot: string, taskPack: TaskPackState): Promise<WriteResult>;
//# sourceMappingURL=repo-intelligence.d.ts.map