Skip to content

fix(init): support JSONC config parsing and hybrid OpenCode detection - #41

Merged
nathanBurg merged 3 commits into
mainfrom
fix/init-method-bugs
Apr 28, 2026
Merged

fix(init): support JSONC config parsing and hybrid OpenCode detection#41
nathanBurg merged 3 commits into
mainfrom
fix/init-method-bugs

Conversation

@nathanBurg

Copy link
Copy Markdown
Contributor

Summary

This PR fixes init setup 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 - Added jsonc-parser runtime dependency.
  • bun.lock - Updated lockfile for new dependency.
  • docs/implementation/config.md - Documented init JSONC parsing behavior and safety guarantees.

Architecture / Structure

  • Introduced a reusable config parsing flow in init setup handlers that attempts strict JSON first and then JSONC parsing, centralizing behavior across read/merge/check logic.
  • Extended detection contracts with a hybrid mode to support agents that can be discovered via either binary probe or filesystem presence.

Verification

Automated Checks

  • bun run typecheck
  • bun run format:check
  • bun run lint
  • bun run build
  • bun test
  • bun test src/commands/init/setup-handlers.test.ts
  • bun test src/commands/init/agent-definitions.test.ts

Manual Verification

  • Removed GitHits entries from local agent config files and reran bun run dev -- init --skip-login; unconfigured agents were detected and set up successfully.
  • Specifically verified OpenCode + Cursor reconfiguration path and full all-agent config-file reconfiguration flow.
  • Known pre-existing compat issue: node dist/cli.js --version fails 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 current main-line code generation.

Related Issues

  • None.

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.
@nathanBurg nathanBurg self-assigned this Apr 28, 2026
@nathanBurg
nathanBurg merged commit 49f9fa6 into main Apr 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant