diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 5b248d5d8..2b9f266d5 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -9,7 +9,7 @@ ## Screenshots -[ For visual changes, include screenshots. ] +[ For visual changes, include screenshots. Screen recordings are particularly helpful, and appreciated! ] ## Testing instructions diff --git a/.github/workflows/jetbrains-release.yaml b/.github/workflows/jetbrains-release.yaml index bf2fa74a6..a968dcc19 100644 --- a/.github/workflows/jetbrains-release.yaml +++ b/.github/workflows/jetbrains-release.yaml @@ -54,7 +54,7 @@ jobs: ref: ${{ github.event.release.tag_name }} - name: Import Apple certificate - uses: apple-actions/import-codesign-certs@v3 + uses: apple-actions/import-codesign-certs@v5 with: keychain: ${{ github.run_id }} keychain-password: ${{ github.run_id }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 73997880a..4b42593d1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -139,7 +139,7 @@ Similarly, any changes to `core` or `extensions/vscode` will be automatically in #### JetBrains -See the [`CONTRIBUTING.md`](./extensions/intellij/CONTRIBUTING.md) for the JetBrains extension. +See [`intellij/CONTRIBUTING.md`](./extensions/intellij/CONTRIBUTING.md) for the JetBrains extension. ### Our Git Workflow @@ -147,7 +147,7 @@ We keep a single permanent branch: `main`. When we are ready to create a "pre-re ### Testing -We have a mix of unit, functional, and e2e test suites, with a primary focus on functional testing. These tests run on each pull request. If your PR causes one of these tests to fail, we will ask that you resolve the issue before we merge. +We have a mix of unit, functional, and e2e test suites, with a primary focus on functional testing. These tests run on each pull request. If your PR causes one of these tests to fail, we will ask that you to resolve the issue before we merge. When contributing, please update or create the appropriate tests to help verify the correctness of your implementaiton. @@ -217,7 +217,7 @@ Continue consists of 2 parts that are split so that it can be extended to work i 1. **Continue GUI** - The Continue GUI is a React application that gives the user control over Continue. It displays the current chat history, allows the user to ask questions, invoke slash commands, and use context providers. The GUI also handles most state and holds as much of the logic as possible so that it can be reused between IDEs. -2. **Continue Extension** - The Continue Extension is a plugin for the IDE which implements the [IDE Interface](./core/index.d.ts#L229). This allows the GUI to request information from or actions to be taken within the IDE. This same interface is used regardless of IDE. The first Continue extensions we have built are for VS Code and JetBrains, but we plan to build clients for other IDEs in the future. The IDE Client must 1. implement IDE Interface, as is done [here](./extensions/vscode/src/ideProtocol.ts) for VS Code and 2. display the Continue GUI in a sidebar, like [here](./extensions/vscode/src/ContinueGUIWebviewViewProvider.ts). +2. **Continue Extension** - The Continue Extension is a plugin for the IDE which implements the [IDE Interface](./core/index.d.ts#L229). This allows the GUI to request information from or actions to be taken within the IDE. This same interface is used regardless of IDE. The first Continue extensions we have built are for VS Code and JetBrains, but we plan to build clients for other IDEs in the future. The IDE Client must 1. implement IDE Interface, as is done [here](./extensions/vscode/src/VsCodeIde.ts) for VS Code and 2. display the Continue GUI in a sidebar, like [here](./extensions/vscode/src/ContinueGUIWebviewViewProvider.ts). ### Continue VS Code Extension diff --git a/binary/package-lock.json b/binary/package-lock.json index 5ce095e37..d1c773550 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -48,9 +48,9 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.63", + "@continuedev/config-yaml": "^1.0.67", "@continuedev/fetch": "^1.0.4", - "@continuedev/llm-info": "^1.0.2", + "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", "@modelcontextprotocol/sdk": "^1.5.0", "@mozilla/readability": "^0.5.0", @@ -135,7 +135,8 @@ "myers-diff": "^2.1.0", "onnxruntime-common": "1.14.0", "onnxruntime-web": "1.14.0", - "ts-jest": "^29.1.1" + "ts-jest": "^29.1.1", + "typescript": "^5.6.3" }, "engines": { "node": ">=20.11.0" @@ -6404,10 +6405,11 @@ } }, "node_modules/tar-fs": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", - "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.2.tgz", + "integrity": "sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA==", "dev": true, + "license": "MIT", "dependencies": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", diff --git a/core/autocomplete/context/ImportDefinitionsService.ts b/core/autocomplete/context/ImportDefinitionsService.ts index 5528d223c..e2288138a 100644 --- a/core/autocomplete/context/ImportDefinitionsService.ts +++ b/core/autocomplete/context/ImportDefinitionsService.ts @@ -5,6 +5,7 @@ import { getParserForFile, getQueryForFile, } from "../../util/treeSitter"; +import { findUriInDirs } from "../../util/uri"; interface FileInfo { imports: { [key: string]: RangeInFileWithContents[] }; @@ -44,7 +45,15 @@ export class ImportDefinitionsService { let fileContents: string | undefined = undefined; try { - fileContents = await this.ide.readFile(filepath); + const { foundInDir } = findUriInDirs( + filepath, + await this.ide.getWorkspaceDirs(), + ); + if (!foundInDir) { + return null; + } else { + fileContents = await this.ide.readFile(filepath); + } } catch (err) { // File removed return null; diff --git a/core/commands/index.ts b/core/commands/index.ts index 486eaccf2..7115d22be 100644 --- a/core/commands/index.ts +++ b/core/commands/index.ts @@ -1,5 +1,6 @@ import { CustomCommand, SlashCommand, SlashCommandDescription } from "../"; import { renderTemplatedString } from "../promptFiles/v1/renderTemplatedString"; +import { replaceSlashCommandWithPromptInChatHistory } from "../promptFiles/v1/updateChatHistory"; import { renderChatMessage } from "../util/messageContent"; import SlashCommands from "./slash"; @@ -7,68 +8,34 @@ import SlashCommands from "./slash"; export function slashFromCustomCommand( customCommand: CustomCommand, ): SlashCommand { + const commandName = customCommand.name.startsWith("/") + ? customCommand.name.substring(1) + : customCommand.name; return { - name: customCommand.name, + name: commandName, description: customCommand.description ?? "", prompt: customCommand.prompt, run: async function* ({ input, llm, history, ide, completionOptions }) { - // Remove slash command prefix from input - let userInput = input; - if (userInput.startsWith(`/${customCommand.name}`)) { - userInput = userInput - .slice(customCommand.name.length + 1, userInput.length) - .trimStart(); - } - // Render prompt template - let promptUserInput: string; + let renderedPrompt: string; if (customCommand.prompt.includes("{{{ input }}}")) { - promptUserInput = await renderTemplatedString( + renderedPrompt = await renderTemplatedString( customCommand.prompt, ide.readFile.bind(ide), - { input: userInput }, + { input }, ); } else { - promptUserInput = customCommand.prompt + "\n\n" + userInput; + renderedPrompt = customCommand.prompt + "\n\n" + input; } - const messages = [...history]; - // Find the last chat message with this slash command and replace it with the user input - for (let i = messages.length - 1; i >= 0; i--) { - const message = messages[i]; - const { role, content } = message; - if (role !== "user") { - continue; - } - - if ( - Array.isArray(content) && - content.some( - (part) => - "text" in part && part.text?.startsWith(`/${customCommand.name}`), - ) - ) { - messages[i] = { - ...message, - content: content.map((part) => { - if ( - "text" in part && - part.text.startsWith(`/${customCommand.name}`) - ) { - return { type: "text", text: promptUserInput }; - } - return part; - }), - }; - break; - } else if ( - typeof content === "string" && - content.startsWith(`/${customCommand.name}`) - ) { - messages[i] = { ...message, content: promptUserInput }; - break; - } - } + // Replaces slash command messages with the rendered prompt + // which INCLUDES the input + const messages = replaceSlashCommandWithPromptInChatHistory( + history, + commandName, + renderedPrompt, + undefined, + ); for await (const chunk of llm.streamChat( messages, diff --git a/core/config/yaml/convertFromJson.ts b/core/config/yaml/convertFromJson.ts index 072dc79de..dbc567005 100644 --- a/core/config/yaml/convertFromJson.ts +++ b/core/config/yaml/convertFromJson.ts @@ -2,6 +2,9 @@ import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml"; import { SerializedContinueConfig } from "../.."; +/* +TODO this is not functional +*/ export function convertConfigJsonToConfigYaml( configJson: SerializedContinueConfig, ): AssistantUnrolled { diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index 57caf324a..e9d5bd55c 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -39,7 +39,7 @@ async function modelConfigToBaseLLM( let options: LLMOptions = { ...rest, - // contextLength: model.defaultCompletionOptions?.contextLength ?? undefined, + contextLength: model.defaultCompletionOptions?.contextLength, completionOptions: { ...(model.defaultCompletionOptions ?? {}), model: model.model, diff --git a/core/context/providers/GitCommitContextProvider.ts b/core/context/providers/GitCommitContextProvider.ts index 24d2eab7b..e387b2f66 100644 --- a/core/context/providers/GitCommitContextProvider.ts +++ b/core/context/providers/GitCommitContextProvider.ts @@ -1,12 +1,40 @@ +import { spawn } from "node:child_process"; +import { fileURLToPath } from "node:url"; import { - ContextItem, - ContextProviderDescription, - ContextProviderExtras, - ContextSubmenuItem, - LoadSubmenuItemsArgs, - } from "../../index.js"; + ContextItem, + ContextProviderDescription, + ContextProviderExtras, + ContextSubmenuItem, + LoadSubmenuItemsArgs, +} from "../../index.js"; import { BaseContextProvider } from "../index.js"; -import { fileURLToPath} from "node:url"; + +const runGitCommand = (args: string[], cwd: string): Promise => { + return new Promise((resolve, reject) => { + // First argument is the command, rest are arguments + const gitProcess = spawn("git", args, { + cwd, + }); + let stdout = ""; + let stderr = ""; + + gitProcess.stdout.on("data", (data) => { + stdout += data.toString(); + }); + + gitProcess.stderr.on("data", (data) => { + stderr += data.toString(); + }); + + gitProcess.on("close", (code) => { + if (code !== 0) { + reject(new Error(`Git command failed: ${stderr}`)); + return; + } + resolve(stdout); + }); + }); +}; class GitCommitContextProvider extends BaseContextProvider { static description: ContextProviderDescription = { @@ -16,29 +44,55 @@ class GitCommitContextProvider extends BaseContextProvider { type: "submenu", }; - async getContextItems(query: string, extras: ContextProviderExtras): Promise { + async getContextItems( + query: string, + extras: ContextProviderExtras, + ): Promise { const lastXCommitsDepth = this.options?.LastXCommitsDepth ?? 10; + if (typeof lastXCommitsDepth !== "number") { + throw new Error("LastXCommitsDepth must be a number"); + } const topLevelDir = fileURLToPath((await extras.ide.getWorkspaceDirs())[0]); - try{ - if(query.includes("last ")){ + + try { + if (query.includes("last ")) { + const content = await runGitCommand( + [ + "--no-pager", + "log", + '--pretty=format:"%H,%h,%an,%ae,%ad,%P,%s,%b"', + "-p", + "-n", + lastXCommitsDepth.toString(), + ], + topLevelDir, + ); return [ { - name: query, - description: query, - content: (await extras.ide.subprocess(`git --no-pager log --pretty=format:"%H,%h,%an,%ae,%ad,%P,%s,%b" -p -n ${lastXCommitsDepth}`, topLevelDir))[0], - } - ] - } - else{ + name: query, + description: query, + content, + }, + ]; + } else { + const content = await runGitCommand( + [ + "--no-pager", + "show", + '--pretty=format:"%H,%h,%an,%ae,%ad,%P,%s,%b"', + query, + ], + topLevelDir, + ); return [ { name: query, description: `commit ${query}`, - content: (await extras.ide.subprocess(`git --no-pager show --pretty=format:"%H,%h,%an,%ae,%ad,%P,%s,%b" ${query}`, topLevelDir))[0], - } - ] + content, + }, + ]; } - }catch(err){ + } catch (err) { return []; } } @@ -48,24 +102,48 @@ class GitCommitContextProvider extends BaseContextProvider { ): Promise { const depth = this.options?.Depth ?? 50; const lastXCommitsDepth = this.options?.LastXCommitsDepth ?? 10; - const topLevelDir = fileURLToPath((await args.ide.getWorkspaceDirs())[0]); - try{ - const [gitResult] = await args.ide.subprocess(`git --no-pager log --pretty=format:"%H%x00%s" -n ${depth}`, topLevelDir); - const recentCommits = [{ id: `last ${lastXCommitsDepth} commits`, title: `last ${lastXCommitsDepth} commits`, description: "recent commits" }]; - const allCommits = gitResult - .trim() - .split('\n') - .map(line => { - const [hash, message] = line.split("\0"); - return { - id: hash, - title: message, - description: hash - }; - } + + if (typeof depth !== "number") { + throw new Error("Depth must be a number"); + } + if (typeof lastXCommitsDepth !== "number") { + throw new Error("LastXCommitsDepth must be a number"); + } + + const topLevelDir = fileURLToPath((await args.ide.getWorkspaceDirs())[0]); + try { + const gitResult = await runGitCommand( + [ + "--no-pager", + "log", + '--pretty=format:"%H%x00%s"', + `-n`, + depth.toString(), + ], + topLevelDir, ); + const recentCommits = [ + { + id: `last ${lastXCommitsDepth} commits`, + title: `last ${lastXCommitsDepth} commits`, + description: "recent commits", + }, + ]; + const allCommits = gitResult + .trim() + .split("\n") + .map((line) => { + let [hash, message] = line.split("\0"); + hash = hash.replace(/"/g, ""); + message = message.replace(/"/g, ""); + return { + id: hash, + title: message, + description: hash, + }; + }); return recentCommits.concat(allCommits); - }catch(err: any){ + } catch (err: any) { //could be nice to toast the error eg. not a git repo or git is not installed return []; } diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index a05889c52..16ac82100 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -27,9 +27,9 @@ class LlamaEncoding implements Encoding { } class NonWorkerAsyncEncoder implements AsyncEncoder { - constructor(private readonly encoding: Encoding) { } + constructor(private readonly encoding: Encoding) {} - async close(): Promise { } + async close(): Promise {} async encode(text: string): Promise { return this.encoding.encode(text); @@ -313,8 +313,21 @@ function pruneChatHistory( // 4. Remove entire messages in the last 5, except last 1 while (totalTokens > contextLength && chatHistory.length > 1) { - const message = chatHistory.shift()!; - totalTokens -= countTokens(message.content, modelName); + // If tool call/response detected prune both (can't have response with no call) + // TODO prune lines from tool response before pruning both messages + if ( + chatHistory.length > 2 && + messageHasToolCalls(chatHistory[0]) && + chatHistory[1].role === "tool" + ) { + const firstMessage = chatHistory.shift()!; + const secondMessage = chatHistory.shift()!; + totalTokens -= countTokens(firstMessage.content, modelName); + totalTokens -= countTokens(secondMessage.content, modelName); + } else { + const message = chatHistory.shift()!; + totalTokens -= countTokens(message.content, modelName); + } } // 5. Truncate last message @@ -328,7 +341,6 @@ function pruneChatHistory( ); totalTokens = contextLength; } - return chatHistory; } @@ -384,8 +396,8 @@ function compileChatMessages( ): ChatMessage[] { let msgsCopy = msgs ? msgs - .map((msg) => ({ ...msg })) - .filter((msg) => !chatMessageIsEmpty(msg) && msg.role !== "system") + .map((msg) => ({ ...msg })) + .filter((msg) => !chatMessageIsEmpty(msg) && msg.role !== "system") : []; msgsCopy = addSpaceToAnyEmptyMessages(msgsCopy); @@ -470,6 +482,5 @@ export { pruneLinesFromTop, pruneRawPromptFromTop, pruneStringFromBottom, - pruneStringFromTop + pruneStringFromTop, }; - diff --git a/core/llm/llms/Gemini.ts b/core/llm/llms/Gemini.ts index e6b1c5c70..1c5d24aee 100644 --- a/core/llm/llms/Gemini.ts +++ b/core/llm/llms/Gemini.ts @@ -4,6 +4,7 @@ import { CompletionOptions, LLMOptions, MessagePart, + TextMessagePart, ToolCallDelta, } from "../../index.js"; import { findLast } from "../../util/findLast.js"; @@ -69,20 +70,84 @@ class Gemini extends BaseLLM { } } + /** + * Removes the system message and merges it with the next user message if present. + * @param messages Array of chat messages + * @returns Modified array with system message merged into user message if applicable + */ public removeSystemMessage(messages: ChatMessage[]): ChatMessage[] { - // should be public for use within VertexAI - const msgs = [...messages]; + // If no messages or first message isn't system, return copy of original messages + if (messages.length === 0 || messages[0]?.role !== "system") { + return [...messages]; + } - if (msgs[0]?.role === "system") { - const sysMsg = msgs.shift()?.content; - // @ts-ignore - if (msgs[0]?.role === "user") { - // @ts-ignore - msgs[0].content = `System message - follow these instructions in every response: ${sysMsg}\n\n---\n\n${msgs[0].content}`; + // Extract system message + const systemMessage: ChatMessage = messages[0]; + + // Extract system content based on its type + let systemContent = ""; + + if (typeof systemMessage.content === "string") { + systemContent = systemMessage.content; + } else if (Array.isArray(systemMessage.content)) { + const contentArray: Array = + systemMessage.content as Array; + + const concatenatedText = contentArray + .filter((part): part is TextMessagePart => part.type === "text") + .map((part) => part.text) + .join(" "); + + systemContent = concatenatedText ? concatenatedText : ""; + } else if ( + systemMessage.content && + typeof systemMessage.content === "object" + ) { + const typedContent = systemMessage.content as TextMessagePart; + systemContent = typedContent?.text || ""; + } + + // Create new array without the system message + const remainingMessages: ChatMessage[] = messages.slice(1); + + // Check if there's a user message to merge with + if (remainingMessages.length > 0 && remainingMessages[0].role === "user") { + const userMessage: ChatMessage = remainingMessages[0]; + const prefix = `System message - follow these instructions in every response: ${systemContent}\n\n---\n\n`; + + // Merge based on user content type + if (typeof userMessage.content === "string") { + userMessage.content = prefix + userMessage.content; + } else if (Array.isArray(userMessage.content)) { + const contentArray: Array = + userMessage.content as Array; + const textPart = contentArray.find((part) => part.type === "text") as + | TextMessagePart + | undefined; + + if (textPart) { + textPart.text = prefix + textPart.text; + } else { + userMessage.content.push({ + type: "text", + text: prefix, + } as TextMessagePart); + } + } else if ( + userMessage.content && + typeof userMessage.content === "object" + ) { + const typedContent = userMessage.content as TextMessagePart; + userMessage.content = [ + { + type: "text", + text: prefix + (typedContent.text || ""), + } as TextMessagePart, + ]; } } - return msgs; + return remainingMessages; } protected async *_streamChat( diff --git a/core/llm/llms/WatsonX.ts b/core/llm/llms/WatsonX.ts index 561f4f2d9..7f1fe2e0c 100644 --- a/core/llm/llms/WatsonX.ts +++ b/core/llm/llms/WatsonX.ts @@ -21,7 +21,7 @@ class WatsonX extends BaseLLM { if (this.apiBase?.includes("cloud.ibm.com")) { // watsonx SaaS const wxToken = await ( - await fetch( + await this.fetch( `https://iam.cloud.ibm.com/identity/token?apikey=${this.apiKey}&grant_type=urn:ibm:params:oauth:grant-type:apikey`, { method: "POST", @@ -48,7 +48,7 @@ class WatsonX extends BaseLLM { // Using username/password auth const userPass = this.apiKey?.split(":"); const wxToken = await ( - await fetch(`${this.apiBase}/icp4d-api/v1/authorize`, { + await this.fetch(`${this.apiBase}/icp4d-api/v1/authorize`, { method: "POST", headers: { "Content-Type": "application/json", @@ -61,7 +61,7 @@ class WatsonX extends BaseLLM { }) ).json(); const wxTokenExpiry = await ( - await fetch(`${this.apiBase}/usermgmt/v1/user/tokenExpiry`, { + await this.fetch(`${this.apiBase}/usermgmt/v1/user/tokenExpiry`, { method: "GET", headers: { Accept: "application/json", diff --git a/core/promptFiles/v1/slashCommandFromPromptFile.ts b/core/promptFiles/v1/slashCommandFromPromptFile.ts index b9d4e88c8..6abd4927f 100644 --- a/core/promptFiles/v1/slashCommandFromPromptFile.ts +++ b/core/promptFiles/v1/slashCommandFromPromptFile.ts @@ -5,7 +5,7 @@ import { parsePromptFileV1V2 } from "../v2/parsePromptFileV1V2"; import { getContextProviderHelpers } from "./getContextProviderHelpers"; import { renderTemplatedString } from "./renderTemplatedString"; -import { updateChatHistory } from "./updateChatHistory"; +import { replaceSlashCommandWithPromptInChatHistory } from "./updateChatHistory"; export function extractName(preamble: { name?: string }, path: string): string { return preamble.name ?? getLastNPathParts(path, 1).split(".prompt")[0]; @@ -68,7 +68,7 @@ export function slashCommandFromPromptFileV1( const userInput = extractUserInput(context.input, name); const renderedPrompt = await renderPromptV1(prompt, context, userInput); - const messages = updateChatHistory( + const messages = replaceSlashCommandWithPromptInChatHistory( context.history, name, renderedPrompt, diff --git a/core/promptFiles/v1/updateChatHistory.ts b/core/promptFiles/v1/updateChatHistory.ts index 8ebc6f038..04cbcd91b 100644 --- a/core/promptFiles/v1/updateChatHistory.ts +++ b/core/promptFiles/v1/updateChatHistory.ts @@ -1,4 +1,4 @@ -export function updateChatHistory( +export function replaceSlashCommandWithPromptInChatHistory( history: any[], commandName: string, renderedPrompt: string, diff --git a/core/tools/definitions/readCurrentlyOpenFile.ts b/core/tools/definitions/readCurrentlyOpenFile.ts index f4df8e1e5..eacaab70d 100644 --- a/core/tools/definitions/readCurrentlyOpenFile.ts +++ b/core/tools/definitions/readCurrentlyOpenFile.ts @@ -6,7 +6,7 @@ export const readCurrentlyOpenFileTool: Tool = { displayTitle: "Read Currently Open File", wouldLikeTo: "read the current file", isCurrently: "reading the current file", - hasAlready: "read the current file", + hasAlready: "viewed the current file", readonly: true, group: BUILT_IN_GROUP_NAME, function: { diff --git a/core/tools/definitions/readFile.ts b/core/tools/definitions/readFile.ts index 0133b54b0..ff5d58a31 100644 --- a/core/tools/definitions/readFile.ts +++ b/core/tools/definitions/readFile.ts @@ -6,7 +6,7 @@ export const readFileTool: Tool = { displayTitle: "Read File", wouldLikeTo: "read {{{ filepath }}}", isCurrently: "reading {{{ filepath }}}", - hasAlready: "read {{{ filepath }}}", + hasAlready: "viewed {{{ filepath }}}", readonly: true, group: BUILT_IN_GROUP_NAME, function: { diff --git a/docs/docs/customize/model-providers/more/watsonx.mdx b/docs/docs/customize/model-providers/more/watsonx.mdx index f2360788f..1bc247399 100644 --- a/docs/docs/customize/model-providers/more/watsonx.mdx +++ b/docs/docs/customize/model-providers/more/watsonx.mdx @@ -128,8 +128,8 @@ You can also configure generation parameters, such as temperature, topP, topK, f apiBase: watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com apiKey: API_KEY/ZENAPI_KEY/USERNAME:PASSWORD template: granite - contextLength: 8000 defaultCompletionOptions: + contextLength: 8000 temperature: 0.1 topP: 0.3 topK: 20 @@ -245,7 +245,6 @@ To view the list of available embeddings models, visit [this page](https://datap - ## Reranker diff --git a/docs/docs/hub/governance/creating-an-org.md b/docs/docs/hub/governance/creating-an-org.md new file mode 100644 index 000000000..aa91d8f5e --- /dev/null +++ b/docs/docs/hub/governance/creating-an-org.md @@ -0,0 +1,20 @@ +--- +title: Creating an Organization +description: Creating an Organization +keywords: [governance, organization, org, create] +--- + +To Create an Organization, click the organization selector in the top right and select `Create Organization` + +![create an org selector](/img/hub/org-selector.png) + +1. Choose a name, which will be used as the display name for your organization throughout the hub +2. Add a slug, which will be used for your org URL and as the prefix to all organization blocks and assistant slugs +3. Select an icon for your organization using the image uploader +4. Finally, add a Biography, which will be displayed on your org Home Page + +![Creating an org](/img/hub/create-org-form.png) + +You will then be signed in to your org and taken to the org home page + +![Org home page](/img/hub/org-home-page.png) diff --git a/docs/docs/introduction.md b/docs/docs/introduction.md index f5695d033..e8bd4269e 100644 --- a/docs/docs/introduction.md +++ b/docs/docs/introduction.md @@ -22,4 +22,4 @@ keywords: - [Chat](chat/how-to-use-it) to understand and iterate on code in the sidebar - [Autocomplete](autocomplete/how-to-use-it) to receive inline code suggestions as you type - [Edit](edit/how-to-use-it) to modify code without leaving your current file -- [Agent](agent/how-to-use-it) to make more substanial changes to your codebase \ No newline at end of file +- [Agent](agent/how-to-use-it) to make more substantial changes to your codebase diff --git a/docs/sidebars.js b/docs/sidebars.js index 4cc40ae07..20a47be93 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -165,7 +165,11 @@ const sidebars = { { type: "category", label: "Governance", - items: ["hub/governance/org-permissions", "hub/governance/pricing"], + items: [ + "hub/governance/org-permissions", + "hub/governance/creating-an-org", + "hub/governance/pricing", + ], }, { type: "link", diff --git a/docs/static/img/hub/create-org-form.png b/docs/static/img/hub/create-org-form.png new file mode 100644 index 000000000..db4497ec2 Binary files /dev/null and b/docs/static/img/hub/create-org-form.png differ diff --git a/docs/static/img/hub/org-home-page.png b/docs/static/img/hub/org-home-page.png new file mode 100644 index 000000000..a85e283c4 Binary files /dev/null and b/docs/static/img/hub/org-home-page.png differ diff --git a/docs/static/img/hub/org-selector.png b/docs/static/img/hub/org-selector.png new file mode 100644 index 000000000..a154659be Binary files /dev/null and b/docs/static/img/hub/org-selector.png differ diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index cf4a7e0f1..957c112f3 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension pluginName=continue-intellij-extension pluginRepositoryUrl=https://github.com/continuedev/continue # SemVer format -> https://semver.org -pluginVersion=1.0.8 +pluginVersion=1.0.9 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild=223 # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt index 9d48705df..e1da218c5 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt @@ -1,4 +1,5 @@ package com.github.continuedev.continueintellijextension.activities +import IntelliJIDE import com.intellij.openapi.fileEditor.FileEditorManagerListener import com.github.continuedev.continueintellijextension.auth.AuthListener import com.github.continuedev.continueintellijextension.auth.ContinueAuthService @@ -185,6 +186,8 @@ class ContinuePluginStartupActivity : StartupActivity, DumbAware { // Notify core of content changes if (changedURIs.isNotEmpty()) { + continuePluginService.updateLastFileSaveTimestamp() + val data = mapOf("uris" to changedURIs) continuePluginService.coreMessenger?.request("files/changed", data, null) { _ -> } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GitService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GitService.kt new file mode 100644 index 000000000..a378820e8 --- /dev/null +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GitService.kt @@ -0,0 +1,94 @@ +package com.github.continuedev.continueintellijextension.`continue` + +import com.github.continuedev.continueintellijextension.services.ContinuePluginService +import com.github.continuedev.continueintellijextension.utils.toUriOrNull +import com.intellij.openapi.project.Project +import com.intellij.openapi.project.guessProjectDir +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import java.io.BufferedReader +import java.io.File +import java.io.InputStreamReader +import java.net.URI + +class GitService( + private val project: Project, + private val continuePluginService: ContinuePluginService +) { + // Add a simple cache for diff results + private data class DiffCache( + val timestamp: Long, + val diffs: List + ) + + // Cache the last diff result + private var diffCache: DiffCache? = null + private var lastFileSaveTimestamp: Long = System.currentTimeMillis() + + /** + * Updates the timestamp when a file is saved + */ + fun updateLastFileSaveTimestamp() { + lastFileSaveTimestamp = System.currentTimeMillis() + } + + /** + * Returns the git diff for all workspace directories + */ + suspend fun getDiff(includeUnstaged: Boolean): List { + // Check if we have a valid cache entry + if (diffCache != null && diffCache!!.timestamp == lastFileSaveTimestamp) { + return diffCache!!.diffs + } + + // If no cache hit, compute the diff + val workspaceDirs = workspaceDirectories() + val diffs = mutableListOf() + + for (workspaceDir in workspaceDirs) { + val output = StringBuilder() + val builder = if (includeUnstaged) { + ProcessBuilder("git", "diff") + } else { + ProcessBuilder("git", "diff", "--cached") + } + builder.directory(File(URI(workspaceDir))) + val process = withContext(Dispatchers.IO) { + builder.start() + } + + val reader = BufferedReader(InputStreamReader(process.inputStream)) + var line: String? = withContext(Dispatchers.IO) { + reader.readLine() + } + while (line != null) { + output.append(line) + output.append("\n") + line = withContext(Dispatchers.IO) { + reader.readLine() + } + } + + withContext(Dispatchers.IO) { + process.waitFor() + } + + diffs.add(output.toString()) + } + + // Cache the result + diffCache = DiffCache(lastFileSaveTimestamp, diffs) + return diffs + } + + private fun workspaceDirectories(): Array { + val dirs = this.continuePluginService.workspacePaths + + if (dirs?.isNotEmpty() == true) { + return dirs + } + + return listOfNotNull(project.guessProjectDir()?.toUriOrNull()).toTypedArray() + } + +} \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index 268a7674f..95270f26b 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -45,6 +45,10 @@ class IdeProtocolClient( ) } + fun updateLastFileSaveTimestamp() { + (ide as IntelliJIDE).updateLastFileSaveTimestamp() + } + fun handleMessage(msg: String, respond: (Any?) -> Unit) { coroutineScope.launch(Dispatchers.IO) { val message = Gson().fromJson(msg, Message::class.java) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index e903e1238..7e68cf007 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -1,13 +1,9 @@ import com.github.continuedev.continueintellijextension.* import com.github.continuedev.continueintellijextension.constants.getContinueGlobalPath +import com.github.continuedev.continueintellijextension.`continue`.GitService import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.github.continuedev.continueintellijextension.services.ContinuePluginService -import com.github.continuedev.continueintellijextension.utils.OS -import com.github.continuedev.continueintellijextension.utils.getMachineUniqueID -import com.github.continuedev.continueintellijextension.utils.getOS -import com.github.continuedev.continueintellijextension.utils.toUriOrNull -import com.github.continuedev.continueintellijextension.utils.Desktop -import com.google.gson.Gson +import com.github.continuedev.continueintellijextension.utils.* import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.util.ExecUtil @@ -31,12 +27,7 @@ import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiDocumentManager import com.intellij.testFramework.LightVirtualFile -import com.intellij.util.containers.toArray import kotlinx.coroutines.* -import okhttp3.MediaType.Companion.toMediaType -import okhttp3.OkHttpClient -import okhttp3.Request -import okhttp3.RequestBody.Companion.toRequestBody import java.awt.Toolkit import java.awt.datatransfer.DataFlavor import java.io.BufferedReader @@ -44,7 +35,6 @@ import java.io.File import java.io.FileInputStream import java.io.InputStreamReader import java.net.URI -import java.net.URL import java.nio.charset.Charset import java.nio.file.Paths @@ -52,7 +42,11 @@ class IntelliJIDE( private val project: Project, private val continuePluginService: ContinuePluginService, - ) : IDE { +) : IDE { + + private val gitService = GitService(project, continuePluginService) + + private val ripgrep: String init { @@ -66,6 +60,13 @@ class IntelliJIDE( Paths.get(pluginPath.toString(), "ripgrep", "bin", "rg" + if (os == OS.WINDOWS) ".exe" else "").toString() } + /** + * Updates the timestamp when a file is saved + */ + override fun updateLastFileSaveTimestamp() { + gitService.updateLastFileSaveTimestamp() + } + override suspend fun getIdeInfo(): IdeInfo { val applicationInfo = ApplicationInfo.getInstance() val ideName: String = applicationInfo.fullApplicationName @@ -110,41 +111,7 @@ class IntelliJIDE( } override suspend fun getDiff(includeUnstaged: Boolean): List { - val workspaceDirs = workspaceDirectories() - val diffs = mutableListOf() - - for (workspaceDir in workspaceDirs) { - val output = StringBuilder() - val builder = if (includeUnstaged) { - ProcessBuilder("git", "diff") - } else { - ProcessBuilder("git", "diff", "--cached") - } - builder.directory(File(URI(workspaceDir))) - val process = withContext(Dispatchers.IO) { - builder.start() - } - - val reader = BufferedReader(InputStreamReader(process.inputStream)) - var line: String? = withContext(Dispatchers.IO) { - reader.readLine() - } - while (line != null) { - output.append(line) - output.append("\n") - line = withContext(Dispatchers.IO) { - reader.readLine() - } - } - - withContext(Dispatchers.IO) { - process.waitFor() - } - - diffs.add(output.toString()) - } - - return diffs + return gitService.getDiff(includeUnstaged) } override suspend fun getClipboardContent(): Map { @@ -185,7 +152,7 @@ class IntelliJIDE( } override suspend fun getWorkspaceConfigs(): List { - val workspaceDirs = workspaceDirectories() + val workspaceDirs = this.getWorkspaceDirs() val configs = mutableListOf() @@ -434,7 +401,7 @@ class IntelliJIDE( } override suspend fun getTags(artifactId: String): List { - val workspaceDirs = workspaceDirectories() + val workspaceDirs = this.getWorkspaceDirs() // Collect branches concurrently using Kotlin coroutines val branches = withContext(Dispatchers.IO) { @@ -577,4 +544,5 @@ class IntelliJIDE( return listOfNotNull(project.guessProjectDir()?.toUriOrNull()).toTypedArray() } + } \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt index cf1005596..d3b8ea68a 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt @@ -41,4 +41,8 @@ class ContinuePluginService : Disposable, DumbAware { ) { continuePluginWindow?.browser?.sendToWebview(messageType, data, messageId) } + + fun updateLastFileSaveTimestamp() { + ideProtocolClient?.updateLastFileSaveTimestamp() + } } \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt index 7dfa83da4..5d340ede0 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt @@ -192,6 +192,10 @@ interface IDE { // Callbacks fun onDidChangeActiveTextEditor(callback: (filepath: String) -> Unit) + + fun updateLastFileSaveTimestamp() { + // Default implementation does nothing + } } data class GetGhTokenArgs( diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 2a908c045..b8ae1d407 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -3063,7 +3063,7 @@ "default": { "title": "Tab Autocomplete Model", "provider": "ollama", - "model": "deepseek-coder:1.3b-base" + "model": "qwen2.5-coder:1.5b-base" }, "oneOf": [ { diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 1170be786..3b3f05ad0 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.17", + "version": "1.1.18", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.17", + "version": "1.1.18", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 142f9f95d..5dec30f35 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": "1.1.17", + "version": "1.1.18", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" diff --git a/gui/package-lock.json b/gui/package-lock.json index 389343794..78eb2e61d 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -95,7 +95,7 @@ "tailwindcss": "^3.2.7", "typescript": "^5.6.3", "typescript-eslint": "^8.16.0", - "vite": "^4.1.0", + "vite": "^4.5.11", "vitest": "^2.1.3" }, "engines": { @@ -12291,9 +12291,9 @@ } }, "node_modules/vite": { - "version": "4.5.9", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.9.tgz", - "integrity": "sha512-qK9W4xjgD3gXbC0NmdNFFnVFLMWSNiR3swj957yutwzzN16xF/E7nmtAyp1rT9hviDroQANjE4HK3H4WqWdFtw==", + "version": "4.5.11", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.11.tgz", + "integrity": "sha512-4mVdhLkZ0vpqZLGJhNm+X1n7juqXApEMGlUXcOQawA45UmpxivOYaMBkI/Js3FlBsNA8hCgEnX5X04moFitSGw==", "dev": true, "license": "MIT", "dependencies": { diff --git a/gui/package.json b/gui/package.json index 33f326de3..3210a55f5 100644 --- a/gui/package.json +++ b/gui/package.json @@ -103,7 +103,7 @@ "tailwindcss": "^3.2.7", "typescript": "^5.6.3", "typescript-eslint": "^8.16.0", - "vite": "^4.1.0", + "vite": "^4.5.11", "vitest": "^2.1.3" }, "engine-strict": true, diff --git a/gui/src/components/CodeToEditCard/AddFileButton.tsx b/gui/src/components/CodeToEditCard/AddFileButton.tsx index 18316a5d7..d051f847f 100644 --- a/gui/src/components/CodeToEditCard/AddFileButton.tsx +++ b/gui/src/components/CodeToEditCard/AddFileButton.tsx @@ -39,15 +39,15 @@ export default function AddFileButton({ onClick }: AddFileButtonProps) { className="bg-vsc-editor-background m-0 rounded-md p-0" >
{ e.preventDefault(); e.stopPropagation(); onClick(); }} > - - + + Add file
diff --git a/gui/src/components/CodeToEditCard/CodeToEditCard.tsx b/gui/src/components/CodeToEditCard/CodeToEditCard.tsx index 99149ba5f..6e16d4d4f 100644 --- a/gui/src/components/CodeToEditCard/CodeToEditCard.tsx +++ b/gui/src/components/CodeToEditCard/CodeToEditCard.tsx @@ -1,16 +1,16 @@ +import { PlusIcon, XMarkIcon } from "@heroicons/react/24/outline"; +import type { CodeToEdit } from "core"; import { useContext, useState } from "react"; import { useDispatch } from "react-redux"; import { IdeMessengerContext } from "../../context/IdeMessenger"; -import CodeToEditListItem from "./CodeToEditListItem"; -import type { CodeToEdit } from "core"; -import AddFileButton from "./AddFileButton"; -import AddFileCombobox from "./AddFileCombobox"; -import { PlusIcon, XMarkIcon } from "@heroicons/react/24/outline"; import { useAppSelector } from "../../redux/hooks"; import { addCodeToEdit, removeCodeToEdit, } from "../../redux/slices/sessionSlice"; +import AddFileButton from "./AddFileButton"; +import AddFileCombobox from "./AddFileCombobox"; +import CodeToEditListItem from "./CodeToEditListItem"; export default function CodeToEditCard() { const dispatch = useDispatch(); @@ -18,12 +18,12 @@ export default function CodeToEditCard() { const [showAddFileCombobox, setShowAddFileCombobox] = useState(false); const codeToEdit = useAppSelector((state) => state.session.codeToEdit); - const title = + const itemCount = codeToEdit.length === 0 - ? "Code to edit" + ? "" : codeToEdit.length === 1 - ? "Code to edit (1 item)" - : `Code to edit (${codeToEdit.length} items)`; + ? "(1 item)" + : `(${codeToEdit.length} items)`; function onDelete(rif: CodeToEdit) { dispatch(removeCodeToEdit(rif)); @@ -57,7 +57,11 @@ export default function CodeToEditCard() { return (
- {title} +
+ Code to edit + {itemCount} +
+ setShowAddFileCombobox(true)} />
diff --git a/gui/src/components/ExploreHubCard/index.tsx b/gui/src/components/ExploreHubCard/index.tsx index c546becd4..bf6327c35 100644 --- a/gui/src/components/ExploreHubCard/index.tsx +++ b/gui/src/components/ExploreHubCard/index.tsx @@ -23,12 +23,17 @@ export function ExploreHubCard() { return dispatch(setIsExploreDialogOpen(false)); }} > -
-

Create Your Own Assistant

+
+
+

+ Create Your Own Assistant +

-

- Discover and remix popular assistants, or create your own from scratch -

+

+ Discover and remix popular assistants, or create your own from + scratch +

+