claudepluginhub 0.16.0 → 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 +8 -27
- 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 +4 -0
- package/dist/download.js +12 -18
- package/dist/fetch.d.ts +4 -8
- package/dist/fetch.js +13 -19
- 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 +54 -56
- package/dist/recommend.js +69 -127
- package/dist/remove.d.ts +1 -1
- package/dist/remove.js +5 -10
- package/dist/update.js +5 -8
- 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,39 +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[];
|
|
54
|
+
/** Display names index-aligned with coInstalledWith. */
|
|
55
|
+
coInstalledNames?: string[];
|
|
78
56
|
} | null;
|
|
79
|
-
/** Site-relative detail-page URL
|
|
57
|
+
/** Site-relative detail-page URL. */
|
|
80
58
|
url?: string;
|
|
81
|
-
/** Present component types (presence only). Absent from pre-P2 servers. */
|
|
82
59
|
componentTypes?: string[];
|
|
83
60
|
/**
|
|
84
|
-
* Server-derived code-execution flag covering all six vectors
|
|
85
|
-
* (hooks/MCP/LSP/bin/monitors/workflows — the safe.json exclusion set).
|
|
86
61
|
* The ONLY source for the "runs code" warning: componentTypes cannot
|
|
87
|
-
* represent bin, so
|
|
88
|
-
* servers (no flag shown rather than a wrong one).
|
|
62
|
+
* represent bin, so inferring from them would under-warn.
|
|
89
63
|
*/
|
|
90
64
|
runsCode?: boolean;
|
|
91
|
-
/** Claimed/verified maintainer flag (absent from pre-P2 servers). */
|
|
92
65
|
hasVerifiedOwner?: boolean;
|
|
66
|
+
repoOwnerLogin?: string | null;
|
|
67
|
+
/** starCount is the PARENT repo's total (monorepo-subdir plugin). */
|
|
68
|
+
starsInherited?: boolean;
|
|
93
69
|
install: {
|
|
94
70
|
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
|
-
*/
|
|
71
|
+
/** Override commands are manual-only: never selectable, never executed. */
|
|
100
72
|
maintainerOverride: boolean;
|
|
101
73
|
/** Generated Claude Code fallback; null exactly when an override is set. */
|
|
102
74
|
claude: {
|
|
@@ -105,12 +77,38 @@ interface RecommendResultItem {
|
|
|
105
77
|
} | null;
|
|
106
78
|
};
|
|
107
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
|
+
}
|
|
108
103
|
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
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
|
+
}>;
|
|
115
113
|
export declare function runRecommend(argv: string[]): Promise<void>;
|
|
116
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,10 @@ 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
|
-
|
|
333
|
+
const coName = Array.isArray(evidence.coInstalledNames)
|
|
334
|
+
? evidence.coInstalledNames[0]
|
|
335
|
+
: undefined;
|
|
336
|
+
signals.push(`often copied alongside ${coName ?? evidence.coInstalledWith[0]}`);
|
|
370
337
|
}
|
|
371
338
|
if (evidence.recentInstalls90d >= EVIDENCE_MIN_INSTALLS) {
|
|
372
339
|
signals.push(`${evidence.recentInstalls90d} copy clicks in 90 days`);
|
|
@@ -375,27 +342,11 @@ export function buildEvidenceLine(evidence, stackLabel) {
|
|
|
375
342
|
return null;
|
|
376
343
|
return signals.slice(0, EVIDENCE_MAX_SIGNALS).join(' · ');
|
|
377
344
|
}
|
|
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
345
|
export function runsCodeFlag(item) {
|
|
384
346
|
return item.runsCode === true;
|
|
385
347
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
if (!json)
|
|
389
|
-
printBanner();
|
|
390
|
-
const signals = collectProjectSignals(process.cwd());
|
|
391
|
-
if (signals.dependencies.length === 0 && signals.files.length === 0) {
|
|
392
|
-
printError('No project manifests found in the current directory.\n' +
|
|
393
|
-
`Run from a project root, or browse ${BASE_URL}/tools/for-your-project`);
|
|
394
|
-
process.exit(1);
|
|
395
|
-
}
|
|
396
|
-
if (!json) {
|
|
397
|
-
printStep(`Detected ${signals.dependencies.length} dependencies, ${signals.files.length} project files`);
|
|
398
|
-
}
|
|
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) {
|
|
399
350
|
let response;
|
|
400
351
|
try {
|
|
401
352
|
response = await fetch(recommendUrl(source), {
|
|
@@ -410,32 +361,44 @@ export async function runRecommend(argv) {
|
|
|
410
361
|
});
|
|
411
362
|
}
|
|
412
363
|
catch (err) {
|
|
413
|
-
|
|
414
|
-
process.exit(1);
|
|
364
|
+
return { ok: false, error: `Network error: ${err.message}` };
|
|
415
365
|
}
|
|
416
366
|
if (!response.ok) {
|
|
417
367
|
if (response.status === 429) {
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
const message = await response
|
|
422
|
-
.json()
|
|
423
|
-
.then((body) => body.error)
|
|
424
|
-
.catch(() => null);
|
|
425
|
-
printError(message ?? `HTTP ${response.status}: ${response.statusText}`);
|
|
368
|
+
return { ok: false, error: 'Rate limit exceeded. Please wait a few minutes and try again.' };
|
|
426
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);
|
|
427
394
|
process.exit(1);
|
|
428
395
|
}
|
|
429
|
-
const body =
|
|
396
|
+
const body = fetched.body;
|
|
430
397
|
if (json) {
|
|
431
398
|
print(JSON.stringify(body, null, 2));
|
|
432
399
|
return;
|
|
433
400
|
}
|
|
434
|
-
//
|
|
435
|
-
// array is a server contract break / version skew — NOT "no data" — so surface
|
|
436
|
-
// it rather than masking it as the reassuring empty state below (mirrors the
|
|
437
|
-
// site picker, which lets a missing `results` throw into its error state so a
|
|
438
|
-
// 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.
|
|
439
402
|
if (!Array.isArray(body.sections)) {
|
|
440
403
|
printError('Unexpected response from the recommend API (missing sections). Please try again later.');
|
|
441
404
|
process.exit(1);
|
|
@@ -454,16 +417,18 @@ export async function runRecommend(argv) {
|
|
|
454
417
|
print(`${DIM}(also detected: ${body.droppedStacks.join(', ')} — showing your ${body.stacks.length} most specific stacks)${RESET}`);
|
|
455
418
|
}
|
|
456
419
|
print('');
|
|
457
|
-
// One "For {Stack}:" group per detected stack — each its own ranking, deduped
|
|
458
|
-
// server-side so a plugin never repeats across sections.
|
|
459
420
|
sections.forEach((section) => {
|
|
460
421
|
const stackLabel = formatStackLabel(section.stack);
|
|
461
422
|
print(`${BOLD}For ${stackLabel}:${RESET}`);
|
|
462
423
|
section.results.forEach((item, i) => {
|
|
463
424
|
const rank = `${String(i + 1).padStart(2)}.`;
|
|
464
|
-
const
|
|
425
|
+
const repoQualifier = item.starsInherited === true ? ' (repo)' : '';
|
|
426
|
+
const stars = item.starCount > 0
|
|
427
|
+
? ` ${YELLOW}★ ${formatCount(item.starCount)}${repoQualifier}${RESET}`
|
|
428
|
+
: '';
|
|
465
429
|
const codeFlag = runsCodeFlag(item) ? ` ${YELLOW}⚠ runs code${RESET}` : '';
|
|
466
|
-
|
|
430
|
+
const owner = item.repoOwnerLogin ? ` ${DIM}by ${item.repoOwnerLogin}${RESET}` : '';
|
|
431
|
+
print(` ${BOLD}${rank} ${item.name}${RESET}${owner}${stars}${codeFlag}`);
|
|
467
432
|
if (item.description) {
|
|
468
433
|
print(` ${DIM}${truncate(item.description, 88)}${RESET}`);
|
|
469
434
|
}
|
|
@@ -478,11 +443,9 @@ export async function runRecommend(argv) {
|
|
|
478
443
|
});
|
|
479
444
|
print('');
|
|
480
445
|
});
|
|
481
|
-
// Interactive install (TTY only). The footer prints AFTER the flow so the
|
|
482
|
-
// last line is always the refine link, whatever path was taken.
|
|
483
446
|
await runInteractiveInstall(body);
|
|
484
447
|
}
|
|
485
|
-
/** Always the last
|
|
448
|
+
/** Always the last line printed. Links the picker, not /for/[stack] (low-coverage stacks 404 there). */
|
|
486
449
|
function printFooter() {
|
|
487
450
|
print(`${DIM}Refine stacks: ${BASE_URL}/tools/for-your-project${RESET}`);
|
|
488
451
|
}
|
|
@@ -492,20 +455,14 @@ const STAGE_TO_FAILURE_CLASS = {
|
|
|
492
455
|
install: 'install_failed',
|
|
493
456
|
};
|
|
494
457
|
/**
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
* install each through the shared wrapper-marketplace path (identical to
|
|
498
|
-
* `p/<slug>`). Skipped entirely for non-TTY runs (both streams checked —
|
|
499
|
-
* stdin alone misses `recommend | cat`) and when nothing is natively
|
|
500
|
-
* 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.
|
|
501
460
|
*/
|
|
502
461
|
async function runInteractiveInstall(body) {
|
|
503
462
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
504
463
|
printFooter();
|
|
505
464
|
return;
|
|
506
465
|
}
|
|
507
|
-
// Maintainer-override items are manual-only and never selectable — their
|
|
508
|
-
// override command is already printed above and is NEVER executed here.
|
|
509
466
|
const installable = body.sections.flatMap((section) => section.results
|
|
510
467
|
.filter((item) => !item.install.maintainerOverride && item.install.claude !== null)
|
|
511
468
|
.map((item) => ({ item, stack: section.stack })));
|
|
@@ -513,11 +470,7 @@ async function runInteractiveInstall(body) {
|
|
|
513
470
|
printFooter();
|
|
514
471
|
return;
|
|
515
472
|
}
|
|
516
|
-
//
|
|
517
|
-
// error exit: the recommendations already printed successfully and the
|
|
518
|
-
// install tail is optional — checkClaudeCli() prints the actionable hint,
|
|
519
|
-
// then the run ends cleanly with the footer like every other skip path.
|
|
520
|
-
// (Exit 1 stays reserved for attempted installs that failed, below.)
|
|
473
|
+
// Not an error exit: exit 1 is reserved for attempted installs that failed.
|
|
521
474
|
if (!checkClaudeCli()) {
|
|
522
475
|
print('');
|
|
523
476
|
printFooter();
|
|
@@ -525,8 +478,7 @@ async function runInteractiveInstall(body) {
|
|
|
525
478
|
}
|
|
526
479
|
print('');
|
|
527
480
|
const chosen = await recommendPrompt('Install plugins:', installable.map(({ item, stack }) => ({
|
|
528
|
-
//
|
|
529
|
-
// above may have scrolled away by selection time.
|
|
481
|
+
// Repeated here: the list line may have scrolled away.
|
|
530
482
|
label: `${item.name} (${formatStackLabel(stack)})${runsCodeFlag(item) ? ' ⚠ runs code' : ''}`,
|
|
531
483
|
selected: false,
|
|
532
484
|
})), RECOMMEND_MAX_SELECTIONS);
|
|
@@ -543,10 +495,7 @@ async function runInteractiveInstall(body) {
|
|
|
543
495
|
printFooter();
|
|
544
496
|
return;
|
|
545
497
|
}
|
|
546
|
-
//
|
|
547
|
-
// exits cleanly with zero mutations. The reporting disclosure prints BEFORE
|
|
548
|
-
// this prompt — confirming is what leads to the outcome report, so the user
|
|
549
|
-
// must see it while declining still prevents the send.
|
|
498
|
+
// The reporting disclosure must print BEFORE the confirm, while declining still prevents the send.
|
|
550
499
|
print('');
|
|
551
500
|
print(`${BOLD}Selected:${RESET} ${selected.map(({ item }) => item.name).join(', ')}`);
|
|
552
501
|
print(`${DIM}Anonymous install outcomes are reported to claudepluginhub.com.${RESET}`);
|
|
@@ -567,8 +516,7 @@ async function runInteractiveInstall(body) {
|
|
|
567
516
|
outcomes.push({ slug: item.slug, status: 'failed', failureClass: 'fetch_failed' });
|
|
568
517
|
continue;
|
|
569
518
|
}
|
|
570
|
-
// Wrapper manifests name their single plugin after the slug
|
|
571
|
-
// installer verifies that by name instead of trusting plugins[0].
|
|
519
|
+
// Wrapper manifests name their single plugin after the slug.
|
|
572
520
|
const result = installPluginFromManifest(manifest, item.slug, manifestUrl, scope);
|
|
573
521
|
if (result.ok) {
|
|
574
522
|
printSuccess(item.name);
|
|
@@ -591,10 +539,7 @@ async function runInteractiveInstall(body) {
|
|
|
591
539
|
print('');
|
|
592
540
|
print(`${DIM}Manage: claude plugin list | claude plugin uninstall <name>${RESET}`);
|
|
593
541
|
print('');
|
|
594
|
-
//
|
|
595
|
-
// deliberately prints even when reportOutcomes skipped it (no proof from an
|
|
596
|
-
// older server, POST failure): over-disclosing beats a privacy notice
|
|
597
|
-
// 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.
|
|
598
543
|
print(`${DIM}Anonymous install outcomes are reported to claudepluginhub.com.${RESET}`);
|
|
599
544
|
printFooter();
|
|
600
545
|
if (failed > 0) {
|
|
@@ -602,11 +547,8 @@ async function runInteractiveInstall(body) {
|
|
|
602
547
|
}
|
|
603
548
|
}
|
|
604
549
|
/**
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
* names, paths, plugin inventories, command output, or raw error text. Any
|
|
608
|
-
* failure here is invisible and never changes the local install result; runs
|
|
609
|
-
* 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.
|
|
610
552
|
*/
|
|
611
553
|
async function reportOutcomes(proof, outcomes) {
|
|
612
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>;
|