Skip to content

Commit 909bc78

Browse files
committed
Refactor relevant file search prompt construction to separate system formatting from user instructions and update instruction text
- the checkpionts quick pick should not use relative time
1 parent 9f9de19 commit 909bc78

5 files changed

Lines changed: 12 additions & 11 deletions

File tree

apps/editor/src/commands/search-files-command/utils/fetch-relevant-files-from-api.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ export const fetch_relevant_files_from_api = async (
2626
}
2727
xml_files += `</files>`
2828

29-
const system_instructions_xml = `${find_relevant_files_format}\n${find_relevant_files_instructions}`
30-
const part2 = `${system_instructions_xml}\n${instructions}`
29+
const part2 = `${find_relevant_files_format}\n\n${find_relevant_files_instructions}\n\n${instructions}`
3130
const user_content = build_user_content({
3231
model_provider,
3332
part1: xml_files,

apps/editor/src/constants/instructions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const commit_message_instructions =
3333
"Write a brief and precise summary for the changes, limited to a single sentence. Because the summary will be used for a commit message, don't use any markdown formatting and don't include a trailing dot. Use an imperative tone to ensure clarity and focus on the primary change or purpose."
3434

3535
export const find_relevant_files_instructions =
36-
'Find a complete set of relevant files according to the following query:'
36+
'Find a complete set of files relevant to the following query (include the primary files as well as any structural files):'
3737

3838
export const find_relevant_files_format = `# System
3939

apps/editor/src/views/panel/backend/message-handlers/handle-copy-prompt.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export const handle_copy_prompt = async (params: {
125125
})
126126

127127
let formatted_system_instructions = ''
128+
let user_instructions = processed_instructions
128129

129130
if (params.panel_provider.web_prompt_type == 'edit-files') {
130131
const edit_format =
@@ -150,14 +151,15 @@ export const handle_copy_prompt = async (params: {
150151
formatted_system_instructions = `# System\n\n${edit_format_instructions}`
151152
}
152153
} else if (is_in_find_relevant_files_prompt_type) {
153-
formatted_system_instructions = `${find_relevant_files_format_for_panel}\n\n${find_relevant_files_instructions}`
154+
formatted_system_instructions = find_relevant_files_format_for_panel
155+
user_instructions = `${find_relevant_files_instructions}\n\n${processed_instructions}`
154156
}
155157

156158
const { full_prompt: text } = PromptBuilder.build_prompt({
157159
context_text,
158160
skill_definitions,
159161
system_instructions: formatted_system_instructions,
160-
user_instructions: processed_instructions
162+
user_instructions
161163
})
162164

163165
vscode.env.clipboard.writeText(text.trim())

apps/editor/src/views/panel/backend/message-handlers/handle-find-relevant-files.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,12 @@ export const handle_find_relevant_files = async (
216216

217217
const endpoint_url = model_provider.base_url
218218

219-
const formatted_system_instructions = `${find_relevant_files_format_for_panel}\n\n${find_relevant_files_instructions}`
220-
221219
const { part1, part2 } = PromptBuilder.build_prompt({
222220
other_files: collected.other_files,
223221
recent_files: collected.recent_files,
224222
skill_definitions,
225-
system_instructions: formatted_system_instructions,
226-
user_instructions: processed_instructions
223+
system_instructions: find_relevant_files_format_for_panel,
224+
user_instructions: `${find_relevant_files_instructions}\n\n${processed_instructions}`
227225
})
228226

229227
const user_content = build_user_content({

apps/editor/src/views/panel/backend/message-handlers/handle-send-to-browser.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export const handle_send_to_browser = async (params: {
161161
})
162162

163163
let formatted_system_instructions = ''
164+
let user_instructions = processed_instructions
164165
if (params.panel_provider.web_prompt_type == 'edit-files') {
165166
const config = vscode.workspace.getConfiguration('codeWebChat')
166167
const instructions_key = {
@@ -181,14 +182,15 @@ export const handle_send_to_browser = async (params: {
181182
formatted_system_instructions = `# System\n\n${edit_format_instructions}`
182183
}
183184
} else if (params.panel_provider.web_prompt_type == 'find-relevant-files') {
184-
formatted_system_instructions = `${find_relevant_files_format_for_panel}\n\n${find_relevant_files_instructions}`
185+
formatted_system_instructions = find_relevant_files_format_for_panel
186+
user_instructions = `${find_relevant_files_instructions}\n\n${processed_instructions}`
185187
}
186188

187189
const { full_prompt: text } = PromptBuilder.build_prompt({
188190
context_text,
189191
skill_definitions,
190192
system_instructions: formatted_system_instructions,
191-
user_instructions: processed_instructions
193+
user_instructions
192194
})
193195

194196
sent =

0 commit comments

Comments
 (0)