claudepluginhub 0.16.1 → 0.18.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 +36 -2
- 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 +29 -16
- package/dist/doctor/rules.js +86 -26
- package/dist/doctor/run.d.ts +1 -1
- package/dist/doctor/run.js +13 -8
- 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
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { BASE_URL } from '../fetch.js';
|
|
3
|
+
import { DEFAULT_LIMIT as RECOMMEND_LIMIT, collectProjectSignals, fetchRecommendations } from '../recommend.js';
|
|
4
|
+
import { probeClaude } from '../doctor/claude-source.js';
|
|
5
|
+
import { canonicalize } from '../doctor/paths.js';
|
|
6
|
+
import { createScanner } from '../doctor/inventory.js';
|
|
7
|
+
import { buildDoctorReport } from '../doctor/run.js';
|
|
8
|
+
/**
|
|
9
|
+
* The four MCP tools. Definitions are deliberately terse: every byte here is sent to the model
|
|
10
|
+
* in every session that has the server enabled (budget enforced by mcp-server.test.ts).
|
|
11
|
+
*/
|
|
12
|
+
/** Canonical host for links shown to users (the apex 308s to www). */
|
|
13
|
+
const SITE = 'https://www.claudepluginhub.com';
|
|
14
|
+
const SLUG_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
15
|
+
const MAX_LIMIT = 10;
|
|
16
|
+
const DEFAULT_LIMIT = 5;
|
|
17
|
+
/** Component-type filter → `/api/plugins` boolean query flag. */
|
|
18
|
+
const TYPE_FLAGS = {
|
|
19
|
+
skill: 'skills',
|
|
20
|
+
agent: 'agents',
|
|
21
|
+
command: 'commands',
|
|
22
|
+
hook: 'hooks',
|
|
23
|
+
mcp: 'mcp',
|
|
24
|
+
outputStyle: 'outputStyles',
|
|
25
|
+
theme: 'themes',
|
|
26
|
+
monitor: 'monitors',
|
|
27
|
+
workflow: 'workflows',
|
|
28
|
+
};
|
|
29
|
+
/** Omitted → the server's cwd, which Claude Code sets to the project root. */
|
|
30
|
+
const projectDir = { type: 'string' };
|
|
31
|
+
export const TOOL_DEFINITIONS = [
|
|
32
|
+
{
|
|
33
|
+
name: 'search_plugins',
|
|
34
|
+
description: 'Search Claude Code plugins on ClaudePluginHub',
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
query: { type: 'string' },
|
|
39
|
+
type: { type: 'string', enum: Object.keys(TYPE_FLAGS) },
|
|
40
|
+
maxTokens: { type: 'integer', description: 'Max always-on tokens' },
|
|
41
|
+
noHooks: { type: 'boolean' },
|
|
42
|
+
limit: { type: 'integer', maximum: MAX_LIMIT },
|
|
43
|
+
},
|
|
44
|
+
required: ['query'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'inspect_plugin',
|
|
49
|
+
description: 'Plugin details: components, always-on tokens, code it runs, install command',
|
|
50
|
+
inputSchema: { type: 'object', properties: { slug: { type: 'string' } }, required: ['slug'] },
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'recommend_for_project',
|
|
54
|
+
description: "Recommend plugins for a project's stack",
|
|
55
|
+
inputSchema: { type: 'object', properties: { projectDir } },
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'doctor_setup',
|
|
59
|
+
description: 'Offline health check of installed plugins',
|
|
60
|
+
inputSchema: { type: 'object', properties: { projectDir } },
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
const ok = (value) => ({ content: [{ type: 'text', text: JSON.stringify(value) }] });
|
|
64
|
+
function optionalString(args, key) {
|
|
65
|
+
const value = args[key];
|
|
66
|
+
if (value === undefined)
|
|
67
|
+
return undefined;
|
|
68
|
+
if (typeof value !== 'string' || value.trim() === '')
|
|
69
|
+
throw new Error(`"${key}" must be a non-empty string`);
|
|
70
|
+
return value.trim();
|
|
71
|
+
}
|
|
72
|
+
function optionalInt(args, key, min, max) {
|
|
73
|
+
const value = args[key];
|
|
74
|
+
if (value === undefined)
|
|
75
|
+
return undefined;
|
|
76
|
+
if (typeof value !== 'number' || !Number.isInteger(value) || value < min || value > max) {
|
|
77
|
+
throw new Error(`"${key}" must be an integer ${min}-${max}`);
|
|
78
|
+
}
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
async function getJson(url, notFound) {
|
|
82
|
+
let res;
|
|
83
|
+
try {
|
|
84
|
+
res = await fetch(url, { signal: AbortSignal.timeout(15_000) });
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
throw new Error(`Network error: ${err.message}`);
|
|
88
|
+
}
|
|
89
|
+
if (res.status === 404)
|
|
90
|
+
throw new Error(notFound);
|
|
91
|
+
if (res.status === 429)
|
|
92
|
+
throw new Error('Rate limit exceeded. Try again in a few minutes.');
|
|
93
|
+
if (!res.ok)
|
|
94
|
+
throw new Error(`ClaudePluginHub returned HTTP ${res.status}`);
|
|
95
|
+
return res.json();
|
|
96
|
+
}
|
|
97
|
+
async function searchPlugins(args) {
|
|
98
|
+
const query = optionalString(args, 'query');
|
|
99
|
+
if (!query)
|
|
100
|
+
throw new Error('"query" is required');
|
|
101
|
+
const type = optionalString(args, 'type');
|
|
102
|
+
if (type !== undefined && !TYPE_FLAGS[type]) {
|
|
103
|
+
throw new Error(`"type" must be one of: ${Object.keys(TYPE_FLAGS).join(', ')}`);
|
|
104
|
+
}
|
|
105
|
+
const maxTokens = optionalInt(args, 'maxTokens', 0, Number.MAX_SAFE_INTEGER);
|
|
106
|
+
const limit = optionalInt(args, 'limit', 1, MAX_LIMIT) ?? DEFAULT_LIMIT;
|
|
107
|
+
if (args.noHooks !== undefined && typeof args.noHooks !== 'boolean')
|
|
108
|
+
throw new Error('"noHooks" must be a boolean');
|
|
109
|
+
const noHooks = args.noHooks === true;
|
|
110
|
+
// The free directory search the /plugins page uses — not Premium Power Search.
|
|
111
|
+
const url = new URL(`${BASE_URL}/api/plugins`);
|
|
112
|
+
url.searchParams.set('q', query.slice(0, 500));
|
|
113
|
+
if (type)
|
|
114
|
+
url.searchParams.set(TYPE_FLAGS[type], 'true');
|
|
115
|
+
const body = (await getJson(url.toString(), 'Search endpoint not found'));
|
|
116
|
+
if (!Array.isArray(body.items))
|
|
117
|
+
throw new Error('Unexpected response from ClaudePluginHub');
|
|
118
|
+
const results = body.items
|
|
119
|
+
.filter((p) => !noHooks || p.currentVersion?.hasHooksDetail !== true)
|
|
120
|
+
// An unknown estimate can't satisfy a token ceiling.
|
|
121
|
+
.filter((p) => maxTokens === undefined || (typeof p.alwaysOnTokens === 'number' && p.alwaysOnTokens <= maxTokens))
|
|
122
|
+
.slice(0, limit)
|
|
123
|
+
.map((p) => ({
|
|
124
|
+
slug: p.slug,
|
|
125
|
+
name: p.displayName ?? p.name,
|
|
126
|
+
description: p.description && p.description.length > 160 ? `${p.description.slice(0, 159)}…` : p.description,
|
|
127
|
+
alwaysOnTokens: p.alwaysOnTokens ?? null,
|
|
128
|
+
hasHooks: p.currentVersion?.hasHooksDetail ?? false,
|
|
129
|
+
hasMcp: p.currentVersion?.hasMcpDetail ?? false,
|
|
130
|
+
stars: p.starCount,
|
|
131
|
+
install: `npx claudepluginhub p/${p.slug}`,
|
|
132
|
+
url: `${SITE}/plugins/${p.slug}`,
|
|
133
|
+
}));
|
|
134
|
+
return ok({
|
|
135
|
+
results,
|
|
136
|
+
// Lives in the result, not the always-on definitions: list items carry no CLI refusal.
|
|
137
|
+
note: results.length > 0 ? 'Run inspect_plugin before installing: it shows Claude Code refusals.' : undefined,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async function inspectPlugin(args) {
|
|
141
|
+
const slug = optionalString(args, 'slug');
|
|
142
|
+
if (!slug || !SLUG_RE.test(slug))
|
|
143
|
+
throw new Error('"slug" must be a plugin slug like "my-plugin"');
|
|
144
|
+
const body = await getJson(`${BASE_URL}/api/plugins/${slug}`, `No plugin with slug "${slug}"`);
|
|
145
|
+
return ok(body);
|
|
146
|
+
}
|
|
147
|
+
async function recommendForProject(args) {
|
|
148
|
+
const dir = resolve(optionalString(args, 'projectDir') ?? process.cwd());
|
|
149
|
+
const signals = collectProjectSignals(dir);
|
|
150
|
+
if (signals.dependencies.length === 0 && signals.files.length === 0) {
|
|
151
|
+
throw new Error(`No project manifests found in ${dir}`);
|
|
152
|
+
}
|
|
153
|
+
// `cli` attribution: the server allowlists cli|plugin only, and this is the same npm package.
|
|
154
|
+
const fetched = await fetchRecommendations(signals, RECOMMEND_LIMIT, 'cli');
|
|
155
|
+
if (!fetched.ok)
|
|
156
|
+
throw new Error(fetched.error);
|
|
157
|
+
const { body } = fetched;
|
|
158
|
+
if (!Array.isArray(body.sections))
|
|
159
|
+
throw new Error('Unexpected response from the recommend API');
|
|
160
|
+
return ok({
|
|
161
|
+
stacks: body.stacks,
|
|
162
|
+
sections: body.sections.map((s) => ({
|
|
163
|
+
stack: s.stack,
|
|
164
|
+
plugins: s.results.map((r) => ({
|
|
165
|
+
slug: r.slug,
|
|
166
|
+
name: r.name,
|
|
167
|
+
stars: r.starCount,
|
|
168
|
+
runsCode: r.runsCode === true,
|
|
169
|
+
install: r.install.command,
|
|
170
|
+
url: `${SITE}/plugins/${r.slug}`,
|
|
171
|
+
})),
|
|
172
|
+
})),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function compactFinding(f) {
|
|
176
|
+
return {
|
|
177
|
+
severity: f.severity,
|
|
178
|
+
title: f.title,
|
|
179
|
+
message: f.message,
|
|
180
|
+
plugins: f.pluginIds.items,
|
|
181
|
+
...(f.remediation ? { fix: f.remediation } : {}),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function doctorSetup(args) {
|
|
185
|
+
const dir = resolve(optionalString(args, 'projectDir') ?? process.cwd());
|
|
186
|
+
const probe = probeClaude();
|
|
187
|
+
if (!probe.ok)
|
|
188
|
+
throw new Error(probe.reason);
|
|
189
|
+
const report = buildDoctorReport({
|
|
190
|
+
records: probe.records,
|
|
191
|
+
droppedRecords: probe.droppedRecords,
|
|
192
|
+
claudeVersion: probe.claudeVersion,
|
|
193
|
+
cwdCanonical: canonicalize(dir),
|
|
194
|
+
flags: { json: true, strict: false, verbose: false, open: false, scope: 'all', allProjects: false },
|
|
195
|
+
scanner: createScanner(),
|
|
196
|
+
});
|
|
197
|
+
const { errors, warnings } = report.summary;
|
|
198
|
+
return ok({
|
|
199
|
+
verdict: errors > 0 ? 'error' : warnings > 0 ? 'warning' : 'ok',
|
|
200
|
+
claudeVersion: report.claude.version,
|
|
201
|
+
summary: report.summary,
|
|
202
|
+
findings: report.findings.items.map(compactFinding),
|
|
203
|
+
contexts: report.contexts.map((c) => ({
|
|
204
|
+
label: c.label,
|
|
205
|
+
isCurrent: c.isCurrent,
|
|
206
|
+
alwaysOnTokens: c.summary.estimatedAlwaysOnTokens,
|
|
207
|
+
estimateComplete: c.summary.estimateComplete,
|
|
208
|
+
activePlugins: c.summary.activePlugins,
|
|
209
|
+
topContributors: c.contributors?.top ?? [],
|
|
210
|
+
findings: c.findings.items.map(compactFinding),
|
|
211
|
+
})),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const HANDLERS = {
|
|
215
|
+
search_plugins: searchPlugins,
|
|
216
|
+
inspect_plugin: inspectPlugin,
|
|
217
|
+
recommend_for_project: recommendForProject,
|
|
218
|
+
doctor_setup: doctorSetup,
|
|
219
|
+
};
|
|
220
|
+
export function hasTool(name) {
|
|
221
|
+
return Object.hasOwn(HANDLERS, name);
|
|
222
|
+
}
|
|
223
|
+
export async function callTool(name, args) {
|
|
224
|
+
// Every failure (bad input, upstream, doctor) is a tool result the model can read and act on.
|
|
225
|
+
try {
|
|
226
|
+
return await HANDLERS[name](args);
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
return { content: [{ type: 'text', text: err.message }], isError: true };
|
|
230
|
+
}
|
|
231
|
+
}
|
package/dist/output.d.ts
CHANGED
|
@@ -18,8 +18,3 @@ export declare function printStep(label: string): void;
|
|
|
18
18
|
export declare function printSuccess(label: string): void;
|
|
19
19
|
export declare function printProgress(label: string): void;
|
|
20
20
|
export declare function printFail(label: string, error?: string): void;
|
|
21
|
-
export declare function printSummary(results: {
|
|
22
|
-
name: string;
|
|
23
|
-
ok: boolean;
|
|
24
|
-
error?: string;
|
|
25
|
-
}[]): void;
|
package/dist/output.js
CHANGED
|
@@ -34,15 +34,3 @@ export function printProgress(label) {
|
|
|
34
34
|
export function printFail(label, error) {
|
|
35
35
|
print(` ${RED}fail${RESET} ${label}${error ? ` ${DIM}(${error})${RESET}` : ''}`);
|
|
36
36
|
}
|
|
37
|
-
export function printSummary(results) {
|
|
38
|
-
const succeeded = results.filter((r) => r.ok).length;
|
|
39
|
-
const failed = results.filter((r) => !r.ok).length;
|
|
40
|
-
print('');
|
|
41
|
-
if (failed === 0) {
|
|
42
|
-
print(`${GREEN}${BOLD}Done!${RESET} ${succeeded} plugin(s) installed successfully.`);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
print(`${YELLOW}${BOLD}Done.${RESET} ${succeeded} succeeded, ${failed} failed.`);
|
|
46
|
-
}
|
|
47
|
-
print('');
|
|
48
|
-
}
|
package/dist/prompts.d.ts
CHANGED
|
@@ -6,16 +6,9 @@ export interface SelectableItem {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function checkboxPrompt(title: string, items: SelectableItem[]): Promise<number[] | null>;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - NO select-all: the 'a' key is ignored — recommendations are opt-in per
|
|
13
|
-
* item, never bulk-installed.
|
|
14
|
-
* - Hard selection cap: toggling ON past `maxSelected` is rejected with
|
|
15
|
-
* immediate hint feedback; toggling OFF always works.
|
|
16
|
-
* - Non-TTY fallback returns [] (select nothing) — recommend must never
|
|
17
|
-
* auto-install in a non-interactive run, unlike checkboxPrompt's
|
|
18
|
-
* all-selected fallback.
|
|
9
|
+
* Unlike `checkboxPrompt`, deliberately: no select-all, a hard cap of
|
|
10
|
+
* `maxSelected` (toggling off always works), and non-TTY returns [] so
|
|
11
|
+
* recommend never auto-installs.
|
|
19
12
|
*/
|
|
20
13
|
export declare function recommendPrompt(title: string, items: SelectableItem[], maxSelected: number): Promise<number[] | null>;
|
|
21
14
|
export declare function confirmPrompt(message: string): Promise<boolean>;
|
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 {};
|