Skip to content

Commit 1e7aeea

Browse files
committed
feat: add prompt generation templates for mercury-coder
1 parent 0358717 commit 1e7aeea

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

core/nextEdit/templating/NextEditPromptEngine.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ import {
3939
type TemplateRenderer = (vars: TemplateVars) => string;
4040

4141
const NEXT_EDIT_MODEL_TEMPLATES: Record<NEXT_EDIT_MODELS, NextEditTemplate> = {
42+
"mercury-coder": {
43+
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\nThe developer was working on a section of code within the tags \`<|code_to_edit|>\` in the file located at {{{currentFilePath}}}.\nUsing the given \`recently_viewed_code_snippets\`, \`current_file_content\`, \`edit_diff_history\`, and the cursor position marked as \`<|cursor|>\`, please continue the developer's work. Update the \`code_to_edit\` section by predicting and completing the changes they would have made next. Provide the revised code that was between the \`<|code_to_edit|>\` and \`<|/code_to_edit|>\` tags, including the tags themselves.`,
44+
},
4245
"mercury-coder-nextedit": {
4346
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\nThe developer was working on a section of code within the tags \`<|code_to_edit|>\` in the file located at {{{currentFilePath}}}.\nUsing the given \`recently_viewed_code_snippets\`, \`current_file_content\`, \`edit_diff_history\`, and the cursor position marked as \`<|cursor|>\`, please continue the developer's work. Update the \`code_to_edit\` section by predicting and completing the changes they would have made next. Provide the revised code that was between the \`<|code_to_edit|>\` and \`<|/code_to_edit|>\` tags, including the tags themselves.`,
4447
},
@@ -90,7 +93,36 @@ export async function renderPrompt(
9093
let tv: TemplateVars;
9194

9295
switch (modelName) {
93-
case "mercury-coder-nextedit": {
96+
case NEXT_EDIT_MODELS.MERCURY_CODER: {
97+
userEdits = ctx.editDiffHistory;
98+
99+
// editedCodeWithTokens = insertTokens(
100+
// helper.fileContents.split("\n"),
101+
// helper.pos,
102+
// MERCURY_CURSOR,
103+
// );
104+
105+
const mercuryCtx: MercuryTemplateVars = {
106+
recentlyViewedCodeSnippets: recentlyViewedCodeSnippetsBlock(
107+
ctx.recentlyViewedCodeSnippets,
108+
),
109+
currentFileContent: currentFileContentBlock(
110+
ctx.currentFileContent,
111+
ctx.editableRegionStartLine,
112+
ctx.editableRegionEndLine,
113+
helper.pos,
114+
),
115+
editDiffHistory: editHistoryBlock(ctx.editDiffHistory),
116+
currentFilePath: ctx.currentFilePath,
117+
};
118+
119+
tv = mercuryCtx;
120+
121+
editedCodeWithTokens = mercuryCtx.currentFileContent;
122+
123+
break;
124+
}
125+
case NEXT_EDIT_MODELS.MERCURY_CODER_NEXTEDIT: {
94126
userEdits = ctx.editDiffHistory;
95127

96128
// editedCodeWithTokens = insertTokens(
@@ -119,7 +151,7 @@ export async function renderPrompt(
119151

120152
break;
121153
}
122-
case "instinct": {
154+
case NEXT_EDIT_MODELS.INSTINCT: {
123155
userEdits = ctx.editDiffHistory;
124156

125157
// editedCodeWithTokens = insertTokens(

0 commit comments

Comments
 (0)