Skip to content

Commit c53382b

Browse files
committed
remove now unnecessary methods
1 parent 30746dc commit c53382b

File tree

5 files changed

+21
-66
lines changed

5 files changed

+21
-66
lines changed

src/services/ghost/GhostStrategy.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,6 @@ export class GhostStrategy {
2626
return { systemPrompt, userPrompt }
2727
}
2828

29-
/**
30-
* Get the system prompt based on context using the new strategy system
31-
* @deprecated Use getPrompts() instead for better performance
32-
*/
33-
getSystemPrompt(context: GhostSuggestionContext): string {
34-
return this.getPrompts(context).systemPrompt
35-
}
36-
37-
/**
38-
* Get the user prompt based on context using the new strategy system
39-
* @param context The suggestion context
40-
* @returns The user prompt
41-
* @deprecated Use getPrompts() instead for better performance
42-
*/
43-
getSuggestionPrompt(context: GhostSuggestionContext): string {
44-
return this.getPrompts(context).userPrompt
45-
}
46-
4729
/**
4830
* Initialize streaming parser for incremental parsing
4931
*/

src/services/ghost/__tests__/GhostModelPerformance.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ describe("GhostModelPerformance", () => {
2525
document: document,
2626
}
2727

28-
const systemPrompt = strategy.getSystemPrompt(context)
29-
const suggestionPrompt = strategy.getSuggestionPrompt(context)
28+
const { systemPrompt, userPrompt } = strategy.getPrompts(context)
3029

31-
return { systemPrompt, suggestionPrompt }
30+
return { systemPrompt, suggestionPrompt: userPrompt }
3231
}
3332

3433
const performTest = async (apiHandler: ApiHandler, prompt: { systemPrompt: string; suggestionPrompt: string }) => {

src/services/ghost/__tests__/GhostRecentOperations.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ describe("GhostRecentOperations", () => {
116116
expect(enrichedContext.recentOperations?.length).toBeGreaterThan(0)
117117

118118
// Generate prompt
119-
const prompt = strategy.getSuggestionPrompt(enrichedContext)
119+
const { userPrompt } = strategy.getPrompts(enrichedContext)
120120

121121
// Verify that the prompt includes the recent operations section
122122
// The new strategy system uses "## Recent Typing" format
123-
expect(prompt).toContain("## Recent Typing")
123+
expect(userPrompt).toContain("## Recent Typing")
124124
})
125125

126126
it("should not include recent operations in the prompt when not available", async () => {
@@ -133,11 +133,11 @@ describe("GhostRecentOperations", () => {
133133
const enrichedContext = await context.generate(suggestionContext)
134134

135135
// Generate prompt
136-
const prompt = strategy.getSuggestionPrompt(enrichedContext)
136+
const { userPrompt } = strategy.getPrompts(enrichedContext)
137137

138138
// Verify that the prompt does not include recent operations section
139139
// The current document content will still be in the prompt, so we should only check
140140
// that the "**Recent Changes (Diff):**" section is not present
141-
expect(prompt.includes("**Recent Changes (Diff):**")).toBe(false)
141+
expect(userPrompt.includes("**Recent Changes (Diff):**")).toBe(false)
142142
})
143143
})

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,25 +246,25 @@ describe("GhostStrategy", () => {
246246
expect(userPrompt).toContain("<<<AUTOCOMPLETE_HERE>>>")
247247
})
248248

249-
it("should generate system prompt", () => {
249+
it("should generate system prompt via getPrompts", () => {
250250
const context: GhostSuggestionContext = {
251251
document: mockDocument,
252252
}
253-
const systemPrompt = strategy.getSystemPrompt(context)
253+
const { systemPrompt } = strategy.getPrompts(context)
254254
expect(systemPrompt).toContain("CRITICAL OUTPUT FORMAT")
255255
expect(systemPrompt).toContain("XML-formatted changes")
256256
})
257257

258-
it("should generate suggestion prompt with context", () => {
258+
it("should generate suggestion prompt with context via getPrompts", () => {
259259
const context: GhostSuggestionContext = {
260260
document: mockDocument,
261261
userInput: "Add a comment",
262262
range: new vscode.Range(new vscode.Position(0, 0), new vscode.Position(0, 0)),
263263
}
264264

265-
const suggestionPrompt = strategy.getSuggestionPrompt(context)
266-
expect(suggestionPrompt).toContain("Add a comment")
267-
expect(suggestionPrompt).toContain("<<<AUTOCOMPLETE_HERE>>>")
265+
const { userPrompt } = strategy.getPrompts(context)
266+
expect(userPrompt).toContain("Add a comment")
267+
expect(userPrompt).toContain("<<<AUTOCOMPLETE_HERE>>>")
268268
})
269269
})
270270
})

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

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ describe("GhostStrategy", () => {
1313
strategy = new GhostStrategy()
1414
})
1515

16-
describe("getSystemPrompt", () => {
17-
it("should use PromptStrategyManager to generate system prompt", () => {
16+
describe("getPrompts", () => {
17+
it("should use PromptStrategyManager to generate prompts", () => {
1818
const mockDocument = {
1919
languageId: "typescript",
2020
getText: () => "const x = 1;",
@@ -27,10 +27,10 @@ describe("GhostStrategy", () => {
2727
userInput: "Complete this function",
2828
}
2929

30-
const prompt = strategy.getSystemPrompt(context)
30+
const { systemPrompt } = strategy.getPrompts(context)
3131

3232
// Should contain base instructions from strategy system
33-
expect(prompt).toContain("CRITICAL OUTPUT FORMAT")
33+
expect(systemPrompt).toContain("CRITICAL OUTPUT FORMAT")
3434
})
3535

3636
it("should select UserRequestStrategy when user input is provided", () => {
@@ -47,8 +47,7 @@ describe("GhostStrategy", () => {
4747
userInput: "Add a function to calculate sum",
4848
}
4949

50-
const systemPrompt = strategy.getSystemPrompt(context)
51-
const userPrompt = strategy.getSuggestionPrompt(context)
50+
const { systemPrompt, userPrompt } = strategy.getPrompts(context)
5251

5352
// UserRequestStrategy should be selected
5453
expect(systemPrompt).toContain("Execute User's Explicit Request")
@@ -80,35 +79,13 @@ describe("GhostStrategy", () => {
8079
],
8180
}
8281

83-
const systemPrompt = strategy.getSystemPrompt(context)
82+
const { systemPrompt } = strategy.getPrompts(context)
8483

8584
// ErrorFixStrategy should be selected
8685
expect(systemPrompt).toContain("Fix Compilation Errors and Warnings")
8786
})
8887
})
8988

90-
describe("getSuggestionPrompt", () => {
91-
it("should delegate to PromptStrategyManager", () => {
92-
const mockDocument = {
93-
languageId: "typescript",
94-
getText: () => "const x = 1;",
95-
lineAt: (line: number) => ({ text: "const x = 1;" }),
96-
uri: { toString: () => "file:///test.ts" },
97-
offsetAt: (position: vscode.Position) => 13,
98-
} as vscode.TextDocument
99-
100-
const context: GhostSuggestionContext = {
101-
document: mockDocument,
102-
}
103-
104-
const prompt = strategy.getSuggestionPrompt(context)
105-
106-
// Should return a structured prompt
107-
expect(prompt).toBeDefined()
108-
expect(prompt.length).toBeGreaterThan(0)
109-
})
110-
})
111-
11289
describe("Integration", () => {
11390
it("should work with both system and user prompts", () => {
11491
const mockDocument = {
@@ -124,8 +101,7 @@ describe("GhostStrategy", () => {
124101
userInput: "Complete this function",
125102
}
126103

127-
const systemPrompt = strategy.getSystemPrompt(context)
128-
const userPrompt = strategy.getSuggestionPrompt(context)
104+
const { systemPrompt, userPrompt } = strategy.getPrompts(context)
129105

130106
// System prompt should contain format instructions
131107
expect(systemPrompt).toContain("CRITICAL OUTPUT FORMAT")
@@ -220,8 +196,7 @@ describe("GhostStrategy", () => {
220196
document: mockDocument,
221197
}
222198

223-
const systemPrompt = strategy.getSystemPrompt(context)
224-
const userPrompt = strategy.getSuggestionPrompt(context)
199+
const { systemPrompt, userPrompt } = strategy.getPrompts(context)
225200

226201
expect(systemPrompt).toBeDefined()
227202
expect(systemPrompt.length).toBeGreaterThan(0)
@@ -279,8 +254,7 @@ describe("GhostStrategy", () => {
279254
]
280255

281256
contexts.forEach((context) => {
282-
const systemPrompt = strategy.getSystemPrompt(context as GhostSuggestionContext)
283-
const userPrompt = strategy.getSuggestionPrompt(context as GhostSuggestionContext)
257+
const { systemPrompt, userPrompt } = strategy.getPrompts(context as GhostSuggestionContext)
284258

285259
expect(systemPrompt).toBeDefined()
286260
expect(systemPrompt.length).toBeGreaterThan(0)

0 commit comments

Comments
 (0)