Skip to content

fix(cli-codex): auto-install plugin to ~/.codex/plugins/cache after marketplace add#52

Open
shakestzd wants to merge 1 commit intomainfrom
bug-d25198ff-codex-auto-install
Open

fix(cli-codex): auto-install plugin to ~/.codex/plugins/cache after marketplace add#52
shakestzd wants to merge 1 commit intomainfrom
bug-d25198ff-codex-auto-install

Conversation

@shakestzd
Copy link
Copy Markdown
Owner

Summary

  • codex marketplace add only registers the source — actual install to ~/.codex/plugins/cache requires either an interactive /plugin flow in the TUI or a manual file copy. Fixing the UX by doing the copy ourselves after marketplace add succeeds.
  • Wired into htmlgraph codex --init and htmlgraph codex --dev.
  • Idempotent: subsequent runs clear the stale cache and copy fresh.

Related

Test plan

  • go build / vet / test pass
  • TestParseCodexMarketplaceJSON, TestParseCodexPluginVersion, TestCopyDirCreatesExpectedLayout, TestCopyDirIdempotent, TestInstallCodexPluginToCacheCreatesExpectedLayout, TestInstallCodexPluginToCacheIdempotent all pass
  • Reviewer: clean ~/.codex/plugins/cache/htmlgraph; run htmlgraph codex --init; verify cache dir is populated without opening Codex's TUI

🤖 Generated with Claude Code

…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>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread cmd/htmlgraph/codex.go
mktName = mkt.Name
pluginName = mkt.Plugins[0].Name
// Remove leading "./" if present
pluginSourceSubpath = strings.TrimPrefix(mkt.Plugins[0].Source.Path, "./")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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