Skip to content

Conversation

@kdcokenny
Copy link
Contributor

@kdcokenny kdcokenny commented Jan 12, 2026

Closes #7559

Adds environment variable to disable project-level config discovery for external tooling integration.

Changes

  • Skip project config files when flag is set
  • Skip project .opencode/ directories
  • Skip local rule files (AGENTS.md, CLAUDE.md, CONTEXT.md)
  • Relative instructions without OPENCODE_CONFIG_DIR log warning and skip
  • Use dynamic getters for env var flags (fixes runtime evaluation)

Usage

OPENCODE_DISABLE_PROJECT_DISCOVERY=true \
OPENCODE_CONFIG_DIR=/path/to/profile/ \
opencode

Verification

Automated

Test Command Result
Unit tests bun test --filter "OPENCODE_DISABLE_PROJECT_DISCOVERY" 5/5 passing

Manual

Setup:

mkdir -p /tmp/test-proj
cat > /tmp/test-proj/opencode.json << 'EOF'
{"mcp": {"test_server_1": {"type": "remote", "url": "https://example.com", "enabled": true}}}
EOF
echo "Always say PINEAPPLE first." > /tmp/test-proj/AGENTS.md
Test Command Expected Result
Config without flag bun dev /tmp/test-proj run "what tools do you have?" Shows test_server_1
Config with flag OPENCODE_DISABLE_PROJECT_DISCOVERY=true bun dev /tmp/test-proj run "what tools do you have?" No test_server_1
AGENTS.md without flag bun dev /tmp/test-proj run "say hello" Says PINEAPPLE
AGENTS.md with flag OPENCODE_DISABLE_PROJECT_DISCOVERY=true bun dev /tmp/test-proj run "say hello" No PINEAPPLE
Global config preserved OPENCODE_DISABLE_PROJECT_DISCOVERY=true bun dev /tmp/test-proj run "what tools do you have?" Shows global MCP servers

Cleanup:

rm -rf /tmp/test-proj

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@kdcokenny kdcokenny force-pushed the feat/disable-project-discovery branch from 8fadde1 to 31aff11 Compare January 13, 2026 02:46
Adds environment variable to disable project-level config discovery
for external tooling integration.

Closes anomalyco#7559
Static constants are evaluated at module load time, but external
tooling needs to set env vars at runtime. Changed to getters that
re-evaluate on each access.
@kdcokenny kdcokenny force-pushed the feat/disable-project-discovery branch from f089639 to 9f42f87 Compare January 13, 2026 03:04
@kdcokenny kdcokenny force-pushed the feat/disable-project-discovery branch from 9f42f87 to 2c95d8c Compare January 13, 2026 03:06
@kdcokenny kdcokenny marked this pull request as ready for review January 13, 2026 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add OPENCODE_DISABLE_PROJECT_CONFIG for external tooling integration

1 participant