feat: split diff

This commit is contained in:
tomasz-io 2024-11-26 14:30:26 -08:00
parent db88b285fe
commit b7defc8d91
3 changed files with 3 additions and 3 deletions

View file

@ -13,7 +13,7 @@ const CommitMessageCommand: SlashCommand = {
return;
}
const prompt = `${diff}\n\nGenerate a commit message for the above set of changes. First, give a single sentence, no more than 80 characters. Then, after 2 line breaks, give a list of no more than 5 short bullet points, each no more than 40 characters. Output nothing except for the commit message, and don't surround it in quotes.`;
const prompt = `${diff.joing("\n")}\n\nGenerate a commit message for the above set of changes. First, give a single sentence, no more than 80 characters. Then, after 2 line breaks, give a list of no more than 5 short bullet points, each no more than 40 characters. Output nothing except for the commit message, and don't surround it in quotes.`;
for await (const chunk of llm.streamChat(
[{ role: "user", content: prompt }],
new AbortController().signal,

View file

@ -24,7 +24,7 @@ class DiffContextProvider extends BaseContextProvider {
content:
diff.length === 0
? "Git shows no current changes."
: `\`\`\`git diff\n${diff}\n\`\`\``,
: `\`\`\`git diff\n${diff.join("\n")}\n\`\`\``,
name: "Git Diff",
},
];

View file

@ -77,7 +77,7 @@ describe("IDE Utils", () => {
test("noDiff", async () => {
const noDiff = await utils.getDiff(false);
assert(noDiff === "");
assert(noDiff.length === 0);
});
test.skip("getBranch", async () => {