Skip to content

feat(agent/agentcontext): discover plugin packs in the Claude Code plugin cache layout - #223

Merged
ibetitsmike merged 15 commits into
mainfrom
mike/plugin-packs-12-claude-cache
Nov 12, 2026
Merged

ibetitsmike merged 15 commits into
mainfrom
mike/plugin-packs-12-claude-cache

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

~/.claude/plugins/cache is a built-in plugin pack scan root, but Claude Code installs plugins there as cache/<marketplace>/<plugin>/<version>/, three levels below the root. Pack discovery only looked at the root and its direct children, so it found nothing in that directory.

Pack discovery now walks the Claude Code cache layout and emits one pack per cached plugin: the newest version directory that holds a manifest and has no .orphaned_at marker. Claude Code keeps superseded or uninstalled versions for 14 days with that marker, so emitting every version would serve stale copies next to the current one. The watch set now covers the marketplace, plugin, and live version directories, so a new install, a new version, or an orphan marker triggers a resync.

Discovery also follows more of Claude Code's plugin rules:

  • skills and agents in .claude-plugin/plugin.json may be a string or an array of strings, and an agents entry may name a single .md file. Any other non-null shape rejects the plugin, as Claude Code does. As in Claude Code, a declared path that escapes the plugin or does not exist is dropped and the rest of the plugin loads, and a declared agents entry that is not a .md file loads nothing. Cursor and root manifests keep falling back to the default directories and accept agent folders.
  • A cached plugin's marketplace entry is read from the catalog at its known_marketplaces.json install location, or from plugins/marketplaces/<marketplace>/.claude-plugin/marketplace.json. An entry counts only with a name and a valid source. Without plugin.json the entry is the manifest. With plugin.json, the entry's skills and agents are added, unless the entry sets strict: false, in which case any component field in plugin.json rejects the plugin. Catalog writes trigger a resync, but the marketplaces/ directory itself is not watched.
  • A marketplace added from a local directory or file in known_marketplaces.json loads its relative-path plugins in place from the marketplace folder, as Claude Code does, when installed_plugins.json has a user, unscoped or managed record for them and the folder stays inside the marketplace root. An in-place plugin replaces a cached copy with the same id, and its catalog and folder are watched.
  • A Claude plugin with SKILL.md at its root and no skills/ directory or skills field loads that file as its one skill, named from its front-matter.
  • ${CLAUDE_PLUGIN_ROOT} in a Claude plugin's skill or agent Markdown body is replaced with the plugin root. Front-matter is left unchanged.
  • The default agents/ directory of a Claude plugin is walked into subfolders (at most 4 levels and 64 folders, no symlinks) and each folder is watched. A nested agent keeps its own name, without Claude Code's plugin:folder: prefix, so clashes fall to first-wins.
  • plugins/installed_plugins.json next to the cache picks the version when it names one. User, unscoped and managed records count; a plugin recorded only with project or local scope is skipped, because the agent does not know which project a session runs in. Without a usable record, discovery falls back to the newest live version.
  • When CLAUDE_CODE_PLUGIN_CACHE_DIR is set, <that dir>/cache replaces ~/.claude/plugins/cache as the built-in scan root.
  • When CLAUDE_CONFIG_DIR is set, the cache moves to <that dir>/plugins/cache and the user settings to <that dir>/settings.json. If CLAUDE_CODE_PLUGIN_CACHE_DIR is also set, the cache follows it and the settings stay in the config directory.
  • A plugin whose <plugin>@<marketplace> id is false under enabledPlugins in the user settings file is skipped. A plugin with no setting follows defaultEnabled from its marketplace entry or manifest, but starts enabled when an enabled plugin depends on it. An enabled plugin whose dependency is turned off does not load, as Claude Code reports it as a dependency error. Project, local and managed settings are not read, because the agent does not know which project a session runs in. A write to that settings file, or to its target when it is a symlink, triggers a resync.

Two packs that expose the same skill or agent name still resolve first-wins, as they do for every pack source.

Not handled yet: hooks and mcpServers in a marketplace entry, skills: null is treated as absent, a dependency that is not installed does not fail its dependent (its install may be at a scope the agent cannot see), and dependency version ranges are not checked.

Validation: on a412921, gofmt -l agent/agentcontext is clean, and go build ./agent/..., go vet ./agent/agentcontext/... and go test -count=3 ./agent/agentcontext/... pass.

Related to #12.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T03:04:57.177740Z a412921 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: c646447d74

ℹ️ 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 agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
…nv override, and disabled plugins

Accept string or array declarations for skills and agents in plugin manifests, serve single agent .md file entries, recognize the CLAUDE_CODE_PLUGIN_CACHE_DIR cache, and skip cached plugins the user settings disable.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

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

Copy link
Copy Markdown

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: a9aeee8cd9

ℹ️ 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 agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

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

Copy link
Copy Markdown

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: d87c381e51

ℹ️ 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 agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

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

Copy link
Copy Markdown

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: 9aa417b817

ℹ️ 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 agent/agentcontext/fork_plugins.go Resolved
…claude-cache

# Conflicts:
#	agent/agentcontext/fork_plugins.go
#	agent/agentcontext/fork_plugins_test.go
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

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

Copy link
Copy Markdown

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: de2d3223a2

ℹ️ 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 agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

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

Copy link
Copy Markdown

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: 4b7a97dee7

ℹ️ 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 agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
…ts, marketplace entries, root skills, plugin root and nested agents
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

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

Copy link
Copy Markdown

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: 4a97506eed

ℹ️ 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 agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

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

Copy link
Copy Markdown

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: 00b816e4d1

ℹ️ 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 agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
… settings, entry sources and local marketplaces
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

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

Copy link
Copy Markdown

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: a412921a34

ℹ️ 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 agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
Comment thread agent/agentcontext/fork_plugins.go Resolved
@ibetitsmike
ibetitsmike merged commit 114f59d into main Nov 12, 2026
10 checks passed
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Lead merge check on head a412921a34: fork-ci run 43144374846 (pull_request) green; Codex review 5868324071 on this commit had 8 P2 findings, all Claude-parity edge cases, each answered and resolved under the fork's review rule. The plugin namespace thread was resolved by the lead for the same reason: two packs exposing the same name already resolve first-wins for every pack source. Go validation on this head passed (gofmt, build, vet, go test -count=3 ./agent/agentcontext/...). Pack rows reach chats only while the server advertises fork-plugin-packs, which is off on the daily deployment. The PR is larger than the usual 500-line target (about 1,500 non-test lines). It stays one PR because the cache walk, manifest rules and watch set share one discovery path.

@ibetitsmike
ibetitsmike deleted the mike/plugin-packs-12-claude-cache branch November 12, 2026 03:08
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