Skip to content

Commit a931227

Browse files
committed
add valkey
1 parent 342ee70 commit a931227

File tree

29 files changed

+634
-81
lines changed

29 files changed

+634
-81
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,8 @@
5454
"undici": ">=5.29.0",
5555
"brace-expansion": ">=2.0.2"
5656
}
57+
},
58+
"dependencies": {
59+
"iovalkey": "^0.3.3"
5760
}
5861
}

packages/types/src/codebase-index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export const codebaseIndexConfigSchema = z.object({
3434
// OpenAI Compatible specific fields
3535
codebaseIndexOpenAiCompatibleBaseUrl: z.string().optional(),
3636
codebaseIndexOpenAiCompatibleModelDimension: z.number().optional(),
37+
codebaseIndexValkeyUrl: z.string().optional(),
38+
searchProvider: z.string().optional(),
3739
})
3840

3941
export type CodebaseIndexConfig = z.infer<typeof codebaseIndexConfigSchema>

pnpm-lock.yaml

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/webview/ClineProvider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,13 +1547,15 @@ export class ClineProvider
15471547
codebaseIndexConfig: {
15481548
codebaseIndexEnabled: codebaseIndexConfig?.codebaseIndexEnabled ?? true,
15491549
codebaseIndexQdrantUrl: codebaseIndexConfig?.codebaseIndexQdrantUrl ?? "http://localhost:6333",
1550+
codebaseIndexValkeyUrl: codebaseIndexConfig?.codebaseIndexValkeyUrl ?? "http://localhost:6379",
15501551
codebaseIndexEmbedderProvider: codebaseIndexConfig?.codebaseIndexEmbedderProvider ?? "openai",
15511552
codebaseIndexEmbedderBaseUrl: codebaseIndexConfig?.codebaseIndexEmbedderBaseUrl ?? "",
15521553
codebaseIndexEmbedderModelId: codebaseIndexConfig?.codebaseIndexEmbedderModelId ?? "",
15531554
codebaseIndexEmbedderModelDimension: codebaseIndexConfig?.codebaseIndexEmbedderModelDimension ?? 1536,
15541555
codebaseIndexOpenAiCompatibleBaseUrl: codebaseIndexConfig?.codebaseIndexOpenAiCompatibleBaseUrl,
15551556
codebaseIndexSearchMaxResults: codebaseIndexConfig?.codebaseIndexSearchMaxResults,
15561557
codebaseIndexSearchMinScore: codebaseIndexConfig?.codebaseIndexSearchMinScore,
1558+
searchProvider: codebaseIndexConfig?.searchProvider,
15571559
},
15581560
mdmCompliant: this.checkMdmCompliance(),
15591561
profileThresholds: profileThresholds ?? {},
@@ -1716,6 +1718,8 @@ export class ClineProvider
17161718
codebaseIndexEnabled: stateValues.codebaseIndexConfig?.codebaseIndexEnabled ?? true,
17171719
codebaseIndexQdrantUrl:
17181720
stateValues.codebaseIndexConfig?.codebaseIndexQdrantUrl ?? "http://localhost:6333",
1721+
codebaseIndexValkeyUrl:
1722+
stateValues.codebaseIndexConfig?.codebaseIndexValkeyUrl ?? "http://localhost:6379",
17191723
codebaseIndexEmbedderProvider:
17201724
stateValues.codebaseIndexConfig?.codebaseIndexEmbedderProvider ?? "openai",
17211725
codebaseIndexEmbedderBaseUrl: stateValues.codebaseIndexConfig?.codebaseIndexEmbedderBaseUrl ?? "",
@@ -1726,6 +1730,7 @@ export class ClineProvider
17261730
stateValues.codebaseIndexConfig?.codebaseIndexOpenAiCompatibleBaseUrl,
17271731
codebaseIndexSearchMaxResults: stateValues.codebaseIndexConfig?.codebaseIndexSearchMaxResults,
17281732
codebaseIndexSearchMinScore: stateValues.codebaseIndexConfig?.codebaseIndexSearchMinScore,
1733+
searchProvider: stateValues.codebaseIndexConfig?.searchProvider,
17291734
},
17301735
profileThresholds: stateValues.profileThresholds ?? {},
17311736
// Add diagnostic message settings

src/core/webview/webviewMessageHandler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,13 +1991,15 @@ export const webviewMessageHandler = async (
19911991
...currentConfig,
19921992
codebaseIndexEnabled: settings.codebaseIndexEnabled,
19931993
codebaseIndexQdrantUrl: settings.codebaseIndexQdrantUrl,
1994+
codebaseIndexValkeyUrl: settings.codebaseIndexValkeyUrl,
19941995
codebaseIndexEmbedderProvider: settings.codebaseIndexEmbedderProvider,
19951996
codebaseIndexEmbedderBaseUrl: settings.codebaseIndexEmbedderBaseUrl,
19961997
codebaseIndexEmbedderModelId: settings.codebaseIndexEmbedderModelId,
19971998
codebaseIndexEmbedderModelDimension: settings.codebaseIndexEmbedderModelDimension, // Generic dimension
19981999
codebaseIndexOpenAiCompatibleBaseUrl: settings.codebaseIndexOpenAiCompatibleBaseUrl,
19992000
codebaseIndexSearchMaxResults: settings.codebaseIndexSearchMaxResults,
20002001
codebaseIndexSearchMinScore: settings.codebaseIndexSearchMinScore,
2002+
searchProvider: settings.searchProvider,
20012003
}
20022004

20032005
// Save global state first

src/services/code-index/config-manager.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export class CodeIndexConfigManager {
2121
private mistralOptions?: { apiKey: string }
2222
private qdrantUrl?: string = "http://localhost:6333"
2323
private qdrantApiKey?: string
24+
private searchProvider?: string
25+
private valkeyUrl?: string = "http://localhost:6379"
2426
private searchMinScore?: number
2527
private searchMaxResults?: number
2628

@@ -45,6 +47,7 @@ export class CodeIndexConfigManager {
4547
const codebaseIndexConfig = this.contextProxy?.getGlobalState("codebaseIndexConfig") ?? {
4648
codebaseIndexEnabled: true,
4749
codebaseIndexQdrantUrl: "http://localhost:6333",
50+
codebaseIndexValkeyUrl: "http://localhost:6379",
4851
codebaseIndexEmbedderProvider: "openai",
4952
codebaseIndexEmbedderBaseUrl: "",
5053
codebaseIndexEmbedderModelId: "",
@@ -55,11 +58,13 @@ export class CodeIndexConfigManager {
5558
const {
5659
codebaseIndexEnabled,
5760
codebaseIndexQdrantUrl,
61+
codebaseIndexValkeyUrl,
5862
codebaseIndexEmbedderProvider,
5963
codebaseIndexEmbedderBaseUrl,
6064
codebaseIndexEmbedderModelId,
6165
codebaseIndexSearchMinScore,
6266
codebaseIndexSearchMaxResults,
67+
searchProvider,
6368
} = codebaseIndexConfig
6469

6570
const openAiKey = this.contextProxy?.getSecret("codeIndexOpenAiKey") ?? ""
@@ -74,8 +79,10 @@ export class CodeIndexConfigManager {
7479
this.codebaseIndexEnabled = codebaseIndexEnabled ?? true
7580
this.qdrantUrl = codebaseIndexQdrantUrl
7681
this.qdrantApiKey = qdrantApiKey ?? ""
82+
this.valkeyUrl = codebaseIndexValkeyUrl
7783
this.searchMinScore = codebaseIndexSearchMinScore
7884
this.searchMaxResults = codebaseIndexSearchMaxResults
85+
this.searchProvider = searchProvider
7986

8087
// Validate and set model dimension
8188
const rawDimension = codebaseIndexConfig.codebaseIndexEmbedderModelDimension
@@ -143,6 +150,8 @@ export class CodeIndexConfigManager {
143150
mistralOptions?: { apiKey: string }
144151
qdrantUrl?: string
145152
qdrantApiKey?: string
153+
valkeyUrl?: string
154+
searchProvider?: string
146155
searchMinScore?: number
147156
}
148157
requiresRestart: boolean
@@ -161,6 +170,8 @@ export class CodeIndexConfigManager {
161170
geminiApiKey: this.geminiOptions?.apiKey ?? "",
162171
mistralApiKey: this.mistralOptions?.apiKey ?? "",
163172
qdrantUrl: this.qdrantUrl ?? "",
173+
valkeyUrl: this.valkeyUrl ?? "",
174+
searchProvider: this.searchProvider,
164175
qdrantApiKey: this.qdrantApiKey ?? "",
165176
}
166177

@@ -186,6 +197,8 @@ export class CodeIndexConfigManager {
186197
mistralOptions: this.mistralOptions,
187198
qdrantUrl: this.qdrantUrl,
188199
qdrantApiKey: this.qdrantApiKey,
200+
valkeyUrl: this.valkeyUrl,
201+
searchProvider: this.searchProvider,
189202
searchMinScore: this.currentSearchMinScore,
190203
},
191204
requiresRestart,
@@ -377,6 +390,8 @@ export class CodeIndexConfigManager {
377390
mistralOptions: this.mistralOptions,
378391
qdrantUrl: this.qdrantUrl,
379392
qdrantApiKey: this.qdrantApiKey,
393+
searchProvider: this.searchProvider,
394+
valkeyUrl: this.valkeyUrl,
380395
searchMinScore: this.currentSearchMinScore,
381396
searchMaxResults: this.currentSearchMaxResults,
382397
}

src/services/code-index/interfaces/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export interface CodeIndexConfig {
1616
mistralOptions?: { apiKey: string }
1717
qdrantUrl?: string
1818
qdrantApiKey?: string
19+
valkeyUrl?: string
20+
searchProvider?: string
1921
searchMinScore?: number
2022
searchMaxResults?: number
2123
}
@@ -37,4 +39,6 @@ export type PreviousConfigSnapshot = {
3739
mistralApiKey?: string
3840
qdrantUrl?: string
3941
qdrantApiKey?: string
42+
valkeyUrl?: string
43+
searchProvider?: string
4044
}

src/services/code-index/service-factory.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { GeminiEmbedder } from "./embedders/gemini"
66
import { MistralEmbedder } from "./embedders/mistral"
77
import { EmbedderProvider, getDefaultModelId, getModelDimension } from "../../shared/embeddingModels"
88
import { QdrantVectorStore } from "./vector-store/qdrant-client"
9+
import { ValkeySearchVectorStore } from "./vector-store/valkey-search-client"
910
import { codeParser, DirectoryScanner, FileWatcher } from "./processors"
1011
import { ICodeParser, IEmbedder, IFileWatcher, IVectorStore } from "./interfaces"
1112
import { CodeIndexConfigManager } from "./config-manager"
@@ -132,12 +133,16 @@ export class CodeIndexServiceFactory {
132133
}
133134
}
134135

135-
if (!config.qdrantUrl) {
136-
throw new Error(t("embeddings:serviceFactory.qdrantUrlMissing"))
136+
const searchProvider = config.searchProvider
137+
138+
if (searchProvider === "qdrant" && config.qdrantUrl) {
139+
return new QdrantVectorStore(this.workspacePath, config.qdrantUrl, vectorSize, config.qdrantApiKey)
140+
} else if (searchProvider === "valkey" && config.valkeyUrl) {
141+
return new ValkeySearchVectorStore(this.workspacePath, config.valkeyUrl, vectorSize)
137142
}
138143

139144
// Assuming constructor is updated: new QdrantVectorStore(workspacePath, url, vectorSize, apiKey?)
140-
return new QdrantVectorStore(this.workspacePath, config.qdrantUrl, vectorSize, config.qdrantApiKey)
145+
throw new Error(t("embeddings:serviceFactory.vectorStoreUrlMissing"))
141146
}
142147

143148
/**

0 commit comments

Comments
 (0)