Skip to content

fix: use jsonc-parser for all JSON config files to support comments#41

Merged
Dhravya merged 2 commits intosupermemoryai:mainfrom
remorses:fix/jsonc-support-for-json-files
Jan 21, 2026
Merged

fix: use jsonc-parser for all JSON config files to support comments#41
Dhravya merged 2 commits intosupermemoryai:mainfrom
remorses:fix/jsonc-support-for-json-files

Conversation

@remorses
Copy link
Contributor

@remorses remorses commented Jan 18, 2026

Some clients like opencode use .json files that contain JSONC content (comments). Previously, only .jsonc files were parsed with jsonc-parser, causing JSON.parse() to fail on .json files with comments. This resulted in the entire config being replaced with just the MCP section, losing all other settings.

Now we always use jsonc-parser for reading JSON files and use jsonc.modify() to update only the specific configKey path when writing, preserving comments, formatting, and all other config keys. Indentation is detected from the existing file content so the output matches the original style.

Some clients like opencode use .json files that contain JSONC content
(comments). Previously, only .jsonc files were parsed with jsonc-parser,
causing JSON.parse to fail on .json files with comments. This resulted
in the entire config being replaced with just the MCP section.

Changes:
- Always use jsonc-parser for reading JSON files (handles comments)
- Use jsonc.modify to update only the configKey path when writing
- Preserves comments, formatting, and all other config keys
Copilot AI review requested due to automatic review settings January 18, 2026 15:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug where JSON config files containing JSONC comments (like opencode.json) would fail to parse with JSON.parse(), causing the entire config to be replaced with just the MCP section and losing all other settings and comments.

Changes:

  • Changed JSON file parsing to always use jsonc-parser instead of only for .jsonc files
  • Simplified write logic to only modify the specific configKey path using jsonc.modify(), preserving comments and other config keys
  • Removed the distinction between .json and .jsonc file handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

remorses added a commit to remorses/install-mcp that referenced this pull request Jan 20, 2026
remorses added a commit to remorses/install-mcp that referenced this pull request Jan 20, 2026
@Dhravya Dhravya self-requested a review January 21, 2026 03:49
Copy link
Member

Dhravya commented Jan 21, 2026

Merge activity

  • Jan 21, 3:49 AM UTC: Graphite couldn't merge this PR because it failed for an unknown reason (Fast-forward merges are not supported for forked repositories. Please create a branch in the target repository in order to merge).

@Dhravya Dhravya merged commit 4221ba8 into supermemoryai:main Jan 21, 2026
2 checks passed
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.

3 participants