Skip to content

Commit 1b28afa

Browse files
committed
Refactor prompt requirements to array and update AGENT prompt documentation
- to 'intelligent search' 'commit messages' and 'code at cursor', add 'agent' detail - requirements on PromptBuilder.build_prompt should be an array ├── README.md └── apps └── editor └── 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 │ ├── copy-markdown-command.ts │ └── generate-commit-message-commands │ ├── actions │ │ ├── get-prompt-data.ts │ │ └── run-generate-action.ts │ ├── generate-commit-message-commands.ts │ ├── index.ts │ └── utils │ ├── build-commit-message-prompt.ts │ ├── generate-commit-message-with-api.ts │ ├── get-commit-message-config.ts │ └── strip-wrapping-quotes.ts ├── constants │ ├── instructions.ts │ └── state-keys.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 ├── i18n │ └── translations │ ├── common.ts │ ├── features │ │ └── search-files.ts │ └── utils │ └── agentic-cli-invocation.ts ├── services │ └── providers-manager.ts ├── utils │ ├── agentic-cli-invocation │ │ ├── agents │ │ │ ├── antigravity.ts │ │ │ ├── claude.ts │ │ │ ├── codex.ts │ │ │ ├── cursor.ts │ │ │ ├── grok.ts │ │ │ ├── index.ts │ │ │ └── opencode.ts │ │ ├── index.ts │ │ ├── invoke-agentic-cli.ts │ │ ├── types.ts │ │ └── utils │ │ ├── check-command-exists.ts │ │ ├── format-duration.ts │ │ ├── generate-diff-markdown.ts │ │ └── get-progress-dots.ts │ ├── apply-reasoning-effort.ts │ ├── build-user-content.ts │ ├── get-api-configuration.ts │ ├── git-repository-utils.ts │ ├── prompt-builder.ts │ └── send-llm-message.ts └── views └── prompt └── backend └── message-handlers ├── handle-autofill.ts ├── handle-copy-prompt.ts ├── handle-invoke-agentic-cli.ts ├── handle-make-api-call.ts ├── handle-preview-prompt.ts ├── handle-preview-web-configuration.ts └── utils └── build-cli-prompt.ts
1 parent 330b99a commit 1b28afa

5 files changed

Lines changed: 106 additions & 15 deletions

File tree

‎README.md‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,37 @@ Output strictly as a bulleted list of file paths without explanations or any oth
128128

129129
</details>
130130

131+
<details>
132+
<summary>AGENT</summary>
133+
134+
```
135+
# Files
136+
137+
[WORKSPACE FILES, A FOLDER OR SELECTED FILES]
138+
139+
# Task
140+
141+
Among the attached files, find the complete set of primary and structural files relevant to the query.
142+
143+
# Output formatting
144+
145+
Output strictly as a bulleted list of file paths without explanations or any other text. Example:
146+
147+
- `src/index.ts`
148+
- `src/greetings/hello.ts`
149+
- `src/greetings/welcome.ts`
150+
151+
# Requirements
152+
153+
- Modifying the file system or running any shell commands (grep, glob, ls, git, etc.) is FORBIDDEN.
154+
155+
# Query
156+
157+
[INSTRUCTIONS]
158+
```
159+
160+
</details>
161+
131162
### 📄 Editing
132163

133164
_New features, bug fixes, and refactors._
@@ -270,6 +301,37 @@ Find correct replacement text for the <missing_text> symbol.
270301

271302
</details>
272303

304+
<details>
305+
<summary>AGENT</summary>
306+
307+
````
308+
# Files
309+
310+
[SELECTED FILES]
311+
312+
### File: `[ACTIVE FILE PATH]`
313+
314+
```
315+
[PREFIX]<missing_text>[INSTRUCTIONS]</missing_text>[SUFFIX]
316+
```
317+
318+
# Output formatting
319+
320+
Respond with replacement text within "replacement" XML tags, without explanations or any other text.
321+
Example:
322+
<replacement>!== undefined</replacement>
323+
324+
# Requirements
325+
326+
- Modifying the file system or running any shell commands (grep, glob, ls, git, etc.) is FORBIDDEN.
327+
328+
# Task
329+
330+
Find correct replacement text for the <missing_text> symbol.
331+
````
332+
333+
</details>
334+
273335
### 📄 Commit messages
274336

275337
_Summaries based on staged changes and context files._
@@ -300,6 +362,35 @@ Write a brief and precise summary for the changes, limited to a single sentence.
300362

301363
</details>
302364

365+
<details>
366+
<summary>AGENT</summary>
367+
368+
```
369+
# Files
370+
371+
[SELECTED FILES WHEN EDITS WERE ACCEPTED]
372+
373+
# Changes
374+
375+
[STAGED CHANGES]
376+
377+
# Output formatting
378+
379+
Your response must begin with "**Commit message:**", then proceed with the message. Example:
380+
381+
**Commit message:** Bump version to 1.0.1
382+
383+
# Requirements
384+
385+
- Modifying the file system or running any shell commands (grep, glob, ls, git, etc.) is FORBIDDEN.
386+
387+
# Task
388+
389+
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.
390+
```
391+
392+
</details>
393+
303394
### 📄 Patch repair
304395

305396
_Applying malformed edits._

‎apps/editor/src/commands/code-at-cursor-command/utils/perform-code-at-cursor.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ export const perform_code_at_cursor = async (params: {
356356
}${text_after_cursor}`
357357
},
358358
output_formatting: code_at_cursor_output_formatting,
359-
requirements: cli_edit_ask_requirements.restrict_shell_commands,
359+
requirements: [cli_edit_ask_requirements.restrict_shell_commands],
360360
user_instructions: code_at_cursor_user_instructions
361361
})
362362

‎apps/editor/src/constants/instructions.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ export const voice_input_instructions =
6969
'Respond with a transcription of the following audio recording or text "INAUDIBLE", and nothing else.'
7070

7171
export const cli_edit_ask_requirements = {
72-
preloaded_context:
73-
"All project's files were preloaded to [files](#files). If [task](#task) includes *.png image paths, read them using the appropriate tool.",
74-
read_images: 'You may only use tools to read images from [task](#task).',
72+
preloaded_context: "All project's files were preloaded to [files](#files).",
7573
restrict_shell_commands:
76-
'Modifying the file system or running any shell commands (grep, glob, ls, git, etc.) is FORBIDDEN.',
77-
restrict_tool_calls_with_exceptions:
78-
'You may only perform file operations (create, update, delete) required to complete the [task](#task); running any shell commands (grep, glob, ls, git, etc.) is FORBIDDEN.'
74+
'Calling tools, including shell commands (grep, glob, ls, git, etc.) is FORBIDDEN.',
75+
exception_read_images:
76+
'Exception: If [task](#task) includes *.png image paths, read them using the appropriate tool.',
77+
exception_allow_file_system_operations:
78+
'Exception: Perform file system operations (create, update, delete) required to complete the [task](#task).'
7979
}

‎apps/editor/src/utils/prompt-builder.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export namespace PromptBuilder {
6666
active_file?: { filepath: string; content: string }
6767
skill_definitions?: string
6868
output_formatting?: string
69-
requirements?: string
69+
requirements?: string[]
7070
user_instructions?: string
7171
}): { part1: string; part2: string; full_prompt: string } => {
7272
let part1 = ''
@@ -114,8 +114,9 @@ export namespace PromptBuilder {
114114
if (params.output_formatting) {
115115
sys += `# Output formatting\n\n${params.output_formatting.trimEnd()}\n\n`
116116
}
117-
if (params.requirements) {
118-
sys += `# Requirements\n\n${params.requirements.trimEnd()}\n\n`
117+
if (params.requirements && params.requirements.length > 0) {
118+
const req_str = params.requirements.map((r) => `- ${r}`).join('\n')
119+
sys += `# Requirements\n\n${req_str}\n\n`
119120
}
120121
sys = sys.trimEnd()
121122

‎apps/editor/src/views/prompt/backend/message-handlers/utils/build-cli-prompt.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,19 @@ export const build_cli_prompt = async (params: {
7777
const requirements_list = [cli_edit_ask_requirements.preloaded_context]
7878

7979
if (prompt_view_provider.cli_prompt_type == 'edit-files') {
80+
requirements_list.push(cli_edit_ask_requirements.exception_read_images)
8081
requirements_list.push(
81-
cli_edit_ask_requirements.restrict_tool_calls_with_exceptions
82+
cli_edit_ask_requirements.exception_allow_file_system_operations
8283
)
8384
} else {
84-
requirements_list.push(cli_edit_ask_requirements.read_images)
8585
requirements_list.push(cli_edit_ask_requirements.restrict_shell_commands)
86+
requirements_list.push(cli_edit_ask_requirements.exception_read_images)
8687
}
8788

88-
const requirements = requirements_list.map((r) => `- ${r}`).join('\n')
89-
9089
const build_result = PromptBuilder.build_prompt({
9190
files_context,
9291
skill_definitions,
93-
requirements,
92+
requirements: requirements_list,
9493
user_instructions: processed_query
9594
})
9695

0 commit comments

Comments
 (0)