chore: add docs as top level config (#1816)

* chore: add docs as top level config

* Update core.ts
This commit is contained in:
Patrick Erichsen 2024-07-23 13:52:53 -07:00 • committed by GitHub
parent d80837ae62
commit dafd2c4c72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 53 additions and 19 deletions

View file

@ -167,7 +167,9 @@ class DocsContextProvider extends BaseContextProvider {
): Promise<ContextSubmenuItem[]> {
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<string, ContextSubmenuItem>();
if (!isJetBrains) {

View file

@ -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),

6
core/index.d.ts vendored
View file

@ -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 {

View file

@ -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).",