Skip to content

Commit 23a7baf

Browse files
committed
Add support for setting default API models and CLI agents for intelligent search
- for api and cli add option to set defaults for 'intelligent search' ├── apps │ └── editor │ ├── package.json │ └── src │ ├── commands │ │ └── code-at-cursor-command │ │ ├── code-at-cursor-commands.ts │ │ ├── index.ts │ │ └── utils │ │ ├── get-code-at-cursor-config.ts │ │ ├── perform-code-at-cursor.ts │ │ └── show-ghost-text.ts │ ├── features │ │ ├── agentic-search │ │ │ └── agentic-search.ts │ │ └── search-files │ │ ├── index.ts │ │ ├── search-files.ts │ │ ├── search-modes │ │ │ ├── perform-intelligent-search-mode.ts │ │ │ ├── perform-keywords-search-mode.ts │ │ │ └── perform-phrase-search-mode.ts │ │ └── utils │ │ ├── analyze-files.ts │ │ ├── check-matches-condition.ts │ │ ├── create-search-regex.ts │ │ ├── prompt-for-config.ts │ │ ├── prompt-for-intelligent-search-results.ts │ │ ├── prompt-for-keywords-match-mode.ts │ │ ├── prompt-for-keywords-target.ts │ │ ├── prompt-for-search-mode.ts │ │ ├── prompt-for-search-results.ts │ │ ├── prompt-for-search-term.ts │ │ ├── prompt-for-shrink-mode.ts │ │ ├── search-files-by-intelligent.ts │ │ ├── search-files-by-keywords.ts │ │ ├── search-files-by-phrase.ts │ │ └── show-search-results-quick-pick.ts │ ├── services │ │ └── providers-manager.ts │ ├── types │ │ └── cli-configuration.ts │ ├── utils │ │ └── cli-configuration-format-converters.ts │ └── views │ ├── settings │ │ ├── backend │ │ │ ├── message-handlers │ │ │ │ ├── handle-get-api-configurations.ts │ │ │ │ ├── handle-get-cli-configurations.ts │ │ │ │ ├── handle-select-default-api-configuration.ts │ │ │ │ ├── handle-select-default-cli-configuration.ts │ │ │ │ ├── handle-set-default-api-configuration.ts │ │ │ │ ├── handle-set-default-cli-configuration.ts │ │ │ │ └── index.ts │ │ │ └── settings-view-provider.ts │ │ ├── frontend │ │ │ ├── Home │ │ │ │ ├── Home.tsx │ │ │ │ └── sections │ │ │ │ ├── ApiSection.tsx │ │ │ │ ├── CliSection.tsx │ │ │ │ └── WebSection.tsx │ │ │ ├── Settings.tsx │ │ │ ├── hooks │ │ │ │ └── use-settings.ts │ │ │ └── i18n │ │ │ └── translations │ │ │ ├── api.ts │ │ │ └── cli.ts │ │ └── types │ │ └── messages.ts │ └── shared │ └── types │ └── api-features.ts └── package.json
1 parent 56ff4ad commit 23a7baf

15 files changed

Lines changed: 177 additions & 46 deletions

‎apps/editor/package.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,9 @@
10451045
},
10461046
"isDefaultForCodeAtCursor": {
10471047
"type": "boolean"
1048+
},
1049+
"isDefaultForIntelligentSearch": {
1050+
"type": "boolean"
10481051
}
10491052
},
10501053
"required": [
@@ -1203,6 +1206,9 @@
12031206
},
12041207
"isDefaultForVoiceInput": {
12051208
"type": "boolean"
1209+
},
1210+
"isDefaultForIntelligentSearch": {
1211+
"type": "boolean"
12061212
}
12071213
},
12081214
"required": [

‎apps/editor/src/features/search-files/search-modes/perform-intelligent-search-mode.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,19 @@ export const perform_intelligent_search_mode = async (params: {
404404
?.defaultValue ||
405405
''
406406

407+
const config_codeWebChat =
408+
vscode.workspace.getConfiguration('codeWebChat')
409+
const agent_configs =
410+
config_codeWebChat.get<any[]>('agents', []) || []
411+
const default_agent = agent_configs.find(
412+
(c) => c.isDefaultForIntelligentSearch
413+
)
414+
415+
const use_quick_pick = !default_agent
416+
const cli_configuration_name = default_agent
417+
? default_agent.name
418+
: undefined
419+
407420
const cli_prompt = `# Files\n\n${md_files}# Task\n\n${base_instructions}\n\n# Output formatting\n\n${ai_file_search_format_instructions}\n\n# Requirements\n\n- ${cli_edit_ask_requirements.preloaded_context}\n- ${cli_edit_ask_requirements.restrict_shell_commands}\n\n# Query\n\n${search_term}`
408421

409422
const invoke_cli_result = await invoke_agentic_cli({
@@ -417,6 +430,8 @@ export const perform_intelligent_search_mode = async (params: {
417430
params.extension_context.workspaceState.get<string>(
418431
LAST_USED_AGENT_FOR_INTELLIGENT_SEARCH_STATE_KEY
419432
),
433+
cli_configuration_name,
434+
use_quick_pick,
420435
on_agent_selected: (name) => {
421436
params.extension_context.workspaceState.update(
422437
LAST_USED_AGENT_FOR_INTELLIGENT_SEARCH_STATE_KEY,

‎apps/editor/src/features/search-files/utils/prompt-for-config.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,19 @@ export const prompt_for_api_configuration = async (params: {
2929
let skipped = false
3030

3131
if (!params.show_quick_pick) {
32-
if (params.api_configurations.length == 1) {
32+
const default_config =
33+
await params.providers_manager.get_default_intelligent_search_api_configuration()
34+
if (default_config) {
35+
const default_id = get_api_configuration_id(default_config)
36+
selected_api_configuration = params.api_configurations.find(
37+
(c) => get_api_configuration_id(c) == default_id
38+
)
39+
if (selected_api_configuration) {
40+
skipped = true
41+
}
42+
}
43+
44+
if (!selected_api_configuration && params.api_configurations.length == 1) {
3345
selected_api_configuration = params.api_configurations[0]
3446
skipped = true
3547
}

‎apps/editor/src/services/providers-manager.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type ConfigApiConfigurationFormat = {
2323
isDefaultForCodeAtCursor?: boolean
2424
isDefaultForPatchRepair?: boolean
2525
isDefaultForVoiceInput?: boolean
26+
isDefaultForIntelligentSearch?: boolean
2627
}
2728

2829
export const get_api_configuration_id = (
@@ -188,6 +189,8 @@ export class ProvidersManager {
188189
new_config.isDefaultForPatchRepair = true
189190
if (old_config?.isDefaultForVoiceInput)
190191
new_config.isDefaultForVoiceInput = true
192+
if (old_config?.isDefaultForIntelligentSearch)
193+
new_config.isDefaultForIntelligentSearch = true
191194
if (c.reasoning_effort !== undefined)
192195
new_config.reasoningEffort = c.reasoning_effort
193196
if (c.is_pinned !== undefined) new_config.isPinned = c.is_pinned
@@ -324,6 +327,24 @@ export class ProvidersManager {
324327
)
325328
}
326329

330+
public async get_default_intelligent_search_api_configuration(): Promise<
331+
ApiConfiguration | undefined
332+
> {
333+
await this._load_promise
334+
return this._get_default_api_configuration_from_settings(
335+
'isDefaultForIntelligentSearch'
336+
)
337+
}
338+
339+
public async set_default_intelligent_search_api_configuration(
340+
api_configuration: ApiConfiguration | null
341+
) {
342+
await this._set_default_api_configuration_in_settings(
343+
'isDefaultForIntelligentSearch',
344+
api_configuration
345+
)
346+
}
347+
327348
public async update_provider_name_in_api_configurations(params: {
328349
old_name: string
329350
new_name: string

‎apps/editor/src/utils/cli-configuration-format-converters.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type ConfigAgentConfigurationFormat = {
88
isPinned?: boolean
99
isDefaultForAgenticSearch?: boolean
1010
isDefaultForCodeAtCursor?: boolean
11+
isDefaultForIntelligentSearch?: boolean
1112
}
1213

1314
export const config_cli_configuration_to_ui_format = (

‎apps/editor/src/views/settings/backend/message-handlers/handle-get-api-configurations.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ export const handle_get_api_configurations = async (
2626
await providers_manager.get_default_patch_repair_api_configuration()
2727
const def_vi =
2828
await providers_manager.get_default_voice_input_api_configuration()
29+
const def_is =
30+
await providers_manager.get_default_intelligent_search_api_configuration()
2931

3032
provider.postMessage({
3133
command: 'API_CONFIGURATIONS',
3234
api_configurations,
3335
defaults: {
3436
'code-at-cursor': def_cac ? get_api_configuration_id(def_cac) : null,
3537
'patch-repair': def_pr ? get_api_configuration_id(def_pr) : null,
36-
'voice-input': def_vi ? get_api_configuration_id(def_vi) : null
38+
'voice-input': def_vi ? get_api_configuration_id(def_vi) : null,
39+
'intelligent-search': def_is ? get_api_configuration_id(def_is) : null
3740
}
3841
})
3942
}

‎apps/editor/src/views/settings/backend/message-handlers/handle-get-cli-configurations.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export const handle_get_cli_configurations = async (
2222
?.name || null,
2323
'code-at-cursor':
2424
cli_configurations_config.find((c: any) => c.isDefaultForCodeAtCursor)
25-
?.name || null
25+
?.name || null,
26+
'intelligent-search':
27+
cli_configurations_config.find(
28+
(c: any) => c.isDefaultForIntelligentSearch
29+
)?.name || null
2630
}
2731
})
2832
}

‎apps/editor/src/views/settings/backend/message-handlers/handle-select-default-cli-configuration.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ export const handle_select_default_cli_configuration = async (
6969
} else {
7070
delete new_c.isDefaultForCodeAtCursor
7171
}
72+
} else if (message.cli_feature == 'intelligent-search') {
73+
if (c.name == selected.cli_configuration_name) {
74+
new_c.isDefaultForIntelligentSearch = true
75+
} else {
76+
delete new_c.isDefaultForIntelligentSearch
77+
}
7278
}
7379
return new_c
7480
})

‎apps/editor/src/views/settings/backend/message-handlers/handle-set-default-api-configuration.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@ export const handle_set_default_api_configuration = async (
3131
await providers_manager.set_default_voice_input_api_configuration(
3232
api_configuration_to_set
3333
)
34+
} else if (type == 'intelligent-search') {
35+
await providers_manager.set_default_intelligent_search_api_configuration(
36+
api_configuration_to_set
37+
)
3438
}
3539
}

‎apps/editor/src/views/settings/backend/message-handlers/handle-set-default-cli-configuration.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ export const handle_set_default_cli_configuration = async (
2020
} else {
2121
delete new_c.isDefaultForCodeAtCursor
2222
}
23+
} else if (message.cli_feature == 'intelligent-search') {
24+
if (c.name == message.cli_configuration_name) {
25+
new_c.isDefaultForIntelligentSearch = true
26+
} else {
27+
delete new_c.isDefaultForIntelligentSearch
28+
}
2329
}
2430
return new_c
2531
})

0 commit comments

Comments
 (0)