Skip to content

Commit 4281ab4

Browse files
authored
Merge pull request #2841 from Kilo-Org/mark/remove-error-fix-strategy
remove ErrorFixStrategy
2 parents 05fa357 + 8017989 commit 4281ab4

File tree

3 files changed

+6
-274
lines changed

3 files changed

+6
-274
lines changed

src/services/ghost/PromptStrategyManager.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { PromptStrategy } from "./types/PromptStrategy"
33

44
// Import all strategies
55
import { UserRequestStrategy } from "./strategies/UserRequestStrategy"
6-
import { ErrorFixStrategy } from "./strategies/ErrorFixStrategy"
76
import { SelectionRefactorStrategy } from "./strategies/SelectionRefactorStrategy"
87
import { CommentDrivenStrategy } from "./strategies/CommentDrivenStrategy"
98
import { NewLineCompletionStrategy } from "./strategies/NewLineCompletionStrategy"
@@ -15,6 +14,7 @@ import { AutoTriggerStrategy } from "./strategies/AutoTriggerStrategy"
1514
*/
1615
export class PromptStrategyManager {
1716
private strategies: PromptStrategy[]
17+
private autoTriggerStrategy: AutoTriggerStrategy
1818
private debug: boolean
1919

2020
constructor(options?: { debug: boolean }) {
@@ -27,9 +27,8 @@ export class PromptStrategyManager {
2727
new NewLineCompletionStrategy(),
2828
new CommentDrivenStrategy(),
2929
new InlineCompletionStrategy(),
30-
new AutoTriggerStrategy(),
31-
new ErrorFixStrategy(), // This need to be implemented in background
3230
]
31+
this.autoTriggerStrategy = new AutoTriggerStrategy()
3332
}
3433

3534
/**
@@ -38,22 +37,13 @@ export class PromptStrategyManager {
3837
* @returns The selected strategy
3938
*/
4039
selectStrategy(context: GhostSuggestionContext): PromptStrategy {
41-
// Find the first strategy that can handle this context
42-
for (const strategy of this.strategies) {
43-
if (strategy.canHandle(context)) {
44-
if (this.debug) {
45-
console.log(`[PromptStrategyManager] Selected strategy: ${strategy.name}`)
46-
}
47-
return strategy
48-
}
49-
}
40+
const strategy = this.strategies.find((s) => s.canHandle(context)) ?? this.autoTriggerStrategy
5041

51-
// Fallback: return the last strategy (AutoTriggerStrategy)
52-
const fallback = this.strategies[this.strategies.length - 1]
5342
if (this.debug) {
54-
console.log(`[PromptStrategyManager] Falling back to: ${fallback.name}`)
43+
console.log(`[PromptStrategyManager] Selected strategy: ${strategy.name}`)
5544
}
56-
return fallback
45+
46+
return strategy
5747
}
5848

5949
/**
@@ -86,12 +76,4 @@ export class PromptStrategyManager {
8676
strategy,
8777
}
8878
}
89-
90-
/**
91-
* Gets all registered strategies (for testing/debugging)
92-
* @returns Array of all strategies
93-
*/
94-
getStrategies(): PromptStrategy[] {
95-
return [...this.strategies]
96-
}
9779
}

src/services/ghost/__tests__/GhostStrategy.test.ts

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { describe, it, expect, beforeEach, vi } from "vitest"
33
import { GhostStrategy } from "../GhostStrategy"
44
import { GhostSuggestionContext } from "../types"
55
import { PromptStrategyManager } from "../PromptStrategyManager"
6-
import { UseCaseType } from "../types/PromptStrategy"
7-
import { skip } from "node:test"
86

97
describe("GhostStrategy", () => {
108
let strategy: GhostStrategy
@@ -53,37 +51,6 @@ describe("GhostStrategy", () => {
5351
expect(systemPrompt).toContain("Execute User's Explicit Request")
5452
expect(userPrompt).toContain("Add a function to calculate sum")
5553
})
56-
57-
skip("should select ErrorFixStrategy when diagnostics are present", () => {
58-
const mockDocument = {
59-
languageId: "typescript",
60-
getText: () => "const x = 1",
61-
lineAt: (line: number) => ({ text: "const x = 1" }),
62-
uri: { toString: () => "file:///test.ts" },
63-
offsetAt: (position: vscode.Position) => 11,
64-
} as vscode.TextDocument
65-
66-
const mockRange = {
67-
start: { line: 0, character: 11 } as vscode.Position,
68-
end: { line: 0, character: 11 } as vscode.Position,
69-
} as vscode.Range
70-
71-
const context: GhostSuggestionContext = {
72-
document: mockDocument,
73-
diagnostics: [
74-
{
75-
severity: vscode.DiagnosticSeverity.Error,
76-
message: "Missing semicolon",
77-
range: mockRange,
78-
} as vscode.Diagnostic,
79-
],
80-
}
81-
82-
const { systemPrompt } = strategy.getPrompts(context)
83-
84-
// ErrorFixStrategy should be selected
85-
expect(systemPrompt).toContain("Fix Compilation Errors and Warnings")
86-
})
8754
})
8855

8956
describe("Integration", () => {
@@ -117,20 +84,6 @@ describe("GhostStrategy", () => {
11784
manager = new PromptStrategyManager()
11885
})
11986

120-
it("should have all 7 strategies registered", () => {
121-
const strategies = manager.getStrategies()
122-
expect(strategies).toHaveLength(7)
123-
124-
const strategyNames = strategies.map((s) => s.name)
125-
expect(strategyNames).toContain("User Request")
126-
expect(strategyNames).toContain("Error Fix")
127-
expect(strategyNames).toContain("Selection Refactor")
128-
expect(strategyNames).toContain("Comment Driven")
129-
expect(strategyNames).toContain("New Line Completion")
130-
expect(strategyNames).toContain("Inline Completion")
131-
expect(strategyNames).toContain("Auto Trigger")
132-
})
133-
13487
it("should select appropriate strategy based on context", () => {
13588
const mockDocument = {
13689
languageId: "typescript",

src/services/ghost/strategies/ErrorFixStrategy.ts

Lines changed: 0 additions & 203 deletions
This file was deleted.

0 commit comments

Comments
 (0)