continue-custom/core/commands/slash/commit.ts
Rob Leidle 78a4025414 Offload all token counting to worker processes as well as some optimizations to do more token counting in parallel
Adding the workerpool logic broke gui as vite does not support __dirname
or path.join(...). To work around this, moved the gui dependency of
stripImages out of countTokens.ts
2024-07-26 13:10:36 -07:00

24 lines
996 B
TypeScript

import { SlashCommand } from "../../index.js";
import { stripImages } from "../../llm/images.js";
const CommitMessageCommand: SlashCommand = {
name: "commit",
description: "Generate a commit message for current changes",
run: async function* ({ ide, llm, input }) {
const diff = await ide.getDiff();
if (!diff || diff.trim() === "") {
yield "No changes detected. Make sure you are in a git repository with current changes.";
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.`;
for await (const chunk of llm.streamChat([
{ role: "user", content: prompt },
])) {
yield stripImages(chunk.content);
}
},
};
export default CommitMessageCommand;