|
|
@@ -13,8 +13,8 @@ describe("GhostStrategy", () => {
|
|
|
strategy = new GhostStrategy()
|
|
|
})
|
|
|
|
|
|
- describe("getSystemPrompt", () => {
|
|
|
- it("should use PromptStrategyManager to generate system prompt", () => {
|
|
|
+ describe("getPrompts", () => {
|
|
|
+ it("should use PromptStrategyManager to generate prompts", () => {
|
|
|
const mockDocument = {
|
|
|
languageId: "typescript",
|
|
|
getText: () => "const x = 1;",
|
|
|
@@ -27,10 +27,10 @@ describe("GhostStrategy", () => {
|
|
|
userInput: "Complete this function",
|
|
|
}
|
|
|
|
|
|
- const prompt = strategy.getSystemPrompt(context)
|
|
|
+ const { systemPrompt } = strategy.getPrompts(context)
|
|
|
|
|
|
// Should contain base instructions from strategy system
|
|
|
- expect(prompt).toContain("CRITICAL OUTPUT FORMAT")
|
|
|
+ expect(systemPrompt).toContain("CRITICAL OUTPUT FORMAT")
|
|
|
})
|
|
|
|
|
|
it("should select UserRequestStrategy when user input is provided", () => {
|
|
|
@@ -47,8 +47,7 @@ describe("GhostStrategy", () => {
|
|
|
userInput: "Add a function to calculate sum",
|
|
|
}
|
|
|
|
|
|
- const systemPrompt = strategy.getSystemPrompt(context)
|
|
|
- const userPrompt = strategy.getSuggestionPrompt(context)
|
|
|
+ const { systemPrompt, userPrompt } = strategy.getPrompts(context)
|
|
|
|
|
|
// UserRequestStrategy should be selected
|
|
|
expect(systemPrompt).toContain("Execute User's Explicit Request")
|
|
|
@@ -80,35 +79,13 @@ describe("GhostStrategy", () => {
|
|
|
],
|
|
|
}
|
|
|
|
|
|
- const systemPrompt = strategy.getSystemPrompt(context)
|
|
|
+ const { systemPrompt } = strategy.getPrompts(context)
|
|
|
|
|
|
// ErrorFixStrategy should be selected
|
|
|
expect(systemPrompt).toContain("Fix Compilation Errors and Warnings")
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- describe("getSuggestionPrompt", () => {
|
|
|
- it("should delegate to PromptStrategyManager", () => {
|
|
|
- const mockDocument = {
|
|
|
- languageId: "typescript",
|
|
|
- getText: () => "const x = 1;",
|
|
|
- lineAt: (line: number) => ({ text: "const x = 1;" }),
|
|
|
- uri: { toString: () => "file:///test.ts" },
|
|
|
- offsetAt: (position: vscode.Position) => 13,
|
|
|
- } as vscode.TextDocument
|
|
|
-
|
|
|
- const context: GhostSuggestionContext = {
|
|
|
- document: mockDocument,
|
|
|
- }
|
|
|
-
|
|
|
- const prompt = strategy.getSuggestionPrompt(context)
|
|
|
-
|
|
|
- // Should return a structured prompt
|
|
|
- expect(prompt).toBeDefined()
|
|
|
- expect(prompt.length).toBeGreaterThan(0)
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
describe("Integration", () => {
|
|
|
it("should work with both system and user prompts", () => {
|
|
|
const mockDocument = {
|
|
|
@@ -124,8 +101,7 @@ describe("GhostStrategy", () => {
|
|
|
userInput: "Complete this function",
|
|
|
}
|
|
|
|
|
|
- const systemPrompt = strategy.getSystemPrompt(context)
|
|
|
- const userPrompt = strategy.getSuggestionPrompt(context)
|
|
|
+ const { systemPrompt, userPrompt } = strategy.getPrompts(context)
|
|
|
|
|
|
// System prompt should contain format instructions
|
|
|
expect(systemPrompt).toContain("CRITICAL OUTPUT FORMAT")
|
|
|
@@ -220,8 +196,7 @@ describe("GhostStrategy", () => {
|
|
|
document: mockDocument,
|
|
|
}
|
|
|
|
|
|
- const systemPrompt = strategy.getSystemPrompt(context)
|
|
|
- const userPrompt = strategy.getSuggestionPrompt(context)
|
|
|
+ const { systemPrompt, userPrompt } = strategy.getPrompts(context)
|
|
|
|
|
|
expect(systemPrompt).toBeDefined()
|
|
|
expect(systemPrompt.length).toBeGreaterThan(0)
|
|
|
@@ -279,8 +254,7 @@ describe("GhostStrategy", () => {
|
|
|
]
|
|
|
|
|
|
contexts.forEach((context) => {
|
|
|
- const systemPrompt = strategy.getSystemPrompt(context as GhostSuggestionContext)
|
|
|
- const userPrompt = strategy.getSuggestionPrompt(context as GhostSuggestionContext)
|
|
|
+ const { systemPrompt, userPrompt } = strategy.getPrompts(context as GhostSuggestionContext)
|
|
|
|
|
|
expect(systemPrompt).toBeDefined()
|
|
|
expect(systemPrompt.length).toBeGreaterThan(0)
|