feat: wire CodeGraph into CoDev Code via custom target or config shim - #210
Merged
Conversation
codegraph has no built-in target for the codev-code fork. setupCodegraph now wires it per run through one of two paths that produce byte-identical config: when the installed codegraph supports custom targets (upstream PR #1459), register the codev spec via `codegraph targets add` and append `codev` to the install CSV; otherwise write the mcp.codegraph entry into ~/.config/codev/codev.json(c) directly with surgical jsonc edits. Since codev-hub always npm-installs the latest codegraph before wiring, the custom-target path activates automatically the moment upstream releases it — the shim and probe then become a pure code deletion. Supporting changes: - configureOpenCodeKind now carries the existing top-level `mcp` map across its whole-file rewrite. Without this, every gateway-key auto-refresh and `codevhub model` switch silently unwired MCP servers — a live bug for OpenCode + CodeGraph users today, not just the fork. - Gating moves from `codegraphTargets(...).length > 0` to codegraphEligible(), which includes codev-code: the always-on flagship selection previously skipped installing the codegraph package entirely, and the new wiring would otherwise reference a missing binary. - `codevhub remove` sweeps the fork's mcp.codegraph entry after `codegraph uninstall` (no-op when a custom-target-aware uninstall already removed it), preserving sibling servers and user-owned files. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
codegraph has no built-in installer target for CoDev Code. This PR wires the fork anyway, structured so that adoption of upstream codegraph PR #1459 (custom installer targets) is fully automatic when it lands:
setupCodegraphprobes the installed binary with the read-onlycodegraph targets list. When custom targets are supported, it registers thecodevspec (codegraph targets add, opencode family,appName: codev) and appendscodevto the singlecodegraph installCSV.wireCodevCodeMcp()writes the samemcp.codegraphentry into~/.config/codev/codev.json(c)directly: surgical jsonc-parser edits (comments and sibling MCP servers survive), idempotent (an already-correct entry writes nothing), and it refuses malformed files rather than risk corrupting them.Both paths produce byte-identical on-disk config in the same file, so a machine can flip between them run-to-run invisibly. Since codev-hub always
npm i -gs the latest codegraph before wiring, Path A activates machine-by-machine the moment upstream releases — no codev-hub release, no user action. Once the released codegraph floor supports custom targets, Path B and the probe are a pure code deletion (marked in AGENTS.md).Also fixes a live clobber bug
configureOpenCodeKindwhole-file-replaces its config and runs on every gateway-key auto-refresh (ensureFreshGatewayKey) andcodevhub modelswitch — silently dropping anymcpentries wired after install. That already bites OpenCode + CodeGraph users today. It now carries the existing top-levelmcpmap across the rewrite (best-effort, object-valued maps only). The map never lands in*.backup, so restore still returns the true pre-CoDev state.Supporting changes
codegraphTargets(...).length > 0gates (Install row, config mode's CodeGraph step, finalize frame) becomecodegraphEligible(tools), which includes codev-code. The always-on flagship selection previously skipped installing the codegraph package entirely — and the new wiring would otherwise reference a missing binary.runCodegraphRemovalsweeps the fork'smcp.codegraphentry aftercodegraph uninstall(no-op when a custom-target-aware uninstall already removed it; drops an emptiedmcpwrapper; sibling servers and user-owned files preserved per the kept-live gate).CodegraphTargetgains"codev"→ "CoDev Code" so the finalize message names it on both paths.Testing
mcpcarry-over for OpenCode and the fork; the remove sweep on a user-owned config.pnpm fix,pnpm typecheck,pnpm test(968 passed),pnpm build && node dist/index.js --versionall green.🤖 Generated with Claude Code