refactor(flags): migrate claude code prompt flag (#27690)

This commit is contained in:
Shoubhit Dash
2026-05-15 14:17:04 +05:30
committed by GitHub
parent 22cb0395e2
commit 202cc863b4
5 changed files with 64 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ import { Instruction } from "../../src/session/instruction"
import type { MessageV2 } from "../../src/session/message-v2"
import { MessageID, PartID, SessionID } from "../../src/session/schema"
import { Global } from "@opencode-ai/core/global"
import { RuntimeFlags } from "../../src/effect/runtime-flags"
import { provideInstance, provideTmpdirInstance, tmpdirScoped } from "../fixture/fixture"
import { testEffect } from "../lib/effect"
import { TestConfig } from "../fixture/config"
@@ -18,18 +19,19 @@ const it = testEffect(Layer.mergeAll(CrossSpawnSpawner.defaultLayer, NodeFileSys
const configLayer = TestConfig.layer()
const instructionLayer = (global: Partial<Global.Interface>) =>
const instructionLayer = (global: Partial<Global.Interface>, flags: Partial<RuntimeFlags.Info> = {}) =>
Instruction.layer.pipe(
Layer.provide(configLayer),
Layer.provide(AppFileSystem.defaultLayer),
Layer.provide(FetchHttpClient.layer),
Layer.provide(Global.layerWith(global)),
Layer.provide(RuntimeFlags.layer(flags)),
)
const provideInstruction =
(global: Partial<Global.Interface>) =>
(global: Partial<Global.Interface>, flags?: Partial<RuntimeFlags.Info>) =>
<A, E, R>(self: Effect.Effect<A, E, R>) =>
self.pipe(Effect.provide(instructionLayer(global)))
self.pipe(Effect.provide(instructionLayer(global, flags)))
const write = (filepath: string, content: string) =>
Effect.gen(function* () {
@@ -215,6 +217,24 @@ describe("Instruction.system", () => {
}).pipe(provideInstance(projectTmp), provideInstruction({ home: globalTmp, config: globalTmp }))
}),
)
it.live("skips project and global CLAUDE.md when Claude Code prompt is disabled", () =>
Effect.gen(function* () {
const globalTmp = yield* tmpWithFiles({ ".claude/CLAUDE.md": "# Global Claude" })
const projectTmp = yield* tmpWithFiles({ "CLAUDE.md": "# Project Claude" })
yield* Effect.gen(function* () {
const svc = yield* Instruction.Service
const paths = yield* svc.systemPaths()
expect(paths.has(path.join(globalTmp, ".claude", "CLAUDE.md"))).toBe(false)
expect(paths.has(path.join(projectTmp, "CLAUDE.md"))).toBe(false)
expect(yield* svc.system()).toEqual([])
}).pipe(
provideInstance(projectTmp),
provideInstruction({ home: globalTmp, config: globalTmp }, { disableClaudeCodePrompt: true }),
)
}),
)
})
describe("Instruction.systemPaths global config", () => {