GeezerVison is showing github.com — opencode-config-normalize: agents-only config silently loses every agent — the agents block is dropped even when the merge splice never lands · Issue #2364 · developing-today/code
opencode-config-normalize: agents-only config silently loses every agent — the agents block is dropped even when the merge splice never lands #2364DescriptionProblem
pkgs/opencode-config-normalize/normalize.sh silently deletes every agent definition from a config that has an agents key but no agent key — which is exactly the shape OpenChamber's v1→v2 migration produces (the script's own header: OpenChamber migrates agent -> agents). The script reports "repaired" and exits 0 while the user's agents vanish, so the v1 CLI loses all its agent definitions — the opposite of the script's purpose.
Evidence (verified this run on main 5a34fa70)
normalize.sh:52-68 (embedded Python): when 'agents' in doc, it computes merged = {**agents, **agent} and, if merged != agent, tries to splice the merged map into the existing "agent" block with the regex "agent"(\s*):\s*\{.*?\n \} (lines 61-65). When there is no "agent" key, that regex cannot match ("agents" does not match "agent" + closing quote), so nothing is inserted and n = 0.
- The drop on line 67 then runs unconditionally:
re.subn(r'\n\s*"agents"\s*:\s*\{.*?\n \},?', '', out, count=1, ...) removes the agents block regardless of whether the merge splice succeeded, and sets changed, so the mutilated text is written after only a parse check (lines 73-79) that cannot detect the loss.
- Probe (this run,
/tmp/probe-laneB-normalize/, script run with OPENCODE_CONFIG pointed at a copy): input with only agents (build + plan entries) and plugins came out as just { "$schema": ..., "plugin": ["opencode-plugin-x"] } — both agents gone, no agent key created, stderr opencode-config-normalize: repaired ..., exit 0.
- Controls in the same probe: a config with a standard pretty-printed
agent block plus agents merges correctly, and a single-line "agent": {} also merges correctly — the loss is specific to the agents-only shape (and to any shape where the splice regex misses while the drop regex hits).
Why it matters
This script runs unattended (it is designed for a path-unit trigger on the live ~/.config/opencode/opencode.jsonc) precisely after OpenChamber launches — i.e. precisely when the config is most likely to be in the agents-only v2 shape. Each such launch can irreversibly strip every custom agent (models, prompts, permissions) from the shared config with no error, no backup, and a "repaired" log line. A repair tool must never be a data-loss path.
Acceptance criteria
- An agents-only config gains an
agent block containing every agents entry (same merge precedence: existing agent wins per key) and loses the agents block — no entry is dropped.
- The
agents block is removed only after its contents are verifiably present in the resulting agent block; if the splice/insert cannot be performed, the file is left byte-identical (no write, non-zero or silent no-op per the script's existing conventions — pin one).
- Regression fixtures: agents-only (2-space pretty), agent+agents merge (existing behaviour preserved), plugins-only rename, and an unparseable file left untouched; each asserts the full parsed document, not just substrings.
- Idempotence preserved: running the script on its own output is a no-op.
Dedup
Searched open + closed issues for opencode-config-normalize, "normalize opencode config agents", and the script path: no issue covers this script's agents handling. #704 (closed) is a different tool (sync-models) with a different JSONC parser; #730 is v2 schema validation of .opencode project config, not this normalizer. Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item effort/xsTrivial: expected under 30 minutes of work on Oct 29, 2026dezren39 commented on Oct 29, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (lane B, new-issue-creator-code-b)
- Session / ID: cron new-issue-creator-code-b, run 2026-10-29 10:20 CDT
- Found via: filed this run
- Task: Triage the agents-only data-loss in pkgs/opencode-config-normalize/normalize.sh: pin the insert-vs-abort rule, then route the small fix (drop the agents block only after its contents land in agent; insert an agent block when none exists) with regression fixtures.
- Expectation: effort xs; done = triage packet routed with the acceptance criteria on the issue.
- Links: evidence/probe in the issue body; queue packet enqueued this run.
dezren39 commented on Oct 31, 2026 dezren39 commented on Oct 31, 2026 agent-note:v1
state: picked up
task: 4335 (repo-health-code-pilot, lane A)
artifact: PR #3002 @ 4425572
note: Resume from awaiting_ci. Fresh verification: no CI workflow covers pkgs/opencode-config-normalize (code search over .github is empty; the PR has only a neutral CodeRabbit check after >1h, so no Actions check will ever start — parking on CI was a loop). Codex state marker on this head: has_any_findings=false, has_unresolved_findings=false. Fixture suite re-run by this lane on the laptop at 4425572: 6/6 PASS (agents-only, agents-last, merge, plugins-only, unparseable, unrecognised). Diff reviewed: insert path + verify-before-write full-document gate match the acceptance criteria. Merging under the standing directive. dezren39 commented on Oct 31, 2026 agent-note:v1
state: done
task: 4335 (repo-health-code-pilot, lane A)
outcome: fixed_merged — PR #3002 merged (6bbb065), this issue closed. Verification: fixture suite 6/6 PASS on the laptop at the merged head; Codex clean on the head; no CI workflow covers this path (noted on the pickup note).
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|