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/.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/commands/slash/commit.ts b/core/commands/slash/commit.ts index 899222998..034e07e5e 100644 --- a/core/commands/slash/commit.ts +++ b/core/commands/slash/commit.ts @@ -4,8 +4,9 @@ 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 includeUnstaged = 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/promptFile.ts b/core/config/promptFile.ts index 88d57595a..ebbbd59ab 100644 --- a/core/config/promptFile.ts +++ b/core/config/promptFile.ts @@ -151,7 +151,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 4efdb99f2..989c5b9b8 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(): Promise; + getDiff(includeUnstaged: 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/context/providers/WebContextProvider.ts b/core/context/providers/WebContextProvider.ts new file mode 100644 index 000000000..b874e695e --- /dev/null +++ b/core/context/providers/WebContextProvider.ts @@ -0,0 +1,44 @@ +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) { + const text = await resp.text(); + throw new Error(`Failed to fetch web context: ${text}`); + } + 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/core/index.d.ts b/core/index.d.ts index 395813c1b..00646c93b 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(): Promise; + getDiff(includeUnstaged: boolean): Promise; isTelemetryEnabled(): Promise; getUniqueId(): Promise; getTerminalContents(): Promise; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 6e5907612..eda6bebfb 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: [undefined, 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 6d8dbd1b3..6e8bd6c0d 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -124,7 +124,7 @@ class FileSystemIde implements IDE { return Promise.resolve([]); } - getDiff(): Promise { + getDiff(includeUnstaged: boolean): Promise { return Promise.resolve(""); } diff --git a/core/util/messageIde.ts b/core/util/messageIde.ts index 98594ce1a..0ed9f63d2 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(includeUnstaged: boolean) { + return await this.request("getDiff", { includeUnstaged }); } async getTerminalContents() { diff --git a/core/util/reverseMessageIde.ts b/core/util/reverseMessageIde.ts index 039c7f5cb..a42ece75c 100644 --- a/core/util/reverseMessageIde.ts +++ b/core/util/reverseMessageIde.ts @@ -100,8 +100,8 @@ export class ReverseMessageIde { return this.ide.getIdeSettings(); }); - this.on("getDiff", () => { - return this.ide.getDiff(); + this.on("getDiff", (data) => { + return this.ide.getDiff(data.includeUnstaged); }); this.on("getTerminalContents", () => { 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 d0a744916..b3fc25c3a 100644 --- a/docs/docs/customize/tutorials/build-your-own-slash-command.md +++ b/docs/docs/customize/tutorials/build-your-own-slash-command.md @@ -44,7 +44,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 c000f2d7f..f7e4daf53 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1534,6 +1534,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. Default is false." + } + } + } + } + } } ], "required": ["name", "description"] @@ -1629,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/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 58128d128..f7e4daf53 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1534,6 +1534,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. Default is false." + } + } + } + } + } } ], "required": ["name", "description"] 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/config_schema.json b/extensions/vscode/config_schema.json index 58128d128..69221f9c7 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1534,6 +1534,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. Default is false." + } + } + } + } + } } ], "required": ["name", "description"] @@ -1588,7 +1609,8 @@ "database", "os", "repo-map", - "greptile" + "greptile", + "web" ], "markdownEnumDescriptions": [ "Reference the contents of the current changes as given by `git diff`", @@ -1613,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" }, @@ -1718,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 5118fe134..7414be280 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -1705,6 +1705,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. Default is false." + } + } + } + } + } } ], "required": [ 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" diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 3ae31f922..5d5cd536b 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -305,8 +305,8 @@ class VsCodeIde implements IDE { return Promise.resolve(vscode.env.machineId); } - async getDiff(): Promise { - return await this.ideUtils.getDiff(); + 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 e7445afb3..cd4e36a99 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(); + return ide.getDiff(msg.data.includeUnstaged); }); this.onWebviewOrCore("getTerminalContents", async (msg) => { return ide.getTerminalContents(); diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index 7dce87f2c..0cc11a0ad 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -404,7 +404,6 @@ export class QuickEdit { quickPick.onDidChangeValue((value) => this.handleQuickPickChange({ value, quickPick, initialItems }), ); - /** * Waits for the user to select an item from the quick pick. * 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 1153375fd..99ee2ce37 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(): Promise { + async getDiff(includeUnstaged: boolean): Promise { let diffs: string[] = []; let repos = []; @@ -630,17 +630,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 (includeUnstaged) { + const unstaged = await repo.diff(false); + diffs.push(`\n${unstaged}`); + } } const fullDiff = diffs.join("\n\n"); 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;