refactor: generalize prompt enhancement into single completion handler

- Rename enhance-prompt.ts to single-completion-handler.ts for better clarity
- Refactor enhancement logic to be more generic and reusable
- Update prompt template handling to use template literals
- Adjust tests and imports accordingly
This commit is contained in:
sam hoang
2025-01-24 01:14:48 +07:00
parent 149e86ed0a
commit 085d42873c
5 changed files with 39 additions and 28 deletions

View File

@@ -36,7 +36,7 @@ import { getNonce } from "./getNonce"
import { getUri } from "./getUri"
import { playSound, setSoundEnabled, setSoundVolume } from "../../utils/sound"
import { checkExistKey } from "../../shared/checkExistApiConfig"
import { enhancePrompt } from "../../utils/enhance-prompt"
import { singleCompletionHandler } from "../../utils/single-completion-handler"
import { getCommitInfo, searchCommits, getWorkingState } from "../../utils/git"
import { ConfigManager } from "../config/ConfigManager"
import { CustomModesManager } from "../config/CustomModesManager"
@@ -996,11 +996,17 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
}
const enhancedPrompt = await enhancePrompt(
const enhancedPrompt = await singleCompletionHandler(
configToUse,
message.text,
supportPrompt.get(customPrompts, "ENHANCE"),
supportPrompt.create(
"ENHANCE",
{
userInput: message.text,
},
customPrompts,
),
)
await this.postMessageToWebview({
type: "enhancedPrompt",
text: enhancedPrompt,