diff --git a/app/components/git/GitUrlImport.client.tsx b/app/components/git/GitUrlImport.client.tsx
index 47ed708..cbdeaa5 100644
--- a/app/components/git/GitUrlImport.client.tsx
+++ b/app/components/git/GitUrlImport.client.tsx
@@ -7,6 +7,7 @@ import { BaseChat } from '~/components/chat/BaseChat';
import { Chat } from '~/components/chat/Chat.client';
import { useGit } from '~/lib/hooks/useGit';
import { useChatHistory } from '~/lib/persistence';
+import { createCommandsMessage, detectProjectCommands } from '~/utils/projectCommands';
const IGNORE_PATTERNS = [
'node_modules/**',
@@ -49,39 +50,49 @@ export function GitUrlImport() {
if (importChat) {
const filePaths = Object.keys(data).filter((filePath) => !ig.ignores(filePath));
- console.log(filePaths);
const textDecoder = new TextDecoder('utf-8');
- const message: Message = {
+
+ // Convert files to common format for command detection
+ const fileContents = filePaths
+ .map((filePath) => {
+ const { data: content, encoding } = data[filePath];
+ return {
+ path: filePath,
+ content: encoding === 'utf8' ? content : content instanceof Uint8Array ? textDecoder.decode(content) : '',
+ };
+ })
+ .filter((f) => f.content);
+
+ // Detect and create commands message
+ const commands = await detectProjectCommands(fileContents);
+ const commandsMessage = createCommandsMessage(commands);
+
+ // Create files message
+ const filesMessage: Message = {
role: 'assistant',
content: `Cloning the repo ${repoUrl} into ${workdir}
-
- ${filePaths
- .map((filePath) => {
- const { data: content, encoding } = data[filePath];
-
- if (encoding === 'utf8') {
- return `
-${content}
-`;
- } else if (content instanceof Uint8Array) {
- return `
-${textDecoder.decode(content)}
-`;
- } else {
- return '';
- }
- })
- .join('\n')}
- `,
+
+${fileContents
+ .map(
+ (file) =>
+ `
+${file.content}
+`,
+ )
+ .join('\n')}
+`,
id: generateId(),
createdAt: new Date(),
};
- console.log(JSON.stringify(message));
- importChat(`Git Project:${repoUrl.split('/').slice(-1)[0]}`, [message]);
+ const messages = [filesMessage];
- // console.log(files);
+ if (commandsMessage) {
+ messages.push(commandsMessage);
+ }
+
+ await importChat(`Git Project:${repoUrl.split('/').slice(-1)[0]}`, messages);
}
}
};