claudepluginhub 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,9 @@
1
1
  import type { Scope } from './prompts.js';
2
+ export declare function runCollectionInstall(url: string, yes: boolean, scopeOverride: Scope | null): Promise<void>;
2
3
  /**
3
- * Install a plugin collection by delegating to Claude Code's native plugin
4
- * system: `claude plugin marketplace add <url>` once, then
5
- * `claude plugin install <name>@<marketplace>` per selected plugin.
6
- *
7
- * Collections reference WHOLE plugins (source only — github/git-subdir/git),
8
- * which the component downloader can't cherry-pick, so native delegation is
9
- * the correct install path. This also covers mixed collections: user-plugin
10
- * entries (component-path arrays) are valid marketplace entries too, so
11
- * nothing is silently dropped.
12
- *
13
- * Requires the `claude` binary (unlike the `u/` component install path).
14
- * Native owns the installed state — manage with `claude plugin ...`.
4
+ * Install a single plugin via its ClaudePluginHub wrapper marketplace
5
+ * (p/<slug> → /api/plugins/<slug>/marketplace.json). The wrapper emits a
6
+ * spec-correct source (git-subdir for monorepo plugins), so this is the
7
+ * correct one-liner for plugins without an indexed native marketplace.
15
8
  */
16
- export declare function runCollectionInstall(url: string, yes: boolean, scopeOverride: Scope | null): Promise<void>;
9
+ export declare function runWrapperPluginInstall(url: string, yes: boolean, scopeOverride: Scope | null): Promise<void>;
@@ -16,34 +16,35 @@ function isInstallableMarketplaceName(name) {
16
16
  name !== '.');
17
17
  }
18
18
  /**
19
- * Install a plugin collection by delegating to Claude Code's native plugin
20
- * system: `claude plugin marketplace add <url>` once, then
19
+ * Install from a hosted marketplace manifest by delegating to Claude Code's
20
+ * native plugin system: `claude plugin marketplace add <url>` once, then
21
21
  * `claude plugin install <name>@<marketplace>` per selected plugin.
22
22
  *
23
- * Collections reference WHOLE plugins (source only — github/git-subdir/git),
24
- * which the component downloader can't cherry-pick, so native delegation is
25
- * the correct install path. This also covers mixed collections: user-plugin
26
- * entries (component-path arrays) are valid marketplace entries too, so
27
- * nothing is silently dropped.
23
+ * Used for plugin collections (c/<userId>/<slug>) and single-plugin wrapper
24
+ * marketplaces (p/<slug>). Both reference WHOLE plugins (source only —
25
+ * github/git-subdir/git), which the component downloader can't cherry-pick,
26
+ * so native delegation is the correct install path. This also covers mixed
27
+ * collections: user-plugin entries (component-path arrays) are valid
28
+ * marketplace entries too, so nothing is silently dropped.
28
29
  *
29
30
  * Requires the `claude` binary (unlike the `u/` component install path).
30
31
  * Native owns the installed state — manage with `claude plugin ...`.
31
32
  */
32
- export async function runCollectionInstall(url, yes, scopeOverride) {
33
+ async function runNativeManifestInstall(url, yes, scopeOverride, kind) {
33
34
  if (!checkClaudeCli())
34
35
  process.exit(1);
35
- printStep('Fetching collection...');
36
+ printStep(`Fetching ${kind}...`);
36
37
  const manifest = await fetchMarketplace(url);
37
38
  if (!manifest) {
38
39
  process.exit(1);
39
40
  }
40
41
  printSuccess(`"${manifest.name}" — ${manifest.plugins.length} plugin(s)`);
41
42
  if (manifest.plugins.length === 0) {
42
- printError('No plugins found in this collection.');
43
+ printError(`No plugins found in this ${kind}.`);
43
44
  process.exit(1);
44
45
  }
45
46
  if (!isInstallableMarketplaceName(manifest.name)) {
46
- printError(`This collection's marketplace name ("${manifest.name}") is not accepted by Claude Code. ` +
47
+ printError(`This ${kind}'s marketplace name ("${manifest.name}") is not accepted by Claude Code. ` +
47
48
  'Please report this to claudepluginhub.com.');
48
49
  process.exit(1);
49
50
  }
@@ -78,15 +79,15 @@ export async function runCollectionInstall(url, yes, scopeOverride) {
78
79
  }
79
80
  scope = chosenScope;
80
81
  }
81
- // Register the collection endpoint itself as the marketplace. URL-based
82
- // registration keeps the marketplace linked to the collection, so
83
- // `claude plugin marketplace update` picks up curation changes. Strip query
82
+ // Register the endpoint itself as the marketplace. URL-based registration
83
+ // keeps the marketplace linked to the hosted manifest, so
84
+ // `claude plugin marketplace update` picks up upstream changes. Strip query
84
85
  // params (e.g. the one-shot ?source=cli tracking param) so native refreshes
85
86
  // hit the canonical URL.
86
87
  const registerUrl = new URL(url);
87
88
  registerUrl.search = '';
88
89
  print('');
89
- printStep('Adding collection marketplace...');
90
+ printStep(`Adding ${kind} marketplace...`);
90
91
  const addResult = claudeMarketplaceAdd(registerUrl.toString(), scope);
91
92
  if (!addResult.ok) {
92
93
  printError(`Failed to add marketplace: ${addResult.output}`);
@@ -119,4 +120,20 @@ export async function runCollectionInstall(url, yes, scopeOverride) {
119
120
  print(` ${DIM}claude plugin uninstall <plugin>${RESET}`);
120
121
  print(` ${DIM}claude plugin marketplace remove ${manifest.name}${RESET}`);
121
122
  print('');
123
+ // Nothing installed at all — that's a failure, not a partial success.
124
+ if (failures === selectedPlugins.length) {
125
+ process.exit(1);
126
+ }
127
+ }
128
+ export async function runCollectionInstall(url, yes, scopeOverride) {
129
+ return runNativeManifestInstall(url, yes, scopeOverride, 'collection');
130
+ }
131
+ /**
132
+ * Install a single plugin via its ClaudePluginHub wrapper marketplace
133
+ * (p/<slug> → /api/plugins/<slug>/marketplace.json). The wrapper emits a
134
+ * spec-correct source (git-subdir for monorepo plugins), so this is the
135
+ * correct one-liner for plugins without an indexed native marketplace.
136
+ */
137
+ export async function runWrapperPluginInstall(url, yes, scopeOverride) {
138
+ return runNativeManifestInstall(url, yes, scopeOverride, 'plugin');
122
139
  }
package/dist/download.js CHANGED
@@ -135,6 +135,33 @@ export async function downloadSingleFile(component, scope) {
135
135
  configFragment: null,
136
136
  };
137
137
  }
138
+ function isRecord(value) {
139
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
140
+ }
141
+ /**
142
+ * Minimal structural contracts for what we write into settings.json —
143
+ * derived from the official Claude Code settings shapes. Deliberately loose
144
+ * (extra fields fine, no enum of event names) so new Claude Code features
145
+ * don't get rejected; the point is to never write something Claude Code
146
+ * cannot parse at all.
147
+ */
148
+ function isValidMcpServerEntry(value) {
149
+ if (!isRecord(value))
150
+ return false;
151
+ // stdio servers need a command; remote servers need a url
152
+ return typeof value.command === 'string' || typeof value.url === 'string';
153
+ }
154
+ function isValidLspServerEntry(value) {
155
+ return isRecord(value) && typeof value.command === 'string';
156
+ }
157
+ /** A hook event's value: array of matcher groups, each with a hooks array of typed handlers. */
158
+ function isValidHookEventHandlers(value) {
159
+ if (!Array.isArray(value))
160
+ return false;
161
+ return value.every((group) => isRecord(group) &&
162
+ Array.isArray(group.hooks) &&
163
+ group.hooks.every((h) => isRecord(h) && typeof h.type === 'string'));
164
+ }
138
165
  async function resolveConfig(component) {
139
166
  const { inlineConfig, source, sourcePath } = component;
140
167
  // Inline config object — use directly
@@ -174,6 +201,13 @@ export async function mergeConfig(component, scope) {
174
201
  const mcpConfig = config.mcpServers
175
202
  ? config.mcpServers
176
203
  : config;
204
+ // Validate BEFORE any write: a malformed server entry means the whole
205
+ // component is skipped loudly — never write config Claude Code can't parse.
206
+ const badMcpKeys = Object.keys(mcpConfig).filter((key) => !isValidMcpServerEntry(mcpConfig[key]));
207
+ if (badMcpKeys.length > 0) {
208
+ printError(`Skipping ${componentName}: malformed MCP server config (${badMcpKeys.join(', ')}) — each server needs a "command" or "url" string`);
209
+ return null;
210
+ }
177
211
  const ownedFragment = {};
178
212
  for (const [key, value] of Object.entries(mcpConfig)) {
179
213
  if (key in servers) {
@@ -192,6 +226,11 @@ export async function mergeConfig(component, scope) {
192
226
  const lspConfig = config.lspServers
193
227
  ? config.lspServers
194
228
  : config;
229
+ const badLspKeys = Object.keys(lspConfig).filter((key) => !isValidLspServerEntry(lspConfig[key]));
230
+ if (badLspKeys.length > 0) {
231
+ printError(`Skipping ${componentName}: malformed LSP server config (${badLspKeys.join(', ')}) — each server needs a "command" string`);
232
+ return null;
233
+ }
195
234
  const ownedFragment = {};
196
235
  for (const [key, value] of Object.entries(lspConfig)) {
197
236
  if (key in servers) {
@@ -210,6 +249,11 @@ export async function mergeConfig(component, scope) {
210
249
  const hookConfig = config.hooks
211
250
  ? config.hooks
212
251
  : config;
252
+ const badEvents = Object.keys(hookConfig).filter((event) => !isValidHookEventHandlers(hookConfig[event]));
253
+ if (badEvents.length > 0) {
254
+ printError(`Skipping ${componentName}: malformed hooks config (${badEvents.join(', ')}) — each event needs an array of {hooks: [{type, ...}]} groups`);
255
+ return null;
256
+ }
213
257
  for (const [event, handlers] of Object.entries(hookConfig)) {
214
258
  if (!Array.isArray(handlers))
215
259
  continue;
package/dist/fetch.d.ts CHANGED
@@ -30,5 +30,11 @@ export declare function resolveMarketplaceUrl(input: string): string | null;
30
30
  * (collection-install.ts) instead of the flatten/download path.
31
31
  */
32
32
  export declare function isCollectionUrl(url: string): boolean;
33
+ /**
34
+ * Single-plugin wrapper marketplaces (/api/plugins/<slug>/marketplace.json)
35
+ * reference one whole plugin (source only) — like collections, they install
36
+ * via native delegation, not the flatten/download path.
37
+ */
38
+ export declare function isPluginWrapperUrl(url: string): boolean;
33
39
  export declare function fetchMarketplace(url: string): Promise<MarketplaceJSON | null>;
34
40
  export declare function flattenComponents(manifest: MarketplaceJSON): FlatComponent[];
package/dist/fetch.js CHANGED
@@ -1,4 +1,4 @@
1
- import { printError } from './output.js';
1
+ import { printError, printWarning } from './output.js';
2
2
  const BASE_URL = 'https://claudepluginhub.com';
3
3
  const ALLOWED_HOSTS = ['claudepluginhub.com', 'www.claudepluginhub.com'];
4
4
  export function resolveMarketplaceUrl(input) {
@@ -33,6 +33,11 @@ export function resolveMarketplaceUrl(input) {
33
33
  const [, userId, slug] = collectionMatch;
34
34
  return `${BASE_URL}/api/collections/${userId}/${slug}/marketplace.json`;
35
35
  }
36
+ // Short form: p/<slug> (single plugin via wrapper marketplace endpoint)
37
+ const pluginMatch = input.match(/^p\/([a-z0-9-]+)$/);
38
+ if (pluginMatch) {
39
+ return `${BASE_URL}/api/plugins/${pluginMatch[1]}/marketplace.json`;
40
+ }
36
41
  return null;
37
42
  }
38
43
  /**
@@ -43,6 +48,14 @@ export function resolveMarketplaceUrl(input) {
43
48
  export function isCollectionUrl(url) {
44
49
  return url.includes('/api/collections/');
45
50
  }
51
+ /**
52
+ * Single-plugin wrapper marketplaces (/api/plugins/<slug>/marketplace.json)
53
+ * reference one whole plugin (source only) — like collections, they install
54
+ * via native delegation, not the flatten/download path.
55
+ */
56
+ export function isPluginWrapperUrl(url) {
57
+ return url.includes('/api/plugins/');
58
+ }
46
59
  export async function fetchMarketplace(url) {
47
60
  try {
48
61
  // Ensure ?source=cli is present for install tracking
@@ -56,7 +69,7 @@ export async function fetchMarketplace(url) {
56
69
  });
57
70
  if (!response.ok) {
58
71
  if (response.status === 404) {
59
- printError('Collection not found. Check the identifier and try again.');
72
+ printError('Not found. Check the identifier and try again.');
60
73
  }
61
74
  else {
62
75
  printError(`HTTP ${response.status}: ${response.statusText}`);
@@ -77,16 +90,30 @@ export async function fetchMarketplace(url) {
77
90
  return null;
78
91
  }
79
92
  }
93
+ /**
94
+ * Marketplace-entry component paths are `./`-prefixed per the plugin spec
95
+ * (paths relative to the plugin root). Strip the prefix before prefix checks
96
+ * and GitHub API calls — the downloader works with bare repo-relative paths.
97
+ */
98
+ function stripDotSlash(path) {
99
+ return path.replace(/^\.\//, '');
100
+ }
80
101
  export function flattenComponents(manifest) {
81
102
  const components = [];
103
+ let skippedWholePlugin = 0;
82
104
  for (const plugin of manifest.plugins) {
83
105
  const repo = plugin.source.repo;
84
106
  // Whole-plugin references (git/git-subdir sources, no component arrays)
85
107
  // can't be cherry-picked; they belong to the collection install path.
86
- if (!repo)
108
+ if (!repo) {
109
+ printWarning(`Skipping "${plugin.name}" — whole-plugin reference (component install can't cherry-pick it)`);
110
+ skippedWholePlugin++;
87
111
  continue;
112
+ }
113
+ const before = components.length;
88
114
  if (plugin.commands) {
89
- for (const path of plugin.commands) {
115
+ for (const rawPath of plugin.commands) {
116
+ const path = stripDotSlash(rawPath);
90
117
  // Preserve full path under commands/ prefix, e.g. "commands/git/commit.md"
91
118
  const relPath = path.startsWith('commands/') ? path.slice('commands/'.length) : path;
92
119
  const name = relPath.replace(/\.md$/, '');
@@ -100,7 +127,8 @@ export function flattenComponents(manifest) {
100
127
  }
101
128
  }
102
129
  if (plugin.agents) {
103
- for (const path of plugin.agents) {
130
+ for (const rawPath of plugin.agents) {
131
+ const path = stripDotSlash(rawPath);
104
132
  const relPath = path.startsWith('agents/') ? path.slice('agents/'.length) : path;
105
133
  const name = relPath.replace(/\.md$/, '');
106
134
  components.push({
@@ -113,7 +141,8 @@ export function flattenComponents(manifest) {
113
141
  }
114
142
  }
115
143
  if (plugin.skills) {
116
- for (const path of plugin.skills) {
144
+ for (const rawPath of plugin.skills) {
145
+ const path = stripDotSlash(rawPath);
117
146
  // Skill name is the directory containing SKILL.md
118
147
  // e.g. "plugins/foo/skills/review/SKILL.md" -> "review"
119
148
  const withoutSkillMd = path.replace(/\/SKILL\.md$/, '');
@@ -132,7 +161,7 @@ export function flattenComponents(manifest) {
132
161
  source: repo,
133
162
  type: 'hook',
134
163
  componentName: `${plugin.name}-hooks`,
135
- sourcePath: typeof plugin.hooks === 'string' ? plugin.hooks : 'hooks/hooks.json',
164
+ sourcePath: typeof plugin.hooks === 'string' ? stripDotSlash(plugin.hooks) : 'hooks/hooks.json',
136
165
  inlineConfig: plugin.hooks,
137
166
  });
138
167
  }
@@ -141,7 +170,7 @@ export function flattenComponents(manifest) {
141
170
  source: repo,
142
171
  type: 'mcp',
143
172
  componentName: `${plugin.name}-mcp`,
144
- sourcePath: typeof plugin.mcpServers === 'string' ? plugin.mcpServers : '.mcp.json',
173
+ sourcePath: typeof plugin.mcpServers === 'string' ? stripDotSlash(plugin.mcpServers) : '.mcp.json',
145
174
  inlineConfig: plugin.mcpServers,
146
175
  });
147
176
  }
@@ -150,10 +179,16 @@ export function flattenComponents(manifest) {
150
179
  source: repo,
151
180
  type: 'lsp',
152
181
  componentName: `${plugin.name}-lsp`,
153
- sourcePath: typeof plugin.lspServers === 'string' ? plugin.lspServers : '.lsp.json',
182
+ sourcePath: typeof plugin.lspServers === 'string' ? stripDotSlash(plugin.lspServers) : '.lsp.json',
154
183
  inlineConfig: plugin.lspServers,
155
184
  });
156
185
  }
186
+ if (components.length === before) {
187
+ printWarning(`"${plugin.name}" contributed no installable components`);
188
+ }
189
+ }
190
+ if (skippedWholePlugin > 0) {
191
+ printWarning(`${skippedWholePlugin} whole-plugin entr${skippedWholePlugin === 1 ? 'y' : 'ies'} skipped — install those via \`claude plugin install\` or a collection`);
157
192
  }
158
193
  return components;
159
194
  }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { resolveMarketplaceUrl, fetchMarketplace, flattenComponents, isCollectionUrl } from './fetch.js';
2
+ import { resolveMarketplaceUrl, fetchMarketplace, flattenComponents, isCollectionUrl, isPluginWrapperUrl } from './fetch.js';
3
3
  import { checkboxPrompt, scopePrompt, confirmPrompt } from './prompts.js';
4
4
  import { runInstall } from './install.js';
5
5
  import { runUpdate } from './update.js';
@@ -33,14 +33,17 @@ Identifiers:
33
33
  owner/repo GitHub plugin or marketplace (via Claude Code)
34
34
  u/<userId>/<slug> ClaudePluginHub user plugin (component install)
35
35
  c/<userId>/<slug> ClaudePluginHub plugin collection (via Claude Code)
36
+ p/<slug> ClaudePluginHub plugin by slug (via Claude Code)
36
37
  https://claudepluginhub.com/api/user-plugins/.../marketplace.json
37
38
  https://claudepluginhub.com/api/collections/.../marketplace.json
39
+ https://claudepluginhub.com/api/plugins/<slug>/marketplace.json
38
40
 
39
41
  Install modes:
40
42
  owner/repo Full plugin install (via Claude Code plugin system)
41
43
  owner/repo --skill <path> Direct single-component install (skill, command, or agent)
42
44
  u/<userId>/<slug> Component install (no Claude Code required)
43
45
  c/<userId>/<slug> Whole-plugin collection install (requires Claude Code)
46
+ p/<slug> Single-plugin install via wrapper marketplace (requires Claude Code)
44
47
 
45
48
  Notes:
46
49
  - list shows all lock-backed installs (collections + direct components)
@@ -123,9 +126,12 @@ async function main() {
123
126
  }
124
127
  process.exit(0);
125
128
  }
126
- // Plugin-collection installs are native-managed (no lock entry)
127
- if (identifier.startsWith('c/') || identifier.includes('/api/collections/')) {
128
- print('Plugin collections are managed by Claude Code directly:');
129
+ // Plugin-collection and wrapper-plugin installs are native-managed (no lock entry)
130
+ if (identifier.startsWith('c/') ||
131
+ identifier.includes('/api/collections/') ||
132
+ identifier.startsWith('p/') ||
133
+ identifier.includes('/api/plugins/')) {
134
+ print('These installs are managed by Claude Code directly:');
129
135
  print(` ${DIM}claude plugin uninstall <plugin>${RESET}`);
130
136
  print(` ${DIM}claude plugin marketplace remove <marketplace-name>${RESET}`);
131
137
  print(` ${DIM}claude plugin marketplace list${RESET}`);
@@ -155,7 +161,7 @@ async function main() {
155
161
  if (!url) {
156
162
  printError(`Invalid identifier: ${identifier}`);
157
163
  print('');
158
- print(`Expected: owner/repo, u/<userId>/<slug>, c/<userId>/<slug>, or a claudepluginhub.com URL`);
164
+ print(`Expected: owner/repo, u/<userId>/<slug>, c/<userId>/<slug>, p/<slug>, or a claudepluginhub.com URL`);
159
165
  process.exit(1);
160
166
  }
161
167
  // Plugin collections reference whole plugins — install via native delegation
@@ -164,6 +170,12 @@ async function main() {
164
170
  await runCollectionInstall(url, yes, scopeOverride);
165
171
  process.exit(0);
166
172
  }
173
+ // Single-plugin wrapper marketplaces likewise install via native delegation
174
+ if (isPluginWrapperUrl(url)) {
175
+ const { runWrapperPluginInstall } = await import('./collection-install.js');
176
+ await runWrapperPluginInstall(url, yes, scopeOverride);
177
+ process.exit(0);
178
+ }
167
179
  // Derive the collection identifier from the input
168
180
  const collectionId = identifier.startsWith('http')
169
181
  ? extractIdentifierFromUrl(identifier)
@@ -11,5 +11,11 @@ export function isOwnerRepo(identifier) {
11
11
  // Reject segments that are purely dots (e.g. "..", ".")
12
12
  if (/^\.+$/.test(owner) || /^\.+$/.test(repo))
13
13
  return false;
14
+ // Reserved short-form prefixes: p/<slug> is owner/repo-SHAPED but means a
15
+ // ClaudePluginHub wrapper install (u/ and c/ are 3-segment, reserved for
16
+ // symmetry). Repos of the literal GitHub users "u"/"c"/"p" are not
17
+ // installable via the bare form — an acceptable, documented trade-off.
18
+ if (owner === 'u' || owner === 'c' || owner === 'p')
19
+ return false;
14
20
  return true;
15
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudepluginhub",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Install Claude Code components from ClaudePluginHub",
5
5
  "bin": {
6
6
  "claudepluginhub": "dist/index.js"