claudepluginhub 0.8.0 → 0.9.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/README.md CHANGED
@@ -11,8 +11,14 @@ npx claudepluginhub owner/repo
11
11
  # ClaudePluginHub collection
12
12
  npx claudepluginhub u/<userId>/<slug>
13
13
 
14
+ # ClaudePluginHub plugin by slug
15
+ npx claudepluginhub p/<slug>
16
+
14
17
  # Full URL
15
18
  npx claudepluginhub https://claudepluginhub.com/api/user-plugins/<userId>/<slug>/marketplace.json
19
+
20
+ # Recommend plugins for the current project
21
+ npx claudepluginhub recommend
16
22
  ```
17
23
 
18
24
  ## Identifier types
@@ -28,6 +34,10 @@ Installs a plugin or marketplace directly from a GitHub repository using Claude
28
34
 
29
35
  Installs from a ClaudePluginHub user-curated collection. Components are downloaded directly and tracked in a lock file.
30
36
 
37
+ ### `p/<slug>` (ClaudePluginHub)
38
+
39
+ Installs a single ClaudePluginHub plugin by its site slug via a wrapper marketplace (requires Claude Code).
40
+
31
41
  ### Full URL
32
42
 
33
43
  Same as `u/` form but with the full marketplace JSON URL.
@@ -40,8 +50,26 @@ npx claudepluginhub add <identifier> Same as above
40
50
  npx claudepluginhub update [identifier] Update (u/ collections only)
41
51
  npx claudepluginhub list List (u/ collections only)
42
52
  npx claudepluginhub remove <identifier> Remove
53
+ npx claudepluginhub recommend Recommend plugins for the current project
54
+ ```
55
+
56
+ ## Recommend
57
+
58
+ Run `npx claudepluginhub recommend` from a project root to get ranked plugin
59
+ recommendations for your detected stacks — no account, no setup.
60
+
61
+ ```bash
62
+ npx claudepluginhub recommend # top 10 for your project
63
+ npx claudepluginhub recommend --limit 20 # more results (1-50)
64
+ npx claudepluginhub recommend --json # raw JSON, pipeable
43
65
  ```
44
66
 
67
+ Detection reads dependency **names** from `package.json`, `requirements.txt`,
68
+ `pyproject.toml`, `Cargo.toml`, and `go.mod`, plus which known config files
69
+ exist (e.g. `next.config.*`, `tailwind.config.*`). **Privacy:** only dependency
70
+ names and allowlisted config-filename prefixes are sent — never file contents,
71
+ never arbitrary filenames.
72
+
45
73
  ## Examples
46
74
 
47
75
  ```bash
@@ -56,6 +84,8 @@ npx claudepluginhub vercel/next.js --plugin cache-components
56
84
  | `--plugin <name>` | Install a specific plugin from a marketplace repo |
57
85
  | `--yes, -y` | Skip prompts (install all, project scope) |
58
86
  | `--scope <scope>` | Set scope: `user`, `project` (default), `local` |
87
+ | `--limit <n>` | `recommend` only: number of results (1-50, default 10) |
88
+ | `--json` | `recommend` only: raw JSON output |
59
89
  | `-h, --help` | Show help |
60
90
 
61
91
  ## Lifecycle differences
package/dist/args.js CHANGED
@@ -75,7 +75,7 @@ export function parseArgs(argv) {
75
75
  process.exit(1);
76
76
  }
77
77
  // Filter out flags and their values
78
- const flagsWithValues = new Set(['--scope', '--plugin', '--source-path']);
78
+ const flagsWithValues = new Set(['--scope', '--plugin', '--source-path', '--limit']);
79
79
  for (const f of COMPONENT_FLAGS)
80
80
  flagsWithValues.add(f);
81
81
  const positional = argv.filter((a, i) => !a.startsWith('-') &&
@@ -85,6 +85,8 @@ export function parseArgs(argv) {
85
85
  // Route commands
86
86
  if (first === 'list')
87
87
  return { command: 'list', identifier: null, plugin, yes, scope, componentFlag };
88
+ if (first === 'recommend')
89
+ return { command: 'recommend', identifier: null, plugin, yes, scope, componentFlag };
88
90
  if (first === 'update')
89
91
  return { command: 'update', identifier: second, plugin, yes, scope, componentFlag };
90
92
  if (first === 'remove')
@@ -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
@@ -1,4 +1,5 @@
1
1
  import type { FlatComponent } from './download.js';
2
+ export declare const BASE_URL = "https://claudepluginhub.com";
2
3
  export interface MarketplacePlugin {
3
4
  name: string;
4
5
  source: {
@@ -30,5 +31,11 @@ export declare function resolveMarketplaceUrl(input: string): string | null;
30
31
  * (collection-install.ts) instead of the flatten/download path.
31
32
  */
32
33
  export declare function isCollectionUrl(url: string): boolean;
34
+ /**
35
+ * Single-plugin wrapper marketplaces (/api/plugins/<slug>/marketplace.json)
36
+ * reference one whole plugin (source only) — like collections, they install
37
+ * via native delegation, not the flatten/download path.
38
+ */
39
+ export declare function isPluginWrapperUrl(url: string): boolean;
33
40
  export declare function fetchMarketplace(url: string): Promise<MarketplaceJSON | null>;
34
41
  export declare function flattenComponents(manifest: MarketplaceJSON): FlatComponent[];
package/dist/fetch.js CHANGED
@@ -1,5 +1,5 @@
1
- import { printError } from './output.js';
2
- const BASE_URL = 'https://claudepluginhub.com';
1
+ import { printError, printWarning } from './output.js';
2
+ export const BASE_URL = 'https://claudepluginhub.com';
3
3
  const ALLOWED_HOSTS = ['claudepluginhub.com', 'www.claudepluginhub.com'];
4
4
  export function resolveMarketplaceUrl(input) {
5
5
  // Full URL
@@ -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';
@@ -28,19 +28,23 @@ Commands:
28
28
  update [identifier] Update installed collections
29
29
  list List all installed collections
30
30
  remove <identifier> Remove
31
+ recommend Recommend plugins for the current project
31
32
 
32
33
  Identifiers:
33
34
  owner/repo GitHub plugin or marketplace (via Claude Code)
34
35
  u/<userId>/<slug> ClaudePluginHub user plugin (component install)
35
36
  c/<userId>/<slug> ClaudePluginHub plugin collection (via Claude Code)
37
+ p/<slug> ClaudePluginHub plugin by slug (via Claude Code)
36
38
  https://claudepluginhub.com/api/user-plugins/.../marketplace.json
37
39
  https://claudepluginhub.com/api/collections/.../marketplace.json
40
+ https://claudepluginhub.com/api/plugins/<slug>/marketplace.json
38
41
 
39
42
  Install modes:
40
43
  owner/repo Full plugin install (via Claude Code plugin system)
41
44
  owner/repo --skill <path> Direct single-component install (skill, command, or agent)
42
45
  u/<userId>/<slug> Component install (no Claude Code required)
43
46
  c/<userId>/<slug> Whole-plugin collection install (requires Claude Code)
47
+ p/<slug> Single-plugin install via wrapper marketplace (requires Claude Code)
44
48
 
45
49
  Notes:
46
50
  - list shows all lock-backed installs (collections + direct components)
@@ -48,6 +52,12 @@ Notes:
48
52
  - Use \`claude plugin list\` for Claude Code plugins
49
53
  - Standalone: \`npx claudepluginhub remove owner/repo\` for cleanup
50
54
 
55
+ Recommend (reads local manifest dependency names + config filenames only —
56
+ never file contents):
57
+ recommend Ranked plugins for your detected stacks
58
+ recommend --limit 20 Number of results (1-50, default 10)
59
+ recommend --json Raw JSON output
60
+
51
61
  Options:
52
62
  --plugin <name> Install a specific plugin from a marketplace repo
53
63
  --skill <path> Install a single skill directly from a repo
@@ -70,6 +80,12 @@ async function main() {
70
80
  validatePlugin(parsed);
71
81
  validateComponentFlag(parsed);
72
82
  const { command, identifier, plugin, yes, scope: scopeOverride, componentFlag } = parsed;
83
+ // recommend owns its banner (suppressed for --json so output stays pipeable)
84
+ if (command === 'recommend') {
85
+ const { runRecommend } = await import('./recommend.js');
86
+ await runRecommend(args);
87
+ process.exit(0);
88
+ }
73
89
  printBanner();
74
90
  // Handle non-install commands
75
91
  if (command === 'list') {
@@ -123,9 +139,12 @@ async function main() {
123
139
  }
124
140
  process.exit(0);
125
141
  }
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:');
142
+ // Plugin-collection and wrapper-plugin installs are native-managed (no lock entry)
143
+ if (identifier.startsWith('c/') ||
144
+ identifier.includes('/api/collections/') ||
145
+ identifier.startsWith('p/') ||
146
+ identifier.includes('/api/plugins/')) {
147
+ print('These installs are managed by Claude Code directly:');
129
148
  print(` ${DIM}claude plugin uninstall <plugin>${RESET}`);
130
149
  print(` ${DIM}claude plugin marketplace remove <marketplace-name>${RESET}`);
131
150
  print(` ${DIM}claude plugin marketplace list${RESET}`);
@@ -155,7 +174,7 @@ async function main() {
155
174
  if (!url) {
156
175
  printError(`Invalid identifier: ${identifier}`);
157
176
  print('');
158
- print(`Expected: owner/repo, u/<userId>/<slug>, c/<userId>/<slug>, or a claudepluginhub.com URL`);
177
+ print(`Expected: owner/repo, u/<userId>/<slug>, c/<userId>/<slug>, p/<slug>, or a claudepluginhub.com URL`);
159
178
  process.exit(1);
160
179
  }
161
180
  // Plugin collections reference whole plugins — install via native delegation
@@ -164,6 +183,12 @@ async function main() {
164
183
  await runCollectionInstall(url, yes, scopeOverride);
165
184
  process.exit(0);
166
185
  }
186
+ // Single-plugin wrapper marketplaces likewise install via native delegation
187
+ if (isPluginWrapperUrl(url)) {
188
+ const { runWrapperPluginInstall } = await import('./collection-install.js');
189
+ await runWrapperPluginInstall(url, yes, scopeOverride);
190
+ process.exit(0);
191
+ }
167
192
  // Derive the collection identifier from the input
168
193
  const collectionId = identifier.startsWith('http')
169
194
  ? extractIdentifierFromUrl(identifier)
@@ -0,0 +1,26 @@
1
+ export interface RecommendFlags {
2
+ limit: number;
3
+ json: boolean;
4
+ }
5
+ export declare function parseRecommendFlags(argv: string[]): RecommendFlags;
6
+ export declare function parsePackageJsonDeps(content: string): string[];
7
+ export declare function parseRequirementsTxt(content: string): string[];
8
+ /**
9
+ * Line-based TOML walk (no TOML dependency): track the current `[section]`
10
+ * and collect what each section contributes. Regexes over whole sections
11
+ * break on inline arrays (`features = ["derive"]`), so never use those here.
12
+ */
13
+ export declare function parsePyprojectToml(content: string): string[];
14
+ export declare function parseCargoToml(content: string): string[];
15
+ export declare function parseGoMod(content: string): string[];
16
+ export interface ProjectSignals {
17
+ dependencies: string[];
18
+ files: string[];
19
+ }
20
+ /**
21
+ * Collect dependency names from known manifests in `cwd` plus telltale config
22
+ * filenames. Fail-soft per manifest: an unreadable or malformed file just
23
+ * contributes nothing (its filename still signals via `files`).
24
+ */
25
+ export declare function collectProjectSignals(cwd: string): ProjectSignals;
26
+ export declare function runRecommend(argv: string[]): Promise<void>;
@@ -0,0 +1,338 @@
1
+ import { readFileSync, readdirSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { BASE_URL } from './fetch.js';
4
+ import { print, printBanner, printStep, printError, BOLD, DIM, RESET, CYAN, YELLOW, } from './output.js';
5
+ /**
6
+ * `npx claudepluginhub recommend` — instant plugin recommendations for the
7
+ * current project. Reads local manifest dependency NAMES and telltale config
8
+ * FILENAMES (never file contents, never CLAUDE.md) and POSTs them to
9
+ * /api/recommend, where they resolve to vocabulary stacks server-side.
10
+ */
11
+ const RECOMMEND_URL = `${BASE_URL}/api/recommend?source=cli`;
12
+ /** Server-side body caps (mirrors the /api/recommend Zod schema). */
13
+ const MAX_DEPENDENCIES = 500;
14
+ const MAX_FILES = 200;
15
+ const MAX_DEP_LENGTH = 128;
16
+ const DEFAULT_LIMIT = 10;
17
+ const MAX_LIMIT = 50;
18
+ /**
19
+ * Telltale filename prefixes. Privacy allowlist: when a cwd entry matches a
20
+ * prefix, the PREFIX ITSELF is sent — never the raw basename — so only
21
+ * strings from this fixed list ever leave the machine (a suffix like
22
+ * `next.config.<project-codename>.ts` carries zero recommendation signal
23
+ * anyway, since the server also prefix-matches). Mirrors the server's
24
+ * dep→tech FILE_PREFIX_TO_TECH list
25
+ * (src/features/stack-recommendations/lib/dep-to-tech.ts); drift is fail-soft
26
+ * in both directions — the server ignores unknown names, and a missing prefix
27
+ * here just loses one detection signal.
28
+ */
29
+ const TELLTALE_PREFIXES = [
30
+ 'next.config',
31
+ 'nuxt.config',
32
+ 'svelte.config',
33
+ 'astro.config',
34
+ 'remix.config',
35
+ 'tailwind.config',
36
+ 'vite.config',
37
+ 'webpack.config',
38
+ 'playwright.config',
39
+ 'cypress.config',
40
+ 'jest.config',
41
+ 'vitest.config',
42
+ 'tsconfig',
43
+ 'cargo.toml',
44
+ 'go.mod',
45
+ 'go.sum',
46
+ 'pyproject.toml',
47
+ 'requirements.txt',
48
+ 'setup.py',
49
+ 'gemfile',
50
+ 'composer.json',
51
+ 'build.gradle',
52
+ 'pom.xml',
53
+ 'mix.exs',
54
+ 'dockerfile',
55
+ 'docker-compose',
56
+ 'pnpm-lock.yaml',
57
+ 'yarn.lock',
58
+ 'package-lock.json',
59
+ 'package.json',
60
+ 'deno.json',
61
+ 'bun.lockb',
62
+ 'terraform.tf',
63
+ 'main.tf',
64
+ 'helmfile',
65
+ 'pubspec.yaml',
66
+ 'project.godot',
67
+ ];
68
+ export function parseRecommendFlags(argv) {
69
+ const json = argv.includes('--json');
70
+ let limit = DEFAULT_LIMIT;
71
+ const limitIdx = argv.indexOf('--limit');
72
+ if (limitIdx !== -1) {
73
+ const val = argv[limitIdx + 1];
74
+ if (!val || val.startsWith('-')) {
75
+ printError('Missing value for --limit');
76
+ process.exit(1);
77
+ }
78
+ const parsed = Number(val);
79
+ if (!Number.isInteger(parsed) || parsed < 1 || parsed > MAX_LIMIT) {
80
+ printError(`Invalid --limit "${val}". Must be an integer 1-${MAX_LIMIT}`);
81
+ process.exit(1);
82
+ }
83
+ limit = parsed;
84
+ }
85
+ return { limit, json };
86
+ }
87
+ /** Strip a Python requirement spec down to the bare package name. */
88
+ function pythonDepName(spec) {
89
+ return spec.trim().split(/[=<>!~;\[\s]/)[0].trim();
90
+ }
91
+ export function parsePackageJsonDeps(content) {
92
+ try {
93
+ const pkg = JSON.parse(content);
94
+ return [
95
+ ...Object.keys(pkg.dependencies ?? {}),
96
+ ...Object.keys(pkg.devDependencies ?? {}),
97
+ ];
98
+ }
99
+ catch {
100
+ return [];
101
+ }
102
+ }
103
+ export function parseRequirementsTxt(content) {
104
+ const names = [];
105
+ for (const rawLine of content.split('\n')) {
106
+ const line = rawLine.trim();
107
+ // Skip comments, pip options (-r/-e/--hash …), and URL/path requirements.
108
+ if (!line || line.startsWith('#') || line.startsWith('-'))
109
+ continue;
110
+ if (line.includes('://') || line.startsWith('.') || line.startsWith('/'))
111
+ continue;
112
+ const name = pythonDepName(line);
113
+ if (name)
114
+ names.push(name);
115
+ }
116
+ return names;
117
+ }
118
+ /**
119
+ * Line-based TOML walk (no TOML dependency): track the current `[section]`
120
+ * and collect what each section contributes. Regexes over whole sections
121
+ * break on inline arrays (`features = ["derive"]`), so never use those here.
122
+ */
123
+ export function parsePyprojectToml(content) {
124
+ const names = [];
125
+ let section = '';
126
+ let inDepsArray = false;
127
+ const pushQuoted = (line) => {
128
+ for (const quoted of line.matchAll(/["']([^"']+)["']/g)) {
129
+ const name = pythonDepName(quoted[1]);
130
+ if (name)
131
+ names.push(name);
132
+ }
133
+ };
134
+ // A `]` inside a quoted spec (extras: "uvicorn[standard]>=0.20") must not
135
+ // close the array — strip quoted segments before checking.
136
+ const closesArray = (fragment) => fragment.replace(/["'][^"']*["']/g, '').includes(']');
137
+ for (const line of content.split('\n')) {
138
+ const header = line.match(/^\s*\[(.+?)\]\s*$/);
139
+ if (header) {
140
+ section = header[1];
141
+ inDepsArray = false;
142
+ continue;
143
+ }
144
+ // PEP 621 arrays: [project] dependencies = [...], every key of
145
+ // [project.optional-dependencies], and PEP 735 [dependency-groups].
146
+ const isArraySection = section === 'project' ||
147
+ section === 'project.optional-dependencies' ||
148
+ section === 'dependency-groups';
149
+ if (isArraySection) {
150
+ if (inDepsArray) {
151
+ pushQuoted(line);
152
+ if (closesArray(line))
153
+ inDepsArray = false;
154
+ continue;
155
+ }
156
+ const assign = line.match(/^\s*([\w".-]+)\s*=\s*\[(.*)$/);
157
+ if (assign && (section !== 'project' || assign[1] === 'dependencies')) {
158
+ pushQuoted(assign[2]);
159
+ inDepsArray = !closesArray(assign[2]);
160
+ }
161
+ continue;
162
+ }
163
+ // Poetry tables: keys under [tool.poetry.dependencies] (+ group variants).
164
+ if (/^tool\.poetry(\.group\.[\w-]+)?\.(dev-)?dependencies$/.test(section)) {
165
+ const key = line.split('=')[0].trim().replace(/^["']|["']$/g, '');
166
+ if (key && !key.startsWith('#') && key !== 'python')
167
+ names.push(key);
168
+ }
169
+ }
170
+ return names;
171
+ }
172
+ export function parseCargoToml(content) {
173
+ const names = [];
174
+ let inDepSection = false;
175
+ for (const line of content.split('\n')) {
176
+ const header = line.match(/^\s*\[(.+?)\]\s*$/);
177
+ if (header) {
178
+ // [dependencies], [dev-dependencies], [workspace.dependencies],
179
+ // [target.'cfg(unix)'.dependencies], ...
180
+ inDepSection = /(^|\.)(dev-|build-)?dependencies$/.test(header[1]);
181
+ continue;
182
+ }
183
+ if (!inDepSection)
184
+ continue;
185
+ const key = line.split('=')[0].trim();
186
+ if (key && !key.startsWith('#'))
187
+ names.push(key);
188
+ }
189
+ return names;
190
+ }
191
+ export function parseGoMod(content) {
192
+ const names = [];
193
+ const requireBlockRe = /require\s*\(([^)]*)\)/g;
194
+ const modulePathRe = /^\s*([\w.\-/]+)\s+v/;
195
+ for (const match of content.matchAll(requireBlockRe)) {
196
+ for (const line of match[1].split('\n')) {
197
+ const m = line.match(modulePathRe);
198
+ if (m)
199
+ names.push(m[1]);
200
+ }
201
+ }
202
+ // Single-line form: require example.com/pkg v1.2.3
203
+ for (const line of content.split('\n')) {
204
+ const m = line.match(/^require\s+([\w.\-/]+)\s+v/);
205
+ if (m)
206
+ names.push(m[1]);
207
+ }
208
+ return names;
209
+ }
210
+ const MANIFEST_PARSERS = [
211
+ ['package.json', parsePackageJsonDeps],
212
+ ['requirements.txt', parseRequirementsTxt],
213
+ ['pyproject.toml', parsePyprojectToml],
214
+ ['Cargo.toml', parseCargoToml],
215
+ ['go.mod', parseGoMod],
216
+ ];
217
+ /**
218
+ * Collect dependency names from known manifests in `cwd` plus telltale config
219
+ * filenames. Fail-soft per manifest: an unreadable or malformed file just
220
+ * contributes nothing (its filename still signals via `files`).
221
+ */
222
+ export function collectProjectSignals(cwd) {
223
+ let entries;
224
+ try {
225
+ entries = readdirSync(cwd);
226
+ }
227
+ catch {
228
+ return { dependencies: [], files: [] };
229
+ }
230
+ // Send the matched allowlist prefix, not the raw basename (see the
231
+ // TELLTALE_PREFIXES privacy note).
232
+ const matchedPrefixes = new Set();
233
+ for (const name of entries) {
234
+ const lower = name.toLowerCase();
235
+ for (const prefix of TELLTALE_PREFIXES) {
236
+ if (lower.startsWith(prefix))
237
+ matchedPrefixes.add(prefix);
238
+ }
239
+ }
240
+ const files = [...matchedPrefixes].slice(0, MAX_FILES);
241
+ const dependencies = new Set();
242
+ for (const [filename, parse] of MANIFEST_PARSERS) {
243
+ if (!entries.includes(filename))
244
+ continue;
245
+ let content;
246
+ try {
247
+ content = readFileSync(join(cwd, filename), 'utf8');
248
+ }
249
+ catch {
250
+ continue;
251
+ }
252
+ for (const dep of parse(content)) {
253
+ if (dep.length <= MAX_DEP_LENGTH)
254
+ dependencies.add(dep);
255
+ }
256
+ }
257
+ return { dependencies: [...dependencies].slice(0, MAX_DEPENDENCIES), files };
258
+ }
259
+ function formatCount(n) {
260
+ return n >= 1000 ? `${(n / 1000).toFixed(1)}k` : String(n);
261
+ }
262
+ function truncate(text, max) {
263
+ return text.length > max ? `${text.slice(0, max - 1).trimEnd()}…` : text;
264
+ }
265
+ export async function runRecommend(argv) {
266
+ const { limit, json } = parseRecommendFlags(argv);
267
+ if (!json)
268
+ printBanner();
269
+ const signals = collectProjectSignals(process.cwd());
270
+ if (signals.dependencies.length === 0 && signals.files.length === 0) {
271
+ printError('No project manifests found in the current directory.\n' +
272
+ `Run from a project root, or browse ${BASE_URL}/tools/for-your-project`);
273
+ process.exit(1);
274
+ }
275
+ if (!json) {
276
+ printStep(`Detected ${signals.dependencies.length} dependencies, ${signals.files.length} project files`);
277
+ }
278
+ let response;
279
+ try {
280
+ response = await fetch(RECOMMEND_URL, {
281
+ method: 'POST',
282
+ headers: { 'content-type': 'application/json' },
283
+ body: JSON.stringify({
284
+ dependencies: signals.dependencies,
285
+ files: signals.files,
286
+ limit,
287
+ }),
288
+ signal: AbortSignal.timeout(15_000),
289
+ });
290
+ }
291
+ catch (err) {
292
+ printError(`Network error: ${err.message}`);
293
+ process.exit(1);
294
+ }
295
+ if (!response.ok) {
296
+ if (response.status === 429) {
297
+ printError('Rate limit exceeded. Please wait a few minutes and try again.');
298
+ }
299
+ else {
300
+ const message = await response
301
+ .json()
302
+ .then((body) => body.error)
303
+ .catch(() => null);
304
+ printError(message ?? `HTTP ${response.status}: ${response.statusText}`);
305
+ }
306
+ process.exit(1);
307
+ }
308
+ const body = (await response.json());
309
+ if (json) {
310
+ print(JSON.stringify(body, null, 2));
311
+ return;
312
+ }
313
+ if (body.results.length === 0) {
314
+ print('');
315
+ print(`No recommendations yet for: ${body.stacks.join(', ')}`);
316
+ print(`${DIM}Browse plugins at ${BASE_URL}/plugins${RESET}`);
317
+ return;
318
+ }
319
+ print('');
320
+ print(`${BOLD}Recommended for:${RESET} ${CYAN}${body.stacks.join(' + ')}${RESET}`);
321
+ if (body.droppedStacks && body.droppedStacks.length > 0) {
322
+ print(`${DIM}(also detected: ${body.droppedStacks.join(', ')} — one request fuses at most ${body.stacks.length} stacks)${RESET}`);
323
+ }
324
+ print('');
325
+ body.results.forEach((item, i) => {
326
+ const rank = `${String(i + 1).padStart(2)}.`;
327
+ const stars = item.starCount > 0 ? ` ${YELLOW}★ ${formatCount(item.starCount)}${RESET}` : '';
328
+ print(`${BOLD}${rank} ${item.name}${RESET}${stars}`);
329
+ if (item.description) {
330
+ print(` ${DIM}${truncate(item.description, 90)}${RESET}`);
331
+ }
332
+ print(` ${CYAN}${item.install.command}${RESET}`);
333
+ print('');
334
+ });
335
+ // Link the always-live picker page, not /for/[stack] — low-coverage stacks
336
+ // (below the min-content gate) 404 there while the API still serves them.
337
+ print(`${DIM}Refine stacks: ${BASE_URL}/tools/for-your-project${RESET}`);
338
+ }
@@ -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.9.0",
4
4
  "description": "Install Claude Code components from ClaudePluginHub",
5
5
  "bin": {
6
6
  "claudepluginhub": "dist/index.js"