mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 00:03:13 +03:00
fix(core): let either Claude Code flag disable every CLAUDE.md (#64533)
This commit is contained in:
committed by
GitHub
Unverified
parent
b0cecfa496
commit
bd115fdac8
@@ -133,9 +133,7 @@ const processEffect = Effect.fnUntraced(function* (options: Options) {
|
||||
content: process.env.OPENCODE_CONFIG_CONTENT,
|
||||
},
|
||||
instructions: {
|
||||
claude: !truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE),
|
||||
// As in V1, the prompt flag only skips ~/.claude/CLAUDE.md.
|
||||
claudeGlobal: !(
|
||||
claude: !(
|
||||
truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE) ||
|
||||
truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT)
|
||||
),
|
||||
|
||||
@@ -42,7 +42,7 @@ export const Plugin = define({
|
||||
// ~/.claude/CLAUDE.md stands in for the global AGENTS.md when it is missing.
|
||||
const claudeGlobalFile = yield* fs.resolve(join(home, ".claude", "CLAUDE.md"))
|
||||
const names = InstructionDiscovery.filenames(discovery)
|
||||
const globalFiles = discovery.claudeGlobal ? [globalFile, claudeGlobalFile] : [globalFile]
|
||||
const globalFiles = discovery.claude ? [globalFile, claudeGlobalFile] : [globalFile]
|
||||
const loaded: { current: Loaded } = { current: { type: "available", files: [] } }
|
||||
const configured: { sources: string[]; remote: Map<string, InstructionDiscovery.File> } = {
|
||||
sources: [],
|
||||
|
||||
@@ -41,10 +41,8 @@ export interface Interface extends State.Transformable<Editor> {
|
||||
// Move it into plugin config once plugins can consume their own options.
|
||||
readonly project: boolean
|
||||
readonly global: boolean
|
||||
// Also read CLAUDE.md where no AGENTS.md exists.
|
||||
// Read CLAUDE.md where no AGENTS.md exists, and ~/.claude/CLAUDE.md when the global AGENTS.md is missing.
|
||||
readonly claude: boolean
|
||||
// Read ~/.claude/CLAUDE.md when the global AGENTS.md is missing.
|
||||
readonly claudeGlobal: boolean
|
||||
readonly list: () => Effect.Effect<File[] | Instructions.Unavailable>
|
||||
readonly load: () => Effect.Effect<Instructions.List>
|
||||
}
|
||||
@@ -53,7 +51,6 @@ export const Options = Schema.Struct({
|
||||
project: Schema.optional(Schema.Boolean),
|
||||
global: Schema.optional(Schema.Boolean),
|
||||
claude: Schema.optional(Schema.Boolean),
|
||||
claudeGlobal: Schema.optional(Schema.Boolean),
|
||||
})
|
||||
export type Options = typeof Options.Type
|
||||
|
||||
@@ -106,7 +103,6 @@ export const layer = (options?: Options) =>
|
||||
project: options?.project !== false,
|
||||
global: options?.global !== false,
|
||||
claude: options?.claude !== false,
|
||||
claudeGlobal: options?.claudeGlobal !== false,
|
||||
transform: state.transform,
|
||||
reload: state.reload,
|
||||
list,
|
||||
|
||||
@@ -34,7 +34,6 @@ const instructionLayer = (input: {
|
||||
http?: HttpClient.HttpClient
|
||||
project?: boolean
|
||||
claude?: boolean
|
||||
claudeGlobal?: boolean
|
||||
}) => {
|
||||
const watcher = Watcher.testLayer
|
||||
const config = Config.testLayer(input.instructions ? [configured(input.instructions)] : [])
|
||||
@@ -55,7 +54,6 @@ const instructionLayer = (input: {
|
||||
InstructionDiscovery.configured({
|
||||
project: input.project,
|
||||
claude: input.claude,
|
||||
claudeGlobal: input.claudeGlobal,
|
||||
}),
|
||||
),
|
||||
Global.node.replace(
|
||||
@@ -439,16 +437,16 @@ describe("ConfigInstructionPlugin.Plugin", () => {
|
||||
const claudeGlobal = path.join(home, ".claude", "CLAUDE.md")
|
||||
const projectAgents = path.join(project, "AGENTS.md")
|
||||
const packageClaude = path.join(directory, "CLAUDE.md")
|
||||
const load = (options: { claude?: boolean; claudeGlobal?: boolean } = {}) =>
|
||||
const load = (claude?: boolean) =>
|
||||
Effect.gen(function* () {
|
||||
const discovery = yield* start()
|
||||
return (yield* readInitial(yield* discovery.load())).text
|
||||
}).pipe(Effect.provide(layer(options)), Effect.scoped)
|
||||
const layer = (options: { claude?: boolean; claudeGlobal?: boolean }) =>
|
||||
}).pipe(Effect.provide(layer(claude)), Effect.scoped)
|
||||
const layer = (claude?: boolean) =>
|
||||
instructionLayer({
|
||||
config: global,
|
||||
home,
|
||||
...options,
|
||||
claude,
|
||||
locationServiceLayer: Layer.succeed(
|
||||
Location.Service,
|
||||
Location.Service.of(
|
||||
@@ -474,11 +472,6 @@ describe("ConfigInstructionPlugin.Plugin", () => {
|
||||
].join("\n\n"),
|
||||
)
|
||||
|
||||
// The prompt flag only drops the global fallback, as in V1.
|
||||
const withoutGlobal = yield* load({ claudeGlobal: false })
|
||||
expect(withoutGlobal).not.toContain("claude global")
|
||||
expect(withoutGlobal).toContain(`Instructions from: ${packageClaude}\npackage claude`)
|
||||
|
||||
yield* Effect.promise(async () => {
|
||||
await fs.mkdir(global, { recursive: true })
|
||||
await fs.writeFile(path.join(global, "AGENTS.md"), "global agents")
|
||||
@@ -487,7 +480,7 @@ describe("ConfigInstructionPlugin.Plugin", () => {
|
||||
expect(preferred).toContain(`Instructions from: ${path.join(global, "AGENTS.md")}\nglobal agents`)
|
||||
expect(preferred).not.toContain("claude global")
|
||||
|
||||
const disabled = yield* load({ claude: false, claudeGlobal: false })
|
||||
const disabled = yield* load(false)
|
||||
expect(disabled).not.toContain("CLAUDE.md")
|
||||
expect(disabled).toContain(`Instructions from: ${projectAgents}\nproject agents`)
|
||||
})
|
||||
|
||||
@@ -128,7 +128,6 @@ const discovery = Layer.mock(InstructionDiscovery.Service, {
|
||||
project: true,
|
||||
global: true,
|
||||
claude: true,
|
||||
claudeGlobal: true,
|
||||
load: () => Effect.succeed(Instructions.empty),
|
||||
})
|
||||
const skills = Layer.mock(SkillInstructions.Service, { load: () => Effect.succeed(Instructions.empty) })
|
||||
|
||||
@@ -80,7 +80,6 @@ const instructionContext = Layer.mock(InstructionDiscovery.Service, {
|
||||
project: true,
|
||||
global: true,
|
||||
claude: true,
|
||||
claudeGlobal: true,
|
||||
load: () => Effect.succeed(Instructions.empty),
|
||||
})
|
||||
const skillInstructions = Layer.mock(SkillInstructions.Service, { load: () => Effect.succeed(Instructions.empty) })
|
||||
|
||||
@@ -392,7 +392,6 @@ const layer = Layer.unwrap(
|
||||
project: true,
|
||||
global: true,
|
||||
claude: true,
|
||||
claudeGlobal: true,
|
||||
load: () => Effect.succeed(Instructions.empty),
|
||||
})
|
||||
const skillInstructions = Layer.mock(SkillInstructions.Service, {
|
||||
|
||||
@@ -42,10 +42,8 @@ export const ServerOptions = Schema.Struct({
|
||||
),
|
||||
instructions: Schema.optional(
|
||||
Schema.Struct({
|
||||
// false skips the per-directory CLAUDE.md fallback.
|
||||
// false skips the per-directory and ~/.claude/CLAUDE.md fallbacks.
|
||||
claude: Schema.optional(Schema.Boolean),
|
||||
// false skips the ~/.claude/CLAUDE.md fallback.
|
||||
claudeGlobal: Schema.optional(Schema.Boolean),
|
||||
}),
|
||||
),
|
||||
windows: Schema.optional(
|
||||
|
||||
@@ -157,7 +157,6 @@ function makeRoutes<AuthError, AuthServices>(
|
||||
InstructionDiscovery.configured({
|
||||
project: options.config?.project,
|
||||
claude: options.instructions?.claude,
|
||||
claudeGlobal: options.instructions?.claudeGlobal,
|
||||
}),
|
||||
),
|
||||
ShellSelect.node.replace(ShellSelect.configured({ gitbash: options.windows?.gitbash })),
|
||||
|
||||
@@ -45,9 +45,9 @@ In any directory without an `AGENTS.md`, OpenCode reads `CLAUDE.md` instead. Wit
|
||||
`~/.config/opencode/AGENTS.md`, it reads `~/.claude/CLAUDE.md`. A directory's `AGENTS.md` always wins over its
|
||||
`CLAUDE.md`, so a symlink between the two loads once.
|
||||
|
||||
Set `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1` to skip only `~/.claude/CLAUDE.md`, or `OPENCODE_DISABLE_CLAUDE_CODE=1` to
|
||||
skip every `CLAUDE.md` and `.claude` skills. The server reads both when it starts. For the background service, persist
|
||||
them with `opencode service set env` and run `opencode service restart`.
|
||||
Set `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1` to skip every `CLAUDE.md`, or `OPENCODE_DISABLE_CLAUDE_CODE=1` to also skip
|
||||
`.claude` skills. The server reads both when it starts. For the background service, persist them with
|
||||
`opencode service set env` and run `opencode service restart`.
|
||||
|
||||
## Discovery
|
||||
|
||||
|
||||
@@ -554,8 +554,8 @@ Existing `AGENTS.md` files stay in place. V2 discovers the global `~/.config/ope
|
||||
files from the current directory up to home. For projects outside home, discovery stops at the project root.
|
||||
|
||||
V2 keeps the V1 `CLAUDE.md` fallback: a directory without `AGENTS.md` uses its `CLAUDE.md`, and `~/.claude/CLAUDE.md`
|
||||
stands in for a missing global `AGENTS.md`. As before, `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT` skips only
|
||||
`~/.claude/CLAUDE.md` and `OPENCODE_DISABLE_CLAUDE_CODE` skips every `CLAUDE.md`. Unlike V1, which stopped at the
|
||||
stands in for a missing global `AGENTS.md`. `OPENCODE_DISABLE_CLAUDE_CODE` skips every `CLAUDE.md`, and so does
|
||||
`OPENCODE_DISABLE_CLAUDE_CODE_PROMPT`, which in V1 skipped only `~/.claude/CLAUDE.md`. Unlike V1, which stopped at the
|
||||
first file name found anywhere up the tree, V2 picks per directory, so an `AGENTS.md` at the root no longer hides a
|
||||
nested `CLAUDE.md`. See [Instructions](/instructions).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user