Skip to content

adopt: write opencode's own global file; check managed-settings.d - #175

Merged
fylorn merged 1 commit into
mainfrom
linux/adopt-shadows
Sep 24, 2026
Merged

fylorn merged 1 commit into
mainfrom
linux/adopt-shadows

Conversation

@fylorn

@fylorn fylorn commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #172: two files that take precedence over what adoption writes.

opencode: opencode.jsonc vs opencode.json

opencode's global config is three files that it deep-merges in order, later wins: config.json, opencode.json, opencode.jsonc (anomalyco/opencode@0f54984 packages/opencode/src/config/config.ts:272-274, mergeConfig = remeda mergeDeep at :42-44). When opencode writes its global config itself, it picks the first existing file of opencode.jsonc, opencode.json, config.json (globalConfigFile, :140-148, used by updateGlobal at :656-657). If none exists, it creates opencode.jsonc with just $schema on first run (:263-270).

Chosen behaviour: write where opencode itself writes, i.e. the highest-precedence existing file, or a new opencode.jsonc. Why this is the least surprising option:

  • Every fresh install already has an opencode.jsonc. Keeping opencode.json and listing .jsonc as a file that takes precedence would flag every user over a file that holds only $schema, and our endpoint would sit in a file opencode itself never edits.
  • With this choice, no file in that directory takes precedence over the one we write, which is the same thing opencode's own config writes rely on.
  • The JSON patcher already edits JSONC in place and keeps comments.

A file we already adopted stays the target, because its sidecar record and originals sit next to it and restore needs them. If the user later creates a higher-precedence file, the diagnosis and the adoption plan report it with the existing "takes precedence" sentences. That finding is Blocking only when the newer file sets provider.thinkwatch; otherwise opencode's deep merge keeps our fields and it is Suspect. The MCP scan now reads all three files.

Claude Code: managed-settings.d/

Per https://code.claude.com/docs/en/managed-settings ("Split a file-based policy across teams"), Claude Code merges managed-settings.json first, then every *.json in managed-settings.d/ in alphabetical order. It skips hidden files and files not ending in .json, and on the same key the later file wins (env merges key by key). Together they form one managed source that takes precedence over the user's settings. The diagnosis now reports each drop-in on all three platforms, since the directory sits next to managed-settings.json in each platform's system directory. A drop-in is Blocking when it carries one of the environment variables we write.

New msg codes: adopt.diag.managed_dropin, adopt.diag.managed_dropin.detail.

🤖 Generated with Claude Code

- opencode reads config.json, opencode.json and opencode.jsonc in that
  order and deep-merges them, later wins; when it writes its global config
  itself it picks the first existing of jsonc, json, config.json and creates
  opencode.jsonc when none exists. Adoption now picks the same file, so a
  fresh install's opencode.jsonc is where the endpoint goes and nothing in
  the directory overrides it. A file we already adopted keeps being used
  (its sidecar and originals live next to it); a higher-precedence file
  created later is reported as taking precedence, Blocking only when it
  sets provider.thinkwatch. The scan reads all three files for MCP servers.
- Claude Code merges managed-settings.d/*.json (alphabetical, hidden and
  non-.json skipped) after managed-settings.json, later wins. The diagnosis
  now reports each drop-in (new codes adopt.diag.managed_dropin and
  adopt.diag.managed_dropin.detail).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn force-pushed the linux/adopt-shadows branch from 1824cd5 to f929219 Compare September 24, 2026 10:04
@fylorn
fylorn merged commit 39d81d7 into main Sep 24, 2026
3 checks passed
@fylorn
fylorn deleted the linux/adopt-shadows branch September 24, 2026 10:13
@fylorn fylorn mentioned this pull request Sep 24, 2026
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.

1 participant