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
package/dist/doctor/rules.d.ts
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import type { Finding, InstallationRecord, ScanResult } from './report.js';
|
|
2
2
|
import type { SelectionOutput } from './select.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* policy cannot drift.
|
|
4
|
+
* Single source of truth for finding severity (drives exit codes / --strict) and
|
|
5
|
+
* category (drives which output section shows it).
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Facts vs findings: capability inventory (hooks exist, MCP servers exist,
|
|
12
|
-
* env key names, monitors, estimates) lives on plugin entries as FIELDS. The
|
|
13
|
-
* findings list carries only actionable conditions — a healthy plugin with
|
|
14
|
-
* hooks and MCP servers produces zero findings.
|
|
15
|
-
*
|
|
16
|
-
* Remediation policy: inspection-first, never chained, never destructive on
|
|
17
|
-
* ambiguity. A mutating suggestion appears only when its target is
|
|
7
|
+
* Capability facts (hooks, MCP servers, estimates) live on plugin entries, not
|
|
8
|
+
* here: a healthy plugin produces zero findings. Remediations are
|
|
9
|
+
* inspection-first; a mutating suggestion appears only when its target is
|
|
18
10
|
* unambiguous from the finding itself.
|
|
19
11
|
*/
|
|
20
12
|
export declare const FINDING_CODES: {
|
|
@@ -138,6 +130,16 @@ export declare const FINDING_CODES: {
|
|
|
138
130
|
readonly category: "review";
|
|
139
131
|
readonly title: "Multiple LSP servers claim the same extension";
|
|
140
132
|
};
|
|
133
|
+
readonly skill_listing_over_budget: {
|
|
134
|
+
readonly severity: "warning";
|
|
135
|
+
readonly category: "review";
|
|
136
|
+
readonly title: "Skill listing is over its budget";
|
|
137
|
+
};
|
|
138
|
+
readonly skill_listing_over_small_budget: {
|
|
139
|
+
readonly severity: "info";
|
|
140
|
+
readonly category: "review";
|
|
141
|
+
readonly title: "Skill listing is over the budget on 200k-context models";
|
|
142
|
+
};
|
|
141
143
|
readonly scan_incomplete: {
|
|
142
144
|
readonly severity: "warning";
|
|
143
145
|
readonly category: "coverage";
|
|
@@ -153,15 +155,26 @@ export type FindingCode = keyof typeof FINDING_CODES;
|
|
|
153
155
|
export declare function makeFinding(code: FindingCode, message: string, pluginIds: string[], evidence?: Record<string, unknown>, remediation?: string): Finding;
|
|
154
156
|
export interface AnalysisInput {
|
|
155
157
|
selection: SelectionOutput;
|
|
156
|
-
/** Scan lookup by record (memoized per canonical root inside the scanner). */
|
|
157
158
|
scanFor: (record: InstallationRecord) => ScanResult;
|
|
158
159
|
droppedRecords: number;
|
|
159
|
-
/**
|
|
160
|
-
* only the specific duplicate_record group matching that key is suppressed. */
|
|
160
|
+
/** duplicateRecordKey()s resolved as scan-equivalent — only those duplicate_record groups are suppressed. */
|
|
161
161
|
scanEquivalentKeys: Set<string>;
|
|
162
|
+
/** Parsed SLASH_COMMAND_TOOL_CHAR_BUDGET; null/absent = the c48 model budgets. */
|
|
163
|
+
listingBudgetOverride?: number | null;
|
|
162
164
|
}
|
|
163
165
|
export interface AnalysisOutput {
|
|
164
166
|
global: Finding[];
|
|
165
167
|
byContext: Map<string, Finding[]>;
|
|
166
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Claude Code's skill listing budget, settled by oracle c48 (CLI 2.1.332; 2.1.333 identical):
|
|
171
|
+
* floor(context window × chars/token × 0.01), i.e. 30,000 on 1M-context models such as Opus 5.5
|
|
172
|
+
* and 8,000 on 200k-context models such as Sonnet 4.6 and Haiku 4.5. SLASH_COMMAND_TOOL_CHAR_BUDGET
|
|
173
|
+
* replaces it. Built-in skills took ~6,200 of the listing in c48's clean config.
|
|
174
|
+
*/
|
|
175
|
+
export declare const SKILL_LISTING_BUDGET_1M = 30000;
|
|
176
|
+
export declare const SKILL_LISTING_BUDGET_200K = 8000;
|
|
177
|
+
export declare const BUILT_IN_SKILL_LISTING_CHARS = 6200;
|
|
178
|
+
/** SLASH_COMMAND_TOOL_CHAR_BUDGET: a positive integer replaces the budget (c48 set 2500); anything else is ignored. */
|
|
179
|
+
export declare function parseListingBudgetOverride(value: string | undefined): number | null;
|
|
167
180
|
export declare function analyze(input: AnalysisInput): AnalysisOutput;
|
package/dist/doctor/rules.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import { boundEvidenceString, boundMessage, cappedList, compareFindings, MAX_EVIDENCE_ITEMS, MAX_PLUGIN_IDS_PER_FINDING, } from './report.js';
|
|
1
|
+
import { boundEvidenceString, boundMessage, cappedList, compareBytes, compareFindings, MAX_EVIDENCE_ITEMS, MAX_PLUGIN_IDS_PER_FINDING, } from './report.js';
|
|
2
2
|
import { isDependencyErrorKind } from './sanitize.js';
|
|
3
3
|
import { findOverlaps } from './overlap.js';
|
|
4
|
+
import { duplicateRecordKey } from './equivalence.js';
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* policy cannot drift.
|
|
6
|
+
* Single source of truth for finding severity (drives exit codes / --strict) and
|
|
7
|
+
* category (drives which output section shows it).
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Facts vs findings: capability inventory (hooks exist, MCP servers exist,
|
|
13
|
-
* env key names, monitors, estimates) lives on plugin entries as FIELDS. The
|
|
14
|
-
* findings list carries only actionable conditions — a healthy plugin with
|
|
15
|
-
* hooks and MCP servers produces zero findings.
|
|
16
|
-
*
|
|
17
|
-
* Remediation policy: inspection-first, never chained, never destructive on
|
|
18
|
-
* ambiguity. A mutating suggestion appears only when its target is
|
|
9
|
+
* Capability facts (hooks, MCP servers, estimates) live on plugin entries, not
|
|
10
|
+
* here: a healthy plugin produces zero findings. Remediations are
|
|
11
|
+
* inspection-first; a mutating suggestion appears only when its target is
|
|
19
12
|
* unambiguous from the finding itself.
|
|
20
13
|
*/
|
|
21
14
|
export const FINDING_CODES = {
|
|
@@ -43,6 +36,8 @@ export const FINDING_CODES = {
|
|
|
43
36
|
dependency_disabled: { severity: 'warning', category: 'review', title: 'Declared plugin dependency is disabled' },
|
|
44
37
|
dependency_resolution_unknown: { severity: 'info', category: 'coverage', title: 'Plugin dependency could not be verified' },
|
|
45
38
|
lsp_extension_conflict: { severity: 'warning', category: 'review', title: 'Multiple LSP servers claim the same extension' },
|
|
39
|
+
skill_listing_over_budget: { severity: 'warning', category: 'review', title: 'Skill listing is over its budget' },
|
|
40
|
+
skill_listing_over_small_budget: { severity: 'info', category: 'review', title: 'Skill listing is over the budget on 200k-context models' },
|
|
46
41
|
scan_incomplete: { severity: 'warning', category: 'coverage', title: 'Plugin scan hit a resource limit' },
|
|
47
42
|
symlink_skipped: { severity: 'warning', category: 'coverage', title: 'Symlinks skipped during scan' },
|
|
48
43
|
};
|
|
@@ -64,7 +59,6 @@ export function makeFinding(code, message, pluginIds, evidence, remediation) {
|
|
|
64
59
|
function evidenceList(values) {
|
|
65
60
|
return cappedList(values.map(boundEvidenceString), MAX_EVIDENCE_ITEMS);
|
|
66
61
|
}
|
|
67
|
-
/** Union of applicable records across contexts, deduplicated by identity. */
|
|
68
62
|
function unionApplicable(selection) {
|
|
69
63
|
const seen = new Set();
|
|
70
64
|
for (const context of selection.contexts) {
|
|
@@ -73,9 +67,7 @@ function unionApplicable(selection) {
|
|
|
73
67
|
}
|
|
74
68
|
return [...seen];
|
|
75
69
|
}
|
|
76
|
-
//
|
|
77
|
-
// Global rules (record/installation/scan level — same truth in every context)
|
|
78
|
-
// ---------------------------------------------------------------------------
|
|
70
|
+
// Global rules: record/installation/scan level, identical in every context.
|
|
79
71
|
function ruleRecordMalformed(dropped, out) {
|
|
80
72
|
if (dropped > 0) {
|
|
81
73
|
out.push(makeFinding('record_malformed', `${dropped} record(s) from \`claude plugin list --json\` were malformed and skipped.`, [], { droppedCount: dropped }));
|
|
@@ -90,7 +82,7 @@ function ruleScopeUnknown(records, out) {
|
|
|
90
82
|
function ruleDuplicateRecord(records, scanEquivalentKeys, out) {
|
|
91
83
|
const groups = new Map();
|
|
92
84
|
for (const record of records) {
|
|
93
|
-
const key =
|
|
85
|
+
const key = duplicateRecordKey(record);
|
|
94
86
|
const group = groups.get(key) ?? [];
|
|
95
87
|
group.push(record);
|
|
96
88
|
groups.set(key, group);
|
|
@@ -188,7 +180,7 @@ function ruleScans(records, scanFor, out) {
|
|
|
188
180
|
out.push(makeFinding(code, message, [pluginId], evidence, remediation));
|
|
189
181
|
},
|
|
190
182
|
};
|
|
191
|
-
for (const record of enabled.sort((a, b) => (a.id
|
|
183
|
+
for (const record of enabled.sort((a, b) => compareBytes(a.id, b.id))) {
|
|
192
184
|
collectScanIssues(record, scanFor(record), sink);
|
|
193
185
|
}
|
|
194
186
|
// Intentionally disabled records (no native errors): issues are
|
|
@@ -197,7 +189,7 @@ function ruleScans(records, scanFor, out) {
|
|
|
197
189
|
// "intentionally disabled": its claude_plugin_load_error (error severity)
|
|
198
190
|
// is the signal, and it must not also read as harmless housekeeping.
|
|
199
191
|
const disabledEmitted = new Set();
|
|
200
|
-
for (const record of disabled.sort((a, b) => (a.id
|
|
192
|
+
for (const record of disabled.sort((a, b) => compareBytes(a.id, b.id))) {
|
|
201
193
|
if (record.errors.length > 0)
|
|
202
194
|
continue;
|
|
203
195
|
const issues = [];
|
|
@@ -216,9 +208,7 @@ function ruleScans(records, scanFor, out) {
|
|
|
216
208
|
out.push(makeFinding('disabled_record_issue', `${record.id} (disabled) has issues in its cached installation: ${[...new Set(issues)].sort().join(', ')}. Harmless while disabled; shown for completeness.`, [record.id], { issues: evidenceList([...new Set(issues)].sort()) }));
|
|
217
209
|
}
|
|
218
210
|
}
|
|
219
|
-
//
|
|
220
|
-
// Context-scoped rules (run per project context, on unambiguous instances)
|
|
221
|
-
// ---------------------------------------------------------------------------
|
|
211
|
+
// Context-scoped rules: run per project context, on unambiguous instances.
|
|
222
212
|
function ruleAmbiguity(context, out) {
|
|
223
213
|
for (const instance of context.instances) {
|
|
224
214
|
if (instance.reason === 'scan_equivalent') {
|
|
@@ -308,7 +298,7 @@ function ruleLspConflicts(context, scanFor, out) {
|
|
|
308
298
|
}
|
|
309
299
|
}
|
|
310
300
|
}
|
|
311
|
-
for (const [extension, claimants] of [...claims.entries()].sort((a, b) => (a[0]
|
|
301
|
+
for (const [extension, claimants] of [...claims.entries()].sort((a, b) => compareBytes(a[0], b[0]))) {
|
|
312
302
|
if (claimants.length < 2)
|
|
313
303
|
continue;
|
|
314
304
|
const pluginIds = [...new Set(claimants.map((c) => c.pluginId))];
|
|
@@ -316,7 +306,76 @@ function ruleLspConflicts(context, scanFor, out) {
|
|
|
316
306
|
out.push(makeFinding('lsp_extension_conflict', `${claimants.length} enabled LSP servers claim ${extension}: ${names.join(', ')}. Per the documented first-wins behavior, only the first registered server starts and the others never do — registration order is not observable here, so no winner is asserted.`, pluginIds, { extension, servers: evidenceList(names) }));
|
|
317
307
|
}
|
|
318
308
|
}
|
|
319
|
-
|
|
309
|
+
/**
|
|
310
|
+
* Claude Code's skill listing budget, settled by oracle c48 (CLI 2.1.332; 2.1.333 identical):
|
|
311
|
+
* floor(context window × chars/token × 0.01), i.e. 30,000 on 1M-context models such as Opus 5.5
|
|
312
|
+
* and 8,000 on 200k-context models such as Sonnet 4.6 and Haiku 4.5. SLASH_COMMAND_TOOL_CHAR_BUDGET
|
|
313
|
+
* replaces it. Built-in skills took ~6,200 of the listing in c48's clean config.
|
|
314
|
+
*/
|
|
315
|
+
export const SKILL_LISTING_BUDGET_1M = 30_000;
|
|
316
|
+
export const SKILL_LISTING_BUDGET_200K = 8_000;
|
|
317
|
+
export const BUILT_IN_SKILL_LISTING_CHARS = 6_200;
|
|
318
|
+
/**
|
|
319
|
+
* One plugin's share of the listing: a `- <plugin>:<name>: <description>` line per listed skill or
|
|
320
|
+
* command plus the newline between lines. `disable-model-invocation` entries and skills without a
|
|
321
|
+
* description are not listed (c48); unreadable components are skipped, so this is a lower bound.
|
|
322
|
+
*/
|
|
323
|
+
function pluginListingChars(pluginName, scan) {
|
|
324
|
+
let total = 0;
|
|
325
|
+
for (const c of scan.components) {
|
|
326
|
+
if (c.type !== 'skill' && c.type !== 'command')
|
|
327
|
+
continue;
|
|
328
|
+
if (c.disableModelInvocation || !c.estimable)
|
|
329
|
+
continue;
|
|
330
|
+
if (c.type === 'skill' && c.description === null)
|
|
331
|
+
continue;
|
|
332
|
+
total += 2 + pluginName.length + 1 + c.listingChars + (c.description !== null ? 2 : 0) + 1;
|
|
333
|
+
}
|
|
334
|
+
return total;
|
|
335
|
+
}
|
|
336
|
+
function ruleSkillListingBudget(context, scanFor, budgetOverride, out) {
|
|
337
|
+
const contributors = context.instances
|
|
338
|
+
.flatMap((i) => i.selection === 'sole' && i.record !== null
|
|
339
|
+
? [{ id: i.id, chars: pluginListingChars(i.record.name, scanFor(i.record)) }]
|
|
340
|
+
: [])
|
|
341
|
+
.filter((c) => c.chars > 0)
|
|
342
|
+
.sort((a, b) => b.chars - a.chars || compareBytes(a.id, b.id));
|
|
343
|
+
const pluginChars = contributors.reduce((sum, c) => sum + c.chars, 0);
|
|
344
|
+
const listingChars = pluginChars + BUILT_IN_SKILL_LISTING_CHARS;
|
|
345
|
+
const n = (value) => value.toLocaleString('en-US');
|
|
346
|
+
let code;
|
|
347
|
+
let budget;
|
|
348
|
+
let over;
|
|
349
|
+
if (budgetOverride !== null) {
|
|
350
|
+
if (listingChars <= budgetOverride)
|
|
351
|
+
return;
|
|
352
|
+
code = 'skill_listing_over_budget';
|
|
353
|
+
budget = budgetOverride;
|
|
354
|
+
over = `the ${n(budget)} set by SLASH_COMMAND_TOOL_CHAR_BUDGET`;
|
|
355
|
+
}
|
|
356
|
+
else if (listingChars > SKILL_LISTING_BUDGET_1M) {
|
|
357
|
+
code = 'skill_listing_over_budget';
|
|
358
|
+
budget = SKILL_LISTING_BUDGET_1M;
|
|
359
|
+
over = `the ${n(budget)} budget on 1M-context models such as Opus 5.5`;
|
|
360
|
+
}
|
|
361
|
+
else if (listingChars > SKILL_LISTING_BUDGET_200K) {
|
|
362
|
+
code = 'skill_listing_over_small_budget';
|
|
363
|
+
budget = SKILL_LISTING_BUDGET_200K;
|
|
364
|
+
over = `the ${n(budget)} budget on 200k-context models such as Sonnet 4.6 and Haiku 4.5; it fits the ${n(SKILL_LISTING_BUDGET_1M)} on 1M-context models`;
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const largest = contributors.slice(0, 3).map((c) => `${c.id} ~${n(c.chars)}`);
|
|
370
|
+
out.push(makeFinding(code, `Plugin skills and commands add ~${n(pluginChars)} characters to Claude Code's skill listing (~${n(listingChars)} with built-in skills), over ${over}. Over budget, entries are shown by name only, without descriptions, so Claude is less likely to pick them. Largest: ${largest.join(', ')}.`, contributors.map((c) => c.id), { listingChars, pluginChars, builtInChars: BUILT_IN_SKILL_LISTING_CHARS, budget, largest: evidenceList(largest) }, 'Run `/skills` to turn some off, set `disable-model-invocation: true` on skills you only run by name, or disable plugins you do not use (`claude plugin disable <id>`). Your own user and project skills are not counted here, and a `skillListingBudgetFraction` setting changes the budget (Claude Code 2.1.332).'));
|
|
371
|
+
}
|
|
372
|
+
/** SLASH_COMMAND_TOOL_CHAR_BUDGET: a positive integer replaces the budget (c48 set 2500); anything else is ignored. */
|
|
373
|
+
export function parseListingBudgetOverride(value) {
|
|
374
|
+
if (value === undefined || !/^\d+$/.test(value.trim()))
|
|
375
|
+
return null;
|
|
376
|
+
const parsed = Number(value.trim());
|
|
377
|
+
return parsed > 0 ? parsed : null;
|
|
378
|
+
}
|
|
320
379
|
export function analyze(input) {
|
|
321
380
|
const { selection, scanFor, droppedRecords, scanEquivalentKeys } = input;
|
|
322
381
|
const applicable = unionApplicable(selection);
|
|
@@ -335,6 +394,7 @@ export function analyze(input) {
|
|
|
335
394
|
ruleBroadHooks(context, scanFor, findings);
|
|
336
395
|
ruleDependencies(context, scanFor, findings);
|
|
337
396
|
ruleLspConflicts(context, scanFor, findings);
|
|
397
|
+
ruleSkillListingBudget(context, scanFor, input.listingBudgetOverride ?? null, findings);
|
|
338
398
|
findings.sort(compareFindings);
|
|
339
399
|
byContext.set(context.context.key, findings);
|
|
340
400
|
}
|
package/dist/doctor/run.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface OpenReportResult {
|
|
|
16
16
|
path: string;
|
|
17
17
|
opened: boolean;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
19
|
+
/** Exclusive create: throws EEXIST rather than overwriting. */
|
|
20
20
|
export declare function writeReportFile(filePath: string, html: string): void;
|
|
21
21
|
export declare function openReport(report: DoctorReport, opener: BrowserOpener): Promise<OpenReportResult>;
|
|
22
22
|
export declare function buildDoctorReport(inputs: DoctorRunInputs): DoctorReport;
|
package/dist/doctor/run.js
CHANGED
|
@@ -7,13 +7,13 @@ import { canonicalize } from './paths.js';
|
|
|
7
7
|
import { selectEffective } from './select.js';
|
|
8
8
|
import { resolveEquivalences } from './equivalence.js';
|
|
9
9
|
import { createScanner } from './inventory.js';
|
|
10
|
-
import { analyze } from './rules.js';
|
|
10
|
+
import { analyze, parseListingBudgetOverride } from './rules.js';
|
|
11
11
|
import { estimatePlugin } from './estimate.js';
|
|
12
12
|
import { renderHuman, renderJson } from './render.js';
|
|
13
13
|
import { renderHtml } from './html-report.js';
|
|
14
14
|
import { defaultOpener } from './open-browser.js';
|
|
15
|
-
import { boundEvidenceString, cappedList, recapList, comparePluginEntries, DOCTOR_SCHEMA_VERSION, MAX_CAPABILITY_ITEMS, MAX_EFFECTIVE_PLUGINS_PER_CONTEXT, MAX_EVIDENCE_ITEMS, MAX_FINDINGS, MAX_PATHS_PER_TYPE, MAX_PLUGINS_PER_CONTEXT, MAX_TOP_CONTRIBUTORS, MAX_UNKNOWN_SCOPE_RECORDS, } from './report.js';
|
|
16
|
-
/**
|
|
15
|
+
import { boundEvidenceString, cappedList, recapList, compareBytes, comparePluginEntries, DOCTOR_SCHEMA_VERSION, MAX_CAPABILITY_ITEMS, MAX_EFFECTIVE_PLUGINS_PER_CONTEXT, MAX_EVIDENCE_ITEMS, MAX_FINDINGS, MAX_PATHS_PER_TYPE, MAX_PLUGINS_PER_CONTEXT, MAX_TOP_CONTRIBUTORS, MAX_UNKNOWN_SCOPE_RECORDS, } from './report.js';
|
|
16
|
+
/** Exclusive create: throws EEXIST rather than overwriting. */
|
|
17
17
|
export function writeReportFile(filePath, html) {
|
|
18
18
|
writeFileSync(filePath, html, { flag: 'wx', mode: 0o600 });
|
|
19
19
|
}
|
|
@@ -67,7 +67,7 @@ function capabilities(scan) {
|
|
|
67
67
|
hooks: {
|
|
68
68
|
total: scan.hooks.length,
|
|
69
69
|
byEvent: cappedList([...byEvent.entries()]
|
|
70
|
-
.sort((a, b) => (a[0]
|
|
70
|
+
.sort((a, b) => compareBytes(a[0], b[0]))
|
|
71
71
|
.map(([event, stats]) => ({ event, ...stats })), MAX_CAPABILITY_ITEMS),
|
|
72
72
|
},
|
|
73
73
|
mcp: cappedList(scan.mcp.map((m) => ({
|
|
@@ -119,7 +119,6 @@ function buildEffectivePlugins(contextSelection, scanFor) {
|
|
|
119
119
|
const estimate = instance.selection === 'sole' && scanned ? estimatePlugin(scan) : null;
|
|
120
120
|
const allScopes = cappedList([...new Set(instance.contenders.map((r) => r.scope))].sort(), MAX_CAPABILITY_ITEMS);
|
|
121
121
|
const allVersions = cappedList([...new Set(instance.contenders.map((r) => r.version))].sort(), MAX_CAPABILITY_ITEMS);
|
|
122
|
-
const isAmbiguous = instance.selection === 'ambiguous';
|
|
123
122
|
return {
|
|
124
123
|
id: instance.id,
|
|
125
124
|
selection: instance.selection,
|
|
@@ -129,7 +128,7 @@ function buildEffectivePlugins(contextSelection, scanFor) {
|
|
|
129
128
|
versions: allVersions,
|
|
130
129
|
estAlwaysOnTokens: estimate ? estimate.alwaysOnTokens : null,
|
|
131
130
|
estimated: estimate ? estimate.estimated : false,
|
|
132
|
-
inventoryIncomplete:
|
|
131
|
+
inventoryIncomplete: scan?.incomplete ?? false,
|
|
133
132
|
components: scanned ? componentSummaries(scan) : null,
|
|
134
133
|
capabilities: scanned ? capabilities(scan) : null,
|
|
135
134
|
largestOnInvoke: estimate ? estimate.largestOnInvoke : [],
|
|
@@ -225,7 +224,13 @@ export function buildDoctorReport(inputs) {
|
|
|
225
224
|
return scan;
|
|
226
225
|
};
|
|
227
226
|
const { resolved: selection, scanEquivalentKeys } = resolveEquivalences(baseSelection, scanFor);
|
|
228
|
-
const analysis = analyze({
|
|
227
|
+
const analysis = analyze({
|
|
228
|
+
selection,
|
|
229
|
+
scanFor,
|
|
230
|
+
droppedRecords,
|
|
231
|
+
scanEquivalentKeys,
|
|
232
|
+
listingBudgetOverride: parseListingBudgetOverride(process.env.SLASH_COMMAND_TOOL_CHAR_BUDGET),
|
|
233
|
+
});
|
|
229
234
|
const contexts = selection.contexts.map((contextSelection) => buildContextReport(contextSelection, analysis.byContext.get(contextSelection.context.key) ?? [], scanFor));
|
|
230
235
|
const allFindings = [...analysis.global, ...[...analysis.byContext.values()].flat()];
|
|
231
236
|
const summary = {
|
|
@@ -248,7 +253,7 @@ export function buildDoctorReport(inputs) {
|
|
|
248
253
|
findings: cappedList(analysis.global, MAX_FINDINGS),
|
|
249
254
|
unknownScopeRecords: cappedList(selection.unknownScopeRecords
|
|
250
255
|
.map((r) => ({ id: r.id, rawScope: r.rawScope, enabled: r.enabled }))
|
|
251
|
-
.sort((a, b) => (a.id
|
|
256
|
+
.sort((a, b) => compareBytes(a.id, b.id)), MAX_UNKNOWN_SCOPE_RECORDS),
|
|
252
257
|
summary,
|
|
253
258
|
scan: stats,
|
|
254
259
|
};
|
|
@@ -4,14 +4,6 @@ import type { CommandFact, NativePluginError } from './report.js';
|
|
|
4
4
|
* extension, env/header key) so hostile input cannot inflate the report.
|
|
5
5
|
*/
|
|
6
6
|
export declare function boundName(value: string): string;
|
|
7
|
-
/**
|
|
8
|
-
* Opaque credential-shaped token, tuned to leave real tool names alone:
|
|
9
|
-
* ≥20 chars AND either a solid base64/hex-ish run with no word separators
|
|
10
|
-
* (AKIA-style keys) or a mixed-case+digit blob (JWT segments, random
|
|
11
|
-
* tokens). Hyphenated lowercase names like `typescript-language-server`
|
|
12
|
-
* must survive — they are the diagnostic value.
|
|
13
|
-
*/
|
|
14
|
-
export declare function looksOpaque(token: string): boolean;
|
|
15
7
|
/** Reduce a URL to scheme://host[:port] — never path, query, fragment, userinfo. */
|
|
16
8
|
export declare function sanitizeUrlOrigin(raw: unknown): string;
|
|
17
9
|
/**
|
package/dist/doctor/sanitize.js
CHANGED
|
@@ -23,7 +23,7 @@ export function boundName(value) {
|
|
|
23
23
|
* tokens). Hyphenated lowercase names like `typescript-language-server`
|
|
24
24
|
* must survive — they are the diagnostic value.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
function looksOpaque(token) {
|
|
27
27
|
if (token.length < 20)
|
|
28
28
|
return false;
|
|
29
29
|
if (/^[A-Za-z0-9+/=_]+$/.test(token))
|
|
@@ -61,10 +61,6 @@ export function sanitizeCommand(command, args) {
|
|
|
61
61
|
}
|
|
62
62
|
return { form, executable };
|
|
63
63
|
}
|
|
64
|
-
// ---------------------------------------------------------------------------
|
|
65
|
-
// Native `errors` field (observed: array of human-readable strings; object
|
|
66
|
-
// elements with a `code` token tolerated as an alternate/future shape)
|
|
67
|
-
// ---------------------------------------------------------------------------
|
|
68
64
|
/** Documented dependency/load error codes (plugin-dependencies docs). */
|
|
69
65
|
const RECOGNIZED_CODES = new Set([
|
|
70
66
|
'dependency-unsatisfied',
|
|
@@ -144,7 +140,6 @@ export function sanitizeNativeErrors(raw) {
|
|
|
144
140
|
else if (element && typeof element === 'object' && !Array.isArray(element)) {
|
|
145
141
|
out.push(fromObject(element));
|
|
146
142
|
}
|
|
147
|
-
// other element shapes are ignored — tolerant by design
|
|
148
143
|
}
|
|
149
144
|
return out;
|
|
150
145
|
}
|
package/dist/doctor/select.d.ts
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
import type { DoctorFlags, EffectiveInstance, InstallationRecord, ProjectContext } from './report.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Records → per-context applicability → effective instances (one per context +
|
|
4
|
+
* plugin id).
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* 3. Effective instances — the unique runtime view per (context, plugin id).
|
|
6
|
+
* Default mode has one context (cwd); --all-projects adds one per distinct
|
|
7
|
+
* project/local projectPath. user/managed records apply in every context,
|
|
8
|
+
* project/local only in their own; analyses never aggregate across contexts.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* overlap, LSP conflicts, hook analysis, dependency resolution, and context
|
|
16
|
-
* estimates each run inside one context.
|
|
17
|
-
*
|
|
18
|
-
* Selection is conservative by design. The settings docs establish a
|
|
19
|
-
* precedence order for setting VALUES (managed > local > project > user) and
|
|
20
|
-
* say `enabledPlugins` merges across scopes, but no documented public rule or
|
|
21
|
-
* machine-readable field states which INSTANCE loads when the same plugin id
|
|
22
|
-
* is enabled at multiple scopes — or twice within one scope (observed in the
|
|
23
|
-
* wild). So: candidates that collapse to one (identical canonical installPath
|
|
24
|
-
* AND version — the shared-cache case) are 'sole'; anything else is
|
|
25
|
-
* 'ambiguous' and is excluded from aggregate analyses. There is deliberately
|
|
26
|
-
* NO precedence branch; a one-version experiment is not a public contract.
|
|
27
|
-
*
|
|
28
|
-
* Unknown scope strings (future Claude versions) are preserved for the report
|
|
29
|
-
* but excluded from analysis — never assumed globally applicable.
|
|
10
|
+
* No public rule says which INSTANCE loads when one plugin id is enabled more
|
|
11
|
+
* than once (settings precedence covers values, not instances), so there is
|
|
12
|
+
* deliberately no precedence branch: candidates collapsing to one canonical
|
|
13
|
+
* installPath + version are 'sole', anything else is 'ambiguous' and excluded
|
|
14
|
+
* from aggregate analyses. Unknown scopes are reported but never applied.
|
|
30
15
|
*/
|
|
31
16
|
export interface ContextSelection {
|
|
32
17
|
context: ProjectContext;
|
package/dist/doctor/select.js
CHANGED
|
@@ -31,7 +31,7 @@ function appliesToContext(record, context) {
|
|
|
31
31
|
if (record.scope === 'project' || record.scope === 'local') {
|
|
32
32
|
return record.projectPathCanonical === context.canonicalPath;
|
|
33
33
|
}
|
|
34
|
-
return false;
|
|
34
|
+
return false;
|
|
35
35
|
}
|
|
36
36
|
function passesScopeFilter(record, flags) {
|
|
37
37
|
if (flags.scope === 'all')
|
|
@@ -49,8 +49,7 @@ function selectWithinContext(context, applicable) {
|
|
|
49
49
|
}
|
|
50
50
|
const instances = [];
|
|
51
51
|
for (const [id, group] of [...byId.entries()].sort((a, b) => compareBytes(a[0], b[0]))) {
|
|
52
|
-
//
|
|
53
|
-
// candidate (the same cached directory enabled at several scopes).
|
|
52
|
+
// Same cached directory enabled at several scopes = one candidate.
|
|
54
53
|
const distinct = new Map();
|
|
55
54
|
for (const record of group) {
|
|
56
55
|
const key = `${record.installPathCanonical ?? record.installPath}\0${record.version}`;
|
package/dist/download.d.ts
CHANGED
|
@@ -2,12 +2,7 @@ import type { Scope } from './prompts.js';
|
|
|
2
2
|
import type { ComponentLock } from './lock.js';
|
|
3
3
|
export interface FlatComponent {
|
|
4
4
|
source: string;
|
|
5
|
-
/**
|
|
6
|
-
* Git ref (branch, tag or commit sha) the component is fetched from; null =
|
|
7
|
-
* the repo's default branch. Carried from the marketplace entry's
|
|
8
|
-
* `source.sha ?? source.ref` so pinned listings install — and update to —
|
|
9
|
-
* the content the hub indexed, not whatever the default branch holds.
|
|
10
|
-
*/
|
|
5
|
+
/** Branch, tag or commit to fetch from; null = default branch. Pinned listings install and update at the pin. */
|
|
11
6
|
ref: string | null;
|
|
12
7
|
type: 'command' | 'agent' | 'skill' | 'hook' | 'mcp' | 'lsp';
|
|
13
8
|
componentName: string;
|
package/dist/download.js
CHANGED
|
@@ -48,7 +48,6 @@ function isSafePath(destPath, baseDir) {
|
|
|
48
48
|
export async function downloadSkill(component, scope) {
|
|
49
49
|
const { source, sourcePath, componentName } = component;
|
|
50
50
|
const downloadSource = component.downloadPath ?? sourcePath;
|
|
51
|
-
// Strip /SKILL.md to get directory path (repo-root-relative for GitHub API)
|
|
52
51
|
const dirPath = downloadSource.replace(/\/SKILL\.md$/, '');
|
|
53
52
|
const branch = await resolveFetchRef(component);
|
|
54
53
|
if (!branch)
|
|
@@ -143,22 +142,17 @@ function isRecord(value) {
|
|
|
143
142
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
144
143
|
}
|
|
145
144
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* (extra fields fine, no enum of event names) so new Claude Code features
|
|
149
|
-
* don't get rejected; the point is to never write something Claude Code
|
|
150
|
-
* cannot parse at all.
|
|
145
|
+
* Deliberately loose shape checks (extra fields and unknown hook events pass):
|
|
146
|
+
* the goal is only to never write settings Claude Code cannot parse.
|
|
151
147
|
*/
|
|
152
148
|
function isValidMcpServerEntry(value) {
|
|
153
149
|
if (!isRecord(value))
|
|
154
150
|
return false;
|
|
155
|
-
// stdio servers need a command; remote servers need a url
|
|
156
151
|
return typeof value.command === 'string' || typeof value.url === 'string';
|
|
157
152
|
}
|
|
158
153
|
function isValidLspServerEntry(value) {
|
|
159
154
|
return isRecord(value) && typeof value.command === 'string';
|
|
160
155
|
}
|
|
161
|
-
/** A hook event's value: array of matcher groups, each with a hooks array of typed handlers. */
|
|
162
156
|
function isValidHookEventHandlers(value) {
|
|
163
157
|
if (!Array.isArray(value))
|
|
164
158
|
return false;
|
|
@@ -168,11 +162,10 @@ function isValidHookEventHandlers(value) {
|
|
|
168
162
|
}
|
|
169
163
|
async function resolveConfig(component) {
|
|
170
164
|
const { inlineConfig, source, sourcePath } = component;
|
|
171
|
-
// Inline config object — use directly
|
|
172
165
|
if (inlineConfig && typeof inlineConfig === 'object') {
|
|
173
166
|
return inlineConfig;
|
|
174
167
|
}
|
|
175
|
-
//
|
|
168
|
+
// A string is a path to the config file; absent means sourcePath.
|
|
176
169
|
if (typeof inlineConfig === 'string' || !inlineConfig) {
|
|
177
170
|
const filePath = typeof inlineConfig === 'string' ? inlineConfig : sourcePath;
|
|
178
171
|
const branch = await resolveFetchRef(component);
|
|
@@ -205,8 +198,7 @@ export async function mergeConfig(component, scope) {
|
|
|
205
198
|
const mcpConfig = config.mcpServers
|
|
206
199
|
? config.mcpServers
|
|
207
200
|
: config;
|
|
208
|
-
// Validate
|
|
209
|
-
// component is skipped loudly — never write config Claude Code can't parse.
|
|
201
|
+
// Validate before any write: one malformed entry skips the whole component.
|
|
210
202
|
const badMcpKeys = Object.keys(mcpConfig).filter((key) => !isValidMcpServerEntry(mcpConfig[key]));
|
|
211
203
|
if (badMcpKeys.length > 0) {
|
|
212
204
|
printError(`Skipping ${componentName}: malformed MCP server config (${badMcpKeys.join(', ')}) — each server needs a "command" or "url" string`);
|
|
@@ -262,7 +254,6 @@ export async function mergeConfig(component, scope) {
|
|
|
262
254
|
if (!Array.isArray(handlers))
|
|
263
255
|
continue;
|
|
264
256
|
const existing = (hooks[event] ?? []);
|
|
265
|
-
// Only add handlers not already present (by deep equality)
|
|
266
257
|
const newHandlers = handlers.filter((h) => !existing.some((e) => JSON.stringify(e) === JSON.stringify(h)));
|
|
267
258
|
if (newHandlers.length > 0) {
|
|
268
259
|
hooks[event] = [...existing, ...newHandlers];
|
|
@@ -316,7 +307,6 @@ export async function installComponent(component, scope, checkExisting) {
|
|
|
316
307
|
const lock = await downloadSingleFile(component, scope);
|
|
317
308
|
return lock ? { status: 'installed', lock } : { status: 'failed' };
|
|
318
309
|
}
|
|
319
|
-
// Config-based: hook, mcp, lsp
|
|
320
310
|
const lock = await mergeConfig(component, scope);
|
|
321
311
|
return lock ? { status: 'installed', lock } : { status: 'failed' };
|
|
322
312
|
}
|
package/dist/fetch.d.ts
CHANGED
|
@@ -28,16 +28,10 @@ export interface MarketplaceJSON {
|
|
|
28
28
|
}
|
|
29
29
|
export declare function resolveMarketplaceUrl(input: string): string | null;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
* component downloader can't cherry-pick
|
|
33
|
-
* (collection-install.ts) instead of the flatten/download path.
|
|
31
|
+
* Collections and wrapper marketplaces reference whole plugins, which the
|
|
32
|
+
* component downloader can't cherry-pick; both install via native delegation.
|
|
34
33
|
*/
|
|
35
34
|
export declare function isCollectionUrl(url: string): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Single-plugin wrapper marketplaces (/api/plugins/<slug>/marketplace.json)
|
|
38
|
-
* reference one whole plugin (source only) — like collections, they install
|
|
39
|
-
* via native delegation, not the flatten/download path.
|
|
40
|
-
*/
|
|
41
35
|
export declare function isPluginWrapperUrl(url: string): boolean;
|
|
42
36
|
export declare function fetchMarketplace(url: string): Promise<MarketplaceJSON | null>;
|
|
43
37
|
export declare function flattenComponents(manifest: MarketplaceJSON): FlatComponent[];
|
package/dist/fetch.js
CHANGED
|
@@ -2,7 +2,6 @@ import { printError, printWarning } from './output.js';
|
|
|
2
2
|
export const BASE_URL = 'https://claudepluginhub.com';
|
|
3
3
|
const ALLOWED_HOSTS = ['claudepluginhub.com', 'www.claudepluginhub.com'];
|
|
4
4
|
export function resolveMarketplaceUrl(input) {
|
|
5
|
-
// Full URL
|
|
6
5
|
if (input.startsWith('http://') || input.startsWith('https://')) {
|
|
7
6
|
try {
|
|
8
7
|
const parsed = new URL(input);
|
|
@@ -41,24 +40,18 @@ export function resolveMarketplaceUrl(input) {
|
|
|
41
40
|
return null;
|
|
42
41
|
}
|
|
43
42
|
/**
|
|
44
|
-
*
|
|
45
|
-
* component downloader can't cherry-pick
|
|
46
|
-
* (collection-install.ts) instead of the flatten/download path.
|
|
43
|
+
* Collections and wrapper marketplaces reference whole plugins, which the
|
|
44
|
+
* component downloader can't cherry-pick; both install via native delegation.
|
|
47
45
|
*/
|
|
48
46
|
export function isCollectionUrl(url) {
|
|
49
47
|
return url.includes('/api/collections/');
|
|
50
48
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Single-plugin wrapper marketplaces (/api/plugins/<slug>/marketplace.json)
|
|
53
|
-
* reference one whole plugin (source only) — like collections, they install
|
|
54
|
-
* via native delegation, not the flatten/download path.
|
|
55
|
-
*/
|
|
56
49
|
export function isPluginWrapperUrl(url) {
|
|
57
50
|
return url.includes('/api/plugins/');
|
|
58
51
|
}
|
|
59
52
|
export async function fetchMarketplace(url) {
|
|
60
53
|
try {
|
|
61
|
-
//
|
|
54
|
+
// ?source=cli attributes the fetch as a CLI install.
|
|
62
55
|
const parsed = new URL(url);
|
|
63
56
|
if (!parsed.searchParams.has('source')) {
|
|
64
57
|
parsed.searchParams.set('source', 'cli');
|
|
@@ -90,11 +83,7 @@ export async function fetchMarketplace(url) {
|
|
|
90
83
|
return null;
|
|
91
84
|
}
|
|
92
85
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Marketplace-entry component paths are `./`-prefixed per the plugin spec
|
|
95
|
-
* (paths relative to the plugin root). Strip the prefix before prefix checks
|
|
96
|
-
* and GitHub API calls — the downloader works with bare repo-relative paths.
|
|
97
|
-
*/
|
|
86
|
+
/** Marketplace component paths are `./`-prefixed; the downloader needs bare repo-relative paths. */
|
|
98
87
|
function stripDotSlash(path) {
|
|
99
88
|
return path.replace(/^\.\//, '');
|
|
100
89
|
}
|
|
@@ -103,11 +92,8 @@ export function flattenComponents(manifest) {
|
|
|
103
92
|
let skippedWholePlugin = 0;
|
|
104
93
|
for (const plugin of manifest.plugins) {
|
|
105
94
|
const repo = plugin.source.repo;
|
|
106
|
-
// Spec
|
|
107
|
-
// the repo's default branch (unpinned listing).
|
|
95
|
+
// Spec precedence: an exact commit wins over a branch/tag; null = default branch.
|
|
108
96
|
const ref = plugin.source.sha ?? plugin.source.ref ?? null;
|
|
109
|
-
// Whole-plugin references (git/git-subdir sources, no component arrays)
|
|
110
|
-
// can't be cherry-picked; they belong to the collection install path.
|
|
111
97
|
if (!repo) {
|
|
112
98
|
printWarning(`Skipping "${plugin.name}" — whole-plugin reference (component install can't cherry-pick it)`);
|
|
113
99
|
skippedWholePlugin++;
|
|
@@ -148,8 +134,7 @@ export function flattenComponents(manifest) {
|
|
|
148
134
|
if (plugin.skills) {
|
|
149
135
|
for (const rawPath of plugin.skills) {
|
|
150
136
|
const path = stripDotSlash(rawPath);
|
|
151
|
-
//
|
|
152
|
-
// e.g. "plugins/foo/skills/review/SKILL.md" -> "review"
|
|
137
|
+
// "plugins/foo/skills/review/SKILL.md" -> "review"
|
|
153
138
|
const withoutSkillMd = path.replace(/\/SKILL\.md$/, '');
|
|
154
139
|
const skillName = withoutSkillMd.split('/').pop() ?? withoutSkillMd;
|
|
155
140
|
components.push({
|