claudepluginhub 0.7.0 → 0.8.0

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.
package/dist/args.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Scope } from './prompts.js';
2
- type ComponentType = 'skill' | 'command' | 'agent';
2
+ declare const COMPONENT_FLAGS: readonly ["--skill", "--command", "--agent"];
3
+ export type ComponentType = (typeof COMPONENT_FLAGS)[number] extends `--${infer T}` ? T : never;
3
4
  export interface ParsedArgs {
4
5
  command: string;
5
6
  identifier: string | null;
@@ -0,0 +1,16 @@
1
+ import type { Scope } from './prompts.js';
2
+ /**
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 ...`.
15
+ */
16
+ export declare function runCollectionInstall(url: string, yes: boolean, scopeOverride: Scope | null): Promise<void>;
@@ -0,0 +1,122 @@
1
+ import { scopePrompt, checkboxPrompt } from './prompts.js';
2
+ import { fetchMarketplace } from './fetch.js';
3
+ import { checkClaudeCli, claudeMarketplaceAdd, claudePluginInstall, } from './native.js';
4
+ import { print, printStep, printSuccess, printFail, printError, BOLD, RESET, DIM, GREEN, YELLOW, } from './output.js';
5
+ /**
6
+ * Claude Code rejects marketplace names containing path separators, ".."
7
+ * sequences, or ".". Our API emits compliant names (cpd-c-<userId>-<slug>),
8
+ * but guard anyway so a bad manifest fails with a clear message instead of a
9
+ * cryptic native error.
10
+ */
11
+ function isInstallableMarketplaceName(name) {
12
+ return (name.length > 0 &&
13
+ !name.includes('/') &&
14
+ !name.includes('\\') &&
15
+ !name.includes('..') &&
16
+ name !== '.');
17
+ }
18
+ /**
19
+ * Install a plugin collection by delegating to Claude Code's native plugin
20
+ * system: `claude plugin marketplace add <url>` once, then
21
+ * `claude plugin install <name>@<marketplace>` per selected plugin.
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.
28
+ *
29
+ * Requires the `claude` binary (unlike the `u/` component install path).
30
+ * Native owns the installed state — manage with `claude plugin ...`.
31
+ */
32
+ export async function runCollectionInstall(url, yes, scopeOverride) {
33
+ if (!checkClaudeCli())
34
+ process.exit(1);
35
+ printStep('Fetching collection...');
36
+ const manifest = await fetchMarketplace(url);
37
+ if (!manifest) {
38
+ process.exit(1);
39
+ }
40
+ printSuccess(`"${manifest.name}" — ${manifest.plugins.length} plugin(s)`);
41
+ if (manifest.plugins.length === 0) {
42
+ printError('No plugins found in this collection.');
43
+ process.exit(1);
44
+ }
45
+ if (!isInstallableMarketplaceName(manifest.name)) {
46
+ printError(`This collection's marketplace name ("${manifest.name}") is not accepted by Claude Code. ` +
47
+ 'Please report this to claudepluginhub.com.');
48
+ process.exit(1);
49
+ }
50
+ // Plugin selection
51
+ let selectedPlugins = manifest.plugins;
52
+ if (!yes && manifest.plugins.length > 1) {
53
+ print('');
54
+ const items = manifest.plugins.map((p) => ({
55
+ label: p.name,
56
+ description: p.description ? `${DIM}${p.description}${RESET}` : undefined,
57
+ selected: true,
58
+ }));
59
+ const chosen = await checkboxPrompt('Select plugins to install:', items);
60
+ if (chosen === null) {
61
+ print('\nCancelled.');
62
+ process.exit(0);
63
+ }
64
+ selectedPlugins = chosen.map((i) => manifest.plugins[i]);
65
+ if (selectedPlugins.length === 0) {
66
+ printError('No plugins selected.');
67
+ process.exit(0);
68
+ }
69
+ }
70
+ // Scope picker
71
+ let scope = scopeOverride ?? 'project';
72
+ if (!yes && !scopeOverride) {
73
+ print('');
74
+ const chosenScope = await scopePrompt('project');
75
+ if (chosenScope === null) {
76
+ print('\nCancelled.');
77
+ process.exit(0);
78
+ }
79
+ scope = chosenScope;
80
+ }
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
84
+ // params (e.g. the one-shot ?source=cli tracking param) so native refreshes
85
+ // hit the canonical URL.
86
+ const registerUrl = new URL(url);
87
+ registerUrl.search = '';
88
+ print('');
89
+ printStep('Adding collection marketplace...');
90
+ const addResult = claudeMarketplaceAdd(registerUrl.toString(), scope);
91
+ if (!addResult.ok) {
92
+ printError(`Failed to add marketplace: ${addResult.output}`);
93
+ process.exit(1);
94
+ }
95
+ printSuccess(`Marketplace "${manifest.name}" added`);
96
+ // Install each selected plugin
97
+ let failures = 0;
98
+ for (const plugin of selectedPlugins) {
99
+ printStep(`Installing ${plugin.name}...`);
100
+ const result = claudePluginInstall(plugin.name, manifest.name, scope);
101
+ if (result.ok) {
102
+ printSuccess(plugin.name);
103
+ }
104
+ else {
105
+ printFail(plugin.name, result.output);
106
+ failures++;
107
+ }
108
+ }
109
+ print('');
110
+ if (failures === 0) {
111
+ print(`${GREEN}${BOLD}Done!${RESET} ${selectedPlugins.length} plugin(s) installed.`);
112
+ }
113
+ else {
114
+ print(`${YELLOW}${BOLD}Done.${RESET} ${selectedPlugins.length - failures} succeeded, ${failures} failed.`);
115
+ }
116
+ print('');
117
+ print(`${DIM}Manage with Claude Code:${RESET}`);
118
+ print(` ${DIM}claude plugin list${RESET}`);
119
+ print(` ${DIM}claude plugin uninstall <plugin>${RESET}`);
120
+ print(` ${DIM}claude plugin marketplace remove ${manifest.name}${RESET}`);
121
+ print('');
122
+ }
@@ -1,4 +1,3 @@
1
1
  import type { Scope } from './prompts.js';
2
- type ComponentType = 'skill' | 'command' | 'agent';
2
+ import type { ComponentType } from './args.js';
3
3
  export declare function runDirectComponentInstall(ownerRepo: string, componentType: ComponentType, repoPath: string, pluginPath: string, yes: boolean, scopeOverride: Scope | null): Promise<void>;
4
- export {};
@@ -7,7 +7,8 @@ import { fetchDefaultBranch, fetchTree } from './github.js';
7
7
  import { print, printStep, printSuccess, printError, BOLD, RESET, DIM, GREEN, } from './output.js';
8
8
  const DIRECT_SENTINEL = '';
9
9
  /**
10
- * Validate that pluginPath has the right extension for its type.
10
+ * Validate that pluginPath has the expected path suffix for its type
11
+ * (/SKILL.md for skills, .md for commands/agents).
11
12
  */
12
13
  function validatePathFormat(componentType, pluginPath) {
13
14
  if (componentType === 'skill') {
@@ -164,7 +165,7 @@ export async function runDirectComponentInstall(ownerRepo, componentType, repoPa
164
165
  };
165
166
  const result = await installComponent(component, scope, false);
166
167
  if (result.status !== 'installed') {
167
- printError(`Failed to install ${componentName}`);
168
+ printError(`Failed to install ${componentName}. Check the error messages above for details.`);
168
169
  process.exit(1);
169
170
  }
170
171
  // Step 9: Merge into lock file
package/dist/fetch.d.ts CHANGED
@@ -3,7 +3,9 @@ export interface MarketplacePlugin {
3
3
  name: string;
4
4
  source: {
5
5
  source: string;
6
- repo: string;
6
+ repo?: string;
7
+ url?: string;
8
+ path?: string;
7
9
  };
8
10
  strict: boolean;
9
11
  description?: string;
@@ -22,5 +24,11 @@ export interface MarketplaceJSON {
22
24
  plugins: MarketplacePlugin[];
23
25
  }
24
26
  export declare function resolveMarketplaceUrl(input: string): string | null;
27
+ /**
28
+ * Plugin collections reference whole plugins (source only), which the
29
+ * component downloader can't cherry-pick — they install via native delegation
30
+ * (collection-install.ts) instead of the flatten/download path.
31
+ */
32
+ export declare function isCollectionUrl(url: string): boolean;
25
33
  export declare function fetchMarketplace(url: string): Promise<MarketplaceJSON | null>;
26
34
  export declare function flattenComponents(manifest: MarketplaceJSON): FlatComponent[];
package/dist/fetch.js CHANGED
@@ -27,8 +27,22 @@ export function resolveMarketplaceUrl(input) {
27
27
  const [, userId, slug] = match;
28
28
  return `${BASE_URL}/api/user-plugins/${userId}/${slug}/marketplace.json?source=cli`;
29
29
  }
30
+ // Short form: c/<userId>/<slug> (plugin collection)
31
+ const collectionMatch = input.match(/^c\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)$/);
32
+ if (collectionMatch) {
33
+ const [, userId, slug] = collectionMatch;
34
+ return `${BASE_URL}/api/collections/${userId}/${slug}/marketplace.json`;
35
+ }
30
36
  return null;
31
37
  }
38
+ /**
39
+ * Plugin collections reference whole plugins (source only), which the
40
+ * component downloader can't cherry-pick — they install via native delegation
41
+ * (collection-install.ts) instead of the flatten/download path.
42
+ */
43
+ export function isCollectionUrl(url) {
44
+ return url.includes('/api/collections/');
45
+ }
32
46
  export async function fetchMarketplace(url) {
33
47
  try {
34
48
  // Ensure ?source=cli is present for install tracking
@@ -67,6 +81,10 @@ export function flattenComponents(manifest) {
67
81
  const components = [];
68
82
  for (const plugin of manifest.plugins) {
69
83
  const repo = plugin.source.repo;
84
+ // Whole-plugin references (git/git-subdir sources, no component arrays)
85
+ // can't be cherry-picked; they belong to the collection install path.
86
+ if (!repo)
87
+ continue;
70
88
  if (plugin.commands) {
71
89
  for (const path of plugin.commands) {
72
90
  // Preserve full path under commands/ prefix, e.g. "commands/git/commit.md"
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { resolveMarketplaceUrl, fetchMarketplace, flattenComponents } from './fetch.js';
2
+ import { resolveMarketplaceUrl, fetchMarketplace, flattenComponents, isCollectionUrl } 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';
@@ -8,7 +8,7 @@ import { runList } from './list.js';
8
8
  import { isOwnerRepo } from './detect.js';
9
9
  import { runGithubInstall, runGithubRemove } from './github-install.js';
10
10
  import { findWrapperScopes } from './wrapper.js';
11
- import { readLock } from './lock.js';
11
+ import { findDirectInstallScopes } from './scope-detect.js';
12
12
  import { parseArgs, validatePlugin, validateComponentFlag } from './args.js';
13
13
  import { print, printBanner, printStep, printSuccess, printError, DIM, RESET, GREEN, CYAN, YELLOW, } from './output.js';
14
14
  const TYPE_BADGES = {
@@ -25,17 +25,26 @@ function printUsage() {
25
25
  Commands:
26
26
  <identifier> Install from a source
27
27
  add <identifier> Same as above
28
- update [identifier] Update (u/ collections only)
29
- list List (u/ collections only)
28
+ update [identifier] Update installed collections
29
+ list List all installed collections
30
30
  remove <identifier> Remove
31
31
 
32
32
  Identifiers:
33
33
  owner/repo GitHub plugin or marketplace (via Claude Code)
34
- u/<userId>/<slug> ClaudePluginHub collection
34
+ u/<userId>/<slug> ClaudePluginHub user plugin (component install)
35
+ c/<userId>/<slug> ClaudePluginHub plugin collection (via Claude Code)
35
36
  https://claudepluginhub.com/api/user-plugins/.../marketplace.json
37
+ https://claudepluginhub.com/api/collections/.../marketplace.json
36
38
 
37
- Note: owner/repo installs use Claude Code's plugin system.
38
- - list/update only show u/ installs
39
+ Install modes:
40
+ owner/repo Full plugin install (via Claude Code plugin system)
41
+ owner/repo --skill <path> Direct single-component install (skill, command, or agent)
42
+ u/<userId>/<slug> Component install (no Claude Code required)
43
+ c/<userId>/<slug> Whole-plugin collection install (requires Claude Code)
44
+
45
+ Notes:
46
+ - list shows all lock-backed installs (collections + direct components)
47
+ - update applies to collections only; direct installs are skipped
39
48
  - Use \`claude plugin list\` for Claude Code plugins
40
49
  - Standalone: \`npx claudepluginhub remove owner/repo\` for cleanup
41
50
 
@@ -50,17 +59,6 @@ Options:
50
59
  -h, --help Show this help
51
60
  `);
52
61
  }
53
- function findDirectInstallScopes(identifier) {
54
- const found = [];
55
- for (const scope of ['project', 'local', 'user']) {
56
- const lock = readLock(scope);
57
- const collection = lock.collections[identifier];
58
- if (collection && collection.apiUrl === '') {
59
- found.push(scope);
60
- }
61
- }
62
- return found;
63
- }
64
62
  async function main() {
65
63
  const args = process.argv.slice(2);
66
64
  if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
@@ -125,6 +123,14 @@ async function main() {
125
123
  }
126
124
  process.exit(0);
127
125
  }
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
+ print(` ${DIM}claude plugin uninstall <plugin>${RESET}`);
130
+ print(` ${DIM}claude plugin marketplace remove <marketplace-name>${RESET}`);
131
+ print(` ${DIM}claude plugin marketplace list${RESET}`);
132
+ process.exit(0);
133
+ }
128
134
  await runRemove(identifier);
129
135
  process.exit(0);
130
136
  }
@@ -149,9 +155,15 @@ async function main() {
149
155
  if (!url) {
150
156
  printError(`Invalid identifier: ${identifier}`);
151
157
  print('');
152
- print(`Expected: owner/repo, u/<userId>/<slug>, or a claudepluginhub.com URL`);
158
+ print(`Expected: owner/repo, u/<userId>/<slug>, c/<userId>/<slug>, or a claudepluginhub.com URL`);
153
159
  process.exit(1);
154
160
  }
161
+ // Plugin collections reference whole plugins — install via native delegation
162
+ if (isCollectionUrl(url)) {
163
+ const { runCollectionInstall } = await import('./collection-install.js');
164
+ await runCollectionInstall(url, yes, scopeOverride);
165
+ process.exit(0);
166
+ }
155
167
  // Derive the collection identifier from the input
156
168
  const collectionId = identifier.startsWith('http')
157
169
  ? extractIdentifierFromUrl(identifier)
@@ -223,6 +235,10 @@ function extractIdentifierFromUrl(url) {
223
235
  if (match) {
224
236
  return `u/${match[1]}/${match[2]}`;
225
237
  }
238
+ const collectionMatch = url.match(/\/api\/collections\/([^/]+)\/([^/]+)/);
239
+ if (collectionMatch) {
240
+ return `c/${collectionMatch[1]}/${collectionMatch[2]}`;
241
+ }
226
242
  return url;
227
243
  }
228
244
  main().catch((err) => {
@@ -0,0 +1,2 @@
1
+ import type { Scope } from './prompts.js';
2
+ export declare function findDirectInstallScopes(identifier: string): Scope[];
@@ -0,0 +1,12 @@
1
+ import { readLock } from './lock.js';
2
+ export function findDirectInstallScopes(identifier) {
3
+ const found = [];
4
+ for (const scope of ['project', 'local', 'user']) {
5
+ const lock = readLock(scope);
6
+ const collection = lock.collections[identifier];
7
+ if (collection && collection.apiUrl === '') {
8
+ found.push(scope);
9
+ }
10
+ }
11
+ return found;
12
+ }
package/dist/update.js CHANGED
@@ -31,7 +31,10 @@ export async function runUpdate(identifier) {
31
31
  found = true;
32
32
  // Skip direct installs (apiUrl === '' sentinel)
33
33
  if (collection.apiUrl === '') {
34
- print(`${BOLD}${collection.identifier}${RESET} — direct install, re-run install command to update`);
34
+ print(`${BOLD}${collection.identifier}${RESET} — direct install, skipped`);
35
+ for (const comp of Object.values(collection.components)) {
36
+ print(` ${DIM}Re-install: npx claudepluginhub ${collection.identifier} --${comp.type} ${comp.sourcePath}${RESET}`);
37
+ }
35
38
  continue;
36
39
  }
37
40
  print(`${BOLD}Updating${RESET} ${collection.identifier}...`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudepluginhub",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Install Claude Code components from ClaudePluginHub",
5
5
  "bin": {
6
6
  "claudepluginhub": "dist/index.js"
@@ -26,7 +26,7 @@
26
26
  "homepage": "https://claudepluginhub.com",
27
27
  "repository": {
28
28
  "type": "git",
29
- "url": "git+https://github.com/heiberik/claudepluginhub.git",
29
+ "url": "git+https://github.com/ClaudePluginHub/claudepluginhub.git",
30
30
  "directory": "packages/cli"
31
31
  },
32
32
  "license": "MIT",