Repository navigation
opencode-config-normalize: an inline // or /* */ comment anywhere in opencode.jsonc silently disables every repair — the probe stripper only removes full-line comments, the parse fails, and the script exits 0 #3179
Description
Problem
pkgs/opencode-config-normalize/normalize.sh silently performs no repair at all on an opencode.jsonc that contains an inline // comment or a /* */ block comment — the two comment forms JSONC allows anywhere, and the forms a hand-edited user config most often contains. The config keeps its v2 plugins/agents keys, which opencode 1.x ignores (the script's own header documents this), so the user's plugins/agents stay broken while the path-unit trigger reports nothing.
Evidence (verified this run, main fc88d0a9, script sha256 c59dd79b…)
normalize.sh:36-41: the membership probe strips only full-line comments —re.sub(r'^\s*//.*$', '', raw, flags=re.M)— thenjson.loads(probe); on any exception it doessys.exit(0)("unparseable: leave it alone"). An inline comment after a value, or a/* */block, is not stripped, so the parse fails and the script exits 0 having changed nothing. The same weak probe is reused for the pre-write verification at lines 108-109.- Laptop probe (
~/git/fleet/probe-2026-10-31-laneA-normalize/, verbatim copy of the script, sha-matched to main):- Case A: config with
"plugins": ["opencode-plugin-x"] // migrated by OpenChamber→ exit 0, file byte-identical,pluginsstill present. - Case A2: config with a
/* user config */header comment and"plugins": [...]→ exit 0, file byte-identical,pluginsstill present. - Control case B (no comments) repairs correctly, proving the fixtures are otherwise in the script's recognised shape.
- Case A: config with
Why it matters
The script exists because OpenChamber rewrites the config to v2 spellings and v1 opencode silently ignores them. A user who annotates their config — the normal thing to do in a JSONC file — falls entirely outside the repair, with no log line, no non-zero exit, and no way to tell the normalizer gave up versus found nothing to do. The failure is silent in exactly the population (hand-editors) most likely to also hand-merge OpenChamber's rewrites.
Acceptance criteria
- A config whose only JSONC features are inline
//comments is repaired the same as the comment-free equivalent (full parsed-document equality, as innormalize_test.sh). - A config with a
/* */block comment is repaired likewise, or — if block comments are deliberately out of scope — the script says so in its header and the limitation is covered by an explicit test fixture asserting the untouched-exit-0 behaviour. - Comment stripping is string-aware: a
//or/*sequence inside a string value (e.g. a URL or prompt) is never treated as a comment, and a,}/,]sequence inside a string is never treated as a trailing comma (the current regex probe at line 37 has the same string-blindness — cf. closed sync-models: naive parseJsonc line-stripper breaks on block comments and string contents — multi-line /* */ or a ' // ' string fails the sync, a ', ]' string is silently corrupted #704 for the same failure in the sync-models stripper). - New fixtures in
normalize_test.shcover inline-comment, block-comment, and comment-like-text-inside-a-string configs, asserting full parsed documents and idempotence. - All existing
normalize_test.shcases still pass, including the byte-identical-on-failure contract.
Dedup
Searched open + closed for opencode-config-normalize / normalize.sh: #2364 (closed) is the agents-drop data-loss bug, fixed with the verification block this issue builds on; #704 (closed) is the same string-blind stripper class in a different tool (sync-models). No existing issue covers this script's comment handling.
Activity
dezren39 commentedon Oct 31, 2026
🤖 Agent note · filed
15 remaining items
dezren39 commentedon Nov 2, 2026
🤖 Agent note · picked up
queue/5653-3179-jsonc-commentsfix(opencode-config-normalize): parse inline and block JSONC comments (…
dezren39 commentedon Nov 2, 2026
🤖 Agent note · done
pluginsrename selects the live top-level key instead of comment text.