From c50d73a13f9b0f6ac3a97bc0ae2bae61f71f3e6c Mon Sep 17 00:00:00 2001 From: George Date: Tue, 6 Aug 2024 22:57:24 +0100 Subject: [PATCH 1/8] Add includeUnstaged option to commit slash command --- core/commands/slash/commit.ts | 4 +-- core/config/promptFile.ts | 2 +- core/config/types.ts | 2 +- core/context/providers/DiffContextProvider.ts | 2 +- core/index.d.ts | 2 +- core/protocol/ide.ts | 2 +- core/util/filesystem.ts | 2 +- core/util/messageIde.ts | 4 +-- core/util/reverseMessageIde.ts | 4 +-- docs/docs/customization/slash-commands.md | 5 ++-- docs/static/schemas/config.json | 21 ++++++++++++++++ .../src/main/resources/config_schema.json | 21 ++++++++++++++++ extensions/vscode/config_schema.json | 21 ++++++++++++++++ extensions/vscode/continue_rc_schema.json | 25 ++++++++++++++++++- .../vscode/src/extension/VsCodeMessenger.ts | 2 +- extensions/vscode/src/ideProtocol.ts | 4 +-- .../src/test/test-suites/ideUtils.test.ts | 2 +- extensions/vscode/src/util/ideUtils.ts | 18 ++++++------- 18 files changed, 113 insertions(+), 30 deletions(-) diff --git a/core/commands/slash/commit.ts b/core/commands/slash/commit.ts index 899222998..90be8c3a9 100644 --- a/core/commands/slash/commit.ts +++ b/core/commands/slash/commit.ts @@ -4,8 +4,8 @@ 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(); + run: async function* ({ ide, llm, params }) { + const diff = await ide.getDiff(!params?.includeUnstaged); if (!diff || diff.trim() === "") { yield "No changes detected. Make sure you are in a git repository with current changes."; diff --git a/core/config/promptFile.ts b/core/config/promptFile.ts index 92d558aaf..fbe097f71 100644 --- a/core/config/promptFile.ts +++ b/core/config/promptFile.ts @@ -146,7 +146,7 @@ async function renderPrompt(prompt: string, context: any, userInput: string) { const helpers = getContextProviderHelpers(context); // A few context providers that don't need to be in config.json to work in .prompt files - const diff = await context.ide.getDiff(); + const diff = await context.ide.getDiff(false); const currentFilePath = await context.ide.getCurrentFile(); const currentFile = currentFilePath ? await context.ide.readFile(currentFilePath) diff --git a/core/config/types.ts b/core/config/types.ts index d950c15f7..bbffc3ae6 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -375,7 +375,7 @@ declare global { export interface IDE { getIdeInfo(): Promise; - getDiff(): Promise; + getDiff(stagedOnly: boolean): Promise; isTelemetryEnabled(): Promise; getUniqueId(): Promise; getTerminalContents(): Promise; diff --git a/core/context/providers/DiffContextProvider.ts b/core/context/providers/DiffContextProvider.ts index 696b71a21..ae0eb42b8 100644 --- a/core/context/providers/DiffContextProvider.ts +++ b/core/context/providers/DiffContextProvider.ts @@ -17,7 +17,7 @@ class DiffContextProvider extends BaseContextProvider { query: string, extras: ContextProviderExtras, ): Promise { - const diff = await extras.ide.getDiff(); + const diff = await extras.ide.getDiff(false); return [ { description: "The current git diff", diff --git a/core/index.d.ts b/core/index.d.ts index 8c08c5923..7cd6865a2 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -442,7 +442,7 @@ export interface IdeSettings { export interface IDE { getIdeInfo(): Promise; getIdeSettings(): Promise; - getDiff(): Promise; + getDiff(stagedOnly: boolean): Promise; isTelemetryEnabled(): Promise; getUniqueId(): Promise; getTerminalContents(): Promise; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index bb5f59810..f05436908 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -47,7 +47,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { getPinnedFiles: [undefined, string[]]; showLines: [{ filepath: string; startLine: number; endLine: number }, void]; readRangeInFile: [{ filepath: string; range: Range }, string]; - getDiff: [undefined, string]; + getDiff: [{ stagedOnly: boolean }, string]; getWorkspaceConfigs: [undefined, ContinueRcJson[]]; getTerminalContents: [undefined, string]; getDebugLocals: [{ threadIndex: number }, string]; diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index 978fa0829..a7251e80a 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -108,7 +108,7 @@ class FileSystemIde implements IDE { return Promise.resolve([]); } - getDiff(): Promise { + getDiff(stagedOnly: boolean): Promise { return Promise.resolve(""); } diff --git a/core/util/messageIde.ts b/core/util/messageIde.ts index 396df29c7..455a885ac 100644 --- a/core/util/messageIde.ts +++ b/core/util/messageIde.ts @@ -108,8 +108,8 @@ export class MessageIde implements IDE { return this.request("getWorkspaceConfigs", undefined); } - async getDiff() { - return await this.request("getDiff", undefined); + async getDiff(stagedOnly: boolean) { + return await this.request("getDiff", { stagedOnly }); } async getTerminalContents() { diff --git a/core/util/reverseMessageIde.ts b/core/util/reverseMessageIde.ts index 1e5a2d1ca..ac8e18c10 100644 --- a/core/util/reverseMessageIde.ts +++ b/core/util/reverseMessageIde.ts @@ -104,8 +104,8 @@ export class ReverseMessageIde { return this.ide.getIdeSettings(); }); - this.on("getDiff", () => { - return this.ide.getDiff(); + this.on("getDiff", (data) => { + return this.ide.getDiff(data.stagedOnly); }); this.on("getTerminalContents", () => { diff --git a/docs/docs/customization/slash-commands.md b/docs/docs/customization/slash-commands.md index 661f7e5e6..39594bf27 100644 --- a/docs/docs/customization/slash-commands.md +++ b/docs/docs/customization/slash-commands.md @@ -68,7 +68,8 @@ Shows the LLM your current git diff and asks it to generate a commit message. ```json { "name": "commit", - "description": "Generate a commit message for the current changes" + "description": "Generate a commit message for the current changes", + "params": { "includeUnstaged": false } } ``` @@ -151,7 +152,7 @@ export function modifyConfig(config: Config): Config { name: "commit", description: "Write a commit message", run: async function* (sdk) { - const diff = await sdk.ide.getDiff(); + const diff = await sdk.ide.getDiff(true); for await (const message of sdk.llm.streamComplete( `${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`, { diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index e9d6e375e..99fcfb171 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1380,6 +1380,27 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": ["commit"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "includeUnstaged": { + "type": "boolean", + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + } + } + } + } + } } ], "required": ["name", "description"] diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index e9d6e375e..99fcfb171 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1380,6 +1380,27 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": ["commit"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "includeUnstaged": { + "type": "boolean", + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + } + } + } + } + } } ], "required": ["name", "description"] diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index e9d6e375e..99fcfb171 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1380,6 +1380,27 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": ["commit"] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "includeUnstaged": { + "type": "boolean", + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + } + } + } + } + } } ], "required": ["name", "description"] diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 180908ddb..047c3eb71 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1526,6 +1526,29 @@ } } } + }, + { + "if": { + "properties": { + "name": { + "enum": [ + "commit" + ] + } + } + }, + "then": { + "properties": { + "params": { + "properties": { + "includeUnstaged": { + "type": "boolean", + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + } + } + } + } + } } ], "required": [ @@ -2726,4 +2749,4 @@ } } } -} \ No newline at end of file +} diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index a51bd8233..fe2d824c2 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -218,7 +218,7 @@ export class VsCodeMessenger { return ide.getIdeSettings(); }); this.onWebviewOrCore("getDiff", async (msg) => { - return ide.getDiff(); + return ide.getDiff(msg.data.stagedOnly); }); this.onWebviewOrCore("getTerminalContents", async (msg) => { return ide.getTerminalContents(); diff --git a/extensions/vscode/src/ideProtocol.ts b/extensions/vscode/src/ideProtocol.ts index df3a909f1..207020329 100644 --- a/extensions/vscode/src/ideProtocol.ts +++ b/extensions/vscode/src/ideProtocol.ts @@ -282,8 +282,8 @@ class VsCodeIde implements IDE { return Promise.resolve(vscode.env.machineId); } - async getDiff(): Promise { - return await this.ideUtils.getDiff(); + async getDiff(stagedOnly: boolean): Promise { + return await this.ideUtils.getDiff(stagedOnly); } async getTerminalContents(): Promise { diff --git a/extensions/vscode/src/test/test-suites/ideUtils.test.ts b/extensions/vscode/src/test/test-suites/ideUtils.test.ts index 761a8343c..adae3fab4 100644 --- a/extensions/vscode/src/test/test-suites/ideUtils.test.ts +++ b/extensions/vscode/src/test/test-suites/ideUtils.test.ts @@ -80,7 +80,7 @@ describe("IDE Utils", () => { }); test("noDiff", async () => { - const noDiff = await utils.getDiff(); + const noDiff = await utils.getDiff(false); assert(noDiff === ""); }); diff --git a/extensions/vscode/src/util/ideUtils.ts b/extensions/vscode/src/util/ideUtils.ts index 15f79ddfd..cf07388de 100644 --- a/extensions/vscode/src/util/ideUtils.ts +++ b/extensions/vscode/src/util/ideUtils.ts @@ -593,7 +593,7 @@ export class VsCodeIdeUtils { return repo?.state?.HEAD?.name || "NONE"; } - async getDiff(): Promise { + async getDiff(stagedOnly: boolean): Promise { let diffs: string[] = []; let repos = []; @@ -604,17 +604,13 @@ export class VsCodeIdeUtils { } repos.push(repo.state.HEAD?.name); - // Staged changes - // const a = await repo.diffIndexWithHEAD(); + const staged = await repo.diff(true); - // Un-staged changes - // const b = await repo.diffWithHEAD(); - const unstaged = await repo.diff(false); - // All changes - // const e = await repo.diffWith("HEAD"); - // Only staged - // const f = await repo.diffIndexWith("HEAD"); - diffs.push(`${staged}\n${unstaged}`); + diffs.push(`${staged}`); + if (!stagedOnly) { + const unstaged = await repo.diff(false); + diffs.push(`\n${unstaged}`); + } } const fullDiff = diffs.join("\n\n"); From d371133becfdd2029776968fd177c5225289053f Mon Sep 17 00:00:00 2001 From: George Date: Sun, 29 Sep 2024 15:25:35 +0100 Subject: [PATCH 2/8] Merge in docs changes --- .../tutorials/build-your-own-slash-command.md | 106 ------------------ 1 file changed, 106 deletions(-) diff --git a/docs/docs/customize/tutorials/build-your-own-slash-command.md b/docs/docs/customize/tutorials/build-your-own-slash-command.md index d33ec9d42..b3fc25c3a 100644 --- a/docs/docs/customize/tutorials/build-your-own-slash-command.md +++ b/docs/docs/customize/tutorials/build-your-own-slash-command.md @@ -2,112 +2,6 @@ title: Build your own slash command --- -# Slash Commands - -Slash commands are shortcuts that can be activated by typing '/' and selecting from the dropdown. For example, the built-in '/edit' slash command let you stream edits directly into your editor. - -![slash-commands](/img/slash-commands.png) - -## Built-in Slash Commands - -To use any of the built-in slash commands, open `~/.continue/config.json` and add it to the `slashCommands` list. - -### `/edit` - -Select code with ctrl/cmd + L (VS Code) or ctrl/cmd + J (JetBrains), and then type "/edit", followed by instructions for the edit. Continue will stream the changes into a side-by-side diff editor. - -```json -{ - "name": "edit", - "description": "Edit highlighted code" -} -``` - -### `/comment` - -Comment works just like /edit, except it will automatically prompt the LLM to comment the code. - -```json -{ - "name": "comment", - "description": "Write comments for the highlighted code" -} -``` - -### `/share` - -Type "/share" to generate a shareable markdown transcript of your current chat history. - -```json -{ - "name": "share", - "description": "Export the current chat session to markdown", - "params": { "outputDir": "~/.continue/session-transcripts" } -} -``` - -Use the `outputDir` parameter to specify where you want to the markdown file to be saved. - -### `/cmd` - -Generate a shell command from natural language and (only in VS Code) automatically paste it into the terminal. - -```json -{ - "name": "cmd", - "description": "Generate a shell command" -} -``` - -### `/commit` - -Shows the LLM your current git diff and asks it to generate a commit message. - -```json -{ - "name": "commit", - "description": "Generate a commit message for the current changes", - "params": { "includeUnstaged": false } -} -``` - -### `/http` - -Write a custom slash command at your own HTTP endpoint. Set 'url' in the params object for the endpoint you have setup. The endpoint should return a sequence of string updates, which will be streamed to the Continue sidebar. See our basic [FastAPI example](https://github.com/continuedev/continue/blob/74002369a5e435735b83278fb965e004ae38a97d/core/context/providers/context_provider_server.py#L34-L45) for reference. - -```json -{ - "name": "http", - "description": "Does something custom", - "params": { "url": "" } -} -``` - -### `/issue` - -Describe the issue you'd like to generate, and Continue will turn into a well-formatted title and body, then give you a link to the draft so you can submit. Make sure to set the URL of the repository you want to generate issues for. - -```json -{ - "name": "issue", - "description": "Generate a link to a drafted GitHub issue", - "params": { "repositoryUrl": "https://github.com/continuedev/continue" } -} -``` - -### `/so` - -The StackOverflow slash command will automatically pull results from StackOverflow to answer your question, quoting links along with its answer. - -```json -{ - "name": "so", - "description": "Reference StackOverflow to answer the question" -} -``` - -## Custom Slash Commands - There are two ways to add custom slash commands: 1. With natural language prompts - this is simpler and only requires writing a string or string template. From cf8b4bdc4391e5c027cf72756fee21843bd1e9d4 Mon Sep 17 00:00:00 2001 From: George Date: Sun, 29 Sep 2024 15:30:10 +0100 Subject: [PATCH 3/8] Refactor stagedOnly -> includeUnstaged --- core/commands/slash/commit.ts | 3 ++- core/config/types.ts | 2 +- core/index.d.ts | 2 +- core/protocol/ide.ts | 2 +- core/util/filesystem.ts | 2 +- core/util/messageIde.ts | 4 ++-- core/util/reverseMessageIde.ts | 2 +- extensions/vscode/src/VsCodeIde.ts | 4 ++-- extensions/vscode/src/extension/VsCodeMessenger.ts | 2 +- extensions/vscode/src/util/ideUtils.ts | 4 ++-- 10 files changed, 14 insertions(+), 13 deletions(-) diff --git a/core/commands/slash/commit.ts b/core/commands/slash/commit.ts index 90be8c3a9..648b76770 100644 --- a/core/commands/slash/commit.ts +++ b/core/commands/slash/commit.ts @@ -5,7 +5,8 @@ const CommitMessageCommand: SlashCommand = { name: "commit", description: "Generate a commit message for current changes", run: async function* ({ ide, llm, params }) { - const diff = await ide.getDiff(!params?.includeUnstaged); + const includeUnstaged = params ? params.includeUnstaged : false; + const diff = await ide.getDiff(includeUnstaged); if (!diff || diff.trim() === "") { yield "No changes detected. Make sure you are in a git repository with current changes."; diff --git a/core/config/types.ts b/core/config/types.ts index 0f9035097..8c03e171d 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -434,7 +434,7 @@ declare global { export interface IDE { getIdeInfo(): Promise; getIdeSettings(): Promise; - getDiff(stagedOnly: boolean): Promise; + getDiff(includeUnstaged: boolean): Promise; isTelemetryEnabled(): Promise; getUniqueId(): Promise; getTerminalContents(): Promise; diff --git a/core/index.d.ts b/core/index.d.ts index 50b66f933..1995045fe 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -464,7 +464,7 @@ export interface IdeSettings { export interface IDE { getIdeInfo(): Promise; getIdeSettings(): Promise; - getDiff(stagedOnly: boolean): Promise; + getDiff(includeUnstaged: boolean): Promise; isTelemetryEnabled(): Promise; getUniqueId(): Promise; getTerminalContents(): Promise; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 542356006..a62b3fdce 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -52,7 +52,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { getPinnedFiles: [undefined, string[]]; showLines: [{ filepath: string; startLine: number; endLine: number }, void]; readRangeInFile: [{ filepath: string; range: Range }, string]; - getDiff: [{ stagedOnly: boolean }, string]; + getDiff: [{ includeUnstaged: boolean }, string]; getWorkspaceConfigs: [undefined, ContinueRcJson[]]; getTerminalContents: [undefined, string]; getDebugLocals: [{ threadIndex: number }, string]; diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index b5ca3be1e..e907d6642 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -124,7 +124,7 @@ class FileSystemIde implements IDE { return Promise.resolve([]); } - getDiff(stagedOnly: boolean): Promise { + getDiff(includeUnstaged: boolean): Promise { return Promise.resolve(""); } diff --git a/core/util/messageIde.ts b/core/util/messageIde.ts index fcd7f199a..5eaaf8752 100644 --- a/core/util/messageIde.ts +++ b/core/util/messageIde.ts @@ -108,8 +108,8 @@ export class MessageIde implements IDE { return this.request("getWorkspaceConfigs", undefined); } - async getDiff(stagedOnly: boolean) { - return await this.request("getDiff", { stagedOnly }); + async getDiff(includeUnstaged: boolean) { + return await this.request("getDiff", { includeUnstaged }); } async getTerminalContents() { diff --git a/core/util/reverseMessageIde.ts b/core/util/reverseMessageIde.ts index e8bdd8797..1b0686d99 100644 --- a/core/util/reverseMessageIde.ts +++ b/core/util/reverseMessageIde.ts @@ -101,7 +101,7 @@ export class ReverseMessageIde { }); this.on("getDiff", (data) => { - return this.ide.getDiff(data.stagedOnly); + return this.ide.getDiff(data.includeUnstaged); }); this.on("getTerminalContents", () => { diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index e8ca30c90..5e5ed1ccd 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -304,8 +304,8 @@ class VsCodeIde implements IDE { return Promise.resolve(vscode.env.machineId); } - async getDiff(stagedOnly: boolean): Promise { - return await this.ideUtils.getDiff(stagedOnly); + async getDiff(includeUnstaged: boolean): Promise { + return await this.ideUtils.getDiff(includeUnstaged); } async getTerminalContents(): Promise { diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index afdf16b23..8f57a421f 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -283,7 +283,7 @@ export class VsCodeMessenger { return ide.getIdeSettings(); }); this.onWebviewOrCore("getDiff", async (msg) => { - return ide.getDiff(msg.data.stagedOnly); + return ide.getDiff(msg.data.includeUnstaged); }); this.onWebviewOrCore("getTerminalContents", async (msg) => { return ide.getTerminalContents(); diff --git a/extensions/vscode/src/util/ideUtils.ts b/extensions/vscode/src/util/ideUtils.ts index 717ce481c..839806111 100644 --- a/extensions/vscode/src/util/ideUtils.ts +++ b/extensions/vscode/src/util/ideUtils.ts @@ -619,7 +619,7 @@ export class VsCodeIdeUtils { return repo?.state?.HEAD?.name || "NONE"; } - async getDiff(stagedOnly: boolean): Promise { + async getDiff(includeUnstaged: boolean): Promise { let diffs: string[] = []; let repos = []; @@ -633,7 +633,7 @@ export class VsCodeIdeUtils { const staged = await repo.diff(true); diffs.push(`${staged}`); - if (!stagedOnly) { + if (includeUnstaged) { const unstaged = await repo.diff(false); diffs.push(`\n${unstaged}`); } From 3b0493961b155cfd62577589a36e30503a667d0d Mon Sep 17 00:00:00 2001 From: George Date: Mon, 14 Oct 2024 22:18:08 +0100 Subject: [PATCH 4/8] Include default in description --- docs/static/schemas/config.json | 2 +- extensions/intellij/src/main/resources/config_schema.json | 2 +- extensions/vscode/config_schema.json | 2 +- extensions/vscode/continue_rc_schema.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index aaaf5794d..1d18d3512 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1549,7 +1549,7 @@ "properties": { "includeUnstaged": { "type": "boolean", - "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included. Default is false." } } } diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 8ba4ea7d6..f7e4daf53 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1549,7 +1549,7 @@ "properties": { "includeUnstaged": { "type": "boolean", - "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included. Default is false." } } } diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 8ba4ea7d6..f7e4daf53 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1549,7 +1549,7 @@ "properties": { "includeUnstaged": { "type": "boolean", - "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included. Default is false." } } } diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index b3ed9a561..252b5a173 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1722,7 +1722,7 @@ "properties": { "includeUnstaged": { "type": "boolean", - "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included." + "markdownDescription": "If includeUnstaged is set to true, then unstaged changes are also included in the prompt, otherwise only staged changes are included. Default is false." } } } From 9a7022d594fb90cb30c4ad21f347dcabfa740037 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 14 Oct 2024 22:21:21 +0100 Subject: [PATCH 5/8] Update default check --- core/commands/slash/commit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/commands/slash/commit.ts b/core/commands/slash/commit.ts index 648b76770..034e07e5e 100644 --- a/core/commands/slash/commit.ts +++ b/core/commands/slash/commit.ts @@ -5,7 +5,7 @@ const CommitMessageCommand: SlashCommand = { name: "commit", description: "Generate a commit message for current changes", run: async function* ({ ide, llm, params }) { - const includeUnstaged = params ? params.includeUnstaged : false; + const includeUnstaged = params?.includeUnstaged ?? false; const diff = await ide.getDiff(includeUnstaged); if (!diff || diff.trim() === "") { From 99b767d653f12008c63727de678ec84fde951eac Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 14 Oct 2024 21:14:49 -0700 Subject: [PATCH 6/8] web context provider --- .vscode/launch.json | 2 +- core/context/providers/WebContextProvider.ts | 43 ++++++++++++ core/context/providers/index.ts | 10 +-- docs/static/schemas/config.json | 66 +++++++++++++++++++ extensions/vscode/config_schema.json | 24 ++++++- extensions/vscode/continue_rc_schema.json | 2 +- .../src/quickEdit/QuickEditQuickPick.ts | 2 +- gui/src/components/mainInput/MentionList.tsx | 5 +- 8 files changed, 144 insertions(+), 10 deletions(-) create mode 100644 core/context/providers/WebContextProvider.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index 896793040..835c09089 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -20,7 +20,7 @@ "outFiles": ["${workspaceFolder}/extensions/vscode/out/extension.js"], "preLaunchTask": "vscode-extension:build", "env": { - // "CONTROL_PLANE_ENV": "local" + "CONTROL_PLANE_ENV": "local" } }, { diff --git a/core/context/providers/WebContextProvider.ts b/core/context/providers/WebContextProvider.ts new file mode 100644 index 000000000..3e1002d33 --- /dev/null +++ b/core/context/providers/WebContextProvider.ts @@ -0,0 +1,43 @@ +import { BaseContextProvider } from ".."; +import { + ContextItem, + ContextProviderDescription, + ContextProviderExtras, +} from "../.."; +import { getHeaders } from "../../continueServer/stubs/headers"; +import { constants } from "../../deploy/constants"; + +export default class WebContextProvider extends BaseContextProvider { + private static ENDPOINT = new URL("web", constants.a); + private static DEFAULT_N = 6; + + static description: ContextProviderDescription = { + title: "web", + displayTitle: "Web", + description: "Search the web", + type: "normal", + renderInlineAs: "", + }; + + async getContextItems( + query: string, + extras: ContextProviderExtras, + ): Promise { + const resp = await extras.fetch(WebContextProvider.ENDPOINT, { + method: "POST", + headers: { + "Content-Type": "application/json", + ...(await getHeaders()), + }, + body: JSON.stringify({ + query: extras.fullInput, + n: this.options.n ?? WebContextProvider.DEFAULT_N, + }), + }); + if (!resp.ok) { + throw new Error("Failed to fetch web context"); + } + const json = await resp.json(); + return json; + } +} diff --git a/core/context/providers/index.ts b/core/context/providers/index.ts index 853c4c4fc..28f8aa33c 100644 --- a/core/context/providers/index.ts +++ b/core/context/providers/index.ts @@ -1,16 +1,18 @@ -import { ContextItem, ContextProviderName } from "../../"; import { BaseContextProvider } from "../"; +import { ContextProviderName } from "../../"; import CodeContextProvider from "./CodeContextProvider"; import ContinueProxyContextProvider from "./ContinueProxyContextProvider"; import CurrentFileContextProvider from "./CurrentFileContextProvider"; import DatabaseContextProvider from "./DatabaseContextProvider"; import DiffContextProvider from "./DiffContextProvider"; +import DiscordContextProvider from "./DiscordContextProvider"; import DocsContextProvider from "./DocsContextProvider"; import FileTreeContextProvider from "./FileTreeContextProvider"; import FolderContextProvider from "./FolderContextProvider"; import GitHubIssuesContextProvider from "./GitHubIssuesContextProvider"; import GitLabMergeRequestContextProvider from "./GitLabMergeRequestContextProvider"; import GoogleContextProvider from "./GoogleContextProvider"; +import GreptileContextProvider from "./GreptileContextProvider"; import HttpContextProvider from "./HttpContextProvider"; import JiraIssuesContextProvider from "./JiraIssuesContextProvider/"; import LocalsProvider from "./LocalsProvider"; @@ -18,12 +20,11 @@ import OSContextProvider from "./OSContextProvider"; import OpenFilesContextProvider from "./OpenFilesContextProvider"; import PostgresContextProvider from "./PostgresContextProvider"; import ProblemsContextProvider from "./ProblemsContextProvider"; +import RepoMapContextProvider from "./RepoMapContextProvider"; import SearchContextProvider from "./SearchContextProvider"; import TerminalContextProvider from "./TerminalContextProvider"; import URLContextProvider from "./URLContextProvider"; -import RepoMapContextProvider from "./RepoMapContextProvider"; -import DiscordContextProvider from "./DiscordContextProvider"; -import GreptileContextProvider from "./GreptileContextProvider"; +import WebContextProvider from "./WebContextProvider"; /** * Note: We are currently omitting the following providers due to bugs: @@ -57,6 +58,7 @@ export const Providers: (typeof BaseContextProvider)[] = [ RepoMapContextProvider, DiscordContextProvider, GreptileContextProvider, + WebContextProvider, ]; export function contextProviderClassFromName( diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 1d18d3512..f7e4daf53 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1650,6 +1650,72 @@ } }, "allOf": [ + { + "if": { + "properties": { + "name": { + "enum": ["discord"] + } + } + }, + "then": { + "allOf": [ + { + "properties": { + "params": { + "properties": { + "discordKey": { + "type": "string", + "description": "Your Discord bot token to access the Discord API. Required to fetch messages from servers." + }, + "guildId": { + "type": "string", + "description": "The ID of the guild (server) from which to fetch channels and messages." + }, + "channels": { + "type": "array", + "description": "A list of channel objects to search for messages", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The unique ID of the channel" + }, + "name": { + "type": "string", + "description": "The name of the channel" + } + }, + "required": ["id"] + } + } + }, + "required": ["discordKey"] + } + } + }, + { + "oneOf": [ + { + "properties": { + "params": { + "required": ["guildId"] + } + } + }, + { + "properties": { + "params": { + "required": ["channels"] + } + } + } + ] + } + ] + } + }, { "if": { "properties": { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index f7e4daf53..69221f9c7 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1609,7 +1609,8 @@ "database", "os", "repo-map", - "greptile" + "greptile", + "web" ], "markdownEnumDescriptions": [ "Reference the contents of the current changes as given by `git diff`", @@ -1634,7 +1635,8 @@ "Reference table schemas", "Operating system and CPU Information", "Map of files in the repository with important code highlights", - "Query your greptile index of the current repo" + "Query your greptile index of the current repo", + "Search the web for sources related to your question" ], "type": "string" }, @@ -1739,6 +1741,24 @@ "required": ["params"] } }, + { + "if": { "properties": { "name": { "enum": ["web"] } } }, + "then": { + "properties": { + "params": { + "properties": { + "n": { + "title": "N", + "description": "The number of results to return", + "default": 6, + "type": "integer" + } + } + } + }, + "required": ["params"] + } + }, { "if": { "properties": { diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 252b5a173..7414be280 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -3109,4 +3109,4 @@ } } } -} +} \ No newline at end of file diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index 0c0b276a8..64d262957 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -384,7 +384,7 @@ export class QuickEdit { const searchResults = this.miniSearch.search( searchQuery, - ) as FileMiniSearchResult[]; + ) as unknown as FileMiniSearchResult[]; if (searchResults.length > 0) { quickPick.items = searchResults diff --git a/gui/src/components/mainInput/MentionList.tsx b/gui/src/components/mainInput/MentionList.tsx index 95ddc15ca..a84294a23 100644 --- a/gui/src/components/mainInput/MentionList.tsx +++ b/gui/src/components/mainInput/MentionList.tsx @@ -60,6 +60,7 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = { docs: BookOpenIcon, issue: ExclamationCircleIcon, trash: TrashIcon, + web: GlobeAltIcon, "repo-map": FolderIcon, "/edit": PencilIcon, "/clear": TrashIcon, @@ -114,7 +115,9 @@ function DropdownIcon(props: { className?: string; item: ComboBoxItem }) { const ItemsDiv = styled.div` border-radius: ${defaultBorderRadius}; - box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0px 10px 20px rgba(0, 0, 0, 0.1); + box-shadow: + 0 0 0 1px rgba(0, 0, 0, 0.05), + 0px 10px 20px rgba(0, 0, 0, 0.1); font-size: 0.9rem; overflow-x: hidden; overflow-y: auto; From 8a7d7ce78cc6cf73f902f37c1f8ad89aeccb4e9d Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 14 Oct 2024 23:00:54 -0700 Subject: [PATCH 7/8] better error handling for web context provider --- core/context/providers/WebContextProvider.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/context/providers/WebContextProvider.ts b/core/context/providers/WebContextProvider.ts index 3e1002d33..b874e695e 100644 --- a/core/context/providers/WebContextProvider.ts +++ b/core/context/providers/WebContextProvider.ts @@ -35,7 +35,8 @@ export default class WebContextProvider extends BaseContextProvider { }), }); if (!resp.ok) { - throw new Error("Failed to fetch web context"); + const text = await resp.text(); + throw new Error(`Failed to fetch web context: ${text}`); } const json = await resp.json(); return json; From 5fabc22d72241f4d4a94de703d69de8f1d792f9e Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 14 Oct 2024 23:17:48 -0700 Subject: [PATCH 8/8] update changelog --- .changes/unreleased/Added-20241014-231551.yaml | 4 ++++ .changes/unreleased/Added-20241014-231622.yaml | 4 ++++ .changes/unreleased/Added-20241014-231639.yaml | 4 ++++ .changes/unreleased/Added-20241014-231657.yaml | 4 ++++ .changes/unreleased/Added-20241014-231714.yaml | 4 ++++ .changes/unreleased/Changed-20241014-231738.yaml | 4 ++++ extensions/vscode/CHANGELOG.md | 10 ++++++++++ extensions/vscode/package.json | 2 +- 8 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Added-20241014-231551.yaml create mode 100644 .changes/unreleased/Added-20241014-231622.yaml create mode 100644 .changes/unreleased/Added-20241014-231639.yaml create mode 100644 .changes/unreleased/Added-20241014-231657.yaml create mode 100644 .changes/unreleased/Added-20241014-231714.yaml create mode 100644 .changes/unreleased/Changed-20241014-231738.yaml diff --git a/.changes/unreleased/Added-20241014-231551.yaml b/.changes/unreleased/Added-20241014-231551.yaml new file mode 100644 index 000000000..1e323fab1 --- /dev/null +++ b/.changes/unreleased/Added-20241014-231551.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: Web context provider +time: 2024-10-14T23:15:51.670444-07:00 diff --git a/.changes/unreleased/Added-20241014-231622.yaml b/.changes/unreleased/Added-20241014-231622.yaml new file mode 100644 index 000000000..82e129b6b --- /dev/null +++ b/.changes/unreleased/Added-20241014-231622.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: Cerebras inference provider +time: 2024-10-14T23:16:22.754491-07:00 diff --git a/.changes/unreleased/Added-20241014-231639.yaml b/.changes/unreleased/Added-20241014-231639.yaml new file mode 100644 index 000000000..89ff18abc --- /dev/null +++ b/.changes/unreleased/Added-20241014-231639.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: Automatic descriptions for previous chats +time: 2024-10-14T23:16:39.451261-07:00 diff --git a/.changes/unreleased/Added-20241014-231657.yaml b/.changes/unreleased/Added-20241014-231657.yaml new file mode 100644 index 000000000..e6a93349e --- /dev/null +++ b/.changes/unreleased/Added-20241014-231657.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: Discord context provider +time: 2024-10-14T23:16:57.089953-07:00 diff --git a/.changes/unreleased/Added-20241014-231714.yaml b/.changes/unreleased/Added-20241014-231714.yaml new file mode 100644 index 000000000..f53eeca37 --- /dev/null +++ b/.changes/unreleased/Added-20241014-231714.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: Improved full screen UI +time: 2024-10-14T23:17:14.574917-07:00 diff --git a/.changes/unreleased/Changed-20241014-231738.yaml b/.changes/unreleased/Changed-20241014-231738.yaml new file mode 100644 index 000000000..f0628aad7 --- /dev/null +++ b/.changes/unreleased/Changed-20241014-231738.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Changed +body: Easier way to accept/reject/re-prompt after cmd/ctrl+I +time: 2024-10-14T23:17:38.086964-07:00 diff --git a/extensions/vscode/CHANGELOG.md b/extensions/vscode/CHANGELOG.md index 99e76e5d5..cabf54bf2 100644 --- a/extensions/vscode/CHANGELOG.md +++ b/extensions/vscode/CHANGELOG.md @@ -5,6 +5,16 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +Pre-release Changes +### Added +* Web context provider +* Cerebras inference provider +* Automatic descriptions for previous chats +* Discord context provider +* Improved full screen UI +### Changed +* Easier way to accept/reject/re-prompt after cmd/ctrl+I + ## 0.8.53 - 2024-10-11 ### Added * Improved loading/accept/reject UI for apply diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index ffa27b831..2df04a2a0 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.215", + "version": "0.9.216", "repository": { "type": "git", "url": "https://github.com/continuedev/continue"