claudepluginhub 0.13.0 → 0.15.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.
@@ -204,6 +204,10 @@ export function scanEquivalent(aRecord, aScan, bRecord, bScan) {
204
204
  return false;
205
205
  if (sortedStrings(aScan.themeFiles).join('\0') !== sortedStrings(bScan.themeFiles).join('\0'))
206
206
  return false;
207
+ // Two installations with different workflow scripts register different slash
208
+ // commands — never collapse them into one "equivalent" row.
209
+ if (sortedStrings(aScan.workflowFiles).join('\0') !== sortedStrings(bScan.workflowFiles).join('\0'))
210
+ return false;
207
211
  if (sortedStrings(aScan.parseErrors).join('\0') !== sortedStrings(bScan.parseErrors).join('\0'))
208
212
  return false;
209
213
  if (sortedStrings(aScan.symlinksSkipped).join('\0') !== sortedStrings(bScan.symlinksSkipped).join('\0'))
@@ -52,6 +52,8 @@ function capsSummary(caps) {
52
52
  parts.push(`lsp: ${caps.lsp.total}`);
53
53
  if (caps.monitors.total > 0)
54
54
  parts.push(`monitors: ${caps.monitors.total}`);
55
+ if (caps.workflowCount > 0)
56
+ parts.push(`workflows: ${caps.workflowCount}`);
55
57
  if (caps.binCount > 0)
56
58
  parts.push(`bin: ${caps.binCount}`);
57
59
  return parts.length > 0 ? parts.join(', ') : 'none';
@@ -61,6 +61,7 @@ export function createScanner(overrides) {
61
61
  mcp: [],
62
62
  lsp: [],
63
63
  monitors: [],
64
+ workflowFiles: [],
64
65
  bin: [],
65
66
  parseErrors: [],
66
67
  symlinksSkipped: [],
@@ -979,6 +980,8 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
979
980
  ['mcpServers', manifest.mcpServers, isPathArrayOrObject],
980
981
  ['lspServers', manifest.lspServers, isPathArrayOrObject],
981
982
  ['monitors', monitorsValue, isPathArrayOrObject],
983
+ // Top-level only — `workflows` is NOT an `experimental.*` field.
984
+ ['workflows', manifest.workflows, isPathOrArray],
982
985
  ['dependencies', manifest.dependencies, (v) => Array.isArray(v)],
983
986
  ];
984
987
  for (const [field, value, valid] of checks) {
@@ -1022,6 +1025,7 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1022
1025
  ...boundPaths(stringPaths(manifest.mcpServers), state),
1023
1026
  ...boundPaths(stringPaths(manifest.lspServers), state),
1024
1027
  ...boundPaths(stringPaths(manifest.monitors !== undefined ? manifest.monitors : experimental.monitors), state),
1028
+ ...boundPaths(stringPaths(manifest.workflows), state),
1025
1029
  ];
1026
1030
  for (const rel of [...new Set(declared)].sort()) {
1027
1031
  // Contained lexical resolve first: a "../…" or absolute declaration is
@@ -1177,6 +1181,68 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1177
1181
  if (inline.length > 0)
1178
1182
  pushFacts(result.monitors, parseMonitorEntries(inline));
1179
1183
  }
1184
+ // --- workflows/ (spec: top-level manifest field, REPLACES the default dir) --
1185
+ // Mirrors the measured loader behaviour, which is narrower than every other
1186
+ // component scan here:
1187
+ // - `.js` ONLY, matched case-sensitively (`W.JS` is silently not loaded)
1188
+ // - direct children only — `workflows/sub/w.js` never loads
1189
+ // Files are LISTED, never read and never executed. The invocation name lives
1190
+ // in the script's `export const meta`, which needs a JS parser the CLI does
1191
+ // not ship, so no name is claimed here.
1192
+ const workflowsRoots = boundPaths(stringPaths(manifest.workflows), state);
1193
+ for (const root of workflowsRoots.length > 0 ? [...new Set(workflowsRoots)].sort() : ['workflows']) {
1194
+ const dirReal = containedReal(rootCanonical, root, state);
1195
+ if (dirReal === null)
1196
+ continue;
1197
+ let entries = [];
1198
+ try {
1199
+ entries = readdirSync(dirReal).sort();
1200
+ }
1201
+ catch {
1202
+ entries = [];
1203
+ }
1204
+ if (entries.length > MAX_KEYS) {
1205
+ state.limitsHit.add('max-facts');
1206
+ state.incomplete = true;
1207
+ }
1208
+ for (const entry of entries.slice(0, MAX_KEYS)) {
1209
+ // Case-SENSITIVE: the loader does not lowercase, so `W.JS` is not a workflow.
1210
+ if (!entry.endsWith('.js'))
1211
+ continue;
1212
+ const abs = join(dirReal, entry);
1213
+ let info;
1214
+ try {
1215
+ info = lstatSync(abs);
1216
+ }
1217
+ catch {
1218
+ continue;
1219
+ }
1220
+ // Same containment rule as bin/ below: `statSync` alone FOLLOWS symlinks,
1221
+ // so an entry resolving outside the plugin root would be listed as a
1222
+ // legitimate workflow of this plugin and the report would not be marked
1223
+ // incomplete — the one signal that tells the reader the scan was bounded.
1224
+ if (info.isSymbolicLink()) {
1225
+ try {
1226
+ const real = realpathSync(abs);
1227
+ if (!isWithin(rootCanonical, real)) {
1228
+ state.symlinksSkipped.push(`${root}/${entry}`);
1229
+ state.incomplete = true;
1230
+ continue;
1231
+ }
1232
+ info = statSync(real);
1233
+ }
1234
+ catch {
1235
+ state.symlinksSkipped.push(`${root}/${entry}`);
1236
+ state.incomplete = true;
1237
+ continue;
1238
+ }
1239
+ }
1240
+ if (!info.isFile())
1241
+ continue;
1242
+ state.filesScanned += 1;
1243
+ result.workflowFiles.push(`${root}/${entry}`);
1244
+ }
1245
+ }
1180
1246
  // --- bin/ (spec: on PATH while the plugin is enabled; tree-only, no manifest) --------
1181
1247
  // The directory itself goes through the contained-realpath helper: a bin/
1182
1248
  // that is a symlink pointing outside the root must not be listed at all.
@@ -167,6 +167,8 @@ export interface ScanResult {
167
167
  mcp: McpFact[];
168
168
  lsp: LspFact[];
169
169
  monitors: MonitorFact[];
170
+ /** Plugin-relative paths of workflow scripts. Never read/parsed — never executed. */
171
+ workflowFiles: string[];
170
172
  bin: {
171
173
  relPath: string;
172
174
  executable: boolean;
@@ -228,6 +230,18 @@ export interface PluginCapabilities {
228
230
  executable: string | null;
229
231
  }>;
230
232
  binCount: number;
233
+ /**
234
+ * Count of `workflows/` scripts found (default dir or the manifest's
235
+ * replaces-default path; `.js`, direct children only).
236
+ *
237
+ * A COUNT, not a per-item list, deliberately: the invocation name a workflow
238
+ * registers lives in its `export const meta = {…}`, and extracting that
239
+ * requires a JS parser the CLI does not ship. Emitting file basenames as if
240
+ * they were command names would be a fabricated claim — the runtime uses
241
+ * `meta.name`, which frequently differs from the filename. Report what we can
242
+ * actually see.
243
+ */
244
+ workflowCount: number;
231
245
  }
232
246
  export interface PluginEntry {
233
247
  id: string;
@@ -89,6 +89,7 @@ function capabilities(scan) {
89
89
  executable: m.command?.executable ?? null,
90
90
  })), MAX_CAPABILITY_ITEMS),
91
91
  binCount: scan.bin.length,
92
+ workflowCount: scan.workflowFiles.length,
92
93
  };
93
94
  }
94
95
  function makeEntry(record, selection, scan) {
@@ -32,4 +32,69 @@ export interface ProjectSignals {
32
32
  * contributes nothing (its filename still signals via `files`).
33
33
  */
34
34
  export declare function collectProjectSignals(cwd: string): ProjectSignals;
35
+ /**
36
+ * Response subset the CLI renders. Canonical contract:
37
+ * src/features/stack-recommendations/types.ts (RecommendApiResponse) — the
38
+ * CLI package can't import site types, so keep this in sync (additive server
39
+ * changes are safe; renames break the site's own consumers first).
40
+ *
41
+ * POST returns per-stack `sections` (not a fused `results` list): fusion buries
42
+ * the sharp single-stack specialists, so the CLI shows each detected stack's own
43
+ * top picks.
44
+ */
45
+ interface RecommendResultItem {
46
+ slug: string;
47
+ name: string;
48
+ description: string | null;
49
+ starCount: number;
50
+ installCount: number;
51
+ /**
52
+ * Per-recommendation evidence (subset of the server's stored evidence
53
+ * payload — see StackRecommendationEvidence in the site schema). Null on
54
+ * cold-stack fallback results; the whole field is absent from pre-P2
55
+ * servers, so it stays optional and every read is guarded.
56
+ */
57
+ evidence?: {
58
+ lift: number | null;
59
+ reuseCount: number;
60
+ recentInstalls90d: number;
61
+ coInstalledWith: string[];
62
+ } | null;
63
+ /** Site-relative detail-page URL (absent from pre-P2 servers). */
64
+ url?: string;
65
+ /** Present component types (presence only). Absent from pre-P2 servers. */
66
+ componentTypes?: string[];
67
+ /**
68
+ * Server-derived code-execution flag covering all six vectors
69
+ * (hooks/MCP/LSP/bin/monitors/workflows — the safe.json exclusion set).
70
+ * The ONLY source for the "runs code" warning: componentTypes cannot
71
+ * represent bin, so client inference would under-warn. Absent from pre-P2
72
+ * servers (no flag shown rather than a wrong one).
73
+ */
74
+ runsCode?: boolean;
75
+ /** Claimed/verified maintainer flag (absent from pre-P2 servers). */
76
+ hasVerifiedOwner?: boolean;
77
+ install: {
78
+ command: string;
79
+ /**
80
+ * True when `command` is a verified maintainer's override. Override items
81
+ * are manual-only: they never enter the interactive selector (their
82
+ * command is already printed in the section list) and are never executed.
83
+ */
84
+ maintainerOverride: boolean;
85
+ /** Generated Claude Code fallback; null exactly when an override is set. */
86
+ claude: {
87
+ addCommand: string;
88
+ installCommand: string;
89
+ } | null;
90
+ };
91
+ }
92
+ export declare function buildEvidenceLine(evidence: RecommendResultItem['evidence'], stackLabel: string): string | null;
93
+ /**
94
+ * "⚠ runs code" marker. Strictly the server-derived `runsCode` field — never
95
+ * inferred from componentTypes (see the field doc: bin is unrepresentable
96
+ * there, so inference under-warns).
97
+ */
98
+ export declare function runsCodeFlag(item: RecommendResultItem): boolean;
35
99
  export declare function runRecommend(argv: string[]): Promise<void>;
100
+ export {};
package/dist/recommend.js CHANGED
@@ -323,6 +323,46 @@ function formatStackLabel(stack) {
323
323
  .map((w) => (w ? w[0].toUpperCase() + w.slice(1) : w))
324
324
  .join(' ');
325
325
  }
326
+ /**
327
+ * Quiet per-item evidence line. Hand-synced mini twin of the site's
328
+ * `buildEvidenceLine` (src/features/stack-recommendations/lib/display.ts —
329
+ * not importable across the package boundary): same signal priority
330
+ * (lift > reuse > co-copy > copy clicks), same honesty thresholds, same
331
+ * ≤2-signal cap, and the same copy-integrity rule — install-derived numbers
332
+ * are copy-click proxies, never described as installs.
333
+ */
334
+ const EVIDENCE_MIN_LIFT = 1.5;
335
+ const EVIDENCE_MIN_REUSE = 2;
336
+ const EVIDENCE_MIN_INSTALLS = 5;
337
+ const EVIDENCE_MAX_SIGNALS = 2;
338
+ export function buildEvidenceLine(evidence, stackLabel) {
339
+ if (!evidence)
340
+ return null;
341
+ const signals = [];
342
+ if (evidence.lift !== null && evidence.lift >= EVIDENCE_MIN_LIFT) {
343
+ signals.push(`popular among ${stackLabel}-focused visitors`);
344
+ }
345
+ if (evidence.reuseCount >= EVIDENCE_MIN_REUSE) {
346
+ signals.push(`components reused in ${evidence.reuseCount} plugins`);
347
+ }
348
+ if (Array.isArray(evidence.coInstalledWith) && evidence.coInstalledWith.length > 0) {
349
+ signals.push(`often copied alongside ${evidence.coInstalledWith[0]}`);
350
+ }
351
+ if (evidence.recentInstalls90d >= EVIDENCE_MIN_INSTALLS) {
352
+ signals.push(`${evidence.recentInstalls90d} copy clicks in 90 days`);
353
+ }
354
+ if (signals.length === 0)
355
+ return null;
356
+ return signals.slice(0, EVIDENCE_MAX_SIGNALS).join(' · ');
357
+ }
358
+ /**
359
+ * "⚠ runs code" marker. Strictly the server-derived `runsCode` field — never
360
+ * inferred from componentTypes (see the field doc: bin is unrepresentable
361
+ * there, so inference under-warns).
362
+ */
363
+ export function runsCodeFlag(item) {
364
+ return item.runsCode === true;
365
+ }
326
366
  export async function runRecommend(argv) {
327
367
  const { limit, json } = parseRecommendFlags(argv);
328
368
  if (!json)
@@ -397,15 +437,24 @@ export async function runRecommend(argv) {
397
437
  // One "For {Stack}:" group per detected stack — each its own ranking, deduped
398
438
  // server-side so a plugin never repeats across sections.
399
439
  sections.forEach((section) => {
400
- print(`${BOLD}For ${formatStackLabel(section.stack)}:${RESET}`);
440
+ const stackLabel = formatStackLabel(section.stack);
441
+ print(`${BOLD}For ${stackLabel}:${RESET}`);
401
442
  section.results.forEach((item, i) => {
402
443
  const rank = `${String(i + 1).padStart(2)}.`;
403
444
  const stars = item.starCount > 0 ? ` ${YELLOW}★ ${formatCount(item.starCount)}${RESET}` : '';
404
- print(` ${BOLD}${rank} ${item.name}${RESET}${stars}`);
445
+ const codeFlag = runsCodeFlag(item) ? ` ${YELLOW}⚠ runs code${RESET}` : '';
446
+ print(` ${BOLD}${rank} ${item.name}${RESET}${stars}${codeFlag}`);
405
447
  if (item.description) {
406
448
  print(` ${DIM}${truncate(item.description, 88)}${RESET}`);
407
449
  }
450
+ const evidenceLine = buildEvidenceLine(item.evidence, stackLabel);
451
+ if (evidenceLine) {
452
+ print(` ${DIM}${truncate(evidenceLine, 88)}${RESET}`);
453
+ }
408
454
  print(` ${CYAN}${item.install.command}${RESET}`);
455
+ if (item.url) {
456
+ print(` ${DIM}${BASE_URL}${item.url}${RESET}`);
457
+ }
409
458
  });
410
459
  print('');
411
460
  });
@@ -456,7 +505,9 @@ async function runInteractiveInstall(body) {
456
505
  }
457
506
  print('');
458
507
  const chosen = await recommendPrompt('Install plugins:', installable.map(({ item, stack }) => ({
459
- label: `${item.name} (${formatStackLabel(stack)})`,
508
+ // Repeat the code-execution flag at the decision point — the list line
509
+ // above may have scrolled away by selection time.
510
+ label: `${item.name} (${formatStackLabel(stack)})${runsCodeFlag(item) ? ' ⚠ runs code' : ''}`,
460
511
  selected: false,
461
512
  })), RECOMMEND_MAX_SELECTIONS);
462
513
  if (chosen === null || chosen.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudepluginhub",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Install Claude Code components from ClaudePluginHub",
5
5
  "bin": {
6
6
  "claudepluginhub": "dist/index.js"