/** * @fileoverview Context Scoring System for ranking skill suggestion relevance * @module @skillsmith/core/triggers/ContextScorer * @see Phase 4: Trigger System Architecture * * Scores the relevance of skill suggestions based on: * - Number and type of triggers fired * - Confidence levels of triggers * - Recency of trigger events * - User feedback history * * @example * const scorer = new ContextScorer(); * const score = scorer.scoreContext(triggers, codebaseContext); * if (score.score >= 0.6) { * // High relevance - suggest skills * } */ import type { DetectedTrigger } from './TriggerDetector.js'; import type { CodebaseContext } from '../analysis/CodebaseAnalyzer.js'; /** * Context score result */ export interface ContextScore { /** Overall relevance score (0-1) */ score: number; /** Confidence in the suggestion (0-1) */ confidence: number; /** Which triggers contributed to the score */ triggers: string[]; /** Human-readable explanation */ reason: string; /** Recommended skill categories */ recommendedCategories: string[]; } /** * Weights for different trigger types in context scoring */ export interface ContextScoringWeights { /** Weight for file pattern triggers (default: 0.4) */ fileWeight: number; /** Weight for command triggers (default: 0.3) */ commandWeight: number; /** Weight for error triggers (default: 0.2) */ errorWeight: number; /** Weight for project structure triggers (default: 0.3) */ projectWeight: number; } /** * Options for context scoring */ export interface ContextScorerOptions { /** Custom weights for trigger types */ weights?: Partial; /** Boost score for multiple triggers (default: true) */ multiTriggerBoost?: boolean; /** Boost multiplier for multiple triggers (default: 1.2) */ multiTriggerMultiplier?: number; /** Enable debug logging */ debug?: boolean; } /** * ContextScorer - Scores skill suggestion relevance * * Uses a weighted scoring algorithm to determine how relevant * skill suggestions would be based on detected triggers. */ export declare class ContextScorer { private readonly weights; private readonly multiTriggerBoost; private readonly multiTriggerMultiplier; private readonly debug; constructor(options?: ContextScorerOptions); /** * Score the context based on detected triggers * * @param triggers - Detected triggers from TriggerDetector * @param codebaseContext - Optional codebase analysis * @returns Context score with recommendations */ scoreContext(triggers: DetectedTrigger[], codebaseContext?: CodebaseContext | null): ContextScore; /** * Group triggers by type */ private groupTriggersByType; /** * Calculate score for a specific trigger type */ private calculateTypeScore; /** * Calculate confidence in the suggestion */ private calculateConfidence; /** * Extract recommended skill categories from triggers */ private extractRecommendedCategories; /** * Generate human-readable reason for the score */ private generateReason; /** * Determine if score meets threshold for suggestion * * @param score - Context score result * @returns Whether to suggest skills */ shouldSuggest(score: ContextScore): boolean; /** * Get suggestion urgency level * * @param score - Context score result * @returns Urgency level */ getUrgency(score: ContextScore): 'high' | 'medium' | 'low'; } export default ContextScorer; //# sourceMappingURL=ContextScorer.d.ts.map