diff --git a/.continue/rules/intellij-plugin-test-execution.yaml b/.continue/rules/intellij-plugin-test-execution.yaml new file mode 100644 index 000000000..386a72a2b --- /dev/null +++ b/.continue/rules/intellij-plugin-test-execution.yaml @@ -0,0 +1,15 @@ +name: IntelliJ Plugin Test Execution +version: 0.0.1 +schema: v1 +rules: + - name: IntelliJ Plugin Test Execution + rule: |- + Run IntelliJ plugin tests using Gradle with the fully qualified test class or method name: + ```bash + # Run test class + ./gradlew test --tests "com.github.continuedev.continueintellijextension.unit.ApplyToFileHandlerTest" + + # Run specific test method + ./gradlew test --tests "com.github.continuedev.continueintellijextension.unit.ApplyToFileHandlerTest.should*" + ``` + globs: extensions/intellij/**/*Test.kt diff --git a/.continue/rules/intellij-test-standards.yaml b/.continue/rules/intellij-test-standards.yaml new file mode 100644 index 000000000..f706757e2 --- /dev/null +++ b/.continue/rules/intellij-test-standards.yaml @@ -0,0 +1,10 @@ +name: IntelliJ Test Standards +version: 0.0.1 +schema: v1 +rules: + - name: IntelliJ Test Standards + rule: When writing tests for the IntelliJ plugin, use the mockk library for + mocking. Prefer mockk's idiomatic syntax for creating and verifying mocks. + Always structure tests with clear Arrange-Act-Assert patterns and use + descriptive test names that indicate the scenario being tested. + globs: "**/test/**/*.kt" diff --git a/.continue/rules/unit-testing-rules.yaml b/.continue/rules/unit-testing-rules.yaml new file mode 100644 index 000000000..ec22e9467 --- /dev/null +++ b/.continue/rules/unit-testing-rules.yaml @@ -0,0 +1,30 @@ +name: unit-testing-rules +version: 0.0.1 +schema: v1 +rules: + - name: unit-testing-rules + rule: >- + For unit testing in this project: + + + 1. The project uses Jest as the testing framework + + 2. Run tests using `npm test` from within the specific package/module + directory + + 3. Command structure: `cd [directory] && npm test -- [test file path]` + + 4. The test script uses experimental VM modules via NODE_OPTIONS flag + + 5. Test files follow the pattern `*.test.ts` + + 6. Tests must import Jest with `import { jest } from "@jest/globals";` + + 7. Run tests from within the specific package directory (e.g., `cd core` + for core module tests) + + 8. Write tests as top-level `test()` functions - DO NOT use `describe()` + blocks + + 9. Include the function name being tested in the test description for + clarity diff --git a/.gitignore b/.gitignore index 2ca914069..95cd177a9 100644 --- a/.gitignore +++ b/.gitignore @@ -162,5 +162,8 @@ extensions/.continue-debug/ *.vsix +# intellij module library files +*.iml + .continuerules **/.continue/assistants/ \ No newline at end of file diff --git a/.idea/jsLinters/eslint.xml b/.idea/jsLinters/eslint.xml new file mode 100644 index 000000000..541945bb0 --- /dev/null +++ b/.idea/jsLinters/eslint.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/prettier.xml b/.idea/prettier.xml index b0c1c68fb..0c83ac4e8 100644 --- a/.idea/prettier.xml +++ b/.idea/prettier.xml @@ -2,5 +2,6 @@ \ No newline at end of file diff --git a/binary/build.js b/binary/build.js index 574a90444..b67afb94f 100644 --- a/binary/build.js +++ b/binary/build.js @@ -64,7 +64,7 @@ async function buildWithEsbuild() { format: "cjs", platform: "node", sourcemap: true, - minify: true, + minify: !esbuildOnly, treeShaking: true, loader: { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/binary/package-lock.json b/binary/package-lock.json index b2b1c8d41..acb5b9fea 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -33,6 +33,7 @@ "@types/jest": "^29.5.12", "@types/uuid": "^9.0.8", "@vercel/ncc": "^0.38.1", + "cross-env": "^7.0.3", "esbuild": "0.19.11", "jest": "^29.7.0", "pkg": "^5.8.1", @@ -3196,6 +3197,25 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", diff --git a/binary/package.json b/binary/package.json index a9926e8f5..0e8949aa6 100644 --- a/binary/package.json +++ b/binary/package.json @@ -33,6 +33,7 @@ "@types/jest": "^29.5.12", "@types/uuid": "^9.0.8", "@vercel/ncc": "^0.38.1", + "cross-env": "^7.0.3", "esbuild": "0.19.11", "jest": "^29.7.0", "pkg": "^5.8.1", diff --git a/core/autocomplete/templating/AutocompleteTemplate.ts b/core/autocomplete/templating/AutocompleteTemplate.ts index 6385fa22b..39c653792 100644 --- a/core/autocomplete/templating/AutocompleteTemplate.ts +++ b/core/autocomplete/templating/AutocompleteTemplate.ts @@ -71,6 +71,21 @@ const qwenCoderFimTemplate: AutocompleteTemplate = { }, }; +const seedCoderFimTemplate: AutocompleteTemplate = { + template: "<[fim-prefix]>{{{prefix}}}<[fim-suffix]>{{{suffix}}}<[fim-middle]>", + completionOptions: { + stop: [ + "<[end▁of▁sentence]>", + "<[fim-prefix]>", + "<[fim-middle]>", + "<[fim-suffix]>", + "<[PAD▁TOKEN]>", + "<[SEP▁TOKEN]>", + "<[begin▁of▁sentence]>", + ], + }, +}; + const codestralFimTemplate: AutocompleteTemplate = { template: "[SUFFIX]{{{suffix}}}[PREFIX]{{{prefix}}}", completionOptions: { @@ -426,6 +441,10 @@ export function getTemplateForModel(model: string): AutocompleteTemplate { return qwenCoderFimTemplate; } + if (lowerCaseModel.includes("seed") && lowerCaseModel.includes("coder")) { + return seedCoderFimTemplate; + } + if ( lowerCaseModel.includes("starcoder") || lowerCaseModel.includes("star-coder") || diff --git a/core/index.d.ts b/core/index.d.ts index d15c73b50..3a0e40c5b 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -197,15 +197,14 @@ export interface CustomContextProvider { description?: string; renderInlineAs?: string; type?: ContextProviderType; + loadSubmenuItems?: ( + args: LoadSubmenuItemsArgs, + ) => Promise; getContextItems( query: string, extras: ContextProviderExtras, ): Promise; - - loadSubmenuItems?: ( - args: LoadSubmenuItemsArgs, - ) => Promise; } export interface ContextSubmenuItem { @@ -459,6 +458,7 @@ export interface ChatHistoryItem { toolCallState?: ToolCallState; isGatheringContext?: boolean; reasoning?: Reasoning; + appliedRules?: RuleWithSource[]; } export interface LLMFullCompletionOptions extends BaseCompletionOptions { @@ -1167,6 +1167,7 @@ export interface MCPResource { description?: string; mimeType?: string; } + export interface MCPTool { name: string; description?: string; @@ -1229,6 +1230,28 @@ export interface ApplyState { toolCallId?: string; } +export interface StreamDiffLinesPayload { + prefix: string; + highlighted: string; + suffix: string; + input: string; + language: string | undefined; + modelTitle: string | undefined; + includeRulesInSystemMessage: boolean; + fileUri?: string; +} + +export interface HighlightedCodePayload { + rangeInFileWithContents: RangeInFileWithContents; + prompt?: string; + shouldRun?: boolean; +} + +export interface AcceptOrRejectDiffPayload { + filepath: string; + streamId?: string; +} + export interface RangeInFileWithContents { filepath: string; range: { @@ -1238,7 +1261,7 @@ export interface RangeInFileWithContents { contents: string; } -export type CodeToEdit = RangeInFileWithContents | FileWithContents; +export type SetCodeToEditPayload = RangeInFileWithContents | FileWithContents; /** * Represents the configuration for a quick action in the Code Lens. @@ -1497,17 +1520,19 @@ export interface TerminalOptions { waitForCompletion?: boolean; } +export type RuleSource = + | "default-chat" + | "default-agent" + | "model-chat-options" + | "model-agent-options" + | "rules-block" + | "json-systemMessage" + | ".continuerules"; + export interface RuleWithSource { name?: string; slug?: string; - source: - | "default-chat" - | "default-agent" - | "model-chat-options" - | "model-agent-options" - | "rules-block" - | "json-systemMessage" - | ".continuerules"; + source: RuleSource; globs?: string | string[]; rule: string; description?: string; diff --git a/core/indexing/CodeSnippetsIndex.ts b/core/indexing/CodeSnippetsIndex.ts index 9a2da5008..bf79b093e 100644 --- a/core/indexing/CodeSnippetsIndex.ts +++ b/core/indexing/CodeSnippetsIndex.ts @@ -7,7 +7,7 @@ import { getQueryForFile, } from "../util/treeSitter"; -import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex"; +import { DatabaseConnection, SqliteDb } from "./refreshIndex"; import { IndexResultType, MarkCompleteCallback, @@ -29,6 +29,7 @@ import { getLastNUriRelativePathParts, getUriPathBasename, } from "../util/uri"; +import { tagToString } from "./utils"; type SnippetChunk = ChunkWithoutID & { title: string; signature: string }; diff --git a/core/indexing/FullTextSearchCodebaseIndex.ts b/core/indexing/FullTextSearchCodebaseIndex.ts index de183e158..1bac74e4a 100644 --- a/core/indexing/FullTextSearchCodebaseIndex.ts +++ b/core/indexing/FullTextSearchCodebaseIndex.ts @@ -3,13 +3,14 @@ import { RETRIEVAL_PARAMS } from "../util/parameters"; import { getUriPathBasename } from "../util/uri"; import { ChunkCodebaseIndex } from "./chunk/ChunkCodebaseIndex"; -import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex"; +import { DatabaseConnection, SqliteDb } from "./refreshIndex"; import { IndexResultType, MarkCompleteCallback, RefreshIndexResults, type CodebaseIndex, } from "./types"; +import { tagToString } from "./utils"; export interface RetrieveConfig { tags: BranchAndDir[]; @@ -97,11 +98,14 @@ export class FullTextSearchCodebaseIndex implements CodebaseIndex { // Delete for (const item of results.del) { - await db.run(` + await db.run( + ` DELETE FROM fts WHERE rowid IN ( SELECT id FROM fts_metadata WHERE path = ? AND cacheKey = ? ) - `,[item.path, item.cacheKey]); + `, + [item.path, item.cacheKey], + ); await db.run("DELETE FROM fts_metadata WHERE path = ? AND cacheKey = ?", [ item.path, item.cacheKey, diff --git a/core/indexing/LanceDbIndex.ts b/core/indexing/LanceDbIndex.ts index 3bf9a645d..cf41beaca 100644 --- a/core/indexing/LanceDbIndex.ts +++ b/core/indexing/LanceDbIndex.ts @@ -14,7 +14,7 @@ import { getUriPathBasename } from "../util/uri"; import { basicChunker } from "./chunk/basic.js"; import { chunkDocument, shouldChunk } from "./chunk/chunk.js"; -import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex.js"; +import { DatabaseConnection, SqliteDb } from "./refreshIndex.js"; import { CodebaseIndex, IndexResultType, @@ -24,6 +24,7 @@ import { } from "./types"; import type * as LanceType from "vectordb"; +import { tagToString } from "./utils"; interface LanceDbRow { uuid: string; diff --git a/core/indexing/chunk/ChunkCodebaseIndex.ts b/core/indexing/chunk/ChunkCodebaseIndex.ts index 9b39e506a..412ff7480 100644 --- a/core/indexing/chunk/ChunkCodebaseIndex.ts +++ b/core/indexing/chunk/ChunkCodebaseIndex.ts @@ -4,7 +4,7 @@ import { RunResult } from "sqlite3"; import { IContinueServerClient } from "../../continueServer/interface.js"; import { Chunk, IndexTag, IndexingProgressUpdate } from "../../index.js"; -import { DatabaseConnection, SqliteDb, tagToString } from "../refreshIndex.js"; +import { DatabaseConnection, SqliteDb } from "../refreshIndex.js"; import { IndexResultType, MarkCompleteCallback, @@ -13,8 +13,9 @@ import { type CodebaseIndex, } from "../types.js"; -import { chunkDocument, shouldChunk } from "./chunk.js"; import { getUriPathBasename } from "../../util/uri.js"; +import { tagToString } from "../utils.js"; +import { chunkDocument, shouldChunk } from "./chunk.js"; export class ChunkCodebaseIndex implements CodebaseIndex { relativeExpectedTime: number = 1; diff --git a/core/indexing/refreshIndex.ts b/core/indexing/refreshIndex.ts index f76c6a7f6..ec84f631b 100644 --- a/core/indexing/refreshIndex.ts +++ b/core/indexing/refreshIndex.ts @@ -18,10 +18,6 @@ import { export type DatabaseConnection = Database; -export function tagToString(tag: IndexTag): string { - return `${tag.directory}::${tag.branch}::${tag.artifactId}`; -} - export class SqliteDb { static db: DatabaseConnection | null = null; diff --git a/core/indexing/test/indexing.ts b/core/indexing/test/indexing.ts index 5f22d0aeb..b90f52564 100644 --- a/core/indexing/test/indexing.ts +++ b/core/indexing/test/indexing.ts @@ -3,11 +3,11 @@ import { jest } from "@jest/globals"; import { IndexTag } from "../.."; import { IContinueServerClient } from "../../continueServer/interface"; import { ChunkCodebaseIndex } from "../chunk/ChunkCodebaseIndex"; -import { tagToString } from "../refreshIndex"; import { CodebaseIndex, RefreshIndexResults } from "../types"; import { testIde } from "../../test/fixtures"; import { addToTestDir, TEST_DIR } from "../../test/testDir"; +import { tagToString } from "../utils"; export const mockFilename = "test.py"; export const mockPathAndCacheKey = { diff --git a/core/indexing/utils.test.ts b/core/indexing/utils.test.ts new file mode 100644 index 000000000..f432da023 --- /dev/null +++ b/core/indexing/utils.test.ts @@ -0,0 +1,58 @@ +import { IndexTag } from ".."; +import { tagToString } from "./utils"; + +test("tagToString returns full tag string when under length limit", () => { + const tag: IndexTag = { + directory: "/normal/path/to/repo", + branch: "main", + artifactId: "12345", + }; + + expect(tagToString(tag)).toBe("/normal/path/to/repo::main::12345"); +}); + +test("tagToString truncates beginning of directory when path is too long", () => { + // Create a very long directory path that exceeds MAX_DIR_LENGTH (200) + const longPrefix = "/very/long/path/that/will/be/truncated/"; + const importantSuffix = "/user/important-project/src/feature"; + const longPath = longPrefix + "x".repeat(200) + importantSuffix; + + const tag: IndexTag = { + directory: longPath, + branch: "feature-branch", + artifactId: "67890", + }; + + const result = tagToString(tag); + + // The result should keep the important suffix part + expect(result).toContain(importantSuffix); + // The result should NOT contain the beginning of the path + expect(result).not.toContain(longPrefix); + // The result should include the branch and artifactId + expect(result).toContain("::feature-branch::67890"); + // The result should be within the MAX_TABLE_NAME_LENGTH limit (240) + expect(result.length).toBeLessThanOrEqual(240); +}); + +test("tagToString preserves branch and artifactId exactly, even when truncating", () => { + const longPath = "/a".repeat(300); // Much longer than MAX_DIR_LENGTH + const tag: IndexTag = { + directory: longPath, + branch: "release-v2.0", + artifactId: "build-123", + }; + + const result = tagToString(tag); + + // Should contain the exact branch and artifactId + expect(result).toContain("::release-v2.0::build-123"); + // Should contain the end of the path + expect(result).toContain("/a/a/a"); + // Should not contain the full original path (it should be truncated) + expect(result.length).toBeLessThan( + longPath.length + "::release-v2.0::build-123".length, + ); + // The result should be within the MAX_TABLE_NAME_LENGTH limit + expect(result.length).toBeLessThanOrEqual(240); +}); diff --git a/core/indexing/utils.ts b/core/indexing/utils.ts new file mode 100644 index 000000000..0713507f0 --- /dev/null +++ b/core/indexing/utils.ts @@ -0,0 +1,45 @@ +import { IndexTag } from ".."; + +// Maximum length for table names to stay under OS filename limits +const MAX_TABLE_NAME_LENGTH = 240; + +// Leave room for branch and artifactId +const MAX_DIR_LENGTH = 200; + +/** + * Converts an IndexTag to a string representation, safely handling long paths. + * + * The string is used as a table name and identifier in various places, so it needs + * to stay under OS filename length limits (typically 255 chars). This is especially + * important for dev containers where the directory path can be very long due to + * containing container configuration. + * + * The format is: "{directory}::{branch}::{artifactId}" + * + * To handle long paths: + * 1. First tries the full string - most backwards compatible + * 2. If too long, truncates directory from the beginning to maintain uniqueness + * (since final parts of paths are more unique than prefixes) + * 3. Finally ensures entire string stays under MAX_TABLE_NAME_LENGTH for OS compatibility + * + * @param tag The tag containing directory, branch, and artifactId + * @returns A string representation safe for use as a table name + */ +export function tagToString(tag: IndexTag): string { + const result = `${tag.directory}::${tag.branch}::${tag.artifactId}`; + + if (result.length <= MAX_TABLE_NAME_LENGTH) { + return result; + } + + // Truncate from the beginning of directory path to preserve the more unique end parts + const dir = + tag.directory.length > MAX_DIR_LENGTH + ? tag.directory.slice(tag.directory.length - MAX_DIR_LENGTH) + : tag.directory; + + return `${dir}::${tag.branch}::${tag.artifactId}`.slice( + 0, + MAX_TABLE_NAME_LENGTH, + ); +} diff --git a/core/llm/llm.test.ts b/core/llm/llm.test.ts index d1067a8bc..7fb840d61 100644 --- a/core/llm/llm.test.ts +++ b/core/llm/llm.test.ts @@ -230,6 +230,7 @@ describe("LLM", () => { testFim: true, skip: false, testToolCall: true, + timeout: 60000, }, ); testLLM( diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index dacd941bb..3d7372fef 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -23,6 +23,29 @@ const matchesGlobs = ( return false; }; +/** + * Filters rules that apply to the given message + */ +export const getApplicableRules = ( + userMessage: UserChatMessage | ToolResultChatMessage | undefined, + rules: RuleWithSource[], +): RuleWithSource[] => { + const filePathsFromMessage = userMessage + ? extractPathsFromCodeBlocks(renderChatMessage(userMessage)) + : []; + + return rules.filter((rule) => { + // A rule is active if it has no globs (applies to all files) + // or if at least one file path matches its globs + const hasNoGlobs = !rule.globs; + const matchesAnyFilePath = filePathsFromMessage.some((path) => + matchesGlobs(path, rule.globs), + ); + + return hasNoGlobs || matchesAnyFilePath; + }); +}; + export const getSystemMessageWithRules = ({ baseSystemMessage, userMessage, @@ -32,23 +55,11 @@ export const getSystemMessageWithRules = ({ userMessage: UserChatMessage | ToolResultChatMessage | undefined; rules: RuleWithSource[]; }) => { - const filePathsFromMessage = userMessage - ? extractPathsFromCodeBlocks(renderChatMessage(userMessage)) - : []; - + const applicableRules = getApplicableRules(userMessage, rules); let systemMessage = baseSystemMessage ?? ""; - for (const rule of rules) { - // A rule is active if it has no globs (applies to all files) - // or if at least one file path matches its globs - const hasNoGlobs = !rule.globs; - const matchesAnyFilePath = filePathsFromMessage.some((path) => - matchesGlobs(path, rule.globs), - ); - - if (hasNoGlobs || matchesAnyFilePath) { - systemMessage += `\n\n${rule.rule}`; - } + for (const rule of applicableRules) { + systemMessage += `\n\n${rule.rule}`; } return systemMessage; diff --git a/core/llm/templates/edit/gpt.ts b/core/llm/templates/edit/gpt.ts index 4dcc39523..61d23a732 100644 --- a/core/llm/templates/edit/gpt.ts +++ b/core/llm/templates/edit/gpt.ts @@ -64,6 +64,8 @@ export const gptEditPrompt: PromptTemplateFunction = (history, otherData) => { \`\`\` The user's request is: "${otherData.userInput}" + + DO NOT output any natural language, only output the code changes. Here is the rewritten code:`); diff --git a/core/package-lock.json b/core/package-lock.json index 71133e753..ea049ae74 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -15266,9 +15266,9 @@ } }, "node_modules/undici": { - "version": "6.21.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.1.tgz", - "integrity": "sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==", + "version": "6.21.3", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.3.tgz", + "integrity": "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==", "license": "MIT", "engines": { "node": ">=18.17" diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 92653d8c5..a460a8076 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -9,7 +9,7 @@ import { AutocompleteInput } from "../autocomplete/util/types"; import { SharedConfigSchema } from "../config/sharedConfig"; import { GlobalContextModelSelections } from "../util/GlobalContext"; -import type { +import { BrowserSerializedContinueConfig, ChatMessage, ContextItem, @@ -29,6 +29,7 @@ import type { SessionMetadata, SiteIndexingConfig, SlashCommandDescription, + StreamDiffLinesPayload, ToolCall, } from "../"; import { SerializedOrgWithProfiles } from "../config/ProfileLifecycleManager"; @@ -143,19 +144,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { }, AsyncGenerator, ]; - streamDiffLines: [ - { - prefix: string; - highlighted: string; - suffix: string; - input: string; - language: string | undefined; - modelTitle: string | undefined; - includeRulesInSystemMessage: boolean; - fileUri?: string; - }, - AsyncGenerator, - ]; + streamDiffLines: [StreamDiffLinesPayload, AsyncGenerator]; "chatDescriber/describe": [ { text: string; diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 17c09a348..3c836126a 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -1,11 +1,13 @@ import { ToIdeFromWebviewOrCoreProtocol } from "./ide"; import { ToWebviewFromIdeOrCoreProtocol } from "./webview"; -import type { +import { ApplyState, - CodeToEdit, + SetCodeToEditPayload, + HighlightedCodePayload, MessageContent, RangeInFileWithContents, + AcceptOrRejectDiffPayload, } from "../"; export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { @@ -42,8 +44,8 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { "jetbrains/getColors": [undefined, Record]; "vscode/openMoveRightMarkdown": [undefined, void]; setGitHubAuthToken: [{ token: string }, void]; - acceptDiff: [{ filepath: string; streamId?: string }, void]; - rejectDiff: [{ filepath: string; streamId?: string }, void]; + acceptDiff: [AcceptOrRejectDiffPayload, void]; + rejectDiff: [AcceptOrRejectDiffPayload, void]; "edit/sendPrompt": [ { prompt: MessageContent; @@ -63,15 +65,8 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & { focusContinueInput: [undefined, void]; focusContinueInputWithoutClear: [undefined, void]; focusContinueInputWithNewSession: [undefined, void]; - highlightedCode: [ - { - rangeInFileWithContents: RangeInFileWithContents; - prompt?: string; - shouldRun?: boolean; - }, - void, - ]; - setCodeToEdit: [CodeToEdit, void]; + highlightedCode: [HighlightedCodePayload, void]; + setCodeToEdit: [SetCodeToEditPayload, void]; navigateTo: [{ path: string; toggle?: boolean }, void]; addModel: [undefined, void]; diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index d8eaf4ffd..34501550b 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -29,11 +29,12 @@ async function callHttpTool( }), }); + const data = await response.json(); + if (!response.ok) { - throw new Error(`Failed to call tool: ${url}`); + throw new Error(`Failed to call tool at ${url}:\n${JSON.stringify(data)}`); } - const data = await response.json(); return data.output; } @@ -84,7 +85,7 @@ async function callToolFromUri( }); if (response.isError === true) { - throw new Error(`Failed to call tool: ${toolName}`); + throw new Error(JSON.stringify(response.content)); } const contextItems: ContextItem[] = []; @@ -130,6 +131,37 @@ async function callToolFromUri( } } +async function callBuiltInTool( + functionName: string, + args: any, + extras: ToolExtras, +): Promise { + switch (functionName) { + case BuiltInToolNames.ReadFile: + return await readFileImpl(args, extras); + case BuiltInToolNames.CreateNewFile: + return await createNewFileImpl(args, extras); + case BuiltInToolNames.GrepSearch: + return await grepSearchImpl(args, extras); + case BuiltInToolNames.FileGlobSearch: + return await fileGlobSearchImpl(args, extras); + case BuiltInToolNames.RunTerminalCommand: + return await runTerminalCommandImpl(args, extras); + case BuiltInToolNames.SearchWeb: + return await searchWebImpl(args, extras); + case BuiltInToolNames.ViewDiff: + return await viewDiffImpl(args, extras); + case BuiltInToolNames.LSTool: + return await lsToolImpl(args, extras); + case BuiltInToolNames.ReadCurrentlyOpenFile: + return await readCurrentlyOpenFileImpl(args, extras); + case BuiltInToolNames.CreateRuleBlock: + return await createRuleBlockImpl(args, extras); + default: + throw new Error(`Tool "${functionName}" not found`); + } +} + // Handles calls for core/non-client tools // Returns an error context item if the tool call fails // Note: Edit tool is handled on client @@ -141,44 +173,11 @@ export async function callTool( contextItems: ContextItem[]; errorMessage: string | undefined; }> { - const args = JSON.parse(callArgs || "{}"); - const uri = tool.uri ?? tool.function.name; try { - let contextItems: ContextItem[] = []; - switch (uri) { - case BuiltInToolNames.ReadFile: - contextItems = await readFileImpl(args, extras); - break; - case BuiltInToolNames.CreateNewFile: - contextItems = await createNewFileImpl(args, extras); - break; - case BuiltInToolNames.GrepSearch: - contextItems = await grepSearchImpl(args, extras); - break; - case BuiltInToolNames.FileGlobSearch: - contextItems = await fileGlobSearchImpl(args, extras); - break; - case BuiltInToolNames.RunTerminalCommand: - contextItems = await runTerminalCommandImpl(args, extras); - break; - case BuiltInToolNames.SearchWeb: - contextItems = await searchWebImpl(args, extras); - break; - case BuiltInToolNames.ViewDiff: - contextItems = await viewDiffImpl(args, extras); - break; - case BuiltInToolNames.LSTool: - contextItems = await lsToolImpl(args, extras); - break; - case BuiltInToolNames.ReadCurrentlyOpenFile: - contextItems = await readCurrentlyOpenFileImpl(args, extras); - break; - case BuiltInToolNames.CreateRuleBlock: - contextItems = await createRuleBlockImpl(args, extras); - break; - default: - contextItems = await callToolFromUri(uri, args, extras); - } + const args = JSON.parse(callArgs || "{}"); + const contextItems = tool.uri + ? await callToolFromUri(tool.uri, args, extras) + : await callBuiltInTool(tool.function.name, args, extras); if (tool.faviconUrl) { contextItems.forEach((item) => { item.icon = tool.faviconUrl; diff --git a/docs/docs/CLA.md b/docs/docs/CLA.md index 11a86a412..00cd9ef07 100644 --- a/docs/docs/CLA.md +++ b/docs/docs/CLA.md @@ -17,6 +17,13 @@ past and future “Contributions” submitted to **Continue (the “Project”)* ## 2. Copyright License +You grant **Continue Dev, Inc.** and all recipients of software distributed by the +Project a perpetual, worldwide, non‑exclusive, royalty‑free, irrevocable +license to reproduce, prepare derivative works of, publicly display, publicly +perform, sublicense, and distribute Your Contributions and derivative works. + +## 3. Patent License + You grant **Continue Dev, Inc.** and all recipients of the Project a perpetual, worldwide, non‑exclusive, royalty‑free, irrevocable (except as below) patent license to make, have made, use, sell, offer to sell, import, and otherwise @@ -38,4 +45,4 @@ entity under this CLA terminate. This Agreement is governed by the laws of the **State of California**, USA, excluding its conflict‑of‑laws rules. If any provision is held unenforceable, -the remaining provisions remain in force. \ No newline at end of file +the remaining provisions remain in force. diff --git a/docs/docs/troubleshooting.mdx b/docs/docs/troubleshooting.mdx index 71eac9d9b..9692191eb 100644 --- a/docs/docs/troubleshooting.mdx +++ b/docs/docs/troubleshooting.mdx @@ -7,8 +7,6 @@ keywords: [reload, delete, manually, logs, server, console] import TabItem from "@theme/TabItem"; import Tabs from "@theme/Tabs"; -The Continue VS Code extension is currently in beta, and the JetBrains extension is in Alpha. If you are having trouble, please follow the steps below. - 1. [Check the logs](#check-the-logs) 2. [Try the latest pre-release](#download-the-latest-pre-release) 3. [Download an older version](#download-an-older-version) diff --git a/extensions/intellij/.run/Start Core Dev Server (CE).run.xml b/extensions/intellij/.run/Start Core Dev Server (CE).run.xml index d6c646ef9..53c668ab2 100644 --- a/extensions/intellij/.run/Start Core Dev Server (CE).run.xml +++ b/extensions/intellij/.run/Start Core Dev Server (CE).run.xml @@ -1,6 +1,6 @@ -