Repository navigation
Conversation
mergeJsonMcpConfig treated invalid existing JSON (JSONC comments, trailing commas) as empty and rewrote the file with only the memorix entry, silently deleting the user's other settings. Throw instead and leave the file intact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
installMcpConfig→mergeJsonMcpConfig(src/cli/commands/setup.ts) treated an existing config file that is not valid JSON as{}, then rewrote the file with only the memorix entry. A common case isopencode.jsonwith JSONC comments or a trailing comma:memorix setupsilently deleted all of the user's other settings in it.What changed
If the existing content cannot be parsed, or is not a JSON object, setup now throws a clear error and leaves the file untouched. An empty file still works as before.
How it was tested
tests/cli/setup-command.test.ts: setup rejects a JSONCopencode.jsonand leaves it unchanged. It fails onmain("promise resolved ... instead of rejecting") and passes with the fix; the file is 43/43.npm install && npm run build, fullnpm test: 3366 passed, 5 skipped, 0 failed.Side effect to note: when setup runs for several agents in one go, it now stops at the first unparseable file instead of overwriting it.
AI disclosure
This change was found, written and tested with Claude Code (Anthropic). I'm responsible for it and happy to rework anything.
🤖 Generated with Claude Code
https://claude.ai/code/session_01A3CSud8Qn852zfCa7YofiN