From af30fbe360def278cd56858d88c5373c80a2dab6 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 27 May 2025 10:19:31 -0700 Subject: [PATCH 01/22] feat: `requestRule` tool --- core/config/load.ts | 4 +- core/config/profile/doLoadConfig.ts | 24 +++++++++ core/config/yaml/loadYaml.ts | 4 +- core/index.d.ts | 6 +++ core/tools/builtIn.ts | 3 +- core/tools/callTool.ts | 3 ++ core/tools/definitions/requestRule.ts | 60 +++++++++++++++++++++++ core/tools/implementations/requestRule.ts | 19 +++++++ core/tools/index.ts | 8 ++- gui/src/redux/slices/uiSlice.ts | 1 + gui/src/redux/thunks/callCurrentTool.ts | 4 +- 11 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 core/tools/definitions/requestRule.ts create mode 100644 core/tools/implementations/requestRule.ts diff --git a/core/config/load.ts b/core/config/load.ts index de08ecfc7..e2f3d71c3 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -51,7 +51,6 @@ import { LLMReranker } from "../llm/llms/llm"; import TransformersJsEmbeddingsProvider from "../llm/llms/TransformersJsEmbeddingsProvider"; import { slashCommandFromPromptFileV1 } from "../promptFiles/v1/slashCommandFromPromptFile"; import { getAllPromptFiles } from "../promptFiles/v2/getPromptFiles"; -import { allTools } from "../tools"; import { copyOf } from "../util"; import { GlobalContext } from "../util/GlobalContext"; import mergeJson from "../util/merge"; @@ -67,6 +66,7 @@ import { } from "../util/paths"; import { localPathToUri } from "../util/pathToUri"; +import { baseToolDefinitions } from "../tools"; import { modifyAnyConfigWithSharedConfig } from "./sharedConfig"; import { getModelByRole, @@ -529,7 +529,7 @@ async function intermediateToFinalConfig({ const continueConfig: ContinueConfig = { ...config, contextProviders, - tools: [...allTools], + tools: baseToolDefinitions, mcpServerStatuses: [], slashCommands: config.slashCommands ?? [], modelsByRole: { diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index cc1b98e49..2a66398b7 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -25,6 +25,7 @@ import { ControlPlaneClient } from "../../control-plane/client.js"; import { getControlPlaneEnv } from "../../control-plane/env.js"; import { TeamAnalytics } from "../../control-plane/TeamAnalytics.js"; import ContinueProxy from "../../llm/llms/stubs/ContinueProxy"; +import { getConfigDependentToolDefinitions } from "../../tools"; import { encodeMCPToolUri } from "../../tools/callTool"; import { getConfigJsonPath, getConfigYamlPath } from "../../util/paths"; import { localPathOrUriToPath } from "../../util/pathToUri"; @@ -193,6 +194,8 @@ export default async function doLoadConfig(options: { } } + newConfig.tools.push(...getConfigDependentTools(newConfig)); + // Detect duplicate tool names const counts: Record = {}; newConfig.tools.forEach((tool) => { @@ -202,6 +205,7 @@ export default async function doLoadConfig(options: { counts[tool.function.name] = 1; } }); + Object.entries(counts).forEach(([toolName, count]) => { if (count > 1) { errors!.push({ @@ -309,3 +313,23 @@ async function getWorkspaceConfigs(ide: IDE): Promise { return workspaceConfigs; } + +/** + * Returns a list of tools that depend on the configuration. + * @param {ContinueConfig} config - The configuration object. + * @returns {Tool[]} Array of tools + * @todo Why is `doLoadConfig` getting called multiple times causing us to have duplicates here unless we filter + */ +function getConfigDependentTools(config: ContinueConfig): Tool[] { + const configDependentTools = getConfigDependentToolDefinitions({ + rules: config.rules, + }); + + return configDependentTools.filter( + (configTool) => + !config.tools.some( + (existingTool) => + existingTool.function.name === configTool.function.name, + ), + ); +} diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 0a0dd03fc..24a60f855 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -36,11 +36,11 @@ import FreeTrial from "../../llm/llms/FreeTrial"; import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider"; import { slashCommandFromPromptFileV1 } from "../../promptFiles/v1/slashCommandFromPromptFile"; import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles"; -import { allTools } from "../../tools"; import { GlobalContext } from "../../util/GlobalContext"; import { modifyAnyConfigWithSharedConfig } from "../sharedConfig"; import { getControlPlaneEnvSync } from "../../control-plane/env"; +import { baseToolDefinitions } from "../../tools"; import { getCleanUriPath } from "../../util/uri"; import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; import { LocalPlatformClient } from "./LocalPlatformClient"; @@ -193,7 +193,7 @@ async function configYamlToContinueConfig(options: { const continueConfig: ContinueConfig = { slashCommands: [], - tools: [...allTools], + tools: baseToolDefinitions, mcpServerStatuses: [], contextProviders: [], modelsByRole: { diff --git a/core/index.d.ts b/core/index.d.ts index 7ff7f0f20..cb3057b95 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1003,6 +1003,12 @@ interface ToolChoice { }; } +export interface ConfigDependentToolParams { + rules: RuleWithSource[]; +} + +export type GetTool = (params: ConfigDependentToolParams) => Tool; + export interface BaseCompletionOptions { temperature?: number; topP?: number; diff --git a/core/tools/builtIn.ts b/core/tools/builtIn.ts index 9f70b1a22..892cc3ff8 100644 --- a/core/tools/builtIn.ts +++ b/core/tools/builtIn.ts @@ -10,6 +10,7 @@ export enum BuiltInToolNames { ViewDiff = "builtin_view_diff", LSTool = "builtin_ls", CreateRuleBlock = "builtin_create_rule_block", + RequestRule = "builtin_request_rule", // excluded from allTools for now ViewRepoMap = "builtin_view_repo_map", @@ -18,4 +19,4 @@ export enum BuiltInToolNames { export const BUILT_IN_GROUP_NAME = "Built-In"; -export const CLIENT_TOOLS = [BuiltInToolNames.EditExistingFile]; +export const CLIENT_TOOLS_IMPLS = [BuiltInToolNames.EditExistingFile]; diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 34501550b..243c162bb 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -10,6 +10,7 @@ import { grepSearchImpl } from "./implementations/grepSearch"; import { lsToolImpl } from "./implementations/lsTool"; import { readCurrentlyOpenFileImpl } from "./implementations/readCurrentlyOpenFile"; import { readFileImpl } from "./implementations/readFile"; +import { requestRuleImpl } from "./implementations/requestRule"; import { runTerminalCommandImpl } from "./implementations/runTerminalCommand"; import { searchWebImpl } from "./implementations/searchWeb"; import { viewDiffImpl } from "./implementations/viewDiff"; @@ -157,6 +158,8 @@ async function callBuiltInTool( return await readCurrentlyOpenFileImpl(args, extras); case BuiltInToolNames.CreateRuleBlock: return await createRuleBlockImpl(args, extras); + case BuiltInToolNames.RequestRule: + return await requestRuleImpl(args, extras); default: throw new Error(`Tool "${functionName}" not found`); } diff --git a/core/tools/definitions/requestRule.ts b/core/tools/definitions/requestRule.ts new file mode 100644 index 000000000..650ab4162 --- /dev/null +++ b/core/tools/definitions/requestRule.ts @@ -0,0 +1,60 @@ +import { ConfigDependentToolParams, GetTool } from "../.."; +import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; + +export interface RequestRuleArgs { + filepath: string; + name: string; +} + +export function getRequestRuleDescription( + rules: ConfigDependentToolParams["rules"], +): string { + // Must be explicitly false + const agentRequestedRules = rules.filter( + (rule) => rule.alwaysApply === false, + ); + + const prefix = + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n"; + + const body = agentRequestedRules + .map( + (rule) => + `Rule: ${rule.name}\nDescription: ${rule.description}\nFilepath: ${rule.ruleFile}`, + ) + .join("\n\n"); + + if (body.length === 0) { + return prefix + "No rules available."; + } + + return prefix + body; +} + +export const requestRuleTool: GetTool = ({ rules }) => ({ + type: "function", + displayTitle: "Request Rules", + wouldLikeTo: "request rule {{{ name }}}", + isCurrently: "reading rule {{{ name }}}", + hasAlready: "read rule {{{ name }}}", + group: BUILT_IN_GROUP_NAME, + readonly: false, + function: { + name: BuiltInToolNames.RequestRule, + description: getRequestRuleDescription(rules), + parameters: { + type: "object", + required: ["name", "filepath"], + properties: { + filepath: { + type: "string", + description: "The path of the rule file", + }, + name: { + type: "string", + description: "Name of the rule", + }, + }, + }, + }, +}); diff --git a/core/tools/implementations/requestRule.ts b/core/tools/implementations/requestRule.ts new file mode 100644 index 000000000..ac34f66e5 --- /dev/null +++ b/core/tools/implementations/requestRule.ts @@ -0,0 +1,19 @@ +import { ToolImpl } from "."; +import { parseMarkdownRule } from "../../config/markdown/parseMarkdownRule"; + +export const requestRuleImpl: ToolImpl = async (args, extras) => { + const fileContent = await extras.ide.readFile(args.filepath); + const { markdown, frontmatter } = parseMarkdownRule(fileContent); + + return [ + { + name: frontmatter.name ?? "", + description: frontmatter.description ?? "", + content: markdown, + uri: { + type: "file", + value: args.filepath, + }, + }, + ]; +}; diff --git a/core/tools/index.ts b/core/tools/index.ts index d89cf8744..f7ed3be4b 100644 --- a/core/tools/index.ts +++ b/core/tools/index.ts @@ -1,3 +1,4 @@ +import { ConfigDependentToolParams, Tool } from ".."; import { createNewFileTool } from "./definitions/createNewFile"; import { createRuleBlock } from "./definitions/createRuleBlock"; import { editFileTool } from "./definitions/editFile"; @@ -6,11 +7,12 @@ import { grepSearchTool } from "./definitions/grepSearch"; import { lsTool } from "./definitions/lsTool"; import { readCurrentlyOpenFileTool } from "./definitions/readCurrentlyOpenFile"; import { readFileTool } from "./definitions/readFile"; +import { requestRuleTool } from "./definitions/requestRule"; import { runTerminalCommandTool } from "./definitions/runTerminalCommand"; import { searchWebTool } from "./definitions/searchWeb"; import { viewDiffTool } from "./definitions/viewDiff"; -export const allTools = [ +export const baseToolDefinitions = [ readFileTool, editFileTool, createNewFileTool, @@ -26,3 +28,7 @@ export const allTools = [ // viewSubdirectoryTool, // viewRepoMapTool, ]; + +export const getConfigDependentToolDefinitions = ( + params: ConfigDependentToolParams, +): Tool[] => [requestRuleTool(params)]; diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index 4105d3319..d995ab8eb 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -56,6 +56,7 @@ export const uiSlice = createSlice({ [BuiltInToolNames.ViewDiff]: "allowedWithoutPermission", [BuiltInToolNames.LSTool]: "allowedWithoutPermission", [BuiltInToolNames.CreateRuleBlock]: "allowedWithPermission", + [BuiltInToolNames.RequestRule]: "allowedWithoutPermission", }, toolGroupSettings: { [BUILT_IN_GROUP_NAME]: "include", diff --git a/gui/src/redux/thunks/callCurrentTool.ts b/gui/src/redux/thunks/callCurrentTool.ts index f6f408238..84270fdd8 100644 --- a/gui/src/redux/thunks/callCurrentTool.ts +++ b/gui/src/redux/thunks/callCurrentTool.ts @@ -1,6 +1,6 @@ import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit"; import { ContextItem } from "core"; -import { CLIENT_TOOLS } from "core/tools/builtIn"; +import { CLIENT_TOOLS_IMPLS } from "core/tools/builtIn"; import { callClientTool } from "../../util/clientTools/callClientTool"; import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; import { selectSelectedChatModel } from "../slices/configSlice"; @@ -51,7 +51,7 @@ export const callCurrentTool = createAsyncThunk( // Errors that occur outside specifically calling the tool // Should not be caught here - should be handled as normal stream errors if ( - CLIENT_TOOLS.find( + CLIENT_TOOLS_IMPLS.find( (toolName) => toolName === toolCallState.toolCall.function.name, ) ) { From 4ddd2755996012677c15069648158bd4334fa3dd Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 27 May 2025 13:12:01 -0700 Subject: [PATCH 02/22] fix: spread tool degs --- core/config/load.ts | 2 +- core/config/profile/doLoadConfig.ts | 26 +++++--------------------- core/config/yaml/loadYaml.ts | 2 +- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index e2f3d71c3..6f63374e5 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -529,7 +529,7 @@ async function intermediateToFinalConfig({ const continueConfig: ContinueConfig = { ...config, contextProviders, - tools: baseToolDefinitions, + tools: [...baseToolDefinitions], mcpServerStatuses: [], slashCommands: config.slashCommands ?? [], modelsByRole: { diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index 2a66398b7..cfaa38ffa 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -194,7 +194,11 @@ export default async function doLoadConfig(options: { } } - newConfig.tools.push(...getConfigDependentTools(newConfig)); + newConfig.tools.push( + ...getConfigDependentToolDefinitions({ + rules: newConfig.rules, + }), + ); // Detect duplicate tool names const counts: Record = {}; @@ -313,23 +317,3 @@ async function getWorkspaceConfigs(ide: IDE): Promise { return workspaceConfigs; } - -/** - * Returns a list of tools that depend on the configuration. - * @param {ContinueConfig} config - The configuration object. - * @returns {Tool[]} Array of tools - * @todo Why is `doLoadConfig` getting called multiple times causing us to have duplicates here unless we filter - */ -function getConfigDependentTools(config: ContinueConfig): Tool[] { - const configDependentTools = getConfigDependentToolDefinitions({ - rules: config.rules, - }); - - return configDependentTools.filter( - (configTool) => - !config.tools.some( - (existingTool) => - existingTool.function.name === configTool.function.name, - ), - ); -} diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 24a60f855..daeecf57e 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -193,7 +193,7 @@ async function configYamlToContinueConfig(options: { const continueConfig: ContinueConfig = { slashCommands: [], - tools: baseToolDefinitions, + tools: [...baseToolDefinitions], mcpServerStatuses: [], contextProviders: [], modelsByRole: { From ae5b18b10daa493e43b31c9888677f8b12e926eb Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 27 May 2025 14:45:58 -0700 Subject: [PATCH 03/22] Update requestRule.ts --- core/tools/definitions/requestRule.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/tools/definitions/requestRule.ts b/core/tools/definitions/requestRule.ts index 650ab4162..569fd794a 100644 --- a/core/tools/definitions/requestRule.ts +++ b/core/tools/definitions/requestRule.ts @@ -9,9 +9,9 @@ export interface RequestRuleArgs { export function getRequestRuleDescription( rules: ConfigDependentToolParams["rules"], ): string { - // Must be explicitly false + // Must be explicitly false and no globs const agentRequestedRules = rules.filter( - (rule) => rule.alwaysApply === false, + (rule) => rule.alwaysApply === false && !rule.globs, ); const prefix = From 03e75521cdee2c6fca95e547ac55c3b62af10347 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 27 May 2025 14:50:59 -0700 Subject: [PATCH 04/22] Create requestRule.test.ts --- core/tools/definitions/requestRule.test.ts | 253 +++++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 core/tools/definitions/requestRule.test.ts diff --git a/core/tools/definitions/requestRule.test.ts b/core/tools/definitions/requestRule.test.ts new file mode 100644 index 000000000..49aac9c6e --- /dev/null +++ b/core/tools/definitions/requestRule.test.ts @@ -0,0 +1,253 @@ +import { getRequestRuleDescription } from "./requestRule"; +import { RuleWithSource } from "../.."; + +describe("getRequestRuleDescription", () => { + it("should return no rules message when no agent-requested rules exist", () => { + const rules: RuleWithSource[] = [ + { + name: "Always Apply Rule", + description: "This rule always applies", + source: "default-chat", + rule: "Always use semicolons", + alwaysApply: true, + ruleFile: "/path/to/rule1.md", + }, + { + name: "Rule with Globs", + description: "This rule has globs", + source: "rules-block", + rule: "Use TypeScript", + globs: "**/*.ts", + ruleFile: "/path/to/rule2.md", + }, + ]; + + const result = getRequestRuleDescription(rules); + + expect(result).toBe( + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\nNo rules available." + ); + }); + + it("should return formatted rules when agent-requested rules exist", () => { + const rules: RuleWithSource[] = [ + { + name: "Agent Rule 1", + description: "First agent-requested rule", + source: "rules-block", + rule: "Use consistent formatting", + alwaysApply: false, + ruleFile: "/path/to/agent-rule1.md", + }, + { + name: "Agent Rule 2", + description: "Second agent-requested rule", + source: "default-agent", + rule: "Follow naming conventions", + alwaysApply: false, + ruleFile: "/path/to/agent-rule2.md", + }, + // These should be filtered out + { + name: "Always Apply Rule", + description: "This rule always applies", + source: "default-chat", + rule: "Always use semicolons", + alwaysApply: true, + ruleFile: "/path/to/rule1.md", + }, + { + name: "Rule with Globs", + description: "This rule has globs", + source: "rules-block", + rule: "Use TypeScript", + globs: "**/*.ts", + ruleFile: "/path/to/rule2.md", + }, + ]; + + const result = getRequestRuleDescription(rules); + + const expected = + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + + "Rule: Agent Rule 1\n" + + "Description: First agent-requested rule\n" + + "Filepath: /path/to/agent-rule1.md\n\n" + + "Rule: Agent Rule 2\n" + + "Description: Second agent-requested rule\n" + + "Filepath: /path/to/agent-rule2.md"; + + expect(result).toBe(expected); + }); + + it("should handle rules with missing description", () => { + const rules: RuleWithSource[] = [ + { + name: "Rule Without Description", + source: "rules-block", + rule: "Some rule content", + alwaysApply: false, + ruleFile: "/path/to/no-desc-rule.md", + }, + ]; + + const result = getRequestRuleDescription(rules); + + const expected = + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + + "Rule: Rule Without Description\n" + + "Description: undefined\n" + + "Filepath: /path/to/no-desc-rule.md"; + + expect(result).toBe(expected); + }); + + it("should handle rules with missing name", () => { + const rules: RuleWithSource[] = [ + { + description: "Rule without name", + source: "rules-block", + rule: "Some rule content", + alwaysApply: false, + ruleFile: "/path/to/no-name-rule.md", + }, + ]; + + const result = getRequestRuleDescription(rules); + + const expected = + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + + "Rule: undefined\n" + + "Description: Rule without name\n" + + "Filepath: /path/to/no-name-rule.md"; + + expect(result).toBe(expected); + }); + + it("should handle rules with missing ruleFile", () => { + const rules: RuleWithSource[] = [ + { + name: "Rule Without File", + description: "Rule without file path", + source: "rules-block", + rule: "Some rule content", + alwaysApply: false, + }, + ]; + + const result = getRequestRuleDescription(rules); + + const expected = + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + + "Rule: Rule Without File\n" + + "Description: Rule without file path\n" + + "Filepath: undefined"; + + expect(result).toBe(expected); + }); + + it("should filter out rules with alwaysApply undefined (truthy)", () => { + const rules: RuleWithSource[] = [ + { + name: "Rule with undefined alwaysApply", + description: "This should be filtered out", + source: "rules-block", + rule: "Some rule", + ruleFile: "/path/to/rule.md", + // alwaysApply is undefined, which is truthy in the filter condition + }, + { + name: "Valid Agent Rule", + description: "This should be included", + source: "rules-block", + rule: "Some rule", + alwaysApply: false, + ruleFile: "/path/to/valid-rule.md", + }, + ]; + + const result = getRequestRuleDescription(rules); + + const expected = + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + + "Rule: Valid Agent Rule\n" + + "Description: This should be included\n" + + "Filepath: /path/to/valid-rule.md"; + + expect(result).toBe(expected); + }); + + it("should filter out rules with any globs defined", () => { + const rules: RuleWithSource[] = [ + { + name: "Rule with string globs", + description: "This should be filtered out", + source: "rules-block", + rule: "Some rule", + alwaysApply: false, + globs: "**/*.ts", + ruleFile: "/path/to/rule1.md", + }, + { + name: "Rule with array globs", + description: "This should also be filtered out", + source: "rules-block", + rule: "Some rule", + alwaysApply: false, + globs: ["**/*.ts", "**/*.js"], + ruleFile: "/path/to/rule2.md", + }, + { + name: "Valid Agent Rule", + description: "This should be included", + source: "rules-block", + rule: "Some rule", + alwaysApply: false, + ruleFile: "/path/to/valid-rule.md", + }, + ]; + + const result = getRequestRuleDescription(rules); + + const expected = + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + + "Rule: Valid Agent Rule\n" + + "Description: This should be included\n" + + "Filepath: /path/to/valid-rule.md"; + + expect(result).toBe(expected); + }); + + it("should handle empty rules array", () => { + const rules: RuleWithSource[] = []; + + const result = getRequestRuleDescription(rules); + + expect(result).toBe( + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\nNo rules available." + ); + }); + + it("should handle single agent-requested rule", () => { + const rules: RuleWithSource[] = [ + { + name: "Single Rule", + description: "The only agent-requested rule", + source: "rules-block", + rule: "Follow this guideline", + alwaysApply: false, + ruleFile: "/path/to/single-rule.md", + }, + ]; + + const result = getRequestRuleDescription(rules); + + const expected = + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + + "Rule: Single Rule\n" + + "Description: The only agent-requested rule\n" + + "Filepath: /path/to/single-rule.md"; + + expect(result).toBe(expected); + }); +}); \ No newline at end of file From aa6450950c80d44a7c7fc96faea9fb08d752f97e Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 27 May 2025 19:42:37 -0700 Subject: [PATCH 05/22] fix typo --- core/tools/definitions/globSearch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tools/definitions/globSearch.ts b/core/tools/definitions/globSearch.ts index 3cbc43d52..5c2375124 100644 --- a/core/tools/definitions/globSearch.ts +++ b/core/tools/definitions/globSearch.ts @@ -6,7 +6,7 @@ export const globSearchTool: Tool = { displayTitle: "Glob File Search", wouldLikeTo: 'find file matches for "{{{ pattern }}}"', isCurrently: 'finding file matches for "{{{ pattern }}}"', - hasAlready: 'retreived file matches for "{{{ pattern }}}"', + hasAlready: 'retrieved file matches for "{{{ pattern }}}"', readonly: true, isInstant: true, group: BUILT_IN_GROUP_NAME, From 0ad746b57ea5686ce2a29ad414598c91eaaa3251 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Wed, 28 May 2025 12:40:00 -0700 Subject: [PATCH 06/22] add rule to make the model describe the code in a bigger-picture context --- .../rules/bigger-picture-description-rules.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .continue/rules/bigger-picture-description-rules.yaml diff --git a/.continue/rules/bigger-picture-description-rules.yaml b/.continue/rules/bigger-picture-description-rules.yaml new file mode 100644 index 000000000..4e076e88a --- /dev/null +++ b/.continue/rules/bigger-picture-description-rules.yaml @@ -0,0 +1,13 @@ +name: bigger-picture-description-rules +version: 0.0.1 +schema: v1 +rules: + - name: bigger-picture-description-rules + rule: >- + When a user asks how a certain part of the code works: + + 1. Describe what the code does in isolation. + + 2. If the code interacts with other parts of the codebase, describe how the code is imported and used in other parts of the codebase. + + 3. When describing each use-case, include the parent function for clarity. From 9c2a780fa986f5f98c3231a12971d3f16c7a8e74 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 28 May 2025 13:55:41 -0700 Subject: [PATCH 07/22] fix: use dir hash in `tagToString` --- core/indexing/utils.test.ts | 71 ++++++++++++++++++++++++++++--------- core/indexing/utils.ts | 27 +++++++++----- 2 files changed, 72 insertions(+), 26 deletions(-) diff --git a/core/indexing/utils.test.ts b/core/indexing/utils.test.ts index f432da023..414fb6ff5 100644 --- a/core/indexing/utils.test.ts +++ b/core/indexing/utils.test.ts @@ -11,8 +11,7 @@ test("tagToString returns full tag string when under length limit", () => { expect(tagToString(tag)).toBe("/normal/path/to/repo::main::12345"); }); -test("tagToString truncates beginning of directory when path is too long", () => { - // Create a very long directory path that exceeds MAX_DIR_LENGTH (200) +test("tagToString truncates beginning of directory when path is too long and adds hash for uniqueness", () => { const longPrefix = "/very/long/path/that/will/be/truncated/"; const importantSuffix = "/user/important-project/src/feature"; const longPath = longPrefix + "x".repeat(200) + importantSuffix; @@ -25,18 +24,14 @@ test("tagToString truncates beginning of directory when path is too long", () => const result = tagToString(tag); - // The result should keep the important suffix part - expect(result).toContain(importantSuffix); - // The result should NOT contain the beginning of the path - expect(result).not.toContain(longPrefix); - // The result should include the branch and artifactId expect(result).toContain("::feature-branch::67890"); - // The result should be within the MAX_TABLE_NAME_LENGTH limit (240) expect(result.length).toBeLessThanOrEqual(240); + expect(result).toMatch(/^[a-f0-9]{8}_/); + expect(result).toContain(importantSuffix); }); test("tagToString preserves branch and artifactId exactly, even when truncating", () => { - const longPath = "/a".repeat(300); // Much longer than MAX_DIR_LENGTH + const longPath = "/a".repeat(300); const tag: IndexTag = { directory: longPath, branch: "release-v2.0", @@ -45,14 +40,56 @@ test("tagToString preserves branch and artifactId exactly, even when truncating" const result = tagToString(tag); - // Should contain the exact branch and artifactId expect(result).toContain("::release-v2.0::build-123"); - // Should contain the end of the path - expect(result).toContain("/a/a/a"); - // Should not contain the full original path (it should be truncated) - expect(result.length).toBeLessThan( - longPath.length + "::release-v2.0::build-123".length, - ); - // The result should be within the MAX_TABLE_NAME_LENGTH limit + expect(result).toMatch(/^[a-f0-9]{8}_/); expect(result.length).toBeLessThanOrEqual(240); }); + +test("tagToString ensures uniqueness for different long paths that would otherwise collide", () => { + const basePath = "/very/long/base/path/that/exceeds/limits/"; + const commonSuffix = "/same/ending/path"; + + const tag1: IndexTag = { + directory: basePath + "different1" + "x".repeat(100) + commonSuffix, + branch: "main", + artifactId: "12345", + }; + + const tag2: IndexTag = { + directory: basePath + "different2" + "y".repeat(100) + commonSuffix, + branch: "main", + artifactId: "12345", + }; + + const fullString1 = `${tag1.directory}::${tag1.branch}::${tag1.artifactId}`; + const fullString2 = `${tag2.directory}::${tag2.branch}::${tag2.artifactId}`; + + const result1 = tagToString(tag1); + const result2 = tagToString(tag2); + + expect(result1).not.toBe(result2); + expect(result1.length).toBeLessThanOrEqual(240); + expect(result2.length).toBeLessThanOrEqual(240); + + if (fullString1.length > 240) { + expect(result1).toMatch(/^[a-f0-9]{8}_/); + expect(result2).toMatch(/^[a-f0-9]{8}_/); + } else { + expect(result1).toBe(fullString1); + expect(result2).toBe(fullString2); + } +}); + +test("tagToString produces consistent results for the same input", () => { + const tag: IndexTag = { + directory: + "/some/very/long/path/that/exceeds/the/maximum/length/limit/for/directory/names/in/the/system", + branch: "develop", + artifactId: "test-123", + }; + + const result1 = tagToString(tag); + const result2 = tagToString(tag); + + expect(result1).toBe(result2); +}); diff --git a/core/indexing/utils.ts b/core/indexing/utils.ts index 0713507f0..40ef7c39a 100644 --- a/core/indexing/utils.ts +++ b/core/indexing/utils.ts @@ -1,3 +1,4 @@ +import crypto from "crypto"; import { IndexTag } from ".."; // Maximum length for table names to stay under OS filename limits @@ -18,8 +19,8 @@ const MAX_DIR_LENGTH = 200; * * To handle long paths: * 1. First tries the full string - most backwards compatible - * 2. If too long, truncates directory from the beginning to maintain uniqueness - * (since final parts of paths are more unique than prefixes) + * 2. If too long, truncates directory from the beginning and adds a hash prefix + * to ensure uniqueness while preserving the more readable end parts * 3. Finally ensures entire string stays under MAX_TABLE_NAME_LENGTH for OS compatibility * * @param tag The tag containing directory, branch, and artifactId @@ -32,14 +33,22 @@ export function tagToString(tag: IndexTag): string { return result; } + // Create a hash of the full directory path to ensure uniqueness + const dirHash = crypto + .createHash("md5") + .update(tag.directory) + .digest("hex") + .slice(0, 8); + + // Calculate how much space we have for the directory after accounting for hash, separators, branch, and artifactId + const nonDirLength = `${dirHash}_::${tag.branch}::${tag.artifactId}`.length; + const maxDirForTruncated = MAX_TABLE_NAME_LENGTH - nonDirLength; + // Truncate from the beginning of directory path to preserve the more unique end parts - const dir = - tag.directory.length > MAX_DIR_LENGTH - ? tag.directory.slice(tag.directory.length - MAX_DIR_LENGTH) + const truncatedDir = + tag.directory.length > maxDirForTruncated + ? tag.directory.slice(tag.directory.length - maxDirForTruncated) : tag.directory; - return `${dir}::${tag.branch}::${tag.artifactId}`.slice( - 0, - MAX_TABLE_NAME_LENGTH, - ); + return `${dirHash}_${truncatedDir}::${tag.branch}::${tag.artifactId}`; } From fb6fd35f1583ad3d88c8cc0287e053546fe1ce90 Mon Sep 17 00:00:00 2001 From: adarshramiyer Date: Wed, 28 May 2025 14:00:49 -0700 Subject: [PATCH 08/22] added a tensor dimension annotation rule --- .continue/rules/tensor-annotation.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .continue/rules/tensor-annotation.md diff --git a/.continue/rules/tensor-annotation.md b/.continue/rules/tensor-annotation.md new file mode 100644 index 000000000..fd6617688 --- /dev/null +++ b/.continue/rules/tensor-annotation.md @@ -0,0 +1,16 @@ +--- +globs: /**/*.{py,ipynb} +description: Clean Tensor Dimension Annotation +--- + +# Tensor Dimension Annotation + +The goal is to help developers easily read, understand, and debug code in pytorch and JAX code where tensor computation plays a major role. + +- Import the typing and jaxtyping libraries and use them throughout according to their best practices (i.e., in a very pythonic way) +- Explicitly include the type of each function argument wherever it is possible to determine, e.g. `image: np.ndarray` +- Explicitly include the return type of each function wherever it is possible to determine, e.g. `def get_x(): -> int:` +- Include jaxtyping annotations of tensor dimensions for all tensor arguments to functions, wherever the dimensions are possible to determine. If the numeric values are unclear, use symbolic notation like "batch", "channel", "height", or "width". Create and use these symbolic dimensions in such a way that they are consistent, semantically meaningful, short, and human-readable. If einops is used, ensure that the symbolic values used there are the same as for the dimension annotations. +- Ensure that the dimension annotations are just strict enough to hold up to all edge cases. +- In the docstring of every function where tensor dimensions play a major role in the computation, incorporate a very short but detailed rationale for the input tensor dimensions. There is no need to do this for very simple functions. +- If it is possible to determine and would assist with readability, include annotations for the tensor dimensions of function outputs as well. From 33b1d3994654f311dcae385f6ef2ef78696d1d89 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 28 May 2025 16:19:11 -0700 Subject: [PATCH 09/22] feat: dallins feedback --- core/core.ts | 1 + core/index.d.ts | 3 +- core/tools/definitions/requestRule.test.ts | 56 ++++++++-------------- core/tools/definitions/requestRule.ts | 14 ++---- core/tools/implementations/requestRule.ts | 13 ++++- gui/src/redux/slices/uiSlice.ts | 2 +- 6 files changed, 38 insertions(+), 51 deletions(-) diff --git a/core/core.ts b/core/core.ts index 6b5f9814e..497e64c66 100644 --- a/core/core.ts +++ b/core/core.ts @@ -723,6 +723,7 @@ export class Core { }; return await callTool(tool, toolCall.function.arguments, { + config, ide: this.ide, llm: config.selectedModelByRole.chat, fetch: (url, init) => diff --git a/core/index.d.ts b/core/index.d.ts index cb90b5bf9..afbdc9eac 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -975,6 +975,7 @@ export interface ToolExtras { toolCallId: string; contextItems: ContextItem[]; }) => void; + config: ContinueConfig; } export interface Tool { @@ -1147,7 +1148,7 @@ export interface StreamableHTTPOptions { requestOptions?: RequestOptions; } -export type TransportOptions = +export type TransportOptions = | StdioOptions | WebSocketOptions | SSEOptions diff --git a/core/tools/definitions/requestRule.test.ts b/core/tools/definitions/requestRule.test.ts index 49aac9c6e..e1d0feb81 100644 --- a/core/tools/definitions/requestRule.test.ts +++ b/core/tools/definitions/requestRule.test.ts @@ -1,5 +1,5 @@ -import { getRequestRuleDescription } from "./requestRule"; import { RuleWithSource } from "../.."; +import { getRequestRuleDescription } from "./requestRule"; describe("getRequestRuleDescription", () => { it("should return no rules message when no agent-requested rules exist", () => { @@ -25,7 +25,7 @@ describe("getRequestRuleDescription", () => { const result = getRequestRuleDescription(rules); expect(result).toBe( - "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\nNo rules available." + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\nNo rules available.", ); }); @@ -68,14 +68,10 @@ describe("getRequestRuleDescription", () => { const result = getRequestRuleDescription(rules); - const expected = + const expected = "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + - "Rule: Agent Rule 1\n" + - "Description: First agent-requested rule\n" + - "Filepath: /path/to/agent-rule1.md\n\n" + - "Rule: Agent Rule 2\n" + - "Description: Second agent-requested rule\n" + - "Filepath: /path/to/agent-rule2.md"; + "Agent Rule 1: First agent-requested rule\n" + + "Agent Rule 2: Second agent-requested rule"; expect(result).toBe(expected); }); @@ -93,11 +89,9 @@ describe("getRequestRuleDescription", () => { const result = getRequestRuleDescription(rules); - const expected = + const expected = "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + - "Rule: Rule Without Description\n" + - "Description: undefined\n" + - "Filepath: /path/to/no-desc-rule.md"; + "Rule Without Description: undefined"; expect(result).toBe(expected); }); @@ -115,11 +109,9 @@ describe("getRequestRuleDescription", () => { const result = getRequestRuleDescription(rules); - const expected = + const expected = "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + - "Rule: undefined\n" + - "Description: Rule without name\n" + - "Filepath: /path/to/no-name-rule.md"; + "undefined: Rule without name"; expect(result).toBe(expected); }); @@ -137,11 +129,9 @@ describe("getRequestRuleDescription", () => { const result = getRequestRuleDescription(rules); - const expected = + const expected = "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + - "Rule: Rule Without File\n" + - "Description: Rule without file path\n" + - "Filepath: undefined"; + "Rule Without File: Rule without file path"; expect(result).toBe(expected); }); @@ -168,11 +158,9 @@ describe("getRequestRuleDescription", () => { const result = getRequestRuleDescription(rules); - const expected = + const expected = "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + - "Rule: Valid Agent Rule\n" + - "Description: This should be included\n" + - "Filepath: /path/to/valid-rule.md"; + "Valid Agent Rule: This should be included"; expect(result).toBe(expected); }); @@ -191,7 +179,7 @@ describe("getRequestRuleDescription", () => { { name: "Rule with array globs", description: "This should also be filtered out", - source: "rules-block", + source: "rules-block", rule: "Some rule", alwaysApply: false, globs: ["**/*.ts", "**/*.js"], @@ -209,11 +197,9 @@ describe("getRequestRuleDescription", () => { const result = getRequestRuleDescription(rules); - const expected = + const expected = "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + - "Rule: Valid Agent Rule\n" + - "Description: This should be included\n" + - "Filepath: /path/to/valid-rule.md"; + "Valid Agent Rule: This should be included"; expect(result).toBe(expected); }); @@ -224,7 +210,7 @@ describe("getRequestRuleDescription", () => { const result = getRequestRuleDescription(rules); expect(result).toBe( - "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\nNo rules available." + "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\nNo rules available.", ); }); @@ -242,12 +228,10 @@ describe("getRequestRuleDescription", () => { const result = getRequestRuleDescription(rules); - const expected = + const expected = "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n" + - "Rule: Single Rule\n" + - "Description: The only agent-requested rule\n" + - "Filepath: /path/to/single-rule.md"; + "Single Rule: The only agent-requested rule"; expect(result).toBe(expected); }); -}); \ No newline at end of file +}); diff --git a/core/tools/definitions/requestRule.ts b/core/tools/definitions/requestRule.ts index 569fd794a..cb60cda73 100644 --- a/core/tools/definitions/requestRule.ts +++ b/core/tools/definitions/requestRule.ts @@ -2,7 +2,6 @@ import { ConfigDependentToolParams, GetTool } from "../.."; import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; export interface RequestRuleArgs { - filepath: string; name: string; } @@ -18,11 +17,8 @@ export function getRequestRuleDescription( "Use this tool to select additional rules, specifically based on their descriptions. Available rules:\n"; const body = agentRequestedRules - .map( - (rule) => - `Rule: ${rule.name}\nDescription: ${rule.description}\nFilepath: ${rule.ruleFile}`, - ) - .join("\n\n"); + .map((rule) => `${rule.name}: ${rule.description}`) + .join("\n"); if (body.length === 0) { return prefix + "No rules available."; @@ -44,12 +40,8 @@ export const requestRuleTool: GetTool = ({ rules }) => ({ description: getRequestRuleDescription(rules), parameters: { type: "object", - required: ["name", "filepath"], + required: ["name"], properties: { - filepath: { - type: "string", - description: "The path of the rule file", - }, name: { type: "string", description: "Name of the rule", diff --git a/core/tools/implementations/requestRule.ts b/core/tools/implementations/requestRule.ts index ac34f66e5..86aff6280 100644 --- a/core/tools/implementations/requestRule.ts +++ b/core/tools/implementations/requestRule.ts @@ -2,7 +2,16 @@ import { ToolImpl } from "."; import { parseMarkdownRule } from "../../config/markdown/parseMarkdownRule"; export const requestRuleImpl: ToolImpl = async (args, extras) => { - const fileContent = await extras.ide.readFile(args.filepath); + // Find the rule by name in the config + const rule = extras.config.rules.find((r) => r.name === args.name); + + if (!rule || !rule.ruleFile) { + throw new Error( + `Rule with name "${args.name}" not found or has no file path`, + ); + } + + const fileContent = await extras.ide.readFile(rule.ruleFile); const { markdown, frontmatter } = parseMarkdownRule(fileContent); return [ @@ -12,7 +21,7 @@ export const requestRuleImpl: ToolImpl = async (args, extras) => { content: markdown, uri: { type: "file", - value: args.filepath, + value: rule.ruleFile, }, }, ]; diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index d995ab8eb..28e91d052 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -56,7 +56,7 @@ export const uiSlice = createSlice({ [BuiltInToolNames.ViewDiff]: "allowedWithoutPermission", [BuiltInToolNames.LSTool]: "allowedWithoutPermission", [BuiltInToolNames.CreateRuleBlock]: "allowedWithPermission", - [BuiltInToolNames.RequestRule]: "allowedWithoutPermission", + [BuiltInToolNames.RequestRule]: "allowedWithPermission", }, toolGroupSettings: { [BUILT_IN_GROUP_NAME]: "include", From b1b7a9c2d48dd3319895c3e097f50fb1ac8fbb0d Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 16:19:35 -0700 Subject: [PATCH 10/22] bump jetbrains to 1.0.20 --- extensions/intellij/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index b9981e11f..390fc25a3 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.19 +pluginVersion=1.0.20 # 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 From 0a898ed2de337e56a962058131285086be0e3a04 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 16:35:01 -0700 Subject: [PATCH 11/22] fix tool call args UI --- .../gui/ToolCallDiv/SimpleToolCallUI.tsx | 38 +++++++++---------- gui/src/pages/gui/ToolCallDiv/ToolCall.tsx | 4 +- .../pages/gui/ToolCallDiv/ToolCallArgs.tsx | 11 +++--- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx index 3342eabda..d17633a13 100644 --- a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +++ b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx @@ -2,7 +2,7 @@ import { ChevronDownIcon, ChevronRightIcon } from "@heroicons/react/24/outline"; import { ContextItemWithId, Tool, ToolCallState } from "core"; import { ComponentType, useMemo, useState } from "react"; import { ContextItemsPeekItem } from "../../../components/mainInput/belowMainInput/ContextItemsPeek"; -import { ArgsItems } from "./ToolCallArgs"; +import { ArgsItems, ArgsToggleIcon } from "./ToolCallArgs"; import { ToolCallStatusMessage } from "./ToolCallStatusMessage"; interface SimpleToolCallUIProps { @@ -32,10 +32,10 @@ export function SimpleToolCallUI({ }, [toolCallState.parsedArgs]); return ( -
-
+
+
setOpen((prev) => !prev)} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} @@ -43,38 +43,36 @@ export function SimpleToolCallUI({ >
{Icon && !isHovered && !open ? ( - + ) : ( <> )}
- - +
- {/*
- {args.length > 0 ? ( - - ) : null} -
*/} + {args.length > 0 ? ( + + ) : null}
)) ) : ( -
+
No tool call output
)} diff --git a/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx b/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx index 6f313236d..263c15dc0 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx @@ -26,8 +26,8 @@ export function ToolCallDisplay({ <>
-
-
+
+
{icon}
diff --git a/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx b/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx index 738be01f9..a451ec135 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx @@ -25,10 +25,9 @@ export const ArgsToggleIcon = ({ e.stopPropagation(); setIsShowing(!isShowing); }} - className={`cursor-pointer select-none rounded-sm px-1 py-0.5 hover:bg-gray-400/40 hover:opacity-80 ${isShowing ? "bg-gray-400/40" : "bg-transparent"}`} + className={`hover:description-muted/30 cursor-pointer select-none rounded px-1 py-0.5 hover:opacity-80 ${isShowing ? "bg-description-muted/30" : "bg-transparent"}`} > - - {/* {`{}`} */} +
{isShowing ? "Hide args" : "Show args"} @@ -52,11 +51,13 @@ export const ArgsItems = ({ args, isShowing }: ArgsItemsProps) => { } return ( -
+
{args.map(([key, value]) => (
{key}: - {value.toString()} + + {JSON.stringify(value)} +
))}
From b7e97fcb67e93005558cc6f3b31846e3b5296d73 Mon Sep 17 00:00:00 2001 From: adarshramiyer Date: Wed, 28 May 2025 17:08:06 -0700 Subject: [PATCH 12/22] updated rule to be relevant to continue codebase --- .continue/rules/llm-specificity.md | 11 +++++++++++ .continue/rules/tensor-annotation.md | 16 ---------------- 2 files changed, 11 insertions(+), 16 deletions(-) create mode 100644 .continue/rules/llm-specificity.md delete mode 100644 .continue/rules/tensor-annotation.md diff --git a/.continue/rules/llm-specificity.md b/.continue/rules/llm-specificity.md new file mode 100644 index 000000000..4ff15c9e7 --- /dev/null +++ b/.continue/rules/llm-specificity.md @@ -0,0 +1,11 @@ +--- +globs: core/llm/llms/**/*.{ts,test.ts} +description: Tailor recommendations for LLM code based on which specific LLM is being used. +--- + +# LLM Model Specificity + +- Refer to the file name and names of big classes to determine which LLM is being used in a file. +- Ground all observations and recommendations with knowledge of that LLM. +- Consider items such as context length, architecture, speed, and such. +- Pay attention to the parent classes in these files. diff --git a/.continue/rules/tensor-annotation.md b/.continue/rules/tensor-annotation.md deleted file mode 100644 index fd6617688..000000000 --- a/.continue/rules/tensor-annotation.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -globs: /**/*.{py,ipynb} -description: Clean Tensor Dimension Annotation ---- - -# Tensor Dimension Annotation - -The goal is to help developers easily read, understand, and debug code in pytorch and JAX code where tensor computation plays a major role. - -- Import the typing and jaxtyping libraries and use them throughout according to their best practices (i.e., in a very pythonic way) -- Explicitly include the type of each function argument wherever it is possible to determine, e.g. `image: np.ndarray` -- Explicitly include the return type of each function wherever it is possible to determine, e.g. `def get_x(): -> int:` -- Include jaxtyping annotations of tensor dimensions for all tensor arguments to functions, wherever the dimensions are possible to determine. If the numeric values are unclear, use symbolic notation like "batch", "channel", "height", or "width". Create and use these symbolic dimensions in such a way that they are consistent, semantically meaningful, short, and human-readable. If einops is used, ensure that the symbolic values used there are the same as for the dimension annotations. -- Ensure that the dimension annotations are just strict enough to hold up to all edge cases. -- In the docstring of every function where tensor dimensions play a major role in the computation, incorporate a very short but detailed rationale for the input tensor dimensions. There is no need to do this for very simple functions. -- If it is possible to determine and would assist with readability, include annotations for the tensor dimensions of function outputs as well. From 204a96fe137dcfd018232e82cc20219e46be8b5e Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 17:34:13 -0700 Subject: [PATCH 13/22] clean up tool call args UI --- gui/src/pages/gui/Chat.tsx | 17 +++---- .../gui/ToolCallDiv/SimpleToolCallUI.tsx | 36 +++++-------- gui/src/pages/gui/ToolCallDiv/ToolCall.tsx | 14 +++-- .../pages/gui/ToolCallDiv/ToolCallArgs.tsx | 2 +- .../gui/ToolCallDiv/ToolCallStatusMessage.tsx | 51 ++++++++----------- gui/src/pages/gui/ToolCallDiv/index.tsx | 18 +++---- 6 files changed, 55 insertions(+), 83 deletions(-) diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 75fb48c4b..c3e8ac512 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -333,17 +333,16 @@ export function Chat() { "assistant" && item.message.toolCalls && item.toolCallState ? ( -
+
{item.message.toolCalls?.map((toolCall, i) => { return ( -
- -
+ ); })}
diff --git a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx index d17633a13..07b7838a7 100644 --- a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +++ b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx @@ -1,4 +1,4 @@ -import { ChevronDownIcon, ChevronRightIcon } from "@heroicons/react/24/outline"; +import { ChevronRightIcon } from "@heroicons/react/24/outline"; import { ContextItemWithId, Tool, ToolCallState } from "core"; import { ComponentType, useMemo, useState } from "react"; import { ContextItemsPeekItem } from "../../../components/mainInput/belowMainInput/ContextItemsPeek"; @@ -32,39 +32,27 @@ export function SimpleToolCallUI({ }, [toolCallState.parsedArgs]); return ( -
-
+
+
setOpen((prev) => !prev)} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} data-testid="context-items-peek" > -
+
{Icon && !isHovered && !open ? ( - + ) : ( - <> - - - + )}
-
- -
+
{args.length > 0 ? ( -
+
-
+
{icon}
{tool?.faviconUrl && ( )} -
- -
+
{!!args.length ? ( { } return ( -
+
{args.map(([key, value]) => (
{key}: diff --git a/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx b/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx index 7a25a7605..40a5f06ef 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx @@ -1,7 +1,5 @@ import { Tool, ToolCallState } from "core"; import Mustache from "mustache"; -import { ReactNode } from "react"; -import { getFontSize } from "../../../util"; import { useFontSize } from "../../../components/ui/font"; interface ToolCallStatusMessageProps { @@ -16,35 +14,26 @@ export function ToolCallStatusMessage({ const fontSize = useFontSize(); if (!tool) return "Agent tool use"; - const defaultToolDescription = ( - <> - {tool.displayTitle ?? tool.function.name} tool - - ); + const toolName = tool.displayTitle ?? tool.function.name; + const defaultToolDescription = `${toolName} tool`; - const futureMessage = tool.wouldLikeTo ? ( - Mustache.render(tool.wouldLikeTo, toolCallState.parsedArgs) - ) : ( - <> - use the {defaultToolDescription} - - ); + const futureMessage: string = tool.wouldLikeTo + ? Mustache.render(tool.wouldLikeTo, toolCallState.parsedArgs) + : `use the ${defaultToolDescription}`; + // TODO go back and replace arg string values and tool names with tags + // to make them more readable let intro = ""; - let message: ReactNode = ""; + let message = ""; if ( toolCallState.status === "done" || (tool.isInstant && toolCallState.status === "calling") ) { intro = ""; - message = tool.hasAlready ? ( - Mustache.render(tool.hasAlready, toolCallState.parsedArgs) - ) : ( - <> - used the {defaultToolDescription} - - ); + message = tool.hasAlready + ? Mustache.render(tool.hasAlready, toolCallState.parsedArgs) + : `used the ${defaultToolDescription}`; } else if (toolCallState.status === "generating") { intro = "is generating output to"; message = futureMessage; @@ -53,13 +42,9 @@ export function ToolCallStatusMessage({ message = futureMessage; } else if (toolCallState.status === "calling") { intro = "is"; - message = tool.isCurrently ? ( - Mustache.render(tool.isCurrently, toolCallState.parsedArgs) - ) : ( - <> - calling the {defaultToolDescription} - - ); + message = tool.isCurrently + ? Mustache.render(tool.isCurrently, toolCallState.parsedArgs) + : `calling the ${defaultToolDescription}`; } else if ( toolCallState.status === "canceled" || toolCallState.status === "errored" @@ -68,8 +53,12 @@ export function ToolCallStatusMessage({ message = futureMessage; } return ( -
- Continue {intro} {message} +
+ {`Continue ${intro} ${message}`}
); } diff --git a/gui/src/pages/gui/ToolCallDiv/index.tsx b/gui/src/pages/gui/ToolCallDiv/index.tsx index 39d14cd0a..c919c0ca1 100644 --- a/gui/src/pages/gui/ToolCallDiv/index.tsx +++ b/gui/src/pages/gui/ToolCallDiv/index.tsx @@ -80,16 +80,14 @@ export function ToolCallDiv(props: ToolCallDivProps) { if (icon) { return ( -
- -
+ ); } From 35034287788672dc1f9a241abd8abb563a0e8778 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 17:58:34 -0700 Subject: [PATCH 14/22] improve selected jetbrains colors --- .../continueintellijextension/continue/GetTheme.kt | 12 ++++++------ gui/src/components/ModeSelect/ModeSelect.tsx | 2 +- gui/src/components/ui/Listbox.tsx | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt index 357757fe0..0ee4c2bd0 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt @@ -132,18 +132,18 @@ class GetTheme { val inputPlaceholder = namedColor("TextField.inactiveForeground") val listHoverBackground = namedColor("List.hoverBackground") ?: slightChange(background) - val actionHoverBackground = namedColor("ActionButton.hoverBackground") ?: namedColor("Button.darcula.hoverBackground") + val listHoverForeground = namedColor("List.hoverForeground") ?: slightChange(foreground) - val tableOddRow = namedColor("Table.hoverBackground") ?: namedColor("Table.stripeColor") - val listSelectionForeground = namedColor("List.selectionForeground") + val tableOddRow = namedColor("Table.hoverBackground") ?: namedColor("Table.stripeColor") - val description = namedColor("Label.disabledForeground") ?: namedColor("Label.infoForeground") + val description = namedColor("Label.infoForeground") ?: namedColor("Label.disabledForeground") ?: foreground val mutedDescription = namedColor("Component.infoForeground") ?: namedColor("ContextHelp.foreground") ?: namedColor("TextField.placeholderForeground") ?: namedColor("Label.disabledForeground") ?: namedColor("ToolTip.foreground") + ?: description val link = namedColor("Link.activeForeground") @@ -201,8 +201,8 @@ class GetTheme { "find-match" to findMatchBackground, "find-match-selected" to findMatchSelectedBackground, "list-hover" to listHoverBackground, - "list-active" to actionHoverBackground, - "list-active-foreground" to listSelectionForeground + "list-active" to listHoverBackground, + "list-active-foreground" to listHoverForeground ).mapValues { toHex(it.value) } return theme } catch (error: Error) { diff --git a/gui/src/components/ModeSelect/ModeSelect.tsx b/gui/src/components/ModeSelect/ModeSelect.tsx index 22a9975ca..75046e476 100644 --- a/gui/src/components/ModeSelect/ModeSelect.tsx +++ b/gui/src/components/ModeSelect/ModeSelect.tsx @@ -72,7 +72,7 @@ export function ModeSelect() {
diff --git a/gui/src/components/ui/Listbox.tsx b/gui/src/components/ui/Listbox.tsx index 1659a06b6..c03efa848 100644 --- a/gui/src/components/ui/Listbox.tsx +++ b/gui/src/components/ui/Listbox.tsx @@ -72,7 +72,7 @@ const ListboxOption = React.forwardRef( ref={ref} {...props} className={cn( - "text-vsc-foreground flex select-none flex-row items-center justify-between px-2 py-1", + "text-foreground flex select-none flex-row items-center justify-between px-2 py-1", props.disabled ? "opacity-50" : "background-transparent hover:bg-list-active hover:text-list-active-foreground cursor-pointer opacity-100", From d158fab740cf803074106717560941cca8cb96c9 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 28 May 2025 18:57:35 -0700 Subject: [PATCH 15/22] feat: dallin feedback pt 2 --- core/config/profile/doLoadConfig.ts | 20 ++++++++++++++++++++ gui/src/redux/slices/uiSlice.ts | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index cfaa38ffa..865667ecb 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -219,6 +219,26 @@ export default async function doLoadConfig(options: { } }); + const ruleCounts: Record = {}; + newConfig.rules.forEach((rule) => { + if (rule.name) { + if (ruleCounts[rule.name]) { + ruleCounts[rule.name] = ruleCounts[rule.name] + 1; + } else { + ruleCounts[rule.name] = 1; + } + } + }); + + Object.entries(ruleCounts).forEach(([ruleName, count]) => { + if (count > 1) { + errors!.push({ + fatal: false, + message: `Duplicate (${count}) rules named "${ruleName}" detected. This may cause unexpected behavior`, + }); + } + }); + newConfig.allowAnonymousTelemetry = newConfig.allowAnonymousTelemetry && (await ide.isTelemetryEnabled()); diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index 28e91d052..b8961a0b1 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -56,7 +56,7 @@ export const uiSlice = createSlice({ [BuiltInToolNames.ViewDiff]: "allowedWithoutPermission", [BuiltInToolNames.LSTool]: "allowedWithoutPermission", [BuiltInToolNames.CreateRuleBlock]: "allowedWithPermission", - [BuiltInToolNames.RequestRule]: "allowedWithPermission", + [BuiltInToolNames.RequestRule]: "disabled", }, toolGroupSettings: { [BUILT_IN_GROUP_NAME]: "include", From fad35a7cba21a7333035548de42b0c07007f5c75 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 19:41:36 -0700 Subject: [PATCH 16/22] fix missing sign in button --- core/control-plane/AuthTypes.ts | 10 +++------- core/control-plane/client.ts | 11 +++++------ gui/src/pages/config/AccountButton.tsx | 4 ++-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/core/control-plane/AuthTypes.ts b/core/control-plane/AuthTypes.ts index c926efac1..3b79d91ae 100644 --- a/core/control-plane/AuthTypes.ts +++ b/core/control-plane/AuthTypes.ts @@ -13,14 +13,10 @@ export interface OnPremSessionInfo { export type ControlPlaneSessionInfo = HubSessionInfo | OnPremSessionInfo; -export function isHubSession( +export function isOnPremSession( sessionInfo: ControlPlaneSessionInfo | undefined, -): sessionInfo is HubSessionInfo { - return ( - sessionInfo !== undefined && - (sessionInfo.AUTH_TYPE === AuthType.WorkOsProd || - sessionInfo.AUTH_TYPE === AuthType.WorkOsStaging) - ); +): sessionInfo is OnPremSessionInfo { + return sessionInfo !== undefined && sessionInfo.AUTH_TYPE === AuthType.OnPrem; } export enum AuthType { diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index e3513ac2d..d2653e246 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -12,7 +12,7 @@ import fetch, { RequestInit, Response } from "node-fetch"; import { OrganizationDescription } from "../config/ProfileLifecycleManager.js"; import { IdeSettings, ModelDescription } from "../index.js"; -import { ControlPlaneSessionInfo, isHubSession } from "./AuthTypes.js"; +import { ControlPlaneSessionInfo, isOnPremSession } from "./AuthTypes.js"; import { getControlPlaneEnv } from "./env.js"; export interface ControlPlaneWorkspace { @@ -63,17 +63,16 @@ export class ControlPlaneClient { async getAccessToken(): Promise { const sessionInfo = await this.sessionInfoPromise; - return isHubSession(sessionInfo) ? sessionInfo.accessToken : undefined; + return isOnPremSession(sessionInfo) ? undefined : sessionInfo?.accessToken; } private async request(path: string, init: RequestInit): Promise { const sessionInfo = await this.sessionInfoPromise; - const hubSession = isHubSession(sessionInfo); - - const accessToken = hubSession ? sessionInfo.accessToken : undefined; + const onPremSession = isOnPremSession(sessionInfo); + const accessToken = await this.getAccessToken(); // Bearer token not necessary for on-prem auth type - if (!accessToken && hubSession) { + if (!accessToken && !onPremSession) { throw new Error("No access token"); } diff --git a/gui/src/pages/config/AccountButton.tsx b/gui/src/pages/config/AccountButton.tsx index 2d6d06b4f..d30e638a0 100644 --- a/gui/src/pages/config/AccountButton.tsx +++ b/gui/src/pages/config/AccountButton.tsx @@ -1,6 +1,6 @@ import { UserCircleIcon } from "@heroicons/react/24/solid"; -import { isHubSession } from "core/control-plane/AuthTypes"; +import { isOnPremSession } from "core/control-plane/AuthTypes"; import { SecondaryButton } from "../../components"; import { Popover, @@ -29,7 +29,7 @@ export function AccountButton() { } // No login button for on-prem deployments - if (!isHubSession(session)) { + if (isOnPremSession(session)) { return null; } From 59647a33f7bae301a3d0a85e1f6c7f5314c0edad Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 21:51:36 -0700 Subject: [PATCH 17/22] fix range in file type shadowing --- .../continue/IdeProtocolClient.kt | 8 +++++++- .../github/continuedev/continueintellijextension/types.kt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) 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 d0527313a..7b146316b 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 @@ -504,10 +504,16 @@ class IdeProtocolClient( val editor = EditorUtils.getEditor(project) val rif = editor?.getHighlightedRIF() ?: return + val serializedRif = com.github.continuedev.continueintellijextension.RangeInFileWithContents( + filepath = rif.filepath, + range = rif.range, + contents = rif.contents + ) + continuePluginService.sendToWebview( "highlightedCode", HighlightedCodePayload( - rangeInFileWithContents = rif, + rangeInFileWithContents = serializedRif, shouldRun = edit ) ) 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 86862a096..c12ab1b82 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 @@ -232,7 +232,7 @@ data class ApplyState( ) data class HighlightedCodePayload( - val rangeInFileWithContents: RangeInFileWithContents, + val rangeInFileWithContents: com.github.continuedev.continueintellijextension.RangeInFileWithContents, val prompt: String? = null, val shouldRun: Boolean? = null ) From f0499024d272f522ebfdaed70b195d279bae2ab4 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 28 May 2025 21:55:20 -0700 Subject: [PATCH 18/22] renderInlineAs "" for mcp context provider --- core/context/providers/MCPContextProvider.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/context/providers/MCPContextProvider.ts b/core/context/providers/MCPContextProvider.ts index 71f071f37..60c256af6 100644 --- a/core/context/providers/MCPContextProvider.ts +++ b/core/context/providers/MCPContextProvider.ts @@ -20,6 +20,7 @@ class MCPContextProvider extends BaseContextProvider { displayTitle: "MCP", description: "Model Context Protocol", type: "submenu", + renderInlineAs: "", }; override get description(): ContextProviderDescription { return { @@ -27,6 +28,7 @@ class MCPContextProvider extends BaseContextProvider { displayTitle: this.options["serverName"] ? `${this.options["serverName"]} resources` : "MCP", + renderInlineAs: "", description: "Model Context Protocol", type: "submenu", }; From 76b4ac8ad3e5c06c828b1b264d87d44c4fe67465 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 28 May 2025 21:58:33 -0700 Subject: [PATCH 19/22] add support for MCP resource templates --- .gitignore | 1 + core/config/profile/doLoadConfig.ts | 21 ++++++++---- core/context/mcp/MCPConnection.ts | 32 ++++++++++++++++--- core/context/providers/MCPContextProvider.ts | 16 +++++++++- core/index.d.ts | 12 ++++++- extensions/vscode/package-lock.json | 6 ++-- .../Lump/sections/mcp/MCPSection.tsx | 12 ++++--- 7 files changed, 81 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 3f3671e74..d3ad46eaf 100644 --- a/.gitignore +++ b/.gitignore @@ -144,6 +144,7 @@ Icon? .continuerc.json .aider* +*.notes.md notes.md manual-testing-sandbox/.idea/** diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index cc1b98e49..f5a0568da 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -176,12 +176,21 @@ export default async function doLoadConfig(options: { ); newConfig.slashCommands.push(...serverSlashCommands); - const submenuItems = server.resources.map((resource) => ({ - title: resource.name, - description: resource.description ?? resource.name, - id: resource.uri, - icon: server.faviconUrl, - })); + const submenuItems = server.resources + .map((resource) => ({ + title: resource.name, + description: resource.description ?? resource.name, + id: resource.uri, + icon: server.faviconUrl, + })) + .concat( + server.resourceTemplates.map((template) => ({ + title: template.name, + description: template.description ?? template.name, + id: template.uriTemplate, + icon: server.faviconUrl, + })), + ); if (submenuItems.length > 0) { const serverContextProvider = new MCPContextProvider({ submenuItems, diff --git a/core/context/mcp/MCPConnection.ts b/core/context/mcp/MCPConnection.ts index 72de75f92..c66a93ed3 100644 --- a/core/context/mcp/MCPConnection.ts +++ b/core/context/mcp/MCPConnection.ts @@ -3,14 +3,15 @@ import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; -import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js"; import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"; +import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js"; import { MCPConnectionStatus, MCPOptions, MCPPrompt, MCPResource, + MCPResourceTemplate, MCPServerStatus, MCPTool, } from "../.."; @@ -37,6 +38,7 @@ class MCPConnection { public prompts: MCPPrompt[] = []; public tools: MCPTool[] = []; public resources: MCPResource[] = []; + public resourceTemplates: MCPResourceTemplate[] = []; private transport: Transport; private connectionPromise: Promise | null = null; private stdioOutput: { stdout: string; stderr: string } = { @@ -72,6 +74,7 @@ class MCPConnection { errors: this.errors, prompts: this.prompts, resources: this.resources, + resourceTemplates: this.resourceTemplates, tools: this.tools, status: this.status, }; @@ -95,6 +98,7 @@ class MCPConnection { this.tools = []; this.prompts = []; this.resources = []; + this.resourceTemplates = []; this.errors = []; this.stdioOutput = { stdout: "", stderr: "" }; @@ -169,6 +173,23 @@ class MCPConnection { } this.errors.push(errorMessage); } + + // Resource templates + try { + const { resourceTemplates } = + await this.client.listResourceTemplates( + {}, + { signal: timeoutController.signal }, + ); + + this.resourceTemplates = resourceTemplates; + } catch (e) { + let errorMessage = `Error loading resource templates for MCP Server ${this.options.name}`; + if (e instanceof Error) { + errorMessage += `: ${e.message}`; + } + this.errors.push(errorMessage); + } } // Tools <—> Tools @@ -337,9 +358,12 @@ class MCPConnection { requestInit: { headers: options.transport.requestOptions?.headers }, }); case "streamable-http": - return new StreamableHTTPClientTransport(new URL(options.transport.url), { - requestInit: { headers: options.transport.requestOptions?.headers }, - }); + return new StreamableHTTPClientTransport( + new URL(options.transport.url), + { + requestInit: { headers: options.transport.requestOptions?.headers }, + }, + ); default: throw new Error( `Unsupported transport type: ${(options.transport as any).type}`, diff --git a/core/context/providers/MCPContextProvider.ts b/core/context/providers/MCPContextProvider.ts index 60c256af6..6465d6b63 100644 --- a/core/context/providers/MCPContextProvider.ts +++ b/core/context/providers/MCPContextProvider.ts @@ -49,6 +49,18 @@ class MCPContextProvider extends BaseContextProvider { super(options); } + /** + * Continue experimentally supports resource templates (https://modelcontextprotocol.io/docs/concepts/resources#resource-templates) + * by allowing specifically just the "query" variable in the template, which we will update with the full input of the user in the input box + */ + private insertInputToUriTemplate(uri: string, query: string): string { + const TEMPLATE_VAR = "query"; + if (uri.includes(`{${TEMPLATE_VAR}}`)) { + return uri.replace(`{${TEMPLATE_VAR}}`, encodeURIComponent(query)); + } + return uri; + } + async getContextItems( query: string, extras: ContextProviderExtras, @@ -60,7 +72,9 @@ class MCPContextProvider extends BaseContextProvider { throw new Error(`No MCP connection found for ${mcpId}`); } - const { contents } = await connection.client.readResource({ uri }); + const { contents } = await connection.client.readResource({ + uri: this.insertInputToUriTemplate(uri, extras.fullInput), + }); return await Promise.all( contents.map(async (resource) => { diff --git a/core/index.d.ts b/core/index.d.ts index 794c03ce0..f7aa806fd 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1141,7 +1141,7 @@ export interface StreamableHTTPOptions { requestOptions?: RequestOptions; } -export type TransportOptions = +export type TransportOptions = | StdioOptions | WebSocketOptions | SSEOptions @@ -1174,6 +1174,7 @@ export interface MCPPrompt { // Leaving here to ideate on // export type ContinueConfigSource = "local-yaml" | "local-json" | "hub-assistant" | "hub" +// https://modelcontextprotocol.io/docs/concepts/resources#direct-resources export interface MCPResource { name: string; uri: string; @@ -1181,6 +1182,14 @@ export interface MCPResource { mimeType?: string; } +// https://modelcontextprotocol.io/docs/concepts/resources#resource-templates +export interface MCPResourceTemplate { + uriTemplate: string; + name: string; + description?: string; + mimeType?: string; +} + export interface MCPTool { name: string; description?: string; @@ -1197,6 +1206,7 @@ export interface MCPServerStatus extends MCPOptions { prompts: MCPPrompt[]; tools: MCPTool[]; resources: MCPResource[]; + resourceTemplates: MCPResourceTemplate[]; } export interface ContinueUIConfig { diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 5634027da..f2db4b382 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.39", + "version": "1.1.40", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.39", + "version": "1.1.40", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", @@ -110,7 +110,7 @@ "@continuedev/fetch": "^1.0.10", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.25", - "@modelcontextprotocol/sdk": "^1.5.0", + "@modelcontextprotocol/sdk": "^1.12.0", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.1.1", "@typescript-eslint/eslint-plugin": "^7.8.0", diff --git a/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx b/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx index 07ec23c56..75c0f0725 100644 --- a/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx @@ -113,11 +113,15 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) { data-tooltip-id={resourcesTooltipId} > - {server.resources.length} + + {server.resources.length + server.resourceTemplates.length} + - {server.resources.map((resource, idx) => ( - {resource.name} - ))} + {[...server.resources, ...server.resourceTemplates].map( + (resource, idx) => ( + {resource.name} + ), + )} {server.resources.length === 0 && ( No resources )} From 767cbd0cf942eec34ce100ff03f1fb5200c26125 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 28 May 2025 21:58:44 -0700 Subject: [PATCH 20/22] bump package.json version --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 101b3de67..c33561f1f 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.40", + "version": "1.1.41", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From f7d59d2424ebd70fccd5fb5aa90fd0d7ac40e49a Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 22:06:03 -0700 Subject: [PATCH 21/22] bump jetbrains to 1.0.21 --- extensions/intellij/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index 390fc25a3..533553649 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.20 +pluginVersion=1.0.21 # 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 From 208d6a6e1a7c00c9a8d5d1fa9c2dd39284272af8 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 29 May 2025 07:53:48 -0700 Subject: [PATCH 22/22] update test --- core/context/mcp/MCPConnection.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/context/mcp/MCPConnection.test.ts b/core/context/mcp/MCPConnection.test.ts index b9dae9ee2..f8f146f07 100644 --- a/core/context/mcp/MCPConnection.test.ts +++ b/core/context/mcp/MCPConnection.test.ts @@ -111,6 +111,7 @@ describe("MCPConnection", () => { errors: [], prompts: [], resources: [], + resourceTemplates: [], tools: [], status: "not-connected", });