Skip to content

C3: Migrate installer and config machinery to v2-native registrations - #34

Merged
diegohb merged 7 commits into
mainfrom
v2/issue-26-migrate-installer
Oct 6, 2026
Merged

diegohb merged 7 commits into
mainfrom
v2/issue-26-migrate-installer

Conversation

@diegohb

@diegohb diegohb commented Oct 6, 2026

Copy link
Copy Markdown
Member

Summary

Closes #26 (child of spec #23). The config editor and installer now operate on v2-native plugin registrations, per docs/reference/opencode-v2-facts.md.

  • Config editor writes the v2 plugins key (src/plugin-config.ts); the v1 plugin key is parsed everywhere but never edited. A matching legacy entry is a zero-write no-op with an upgrade advisory — opencode v2 migrates it at runtime, so it stays functional. config.json entries are additionally flagged as inert (v2 no longer reads that file; facts §5, §13-3).
  • v2 object-form entries ({ package, options }, facts §7) match semantically on install/status and are removed cleanly on uninstall.
  • Cache machinery corrected to v2 reality (facts §7): generation cache at <XDG_CACHE_HOME|~/.cache>/opencode/npm/<key>/<generation> — install-time pruning and clear-cache now remove whole key dirs (every generation beneath). Pinned and foreign keys preserved. A shared NpmCache class owns the path resolution (installer, cache-cleaner, and the plugin's stale-copy advisory, which is now XDG-aware).
  • Mixed-key configs: removing the v2 entry while a legacy entry also exists now warns instead of reporting uninstalled success while the suite keeps loading.
  • Preserved unchanged: manifest gating, legacy copy-manifest migration (--force consent), copy-mode refusal for code-backed packages, partial-cache-artifact detection, scope detection (read-only, never keyed off the launch directory). CLI surface (install/uninstall/status/clear-cache) and exit codes unchanged.

Acceptance criteria

  • Install writes a v2-native registration entry; zero-write no-op holds on repeat installs (incl. the legacy-entry path)
  • Legacy v1 entries are detected, left functional read-only, and advised to upgrade
  • Uninstall, status, and clear-cache behave as before against v2 reality
  • Scope detection still never writes and never keys off the launch directory
  • Migrated config-editor and installer tests green

Test plan

  • bun run check clean
  • bun test: 156 pass / 5 fail — the 5 failures are pre-existing on this branch's baseline (3 chmod-based removal-failure tests and 2 tarball POSIX-path tests; Windows-only environment issues that pass on Linux CI). +13 tests over baseline, zero new failures.
  • New coverage: legacy-entry install/uninstall/status advisories, zero-write legacy repeat install, object-form entries, mixed-key uninstall warning, generation-cache layout seeding/pruning, CLI legacy advisory end-to-end, README snippet contract flipped to the plugins key (D8).

Deliberate non-changes

  • Install against a config holding the package under both keys stays advisory-only — writing a duplicate v2 entry risks double-registration; the issue prescribes read-only tolerance + advisory for legacy entries.
  • CONTEXT.md "Plugin install" glossary entry remains tracked as doc debt for the C5–C7 guidance pass (facts §13-8).

…y tolerance (issue #26)

The editor now writes and verifies the v2 plugins key; the v1 plugin key is parsed read-only everywhere: a matching legacy entry is a zero-write no-op with an upgrade advisory (config.json additionally flagged as no longer read by v2 per opencode-v2-facts SS5, SS13-3). v2 object-form entries ({ package, options }) match semantically and uninstall removes them. Splice machinery targets the plugins key; findRegistration covers both keys so status sees legacy registrations.
)

Cache roots move from <cache>/opencode/packages to <cache>/opencode/npm per opencode-v2-facts SS7: install-time pruning and clear-cache now operate on generation-cache key dirs (each key holding every generation), and the stale-copy advisory in the plugin load hook cites the npm path. Install/uninstall outcomes carry the config advisory (configWarning) so legacy entries surface through the API; uninstall reports plugin mode when only a legacy registration exists.
…ns key (issue #26)

install and uninstall print the config advisory as a warning while the command surface (install/uninstall/status/clear-cache, flags, exit codes) stays unchanged. New CLI test covers install against a legacy v1 config: exit 0, file untouched, advisory on stderr.
Consumer-facing install snippets teach the v2 plugins key with the canonical @latest entry; cache paragraphs describe the npm generation cache; the D8 snippet contract flips to forbid the v1 plugin key as a registration target.
… (review of #26)

The npm cache root was resolved independently in CacheCleaner, Installer, and hardcoded a third time in the plugin advisory — three sites that had to move in lockstep for the v2 location change. A single NpmCache class now owns the resolution; the load-failure advisory uses it, so it honors XDG_CACHE_HOME instead of printing a hardcoded ~/.cache path.
…ries (review of #26)

Removing the v2 plugins entry while the same package also sat under a legacy plugin key reported uninstalled success while the suite kept loading via migration; the removal outcome now carries the legacy advisory alongside it. Also: shared hasLegacyEntry/packageOf helpers, PluginConfigKey union so a typo'd key fails to compile, and the plugins key length derived from its literal instead of a magic offset.
…ci fix for #26)

CI caught the cache-pruning removal-failure test chmod'ing the old <key>/nested path that the v2 generation-layout seeding no longer creates. A fresh audit of the migrated test files found the same class twice more: a silently no-op existsSync assertion against opencode/packages in the cli clear-cache test, and the shared seedCachedPackage helper plus the cli removal-failure test seeding the v1 layout. All now seed and block the v2 <key>/<generation>/node_modules/<pkg> layout. finally-block chmod cleanup is tolerant so the real assertion failure surfaces on platforms where the dir bit does not block removal.
@diegohb
diegohb merged commit 7a56807 into main Oct 6, 2026
1 check 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.

C3: Migrate installer and config machinery to v2-native registrations

1 participant