ai-debug-local-mcp
Version:
๐ฏ ENHANCED AI GUIDANCE v4.1.2: Dramatically improved tool descriptions help AI users choose the right tools instead of 'close enough' options. Ultra-fast keyboard automation (10x speed), universal recording, multi-ecosystem debugging support, and compreh
287 lines (282 loc) โข 11.9 kB
JavaScript
/**
* Debugging Value Tracker
*
* Tracks the real value delivered by AI-Debug: context preservation,
* time savings, automation benefits, and debugging efficiency.
* NOT about token savings (which don't exist with sub-agents).
*/
/**
* Tracks real debugging value delivered to users
*/
export class DebuggingValueTracker {
contextMetrics = new Map();
timeMetrics = new Map();
efficiencyMetrics = new Map();
automationMetrics = new Map();
// Professional capabilities that demonstrate value
PROFESSIONAL_CAPABILITIES = [
'Framework-specific debugging',
'Visual regression detection',
'Accessibility compliance checking',
'Performance profiling',
'Multi-browser testing',
'Network request mocking',
'State time-travel debugging',
'AI-powered error analysis',
'Automated fix suggestions',
'Cross-stack debugging'
];
// Time estimates for common debugging tasks (in minutes)
MANUAL_TIME_ESTIMATES = {
'simple-bug-fix': 15,
'ui-debugging': 30,
'performance-analysis': 45,
'accessibility-audit': 60,
'cross-browser-testing': 90,
'integration-debugging': 120,
'complex-state-debugging': 180
};
/**
* Track context preservation from sub-agent delegation
*/
trackContextPreservation(sessionId, mainConversationLines, subAgentOutput) {
const existing = this.contextMetrics.get(sessionId) || {
sessionId,
timestamp: Date.now(),
mainConversationLines,
debuggingOutputLines: 0,
contextPreservedLines: 0,
contextPreservationRatio: 0,
subAgentDelegations: []
};
existing.debuggingOutputLines += subAgentOutput.outputLines;
existing.contextPreservedLines += subAgentOutput.outputLines;
existing.subAgentDelegations.push({
agentType: subAgentOutput.agentType,
taskDescription: subAgentOutput.taskDescription,
outputLinesHandled: subAgentOutput.outputLines,
delegationTime: subAgentOutput.executionTime
});
// Calculate preservation ratio
const totalPossibleLines = existing.mainConversationLines + existing.debuggingOutputLines;
existing.contextPreservationRatio = existing.contextPreservedLines / totalPossibleLines;
this.contextMetrics.set(sessionId, existing);
}
/**
* Track time savings from automation
*/
trackTimeSavings(sessionId, taskType, automatedSteps, actualExecutionTimeMs) {
// Estimate manual time based on task complexity
const estimatedMinutes = this.estimateManualTime(taskType, automatedSteps);
const estimatedManualTimeMs = estimatedMinutes * 60 * 1000;
const timeSavedMs = Math.max(0, estimatedManualTimeMs - actualExecutionTimeMs);
const timeSavingsPercentage = (timeSavedMs / estimatedManualTimeMs) * 100;
this.timeMetrics.set(sessionId, {
sessionId,
taskType,
automatedSteps,
estimatedManualTimeMs,
actualExecutionTimeMs,
timeSavedMs,
timeSavingsPercentage
});
}
/**
* Track debugging efficiency and outcomes
*/
trackDebuggingEfficiency(sessionId, efficiency) {
const successRate = efficiency.issuesIdentified > 0
? efficiency.issuesResolved / efficiency.issuesIdentified
: 0;
this.efficiencyMetrics.set(sessionId, {
sessionId,
successRate,
...efficiency
});
}
/**
* Track workflow automation value
*/
trackWorkflowAutomation(sessionId, workflowType, manualStepsEliminated, professionalCapabilities) {
const automationLevel = this.calculateAutomationLevel(manualStepsEliminated);
const cognitiveLoadReduction = this.assessCognitiveLoadReduction(manualStepsEliminated);
this.automationMetrics.set(sessionId, {
sessionId,
workflowType,
manualStepsEliminated,
automationLevel,
cognitiveLoadReduction,
professionalCapabilities
});
}
/**
* Get comprehensive value delivered summary
*/
getValueDeliveredSummary() {
const allSessions = new Set([
...this.contextMetrics.keys(),
...this.timeMetrics.keys(),
...this.efficiencyMetrics.keys(),
...this.automationMetrics.keys()
]);
// Context preservation stats
let totalLinesPreserved = 0;
let totalPreservationRatio = 0;
let contextSessionCount = 0;
this.contextMetrics.forEach(metrics => {
totalLinesPreserved += metrics.contextPreservedLines;
totalPreservationRatio += metrics.contextPreservationRatio;
contextSessionCount++;
});
// Time efficiency stats
let totalTimeSavedMs = 0;
let totalSpeedupFactor = 0;
let timeSessionCount = 0;
const resolutionTimes = [];
this.timeMetrics.forEach(metrics => {
totalTimeSavedMs += metrics.timeSavedMs;
const speedup = metrics.estimatedManualTimeMs / metrics.actualExecutionTimeMs;
totalSpeedupFactor += speedup;
timeSessionCount++;
resolutionTimes.push({
task: metrics.taskType,
time: metrics.actualExecutionTimeMs
});
});
// Debugging quality stats
let totalIssuesFound = 0;
let totalIssuesResolved = 0;
let criticalBugsCaught = 0;
let qualitySessionCount = 0;
this.efficiencyMetrics.forEach(metrics => {
totalIssuesFound += metrics.issuesIdentified;
totalIssuesResolved += metrics.issuesResolved;
criticalBugsCaught += metrics.outcomes.filter(o => o.severity === 'critical').length;
qualitySessionCount++;
});
// Automation value stats
let totalStepsAutomated = 0;
const workflowCounts = {};
const capabilityUsage = {};
this.automationMetrics.forEach(metrics => {
totalStepsAutomated += metrics.manualStepsEliminated.length;
workflowCounts[metrics.workflowType] = (workflowCounts[metrics.workflowType] || 0) + 1;
metrics.professionalCapabilities.forEach(cap => {
capabilityUsage[cap] = (capabilityUsage[cap] || 0) + 1;
});
});
// Calculate estimated value
const hoursSaved = totalTimeSavedMs / (1000 * 60 * 60);
const avgDeveloperHourlyRate = 150; // $150/hour average
const dollarValue = hoursSaved * avgDeveloperHourlyRate;
const productivityMultiplier = timeSessionCount > 0 ? totalSpeedupFactor / timeSessionCount : 1;
return {
totalSessions: allSessions.size,
contextPreserved: {
totalLinesKeptFromMain: totalLinesPreserved,
averagePreservationRatio: contextSessionCount > 0 ? totalPreservationRatio / contextSessionCount : 0,
cleanConversationScore: Math.min(100, (totalPreservationRatio / contextSessionCount) * 100)
},
timeEfficiency: {
totalTimeSavedHours: hoursSaved,
averageSpeedupFactor: productivityMultiplier,
fastestResolutions: resolutionTimes
.sort((a, b) => a.time - b.time)
.slice(0, 3)
.map(r => r.task)
},
debuggingQuality: {
totalIssuesFound,
totalIssuesResolved,
overallSuccessRate: totalIssuesFound > 0 ? totalIssuesResolved / totalIssuesFound : 0,
criticalBugsCaught
},
automationValue: {
totalStepsAutomated,
mostAutomatedWorkflows: Object.entries(workflowCounts)
.sort(([, a], [, b]) => b - a)
.slice(0, 3)
.map(([workflow]) => workflow),
professionalFeaturesUsed: Object.entries(capabilityUsage)
.sort(([, a], [, b]) => b - a)
.map(([capability]) => capability)
},
estimatedValueDelivered: {
hoursSaved,
dollarValue,
productivityMultiplier
}
};
}
/**
* Get session-specific value metrics
*/
getSessionValue(sessionId) {
const context = this.contextMetrics.get(sessionId);
const time = this.timeMetrics.get(sessionId);
const efficiency = this.efficiencyMetrics.get(sessionId);
const automation = this.automationMetrics.get(sessionId);
const timeSavedHours = (time?.timeSavedMs || 0) / (1000 * 60 * 60);
const estimatedValue = timeSavedHours * 150; // $150/hour
return {
contextPreserved: context?.contextPreservedLines || 0,
timeSaved: timeSavedHours,
efficiencyScore: efficiency?.successRate || 0,
automationLevel: automation?.automationLevel || 0,
estimatedValue
};
}
// Helper methods
estimateManualTime(taskType, steps) {
// Base time from task type
let baseTime = this.MANUAL_TIME_ESTIMATES[taskType] || 30;
// Add time for each manual step that would be needed
const stepTime = steps.length * 5; // 5 minutes per manual step
return baseTime + stepTime;
}
calculateAutomationLevel(stepsEliminated) {
// Estimate total steps in a typical debugging workflow
const typicalTotalSteps = 10;
const automationRatio = Math.min(1, stepsEliminated.length / typicalTotalSteps);
return Math.round(automationRatio * 100);
}
assessCognitiveLoadReduction(stepsEliminated) {
if (stepsEliminated.length >= 8)
return 'high';
if (stepsEliminated.length >= 4)
return 'medium';
return 'low';
}
/**
* Generate value report for display
*/
generateValueReport() {
const summary = this.getValueDeliveredSummary();
return `
AI-Debug Value Delivered Report
================================
๐ Overall Impact:
- Total debugging sessions: ${summary.totalSessions}
- Time saved: ${summary.timeEfficiency.totalTimeSavedHours.toFixed(1)} hours
- Productivity boost: ${summary.timeEfficiency.averageSpeedupFactor.toFixed(1)}x faster
- Estimated value: $${summary.estimatedValueDelivered.dollarValue.toFixed(2)}
๐งน Context Preservation:
- Lines kept out of main chat: ${summary.contextPreserved.totalLinesKeptFromMain}
- Clean conversation score: ${summary.contextPreserved.cleanConversationScore.toFixed(0)}/100
- Average preservation ratio: ${(summary.contextPreserved.averagePreservationRatio * 100).toFixed(1)}%
๐ Debugging Quality:
- Issues identified: ${summary.debuggingQuality.totalIssuesFound}
- Issues resolved: ${summary.debuggingQuality.totalIssuesResolved}
- Success rate: ${(summary.debuggingQuality.overallSuccessRate * 100).toFixed(1)}%
- Critical bugs caught: ${summary.debuggingQuality.criticalBugsCaught}
๐ค Automation Benefits:
- Manual steps eliminated: ${summary.automationValue.totalStepsAutomated}
- Most automated workflows: ${summary.automationValue.mostAutomatedWorkflows.join(', ')}
- Professional features used: ${summary.automationValue.professionalFeaturesUsed.slice(0, 5).join(', ')}
๐ก Value Proposition:
AI-Debug isn't about saving tokens - it's about saving time, improving quality,
and keeping your conversations clean while leveraging professional debugging capabilities.
`.trim();
}
}
//# sourceMappingURL=debugging-value-tracker.js.map