@@ -8,7 +8,6 @@ import { Flag } from "@/flag/flag"
88import { AppFileSystem } from "@opencode-ai/shared/filesystem"
99import { withTransientReadRetry } from "@/util/effect-http-client"
1010import { Global } from "../global"
11- import { Instance } from "../project/instance"
1211import { Log } from "../util"
1312import type { MessageV2 } from "./message-v2"
1413import type { MessageID } from "./schema"
@@ -82,9 +81,10 @@ export const layer: Layer.Layer<Service, never, AppFileSystem.Service | Config.S
8281 )
8382
8483 const relative = Effect . fnUntraced ( function * ( instruction : string ) {
84+ const ctx = yield * InstanceState . context
8585 if ( ! Flag . OPENCODE_DISABLE_PROJECT_CONFIG ) {
8686 return yield * fs
87- . globUp ( instruction , Instance . directory , Instance . worktree )
87+ . globUp ( instruction , ctx . directory , ctx . worktree )
8888 . pipe ( Effect . catch ( ( ) => Effect . succeed ( [ ] as string [ ] ) ) )
8989 }
9090 if ( ! Flag . OPENCODE_CONFIG_DIR ) {
@@ -119,12 +119,13 @@ export const layer: Layer.Layer<Service, never, AppFileSystem.Service | Config.S
119119
120120 const systemPaths = Effect . fn ( "Instruction.systemPaths" ) ( function * ( ) {
121121 const config = yield * cfg . get ( )
122+ const ctx = yield * InstanceState . context
122123 const paths = new Set < string > ( )
123124
124125 // The first project-level match wins so we don't stack AGENTS.md/CLAUDE.md from every ancestor.
125126 if ( ! Flag . OPENCODE_DISABLE_PROJECT_CONFIG ) {
126127 for ( const file of FILES ) {
127- const matches = yield * fs . findUp ( file , Instance . directory , Instance . worktree )
128+ const matches = yield * fs . findUp ( file , ctx . directory , ctx . worktree )
128129 if ( matches . length > 0 ) {
129130 matches . forEach ( ( item ) => paths . add ( path . resolve ( item ) ) )
130131 break
@@ -191,9 +192,9 @@ export const layer: Layer.Layer<Service, never, AppFileSystem.Service | Config.S
191192 const already = extract ( messages )
192193 const results : { filepath : string ; content : string } [ ] = [ ]
193194 const s = yield * InstanceState . get ( state )
195+ const root = path . resolve ( yield * InstanceState . directory )
194196
195197 const target = path . resolve ( filepath )
196- const root = path . resolve ( Instance . directory )
197198 let current = path . dirname ( target )
198199
199200 // Walk upward from the file being read and attach nearby instruction files once per message.
0 commit comments