@@ -19,7 +19,6 @@ import {
1919 ContinueRcJson ,
2020 CustomContextProvider ,
2121 EmbeddingsProviderDescription ,
22- IContextProvider ,
2322 IDE ,
2423 IdeInfo ,
2524 IdeSettings ,
@@ -36,10 +35,6 @@ import { getLegacyBuiltInSlashCommandFromDescription } from "../commands/slash/b
3635import { convertCustomCommandToSlashCommand } from "../commands/slash/customSlashCommand" ;
3736import { slashCommandFromPromptFile } from "../commands/slash/promptFileSlashCommand" ;
3837import { MCPManagerSingleton } from "../context/mcp/MCPManagerSingleton" ;
39- import ContinueProxyContextProvider from "../context/providers/ContinueProxyContextProvider" ;
40- import CustomContextProviderClass from "../context/providers/CustomContextProvider" ;
41- import FileContextProvider from "../context/providers/FileContextProvider" ;
42- import { contextProviderClassFromName } from "../context/providers/index" ;
4338import { useHub } from "../control-plane/env" ;
4439import { BaseLLM } from "../llm" ;
4540import { LLMClasses , llmFromDescription } from "../llm/llms" ;
@@ -62,9 +57,11 @@ import {
6257} from "../util/paths" ;
6358import { localPathToUri } from "../util/pathToUri" ;
6459
60+ import CustomContextProviderClass from "../context/providers/CustomContextProvider" ;
6561import { getToolsForIde } from "../tools" ;
6662import { resolveRelativePathInDir } from "../util/ideUtils" ;
6763import { getWorkspaceRcConfigs } from "./json/loadRcConfigs" ;
64+ import { loadConfigContextProviders } from "./loadContextProviders" ;
6865import { modifyAnyConfigWithSharedConfig } from "./sharedConfig" ;
6966import {
7067 getModelByRole ,
@@ -229,7 +226,7 @@ function applyRequestOptionsToModels(
229226export function isContextProviderWithParams (
230227 contextProvider : CustomContextProvider | ContextProviderWithParams ,
231228) : contextProvider is ContextProviderWithParams {
232- return ( contextProvider as ContextProviderWithParams ) . name !== undefined ;
229+ return "name" in contextProvider && ! ! contextProvider . name ;
233230}
234231
235232/** Only difference between intermediate and final configs is the `models` array */
@@ -386,50 +383,25 @@ async function intermediateToFinalConfig({
386383
387384 applyRequestOptionsToModels ( tabAutocompleteModels , config ) ;
388385
389- // These context providers are always included, regardless of what, if anything,
390- // the user has configured in config.json
391-
392- const codebaseContextParams =
393- (
394- ( config . contextProviders || [ ] )
395- . filter ( isContextProviderWithParams )
396- . find ( ( cp ) => cp . name === "codebase" ) as
397- | ContextProviderWithParams
398- | undefined
399- ) ?. params || { } ;
400-
401- const DEFAULT_CONTEXT_PROVIDERS = [ new FileContextProvider ( { } ) ] ;
402-
403- const DEFAULT_CONTEXT_PROVIDERS_TITLES = DEFAULT_CONTEXT_PROVIDERS . map (
404- ( { description : { title } } ) => title ,
405- ) ;
406-
407- // Context providers
408- const contextProviders : IContextProvider [ ] = DEFAULT_CONTEXT_PROVIDERS ;
409-
410- for ( const provider of config . contextProviders || [ ] ) {
411- if ( isContextProviderWithParams ( provider ) ) {
412- const cls = contextProviderClassFromName ( provider . name ) as any ;
413- if ( ! cls ) {
414- if ( ! DEFAULT_CONTEXT_PROVIDERS_TITLES . includes ( provider . name ) ) {
415- console . warn ( `Unknown context provider ${ provider . name } ` ) ;
416- }
417-
418- continue ;
419- }
420- const instance : IContextProvider = new cls ( provider . params ) ;
421-
422- // Handle continue-proxy
423- if ( instance . description . title === "continue-proxy" ) {
424- ( instance as ContinueProxyContextProvider ) . workOsAccessToken =
425- workOsAccessToken ;
426- }
386+ // Load context providers
387+ const { providers : contextProviders , errors : contextErrors } =
388+ loadConfigContextProviders (
389+ config . contextProviders
390+ ?. filter ( ( cp ) => isContextProviderWithParams ( cp ) )
391+ . map ( ( cp ) => ( {
392+ provider : ( cp as ContextProviderWithParams ) . name ,
393+ params : ( cp as ContextProviderWithParams ) . params ,
394+ } ) ) ,
395+ ! ! config . docs ?. length ,
396+ ideInfo . ideType ,
397+ ) ;
427398
428- contextProviders . push ( instance ) ;
429- } else {
430- contextProviders . push ( new CustomContextProviderClass ( provider ) ) ;
399+ for ( const cp of config . contextProviders ?? [ ] ) {
400+ if ( ! isContextProviderWithParams ( cp ) ) {
401+ contextProviders . push ( new CustomContextProviderClass ( cp ) ) ;
431402 }
432403 }
404+ errors . push ( ...contextErrors ) ;
433405
434406 // Embeddings Provider
435407 function getEmbeddingsILLM (
0 commit comments