diff --git a/.continue/prompts/core-util-test.prompt b/.continue/prompts/core-util-test.prompt new file mode 100644 index 000000000..19202ddee --- /dev/null +++ b/.continue/prompts/core-util-test.prompt @@ -0,0 +1,21 @@ +name: Write Core Utility Test +description: Generate unit tests for core utilities +--- +Write jest tests for the provided code. Use best practices. Be clear and consise. +Aim for 100% code coverage where reasonable. +Multiple tests can be written, split up tests for best clarity and readability. +Only use typescript, and if the file/code is not typescript, warn the user. +Use given types to generate mock data if needed. + +Additional types can be imported from @core/gui/src/components/mainInput/types.d.ts +If any needed type declaration is still not found, warn the user. + +Existing test fixtures can be found in: +@core/test/util/fixtures.ts +- import and use `testIde` for any IDE type needs +- import and use `testControlPlaneClient` for any ControlPlaneClient needs +- import and use `testConfigHandler` for any ConfigHandler needs +- import and use `ideSettingsPromise` for any IdeSettings needs + +// This note is for if using edit mode to encourage it to create new files +The tests are to be put in a new file with the same filepath but with a .test.ts extension rather than a .ts extension \ No newline at end of file diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index a879c3d9d..9e040bcff 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -5,6 +5,11 @@ on: branches: - main + paths: + - "extensions/vscode/**" + - "core/**" + - "gui/**" + jobs: tsc-check: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 9621811de..9e783860d 100644 --- a/.gitignore +++ b/.gitignore @@ -135,9 +135,7 @@ cached_embeddings.pkl .ruff_cache codeql -**/.continue .DS_Store -.continue .test .tiktoken_cache @@ -153,7 +151,6 @@ continue_server.dist Icon Icon? -.continue .continuerc.json .prompts/ .aider* diff --git a/core/commands/slash/commit.ts b/core/commands/slash/commit.ts index 8fc1ae27b..c2d09adba 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?.includeUnstaged ?? false; + const includeUnstaged = params?.includeUnstaged ?? true; const diff = await ide.getDiff(includeUnstaged); if (diff.length === 0) { diff --git a/core/config/promptFile.ts b/core/config/promptFile.ts index 5020fc112..de17a7120 100644 --- a/core/config/promptFile.ts +++ b/core/config/promptFile.ts @@ -173,7 +173,7 @@ async function renderPrompt( 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(false); + const diff = await context.ide.getDiff(true); const currentFile = await context.ide.getCurrentFile(); const inputData: Record = { diff: diff.join("\n"), diff --git a/core/continueServer/stubs/client.ts b/core/continueServer/stubs/client.ts index f9377b1af..49f02fb65 100644 --- a/core/continueServer/stubs/client.ts +++ b/core/continueServer/stubs/client.ts @@ -15,7 +15,7 @@ export class ContinueServerClient implements IContinueServerClient { this.url = typeof serverUrl !== "string" || serverUrl === "" ? undefined - : new URL(serverUrl); + : new URL(serverUrl.endsWith("/") ? serverUrl : `${serverUrl}/`); } catch (e) { console.warn("Invalid Continue server url", e); this.url = undefined; diff --git a/core/core.ts b/core/core.ts index 1eaef976d..a426a337d 100644 --- a/core/core.ts +++ b/core/core.ts @@ -155,10 +155,10 @@ export class Core { // Index on initialization void this.ide.getWorkspaceDirs().then(async (dirs) => { // Respect pauseCodebaseIndexOnStart user settings - this.indexingPauseToken.paused = true; if (ideSettings.pauseCodebaseIndexOnStart) { + this.indexingPauseToken.paused = true; void this.messenger.request("indexProgress", { - progress: 1, + progress: 0, desc: "Initial Indexing Skipped", status: "paused", }); @@ -842,6 +842,8 @@ export class Core { this.indexingCancellationController.signal, )) { let updateToSend = { ...update }; + // TODO reconsider this status overwrite? + // original goal was to not concern users with edge noncritical errors if (update.status === "failed") { updateToSend.status = "done"; updateToSend.desc = "Indexing complete"; diff --git a/core/index.d.ts b/core/index.d.ts index 34212cfac..81ddd2039 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -42,11 +42,18 @@ export interface IndexingProgressUpdate { progress: number; desc: string; shouldClearIndexes?: boolean; - status: "loading" | "indexing" | "done" | "failed" | "paused" | "disabled"; + status: + | "loading" + | "indexing" + | "done" + | "failed" + | "paused" + | "disabled" + | "cancelled"; debugInfo?: string; } -// This is more or less a V2 of IndexingProgressUpdate +// This is more or less a V2 of IndexingProgressUpdate for docs etc. export interface IndexingStatus { id: string; type: "docs"; @@ -414,7 +421,6 @@ export interface ChatHistoryItem { modifiers?: InputModifiers; promptLogs?: PromptLog[]; toolCallState?: ToolCallState; - mode?: MessageModes; isGatheringContext?: boolean; checkpoint?: Checkpoint; isBeforeCheckpoint?: boolean; diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index 5c70f8bad..af204a723 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -145,9 +145,7 @@ export class CodebaseIndexer { } } - async *refreshFiles( - files: string[], - ): AsyncGenerator { + async *refreshFiles(files: string[]): AsyncGenerator { let progress = 0; if (files.length === 0) { yield { @@ -192,9 +190,9 @@ export class CodebaseIndexer { if (dirs.length === 0) { yield { - progress, + progress: 1, desc: "Nothing to index", - status: "disabled", + status: "done", }; return; } @@ -238,9 +236,9 @@ export class CodebaseIndexer { directoryFiles.push(p); if (abortSignal.aborted) { yield { - progress: 1, + progress: 0, desc: "Indexing cancelled", - status: "disabled", + status: "cancelled", }; return; } @@ -263,9 +261,9 @@ export class CodebaseIndexer { // Handle pausing in this loop because it's the only one really taking time if (abortSignal.aborted) { yield { - progress: 1, + progress: 0, desc: "Indexing cancelled", - status: "disabled", + status: "cancelled", }; return; } diff --git a/core/llm/constructMessages.ts b/core/llm/constructMessages.ts index b1cb0da93..cb7890098 100644 --- a/core/llm/constructMessages.ts +++ b/core/llm/constructMessages.ts @@ -1,7 +1,10 @@ import { ChatHistoryItem, ChatMessage, MessagePart } from "../index.js"; import { normalizeToMessageParts } from "../util/messageContent.js"; + import { modelSupportsTools } from "./autodetect.js"; +const CUSTOM_SYS_MSG_MODEL_FAMILIES = ["sonnet", "gpt-4o", "mistral-large"]; + const SYSTEM_MESSAGE = `When generating new code: 1. Always produce a single code block. @@ -64,7 +67,7 @@ const TOOL_USE_RULES = `When using tools, follow the following guidelines: - Avoid calling tools unless they are absolutely necessary. For example, if you are asked a simple programming question you do not need web search. As another example, if the user asks you to explain something about code, do not create a new file.`; function constructSystemPrompt(model: string): string | null { - if (model.includes("sonnet")) { + if (CUSTOM_SYS_MSG_MODEL_FAMILIES.some((family) => model.includes(family))) { return SYSTEM_MESSAGE + "\n\n" + TOOL_USE_RULES; } if (modelSupportsTools(model)) { diff --git a/core/llm/llms/OpenAI.ts b/core/llm/llms/OpenAI.ts index ed9810932..1ac63f8af 100644 --- a/core/llm/llms/OpenAI.ts +++ b/core/llm/llms/OpenAI.ts @@ -105,7 +105,8 @@ class OpenAI extends BaseLLM { } protected supportsPrediction(model: string): boolean { - return ["gpt-4o-mini", "gpt-4o"].includes(model); + const SUPPORTED_MODELS = ["gpt-4o-mini", "gpt-4o", "mistral-large"]; + return SUPPORTED_MODELS.some((m) => model.includes(m)); } private convertTool(tool: Tool): any { diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 91fa40395..cd79bcd21 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -56,7 +56,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { { accept: boolean; onlyFirst: boolean; filepath: string }, void, ]; - "edit/escape": [undefined, void]; + "edit/exit": [{ shouldFocusEditor: boolean }, void]; }; export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & { diff --git a/docs/docs/chat/how-to-customize.md b/docs/docs/chat/how-to-customize.md index 9df6ec020..ee26a6a84 100644 --- a/docs/docs/chat/how-to-customize.md +++ b/docs/docs/chat/how-to-customize.md @@ -12,3 +12,4 @@ There are a number of different ways to customize Chat - You can create your own [custom code RAG](../customize/tutorials/custom-code-rag.md) - You can configure [`@Docs`](../customize/deep-dives/docs.md) - You can [build your own context provider](../customize/tutorials/build-your-own-context-provider.md) +- You can configure and create custom [tools](../customize/tools.md) diff --git a/docs/docs/customize/deep-dives/configuration.md b/docs/docs/customize/deep-dives/configuration.md index dab15ac4c..62f79952e 100644 --- a/docs/docs/customize/deep-dives/configuration.md +++ b/docs/docs/customize/deep-dives/configuration.md @@ -31,7 +31,7 @@ The format of `.continuerc.json` is the same as `config.json`, plus one _additio Example -```json title="config.json" +```json title=".continuerc.json" { "tabAutocompleteOptions": { "disable": true diff --git a/docs/docs/customize/deep-dives/rules.md b/docs/docs/customize/deep-dives/rules.md index 30100aaeb..f53135b50 100644 --- a/docs/docs/customize/deep-dives/rules.md +++ b/docs/docs/customize/deep-dives/rules.md @@ -5,7 +5,7 @@ keywords: [rules, .continuerules, system, prompt, message] # `.continuerules` -You can create a project-specific system message by adding a `.continuerules` file to the root of your project. This file is raw text and its contents will be inserted into the system message for all LLM requests. +You can create a project-specific system message by adding a `.continuerules` file to the root of your project. This file is raw text and its contents will be inserted into the system message for all chat requests. Rules are not used for autocomplete. ## Simple Examples diff --git a/docs/docs/customize/tools.md b/docs/docs/customize/tools.md new file mode 100644 index 000000000..f18e40387 --- /dev/null +++ b/docs/docs/customize/tools.md @@ -0,0 +1,33 @@ +--- +title: Tools +description: Tool use and customization +keywords: [tool, use, function calling, claude, automatic] +--- + +Tools allow Continue to take action in your IDE and beyond (when you give permission). Currently, they are only supported with [Anthropic](./model-providers/top-level/anthropic.md). To use tools, click on the icon in the input toolbar like below. + +![tools](/img/tool-use-example.png) + +To let you balance speed and safety, each tool can be set to 1 of 3 modes: + +- `Automatic`: When the LLM requests to use the tool, Continue will automatically call it and send the response to the LLM. +- `Allowed`: When the LLM requests to use the tool, Continue will first give you the opportunity to "Cancel" or "Continue" with the tool. +- `Disabled`: The LLM will not know about or be able to use the tool. + +### Custom tools + +Currently custom tools can be configured using the [Model Context Protocol](https://modelcontextprotocol.io/introduction), a standard proposed by Anthropic to unify prompts, context, and tool use. Read their [quickstart](https://modelcontextprotocol.io/quickstart) to learn how to set up a local server and then configure your `config.json` like this: + +```json title="~/.continue/config.json" +{ + "experimental": { + "modelContextProtocolServer": { + "transport": { + "type": "stdio", + "command": "uvx", + "args": ["mcp-server-sqlite", "--db-path", "/Users/NAME/test.db"] + } + } + } +} +``` diff --git a/docs/sidebars.js b/docs/sidebars.js index 11f2e2fd3..caa6fdc52 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -110,6 +110,7 @@ const sidebars = { }, "customize/context-providers", "customize/slash-commands", + "customize/tools", "customize/development-data", { type: "category", diff --git a/docs/static/img/tool-use-example.png b/docs/static/img/tool-use-example.png new file mode 100644 index 000000000..63f1c456a Binary files /dev/null and b/docs/static/img/tool-use-example.png differ diff --git a/extensions/intellij/.run/Prompt Logs.run.xml b/extensions/intellij/.run/Prompt Logs.run.xml index 23fec409a..ce8c399dd 100644 --- a/extensions/intellij/.run/Prompt Logs.run.xml +++ b/extensions/intellij/.run/Prompt Logs.run.xml @@ -1,6 +1,6 @@ -