/** * PRSense - Easy-to-use API wrapper * * Simplified interface for duplicate PR detection */ import type { StorageBackend } from './storage/interface.js'; import type { Embedder } from './embeddingPipeline.js'; /** * Configuration options for PRSense */ export interface PRSenseConfig { embedder: Embedder; duplicateThreshold?: number; possibleThreshold?: number; weights?: [number, number, number]; bloomFilterSize?: number; maxCandidates?: number; /** Enable embedding cache for faster repeat checks */ enableCache?: boolean; /** Maximum cache size (number of embeddings) */ cacheSize?: number; /** Repository ID for cross-repo detection */ repoId?: string; } /** * Input for duplicate check */ export interface PRInput { prId: number; title: string; description: string; files: string[]; diff?: string; linesAdded?: number; linesRemoved?: number; author?: string; } /** * Detection result */ export type DetectionResult = { type: 'DUPLICATE'; originalPr: number; confidence: number; violations?: import('./rules.js').RuleViolation[]; } | { type: 'POSSIBLE'; originalPr: number; confidence: number; violations?: import('./rules.js').RuleViolation[]; } | { type: 'UNIQUE'; confidence: number; violations?: import('./rules.js').RuleViolation[]; }; /** * Score breakdown showing contribution of each signal */ export interface ScoreBreakdown { textSimilarity: number; diffSimilarity: number; fileSimilarity: number; textContribution: number; diffContribution: number; fileContribution: number; finalScore: number; weights: [number, number, number]; } /** * Detailed detection result with score breakdown */ export type DetailedDetectionResult = { type: 'DUPLICATE'; originalPr: number; confidence: number; breakdown: ScoreBreakdown; violations?: import('./rules.js').RuleViolation[]; } | { type: 'POSSIBLE'; originalPr: number; confidence: number; breakdown: ScoreBreakdown; violations?: import('./rules.js').RuleViolation[]; } | { type: 'UNIQUE'; confidence: number; breakdown?: ScoreBreakdown; violations?: import('./rules.js').RuleViolation[]; }; /** * Options for check methods */ export interface CheckOptions { /** Skip indexing this PR (dry-run mode) */ dryRun?: boolean; /** Return detailed score breakdown */ detailed?: boolean; } /** * Batch check result */ export interface BatchCheckResult { prId: number; result: DetectionResult; processingTimeMs: number; } /** * Main PRSense detector class * * Usage: * ```typescript * const detector = new PRSenseDetector({ embedder: myEmbedder }) * const result = await detector.check(prData) * ``` */ export declare class PRSenseDetector { private bloom; private graph; private pipeline; private embeddings; private metadata; private storage?; private config; private cache?; rulesEngine?: import('./rules.js').RulesEngine; private duplicateThreshold; private possibleThreshold; private weights; private maxCandidates; constructor(config: PRSenseConfig & { storage?: StorageBackend; }); /** * Initialize the detector, loading any persisted state from storage. * Must be called after construction if using persistent storage. * * ```typescript * const detector = new PRSenseDetector({ embedder, storage }) * await detector.init() * ``` */ init(): Promise; /** * Compute a content hash for the PR */ private computeContentHash; /** * Load state from persistent storage */ private loadFromStorage; /** * Check if a PR is a duplicate */ check(pr: PRInput, options?: CheckOptions): Promise; /** * Check with detailed score breakdown (Feature 2: Explainability) */ checkDetailed(pr: PRInput, options?: CheckOptions): Promise; /** * Batch check multiple PRs at once (Feature 3: Batch API) */ checkMany(prs: PRInput[], options?: CheckOptions): Promise; /** * Update scoring weights at runtime (Feature 5: Configurable Weights) */ setWeights(weights: [number, number, number]): void; /** * Get current scoring weights */ getWeights(): [number, number, number]; /** * Internal check that returns detailed result */ private checkInternal; /** * Get all duplicates of a PR */ getDuplicates(prId: number): number[]; /** * Get original PR in duplicate chain */ getOriginal(prId: number): number; /** * Get statistics */ getStats(): { totalPRs: number; bloomFilterSize: number; duplicatePairs: number; storage: string; }; private addToIndex; /** * Search for PRs using natural language query */ search(query: string, limit?: number): Promise; private findCandidates; private countDuplicatePairs; /** * Export detector state for persistence */ exportState(): { records: any[]; bloom: string; }; /** * Import detector state from persistence */ importState(data: { records: any[]; bloom: string; }): void; } //# sourceMappingURL=prsense.d.ts.map