fix(cli-codex): auto-install plugin to ~/.codex/plugins/cache after marketplace add#52
fix(cli-codex): auto-install plugin to ~/.codex/plugins/cache after marketplace add#52
Conversation
…arketplace add
`codex marketplace add` only registers the marketplace source in
config.toml. The plugin isn't installed to Codex's runtime cache
(~/.codex/plugins/cache/<marketplace>/<plugin>/<version>/) until the
user manually opens the TUI, runs /plugin, finds the plugin in the
list, and clicks install. Empirically verified.
This is a UX wart for `htmlgraph codex --init`/`--dev`: users expect
"init → launch → skills work", not "init → launch → /plugin → find →
install → now skills work".
Fix: parse <marketplaceRoot>/.agents/plugins/marketplace.json to
resolve marketplace name + plugin name + source subpath, then read
the plugin version from .codex-plugin/plugin.json, and copy the
plugin source tree directly to the cache layout Codex expects:
~/.codex/plugins/cache/<marketplaceName>/<pluginName>/<version>/
The copy is idempotent (clears stale cache first, then copies fresh).
Wired into both runCodexInit and launchCodexDev.
After this fix, a fresh run of `htmlgraph codex --init` is sufficient
to make our skills discoverable via $autocomplete on the next codex
launch — no manual /plugin step required.
Tests added:
- TestParseCodexMarketplaceJSON — parse marketplace.json structure
- TestParseCodexPluginVersion — extract version from plugin.json
- TestCopyDirCreatesExpectedLayout — copyDir creates correct structure
- TestCopyDirIdempotent — copyDir is idempotent
- TestInstallCodexPluginToCacheCreatesExpectedLayout — full cache install
- TestInstallCodexPluginToCacheIdempotent — install is idempotent
Fixes bug-d25198ff.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 459df965c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| mktName = mkt.Name | ||
| pluginName = mkt.Plugins[0].Name | ||
| // Remove leading "./" if present | ||
| pluginSourceSubpath = strings.TrimPrefix(mkt.Plugins[0].Source.Path, "./") |
There was a problem hiding this comment.
Resolve plugin source relative to .agents/plugins
Treating source.path as relative to marketplaceRoot breaks cache installation for the real marketplace layout. In packages/codex-marketplace/.agents/plugins/marketplace.json, source.path is ./htmlgraph relative to .agents/plugins, but this code trims ./ and returns htmlgraph, so later reads target packages/codex-marketplace/htmlgraph/.codex-plugin/plugin.json (nonexistent) instead of packages/codex-marketplace/.agents/plugins/htmlgraph/.codex-plugin/plugin.json. As a result, both htmlgraph codex --init and htmlgraph codex --dev hit the warning path and do not auto-install the plugin cache.
Useful? React with 👍 / 👎.
Summary
codex marketplace addonly registers the source — actual install to ~/.codex/plugins/cache requires either an interactive/pluginflow in the TUI or a manual file copy. Fixing the UX by doing the copy ourselves aftermarketplace addsucceeds.htmlgraph codex --initandhtmlgraph codex --dev.Related
Test plan
htmlgraph codex --init; verify cache dir is populated without opening Codex's TUI🤖 Generated with Claude Code