@@ -7,6 +7,7 @@ import { BaseChat } from '~/components/chat/BaseChat';
77import { Chat } from '~/components/chat/Chat.client' ;
88import { useGit } from '~/lib/hooks/useGit' ;
99import { useChatHistory } from '~/lib/persistence' ;
10+ import { createCommandsMessage , detectProjectCommands } from '~/utils/projectCommands' ;
1011
1112const IGNORE_PATTERNS = [
1213 'node_modules/**' ,
@@ -49,39 +50,49 @@ export function GitUrlImport() {
4950
5051 if ( importChat ) {
5152 const filePaths = Object . keys ( data ) . filter ( ( filePath ) => ! ig . ignores ( filePath ) ) ;
52- console . log ( filePaths ) ;
5353
5454 const textDecoder = new TextDecoder ( 'utf-8' ) ;
55- const message : Message = {
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 = {
5673 role : 'assistant' ,
5774 content : `Cloning the repo ${ repoUrl } into ${ workdir }
58- <boltArtifact id="imported-files" title="Git Cloned Files" type="bundled" >
59- ${ filePaths
60- . map ( ( filePath ) => {
61- const { data : content , encoding } = data [ filePath ] ;
62-
63- if ( encoding === 'utf8' ) {
64- return `<boltAction type="file" filePath="${ filePath } ">
65- ${ content }
66- </boltAction>` ;
67- } else if ( content instanceof Uint8Array ) {
68- return `<boltAction type="file" filePath="${ filePath } ">
69- ${ textDecoder . decode ( content ) }
70- </boltAction>` ;
71- } else {
72- return '' ;
73- }
74- } )
75- . join ( '\n' ) }
76- </boltArtifact>` ,
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>` ,
7785 id : generateId ( ) ,
7886 createdAt : new Date ( ) ,
7987 } ;
80- console . log ( JSON . stringify ( message ) ) ;
8188
82- importChat ( `Git Project:${ repoUrl . split ( '/' ) . slice ( - 1 ) [ 0 ] } ` , [ message ] ) ;
89+ const messages = [ filesMessage ] ;
90+
91+ if ( commandsMessage ) {
92+ messages . push ( commandsMessage ) ;
93+ }
8394
84- // console.log(files );
95+ await importChat ( `Git Project: ${ repoUrl . split ( '/' ) . slice ( - 1 ) [ 0 ] } ` , messages ) ;
8596 }
8697 }
8798 } ;
0 commit comments