Merge branch 'stackblitz-labs:main' into FEAT_BoltDYI_NEW_SETTINGS_UI_V2

This commit is contained in:
Stijnus 2025-01-30 23:43:27 +01:00 committed by GitHub
commit ec1bcb8aaa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 37 additions and 60 deletions

View File

@ -91,6 +91,11 @@ ${escapeBoltTags(file.content)}
const messages = [filesMessage];
if (commandsMessage) {
messages.push({
role: 'user',
id: generateId(),
content: 'Setup the codebase and Start the application',
});
messages.push(commandsMessage);
}

View File

@ -1,7 +1,7 @@
import type { PromptOptions } from '~/lib/common/prompt-library';
export default (options: PromptOptions) => {
const { cwd, allowedHtmlElements, modificationTagName } = options;
const { cwd, allowedHtmlElements } = options;
return `
You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices.
@ -13,6 +13,7 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
- Use Vite for web servers
- Databases: prefer libsql, sqlite, or non-native solutions
- When for react dont forget to write vite config and index.html to the project
- WebContainer CANNOT execute diff or patch editing so always write your code in full no partial/diff update
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
</system_constraints>
@ -25,12 +26,6 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
Available HTML elements: ${allowedHtmlElements.join(', ')}
</message_formatting_info>
<diff_spec>
File modifications in \`<${modificationTagName}>\` section:
- \`<diff path="/path/to/file">\`: GNU unified diff format
- \`<file path="/path/to/file">\`: Full new content
</diff_spec>
<chain_of_thought_instructions>
do not mention the phrase "chain of thought"
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
24. Order actions logically - dependencies MUST be installed first
25. For Vite project must include vite config and index.html for entry point
26. Provide COMPLETE, up-to-date content for all files - NO placeholders or partial updates
27. WebContainer CANNOT execute diff or patch editing so always write your code in full no partial/diff update
CRITICAL: These rules are ABSOLUTE and MUST be followed WITHOUT EXCEPTION in EVERY response.

View File

@ -1,4 +1,4 @@
import { MODIFICATIONS_TAG_NAME, WORK_DIR } from '~/utils/constants';
import { WORK_DIR } from '~/utils/constants';
import { allowedHTMLElements } from '~/utils/markdown';
import { stripIndents } from '~/utils/stripIndent';
@ -25,6 +25,8 @@ You are Bolt, an expert AI assistant and exceptional senior software developer w
IMPORTANT: Git is NOT available.
IMPORTANT: WebContainer CANNOT execute diff or patch editing so always write your code in full no partial/diff update
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!
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
You can make the output pretty by using only the following available HTML elements: ${allowedHTMLElements.map((tagName) => `<${tagName}>`).join(', ')}
</message_formatting_info>
<diff_spec>
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:
- \`<diff path="/some/file/path.ext">\`: Contains GNU unified diff format changes
- \`<file path="/some/file/path.ext">\`: Contains the full new content of the file
The system chooses \`<file>\` if the diff exceeds the new content size, otherwise \`<diff>\`.
GNU unified diff format structure:
- For diffs the header with original and modified file names is omitted!
- Changed sections start with @@ -X,Y +A,B @@ where:
- X: Original file starting line
- Y: Original file line count
- A: Modified file starting line
- B: Modified file line count
- (-) lines: Removed from original
- (+) lines: Added in modified version
- Unmarked lines: Unchanged context
Example:
<${MODIFICATIONS_TAG_NAME}>
<diff path="${WORK_DIR}/src/main.js">
@@ -2,7 +2,10 @@
return a + b;
}
-console.log('Hello, World!');
+console.log('Hello, Bolt!');
+
function greet() {
- return 'Greetings!';
+ return 'Greetings!!';
}
+
+console.log('The End');
</diff>
<file path="${WORK_DIR}/package.json">
// full file content here
</file>
</${MODIFICATIONS_TAG_NAME}>
</diff_spec>
<chain_of_thought_instructions>
Before providing a solution, BRIEFLY outline your implementation steps. This helps ensure systematic thinking and clear communication. Your planning should:
- List concrete steps you'll take

View File

@ -38,7 +38,7 @@ export const createChatFromFolder = async (
role: 'assistant',
content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
<boltArtifact id="imported-files" title="Imported Files">
<boltArtifact id="imported-files" title="Imported Files" type="bundled" >
${fileArtifacts
.map(
(file) => `<boltAction type="file" filePath="${file.path}">
@ -61,6 +61,11 @@ ${escapeBoltTags(file.content)}
const messages = [userMessage, filesMessage];
if (commandsMessage) {
messages.push({
role: 'user',
id: generateId(),
content: 'Setup the codebase and Start the application',
});
messages.push(commandsMessage);
}

View File

@ -3,7 +3,8 @@ import { generateId } from './fileUtils';
export interface ProjectCommands {
type: string;
setupCommand: string;
setupCommand?: string;
startCommand?: string;
followupMessage: string;
}
@ -33,7 +34,8 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
if (availableCommand) {
return {
type: 'Node.js',
setupCommand: `npm install && npm run ${availableCommand}`,
setupCommand: `npm install`,
startCommand: `npm run ${availableCommand}`,
followupMessage: `Found "${availableCommand}" script in package.json. Running "npm run ${availableCommand}" after installation.`,
};
}
@ -53,7 +55,7 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
if (hasFile('index.html')) {
return {
type: 'Static',
setupCommand: 'npx --yes serve',
startCommand: 'npx --yes serve',
followupMessage: '',
};
}
@ -62,17 +64,28 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
}
export function createCommandsMessage(commands: ProjectCommands): Message | null {
if (!commands.setupCommand) {
if (!commands.setupCommand && !commands.startCommand) {
return null;
}
let commandString = '';
if (commands.setupCommand) {
commandString += `
<boltAction type="shell">${commands.setupCommand}</boltAction>`;
}
if (commands.startCommand) {
commandString += `
<boltAction type="start">${commands.startCommand}</boltAction>
`;
}
return {
role: 'assistant',
content: `
<boltArtifact id="project-setup" title="Project Setup">
<boltAction type="shell">
${commands.setupCommand}
</boltAction>
${commandString}
</boltArtifact>${commands.followupMessage ? `\n\n${commands.followupMessage}` : ''}`,
id: generateId(),
createdAt: new Date(),