opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(config): add managed settings support for enterprise deployments

Open Mishkun opened this issue 2 weeks ago • 1 comments

Summary

Adds support for managed settings files that take precedence over all user settings, enabling enterprise administrators to enforce configurations that users cannot override easily

Closes #6358

Changes

  • Add platform-specific path for managed settings in Global.Path
  • Load and apply managed settings as final merge in config loading

Managed Settings Locations

Platform Path
macOS /Library/Application Support/opencode/managed-settings.json
Linux /etc/opencode/managed-settings.json
Windows %ProgramData%\opencode\managed-settings.json

Testing

Generated some tests. I was using env var to inject managed config location. But I think it might compromise the settings. I'm open to suggestions on how to resolve this issue.

Manual testing was performed via these commands:

Setup

sudo mkdir -p "/Library/Application Support/opencode/"
sudo bash -c 'cat > "/Library/Application Support/opencode/managed-settings.json" << EOF                  
{                                                                                                           
  "\$schema": "https://opencode.ai/config.json",
   "tools": {                                                                                                  
        "write": false,                                                                                           
        "bash": false,
        "edit": false
    }                                                                                                       
}                                                                                                         
EOF'

Check

this command should ask for permission when managed settings are present, or simply execute otherwise.

bun dev -p "write a joke to a file in current dir"

Cleanup

sudo rm "/Library/Application Support/opencode/managed-settings.json"
sudo rmdir "/Library/Application Support/opencode/"

Mishkun avatar Dec 30 '25 12:12 Mishkun