mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
Ignore package-lock.json
This commit is contained in:
@@ -28,6 +28,8 @@ import { getCurrentIFrame } from '../workbench/Preview';
|
||||
import { getCurrentMouseData } from '../workbench/PointSelector';
|
||||
import { assert } from '~/lib/replay/ReplayProtocolClient';
|
||||
import { anthropicNumFreeUsesCookieName, anthropicApiKeyCookieName, MaxFreeUses } from '~/utils/freeUses';
|
||||
import type { FileMap } from '~/lib/stores/files';
|
||||
import { shouldIncludeFile } from '~/utils/fileUtils';
|
||||
|
||||
const toastAnimation = cssTransition({
|
||||
enter: 'animated fadeInRight',
|
||||
@@ -130,6 +132,16 @@ function handleInjectMessages(baseMessages: Message[], injectedMessages: Injecte
|
||||
return messages;
|
||||
}
|
||||
|
||||
function filterFiles(files: FileMap): FileMap {
|
||||
const rv: FileMap = {};
|
||||
for (const [path, file] of Object.entries(files)) {
|
||||
if (shouldIncludeFile(path)) {
|
||||
rv[path] = file;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
export const ChatImpl = memo(
|
||||
({ description, initialMessages, storeMessageHistory, importChat, exportChat }: ChatProps) => {
|
||||
useShortcuts();
|
||||
@@ -151,7 +163,7 @@ export const ChatImpl = memo(
|
||||
const { messages: baseMessages, isLoading, input, handleInputChange, setInput, stop, append } = useChat({
|
||||
api: '/api/chat',
|
||||
body: {
|
||||
files,
|
||||
files: filterFiles(files),
|
||||
promptId,
|
||||
},
|
||||
sendExtraMessageFields: true,
|
||||
|
||||
@@ -38,6 +38,8 @@ export async function chatAnthropic(chatController: ChatStreamController, apiKey
|
||||
});
|
||||
}
|
||||
|
||||
console.log("AnthropicMessages", JSON.stringify(messageParams, null, 2));
|
||||
|
||||
const response = await anthropic.messages.create({
|
||||
model: "claude-3-5-sonnet-20241022",
|
||||
messages: messageParams,
|
||||
|
||||
@@ -60,7 +60,7 @@ async function chatAction({ context, request }: ActionFunctionArgs) {
|
||||
await chatAnthropic(chatController, anthropicApiKey, system, coreMessages);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
chatController.writeText("Error chatting with Anthropic.");
|
||||
chatController.writeText(`Error chatting with Anthropic: ${e}`);
|
||||
}
|
||||
|
||||
controller.close();
|
||||
|
||||
@@ -16,6 +16,7 @@ export const IGNORE_PATTERNS = [
|
||||
'**/npm-debug.log*',
|
||||
'**/yarn-debug.log*',
|
||||
'**/yarn-error.log*',
|
||||
'**/package-lock.json',
|
||||
];
|
||||
|
||||
export const MAX_FILES = 1000;
|
||||
@@ -39,6 +40,10 @@ export const isBinaryFile = async (file: File): Promise<boolean> => {
|
||||
};
|
||||
|
||||
export const shouldIncludeFile = (path: string): boolean => {
|
||||
const projectDirectory = "/home/project/";
|
||||
if (path.startsWith(projectDirectory)) {
|
||||
path = path.substring(projectDirectory.length);
|
||||
}
|
||||
return !ig.ignores(path);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Message } from 'ai';
|
||||
import { generateId } from './fileUtils';
|
||||
import { generateId, shouldIncludeFile } from './fileUtils';
|
||||
import { detectProjectCommands, createCommandsMessage } from './projectCommands';
|
||||
|
||||
export interface FileArtifact {
|
||||
@@ -41,19 +41,18 @@ export const createChatFromFolder = async (
|
||||
? `\n\nSkipped ${binaryFiles.length} binary files:\n${binaryFiles.map((f) => `- ${f}`).join('\n')}`
|
||||
: '';
|
||||
|
||||
let filesContent = `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}`;
|
||||
filesContent += `<boltArtifact id="imported-files" title="Imported Files">`;
|
||||
for (const file of fileArtifacts) {
|
||||
if (shouldIncludeFile(file.path)) {
|
||||
filesContent += `<boltAction type="file" filePath="${file.path}">${file.content}</boltAction>\n\n`;
|
||||
}
|
||||
}
|
||||
filesContent += `</boltArtifact>`;
|
||||
|
||||
const filesMessage: Message = {
|
||||
role: 'assistant',
|
||||
content: `I've imported the contents of the "${folderName}" folder.${binaryFilesMessage}
|
||||
|
||||
<boltArtifact id="imported-files" title="Imported Files">
|
||||
${fileArtifacts
|
||||
.map(
|
||||
(file) => `<boltAction type="file" filePath="${file.path}">
|
||||
${file.content}
|
||||
</boltAction>`,
|
||||
)
|
||||
.join('\n\n')}
|
||||
</boltArtifact>`,
|
||||
content: filesContent,
|
||||
id: generateId(),
|
||||
createdAt: new Date(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user