Skip to content

Commit 5cae994

Browse files
author
Kevin White
committed
Merge branch 'main' into my-main
2 parents 77328cf + a8922e0 commit 5cae994

File tree

7 files changed

+55
-36
lines changed

7 files changed

+55
-36
lines changed

src/core/diff/strategies/multi-search-replace.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,8 @@ export class MultiSearchReplaceDiffStrategy implements DiffStrategy {
9191

9292
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
9393
return `## apply_diff
94-
Description: Request to replace existing code using a search and replace block.
95-
This tool allows for precise, surgical replaces to files by specifying exactly what content to search for and what to replace it with.
96-
The tool will maintain proper indentation and formatting while making changes.
97-
Only a single operation is allowed per tool use.
94+
Description: Request to apply targeted modifications to an existing file by searching for specific sections of content and replacing them. This tool is ideal for precise, surgical edits when you know the exact content to change. It helps maintain proper indentation and formatting.
95+
You can perform multiple distinct search and replace operations within a single \`apply_diff\` call by providing multiple SEARCH/REPLACE blocks in the \`diff\` parameter. This is the preferred way to make several targeted changes to one file efficiently.
9896
The SEARCH section must exactly match existing content including whitespace and indentation.
9997
If you're not confident in the exact content to search for, use the read_file tool first to get the exact content.
10098
When applying the diffs, be extra careful to remember to change any closing brackets or other syntax that may be affected by the diff farther down in the file.

src/core/prompts/__tests__/__snapshots__/system.test.ts.snap

Lines changed: 24 additions & 26 deletions
Large diffs are not rendered by default.

src/core/prompts/tools/write-to-file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { ToolArgs } from "./types"
22

33
export function getWriteToFileDescription(args: ToolArgs): string {
44
return `## write_to_file
5-
Description: Request to write full content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
5+
Description: Request to write content to a file. This tool is primarily used for **creating new files** or for scenarios where a **complete rewrite of an existing file is intentionally required**. If the file exists, it will be overwritten. If it doesn't exist, it will be created. This tool will automatically create any directories needed to write the file.
66
Parameters:
77
- path: (required) The path of the file to write to (relative to the current workspace directory ${args.cwd})
8-
- content: (required) The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
8+
- content: (required) The content to write to the file. When performing a full rewrite of an existing file or creating a new one, ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified. Do NOT include the line numbers in the content though, just the actual content of the file.
99
- line_count: (required) The number of lines in the file. Make sure to compute this based on the actual content of the file, not the number of lines in the content you're providing.
1010
Usage:
1111
<write_to_file>

src/core/webview/ClineProvider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,11 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
824824
this.contextProxy.setProviderSettings(providerSettings),
825825
])
826826

827+
// Notify CodeIndexManager about the settings change
828+
if (this.codeIndexManager) {
829+
await this.codeIndexManager.handleExternalSettingsChange()
830+
}
831+
827832
// Change the provider for the current task.
828833
// TODO: We should rename `buildApiHandler` for clarity (e.g. `getProviderClient`).
829834
const task = this.getCurrentCline()

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class CodeIndexConfigManager {
1414
private modelId?: string
1515
private openAiOptions?: ApiHandlerOptions
1616
private ollamaOptions?: ApiHandlerOptions
17-
private qdrantUrl?: string
17+
private qdrantUrl?: string = "http://localhost:6333"
1818
private qdrantApiKey?: string
1919
private searchMinScore?: number
2020

@@ -103,11 +103,18 @@ export class CodeIndexConfigManager {
103103
* Checks if the service is properly configured based on the embedder type.
104104
*/
105105
public isConfigured(): boolean {
106+
106107
if (this.embedderProvider === "openai") {
107-
return !!(this.openAiOptions?.openAiNativeApiKey && this.qdrantUrl)
108+
const openAiKey = this.openAiOptions?.openAiNativeApiKey
109+
const qdrantUrl = this.qdrantUrl
110+
const isConfigured = !!(openAiKey && qdrantUrl)
111+
return isConfigured
108112
} else if (this.embedderProvider === "ollama") {
109113
// Ollama model ID has a default, so only base URL is strictly required for config
110-
return !!(this.ollamaOptions?.ollamaBaseUrl && this.qdrantUrl)
114+
const ollamaBaseUrl = this.ollamaOptions?.ollamaBaseUrl
115+
const qdrantUrl = this.qdrantUrl
116+
const isConfigured = !!(ollamaBaseUrl && qdrantUrl)
117+
return isConfigured
111118
}
112119
return false // Should not happen if embedderProvider is always set correctly
113120
}

src/services/code-index/manager.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,15 @@ export class CodeIndexManager {
244244
this.assertInitialized()
245245
return this._searchService!.searchIndex(query, directoryPrefix)
246246
}
247+
248+
/**
249+
* Handles external settings changes by reloading configuration.
250+
* This method should be called when API provider settings are updated
251+
* to ensure the CodeIndexConfigManager picks up the new configuration.
252+
*/
253+
public async handleExternalSettingsChange(): Promise<void> {
254+
if (this._configManager) {
255+
await this._configManager.loadConfiguration()
256+
}
257+
}
247258
}

webview-ui/src/components/settings/CodeIndexSettings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export const CodeIndexSettings: React.FC<CodeIndexSettingsProps> = ({
300300
</div>
301301
<div>
302302
<VSCodeTextField
303-
value={codebaseIndexConfig.codebaseIndexQdrantUrl}
303+
value={codebaseIndexConfig.codebaseIndexQdrantUrl || "http://localhost:6333"}
304304
onInput={(e: any) =>
305305
setCachedStateField("codebaseIndexConfig", {
306306
...codebaseIndexConfig,

0 commit comments

Comments
 (0)