Skip to content

Commit 7b3568f

Browse files
committed
Standardize prune context instructions and add UI configuration for them
1 parent 4c1bd55 commit 7b3568f

15 files changed

Lines changed: 132 additions & 13 deletions

File tree

‎packages/ui/src/components/editor/panel/Timeline/Timeline.module.scss‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,11 @@
9595
overflow: hidden;
9696
text-overflow: ellipsis;
9797
white-space: nowrap;
98+
font-weight: 500;
9899
}
99100
}
100101

101102
&__description {
102-
font-size: 12px;
103-
color: var(--cwc-text-color-dimmed);
104103
display: -webkit-box;
105104
-webkit-line-clamp: 3;
106105
-webkit-box-orient: vertical;

‎packages/vscode/package.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,11 @@
685685
"scope": "resource",
686686
"default": "You're a helpful coding assistant. Don't explain changes in inline comments."
687687
},
688+
"codeWebChat.pruneContextInstructions": {
689+
"type": "string",
690+
"scope": "resource",
691+
"default": "Find all files building modules the task touches (including tests, type definitions, etc.)."
692+
},
688693
"codeWebChat.chatPresetsForAskAboutContext": {
689694
"type": "array",
690695
"default": [

‎packages/vscode/src/constants/instructions.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ export const intelligent_update_instructions =
2929
export const commit_message_instructions =
3030
"Write a brief and precise summary for the changes, limited to a single sentence, if possible and nothing else. Because the summary will be used for a commit message, don't use any markdown formatting. Use an imperative tone to ensure clarity and focus on the primary change or purpose."
3131

32-
export const prune_context_instructions = `Find all files building modules the task touches (including tests, type definitions, etc.).
33-
<system>
32+
export const prune_context_instructions =
33+
'Find all files building modules the task touches (including tests, type definitions, etc.).'
34+
35+
export const prune_context_format = `<system>
36+
3437
Your response must begin with "**Relevant files:**", then list paths one under another. Don't send anything else. Example:
3538
3639
**Relevant files:**
3740
3841
- \`src/hello.ts\`
3942
- \`src/welcome.ts\`
43+
4044
</system>`

‎packages/vscode/src/views/panel/backend/message-handlers/handle-copy-prompt.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
import { replace_saved_context_placeholder } from '@/utils/replace-saved-context-placeholder'
1111
import {
1212
code_completion_instructions_for_panel,
13-
prune_context_instructions
13+
prune_context_instructions,
14+
prune_context_format
1415
} from '@/constants/instructions'
1516
import { apply_preset_affixes_to_instruction } from '@/utils/apply-preset-affixes'
1617
import { MODE } from '@/views/panel/types/main-view-mode'
@@ -200,7 +201,7 @@ export const handle_copy_prompt = async (params: {
200201
system_instructions_xml = `<system>\n${edit_format_instructions}\n</system>`
201202
}
202203
} else if (is_in_prune_context_prompt_type) {
203-
system_instructions_xml = prune_context_instructions
204+
system_instructions_xml = `${prune_context_instructions}\n${prune_context_format}`
204205
}
205206

206207
const text = context_text

‎packages/vscode/src/views/panel/backend/message-handlers/handle-edit-context.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import { PanelProvider } from '@/views/panel/backend/panel-provider'
2626
import { apply_reasoning_effort } from '@/utils/apply-reasoning-effort'
2727
import { EditContextMessage } from '@/views/panel/types/messages'
2828
import { dictionary } from '@shared/constants/dictionary'
29-
import { prune_context_instructions } from '@/constants/instructions'
29+
import {
30+
prune_context_instructions,
31+
prune_context_format
32+
} from '@/constants/instructions'
3033
import {
3134
EDIT_FORMAT_INSTRUCTIONS_WHOLE,
3235
EDIT_FORMAT_INSTRUCTIONS_TRUNCATED,
@@ -415,7 +418,7 @@ export const handle_edit_context = async (
415418

416419
let system_instructions_xml = ''
417420
if (is_prune_context) {
418-
system_instructions_xml = prune_context_instructions
421+
system_instructions_xml = `${prune_context_instructions}\n${prune_context_format}`
419422
} else if (edit_format_instructions) {
420423
system_instructions_xml = `<system>\n${edit_format_instructions}\n</system>`
421424
}

‎packages/vscode/src/views/panel/backend/message-handlers/handle-prune-context.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import { PanelProvider } from '@/views/panel/backend/panel-provider'
2424
import { apply_reasoning_effort } from '@/utils/apply-reasoning-effort'
2525
import { PruneContextMessage } from '@/views/panel/types/messages'
2626
import { dictionary } from '@shared/constants/dictionary'
27-
import { prune_context_instructions } from '@/constants/instructions'
27+
import {
28+
prune_context_instructions,
29+
prune_context_format
30+
} from '@/constants/instructions'
2831

2932
const get_prune_context_config = async (
3033
api_providers_manager: ModelProvidersManager,
@@ -380,7 +383,7 @@ export const handle_prune_context = async (
380383

381384
const files = `<files>${collected_files}\n</files>`
382385

383-
const system_instructions_xml = prune_context_instructions
386+
const system_instructions_xml = `${prune_context_instructions}\n${prune_context_format}`
384387

385388
const content = `${system_instructions_xml}\n${files}\n${system_instructions_xml}\n${processed_instructions}`
386389

‎packages/vscode/src/views/panel/backend/message-handlers/handle-send-prompt.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
} from '@/views/panel/backend/utils/replace-git-symbols'
1212
import {
1313
code_completion_instructions_for_panel,
14-
prune_context_instructions
14+
prune_context_instructions,
15+
prune_context_format
1516
} from '@/constants/instructions'
1617
import { get_recently_used_presets_or_groups_key } from '@/constants/state-keys'
1718
import { ConfigPresetFormat } from '../utils/preset-format-converters'
@@ -279,7 +280,7 @@ export const handle_send_prompt = async (params: {
279280
system_instructions_xml = `<system>\n${edit_format_instructions}\n</system>`
280281
}
281282
} else if (params.panel_provider.web_prompt_type == 'prune-context') {
282-
system_instructions_xml = prune_context_instructions
283+
system_instructions_xml = `${prune_context_instructions}\n${prune_context_format}`
283284
}
284285

285286
return {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as vscode from 'vscode'
2+
import { SettingsProvider } from '@/views/settings/backend/settings-provider'
3+
import { prune_context_instructions } from '@/constants/instructions'
4+
5+
export const handle_get_prune_context_instructions = async (
6+
provider: SettingsProvider
7+
): Promise<void> => {
8+
const config = vscode.workspace.getConfiguration('codeWebChat')
9+
const instructions =
10+
config.get<string>('pruneContextInstructions') || prune_context_instructions
11+
provider.postMessage({
12+
command: 'PRUNE_CONTEXT_INSTRUCTIONS',
13+
instructions
14+
})
15+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as vscode from 'vscode'
2+
import { UpdatePruneContextInstructionsMessage } from '@/views/settings/types/messages'
3+
import { prune_context_instructions } from '@/constants/instructions'
4+
5+
export const handle_update_prune_context_instructions = async (
6+
message: UpdatePruneContextInstructionsMessage
7+
): Promise<void> => {
8+
await vscode.workspace
9+
.getConfiguration('codeWebChat')
10+
.update(
11+
'pruneContextInstructions',
12+
message.instructions == '' ||
13+
message.instructions == prune_context_instructions
14+
? undefined
15+
: message.instructions,
16+
vscode.ConfigurationTarget.Global
17+
)
18+
}

‎packages/vscode/src/views/settings/backend/message-handlers/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export * from './handle-set-default-intelligent-update-configuration'
2626
export * from './handle-get-prune-context-configurations'
2727
export * from './handle-reorder-prune-context-configurations'
2828
export * from './handle-delete-prune-context-configuration'
29+
export * from './handle-get-prune-context-instructions'
30+
export * from './handle-update-prune-context-instructions'
2931
export * from './handle-get-commit-message-instructions'
3032
export * from './handle-update-commit-message-instructions'
3133
export * from './handle-get-commit-message-auto-accept-after'

0 commit comments

Comments
 (0)