@@ -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,12 +172,14 @@ 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
174- while ( current . startsWith ( root ) ) {
179+ while ( current . startsWith ( root ) && current !== root ) {
175180 const found = await find ( current )
176- if ( found && ! system . has ( found ) && ! already . has ( found ) && ! isClaimed ( messageID , found ) ) {
181+
182+ if ( found && found !== target && ! system . has ( found ) && ! already . has ( found ) && ! isClaimed ( messageID , found ) ) {
177183 claim ( messageID , found )
178184 const content = await Bun . file ( found )
179185 . text ( )
@@ -182,7 +188,6 @@ export namespace InstructionPrompt {
182188 results . push ( { filepath : found , content : "Instructions from: " + found + "\n" + content } )
183189 }
184190 }
185- if ( current === root ) break
186191 current = path . dirname ( current )
187192 }
188193
0 commit comments