feat(installer): extract a shared opencode-family implementation and add a codev target#1272
feat(installer): extract a shared opencode-family implementation and add a codev target#1272quickbeard wants to merge 2 commits into
Conversation
f79e548 to
441bdc9
Compare
…paths) codev (npm codev-code) is an opencode fork that keeps opencode's config shape byte-for-byte but renames the on-disk app identity, so an opencode install was invisible to it: the fork reads ~/.config/codev/codev.jsonc / ./codev.jsonc, never ~/.config/opencode/opencode.jsonc. The opencode target's mechanics (XDG resolution, .jsonc-preferred fallback, surgical jsonc-parser edits, AGENTS.md block) all apply verbatim, so they move to a shared opencode-family factory that both targets are thin specs over. The pre-colbymchenry#535 %APPDATA% sweep stays opencode-only — the fork never shipped through those versions. Verified end-to-end: --target=auto detects a ~/.config/codev dir, writes codev.jsonc, and the real codev binary connects to the codegraph MCP server from that config; uninstall reverses it.
441bdc9 to
c1652c1
Compare
colbymchenry
left a comment
There was a problem hiding this comment.
CodeGraph review
@quickbeard — 1 business rule at risk on this change.
Overall risk: 🟡 Low
This PR introduces a new codev installer target by extracting shared logic into an Opencode‑family implementation and updates the uninstall prompts to reference the new paths. The installer now supports the codev target alongside existing ones, and the changelog documents the new feature. No concrete breakages are evident, but the new shared code lacks direct test coverage.
Worth double-checking
- OpencodeFamilyTarget implementation — Confirm that the shared OpencodeFamilyTarget correctly resolves config and instruction paths for the new
codevtarget and does not interfere with existingopencodebehavior. - Uninstall prompt UI — Verify that the updated uninstall prompt hints now include the
codevpaths and that the displayed text matches the diff. - Runtime compatibility (rule r5) — The new OpencodeFamilyTarget class has no direct unit tests; ensure that this lack of coverage does not affect runtime stability.
Business rules (1 at risk · 3 honored · 1 not applicable)
| Status | Rule | Note |
|---|---|---|
| Runtime compatibility and releases | New shared implementation (OpencodeFamilyTarget) lacks direct unit tests, posing a potential runtime compatibility risk. |
QA checklist — 2 things to verify in the running product
- cli — Run
codegraph install --target=codev(global) and verify that~/.config/codev/codev.jsoncis created with a proper$schemaandmcp.codegraphentry, and that~/.config/codev/AGENTS.mdcontains the CodeGraph block. (Ensures the newcodevtarget writes the expected configuration files without affecting other targets.) - cli — Run
codegraph uninstall --target=codev(global) and confirm that the previously createdcodev.jsoncandAGENTS.mdentries are removed, and that no leftover files remain. (Validates that the uninstall flow correctly cleans up the new target's artifacts.)
Blast radius: 10 files affected beyond the diff · 138 symbols · 1 test file selected
Tests to run:
__tests__/installer-targets.test.ts
The registered opencode and codev targets exercise the shared class
end-to-end; these six tests target the factory itself with a synthetic
spec ('sampleapp') that belongs to neither, proving every path derives
from appName and that %APPDATA% handling follows the
sweepLegacyWindowsAppData flag rather than the app name — the contract
the next fork target relies on.
|
Thanks for the review — addressed the at-risk rule in dfdf889. Runtime compatibility (r5) —
|
colbymchenry
left a comment
There was a problem hiding this comment.
CodeGraph review
Overall risk: 🟡 Low
This PR introduces a new codev installer target by extracting the opencode logic into a shared family implementation and updating the uninstall prompt hints. The change also adds codev to the target registry and updates type definitions. No concrete breakages are evident, but the new target’s behavior should be verified.
Worth double-checking
- Installer target registration — Confirm that
codevTargetis correctly exported and included inALL_TARGETS(src/installer/targets/registry.ts) and that the updatedTargetIdunion (src/installer/targets/types.ts) compiles without affecting existing logic. - Uninstall prompt hints — Verify the hint strings in
runUninstaller(src/installer/index.ts) now list the newcodevpaths and that the formatting matches other entries. - Legacy Windows sweep flag — Ensure
sweepLegacyWindowsAppData: falsefor thecodevspec prevents any accidental writes to%APPDATA%(opencode-family.ts: legacyWindowsConfigDir logic).
Business rules (3 honored · 2 not applicable)
No rules violated or at risk.
QA checklist — 3 things to verify in the running product
- cli — Run
codegraph install --target=codev --location=globaland verify that~/.config/codev/codev.jsonccontains amcp.codegraphentry and that~/.config/opencoderemains untouched. (Validates that the newcodevtarget writes to its own config directory without interfering with the existing opencode target.) - cli — Run
codegraph uninstall --target=codev --location=globaland confirm that thecodev.jsoncfile is removed (or thecodegraphentry is removed) and no residualAGENTS.mdblock remains. (Ensures the uninstall path correctly cleans up thecodevconfiguration and does not leave stale markers.) - cli — Execute
codegraph install --target=codev --location=localin a temporary project and check that./codev.jsoncis created with the correct schema and MCP entry. (Checks that the local‑install path works for the new target.)
Blast radius: 10 files affected beyond the diff · 138 symbols · 1 test file selected
Tests to run:
__tests__/installer-targets.test.ts
|
Confirmed resolved on the current tip ( Re-verified locally:
The QA-checklist items ( |
Closes #1274.
What
Adds a
codevinstaller target forcodev-code(repo) — a fork of opencode that keeps opencode's config format but renames the on-disk app identity.Why
CodeGraph's opencode target writes to
~/.config/opencode/opencode.jsonc(or./opencode.jsonclocally). The codev fork reads only~/.config/codev/codev.jsonc/./codev.jsonc, so a CodeGraph install is invisible to it — anddetect()checks for~/.config/opencode, so on a machine with only codev installed,--target=autonever even offers it. We maintain the fork and hit this directly: CodeGraph simply doesn't work with it today, and manual config editing is the only workaround.Everything except the paths is already compatible. We verified against the fork's source that it keeps opencode's config shape byte-for-byte: the same
mcp.<name>wrapper with{ "type": "local", "command": [...], "enabled": true }, the samehttps://opencode.ai/config.json$schema(the fork stamps that URL into fresh configs itself), the same XDG-only dir resolution viaxdg-basediron every platform,.jsoncpreferred over.json, and the same global + projectAGENTS.mdinstructions convention.How
The opencode target's mechanics apply to the fork verbatim, so rather than copy the file, this PR:
targets/opencode-family.ts(new) — the previousopencode.tsimplementation, unchanged in behavior, parameterized by a small spec:{ id, displayName, docsUrl, appName, sweepLegacyWindowsAppData }.appNamedrives both the config dir and the config file base name.targets/opencode.ts— now a thin spec over the factory (appName: 'opencode',sweepLegacyWindowsAppData: true). Behavior is identical, including the opencode config path on Windows uses %APPDATA% instead of ~/.config/opencode/ #535 legacy%APPDATA%sweep.targets/codev.ts(new) — the codev spec (appName: 'codev'), following the "one new file + one registry entry" architecture. The%APPDATA%sweep is off: the pre-opencode config path on Windows uses %APPDATA% instead of ~/.config/opencode/ #535 misplacement is opencode install history the fork never had, so the codev target must never touch%APPDATA%.TargetIdunion entries, the install/uninstall location-prompt hints, and a CHANGELOG entry under[Unreleased].Tests
mcp-vs-mcpServersshape checks now cover both family members.~/.config/codev/codev.jsonc+AGENTS.md),.jsonc-over-.jsonpreference,.jsonfallback, local./codev.jsonc, fork independence (installing/uninstalling one never touches the other's files), and that detection and install ignore%APPDATA%/codeventirely.__tests__/installer-targets.test.ts: 172/172 pass. Fullnpm test: 2008 pass (three unrelated worker-exit flakes under parallel run; those files pass individually).End-to-end verification
Against a scratch
$HOMEwith the builtdist/:codegraph install --target=auto --yeswith only a~/.config/codevdir present → detects codev, writescodev.jsonc+AGENTS.md.codevbinary pointed at that config:codev mcp list→✓ codegraph connected.codegraph uninstall --target=codev --yes→ config back to the bare$schemafile, AGENTS.md block gone.Notes for review
codegraph install/uninstallcommand descriptions insrc/bin/codegraph.tsuntouched — they list only 5 of the 8 existing agents already, so updating them felt like separate cleanup.opencode-family.tsor restructure the spec if you'd prefer a different shape for downstream-fork targets.