Fix subagent skill-path resolution; sync marketplace.json plugin version (closes #6)#7
Open
deinspanjer wants to merge 3 commits into
Open
Fix subagent skill-path resolution; sync marketplace.json plugin version (closes #6)#7deinspanjer wants to merge 3 commits into
deinspanjer wants to merge 3 commits into
Conversation
The agent file instructed the subagent to Read `skills/codex-peer-review/SKILL.md` as a relative path. The subagent's CWD is the user's project (or worktree), not the plugin install dir, so the path almost never resolves. Symptoms ranged from a hard "file not found" failure to silent improvisation (subagent fakes a protocol from dispatcher hints), making behavior inconsistent and unsafe. Fix: rewrite the agent's "load the skill" step to autodiscover the install location via `ls` glob against the standard plugin paths (`~/.claude/plugins/cache/*/codex-peer-review/*/skills/...` and `~/.claude/plugins/marketplaces/*/plugins/codex-peer-review/skills/...`), then `cat` the four protocol files from the resolved `$SKILL_ROOT`. Also accept an explicit `SKILL_ROOT=<absolute path>` envelope in the dispatch input as an escape hatch for non-standard installs. Also remove the `skills:` frontmatter field — there is no precedent in any plugin or built-in agent for it being honored, and leaving it in the file falsely suggested the harness was loading the skill automatically. Tested against codex-cli 0.118.0 + Claude Code 2.1.119, plugin installed via local-directory marketplace. Bump plugin version 2.0.0 -> 2.0.1.
…putney#6) The 2.0.0 release bumped plugin.json version but marketplace.json's plugin entry stayed at 1.0.11. Clients use marketplace.json for update detection, so 1.x users couldn't auto-update to 2.x and downloads served the wrong version metadata. Bump marketplace.json: - top-level version 1.0.12 -> 1.0.13 (new marketplace release) - plugins[0].version 1.0.11 -> 2.0.1 (matches plugin.json) Closes upstream issue jcputney#6.
…spatch The previous patch presented two separate `ls` glob commands as code blocks. The subagent (Claude) interpreted them as independent tool calls and emitted them in parallel — so when the first failed (e.g. cache/ empty pre-fetch), the second was cancelled by the harness rather than running as a fallback. Force sequential evaluation by collapsing the chain into a single bash call with `||`. Stdout becomes the resolved SKILL.md path; nonzero exit means neither location has the plugin. Verified by dispatching with no SKILL_ROOT envelope: pre-fix dispatch errored on the cache/ no-match and never tried marketplaces/. Post-fix the marketplaces/ fallback resolves correctly when cache/ is empty.
Author
|
I've (the human) reviewed and tested this code and feel it is a good update for the upstream. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two unrelated bugs in
main:agents/codex-peer-reviewer.mdinstructs the subagent toRead skills/codex-peer-review/SKILL.mdas a relative path, but the subagent's CWD is the user's project (or worktree), not the plugin install directory. The path almost never resolves. Symptoms range from a hard "file not found" failure to silent improvisation (subagent fakes the protocol from dispatcher hints), making behavior inconsistent and unsafe.marketplace.jsonplugin version is stale (marketplace.json plugin entry not bumped to 2.0.0 — clients can't auto-update from 1.x #6). The 2.0.0 release bumpedplugin.jsonbut leftmarketplace.json:plugins[0].versionat1.0.11. Clients use the marketplace number for update detection, so 1.x installs can't auto-update to 2.x and the catalog reports the wrong version.This PR fixes both. Closes #6.
Why the relative path doesn't work
${CLAUDE_PLUGIN_ROOT}substitution does not happen in markdown bodies (only inhooks/hooks.jsoncommandfields), so the agent file can't reference its own install path via that variable.Skilltool bytools:frontmatter — there's no precedent for it in any official or community plugin.skills:frontmatter field on the agent appeared aspirational; I couldn't find any plugin where the harness honors it as an auto-loader.So the subagent has to discover the path itself.
Changes
plugins/codex-peer-review/agents/codex-peer-reviewer.md:$SKILL_ROOTvia a single bash call with||-chainedlsglobs —~/.claude/plugins/cache/*/codex-peer-review/*/skills/...falling back to~/.claude/plugins/marketplaces/*/plugins/codex-peer-review/skills/.... Single chained call (not two separate code blocks) so the subagent doesn't emit the globs as parallel tool calls and short-circuit the fallback.SKILL_ROOT=<absolute path>envelope as an escape hatch for non-standard installs (e.g., local-directory marketplace sources).$SKILL_ROOT/....skills:frontmatter field.plugins/codex-peer-review/.claude-plugin/plugin.json: bump2.0.0→2.0.1..claude-plugin/marketplace.json:version1.0.12→1.0.13(new marketplace release).plugins[0].version1.0.11→2.0.1(sync with plugin.json).Three commits, kept separate for clarity — squash if you prefer.
Testing
/codex-peer-reviewcommand locally with the patched plugin installed via github source pointing at the fork (deinspanjer/agent-peer-review).SKILL_ROOT=<absolute path>in the prompt; subagent parsed it,cat'd all four protocol files (byte sizes 16974/8032/5926/8238 — matching disk), codex round-tripped (/tmp/codex_round{0,1}.{txt,jsonl}regenerated fresh), structured verdict returned.SKILL_ROOT=envelope; subagent reported running the||-chainedlsglobs as a single Bash call,marketplaces/glob matched on the fallback, all four protocol files loaded successfully, codex round-tripped, structured verdict returned.marketplace.json:plugins[0].versionreports2.0.1after refetch from the fork — no version skew vsplugin.json.Environment used to validate
Checklist
SKILL_ROOTenvelope is opt-inNotes for the maintainer
||-chain) exists because an earlier draft of this fix presented the twolsglobs as separate code blocks ("run cache glob, then run marketplaces glob"). Live testing surfaced that the subagent emitted those as parallel tool calls and the harness cancelled the second when the first errored — short-circuiting the fallback. Collapsing into a single||-chained bash call eliminates the parallelism question entirely. Worth keeping the lesson visible in the commit history, IMO, but feel free to squash.Skillto the subagent as a cleaner load mechanism. Rejected: no plugin precedent, undocumented for subagents, and the system-reminder skill registry is not documented to propagate to subagent contexts.skills:frontmatter was non-functional in my testing. If it's actively used by some Claude Code path I missed, restore at your discretion.🤖 Generated with Claude Code