fix: honor OPENCODE_DISABLE_CLAUDE_CODE env var#2038
fix: honor OPENCODE_DISABLE_CLAUDE_CODE env var#2038gustavosmendes wants to merge 1 commit intocode-yeongyu:devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the plugin’s Claude Code integration gating so OpenCode’s OPENCODE_DISABLE_CLAUDE_CODE opt-out is reflected in the resolved oh-my-opencode config, and consolidates the scattered per-component enable checks behind a single helper.
Changes:
- Added
applyEnvVarOverrides(config, env?)and applied it inloadPluginConfigto force-disable Claude Code components whenOPENCODE_DISABLE_CLAUDE_CODEis set. - Added
claude_code.enabled(master gate) andisClaudeCodeEnabled(...)helper, then updated handlers/hooks to use it consistently. - Added/expanded tests covering env overrides and the new gating helper.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/config/schema/claude-code.ts |
Adds enabled?: boolean master switch and introduces isClaudeCodeEnabled helper. |
src/plugin-config.ts |
Adds applyEnvVarOverrides and applies it after merging user/project configs. |
src/plugin-handlers/plugin-components-loader.ts |
Uses isClaudeCodeEnabled(..., "plugins") to gate Claude plugin discovery/loading. |
src/plugin-handlers/command-config-handler.ts |
Switches Claude commands/skills gating to isClaudeCodeEnabled. |
src/plugin-handlers/agent-config-handler.ts |
Switches Claude skills/agents gating to isClaudeCodeEnabled. |
src/plugin-handlers/mcp-config-handler.ts |
Switches Claude MCP gating to isClaudeCodeEnabled. |
src/plugin/hooks/create-transform-hooks.ts |
Switches Claude hooks gating to isClaudeCodeEnabled. |
src/plugin/skill-context.ts |
Replaces !== false skills gating with isClaudeCodeEnabled. |
src/plugin-config.test.ts |
Adds tests for applyEnvVarOverrides and isClaudeCodeEnabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * Applies hard overrides from OpenCode env vars onto the resolved config. | ||
| * Accepts an optional `env` parameter so the function stays pure and testable. | ||
| */ | ||
| export function applyEnvVarOverrides( | ||
| config: OhMyOpenCodeConfig, | ||
| env: NodeJS.ProcessEnv = process.env, | ||
| ): OhMyOpenCodeConfig { | ||
| const masterDisabled = | ||
| env.OPENCODE_DISABLE_CLAUDE_CODE === "1" || | ||
| env.OPENCODE_DISABLE_CLAUDE_CODE === "true"; | ||
|
|
There was a problem hiding this comment.
applyEnvVarOverrides currently only checks OPENCODE_DISABLE_CLAUDE_CODE ("1"/"true"). The PR description/issue mentions OPENCODE_DISABLE_CLAUDE_CODE* (e.g., *_SKILLS, *_PROMPT) and OPENCODE_DISABLE_EXTERNAL_SKILLS; if those are intended to be honored too, they should be mapped to the relevant component flags here (or the description should be narrowed to just the master env var).
There was a problem hiding this comment.
Addressed in c0ba654:
OPENCODE_DISABLE_CLAUDE_CODE_SKILLSis now honored — disables only theskillscomponent. Master switch takes precedence when both are set.OPENCODE_DISABLE_CLAUDE_CODE_PROMPTwas intentionally omitted — it controls~/.claude/CLAUDE.mdloading in OpenCode core, but oh-my-opencode doesn't load CLAUDE.md as a prompt, so there's no component to map it to.OPENCODE_DISABLE_EXTERNAL_SKILLScascades fromSKILLSin OpenCode core and is beyond this plugin's scope (external skill loading is handled by OpenCode itself).- Parsing is now case-insensitive via
isTruthy()helper ("1","true","TRUE","True"all work).
| /** | ||
| * Applies hard overrides from OpenCode env vars onto the resolved config. | ||
| * Accepts an optional `env` parameter so the function stays pure and testable. | ||
| */ | ||
| export function applyEnvVarOverrides( | ||
| config: OhMyOpenCodeConfig, | ||
| env: NodeJS.ProcessEnv = process.env, | ||
| ): OhMyOpenCodeConfig { |
There was a problem hiding this comment.
The docstring says the function "stays pure", but the default parameter reads process.env (and loadPluginConfig calls it without passing env), so the function isn't referentially transparent by default. Consider requiring env to be passed explicitly (e.g., from loadPluginConfig) or adjust the wording to describe it as "testable without global mocks" rather than "pure".
There was a problem hiding this comment.
Addressed in c0ba654 — docstring updated from "stays pure" to "testable without global mocks", which accurately describes the design intent (env parameter injection for testing, process.env default for production).
There was a problem hiding this comment.
1 issue found across 9 files
Confidence score: 3/5
- There is a concrete compatibility gap:
src/plugin-config.tsignoresOPENCODE_DISABLE_CLAUDE_CODE_SKILLS, so OpenCode users can’t disable Claude Code skill loading as expected. - This is a user-facing behavior change for a supported integration, which raises some risk beyond a routine merge even though it’s localized.
- Pay close attention to
src/plugin-config.ts- ensure the OpenCode disable flag is honored.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/plugin-config.ts">
<violation number="1" location="src/plugin-config.ts:32">
P1: Custom agent: **Opencode Compatibility**
The PR ignores the `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` environment variable, which OpenCode supports to selectively disable Claude Code skill loading. To maintain compatibility with OpenCode's configuration system, the plugin should also honor this specific environment variable to disable the `skills` component when set.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
0e96323 to
c0ba654
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes #2037 Adds `applyEnvVarOverrides` (pure fn, injectable env) called at the end of `loadPluginConfig`. When `OPENCODE_DISABLE_CLAUDE_CODE=1` (or `true`) all seven Claude Code component gates are forced to `false` before any handler runs. Adds `isClaudeCodeEnabled(claudeCode, component)` helper that consolidates the `?? true` / `!== false` scatter across 8 call sites into a single function that also honours the new `claude_code.enabled` master switch. Changes: - `src/config/schema/claude-code.ts`: add `enabled?: boolean` field + `isClaudeCodeEnabled` helper - `src/plugin-config.ts`: add `applyEnvVarOverrides`, call in `loadPluginConfig` - 7 handlers/context files: replace raw `?.X ?? true` / `!== false` with `isClaudeCodeEnabled` - `src/plugin-config.test.ts`: 15 new tests covering all branches
c0ba654 to
93e274e
Compare
|
[sisyphus-bot] PR Review AssessmentSummaryThis PR fixes the Changes Analysis
Technical ReviewWhat it fixes:
Architecture:
Review Feedback Addressed:
Risk Assessment
RecommendationThis is a well-structured bugfix with:
Action Required: Needs maintainer approval to merge. The |
Summary
Fixes #2037 — oh-my-opencode ignored
OPENCODE_DISABLE_CLAUDE_CODEand related env vars, injecting Claude Code components into the resolved config regardless of the user's OpenCode-level opt-out.What changed
applyEnvVarOverrides(config, env?)— pure function (env injected as parameter, testable without global mocks) called at the end ofloadPluginConfig. Honors both master and per-component env vars:OPENCODE_DISABLE_CLAUDE_CODE=1|true→ disables all seven component gatesOPENCODE_DISABLE_CLAUDE_CODE_SKILLS=1|true→ disables only skills (matching OpenCode core's per-component cascade fromflag.ts)isTruthy(env, key)— case-insensitive env var parser ("1","true","TRUE","True"all work)isClaudeCodeEnabled(claudeCode, component)— consolidates the?? true/!== falsescatter across 8 call sites into a single function. Also honours the newclaude_code.enabledmaster switch.claude_code.enabled?: booleanfield inClaudeCodeConfigSchema— single JSON-level master toggle subordinating all per-component flags.Files changed
src/config/schema/claude-code.tsenabled?: booleanfield +isClaudeCodeEnabledhelpersrc/plugin-config.tsapplyEnvVarOverrideswithisTruthy+ call inloadPluginConfigsrc/plugin-handlers/plugin-components-loader.tsisClaudeCodeEnabledsrc/plugin-handlers/command-config-handler.tsisClaudeCodeEnabledsrc/plugin-handlers/agent-config-handler.tsisClaudeCodeEnabledsrc/plugin-handlers/mcp-config-handler.tsisClaudeCodeEnabledsrc/plugin/hooks/create-transform-hooks.tsisClaudeCodeEnabledsrc/plugin/skill-context.ts!== false→isClaudeCodeEnabledsrc/plugin-config.test.tsBehavior
OPENCODE_DISABLE_CLAUDE_CODE=1OPENCODE_DISABLE_CLAUDE_CODE=TRUEOPENCODE_DISABLE_CLAUDE_CODE_SKILLS=1OPENCODE_DISABLE_CLAUDE_CODE=1+SKILLS=0claude_code.enabled: falsein JSONclaude_code.mcp: falsein JSONmcpdisabledExisting workaround (
claude_code.{ agents,commands,hooks,mcp,plugins,skills }: false) continues to work.Test plan
bun test src/plugin-config.test.ts— 30 pass (84 assertions)bun test— full suite passes, 0 failOPENCODE_DISABLE_CLAUDE_CODE=1 opencode debug config | rg "everything-claude-code"should return emptyReview feedback addressed
OPENCODE_DISABLE_CLAUDE_CODE_SKILLSper-component support (confirmed real env var from OpenCode coreflag.ts)SKILLS)"","yes",undefined), per-component override tests