Repository navigation
fix(sync-models): string-aware parseJsonc (#704) - #1236
Conversation
… contents no longer break or corrupt the config parse (#704)
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 14 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Fixes #704 — queue task 1245 (follow-up to triage task 1071).
bin/sync-models.mjsread the OpenCode config with a naive line-based JSONC stripper (parseJsonc): it threw on multi-line block comments and on strings containing//(sync exits 1 via main()'s guard), and silently corrupted strings containing, ](the trailing-comma regex fired inside string literals:"x, ]"parsed as"x]"). All three reproduced verbatim on main in triage 1071.Change:
parseJsoncis now a single string-aware scan — comments and trailing commas are only special outside string literals, string contents are copied verbatim (escape-aware), block comments collapse to a space so neighbouring tokens stay separated. The comment-preserving edit path (parseJsoncTree/setJsoncPath) is untouched, and main()'s catch-and-exit-1 guard for genuinely malformed configs still fires (covered by a test). This keeps the function's plain-value contract, which a rawparseJsoncTreeswap could not (it returns a span tree; its array branch records only start/end).Tests: new
bin/sync-models.test.mjs(run:node --test bin/sync-models.test.mjs) — the script runs on import, so the test extractsparseJsoncfrom source verbatim (the triage probe method; extraction fails loudly if the declaration shape changes). 6/6 pass: block comment,//string,, ]and, }strings uncorrupted, trailing-comma + line-comment controls, malformed config still throws. The repo's real.opencode/opencode.jsoncparses cleanly with the new parser.Need help on this PR? Tag
@codesmith-botwith what you need.