From b7defc8d912b09d9323e05a82442bea17c6faef4 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 26 Nov 2024 14:30:26 -0800 Subject: [PATCH] feat: split diff --- core/commands/slash/commit.ts | 2 +- core/context/providers/DiffContextProvider.ts | 2 +- extensions/vscode/src/test/test-suites/ideUtils.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/commands/slash/commit.ts b/core/commands/slash/commit.ts index fc6e81531..2890a7ad0 100644 --- a/core/commands/slash/commit.ts +++ b/core/commands/slash/commit.ts @@ -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, diff --git a/core/context/providers/DiffContextProvider.ts b/core/context/providers/DiffContextProvider.ts index a0fc7524d..ef5823580 100644 --- a/core/context/providers/DiffContextProvider.ts +++ b/core/context/providers/DiffContextProvider.ts @@ -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", }, ]; diff --git a/extensions/vscode/src/test/test-suites/ideUtils.test.ts b/extensions/vscode/src/test/test-suites/ideUtils.test.ts index 99a0532ae..3a289a079 100644 --- a/extensions/vscode/src/test/test-suites/ideUtils.test.ts +++ b/extensions/vscode/src/test/test-suites/ideUtils.test.ts @@ -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 () => {