From 6d6f89fe55e7301d3c84473162d2e4da8bf0dc31 Mon Sep 17 00:00:00 2001 From: Jacob Date: Mon, 9 Jun 2025 11:04:23 +0800 Subject: [PATCH 01/46] fix: Fix the issue where the chunk index might be duplicated --- core/indexing/chunk/chunk.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/indexing/chunk/chunk.ts b/core/indexing/chunk/chunk.ts index d51f368a2..c918ddac8 100644 --- a/core/indexing/chunk/chunk.ts +++ b/core/indexing/chunk/chunk.ts @@ -62,12 +62,11 @@ export async function* chunkDocument({ resolve({ ...chunkWithoutId, digest, - index, + index: index++, filepath, }); }), ); - index++; } for await (const chunk of chunkPromises) { if (!chunk) { From c69270959cb6b30c72e75d0d0dceae348bd490be Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 10 Jun 2025 13:23:46 -0700 Subject: [PATCH 02/46] improved error logging --- .../pipelines/NoRerankerRetrievalPipeline.ts | 10 +++++++++- .../pipelines/RerankerRetrievalPipeline.ts | 7 ++++++- core/util/posthog.ts | 19 +++++++++++++++++++ extensions/vscode/package-lock.json | 4 ++-- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/core/context/retrieval/pipelines/NoRerankerRetrievalPipeline.ts b/core/context/retrieval/pipelines/NoRerankerRetrievalPipeline.ts index f35809fed..ca88c479e 100644 --- a/core/context/retrieval/pipelines/NoRerankerRetrievalPipeline.ts +++ b/core/context/retrieval/pipelines/NoRerankerRetrievalPipeline.ts @@ -1,4 +1,5 @@ import { Chunk } from "../../../"; +import { Telemetry } from "../../../util/posthog"; import { findUriInDirs } from "../../../util/uri"; import { requestFilesFromRepoMap } from "../repoMapRequest"; import { deduplicateChunks } from "../util"; @@ -23,7 +24,8 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline { try { ftsChunks = await this.retrieveFts(args, ftsNFinal); } catch (error) { - console.error("Error retrieving FTS chunks:", error); + await Telemetry.captureError("no_reranker_fts_retrieval", error); + // console.error("Error retrieving FTS chunks:", error); } let embeddingsChunks: Chunk[] = []; @@ -32,6 +34,7 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline { ? await this.retrieveEmbeddings(input, embeddingsNFinal) : []; } catch (error) { + await Telemetry.captureError("no_reranker_embeddings_retrieval", error); console.error("Error retrieving embeddings:", error); } @@ -40,6 +43,10 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline { recentlyEditedFilesChunks = await this.retrieveAndChunkRecentlyEditedFiles(recentlyEditedNFinal); } catch (error) { + await Telemetry.captureError( + "no_reranker_recently_edited_retrieval", + error, + ); console.error("Error retrieving recently edited files:", error); } @@ -53,6 +60,7 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline { filterDirectory, ); } catch (error) { + await Telemetry.captureError("no_reranker_repo_map_retrieval", error); console.error("Error retrieving repo map chunks:", error); } diff --git a/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts b/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts index e73edf118..28de3d096 100644 --- a/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts +++ b/core/context/retrieval/pipelines/RerankerRetrievalPipeline.ts @@ -1,5 +1,6 @@ import { Chunk } from "../../.."; import { RETRIEVAL_PARAMS } from "../../../util/parameters"; +import { Telemetry } from "../../../util/posthog"; import { findUriInDirs } from "../../../util/uri"; import { requestFilesFromRepoMap } from "../repoMapRequest"; import { deduplicateChunks } from "../util"; @@ -20,7 +21,8 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline { try { ftsChunks = await this.retrieveFts(args, nRetrieve); } catch (error) { - console.error("Error retrieving FTS chunks:", error); + await Telemetry.captureError("reranker_fts_retrieval", error); + // console.error("Error retrieving FTS chunks:", error); } let embeddingsChunks: Chunk[] = []; @@ -29,6 +31,7 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline { ? await this.retrieveEmbeddings(input, nRetrieve) : []; } catch (error) { + await Telemetry.captureError("reranker_embeddings_retrieval", error); console.error("Error retrieving embeddings chunks:", error); } @@ -37,6 +40,7 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline { recentlyEditedFilesChunks = await this.retrieveAndChunkRecentlyEditedFiles(nRetrieve); } catch (error) { + await Telemetry.captureError("reranker_recently_edited_retrieval", error); console.error("Error retrieving recently edited files chunks:", error); } @@ -50,6 +54,7 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline { filterDirectory, ); } catch (error) { + await Telemetry.captureError("reranker_repo_map_retrieval", error); console.error("Error retrieving repo map chunks:", error); } diff --git a/core/util/posthog.ts b/core/util/posthog.ts index 25b3ab600..dfde657fb 100644 --- a/core/util/posthog.ts +++ b/core/util/posthog.ts @@ -4,6 +4,7 @@ import { TeamAnalytics } from "../control-plane/TeamAnalytics.js"; import { IdeInfo } from "../index.js"; import type { PostHog as PostHogType } from "posthog-node"; +import { extractMinimalStackTraceInfo } from "./extractMinimalStackTraceInfo.js"; export enum PosthogFeatureFlag { AutocompleteTimeout = "autocomplete-timeout", @@ -37,6 +38,24 @@ export class Telemetry { static os: string | undefined = undefined; static ideInfo: IdeInfo | undefined = undefined; + /** + * Convenience method for capturing errors in a single event + */ + static async captureError(errorName: string, error: unknown) { + if (!(error instanceof Error)) { + return; + } + await Telemetry.capture( + "extension_error_caught", + { + errorName, + message: error.message, + stack: extractMinimalStackTraceInfo(error.stack), + }, + false, + ); + } + static async capture( event: string, properties: { [key: string]: any }, diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 8d4221fa2..f66fd08f3 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.45", + "version": "1.1.46", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.45", + "version": "1.1.46", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", From 498e90778831d3b5bf517c81ab92aa5639c9fe84 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 12 Jun 2025 17:52:13 +0530 Subject: [PATCH 03/46] chore: migrate core (commands) tests to vitest --- core/commands/util.test.ts | 3 ++- core/jest.config.js | 1 + core/vitest.config.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/commands/util.test.ts b/core/commands/util.test.ts index 447ec0e60..656903aa5 100644 --- a/core/commands/util.test.ts +++ b/core/commands/util.test.ts @@ -1,5 +1,6 @@ -import { ctxItemToRifWithContents } from "./util"; +import { describe, expect, it } from "vitest"; import { ContextItemWithId, RangeInFileWithContents } from "../index"; +import { ctxItemToRifWithContents } from "./util"; describe("ctxItemToRifWithContents", () => { it("should parse start and end lines from the item name when format is valid", () => { diff --git a/core/jest.config.js b/core/jest.config.js index 75bb11e9a..7bc65548e 100644 --- a/core/jest.config.js +++ b/core/jest.config.js @@ -35,5 +35,6 @@ export default { testPathIgnorePatterns: [ "/config/yaml/LocalPlatformClient.test.ts", "/autocomplete/", + "/commands/", ], }; diff --git a/core/vitest.config.ts b/core/vitest.config.ts index d781d152d..0bad68f69 100644 --- a/core/vitest.config.ts +++ b/core/vitest.config.ts @@ -13,6 +13,7 @@ export default defineConfig({ "**/*.vitest.ts", "config/yaml/LocalPlatformClient.test.ts", "autocomplete/**/*.test.ts", + "commands/**/*.test.ts", ], }, }); From 27c19aa6ceaf9ad0ca0789628fe2aab80d9b693d Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 13 Jun 2025 19:27:03 +0530 Subject: [PATCH 04/46] migrate `control-plane` to vitest --- core/control-plane/mdm/mdm.test.ts | 1 + core/jest.config.js | 1 + core/vitest.config.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/core/control-plane/mdm/mdm.test.ts b/core/control-plane/mdm/mdm.test.ts index ca4f5f0ec..193960e27 100644 --- a/core/control-plane/mdm/mdm.test.ts +++ b/core/control-plane/mdm/mdm.test.ts @@ -1,4 +1,5 @@ import * as crypto from "crypto"; +import { expect, test } from "vitest"; import { LicenseKeyData, validateLicenseKey } from "./mdm"; // We'll create a real key pair once for all tests diff --git a/core/jest.config.js b/core/jest.config.js index 7bc65548e..b00bd7099 100644 --- a/core/jest.config.js +++ b/core/jest.config.js @@ -36,5 +36,6 @@ export default { "/config/yaml/LocalPlatformClient.test.ts", "/autocomplete/", "/commands/", + "/control-plane/", ], }; diff --git a/core/vitest.config.ts b/core/vitest.config.ts index 0bad68f69..dc7d7dc91 100644 --- a/core/vitest.config.ts +++ b/core/vitest.config.ts @@ -14,6 +14,7 @@ export default defineConfig({ "config/yaml/LocalPlatformClient.test.ts", "autocomplete/**/*.test.ts", "commands/**/*.test.ts", + "control-plane/**/*.test.ts", ], }, }); From 4eb5b777a5a50b1f083fe260891fd5c1d5e74846 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 13 Jun 2025 19:28:17 +0530 Subject: [PATCH 05/46] migrate `data` to vitest --- core/data/log.test.ts | 24 ++++++++++++++++-------- core/jest.config.js | 1 + core/vitest.config.ts | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/core/data/log.test.ts b/core/data/log.test.ts index 1b7b42b2e..f79e05130 100644 --- a/core/data/log.test.ts +++ b/core/data/log.test.ts @@ -1,13 +1,22 @@ import { DevDataLogEvent } from "@continuedev/config-yaml"; import fs from "fs"; import path from "path"; +import { + afterAll, + beforeAll, + beforeEach, + describe, + expect, + it, + vi, +} from "vitest"; import { IdeInfo, IdeSettings } from ".."; import { Core } from "../core"; import { getDevDataFilePath } from "../util/paths"; import { DataLogger } from "./log"; // Only mock fetch, not fs -jest.mock("@continuedev/fetch"); +vi.mock("@continuedev/fetch"); const TEST_EVENT: DevDataLogEvent = { name: "tokensGenerated", @@ -54,7 +63,7 @@ describe("DataLogger", () => { beforeEach(() => { // Reset mocks - jest.clearAllMocks(); + vi.clearAllMocks(); // Remove test file if it exists if (fs.existsSync(testFilePath)) { @@ -67,7 +76,7 @@ describe("DataLogger", () => { // Mock core and required promises dataLogger.core = { configHandler: { - loadConfig: jest.fn().mockResolvedValue({ + loadConfig: vi.fn().mockResolvedValue({ config: { data: [], }, @@ -78,7 +87,7 @@ describe("DataLogger", () => { }, }, controlPlaneClient: { - getAccessToken: jest.fn().mockResolvedValue("test-access-token"), + getAccessToken: vi.fn().mockResolvedValue("test-access-token"), }, }, } as unknown as Core; @@ -184,7 +193,6 @@ describe("DataLogger", () => { // Read file contents and verify const fileContent = fs.readFileSync(filepath, "utf8"); - console.log("debug1 filecontent", fileContent); expect(fileContent).toContain('"eventName":"chatInteraction"'); expect(fileContent).toContain('"prompt":"Hello, world!"'); expect(fileContent).toContain('"completion":"Hello, world!"'); @@ -195,10 +203,10 @@ describe("DataLogger", () => { describe("logDevData", () => { it("should log data locally and to configured destinations", async () => { // Spy on logLocalData and logToOneDestination - const logLocalDataSpy = jest + const logLocalDataSpy = vi .spyOn(dataLogger, "logLocalData") .mockResolvedValue(); - const logToOneDestinationSpy = jest + const logToOneDestinationSpy = vi .spyOn(dataLogger, "logToOneDestination") .mockResolvedValue(); @@ -212,7 +220,7 @@ describe("DataLogger", () => { }, }; - dataLogger.core!.configHandler.loadConfig = jest + dataLogger.core!.configHandler.loadConfig = vi .fn() .mockResolvedValue(mockConfig); diff --git a/core/jest.config.js b/core/jest.config.js index b00bd7099..da0bb3a79 100644 --- a/core/jest.config.js +++ b/core/jest.config.js @@ -37,5 +37,6 @@ export default { "/autocomplete/", "/commands/", "/control-plane/", + "/data/", ], }; diff --git a/core/vitest.config.ts b/core/vitest.config.ts index dc7d7dc91..129c71a03 100644 --- a/core/vitest.config.ts +++ b/core/vitest.config.ts @@ -15,6 +15,7 @@ export default defineConfig({ "autocomplete/**/*.test.ts", "commands/**/*.test.ts", "control-plane/**/*.test.ts", + "data/**/*.test.ts", ], }, }); From c86fb9cfcbd4c02d2976cee59d11402e62d3a726 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 13 Jun 2025 19:29:41 +0530 Subject: [PATCH 06/46] migrate `diff` folder --- core/diff/myers.test.ts | 2 ++ core/diff/streamDiff.test.ts | 9 +++------ core/diff/util.test.ts | 8 ++++---- core/jest.config.js | 1 + core/vitest.config.ts | 1 + 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/diff/myers.test.ts b/core/diff/myers.test.ts index 0683e5a96..a5902142a 100644 --- a/core/diff/myers.test.ts +++ b/core/diff/myers.test.ts @@ -1,3 +1,5 @@ +import { describe, expect, test } from "vitest"; + import { dedent } from "../util"; import { myersDiff } from "./myers"; diff --git a/core/diff/streamDiff.test.ts b/core/diff/streamDiff.test.ts index 560d2e13d..57c6e77f1 100644 --- a/core/diff/streamDiff.test.ts +++ b/core/diff/streamDiff.test.ts @@ -1,6 +1,8 @@ import fs from "node:fs"; import path from "node:path"; +import { describe, expect, test } from "vitest"; + // @ts-ignore no typings available import { changed, diff as myersDiff } from "myers-diff"; import { streamDiff } from "../diff/streamDiff.js"; @@ -54,12 +56,7 @@ function displayDiff(diff: DiffLine[]) { } async function expectDiff(file: string) { - const testFilePath = path.join( - __dirname, - "diff", - "test-examples", - file + ".diff", - ); + const testFilePath = path.join(__dirname, "test-examples", file + ".diff"); const testFileContents = fs.readFileSync(testFilePath, "utf-8"); const [oldText, newText, expectedDiff] = testFileContents .split("\n---\n") diff --git a/core/diff/util.test.ts b/core/diff/util.test.ts index fca80ba6a..b94ab6317 100644 --- a/core/diff/util.test.ts +++ b/core/diff/util.test.ts @@ -1,8 +1,8 @@ // Generated by continue -import { matchLine, streamLines, generateLines } from "./util"; +import { describe, expect, it, vi } from "vitest"; import { ChatMessage } from "../index"; -import { jest } from "@jest/globals"; +import { generateLines, matchLine, streamLines } from "./util"; describe.skip("matchLine", () => { it("should match empty lines if the first old line is also empty", () => { @@ -146,7 +146,7 @@ describe("streamLines", () => { content: "line4", }; - // const spy = jest.spyOn(messageContentModule, "renderChatMessage"); + // const spy = vi.spyOn(messageContentModule, "renderChatMessage"); async function* streamCompletion(): AsyncGenerator { yield messageChunk1; @@ -164,7 +164,7 @@ describe("streamLines", () => { }); it("should log lines if log parameter is true", async () => { - const consoleSpy = jest.spyOn(console, "log").mockImplementation(() => {}); + const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {}); async function* streamCompletion(): AsyncGenerator { yield "line1\nline2\n"; diff --git a/core/jest.config.js b/core/jest.config.js index da0bb3a79..6c8a12faf 100644 --- a/core/jest.config.js +++ b/core/jest.config.js @@ -38,5 +38,6 @@ export default { "/commands/", "/control-plane/", "/data/", + "/diff/", ], }; diff --git a/core/vitest.config.ts b/core/vitest.config.ts index 129c71a03..b3c387fdb 100644 --- a/core/vitest.config.ts +++ b/core/vitest.config.ts @@ -16,6 +16,7 @@ export default defineConfig({ "commands/**/*.test.ts", "control-plane/**/*.test.ts", "data/**/*.test.ts", + "diff/**/*.test.ts", ], }, }); From a6f030420f436050db089044eff536db2adb2f13 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 18 Jun 2025 13:48:17 -0700 Subject: [PATCH 07/46] programming principles rule --- .continue/rules/programming-principles.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .continue/rules/programming-principles.md diff --git a/.continue/rules/programming-principles.md b/.continue/rules/programming-principles.md new file mode 100644 index 000000000..0485f4f68 --- /dev/null +++ b/.continue/rules/programming-principles.md @@ -0,0 +1,6 @@ +--- +name: Programming principles +description: Guidelines for coding fundamentals in this project +--- + +Use functional programming paradigms whenever possible. Modifying existing classes or creating singletons where needed is acceptable. but otherwise, use functions. From 07dc2c46cef00663900f0ef84d34d2bfa9437ac3 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 18 Jun 2025 15:31:29 -0700 Subject: [PATCH 08/46] feat: patterns --- core/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/index.d.ts b/core/index.d.ts index ce78a8d82..1c7f336f2 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1576,12 +1576,12 @@ export interface RuleWithSource { slug?: string; source: RuleSource; globs?: string | string[]; + patterns?: string | string[]; rule: string; description?: string; ruleFile?: string; alwaysApply?: boolean; } - export interface CompleteOnboardingPayload { mode: OnboardingModes; provider?: string; From 3a33dc788711f739d79d0eff4f84320b27f08633 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 18 Jun 2025 15:36:22 -0700 Subject: [PATCH 09/46] Update getSystemMessageWithRules.ts --- core/llm/rules/getSystemMessageWithRules.ts | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index a0f3cf64f..00532bbed 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -52,6 +52,44 @@ const matchesGlobs = ( return false; }; +/** + * Checks if a path matches any of the provided regex patterns + */ +const matchesPatterns = ( + filePath: string, + patterns: string | string[] | undefined, +): boolean => { + if (!patterns) return true; + + // Handle single string pattern + if (typeof patterns === "string") { + try { + const regex = new RegExp(patterns); + return regex.test(filePath); + } catch (e) { + console.error(`Invalid regex pattern: ${patterns}`, e); + return false; + } + } + // Handle array of patterns + if (Array.isArray(patterns)) { + if (patterns.length === 0) return true; + + // File must match at least one pattern + return patterns.some((pattern) => { + try { + const regex = new RegExp(pattern); + return regex.test(filePath); + } catch (e) { + console.error(`Invalid regex pattern: ${pattern}`, e); + return false; + } + }); + } + + return false; +}; + /** * Determines if a file path is within a specific directory or its subdirectories * From 1703fce6507aad8fa1d283f7735c1399a48dbb14 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 18 Jun 2025 15:40:38 -0700 Subject: [PATCH 10/46] Update getSystemMessageWithRules.ts --- core/llm/rules/getSystemMessageWithRules.ts | 89 ++++++++++++++++++--- 1 file changed, 79 insertions(+), 10 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 00532bbed..1c4f0f814 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -149,6 +149,13 @@ const isGlobalRule = (rule: RuleWithSource): boolean => { return false; }; +/** + * Determines if a rule should be applied based on its alwaysApply property and file path matching + * + * @param rule - The rule to check + * @param filePaths - Array of file paths to check against the rule's globs + * @returns true if the rule should be applied, false otherwise + */ /** * Determines if a rule should be applied based on its alwaysApply property and file path matching * @@ -200,31 +207,93 @@ export const shouldApplyRule = ( return false; } - // If we have globs, check if any files in this directory match them - if (rule.globs) { + // Check both globs and patterns + const hasGlobs = rule.globs !== undefined; + const hasPatterns = rule.patterns !== undefined; + + // If we have both globs and patterns, check if any files match both + if (hasGlobs && hasPatterns) { + return filesInRuleDirectory.some( + (filePath) => + matchesGlobs(filePath, rule.globs) && + matchesPatterns(filePath, rule.patterns), + ); + } + + // If we only have globs, check those + if (hasGlobs) { return filesInRuleDirectory.some((filePath) => matchesGlobs(filePath, rule.globs), ); } - // No globs but files are in this directory, so apply the rule + // If we only have patterns, check those + if (hasPatterns) { + return filesInRuleDirectory.some((filePath) => + matchesPatterns(filePath, rule.patterns), + ); + } + + // No globs or patterns but files are in this directory, so apply the rule return true; } // For root-level rules: - // If alwaysApply is explicitly false, only apply if there are globs AND they match + // If alwaysApply is explicitly false, only apply if there are globs AND/OR patterns AND they match if (rule.alwaysApply === false) { - if (!rule.globs) { + const hasGlobs = rule.globs !== undefined; + const hasPatterns = rule.patterns !== undefined; + + if (!hasGlobs && !hasPatterns) { return false; } - return filePaths.some((path) => matchesGlobs(path, rule.globs)); + + // If we have both globs and patterns, check if any files match both + if (hasGlobs && hasPatterns) { + return filePaths.some( + (filePath) => + matchesGlobs(filePath, rule.globs) && + matchesPatterns(filePath, rule.patterns), + ); + } + + // If we only have globs, check those + if (hasGlobs) { + return filePaths.some((filePath) => matchesGlobs(filePath, rule.globs)); + } + + // If we only have patterns, check those + if (hasPatterns) { + return filePaths.some((filePath) => + matchesPatterns(filePath, rule.patterns), + ); + } } - // Default behavior for root rules with globs: - // - Only apply if they match the globs - if (rule.globs) { - return filePaths.some((path) => matchesGlobs(path, rule.globs)); + // Default behavior for root rules with globs and/or patterns: + const hasGlobs = rule.globs !== undefined; + const hasPatterns = rule.patterns !== undefined; + + // If we have both globs and patterns, check if any files match both + if (hasGlobs && hasPatterns) { + return filePaths.some( + (filePath) => + matchesGlobs(filePath, rule.globs) && + matchesPatterns(filePath, rule.patterns), + ); + } + + // If we only have globs, check those + if (hasGlobs) { + return filePaths.some((filePath) => matchesGlobs(filePath, rule.globs)); + } + + // If we only have patterns, check those + if (hasPatterns) { + return filePaths.some((filePath) => + matchesPatterns(filePath, rule.patterns), + ); } // This point should not be reached as we've handled all cases above From 3422fff6077ac75196bf5ff034a219586819a0b8 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 18 Jun 2025 17:08:02 -0700 Subject: [PATCH 11/46] Update getSystemMessageWithRules.ts --- core/llm/rules/getSystemMessageWithRules.ts | 164 +++++++++++--------- 1 file changed, 90 insertions(+), 74 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 1c4f0f814..73942d4d0 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -53,10 +53,14 @@ const matchesGlobs = ( }; /** - * Checks if a path matches any of the provided regex patterns + * Checks if file content matches any of the provided regex patterns + * + * @param fileContent - The content of the file to check + * @param patterns - A single regex pattern string or array of regex pattern strings + * @returns true if the content matches any pattern (or if no patterns are provided), false otherwise */ -const matchesPatterns = ( - filePath: string, +const contentMatchesPatterns = ( + fileContent: string, patterns: string | string[] | undefined, ): boolean => { if (!patterns) return true; @@ -65,21 +69,22 @@ const matchesPatterns = ( if (typeof patterns === "string") { try { const regex = new RegExp(patterns); - return regex.test(filePath); + return regex.test(fileContent); } catch (e) { console.error(`Invalid regex pattern: ${patterns}`, e); return false; } } + // Handle array of patterns if (Array.isArray(patterns)) { if (patterns.length === 0) return true; - // File must match at least one pattern + // Content must match at least one pattern return patterns.some((pattern) => { try { const regex = new RegExp(pattern); - return regex.test(filePath); + return regex.test(fileContent); } catch (e) { console.error(`Invalid regex pattern: ${pattern}`, e); return false; @@ -150,22 +155,18 @@ const isGlobalRule = (rule: RuleWithSource): boolean => { }; /** - * Determines if a rule should be applied based on its alwaysApply property and file path matching - * - * @param rule - The rule to check - * @param filePaths - Array of file paths to check against the rule's globs - * @returns true if the rule should be applied, false otherwise - */ -/** - * Determines if a rule should be applied based on its alwaysApply property and file path matching + * Determines if a rule should be applied based on its properties and file matching * * @param rule - The rule to check * @param filePaths - Array of file paths to check against the rule's globs + * @param fileContents - Map of file paths to their contents for pattern matching + * @param rulePolicies - Optional policies that can override normal rule behavior * @returns true if the rule should be applied, false otherwise */ export const shouldApplyRule = ( rule: RuleWithSource, filePaths: string[], + fileContents: Record = {}, rulePolicies: RulePolicies = {}, ): boolean => { const policy = rulePolicies[rule.name || ""]; @@ -207,40 +208,40 @@ export const shouldApplyRule = ( return false; } - // Check both globs and patterns + // First check if the files match the globs const hasGlobs = rule.globs !== undefined; - const hasPatterns = rule.patterns !== undefined; - // If we have both globs and patterns, check if any files match both - if (hasGlobs && hasPatterns) { - return filesInRuleDirectory.some( - (filePath) => - matchesGlobs(filePath, rule.globs) && - matchesPatterns(filePath, rule.patterns), - ); + // Filter to files that match the globs (or all files if no globs) + const matchingFiles = hasGlobs + ? filesInRuleDirectory.filter((filePath) => + matchesGlobs(filePath, rule.globs), + ) + : filesInRuleDirectory; + + // If no files match the globs, don't apply the rule + if (matchingFiles.length === 0) { + return false; } - // If we only have globs, check those - if (hasGlobs) { - return filesInRuleDirectory.some((filePath) => - matchesGlobs(filePath, rule.globs), - ); + // Now check for pattern matches in file contents if patterns are specified + if (rule.patterns) { + // Check if any of the matching files also match the content patterns + return matchingFiles.some((filePath) => { + const content = fileContents[filePath]; + // If we don't have the content, we can't check patterns + if (!content) return false; + return contentMatchesPatterns(content, rule.patterns); + }); } - // If we only have patterns, check those - if (hasPatterns) { - return filesInRuleDirectory.some((filePath) => - matchesPatterns(filePath, rule.patterns), - ); - } - - // No globs or patterns but files are in this directory, so apply the rule - return true; + // If we have no patterns or if we couldn't check patterns (no content), + // just go with the glob matches + return matchingFiles.length > 0; } // For root-level rules: - // If alwaysApply is explicitly false, only apply if there are globs AND/OR patterns AND they match + // If alwaysApply is explicitly false, we need to check globs and/or patterns if (rule.alwaysApply === false) { const hasGlobs = rule.globs !== undefined; const hasPatterns = rule.patterns !== undefined; @@ -249,55 +250,60 @@ export const shouldApplyRule = ( return false; } - // If we have both globs and patterns, check if any files match both - if (hasGlobs && hasPatterns) { - return filePaths.some( - (filePath) => - matchesGlobs(filePath, rule.globs) && - matchesPatterns(filePath, rule.patterns), - ); + // Filter to files that match the globs (or all files if no globs) + const matchingFiles = hasGlobs + ? filePaths.filter((filePath) => matchesGlobs(filePath, rule.globs)) + : filePaths; + + // If no files match the globs, don't apply the rule + if (matchingFiles.length === 0) { + return false; } - // If we only have globs, check those - if (hasGlobs) { - return filePaths.some((filePath) => matchesGlobs(filePath, rule.globs)); - } - - // If we only have patterns, check those + // Now check for pattern matches in file contents if patterns are specified if (hasPatterns) { - return filePaths.some((filePath) => - matchesPatterns(filePath, rule.patterns), - ); + // Check if any of the matching files also match the content patterns + return matchingFiles.some((filePath) => { + const content = fileContents[filePath]; + // If we don't have the content, we can't check patterns + if (!content) return false; + return contentMatchesPatterns(content, rule.patterns); + }); } + + // If we have no patterns or if we couldn't check patterns (no content), + // just go with the glob matches + return matchingFiles.length > 0; } - // Default behavior for root rules with globs and/or patterns: + // Default behavior for root rules with globs: const hasGlobs = rule.globs !== undefined; const hasPatterns = rule.patterns !== undefined; - // If we have both globs and patterns, check if any files match both - if (hasGlobs && hasPatterns) { - return filePaths.some( - (filePath) => - matchesGlobs(filePath, rule.globs) && - matchesPatterns(filePath, rule.patterns), - ); + // Filter to files that match the globs (or all files if no globs) + const matchingFiles = hasGlobs + ? filePaths.filter((filePath) => matchesGlobs(filePath, rule.globs)) + : filePaths; + + // If no files match the globs, don't apply the rule + if (matchingFiles.length === 0) { + return false; } - // If we only have globs, check those - if (hasGlobs) { - return filePaths.some((filePath) => matchesGlobs(filePath, rule.globs)); - } - - // If we only have patterns, check those + // Now check for pattern matches in file contents if patterns are specified if (hasPatterns) { - return filePaths.some((filePath) => - matchesPatterns(filePath, rule.patterns), - ); + // Check if any of the matching files also match the content patterns + return matchingFiles.some((filePath) => { + const content = fileContents[filePath]; + // If we don't have the content, we can't check patterns + if (!content) return false; + return contentMatchesPatterns(content, rule.patterns); + }); } - // This point should not be reached as we've handled all cases above - return false; + // If we have no patterns or if we couldn't check patterns (no content), + // just go with the glob matches + return matchingFiles.length > 0; }; /** @@ -327,10 +333,20 @@ export const getApplicableRules = ( // Combine file paths from both sources const allFilePaths = [...filePathsFromMessage, ...filePathsFromContextItems]; + // Create a map of file paths to their contents for pattern matching + const fileContents: Record = {}; + + // Extract contents from context items with file URIs + contextItems.forEach((item) => { + if (item.uri?.type === "file" && item.uri?.value) { + fileContents[item.uri.value] = item.content; + } + }); + // Apply shouldApplyRule to all rules - this will handle global rules, rule policies, // and path matching in a consistent way const applicableRules = rules.filter((rule) => - shouldApplyRule(rule, allFilePaths, rulePolicies), + shouldApplyRule(rule, allFilePaths, fileContents, rulePolicies), ); return applicableRules; From ff80ffeb3f2bcb8381dc73a624e41ac96cd0eeee Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 18 Jun 2025 17:33:12 -0700 Subject: [PATCH 12/46] fix: missing patterns --- core/tools/definitions/createRuleBlock.ts | 8 +++++--- core/tools/implementations/createRuleBlock.ts | 3 ++- packages/config-yaml/src/markdown/createMarkdownRule.ts | 8 ++++++++ packages/config-yaml/src/markdown/markdownToRule.ts | 2 ++ packages/config-yaml/src/schemas/index.ts | 1 + 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/core/tools/definitions/createRuleBlock.ts b/core/tools/definitions/createRuleBlock.ts index ace3bc6b2..23c0185b5 100644 --- a/core/tools/definitions/createRuleBlock.ts +++ b/core/tools/definitions/createRuleBlock.ts @@ -1,6 +1,3 @@ -import { Tool } from "../.."; -import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; - export const createRuleBlock: Tool = { type: "function", displayTitle: "Create Rule Block", @@ -37,6 +34,11 @@ export const createRuleBlock: Tool = { description: "Optional file patterns to which this rule applies (e.g. ['**/*.{ts,tsx}'] or ['src/**/*.ts', 'tests/**/*.ts'])", }, + patterns: { + type: "string", + description: + "Optional regex patterns to match against file content. Rule applies only to files whose content matches the pattern (e.g. 'useEffect' for React hooks or '\\bclass\\b' for class definitions)", + }, }, }, }, diff --git a/core/tools/implementations/createRuleBlock.ts b/core/tools/implementations/createRuleBlock.ts index a38e06056..5ecb756fa 100644 --- a/core/tools/implementations/createRuleBlock.ts +++ b/core/tools/implementations/createRuleBlock.ts @@ -7,7 +7,7 @@ export type CreateRuleBlockArgs = Pick< Required, "rule" | "description" | "alwaysApply" | "name" > & - Pick; + Pick; export const createRuleBlockImpl: ToolImpl = async ( args: CreateRuleBlockArgs, @@ -16,6 +16,7 @@ export const createRuleBlockImpl: ToolImpl = async ( const fileContent = createRuleMarkdown(args.name, args.rule, { description: args.description, globs: args.globs, + patterns: args.patterns, }); const [localContinueDir] = await extras.ide.getWorkspaceDirs(); diff --git a/packages/config-yaml/src/markdown/createMarkdownRule.ts b/packages/config-yaml/src/markdown/createMarkdownRule.ts index 14843f14d..13cce86f4 100644 --- a/packages/config-yaml/src/markdown/createMarkdownRule.ts +++ b/packages/config-yaml/src/markdown/createMarkdownRule.ts @@ -34,6 +34,7 @@ export function createRuleMarkdown( options: { description?: string; globs?: string | string[]; + patterns?: string | string[]; alwaysApply?: boolean; } = {}, ): string { @@ -44,6 +45,13 @@ export function createRuleMarkdown( typeof options.globs === "string" ? options.globs.trim() : options.globs; } + if (options.patterns) { + frontmatter.patterns = + typeof options.patterns === "string" + ? options.patterns.trim() + : options.patterns; + } + if (options.description) { frontmatter.description = options.description.trim(); } diff --git a/packages/config-yaml/src/markdown/markdownToRule.ts b/packages/config-yaml/src/markdown/markdownToRule.ts index a48f8176a..5bed93ac8 100644 --- a/packages/config-yaml/src/markdown/markdownToRule.ts +++ b/packages/config-yaml/src/markdown/markdownToRule.ts @@ -7,6 +7,7 @@ import { RuleObject } from "../schemas/index.js"; export interface RuleFrontmatter { globs?: RuleObject["globs"]; + patterns?: RuleObject["patterns"]; name?: RuleObject["name"]; description?: RuleObject["description"]; alwaysApply?: RuleObject["alwaysApply"]; @@ -56,6 +57,7 @@ export function markdownToRule( name: frontmatter.name ?? packageIdentifierToDisplayName(id), rule: markdown, globs: frontmatter.globs, + patterns: frontmatter.patterns, description: frontmatter.description, alwaysApply: frontmatter.alwaysApply, }; diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 224278cd7..14d4a7486 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -45,6 +45,7 @@ const ruleObjectSchema = z.object({ rule: z.string(), description: z.string().optional(), globs: z.union([z.string(), z.array(z.string())]).optional(), + patterns: z.union([z.string(), z.array(z.string())]).optional(), alwaysApply: z.boolean().optional(), }); const ruleSchema = z.union([z.string(), ruleObjectSchema]); From c1467f5eca45f7d3260bf1ad78473bf92a1f9fea Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 18 Jun 2025 17:34:58 -0700 Subject: [PATCH 13/46] fix: types --- core/tools/definitions/createRuleBlock.ts | 3 +++ core/tools/implementations/createRuleBlock.ts | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/core/tools/definitions/createRuleBlock.ts b/core/tools/definitions/createRuleBlock.ts index 23c0185b5..2afb19d70 100644 --- a/core/tools/definitions/createRuleBlock.ts +++ b/core/tools/definitions/createRuleBlock.ts @@ -1,3 +1,6 @@ +import { Tool } from "../.."; +import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; + export const createRuleBlock: Tool = { type: "function", displayTitle: "Create Rule Block", diff --git a/core/tools/implementations/createRuleBlock.ts b/core/tools/implementations/createRuleBlock.ts index 5ecb756fa..cfa60a5a3 100644 --- a/core/tools/implementations/createRuleBlock.ts +++ b/core/tools/implementations/createRuleBlock.ts @@ -13,11 +13,18 @@ export const createRuleBlockImpl: ToolImpl = async ( args: CreateRuleBlockArgs, extras, ) => { - const fileContent = createRuleMarkdown(args.name, args.rule, { + // Create options object with the fields that createRuleMarkdown expects + const options: any = { description: args.description, globs: args.globs, - patterns: args.patterns, - }); + }; + + // Add patterns if provided + if (args.patterns) { + options.patterns = args.patterns; + } + + const fileContent = createRuleMarkdown(args.name, args.rule, options); const [localContinueDir] = await extras.ide.getWorkspaceDirs(); const ruleFilePath = createRuleFilePath(localContinueDir, args.name); From 3786a04fc9140d20ab98bd2765917db099761698 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Wed, 18 Jun 2025 17:35:35 -0700 Subject: [PATCH 14/46] Update getSystemMessageWithRules.ts --- core/llm/rules/getSystemMessageWithRules.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 73942d4d0..3a662b1b6 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -146,11 +146,19 @@ const isGlobalRule = (rule: RuleWithSource): boolean => { return true; } - // Root-level rules with no globs are implicitly global - if (isRootLevelRule(rule) && !rule.globs && rule.alwaysApply !== false) { + console.log("RULE", rule); + // Root-level rules with no globs or patterns are implicitly global + if ( + isRootLevelRule(rule) && + !rule.globs && + !rule.patterns && + rule.alwaysApply !== false + ) { + console.log("IS ROOT"); return true; } + console.log("NOT ROOT"); return false; }; From 73818bb7082694f46b3245a33c9f2c855e724c56 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 19 Jun 2025 19:03:09 -0700 Subject: [PATCH 15/46] implement maxResults param for getFileResults ide message --- core/index.d.ts | 2 +- core/protocol/ide.ts | 2 +- core/protocol/messenger/reverseMessageIde.ts | 2 +- core/util/filesystem.ts | 5 ++++- .../continue/IdeProtocolClient.kt | 2 +- .../continue/IntelliJIde.kt | 12 +++++++++--- .../continueintellijextension/protocol/ide.kt | 2 +- .../continueintellijextension/types.kt | 2 +- extensions/vscode/src/VsCodeIde.ts | 18 ++++++++++++++---- .../vscode/src/extension/VsCodeMessenger.ts | 2 +- 10 files changed, 34 insertions(+), 15 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index ce78a8d82..4f422dfae 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -783,7 +783,7 @@ export interface IDE { getSearchResults(query: string): Promise; - getFileResults(pattern: string): Promise; + getFileResults(pattern: string, maxResults?: number): Promise; subprocess(command: string, cwd?: string): Promise<[string, string]>; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index fda1b84fe..5e24a62ff 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -30,7 +30,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { openUrl: [string, void]; runCommand: [{ command: string; options?: TerminalOptions }, void]; getSearchResults: [{ query: string }, string]; - getFileResults: [{ pattern: string }, string[]]; + getFileResults: [{ pattern: string; maxResults?: number }, string[]]; subprocess: [{ command: string; cwd?: string }, [string, string]]; saveFile: [{ filepath: string }, void]; fileExists: [{ filepath: string }, boolean]; diff --git a/core/protocol/messenger/reverseMessageIde.ts b/core/protocol/messenger/reverseMessageIde.ts index f40915664..447a66c65 100644 --- a/core/protocol/messenger/reverseMessageIde.ts +++ b/core/protocol/messenger/reverseMessageIde.ts @@ -163,7 +163,7 @@ export class ReverseMessageIde { }); this.on("getFileResults", (data) => { - return this.ide.getFileResults(data.pattern); + return this.ide.getFileResults(data.pattern, data.maxResults); }); this.on("getProblems", (data) => { diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index 0bdaffbfd..6f131df18 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -238,7 +238,10 @@ class FileSystemIde implements IDE { return ""; } - async getFileResults(pattern: string): Promise { + async getFileResults( + pattern: string, + maxResults?: number, + ): Promise { return []; } 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 cd2b3b86a..b1c91b1d7 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 @@ -365,7 +365,7 @@ class IdeProtocolClient( dataElement.toString(), GetFileResultsParams::class.java ) - val results = ide.getFileResults(params.pattern) + val results = ide.getFileResults(params.pattern, params.maxResults) respond(results) } 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 908ba2edd..0026ae518 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 @@ -315,11 +315,11 @@ class IntelliJIDE( return getOpenFiles() } - override suspend fun getFileResults(pattern: String): List { + override suspend fun getFileResults(pattern: String, maxResults: Int?): List { val ideInfo = this.getIdeInfo() if (ideInfo.remoteName == "local") { try { - val command = GeneralCommandLine( + var commandArgs = mutableListOf( ripgrep, "--files", "--iglob", @@ -327,8 +327,14 @@ class IntelliJIDE( "--ignore-file", ".continueignore", "--ignore-file", - ".gitignore", + ".gitignore" ) + if (maxResults != null) { + commandArgs.add("--max-count") + commandArgs.add(maxResults.toString()) + } + + val command = GeneralCommandLine(commandArgs) command.setWorkDirectory(project.basePath) val results = ExecUtil.execAndGetOutput(command).stdout diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt index 4c66fcc0c..170ed05a6 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/protocol/ide.kt @@ -23,7 +23,7 @@ typealias getTagsParams = String data class GetSearchResultsParams(val query: String) -data class GetFileResultsParams(val pattern: String) +data class GetFileResultsParams(val pattern: String, val maxResults: Int?) data class SaveFileParams(val filepath: String) 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 71e7092e0..c09021fff 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 @@ -159,7 +159,7 @@ interface IDE { suspend fun getSearchResults(query: String): String - suspend fun getFileResults(pattern: String): List + suspend fun getFileResults(pattern: String, maxResults: Int?): List // Note: This should be a `Pair` but we use `List` because the keys of `Pair` // will serialize to `first and `second` rather than `0` and `1` like in JavaScript diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index dcc17d179..149d09066 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -433,8 +433,10 @@ class VsCodeIde implements IDE { }); } - async getFileResults(pattern: string): Promise { - const MAX_FILE_RESULTS = 200; + async getFileResults( + pattern: string, + maxResults?: number, + ): Promise { if (vscode.env.remoteName) { // TODO better tests for this remote search implementation // throw new Error("Ripgrep not supported, this workspace is remote"); @@ -501,7 +503,7 @@ class VsCodeIde implements IDE { const results = await vscode.workspace.findFiles( pattern, ignoreGlobs.size ? `{${ignoreGlobsArray.join(",")}}` : null, - MAX_FILE_RESULTS, + maxResults, ); return results.map((result) => vscode.workspace.asRelativePath(result)); } else { @@ -515,12 +517,20 @@ class VsCodeIde implements IDE { ".continueignore", "--ignore-file", ".gitignore", + ...(maxResults ? ["--max-count", String(maxResults)] : []), ]); results.push(dirResults); } - return results.join("\n").split("\n").slice(0, MAX_FILE_RESULTS); + const allResults = results.join("\n").split("\n"); + if (maxResults) { + // In the case of multiple workspaces, maxResults will be applied to each workspace + // And then the combined results will also be truncated + return allResults.slice(0, maxResults); + } else { + return allResults; + } } } diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index b0c0a4d7b..6b34d04fc 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -324,7 +324,7 @@ export class VsCodeMessenger { return ide.getSearchResults(msg.data.query); }); this.onWebviewOrCore("getFileResults", async (msg) => { - return ide.getFileResults(msg.data.pattern); + return ide.getFileResults(msg.data.pattern, msg.data.maxResults); }); this.onWebviewOrCore("subprocess", async (msg) => { return ide.subprocess(msg.data.command, msg.data.cwd); From 2cf2a74646c65104a4f9481683b11872c49e5bc6 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 19 Jun 2025 19:07:59 -0700 Subject: [PATCH 16/46] implement glob limiting in tool --- core/tools/definitions/globSearch.ts | 3 ++- core/tools/implementations/globSearch.ts | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/core/tools/definitions/globSearch.ts b/core/tools/definitions/globSearch.ts index 5c2375124..b3cbcac5b 100644 --- a/core/tools/definitions/globSearch.ts +++ b/core/tools/definitions/globSearch.ts @@ -12,7 +12,8 @@ export const globSearchTool: Tool = { group: BUILT_IN_GROUP_NAME, function: { name: BuiltInToolNames.FileGlobSearch, - description: "Search for files in the project", + description: + "Search for files in the project. Output may be truncated; use targeted patterns", parameters: { type: "object", required: ["pattern"], diff --git a/core/tools/implementations/globSearch.ts b/core/tools/implementations/globSearch.ts index c0b214357..1e551d9e2 100644 --- a/core/tools/implementations/globSearch.ts +++ b/core/tools/implementations/globSearch.ts @@ -1,12 +1,28 @@ import { ToolImpl } from "."; +import { ContextItem } from "../.."; +const MAX_AGENT_GLOB_RESULTS = 100; export const fileGlobSearchImpl: ToolImpl = async (args, extras) => { - const results = await extras.ide.getFileResults(args.pattern); - return [ + const results = await extras.ide.getFileResults( + args.pattern, + MAX_AGENT_GLOB_RESULTS, + ); + const contextItems: ContextItem[] = [ { name: "File results", description: "Results from file glob search", content: results.join("\n"), }, ]; + + // In case of truncation, add a warning + if (results.length === MAX_AGENT_GLOB_RESULTS) { + contextItems.push({ + name: "Truncation warning", + description: "Inform the model that results were truncated", + content: `Warning: the results above were truncated to the first ${MAX_AGENT_GLOB_RESULTS} files. If the results are not satisfactory, refine your search pattern`, + }); + } + + return contextItems; }; From 2b5b09ebb2b16a76cf86812c84e94da314e0bb8b Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 19 Jun 2025 19:14:03 -0700 Subject: [PATCH 17/46] update the docs --- docs/docs/agent/how-it-works.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/agent/how-it-works.md b/docs/docs/agent/how-it-works.md index 1191fa9f8..5847b99a5 100644 --- a/docs/docs/agent/how-it-works.md +++ b/docs/docs/agent/how-it-works.md @@ -32,6 +32,7 @@ Continue includes several built-in tools which provide the model access to IDE f - **Read currently open file** (`builtin_read_currently_open_file`): read the contents of the currently open file - **Create new file** (`builtin_create_new_file`): Create a new file within the project, with path and contents specified by the model - **Exact search** (`builtin_exact_search`): perform a `ripgrep` search within the project +- **Glob search** (`builtin_file_glob_search`): perform a glob search on files in the project. Currently limits to 100 output and warns the Agent if limit reached. - **Run terminal command** (`builtin_run_terminal_command`): run a terminal command from the workspace root - **Search web** (`builtin_search_web`): Perform a web search to get top results - **View diff** (`builtin_view_diff`): View the current working git diff From a4c5a489e288025a4452a6d6e8f0991ec8ed0eba Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 19 Jun 2025 19:35:19 -0700 Subject: [PATCH 18/46] update unit testing rules --- .continue/rules/unit-testing-rules.yaml | 30 ++++++++++++------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/.continue/rules/unit-testing-rules.yaml b/.continue/rules/unit-testing-rules.yaml index ec22e9467..f846986c2 100644 --- a/.continue/rules/unit-testing-rules.yaml +++ b/.continue/rules/unit-testing-rules.yaml @@ -6,25 +6,23 @@ rules: rule: >- For unit testing in this project: + 1. The project uses Vitest and Jest for testing. Prefer Vitest - 1. The project uses Jest as the testing framework + 2. Run tests from within the specific package directory (e.g., `cd core && ..` - 2. Run tests using `npm test` from within the specific package/module - directory + 3. For vitest tests, + - Test files follow the pattern `*.vitest.ts` + - Run tests using `vitest` from within the specific package/module + directory: `cd [directory] && vitest -- [test file path]` - 3. Command structure: `cd [directory] && npm test -- [test file path]` + 4. For jest tests, + - Test files follow the pattern `*.test.ts` + - Run tests using `npm test` from within the specific package/module + directory: `cd [directory] && npm test -- [test file path]` + - The test script uses experimental VM modules via NODE_OPTIONS flag - 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()` + 5. For both + - Write tests as top-level `test()` functions - DO NOT use `describe()` blocks - - 9. Include the function name being tested in the test description for + - Include the function name being tested in the test description for clarity From 2c0181bd3e20992bb7f93308e7f761ba2d861f6a Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 20 Jun 2025 09:01:21 -0700 Subject: [PATCH 19/46] improv: clean up code --- core/llm/rules/getSystemMessageWithRules.ts | 158 ++++++++------------ 1 file changed, 60 insertions(+), 98 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 3a662b1b6..2a2ca584a 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -162,6 +162,45 @@ const isGlobalRule = (rule: RuleWithSource): boolean => { return false; }; +const checkGlobsAndPatterns = ({ + hasGlobs, + hasPatterns, + rule, + filePaths, + fileContents, +}: { + hasGlobs: boolean; + hasPatterns: boolean; + rule: RuleWithSource; + filePaths: string[]; + fileContents: Record; +}) => { + const matchingFiles = hasGlobs + ? filePaths.filter((filePath) => matchesGlobs(filePath, rule.globs)) + : filePaths; + + // If no files match the globs, don't apply the rule + if (matchingFiles.length === 0) { + return false; + } + + // Now check for pattern matches in file contents if patterns are specified + if (hasPatterns) { + console.log("HAS PATTERNS", rule.patterns); + // Check if any of the matching files also match the content patterns + return matchingFiles.some((filePath) => { + const content = fileContents[filePath]; + // If we don't have the content, we can't check patterns + if (!content) return false; + return contentMatchesPatterns(content, rule.patterns); + }); + } + + // If we have no patterns or if we couldn't check patterns (no content), + // just go with the glob matches + return matchingFiles.length > 0; +}; + /** * Determines if a rule should be applied based on its properties and file matching * @@ -177,6 +216,7 @@ export const shouldApplyRule = ( fileContents: Record = {}, rulePolicies: RulePolicies = {}, ): boolean => { + console.log("CHECKING SHOULD APPLY RULE", rule); const policy = rulePolicies[rule.name || ""]; // Never apply if policy is "off" @@ -198,6 +238,8 @@ export const shouldApplyRule = ( // Check if this is a root-level rule (in .continue directory or no file path) const isRootRule = isRootLevelRule(rule); + const hasGlobs = rule.globs !== undefined; + const hasPatterns = rule.patterns !== undefined; // For non-root rules, we need to check if any files are in the rule's directory if (!isRootRule && rule.ruleFile) { @@ -211,107 +253,27 @@ export const shouldApplyRule = ( isFileInDirectory(filePath, ruleDirPath), ); - // If no files are in this directory, don't apply the rule - if (filesInRuleDirectory.length === 0) { - return false; - } - - // First check if the files match the globs - const hasGlobs = rule.globs !== undefined; - - // Filter to files that match the globs (or all files if no globs) - const matchingFiles = hasGlobs - ? filesInRuleDirectory.filter((filePath) => - matchesGlobs(filePath, rule.globs), - ) - : filesInRuleDirectory; - - // If no files match the globs, don't apply the rule - if (matchingFiles.length === 0) { - return false; - } - - // Now check for pattern matches in file contents if patterns are specified - if (rule.patterns) { - // Check if any of the matching files also match the content patterns - return matchingFiles.some((filePath) => { - const content = fileContents[filePath]; - // If we don't have the content, we can't check patterns - if (!content) return false; - return contentMatchesPatterns(content, rule.patterns); - }); - } - - // If we have no patterns or if we couldn't check patterns (no content), - // just go with the glob matches - return matchingFiles.length > 0; - } - - // For root-level rules: - - // If alwaysApply is explicitly false, we need to check globs and/or patterns - if (rule.alwaysApply === false) { - const hasGlobs = rule.globs !== undefined; - const hasPatterns = rule.patterns !== undefined; - - if (!hasGlobs && !hasPatterns) { - return false; - } - - // Filter to files that match the globs (or all files if no globs) - const matchingFiles = hasGlobs - ? filePaths.filter((filePath) => matchesGlobs(filePath, rule.globs)) - : filePaths; - - // If no files match the globs, don't apply the rule - if (matchingFiles.length === 0) { - return false; - } - - // Now check for pattern matches in file contents if patterns are specified - if (hasPatterns) { - // Check if any of the matching files also match the content patterns - return matchingFiles.some((filePath) => { - const content = fileContents[filePath]; - // If we don't have the content, we can't check patterns - if (!content) return false; - return contentMatchesPatterns(content, rule.patterns); - }); - } - - // If we have no patterns or if we couldn't check patterns (no content), - // just go with the glob matches - return matchingFiles.length > 0; - } - - // Default behavior for root rules with globs: - const hasGlobs = rule.globs !== undefined; - const hasPatterns = rule.patterns !== undefined; - - // Filter to files that match the globs (or all files if no globs) - const matchingFiles = hasGlobs - ? filePaths.filter((filePath) => matchesGlobs(filePath, rule.globs)) - : filePaths; - - // If no files match the globs, don't apply the rule - if (matchingFiles.length === 0) { - return false; - } - - // Now check for pattern matches in file contents if patterns are specified - if (hasPatterns) { - // Check if any of the matching files also match the content patterns - return matchingFiles.some((filePath) => { - const content = fileContents[filePath]; - // If we don't have the content, we can't check patterns - if (!content) return false; - return contentMatchesPatterns(content, rule.patterns); + return checkGlobsAndPatterns({ + filePaths: filesInRuleDirectory, + fileContents, + rule, + hasGlobs, + hasPatterns, }); } - // If we have no patterns or if we couldn't check patterns (no content), - // just go with the glob matches - return matchingFiles.length > 0; + // If alwaysApply is explicitly false, we need to check globs and/or patterns + if (rule.alwaysApply === false && !hasGlobs && !hasPatterns) { + return false; + } + + return checkGlobsAndPatterns({ + filePaths, + fileContents, + rule, + hasGlobs, + hasPatterns, + }); }; /** From 559b5aa9fbb7c4fb60e7b67d34822ece16e5474d Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 20 Jun 2025 09:07:07 -0700 Subject: [PATCH 20/46] improv: clean up --- core/llm/rules/getSystemMessageWithRules.ts | 22 +++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 2a2ca584a..54a7311d2 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -63,6 +63,7 @@ const contentMatchesPatterns = ( fileContent: string, patterns: string | string[] | undefined, ): boolean => { + console.log(""); if (!patterns) return true; // Handle single string pattern @@ -163,19 +164,16 @@ const isGlobalRule = (rule: RuleWithSource): boolean => { }; const checkGlobsAndPatterns = ({ - hasGlobs, - hasPatterns, rule, filePaths, fileContents, }: { - hasGlobs: boolean; - hasPatterns: boolean; rule: RuleWithSource; filePaths: string[]; fileContents: Record; }) => { - const matchingFiles = hasGlobs + console.log("HERE ZZZZ"); + const matchingFiles = rule.globs ? filePaths.filter((filePath) => matchesGlobs(filePath, rule.globs)) : filePaths; @@ -185,7 +183,7 @@ const checkGlobsAndPatterns = ({ } // Now check for pattern matches in file contents if patterns are specified - if (hasPatterns) { + if (rule.patterns) { console.log("HAS PATTERNS", rule.patterns); // Check if any of the matching files also match the content patterns return matchingFiles.some((filePath) => { @@ -238,8 +236,6 @@ export const shouldApplyRule = ( // Check if this is a root-level rule (in .continue directory or no file path) const isRootRule = isRootLevelRule(rule); - const hasGlobs = rule.globs !== undefined; - const hasPatterns = rule.patterns !== undefined; // For non-root rules, we need to check if any files are in the rule's directory if (!isRootRule && rule.ruleFile) { @@ -257,13 +253,15 @@ export const shouldApplyRule = ( filePaths: filesInRuleDirectory, fileContents, rule, - hasGlobs, - hasPatterns, }); } // If alwaysApply is explicitly false, we need to check globs and/or patterns - if (rule.alwaysApply === false && !hasGlobs && !hasPatterns) { + if ( + rule.alwaysApply === false && + rule.globs === undefined && + rule.patterns === undefined + ) { return false; } @@ -271,8 +269,6 @@ export const shouldApplyRule = ( filePaths, fileContents, rule, - hasGlobs, - hasPatterns, }); }; From b270e25059d942efce3e910fc670b4f4ff28dfa8 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 20 Jun 2025 09:22:14 -0700 Subject: [PATCH 21/46] Update getSystemMessageWithRules.ts --- core/llm/rules/getSystemMessageWithRules.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 54a7311d2..ccc70c092 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -61,15 +61,15 @@ const matchesGlobs = ( */ const contentMatchesPatterns = ( fileContent: string, - patterns: string | string[] | undefined, + patterns: string | string[], ): boolean => { - console.log(""); - if (!patterns) return true; + console.log("HERE XXXXX"); // Handle single string pattern if (typeof patterns === "string") { try { const regex = new RegExp(patterns); + console.log("REGEX", regex); return regex.test(fileContent); } catch (e) { console.error(`Invalid regex pattern: ${patterns}`, e); @@ -188,9 +188,10 @@ const checkGlobsAndPatterns = ({ // Check if any of the matching files also match the content patterns return matchingFiles.some((filePath) => { const content = fileContents[filePath]; + console.log("TESTING FILE MATCH", content); // If we don't have the content, we can't check patterns if (!content) return false; - return contentMatchesPatterns(content, rule.patterns); + return contentMatchesPatterns(content, rule.patterns!); }); } @@ -304,10 +305,12 @@ export const getApplicableRules = ( // Extract contents from context items with file URIs contextItems.forEach((item) => { + console.log("ITEM", item); if (item.uri?.type === "file" && item.uri?.value) { fileContents[item.uri.value] = item.content; } }); + console.log("FILE CONTENTS", fileContents); // Apply shouldApplyRule to all rules - this will handle global rules, rule policies, // and path matching in a consistent way From 4cf154d9c9b90103fe5afaf69c28e8cfaaf8d028 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 20 Jun 2025 09:27:33 -0700 Subject: [PATCH 22/46] fix: pattern matching --- core/llm/rules/getSystemMessageWithRules.ts | 17 ++++++++++- .../llm/utils/extractContentFromCodeBlocks.ts | 29 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 core/llm/utils/extractContentFromCodeBlocks.ts diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index ccc70c092..bdfe0aa0a 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -7,6 +7,7 @@ import { } from "../.."; import { renderChatMessage } from "../../util/messageContent"; import { getCleanUriPath } from "../../util/uri"; +import { extractContentFromCodeBlock } from "../utils/extractContentFromCodeBlocks"; import { extractPathsFromCodeBlocks } from "../utils/extractPathsFromCodeBlocks"; import { RulePolicies } from "./types"; @@ -305,11 +306,25 @@ export const getApplicableRules = ( // Extract contents from context items with file URIs contextItems.forEach((item) => { - console.log("ITEM", item); if (item.uri?.type === "file" && item.uri?.value) { fileContents[item.uri.value] = item.content; } }); + + // Extract contents from code blocks in the message for paths that don't have content yet + if (userMessage) { + const messageContent = renderChatMessage(userMessage); + filePathsFromMessage.forEach((path) => { + // Only extract content if we don't already have it from context items + if (!fileContents[path]) { + const blockContent = extractContentFromCodeBlock(messageContent, path); + if (blockContent) { + fileContents[path] = blockContent; + } + } + }); + } + console.log("FILE CONTENTS", fileContents); // Apply shouldApplyRule to all rules - this will handle global rules, rule policies, diff --git a/core/llm/utils/extractContentFromCodeBlocks.ts b/core/llm/utils/extractContentFromCodeBlocks.ts new file mode 100644 index 000000000..00abc49cf --- /dev/null +++ b/core/llm/utils/extractContentFromCodeBlocks.ts @@ -0,0 +1,29 @@ +/** + * Extracts content from code blocks with given path + * @param content The full message content + * @param path The file path to look for + * @returns The content of the code block if found, undefined otherwise + */ +export function extractContentFromCodeBlock( + content: string, + path: string +): string | undefined { + // Escape special characters in the path for regex + const escapedPath = path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + + // Match the code block with this path + // This regex looks for: + // 1. Code block start with the path (```[language] path) + // 2. The content until the closing ``` + const regex = new RegExp( + `\`\`\`[^\\n]*${escapedPath}[^\\n]*\\n([\\s\\S]*?)\\n\`\`\``, + "m" + ); + + const match = content.match(regex); + if (match && match[1]) { + return match[1]; + } + + return undefined; +} \ No newline at end of file From 0f174fca79a876233f0f78fb180fee74a584cb40 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 20 Jun 2025 09:30:00 -0700 Subject: [PATCH 23/46] improv: tests --- .../extractContentFromCodeBlocks.test.ts | 71 +++++++++++++++++++ .../llm/utils/extractContentFromCodeBlocks.ts | 18 +++-- 2 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 core/llm/utils/extractContentFromCodeBlocks.test.ts diff --git a/core/llm/utils/extractContentFromCodeBlocks.test.ts b/core/llm/utils/extractContentFromCodeBlocks.test.ts new file mode 100644 index 000000000..b6a612ed3 --- /dev/null +++ b/core/llm/utils/extractContentFromCodeBlocks.test.ts @@ -0,0 +1,71 @@ +import { extractContentFromCodeBlock } from "./extractContentFromCodeBlocks"; + +describe("extractContentFromCodeBlock", () => { + it("should extract content from code block with language and filepath", () => { + const content = "```typescript src/main.ts\nconst x = 1;\n```"; + expect(extractContentFromCodeBlock(content, "src/main.ts")).toBe("const x = 1;"); + }); + + it("should extract content from code block with filepath only (no language)", () => { + const content = "```test.js\nclass Calculator { }\n```"; + expect(extractContentFromCodeBlock(content, "test.js")).toBe("class Calculator { }"); + }); + + it("should extract content from code block with line ranges", () => { + const content = "```js test.js (19-25)\nfunction test() {}\n```"; + expect(extractContentFromCodeBlock(content, "test.js")).toBe("function test() {}"); + }); + + it("should handle multiple code blocks and find the right one", () => { + const content = + "```typescript src/main.ts\nconst x = 1;\n```\n" + + "```test.js\nclass Calculator { }\n```\n" + + "```js utils.js (19-25)\nfunction test() {}\n```"; + + expect(extractContentFromCodeBlock(content, "src/main.ts")).toBe("const x = 1;"); + expect(extractContentFromCodeBlock(content, "test.js")).toBe("class Calculator { }"); + expect(extractContentFromCodeBlock(content, "utils.js")).toBe("function test() {}"); + }); + + it("should handle paths with special regex characters", () => { + const content = "```typescript src/special+chars.ts[123]\nconst special = true;\n```"; + expect(extractContentFromCodeBlock(content, "src/special+chars.ts[123]")).toBe("const special = true;"); + }); + + it("should handle multiline content", () => { + const content = + "```typescript src/multi-line.ts\n" + + "function example() {\n" + + " const x = 1;\n" + + " return x + 2;\n" + + "}\n" + + "```"; + + const expected = + "function example() {\n" + + " const x = 1;\n" + + " return x + 2;\n" + + "}"; + + expect(extractContentFromCodeBlock(content, "src/multi-line.ts")).toBe(expected); + }); + + it("should return undefined when path doesn't exist in any code block", () => { + const content = "```typescript src/main.ts\nconst x = 1;\n```"; + expect(extractContentFromCodeBlock(content, "nonexistent.ts")).toBeUndefined(); + }); + + it("should extract content when the path has directory structure", () => { + const content = "```js src/components/Button.jsx\nconst Button = () => ;\n```"; + expect(extractContentFromCodeBlock(content, "src/components/Button.jsx")).toBe("const Button = () => ;"); + }); + + it("should match exact paths only", () => { + const content = + "```typescript src/utils.ts\nconst util = {};\n```\n" + + "```typescript src/utils/index.ts\nconst index = {};\n```"; + + expect(extractContentFromCodeBlock(content, "src/utils.ts")).toBe("const util = {};"); + expect(extractContentFromCodeBlock(content, "src/utils/index.ts")).toBe("const index = {};"); + }); +}); \ No newline at end of file diff --git a/core/llm/utils/extractContentFromCodeBlocks.ts b/core/llm/utils/extractContentFromCodeBlocks.ts index 00abc49cf..c67ab2f7d 100644 --- a/core/llm/utils/extractContentFromCodeBlocks.ts +++ b/core/llm/utils/extractContentFromCodeBlocks.ts @@ -6,24 +6,28 @@ */ export function extractContentFromCodeBlock( content: string, - path: string + path: string, ): string | undefined { // Escape special characters in the path for regex const escapedPath = path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - + // Match the code block with this path // This regex looks for: // 1. Code block start with the path (```[language] path) // 2. The content until the closing ``` + // The path can be: + // - With language: ```typescript src/main.ts + // - Without language: ```src/main.ts + // - With line ranges: ```js src/main.ts (1-10) const regex = new RegExp( - `\`\`\`[^\\n]*${escapedPath}[^\\n]*\\n([\\s\\S]*?)\\n\`\`\``, - "m" + `\`\`\`[^\\n]*\\b${escapedPath}(?:\\s+\\([\\d-]+\\))?[^\\n]*\\n([\\s\\S]*?)\\n\`\`\``, + "m", ); - + const match = content.match(regex); if (match && match[1]) { return match[1]; } - + return undefined; -} \ No newline at end of file +} From 897f7130e0d4f17c75013f6eebdbe97b3a07b592 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 20 Jun 2025 09:32:10 -0700 Subject: [PATCH 24/46] improv: clean up --- core/llm/rules/getSystemMessageWithRules.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index bdfe0aa0a..c0ea95fef 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -64,13 +64,10 @@ const contentMatchesPatterns = ( fileContent: string, patterns: string | string[], ): boolean => { - console.log("HERE XXXXX"); - // Handle single string pattern if (typeof patterns === "string") { try { const regex = new RegExp(patterns); - console.log("REGEX", regex); return regex.test(fileContent); } catch (e) { console.error(`Invalid regex pattern: ${patterns}`, e); @@ -148,7 +145,6 @@ const isGlobalRule = (rule: RuleWithSource): boolean => { return true; } - console.log("RULE", rule); // Root-level rules with no globs or patterns are implicitly global if ( isRootLevelRule(rule) && @@ -156,11 +152,9 @@ const isGlobalRule = (rule: RuleWithSource): boolean => { !rule.patterns && rule.alwaysApply !== false ) { - console.log("IS ROOT"); return true; } - console.log("NOT ROOT"); return false; }; @@ -173,7 +167,6 @@ const checkGlobsAndPatterns = ({ filePaths: string[]; fileContents: Record; }) => { - console.log("HERE ZZZZ"); const matchingFiles = rule.globs ? filePaths.filter((filePath) => matchesGlobs(filePath, rule.globs)) : filePaths; @@ -185,11 +178,9 @@ const checkGlobsAndPatterns = ({ // Now check for pattern matches in file contents if patterns are specified if (rule.patterns) { - console.log("HAS PATTERNS", rule.patterns); // Check if any of the matching files also match the content patterns return matchingFiles.some((filePath) => { const content = fileContents[filePath]; - console.log("TESTING FILE MATCH", content); // If we don't have the content, we can't check patterns if (!content) return false; return contentMatchesPatterns(content, rule.patterns!); @@ -216,7 +207,6 @@ export const shouldApplyRule = ( fileContents: Record = {}, rulePolicies: RulePolicies = {}, ): boolean => { - console.log("CHECKING SHOULD APPLY RULE", rule); const policy = rulePolicies[rule.name || ""]; // Never apply if policy is "off" @@ -325,8 +315,6 @@ export const getApplicableRules = ( }); } - console.log("FILE CONTENTS", fileContents); - // Apply shouldApplyRule to all rules - this will handle global rules, rule policies, // and path matching in a consistent way const applicableRules = rules.filter((rule) => From 1bc7b78a1c093a579b8a737dd77e07a2401714d8 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 20 Jun 2025 09:39:04 -0700 Subject: [PATCH 25/46] fix: args --- core/llm/rules/getSystemMessageWithRules.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index c0ea95fef..62756923e 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -204,8 +204,8 @@ const checkGlobsAndPatterns = ({ export const shouldApplyRule = ( rule: RuleWithSource, filePaths: string[], - fileContents: Record = {}, rulePolicies: RulePolicies = {}, + fileContents: Record = {}, ): boolean => { const policy = rulePolicies[rule.name || ""]; @@ -318,7 +318,7 @@ export const getApplicableRules = ( // Apply shouldApplyRule to all rules - this will handle global rules, rule policies, // and path matching in a consistent way const applicableRules = rules.filter((rule) => - shouldApplyRule(rule, allFilePaths, fileContents, rulePolicies), + shouldApplyRule(rule, allFilePaths, rulePolicies, fileContents), ); return applicableRules; From a251c1b6f641d22aeaaaacd1a827e8a129c268fc Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 20 Jun 2025 11:22:32 -0700 Subject: [PATCH 26/46] test: pattern matching --- .../rules/getSystemMessageWithRules.vitest.ts | 237 +++++++++++++++++- 1 file changed, 235 insertions(+), 2 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.vitest.ts b/core/llm/rules/getSystemMessageWithRules.vitest.ts index f652d3a77..8425c8324 100644 --- a/core/llm/rules/getSystemMessageWithRules.vitest.ts +++ b/core/llm/rules/getSystemMessageWithRules.vitest.ts @@ -1,6 +1,14 @@ import { describe, expect, it } from "vitest"; -import { RuleWithSource } from "../.."; -import { shouldApplyRule } from "./getSystemMessageWithRules"; +import { + ContextItemId, + ContextItemWithId, + RuleWithSource, + UserChatMessage, +} from "../.."; +import { + getApplicableRules, + shouldApplyRule, +} from "./getSystemMessageWithRules"; import { RulePolicies } from "./types"; describe("Rule colocation glob matching", () => { @@ -244,3 +252,228 @@ describe("Rule policies", () => { ).toBe(false); }); }); + +describe("Content pattern matching", () => { + it("should apply rules when file content matches pattern", () => { + // Rule with pattern to match React component files + const reactComponentRule: RuleWithSource = { + name: "React Component Rule", + rule: "Follow React component standards", + patterns: "export (function|const) \\w+.*\\(", + source: "rules-block", + ruleFile: "src/components/rules.md", + }; + + // File that matches the pattern + const filePath = "src/components/Button.tsx"; + const fileContents = { + [filePath]: + "export function Button() { return }", + }; + + expect( + shouldApplyRule(reactComponentRule, [filePath], {}, fileContents), + ).toBe(true); + + // File that doesn't match the pattern + const nonMatchingContents = { + [filePath]: + "import React from 'react'; // Just an import, not a component", + }; + + expect( + shouldApplyRule(reactComponentRule, [filePath], {}, nonMatchingContents), + ).toBe(false); + }); + + it("should support multiple regex patterns as an array", () => { + // Rule with multiple patterns + const multiPatternRule: RuleWithSource = { + name: "Multi-Pattern Rule", + rule: "Apply to functions or classes", + patterns: ["function\\s+\\w+", "class\\s+\\w+"], + source: "rules-block", + ruleFile: "src/utils/rules.md", + }; + + const filePath = "src/utils/helper.ts"; + + // Content with function - should match + const functionContent = { + [filePath]: "function formatDate(date) { return date.toISOString(); }", + }; + expect( + shouldApplyRule(multiPatternRule, [filePath], {}, functionContent), + ).toBe(true); + + // Content with class - should match + const classContent = { + [filePath]: + "class DateFormatter { format(date) { return date.toISOString(); } }", + }; + expect( + shouldApplyRule(multiPatternRule, [filePath], {}, classContent), + ).toBe(true); + + // Content with neither - should not match + const nonMatchingContent = { + [filePath]: "const PI = 3.14159;", + }; + expect( + shouldApplyRule(multiPatternRule, [filePath], {}, nonMatchingContent), + ).toBe(false); + }); + + it("should apply rules based on both globs and patterns when both are specified", () => { + // Rule with both glob and pattern restrictions + const typescriptClassRule: RuleWithSource = { + name: "TypeScript Class Rule", + rule: "Follow class standards in TypeScript", + globs: "**/*.ts", + patterns: "class\\s+\\w+", + source: "rules-block", + ruleFile: "src/models/rules.md", + }; + + const tsFilePath = "src/models/User.ts"; + const jsFilePath = "src/models/Product.js"; + + // TypeScript file with class - should match + const tsClassContent = { + [tsFilePath]: "export class User { constructor(public name: string) {} }", + }; + expect( + shouldApplyRule(typescriptClassRule, [tsFilePath], {}, tsClassContent), + ).toBe(true); + + // TypeScript file without class - should not match + const tsNonClassContent = { + [tsFilePath]: "export const createUser = (name: string) => ({ name });", + }; + expect( + shouldApplyRule(typescriptClassRule, [tsFilePath], {}, tsNonClassContent), + ).toBe(false); + + // JavaScript file with class - should not match due to glob + const jsClassContent = { + [jsFilePath]: + "export class Product { constructor(name) { this.name = name; } }", + }; + expect( + shouldApplyRule(typescriptClassRule, [jsFilePath], {}, jsClassContent), + ).toBe(false); + }); + + it("should extract file content from messages for pattern matching", () => { + // Rule with pattern + const arrowFunctionRule: RuleWithSource = { + name: "Arrow Function Rule", + rule: "Use arrow functions for better this binding", + patterns: "const\\s+\\w+\\s*=\\s*\\(", + source: "rules-block", + ruleFile: "src/utils/rules.md", + }; + + // Message with code block containing a matching pattern + const messageWithArrowFn: UserChatMessage = { + role: "user", + content: + "Can you check this code?\n```typescript src/utils/formatter.ts\nconst format = (date) => {\n return date.toISOString();\n};\n```", + }; + + // Create context item to match the file in the message + const contextItem: ContextItemWithId = { + id: { providerTitle: "file", itemId: "formatter" } as ContextItemId, + uri: { type: "file", value: "src/utils/formatter.ts" }, + content: "const format = (date) => {\n return date.toISOString();\n};", + name: "formatter.ts", + description: "Utility formatter", + }; + + // Should match the pattern + const applicableRules = getApplicableRules( + messageWithArrowFn, + [arrowFunctionRule], + [contextItem], + ); + + expect(applicableRules).toHaveLength(1); + expect(applicableRules[0].name).toBe("Arrow Function Rule"); + + // Message with code block that doesn't match the pattern + const messageWithoutArrowFn: UserChatMessage = { + role: "user", + content: + "Can you check this code?\n```typescript src/utils/formatter.ts\nfunction format(date) {\n return date.toISOString();\n}\n```", + }; + + // Context item with non-matching content + const nonMatchingContextItem: ContextItemWithId = { + id: { providerTitle: "file", itemId: "formatter2" } as ContextItemId, + uri: { type: "file", value: "src/utils/formatter.ts" }, + content: "function format(date) {\n return date.toISOString();\n}", + name: "formatter.ts", + description: "Utility formatter", + }; + + // Should not match the pattern + const nonApplicableRules = getApplicableRules( + messageWithoutArrowFn, + [arrowFunctionRule], + [nonMatchingContextItem], + ); + + expect(nonApplicableRules).toHaveLength(0); + }); + + it("should handle invalid regex patterns gracefully", () => { + // Rule with invalid regex pattern + const invalidRegexRule: RuleWithSource = { + name: "Invalid Regex Rule", + rule: "This rule has an invalid regex pattern", + patterns: "([unclosed parenthesis", + source: "rules-block", + ruleFile: "src/utils/rules.md", + }; + + const filePath = "src/utils/helper.ts"; + const fileContents = { + [filePath]: "function helper() { return true; }", + }; + + // Should not throw an error but gracefully not apply the rule + expect( + shouldApplyRule(invalidRegexRule, [filePath], {}, fileContents), + ).toBe(false); + }); + + it("should respect directory restrictions for pattern rules", () => { + // Rule with pattern in a nested directory + const nestedPatternRule: RuleWithSource = { + name: "Nested Pattern Rule", + rule: "Apply only to model files with interfaces", + patterns: "interface\\s+\\w+", + source: "rules-block", + ruleFile: "src/models/rules.md", + }; + + // File in the correct directory with matching content + const modelFilePath = "src/models/User.ts"; + const modelContents = { + [modelFilePath]: "export interface User { id: string; name: string; }", + }; + expect( + shouldApplyRule(nestedPatternRule, [modelFilePath], {}, modelContents), + ).toBe(true); + + // File outside the directory with matching content - should not match + const utilFilePath = "src/utils/types.ts"; + const utilContents = { + [utilFilePath]: + "export interface Config { apiUrl: string; timeout: number; }", + }; + expect( + shouldApplyRule(nestedPatternRule, [utilFilePath], {}, utilContents), + ).toBe(false); + }); +}); From 77989095ba5334b6a9aff4e44a1a08f94220505f Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 20 Jun 2025 11:24:06 -0700 Subject: [PATCH 27/46] fix: formatting --- .../extractContentFromCodeBlocks.test.ts | 75 ++++++++++++------- .../e2e/actions/Autocomplete.actions.ts | 4 +- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/core/llm/utils/extractContentFromCodeBlocks.test.ts b/core/llm/utils/extractContentFromCodeBlocks.test.ts index b6a612ed3..47a814934 100644 --- a/core/llm/utils/extractContentFromCodeBlocks.test.ts +++ b/core/llm/utils/extractContentFromCodeBlocks.test.ts @@ -3,17 +3,23 @@ import { extractContentFromCodeBlock } from "./extractContentFromCodeBlocks"; describe("extractContentFromCodeBlock", () => { it("should extract content from code block with language and filepath", () => { const content = "```typescript src/main.ts\nconst x = 1;\n```"; - expect(extractContentFromCodeBlock(content, "src/main.ts")).toBe("const x = 1;"); + expect(extractContentFromCodeBlock(content, "src/main.ts")).toBe( + "const x = 1;", + ); }); it("should extract content from code block with filepath only (no language)", () => { const content = "```test.js\nclass Calculator { }\n```"; - expect(extractContentFromCodeBlock(content, "test.js")).toBe("class Calculator { }"); + expect(extractContentFromCodeBlock(content, "test.js")).toBe( + "class Calculator { }", + ); }); it("should extract content from code block with line ranges", () => { const content = "```js test.js (19-25)\nfunction test() {}\n```"; - expect(extractContentFromCodeBlock(content, "test.js")).toBe("function test() {}"); + expect(extractContentFromCodeBlock(content, "test.js")).toBe( + "function test() {}", + ); }); it("should handle multiple code blocks and find the right one", () => { @@ -21,51 +27,68 @@ describe("extractContentFromCodeBlock", () => { "```typescript src/main.ts\nconst x = 1;\n```\n" + "```test.js\nclass Calculator { }\n```\n" + "```js utils.js (19-25)\nfunction test() {}\n```"; - - expect(extractContentFromCodeBlock(content, "src/main.ts")).toBe("const x = 1;"); - expect(extractContentFromCodeBlock(content, "test.js")).toBe("class Calculator { }"); - expect(extractContentFromCodeBlock(content, "utils.js")).toBe("function test() {}"); + + expect(extractContentFromCodeBlock(content, "src/main.ts")).toBe( + "const x = 1;", + ); + expect(extractContentFromCodeBlock(content, "test.js")).toBe( + "class Calculator { }", + ); + expect(extractContentFromCodeBlock(content, "utils.js")).toBe( + "function test() {}", + ); }); it("should handle paths with special regex characters", () => { - const content = "```typescript src/special+chars.ts[123]\nconst special = true;\n```"; - expect(extractContentFromCodeBlock(content, "src/special+chars.ts[123]")).toBe("const special = true;"); + const content = + "```typescript src/special+chars.ts[123]\nconst special = true;\n```"; + expect( + extractContentFromCodeBlock(content, "src/special+chars.ts[123]"), + ).toBe("const special = true;"); }); it("should handle multiline content", () => { - const content = + const content = "```typescript src/multi-line.ts\n" + "function example() {\n" + " const x = 1;\n" + " return x + 2;\n" + "}\n" + "```"; - - const expected = - "function example() {\n" + - " const x = 1;\n" + - " return x + 2;\n" + - "}"; - - expect(extractContentFromCodeBlock(content, "src/multi-line.ts")).toBe(expected); + + const expected = + "function example() {\n" + " const x = 1;\n" + " return x + 2;\n" + "}"; + + expect(extractContentFromCodeBlock(content, "src/multi-line.ts")).toBe( + expected, + ); }); it("should return undefined when path doesn't exist in any code block", () => { const content = "```typescript src/main.ts\nconst x = 1;\n```"; - expect(extractContentFromCodeBlock(content, "nonexistent.ts")).toBeUndefined(); + expect( + extractContentFromCodeBlock(content, "nonexistent.ts"), + ).toBeUndefined(); }); it("should extract content when the path has directory structure", () => { - const content = "```js src/components/Button.jsx\nconst Button = () => ;\n```"; - expect(extractContentFromCodeBlock(content, "src/components/Button.jsx")).toBe("const Button = () => ;"); + const content = + "```js src/components/Button.jsx\nconst Button = () => ;\n```"; + expect( + extractContentFromCodeBlock(content, "src/components/Button.jsx"), + ).toBe("const Button = () => ;"); }); it("should match exact paths only", () => { - const content = + const content = "```typescript src/utils.ts\nconst util = {};\n```\n" + "```typescript src/utils/index.ts\nconst index = {};\n```"; - - expect(extractContentFromCodeBlock(content, "src/utils.ts")).toBe("const util = {};"); - expect(extractContentFromCodeBlock(content, "src/utils/index.ts")).toBe("const index = {};"); + + expect(extractContentFromCodeBlock(content, "src/utils.ts")).toBe( + "const util = {};", + ); + expect(extractContentFromCodeBlock(content, "src/utils/index.ts")).toBe( + "const index = {};", + ); }); -}); \ No newline at end of file +}); diff --git a/extensions/vscode/e2e/actions/Autocomplete.actions.ts b/extensions/vscode/e2e/actions/Autocomplete.actions.ts index 9e91355fd..29902e4f2 100644 --- a/extensions/vscode/e2e/actions/Autocomplete.actions.ts +++ b/extensions/vscode/e2e/actions/Autocomplete.actions.ts @@ -30,14 +30,14 @@ export class AutocompleteActions { expect(ghostText1).to.equal(messagePair1.llmResponse); } - public static async forceCompletion(editor: TextEditor): Promise { + public static async forceCompletion(editor: TextEditor): Promise { await editor.setText("def main():\n "); await editor.moveCursor(2, 5); await new Workbench().executeCommand("Continue: Force Autocomplete"); const ghostText = await TestUtils.waitForSuccess(() => - AutocompleteSelectors.getGhostTextContent(VSBrowser.instance.driver) + AutocompleteSelectors.getGhostTextContent(VSBrowser.instance.driver), ); return ghostText; From e4dcc2cf099ef0dd3c3015bbaf91daadc91a150c Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 20 Jun 2025 16:52:05 -0700 Subject: [PATCH 28/46] Update package.json --- packages/openai-adapters/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/openai-adapters/package.json b/packages/openai-adapters/package.json index 2b5043cfb..d775bb0b3 100644 --- a/packages/openai-adapters/package.json +++ b/packages/openai-adapters/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/openai-adapters", - "version": "1.0.38", + "version": "1.0.39", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From ad7fb2da77116aab5fbac861dbec4500a04bc1ae Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 20 Jun 2025 19:49:58 -0700 Subject: [PATCH 29/46] Update package-lock.json --- packages/openai-adapters/package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/openai-adapters/package-lock.json b/packages/openai-adapters/package-lock.json index 1d88a8b5e..155f8ab36 100644 --- a/packages/openai-adapters/package-lock.json +++ b/packages/openai-adapters/package-lock.json @@ -1,12 +1,12 @@ { "name": "@continuedev/openai-adapters", - "version": "1.0.36", + "version": "1.0.39", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/openai-adapters", - "version": "1.0.36", + "version": "1.0.39", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.5", From 3ae9cc069e3a3e7b58b1e155bae6a3b69276fa2a Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 20 Jun 2025 19:54:31 -0700 Subject: [PATCH 30/46] Update ide.ts --- core/protocol/ide.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 5e24a62ff..7a9b8d68e 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -29,7 +29,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { openFile: [{ path: string }, void]; openUrl: [string, void]; runCommand: [{ command: string; options?: TerminalOptions }, void]; - getSearchResults: [{ query: string }, string]; + getSearchResults: [{ query: string; maxResults?: number }, string]; getFileResults: [{ pattern: string; maxResults?: number }, string[]]; subprocess: [{ command: string; cwd?: string }, [string, string]]; saveFile: [{ filepath: string }, void]; From fdc63310494f259a871d7b9eeccd19971960eb3c Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 20 Jun 2025 20:48:49 -0700 Subject: [PATCH 31/46] chore: version bumps --- extensions/intellij/gradle.properties | 2 +- extensions/vscode/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index 8c3302728..15326353d 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.24 +pluginVersion=1.0.25 # 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/vscode/package.json b/extensions/vscode/package.json index 81b1a142d..22c040f40 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.49", + "version": "1.1.50", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 5c7a5ae023655824fb18dd82ee2f092385bc1847 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Fri, 20 Jun 2025 21:45:40 -0700 Subject: [PATCH 32/46] chore: bump openai-adapters --- packages/openai-adapters/package-lock.json | 4 ++-- packages/openai-adapters/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/openai-adapters/package-lock.json b/packages/openai-adapters/package-lock.json index 155f8ab36..c114ee618 100644 --- a/packages/openai-adapters/package-lock.json +++ b/packages/openai-adapters/package-lock.json @@ -1,12 +1,12 @@ { "name": "@continuedev/openai-adapters", - "version": "1.0.39", + "version": "1.0.40", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/openai-adapters", - "version": "1.0.39", + "version": "1.0.40", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.5", diff --git a/packages/openai-adapters/package.json b/packages/openai-adapters/package.json index d775bb0b3..dbbb23789 100644 --- a/packages/openai-adapters/package.json +++ b/packages/openai-adapters/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/openai-adapters", - "version": "1.0.39", + "version": "1.0.40", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From ea52d138558cdb55b3ea0f9f8b252240a05c4106 Mon Sep 17 00:00:00 2001 From: Shankhadeep Dey Date: Sun, 22 Jun 2025 22:29:59 +0530 Subject: [PATCH 33/46] feat: add webview listener for index progress to load submenu items --- gui/src/context/SubmenuContextProviders.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gui/src/context/SubmenuContextProviders.tsx b/gui/src/context/SubmenuContextProviders.tsx index 8268377de..804d622f2 100644 --- a/gui/src/context/SubmenuContextProviders.tsx +++ b/gui/src/context/SubmenuContextProviders.tsx @@ -356,6 +356,16 @@ export const SubmenuContextProvidersProvider = ({ [loadSubmenuItems], ); + useWebviewListener( + "indexProgress", + async (data) => { + if (data.status === "done") { + loadSubmenuItems("dependsOnIndexing") + } + }, + [loadSubmenuItems], + ); + // Reload all submenu items on the initial config load useEffect(() => { if (!submenuContextProviders.length) { From 944f3e16d2aa33beae0810d8d3aa642fe1b959ed Mon Sep 17 00:00:00 2001 From: Shankhadeep Dey Date: Sun, 22 Jun 2025 22:36:44 +0530 Subject: [PATCH 34/46] fix: prettier format --- gui/src/context/SubmenuContextProviders.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/context/SubmenuContextProviders.tsx b/gui/src/context/SubmenuContextProviders.tsx index 804d622f2..cf3939c48 100644 --- a/gui/src/context/SubmenuContextProviders.tsx +++ b/gui/src/context/SubmenuContextProviders.tsx @@ -360,7 +360,7 @@ export const SubmenuContextProvidersProvider = ({ "indexProgress", async (data) => { if (data.status === "done") { - loadSubmenuItems("dependsOnIndexing") + loadSubmenuItems("dependsOnIndexing"); } }, [loadSubmenuItems], From 7927a6242244a21d950e550d5cf9512d4a86a0e3 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sun, 22 Jun 2025 11:25:03 -0700 Subject: [PATCH 35/46] feat: create `AssistantAndOrgListbox` --- extensions/vscode/package-lock.json | 4 +- .../AssistantIcon.tsx | 4 +- .../AssistantOption.tsx | 118 ++++++ .../AssistantOptions.tsx | 54 +++ .../OrganizationInfo.tsx | 14 + .../AssistantAndOrgListbox}/ScopeSelect.tsx | 30 +- .../SelectedAssistantButton.tsx | 38 ++ .../AssistantAndOrgListbox/index.tsx | 173 ++++++++ .../shared.tsx | 4 +- .../platform => }/FreeTrialButton.tsx | 11 +- .../LumpToolbar/BlockSettingsTopToolbar.tsx | 6 +- .../platform/AssistantSelect.tsx | 388 ------------------ gui/src/pages/config/AccountButton.tsx | 2 +- packages/config-yaml/package-lock.json | 4 +- 14 files changed, 432 insertions(+), 418 deletions(-) rename gui/src/components/{modelSelection/platform => AssistantAndOrgListbox}/AssistantIcon.tsx (86%) create mode 100644 gui/src/components/AssistantAndOrgListbox/AssistantOption.tsx create mode 100644 gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx create mode 100644 gui/src/components/AssistantAndOrgListbox/OrganizationInfo.tsx rename gui/src/{pages/config => components/AssistantAndOrgListbox}/ScopeSelect.tsx (81%) create mode 100644 gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx create mode 100644 gui/src/components/AssistantAndOrgListbox/index.tsx rename gui/src/components/{modelSelection/platform => AssistantAndOrgListbox}/shared.tsx (98%) rename gui/src/components/{modelSelection/platform => }/FreeTrialButton.tsx (93%) delete mode 100644 gui/src/components/modelSelection/platform/AssistantSelect.tsx diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 199c669c7..1d493deef 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.48", + "version": "1.1.49", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.48", + "version": "1.1.49", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", diff --git a/gui/src/components/modelSelection/platform/AssistantIcon.tsx b/gui/src/components/AssistantAndOrgListbox/AssistantIcon.tsx similarity index 86% rename from gui/src/components/modelSelection/platform/AssistantIcon.tsx rename to gui/src/components/AssistantAndOrgListbox/AssistantIcon.tsx index c901bfdf4..aca23dad7 100644 --- a/gui/src/components/modelSelection/platform/AssistantIcon.tsx +++ b/gui/src/components/AssistantAndOrgListbox/AssistantIcon.tsx @@ -1,13 +1,13 @@ import { ComputerDesktopIcon, SparklesIcon } from "@heroicons/react/24/outline"; import { ProfileDescription } from "core/config/ProfileLifecycleManager"; -import { isLocalProfile } from "../../../util"; +import { isLocalProfile } from "../../util"; export interface AssistantIconProps { assistant: ProfileDescription; size?: number; } -export default function AssistantIcon({ assistant, size }: AssistantIconProps) { +export function AssistantIcon({ assistant, size }: AssistantIconProps) { const sizeTw = size ?? 4; if (isLocalProfile(assistant)) { return ( diff --git a/gui/src/components/AssistantAndOrgListbox/AssistantOption.tsx b/gui/src/components/AssistantAndOrgListbox/AssistantOption.tsx new file mode 100644 index 000000000..201a9e852 --- /dev/null +++ b/gui/src/components/AssistantAndOrgListbox/AssistantOption.tsx @@ -0,0 +1,118 @@ +import { + ArrowTopRightOnSquareIcon, + Cog6ToothIcon, + ExclamationTriangleIcon, +} from "@heroicons/react/24/outline"; +import { ProfileDescription } from "core/config/ProfileLifecycleManager"; +import { useContext, useMemo } from "react"; +import { useNavigate } from "react-router-dom"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useAppDispatch } from "../../redux/hooks"; +import { setSelectedProfile } from "../../redux/slices/profilesSlice"; +import { isLocalProfile } from "../../util"; +import { ROUTES } from "../../util/navigation"; +import { useLump } from "../mainInput/Lump/LumpContext"; +import { ListboxOption, useFontSize } from "../ui"; +import { AssistantIcon } from "./AssistantIcon"; + +interface AssistantOptionProps { + profile: ProfileDescription; + selected: boolean; + onClick: () => void; +} + +export function AssistantOption({ + profile, + selected, + onClick, +}: AssistantOptionProps) { + const tinyFont = useFontSize(-4); + const navigate = useNavigate(); + const { setSelectedSection } = useLump(); + const dispatch = useAppDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + + const hasFatalErrors = useMemo(() => { + return !!profile.errors?.find((error) => error.fatal); + }, [profile.errors]); + + function handleOptionClick() { + // optimistic update + dispatch(setSelectedProfile(profile.id)); + // notify core which will handle actual update + ideMessenger.post("didChangeSelectedProfile", { + id: profile.id, + }); + onClick(); + } + + function handleConfigure() { + ideMessenger.post("config/openProfile", { profileId: profile.id }); + onClick(); + } + + function handleClickError() { + if (profile.id === "local") { + navigate(ROUTES.HOME); + setSelectedSection("error"); + } else { + ideMessenger.post("config/openProfile", { profileId: profile.id }); + } + onClick(); + } + + return ( + +
+
+
+ +
+ + {profile.title} + +
+
+ {profile.errors && profile.errors?.length > 0 && ( + { + e.preventDefault(); + e.stopPropagation(); + handleClickError(); + }} + /> + )} + {isLocalProfile(profile) ? ( + { + e.stopPropagation(); + e.preventDefault(); + handleConfigure(); + }} + /> + ) : ( + { + e.stopPropagation(); + e.preventDefault(); + handleConfigure(); + }} + /> + )} +
+
+
+ ); +} diff --git a/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx b/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx new file mode 100644 index 000000000..304444b23 --- /dev/null +++ b/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx @@ -0,0 +1,54 @@ +import { ArrowPathIcon } from "@heroicons/react/24/outline"; +import { useState } from "react"; +import { useAuth } from "../../context/Auth"; +import { cn } from "../../util/cn"; +import { AssistantOption } from "./AssistantOption"; + +interface AssistantOptionsProps { + selectedProfileId: string | undefined; + onClose: () => void; +} + +export function AssistantOptions({ + selectedProfileId, + onClose, +}: AssistantOptionsProps) { + const [loading, setLoading] = useState(false); + const { profiles, refreshProfiles } = useAuth(); + + return ( + <> + {/* Assistants Section Header */} +
+ +
{ + e.stopPropagation(); + setLoading(true); + await refreshProfiles(); + setLoading(false); + }} + > + +
+
+ +
+ {profiles?.map((profile, idx) => ( + + ))} +
+ + ); +} diff --git a/gui/src/components/AssistantAndOrgListbox/OrganizationInfo.tsx b/gui/src/components/AssistantAndOrgListbox/OrganizationInfo.tsx new file mode 100644 index 000000000..7965616ad --- /dev/null +++ b/gui/src/components/AssistantAndOrgListbox/OrganizationInfo.tsx @@ -0,0 +1,14 @@ +import { ScopeSelect } from "./ScopeSelect"; + +export function OrganizationInfo() { + return ( +
+
+ + +
+
+ ); +} diff --git a/gui/src/pages/config/ScopeSelect.tsx b/gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx similarity index 81% rename from gui/src/pages/config/ScopeSelect.tsx rename to gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx index 9e574f44a..6374394fd 100644 --- a/gui/src/pages/config/ScopeSelect.tsx +++ b/gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx @@ -4,12 +4,6 @@ import { } from "@heroicons/react/24/outline"; import { UserCircleIcon } from "@heroicons/react/24/solid"; import { useContext } from "react"; -import { - Listbox, - ListboxButton, - ListboxOption, - ListboxOptions, -} from "../../components/ui/Listbox"; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; @@ -17,6 +11,12 @@ import { selectCurrentOrg, setSelectedOrgId, } from "../../redux/slices/profilesSlice"; +import { + Listbox, + ListboxButton, + ListboxOption, + ListboxOptions, +} from "../ui/Listbox"; interface ScopeSelectProps { onSelect?: () => void; @@ -54,15 +54,19 @@ export function ScopeSelect({ onSelect }: ScopeSelectProps) {
{selectedDisplay?.iconUrl ? ( - + ) : ( - + )} {selectedDisplay?.name || "Select Organization"}
-
@@ -70,9 +74,13 @@ export function ScopeSelect({ onSelect }: ScopeSelectProps) {
{org.iconUrl ? ( - + ) : ( - + )} {org.name}
diff --git a/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx b/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx new file mode 100644 index 000000000..131f0d1e1 --- /dev/null +++ b/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx @@ -0,0 +1,38 @@ +import { ChevronDownIcon } from "@heroicons/react/24/outline"; +import type { ProfileDescription } from "core/config/ConfigHandler"; +import { fontSize } from "../../util"; +import { useLump } from "../mainInput/Lump/LumpContext"; +import { ListboxButton } from "../ui"; +import { AssistantIcon } from "./AssistantIcon"; + +interface SelectedAssistantButtonProps { + selectedProfile: ProfileDescription; +} + +export function SelectedAssistantButton({ + selectedProfile, +}: SelectedAssistantButtonProps) { + const { isToolbarExpanded } = useLump(); + return ( + +
+
+ +
+ + {selectedProfile.title} + +
+
+ ); +} diff --git a/gui/src/components/AssistantAndOrgListbox/index.tsx b/gui/src/components/AssistantAndOrgListbox/index.tsx new file mode 100644 index 000000000..f4e92c144 --- /dev/null +++ b/gui/src/components/AssistantAndOrgListbox/index.tsx @@ -0,0 +1,173 @@ +import { PlusIcon } from "@heroicons/react/24/outline"; +import { useContext, useEffect, useRef } from "react"; +import { useAuth } from "../../context/Auth"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; +import { + selectCurrentOrg, + setSelectedProfile, +} from "../../redux/slices/profilesSlice"; +import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util"; +import { useLump } from "../mainInput/Lump/LumpContext"; +import { + Listbox, + ListboxOption, + ListboxOptions, + Transition, + useFontSize, +} from "../ui"; +import { AssistantOptions } from "./AssistantOptions"; +import { OrganizationInfo } from "./OrganizationInfo"; +import { SelectedAssistantButton } from "./SelectedAssistantButton"; + +export function AssistantAndOrgListbox() { + const dispatch = useAppDispatch(); + const listboxRef = useRef(null); + const currentOrg = useAppSelector(selectCurrentOrg); + const ideMessenger = useContext(IdeMessengerContext); + const { isToolbarExpanded } = useLump(); + const { profiles, logout, selectedProfile, session, login } = useAuth(); + const smallFont = useFontSize(-3); + const tinyFont = useFontSize(-4); + + function close() { + // Close the listbox by clicking outside or programmatically + const event = new KeyboardEvent("keydown", { key: "Escape" }); + document.dispatchEvent(event); + } + + function onNewAssistant() { + void ideMessenger.request("controlPlane/openUrl", { + path: "/new", + orgSlug: currentOrg?.slug, + }); + close(); + } + + function onLogout() { + logout(); + close(); + } + + useEffect(() => { + let lastToggleTime = 0; + const DEBOUNCE_MS = 800; + + const handleKeyDown = (event: KeyboardEvent) => { + if ( + event.key === "'" && + isMetaEquivalentKeyPressed(event as any) && + event.shiftKey + ) { + const now = Date.now(); + + if (now - lastToggleTime >= DEBOUNCE_MS) { + lastToggleTime = now; + + const profileIds = profiles?.map((profile) => profile.id) ?? []; + // In case of 1 or 0 profiles just does nothing + if (profileIds.length < 2) { + return; + } + let nextId = profileIds[0]; + if (selectedProfile) { + const curIndex = profileIds.indexOf(selectedProfile.id); + const nextIndex = (curIndex + 1) % profileIds.length; + nextId = profileIds[nextIndex]; + } + // Optimistic update + dispatch(setSelectedProfile(nextId)); + ideMessenger.post("didChangeSelectedProfile", { + id: nextId, + }); + } + } + }; + + window.addEventListener("keydown", handleKeyDown); + return () => { + window.removeEventListener("keydown", handleKeyDown); + }; + }, [currentOrg, selectedProfile]); + + if (!selectedProfile) { + return ( +
{ + void ideMessenger.request("controlPlane/openUrl", { + path: "/new?type=assistant", + orgSlug: currentOrg?.slug, + }); + }} + className="text-description flex cursor-pointer select-none items-center gap-1" + style={{ fontSize: smallFont }} + > + + + Create your first assistant + +
+ ); + } + + return ( + +
+ + + + + + + {/* Bottom Actions */} +
+ login(false)} + > +
+ New Assistant +
+
+ + {session && ( + +
+ Log out +
+
+ )} + +
+ + {getMetaKeyLabel()} ⇧ ' to toggle assistant + +
+
+
+
+
+
+ ); +} diff --git a/gui/src/components/modelSelection/platform/shared.tsx b/gui/src/components/AssistantAndOrgListbox/shared.tsx similarity index 98% rename from gui/src/components/modelSelection/platform/shared.tsx rename to gui/src/components/AssistantAndOrgListbox/shared.tsx index b617fd34e..1f57a4309 100644 --- a/gui/src/components/modelSelection/platform/shared.tsx +++ b/gui/src/components/AssistantAndOrgListbox/shared.tsx @@ -10,8 +10,8 @@ import { defaultBorderRadius, lightGray, vscCommandCenterInactiveBorder, -} from "../.."; -import { ToolTip } from "../../gui/Tooltip"; +} from ".."; +import { ToolTip } from "../gui/Tooltip"; export const OptionDiv = styled.div<{ isDisabled?: boolean; diff --git a/gui/src/components/modelSelection/platform/FreeTrialButton.tsx b/gui/src/components/FreeTrialButton.tsx similarity index 93% rename from gui/src/components/modelSelection/platform/FreeTrialButton.tsx rename to gui/src/components/FreeTrialButton.tsx index c34d0abce..1665b318d 100644 --- a/gui/src/components/modelSelection/platform/FreeTrialButton.tsx +++ b/gui/src/components/FreeTrialButton.tsx @@ -1,11 +1,10 @@ import { ChevronDownIcon } from "@heroicons/react/24/outline"; import { FreeTrialStatus } from "core/control-plane/client"; import { useContext } from "react"; -import { Button, SecondaryButton, vscButtonBackground } from "../.."; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { fontSize } from "../../../util"; -import { Listbox, ListboxButton, ListboxOptions, Transition } from "../../ui"; -import { useFontSize } from "../../ui/font"; +import { Button, SecondaryButton, vscButtonBackground } from "."; +import { IdeMessengerContext } from "../context/IdeMessenger"; +import { fontSize } from "../util"; +import { Listbox, ListboxButton, ListboxOptions, Transition } from "./ui"; interface ProgressBarProps { label: string; @@ -78,8 +77,6 @@ interface FreeTrialButtonProps { export default function FreeTrialButton({ freeTrialStatus, }: FreeTrialButtonProps) { - const smallFont = useFontSize(-3); - const tinyFont = useFontSize(-4); const ideMessenger = useContext(IdeMessengerContext); return ( diff --git a/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx b/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx index 4be749689..f902c757a 100644 --- a/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx +++ b/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx @@ -13,9 +13,8 @@ import { ReactNode, useContext, useEffect, useState } from "react"; import { vscBadgeForeground } from "../../.."; import { IdeMessengerContext } from "../../../../context/IdeMessenger"; import { useAppSelector } from "../../../../redux/hooks"; +import FreeTrialButton from "../../../FreeTrialButton"; import { ToolTip } from "../../../gui/Tooltip"; -import AssistantSelect from "../../../modelSelection/platform/AssistantSelect"; -import FreeTrialButton from "../../../modelSelection/platform/FreeTrialButton"; import { useFontSize } from "../../../ui/font"; import HoverItem from "../../InputToolbar/HoverItem"; import { useLump } from "../LumpContext"; @@ -25,6 +24,7 @@ import { ToolsSectionTooltip } from "../sections/tool-policies/ToolPoliciesSecti import { usesFreeTrialApiKey } from "core/config/usesFreeTrialApiKey"; import type { FreeTrialStatus } from "core/control-plane/client"; +import { AssistantAndOrgListbox } from "../../../AssistantAndOrgListbox"; interface BlockSettingsToolbarIcon { title: string; @@ -236,7 +236,7 @@ export function BlockSettingsTopToolbar() { {isUsingFreeTrial ? ( ) : ( - + )} {isUsingFreeTrial ? "View free trial usage" : "Select Assistant"} diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx deleted file mode 100644 index d360abce4..000000000 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ /dev/null @@ -1,388 +0,0 @@ -import { - ArrowPathIcon, - ArrowTopRightOnSquareIcon, - BuildingOfficeIcon, - ChevronDownIcon, - Cog6ToothIcon, - ExclamationTriangleIcon, - PlusIcon, -} from "@heroicons/react/24/outline"; -import type { ProfileDescription } from "core/config/ConfigHandler"; -import { useContext, useEffect, useMemo, useRef, useState } from "react"; -import { useNavigate } from "react-router-dom"; -import { useAuth } from "../../../context/Auth"; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; -import { - selectCurrentOrg, - setSelectedOrgId, - setSelectedProfile, -} from "../../../redux/slices/profilesSlice"; -import { - fontSize, - getMetaKeyLabel, - isLocalProfile, - isMetaEquivalentKeyPressed, -} from "../../../util"; -import { cn } from "../../../util/cn"; -import { ROUTES } from "../../../util/navigation"; -import { useLump } from "../../mainInput/Lump/LumpContext"; -import { - Listbox, - ListboxButton, - ListboxOption, - ListboxOptions, - Transition, - useFontSize, -} from "../../ui"; -import AssistantIcon from "./AssistantIcon"; -interface AssistantSelectOptionProps { - profile: ProfileDescription; - selected: boolean; - onClick: () => void; -} - -const AssistantSelectOption = ({ - profile, - selected, - onClick, -}: AssistantSelectOptionProps) => { - const tinyFont = useFontSize(-4); - - const navigate = useNavigate(); - const { setSelectedSection } = useLump(); - - const hasFatalErrors = useMemo(() => { - return !!profile.errors?.find((error) => error.fatal); - }, [profile.errors]); - - const dispatch = useAppDispatch(); - const ideMessenger = useContext(IdeMessengerContext); - - function handleOptionClick() { - // optimistic update - dispatch(setSelectedProfile(profile.id)); - // notify core which will handle actual update - ideMessenger.post("didChangeSelectedProfile", { - id: profile.id, - }); - onClick(); - } - - function handleConfigure() { - ideMessenger.post("config/openProfile", { profileId: profile.id }); - onClick(); - } - - function handleClickError() { - if (profile.id === "local") { - navigate(ROUTES.HOME); - setSelectedSection("error"); - } else { - ideMessenger.post("config/openProfile", { profileId: profile.id }); - } - onClick(); - } - - return ( - -
-
-
-
- -
- - {profile.title} - -
-
- {profile.errors && profile.errors?.length > 0 && ( - { - e.preventDefault(); - e.stopPropagation(); - handleClickError(); - }} - /> - )} - {isLocalProfile(profile) ? ( - { - e.stopPropagation(); - e.preventDefault(); - handleConfigure(); - }} - /> - ) : ( - { - e.stopPropagation(); - e.preventDefault(); - handleConfigure(); - }} - /> - )} -
-
-
-
- ); -}; - -export default function AssistantSelect() { - const dispatch = useAppDispatch(); - const buttonRef = useRef(null); - const currentOrg = useAppSelector(selectCurrentOrg); - const orgs = useAppSelector((store) => store.profiles.organizations); - const ideMessenger = useContext(IdeMessengerContext); - const { isToolbarExpanded } = useLump(); - const [loading, setLoading] = useState(false); - const { profiles, session, login, selectedProfile, refreshProfiles } = - useAuth(); - - function close() { - if (buttonRef.current) { - buttonRef.current.click(); - } - } - function onNewAssistant() { - ideMessenger.post("controlPlane/openUrl", { - path: "new", - orgSlug: currentOrg?.slug, - }); - close(); - } - - useEffect(() => { - let lastToggleTime = 0; - const DEBOUNCE_MS = 800; - - const handleKeyDown = (event: KeyboardEvent) => { - if ( - event.key === "'" && - isMetaEquivalentKeyPressed(event as any) && - event.shiftKey - ) { - const now = Date.now(); - - if (now - lastToggleTime >= DEBOUNCE_MS) { - lastToggleTime = now; - - const profileIds = profiles?.map((profile) => profile.id) ?? []; - // In case of 1 or 0 profiles just does nothing - if (profileIds.length < 2) { - return; - } - let nextId = profileIds[0]; - if (selectedProfile) { - const curIndex = profileIds.indexOf(selectedProfile.id); - const nextIndex = (curIndex + 1) % profileIds.length; - nextId = profileIds[nextIndex]; - } - // Optimistic update - dispatch(setSelectedProfile(nextId)); - ideMessenger.post("didChangeSelectedProfile", { - id: nextId, - }); - } - } - }; - - window.addEventListener("keydown", handleKeyDown); - return () => { - window.removeEventListener("keydown", handleKeyDown); - }; - }, [currentOrg, selectedProfile]); - - const cycleOrgs = () => { - if (!session) { - void login(false); - return; - } - - const orgIds = orgs.map((org) => org.id); - if (orgIds.length < 2) { - return; - } - let nextId = orgIds[0]; - if (currentOrg) { - const curIndex = orgIds.indexOf(currentOrg.id); - const nextIndex = (curIndex + 1) % orgIds.length; - nextId = orgIds[nextIndex]; - } - // Optimistic update - dispatch(setSelectedOrgId(nextId)); - ideMessenger.post("didChangeSelectedOrg", { - id: nextId, - }); - }; - - const tinyFont = useFontSize(-4); - const smallFont = useFontSize(-3); - - if (!selectedProfile) { - return ( -
{ - void ideMessenger.request("controlPlane/openUrl", { - path: "/new?type=assistant", - orgSlug: currentOrg?.slug, - }); - }} - className="text-description flex cursor-pointer select-none items-center gap-1" - style={{ fontSize: smallFont }} - > - - - Create your first assistant - -
- ); - } - - return ( - -
- -
-
- -
- - {selectedProfile.title} - -
-
- - - -
- Assistants -
{ - e.stopPropagation(); - setLoading(true); - await refreshProfiles(); - setLoading(false); - buttonRef.current?.click(); - }} - > - -
-
- -
- {profiles?.map((profile, idx) => { - return ( - - ); - })} -
- -
-
- login(false)} - > -
- - New Assistant -
-
-
- -
- - {getMetaKeyLabel()} ⇧ ' to toggle - -
- {currentOrg?.iconUrl ? ( - - ) : ( - - )} - - {currentOrg?.name || "Personal"} - -
-
-
-
-
-
-
- ); -} diff --git a/gui/src/pages/config/AccountButton.tsx b/gui/src/pages/config/AccountButton.tsx index 888488208..f108c8e65 100644 --- a/gui/src/pages/config/AccountButton.tsx +++ b/gui/src/pages/config/AccountButton.tsx @@ -1,5 +1,6 @@ import { UserCircleIcon } from "@heroicons/react/24/solid"; import { isOnPremSession } from "core/control-plane/AuthTypes"; +import { ScopeSelect } from "../../components/AssistantAndOrgListbox/ScopeSelect"; import { Button, Popover, @@ -10,7 +11,6 @@ import { import { useAuth } from "../../context/Auth"; import { useAppSelector } from "../../redux/hooks"; import { selectCurrentOrg } from "../../redux/slices/profilesSlice"; -import { ScopeSelect } from "./ScopeSelect"; export function AccountButton() { const { session, logout, login, organizations } = useAuth(); diff --git a/packages/config-yaml/package-lock.json b/packages/config-yaml/package-lock.json index 492e0eaa5..6d02d51d8 100644 --- a/packages/config-yaml/package-lock.json +++ b/packages/config-yaml/package-lock.json @@ -1,12 +1,12 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.93", + "version": "1.0.94", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/config-yaml", - "version": "1.0.93", + "version": "1.0.94", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", From b96068408e65b2c5687b7736eba831febcc02fc8 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sun, 22 Jun 2025 11:35:16 -0700 Subject: [PATCH 36/46] remove accountbutton --- .../AssistantAndOrgListbox/AccountOption.tsx | 42 ++++++++++ .../OrganizationInfo.tsx | 14 +++- .../AssistantAndOrgListbox/index.tsx | 24 +----- gui/src/pages/config/AccountButton.tsx | 82 ------------------- gui/src/pages/config/index.tsx | 2 - gui/src/pages/history/index.tsx | 8 +- 6 files changed, 57 insertions(+), 115 deletions(-) create mode 100644 gui/src/components/AssistantAndOrgListbox/AccountOption.tsx delete mode 100644 gui/src/pages/config/AccountButton.tsx diff --git a/gui/src/components/AssistantAndOrgListbox/AccountOption.tsx b/gui/src/components/AssistantAndOrgListbox/AccountOption.tsx new file mode 100644 index 000000000..8f4f8e11e --- /dev/null +++ b/gui/src/components/AssistantAndOrgListbox/AccountOption.tsx @@ -0,0 +1,42 @@ +import { isOnPremSession } from "core/control-plane/AuthTypes"; +import { useAuth } from "../../context/Auth"; +import { ListboxOption, useFontSize } from "../ui"; + +interface AccountOptionProps { + onClose: () => void; +} + +export function AccountOption({ onClose }: AccountOptionProps) { + const { session, logout, login } = useAuth(); + const tinyFont = useFontSize(-4); + + // No account option for on-prem deployments + if (session && isOnPremSession(session)) { + return null; + } + + async function handleClick() { + if (session) { + logout(); + } else { + await login(false); + } + onClose(); + } + + return ( + +
+ {session ? "Log out" : "Sign in"} +
+
+ ); +} diff --git a/gui/src/components/AssistantAndOrgListbox/OrganizationInfo.tsx b/gui/src/components/AssistantAndOrgListbox/OrganizationInfo.tsx index 7965616ad..a4439afab 100644 --- a/gui/src/components/AssistantAndOrgListbox/OrganizationInfo.tsx +++ b/gui/src/components/AssistantAndOrgListbox/OrganizationInfo.tsx @@ -1,12 +1,20 @@ +import { useAuth } from "../../context/Auth"; import { ScopeSelect } from "./ScopeSelect"; export function OrganizationInfo() { + const { session } = useAuth(); + return (
- +
+ + {!session && ( + (Signed out) + )} +
diff --git a/gui/src/components/AssistantAndOrgListbox/index.tsx b/gui/src/components/AssistantAndOrgListbox/index.tsx index f4e92c144..114b70ef2 100644 --- a/gui/src/components/AssistantAndOrgListbox/index.tsx +++ b/gui/src/components/AssistantAndOrgListbox/index.tsx @@ -16,6 +16,7 @@ import { Transition, useFontSize, } from "../ui"; +import { AccountOption } from "./AccountOption"; import { AssistantOptions } from "./AssistantOptions"; import { OrganizationInfo } from "./OrganizationInfo"; import { SelectedAssistantButton } from "./SelectedAssistantButton"; @@ -26,7 +27,7 @@ export function AssistantAndOrgListbox() { const currentOrg = useAppSelector(selectCurrentOrg); const ideMessenger = useContext(IdeMessengerContext); const { isToolbarExpanded } = useLump(); - const { profiles, logout, selectedProfile, session, login } = useAuth(); + const { profiles, selectedProfile, session, login } = useAuth(); const smallFont = useFontSize(-3); const tinyFont = useFontSize(-4); @@ -44,11 +45,6 @@ export function AssistantAndOrgListbox() { close(); } - function onLogout() { - logout(); - close(); - } - useEffect(() => { let lastToggleTime = 0; const DEBOUNCE_MS = 800; @@ -140,21 +136,7 @@ export function AssistantAndOrgListbox() {
- {session && ( - -
- Log out -
-
- )} +
login(false)} - > - Sign in - - ); - } - - // No login button for on-prem deployments - if (isOnPremSession(session)) { - return null; - } - - return ( - - {({ close }) => ( - <> - -
- - {selectedOrg === null ? "Personal" : selectedOrg.name} - - -
-
- - - -
-
- {session.account.label} - - {session.account.id} - -
- - {organizations.length > 0 && ( -
- - -
- )} - - -
-
-
- - )} -
- ); -} diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index ea5ccef44..d9939a2c8 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -9,7 +9,6 @@ import { useNavigate } from "react-router-dom"; import { PageHeader } from "../../components/PageHeader"; import { useNavigationListener } from "../../hooks/useNavigationListener"; import { fontSize } from "../../util"; -import { AccountButton } from "./AccountButton"; import { HelpCenterSection } from "./HelpCenterSection"; import { IndexingSettingsSection } from "./IndexingSettingsSection"; import KeyboardShortcuts from "./KeyboardShortcuts"; @@ -63,7 +62,6 @@ function ConfigPage() { showBorder onTitleClick={() => navigate("/")} title="Chat" - rightContent={} /> {/* Tab Headers */} diff --git a/gui/src/pages/history/index.tsx b/gui/src/pages/history/index.tsx index a8be3d92f..86950ff24 100644 --- a/gui/src/pages/history/index.tsx +++ b/gui/src/pages/history/index.tsx @@ -2,7 +2,6 @@ import { useNavigate } from "react-router-dom"; import { History } from "../../components/History"; import { PageHeader } from "../../components/PageHeader"; import { getFontSize } from "../../util"; -import { AccountButton } from "../config/AccountButton"; export default function HistoryPage() { const navigate = useNavigate(); @@ -12,12 +11,7 @@ export default function HistoryPage() { className="flex flex-1 flex-col overflow-auto" style={{ fontSize: getFontSize() }} > - navigate("/")} - title="Chat" - rightContent={} - /> + navigate("/")} title="Chat" />
); From 7e80ca94ce128dcb2e63c6b1950b02c03401ae17 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sun, 22 Jun 2025 11:41:23 -0700 Subject: [PATCH 37/46] remove auth dialog --- .../AssistantAndOrgListbox/index.tsx | 2 +- gui/src/context/Auth.tsx | 31 ++++--------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/gui/src/components/AssistantAndOrgListbox/index.tsx b/gui/src/components/AssistantAndOrgListbox/index.tsx index 114b70ef2..ee175a725 100644 --- a/gui/src/components/AssistantAndOrgListbox/index.tsx +++ b/gui/src/components/AssistantAndOrgListbox/index.tsx @@ -113,7 +113,7 @@ export function AssistantAndOrgListbox() {
- + = ({ const selectedProfile = useAppSelector(selectSelectedProfile); const login: AuthContextType["login"] = (useOnboarding: boolean) => { - return new Promise((resolve) => { - ideMessenger + return new Promise(async (resolve) => { + await ideMessenger .request("getControlPlaneSessionInfo", { silent: false, useOnboarding, @@ -73,27 +71,10 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ }; const logout = () => { - dispatch(setShowDialog(true)); - dispatch( - setDialogMessage( - { - ideMessenger.post("logoutOfControlPlane", undefined); - dispatch( - setOrganizations(orgs.filter((org) => org.id === "personal")), - ); - dispatch(setSelectedOrgId("personal")); - setSession(undefined); - }} - onCancel={() => { - dispatch(setDialogMessage(undefined)); - dispatch(setShowDialog(false)); - }} - />, - ), - ); + ideMessenger.post("logoutOfControlPlane", undefined); + dispatch(setOrganizations(orgs.filter((org) => org.id === "personal"))); + dispatch(setSelectedOrgId("personal")); + setSession(undefined); }; useEffect(() => { From 94113e0ee18785c55414ec6744b8147ca0d88f60 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sun, 22 Jun 2025 12:06:51 -0700 Subject: [PATCH 38/46] fix: use last 2 parts of file uri for rule names --- .../src/markdown/markdownToRule.test.ts | 123 ++++++++++++++++-- .../src/markdown/markdownToRule.ts | 24 +++- 2 files changed, 137 insertions(+), 10 deletions(-) diff --git a/packages/config-yaml/src/markdown/markdownToRule.test.ts b/packages/config-yaml/src/markdown/markdownToRule.test.ts index 71c22343b..1b930220a 100644 --- a/packages/config-yaml/src/markdown/markdownToRule.test.ts +++ b/packages/config-yaml/src/markdown/markdownToRule.test.ts @@ -1,5 +1,5 @@ import { PackageIdentifier } from "../browser.js"; -import { markdownToRule } from "./markdownToRule.js"; +import { getRuleName, markdownToRule } from "./markdownToRule.js"; describe("markdownToRule", () => { // Use a mock PackageIdentifier for testing @@ -36,7 +36,7 @@ This is a test rule.`; const result = markdownToRule(content, mockId); expect(result.globs).toBe("**/test/**/*.kt"); expect(result.rule).toBe("# Test Rule\n\nThis is a test rule."); - expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result + expect(result.name).toBe("to/file"); // Should use last two path segments }); it("should handle missing frontmatter", () => { @@ -47,7 +47,7 @@ This is a test rule without frontmatter.`; const result = markdownToRule(content, mockId); expect(result.globs).toBeUndefined(); expect(result.rule).toBe(content); - expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result + expect(result.name).toBe("to/file"); // Should use last two path segments }); it("should handle empty frontmatter", () => { @@ -63,7 +63,7 @@ This is a test rule with empty frontmatter.`; expect(result.rule).toBe( "# Test Rule\n\nThis is a test rule with empty frontmatter.", ); - expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result + expect(result.name).toBe("to/file"); // Should use last two path segments }); it("should handle frontmatter with whitespace", () => { @@ -78,7 +78,7 @@ This is a test rule.`; const result = markdownToRule(content, mockId); expect(result.globs).toBe("**/test/**/*.kt"); expect(result.rule).toBe("# Test Rule\n\nThis is a test rule."); - expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result + expect(result.name).toBe("to/file"); // Should use last two path segments }); it("should handle Windows line endings (CRLF)", () => { @@ -95,7 +95,7 @@ This is a test rule.`; expect(result.globs).toBe("**/test/**/*.kt"); // The result should be normalized to \n expect(result.rule).toBe("# Test Rule\n\nThis is a test rule."); - expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result + expect(result.name).toBe("to/file"); // Should use last two path segments }); it("should handle malformed frontmatter", () => { @@ -112,7 +112,7 @@ This is a test rule.`; const result = markdownToRule(content, mockId); expect(result.globs).toBeUndefined(); expect(result.rule).toBe(content); - expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result + expect(result.name).toBe("to/file"); // Should use last two path segments }); it("should use packageIdentifierToDisplayName if no heading or frontmatter name", () => { @@ -125,7 +125,7 @@ globs: "**/test/**/*.kt" This is a test rule.`; const result = markdownToRule(content, mockId); - expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result + expect(result.name).toBe("to/file"); // Should use last two path segments }); it("should use packageIdentifierToDisplayName if no heading or frontmatter name (no heading)", () => { @@ -136,7 +136,7 @@ globs: "**/test/**/*.kt" This is a test rule without a heading.`; const result = markdownToRule(content, mockId); - expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result + expect(result.name).toBe("to/file"); // Should use last two path segments }); it("should include description from frontmatter", () => { @@ -171,3 +171,108 @@ This is a rule with alwaysApply explicitly set to false.`; expect(result.alwaysApply).toBe(false); }); }); + +describe("getRuleName", () => { + it("should return frontmatter name when provided", () => { + const frontmatter = { name: "Custom Rule Name" }; + const id: PackageIdentifier = { + uriType: "file", + filePath: "/path/to/my-rule.md", + }; + + const result = getRuleName(frontmatter, id); + expect(result).toBe("Custom Rule Name"); + }); + + it("should return last two path segments for file identifier when no name", () => { + const frontmatter = {}; + const id: PackageIdentifier = { + uriType: "file", + filePath: "/long/path/to/rules/my-rule.md", + }; + + const result = getRuleName(frontmatter, id); + expect(result).toBe("rules/my-rule.md"); + }); + + it("should handle file paths with backslashes", () => { + const frontmatter = {}; + const id: PackageIdentifier = { + uriType: "file", + filePath: "C:\\long\\path\\to\\rules\\my-rule.md", + }; + + const result = getRuleName(frontmatter, id); + expect(result).toBe("rules/my-rule.md"); + }); + + it("should handle mixed forward and back slashes", () => { + const frontmatter = {}; + const id: PackageIdentifier = { + uriType: "file", + filePath: "/path/to\\rules/my-rule.md", + }; + + const result = getRuleName(frontmatter, id); + expect(result).toBe("rules/my-rule.md"); + }); + + it("should handle single segment path", () => { + const frontmatter = {}; + const id: PackageIdentifier = { + uriType: "file", + filePath: "my-rule.md", + }; + + const result = getRuleName(frontmatter, id); + expect(result).toBe("my-rule.md"); + }); + + it("should handle two segment path", () => { + const frontmatter = {}; + const id: PackageIdentifier = { + uriType: "file", + filePath: "rules/my-rule.md", + }; + + const result = getRuleName(frontmatter, id); + expect(result).toBe("rules/my-rule.md"); + }); + + it("should return display name for non-file identifiers", () => { + const frontmatter = {}; + const id: PackageIdentifier = { + uriType: "slug", + fullSlug: { + ownerSlug: "test-owner", + packageSlug: "my-rule-package", + versionSlug: "v1.0.0", + }, + }; + + const result = getRuleName(frontmatter, id); + expect(result).toBe("my-rule-package"); // packageIdentifierToDisplayName returns just the packageSlug + }); + + it("should prioritize frontmatter name over file path", () => { + const frontmatter = { name: "Override Name" }; + const id: PackageIdentifier = { + uriType: "file", + filePath: "/very/long/path/to/rules/original-name.md", + }; + + const result = getRuleName(frontmatter, id); + expect(result).toBe("Override Name"); + }); + + it("should handle empty string name in frontmatter by falling back to path", () => { + const frontmatter = { name: "" }; + const id: PackageIdentifier = { + uriType: "file", + filePath: "/path/to/rules/my-rule.md", + }; + + const result = getRuleName(frontmatter, id); + expect(result).toBe("rules/my-rule.md"); // Empty string is falsy, so falls back to path logic + }); +}); diff --git a/packages/config-yaml/src/markdown/markdownToRule.ts b/packages/config-yaml/src/markdown/markdownToRule.ts index a48f8176a..6c52cd82f 100644 --- a/packages/config-yaml/src/markdown/markdownToRule.ts +++ b/packages/config-yaml/src/markdown/markdownToRule.ts @@ -46,6 +46,28 @@ export function parseMarkdownRule(content: string): { return { frontmatter: {}, markdown: normalizedContent }; } +export function getRuleName( + frontmatter: RuleFrontmatter, + id: PackageIdentifier, +): string { + if (frontmatter.name) { + return frontmatter.name; + } + + const displayName = packageIdentifierToDisplayName(id); + + // If it's a file identifier, extract the last two parts of the file path + if (id.uriType === "file") { + // Handle both forward slashes and backslashes, get the last two segments + const segments = displayName.split(/[/\\]/); + const lastTwoParts = segments.slice(-2); + return lastTwoParts.join("/"); + } + + // Otherwise return the display name as-is (for slug identifiers) + return displayName; +} + export function markdownToRule( rule: string, id: PackageIdentifier, @@ -53,7 +75,7 @@ export function markdownToRule( const { frontmatter, markdown } = parseMarkdownRule(rule); return { - name: frontmatter.name ?? packageIdentifierToDisplayName(id), + name: getRuleName(frontmatter, id), rule: markdown, globs: frontmatter.globs, description: frontmatter.description, From 141e7dc30b9442d4eeaf9913dab2e337a1b06c9d Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sun, 22 Jun 2025 12:21:59 -0700 Subject: [PATCH 39/46] Update ScopeSelect.tsx --- .../AssistantAndOrgListbox/ScopeSelect.tsx | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx b/gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx index 6374394fd..7cac430a8 100644 --- a/gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx +++ b/gui/src/components/AssistantAndOrgListbox/ScopeSelect.tsx @@ -21,6 +21,19 @@ import { interface ScopeSelectProps { onSelect?: () => void; } + +function getOrgIcon(org: { name: string; iconUrl?: string | null }) { + if (org.iconUrl) { + return ( + + ); + } + + const IconComponent = + org.name === "Personal" ? UserCircleIcon : BuildingOfficeIcon; + return ; +} + export function ScopeSelect({ onSelect }: ScopeSelectProps) { const { organizations } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); @@ -39,10 +52,6 @@ export function ScopeSelect({ onSelect }: ScopeSelectProps) { onSelect?.(); }; - const CurScopeEntityFallBackIcon = selectedOrgId - ? BuildingOfficeIcon - : UserCircleIcon; - const selectedDisplay = currentOrg ?? { name: "Personal", iconUrl: null, @@ -53,15 +62,7 @@ export function ScopeSelect({ onSelect }: ScopeSelectProps) {
- {selectedDisplay?.iconUrl ? ( - - ) : ( - - )} + {getOrgIcon(selectedDisplay)} {selectedDisplay?.name || "Select Organization"} @@ -73,15 +74,7 @@ export function ScopeSelect({ onSelect }: ScopeSelectProps) { {organizations.map((org) => (
- {org.iconUrl ? ( - - ) : ( - - )} + {getOrgIcon(org)} {org.name}
From bf470aecda7121996b893de2a21f76b07ea084ba Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sun, 22 Jun 2025 16:57:48 -0700 Subject: [PATCH 40/46] feat: new rules --- .../rules/github-pr-documentation-updater.md | 7 +++ .continue/rules/pure-function-unit-tests.md | 1 + .../vs-code-commands-helper-functions.md | 5 ++ extensions/intellij/rules.md | 56 +++++++++++++++++++ extensions/vscode/package-lock.json | 4 +- packages/config-yaml/package-lock.json | 4 +- 6 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 .continue/rules/github-pr-documentation-updater.md create mode 100644 .continue/rules/pure-function-unit-tests.md create mode 100644 .continue/rules/vs-code-commands-helper-functions.md create mode 100644 extensions/intellij/rules.md diff --git a/.continue/rules/github-pr-documentation-updater.md b/.continue/rules/github-pr-documentation-updater.md new file mode 100644 index 000000000..3560ccdad --- /dev/null +++ b/.continue/rules/github-pr-documentation-updater.md @@ -0,0 +1,7 @@ +--- +name: Update docs from GitHub PR +description: Provide a PR link to update docs based on +alwaysApply: false +--- + +When provided with a GitHub PR URL, use the GitHub CLI (`gh pr view --json title,body,commits,files,additions,deletions,changedFiles`) to fetch comprehensive PR details including title, description, commits, changed files, and diff statistics. Analyze the PR content to identify what documentation in the `docs` folder needs to be updated, created, or modified. Update relevant documentation files to reflect the changes, new features, bug fixes, or improvements described in the PR. Ensure documentation changes are accurate, well-structured, and maintain consistency with existing docs formatting and style. diff --git a/.continue/rules/pure-function-unit-tests.md b/.continue/rules/pure-function-unit-tests.md new file mode 100644 index 000000000..68a1ff983 --- /dev/null +++ b/.continue/rules/pure-function-unit-tests.md @@ -0,0 +1 @@ +Always create comprehensive unit tests for new pure functions. Tests should cover normal cases, edge cases, and boundary conditions. diff --git a/.continue/rules/vs-code-commands-helper-functions.md b/.continue/rules/vs-code-commands-helper-functions.md new file mode 100644 index 000000000..bf2e0a8da --- /dev/null +++ b/.continue/rules/vs-code-commands-helper-functions.md @@ -0,0 +1,5 @@ +--- +globs: "extensions/vscode/src/commands.ts" +--- + +When adding new commands to the commands map, always create a separate helper function for the command logic instead of defining it inline. Follow the pattern of existing commands like `streamInlineEdit` - define the helper function below the commands map, then call it from within the command entry. diff --git a/extensions/intellij/rules.md b/extensions/intellij/rules.md new file mode 100644 index 000000000..1f95724c9 --- /dev/null +++ b/extensions/intellij/rules.md @@ -0,0 +1,56 @@ +# Continue JetBrains Extension + +## Project Purpose + +JetBrains/IntelliJ extension for Continue AI code assistant. Provides chat, autocomplete, inline edit, and agent features within JetBrains IDEs. + +## Architecture + +- **Language**: Kotlin (JDK 17), Gradle build +- **Communication**: stdin/stdout message passing with core binary from `../../binary` +- **UI**: Embeds React webview from `../../gui` +- **Platform**: IntelliJ Platform Plugin (IDEA, PyCharm, WebStorm, etc.) + +## Key Source Structure + +``` +src/main/kotlin/com/github/continuedev/continueintellijextension/ +├── continue/ # Core integration (CoreMessenger, IntelliJIde, IdeProtocolClient) +├── autocomplete/ # Code completion logic +├── editor/ # Diff handling, inline edits +├── toolWindow/ # Main UI panel +├── services/ # Settings, plugin lifecycle +├── actions/ # Keyboard shortcuts, menu actions +├── protocol/ # Message type definitions +└── constants/ # App constants, paths + +src/main/resources/ +├── META-INF/plugin.xml # Plugin configuration +└── webview/ # Embedded React UI assets +``` + +## Core Files + +- `IntelliJIde.kt`: Main IDE interface implementation +- `CoreMessenger.kt`: Binary communication handler +- `plugin.xml`: Plugin manifest and extension points +- `build.gradle.kts`: Build configuration +- `ContinuePluginService.kt`: Main service orchestrator + +## Message Protocol + +JSON messages between Extension ↔ Core ↔ GUI. Message types in `constants/MessageTypes.kt`. Extension relays messages between core binary and webview. + +## Testing + +- Unit tests: `src/test/kotlin/` +- E2E tests: UI automation with intellij-ui-test-robot +- Test command: `./gradlew test` +- Debug: `runIde` Gradle task + +## Key Integration Points + +- File operations via IntelliJ VFS +- Editor integration for diffs/autocomplete +- Git operations for repository context +- Settings via IntelliJ platform storage diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 199c669c7..1d493deef 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.48", + "version": "1.1.49", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.48", + "version": "1.1.49", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", diff --git a/packages/config-yaml/package-lock.json b/packages/config-yaml/package-lock.json index 492e0eaa5..6d02d51d8 100644 --- a/packages/config-yaml/package-lock.json +++ b/packages/config-yaml/package-lock.json @@ -1,12 +1,12 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.93", + "version": "1.0.94", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/config-yaml", - "version": "1.0.93", + "version": "1.0.94", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", From 084f6cc27eeb2f784b522da2e835a9835dc03564 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 23 Jun 2025 16:25:45 +0530 Subject: [PATCH 41/46] add enable reasoning button --- gui/src/components/mainInput/InputToolbar.tsx | 30 ++++++++++++++++++- gui/src/hooks/ParallelListeners.tsx | 10 ++++++- gui/src/redux/slices/sessionSlice.ts | 5 ++++ gui/src/redux/thunks/streamNormalInput.ts | 8 +++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx index 23d242ae2..0dfbcd493 100644 --- a/gui/src/components/mainInput/InputToolbar.tsx +++ b/gui/src/components/mainInput/InputToolbar.tsx @@ -1,4 +1,8 @@ -import { AtSymbolIcon, PhotoIcon } from "@heroicons/react/24/outline"; +import { + AtSymbolIcon, + LightBulbIcon, + PhotoIcon, +} from "@heroicons/react/24/outline"; import { InputModifiers } from "core"; import { modelSupportsImages, modelSupportsTools } from "core/llm/autodetect"; import { useContext, useRef } from "react"; @@ -10,8 +14,10 @@ import { selectCurrentToolCallApplyState, } from "../../redux/selectors/selectCurrentToolCall"; import { selectSelectedChatModel } from "../../redux/slices/configSlice"; +import { setHasReasoningEnabled } from "../../redux/slices/sessionSlice"; import { exitEdit } from "../../redux/thunks/edit"; import { getAltKeyLabel, isMetaEquivalentKeyPressed } from "../../util"; +import { cn } from "../../util/cn"; import { ToolTip } from "../gui/Tooltip"; import ModelSelect from "../modelSelection/ModelSelect"; import { ModeSelect } from "../ModeSelect"; @@ -51,6 +57,9 @@ function InputToolbar(props: InputToolbarProps) { const currentToolCallApplyState = useAppSelector( selectCurrentToolCallApplyState, ); + const hasReasoningEnabled = useAppSelector( + (store) => store.session.hasReasoningEnabled, + ); const isEnterDisabled = props.disabled || @@ -143,6 +152,25 @@ function InputToolbar(props: InputToolbarProps) { )} + {defaultModel?.provider === "anthropic" && ( + + dispatch(setHasReasoningEnabled(!hasReasoningEnabled)) + } + > + + + + Use Model Reasoning + + + )}
diff --git a/gui/src/hooks/ParallelListeners.tsx b/gui/src/hooks/ParallelListeners.tsx index a283ed969..8d0fef86d 100644 --- a/gui/src/hooks/ParallelListeners.tsx +++ b/gui/src/hooks/ParallelListeners.tsx @@ -20,6 +20,7 @@ import { import { acceptToolCall, addContextItemsAtIndex, + setHasReasoningEnabled, updateApplyState, } from "../redux/slices/sessionSlice"; import { setTTSActive } from "../redux/slices/uiSlice"; @@ -86,6 +87,13 @@ function ParallelListeners() { setLocalStorage("fontSize", configResult.config.ui.fontSize); document.body.style.fontSize = `${configResult.config.ui.fontSize}px`; } + + if ( + configResult.config?.selectedModelByRole.chat?.completionOptions + ?.reasoning + ) { + dispatch(setHasReasoningEnabled(true)); + } }, [dispatch, hasDoneInitialConfigLoad], ); @@ -241,7 +249,7 @@ function ParallelListeners() { dispatch(updateEditStateApplyState(state)); if (state.status === "closed") { - dispatch(exitEdit({})); + void dispatch(exitEdit({})); } } else { // chat or agent diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 37eba4b4f..6803947fb 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -51,6 +51,7 @@ type SessionState = { curIndex: number; }; newestToolbarPreviewForInput: Record; + hasReasoningEnabled?: boolean; }; const initialState: SessionState = { @@ -594,6 +595,9 @@ export const sessionSlice = createSlice({ setIsInEdit: (state, action: PayloadAction) => { state.isInEdit = action.payload; }, + setHasReasoningEnabled: (state, action: PayloadAction) => { + state.hasReasoningEnabled = action.payload; + }, setNewestToolbarPreviewForInput: ( state, { @@ -691,6 +695,7 @@ export const { deleteSessionMetadata, setNewestToolbarPreviewForInput, setIsInEdit, + setHasReasoningEnabled, } = sessionSlice.actions; export const { selectIsGatheringContext } = sessionSlice.selectors; diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 441cf3c20..6d84f800e 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -45,6 +45,14 @@ export const streamNormalInput = createAsyncThunk< }; } + if (state.session.hasReasoningEnabled) { + completionOptions = { + ...completionOptions, + reasoning: true, + reasoningBudgetTokens: completionOptions.reasoningBudgetTokens ?? 2048, + }; + } + // Send request const gen = extra.ideMessenger.llmStreamChat( { From 2574a8b4b57d1287f0c75b6519606130b996d9f3 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 23 Jun 2025 18:41:59 +0530 Subject: [PATCH 42/46] rename to vitest --- core/commands/{util.test.ts => util.vitest.ts} | 0 core/control-plane/mdm/{mdm.test.ts => mdm.vitest.ts} | 0 core/data/{log.test.ts => log.vitest.ts} | 0 core/diff/{myers.test.ts => myers.vitest.ts} | 0 core/diff/{streamDiff.test.ts => streamDiff.vitest.ts} | 0 core/diff/{util.test.ts => util.vitest.ts} | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename core/commands/{util.test.ts => util.vitest.ts} (100%) rename core/control-plane/mdm/{mdm.test.ts => mdm.vitest.ts} (100%) rename core/data/{log.test.ts => log.vitest.ts} (100%) rename core/diff/{myers.test.ts => myers.vitest.ts} (100%) rename core/diff/{streamDiff.test.ts => streamDiff.vitest.ts} (100%) rename core/diff/{util.test.ts => util.vitest.ts} (100%) diff --git a/core/commands/util.test.ts b/core/commands/util.vitest.ts similarity index 100% rename from core/commands/util.test.ts rename to core/commands/util.vitest.ts diff --git a/core/control-plane/mdm/mdm.test.ts b/core/control-plane/mdm/mdm.vitest.ts similarity index 100% rename from core/control-plane/mdm/mdm.test.ts rename to core/control-plane/mdm/mdm.vitest.ts diff --git a/core/data/log.test.ts b/core/data/log.vitest.ts similarity index 100% rename from core/data/log.test.ts rename to core/data/log.vitest.ts diff --git a/core/diff/myers.test.ts b/core/diff/myers.vitest.ts similarity index 100% rename from core/diff/myers.test.ts rename to core/diff/myers.vitest.ts diff --git a/core/diff/streamDiff.test.ts b/core/diff/streamDiff.vitest.ts similarity index 100% rename from core/diff/streamDiff.test.ts rename to core/diff/streamDiff.vitest.ts diff --git a/core/diff/util.test.ts b/core/diff/util.vitest.ts similarity index 100% rename from core/diff/util.test.ts rename to core/diff/util.vitest.ts From 7f541da7ecaec0dee26d51218ccb22fa534e3dc4 Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 23 Jun 2025 09:23:00 -0700 Subject: [PATCH 43/46] improv: naming --- core/index.d.ts | 2 +- core/llm/rules/getSystemMessageWithRules.ts | 44 +++++++++---------- .../rules/getSystemMessageWithRules.vitest.ts | 20 ++++----- core/tools/definitions/createRuleBlock.ts | 2 +- core/tools/implementations/createRuleBlock.ts | 8 ++-- docs/docs/customize/deep-dives/rules.mdx | 1 + .../src/markdown/createMarkdownRule.ts | 10 ++--- .../src/markdown/markdownToRule.ts | 4 +- packages/config-yaml/src/schemas/index.ts | 2 +- 9 files changed, 46 insertions(+), 47 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index 1c7f336f2..3dde3bc78 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1576,7 +1576,7 @@ export interface RuleWithSource { slug?: string; source: RuleSource; globs?: string | string[]; - patterns?: string | string[]; + regex?: string | string[]; rule: string; description?: string; ruleFile?: string; diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 62756923e..65c04f2a6 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -54,33 +54,33 @@ const matchesGlobs = ( }; /** - * Checks if file content matches any of the provided regex patterns + * Checks if file content matches any of the provided regex regex * * @param fileContent - The content of the file to check - * @param patterns - A single regex pattern string or array of regex pattern strings - * @returns true if the content matches any pattern (or if no patterns are provided), false otherwise + * @param regex - A single regex pattern string or array of regex pattern strings + * @returns true if the content matches any pattern (or if no regex is provided), false otherwise */ const contentMatchesPatterns = ( fileContent: string, - patterns: string | string[], + regex: string | string[], ): boolean => { // Handle single string pattern - if (typeof patterns === "string") { + if (typeof regex === "string") { try { - const regex = new RegExp(patterns); - return regex.test(fileContent); + const expression = new RegExp(regex); + return expression.test(fileContent); } catch (e) { - console.error(`Invalid regex pattern: ${patterns}`, e); + console.error(`Invalid regex pattern: ${regex}`, e); return false; } } - // Handle array of patterns - if (Array.isArray(patterns)) { - if (patterns.length === 0) return true; + // Handle array of regex + if (Array.isArray(regex)) { + if (regex.length === 0) return true; // Content must match at least one pattern - return patterns.some((pattern) => { + return regex.some((pattern) => { try { const regex = new RegExp(pattern); return regex.test(fileContent); @@ -145,11 +145,11 @@ const isGlobalRule = (rule: RuleWithSource): boolean => { return true; } - // Root-level rules with no globs or patterns are implicitly global + // Root-level rules with no globs or regex are implicitly global if ( isRootLevelRule(rule) && !rule.globs && - !rule.patterns && + !rule.regex && rule.alwaysApply !== false ) { return true; @@ -176,18 +176,18 @@ const checkGlobsAndPatterns = ({ return false; } - // Now check for pattern matches in file contents if patterns are specified - if (rule.patterns) { - // Check if any of the matching files also match the content patterns + // Now check for pattern matches in file contents if regex are specified + if (rule.regex) { + // Check if any of the matching files also match the content regex return matchingFiles.some((filePath) => { const content = fileContents[filePath]; - // If we don't have the content, we can't check patterns + // If we don't have the content, we can't check regex if (!content) return false; - return contentMatchesPatterns(content, rule.patterns!); + return contentMatchesPatterns(content, rule.regex!); }); } - // If we have no patterns or if we couldn't check patterns (no content), + // If we have no regex or if we couldn't check regex (no content), // just go with the glob matches return matchingFiles.length > 0; }; @@ -248,11 +248,11 @@ export const shouldApplyRule = ( }); } - // If alwaysApply is explicitly false, we need to check globs and/or patterns + // If alwaysApply is explicitly false, we need to check globs and/or regex if ( rule.alwaysApply === false && rule.globs === undefined && - rule.patterns === undefined + rule.regex === undefined ) { return false; } diff --git a/core/llm/rules/getSystemMessageWithRules.vitest.ts b/core/llm/rules/getSystemMessageWithRules.vitest.ts index 8425c8324..0b4444cd1 100644 --- a/core/llm/rules/getSystemMessageWithRules.vitest.ts +++ b/core/llm/rules/getSystemMessageWithRules.vitest.ts @@ -259,7 +259,7 @@ describe("Content pattern matching", () => { const reactComponentRule: RuleWithSource = { name: "React Component Rule", rule: "Follow React component standards", - patterns: "export (function|const) \\w+.*\\(", + regex: "export (function|const) \\w+.*\\(", source: "rules-block", ruleFile: "src/components/rules.md", }; @@ -286,12 +286,12 @@ describe("Content pattern matching", () => { ).toBe(false); }); - it("should support multiple regex patterns as an array", () => { - // Rule with multiple patterns + it("should support multiple regex regex as an array", () => { + // Rule with multiple regex const multiPatternRule: RuleWithSource = { name: "Multi-Pattern Rule", rule: "Apply to functions or classes", - patterns: ["function\\s+\\w+", "class\\s+\\w+"], + regex: ["function\\s+\\w+", "class\\s+\\w+"], source: "rules-block", ruleFile: "src/utils/rules.md", }; @@ -324,13 +324,13 @@ describe("Content pattern matching", () => { ).toBe(false); }); - it("should apply rules based on both globs and patterns when both are specified", () => { + it("should apply rules based on both globs and regex when both are specified", () => { // Rule with both glob and pattern restrictions const typescriptClassRule: RuleWithSource = { name: "TypeScript Class Rule", rule: "Follow class standards in TypeScript", globs: "**/*.ts", - patterns: "class\\s+\\w+", + regex: "class\\s+\\w+", source: "rules-block", ruleFile: "src/models/rules.md", }; @@ -369,7 +369,7 @@ describe("Content pattern matching", () => { const arrowFunctionRule: RuleWithSource = { name: "Arrow Function Rule", rule: "Use arrow functions for better this binding", - patterns: "const\\s+\\w+\\s*=\\s*\\(", + regex: "const\\s+\\w+\\s*=\\s*\\(", source: "rules-block", ruleFile: "src/utils/rules.md", }; @@ -426,12 +426,12 @@ describe("Content pattern matching", () => { expect(nonApplicableRules).toHaveLength(0); }); - it("should handle invalid regex patterns gracefully", () => { + it("should handle invalid regex regex gracefully", () => { // Rule with invalid regex pattern const invalidRegexRule: RuleWithSource = { name: "Invalid Regex Rule", rule: "This rule has an invalid regex pattern", - patterns: "([unclosed parenthesis", + regex: "([unclosed parenthesis", source: "rules-block", ruleFile: "src/utils/rules.md", }; @@ -452,7 +452,7 @@ describe("Content pattern matching", () => { const nestedPatternRule: RuleWithSource = { name: "Nested Pattern Rule", rule: "Apply only to model files with interfaces", - patterns: "interface\\s+\\w+", + regex: "interface\\s+\\w+", source: "rules-block", ruleFile: "src/models/rules.md", }; diff --git a/core/tools/definitions/createRuleBlock.ts b/core/tools/definitions/createRuleBlock.ts index 2afb19d70..dfb6294ae 100644 --- a/core/tools/definitions/createRuleBlock.ts +++ b/core/tools/definitions/createRuleBlock.ts @@ -37,7 +37,7 @@ export const createRuleBlock: Tool = { description: "Optional file patterns to which this rule applies (e.g. ['**/*.{ts,tsx}'] or ['src/**/*.ts', 'tests/**/*.ts'])", }, - patterns: { + regex: { type: "string", description: "Optional regex patterns to match against file content. Rule applies only to files whose content matches the pattern (e.g. 'useEffect' for React hooks or '\\bclass\\b' for class definitions)", diff --git a/core/tools/implementations/createRuleBlock.ts b/core/tools/implementations/createRuleBlock.ts index cfa60a5a3..06921f770 100644 --- a/core/tools/implementations/createRuleBlock.ts +++ b/core/tools/implementations/createRuleBlock.ts @@ -7,7 +7,7 @@ export type CreateRuleBlockArgs = Pick< Required, "rule" | "description" | "alwaysApply" | "name" > & - Pick; + Pick; export const createRuleBlockImpl: ToolImpl = async ( args: CreateRuleBlockArgs, @@ -19,9 +19,9 @@ export const createRuleBlockImpl: ToolImpl = async ( globs: args.globs, }; - // Add patterns if provided - if (args.patterns) { - options.patterns = args.patterns; + // Add regex if provided + if (args.regex) { + options.regex = args.regex; } const fileContent = createRuleMarkdown(args.name, args.rule, options); diff --git a/docs/docs/customize/deep-dives/rules.mdx b/docs/docs/customize/deep-dives/rules.mdx index 147606f85..bb0730afd 100644 --- a/docs/docs/customize/deep-dives/rules.mdx +++ b/docs/docs/customize/deep-dives/rules.mdx @@ -63,6 +63,7 @@ Rules blocks can be simple text, written in YAML configuration files, or as Mark - `name` (**required** for YAML): A display name/title for the rule - `globs` (optional): When files are provided as context that match this glob pattern, the rule will be included. This can be either a single pattern (e.g., `"**/*.{ts,tsx}"`) or an array of patterns (e.g., `["src/**/*.ts", "tests/**/*.ts"]`). +- `regex` (optional): When files are provided as context and their content matches this regex pattern, the rule will be included. This can be either a single pattern (e.g., `"^import .* from '.*';$"`) or an array of patterns (e.g., `["^import .* from '.*';$", "^export .* from '.*';$"]`). - `description` (optional): A description for the rule. Agents may read this description when `alwaysApply` is false to determine whether the rule should be pulled into context. - `alwaysApply`: true - Always include the rule, regardless of file context - `alwaysApply`: false - Included if globs exist AND match file context, or the agent decides to pull the rule into context based on it's description diff --git a/packages/config-yaml/src/markdown/createMarkdownRule.ts b/packages/config-yaml/src/markdown/createMarkdownRule.ts index 13cce86f4..0fdf522f8 100644 --- a/packages/config-yaml/src/markdown/createMarkdownRule.ts +++ b/packages/config-yaml/src/markdown/createMarkdownRule.ts @@ -34,7 +34,7 @@ export function createRuleMarkdown( options: { description?: string; globs?: string | string[]; - patterns?: string | string[]; + regex?: string | string[]; alwaysApply?: boolean; } = {}, ): string { @@ -45,11 +45,9 @@ export function createRuleMarkdown( typeof options.globs === "string" ? options.globs.trim() : options.globs; } - if (options.patterns) { - frontmatter.patterns = - typeof options.patterns === "string" - ? options.patterns.trim() - : options.patterns; + if (options.regex) { + frontmatter.regex = + typeof options.regex === "string" ? options.regex.trim() : options.regex; } if (options.description) { diff --git a/packages/config-yaml/src/markdown/markdownToRule.ts b/packages/config-yaml/src/markdown/markdownToRule.ts index 5bed93ac8..85d5b3036 100644 --- a/packages/config-yaml/src/markdown/markdownToRule.ts +++ b/packages/config-yaml/src/markdown/markdownToRule.ts @@ -7,7 +7,7 @@ import { RuleObject } from "../schemas/index.js"; export interface RuleFrontmatter { globs?: RuleObject["globs"]; - patterns?: RuleObject["patterns"]; + regex?: RuleObject["regex"]; name?: RuleObject["name"]; description?: RuleObject["description"]; alwaysApply?: RuleObject["alwaysApply"]; @@ -57,7 +57,7 @@ export function markdownToRule( name: frontmatter.name ?? packageIdentifierToDisplayName(id), rule: markdown, globs: frontmatter.globs, - patterns: frontmatter.patterns, + regex: frontmatter.regex, description: frontmatter.description, alwaysApply: frontmatter.alwaysApply, }; diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 14d4a7486..7a0a6562b 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -45,7 +45,7 @@ const ruleObjectSchema = z.object({ rule: z.string(), description: z.string().optional(), globs: z.union([z.string(), z.array(z.string())]).optional(), - patterns: z.union([z.string(), z.array(z.string())]).optional(), + regex: z.union([z.string(), z.array(z.string())]).optional(), alwaysApply: z.boolean().optional(), }); const ruleSchema = z.union([z.string(), ruleObjectSchema]); From be7c31779971dc9402d80b710cbd1f822987eaac Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 23 Jun 2025 09:42:00 -0700 Subject: [PATCH 44/46] improv: naming --- core/llm/rules/getSystemMessageWithRules.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index 65c04f2a6..c005a5f92 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -60,7 +60,7 @@ const matchesGlobs = ( * @param regex - A single regex pattern string or array of regex pattern strings * @returns true if the content matches any pattern (or if no regex is provided), false otherwise */ -const contentMatchesPatterns = ( +const contentMatchesRegex = ( fileContent: string, regex: string | string[], ): boolean => { @@ -158,7 +158,7 @@ const isGlobalRule = (rule: RuleWithSource): boolean => { return false; }; -const checkGlobsAndPatterns = ({ +const checkGlobsAndRegex = ({ rule, filePaths, fileContents, @@ -183,7 +183,7 @@ const checkGlobsAndPatterns = ({ const content = fileContents[filePath]; // If we don't have the content, we can't check regex if (!content) return false; - return contentMatchesPatterns(content, rule.regex!); + return contentMatchesRegex(content, rule.regex!); }); } @@ -241,7 +241,7 @@ export const shouldApplyRule = ( isFileInDirectory(filePath, ruleDirPath), ); - return checkGlobsAndPatterns({ + return checkGlobsAndRegex({ filePaths: filesInRuleDirectory, fileContents, rule, @@ -257,7 +257,7 @@ export const shouldApplyRule = ( return false; } - return checkGlobsAndPatterns({ + return checkGlobsAndRegex({ filePaths, fileContents, rule, From b7119ddb64857d9eb518e9806a0fd7004b4bb992 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 23 Jun 2025 10:11:53 -0700 Subject: [PATCH 45/46] rules for vs code and navigating user requests --- .continue/rules/navigating-responses.md | 4 ++++ extensions/vscode/rules.md | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 .continue/rules/navigating-responses.md create mode 100644 extensions/vscode/rules.md diff --git a/.continue/rules/navigating-responses.md b/.continue/rules/navigating-responses.md new file mode 100644 index 000000000..dadbd0f80 --- /dev/null +++ b/.continue/rules/navigating-responses.md @@ -0,0 +1,4 @@ +If the user's request is vague and you don't have enough information to confidently answer, you can either + +- In Chat OR Agent mode, stop and ask questions to clarify before proceeding +- In Agent mode, use tools to discover more information, starting with the glob/grep tools if available. diff --git a/extensions/vscode/rules.md b/extensions/vscode/rules.md new file mode 100644 index 000000000..865f0dac5 --- /dev/null +++ b/extensions/vscode/rules.md @@ -0,0 +1,6 @@ +The `extensions/vscode` folder contains code for the "Continue" VS Code Extension. Continue is a coding assistant extension which extends IDE functionality with AI. +Core IDE functionality, such as reading files, is implemented using the `VSCodeIDE` class. Code to enable editing/diff streaming into the editor, code suggestion autocompletion, and more can also be found in this directory. +Shared code that has abstract logic for the extension is in `core/`. Avoid importing code from `core/` directly where possible. Core is designed to be bundalable as a binary. Use `core.invoke` to send messages to the + +- see `core/protocol/core.ts` for a list of commands VS Code can post/request to Core +- see `core/portocol/ide.ts` for a list of commands/message types core can post/request to VS Code From 393bf0854a7c9aa8e8d3f67cac8c93b2a7ee18b5 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 23 Jun 2025 11:15:51 -0700 Subject: [PATCH 46/46] nate's feedback --- .../AssistantAndOrgListbox/AccountOption.tsx | 11 ++++++- .../AssistantOptions.tsx | 2 +- .../OrganizationInfo.tsx | 22 -------------- .../AssistantAndOrgListbox/index.tsx | 30 ++++++++++++++----- 4 files changed, 34 insertions(+), 31 deletions(-) delete mode 100644 gui/src/components/AssistantAndOrgListbox/OrganizationInfo.tsx diff --git a/gui/src/components/AssistantAndOrgListbox/AccountOption.tsx b/gui/src/components/AssistantAndOrgListbox/AccountOption.tsx index 8f4f8e11e..98e8adbc5 100644 --- a/gui/src/components/AssistantAndOrgListbox/AccountOption.tsx +++ b/gui/src/components/AssistantAndOrgListbox/AccountOption.tsx @@ -1,3 +1,7 @@ +import { + ArrowRightEndOnRectangleIcon, + UserCircleIcon as UserCircleIconOutline, +} from "@heroicons/react/24/outline"; import { isOnPremSession } from "core/control-plane/AuthTypes"; import { useAuth } from "../../context/Auth"; import { ListboxOption, useFontSize } from "../ui"; @@ -28,13 +32,18 @@ export function AccountOption({ onClose }: AccountOptionProps) {
+ {session ? ( + + ) : ( + + )} {session ? "Log out" : "Sign in"}
diff --git a/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx b/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx index 304444b23..869aa5c67 100644 --- a/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx +++ b/gui/src/components/AssistantAndOrgListbox/AssistantOptions.tsx @@ -19,7 +19,7 @@ export function AssistantOptions({ return ( <> {/* Assistants Section Header */} -
+
-
-
- - {!session && ( - (Signed out) - )} -
- -
-
- ); -} diff --git a/gui/src/components/AssistantAndOrgListbox/index.tsx b/gui/src/components/AssistantAndOrgListbox/index.tsx index ee175a725..dcf0bb4a4 100644 --- a/gui/src/components/AssistantAndOrgListbox/index.tsx +++ b/gui/src/components/AssistantAndOrgListbox/index.tsx @@ -1,4 +1,5 @@ import { PlusIcon } from "@heroicons/react/24/outline"; +import { isOnPremSession } from "core/control-plane/AuthTypes"; import { useContext, useEffect, useRef } from "react"; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; @@ -18,7 +19,7 @@ import { } from "../ui"; import { AccountOption } from "./AccountOption"; import { AssistantOptions } from "./AssistantOptions"; -import { OrganizationInfo } from "./OrganizationInfo"; +import { ScopeSelect } from "./ScopeSelect"; import { SelectedAssistantButton } from "./SelectedAssistantButton"; export function AssistantAndOrgListbox() { @@ -27,9 +28,12 @@ export function AssistantAndOrgListbox() { const currentOrg = useAppSelector(selectCurrentOrg); const ideMessenger = useContext(IdeMessengerContext); const { isToolbarExpanded } = useLump(); - const { profiles, selectedProfile, session, login } = useAuth(); + const { profiles, selectedProfile, session, login, organizations } = + useAuth(); const smallFont = useFontSize(-3); const tinyFont = useFontSize(-4); + const shouldRenderOrgInfo = + session && organizations.length > 1 && !isOnPremSession(session); function close() { // Close the listbox by clicking outside or programmatically @@ -114,7 +118,19 @@ export function AssistantAndOrgListbox() { - + {shouldRenderOrgInfo && ( +
+
+ + {session.account.id} + + + +
+
+ )} login(false)} > -
- New Assistant -
+ New Assistant +