@@ -75,7 +75,9 @@ export namespace InstructionPrompt {
7575 for ( const file of FILES ) {
7676 const matches = await Filesystem . findUp ( file , Instance . directory , Instance . worktree )
7777 if ( matches . length > 0 ) {
78- matches . forEach ( ( p ) => paths . add ( path . resolve ( p ) ) )
78+ matches . forEach ( ( p ) => {
79+ paths . add ( path . resolve ( p ) )
80+ } )
7981 break
8082 }
8183 }
@@ -103,7 +105,9 @@ export namespace InstructionPrompt {
103105 } ) ,
104106 ) . catch ( ( ) => [ ] )
105107 : await resolveRelative ( instruction )
106- matches . forEach ( ( p ) => paths . add ( path . resolve ( p ) ) )
108+ matches . forEach ( ( p ) => {
109+ paths . add ( path . resolve ( p ) )
110+ } )
107111 }
108112 }
109113
@@ -168,11 +172,17 @@ export namespace InstructionPrompt {
168172 const already = loaded ( messages )
169173 const results : { filepath : string ; content : string } [ ] = [ ]
170174
171- let current = path . dirname ( path . resolve ( filepath ) )
175+ const target = path . resolve ( filepath )
176+ let current = path . dirname ( target )
172177 const root = path . resolve ( Instance . directory )
173178
174179 while ( current . startsWith ( root ) ) {
175180 const found = await find ( current )
181+ if ( found === target ) {
182+ if ( current === root ) break
183+ current = path . dirname ( current )
184+ continue
185+ }
176186 if ( found && ! system . has ( found ) && ! already . has ( found ) && ! isClaimed ( messageID , found ) ) {
177187 claim ( messageID , found )
178188 const content = await Bun . file ( found )
0 commit comments