Skip to content

fix(setup): treat empty client config files as new documents - #1117

Merged
morluto merged 3 commits into
morluto:mainfrom
lalomorales22:fix/setup-empty-client-config
Oct 8, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
lalomorales22:fix/setup-empty-client-config

Conversation

@lalomorales22

Copy link
Copy Markdown
Contributor

Problem

npx rea-agents setup stops with status: needs_human and no planned actions when any detected client has a zero-byte MCP config file:

remediation: "Antigravity: The existing configuration is malformed. Repair it before setup applies any other changes."

Antigravity can leave ~/.gemini/config/mcp_config.json as an empty file. jsonc-parser reports ValueExpected for empty input, so setup reported the file as malformed and refused to configure every detected agent, not only Antigravity.

Fix

  • parseDocument: a JSON/JSONC file that is empty, whitespace-only, or BOM-only parses as {}. TOML already behaved this way.
  • serializeClientConfiguration: when the original text is empty, write a fresh document. In-place JSONC edits on a BOM-only file would otherwise put the BOM after the closing brace.

Files with real syntax errors are still rejected, and the existing malformed-BOM test still passes.

Verification

  • New boundary test (clientConfigurationBom.test.ts) covers "", "\n \n", and "": preflight → configure → readback → already_current. It fails without the fix and passes with it.
  • npm run check:changed and npm run check:fast pass.
  • On the affected machine, rea setup --all-detected --dry-run now returns status: planned with actions for all 8 detected clients, including Antigravity. Before the fix it returned needs_human with no actions.

🤖 Generated with Claude Code

lalomorales22 and others added 3 commits October 8, 2026 12:12
An empty MCP config file (for example Antigravity's mcp_config.json, which
the client can create with zero bytes) was reported as malformed, which
blocked rea setup from configuring every other detected agent. Parse a
whitespace- or BOM-only JSON/JSONC file as an empty document and write a
fresh document over it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/application/ClientConfigurationDocument.ts
@morluto

morluto commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Merged origin/main into this branch to resolve the conflict with #1134 (Grok client support), which had reworked serializeClientConfiguration in src/application/ClientConfigurationDocument.ts.

How it was resolved:

  • Kept the new grok branch (serializeGrokConfiguration) as-is. Grok/TOML parsing already handles empty files (smol-toml parses "" as {}), so no change needed on that path.
  • Re-applied this PR's empty-original guard onto feat(clients): register Grok Build and Grok Bot during setup #1134's new in-place JSONC edit body (which also gained comment-preserving deletion), so empty/whitespace/BOM-only JSON originals still serialize as a fresh document.
  • Factored the emptiness check into a shared isEmptyClientConfigurationText helper now used by both parseDocument and serializeClientConfiguration (review nit).
  • Replaced the invisible literal BOM character in the new test's it.each with an explicit "\\uFEFF" escape (review nit).

Verification: tsc clean, oxlint/oxfmt --check clean on both touched files, and the three client-configuration boundary suites pass (39 tests, including the 3 new empty-file cases).

@morluto
morluto merged commit 9fd65ce into morluto:main Oct 8, 2026
11 of 12 checks passed
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
…#1117)

* fix(setup): treat empty client config files as new documents

An empty MCP config file (for example Antigravity's mcp_config.json, which
the client can create with zero bytes) was reported as malformed, which
blocked rea setup from configuring every other detected agent. Parse a
whitespace- or BOM-only JSON/JSONC file as an empty document and write a
fresh document over it.


* test(setup): use explicit unicode escape for BOM-only empty config case

---------

Co-authored-by: morluto <[email protected]>
viniciusdsandrade added a commit to viniciusdsandrade/rea that referenced this pull request Oct 11, 2026
YAML parses an empty file to null, so Hermes configuration was checked
as an object before the shared empty-file rule and rejected. Setup then
failed its readback gate for a zero-byte config.yaml, although a missing
file is configured and the Hermes serializer already writes a fresh
document for empty original text. Apply the empty-file rule before the
Hermes YAML parse, as morluto#1117 did for JSON clients.
morluto pushed a commit that referenced this pull request Oct 12, 2026
* fix(setup): treat an empty Hermes config.yaml as a new document

YAML parses an empty file to null, so Hermes configuration was checked
as an object before the shared empty-file rule and rejected. Setup then
failed its readback gate for a zero-byte config.yaml, although a missing
file is configured and the Hermes serializer already writes a fresh
document for empty original text. Apply the empty-file rule before the
Hermes YAML parse, as #1117 did for JSON clients.

* test(setup): configure an empty Hermes config.yaml

Configure zero-byte and newline-only config.yaml files through the
real filesystem workflow, then read the registration back as aligned.
@morluto morluto added bug Something isn't working area: cli CLI adapter and one-shot commands labels Oct 14, 2026
@morluto morluto added the area: setup Setup, packaging, upgrade, install, Doctor, and client registration label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants