-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: migrate claude to the target registry (no behavior change) #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4f74ef5
refactor: migrate cursor to the target registry (no behavior change)
steve-calvert-glean 6b9be44
fix: apply the per-plugin version override in cursor's manifest
steve-calvert-glean d0677f1
refactor: migrate claude to the target registry (no behavior change)
steve-calvert-glean b1c0e9f
Merge remote-tracking branch 'origin/main' into refactor/claude-targe…
steve-calvert-glean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| import path from "node:path"; | ||
| import { stripUndefined } from "./shared.js"; | ||
| import { | ||
| error, | ||
| readJson, | ||
| validateBareStringSourceEntry, | ||
| validateFrontmatter, | ||
| validateHooksShape, | ||
| validateMarketplaceBasics, | ||
| } from "./validation-shared.js"; | ||
| import type { PluginTargetDefinition } from "./types.js"; | ||
|
|
||
| const pluginNamePattern = /^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/; | ||
|
|
||
| /** | ||
| * Claude Code agent-plugin target. `validateManifest`'s required fields | ||
| * (`version`, `description`, `author.name`) were verified directly against | ||
| * `claude plugin validate --strict` — a minimal manifest with only `name` | ||
| * fails that check, so pluginpack's existing stricter validation matches the | ||
| * real CLI rather than over-constraining it. | ||
| */ | ||
| export const claude: PluginTargetDefinition = { | ||
| name: "claude", | ||
|
|
||
| defaultComponents: ["skills", "agents", "hooks", "scripts", "assets"], | ||
|
|
||
| resolvePluginPath: (pluginName, pluginConfig, targetConfig) => | ||
| pluginConfig.path ?? | ||
| path.join(targetConfig.pluginRoot ?? "plugins", pluginName), | ||
|
|
||
| buildPluginManifest: ({ metadata, version, pluginName, pluginConfig }) => | ||
| stripUndefined({ | ||
| name: pluginName, | ||
| version: pluginConfig.version ?? version, | ||
| description: pluginConfig.description ?? metadata?.description, | ||
| author: metadata?.author, | ||
| homepage: metadata?.homepage, | ||
| repository: metadata?.repository, | ||
| license: metadata?.license, | ||
| keywords: metadata?.keywords, | ||
| }), | ||
| manifestPaths: (pluginPath, targetConfig) => [ | ||
| path.join( | ||
| pluginPath, | ||
| targetConfig.marketplaceDir ?? ".claude-plugin", | ||
| "plugin.json", | ||
| ), | ||
| ], | ||
|
|
||
| buildMarketplaceEntry: ({ pluginName, pluginPath, pluginConfig, manifest }) => | ||
| stripUndefined({ | ||
| name: pluginName, | ||
| source: `./${pluginPath}`, | ||
| description: | ||
| pluginConfig.description ?? | ||
| (manifest?.description as string | undefined), | ||
| }), | ||
|
|
||
| buildMarketplaceManifest: ({ project, version, plugins }) => | ||
| stripUndefined({ | ||
| $schema: "https://anthropic.com/claude-code/marketplace.schema.json", | ||
| name: project.config.name, | ||
| version, | ||
| description: project.config.metadata?.description, | ||
| owner: project.config.metadata?.owner ?? project.config.metadata?.author, | ||
| plugins, | ||
| }), | ||
| marketplacePaths: (targetConfig) => [ | ||
| path.join( | ||
| targetConfig.marketplaceDir ?? ".claude-plugin", | ||
| "marketplace.json", | ||
| ), | ||
| ], | ||
|
|
||
| mcpConfigPath: (pluginPath) => path.join(pluginPath, ".mcp.json"), | ||
| hooksPath: (pluginPath) => path.join(pluginPath, "hooks", "hooks.json"), | ||
|
|
||
| validateManifest: (manifest, pluginName, issues) => { | ||
| for (const field of ["name", "version", "description"]) { | ||
| if (typeof manifest[field] !== "string" || !manifest[field]) { | ||
| error( | ||
| issues, | ||
| `${pluginName}: plugin.json is missing required field "${field}".`, | ||
| ); | ||
| } | ||
| } | ||
| const author = manifest.author as Record<string, unknown> | undefined; | ||
| if (!author || typeof author.name !== "string" || !author.name) { | ||
| error(issues, `${pluginName}: plugin.json is missing "author.name".`); | ||
| } | ||
| }, | ||
| validateMarketplaceEntry: (entry, index, root, issues) => | ||
| validateBareStringSourceEntry( | ||
| entry, | ||
| index, | ||
| root, | ||
| issues, | ||
| pluginNamePattern, | ||
| ), | ||
|
|
||
| validateOutput: async (root, issues) => { | ||
| const marketplacePath = path.join( | ||
| root, | ||
| ".claude-plugin", | ||
| "marketplace.json", | ||
| ); | ||
| const marketplace = await readJson( | ||
| marketplacePath, | ||
| "Marketplace manifest", | ||
| issues, | ||
| ); | ||
| if (!marketplace) { | ||
| return; | ||
| } | ||
| validateMarketplaceBasics(marketplace, issues); | ||
| const plugins = Array.isArray(marketplace.plugins) | ||
| ? marketplace.plugins | ||
| : []; | ||
| if (plugins.length === 0) { | ||
| error(issues, 'Marketplace "plugins" must be a non-empty array.'); | ||
| return; | ||
| } | ||
| for (const [index, entry] of plugins.entries()) { | ||
| const pluginName = claude.validateMarketplaceEntry( | ||
| entry, | ||
| index, | ||
| root, | ||
| issues, | ||
| ); | ||
| if (!pluginName) { | ||
| continue; | ||
| } | ||
| const pluginDir = path.join(root, entry.source); | ||
| const manifest = await readJson( | ||
| path.join(pluginDir, ".claude-plugin", "plugin.json"), | ||
| `${pluginName} plugin manifest`, | ||
| issues, | ||
| ); | ||
| if (!manifest) { | ||
| continue; | ||
| } | ||
| if (manifest.name !== pluginName) { | ||
| error( | ||
| issues, | ||
| `${pluginName}: marketplace entry name does not match plugin.json name ("${manifest.name}").`, | ||
| ); | ||
| } | ||
| claude.validateManifest(manifest, pluginName, issues); | ||
| await validateFrontmatter(pluginDir, pluginName, "claude", issues); | ||
| await validateHooksShape( | ||
| pluginDir, | ||
| pluginName, | ||
| "hooks/hooks.json", | ||
| issues, | ||
| ); | ||
| } | ||
| }, | ||
|
|
||
| installSnippet: { | ||
| userConfigurable: true, | ||
| build: ({ repository, pluginName, marketplaceName }) => ({ | ||
| kind: "command", | ||
| snippet: `/plugin marketplace add ${repository}\n/plugin install ${pluginName}@${marketplaceName}`, | ||
| note: `Once the marketplace is added, "claude plugin install ${pluginName}@${marketplaceName}" also works as a standalone shell command — but marketplace add itself is slash-only, with no shell equivalent.`, | ||
| }), | ||
| citation: { | ||
| claim: | ||
| "/plugin marketplace add is slash-only; claude plugin install works as a standalone shell command once a marketplace is already added", | ||
| documentationUrl: | ||
| "https://code.claude.com/docs/en/plugins-reference#cli-commands-reference", | ||
| verifiedAt: "2026-07-25", | ||
| }, | ||
| }, | ||
|
|
||
| citations: [ | ||
| { | ||
| claim: | ||
| "claude plugin validate --strict treats missing version/description/author.name as errors", | ||
| documentationUrl: "https://code.claude.com/docs/en/plugins-reference", | ||
| verifiedAt: "2026-07-26", | ||
| }, | ||
| ], | ||
| }; | ||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: In src/targets/claude.ts, resolvePluginPath does not normalize the computed pluginPath with toPosix(), unlike the legacy emitClaude and the migrated Copilot target, so on Windows the marketplace entry source field will contain backslashes (e.g. "./plugins\my-plugin") instead of the expected POSIX-style path, changing behavior and potentially breaking consumers that expect forward slashes.
Suggested fix: Update resolvePluginPath in src/targets/claude.ts to mirror the legacy Claude and Copilot implementations by wrapping the joined path in toPosix(), and import toPosix from ../fs.js. For example:
🔧 Tag
@ glean-for-engineeringto fix or click here to fix in Glean💬 Help us improve! Was this comment helpful? React with 👍 or 👎