mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-03-09 13:41:00 +00:00
fix: issue with alternate message when importing from folder and git (#1216)
This commit is contained in:
parent
7016111906
commit
f5fbf421e9
@ -91,6 +91,11 @@ ${escapeBoltTags(file.content)}
|
|||||||
const messages = [filesMessage];
|
const messages = [filesMessage];
|
||||||
|
|
||||||
if (commandsMessage) {
|
if (commandsMessage) {
|
||||||
|
messages.push({
|
||||||
|
role: 'user',
|
||||||
|
id: generateId(),
|
||||||
|
content: 'Setup the codebase and Start the application',
|
||||||
|
});
|
||||||
messages.push(commandsMessage);
|
messages.push(commandsMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export const createChatFromFolder = async (
|
|||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
|
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
|
${fileArtifacts
|
||||||
.map(
|
.map(
|
||||||
(file) => `<boltAction type="file" filePath="${file.path}">
|
(file) => `<boltAction type="file" filePath="${file.path}">
|
||||||
@ -61,6 +61,11 @@ ${escapeBoltTags(file.content)}
|
|||||||
const messages = [userMessage, filesMessage];
|
const messages = [userMessage, filesMessage];
|
||||||
|
|
||||||
if (commandsMessage) {
|
if (commandsMessage) {
|
||||||
|
messages.push({
|
||||||
|
role: 'user',
|
||||||
|
id: generateId(),
|
||||||
|
content: 'Setup the codebase and Start the application',
|
||||||
|
});
|
||||||
messages.push(commandsMessage);
|
messages.push(commandsMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@ import { generateId } from './fileUtils';
|
|||||||
|
|
||||||
export interface ProjectCommands {
|
export interface ProjectCommands {
|
||||||
type: string;
|
type: string;
|
||||||
setupCommand: string;
|
setupCommand?: string;
|
||||||
|
startCommand?: string;
|
||||||
followupMessage: string;
|
followupMessage: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +34,8 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
|
|||||||
if (availableCommand) {
|
if (availableCommand) {
|
||||||
return {
|
return {
|
||||||
type: 'Node.js',
|
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.`,
|
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')) {
|
if (hasFile('index.html')) {
|
||||||
return {
|
return {
|
||||||
type: 'Static',
|
type: 'Static',
|
||||||
setupCommand: 'npx --yes serve',
|
startCommand: 'npx --yes serve',
|
||||||
followupMessage: '',
|
followupMessage: '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -62,17 +64,28 @@ export async function detectProjectCommands(files: FileContent[]): Promise<Proje
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createCommandsMessage(commands: ProjectCommands): Message | null {
|
export function createCommandsMessage(commands: ProjectCommands): Message | null {
|
||||||
if (!commands.setupCommand) {
|
if (!commands.setupCommand && !commands.startCommand) {
|
||||||
return null;
|
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 {
|
return {
|
||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
content: `
|
content: `
|
||||||
<boltArtifact id="project-setup" title="Project Setup">
|
<boltArtifact id="project-setup" title="Project Setup">
|
||||||
<boltAction type="shell">
|
${commandString}
|
||||||
${commands.setupCommand}
|
|
||||||
</boltAction>
|
|
||||||
</boltArtifact>${commands.followupMessage ? `\n\n${commands.followupMessage}` : ''}`,
|
</boltArtifact>${commands.followupMessage ? `\n\n${commands.followupMessage}` : ''}`,
|
||||||
id: generateId(),
|
id: generateId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
|
Loading…
Reference in New Issue
Block a user