From c64dd9319345bbe22f82c7ee2892132cbf845809 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 27 Jun 2025 17:44:49 +0530 Subject: [PATCH 001/282] add new `indexTypes` for context indexing --- core/context/providers/CodeContextProvider.ts | 2 +- .../providers/CodebaseContextProvider.ts | 1 + .../providers/FolderContextProvider.ts | 2 +- core/index.d.ts | 7 ++- core/indexing/CodebaseIndexer.ts | 58 +++++++++++++------ core/protocol/webview.ts | 2 +- gui/src/context/SubmenuContextProviders.tsx | 17 +++--- 7 files changed, 58 insertions(+), 31 deletions(-) diff --git a/core/context/providers/CodeContextProvider.ts b/core/context/providers/CodeContextProvider.ts index b746199b0..0a3c361a3 100644 --- a/core/context/providers/CodeContextProvider.ts +++ b/core/context/providers/CodeContextProvider.ts @@ -16,7 +16,7 @@ class CodeContextProvider extends BaseContextProvider { displayTitle: "Code", description: "Type to search", type: "submenu", - dependsOnIndexing: true, + indexTypes: ["chunk", "codeSnippets"], }; async getContextItems( diff --git a/core/context/providers/CodebaseContextProvider.ts b/core/context/providers/CodebaseContextProvider.ts index 51881f457..682a65a1f 100644 --- a/core/context/providers/CodebaseContextProvider.ts +++ b/core/context/providers/CodebaseContextProvider.ts @@ -13,6 +13,7 @@ class CodebaseContextProvider extends BaseContextProvider { description: "Automatically find relevant files", type: "normal", renderInlineAs: "", + indexTypes: ["embeddings", "fullTextSearch", "chunk"], }; async getContextItems( diff --git a/core/context/providers/FolderContextProvider.ts b/core/context/providers/FolderContextProvider.ts index b4d2e0e09..981ca8579 100644 --- a/core/context/providers/FolderContextProvider.ts +++ b/core/context/providers/FolderContextProvider.ts @@ -19,7 +19,7 @@ class FolderContextProvider extends BaseContextProvider { displayTitle: "Folder", description: "Type to search", type: "submenu", - dependsOnIndexing: true, + indexTypes: ["embeddings"], }; async getContextItems( diff --git a/core/index.d.ts b/core/index.d.ts index 4aea44fd4..68cf3aba6 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -165,6 +165,11 @@ export interface ModelInstaller { } export type ContextProviderType = "normal" | "query" | "submenu"; +export type ContextIndexingType = + | "chunk" + | "embeddings" + | "fullTextSearch" + | "codeSnippets"; export interface ContextProviderDescription { title: ContextProviderName; @@ -172,7 +177,7 @@ export interface ContextProviderDescription { description: string; renderInlineAs?: string; type: ContextProviderType; - dependsOnIndexing?: boolean; + indexTypes?: ContextIndexingType[]; } export type FetchFunction = (url: string | URL, init?: any) => Promise; diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index d2de0c512..880284e46 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -1,7 +1,12 @@ import * as fs from "fs/promises"; import { ConfigHandler } from "../config/ConfigHandler.js"; -import { IDE, IndexingProgressUpdate, IndexTag } from "../index.js"; +import { + ContextIndexingType, + IDE, + IndexingProgressUpdate, + IndexTag, +} from "../index.js"; import type { FromCoreProtocol, ToCoreProtocol } from "../protocol"; import type { IMessenger } from "../protocol/messenger"; import { extractMinimalStackTraceInfo } from "../util/extractMinimalStackTraceInfo.js"; @@ -123,28 +128,43 @@ export class CodebaseIndexer { return []; } - const indexes: CodebaseIndex[] = [ - new ChunkCodebaseIndex( - this.ide.readFile.bind(this.ide), - continueServerClient, - embeddingsModel.maxEmbeddingChunkSize, - ), // Chunking must come first - ]; - - const lanceDbIndex = await LanceDbIndex.create( - embeddingsModel, - this.ide.readFile.bind(this.ide), + const indexTypesToBuild = new Set( // use set to remove duplicates + config.contextProviders + .map((provider) => provider.description.indexTypes) + .filter((indexType) => Array.isArray(indexType)) // remove undefined indexTypes + .flat(), ); - if (lanceDbIndex) { - indexes.push(lanceDbIndex); + const indexTypeToIndexerMapping: Record< + ContextIndexingType, + () => Promise + > = { + chunk: async () => + new ChunkCodebaseIndex( + this.ide.readFile.bind(this.ide), + continueServerClient, + embeddingsModel.maxEmbeddingChunkSize, + ), + codeSnippets: async () => new CodeSnippetsCodebaseIndex(this.ide), + fullTextSearch: async () => new FullTextSearchCodebaseIndex(), + embeddings: async () => { + const lanceDbIndex = await LanceDbIndex.create( + embeddingsModel, + this.ide.readFile.bind(this.ide), + ); + return lanceDbIndex; + }, + }; + + const indexes: CodebaseIndex[] = []; + // not parallelizing to avoid race conditions in sqlite + for (const indexType of indexTypesToBuild) { + const index = await indexTypeToIndexerMapping[indexType](); + if (index) { + indexes.push(index); + } } - indexes.push( - new FullTextSearchCodebaseIndex(), - new CodeSnippetsCodebaseIndex(this.ide), - ); - return indexes; } diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index 1a8d40313..b43bf271f 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -24,7 +24,7 @@ export type ToWebviewFromIdeOrCoreProtocol = { "indexing/statusUpdate": [IndexingStatus, void]; // Docs, etc. refreshSubmenuItems: [ { - providers: "all" | "dependsOnIndexing" | ContextProviderName[]; + providers: "all" | "indexTypes" | ContextProviderName[]; }, void, ]; diff --git a/gui/src/context/SubmenuContextProviders.tsx b/gui/src/context/SubmenuContextProviders.tsx index cf3939c48..87428ddba 100644 --- a/gui/src/context/SubmenuContextProviders.tsx +++ b/gui/src/context/SubmenuContextProviders.tsx @@ -115,7 +115,7 @@ export const SubmenuContextProvidersProvider = ({ const interval = setInterval(refreshOpenFiles, 2000); - refreshOpenFiles(); // Initial call + void refreshOpenFiles(); // Initial call return () => { isMounted = false; @@ -227,7 +227,7 @@ export const SubmenuContextProvidersProvider = ({ ); const loadSubmenuItems = useCallback( - async (providers: "dependsOnIndexing" | "all" | ContextProviderName[]) => { + async (providers: "indexTypes" | "all" | ContextProviderName[]) => { await Promise.allSettled( submenuContextProviders.map( async (description: ContextProviderDescription) => { @@ -236,12 +236,13 @@ export const SubmenuContextProvidersProvider = ({ const refreshProvider = providers === "all" ? true - : providers === "dependsOnIndexing" - ? description.dependsOnIndexing + : providers === "indexTypes" + ? description.indexTypes && + description.indexTypes?.length > 0 : providers.includes(description.title); if (!refreshProvider) { - if (providers === "dependsOnIndexing") { + if (providers === "indexTypes") { console.debug( `Skipping ${description.title} provider due to disabled indexing`, ); @@ -351,7 +352,7 @@ export const SubmenuContextProvidersProvider = ({ useWebviewListener( "refreshSubmenuItems", async (data) => { - loadSubmenuItems(data.providers); + void loadSubmenuItems(data.providers); }, [loadSubmenuItems], ); @@ -360,7 +361,7 @@ export const SubmenuContextProvidersProvider = ({ "indexProgress", async (data) => { if (data.status === "done") { - loadSubmenuItems("dependsOnIndexing"); + void loadSubmenuItems("indexTypes"); } }, [loadSubmenuItems], @@ -379,7 +380,7 @@ export const SubmenuContextProvidersProvider = ({ ) .map((provider) => provider.title); if (newTitles.length > 0) { - loadSubmenuItems(newTitles); + void loadSubmenuItems(newTitles); } lastProviders.current = submenuContextProviders; }, [loadSubmenuItems, submenuContextProviders]); From 4c0e2b3cc6453d99bee8098913ddb91b4ad35061 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 30 Jun 2025 23:48:52 +0530 Subject: [PATCH 002/282] rename to dependsOnIndexing --- core/context/providers/CodeContextProvider.ts | 2 +- core/context/providers/FolderContextProvider.ts | 2 +- core/index.d.ts | 2 +- core/indexing/CodebaseIndexer.ts | 2 +- core/protocol/webview.ts | 2 +- gui/src/context/SubmenuContextProviders.tsx | 12 ++++++------ 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/context/providers/CodeContextProvider.ts b/core/context/providers/CodeContextProvider.ts index 0a3c361a3..db3b81664 100644 --- a/core/context/providers/CodeContextProvider.ts +++ b/core/context/providers/CodeContextProvider.ts @@ -16,7 +16,7 @@ class CodeContextProvider extends BaseContextProvider { displayTitle: "Code", description: "Type to search", type: "submenu", - indexTypes: ["chunk", "codeSnippets"], + dependsOnIndexing: ["chunk", "codeSnippets"], }; async getContextItems( diff --git a/core/context/providers/FolderContextProvider.ts b/core/context/providers/FolderContextProvider.ts index 981ca8579..48efcb121 100644 --- a/core/context/providers/FolderContextProvider.ts +++ b/core/context/providers/FolderContextProvider.ts @@ -19,7 +19,7 @@ class FolderContextProvider extends BaseContextProvider { displayTitle: "Folder", description: "Type to search", type: "submenu", - indexTypes: ["embeddings"], + dependsOnIndexing: ["embeddings", "fullTextSearch", "chunk"], }; async getContextItems( diff --git a/core/index.d.ts b/core/index.d.ts index 2f3766d24..6f18e1c32 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -177,7 +177,7 @@ export interface ContextProviderDescription { description: string; renderInlineAs?: string; type: ContextProviderType; - indexTypes?: ContextIndexingType[]; + dependsOnIndexing?: ContextIndexingType[]; } export type FetchFunction = (url: string | URL, init?: any) => Promise; diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index 880284e46..f2fabb90c 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -130,7 +130,7 @@ export class CodebaseIndexer { const indexTypesToBuild = new Set( // use set to remove duplicates config.contextProviders - .map((provider) => provider.description.indexTypes) + .map((provider) => provider.description.dependsOnIndexing) .filter((indexType) => Array.isArray(indexType)) // remove undefined indexTypes .flat(), ); diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index b43bf271f..1a8d40313 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -24,7 +24,7 @@ export type ToWebviewFromIdeOrCoreProtocol = { "indexing/statusUpdate": [IndexingStatus, void]; // Docs, etc. refreshSubmenuItems: [ { - providers: "all" | "indexTypes" | ContextProviderName[]; + providers: "all" | "dependsOnIndexing" | ContextProviderName[]; }, void, ]; diff --git a/gui/src/context/SubmenuContextProviders.tsx b/gui/src/context/SubmenuContextProviders.tsx index 87428ddba..9f6bcd55c 100644 --- a/gui/src/context/SubmenuContextProviders.tsx +++ b/gui/src/context/SubmenuContextProviders.tsx @@ -227,7 +227,7 @@ export const SubmenuContextProvidersProvider = ({ ); const loadSubmenuItems = useCallback( - async (providers: "indexTypes" | "all" | ContextProviderName[]) => { + async (providers: "dependsOnIndexing" | "all" | ContextProviderName[]) => { await Promise.allSettled( submenuContextProviders.map( async (description: ContextProviderDescription) => { @@ -236,13 +236,13 @@ export const SubmenuContextProvidersProvider = ({ const refreshProvider = providers === "all" ? true - : providers === "indexTypes" - ? description.indexTypes && - description.indexTypes?.length > 0 + : providers === "dependsOnIndexing" + ? description.dependsOnIndexing && + description.dependsOnIndexing?.length > 0 : providers.includes(description.title); if (!refreshProvider) { - if (providers === "indexTypes") { + if (providers === "dependsOnIndexing") { console.debug( `Skipping ${description.title} provider due to disabled indexing`, ); @@ -361,7 +361,7 @@ export const SubmenuContextProvidersProvider = ({ "indexProgress", async (data) => { if (data.status === "done") { - void loadSubmenuItems("indexTypes"); + void loadSubmenuItems("dependsOnIndexing"); } }, [loadSubmenuItems], From 5a9b9db915624a51f9a8229fbd98dbaa0cdcc016 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 1 Jul 2025 00:03:01 +0530 Subject: [PATCH 003/282] type correction --- core/context/providers/CodebaseContextProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/context/providers/CodebaseContextProvider.ts b/core/context/providers/CodebaseContextProvider.ts index 682a65a1f..43eaec433 100644 --- a/core/context/providers/CodebaseContextProvider.ts +++ b/core/context/providers/CodebaseContextProvider.ts @@ -13,7 +13,7 @@ class CodebaseContextProvider extends BaseContextProvider { description: "Automatically find relevant files", type: "normal", renderInlineAs: "", - indexTypes: ["embeddings", "fullTextSearch", "chunk"], + dependsOnIndexing: ["embeddings", "fullTextSearch", "chunk"], }; async getContextItems( From 2df3f1307fc8d3f9830923f85ae507f44e9208df Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 1 Jul 2025 00:56:37 +0530 Subject: [PATCH 005/282] fix typecheck --- core/indexing/CodebaseIndexer.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index f2fabb90c..2706f0c1e 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -159,9 +159,11 @@ export class CodebaseIndexer { const indexes: CodebaseIndex[] = []; // not parallelizing to avoid race conditions in sqlite for (const indexType of indexTypesToBuild) { - const index = await indexTypeToIndexerMapping[indexType](); - if (index) { - indexes.push(index); + if (indexType && indexType in indexTypeToIndexerMapping) { + const index = await indexTypeToIndexerMapping[indexType](); + if (index) { + indexes.push(index); + } } } From a8a03d7d98db44173f340efa1a83421ea1a3f87b Mon Sep 17 00:00:00 2001 From: Suhas S Date: Fri, 25 Jul 2025 19:23:25 +0800 Subject: [PATCH 006/282] feat: add HuggingFace OpenAI-compatible router detection - Add isHuggingFaceOpenAICompatible function to detect OpenAI-compatible HuggingFace endpoints - Add huggingface-inference-api provider to constructLlmApi switch case - Route OpenAI-compatible HuggingFace endpoints through OpenAI adapter - Return undefined for native HuggingFace endpoints to use existing HuggingFaceInferenceAPI class - Add huggingface-inference-api to provider types in OpenAIConfigSchema Fixes #5763 --- packages/openai-adapters/src/index.ts | 35 +++++++++++++++++++++++++++ packages/openai-adapters/src/types.ts | 1 + 2 files changed, 36 insertions(+) diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index 07f849f33..97c4a940c 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -31,6 +31,33 @@ function openAICompatible( }); } +/** + * Detects if a HuggingFace API URL is using an OpenAI-compatible router + * @param url The URL to check + * @returns true if the URL appears to be using an OpenAI-compatible router + */ +function isHuggingFaceOpenAICompatible(url: string): boolean { + if (!url) { + return false; + } + + // Normalize the URL to lowercase for case-insensitive matching + const normalizedUrl = url.toLowerCase(); + + // Check for common OpenAI-compatible patterns + const openAIPatterns = [ + '/v1/', // Standard OpenAI v1 API pattern + '/openai/', // Explicit OpenAI compatibility path + '/v1/chat/completions', // Specific OpenAI chat completions endpoint + '/v1/completions', // OpenAI completions endpoint + '/v1/embeddings', // OpenAI embeddings endpoint + '/v1/models', // OpenAI models endpoint + ]; + + // Check if the URL contains any of the OpenAI-compatible patterns + return openAIPatterns.some(pattern => normalizedUrl.includes(pattern)); +} + export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined { switch (config.provider) { case "openai": @@ -115,6 +142,14 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined { return openAICompatible("http://localhost:1234/", config); case "mock": return new MockApi(); + case "huggingface-inference-api": + // Check if it's an OpenAI-compatible router + if (config.apiBase && isHuggingFaceOpenAICompatible(config.apiBase)) { + return openAICompatible(config.apiBase, config); + } + // Return undefined for native HuggingFace endpoints + // (handled by HuggingFaceInferenceAPI class in core) + return undefined; default: return undefined; } diff --git a/packages/openai-adapters/src/types.ts b/packages/openai-adapters/src/types.ts index 6786ec812..5098f73ef 100644 --- a/packages/openai-adapters/src/types.ts +++ b/packages/openai-adapters/src/types.ts @@ -57,6 +57,7 @@ export const OpenAIConfigSchema = BasePlusConfig.extend({ z.literal("scaleway"), z.literal("ncompass"), z.literal("relace"), + z.literal("huggingface-inference-api"), ]), }); export type OpenAIConfig = z.infer; From 085f76602854b00bcd2903bad4d1e160581d724c Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:59:21 +0530 Subject: [PATCH 007/282] write tests for "getIndexesToBuild" --- core/indexing/CodebaseIndexer.test.ts | 90 +++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 63822bea9..aee2fbebb 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -688,4 +688,94 @@ describe("CodebaseIndexer", () => { }); }); }); + + describe("getIndexesToBuild", () => { + let indexer: CodebaseIndexer; + let mockConfig: any; + let mockEmbeddingsModel: any; + let mockIdeSettings: any; + + beforeEach(() => { + indexer = new CodebaseIndexer( + testConfigHandler, + testIde, + mockMessenger as any, + false, + ); + + mockEmbeddingsModel = { + maxEmbeddingChunkSize: 1000, + model: "test-model", + provider: "test-provider", + }; + + mockIdeSettings = { + remoteConfigServerUrl: "http://test.com", + userToken: "test-token", + }; + + mockConfig = { + selectedModelByRole: { + embed: mockEmbeddingsModel, + }, + contextProviders: [], + }; + + jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + test("should create specific indexTypes for the requested context providers", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["chunk", "codeSnippets"], + }, + }, + ]; + + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = (await ( + indexer as any + ).getIndexesToBuild()) as CodebaseIndex[]; + + expect(indexes).toHaveLength(2); + expect(indexes[0].artifactId).toBe("chunks"); + expect(indexes[1].artifactId).toBe("codeSnippets"); + }); + + test("should handle duplicate contexts", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + ]; + + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = await (indexer as any).getIndexesToBuild(); + + expect(indexes).toHaveLength(1); + expect(indexes[0].artifactId).toBe("codeSnippets"); + }); + }); }); From cdc71422a96427a3580dc4a8604bc046884fb59b Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 11:56:28 +0530 Subject: [PATCH 009/282] revert tests --- core/indexing/CodebaseIndexer.test.ts | 90 --------------------------- 1 file changed, 90 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index c15e2b062..e6b2c2055 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -710,94 +710,4 @@ describe("CodebaseIndexer", () => { }); }); }); - - describe("getIndexesToBuild", () => { - let indexer: CodebaseIndexer; - let mockConfig: any; - let mockEmbeddingsModel: any; - let mockIdeSettings: any; - - beforeEach(() => { - indexer = new CodebaseIndexer( - testConfigHandler, - testIde, - mockMessenger as any, - false, - ); - - mockEmbeddingsModel = { - maxEmbeddingChunkSize: 1000, - model: "test-model", - provider: "test-provider", - }; - - mockIdeSettings = { - remoteConfigServerUrl: "http://test.com", - userToken: "test-token", - }; - - mockConfig = { - selectedModelByRole: { - embed: mockEmbeddingsModel, - }, - contextProviders: [], - }; - - jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings); - }); - - afterEach(() => { - jest.clearAllMocks(); - }); - - test("should create specific indexTypes for the requested context providers", async () => { - mockConfig.contextProviders = [ - { - description: { - dependsOnIndexing: ["chunk", "codeSnippets"], - }, - }, - ]; - - jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ - config: mockConfig, - errors: [], - configLoadInterrupted: false, - }); - - const indexes = (await ( - indexer as any - ).getIndexesToBuild()) as CodebaseIndex[]; - - expect(indexes).toHaveLength(2); - expect(indexes[0].artifactId).toBe("chunks"); - expect(indexes[1].artifactId).toBe("codeSnippets"); - }); - - test("should handle duplicate contexts", async () => { - mockConfig.contextProviders = [ - { - description: { - dependsOnIndexing: ["codeSnippets"], - }, - }, - { - description: { - dependsOnIndexing: ["codeSnippets"], - }, - }, - ]; - - jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ - config: mockConfig, - errors: [], - configLoadInterrupted: false, - }); - - const indexes = await (indexer as any).getIndexesToBuild(); - - expect(indexes).toHaveLength(1); - expect(indexes[0].artifactId).toBe("codeSnippets"); - }); - }); }); From 2c2db8f967e7d363ec87ef3d000467f5725fe581 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:02:11 +0530 Subject: [PATCH 010/282] Revert "revert tests" This reverts commit cdc71422a96427a3580dc4a8604bc046884fb59b. --- core/indexing/CodebaseIndexer.test.ts | 90 +++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index e6b2c2055..c15e2b062 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -710,4 +710,94 @@ describe("CodebaseIndexer", () => { }); }); }); + + describe("getIndexesToBuild", () => { + let indexer: CodebaseIndexer; + let mockConfig: any; + let mockEmbeddingsModel: any; + let mockIdeSettings: any; + + beforeEach(() => { + indexer = new CodebaseIndexer( + testConfigHandler, + testIde, + mockMessenger as any, + false, + ); + + mockEmbeddingsModel = { + maxEmbeddingChunkSize: 1000, + model: "test-model", + provider: "test-provider", + }; + + mockIdeSettings = { + remoteConfigServerUrl: "http://test.com", + userToken: "test-token", + }; + + mockConfig = { + selectedModelByRole: { + embed: mockEmbeddingsModel, + }, + contextProviders: [], + }; + + jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + test("should create specific indexTypes for the requested context providers", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["chunk", "codeSnippets"], + }, + }, + ]; + + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = (await ( + indexer as any + ).getIndexesToBuild()) as CodebaseIndex[]; + + expect(indexes).toHaveLength(2); + expect(indexes[0].artifactId).toBe("chunks"); + expect(indexes[1].artifactId).toBe("codeSnippets"); + }); + + test("should handle duplicate contexts", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + ]; + + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = await (indexer as any).getIndexesToBuild(); + + expect(indexes).toHaveLength(1); + expect(indexes[0].artifactId).toBe("codeSnippets"); + }); + }); }); From c1013ee18dd7eb1ce3ed89e38bfc687b5538b8a6 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:02:42 +0530 Subject: [PATCH 011/282] test only codebaseindexer --- .github/workflows/pr-checks.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index 63afde345..1b4a41d87 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -44,17 +44,18 @@ jobs: component: core include-root: true - - name: Type check and lint - run: | - cd core - npx tsc --noEmit - npm run lint - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + # - name: Type check and lint + # run: | + # cd core + # npx tsc --noEmit + # npm run lint + # env: + # OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Run tests run: | cd core + npm test -- CodebaseIndexer npm test npm run vitest env: From 7a80e793d4dfb58b302ca0e2f26c34e23a5b13e8 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:12:24 +0530 Subject: [PATCH 012/282] rerun tests --- core/indexing/CodebaseIndexer.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index c15e2b062..95ba7bc97 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -717,7 +717,7 @@ describe("CodebaseIndexer", () => { let mockEmbeddingsModel: any; let mockIdeSettings: any; - beforeEach(() => { + beforeEach(async () => { indexer = new CodebaseIndexer( testConfigHandler, testIde, @@ -774,7 +774,7 @@ describe("CodebaseIndexer", () => { expect(indexes[1].artifactId).toBe("codeSnippets"); }); - test("should handle duplicate contexts", async () => { + test.skip("should handle duplicate contexts", async () => { mockConfig.contextProviders = [ { description: { From 36755840d6fd4170fba5b6822ea32d52232f85c2 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:14:02 +0530 Subject: [PATCH 013/282] rerun tests --- core/indexing/CodebaseIndexer.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 95ba7bc97..cf4102bd7 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -750,7 +750,7 @@ describe("CodebaseIndexer", () => { jest.clearAllMocks(); }); - test("should create specific indexTypes for the requested context providers", async () => { + test.skip("should create specific indexTypes for the requested context providers", async () => { mockConfig.contextProviders = [ { description: { From 3713a4d61c37f28c1fe6925318655d0733cd7ac0 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:17:26 +0530 Subject: [PATCH 014/282] wait for logs to cleanup --- core/indexing/CodebaseIndexer.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index cf4102bd7..b9c24519a 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -746,11 +746,12 @@ describe("CodebaseIndexer", () => { jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings); }); - afterEach(() => { + afterEach(async () => { jest.clearAllMocks(); + await new Promise((resolve) => setTimeout(resolve, 500)); // wait for error logs to cleanup }); - test.skip("should create specific indexTypes for the requested context providers", async () => { + test("should create specific indexTypes for the requested context providers", async () => { mockConfig.contextProviders = [ { description: { @@ -774,7 +775,7 @@ describe("CodebaseIndexer", () => { expect(indexes[1].artifactId).toBe("codeSnippets"); }); - test.skip("should handle duplicate contexts", async () => { + test("should handle duplicate contexts", async () => { mockConfig.contextProviders = [ { description: { From 050078fa5cb14d8af4ae986b0e1c4b8e61811af2 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:21:11 +0530 Subject: [PATCH 015/282] rerun tests --- core/indexing/CodebaseIndexer.test.ts | 157 +++++++++++++------------- 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index b9c24519a..16671861a 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -709,96 +709,97 @@ describe("CodebaseIndexer", () => { ]); }); }); - }); - describe("getIndexesToBuild", () => { - let indexer: CodebaseIndexer; - let mockConfig: any; - let mockEmbeddingsModel: any; - let mockIdeSettings: any; + describe("getIndexesToBuild", () => { + let indexer: CodebaseIndexer; + let mockConfig: any; + let mockEmbeddingsModel: any; + let mockIdeSettings: any; - beforeEach(async () => { - indexer = new CodebaseIndexer( - testConfigHandler, - testIde, - mockMessenger as any, - false, - ); + beforeEach(async () => { + indexer = new CodebaseIndexer( + testConfigHandler, + testIde, + mockMessenger as any, + false, + ); - mockEmbeddingsModel = { - maxEmbeddingChunkSize: 1000, - model: "test-model", - provider: "test-provider", - }; + mockEmbeddingsModel = { + maxEmbeddingChunkSize: 1000, + model: "test-model", + provider: "test-provider", + }; - mockIdeSettings = { - remoteConfigServerUrl: "http://test.com", - userToken: "test-token", - }; + mockIdeSettings = { + remoteConfigServerUrl: "http://test.com", + userToken: "test-token", + }; - mockConfig = { - selectedModelByRole: { - embed: mockEmbeddingsModel, - }, - contextProviders: [], - }; - - jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings); - }); - - afterEach(async () => { - jest.clearAllMocks(); - await new Promise((resolve) => setTimeout(resolve, 500)); // wait for error logs to cleanup - }); - - test("should create specific indexTypes for the requested context providers", async () => { - mockConfig.contextProviders = [ - { - description: { - dependsOnIndexing: ["chunk", "codeSnippets"], + mockConfig = { + selectedModelByRole: { + embed: mockEmbeddingsModel, }, - }, - ]; + contextProviders: [], + }; - jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ - config: mockConfig, - errors: [], - configLoadInterrupted: false, + jest + .spyOn(testIde, "getIdeSettings") + .mockResolvedValue(mockIdeSettings); }); - const indexes = (await ( - indexer as any - ).getIndexesToBuild()) as CodebaseIndex[]; - - expect(indexes).toHaveLength(2); - expect(indexes[0].artifactId).toBe("chunks"); - expect(indexes[1].artifactId).toBe("codeSnippets"); - }); - - test("should handle duplicate contexts", async () => { - mockConfig.contextProviders = [ - { - description: { - dependsOnIndexing: ["codeSnippets"], - }, - }, - { - description: { - dependsOnIndexing: ["codeSnippets"], - }, - }, - ]; - - jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ - config: mockConfig, - errors: [], - configLoadInterrupted: false, + afterEach(() => { + jest.clearAllMocks(); }); - const indexes = await (indexer as any).getIndexesToBuild(); + test("should create specific indexTypes for the requested context providers", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["chunk", "codeSnippets"], + }, + }, + ]; - expect(indexes).toHaveLength(1); - expect(indexes[0].artifactId).toBe("codeSnippets"); + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = (await ( + indexer as any + ).getIndexesToBuild()) as CodebaseIndex[]; + + expect(indexes).toHaveLength(2); + expect(indexes[0].artifactId).toBe("chunks"); + expect(indexes[1].artifactId).toBe("codeSnippets"); + }); + + test("should handle duplicate contexts", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + ]; + + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = await (indexer as any).getIndexesToBuild(); + + expect(indexes).toHaveLength(1); + expect(indexes[0].artifactId).toBe("codeSnippets"); + }); }); }); }); From cf496bb768067186fb417190f64e6dc23b64b402 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:22:57 +0530 Subject: [PATCH 016/282] revert ci changes --- .github/workflows/pr-checks.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index 1b4a41d87..63afde345 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -44,18 +44,17 @@ jobs: component: core include-root: true - # - name: Type check and lint - # run: | - # cd core - # npx tsc --noEmit - # npm run lint - # env: - # OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + - name: Type check and lint + run: | + cd core + npx tsc --noEmit + npm run lint + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Run tests run: | cd core - npm test -- CodebaseIndexer npm test npm run vitest env: From 3dd8b92e3072cd0e4a9b9c0c12107c09d288c55e Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 12 Aug 2025 19:15:20 -0400 Subject: [PATCH 017/282] feat: improve settings UI --- gui/src/components/gui/NumberInput.tsx | 2 +- gui/src/components/gui/Select.tsx | 12 ++++++++---- gui/src/components/gui/Switch.tsx | 2 +- gui/src/components/index.ts | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gui/src/components/gui/NumberInput.tsx b/gui/src/components/gui/NumberInput.tsx index fa622d5e5..16e70ba6f 100644 --- a/gui/src/components/gui/NumberInput.tsx +++ b/gui/src/components/gui/NumberInput.tsx @@ -51,7 +51,7 @@ const NumberInput: React.FC = ({ }; return ( -
+
> = ( >