UNPKG

@quantumai/quantum-cli-core

Version:

Quantum CLI Core - Multi-LLM Collaboration System

481 lines 22.1 kB
/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ export class SettingsRecommendationSystem { historyManager; preferenceEngine; onboardingSystem; userState; constructor(historyManager, preferenceEngine, onboardingSystem, initialState) { this.historyManager = historyManager; this.preferenceEngine = preferenceEngine; this.onboardingSystem = onboardingSystem; this.userState = { currentSettings: {}, appliedRecommendations: new Set(), dismissedRecommendations: new Set(), lastOptimizationTime: 0, settingsVersion: '1.0.0', customProfiles: [], ...initialState }; } /** * 사용자 패턴을 분석하여 개인화된 설정 추천을 생성합니다 */ generatePersonalizedRecommendations() { const userPattern = this.historyManager.getUserPattern(); const preferences = this.preferenceEngine.getPreferences(); const onboardingState = this.onboardingSystem.getOnboardingState(); const recommendations = []; // Performance optimizations based on usage patterns recommendations.push(...this.analyzePerformanceSettings(userPattern)); // UI/UX improvements based on interaction patterns recommendations.push(...this.analyzeUISettings(userPattern, preferences)); // Collaboration settings based on work patterns recommendations.push(...this.analyzeCollaborationSettings(userPattern, onboardingState)); // Workflow optimizations based on command usage recommendations.push(...this.analyzeWorkflowSettings(userPattern)); // Security recommendations based on project context recommendations.push(...this.analyzeSecuritySettings(userPattern)); // Filter out already applied or dismissed recommendations const filteredRecommendations = recommendations.filter(rec => !this.userState.appliedRecommendations.has(rec.setting) && !this.userState.dismissedRecommendations.has(rec.setting)); // Sort by priority and impact return filteredRecommendations .sort((a, b) => { const priorityDiff = b.priority - a.priority; if (priorityDiff !== 0) return priorityDiff; const impactWeight = { 'high': 3, 'medium': 2, 'low': 1 }; return impactWeight[b.impact] - impactWeight[a.impact]; }) .slice(0, 5); // Top 5 recommendations } /** * 특정 카테고리의 설정 추천을 생성합니다 */ getRecommendationsByCategory(category) { return this.generatePersonalizedRecommendations() .filter(rec => rec.category === category); } /** * 현재 설정을 분석하여 즉시 최적화할 수 있는 설정을 찾습니다 */ getQuickOptimizations() { const recommendations = this.generatePersonalizedRecommendations(); return recommendations.filter(rec => rec.effort === 'low' && (rec.impact === 'medium' || rec.impact === 'high')); } /** * 사용자의 워크플로우에 맞는 설정 프로파일을 추천합니다 */ recommendSettingsProfile() { const userPattern = this.historyManager.getUserPattern(); const preferences = this.preferenceEngine.getPreferences(); const profiles = this.getBuiltInProfiles(); for (const profile of profiles) { if (this.isProfileSuitable(profile, userPattern, preferences)) { return profile; } } // Generate custom profile if no built-in profile matches return this.generateCustomProfile(userPattern, preferences); } /** * 설정 추천을 적용했을 때의 예상 효과를 계산합니다 */ estimateImpact(recommendations) { let performanceScore = 0; let productivityScore = 0; let satisfactionScore = 0; let totalEffort = 0; for (const rec of recommendations) { const impactMultiplier = { 'high': 3, 'medium': 2, 'low': 1 }; const effortCost = { 'high': 5, 'medium': 3, 'low': 1 }; const impact = impactMultiplier[rec.impact]; if (rec.category === 'performance') { performanceScore += impact; } else if (rec.category === 'workflow') { productivityScore += impact; } else if (rec.category === 'ui') { satisfactionScore += impact; } totalEffort += effortCost[rec.effort]; } return { performanceImprovement: Math.min(performanceScore * 10, 100), productivityGain: Math.min(productivityScore * 15, 100), userSatisfaction: Math.min(satisfactionScore * 12, 100), timeToValue: totalEffort * 2 // minutes }; } /** * 설정 추천 적용을 기록합니다 */ markRecommendationApplied(setting, value) { this.userState.appliedRecommendations.add(setting); this.userState.currentSettings[setting] = value; // Record for learning this.preferenceEngine.recordInteraction({ type: 'setting_applied', setting, value, timestamp: Date.now(), context: {} }); } /** * 설정 추천 거부를 기록합니다 */ markRecommendationDismissed(setting, reason) { this.userState.dismissedRecommendations.add(setting); this.preferenceEngine.recordInteraction({ type: 'setting_dismissed', setting, timestamp: Date.now(), context: { reason } }); } analyzePerformanceSettings(userPattern) { const recommendations = []; // Analyze response time patterns if (userPattern.sessionMetrics.avgSessionDuration > 30) { recommendations.push({ category: 'performance', setting: 'collaboration.maxLatency', currentValue: 10000, recommendedValue: 5000, rationale: '긴 세션이 감지되었습니다. 응답 속도를 향상시켜 대기 시간을 줄일 수 있습니다.', impact: 'high', effort: 'low', priority: 0.9, personalizedMessage: '평균 세션 시간이 30분을 넘어서므로, 빠른 응답 모드를 활성화하면 전체 작업 시간을 크게 단축할 수 있습니다.', howToApply: '/settings collaboration.maxLatency 5000', relatedFeatures: ['multi_llm_verification'] }); } // Analyze memory usage patterns if (userPattern.contextMetrics.avgFilesPerQuery > 15) { recommendations.push({ category: 'performance', setting: 'contextLimit', currentValue: 100, recommendedValue: 150, rationale: '많은 파일을 동시에 작업하는 패턴이 감지되었습니다.', impact: 'medium', effort: 'low', priority: 0.7, personalizedMessage: '대규모 프로젝트에서 작업하시는 것 같아 컨텍스트 제한을 늘리면 더 효율적일 것 같습니다.', howToApply: '/settings contextLimit 150' }); } // Analyze caching needs if (userPattern.behaviorMetrics.commandRepetition > 5) { recommendations.push({ category: 'performance', setting: 'cacheResponses', currentValue: false, recommendedValue: true, rationale: '반복되는 쿼리 패턴이 감지되어 캐싱이 도움이 될 것 같습니다.', impact: 'medium', effort: 'low', priority: 0.8, personalizedMessage: '유사한 작업을 자주 반복하시는군요. 응답 캐싱을 활성화하면 중복 계산을 줄일 수 있습니다.', howToApply: '/settings collaboration.cacheResponses true' }); } return recommendations; } analyzeUISettings(userPattern, preferences) { const recommendations = []; // Analyze session length for theme recommendations if (userPattern.sessionMetrics.avgSessionDuration > 60) { recommendations.push({ category: 'ui', setting: 'theme', currentValue: 'default', recommendedValue: 'dark', rationale: '긴 작업 세션이 감지되어 눈의 피로를 줄이는 다크 테마를 추천합니다.', impact: 'medium', effort: 'low', priority: 0.6, personalizedMessage: '장시간 작업하시는 것 같아 다크 테마로 변경하면 눈의 피로를 줄일 수 있습니다.', howToApply: '/theme dark' }); } // Analyze error patterns for helpful indicators if (userPattern.behaviorMetrics.errorRate > 0.1) { recommendations.push({ category: 'ui', setting: 'showDetailedErrors', currentValue: false, recommendedValue: true, rationale: '오류 발생률이 높아 상세한 오류 정보 표시가 도움이 될 것 같습니다.', impact: 'high', effort: 'low', priority: 0.8, personalizedMessage: '작업 중 오류가 자주 발생하는군요. 상세한 오류 정보를 표시하면 문제 해결이 쉬워집니다.', howToApply: '/settings showDetailedErrors true' }); } // Analyze command patterns for autocomplete if (userPattern.behaviorMetrics.commandRepetition > 3) { recommendations.push({ category: 'ui', setting: 'enableAutocomplete', currentValue: false, recommendedValue: true, rationale: '반복 명령어 사용이 많아 자동완성이 효율성을 높일 것 같습니다.', impact: 'medium', effort: 'low', priority: 0.7, personalizedMessage: '비슷한 명령어를 자주 사용하시는군요. 자동완성을 활성화하면 타이핑 시간을 절약할 수 있습니다.', howToApply: '/settings enableAutocomplete true' }); } return recommendations; } analyzeCollaborationSettings(userPattern, onboardingState) { const recommendations = []; // Analyze complexity patterns for auto-verification const highComplexityQueries = userPattern.queryComplexityDistribution.filter(q => q.complexity > 0.8).length; if (highComplexityQueries > 3 && !onboardingState.completedFeatures.has('multi_llm_verification')) { recommendations.push({ category: 'collaboration', setting: 'collaboration.autoVerifyThreshold', currentValue: 1.0, recommendedValue: 0.7, rationale: '복잡한 쿼리가 많아 자동 검증 기능을 활성화하면 품질이 향상될 것 같습니다.', impact: 'high', effort: 'medium', priority: 0.9, personalizedMessage: '복잡한 작업을 많이 하시는군요. 자동 검증을 활성화하면 더 정확한 결과를 얻을 수 있습니다.', howToApply: '/settings collaboration.autoVerifyThreshold 0.7', relatedFeatures: ['multi_llm_verification', 'uncertainty_detection'] }); } // Analyze cost sensitivity const costSensitivity = this.estimateCostSensitivity(userPattern); if (costSensitivity === 'high') { recommendations.push({ category: 'collaboration', setting: 'collaboration.maxCostPerQuery', currentValue: 0.10, recommendedValue: 0.05, rationale: '비용 효율적인 사용 패턴이 감지되어 쿼리당 비용 제한을 낮추는 것을 추천합니다.', impact: 'medium', effort: 'low', priority: 0.7, personalizedMessage: '비용을 고려하여 사용하시는 것 같아 쿼리당 비용 제한을 설정하면 예산 관리에 도움이 됩니다.', howToApply: '/settings collaboration.maxCostPerQuery 0.05' }); } return recommendations; } analyzeWorkflowSettings(userPattern) { const recommendations = []; // Analyze file operation patterns if (userPattern.toolUsage.fileOperations > 20) { recommendations.push({ category: 'workflow', setting: 'autoSaveEnabled', currentValue: false, recommendedValue: true, rationale: '파일 작업이 많아 자동 저장 기능이 작업 손실을 방지하는데 도움이 될 것 같습니다.', impact: 'high', effort: 'low', priority: 0.8, personalizedMessage: '파일 작업을 많이 하시는군요. 자동 저장을 활성화하면 작업 손실을 방지할 수 있습니다.', howToApply: '/settings autoSaveEnabled true' }); } // Analyze shell command usage if (userPattern.toolUsage.shellCommands > 15) { recommendations.push({ category: 'workflow', setting: 'confirmDangerousCommands', currentValue: true, recommendedValue: false, rationale: '셸 명령어를 자주 사용하시므로 확인 단계를 줄여 작업 속도를 높일 수 있습니다.', impact: 'medium', effort: 'low', priority: 0.6, personalizedMessage: '셸 명령어에 익숙하신 것 같아 위험한 명령어 확인을 비활성화하면 더 빠르게 작업할 수 있습니다.', howToApply: '/settings confirmDangerousCommands false' }); } return recommendations; } analyzeSecuritySettings(userPattern) { const recommendations = []; // Analyze for sensitive data patterns const hasSensitiveQueries = userPattern.recentQueries.some(q => q.text.toLowerCase().includes('password') || q.text.toLowerCase().includes('secret') || q.text.toLowerCase().includes('key')); if (hasSensitiveQueries) { recommendations.push({ category: 'security', setting: 'redactSensitiveData', currentValue: false, recommendedValue: true, rationale: '민감한 데이터 관련 쿼리가 감지되어 자동 마스킹 기능을 활성화하는 것을 추천합니다.', impact: 'high', effort: 'low', priority: 0.9, personalizedMessage: '보안 관련 작업을 하시는군요. 민감한 데이터 자동 마스킹을 활성화하면 보안이 강화됩니다.', howToApply: '/settings redactSensitiveData true' }); } // Analyze for production environment indicators const hasProductionContext = userPattern.contextMetrics.detectedEnvironments.includes('production'); if (hasProductionContext) { recommendations.push({ category: 'security', setting: 'requireConfirmationForProd', currentValue: false, recommendedValue: true, rationale: '프로덕션 환경 작업이 감지되어 추가 확인 단계를 활성화하는 것을 추천합니다.', impact: 'high', effort: 'low', priority: 0.8, personalizedMessage: '프로덕션 환경에서 작업하시는군요. 중요한 작업에 대한 추가 확인을 활성화하면 안전합니다.', howToApply: '/settings requireConfirmationForProd true' }); } return recommendations; } getBuiltInProfiles() { return [ { name: 'Developer Pro', description: '경험 많은 개발자를 위한 고급 설정', targetUser: '복잡한 프로젝트를 다루는 시니어 개발자', settings: { 'collaboration.autoVerifyThreshold': 0.8, 'collaboration.maxCostPerQuery': 0.08, 'confirmDangerousCommands': false, 'enableAutocomplete': true, 'showDetailedErrors': true, 'contextLimit': 200 }, benefits: [ '고급 기능에 빠른 접근', '최소한의 확인 단계', '최대 성능 활용' ] }, { name: 'Team Collaborator', description: '팀 작업과 코드 품질에 중점을 둔 설정', targetUser: '팀 프로젝트에서 협업하는 개발자', settings: { 'collaboration.autoVerifyThreshold': 0.6, 'collaboration.requireConsensus': true, 'redactSensitiveData': true, 'autoSaveEnabled': true, 'showDetailedErrors': true }, benefits: [ '높은 코드 품질 보장', '팀 협업 지원', '보안 강화' ] }, { name: 'Efficiency Master', description: '생산성과 속도에 최적화된 설정', targetUser: '빠른 프로토타이핑과 반복 개발을 하는 개발자', settings: { 'collaboration.maxLatency': 3000, 'collaboration.cacheResponses': true, 'enableAutocomplete': true, 'theme': 'minimal', 'autoSaveEnabled': true }, benefits: [ '최고 속도 성능', '반복 작업 최적화', '빠른 피드백 루프' ] }, { name: 'Security Focused', description: '보안과 안전성에 중점을 둔 설정', targetUser: '보안이 중요한 환경에서 작업하는 개발자', settings: { 'redactSensitiveData': true, 'requireConfirmationForProd': true, 'collaboration.autoVerifyThreshold': 0.5, 'confirmDangerousCommands': true, 'auditTrailEnabled': true }, benefits: [ '최고 수준 보안', '위험 최소화', '완전한 감사 추적' ] } ]; } isProfileSuitable(profile, userPattern, preferences) { const skillLevel = this.onboardingSystem.getOnboardingState().skillLevel; // Match profile to user characteristics switch (profile.name) { case 'Developer Pro': return skillLevel === 'advanced' && userPattern.sessionMetrics.totalSessions > 20; case 'Team Collaborator': return userPattern.toolUsage.collaborationFeatures > 5; case 'Efficiency Master': return userPattern.behaviorMetrics.commandRepetition > 5; case 'Security Focused': return userPattern.recentQueries.some(q => q.text.toLowerCase().includes('security') || q.text.toLowerCase().includes('production')); default: return false; } } generateCustomProfile(userPattern, preferences) { const customSettings = {}; const benefits = []; // Analyze patterns and build custom profile if (userPattern.sessionMetrics.avgSessionDuration > 45) { customSettings['theme'] = 'dark'; benefits.push('장시간 작업에 최적화'); } if (userPattern.toolUsage.fileOperations > 15) { customSettings['autoSaveEnabled'] = true; benefits.push('파일 작업 안전성 향상'); } if (userPattern.behaviorMetrics.errorRate > 0.1) { customSettings['showDetailedErrors'] = true; benefits.push('향상된 디버깅 지원'); } return { name: 'Custom Profile', description: '사용자 패턴에 맞춤 설정된 프로파일', targetUser: '개인 사용 패턴 최적화', settings: customSettings, benefits }; } estimateCostSensitivity(userPattern) { // Simple heuristic based on usage patterns const avgSessionDuration = userPattern.sessionMetrics.avgSessionDuration; const totalSessions = userPattern.sessionMetrics.totalSessions; if (avgSessionDuration < 10 && totalSessions > 20) { return 'high'; // Short, frequent sessions suggest cost awareness } else if (avgSessionDuration > 60) { return 'low'; // Long sessions suggest less cost sensitivity } else { return 'medium'; } } } //# sourceMappingURL=settings-recommendation.js.map