feat(core): [v2] restore OPENCODE_DISABLE_CLAUDE_CODE - #44725
malarahfelipe wants to merge 6 commits into
Conversation
1b1e312 to
e824b19
Compare
|
Did this as a partial implementation for the #36990 – can you take a look once you got time @rekram1-node ? |
2a354d3 to
ccabcb6
Compare
ccabcb6 to
e2fcbd5
Compare
|
just rebased and solved conflicts, can you approve the workflows? @rekram1-node |
holny
left a comment
There was a problem hiding this comment.
Read this against current v2 — the placement looks right to me. discovery.ts is the only place that produces .claude roots, and everything downstream of sources.claude derives from that array: the skills scan in config/plugin/compatibility.ts:40 (via config.compatibility()) and the watch list in config/watch.ts:16. Emptying the array stops both the skill loading and the extra fs watches, and the AGENTS.md instruction plugin never touches .claude anyway, so this covers the whole surface on its own.
One gap: the env var is the part people actually set, but the new test only drives the disableClaudeCode option, so nothing pins the Config.boolean(...) wiring. It does work — I ran a probe against the effect version in this repo from packages/core and OPENCODE_DISABLE_CLAUDE_CODE=1 / yes gives true while 0 / unset gives false — but the config tests don't provide a ConfigProvider, so discovery now reads the ambient environment: with that variable exported in the shell, the assertions at config.test.ts:917 and :1573 flip to an empty claude list. Pinning a provider in one test, e.g. ConfigProvider.layer(ConfigProvider.fromEnv({ env: { OPENCODE_DISABLE_CLAUDE_CODE: "1" } })) the way packages/ai tests do, would cover the env path and keep the suite hermetic.
Minor: config.ts:47 documents what global: false skips; a one-liner on disableClaudeCode noting the env var as the fallback would help the next person wiring a CLI flag.
…_CODE - testLayer now provides ConfigProvider (empty env by default) so config discovery never reads the ambient process environment. - Add an env-path test alongside the disableClaudeCode option test, with a no-flag assertion so it cannot pass trivially. - Assert via Config.compatibility(); the claude/agents entry types were removed on v2, which left the option test red after the rebase. - Document the OPENCODE_DISABLE_CLAUDE_CODE fallback on the option.
|
Thanks @holny — both points addressed in eaa5aa4. Env path is now pinned. New test covers the env var. It pins Doc comment added on One thing the rebase surfaced: the option test was still asserting on Unrelated heads-up: |
Why this matters
EvidenceTip
Confirms the flag actually skips Claude sources. Happy to help land. Ask (design, light) — prospective
|
Extract the duplicated claude/agents root building into an optionalRoots helper: roots vanish when disabled, and the global directory joins only while the global scope is enabled. No behavior change; covered by the config discovery tests.
|
Follow-up, @kvnloo — took the helper option and landed it in 02f41dd. // Optional roots vanish when disabled; their global directory joins only
// while the global scope is enabled.
const optionalRoots = (name: string, globalPath: AbsolutePath, enabled = true) => …
claude: optionalRoots(".claude", globalClaudeDirectory, !disableClaudeCode),
agents: optionalRoots(".agents", globalAgentsDirectory),On your two questions:
Behavior unchanged: 42/42 config tests with the var unset and |
Issue for this PR
Part of #36990
Type of change
What does this PR do?
Brings back
OPENCODE_DISABLE_CLAUDE_CODEsupport on thev2branch.V1 honored this flag to keep OpenCode from reading
~/.claude(the prompt and skills). On v2 the env var was declared in the flag module but never wired into config discovery, so the flag had no effect: config kept pulling in the global~/.claudedirectory plus any.claudedirs found walking up from the project.The change gates the
claudesource inConfig.discover()on the flag. The global~/.claudedirectory and project.claudedirs are both skipped whenOPENCODE_DISABLE_CLAUDE_CODEis set, matching V1 behavior. Setting it stops.claudeskills and theCLAUDE.mdprompt from loading, which is useful when you don't use Claude Code and don't want its content appearing in OpenCode.I also added
disableClaudeCodetoConfig.Optionsso callers can control this at the API level as well, not just through the env var. A test covers the discovery behavior (claude sources dropped,.agentsuntouched).How did you verify your code works?
~/.claude+.agentsand a project.agents, then asserts that with the flag on, noclaudeentries are discovered whileagentsstill are.Screenshots / recordings
N/A
Checklist