added setup command
Browse files
app/components/git/GitUrlImport.client.tsx
CHANGED
@@ -7,6 +7,7 @@ import { BaseChat } from '~/components/chat/BaseChat';
|
|
7 |
import { Chat } from '~/components/chat/Chat.client';
|
8 |
import { useGit } from '~/lib/hooks/useGit';
|
9 |
import { useChatHistory } from '~/lib/persistence';
|
|
|
10 |
|
11 |
const IGNORE_PATTERNS = [
|
12 |
'node_modules/**',
|
@@ -49,39 +50,49 @@ export function GitUrlImport() {
|
|
49 |
|
50 |
if (importChat) {
|
51 |
const filePaths = Object.keys(data).filter((filePath) => !ig.ignores(filePath));
|
52 |
-
console.log(filePaths);
|
53 |
|
54 |
const textDecoder = new TextDecoder('utf-8');
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
role: 'assistant',
|
57 |
content: `Cloning the repo ${repoUrl} into ${workdir}
|
58 |
-
<boltArtifact id="imported-files" title="Git Cloned Files" type="bundled"
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
return `<boltAction type="file" filePath="${filePath}">
|
69 |
-
${textDecoder.decode(content)}
|
70 |
-
</boltAction>`;
|
71 |
-
} else {
|
72 |
-
return '';
|
73 |
-
}
|
74 |
-
})
|
75 |
-
.join('\n')}
|
76 |
-
</boltArtifact>`,
|
77 |
id: generateId(),
|
78 |
createdAt: new Date(),
|
79 |
};
|
80 |
-
console.log(JSON.stringify(message));
|
81 |
|
82 |
-
|
|
|
|
|
|
|
|
|
83 |
|
84 |
-
|
85 |
}
|
86 |
}
|
87 |
};
|
|
|
7 |
import { Chat } from '~/components/chat/Chat.client';
|
8 |
import { useGit } from '~/lib/hooks/useGit';
|
9 |
import { useChatHistory } from '~/lib/persistence';
|
10 |
+
import { createCommandsMessage, detectProjectCommands } from '~/utils/projectCommands';
|
11 |
|
12 |
const IGNORE_PATTERNS = [
|
13 |
'node_modules/**',
|
|
|
50 |
|
51 |
if (importChat) {
|
52 |
const filePaths = Object.keys(data).filter((filePath) => !ig.ignores(filePath));
|
|
|
53 |
|
54 |
const textDecoder = new TextDecoder('utf-8');
|
55 |
+
|
56 |
+
// Convert files to common format for command detection
|
57 |
+
const fileContents = filePaths
|
58 |
+
.map((filePath) => {
|
59 |
+
const { data: content, encoding } = data[filePath];
|
60 |
+
return {
|
61 |
+
path: filePath,
|
62 |
+
content: encoding === 'utf8' ? content : content instanceof Uint8Array ? textDecoder.decode(content) : '',
|
63 |
+
};
|
64 |
+
})
|
65 |
+
.filter((f) => f.content);
|
66 |
+
|
67 |
+
// Detect and create commands message
|
68 |
+
const commands = await detectProjectCommands(fileContents);
|
69 |
+
const commandsMessage = createCommandsMessage(commands);
|
70 |
+
|
71 |
+
// Create files message
|
72 |
+
const filesMessage: Message = {
|
73 |
role: 'assistant',
|
74 |
content: `Cloning the repo ${repoUrl} into ${workdir}
|
75 |
+
<boltArtifact id="imported-files" title="Git Cloned Files" type="bundled">
|
76 |
+
${fileContents
|
77 |
+
.map(
|
78 |
+
(file) =>
|
79 |
+
`<boltAction type="file" filePath="${file.path}">
|
80 |
+
${file.content}
|
81 |
+
</boltAction>`,
|
82 |
+
)
|
83 |
+
.join('\n')}
|
84 |
+
</boltArtifact>`,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
id: generateId(),
|
86 |
createdAt: new Date(),
|
87 |
};
|
|
|
88 |
|
89 |
+
const messages = [filesMessage];
|
90 |
+
|
91 |
+
if (commandsMessage) {
|
92 |
+
messages.push(commandsMessage);
|
93 |
+
}
|
94 |
|
95 |
+
await importChat(`Git Project:${repoUrl.split('/').slice(-1)[0]}`, messages);
|
96 |
}
|
97 |
}
|
98 |
};
|