Merge branch 'dev' into tomasz/cmd-i-improvements

This commit is contained in:
Nate Sesti 2024-10-15 09:03:26 -07:00 • committed by GitHub
commit 43034f81b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 289 additions and 38 deletions

View file

@ -0,0 +1,4 @@
project: extensions/vscode
kind: Added
body: Web context provider
time: 2024-10-14T23:15:51.670444-07:00

View file

@ -0,0 +1,4 @@
project: extensions/vscode
kind: Added
body: Cerebras inference provider
time: 2024-10-14T23:16:22.754491-07:00

View file

@ -0,0 +1,4 @@
project: extensions/vscode
kind: Added
body: Automatic descriptions for previous chats
time: 2024-10-14T23:16:39.451261-07:00

View file

@ -0,0 +1,4 @@
project: extensions/vscode
kind: Added
body: Discord context provider
time: 2024-10-14T23:16:57.089953-07:00

View file

@ -0,0 +1,4 @@
project: extensions/vscode
kind: Added
body: Improved full screen UI
time: 2024-10-14T23:17:14.574917-07:00

View file

@ -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

2
.vscode/launch.json vendored
View file

@ -20,7 +20,7 @@
"outFiles": ["${workspaceFolder}/extensions/vscode/out/extension.js"],
"preLaunchTask": "vscode-extension:build",
"env": {
// "CONTROL_PLANE_ENV": "local"
"CONTROL_PLANE_ENV": "local"
}
},
{

View file

@ -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.";

View file

@ -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)

View file

@ -434,7 +434,7 @@ declare global {
export interface IDE {
getIdeInfo(): Promise<IdeInfo>;
getIdeSettings(): Promise<IdeSettings>;
getDiff(): Promise<string>;
getDiff(includeUnstaged: boolean): Promise<string>;
isTelemetryEnabled(): Promise<boolean>;
getUniqueId(): Promise<string>;
getTerminalContents(): Promise<string>;

View file

@ -17,7 +17,7 @@ class DiffContextProvider extends BaseContextProvider {
query: string,
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
const diff = await extras.ide.getDiff();
const diff = await extras.ide.getDiff(false);
return [
{
description: "The current git diff",

View file

@ -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<ContextItem[]> {
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;
}
}

View file

@ -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(

2
core/index.d.ts vendored
View file

@ -464,7 +464,7 @@ export interface IdeSettings {
export interface IDE {
getIdeInfo(): Promise<IdeInfo>;
getIdeSettings(): Promise<IdeSettings>;
getDiff(): Promise<string>;
getDiff(includeUnstaged: boolean): Promise<string>;
isTelemetryEnabled(): Promise<boolean>;
getUniqueId(): Promise<string>;
getTerminalContents(): Promise<string>;

View file

@ -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];

View file

@ -124,7 +124,7 @@ class FileSystemIde implements IDE {
return Promise.resolve([]);
}
getDiff(): Promise<string> {
getDiff(includeUnstaged: boolean): Promise<string> {
return Promise.resolve("");
}

View file

@ -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() {

View file

@ -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", () => {

View file

@ -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'):`,
{

View file

@ -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": {

View file

@ -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"]

View file

@ -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

View file

@ -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": {

View file

@ -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": [

View file

@ -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"

View file

@ -305,8 +305,8 @@ class VsCodeIde implements IDE {
return Promise.resolve(vscode.env.machineId);
}
async getDiff(): Promise<string> {
return await this.ideUtils.getDiff();
async getDiff(includeUnstaged: boolean): Promise<string> {
return await this.ideUtils.getDiff(includeUnstaged);
}
async getTerminalContents(): Promise<string> {

View file

@ -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();

View file

@ -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.
*

View file

@ -80,7 +80,7 @@ describe("IDE Utils", () => {
});
test("noDiff", async () => {
const noDiff = await utils.getDiff();
const noDiff = await utils.getDiff(false);
assert(noDiff === "");
});

View file

@ -619,7 +619,7 @@ export class VsCodeIdeUtils {
return repo?.state?.HEAD?.name || "NONE";
}
async getDiff(): Promise<string> {
async getDiff(includeUnstaged: boolean): Promise<string> {
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");

View file

@ -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;