From aa2aff01c046cf30c19e95c0d22b640d10bcd786 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 8 Apr 2025 15:07:11 -0700 Subject: [PATCH] include workspace assistants when in org scope --- core/config/ConfigHandler.ts | 70 ++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 2d4a471d5..790bc01d8 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -197,7 +197,11 @@ export class ConfigHandler { private async getNonPersonalHubOrg( org: OrganizationDescription, ): Promise { - const profiles = await this.getHubProfiles(org.id); + const localProfiles = await this.getLocalProfiles({ + includeGlobal: false, + includeWorkspace: true, + }); + const profiles = [...(await this.getHubProfiles(org.id)), ...localProfiles]; return this.rectifyProfilesForOrg(org, profiles); } @@ -208,20 +212,29 @@ export class ConfigHandler { slug: undefined, }; private async getPersonalHubOrg() { - const allLocalProfiles = await this.getAllLocalProfiles(); + const localProfiles = await this.getLocalProfiles({ + includeGlobal: true, + includeWorkspace: true, + }); const hubProfiles = await this.getHubProfiles(null); - const profiles = [...hubProfiles, ...allLocalProfiles]; + const profiles = [...hubProfiles, ...localProfiles]; return this.rectifyProfilesForOrg(this.PERSONAL_ORG_DESC, profiles); } private async getLocalOrg() { - const allLocalProfiles = await this.getAllLocalProfiles(); - return this.rectifyProfilesForOrg(this.PERSONAL_ORG_DESC, allLocalProfiles); + const localProfiles = await this.getLocalProfiles({ + includeGlobal: true, + includeWorkspace: true, + }); + return this.rectifyProfilesForOrg(this.PERSONAL_ORG_DESC, localProfiles); } async getTeamsOrg(org: OrganizationDescription): Promise { const workspaces = await this.controlPlaneClient.listWorkspaces(); - const profiles = await this.getAllLocalProfiles(); + const localProfiles = await this.getLocalProfiles({ + includeGlobal: true, + includeWorkspace: true, + }); workspaces.forEach((workspace) => { const profileLoader = new ControlPlaneProfileLoader( workspace.id, @@ -233,9 +246,9 @@ export class ConfigHandler { this.reloadConfig.bind(this), ); - profiles.push(new ProfileLifecycleManager(profileLoader, this.ide)); + localProfiles.push(new ProfileLifecycleManager(profileLoader, this.ide)); }); - return this.rectifyProfilesForOrg(org, profiles); + return this.rectifyProfilesForOrg(org, localProfiles); } private async rectifyProfilesForOrg( @@ -282,24 +295,37 @@ export class ConfigHandler { }; } - async getAllLocalProfiles() { + async getLocalProfiles(options: { + includeGlobal: boolean | undefined; + includeWorkspace: boolean | undefined; + }) { /** * Users can define as many local assistants as they want in a `.continue/assistants` folder */ - const assistantFiles = await getAllAssistantFiles(this.ide); - const profiles = assistantFiles.map((assistant) => { - return new LocalProfileLoader( - this.ide, - this.ideSettingsPromise, - this.controlPlaneClient, - this.llmLogger, - assistant, + const localProfiles: ProfileLifecycleManager[] = []; + + if (options.includeGlobal) { + localProfiles.push(this.globalLocalProfileManager); + } + + if (options.includeWorkspace) { + const assistantFiles = await getAllAssistantFiles(this.ide); + const profiles = assistantFiles.map((assistant) => { + return new LocalProfileLoader( + this.ide, + this.ideSettingsPromise, + this.controlPlaneClient, + this.llmLogger, + assistant, + ); + }); + const localAssistantProfiles = profiles.map( + (profile) => new ProfileLifecycleManager(profile, this.ide), ); - }); - const localAssistantProfiles = profiles.map( - (profile) => new ProfileLifecycleManager(profile, this.ide), - ); - return [this.globalLocalProfileManager, ...localAssistantProfiles]; + localProfiles.push(...localAssistantProfiles); + } + + return localProfiles; } //////////////////