Elffuss BraidHub

kikocis/continue public

main · 998 BRawPermalink
1import {
2 ContextItem,
3 ContextProviderDescription,
4 ContextProviderExtras,
5} from "../../index.js";
6import { BaseContextProvider } from "../index.js";
7
8class DiffContextProvider extends BaseContextProvider {
9 static description: ContextProviderDescription = {
10 title: "diff",
11 displayTitle: "Git Diff",
12 description: "Reference the current git diff",
13 type: "normal",
14 };
15
16 async getContextItems(
17 query: string,
18 extras: ContextProviderExtras,
19 ): Promise<ContextItem[]> {
20 const includeUnstaged = this.options?.includeUnstaged ?? true;
21 const diffs = await extras.ide.getDiff(includeUnstaged); // TODO use diff cache (currently cache always includes unstaged)
22 return [
23 {
24 description: "The current git diff",
25 content:
26 diffs.length === 0
27 ? "Git shows no current changes."
28 : `\`\`\`git diff\n${diffs.join("\n")}\n\`\`\``,
29 name: "Git Diff",
30 },
31 ];
32 }
33}
34
35export default DiffContextProvider;