Elffuss BraidHub

kikocis/continue public

main · 1.4 KiBRawPermalink
1import { PromptTemplateFunction } from "../../..";
2
3export const claudeEditPrompt: PromptTemplateFunction = (_, otherData) => {
4 if (otherData?.codeToEdit?.trim().length === 0) {
5 return `\
6\`\`\`${otherData.language}
7${otherData.prefix}[BLANK]${otherData.codeToEdit}${otherData.suffix}
8\`\`\`
9
10Above is the file of code that the user is currently editing in. Their cursor is located at the "[BLANK]". They have requested that you fill in the "[BLANK]" with code that satisfies the following request:
11
12"${otherData.userInput}"
13
14Please generate this code. Your output will be only the code that should replace the "[BLANK]", without repeating any of the prefix or suffix, without any natural language explanation, and without messing up indentation. Here is the code that will replace the "[BLANK]":`;
15 }
16
17 const paragraphs = [
18 "The user has requested a section of code in a file to be rewritten.",
19 ];
20 if (otherData.prefix?.trim().length > 0) {
21 paragraphs.push(`This is the prefix of the file:
22\`\`\`${otherData.language}
23${otherData.prefix}
24\`\`\``);
25 }
26
27 if (otherData.suffix?.trim().length > 0) {
28 paragraphs.push(`This is the suffix of the file:
29\`\`\`${otherData.language}
30${otherData.suffix}
31\`\`\``);
32 }
33
34 paragraphs.push(`This is the code to rewrite:
35\`\`\`${otherData.language}
36${otherData.codeToEdit}
37\`\`\`
38
39The user's request is: "${otherData.userInput}"
40
41Here is the rewritten code:`);
42
43 return paragraphs.join("\n\n");
44};