diff --git a/core/nextEdit/providers/MercuryCoderNextEditProvider.ts b/core/nextEdit/providers/MercuryCoderNextEditProvider.ts index 49527c84e..533f4341c 100644 --- a/core/nextEdit/providers/MercuryCoderNextEditProvider.ts +++ b/core/nextEdit/providers/MercuryCoderNextEditProvider.ts @@ -1,5 +1,6 @@ import { HelperVars } from "../../autocomplete/util/HelperVars.js"; import { NEXT_EDIT_MODELS } from "../../llm/constants.js"; +import { getUriPathBasename } from "../../util/uri.js"; import { MERCURY_SYSTEM_PROMPT, UNIQUE_TOKEN } from "../constants.js"; import { currentFileContentBlock, @@ -58,7 +59,7 @@ export class MercuryCoderProvider extends BaseNextEditModelProvider { editableRegionStartLine: context.editableRegionStartLine, editableRegionEndLine: context.editableRegionEndLine, editDiffHistory: context.diffContext, - currentFilePath: context.helper.filepath, + currentFilePath: getUriPathBasename(context.helper.filepath), }; } diff --git a/core/nextEdit/templating/NextEditPromptEngine.ts b/core/nextEdit/templating/NextEditPromptEngine.ts index 0d02a2f27..f2ef8f041 100644 --- a/core/nextEdit/templating/NextEditPromptEngine.ts +++ b/core/nextEdit/templating/NextEditPromptEngine.ts @@ -17,7 +17,7 @@ export const NEXT_EDIT_MODEL_TEMPLATES: Record< NextEditTemplate > = { "mercury-coder": { - template: `${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_OPEN}\n{{{recentlyViewedCodeSnippets}}}\n${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_CLOSE}\n\n${MERCURY_CURRENT_FILE_CONTENT_OPEN}\n{{{currentFileContent}}}\n${MERCURY_CURRENT_FILE_CONTENT_CLOSE}\n\n${MERCURY_EDIT_DIFF_HISTORY_OPEN}\n{{{editDiffHistory}}}\n${MERCURY_EDIT_DIFF_HISTORY_CLOSE}\n`, + template: `${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_OPEN}\n{{{recentlyViewedCodeSnippets}}}\n${MERCURY_RECENTLY_VIEWED_CODE_SNIPPETS_CLOSE}\n\n${MERCURY_CURRENT_FILE_CONTENT_OPEN}\ncurrent_file_path: {{{currentFilePath}}}\n{{{currentFileContent}}}\n${MERCURY_CURRENT_FILE_CONTENT_CLOSE}\n\n${MERCURY_EDIT_DIFF_HISTORY_OPEN}\n{{{editDiffHistory}}}\n${MERCURY_EDIT_DIFF_HISTORY_CLOSE}\n`, }, instinct: { template: `${INSTINCT_USER_PROMPT_PREFIX}\n\n### Context:\n{{{contextSnippets}}}\n\n### User Edits:\n\n{{{editDiffHistory}}}\n\n### User Excerpt:\n{{{currentFilePath}}}\n\n{{{currentFileContent}}}\`\`\`\n### Response:`, diff --git a/core/nextEdit/templating/NextEditPromptEngine.vitest.ts b/core/nextEdit/templating/NextEditPromptEngine.vitest.ts index 7fd189ecc..184a86b96 100644 --- a/core/nextEdit/templating/NextEditPromptEngine.vitest.ts +++ b/core/nextEdit/templating/NextEditPromptEngine.vitest.ts @@ -39,6 +39,7 @@ describe("NextEditPromptEngine", () => { expect(template).toContain("{{{recentlyViewedCodeSnippets}}}"); expect(template).toContain("{{{currentFileContent}}}"); expect(template).toContain("{{{editDiffHistory}}}"); + expect(template).toContain("{{{currentFilePath}}}"); }); it("instinct template should contain expected tokens", () => { @@ -87,11 +88,13 @@ describe("NextEditPromptEngine", () => { recentlyViewedCodeSnippets: "snippet1", currentFileContent: "file content", editDiffHistory: "diff history", + currentFilePath: "file.py", }); expect(result).toContain("snippet1"); expect(result).toContain("file content"); expect(result).toContain("diff history"); + expect(result).toContain("current_file_path: file.py"); }); });