From 47a47dac42ee8e025b21d0950bc190dc3206a9fc Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 28 Feb 2025 14:54:23 -0800 Subject: [PATCH 01/14] docs note --- docs/docs/json-reference.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs/json-reference.md b/docs/docs/json-reference.md index ba21ccb65..11e92a183 100644 --- a/docs/docs/json-reference.md +++ b/docs/docs/json-reference.md @@ -36,6 +36,7 @@ Each model has specific configuration options tailored to its provider and funct - `engine`: Engine for Azure OpenAI requests. - `capabilities`: Override auto-detected capabilities: - `uploadImage`: Boolean indicating if the model supports image uploads. + - `tools`: Boolean indicating if the model supports tool calls. _(AWS Only)_ From 19c8da156f75c01bb587814d1d197f509a7fcaba Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 4 Mar 2025 09:55:11 -0800 Subject: [PATCH 02/14] yaml model capabilities --- core/config/yaml/models.ts | 20 +++++++++++++++++++- packages/config-yaml/src/schemas/models.ts | 9 +++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index c6916b010..a0dccd46a 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -35,8 +35,10 @@ async function modelConfigToBaseLLM( return undefined; } + const { capabilities, ...rest } = model; + let options: LLMOptions = { - ...model, + ...rest, completionOptions: { ...(model.defaultCompletionOptions ?? {}), model: model.model, @@ -51,6 +53,22 @@ async function modelConfigToBaseLLM( promptTemplates: model.promptTemplates, }; + // Model capabilities - need to be undefined if not found + // To fallback to our autodetection + if (capabilities?.find((c) => c === "tool_use")) { + options.capabilities = { + ...options.capabilities, + tools: true, + }; + } + + if (capabilities?.find((c) => c === "image_input")) { + options.capabilities = { + ...options.capabilities, + uploadImage: true, + }; + } + if (model.embedOptions?.maxBatchSize) { options.maxEmbeddingBatchSize = model.embedOptions.maxBatchSize; } diff --git a/packages/config-yaml/src/schemas/models.ts b/packages/config-yaml/src/schemas/models.ts index 1fd6247a6..ff3f6bec3 100644 --- a/packages/config-yaml/src/schemas/models.ts +++ b/packages/config-yaml/src/schemas/models.ts @@ -31,6 +31,14 @@ export const modelRolesSchema = z.enum([ ]); export type ModelRole = z.infer; +// TODO consider just using array of strings for model capabilities +// To allow more dynamic string parsing +export const modelCapabilitySchema = z.union([ + z.literal("tool_use"), + z.literal("image_input"), +]); +export type ModelCapability = z.infer; + export const completionOptionsSchema = z.object({ contextLength: z.number().optional(), maxTokens: z.number().optional(), @@ -61,6 +69,7 @@ const baseModelFields = { apiKey: z.string().optional(), apiBase: z.string().optional(), roles: modelRolesSchema.array().optional(), + capabilities: modelCapabilitySchema.array().optional(), defaultCompletionOptions: completionOptionsSchema.optional(), requestOptions: requestOptionsSchema.optional(), embedOptions: embedOptionsSchema.optional(), From 84066e35f3b5ac7515aee64af63a977f09432b8e Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 4 Mar 2025 09:59:30 -0800 Subject: [PATCH 03/14] yaml example --- docs/docs/yaml-reference.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/docs/yaml-reference.md b/docs/docs/yaml-reference.md index 9de133cd7..5a4263ef3 100644 --- a/docs/docs/yaml-reference.md +++ b/docs/docs/yaml-reference.md @@ -134,6 +134,7 @@ The `models` section defines the language models used in your configuration. Mod - `provider` (**required**): The provider of the model (e.g., `openai`, `ollama`). - `model` (**required**): The specific model name (e.g., `gpt-4`, `starcoder`). - `roles`: An array specifying the roles this model can fulfill, such as `chat`, `autocomplete`, `embed`, `rerank`, `edit`, `apply`, `summarize`. The default value is `[chat, edit, apply, summarize]`. Note that the `summarize` role is not currently used. +- `capabilities`: Array of strings denoting model capabilities, which will overwrite Continue's autodetection based on provider and model. Supported capabilities include `tool_use` and `image_input`. - `embedOptions`: If the model includes role `embed`, these settings apply for embeddings: - `maxChunkSize`: Maximum tokens per document chunk. Minimum is 128 tokens. @@ -187,6 +188,17 @@ models: model: codestral-latest roles: - autocomplete + + - name: My Model - OpenAI-Compatible + provider: openai + apiBase: http://my-endpoint/v1 + model: my-custom-model + capabilities: + - tool_use + - image_input + roles: + - chat + - edit ``` --- From c707feb5bd787d1feb54e8b2ac9cfc68985fdac0 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 4 Mar 2025 11:11:27 -0800 Subject: [PATCH 04/14] bump and release new config yaml version --- packages/config-yaml/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index 9433fbc30..9163700c4 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.52", + "version": "1.0.53", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From b5cbc5f1d2a77123a84c4fc9a3b64f12d32d0c33 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 10 Mar 2025 12:13:38 -0700 Subject: [PATCH 05/14] bump config-yaml version --- packages/config-yaml/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index 9163700c4..7c7619e97 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.53", + "version": "1.0.56", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", From f9535c32d68006ea020f4e0a69dab7ba60eaa2d7 Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 10 Mar 2025 14:03:58 -0700 Subject: [PATCH 06/14] bump config-yaml version --- core/package-lock.json | 8 ++++---- core/package.json | 2 +- gui/package-lock.json | 10 +++++----- gui/package.json | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/package-lock.json b/core/package-lock.json index a15d33faf..ec99105e1 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.52", + "@continuedev/config-yaml": "^1.0.56", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", @@ -3038,9 +3038,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.52", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.52.tgz", - "integrity": "sha512-x0m4bcQpjHrrv95cq5tsen4Hb6yKCVGn+NeojyzNQYnRD0If/On+ATgX78uXtQtZxsdO4ip73HHCyQlA0O3ZyQ==", + "version": "1.0.56", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.56.tgz", + "integrity": "sha512-2OBhmlSFOgZ+Z/ZQ18R/JR9zo6HIzkQ09PCuHQQ9NanN+g5AEVCdWgEtMyOq5DmQM3HLJCoLMXwqzQ9qSJEfFg==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/core/package.json b/core/package.json index a88bf0cf1..75c47caf6 100644 --- a/core/package.json +++ b/core/package.json @@ -46,7 +46,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.52", + "@continuedev/config-yaml": "^1.0.56", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/gui/package-lock.json b/gui/package-lock.json index 74273c5aa..619c645fe 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.52", + "@continuedev/config-yaml": "^1.0.56", "@headlessui/react": "^1.7.17", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -107,7 +107,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.52", + "@continuedev/config-yaml": "^1.0.56", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", @@ -555,9 +555,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.52", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.52.tgz", - "integrity": "sha512-x0m4bcQpjHrrv95cq5tsen4Hb6yKCVGn+NeojyzNQYnRD0If/On+ATgX78uXtQtZxsdO4ip73HHCyQlA0O3ZyQ==", + "version": "1.0.56", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.56.tgz", + "integrity": "sha512-2OBhmlSFOgZ+Z/ZQ18R/JR9zo6HIzkQ09PCuHQQ9NanN+g5AEVCdWgEtMyOq5DmQM3HLJCoLMXwqzQ9qSJEfFg==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/gui/package.json b/gui/package.json index 9a9b8d737..b54727753 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.52", + "@continuedev/config-yaml": "^1.0.56", "@headlessui/react": "^1.7.17", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", From 00eb26099f9ef7ed5c828c8df6a710ac58254faf Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 11 Mar 2025 15:35:12 -0700 Subject: [PATCH 07/14] local assistant instead of config --- core/config/profile/LocalProfileLoader.ts | 2 +- core/config/yaml/convertFromJson.ts | 4 ++-- core/config/yaml/default.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/config/profile/LocalProfileLoader.ts b/core/config/profile/LocalProfileLoader.ts index 13a1480c9..396b37e62 100644 --- a/core/config/profile/LocalProfileLoader.ts +++ b/core/config/profile/LocalProfileLoader.ts @@ -30,7 +30,7 @@ export default class LocalProfileLoader implements IProfileLoader { versionSlug: "", }, iconUrl: "", - title: overrideAssistantFile?.path ?? "Local Config", + title: overrideAssistantFile?.path ?? "Local Assistant", errors: undefined, uri: overrideAssistantFile?.path ?? diff --git a/core/config/yaml/convertFromJson.ts b/core/config/yaml/convertFromJson.ts index fdf73606f..ef928e6a6 100644 --- a/core/config/yaml/convertFromJson.ts +++ b/core/config/yaml/convertFromJson.ts @@ -1,4 +1,4 @@ -import { ModelConfig, AssistantUnrolled } from "@continuedev/config-yaml"; +import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml"; import { SerializedContinueConfig } from "../.."; @@ -6,7 +6,7 @@ export function convertConfigJsonToConfigYaml( configJson: SerializedContinueConfig, ): AssistantUnrolled { return { - name: "Local Config", + name: "Local Assistant", version: "1.0.0", models: [ ...configJson.models.map( diff --git a/core/config/yaml/default.ts b/core/config/yaml/default.ts index c9ca4dc8e..b63b2b848 100644 --- a/core/config/yaml/default.ts +++ b/core/config/yaml/default.ts @@ -4,13 +4,13 @@ import { AssistantUnrolled } from "@continuedev/config-yaml"; export const defaultConfigYaml: AssistantUnrolled = { models: [], context: [], - name: "Local Config", + name: "Local Assistant", version: "1.0.0", }; export const defaultConfigYamlJetBrains: AssistantUnrolled = { models: [], context: [], - name: "Local Config", + name: "Local Assistant", version: "1.0.0", }; From eba181c92df0398dc13c8aca5ff9c9c85dcf527e Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 11 Mar 2025 16:11:01 -0700 Subject: [PATCH 08/14] override ignore pattern when searching for config.yaml (local assistants) --- core/config/getSystemPromptDotFile.ts | 11 ++++++++++- core/indexing/walkDir.ts | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/config/getSystemPromptDotFile.ts b/core/config/getSystemPromptDotFile.ts index fa07b9cfd..652f4285a 100644 --- a/core/config/getSystemPromptDotFile.ts +++ b/core/config/getSystemPromptDotFile.ts @@ -1,4 +1,9 @@ +import ignore from "ignore"; import { IDE } from ".."; +import { + DEFAULT_IGNORE_DIRS, + DEFAULT_IGNORE_FILETYPES, +} from "../indexing/ignore"; import { walkDir } from "../indexing/walkDir"; import { getGlobalAssistantsPath } from "../util/paths"; import { localPathToUri } from "../util/pathToUri"; @@ -41,7 +46,11 @@ export async function getAssistantFilesFromDir( return []; } - const uris = await walkDir(dir, ide); + const overrideIgnore = ignore() + .add(DEFAULT_IGNORE_FILETYPES.filter((t) => t !== "config.yaml")) + .add(DEFAULT_IGNORE_DIRS); + + const uris = await walkDir(dir, ide, { overrideIgnore }); const assistantFilePaths = uris.filter( (p) => p.endsWith(".yaml") || p.endsWith(".yml"), ); diff --git a/core/indexing/walkDir.ts b/core/indexing/walkDir.ts index 757163d96..a544cff9e 100644 --- a/core/indexing/walkDir.ts +++ b/core/indexing/walkDir.ts @@ -12,6 +12,7 @@ import { export interface WalkerOptions { onlyDirs?: boolean; returnRelativeUrisPaths?: boolean; + overrideIgnore?: Ignore; } type Entry = [string, FileType]; @@ -46,7 +47,7 @@ class DFSWalker { // walk is a depth-first search implementation public async *walk(): AsyncGenerator { const defaultAndGlobalIgnores = ignore() - .add(defaultIgnoreFileAndDir) + .add(this.options.overrideIgnore ?? defaultIgnoreFileAndDir) .add(getGlobalContinueIgArray()); const rootContext: WalkContext = { From 762881f981635ad38b3be1ee15a12903cbdb97d0 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 11 Mar 2025 16:38:30 -0700 Subject: [PATCH 09/14] reload assistants when a new local one is created --- .gitignore | 2 +- core/config/ConfigHandler.ts | 2 +- core/config/getSystemPromptDotFile.ts | 65 ----------------------- core/config/loadLocalAssistants.ts | 76 +++++++++++++++++++++++++++ core/core.ts | 8 +++ extensions/vscode/package-lock.json | 4 +- 6 files changed, 88 insertions(+), 69 deletions(-) create mode 100644 core/config/loadLocalAssistants.ts diff --git a/.gitignore b/.gitignore index b24d52983..763b96238 100644 --- a/.gitignore +++ b/.gitignore @@ -169,4 +169,4 @@ extensions/.continue-debug/ *.vsix .continuerules -.continue/assistants/ \ No newline at end of file +**/.continue/assistants/ \ No newline at end of file diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 8f2c6ad4c..b84349eaa 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -16,7 +16,7 @@ import { import Ollama from "../llm/llms/Ollama.js"; import { GlobalContext } from "../util/GlobalContext.js"; -import { getAllAssistantFiles } from "./getSystemPromptDotFile.js"; +import { getAllAssistantFiles } from "./loadLocalAssistants.js"; import { LOCAL_ONBOARDING_CHAT_MODEL, LOCAL_ONBOARDING_PROVIDER_TITLE, diff --git a/core/config/getSystemPromptDotFile.ts b/core/config/getSystemPromptDotFile.ts index 652f4285a..550144cd8 100644 --- a/core/config/getSystemPromptDotFile.ts +++ b/core/config/getSystemPromptDotFile.ts @@ -1,12 +1,4 @@ -import ignore from "ignore"; import { IDE } from ".."; -import { - DEFAULT_IGNORE_DIRS, - DEFAULT_IGNORE_FILETYPES, -} from "../indexing/ignore"; -import { walkDir } from "../indexing/walkDir"; -import { getGlobalAssistantsPath } from "../util/paths"; -import { localPathToUri } from "../util/pathToUri"; import { joinPathsToUri } from "../util/uri"; export const SYSTEM_PROMPT_DOT_FILE = ".continuerules"; @@ -32,60 +24,3 @@ export async function getSystemPromptDotFile(ide: IDE): Promise { return prompts.join("\n\n"); } - -export const ASSISTANTS_FOLDER = ".continue/assistants"; - -export async function getAssistantFilesFromDir( - ide: IDE, - dir: string, -): Promise<{ path: string; content: string }[]> { - try { - const exists = await ide.fileExists(dir); - - if (!exists) { - return []; - } - - const overrideIgnore = ignore() - .add(DEFAULT_IGNORE_FILETYPES.filter((t) => t !== "config.yaml")) - .add(DEFAULT_IGNORE_DIRS); - - const uris = await walkDir(dir, ide, { overrideIgnore }); - const assistantFilePaths = uris.filter( - (p) => p.endsWith(".yaml") || p.endsWith(".yml"), - ); - const results = assistantFilePaths.map(async (uri) => { - const content = await ide.readFile(uri); // make a try catch - return { path: uri, content }; - }); - return Promise.all(results); - } catch (e) { - console.error(e); - return []; - } -} - -export async function getAllAssistantFiles( - ide: IDE, -): Promise<{ path: string; content: string }[]> { - const workspaceDirs = await ide.getWorkspaceDirs(); - let assistantFiles: { path: string; content: string }[] = []; - - let dirsToCheck = [ASSISTANTS_FOLDER]; - const fullDirs = workspaceDirs - .map((dir) => dirsToCheck.map((d) => joinPathsToUri(dir, d))) - .flat(); - - fullDirs.push(localPathToUri(getGlobalAssistantsPath())); - - assistantFiles = ( - await Promise.all(fullDirs.map((dir) => getAssistantFilesFromDir(ide, dir))) - ).flat(); - - return await Promise.all( - assistantFiles.map(async (file) => { - const content = await ide.readFile(file.path); - return { path: file.path, content }; - }), - ); -} diff --git a/core/config/loadLocalAssistants.ts b/core/config/loadLocalAssistants.ts new file mode 100644 index 000000000..6eb6670ea --- /dev/null +++ b/core/config/loadLocalAssistants.ts @@ -0,0 +1,76 @@ +import ignore from "ignore"; +import { IDE } from ".."; +import { + DEFAULT_IGNORE_DIRS, + DEFAULT_IGNORE_FILETYPES, +} from "../indexing/ignore"; +import { walkDir } from "../indexing/walkDir"; +import { getGlobalAssistantsPath } from "../util/paths"; +import { localPathToUri } from "../util/pathToUri"; +import { joinPathsToUri } from "../util/uri"; + +export const ASSISTANTS_FOLDER = ".continue/assistants"; + +export function isLocalAssistantFile(uri: string): boolean { + if (!uri.endsWith(".yaml") && !uri.endsWith(".yml")) { + return false; + } + + const normalizedUri = uri.replace(/\\/g, "/"); + return normalizedUri.includes(`/${ASSISTANTS_FOLDER}/`); +} + +export async function getAssistantFilesFromDir( + ide: IDE, + dir: string, +): Promise<{ path: string; content: string }[]> { + try { + const exists = await ide.fileExists(dir); + + if (!exists) { + return []; + } + + const overrideIgnore = ignore() + .add(DEFAULT_IGNORE_FILETYPES.filter((t) => t !== "config.yaml")) + .add(DEFAULT_IGNORE_DIRS); + + const uris = await walkDir(dir, ide, { overrideIgnore }); + const assistantFilePaths = uris.filter( + (p) => p.endsWith(".yaml") || p.endsWith(".yml"), + ); + const results = assistantFilePaths.map(async (uri) => { + const content = await ide.readFile(uri); // make a try catch + return { path: uri, content }; + }); + return Promise.all(results); + } catch (e) { + console.error(e); + return []; + } +} + +export async function getAllAssistantFiles( + ide: IDE, +): Promise<{ path: string; content: string }[]> { + const workspaceDirs = await ide.getWorkspaceDirs(); + let assistantFiles: { path: string; content: string }[] = []; + + let dirsToCheck = [ASSISTANTS_FOLDER]; + const fullDirs = workspaceDirs + .map((dir) => dirsToCheck.map((d) => joinPathsToUri(dir, d))) + .flat(); + + fullDirs.push(localPathToUri(getGlobalAssistantsPath())); + + assistantFiles = ( + await Promise.all(fullDirs.map((dir) => getAssistantFilesFromDir(ide, dir))) + ).flat(); + + return await Promise.all( + assistantFiles.map(async (file) => { + const content = await ide.readFile(file.path); + return { path: file.path, content }; + }), + ); +} diff --git a/core/core.ts b/core/core.ts index 037bb48ce..8e14aa668 100644 --- a/core/core.ts +++ b/core/core.ts @@ -44,6 +44,7 @@ import { type IndexingProgressUpdate, } from "."; +import { isLocalAssistantFile } from "./config/loadLocalAssistants"; import { shouldIgnore } from "./indexing/shouldIgnore"; import type { FromCoreProtocol, ToCoreProtocol } from "./protocol"; import type { IMessenger, Message } from "./protocol/messenger"; @@ -926,6 +927,13 @@ export class Core { on("files/created", async ({ data }) => { if (data?.uris?.length) { void refreshIfNotIgnored(data.uris); + + // If it's a local assistant being created, we want to reload all assistants so it shows up in the list + for (const uri of data.uris) { + if (isLocalAssistantFile(uri)) { + await this.configHandler.loadAssistantsForSelectedOrg(); + } + } } }); diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 5f7702aee..dc6465ddd 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.7", + "version": "1.1.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.7", + "version": "1.1.8", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", From dc9485763163a1d23335d45fc5c789bbf44f3514 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 11 Mar 2025 16:38:41 -0700 Subject: [PATCH 10/14] default local assistant name to basename, not full uri --- core/config/profile/LocalProfileLoader.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/config/profile/LocalProfileLoader.ts b/core/config/profile/LocalProfileLoader.ts index 396b37e62..94af3a0e2 100644 --- a/core/config/profile/LocalProfileLoader.ts +++ b/core/config/profile/LocalProfileLoader.ts @@ -6,6 +6,7 @@ import { ProfileDescription } from "../ProfileLifecycleManager.js"; import { getPrimaryConfigFilePath } from "../../util/paths.js"; import { localPathToUri } from "../../util/pathToUri.js"; +import { getUriPathBasename } from "../../util/uri.js"; import doLoadConfig from "./doLoadConfig.js"; import { IProfileLoader } from "./IProfileLoader.js"; @@ -30,7 +31,9 @@ export default class LocalProfileLoader implements IProfileLoader { versionSlug: "", }, iconUrl: "", - title: overrideAssistantFile?.path ?? "Local Assistant", + title: overrideAssistantFile?.path + ? getUriPathBasename(overrideAssistantFile.path) + : "Local Assistant", errors: undefined, uri: overrideAssistantFile?.path ?? From ce24a200f56c2153ed327398b03aa51f288f8f2b Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 11 Mar 2025 17:14:10 -0700 Subject: [PATCH 11/14] correctly persist selected profile --- core/core.ts | 7 +++++-- core/protocol/core.ts | 5 ++++- gui/src/context/Auth.tsx | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/core.ts b/core/core.ts index 8e14aa668..fd4c6eb62 100644 --- a/core/core.ts +++ b/core/core.ts @@ -295,8 +295,11 @@ export class Core { this.configHandler.updateIdeSettings(msg.data); }); - on("config/listProfiles", (msg) => { - return this.configHandler.listProfiles(); + on("config/listProfiles", async (msg) => { + const profiles = this.configHandler.listProfiles(); + const selectedProfileId = + this.configHandler.currentProfile?.profileDescription.id ?? null; + return { profiles, selectedProfileId }; }); on("config/refreshProfiles", async (msg) => { diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 1b19a46cb..138c7e9d3 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -68,7 +68,10 @@ export type ToCoreFromIdeOrWebviewProtocol = { "config/deleteModel": [{ title: string }, void]; "config/addContextProvider": [ContextProviderWithParams, void]; "config/reload": [undefined, ConfigResult]; - "config/listProfiles": [undefined, ProfileDescription[] | null]; + "config/listProfiles": [ + undefined, + { profiles: ProfileDescription[] | null; selectedProfileId: string | null }, + ]; "config/refreshProfiles": [undefined, void]; "config/openProfile": [{ profileId: string | undefined }, void]; "config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema]; diff --git a/gui/src/context/Auth.tsx b/gui/src/context/Auth.tsx index 807065019..d4e6f7925 100644 --- a/gui/src/context/Auth.tsx +++ b/gui/src/context/Auth.tsx @@ -168,8 +168,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ if (result.status === "success") { dispatch( updateProfilesThunk({ - profiles: result.content, - selectedProfileId: null, + profiles: result.content.profiles, + selectedProfileId: result.content.selectedProfileId, }), ); } From 0510ab3fcdc82218183091cad1391103396e47e2 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 11 Mar 2025 17:40:06 -0700 Subject: [PATCH 12/14] default all tools to allowed with permission --- gui/src/redux/slices/uiSlice.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index 01c398eb5..8b03d30f3 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -88,9 +88,8 @@ export const uiSlice = createSlice({ state.useTools = !state.useTools; }, addTool: (state, action: PayloadAction) => { - state.toolSettings[action.payload.function.name] = action.payload.readonly - ? "allowedWithoutPermission" - : "allowedWithPermission"; + state.toolSettings[action.payload.function.name] = + "allowedWithPermission"; }, toggleToolSetting: (state, action: PayloadAction) => { const setting = state.toolSettings[action.payload]; From 6ee1df8b06eb2596b789d36ce7c6ad4b7c1caf94 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 11 Mar 2025 19:22:35 -0700 Subject: [PATCH 13/14] remove unecessary loading --- core/config/ConfigHandler.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index b84349eaa..f5b1b18da 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -114,12 +114,6 @@ export class ConfigHandler { } private async init() { - try { - await this.loadLocalProfilesOnly(); - } catch (e) { - console.error("Failed to load local assistants: ", e); - } - try { await this.fetchControlPlaneProfiles(); } catch (e) { @@ -357,6 +351,9 @@ export class ConfigHandler { } async setSelectedProfile(profileId: string | null) { + console.log( + `Changing selected profile from ${this.selectedProfileId} to ${profileId}`, + ); this.selectedProfileId = profileId; const result = await this.loadConfig(); this.notifyConfigListeners(result); From 5c904a1c686532c723a65ed6399b6f27060a97ff Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 11 Mar 2025 19:39:24 -0700 Subject: [PATCH 14/14] select first org on login --- core/config/ConfigHandler.ts | 16 +++++++++++++++- core/core.ts | 5 +++++ core/protocol/coreWebview.ts | 1 + core/protocol/passThrough.ts | 1 + .../constants/MessageTypes.kt | 1 + gui/src/pages/config/ScopeSelect.tsx | 5 +++++ 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index f5b1b18da..3eadb9708 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -50,6 +50,7 @@ export class ConfigHandler { private ideSettingsPromise: Promise, private readonly writeLog: (text: string) => Promise, sessionInfoPromise: Promise, + private readonly didSelectOrganization?: (orgId: string | null) => void, ) { this.ide = ide; this.ideSettingsPromise = ideSettingsPromise; @@ -340,7 +341,8 @@ export class ConfigHandler { async getSelectedOrgId(): Promise { const selectedOrgs = this.globalContext.get("lastSelectedOrgIdForWorkspace") ?? {}; - return selectedOrgs[await this.getWorkspaceId()] ?? null; + const workspaceId = await this.getWorkspaceId(); + return selectedOrgs[workspaceId] ?? null; } async setSelectedOrgId(orgId: string | null) { @@ -348,6 +350,7 @@ export class ConfigHandler { this.globalContext.get("lastSelectedOrgIdForWorkspace") ?? {}; selectedOrgs[await this.getWorkspaceId()] = orgId; this.globalContext.update("lastSelectedOrgIdForWorkspace", selectedOrgs); + this.didSelectOrganization?.(orgId); } async setSelectedProfile(profileId: string | null) { @@ -385,6 +388,17 @@ export class ConfigHandler { Promise.resolve(sessionInfo), this.ideSettingsPromise, ); + + // After login, default to the first org as the selected org + try { + const orgs = await this.controlPlaneClient.listOrganizations(); + if (orgs.length) { + await this.setSelectedOrgId(orgs[0].id); + } + } catch (e) { + console.error("Failed to fetch control plane profiles: ", e); + } + this.fetchControlPlaneProfiles().catch(async (e) => { console.error("Failed to fetch control plane profiles: ", e); await this.loadLocalProfilesOnly(); diff --git a/core/core.ts b/core/core.ts index fd4c6eb62..77505a976 100644 --- a/core/core.ts +++ b/core/core.ts @@ -107,6 +107,11 @@ export class Core { ideSettingsPromise, this.onWrite, sessionInfoPromise, + (orgId: string | null) => { + void messenger.request("didSelectOrganization", { + orgId, + }); + }, ); this.docsService = DocsService.createSingleton( diff --git a/core/protocol/coreWebview.ts b/core/protocol/coreWebview.ts index 5e71e5f11..4dcf74ee5 100644 --- a/core/protocol/coreWebview.ts +++ b/core/protocol/coreWebview.ts @@ -15,4 +15,5 @@ export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol & { { profiles: ProfileDescription[]; selectedProfileId: string | null }, void, ]; + didSelectOrganization: [{ orgId: string | null }, void]; }; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 352075d2e..7d0d51fc0 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -85,4 +85,5 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] = "getCurrentSessionId", "docs/suggestions", "didCloseFiles", + "didSelectOrganization", ]; diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index 81a6e1313..945fb218c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -72,6 +72,7 @@ class MessageTypes { "getCurrentSessionId", "docs/suggestions", "didCloseFiles", + "didSelectOrganization" ) // Note: If updating these values, make a corresponding update in diff --git a/gui/src/pages/config/ScopeSelect.tsx b/gui/src/pages/config/ScopeSelect.tsx index c67f68241..2d42483a0 100644 --- a/gui/src/pages/config/ScopeSelect.tsx +++ b/gui/src/pages/config/ScopeSelect.tsx @@ -5,6 +5,7 @@ import { UserCircleIcon, } from "@heroicons/react/24/outline"; import { useAuth } from "../../context/Auth"; +import { useWebviewListener } from "../../hooks/useWebviewListener"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { selectOrgThunk } from "../../redux/thunks/profileAndOrg"; @@ -19,6 +20,10 @@ export function ScopeSelect() { dispatch(selectOrgThunk(newValue)); }; + useWebviewListener("didSelectOrganization", async (data) => { + handleChange(data.orgId); + }); + const CurScopeEntityFallBackIcon = selectedOrgId ? BuildingOfficeIcon : UserCircleIcon;