-
Notifications
You must be signed in to change notification settings - Fork 367
refactor(toml): replace smol-toml with @rainbowatcher/toml-edit-js #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- add new toml-edit utility module with format-preserving editing - implement incremental TOML editing in zcf-config to preserve user customizations - replace smol-toml imports across the codebase - add comprehensive tests for toml-edit functionality - update documentation for new TOML parsing approach
ba4934f to
8dca0d0
Compare
- add section boundary detection to prevent modifying fields inside sections - fix newline handling when inserting lastUpdated after version field - add insertAtTopLevelStart helper for proper comment preservation - add insertAfterVersionField helper for correct field positioning - add comprehensive test cases for edge scenarios (PR #277 bugs) Refs: #277
…comments - Update regex patterns in insertAfterVersionField and updateTopLevelTomlFields functions to handle inline comments for version and lastUpdated fields. - Add tests to ensure correct handling of TOML fields with inline comments and trailing spaces. - Improve overall robustness of TOML configuration handling. Refs: #277
…on corruption - Introduced a new utility module `codex-toml-updater` for precise modifications to TOML files, ensuring that changes to API configurations do not affect MCP configurations. - Updated multiple functions across the codebase to utilize targeted updates, preserving existing MCP services and other configurations. - Added a new markdown file documenting the issue and solution for reference. - Enhanced tests to validate the integrity of configurations after updates. Refs: #259
- Removed the writeCodexConfig function to streamline configuration handling. - Updated tests to replace calls to writeCodexConfig with batchUpdateCodexMcpServices, ensuring proper functionality and integration. - Enhanced mocking in tests to reflect the removal of writeCodexConfig, maintaining test coverage for configuration operations. Refs: #259
…cf-config - Ensure content is always inserted on a new line after the version field in the insertAfterVersionField function. - Update the writeTomlConfig function to conditionally include optional Claude Code fields only if they are defined, preventing unnecessary edits and potential issues with batch editing. Refs: #259
- add section boundary detection to prevent modifying fields inside sections - fix newline handling when inserting lastUpdated after version field - add insertAtTopLevelStart helper for proper comment preservation - add insertAfterVersionField helper for correct field positioning - add comprehensive test cases for edge scenarios (PR #277 bugs) Refs: #277
…comments - Update regex patterns in insertAfterVersionField and updateTopLevelTomlFields functions to handle inline comments for version and lastUpdated fields. - Add tests to ensure correct handling of TOML fields with inline comments and trailing spaces. - Improve overall robustness of TOML configuration handling. Refs: #277
User description
Description
This PR migrates the TOML parsing library from
smol-tomlto@rainbowatcher/toml-edit-js, enabling format-preserving TOML editing capabilities.Why This Change?
The new library (
toml-edit-js) wraps the Rusttoml_editcrate via WASM, providing fine-grained TOML modifications while preserving:This is critical for ZCF's configuration management, where we need to update specific fields without destroying user customizations.
Key Changes
src/utils/toml-edit.tswith format-preserving editing functionszcf-config.tsnow usesbatchEditToml()when file existssmol-tomlwith@rainbowatcher/toml-edit-jsFiles Modified
package.json- Dependency updatepnpm-workspace.yaml- Catalog updatepnpm-lock.yaml- Lockfile updatesrc/utils/toml-edit.ts- New TOML editing utility modulesrc/utils/zcf-config.ts- Integrated incremental editingsrc/utils/code-tools/codex.ts- Updated importsrc/utils/code-tools/CLAUDE.md- Updated documentationtests/unit/utils/toml-edit.test.ts- New comprehensive teststests/unit/utils/zcf-config.test.ts- Updated mockstests/unit/utils/code-tools/codex.test.ts- Updated importtests/unit/utils/code-tools/toml-parser-refactor.test.ts- Updated descriptionsType of Change
Testing
toml-edit.tsmoduleChecklist
Additional Information
Branch:
refactor/taplo-toml→mainCommits: 1
Files Changed: 11 (+583, -66)
Commit History
🤖 Generated with /zcf-pr command
PR Type
Enhancement, Tests
Description
Replace
smol-tomlwith@rainbowatcher/toml-edit-jsfor format-preserving TOML editingAdd new
toml-edit.tsutility module with parsing, stringifying, and incremental editing functionsImplement incremental TOML editing in
zcf-config.tsto preserve user comments and formattingAdd 244 lines of comprehensive test coverage for new TOML editing functionality
Diagram Walkthrough
File Walkthrough
3 files
New format-preserving TOML editing utility moduleImplement incremental TOML editing with format preservationUpdate import from smol-toml to toml-edit module1 files
Update documentation for new TOML parsing approach4 files
Add comprehensive tests for format-preserving TOML editingUpdate mocks and tests for new toml-edit integrationUpdate import reference in codex test fileUpdate test descriptions for new TOML library2 files
Replace smol-toml with @rainbowatcher/toml-edit-js dependencyUpdate lockfile with new dependency and remove old one1 files
Update catalog with new TOML library versionNote
Addresses MCP config corruption (Issue #259) by isolating TOML mutations and preserving user formatting/comments.
@rainbowatcher/toml-edit-jsand addssrc/utils/toml-edit.tsfor format‑preservingparse/stringify/editAPIscodex-toml-updater.tsto update onlymodel,model_provider,model_providers.*, andmcp_servers.*without cross‑contamination (SSEurlservices remain untouched)codex.ts,codex-configure.ts,codex-provider-manager.ts,features.ts) to replacewriteCodexConfigwith targeted updates (add/edit/delete providers, batch MCP updates, provider switching)zcf-config.tsto safely updateversion/lastUpdatedoutside sections; uses incrementalbatchEditTomlwhen possibleCLAUDE.md) for new TOML APIs and replaces dependencysmol-toml→@rainbowatcher/toml-edit-js(package/workspace/lockfile)Written by Cursor Bugbot for commit 45cdb0b. This will update automatically on new commits. Configure here.