fix(config): update() writes to existing config file instead of hardcoding config.json#16979
fix(config): update() writes to existing config file instead of hardcoding config.json#16979dibstern wants to merge 1 commit intoanomalyco:devfrom
Conversation
…oding config.json Config.update() always wrote to config.json regardless of which config file the project actually used. Projects using opencode.jsonc got a spurious config.json created alongside their real config file, and the changes were effectively lost since config.json is not a valid project config filename. Add localConfigFile() to resolve the existing project config file (opencode.jsonc > opencode.json), mirroring globalConfigFile(). Handle .jsonc files with patchJsonc() to preserve comments, matching the updateGlobal() pattern.
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: I found a potentially related PR: PR #12347: fix: PATCH /config writes to correct project config file This PR appears to address the same issue - fixing |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Summary
Config.update()hardcodedconfig.jsonas the write target, ignoring the project's actual config file. Projects usingopencode.jsoncgot a spuriousconfig.jsoncreated alongside their real config, and changes (e.g. persisted permission rules viaPATCH /config) were effectively lost sinceconfig.jsonis not loaded as project config.localConfigFile()to resolve the existing project config file (opencode.jsonc>opencode.json), mirroring the existingglobalConfigFile()pattern. Handles.jsoncfiles withpatchJsonc()to preserve comments, matchingupdateGlobal().Reproduction
opencode.jsoncas the config filePATCH /config(e.g. via "Always Allow" on a permission prompt)config.jsonis created instead ofopencode.jsoncbeing updatedconfig.jsonis not a valid project config filenameChanges
packages/opencode/src/config/config.ts: AddedlocalConfigFile()resolver; rewroteupdate()to use it with.jsoncsupportpackages/opencode/test/config/config.test.ts: Updated existing test; added new test verifyingopencode.jsoncis updated andconfig.jsonis not createdVerification
bun test test/config/config.test.ts)