claudepluginhub 0.16.1 → 0.18.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.
Files changed (55) hide show
  1. package/README.md +36 -2
  2. package/dist/args.js +0 -6
  3. package/dist/collection-install.d.ts +4 -23
  4. package/dist/collection-install.js +9 -45
  5. package/dist/component-install.js +7 -29
  6. package/dist/detect.d.ts +0 -2
  7. package/dist/detect.js +3 -7
  8. package/dist/doctor/claude-source.d.ts +4 -6
  9. package/dist/doctor/claude-source.js +1 -2
  10. package/dist/doctor/color.d.ts +0 -1
  11. package/dist/doctor/color.js +0 -1
  12. package/dist/doctor/equivalence.d.ts +1 -1
  13. package/dist/doctor/equivalence.js +68 -149
  14. package/dist/doctor/estimate.js +12 -61
  15. package/dist/doctor/html-report.d.ts +1 -6
  16. package/dist/doctor/html-report.js +43 -116
  17. package/dist/doctor/inventory.d.ts +10 -24
  18. package/dist/doctor/inventory.js +29 -63
  19. package/dist/doctor/overlap.d.ts +3 -6
  20. package/dist/doctor/render.js +20 -38
  21. package/dist/doctor/report.d.ts +7 -16
  22. package/dist/doctor/report.js +3 -6
  23. package/dist/doctor/rules.d.ts +29 -16
  24. package/dist/doctor/rules.js +86 -26
  25. package/dist/doctor/run.d.ts +1 -1
  26. package/dist/doctor/run.js +13 -8
  27. package/dist/doctor/sanitize.d.ts +0 -8
  28. package/dist/doctor/sanitize.js +1 -6
  29. package/dist/doctor/select.d.ts +10 -25
  30. package/dist/doctor/select.js +2 -3
  31. package/dist/download.d.ts +1 -6
  32. package/dist/download.js +4 -14
  33. package/dist/fetch.d.ts +2 -8
  34. package/dist/fetch.js +6 -21
  35. package/dist/github-install.js +1 -12
  36. package/dist/index.js +14 -22
  37. package/dist/install.js +1 -2
  38. package/dist/mcp/server.d.ts +25 -0
  39. package/dist/mcp/server.js +103 -0
  40. package/dist/mcp/tools.d.ts +73 -0
  41. package/dist/mcp/tools.js +231 -0
  42. package/dist/output.d.ts +0 -5
  43. package/dist/output.js +0 -12
  44. package/dist/prompts.d.ts +3 -10
  45. package/dist/prompts.js +5 -20
  46. package/dist/recommend.d.ts +51 -66
  47. package/dist/recommend.js +59 -132
  48. package/dist/remove.d.ts +1 -1
  49. package/dist/remove.js +5 -10
  50. package/dist/update.js +1 -5
  51. package/dist/validation.d.ts +0 -5
  52. package/dist/validation.js +3 -10
  53. package/dist/wrapper.d.ts +0 -1
  54. package/dist/wrapper.js +1 -8
  55. package/package.json +1 -1
package/dist/recommend.js CHANGED
@@ -6,17 +6,12 @@ import { installPluginFromManifest } from './collection-install.js';
6
6
  import { recommendPrompt, scopePrompt, confirmPrompt } from './prompts.js';
7
7
  import { print, printBanner, printStep, printSuccess, printFail, printError, BOLD, DIM, RESET, CYAN, YELLOW, } from './output.js';
8
8
  /**
9
- * `npx claudepluginhub recommend` — instant plugin recommendations for the
10
- * current project. Reads local manifest dependency NAMES and telltale config
11
- * FILENAMES (never file contents, never CLAUDE.md) and POSTs them to
12
- * /api/recommend, where they resolve to vocabulary stacks server-side.
9
+ * Sends only manifest dependency NAMES and allowlisted config-filename
10
+ * prefixes (never file contents) to /api/recommend.
13
11
  */
14
12
  /**
15
- * Analytics source tag sent as `?source=`. Default `cli`; the Claude Code
16
- * plugin (which wraps this command) passes `--source plugin` so plugin-driven
17
- * usage stays separable from direct CLI usage in readouts. Allowlisted here
18
- * AND server-side (`resolveSource`); unknown values are rejected at parse so
19
- * a typo can't silently degrade to the server's `web` fallback.
13
+ * `?source=` analytics tag, allowlisted here and server-side (`resolveSource`).
14
+ * Unknown values are rejected so a typo can't degrade to the server's `web` fallback.
20
15
  */
21
16
  const RECOMMEND_SOURCES = ['cli', 'plugin'];
22
17
  function recommendUrl(source) {
@@ -26,32 +21,19 @@ function recommendUrl(source) {
26
21
  const MAX_DEPENDENCIES = 500;
27
22
  const MAX_FILES = 200;
28
23
  const MAX_DEP_LENGTH = 128;
29
- /**
30
- * `--limit` is recommendations PER detected stack: the output is grouped into a
31
- * "For {Stack}:" section per stack, not one fused list. 4 keeps each section
32
- * tight while covering the project's main stacks.
33
- */
34
- const DEFAULT_LIMIT = 4;
24
+ /** `--limit` is per detected stack, not a total. */
25
+ export const DEFAULT_LIMIT = 4;
35
26
  const MAX_LIMIT = 50;
36
27
  /**
37
- * Hard cap on plugins selectable in one interactive recommend run. Deliberate
38
- * selection-safety bound: the selector has no select-all and every item starts
39
- * unchecked, so a run can never bulk-install a 20-item recommendation list.
40
- * Coupled surfaces when raising: the server's MAX_OUTCOMES cap
41
- * (/api/recommend/outcome — must deploy FIRST, or over-cap outcome reports
42
- * silently schema-reject) and the "up to 5" literal in index.ts help text.
28
+ * Selection-safety cap per interactive run. Raising it requires deploying the
29
+ * server's MAX_OUTCOMES cap (/api/recommend/outcome) FIRST, or over-cap reports
30
+ * silently schema-reject; also update "up to 5" in index.ts help text.
43
31
  */
44
32
  export const RECOMMEND_MAX_SELECTIONS = 5;
45
33
  /**
46
- * Telltale filename prefixes. Privacy allowlist: when a cwd entry matches a
47
- * prefix, the PREFIX ITSELF is sent — never the raw basename — so only
48
- * strings from this fixed list ever leave the machine (a suffix like
49
- * `next.config.<project-codename>.ts` carries zero recommendation signal
50
- * anyway, since the server also prefix-matches). Mirrors the server's
51
- * dep→tech FILE_PREFIX_TO_TECH list
52
- * (src/features/stack-recommendations/lib/dep-to-tech.ts); drift is fail-soft
53
- * in both directions — the server ignores unknown names, and a missing prefix
54
- * here just loses one detection signal.
34
+ * Privacy allowlist: a matching cwd entry sends the PREFIX, never the raw
35
+ * basename. Mirrors FILE_PREFIX_TO_TECH in
36
+ * src/features/stack-recommendations/lib/dep-to-tech.ts (drift is fail-soft).
55
37
  */
56
38
  const TELLTALE_PREFIXES = [
57
39
  'next.config',
@@ -141,7 +123,7 @@ export function parseRequirementsTxt(content) {
141
123
  const names = [];
142
124
  for (const rawLine of content.split('\n')) {
143
125
  const line = rawLine.trim();
144
- // Skip comments, pip options (-r/-e/--hash …), and URL/path requirements.
126
+ // Skip comments, pip options (-r/-e/--hash …) and URL/path requirements.
145
127
  if (!line || line.startsWith('#') || line.startsWith('-'))
146
128
  continue;
147
129
  if (line.includes('://') || line.startsWith('.') || line.startsWith('/'))
@@ -152,11 +134,7 @@ export function parseRequirementsTxt(content) {
152
134
  }
153
135
  return names;
154
136
  }
155
- /**
156
- * Line-based TOML walk (no TOML dependency): track the current `[section]`
157
- * and collect what each section contributes. Regexes over whole sections
158
- * break on inline arrays (`features = ["derive"]`), so never use those here.
159
- */
137
+ /** Line-based TOML walk: whole-section regexes break on inline arrays (`features = ["derive"]`). */
160
138
  export function parsePyprojectToml(content) {
161
139
  const names = [];
162
140
  let section = '';
@@ -251,11 +229,7 @@ const MANIFEST_PARSERS = [
251
229
  ['Cargo.toml', parseCargoToml],
252
230
  ['go.mod', parseGoMod],
253
231
  ];
254
- /**
255
- * Collect dependency names from known manifests in `cwd` plus telltale config
256
- * filenames. Fail-soft per manifest: an unreadable or malformed file just
257
- * contributes nothing (its filename still signals via `files`).
258
- */
232
+ /** Fail-soft per manifest: an unreadable or malformed file contributes no dependencies. */
259
233
  export function collectProjectSignals(cwd) {
260
234
  let entries;
261
235
  try {
@@ -264,8 +238,6 @@ export function collectProjectSignals(cwd) {
264
238
  catch {
265
239
  return { dependencies: [], files: [] };
266
240
  }
267
- // Send the matched allowlist prefix, not the raw basename (see the
268
- // TELLTALE_PREFIXES privacy note).
269
241
  const matchedPrefixes = new Set();
270
242
  for (const name of entries) {
271
243
  const lower = name.toLowerCase();
@@ -299,12 +271,7 @@ function formatCount(n) {
299
271
  function truncate(text, max) {
300
272
  return text.length > max ? `${text.slice(0, max - 1).trimEnd()}…` : text;
301
273
  }
302
- /**
303
- * Prettify a vocabulary stack tag for a section header. This is a curated subset
304
- * of the site's `formatStackName` special-cases (the CLI can't import site
305
- * types, so it's hand-kept — not a full mirror, and may lag/drift slightly);
306
- * anything not listed falls back to title-casing the hyphen/space tokens.
307
- */
274
+ /** Hand-kept subset of the site's `formatStackName` special cases; the rest are title-cased. */
308
275
  const STACK_LABELS = {
309
276
  nextjs: 'Next.js',
310
277
  nuxt: 'Nuxt',
@@ -344,12 +311,9 @@ function formatStackLabel(stack) {
344
311
  .join(' ');
345
312
  }
346
313
  /**
347
- * Quiet per-item evidence line. Hand-synced mini twin of the site's
348
- * `buildEvidenceLine` (src/features/stack-recommendations/lib/display.ts —
349
- * not importable across the package boundary): same signal priority
350
- * (lift > reuse > co-copy > copy clicks), same honesty thresholds, same
351
- * ≤2-signal cap, and the same copy-integrity rule — install-derived numbers
352
- * are copy-click proxies, never described as installs.
314
+ * Hand-synced twin of `buildEvidenceLine` in
315
+ * src/features/stack-recommendations/lib/display.ts (same priority, thresholds
316
+ * and cap). Install-derived numbers are copy clicks — never call them installs.
353
317
  */
354
318
  const EVIDENCE_MIN_LIFT = 1.5;
355
319
  const EVIDENCE_MIN_REUSE = 2;
@@ -366,7 +330,6 @@ export function buildEvidenceLine(evidence, stackLabel) {
366
330
  signals.push(`components reused in ${evidence.reuseCount} plugins`);
367
331
  }
368
332
  if (Array.isArray(evidence.coInstalledWith) && evidence.coInstalledWith.length > 0) {
369
- // Prefer the index-aligned display name (absent on older servers/rows).
370
333
  const coName = Array.isArray(evidence.coInstalledNames)
371
334
  ? evidence.coInstalledNames[0]
372
335
  : undefined;
@@ -379,27 +342,11 @@ export function buildEvidenceLine(evidence, stackLabel) {
379
342
  return null;
380
343
  return signals.slice(0, EVIDENCE_MAX_SIGNALS).join(' · ');
381
344
  }
382
- /**
383
- * "⚠ runs code" marker. Strictly the server-derived `runsCode` field — never
384
- * inferred from componentTypes (see the field doc: bin is unrepresentable
385
- * there, so inference under-warns).
386
- */
387
345
  export function runsCodeFlag(item) {
388
346
  return item.runsCode === true;
389
347
  }
390
- export async function runRecommend(argv) {
391
- const { limit, json, source } = parseRecommendFlags(argv);
392
- if (!json)
393
- printBanner();
394
- const signals = collectProjectSignals(process.cwd());
395
- if (signals.dependencies.length === 0 && signals.files.length === 0) {
396
- printError('No project manifests found in the current directory.\n' +
397
- `Run from a project root, or browse ${BASE_URL}/tools/for-your-project`);
398
- process.exit(1);
399
- }
400
- if (!json) {
401
- printStep(`Detected ${signals.dependencies.length} dependencies, ${signals.files.length} project files`);
402
- }
348
+ /** POSTs the signals to /api/recommend. Never prints or exits, so the MCP server can reuse it. */
349
+ export async function fetchRecommendations(signals, limit, source) {
403
350
  let response;
404
351
  try {
405
352
  response = await fetch(recommendUrl(source), {
@@ -414,32 +361,44 @@ export async function runRecommend(argv) {
414
361
  });
415
362
  }
416
363
  catch (err) {
417
- printError(`Network error: ${err.message}`);
418
- process.exit(1);
364
+ return { ok: false, error: `Network error: ${err.message}` };
419
365
  }
420
366
  if (!response.ok) {
421
367
  if (response.status === 429) {
422
- printError('Rate limit exceeded. Please wait a few minutes and try again.');
423
- }
424
- else {
425
- const message = await response
426
- .json()
427
- .then((body) => body.error)
428
- .catch(() => null);
429
- printError(message ?? `HTTP ${response.status}: ${response.statusText}`);
368
+ return { ok: false, error: 'Rate limit exceeded. Please wait a few minutes and try again.' };
430
369
  }
370
+ const message = await response
371
+ .json()
372
+ .then((body) => body.error)
373
+ .catch(() => null);
374
+ return { ok: false, error: message ?? `HTTP ${response.status}: ${response.statusText}` };
375
+ }
376
+ return { ok: true, body: (await response.json()) };
377
+ }
378
+ export async function runRecommend(argv) {
379
+ const { limit, json, source } = parseRecommendFlags(argv);
380
+ if (!json)
381
+ printBanner();
382
+ const signals = collectProjectSignals(process.cwd());
383
+ if (signals.dependencies.length === 0 && signals.files.length === 0) {
384
+ printError('No project manifests found in the current directory.\n' +
385
+ `Run from a project root, or browse ${BASE_URL}/tools/for-your-project`);
386
+ process.exit(1);
387
+ }
388
+ if (!json) {
389
+ printStep(`Detected ${signals.dependencies.length} dependencies, ${signals.files.length} project files`);
390
+ }
391
+ const fetched = await fetchRecommendations(signals, limit, source);
392
+ if (!fetched.ok) {
393
+ printError(fetched.error);
431
394
  process.exit(1);
432
395
  }
433
- const body = (await response.json());
396
+ const body = fetched.body;
434
397
  if (json) {
435
398
  print(JSON.stringify(body, null, 2));
436
399
  return;
437
400
  }
438
- // A well-formed 200 always carries `sections` (the POST contract). A missing
439
- // array is a server contract break / version skew — NOT "no data" — so surface
440
- // it rather than masking it as the reassuring empty state below (mirrors the
441
- // site picker, which lets a missing `results` throw into its error state so a
442
- // broken response never reads as "your stack is unsupported").
401
+ // Missing `sections` is a contract break, not "no data": never show it as the empty state.
443
402
  if (!Array.isArray(body.sections)) {
444
403
  printError('Unexpected response from the recommend API (missing sections). Please try again later.');
445
404
  process.exit(1);
@@ -458,25 +417,16 @@ export async function runRecommend(argv) {
458
417
  print(`${DIM}(also detected: ${body.droppedStacks.join(', ')} — showing your ${body.stacks.length} most specific stacks)${RESET}`);
459
418
  }
460
419
  print('');
461
- // One "For {Stack}:" group per detected stack — each its own ranking, deduped
462
- // server-side so a plugin never repeats across sections.
463
420
  sections.forEach((section) => {
464
421
  const stackLabel = formatStackLabel(section.stack);
465
422
  print(`${BOLD}For ${stackLabel}:${RESET}`);
466
423
  section.results.forEach((item, i) => {
467
424
  const rank = `${String(i + 1).padStart(2)}.`;
468
- // Inherited-star honesty (mirrors the web card's "repo" marker): on
469
- // monorepo-subdir plugins starCount is the PARENT repo's total —
470
- // qualify it so ★ 140.1k never reads as plugin-earned. Strict ===
471
- // true: absent on pre-2026-08 servers → unqualified, like before.
472
425
  const repoQualifier = item.starsInherited === true ? ' (repo)' : '';
473
426
  const stars = item.starCount > 0
474
427
  ? ` ${YELLOW}★ ${formatCount(item.starCount)}${repoQualifier}${RESET}`
475
428
  : '';
476
429
  const codeFlag = runsCodeFlag(item) ? ` ${YELLOW}⚠ runs code${RESET}` : '';
477
- // Owner disambiguation: distinct plugins share generic names (six
478
- // actives named "nextjs") — the owner login tells them apart. Absent
479
- // on pre-2026-08 servers → name renders alone, like before.
480
430
  const owner = item.repoOwnerLogin ? ` ${DIM}by ${item.repoOwnerLogin}${RESET}` : '';
481
431
  print(` ${BOLD}${rank} ${item.name}${RESET}${owner}${stars}${codeFlag}`);
482
432
  if (item.description) {
@@ -493,11 +443,9 @@ export async function runRecommend(argv) {
493
443
  });
494
444
  print('');
495
445
  });
496
- // Interactive install (TTY only). The footer prints AFTER the flow so the
497
- // last line is always the refine link, whatever path was taken.
498
446
  await runInteractiveInstall(body);
499
447
  }
500
- /** Always the last output: the picker page link (not /for/[stack] — low-coverage stacks 404 there). */
448
+ /** Always the last line printed. Links the picker, not /for/[stack] (low-coverage stacks 404 there). */
501
449
  function printFooter() {
502
450
  print(`${DIM}Refine stacks: ${BASE_URL}/tools/for-your-project${RESET}`);
503
451
  }
@@ -507,20 +455,14 @@ const STAGE_TO_FAILURE_CLASS = {
507
455
  install: 'install_failed',
508
456
  };
509
457
  /**
510
- * Optional interactive tail of `recommend`: select up to
511
- * RECOMMEND_MAX_SELECTIONS recommended plugins, pick one scope, confirm, and
512
- * install each through the shared wrapper-marketplace path (identical to
513
- * `p/<slug>`). Skipped entirely for non-TTY runs (both streams checked —
514
- * stdin alone misses `recommend | cat`) and when nothing is natively
515
- * installable. Exits 1 when any selected install failed.
458
+ * Installs selected plugins via the p/<slug> wrapper path. Both streams must
459
+ * be TTYs (stdin alone misses `recommend | cat`). Exits 1 when any install failed.
516
460
  */
517
461
  async function runInteractiveInstall(body) {
518
462
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
519
463
  printFooter();
520
464
  return;
521
465
  }
522
- // Maintainer-override items are manual-only and never selectable — their
523
- // override command is already printed above and is NEVER executed here.
524
466
  const installable = body.sections.flatMap((section) => section.results
525
467
  .filter((item) => !item.install.maintainerOverride && item.install.claude !== null)
526
468
  .map((item) => ({ item, stack: section.stack })));
@@ -528,11 +470,7 @@ async function runInteractiveInstall(body) {
528
470
  printFooter();
529
471
  return;
530
472
  }
531
- // Prerequisite check BEFORE asking the user to make any decisions. Not an
532
- // error exit: the recommendations already printed successfully and the
533
- // install tail is optional — checkClaudeCli() prints the actionable hint,
534
- // then the run ends cleanly with the footer like every other skip path.
535
- // (Exit 1 stays reserved for attempted installs that failed, below.)
473
+ // Not an error exit: exit 1 is reserved for attempted installs that failed.
536
474
  if (!checkClaudeCli()) {
537
475
  print('');
538
476
  printFooter();
@@ -540,8 +478,7 @@ async function runInteractiveInstall(body) {
540
478
  }
541
479
  print('');
542
480
  const chosen = await recommendPrompt('Install plugins:', installable.map(({ item, stack }) => ({
543
- // Repeat the code-execution flag at the decision point — the list line
544
- // above may have scrolled away by selection time.
481
+ // Repeated here: the list line may have scrolled away.
545
482
  label: `${item.name} (${formatStackLabel(stack)})${runsCodeFlag(item) ? ' ⚠ runs code' : ''}`,
546
483
  selected: false,
547
484
  })), RECOMMEND_MAX_SELECTIONS);
@@ -558,10 +495,7 @@ async function runInteractiveInstall(body) {
558
495
  printFooter();
559
496
  return;
560
497
  }
561
- // Final confirmation with the exact names, count, and scope. Declining
562
- // exits cleanly with zero mutations. The reporting disclosure prints BEFORE
563
- // this prompt — confirming is what leads to the outcome report, so the user
564
- // must see it while declining still prevents the send.
498
+ // The reporting disclosure must print BEFORE the confirm, while declining still prevents the send.
565
499
  print('');
566
500
  print(`${BOLD}Selected:${RESET} ${selected.map(({ item }) => item.name).join(', ')}`);
567
501
  print(`${DIM}Anonymous install outcomes are reported to claudepluginhub.com.${RESET}`);
@@ -582,8 +516,7 @@ async function runInteractiveInstall(body) {
582
516
  outcomes.push({ slug: item.slug, status: 'failed', failureClass: 'fetch_failed' });
583
517
  continue;
584
518
  }
585
- // Wrapper manifests name their single plugin after the slug; the shared
586
- // installer verifies that by name instead of trusting plugins[0].
519
+ // Wrapper manifests name their single plugin after the slug.
587
520
  const result = installPluginFromManifest(manifest, item.slug, manifestUrl, scope);
588
521
  if (result.ok) {
589
522
  printSuccess(item.name);
@@ -606,10 +539,7 @@ async function runInteractiveInstall(body) {
606
539
  print('');
607
540
  print(`${DIM}Manage: claude plugin list | claude plugin uninstall <name>${RESET}`);
608
541
  print('');
609
- // Repeats the pre-confirm disclosure adjacent to the actual send, and
610
- // deliberately prints even when reportOutcomes skipped it (no proof from an
611
- // older server, POST failure): over-disclosing beats a privacy notice
612
- // that's absent on runs where the report DID go out.
542
+ // Printed even when reportOutcomes skipped the send: over-disclosing beats a missing notice.
613
543
  print(`${DIM}Anonymous install outcomes are reported to claudepluginhub.com.${RESET}`);
614
544
  printFooter();
615
545
  if (failed > 0) {
@@ -617,11 +547,8 @@ async function runInteractiveInstall(body) {
617
547
  }
618
548
  }
619
549
  /**
620
- * Fail-soft outcome report: echo the server's signed proof back with only
621
- * {pluginId, status, failureClass} per ATTEMPTED plugin — never dependency
622
- * names, paths, plugin inventories, command output, or raw error text. Any
623
- * failure here is invisible and never changes the local install result; runs
624
- * where nothing was selected never reach this call.
550
+ * Sends only {pluginId, status, failureClass} per attempted plugin — never
551
+ * dependency names, paths, command output or error text. Silent on failure.
625
552
  */
626
553
  async function reportOutcomes(proof, outcomes) {
627
554
  if (!proof || outcomes.length === 0)
package/dist/remove.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Scope } from './prompts.js';
2
2
  import type { ComponentLock } from './lock.js';
3
- export declare function removeComponentByLock(comp: ComponentLock): void;
3
+ export declare function removeComponentByLock(lock: ComponentLock): void;
4
4
  export declare function runDirectRemove(identifier: string, scope: Scope): Promise<void>;
5
5
  export declare function runRemove(identifier: string): Promise<void>;
package/dist/remove.js CHANGED
@@ -12,7 +12,6 @@ function removeConfigKeys(lock) {
12
12
  try {
13
13
  const settings = JSON.parse(readFileSync(lock.configFile, 'utf-8'));
14
14
  if (lock.type === 'hook' && lock.configFragment) {
15
- // Remove hooks by deep equality
16
15
  const hooks = settings.hooks;
17
16
  if (hooks) {
18
17
  const fragment = lock.configFragment;
@@ -30,7 +29,7 @@ function removeConfigKeys(lock) {
30
29
  }
31
30
  }
32
31
  else if (lock.configKeys) {
33
- // Remove by key path (mcpServers.x, lspServers.x)
32
+ // Key paths are `section.key` (mcpServers.x, lspServers.x).
34
33
  for (const keyPath of lock.configKeys) {
35
34
  const parts = keyPath.split('.');
36
35
  if (parts.length === 2) {
@@ -58,9 +57,9 @@ function isSafeRemovePath(targetPath) {
58
57
  return (resolved.startsWith(userBase + sep) ||
59
58
  resolved.startsWith(projectBase + sep));
60
59
  }
61
- function removeFiles(lock) {
60
+ export function removeComponentByLock(lock) {
62
61
  if (lock.configFile) {
63
- // Config-based component — remove config keys, not the settings file
62
+ // Config-based component: remove its keys, never the settings file itself.
64
63
  removeConfigKeys(lock);
65
64
  return;
66
65
  }
@@ -82,9 +81,6 @@ function removeFiles(lock) {
82
81
  // Best effort
83
82
  }
84
83
  }
85
- export function removeComponentByLock(comp) {
86
- removeFiles(comp);
87
- }
88
84
  export async function runDirectRemove(identifier, scope) {
89
85
  const lock = readLock(scope);
90
86
  const collection = lock.collections[identifier];
@@ -94,7 +90,7 @@ export async function runDirectRemove(identifier, scope) {
94
90
  }
95
91
  printStep(`Removing ${Object.keys(collection.components).length} component(s) from ${scope} scope...`);
96
92
  for (const [, comp] of Object.entries(collection.components)) {
97
- removeFiles(comp);
93
+ removeComponentByLock(comp);
98
94
  printSuccess(`${comp.componentName} (${comp.type})`);
99
95
  }
100
96
  removeCollection(lock, identifier);
@@ -104,7 +100,6 @@ export async function runDirectRemove(identifier, scope) {
104
100
  print('');
105
101
  }
106
102
  export async function runRemove(identifier) {
107
- // Try all scopes to find the collection
108
103
  const scopes = ['project', 'local', 'user'];
109
104
  let foundScope = null;
110
105
  let foundCollection = null;
@@ -123,7 +118,7 @@ export async function runRemove(identifier) {
123
118
  }
124
119
  printStep(`Removing ${Object.keys(foundCollection.components).length} component(s)...`);
125
120
  for (const [, comp] of Object.entries(foundCollection.components)) {
126
- removeFiles(comp);
121
+ removeComponentByLock(comp);
127
122
  printSuccess(`${comp.componentName} (${comp.type})`);
128
123
  }
129
124
  const lock = readLock(foundScope);
package/dist/update.js CHANGED
@@ -30,7 +30,7 @@ export async function runUpdate(identifier) {
30
30
  if (identifier && collection.identifier !== identifier)
31
31
  continue;
32
32
  found = true;
33
- // Skip direct installs (apiUrl === '' sentinel)
33
+ // apiUrl === '' marks a direct install; there is no manifest to update from.
34
34
  if (collection.apiUrl === '') {
35
35
  print(`${BOLD}${collection.identifier}${RESET} — direct install, skipped`);
36
36
  for (const comp of Object.values(collection.components)) {
@@ -64,7 +64,6 @@ export async function runUpdate(identifier) {
64
64
  removed.push(key);
65
65
  }
66
66
  }
67
- // Check hashes before downloading to avoid unnecessary re-downloads
68
67
  const changed = [];
69
68
  for (const comp of toCheck) {
70
69
  const key = componentKey(comp.source, comp.sourcePath);
@@ -78,14 +77,12 @@ export async function runUpdate(identifier) {
78
77
  printSuccess('Already up to date');
79
78
  continue;
80
79
  }
81
- // Remove deleted components (including config cleanup)
82
80
  for (const key of removed) {
83
81
  const comp = collection.components[key];
84
82
  removeComponentByLock(comp);
85
83
  delete collection.components[key];
86
84
  printSuccess(`Removed ${comp.componentName} (${comp.type})`);
87
85
  }
88
- // Add new components
89
86
  for (const comp of added) {
90
87
  const result = await installComponent(comp, scope, false);
91
88
  if (result.status === 'installed') {
@@ -97,7 +94,6 @@ export async function runUpdate(identifier) {
97
94
  printFail(`${comp.componentName} (${comp.type})`, 'download failed');
98
95
  }
99
96
  }
100
- // Re-download changed components: clean up old files/config, then reinstall
101
97
  for (const comp of changed) {
102
98
  const key = componentKey(comp.source, comp.sourcePath);
103
99
  const existing = collection.components[key];
@@ -1,7 +1,2 @@
1
- /** Shared validation constants and helpers for the CLI. */
2
- /** Matches a single valid name segment: alphanumeric, underscore, dot, hyphen. */
3
1
  export declare const VALID_NAME_RE: RegExp;
4
- /** Matches an owner/repo string (two valid name segments separated by /). */
5
- export declare const OWNER_REPO_RE: RegExp;
6
- /** Validates that a string is a well-formed owner/repo identifier. */
7
2
  export declare function isOwnerRepo(identifier: string): boolean;
@@ -1,20 +1,13 @@
1
- /** Shared validation constants and helpers for the CLI. */
2
- /** Matches a single valid name segment: alphanumeric, underscore, dot, hyphen. */
3
1
  export const VALID_NAME_RE = /^[a-zA-Z0-9_.-]+$/;
4
- /** Matches an owner/repo string (two valid name segments separated by /). */
5
- export const OWNER_REPO_RE = /^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/;
6
- /** Validates that a string is a well-formed owner/repo identifier. */
2
+ const OWNER_REPO_RE = /^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/;
7
3
  export function isOwnerRepo(identifier) {
8
4
  if (!OWNER_REPO_RE.test(identifier))
9
5
  return false;
10
6
  const [owner, repo] = identifier.split('/');
11
- // Reject segments that are purely dots (e.g. "..", ".")
12
7
  if (/^\.+$/.test(owner) || /^\.+$/.test(repo))
13
8
  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.
9
+ // p/<slug> is owner/repo-shaped but means a wrapper install (u/ and c/ are
10
+ // reserved for symmetry), so GitHub users "u"/"c"/"p" can't use the bare form.
18
11
  if (owner === 'u' || owner === 'c' || owner === 'p')
19
12
  return false;
20
13
  return true;
package/dist/wrapper.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { Scope } from './prompts.js';
2
2
  export declare function sanitizeName(raw: string): string;
3
- export declare function validateManifestName(name: string): boolean;
4
3
  export declare function getWrapperDir(ownerRepo: string, scope: Scope): string;
5
4
  export declare function getMarketplaceName(ownerRepo: string, scope: Scope): string;
6
5
  export interface WrapperOptions {
package/dist/wrapper.js CHANGED
@@ -2,7 +2,6 @@ import { mkdirSync, writeFileSync, readFileSync, existsSync, rmSync } from 'node
2
2
  import { join } from 'node:path';
3
3
  import { homedir } from 'node:os';
4
4
  import { createHash } from 'node:crypto';
5
- import { VALID_NAME_RE } from './validation.js';
6
5
  export function sanitizeName(raw) {
7
6
  return (raw
8
7
  .toLowerCase()
@@ -10,9 +9,6 @@ export function sanitizeName(raw) {
10
9
  .replace(/-+/g, '-')
11
10
  .replace(/^-|-$/g, '') || 'plugin');
12
11
  }
13
- export function validateManifestName(name) {
14
- return VALID_NAME_RE.test(name);
15
- }
16
12
  function cwdHash() {
17
13
  return createHash('sha256').update(process.cwd()).digest('hex').slice(0, 8);
18
14
  }
@@ -28,7 +24,6 @@ export function getWrapperDir(ownerRepo, scope) {
28
24
  if (scope === 'project') {
29
25
  return join(process.cwd(), '.claude', '.cpd-wrappers', name);
30
26
  }
31
- // user and local both go under ~/.claude/
32
27
  return join(homedir(), '.claude', '.cpd-wrappers', name);
33
28
  }
34
29
  export function getMarketplaceName(ownerRepo, scope) {
@@ -80,7 +75,6 @@ export function readWrapperMeta(ownerRepo, scope) {
80
75
  export function findWrapperScopes(ownerRepo) {
81
76
  const scopes = [];
82
77
  const [owner, repo] = ownerRepo.split('/');
83
- // Check user scope
84
78
  const userDir = join(homedir(), '.claude', '.cpd-wrappers');
85
79
  if (existsSync(userDir)) {
86
80
  const userWrapper = join(userDir, `${owner}-${repo}-user`);
@@ -88,7 +82,6 @@ export function findWrapperScopes(ownerRepo) {
88
82
  scopes.push('user');
89
83
  }
90
84
  }
91
- // Check project scope
92
85
  const projectDir = join(process.cwd(), '.claude', '.cpd-wrappers');
93
86
  if (existsSync(projectDir)) {
94
87
  const projectWrapper = join(projectDir, `${owner}-${repo}-project`);
@@ -96,7 +89,7 @@ export function findWrapperScopes(ownerRepo) {
96
89
  scopes.push('project');
97
90
  }
98
91
  }
99
- // Check local scope — only matches current cwd
92
+ // Local wrappers are keyed by cwd hash, so only the current cwd matches.
100
93
  if (existsSync(userDir)) {
101
94
  const localWrapper = join(userDir, `${owner}-${repo}-local-${cwdHash()}`);
102
95
  if (existsSync(join(localWrapper, 'cpd-meta.json'))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudepluginhub",
3
- "version": "0.16.1",
3
+ "version": "0.18.0",
4
4
  "description": "Install Claude Code components from ClaudePluginHub",
5
5
  "bin": {
6
6
  "claudepluginhub": "dist/index.js"