@@ -7,12 +7,14 @@ import { t } from '@/i18n'
77import {
88 LAST_SELECTED_WORKSPACE_IN_AGENTIC_SEARCH_STATE_KEY ,
99 LAST_USED_AGENTIC_SEARCH_AGENT_STATE_KEY ,
10- LAST_AGENTIC_SEARCH_QUERY_STATE_KEY
10+ LAST_AGENTIC_SEARCH_QUERY_STATE_KEY ,
11+ LAST_AGENTIC_SEARCH_ADDITIONAL_INSTRUCTIONS_STATE_KEY
1112} from '@/constants/state-keys'
1213import { extract_paths_from_bullet_list } from '@/utils/extract-paths-from-bullet-list'
1314import { get_all_workspace_files } from '@/context/helpers/get-all-workspace-files'
1415import { show_search_results_quick_pick } from '@/features/search-files/utils/show-search-results-quick-pick'
1516import { prompt_for_search_term } from './utils/prompt-for-search-term'
17+ import { prompt_for_additional_instructions } from './utils/prompt-for-additional-instructions'
1618import { build_agent_prompt } from './utils/build-agent-prompt'
1719import { replace_symbols } from '@/views/prompt/backend/utils/symbols/replace-symbols'
1820import { search_files } from '@/features/search-files'
@@ -90,15 +92,55 @@ export const agentic_search = async (params: {
9092 target_folder : params . folder_path ,
9193 build_prompt : async ( ) => {
9294 while ( true ) {
95+ let current_query = query
96+
9397 if (
9498 first_run &&
9599 params . skip_prompt_if_not_empty &&
96100 query . trim ( ) !== ''
97101 ) {
102+ const last_additional =
103+ params . extension_context . workspaceState . get < string > (
104+ LAST_AGENTIC_SEARCH_ADDITIONAL_INSTRUCTIONS_STATE_KEY
105+ ) || ''
106+ const additional_instructions_result =
107+ await prompt_for_additional_instructions ( {
108+ show_back_button : true ,
109+ initial_value : last_additional ,
110+ on_change : ( value ) => {
111+ params . extension_context . workspaceState . update (
112+ LAST_AGENTIC_SEARCH_ADDITIONAL_INSTRUCTIONS_STATE_KEY ,
113+ value
114+ )
115+ }
116+ } )
117+
118+ if ( additional_instructions_result . back ) {
119+ return 'back'
120+ }
121+
122+ if ( additional_instructions_result . value === undefined ) {
123+ return undefined
124+ }
125+
98126 first_run = false
127+
128+ if ( additional_instructions_result . value . trim ( ) !== '' ) {
129+ current_query = `${ query } \n\nAdditional instructions:\n${ additional_instructions_result . value } `
130+ }
99131 } else {
100132 const query_result = await prompt_for_search_term ( query , {
101- show_back_button : true
133+ show_back_button : true ,
134+ on_change : ( value ) => {
135+ query = value
136+ params . extension_context . workspaceState . update (
137+ LAST_AGENTIC_SEARCH_QUERY_STATE_KEY ,
138+ {
139+ instructions : params . current_instructions ,
140+ query : value
141+ }
142+ )
143+ }
102144 } )
103145
104146 if ( query_result . back ) {
@@ -109,23 +151,25 @@ export const agentic_search = async (params: {
109151 return undefined
110152 }
111153
154+ first_run = false
155+
112156 query = query_result . value
157+ current_query = query
113158 }
114- first_run = false
115159
116- if ( query . trim ( ) === '' ) {
160+ if ( current_query . trim ( ) === '' ) {
117161 continue
118162 }
119163
120164 await params . extension_context . workspaceState . update (
121165 LAST_AGENTIC_SEARCH_QUERY_STATE_KEY ,
122166 {
123167 instructions : params . current_instructions ,
124- query
168+ query : current_query
125169 }
126170 )
127171
128- const instructions_to_process = [ query ]
172+ const instructions_to_process = [ current_query ]
129173 if ( params . completed_tasks ) {
130174 instructions_to_process . push ( ...params . completed_tasks )
131175 }
0 commit comments