opencode
opencode copied to clipboard
feat: add OPENCODE_DISABLE_PROJECT_DISCOVERY env var
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