@@ -3,16 +3,17 @@ import { Effect, Layer, Context } from "effect"
33import { FetchHttpClient , HttpClient , HttpClientRequest } from "effect/unstable/http"
44import { Config } from "@/config/config"
55import { InstanceState } from "@/effect/instance-state"
6+ import { RuntimeFlags } from "@/effect/runtime-flags"
67import { Flag } from "@opencode-ai/core/flag/flag"
78import { AppFileSystem } from "@opencode-ai/core/filesystem"
89import { withTransientReadRetry } from "@/util/effect-http-client"
910import { Global } from "@opencode-ai/core/global"
1011import type { MessageV2 } from "./message-v2"
1112import type { MessageID } from "./schema"
1213
13- const FILES = [
14+ const files = ( disableClaudeCodePrompt : boolean ) => [
1415 "AGENTS.md" ,
15- ...( Flag . OPENCODE_DISABLE_CLAUDE_CODE_PROMPT ? [ ] : [ "CLAUDE.md" ] ) ,
16+ ...( disableClaudeCodePrompt ? [ ] : [ "CLAUDE.md" ] ) ,
1617 "CONTEXT.md" , // deprecated
1718]
1819
@@ -50,18 +51,20 @@ export class Service extends Context.Service<Service, Interface>()("@opencode/In
5051export const layer : Layer . Layer <
5152 Service ,
5253 never ,
53- AppFileSystem . Service | Config . Service | Global . Service | HttpClient . HttpClient
54+ AppFileSystem . Service | Config . Service | Global . Service | HttpClient . HttpClient | RuntimeFlags . Service
5455> = Layer . effect (
5556 Service ,
5657 Effect . gen ( function * ( ) {
5758 const cfg = yield * Config . Service
5859 const fs = yield * AppFileSystem . Service
5960 const global = yield * Global . Service
61+ const flags = yield * RuntimeFlags . Service
6062 const http = HttpClient . filterStatusOk ( withTransientReadRetry ( yield * HttpClient . HttpClient ) )
6163 const globalFiles = [
6264 path . join ( global . config , "AGENTS.md" ) ,
63- ...( ! Flag . OPENCODE_DISABLE_CLAUDE_CODE_PROMPT ? [ path . join ( global . home , ".claude" , "CLAUDE.md" ) ] : [ ] ) ,
65+ ...( ! flags . disableClaudeCodePrompt ? [ path . join ( global . home , ".claude" , "CLAUDE.md" ) ] : [ ] ) ,
6466 ]
67+ const instructionFiles = files ( flags . disableClaudeCodePrompt )
6568
6669 const state = yield * InstanceState . make (
6770 Effect . fn ( "Instruction.state" ) ( ( ) =>
@@ -117,7 +120,7 @@ export const layer: Layer.Layer<
117120
118121 // The first project-level match wins so we don't stack AGENTS.md/CLAUDE.md from every ancestor.
119122 if ( ! Flag . OPENCODE_DISABLE_PROJECT_CONFIG ) {
120- for ( const file of FILES ) {
123+ for ( const file of instructionFiles ) {
121124 const matches = yield * fs
122125 . findUp ( file , ctx . directory , ctx . worktree )
123126 . pipe ( Effect . catch ( ( ) => Effect . succeed ( [ ] ) ) )
@@ -165,7 +168,7 @@ export const layer: Layer.Layer<
165168 } )
166169
167170 const find = Effect . fn ( "Instruction.find" ) ( function * ( dir : string ) {
168- for ( const file of FILES ) {
171+ for ( const file of instructionFiles ) {
169172 const filepath = path . resolve ( path . join ( dir , file ) )
170173 if ( yield * fs . existsSafe ( filepath ) ) return filepath
171174 }
@@ -225,6 +228,7 @@ export const defaultLayer = layer.pipe(
225228 Layer . provide ( Global . layer ) ,
226229 Layer . provide ( AppFileSystem . defaultLayer ) ,
227230 Layer . provide ( FetchHttpClient . layer ) ,
231+ Layer . provide ( RuntimeFlags . defaultLayer ) ,
228232)
229233
230234export function loaded ( messages : MessageV2 . WithParts [ ] ) {
0 commit comments