diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 790bc01d8..f841a5fdf 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -17,7 +17,10 @@ import { import Ollama from "../llm/llms/Ollama.js"; import { GlobalContext } from "../util/GlobalContext.js"; -import { getAllAssistantFiles } from "./loadLocalAssistants.js"; +import { + getAllAssistantFiles, + LoadAssistantFilesOptions, +} from "./loadLocalAssistants.js"; import { LOCAL_ONBOARDING_CHAT_MODEL, LOCAL_ONBOARDING_PROVIDER_TITLE, @@ -295,10 +298,7 @@ export class ConfigHandler { }; } - async getLocalProfiles(options: { - includeGlobal: boolean | undefined; - includeWorkspace: boolean | undefined; - }) { + async getLocalProfiles(options: LoadAssistantFilesOptions) { /** * Users can define as many local assistants as they want in a `.continue/assistants` folder */ @@ -309,7 +309,7 @@ export class ConfigHandler { } if (options.includeWorkspace) { - const assistantFiles = await getAllAssistantFiles(this.ide); + const assistantFiles = await getAllAssistantFiles(this.ide, options); const profiles = assistantFiles.map((assistant) => { return new LocalProfileLoader( this.ide, diff --git a/core/config/loadLocalAssistants.ts b/core/config/loadLocalAssistants.ts index 7faa87d5e..296a8ae30 100644 --- a/core/config/loadLocalAssistants.ts +++ b/core/config/loadLocalAssistants.ts @@ -53,18 +53,32 @@ export async function getAssistantFilesFromDir( } } +export interface LoadAssistantFilesOptions { + includeGlobal: boolean; + includeWorkspace: boolean; +} + export async function getAllAssistantFiles( ide: IDE, + options: LoadAssistantFilesOptions, ): 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(); + let fullDirs: string[] = []; - fullDirs.push(localPathToUri(getGlobalAssistantsPath())); + // Workspace .continue/assistants + if (options.includeWorkspace) { + fullDirs = workspaceDirs + .map((dir) => dirsToCheck.map((d) => joinPathsToUri(dir, d))) + .flat(); + } + + // ~/.continue/assistants + if (options.includeGlobal) { + fullDirs.push(localPathToUri(getGlobalAssistantsPath())); + } assistantFiles = ( await Promise.all(fullDirs.map((dir) => getAssistantFilesFromDir(ide, dir)))