load ~/.continue/assistants
This commit is contained in:
parent
aa2aff01c0
commit
b66fe4185b
2 changed files with 24 additions and 10 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue