From dafd2c4c723c294ad16fd1e02cfc0d69fa9adb76 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 23 Jul 2024 13:52:53 -0700 Subject: [PATCH] chore: add docs as top level config (#1816) * chore: add docs as top level config * Update core.ts --- core/context/providers/DocsContextProvider.ts | 4 ++- core/core.ts | 35 ++++++++++--------- core/index.d.ts | 6 ++-- extensions/vscode/config_schema.json | 27 ++++++++++++++ 4 files changed, 53 insertions(+), 19 deletions(-) diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index c79ee4885..4d2da78dc 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -167,7 +167,9 @@ class DocsContextProvider extends BaseContextProvider { ): Promise { const ideInfo = await args.ide.getIdeInfo(); const isJetBrains = ideInfo.ideType === "jetbrains"; - const configSites = this.options?.sites || []; + const configSites = [ + ...new Set([...(this.options?.sites || []), ...(args.config.docs || [])]), + ]; const submenuItemsMap = new Map(); if (!isJetBrains) { diff --git a/core/core.ts b/core/core.ts index 5cf32478e..046319978 100644 --- a/core/core.ts +++ b/core/core.ts @@ -143,21 +143,19 @@ export class Core { ); // Index on initialization - this.ide - .getWorkspaceDirs() - .then(async (dirs) => { - // Respect pauseCodebaseIndexOnStart user settings - if (ideSettings.pauseCodebaseIndexOnStart) { - await this.messenger.request("indexProgress", { - progress: 100, - desc: "Initial Indexing Skipped", - status: "paused", - }); - return; - } + this.ide.getWorkspaceDirs().then(async (dirs) => { + // Respect pauseCodebaseIndexOnStart user settings + if (ideSettings.pauseCodebaseIndexOnStart) { + await this.messenger.request("indexProgress", { + progress: 100, + desc: "Initial Indexing Skipped", + status: "paused", + }); + return; + } - this.refreshCodebaseIndex(dirs); - }); + this.refreshCodebaseIndex(dirs); + }); }); const getLlm = async () => { @@ -280,8 +278,12 @@ export class Core { return; } - const siteIndexingOptions: SiteIndexingConfig[] = ((mProvider) => - mProvider?.options?.sites || [])({ ...provider }); + const siteIndexingOptions: SiteIndexingConfig[] = ((mProvider) => [ + ...new Set([ + ...(mProvider?.options?.sites || []), + ...(config.docs || []), + ]), + ])({ ...provider }); for (const site of siteIndexingOptions) { await this.getEmbeddingsProviderAndIndexDoc(site, msg.data.reIndex); @@ -294,6 +296,7 @@ export class Core { const items = config.contextProviders ?.find((provider) => provider.description.title === msg.data.title) ?.loadSubmenuItems({ + config, ide: this.ide, fetch: (url, init) => fetchwithRequestOptions(url, init, config.requestOptions), diff --git a/core/index.d.ts b/core/index.d.ts index bd8f99401..988f155ac 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -137,6 +137,7 @@ export interface ContextProviderExtras { } export interface LoadSubmenuItemsArgs { + config: ContinueConfig; ide: IDE; fetch: FetchFunction; } @@ -422,8 +423,8 @@ export interface IdeSettings { remoteConfigSyncPeriod: number; userToken: string; enableControlServerBeta: boolean; - pauseCodebaseIndexOnStart: boolean - enableDebugLogs: boolean + pauseCodebaseIndexOnStart: boolean; + enableDebugLogs: boolean; } export interface IDE { @@ -948,6 +949,7 @@ export interface ContinueConfig { ui?: ContinueUIConfig; reranker?: Reranker; experimental?: ExperimentalConfig; + docs?: SiteIndexingConfig[]; } export interface BrowserSerializedContinueConfig { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 0512f8ac0..f57459207 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1827,6 +1827,33 @@ "title": "config.json", "type": "object", "properties": { + "docs": { + "title": "Docs", + "description": "A list of documentation sites to be indexed", + "type": "array", + "items": { + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "The title of the documentation site" + }, + "startUrl": { + "type": "string", + "description": "The starting URL for indexing the documentation" + }, + "rootUrl": { + "type": "string", + "description": "The root URL of the documentation site" + }, + "maxDepth": { + "type": "integer", + "description": "The maximum depth to crawl the documentation site" + } + }, + "required": ["title", "startUrl"] + } + }, "allowAnonymousTelemetry": { "title": "Allow Anonymous Telemetry", "markdownDescription": "If this field is set to True, we will collect anonymous telemetry as described in the documentation page on telemetry. If set to `false`, we will not collect any data. Learn more in [the docs](https://docs.continue.dev/telemetry).",