claudepluginhub 0.10.0 → 0.12.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 +82 -3
- package/dist/doctor/args.d.ts +12 -0
- package/dist/doctor/args.js +111 -0
- package/dist/doctor/claude-source.d.ts +27 -0
- package/dist/doctor/claude-source.js +115 -0
- package/dist/doctor/color.d.ts +11 -0
- package/dist/doctor/color.js +23 -0
- package/dist/doctor/equivalence.d.ts +9 -0
- package/dist/doctor/equivalence.js +263 -0
- package/dist/doctor/estimate.d.ts +30 -0
- package/dist/doctor/estimate.js +47 -0
- package/dist/doctor/html-report.d.ts +9 -0
- package/dist/doctor/html-report.js +385 -0
- package/dist/doctor/inventory.d.ts +69 -0
- package/dist/doctor/inventory.js +1175 -0
- package/dist/doctor/open-browser.d.ts +11 -0
- package/dist/doctor/open-browser.js +38 -0
- package/dist/doctor/overlap.d.ts +22 -0
- package/dist/doctor/overlap.js +23 -0
- package/dist/doctor/paths.d.ts +9 -0
- package/dist/doctor/paths.js +23 -0
- package/dist/doctor/render.d.ts +3 -0
- package/dist/doctor/render.js +353 -0
- package/dist/doctor/report.d.ts +347 -0
- package/dist/doctor/report.js +70 -0
- package/dist/doctor/rules.d.ts +167 -0
- package/dist/doctor/rules.js +342 -0
- package/dist/doctor/run.d.ts +24 -0
- package/dist/doctor/run.js +315 -0
- package/dist/doctor/sanitize.d.ts +28 -0
- package/dist/doctor/sanitize.js +150 -0
- package/dist/doctor/select.d.ts +53 -0
- package/dist/doctor/select.js +100 -0
- package/dist/doctor/wrap.d.ts +2 -0
- package/dist/doctor/wrap.js +84 -0
- package/dist/index.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared report model for `claudepluginhub doctor`.
|
|
3
|
+
*
|
|
4
|
+
* schemaVersion 1. Every list that grows with plugin count passes through
|
|
5
|
+
* cappedList() so the JSON stays bounded at hundreds of plugins; ordering is
|
|
6
|
+
* deterministic (byte-order comparators, fixed severity/scope ranks) so two
|
|
7
|
+
* runs over identical state produce byte-identical output. The model never
|
|
8
|
+
* carries absolute paths, file contents, env/header values, URL paths, or
|
|
9
|
+
* command strings — see sanitize.ts.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DOCTOR_SCHEMA_VERSION = 1;
|
|
12
|
+
export type Severity = 'error' | 'warning' | 'info';
|
|
13
|
+
export type FindingCategory = 'confirmed_problem' | 'review' | 'coverage' | 'maintenance';
|
|
14
|
+
export type ScopeFilter = 'user' | 'project' | 'local' | 'all';
|
|
15
|
+
export type KnownScope = 'user' | 'project' | 'local' | 'managed';
|
|
16
|
+
export type RecordScope = KnownScope | 'unknown';
|
|
17
|
+
export type SelectionReason = 'single' | 'shared_install' | 'scan_equivalent' | 'unresolved';
|
|
18
|
+
export interface DoctorFlags {
|
|
19
|
+
json: boolean;
|
|
20
|
+
strict: boolean;
|
|
21
|
+
verbose: boolean;
|
|
22
|
+
open: boolean;
|
|
23
|
+
scope: ScopeFilter;
|
|
24
|
+
allProjects: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sanitized native error from a record's optional `errors` field.
|
|
28
|
+
* Observed shape (spike 2026-07-18, Claude Code 2.1.212): array of
|
|
29
|
+
* human-readable strings; a record can stay enabled:true with an unsatisfied
|
|
30
|
+
* dependency. Object-with-`code` elements are tolerated as an alternate/future
|
|
31
|
+
* shape. Raw messages are never stored.
|
|
32
|
+
*/
|
|
33
|
+
export interface NativePluginError {
|
|
34
|
+
/** 'dependency-missing', a validated code token, or 'unknown'. */
|
|
35
|
+
kind: string;
|
|
36
|
+
recognized: boolean;
|
|
37
|
+
/** Our canonical text — never the raw native message. */
|
|
38
|
+
summary: string;
|
|
39
|
+
/** Present only when extracted AND strictly validated as a plugin id. */
|
|
40
|
+
dependencyId?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface InstallationRecord {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
marketplace: string;
|
|
46
|
+
version: string;
|
|
47
|
+
scope: RecordScope;
|
|
48
|
+
rawScope: string;
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
installPath: string;
|
|
51
|
+
installPathCanonical: string | null;
|
|
52
|
+
/** Internal only — never serialized into the report. */
|
|
53
|
+
projectPathCanonical: string | null;
|
|
54
|
+
errors: NativePluginError[];
|
|
55
|
+
}
|
|
56
|
+
export interface ProjectContext {
|
|
57
|
+
key: string;
|
|
58
|
+
/** Basename — display only, never identity (basenames can collide). */
|
|
59
|
+
label: string;
|
|
60
|
+
isCurrent: boolean;
|
|
61
|
+
/** Internal only — never serialized into the report. */
|
|
62
|
+
canonicalPath: string;
|
|
63
|
+
}
|
|
64
|
+
export type Selection = 'sole' | 'ambiguous';
|
|
65
|
+
export interface EffectiveInstance {
|
|
66
|
+
contextKey: string;
|
|
67
|
+
id: string;
|
|
68
|
+
selection: Selection;
|
|
69
|
+
reason: SelectionReason;
|
|
70
|
+
/** The selected record; null when ambiguous. */
|
|
71
|
+
record: InstallationRecord | null;
|
|
72
|
+
contenders: InstallationRecord[];
|
|
73
|
+
}
|
|
74
|
+
export type MdComponentType = 'skill' | 'command' | 'agent' | 'outputStyle';
|
|
75
|
+
export interface ComponentInfo {
|
|
76
|
+
type: MdComponentType;
|
|
77
|
+
relPath: string;
|
|
78
|
+
name: string | null;
|
|
79
|
+
description: string | null;
|
|
80
|
+
/** False when the bounded frontmatter reader could not understand the file. */
|
|
81
|
+
estimable: boolean;
|
|
82
|
+
nameDescChars: number;
|
|
83
|
+
bodyChars: number;
|
|
84
|
+
/** Normalized content hash — only for skill/command/agent. */
|
|
85
|
+
hash: string | null;
|
|
86
|
+
}
|
|
87
|
+
export type CommandForm = 'shell' | 'exec';
|
|
88
|
+
export interface CommandFact {
|
|
89
|
+
form: CommandForm;
|
|
90
|
+
/** Sanitized executable basename — see sanitize.ts. */
|
|
91
|
+
executable: string;
|
|
92
|
+
}
|
|
93
|
+
export interface HookFact {
|
|
94
|
+
event: string;
|
|
95
|
+
/** True only for the documented tool-matched events. */
|
|
96
|
+
toolMatched: boolean;
|
|
97
|
+
/** Matcher omitted / "" / "*" on a tool-matched event. */
|
|
98
|
+
broad: boolean;
|
|
99
|
+
/** Handler (or its entry) declares an `if` filter. */
|
|
100
|
+
conditional: boolean;
|
|
101
|
+
type: string;
|
|
102
|
+
command: CommandFact | null;
|
|
103
|
+
/** Origin-only URL for http hooks. */
|
|
104
|
+
targetOrigin: string | null;
|
|
105
|
+
}
|
|
106
|
+
export interface McpFact {
|
|
107
|
+
name: string;
|
|
108
|
+
kind: 'stdio' | 'remote' | 'unknown';
|
|
109
|
+
command: CommandFact | null;
|
|
110
|
+
targetOrigin: string | null;
|
|
111
|
+
/** Bounded at parse time; total/omitted describe the ORIGINAL key set. */
|
|
112
|
+
envKeys: CappedList<string>;
|
|
113
|
+
headerKeys: CappedList<string>;
|
|
114
|
+
/** null = prerequisite not checkable (env expansion / unresolvable form). */
|
|
115
|
+
commandFound: boolean | null;
|
|
116
|
+
}
|
|
117
|
+
export interface LspFact {
|
|
118
|
+
name: string;
|
|
119
|
+
command: CommandFact | null;
|
|
120
|
+
/** Bounded at parse time; total/omitted describe the ORIGINAL declaration. */
|
|
121
|
+
extensions: CappedList<string>;
|
|
122
|
+
languages: CappedList<string>;
|
|
123
|
+
commandFound: boolean | null;
|
|
124
|
+
}
|
|
125
|
+
export interface MonitorFact {
|
|
126
|
+
name: string | null;
|
|
127
|
+
when: string | null;
|
|
128
|
+
command: CommandFact | null;
|
|
129
|
+
}
|
|
130
|
+
export interface DependencyDecl {
|
|
131
|
+
name: string | null;
|
|
132
|
+
versionRange: string | null;
|
|
133
|
+
marketplace: string | null;
|
|
134
|
+
parseable: boolean;
|
|
135
|
+
}
|
|
136
|
+
export interface ManifestState {
|
|
137
|
+
present: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* True only when the manifest's content was actually read (and a parse was
|
|
140
|
+
* attempted). A manifest refused for containment or resource-limit reasons
|
|
141
|
+
* is present but NOT inspected — no content-derived claim (invalid JSON,
|
|
142
|
+
* invalid name, invalid fields, declared-missing) may be made about it.
|
|
143
|
+
*/
|
|
144
|
+
inspected: boolean;
|
|
145
|
+
parseError: boolean;
|
|
146
|
+
name: string | null;
|
|
147
|
+
nameInvalid: boolean;
|
|
148
|
+
/** Recognized fields carrying load-blocking wrong types. */
|
|
149
|
+
invalidFields: string[];
|
|
150
|
+
/** Explicitly declared paths that do not exist under the plugin root. */
|
|
151
|
+
declaredMissing: string[];
|
|
152
|
+
dependencies: DependencyDecl[];
|
|
153
|
+
}
|
|
154
|
+
export type PathIssue = 'missing' | 'unreadable' | 'not-directory';
|
|
155
|
+
export interface ScanResult {
|
|
156
|
+
pathIssue: PathIssue | null;
|
|
157
|
+
manifest: ManifestState;
|
|
158
|
+
components: ComponentInfo[];
|
|
159
|
+
themeFiles: string[];
|
|
160
|
+
hooks: HookFact[];
|
|
161
|
+
mcp: McpFact[];
|
|
162
|
+
lsp: LspFact[];
|
|
163
|
+
monitors: MonitorFact[];
|
|
164
|
+
bin: {
|
|
165
|
+
relPath: string;
|
|
166
|
+
executable: boolean;
|
|
167
|
+
}[];
|
|
168
|
+
/** Plugin-relative paths of JSON configs that could not be parsed. */
|
|
169
|
+
parseErrors: string[];
|
|
170
|
+
/** Plugin-relative paths of symlinks skipped (escape/cycle/unresolvable). */
|
|
171
|
+
symlinksSkipped: string[];
|
|
172
|
+
filesScanned: number;
|
|
173
|
+
bytesRead: number;
|
|
174
|
+
limitsHit: string[];
|
|
175
|
+
incomplete: boolean;
|
|
176
|
+
}
|
|
177
|
+
export interface CappedList<T> {
|
|
178
|
+
items: T[];
|
|
179
|
+
total: number;
|
|
180
|
+
omitted: number;
|
|
181
|
+
}
|
|
182
|
+
export interface Finding {
|
|
183
|
+
code: string;
|
|
184
|
+
severity: Severity;
|
|
185
|
+
category: FindingCategory;
|
|
186
|
+
title: string;
|
|
187
|
+
message: string;
|
|
188
|
+
pluginIds: CappedList<string>;
|
|
189
|
+
evidence?: Record<string, unknown>;
|
|
190
|
+
remediation?: string;
|
|
191
|
+
}
|
|
192
|
+
export interface ComponentTypeSummary {
|
|
193
|
+
count: number;
|
|
194
|
+
paths: CappedList<string>;
|
|
195
|
+
}
|
|
196
|
+
export interface PluginCapabilities {
|
|
197
|
+
hooks: {
|
|
198
|
+
total: number;
|
|
199
|
+
byEvent: CappedList<{
|
|
200
|
+
event: string;
|
|
201
|
+
count: number;
|
|
202
|
+
broad: number;
|
|
203
|
+
conditional: number;
|
|
204
|
+
}>;
|
|
205
|
+
};
|
|
206
|
+
mcp: CappedList<{
|
|
207
|
+
name: string;
|
|
208
|
+
kind: string;
|
|
209
|
+
executable: string | null;
|
|
210
|
+
targetOrigin: string | null;
|
|
211
|
+
envKeys: CappedList<string>;
|
|
212
|
+
headerKeys: CappedList<string>;
|
|
213
|
+
}>;
|
|
214
|
+
lsp: CappedList<{
|
|
215
|
+
name: string;
|
|
216
|
+
extensions: CappedList<string>;
|
|
217
|
+
languages: CappedList<string>;
|
|
218
|
+
}>;
|
|
219
|
+
monitors: CappedList<{
|
|
220
|
+
name: string | null;
|
|
221
|
+
when: string | null;
|
|
222
|
+
executable: string | null;
|
|
223
|
+
}>;
|
|
224
|
+
binCount: number;
|
|
225
|
+
}
|
|
226
|
+
export interface PluginEntry {
|
|
227
|
+
id: string;
|
|
228
|
+
version: string;
|
|
229
|
+
versionNote: string | null;
|
|
230
|
+
scope: RecordScope;
|
|
231
|
+
enabled: boolean;
|
|
232
|
+
selection: Selection | 'disabled';
|
|
233
|
+
nativeErrors: NativePluginError[];
|
|
234
|
+
components: Record<string, ComponentTypeSummary> | null;
|
|
235
|
+
capabilities: PluginCapabilities | null;
|
|
236
|
+
estAlwaysOnTokens: number | null;
|
|
237
|
+
estimated: boolean;
|
|
238
|
+
largestOnInvoke: {
|
|
239
|
+
path: string;
|
|
240
|
+
tokens: number;
|
|
241
|
+
}[];
|
|
242
|
+
inventoryIncomplete: boolean;
|
|
243
|
+
}
|
|
244
|
+
export interface EffectivePluginEntry {
|
|
245
|
+
id: string;
|
|
246
|
+
selection: Selection;
|
|
247
|
+
reason: SelectionReason;
|
|
248
|
+
recordCount: number;
|
|
249
|
+
scopes: CappedList<string>;
|
|
250
|
+
versions: CappedList<string>;
|
|
251
|
+
estAlwaysOnTokens: number | null;
|
|
252
|
+
estimated: boolean;
|
|
253
|
+
inventoryIncomplete: boolean;
|
|
254
|
+
components: Record<string, ComponentTypeSummary> | null;
|
|
255
|
+
capabilities: PluginCapabilities | null;
|
|
256
|
+
largestOnInvoke: {
|
|
257
|
+
path: string;
|
|
258
|
+
tokens: number;
|
|
259
|
+
}[];
|
|
260
|
+
}
|
|
261
|
+
export interface ContextContributors {
|
|
262
|
+
top: {
|
|
263
|
+
id: string;
|
|
264
|
+
tokens: number;
|
|
265
|
+
}[];
|
|
266
|
+
remainingCount: number;
|
|
267
|
+
remainingTokens: number;
|
|
268
|
+
}
|
|
269
|
+
export interface ContextReport {
|
|
270
|
+
key: string;
|
|
271
|
+
label: string;
|
|
272
|
+
isCurrent: boolean;
|
|
273
|
+
plugins: CappedList<PluginEntry>;
|
|
274
|
+
effectivePlugins: CappedList<EffectivePluginEntry>;
|
|
275
|
+
contributors: ContextContributors | null;
|
|
276
|
+
findings: CappedList<Finding>;
|
|
277
|
+
summary: {
|
|
278
|
+
activePlugins: number;
|
|
279
|
+
ambiguousPlugins: number;
|
|
280
|
+
disabledRecords: number;
|
|
281
|
+
estimatedAlwaysOnTokens: number | null;
|
|
282
|
+
estimateComplete: boolean;
|
|
283
|
+
confirmedProblems: number;
|
|
284
|
+
reviewItems: number;
|
|
285
|
+
coverageGaps: number;
|
|
286
|
+
maintenanceNotes: number;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
export interface DoctorReport {
|
|
290
|
+
schemaVersion: typeof DOCTOR_SCHEMA_VERSION;
|
|
291
|
+
claude: {
|
|
292
|
+
version: string | null;
|
|
293
|
+
};
|
|
294
|
+
options: {
|
|
295
|
+
scope: ScopeFilter;
|
|
296
|
+
allProjects: boolean;
|
|
297
|
+
strict: boolean;
|
|
298
|
+
};
|
|
299
|
+
contexts: ContextReport[];
|
|
300
|
+
/** Distinct project paths beyond MAX_CONTEXTS that were not analyzed. */
|
|
301
|
+
contextsOmitted: number;
|
|
302
|
+
findings: CappedList<Finding>;
|
|
303
|
+
unknownScopeRecords: CappedList<{
|
|
304
|
+
id: string;
|
|
305
|
+
rawScope: string;
|
|
306
|
+
enabled: boolean;
|
|
307
|
+
}>;
|
|
308
|
+
summary: {
|
|
309
|
+
errors: number;
|
|
310
|
+
warnings: number;
|
|
311
|
+
notes: number;
|
|
312
|
+
confirmedProblems: number;
|
|
313
|
+
reviewItems: number;
|
|
314
|
+
coverageGaps: number;
|
|
315
|
+
maintenanceNotes: number;
|
|
316
|
+
otherProjectRecordsIgnored: number;
|
|
317
|
+
};
|
|
318
|
+
scan: {
|
|
319
|
+
pluginsScanned: number;
|
|
320
|
+
filesScanned: number;
|
|
321
|
+
bytesRead: number;
|
|
322
|
+
truncated: boolean;
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
export declare const MAX_FINDINGS = 500;
|
|
326
|
+
export declare const MAX_PATHS_PER_TYPE = 50;
|
|
327
|
+
export declare const MAX_PLUGIN_IDS_PER_FINDING = 20;
|
|
328
|
+
export declare const MAX_EVIDENCE_ITEMS = 10;
|
|
329
|
+
export declare const MAX_EVIDENCE_STRING = 200;
|
|
330
|
+
export declare const MAX_MESSAGE_CHARS = 500;
|
|
331
|
+
export declare const MAX_CONTEXTS = 50;
|
|
332
|
+
export declare const MAX_PLUGINS_PER_CONTEXT = 200;
|
|
333
|
+
export declare const MAX_EFFECTIVE_PLUGINS_PER_CONTEXT = 200;
|
|
334
|
+
export declare const MAX_TOP_CONTRIBUTORS = 3;
|
|
335
|
+
export declare const MAX_UNKNOWN_SCOPE_RECORDS = 50;
|
|
336
|
+
export declare const MAX_CAPABILITY_ITEMS = 25;
|
|
337
|
+
export declare function cappedList<T>(items: T[], cap: number): CappedList<T>;
|
|
338
|
+
/**
|
|
339
|
+
* Re-cap an already-capped list to a smaller display cap while PRESERVING the
|
|
340
|
+
* original collection's total — never re-derive total from the retained items.
|
|
341
|
+
*/
|
|
342
|
+
export declare function recapList<T>(list: CappedList<T>, cap: number): CappedList<T>;
|
|
343
|
+
export declare function boundEvidenceString(value: string): string;
|
|
344
|
+
export declare function boundMessage(value: string): string;
|
|
345
|
+
export declare function compareBytes(a: string, b: string): number;
|
|
346
|
+
export declare function compareFindings(a: Finding, b: Finding): number;
|
|
347
|
+
export declare function comparePluginEntries(a: Pick<PluginEntry, 'id' | 'scope' | 'version'>, b: Pick<PluginEntry, 'id' | 'scope' | 'version'>): number;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared report model for `claudepluginhub doctor`.
|
|
3
|
+
*
|
|
4
|
+
* schemaVersion 1. Every list that grows with plugin count passes through
|
|
5
|
+
* cappedList() so the JSON stays bounded at hundreds of plugins; ordering is
|
|
6
|
+
* deterministic (byte-order comparators, fixed severity/scope ranks) so two
|
|
7
|
+
* runs over identical state produce byte-identical output. The model never
|
|
8
|
+
* carries absolute paths, file contents, env/header values, URL paths, or
|
|
9
|
+
* command strings — see sanitize.ts.
|
|
10
|
+
*/
|
|
11
|
+
export const DOCTOR_SCHEMA_VERSION = 1;
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Bounds & ordering
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
export const MAX_FINDINGS = 500;
|
|
16
|
+
export const MAX_PATHS_PER_TYPE = 50;
|
|
17
|
+
export const MAX_PLUGIN_IDS_PER_FINDING = 20;
|
|
18
|
+
export const MAX_EVIDENCE_ITEMS = 10;
|
|
19
|
+
export const MAX_EVIDENCE_STRING = 200;
|
|
20
|
+
export const MAX_MESSAGE_CHARS = 500;
|
|
21
|
+
export const MAX_CONTEXTS = 50;
|
|
22
|
+
export const MAX_PLUGINS_PER_CONTEXT = 200;
|
|
23
|
+
export const MAX_EFFECTIVE_PLUGINS_PER_CONTEXT = 200;
|
|
24
|
+
export const MAX_TOP_CONTRIBUTORS = 3;
|
|
25
|
+
export const MAX_UNKNOWN_SCOPE_RECORDS = 50;
|
|
26
|
+
export const MAX_CAPABILITY_ITEMS = 25;
|
|
27
|
+
export function cappedList(items, cap) {
|
|
28
|
+
const total = items.length;
|
|
29
|
+
const kept = items.slice(0, cap);
|
|
30
|
+
return { items: kept, total, omitted: total - kept.length };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Re-cap an already-capped list to a smaller display cap while PRESERVING the
|
|
34
|
+
* original collection's total — never re-derive total from the retained items.
|
|
35
|
+
*/
|
|
36
|
+
export function recapList(list, cap) {
|
|
37
|
+
const kept = list.items.slice(0, cap);
|
|
38
|
+
return { items: kept, total: list.total, omitted: list.total - kept.length };
|
|
39
|
+
}
|
|
40
|
+
function boundString(value, max) {
|
|
41
|
+
return value.length > max ? `${value.slice(0, max - 1)}…` : value;
|
|
42
|
+
}
|
|
43
|
+
export function boundEvidenceString(value) {
|
|
44
|
+
return boundString(value, MAX_EVIDENCE_STRING);
|
|
45
|
+
}
|
|
46
|
+
export function boundMessage(value) {
|
|
47
|
+
return boundString(value, MAX_MESSAGE_CHARS);
|
|
48
|
+
}
|
|
49
|
+
const SEVERITY_RANK = { error: 0, warning: 1, info: 2 };
|
|
50
|
+
const SCOPE_RANK = {
|
|
51
|
+
user: 0,
|
|
52
|
+
project: 1,
|
|
53
|
+
local: 2,
|
|
54
|
+
managed: 3,
|
|
55
|
+
unknown: 4,
|
|
56
|
+
};
|
|
57
|
+
export function compareBytes(a, b) {
|
|
58
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
59
|
+
}
|
|
60
|
+
export function compareFindings(a, b) {
|
|
61
|
+
return (SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity] ||
|
|
62
|
+
compareBytes(a.code, b.code) ||
|
|
63
|
+
compareBytes(a.pluginIds.items[0] ?? '', b.pluginIds.items[0] ?? '') ||
|
|
64
|
+
compareBytes(a.message, b.message));
|
|
65
|
+
}
|
|
66
|
+
export function comparePluginEntries(a, b) {
|
|
67
|
+
return (compareBytes(a.id, b.id) ||
|
|
68
|
+
SCOPE_RANK[a.scope] - SCOPE_RANK[b.scope] ||
|
|
69
|
+
compareBytes(a.version, b.version));
|
|
70
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { Finding, InstallationRecord, ScanResult } from './report.js';
|
|
2
|
+
import type { SelectionOutput } from './select.js';
|
|
3
|
+
/**
|
|
4
|
+
* The single source of truth for finding codes, severities, and categories.
|
|
5
|
+
* Rules and renderers both key off this table, so severity and category
|
|
6
|
+
* policy cannot drift.
|
|
7
|
+
*
|
|
8
|
+
* Category controls PRESENTATION tier (which output section a finding
|
|
9
|
+
* appears in). Severity controls exit codes and --strict behaviour.
|
|
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
|
|
18
|
+
* unambiguous from the finding itself.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FINDING_CODES: {
|
|
21
|
+
readonly record_malformed: {
|
|
22
|
+
readonly severity: "warning";
|
|
23
|
+
readonly category: "coverage";
|
|
24
|
+
readonly title: "Malformed plugin list record";
|
|
25
|
+
};
|
|
26
|
+
readonly claude_plugin_load_error: {
|
|
27
|
+
readonly severity: "error";
|
|
28
|
+
readonly category: "confirmed_problem";
|
|
29
|
+
readonly title: "Claude Code reports a plugin load error";
|
|
30
|
+
};
|
|
31
|
+
readonly install_path_missing: {
|
|
32
|
+
readonly severity: "error";
|
|
33
|
+
readonly category: "confirmed_problem";
|
|
34
|
+
readonly title: "Install path does not exist";
|
|
35
|
+
};
|
|
36
|
+
readonly install_path_unreadable: {
|
|
37
|
+
readonly severity: "error";
|
|
38
|
+
readonly category: "confirmed_problem";
|
|
39
|
+
readonly title: "Install path is not readable";
|
|
40
|
+
};
|
|
41
|
+
readonly install_path_not_directory: {
|
|
42
|
+
readonly severity: "error";
|
|
43
|
+
readonly category: "confirmed_problem";
|
|
44
|
+
readonly title: "Install path is not a directory";
|
|
45
|
+
};
|
|
46
|
+
readonly disabled_record_issue: {
|
|
47
|
+
readonly severity: "info";
|
|
48
|
+
readonly category: "maintenance";
|
|
49
|
+
readonly title: "Disabled installation has stale or invalid content";
|
|
50
|
+
};
|
|
51
|
+
readonly duplicate_record: {
|
|
52
|
+
readonly severity: "warning";
|
|
53
|
+
readonly category: "maintenance";
|
|
54
|
+
readonly title: "Duplicate installation record";
|
|
55
|
+
};
|
|
56
|
+
readonly redundant_enabled_records: {
|
|
57
|
+
readonly severity: "info";
|
|
58
|
+
readonly category: "maintenance";
|
|
59
|
+
readonly title: "Redundant enabled installation records";
|
|
60
|
+
};
|
|
61
|
+
readonly duplicate_enabled_records: {
|
|
62
|
+
readonly severity: "warning";
|
|
63
|
+
readonly category: "coverage";
|
|
64
|
+
readonly title: "Multiple enabled installation records";
|
|
65
|
+
};
|
|
66
|
+
readonly effective_selection_ambiguous: {
|
|
67
|
+
readonly severity: "warning";
|
|
68
|
+
readonly category: "coverage";
|
|
69
|
+
readonly title: "Effective plugin selection is ambiguous";
|
|
70
|
+
};
|
|
71
|
+
readonly scope_unknown: {
|
|
72
|
+
readonly severity: "info";
|
|
73
|
+
readonly category: "coverage";
|
|
74
|
+
readonly title: "Unrecognized plugin scope";
|
|
75
|
+
};
|
|
76
|
+
readonly manifest_invalid_json: {
|
|
77
|
+
readonly severity: "error";
|
|
78
|
+
readonly category: "confirmed_problem";
|
|
79
|
+
readonly title: "Plugin manifest is not valid JSON";
|
|
80
|
+
};
|
|
81
|
+
readonly manifest_invalid_name: {
|
|
82
|
+
readonly severity: "error";
|
|
83
|
+
readonly category: "confirmed_problem";
|
|
84
|
+
readonly title: "Plugin manifest name is invalid";
|
|
85
|
+
};
|
|
86
|
+
readonly manifest_field_invalid: {
|
|
87
|
+
readonly severity: "error";
|
|
88
|
+
readonly category: "confirmed_problem";
|
|
89
|
+
readonly title: "Plugin manifest field has an invalid type";
|
|
90
|
+
};
|
|
91
|
+
readonly declared_component_missing: {
|
|
92
|
+
readonly severity: "warning";
|
|
93
|
+
readonly category: "review";
|
|
94
|
+
readonly title: "Manifest-declared component path is missing";
|
|
95
|
+
};
|
|
96
|
+
readonly component_parse_error: {
|
|
97
|
+
readonly severity: "warning";
|
|
98
|
+
readonly category: "review";
|
|
99
|
+
readonly title: "Component configuration could not be parsed";
|
|
100
|
+
};
|
|
101
|
+
readonly exact_component_overlap: {
|
|
102
|
+
readonly severity: "warning";
|
|
103
|
+
readonly category: "review";
|
|
104
|
+
readonly title: "Exact component content overlap";
|
|
105
|
+
};
|
|
106
|
+
readonly hook_broad_unconditional: {
|
|
107
|
+
readonly severity: "warning";
|
|
108
|
+
readonly category: "review";
|
|
109
|
+
readonly title: "Broad unconditional command hook";
|
|
110
|
+
};
|
|
111
|
+
readonly prerequisite_missing: {
|
|
112
|
+
readonly severity: "warning";
|
|
113
|
+
readonly category: "review";
|
|
114
|
+
readonly title: "Declared executable not found on PATH";
|
|
115
|
+
};
|
|
116
|
+
readonly bin_not_executable: {
|
|
117
|
+
readonly severity: "warning";
|
|
118
|
+
readonly category: "review";
|
|
119
|
+
readonly title: "bin/ file is not executable";
|
|
120
|
+
};
|
|
121
|
+
readonly dependency_missing: {
|
|
122
|
+
readonly severity: "warning";
|
|
123
|
+
readonly category: "review";
|
|
124
|
+
readonly title: "Declared plugin dependency is not installed";
|
|
125
|
+
};
|
|
126
|
+
readonly dependency_disabled: {
|
|
127
|
+
readonly severity: "warning";
|
|
128
|
+
readonly category: "review";
|
|
129
|
+
readonly title: "Declared plugin dependency is disabled";
|
|
130
|
+
};
|
|
131
|
+
readonly dependency_resolution_unknown: {
|
|
132
|
+
readonly severity: "info";
|
|
133
|
+
readonly category: "coverage";
|
|
134
|
+
readonly title: "Plugin dependency could not be verified";
|
|
135
|
+
};
|
|
136
|
+
readonly lsp_extension_conflict: {
|
|
137
|
+
readonly severity: "warning";
|
|
138
|
+
readonly category: "review";
|
|
139
|
+
readonly title: "Multiple LSP servers claim the same extension";
|
|
140
|
+
};
|
|
141
|
+
readonly scan_incomplete: {
|
|
142
|
+
readonly severity: "warning";
|
|
143
|
+
readonly category: "coverage";
|
|
144
|
+
readonly title: "Plugin scan hit a resource limit";
|
|
145
|
+
};
|
|
146
|
+
readonly symlink_skipped: {
|
|
147
|
+
readonly severity: "warning";
|
|
148
|
+
readonly category: "coverage";
|
|
149
|
+
readonly title: "Symlinks skipped during scan";
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export type FindingCode = keyof typeof FINDING_CODES;
|
|
153
|
+
export declare function makeFinding(code: FindingCode, message: string, pluginIds: string[], evidence?: Record<string, unknown>, remediation?: string): Finding;
|
|
154
|
+
export interface AnalysisInput {
|
|
155
|
+
selection: SelectionOutput;
|
|
156
|
+
/** Scan lookup by record (memoized per canonical root inside the scanner). */
|
|
157
|
+
scanFor: (record: InstallationRecord) => ScanResult;
|
|
158
|
+
droppedRecords: number;
|
|
159
|
+
/** Composite keys (id\0rawScope\0projectPath\0version) resolved as scan-equivalent —
|
|
160
|
+
* only the specific duplicate_record group matching that key is suppressed. */
|
|
161
|
+
scanEquivalentKeys: Set<string>;
|
|
162
|
+
}
|
|
163
|
+
export interface AnalysisOutput {
|
|
164
|
+
global: Finding[];
|
|
165
|
+
byContext: Map<string, Finding[]>;
|
|
166
|
+
}
|
|
167
|
+
export declare function analyze(input: AnalysisInput): AnalysisOutput;
|