claudepluginhub 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -0
- package/dist/recommend.d.ts +81 -0
- package/dist/recommend.js +78 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -62,6 +62,7 @@ never file contents):
|
|
|
62
62
|
attempted installs are reported)
|
|
63
63
|
recommend --limit 6 Results per stack (1-50, default 4)
|
|
64
64
|
recommend --json Raw JSON output (never interactive)
|
|
65
|
+
recommend --source plugin Attribution tag for wrappers (cli|plugin; default cli)
|
|
65
66
|
|
|
66
67
|
Options:
|
|
67
68
|
--plugin <name> Install a specific plugin from a marketplace repo
|
package/dist/recommend.d.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `npx claudepluginhub recommend` — instant plugin recommendations for the
|
|
3
|
+
* current project. Reads local manifest dependency NAMES and telltale config
|
|
4
|
+
* FILENAMES (never file contents, never CLAUDE.md) and POSTs them to
|
|
5
|
+
* /api/recommend, where they resolve to vocabulary stacks server-side.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Analytics source tag sent as `?source=`. Default `cli`; the Claude Code
|
|
9
|
+
* plugin (which wraps this command) passes `--source plugin` so plugin-driven
|
|
10
|
+
* usage stays separable from direct CLI usage in readouts. Allowlisted here
|
|
11
|
+
* AND server-side (`resolveSource`); unknown values are rejected at parse so
|
|
12
|
+
* a typo can't silently degrade to the server's `web` fallback.
|
|
13
|
+
*/
|
|
14
|
+
declare const RECOMMEND_SOURCES: readonly ["cli", "plugin"];
|
|
15
|
+
export type RecommendSource = (typeof RECOMMEND_SOURCES)[number];
|
|
1
16
|
/**
|
|
2
17
|
* Hard cap on plugins selectable in one interactive recommend run. Deliberate
|
|
3
18
|
* selection-safety bound: the selector has no select-all and every item starts
|
|
@@ -10,6 +25,7 @@ export declare const RECOMMEND_MAX_SELECTIONS = 5;
|
|
|
10
25
|
export interface RecommendFlags {
|
|
11
26
|
limit: number;
|
|
12
27
|
json: boolean;
|
|
28
|
+
source: RecommendSource;
|
|
13
29
|
}
|
|
14
30
|
export declare function parseRecommendFlags(argv: string[]): RecommendFlags;
|
|
15
31
|
export declare function parsePackageJsonDeps(content: string): string[];
|
|
@@ -32,4 +48,69 @@ export interface ProjectSignals {
|
|
|
32
48
|
* contributes nothing (its filename still signals via `files`).
|
|
33
49
|
*/
|
|
34
50
|
export declare function collectProjectSignals(cwd: string): ProjectSignals;
|
|
51
|
+
/**
|
|
52
|
+
* Response subset the CLI renders. Canonical contract:
|
|
53
|
+
* src/features/stack-recommendations/types.ts (RecommendApiResponse) — the
|
|
54
|
+
* CLI package can't import site types, so keep this in sync (additive server
|
|
55
|
+
* changes are safe; renames break the site's own consumers first).
|
|
56
|
+
*
|
|
57
|
+
* POST returns per-stack `sections` (not a fused `results` list): fusion buries
|
|
58
|
+
* the sharp single-stack specialists, so the CLI shows each detected stack's own
|
|
59
|
+
* top picks.
|
|
60
|
+
*/
|
|
61
|
+
interface RecommendResultItem {
|
|
62
|
+
slug: string;
|
|
63
|
+
name: string;
|
|
64
|
+
description: string | null;
|
|
65
|
+
starCount: number;
|
|
66
|
+
installCount: number;
|
|
67
|
+
/**
|
|
68
|
+
* Per-recommendation evidence (subset of the server's stored evidence
|
|
69
|
+
* payload — see StackRecommendationEvidence in the site schema). Null on
|
|
70
|
+
* cold-stack fallback results; the whole field is absent from pre-P2
|
|
71
|
+
* servers, so it stays optional and every read is guarded.
|
|
72
|
+
*/
|
|
73
|
+
evidence?: {
|
|
74
|
+
lift: number | null;
|
|
75
|
+
reuseCount: number;
|
|
76
|
+
recentInstalls90d: number;
|
|
77
|
+
coInstalledWith: string[];
|
|
78
|
+
} | null;
|
|
79
|
+
/** Site-relative detail-page URL (absent from pre-P2 servers). */
|
|
80
|
+
url?: string;
|
|
81
|
+
/** Present component types (presence only). Absent from pre-P2 servers. */
|
|
82
|
+
componentTypes?: string[];
|
|
83
|
+
/**
|
|
84
|
+
* Server-derived code-execution flag covering all six vectors
|
|
85
|
+
* (hooks/MCP/LSP/bin/monitors/workflows — the safe.json exclusion set).
|
|
86
|
+
* The ONLY source for the "runs code" warning: componentTypes cannot
|
|
87
|
+
* represent bin, so client inference would under-warn. Absent from pre-P2
|
|
88
|
+
* servers (no flag shown rather than a wrong one).
|
|
89
|
+
*/
|
|
90
|
+
runsCode?: boolean;
|
|
91
|
+
/** Claimed/verified maintainer flag (absent from pre-P2 servers). */
|
|
92
|
+
hasVerifiedOwner?: boolean;
|
|
93
|
+
install: {
|
|
94
|
+
command: string;
|
|
95
|
+
/**
|
|
96
|
+
* True when `command` is a verified maintainer's override. Override items
|
|
97
|
+
* are manual-only: they never enter the interactive selector (their
|
|
98
|
+
* command is already printed in the section list) and are never executed.
|
|
99
|
+
*/
|
|
100
|
+
maintainerOverride: boolean;
|
|
101
|
+
/** Generated Claude Code fallback; null exactly when an override is set. */
|
|
102
|
+
claude: {
|
|
103
|
+
addCommand: string;
|
|
104
|
+
installCommand: string;
|
|
105
|
+
} | null;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export declare function buildEvidenceLine(evidence: RecommendResultItem['evidence'], stackLabel: string): string | null;
|
|
109
|
+
/**
|
|
110
|
+
* "⚠ runs code" marker. Strictly the server-derived `runsCode` field — never
|
|
111
|
+
* inferred from componentTypes (see the field doc: bin is unrepresentable
|
|
112
|
+
* there, so inference under-warns).
|
|
113
|
+
*/
|
|
114
|
+
export declare function runsCodeFlag(item: RecommendResultItem): boolean;
|
|
35
115
|
export declare function runRecommend(argv: string[]): Promise<void>;
|
|
116
|
+
export {};
|
package/dist/recommend.js
CHANGED
|
@@ -11,7 +11,17 @@ import { print, printBanner, printStep, printSuccess, printFail, printError, BOL
|
|
|
11
11
|
* FILENAMES (never file contents, never CLAUDE.md) and POSTs them to
|
|
12
12
|
* /api/recommend, where they resolve to vocabulary stacks server-side.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
/**
|
|
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.
|
|
20
|
+
*/
|
|
21
|
+
const RECOMMEND_SOURCES = ['cli', 'plugin'];
|
|
22
|
+
function recommendUrl(source) {
|
|
23
|
+
return `${BASE_URL}/api/recommend?source=${source}`;
|
|
24
|
+
}
|
|
15
25
|
/** Server-side body caps (mirrors the /api/recommend Zod schema). */
|
|
16
26
|
const MAX_DEPENDENCIES = 500;
|
|
17
27
|
const MAX_FILES = 200;
|
|
@@ -85,6 +95,16 @@ const TELLTALE_PREFIXES = [
|
|
|
85
95
|
export function parseRecommendFlags(argv) {
|
|
86
96
|
const json = argv.includes('--json');
|
|
87
97
|
let limit = DEFAULT_LIMIT;
|
|
98
|
+
let source = 'cli';
|
|
99
|
+
const sourceIdx = argv.indexOf('--source');
|
|
100
|
+
if (sourceIdx !== -1) {
|
|
101
|
+
const val = argv[sourceIdx + 1];
|
|
102
|
+
if (!val || !RECOMMEND_SOURCES.includes(val)) {
|
|
103
|
+
printError(`Invalid --source "${val ?? ''}". Must be one of: ${RECOMMEND_SOURCES.join(', ')}`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
source = val;
|
|
107
|
+
}
|
|
88
108
|
const limitIdx = argv.indexOf('--limit');
|
|
89
109
|
if (limitIdx !== -1) {
|
|
90
110
|
const val = argv[limitIdx + 1];
|
|
@@ -99,7 +119,7 @@ export function parseRecommendFlags(argv) {
|
|
|
99
119
|
}
|
|
100
120
|
limit = parsed;
|
|
101
121
|
}
|
|
102
|
-
return { limit, json };
|
|
122
|
+
return { limit, json, source };
|
|
103
123
|
}
|
|
104
124
|
/** Strip a Python requirement spec down to the bare package name. */
|
|
105
125
|
function pythonDepName(spec) {
|
|
@@ -323,8 +343,48 @@ function formatStackLabel(stack) {
|
|
|
323
343
|
.map((w) => (w ? w[0].toUpperCase() + w.slice(1) : w))
|
|
324
344
|
.join(' ');
|
|
325
345
|
}
|
|
346
|
+
/**
|
|
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.
|
|
353
|
+
*/
|
|
354
|
+
const EVIDENCE_MIN_LIFT = 1.5;
|
|
355
|
+
const EVIDENCE_MIN_REUSE = 2;
|
|
356
|
+
const EVIDENCE_MIN_INSTALLS = 5;
|
|
357
|
+
const EVIDENCE_MAX_SIGNALS = 2;
|
|
358
|
+
export function buildEvidenceLine(evidence, stackLabel) {
|
|
359
|
+
if (!evidence)
|
|
360
|
+
return null;
|
|
361
|
+
const signals = [];
|
|
362
|
+
if (evidence.lift !== null && evidence.lift >= EVIDENCE_MIN_LIFT) {
|
|
363
|
+
signals.push(`popular among ${stackLabel}-focused visitors`);
|
|
364
|
+
}
|
|
365
|
+
if (evidence.reuseCount >= EVIDENCE_MIN_REUSE) {
|
|
366
|
+
signals.push(`components reused in ${evidence.reuseCount} plugins`);
|
|
367
|
+
}
|
|
368
|
+
if (Array.isArray(evidence.coInstalledWith) && evidence.coInstalledWith.length > 0) {
|
|
369
|
+
signals.push(`often copied alongside ${evidence.coInstalledWith[0]}`);
|
|
370
|
+
}
|
|
371
|
+
if (evidence.recentInstalls90d >= EVIDENCE_MIN_INSTALLS) {
|
|
372
|
+
signals.push(`${evidence.recentInstalls90d} copy clicks in 90 days`);
|
|
373
|
+
}
|
|
374
|
+
if (signals.length === 0)
|
|
375
|
+
return null;
|
|
376
|
+
return signals.slice(0, EVIDENCE_MAX_SIGNALS).join(' · ');
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* "⚠ runs code" marker. Strictly the server-derived `runsCode` field — never
|
|
380
|
+
* inferred from componentTypes (see the field doc: bin is unrepresentable
|
|
381
|
+
* there, so inference under-warns).
|
|
382
|
+
*/
|
|
383
|
+
export function runsCodeFlag(item) {
|
|
384
|
+
return item.runsCode === true;
|
|
385
|
+
}
|
|
326
386
|
export async function runRecommend(argv) {
|
|
327
|
-
const { limit, json } = parseRecommendFlags(argv);
|
|
387
|
+
const { limit, json, source } = parseRecommendFlags(argv);
|
|
328
388
|
if (!json)
|
|
329
389
|
printBanner();
|
|
330
390
|
const signals = collectProjectSignals(process.cwd());
|
|
@@ -338,7 +398,7 @@ export async function runRecommend(argv) {
|
|
|
338
398
|
}
|
|
339
399
|
let response;
|
|
340
400
|
try {
|
|
341
|
-
response = await fetch(
|
|
401
|
+
response = await fetch(recommendUrl(source), {
|
|
342
402
|
method: 'POST',
|
|
343
403
|
headers: { 'content-type': 'application/json' },
|
|
344
404
|
body: JSON.stringify({
|
|
@@ -397,15 +457,24 @@ export async function runRecommend(argv) {
|
|
|
397
457
|
// One "For {Stack}:" group per detected stack — each its own ranking, deduped
|
|
398
458
|
// server-side so a plugin never repeats across sections.
|
|
399
459
|
sections.forEach((section) => {
|
|
400
|
-
|
|
460
|
+
const stackLabel = formatStackLabel(section.stack);
|
|
461
|
+
print(`${BOLD}For ${stackLabel}:${RESET}`);
|
|
401
462
|
section.results.forEach((item, i) => {
|
|
402
463
|
const rank = `${String(i + 1).padStart(2)}.`;
|
|
403
464
|
const stars = item.starCount > 0 ? ` ${YELLOW}★ ${formatCount(item.starCount)}${RESET}` : '';
|
|
404
|
-
|
|
465
|
+
const codeFlag = runsCodeFlag(item) ? ` ${YELLOW}⚠ runs code${RESET}` : '';
|
|
466
|
+
print(` ${BOLD}${rank} ${item.name}${RESET}${stars}${codeFlag}`);
|
|
405
467
|
if (item.description) {
|
|
406
468
|
print(` ${DIM}${truncate(item.description, 88)}${RESET}`);
|
|
407
469
|
}
|
|
470
|
+
const evidenceLine = buildEvidenceLine(item.evidence, stackLabel);
|
|
471
|
+
if (evidenceLine) {
|
|
472
|
+
print(` ${DIM}${truncate(evidenceLine, 88)}${RESET}`);
|
|
473
|
+
}
|
|
408
474
|
print(` ${CYAN}${item.install.command}${RESET}`);
|
|
475
|
+
if (item.url) {
|
|
476
|
+
print(` ${DIM}${BASE_URL}${item.url}${RESET}`);
|
|
477
|
+
}
|
|
409
478
|
});
|
|
410
479
|
print('');
|
|
411
480
|
});
|
|
@@ -456,7 +525,9 @@ async function runInteractiveInstall(body) {
|
|
|
456
525
|
}
|
|
457
526
|
print('');
|
|
458
527
|
const chosen = await recommendPrompt('Install plugins:', installable.map(({ item, stack }) => ({
|
|
459
|
-
|
|
528
|
+
// Repeat the code-execution flag at the decision point — the list line
|
|
529
|
+
// above may have scrolled away by selection time.
|
|
530
|
+
label: `${item.name} (${formatStackLabel(stack)})${runsCodeFlag(item) ? ' ⚠ runs code' : ''}`,
|
|
460
531
|
selected: false,
|
|
461
532
|
})), RECOMMEND_MAX_SELECTIONS);
|
|
462
533
|
if (chosen === null || chosen.length === 0) {
|