Skip to content

fix(claude): validate plugin.json and marketplace.json explicitly; read the --json report on 2.1.259+ - #474

Merged
ScriptedAlchemy merged 3 commits into
mainfrom
chore/claude-plugin-tooling-alignment
Sep 4, 2026
Merged

fix(claude): validate plugin.json and marketplace.json explicitly; read the --json report on 2.1.259+#474
ScriptedAlchemy merged 3 commits into
mainfrom
chore/claude-plugin-tooling-alignment

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

agent-bundle validate --artifact ran claude plugin validate <bundle-dir> --strict. The emitted Claude bundle places .claude-plugin/marketplace.json beside .claude-plugin/plugin.json, and Claude Code resolves a directory that holds a marketplace manifest as a marketplace. A marketplace run validates marketplace.json and re-checks each local entry's plugin.json, but — quoting the official docs — "From a marketplace directory, Claude Code doesn't open the plugins' skill, agent, command, or hook files." Every hook, skill, and agent finding was therefore invisible to the claude and plugin targets, while the host report said passed.

This PR:

  • Runs claude plugin validate <dir>/.claude-plugin/plugin.json --strict (covers plugin.json, hooks/hooks.json, skills/, agents/, commands/) and then, when the bundle emits one, claude plugin validate <dir>/.claude-plugin/marketplace.json --strict. Falls back to the directory only when plugin.json is absent.
  • Adds --json when the probed CLI is ≥ 2.1.259 and parses the documented report (success/strict/target/manifest/contents[]); older releases (CI pins 2.1.250, which answers error: unknown option '--json') keep the text report, now parsed with its Validating <type>: <file> headers.
  • Attributes every AB6020/AB6021 to its file via generatedPath and Claude's field path, e.g. Claude plugin validation (hooks hooks/hooks.json): hooks: hooks.postToolUse: unknown hook event; entry ignored at runtime.
  • Drops the marketplace run's plugins[N] plugin.json → … copies of manifest findings the plugin run already reported; surfaces notes as info; a ≥2.1.259 run that returns no JSON (exit 2 writes only to stderr) is AB6022 carrying that stderr.
  • Points the native Claude eval gate (native-claude-contract.ts) at plugin.json for the same reason.
  • Documents AB6019AB6022 in docs/diagnostics.md (previously listed nowhere), updates the validation guide (en + zh) with the two commands, the --json floor, and the claude --plugin-dir artifact/claude + /reload-plugins dev loop, and records the evidence in the Claude capability JSON and schema PROVENANCE.json.

Evidence (official Claude Code docs, uploaded markdown)

  • plugin-marketplaces-0.mdTroubleshooting › Marketplace validation errors (L1338–1348): a marketplace-directory run checks marketplace.json, duplicate names, path traversal, and each local entry's plugin.json (prefixed plugins[2] plugin.json →); "From a marketplace directory, Claude Code doesn't open the plugins' skill, agent, command, or hook files."
  • plugin-marketplaces-0.mdValidate a plugin or a directory without a manifest › Pick the directory to name (L1375–1381): a plugin run checks plugin.json, hooks/hooks.json, and the skills, agents, and commands directories at the plugin root.
  • plugins-reference-1.mdCLI commands reference › plugin validate (L1212–1242): exit codes 0/1/2; --json "Requires Claude Code v2.1.259 or later"; report fields success, strict, target, manifest (or null), contents per-file with errors, warnings, notes; "On exit 2, the command writes nothing to stdout; the error message goes to stderr."
  • plugins-0.mdTest your plugins locally (L290–309): claude --plugin-dir ./my-plugin; /reload-plugins "reloads plugins, skills, agents, hooks, plugin MCP servers, and plugin LSP servers."
  • plugins-reference-1.mdplugin list (L1157): --plugin-dir plugins appear in claude plugin list "only when the same flag precedes the subcommand."

Reproduction on this machine (Claude Code 2.1.259 and the CI pin 2.1.250)

Bundle with two unknown manifest fields, an agent without description, and a hooks.json with an unknown hook type and a miscased postToolUse event:

Command Result
claude plugin validate . --strict (old behaviour) Validating marketplace manifest → only the 2 manifest warnings; hooks and agents never mentioned
claude plugin validate .claude-plugin/plugin.json --strict 2 manifest warnings + agents/bad.md warning + 2 hooks/hooks.json findings (warnings on 2.1.259, errors on 2.1.250)
… --strict --json on 2.1.250 error: unknown option '--json', exit 1

agent-bundle validate before → claude passed (2 diagnostics on the broken bundle). After → 5 diagnostics, each with generatedPath.

Recorded --json and 2.1.250 text reports live in packages/agent-bundle/tests/fixtures/claude-plugin-validate/.

Verification

  • pnpm typecheck, pnpm lint, pnpm test:unit (3033 tests), artifact-validator.test.ts + cli.test.ts under the integration config, pnpm docs:site:build (parity OK).
  • Real-CLI run of validateClaudePlugin against examples/host-test/artifact/claude (passed, 0 diagnostics) and the broken bundle above, with both the 2.1.259 and 2.1.250 binaries.

Review status

  • Codex reviewed efa9701a8 (one P2 thread: published README still named the directory form) — addressed in 58818c38e (README now shows both manifest invocations and the 2.1.259 --json floor).
  • Unreviewed head: 58818c38e (ee49efd4d changeset PR number, 58818c38e README). No fresh review was requested per maintainer instruction.
  • CI: every check green except Release gates, which fails in the release audit's npm audit call with 503 Service Unavailable from registry.npmjs.org/-/npm/v1/security/audits/quick (same failure on main; job being removed separately). Merged under the maintainer's merge-gate relaxation for that job.

…ad the --json report on 2.1.259+

A bundle directory that holds both .claude-plugin manifests is a marketplace
to `claude plugin validate`, and a marketplace run never opens hooks/,
skills/, agents/, or commands/. Name each manifest, gate --json on the probed
version, attribute every finding to its file, and de-duplicate the
marketplace run's plugins[N] plugin.json copies.
@changeset-bot

changeset-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 58818c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@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: efa9701a8b

ℹ️ 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".

args: Object.freeze([
'plugin',
'validate',
validationTarget.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.

P2 Badge Update the published README to name both manifests

Package users following packages/agent-bundle/README.md:135-139 are still told that artifact validation runs claude plugin validate <bundle-dir> --strict, although this loop now validates plugin.json and the optional marketplace.json separately. The captured Claude behavior in packages/agent-bundle/src/adapters/capabilities/claude-2.1.250.json:803 confirms that directory validation selects the marketplace and does not inspect hook, skill, agent, or command files, so the README command recreates the blind spot fixed by this commit. Because packages/agent-bundle/package.json includes README.md in the published package, update it with the two manifest invocations and version-gated --json behavior.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 58818c3: the published README now shows the two manifest invocations (.claude-plugin/plugin.json, then .claude-plugin/marketplace.json), the 2.1.259 --json floor with the text fallback, and the AB6019–AB6021 mapping, matching the website guide and docs/diagnostics.md.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T23:33:35.868975Z efa9701 PR opened
ℹ️ 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.

@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@474
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@474
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@474

commit: 58818c3

@ScriptedAlchemy
ScriptedAlchemy merged commit e879820 into main Sep 4, 2026
12 of 13 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the chore/claude-plugin-tooling-alignment branch September 4, 2026 00:30
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