Skip to content

feat: wire CodeGraph into CoDev Code via custom target or config shim - #210

Merged
quickbeard merged 1 commit into
mainfrom
feat/codegraph-codev-code-wiring
Jul 27, 2026
Merged

feat: wire CodeGraph into CoDev Code via custom target or config shim#210
quickbeard merged 1 commit into
mainfrom
feat/codegraph-codev-code-wiring

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

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:

  • Path A (custom target)setupCodegraph probes the installed binary with the read-only codegraph targets list. When custom targets are supported, it registers the codev spec (codegraph targets add, opencode family, appName: codev) and appends codev to the single codegraph install CSV.
  • Path B (config shim) — on today's binaries, wireCodevCodeMcp() writes the same mcp.codegraph entry 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

configureOpenCodeKind whole-file-replaces its config and runs on every gateway-key auto-refresh (ensureFreshGatewayKey) and codevhub model switch — silently dropping any mcp entries wired after install. That already bites OpenCode + CodeGraph users today. It now carries the existing top-level mcp map 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

  • Gating: the three codegraphTargets(...).length > 0 gates (Install row, config mode's CodeGraph step, finalize frame) become codegraphEligible(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.
  • Remove: runCodegraphRemoval sweeps the fork's mcp.codegraph entry after codegraph uninstall (no-op when a custom-target-aware uninstall already removed it; drops an emptied mcp wrapper; sibling servers and user-owned files preserved per the kept-live gate).
  • CodegraphTarget gains "codev" → "CoDev Code" so the finalize message names it on both paths.

Testing

  • 18 new tests: probe/register call shapes; all four setup paths (custom target, shim, codev-only, registration-failure fallback); shim idempotency, comment/sibling preservation, malformed-file refusal; unwire behavior; mcp carry-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 --version all green.

🤖 Generated with Claude Code

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>
@quickbeard
quickbeard merged commit f6b2ea5 into main Jul 27, 2026
4 checks passed
@quickbeard
quickbeard deleted the feat/codegraph-codev-code-wiring branch July 27, 2026 09:29
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