claudepluginhub 0.7.1 → 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/collection-install.d.ts +16 -0
- package/dist/collection-install.js +122 -0
- package/dist/fetch.d.ts +9 -1
- package/dist/fetch.js +18 -0
- package/dist/index.js +25 -4
- package/package.json +2 -2
|
@@ -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
|
+
}
|
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
|
|
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';
|
|
@@ -31,13 +31,16 @@ Commands:
|
|
|
31
31
|
|
|
32
32
|
Identifiers:
|
|
33
33
|
owner/repo GitHub plugin or marketplace (via Claude Code)
|
|
34
|
-
u/<userId>/<slug> ClaudePluginHub
|
|
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
39
|
Install modes:
|
|
38
40
|
owner/repo Full plugin install (via Claude Code plugin system)
|
|
39
41
|
owner/repo --skill <path> Direct single-component install (skill, command, or agent)
|
|
40
|
-
u/<userId>/<slug>
|
|
42
|
+
u/<userId>/<slug> Component install (no Claude Code required)
|
|
43
|
+
c/<userId>/<slug> Whole-plugin collection install (requires Claude Code)
|
|
41
44
|
|
|
42
45
|
Notes:
|
|
43
46
|
- list shows all lock-backed installs (collections + direct components)
|
|
@@ -120,6 +123,14 @@ async function main() {
|
|
|
120
123
|
}
|
|
121
124
|
process.exit(0);
|
|
122
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
|
+
}
|
|
123
134
|
await runRemove(identifier);
|
|
124
135
|
process.exit(0);
|
|
125
136
|
}
|
|
@@ -144,9 +155,15 @@ async function main() {
|
|
|
144
155
|
if (!url) {
|
|
145
156
|
printError(`Invalid identifier: ${identifier}`);
|
|
146
157
|
print('');
|
|
147
|
-
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`);
|
|
148
159
|
process.exit(1);
|
|
149
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
|
+
}
|
|
150
167
|
// Derive the collection identifier from the input
|
|
151
168
|
const collectionId = identifier.startsWith('http')
|
|
152
169
|
? extractIdentifierFromUrl(identifier)
|
|
@@ -218,6 +235,10 @@ function extractIdentifierFromUrl(url) {
|
|
|
218
235
|
if (match) {
|
|
219
236
|
return `u/${match[1]}/${match[2]}`;
|
|
220
237
|
}
|
|
238
|
+
const collectionMatch = url.match(/\/api\/collections\/([^/]+)\/([^/]+)/);
|
|
239
|
+
if (collectionMatch) {
|
|
240
|
+
return `c/${collectionMatch[1]}/${collectionMatch[2]}`;
|
|
241
|
+
}
|
|
221
242
|
return url;
|
|
222
243
|
}
|
|
223
244
|
main().catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudepluginhub",
|
|
3
|
-
"version": "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/
|
|
29
|
+
"url": "git+https://github.com/ClaudePluginHub/claudepluginhub.git",
|
|
30
30
|
"directory": "packages/cli"
|
|
31
31
|
},
|
|
32
32
|
"license": "MIT",
|