refactor: separate mode and support prompts

- Rename customPrompts to customModePrompts for mode-specific prompts
- Add new customSupportPrompts type for support action prompts
- Update types to be more specific (CustomModePrompts and CustomSupportPrompts)
- Fix all related tests and component implementations
This commit is contained in:
sam hoang
2025-01-24 01:46:33 +07:00
parent 085d42873c
commit f86e96d157
13 changed files with 119 additions and 99 deletions

View File

@@ -97,18 +97,18 @@ describe("Code Action Prompts", () => {
it("should return custom template when provided", () => {
const customTemplate = "Custom template for explaining code"
const customPrompts = {
const customSupportPrompts = {
EXPLAIN: customTemplate,
}
const template = supportPrompt.get(customPrompts, "EXPLAIN")
const template = supportPrompt.get(customSupportPrompts, "EXPLAIN")
expect(template).toBe(customTemplate)
})
it("should return default template when custom prompts does not include type", () => {
const customPrompts = {
const customSupportPrompts = {
SOMETHING_ELSE: "Other template",
}
const template = supportPrompt.get(customPrompts, "EXPLAIN")
const template = supportPrompt.get(customSupportPrompts, "EXPLAIN")
expect(template).toBe(supportPrompt.default.EXPLAIN)
})
})
@@ -116,7 +116,7 @@ describe("Code Action Prompts", () => {
describe("create with custom prompts", () => {
it("should use custom template when provided", () => {
const customTemplate = "Custom template for ${filePath}"
const customPrompts = {
const customSupportPrompts = {
EXPLAIN: customTemplate,
}
@@ -126,7 +126,7 @@ describe("Code Action Prompts", () => {
filePath: testFilePath,
selectedText: testCode,
},
customPrompts,
customSupportPrompts,
)
expect(prompt).toContain(`Custom template for ${testFilePath}`)
@@ -134,7 +134,7 @@ describe("Code Action Prompts", () => {
})
it("should use default template when custom prompts does not include type", () => {
const customPrompts = {
const customSupportPrompts = {
EXPLAIN: "Other template",
}
@@ -144,7 +144,7 @@ describe("Code Action Prompts", () => {
filePath: testFilePath,
selectedText: testCode,
},
customPrompts,
customSupportPrompts,
)
expect(prompt).toContain("Other template")