claudepluginhub 0.16.1 → 0.17.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 +34 -1
  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 +6 -16
  24. package/dist/doctor/rules.js +13 -26
  25. package/dist/doctor/run.d.ts +1 -1
  26. package/dist/doctor/run.js +5 -6
  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/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.17.0",
4
4
  "description": "Install Claude Code components from ClaudePluginHub",
5
5
  "bin": {
6
6
  "claudepluginhub": "dist/index.js"