refactor: remove debug functionality

This commit is contained in:
Daniel Riccio
2025-01-14 18:03:03 -05:00
parent e6d3db6075
commit f696f8e0f1
2 changed files with 7 additions and 28 deletions

View File

@@ -253,12 +253,11 @@ export async function applyEdit(
hunk: Hunk,
content: string[],
matchPosition: number,
confidence: number,
debug: string = '',
confidence: number,
minConfidence: number = 0.9
): Promise<EditResult> {
// Don't attempt regular edits if confidence is too low
if (confidence < minConfidence && debug === '') {
if (confidence < minConfidence) {
console.log(`Search confidence (${confidence}) below minimum threshold (${minConfidence}), trying git fallback...`);
return applyGitFallback(hunk, content);
}
@@ -270,30 +269,10 @@ export async function applyEdit(
{ name: 'git-fallback', apply: () => applyGitFallback(hunk, content) }
];
if (debug !== '') {
// In debug mode, try all strategies including git fallback
const results = await Promise.all([
...strategies.map(async strategy => {
console.log(`Attempting edit with ${strategy.name} strategy...`);
const result = await strategy.apply();
console.log(`Strategy ${strategy.name} succeeded with confidence ${result.confidence}`);
return result;
})
]);
return results.find(result => result.strategy === debug) || { confidence: 0, result: content, strategy: 'none' };
} else {
// Normal mode - try strategies sequentially until one succeeds
for (const strategy of strategies) {
const result = await strategy.apply();
if (result.confidence === 1) {
return result;
}
}
// If all strategies fail, try git fallback
const result = await applyGitFallback(hunk, content);
if(result.confidence === 1) {
// Try strategies sequentially until one succeeds
for (const strategy of strategies) {
const result = await strategy.apply();
if (result.confidence >= minConfidence) {
return result;
}
}

View File

@@ -206,7 +206,7 @@ Your diff here
const contextStr = prepareSearchString(hunk.changes)
const { index: matchPosition, confidence, strategy } = findBestMatch(contextStr, result, 0, this.confidenceThreshold)
const editResult = await applyEdit(hunk, result, matchPosition, confidence, '', this.confidenceThreshold)
const editResult = await applyEdit(hunk, result, matchPosition, confidence, this.confidenceThreshold)
if (editResult.confidence >= this.confidenceThreshold) {
result = editResult.result
} else {