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.
- package/README.md +34 -1
- package/dist/args.js +0 -6
- package/dist/collection-install.d.ts +4 -23
- package/dist/collection-install.js +9 -45
- package/dist/component-install.js +7 -29
- package/dist/detect.d.ts +0 -2
- package/dist/detect.js +3 -7
- package/dist/doctor/claude-source.d.ts +4 -6
- package/dist/doctor/claude-source.js +1 -2
- package/dist/doctor/color.d.ts +0 -1
- package/dist/doctor/color.js +0 -1
- package/dist/doctor/equivalence.d.ts +1 -1
- package/dist/doctor/equivalence.js +68 -149
- package/dist/doctor/estimate.js +12 -61
- package/dist/doctor/html-report.d.ts +1 -6
- package/dist/doctor/html-report.js +43 -116
- package/dist/doctor/inventory.d.ts +10 -24
- package/dist/doctor/inventory.js +29 -63
- package/dist/doctor/overlap.d.ts +3 -6
- package/dist/doctor/render.js +20 -38
- package/dist/doctor/report.d.ts +7 -16
- package/dist/doctor/report.js +3 -6
- package/dist/doctor/rules.d.ts +6 -16
- package/dist/doctor/rules.js +13 -26
- package/dist/doctor/run.d.ts +1 -1
- package/dist/doctor/run.js +5 -6
- package/dist/doctor/sanitize.d.ts +0 -8
- package/dist/doctor/sanitize.js +1 -6
- package/dist/doctor/select.d.ts +10 -25
- package/dist/doctor/select.js +2 -3
- package/dist/download.d.ts +1 -6
- package/dist/download.js +4 -14
- package/dist/fetch.d.ts +2 -8
- package/dist/fetch.js +6 -21
- package/dist/github-install.js +1 -12
- package/dist/index.js +14 -22
- package/dist/install.js +1 -2
- package/dist/mcp/server.d.ts +25 -0
- package/dist/mcp/server.js +103 -0
- package/dist/mcp/tools.d.ts +73 -0
- package/dist/mcp/tools.js +231 -0
- package/dist/output.d.ts +0 -5
- package/dist/output.js +0 -12
- package/dist/prompts.d.ts +3 -10
- package/dist/prompts.js +5 -20
- package/dist/recommend.d.ts +51 -66
- package/dist/recommend.js +59 -132
- package/dist/remove.d.ts +1 -1
- package/dist/remove.js +5 -10
- package/dist/update.js +1 -5
- package/dist/validation.d.ts +0 -5
- package/dist/validation.js +3 -10
- package/dist/wrapper.d.ts +0 -1
- package/dist/wrapper.js +1 -8
- package/package.json +1 -1
package/dist/prompts.js
CHANGED
|
@@ -34,7 +34,6 @@ export async function checkboxPrompt(title, items) {
|
|
|
34
34
|
write(HIDE_CURSOR);
|
|
35
35
|
let cursor = 0;
|
|
36
36
|
const totalLines = items.length + 2; // title + hint + items
|
|
37
|
-
// Initial render
|
|
38
37
|
write(renderCheckbox(title, items, cursor));
|
|
39
38
|
try {
|
|
40
39
|
while (true) {
|
|
@@ -52,11 +51,9 @@ export async function checkboxPrompt(title, items) {
|
|
|
52
51
|
.map((item, i) => (item.selected ? i : -1))
|
|
53
52
|
.filter((i) => i !== -1);
|
|
54
53
|
}
|
|
55
|
-
// Space - toggle
|
|
56
54
|
if (str === ' ') {
|
|
57
55
|
items[cursor].selected = !items[cursor].selected;
|
|
58
56
|
}
|
|
59
|
-
// 'a' - toggle all
|
|
60
57
|
if (str === 'a') {
|
|
61
58
|
const allSelected = items.every((item) => item.selected);
|
|
62
59
|
for (const item of items) {
|
|
@@ -71,7 +68,6 @@ export async function checkboxPrompt(title, items) {
|
|
|
71
68
|
if (str === '\x1b[B' || str === 'j') {
|
|
72
69
|
cursor = cursor < items.length - 1 ? cursor + 1 : 0;
|
|
73
70
|
}
|
|
74
|
-
// Re-render
|
|
75
71
|
write(moveUp(totalLines - 1) + '\r');
|
|
76
72
|
write(renderCheckbox(title, items, cursor));
|
|
77
73
|
}
|
|
@@ -83,9 +79,8 @@ export async function checkboxPrompt(title, items) {
|
|
|
83
79
|
}
|
|
84
80
|
}
|
|
85
81
|
function renderRecommendSelect(title, items, cursor, maxSelected, atCap) {
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
// otherwise leave residue from the longer variant.
|
|
82
|
+
// CLEAR_LINE on every line: the cap hint changes width between renders and
|
|
83
|
+
// would otherwise leave residue from the longer variant.
|
|
89
84
|
const lines = [`${CLEAR_LINE}${BOLD}${title}${RESET}`];
|
|
90
85
|
const capHint = atCap ? `(max ${maxSelected} reached)` : `(max ${maxSelected})`;
|
|
91
86
|
lines.push(`${CLEAR_LINE}${DIM} Space=toggle Enter=confirm Ctrl+C=skip ${capHint}${RESET}`);
|
|
@@ -101,16 +96,9 @@ function renderRecommendSelect(title, items, cursor, maxSelected, atCap) {
|
|
|
101
96
|
return lines.join('\n');
|
|
102
97
|
}
|
|
103
98
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* - NO select-all: the 'a' key is ignored — recommendations are opt-in per
|
|
108
|
-
* item, never bulk-installed.
|
|
109
|
-
* - Hard selection cap: toggling ON past `maxSelected` is rejected with
|
|
110
|
-
* immediate hint feedback; toggling OFF always works.
|
|
111
|
-
* - Non-TTY fallback returns [] (select nothing) — recommend must never
|
|
112
|
-
* auto-install in a non-interactive run, unlike checkboxPrompt's
|
|
113
|
-
* all-selected fallback.
|
|
99
|
+
* Unlike `checkboxPrompt`, deliberately: no select-all, a hard cap of
|
|
100
|
+
* `maxSelected` (toggling off always works), and non-TTY returns [] so
|
|
101
|
+
* recommend never auto-installs.
|
|
114
102
|
*/
|
|
115
103
|
export async function recommendPrompt(title, items, maxSelected) {
|
|
116
104
|
if (!isInteractive()) {
|
|
@@ -140,13 +128,11 @@ export async function recommendPrompt(title, items, maxSelected) {
|
|
|
140
128
|
.map((item, i) => (item.selected ? i : -1))
|
|
141
129
|
.filter((i) => i !== -1);
|
|
142
130
|
}
|
|
143
|
-
// Space - toggle (ON only below the cap; OFF always allowed)
|
|
144
131
|
if (str === ' ') {
|
|
145
132
|
if (items[cursor].selected || selectedCount() < maxSelected) {
|
|
146
133
|
items[cursor].selected = !items[cursor].selected;
|
|
147
134
|
}
|
|
148
135
|
}
|
|
149
|
-
// NOTE: no 'a' (select-all) handler by design.
|
|
150
136
|
// Arrow up or 'k'
|
|
151
137
|
if (str === '\x1b[A' || str === 'k') {
|
|
152
138
|
cursor = cursor > 0 ? cursor - 1 : items.length - 1;
|
|
@@ -155,7 +141,6 @@ export async function recommendPrompt(title, items, maxSelected) {
|
|
|
155
141
|
if (str === '\x1b[B' || str === 'j') {
|
|
156
142
|
cursor = cursor < items.length - 1 ? cursor + 1 : 0;
|
|
157
143
|
}
|
|
158
|
-
// Re-render
|
|
159
144
|
write(moveUp(totalLines - 1) + '\r');
|
|
160
145
|
write(renderRecommendSelect(title, items, cursor, maxSelected, selectedCount() >= maxSelected));
|
|
161
146
|
}
|
package/dist/recommend.d.ts
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* FILENAMES (never file contents, never CLAUDE.md) and POSTs them to
|
|
5
|
-
* /api/recommend, where they resolve to vocabulary stacks server-side.
|
|
2
|
+
* Sends only manifest dependency NAMES and allowlisted config-filename
|
|
3
|
+
* prefixes (never file contents) to /api/recommend.
|
|
6
4
|
*/
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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.
|
|
6
|
+
* `?source=` analytics tag, allowlisted here and server-side (`resolveSource`).
|
|
7
|
+
* Unknown values are rejected so a typo can't degrade to the server's `web` fallback.
|
|
13
8
|
*/
|
|
14
9
|
declare const RECOMMEND_SOURCES: readonly ["cli", "plugin"];
|
|
15
10
|
export type RecommendSource = (typeof RECOMMEND_SOURCES)[number];
|
|
11
|
+
/** `--limit` is per detected stack, not a total. */
|
|
12
|
+
export declare const DEFAULT_LIMIT = 4;
|
|
16
13
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* Coupled surfaces when raising: the server's MAX_OUTCOMES cap
|
|
21
|
-
* (/api/recommend/outcome — must deploy FIRST, or over-cap outcome reports
|
|
22
|
-
* silently schema-reject) and the "up to 5" literal in index.ts help text.
|
|
14
|
+
* Selection-safety cap per interactive run. Raising it requires deploying the
|
|
15
|
+
* server's MAX_OUTCOMES cap (/api/recommend/outcome) FIRST, or over-cap reports
|
|
16
|
+
* silently schema-reject; also update "up to 5" in index.ts help text.
|
|
23
17
|
*/
|
|
24
18
|
export declare const RECOMMEND_MAX_SELECTIONS = 5;
|
|
25
19
|
export interface RecommendFlags {
|
|
@@ -30,11 +24,7 @@ export interface RecommendFlags {
|
|
|
30
24
|
export declare function parseRecommendFlags(argv: string[]): RecommendFlags;
|
|
31
25
|
export declare function parsePackageJsonDeps(content: string): string[];
|
|
32
26
|
export declare function parseRequirementsTxt(content: string): string[];
|
|
33
|
-
/**
|
|
34
|
-
* Line-based TOML walk (no TOML dependency): track the current `[section]`
|
|
35
|
-
* and collect what each section contributes. Regexes over whole sections
|
|
36
|
-
* break on inline arrays (`features = ["derive"]`), so never use those here.
|
|
37
|
-
*/
|
|
27
|
+
/** Line-based TOML walk: whole-section regexes break on inline arrays (`features = ["derive"]`). */
|
|
38
28
|
export declare function parsePyprojectToml(content: string): string[];
|
|
39
29
|
export declare function parseCargoToml(content: string): string[];
|
|
40
30
|
export declare function parseGoMod(content: string): string[];
|
|
@@ -42,21 +32,12 @@ export interface ProjectSignals {
|
|
|
42
32
|
dependencies: string[];
|
|
43
33
|
files: string[];
|
|
44
34
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Collect dependency names from known manifests in `cwd` plus telltale config
|
|
47
|
-
* filenames. Fail-soft per manifest: an unreadable or malformed file just
|
|
48
|
-
* contributes nothing (its filename still signals via `files`).
|
|
49
|
-
*/
|
|
35
|
+
/** Fail-soft per manifest: an unreadable or malformed file contributes no dependencies. */
|
|
50
36
|
export declare function collectProjectSignals(cwd: string): ProjectSignals;
|
|
51
37
|
/**
|
|
52
|
-
* Response subset the CLI renders.
|
|
53
|
-
* src/features/stack-recommendations/types.ts
|
|
54
|
-
*
|
|
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.
|
|
38
|
+
* Response subset the CLI renders. Keep in sync with RecommendSectionedResponse in
|
|
39
|
+
* src/features/stack-recommendations/types.ts. Optional fields are absent from
|
|
40
|
+
* older servers, so every read is guarded (published CLIs outlive deploys).
|
|
60
41
|
*/
|
|
61
42
|
interface RecommendResultItem {
|
|
62
43
|
slug: string;
|
|
@@ -64,52 +45,30 @@ interface RecommendResultItem {
|
|
|
64
45
|
description: string | null;
|
|
65
46
|
starCount: number;
|
|
66
47
|
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
|
-
*/
|
|
48
|
+
/** Null on cold-stack fallback results. */
|
|
73
49
|
evidence?: {
|
|
74
50
|
lift: number | null;
|
|
75
51
|
reuseCount: number;
|
|
76
52
|
recentInstalls90d: number;
|
|
77
53
|
coInstalledWith: string[];
|
|
78
|
-
/** Display names index-aligned with coInstalledWith
|
|
54
|
+
/** Display names index-aligned with coInstalledWith. */
|
|
79
55
|
coInstalledNames?: string[];
|
|
80
56
|
} | null;
|
|
81
|
-
/** Site-relative detail-page URL
|
|
57
|
+
/** Site-relative detail-page URL. */
|
|
82
58
|
url?: string;
|
|
83
|
-
/** Present component types (presence only). Absent from pre-P2 servers. */
|
|
84
59
|
componentTypes?: string[];
|
|
85
60
|
/**
|
|
86
|
-
* Server-derived code-execution flag covering all six vectors
|
|
87
|
-
* (hooks/MCP/LSP/bin/monitors/workflows — the safe.json exclusion set).
|
|
88
61
|
* The ONLY source for the "runs code" warning: componentTypes cannot
|
|
89
|
-
* represent bin, so
|
|
90
|
-
* servers (no flag shown rather than a wrong one).
|
|
62
|
+
* represent bin, so inferring from them would under-warn.
|
|
91
63
|
*/
|
|
92
64
|
runsCode?: boolean;
|
|
93
|
-
/** Claimed/verified maintainer flag (absent from pre-P2 servers). */
|
|
94
65
|
hasVerifiedOwner?: boolean;
|
|
95
|
-
/**
|
|
96
|
-
* GitHub owner login for name disambiguation (absent from pre-2026-08
|
|
97
|
-
* servers → the name renders alone).
|
|
98
|
-
*/
|
|
99
66
|
repoOwnerLogin?: string | null;
|
|
100
|
-
/**
|
|
101
|
-
* True for monorepo-subdir plugins whose starCount is the PARENT repo's
|
|
102
|
-
* total; rendered as a "(repo)" qualifier. Absent from pre-2026-08
|
|
103
|
-
* servers → no qualifier (never a guessed one).
|
|
104
|
-
*/
|
|
67
|
+
/** starCount is the PARENT repo's total (monorepo-subdir plugin). */
|
|
105
68
|
starsInherited?: boolean;
|
|
106
69
|
install: {
|
|
107
70
|
command: string;
|
|
108
|
-
/**
|
|
109
|
-
* True when `command` is a verified maintainer's override. Override items
|
|
110
|
-
* are manual-only: they never enter the interactive selector (their
|
|
111
|
-
* command is already printed in the section list) and are never executed.
|
|
112
|
-
*/
|
|
71
|
+
/** Override commands are manual-only: never selectable, never executed. */
|
|
113
72
|
maintainerOverride: boolean;
|
|
114
73
|
/** Generated Claude Code fallback; null exactly when an override is set. */
|
|
115
74
|
claude: {
|
|
@@ -118,12 +77,38 @@ interface RecommendResultItem {
|
|
|
118
77
|
} | null;
|
|
119
78
|
};
|
|
120
79
|
}
|
|
80
|
+
/** Server-signed receipt: echoed back VERBATIM to /api/recommend/outcome, never built or modified here. */
|
|
81
|
+
interface RecommendOutcomeProofItem {
|
|
82
|
+
pluginId: string;
|
|
83
|
+
slug: string;
|
|
84
|
+
rank: number;
|
|
85
|
+
stack: string;
|
|
86
|
+
}
|
|
87
|
+
interface RecommendOutcomeProof {
|
|
88
|
+
recommendId: string;
|
|
89
|
+
source: string;
|
|
90
|
+
issuedAt: number;
|
|
91
|
+
items: RecommendOutcomeProofItem[];
|
|
92
|
+
sig: string;
|
|
93
|
+
}
|
|
94
|
+
interface RecommendResponse {
|
|
95
|
+
stacks: string[];
|
|
96
|
+
droppedStacks?: string[];
|
|
97
|
+
sections: Array<{
|
|
98
|
+
stack: string;
|
|
99
|
+
results: RecommendResultItem[];
|
|
100
|
+
}>;
|
|
101
|
+
outcomeProof?: RecommendOutcomeProof;
|
|
102
|
+
}
|
|
121
103
|
export declare function buildEvidenceLine(evidence: RecommendResultItem['evidence'], stackLabel: string): string | null;
|
|
122
|
-
/**
|
|
123
|
-
* "⚠ runs code" marker. Strictly the server-derived `runsCode` field — never
|
|
124
|
-
* inferred from componentTypes (see the field doc: bin is unrepresentable
|
|
125
|
-
* there, so inference under-warns).
|
|
126
|
-
*/
|
|
127
104
|
export declare function runsCodeFlag(item: RecommendResultItem): boolean;
|
|
105
|
+
/** POSTs the signals to /api/recommend. Never prints or exits, so the MCP server can reuse it. */
|
|
106
|
+
export declare function fetchRecommendations(signals: ProjectSignals, limit: number, source: RecommendSource): Promise<{
|
|
107
|
+
ok: true;
|
|
108
|
+
body: RecommendResponse;
|
|
109
|
+
} | {
|
|
110
|
+
ok: false;
|
|
111
|
+
error: string;
|
|
112
|
+
}>;
|
|
128
113
|
export declare function runRecommend(argv: string[]): Promise<void>;
|
|
129
114
|
export {};
|
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
|
-
*
|
|
10
|
-
*
|
|
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
|
-
*
|
|
16
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
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
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
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 …)
|
|
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
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
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
|
-
|
|
391
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
396
|
+
const body = fetched.body;
|
|
434
397
|
if (json) {
|
|
435
398
|
print(JSON.stringify(body, null, 2));
|
|
436
399
|
return;
|
|
437
400
|
}
|
|
438
|
-
//
|
|
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
|
|
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
|
-
*
|
|
511
|
-
*
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
|
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
|
-
//
|
|
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
|
-
*
|
|
621
|
-
*
|
|
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(
|
|
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>;
|