Skip to content

Commit 137e268

Browse files
authored
fix: tune the system prompt to avoid diff writing (#1218)
1 parent f5fbf42 commit 137e268

File tree

2 files changed

+6
-52
lines changed

2 files changed

+6
-52
lines changed

app/lib/common/prompts/optimized.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { PromptOptions } from '~/lib/common/prompt-library';
22

33
export default (options: PromptOptions) => {
4-
const { cwd, allowedHtmlElements, modificationTagName } = options;
4+
const { cwd, allowedHtmlElements } = options;
55
return `
66
You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices.
77
@@ -13,6 +13,7 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
1313
- Use Vite for web servers
1414
- Databases: prefer libsql, sqlite, or non-native solutions
1515
- When for react dont forget to write vite config and index.html to the project
16+
- WebContainer CANNOT execute diff or patch editing so always write your code in full no partial/diff update
1617
1718
Available shell commands: cat, cp, ls, mkdir, mv, rm, rmdir, touch, hostname, ps, pwd, uptime, env, node, python3, code, jq, curl, head, sort, tail, clear, which, export, chmod, scho, kill, ln, xxd, alias, getconf, loadenv, wasm, xdg-open, command, exit, source
1819
</system_constraints>
@@ -25,12 +26,6 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
2526
Available HTML elements: ${allowedHtmlElements.join(', ')}
2627
</message_formatting_info>
2728
28-
<diff_spec>
29-
File modifications in \`<${modificationTagName}>\` section:
30-
- \`<diff path="/path/to/file">\`: GNU unified diff format
31-
- \`<file path="/path/to/file">\`: Full new content
32-
</diff_spec>
33-
3429
<chain_of_thought_instructions>
3530
do not mention the phrase "chain of thought"
3631
Before solutions, briefly outline implementation steps (2-4 lines max):
@@ -88,6 +83,7 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
8883
24. Order actions logically - dependencies MUST be installed first
8984
25. For Vite project must include vite config and index.html for entry point
9085
26. Provide COMPLETE, up-to-date content for all files - NO placeholders or partial updates
86+
27. WebContainer CANNOT execute diff or patch editing so always write your code in full no partial/diff update
9187
9288
CRITICAL: These rules are ABSOLUTE and MUST be followed WITHOUT EXCEPTION in EVERY response.
9389

app/lib/common/prompts/prompts.ts

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MODIFICATIONS_TAG_NAME, WORK_DIR } from '~/utils/constants';
1+
import { WORK_DIR } from '~/utils/constants';
22
import { allowedHTMLElements } from '~/utils/markdown';
33
import { stripIndents } from '~/utils/stripIndent';
44

@@ -25,6 +25,8 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
2525
2626
IMPORTANT: Git is NOT available.
2727
28+
IMPORTANT: WebContainer CANNOT execute diff or patch editing so always write your code in full no partial/diff update
29+
2830
IMPORTANT: Prefer writing Node.js scripts instead of shell scripts. The environment doesn't fully support shell scripts, so use Node.js for scripting tasks whenever possible!
2931
3032
IMPORTANT: When choosing databases or npm packages, prefer options that don't rely on native binaries. For databases, prefer libsql, sqlite, or other solutions that don't involve native code. WebContainer CANNOT execute arbitrary native binaries.
@@ -65,50 +67,6 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
6567
You can make the output pretty by using only the following available HTML elements: ${allowedHTMLElements.map((tagName) => `<${tagName}>`).join(', ')}
6668
</message_formatting_info>
6769
68-
<diff_spec>
69-
For user-made file modifications, a \`<${MODIFICATIONS_TAG_NAME}>\` section will appear at the start of the user message. It will contain either \`<diff>\` or \`<file>\` elements for each modified file:
70-
71-
- \`<diff path="/some/file/path.ext">\`: Contains GNU unified diff format changes
72-
- \`<file path="/some/file/path.ext">\`: Contains the full new content of the file
73-
74-
The system chooses \`<file>\` if the diff exceeds the new content size, otherwise \`<diff>\`.
75-
76-
GNU unified diff format structure:
77-
78-
- For diffs the header with original and modified file names is omitted!
79-
- Changed sections start with @@ -X,Y +A,B @@ where:
80-
- X: Original file starting line
81-
- Y: Original file line count
82-
- A: Modified file starting line
83-
- B: Modified file line count
84-
- (-) lines: Removed from original
85-
- (+) lines: Added in modified version
86-
- Unmarked lines: Unchanged context
87-
88-
Example:
89-
90-
<${MODIFICATIONS_TAG_NAME}>
91-
<diff path="${WORK_DIR}/src/main.js">
92-
@@ -2,7 +2,10 @@
93-
return a + b;
94-
}
95-
96-
-console.log('Hello, World!');
97-
+console.log('Hello, Bolt!');
98-
+
99-
function greet() {
100-
- return 'Greetings!';
101-
+ return 'Greetings!!';
102-
}
103-
+
104-
+console.log('The End');
105-
</diff>
106-
<file path="${WORK_DIR}/package.json">
107-
// full file content here
108-
</file>
109-
</${MODIFICATIONS_TAG_NAME}>
110-
</diff_spec>
111-
11270
<chain_of_thought_instructions>
11371
Before providing a solution, BRIEFLY outline your implementation steps. This helps ensure systematic thinking and clear communication. Your planning should:
11472
- List concrete steps you'll take

0 commit comments

Comments
 (0)