Stijnus commited on
Commit
ec1bcb8
·
unverified ·
2 Parent(s): 73bc81c 137e268

Merge branch 'stackblitz-labs:main' into FEAT_BoltDYI_NEW_SETTINGS_UI_V2

Browse files
app/components/git/GitUrlImport.client.tsx CHANGED
@@ -91,6 +91,11 @@ ${escapeBoltTags(file.content)}
91
  const messages = [filesMessage];
92
 
93
  if (commandsMessage) {
 
 
 
 
 
94
  messages.push(commandsMessage);
95
  }
96
 
 
91
  const messages = [filesMessage];
92
 
93
  if (commandsMessage) {
94
+ messages.push({
95
+ role: 'user',
96
+ id: generateId(),
97
+ content: 'Setup the codebase and Start the application',
98
+ });
99
  messages.push(commandsMessage);
100
  }
101
 
app/lib/common/prompts/optimized.ts CHANGED
@@ -1,7 +1,7 @@
1
  import type { PromptOptions } from '~/lib/common/prompt-library';
2
 
3
  export default (options: PromptOptions) => {
4
- const { cwd, allowedHtmlElements, modificationTagName } = options;
5
  return `
6
  You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices.
7
 
@@ -13,6 +13,7 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
13
  - Use Vite for web servers
14
  - Databases: prefer libsql, sqlite, or non-native solutions
15
  - When for react dont forget to write vite config and index.html to the project
 
16
 
17
  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
18
  </system_constraints>
@@ -25,12 +26,6 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
25
  Available HTML elements: ${allowedHtmlElements.join(', ')}
26
  </message_formatting_info>
27
 
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
-
34
  <chain_of_thought_instructions>
35
  do not mention the phrase "chain of thought"
36
  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
88
  24. Order actions logically - dependencies MUST be installed first
89
  25. For Vite project must include vite config and index.html for entry point
90
  26. Provide COMPLETE, up-to-date content for all files - NO placeholders or partial updates
 
91
 
92
  CRITICAL: These rules are ABSOLUTE and MUST be followed WITHOUT EXCEPTION in EVERY response.
93
 
 
1
  import type { PromptOptions } from '~/lib/common/prompt-library';
2
 
3
  export default (options: PromptOptions) => {
4
+ const { cwd, allowedHtmlElements } = options;
5
  return `
6
  You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices.
7
 
 
13
  - Use Vite for web servers
14
  - Databases: prefer libsql, sqlite, or non-native solutions
15
  - 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
17
 
18
  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
19
  </system_constraints>
 
26
  Available HTML elements: ${allowedHtmlElements.join(', ')}
27
  </message_formatting_info>
28
 
 
 
 
 
 
 
29
  <chain_of_thought_instructions>
30
  do not mention the phrase "chain of thought"
31
  Before solutions, briefly outline implementation steps (2-4 lines max):
 
83
  24. Order actions logically - dependencies MUST be installed first
84
  25. For Vite project must include vite config and index.html for entry point
85
  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
87
 
88
  CRITICAL: These rules are ABSOLUTE and MUST be followed WITHOUT EXCEPTION in EVERY response.
89
 
app/lib/common/prompts/prompts.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MODIFICATIONS_TAG_NAME, WORK_DIR } from '~/utils/constants';
2
  import { allowedHTMLElements } from '~/utils/markdown';
3
  import { stripIndents } from '~/utils/stripIndent';
4
 
@@ -25,6 +25,8 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
25
 
26
  IMPORTANT: Git is NOT available.
27
 
 
 
28
  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!
29
 
30
  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
65
  You can make the output pretty by using only the following available HTML elements: ${allowedHTMLElements.map((tagName) => `<${tagName}>`).join(', ')}
66
  </message_formatting_info>
67
 
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
-
112
  <chain_of_thought_instructions>
113
  Before providing a solution, BRIEFLY outline your implementation steps. This helps ensure systematic thinking and clear communication. Your planning should:
114
  - List concrete steps you'll take
 
1
+ import { WORK_DIR } from '~/utils/constants';
2
  import { allowedHTMLElements } from '~/utils/markdown';
3
  import { stripIndents } from '~/utils/stripIndent';
4
 
 
25
 
26
  IMPORTANT: Git is NOT available.
27
 
28
+ IMPORTANT: WebContainer CANNOT execute diff or patch editing so always write your code in full no partial/diff update
29
+
30
  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!
31
 
32
  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.
 
67
  You can make the output pretty by using only the following available HTML elements: ${allowedHTMLElements.map((tagName) => `<${tagName}>`).join(', ')}
68
  </message_formatting_info>
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  <chain_of_thought_instructions>
71
  Before providing a solution, BRIEFLY outline your implementation steps. This helps ensure systematic thinking and clear communication. Your planning should:
72
  - List concrete steps you'll take
app/utils/folderImport.ts CHANGED
@@ -38,7 +38,7 @@ export const createChatFromFolder = async (
38
  role: 'assistant',
39
  content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
40
 
41
- <boltArtifact id="imported-files" title="Imported Files">
42
  ${fileArtifacts
43
  .map(
44
  (file) => `<boltAction type="file" filePath="${file.path}">
@@ -61,6 +61,11 @@ ${escapeBoltTags(file.content)}
61
  const messages = [userMessage, filesMessage];
62
 
63
  if (commandsMessage) {
 
 
 
 
 
64
  messages.push(commandsMessage);
65
  }
66
 
 
38
  role: 'assistant',
39
  content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
40
 
41
+ <boltArtifact id="imported-files" title="Imported Files" type="bundled" >
42
  ${fileArtifacts
43
  .map(
44
  (file) => `<boltAction type="file" filePath="${file.path}">
 
61
  const messages = [userMessage, filesMessage];
62
 
63
  if (commandsMessage) {
64
+ messages.push({
65
+ role: 'user',
66
+ id: generateId(),
67
+ content: 'Setup the codebase and Start the application',
68
+ });
69
  messages.push(commandsMessage);
70
  }
71
 
app/utils/projectCommands.ts CHANGED
@@ -3,7 +3,8 @@ import { generateId } from './fileUtils';
3
 
4
  export interface ProjectCommands {
5
  type: string;
6
- setupCommand: string;
 
7
  followupMessage: string;
8
  }
9
 
@@ -33,7 +34,8 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
33
  if (availableCommand) {
34
  return {
35
  type: 'Node.js',
36
- setupCommand: `npm install && npm run ${availableCommand}`,
 
37
  followupMessage: `Found "${availableCommand}" script in package.json. Running "npm run ${availableCommand}" after installation.`,
38
  };
39
  }
@@ -53,7 +55,7 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
53
  if (hasFile('index.html')) {
54
  return {
55
  type: 'Static',
56
- setupCommand: 'npx --yes serve',
57
  followupMessage: '',
58
  };
59
  }
@@ -62,17 +64,28 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
62
  }
63
 
64
  export function createCommandsMessage(commands: ProjectCommands): Message | null {
65
- if (!commands.setupCommand) {
66
  return null;
67
  }
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  return {
70
  role: 'assistant',
71
  content: `
72
  <boltArtifact id="project-setup" title="Project Setup">
73
- <boltAction type="shell">
74
- ${commands.setupCommand}
75
- </boltAction>
76
  </boltArtifact>${commands.followupMessage ? `\n\n${commands.followupMessage}` : ''}`,
77
  id: generateId(),
78
  createdAt: new Date(),
 
3
 
4
  export interface ProjectCommands {
5
  type: string;
6
+ setupCommand?: string;
7
+ startCommand?: string;
8
  followupMessage: string;
9
  }
10
 
 
34
  if (availableCommand) {
35
  return {
36
  type: 'Node.js',
37
+ setupCommand: `npm install`,
38
+ startCommand: `npm run ${availableCommand}`,
39
  followupMessage: `Found "${availableCommand}" script in package.json. Running "npm run ${availableCommand}" after installation.`,
40
  };
41
  }
 
55
  if (hasFile('index.html')) {
56
  return {
57
  type: 'Static',
58
+ startCommand: 'npx --yes serve',
59
  followupMessage: '',
60
  };
61
  }
 
64
  }
65
 
66
  export function createCommandsMessage(commands: ProjectCommands): Message | null {
67
+ if (!commands.setupCommand && !commands.startCommand) {
68
  return null;
69
  }
70
 
71
+ let commandString = '';
72
+
73
+ if (commands.setupCommand) {
74
+ commandString += `
75
+ <boltAction type="shell">${commands.setupCommand}</boltAction>`;
76
+ }
77
+
78
+ if (commands.startCommand) {
79
+ commandString += `
80
+ <boltAction type="start">${commands.startCommand}</boltAction>
81
+ `;
82
+ }
83
+
84
  return {
85
  role: 'assistant',
86
  content: `
87
  <boltArtifact id="project-setup" title="Project Setup">
88
+ ${commandString}
 
 
89
  </boltArtifact>${commands.followupMessage ? `\n\n${commands.followupMessage}` : ''}`,
90
  id: generateId(),
91
  createdAt: new Date(),