fix(init): support JSONC config parsing and hybrid OpenCode detection - #41
Merged
Conversation
Allow init to read JSONC-style MCP config files so setup does not fail on comments or trailing commas. This keeps malformed files safe by returning parse errors without modifying existing content.
Use hybrid detection for OpenCode so init recognizes both CLI installs and desktop app data directories. This prevents missing setup prompts when only Desktop is installed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes
initsetup reliability for config-file agents by accepting JSONC inputs (comments/trailing commas) and adds hybrid OpenCode detection so users with either OpenCode CLI or OpenCode Desktop are correctly prompted for setup. It matters because users were seeing setup failures or missing OpenCode detection despite having supported environments installed.Changes
Files Changed
src/commands/init/setup-handlers.ts- Added strict JSON + JSONC fallback parsing for config files, exposed config format detection helper, and reused parser in merge and configuration checks.src/commands/init/setup-handlers.test.ts- Added coverage for JSON/JSONC/invalid detection and JSONC behavior across merge, pre-check, and setup execution paths.src/commands/init/agent-definitions.ts- Added hybrid detection mode and OpenCode desktop/config path detection (while retaining binary detection), plus scan support for hybrid agents.src/commands/init/agent-definitions.test.ts- Added/updated OpenCode hybrid detection and cross-platform scan tests, and refreshed deprecated detectAgents expectations.package.json- Addedjsonc-parserruntime dependency.bun.lock- Updated lockfile for new dependency.docs/implementation/config.md- Documented init JSONC parsing behavior and safety guarantees.Architecture / Structure
hybridmode to support agents that can be discovered via either binary probe or filesystem presence.Verification
Automated Checks
bun run typecheckbun run format:checkbun run lintbun run buildbun testbun test src/commands/init/setup-handlers.test.tsbun test src/commands/init/agent-definitions.test.tsManual Verification
GitHitsentries from local agent config files and reranbun run dev -- init --skip-login; unconfigured agents were detected and set up successfully.node dist/cli.js --versionfails on this branch due to a duplicate export (resolveStartupCodeNavigationRegistrationState) in the generated bundle under Node 25. This issue is outside the scope of this PR and reproducible on currentmain-line code generation.Related Issues