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,385 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-contained HTML report renderer for `claudepluginhub doctor --open`.
|
|
3
|
+
*
|
|
4
|
+
* Produces a complete <!DOCTYPE html> document with inlined CSS, no scripts,
|
|
5
|
+
* no external resources. Light/dark theme via prefers-color-scheme.
|
|
6
|
+
*/
|
|
7
|
+
import { formatApproxTokens } from './estimate.js';
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Escaping
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
export function escapeHtml(s) {
|
|
12
|
+
return s
|
|
13
|
+
.replace(/&/g, '&')
|
|
14
|
+
.replace(/</g, '<')
|
|
15
|
+
.replace(/>/g, '>')
|
|
16
|
+
.replace(/"/g, '"')
|
|
17
|
+
.replace(/'/g, ''');
|
|
18
|
+
}
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Helpers
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
function severityBadge(s) {
|
|
23
|
+
const cls = s === 'error' ? 'badge-error' : s === 'warning' ? 'badge-warning' : 'badge-info';
|
|
24
|
+
const label = s === 'error' ? 'ERROR' : s === 'warning' ? 'WARN' : 'INFO';
|
|
25
|
+
return `<span class="badge ${escapeHtml(cls)}">${label}</span>`;
|
|
26
|
+
}
|
|
27
|
+
function cappedNote(list) {
|
|
28
|
+
return list.omitted > 0 ? `<span class="dim"> (+${list.omitted} more)</span>` : '';
|
|
29
|
+
}
|
|
30
|
+
function renderFinding(f) {
|
|
31
|
+
const pluginList = f.pluginIds.items.length > 0
|
|
32
|
+
? `<div class="finding-plugins">Affects: ${f.pluginIds.items
|
|
33
|
+
.map((id) => `<code>${escapeHtml(id)}</code>`)
|
|
34
|
+
.join(', ')}${cappedNote(f.pluginIds)}</div>`
|
|
35
|
+
: '';
|
|
36
|
+
const remediation = f.remediation
|
|
37
|
+
? `<div class="finding-remediation"><strong>Remediation:</strong> ${escapeHtml(f.remediation)}</div>`
|
|
38
|
+
: '';
|
|
39
|
+
return `<div class="finding-card">
|
|
40
|
+
<div class="finding-header">${severityBadge(f.severity)} <span class="finding-title">${escapeHtml(f.title)}</span> <code class="finding-code">${escapeHtml(f.code)}</code></div>
|
|
41
|
+
<div class="finding-message">${escapeHtml(f.message)}</div>
|
|
42
|
+
${pluginList}${remediation}
|
|
43
|
+
</div>`;
|
|
44
|
+
}
|
|
45
|
+
function capsSummary(caps) {
|
|
46
|
+
const parts = [];
|
|
47
|
+
if (caps.hooks.total > 0)
|
|
48
|
+
parts.push(`hooks: ${caps.hooks.total}`);
|
|
49
|
+
if (caps.mcp.total > 0)
|
|
50
|
+
parts.push(`mcp: ${caps.mcp.total}`);
|
|
51
|
+
if (caps.lsp.total > 0)
|
|
52
|
+
parts.push(`lsp: ${caps.lsp.total}`);
|
|
53
|
+
if (caps.monitors.total > 0)
|
|
54
|
+
parts.push(`monitors: ${caps.monitors.total}`);
|
|
55
|
+
if (caps.binCount > 0)
|
|
56
|
+
parts.push(`bin: ${caps.binCount}`);
|
|
57
|
+
return parts.length > 0 ? parts.join(', ') : 'none';
|
|
58
|
+
}
|
|
59
|
+
function renderEffectivePlugin(ep) {
|
|
60
|
+
const tokenStr = ep.estAlwaysOnTokens != null ? formatApproxTokens(ep.estAlwaysOnTokens) + ' tok' : 'n/a';
|
|
61
|
+
const estimateNote = !ep.estimated ? ' <span class="dim">(incomplete estimate)</span>' : '';
|
|
62
|
+
const incompleteNote = ep.selection === 'ambiguous'
|
|
63
|
+
? ' <span class="dim">(active copy unresolved)</span>'
|
|
64
|
+
: ep.inventoryIncomplete
|
|
65
|
+
? ' <span class="dim">(scan incomplete)</span>'
|
|
66
|
+
: '';
|
|
67
|
+
const compRows = ep.components
|
|
68
|
+
? Object.entries(ep.components)
|
|
69
|
+
.filter(([, v]) => v.count > 0)
|
|
70
|
+
.map(([type, v]) => `<li><strong>${escapeHtml(type)}</strong>: ${v.count}${v.paths.items.length > 0 ? ` (${v.paths.items.map((p) => `<code>${escapeHtml(p)}</code>`).join(', ')}${cappedNote(v.paths)})` : ''}</li>`)
|
|
71
|
+
.join('\n')
|
|
72
|
+
: '';
|
|
73
|
+
const capsRow = ep.capabilities
|
|
74
|
+
? `<li><strong>Capabilities:</strong> ${escapeHtml(capsSummary(ep.capabilities))}</li>`
|
|
75
|
+
: '';
|
|
76
|
+
const invokeRows = ep.largestOnInvoke.length > 0
|
|
77
|
+
? `<li><strong>Largest on-invoke:</strong> ${ep.largestOnInvoke.map((l) => `<code>${escapeHtml(l.path)}</code> ${formatApproxTokens(l.tokens)} tok`).join(', ')}</li>`
|
|
78
|
+
: '';
|
|
79
|
+
return `<details class="plugin-detail">
|
|
80
|
+
<summary><code class="plugin-id">${escapeHtml(ep.id)}</code> <span class="dim">${escapeHtml(tokenStr)}${estimateNote}${incompleteNote}</span></summary>
|
|
81
|
+
<ul class="plugin-facts">
|
|
82
|
+
<li><strong>Status:</strong> ${ep.selection === 'ambiguous' ? 'active copy unresolved' : escapeHtml(ep.reason === 'scan_equivalent' ? 'active (equivalent records)' : 'active')}</li>
|
|
83
|
+
<li><strong>Records:</strong> ${ep.recordCount} — scopes: ${ep.scopes.items.map((s) => escapeHtml(s)).join(', ')}${ep.scopes.omitted > 0 ? ` (+${ep.scopes.omitted} more)` : ''} — versions: ${ep.versions.items.map((v) => `<code>${escapeHtml(v)}</code>`).join(', ')}${ep.versions.omitted > 0 ? ` (+${ep.versions.omitted} more)` : ''}</li>
|
|
84
|
+
${compRows}${capsRow}${invokeRows}
|
|
85
|
+
</ul>
|
|
86
|
+
</details>`;
|
|
87
|
+
}
|
|
88
|
+
function renderContextFootprint(ctx, multiContext) {
|
|
89
|
+
const heading = multiContext
|
|
90
|
+
? `${escapeHtml(ctx.key)} · ${escapeHtml(ctx.label)}`
|
|
91
|
+
: escapeHtml(ctx.label);
|
|
92
|
+
const label = heading + (ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : '');
|
|
93
|
+
const totalTok = ctx.summary.estimatedAlwaysOnTokens != null
|
|
94
|
+
? formatApproxTokens(ctx.summary.estimatedAlwaysOnTokens) + ' tok always-on'
|
|
95
|
+
: 'estimate unavailable';
|
|
96
|
+
const completeNote = !ctx.summary.estimateComplete ? ' (incomplete)' : '';
|
|
97
|
+
let barChart = '';
|
|
98
|
+
if (ctx.contributors && ctx.contributors.top.length > 0) {
|
|
99
|
+
const maxTok = ctx.contributors.top[0]?.tokens ?? 1;
|
|
100
|
+
const bars = ctx.contributors.top
|
|
101
|
+
.map((c) => {
|
|
102
|
+
const pct = maxTok > 0 ? Math.max(2, Math.round((c.tokens / maxTok) * 100)) : 2;
|
|
103
|
+
return `<div class="bar-row"><code class="bar-label">${escapeHtml(c.id)}</code><div class="bar-track"><div class="bar-fill" style="width:${pct}%"></div></div><span class="bar-value">${formatApproxTokens(c.tokens)}</span></div>`;
|
|
104
|
+
})
|
|
105
|
+
.join('\n');
|
|
106
|
+
const remainder = ctx.contributors.remainingCount > 0
|
|
107
|
+
? `<div class="dim bar-remainder">+${ctx.contributors.remainingCount} more with ${formatApproxTokens(ctx.contributors.remainingTokens)} tok combined</div>`
|
|
108
|
+
: '';
|
|
109
|
+
barChart = `<div class="bar-chart">${bars}${remainder}</div>`;
|
|
110
|
+
}
|
|
111
|
+
return `<div class="context-block">
|
|
112
|
+
<h3>${label}</h3>
|
|
113
|
+
<p>${escapeHtml(totalTok)}${escapeHtml(completeNote)} — ${ctx.summary.activePlugins} active plugin${ctx.summary.activePlugins !== 1 ? 's' : ''}</p>
|
|
114
|
+
${barChart}
|
|
115
|
+
</div>`;
|
|
116
|
+
}
|
|
117
|
+
function renderOmissions(report) {
|
|
118
|
+
const parts = [];
|
|
119
|
+
const multiContext = report.contexts.length > 1;
|
|
120
|
+
const findingsOmitted = report.findings.omitted +
|
|
121
|
+
report.contexts.reduce((sum, c) => sum + c.findings.omitted, 0);
|
|
122
|
+
if (findingsOmitted > 0) {
|
|
123
|
+
parts.push(`<p class="dim">${findingsOmitted} additional finding(s) not shown (report capped).</p>`);
|
|
124
|
+
}
|
|
125
|
+
if (report.contextsOmitted > 0) {
|
|
126
|
+
parts.push(`<p class="dim">${report.contextsOmitted} additional project context(s) were not analyzed.</p>`);
|
|
127
|
+
}
|
|
128
|
+
for (const ctx of report.contexts) {
|
|
129
|
+
const ctxName = multiContext
|
|
130
|
+
? `${escapeHtml(ctx.key)} · ${escapeHtml(ctx.label)}`
|
|
131
|
+
: escapeHtml(ctx.label);
|
|
132
|
+
if (ctx.effectivePlugins.omitted > 0) {
|
|
133
|
+
parts.push(`<p class="dim">${ctx.effectivePlugins.omitted} additional plugin(s) in ${ctxName} not shown.</p>`);
|
|
134
|
+
}
|
|
135
|
+
if (ctx.plugins.omitted > 0) {
|
|
136
|
+
parts.push(`<p class="dim">${ctx.plugins.omitted} inventory record(s) in ${ctxName} not shown.</p>`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return parts.length > 0 ? `<div class="omissions">${parts.join('\n')}</div>` : '';
|
|
140
|
+
}
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
// Verdict
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
function renderVerdict(report) {
|
|
145
|
+
const { confirmedProblems, reviewItems, coverageGaps } = report.summary;
|
|
146
|
+
const actionableCount = confirmedProblems + reviewItems;
|
|
147
|
+
if (actionableCount > 0) {
|
|
148
|
+
const cls = confirmedProblems > 0 ? 'verdict-fail' : 'verdict-warn';
|
|
149
|
+
const parts = [];
|
|
150
|
+
if (confirmedProblems > 0)
|
|
151
|
+
parts.push(`${confirmedProblems} confirmed problem${confirmedProblems !== 1 ? 's' : ''}`);
|
|
152
|
+
if (reviewItems > 0)
|
|
153
|
+
parts.push(`${reviewItems} review item${reviewItems !== 1 ? 's' : ''}`);
|
|
154
|
+
return `<div class="verdict ${cls}">${parts.join(', ')}</div>`;
|
|
155
|
+
}
|
|
156
|
+
if (coverageGaps > 0) {
|
|
157
|
+
return `<div class="verdict verdict-warn">Doctor could not fully verify ${coverageGaps} item${coverageGaps !== 1 ? 's' : ''}.</div>`;
|
|
158
|
+
}
|
|
159
|
+
return `<div class="verdict verdict-pass">No broken plugins found.</div>`;
|
|
160
|
+
}
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
// CSS
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
const CSS = `
|
|
165
|
+
:root {
|
|
166
|
+
--bg: #fff; --fg: #1a1a1a; --muted: #666; --border: #e0e0e0;
|
|
167
|
+
--card-bg: #fafafa; --code-bg: #f0f0f0;
|
|
168
|
+
--green: #16a34a; --red: #dc2626; --amber: #d97706; --blue: #2563eb;
|
|
169
|
+
--bar-fill: #6366f1;
|
|
170
|
+
}
|
|
171
|
+
@media (prefers-color-scheme: dark) {
|
|
172
|
+
:root {
|
|
173
|
+
--bg: #111; --fg: #e5e5e5; --muted: #999; --border: #333;
|
|
174
|
+
--card-bg: #1a1a1a; --code-bg: #252525;
|
|
175
|
+
--green: #4ade80; --red: #f87171; --amber: #fbbf24; --blue: #60a5fa;
|
|
176
|
+
--bar-fill: #818cf8;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
180
|
+
body { margin: 0; padding: 2rem 1rem; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); line-height: 1.6; overflow-wrap: break-word; word-break: break-word; }
|
|
181
|
+
.container { max-width: 52rem; margin: 0 auto; }
|
|
182
|
+
h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
|
|
183
|
+
h2 { font-size: 1.2rem; margin: 2rem 0 0.75rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }
|
|
184
|
+
h3 { font-size: 1rem; margin: 0.5rem 0 0.25rem; }
|
|
185
|
+
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.875em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 3px; }
|
|
186
|
+
.dim { color: var(--muted); }
|
|
187
|
+
.header-meta { color: var(--muted); font-size: 0.875rem; margin-bottom: 1.5rem; }
|
|
188
|
+
|
|
189
|
+
.verdict { padding: 0.75rem 1rem; border-radius: 6px; font-weight: 600; margin-bottom: 1.5rem; }
|
|
190
|
+
.verdict-pass { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green); }
|
|
191
|
+
.verdict-fail { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
|
|
192
|
+
.verdict-warn { background: color-mix(in srgb, var(--amber) 12%, transparent); color: var(--amber); }
|
|
193
|
+
|
|
194
|
+
.badge { display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 0.1em 0.5em; border-radius: 3px; text-transform: uppercase; vertical-align: middle; }
|
|
195
|
+
.badge-error { background: var(--red); color: #fff; }
|
|
196
|
+
.badge-warning { background: var(--amber); color: #000; }
|
|
197
|
+
.badge-info { background: var(--blue); color: #fff; }
|
|
198
|
+
|
|
199
|
+
.finding-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
|
|
200
|
+
.finding-header { margin-bottom: 0.35rem; }
|
|
201
|
+
.finding-title { font-weight: 600; }
|
|
202
|
+
.finding-code { font-size: 0.75rem; color: var(--muted); margin-left: 0.5rem; }
|
|
203
|
+
.finding-message { margin-bottom: 0.35rem; }
|
|
204
|
+
.finding-plugins { font-size: 0.875rem; margin-bottom: 0.25rem; }
|
|
205
|
+
.finding-remediation { font-size: 0.875rem; color: var(--muted); }
|
|
206
|
+
|
|
207
|
+
.context-block { margin-bottom: 1.25rem; }
|
|
208
|
+
.bar-chart { margin: 0.5rem 0; }
|
|
209
|
+
.bar-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
|
|
210
|
+
.bar-label { flex: 0 0 auto; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; }
|
|
211
|
+
.bar-track { flex: 1 1 auto; height: 0.6rem; background: var(--border); border-radius: 3px; overflow: hidden; }
|
|
212
|
+
.bar-fill { height: 100%; background: var(--bar-fill); border-radius: 3px; min-width: 2%; }
|
|
213
|
+
.bar-value { flex: 0 0 auto; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
|
|
214
|
+
.bar-remainder { font-size: 0.8rem; margin-top: 0.15rem; }
|
|
215
|
+
|
|
216
|
+
details.plugin-detail { margin-bottom: 0.5rem; }
|
|
217
|
+
details.plugin-detail > summary { cursor: pointer; padding: 0.35rem 0; }
|
|
218
|
+
details.plugin-detail > summary:hover { color: var(--blue); }
|
|
219
|
+
.plugin-id { font-weight: 600; }
|
|
220
|
+
.plugin-facts { margin: 0.25rem 0 0.5rem 1.25rem; font-size: 0.875rem; }
|
|
221
|
+
.plugin-facts li { margin-bottom: 0.2rem; }
|
|
222
|
+
|
|
223
|
+
.footer { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--muted); }
|
|
224
|
+
|
|
225
|
+
@media print {
|
|
226
|
+
details > *:not(summary) { display: block !important; }
|
|
227
|
+
.verdict { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
|
|
228
|
+
.badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@media (max-width: 600px) {
|
|
232
|
+
body { padding: 1rem 0.5rem; }
|
|
233
|
+
.bar-label { max-width: 8rem; }
|
|
234
|
+
}
|
|
235
|
+
`;
|
|
236
|
+
// ---------------------------------------------------------------------------
|
|
237
|
+
// Main renderer
|
|
238
|
+
// ---------------------------------------------------------------------------
|
|
239
|
+
export function renderHtml(report) {
|
|
240
|
+
const version = report.claude.version ? `v${escapeHtml(report.claude.version)}` : 'unknown';
|
|
241
|
+
const scopeLabel = escapeHtml(report.options.scope);
|
|
242
|
+
const opts = [
|
|
243
|
+
`scope: ${scopeLabel}`,
|
|
244
|
+
report.options.allProjects ? 'all-projects' : null,
|
|
245
|
+
report.options.strict ? 'strict' : null,
|
|
246
|
+
]
|
|
247
|
+
.filter(Boolean)
|
|
248
|
+
.join(' | ');
|
|
249
|
+
// --- Issues (confirmed_problem + review) --------------------------------
|
|
250
|
+
const globalIssues = report.findings.items.filter((f) => f.category === 'confirmed_problem' || f.category === 'review');
|
|
251
|
+
const globalCoverage = report.findings.items.filter((f) => f.category === 'coverage');
|
|
252
|
+
const multiContext = report.contexts.length > 1;
|
|
253
|
+
let issuesHtml = '';
|
|
254
|
+
if (multiContext) {
|
|
255
|
+
const parts = [];
|
|
256
|
+
if (globalIssues.length > 0) {
|
|
257
|
+
parts.push(`<h3>Installation-wide</h3>\n${globalIssues.map(renderFinding).join('\n')}`);
|
|
258
|
+
}
|
|
259
|
+
for (const ctx of report.contexts) {
|
|
260
|
+
const ctxIssues = ctx.findings.items.filter((f) => f.category === 'confirmed_problem' || f.category === 'review');
|
|
261
|
+
if (ctxIssues.length > 0) {
|
|
262
|
+
parts.push(`<h3>${escapeHtml(ctx.key)} · ${escapeHtml(ctx.label)}${ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : ''}</h3>\n${ctxIssues.map(renderFinding).join('\n')}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (parts.length > 0) {
|
|
266
|
+
issuesHtml = `<h2>Issues</h2>\n${parts.join('\n')}`;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
const allIssues = [
|
|
271
|
+
...globalIssues,
|
|
272
|
+
...report.contexts.flatMap((c) => c.findings.items.filter((f) => f.category === 'confirmed_problem' || f.category === 'review')),
|
|
273
|
+
];
|
|
274
|
+
issuesHtml = allIssues.length > 0
|
|
275
|
+
? `<h2>Issues</h2>\n${allIssues.map(renderFinding).join('\n')}`
|
|
276
|
+
: '';
|
|
277
|
+
}
|
|
278
|
+
// --- Context footprint ---------------------------------------------------
|
|
279
|
+
const sorted = [...report.contexts].sort((a, b) => a.isCurrent === b.isCurrent ? 0 : a.isCurrent ? -1 : 1);
|
|
280
|
+
const contextHtml = sorted.length > 0
|
|
281
|
+
? `<h2>Context Footprint</h2>\n${sorted.map((c) => renderContextFootprint(c, multiContext)).join('\n')}`
|
|
282
|
+
: '';
|
|
283
|
+
// --- Coverage notes ------------------------------------------------------
|
|
284
|
+
let coverageHtml = '';
|
|
285
|
+
if (multiContext) {
|
|
286
|
+
const parts = [];
|
|
287
|
+
if (globalCoverage.length > 0) {
|
|
288
|
+
parts.push(`<h3>Installation-wide</h3>\n${globalCoverage.map(renderFinding).join('\n')}`);
|
|
289
|
+
}
|
|
290
|
+
for (const ctx of report.contexts) {
|
|
291
|
+
const ctxCoverage = ctx.findings.items.filter((f) => f.category === 'coverage');
|
|
292
|
+
if (ctxCoverage.length > 0) {
|
|
293
|
+
parts.push(`<h3>${escapeHtml(ctx.key)} · ${escapeHtml(ctx.label)}${ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : ''}</h3>\n${ctxCoverage.map(renderFinding).join('\n')}`);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (parts.length > 0) {
|
|
297
|
+
coverageHtml = `<h2>Coverage Notes</h2>\n${parts.join('\n')}`;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
const allCoverage = [
|
|
302
|
+
...globalCoverage,
|
|
303
|
+
...report.contexts.flatMap((c) => c.findings.items.filter((f) => f.category === 'coverage')),
|
|
304
|
+
];
|
|
305
|
+
coverageHtml = allCoverage.length > 0
|
|
306
|
+
? `<h2>Coverage Notes</h2>\n${allCoverage.map(renderFinding).join('\n')}`
|
|
307
|
+
: '';
|
|
308
|
+
}
|
|
309
|
+
// --- Per-plugin details --------------------------------------------------
|
|
310
|
+
let pluginDetailsHtml = '';
|
|
311
|
+
if (multiContext) {
|
|
312
|
+
const parts = [];
|
|
313
|
+
for (const ctx of report.contexts) {
|
|
314
|
+
if (ctx.effectivePlugins.items.length > 0) {
|
|
315
|
+
parts.push(`<h3>${escapeHtml(ctx.key)} · ${escapeHtml(ctx.label)}${ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : ''}</h3>\n${ctx.effectivePlugins.items.map(renderEffectivePlugin).join('\n')}`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (parts.length > 0) {
|
|
319
|
+
pluginDetailsHtml = `<h2>Plugin Details</h2>\n${parts.join('\n')}`;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
const effectivePlugins = report.contexts.flatMap((c) => c.effectivePlugins.items);
|
|
324
|
+
pluginDetailsHtml = effectivePlugins.length > 0
|
|
325
|
+
? `<h2>Plugin Details</h2>\n${effectivePlugins.map(renderEffectivePlugin).join('\n')}`
|
|
326
|
+
: '';
|
|
327
|
+
}
|
|
328
|
+
// --- Maintenance (collapsed) ---------------------------------------------
|
|
329
|
+
const globalMaintenance = report.findings.items.filter((f) => f.category === 'maintenance');
|
|
330
|
+
let maintenanceHtml = '';
|
|
331
|
+
if (multiContext) {
|
|
332
|
+
const parts = [];
|
|
333
|
+
if (globalMaintenance.length > 0) {
|
|
334
|
+
parts.push(`<h3>Installation-wide</h3>\n${globalMaintenance.map(renderFinding).join('\n')}`);
|
|
335
|
+
}
|
|
336
|
+
for (const ctx of report.contexts) {
|
|
337
|
+
const ctxMaintenance = ctx.findings.items.filter((f) => f.category === 'maintenance');
|
|
338
|
+
if (ctxMaintenance.length > 0) {
|
|
339
|
+
parts.push(`<h3>${escapeHtml(ctx.key)} · ${escapeHtml(ctx.label)}${ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : ''}</h3>\n${ctxMaintenance.map(renderFinding).join('\n')}`);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (parts.length > 0) {
|
|
343
|
+
const totalMaintenance = globalMaintenance.length +
|
|
344
|
+
report.contexts.reduce((sum, c) => sum + c.findings.items.filter((f) => f.category === 'maintenance').length, 0);
|
|
345
|
+
maintenanceHtml = `<h2>Maintenance</h2>\n<details><summary>${totalMaintenance} maintenance note${totalMaintenance !== 1 ? 's' : ''}</summary>\n${parts.join('\n')}\n</details>`;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
const allMaintenance = [
|
|
350
|
+
...globalMaintenance,
|
|
351
|
+
...report.contexts.flatMap((c) => c.findings.items.filter((f) => f.category === 'maintenance')),
|
|
352
|
+
];
|
|
353
|
+
maintenanceHtml =
|
|
354
|
+
allMaintenance.length > 0
|
|
355
|
+
? `<h2>Maintenance</h2>\n<details><summary>${allMaintenance.length} maintenance note${allMaintenance.length !== 1 ? 's' : ''}</summary>\n${allMaintenance.map(renderFinding).join('\n')}\n</details>`
|
|
356
|
+
: '';
|
|
357
|
+
}
|
|
358
|
+
return `<!DOCTYPE html>
|
|
359
|
+
<html lang="en">
|
|
360
|
+
<head>
|
|
361
|
+
<meta charset="utf-8">
|
|
362
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
363
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:; object-src 'none'; base-uri 'none'; form-action 'none'">
|
|
364
|
+
<title>ClaudePluginHub Doctor Report</title>
|
|
365
|
+
<style>${CSS}</style>
|
|
366
|
+
</head>
|
|
367
|
+
<body>
|
|
368
|
+
<div class="container">
|
|
369
|
+
<h1>ClaudePluginHub Doctor</h1>
|
|
370
|
+
<div class="header-meta">Claude ${version} — ${escapeHtml(opts)}</div>
|
|
371
|
+
${renderVerdict(report)}
|
|
372
|
+
${issuesHtml}
|
|
373
|
+
${contextHtml}
|
|
374
|
+
${coverageHtml}
|
|
375
|
+
${pluginDetailsHtml}
|
|
376
|
+
${maintenanceHtml}
|
|
377
|
+
${renderOmissions(report)}
|
|
378
|
+
<div class="footer">
|
|
379
|
+
<p>Generated locally by ClaudePluginHub Doctor. No report data was uploaded.</p>
|
|
380
|
+
<p>Token estimates are approximations (~chars/4). Run <code>claude plugin details</code> for authoritative values.</p>
|
|
381
|
+
</div>
|
|
382
|
+
</div>
|
|
383
|
+
</body>
|
|
384
|
+
</html>`;
|
|
385
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ScanResult } from './report.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bounded, deterministic, read-only inventory of one plugin install root.
|
|
4
|
+
*
|
|
5
|
+
* Treats every plugin file as untrusted input: size-checked before reading,
|
|
6
|
+
* JSON parsed in try/catch, frontmatter read by a bounded line scanner (NOT a
|
|
7
|
+
* YAML parser — files it cannot understand become "unestimated", never
|
|
8
|
+
* "invalid"). Nothing from a plugin is ever executed, required, or imported.
|
|
9
|
+
*
|
|
10
|
+
* These are LIMITED STRUCTURAL CHECKS, not full plugin validation — the
|
|
11
|
+
* authoritative validator is `claude plugin validate <path>`.
|
|
12
|
+
*
|
|
13
|
+
* Symlinks: the root is canonicalized first; entries are lstat'ed; symlinks
|
|
14
|
+
* are followed only when their realpath stays within the canonical root
|
|
15
|
+
* (legitimate dev setups), guarded by a visited-realpath set (cycles) and the
|
|
16
|
+
* depth/file/byte budgets. Escaping or unresolvable links are reported and
|
|
17
|
+
* mark the inventory incomplete rather than being silently ignored.
|
|
18
|
+
*
|
|
19
|
+
* Scans are memoized globally by canonical root: the same directory is never
|
|
20
|
+
* rescanned no matter how many records or project contexts point at it.
|
|
21
|
+
*/
|
|
22
|
+
export interface ScanLimits {
|
|
23
|
+
/** Distinct plugin roots scanned per run. */
|
|
24
|
+
maxPlugins: number;
|
|
25
|
+
/** Files encountered per plugin before the walk stops. */
|
|
26
|
+
maxFilesPerPlugin: number;
|
|
27
|
+
/** Per-file read cap — larger files are counted but not read. */
|
|
28
|
+
maxFileBytes: number;
|
|
29
|
+
/** Total bytes read per plugin. */
|
|
30
|
+
maxPluginBytes: number;
|
|
31
|
+
/** Total bytes read per run. */
|
|
32
|
+
maxTotalBytes: number;
|
|
33
|
+
/** Directory depth below the plugin root. */
|
|
34
|
+
maxDepth: number;
|
|
35
|
+
}
|
|
36
|
+
export declare const DEFAULT_LIMITS: ScanLimits;
|
|
37
|
+
/** Documented tool-matched hook events (hooks reference). */
|
|
38
|
+
export declare const TOOL_MATCHED_EVENTS: Set<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Aggregate cap on hook/MCP/LSP/monitor facts per plugin. Parse helpers stop
|
|
41
|
+
* producing at MAX_FACTS_PER_TYPE + 1 so the scanner can DETECT the overflow
|
|
42
|
+
* and flag it ('max-facts' → scan_incomplete) instead of capping silently.
|
|
43
|
+
*/
|
|
44
|
+
export declare const MAX_FACTS_PER_TYPE = 100;
|
|
45
|
+
export interface Scanner {
|
|
46
|
+
scan(installPath: string): ScanResult;
|
|
47
|
+
stats(): {
|
|
48
|
+
pluginsScanned: number;
|
|
49
|
+
filesScanned: number;
|
|
50
|
+
bytesRead: number;
|
|
51
|
+
truncated: boolean;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export declare function createScanner(overrides?: Partial<ScanLimits>): Scanner;
|
|
55
|
+
interface ParsedFrontmatter {
|
|
56
|
+
name: string | null;
|
|
57
|
+
description: string | null;
|
|
58
|
+
understood: boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare function parseFrontmatter(content: string): ParsedFrontmatter;
|
|
61
|
+
export declare function hashComponentContent(content: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* PATH-style prerequisite lookup. Pure fs — the command is never executed.
|
|
64
|
+
* Returns null when the declaration cannot be resolved statically
|
|
65
|
+
* (env expansion other than ${CLAUDE_PLUGIN_ROOT}, relative paths):
|
|
66
|
+
* "unresolvable" must never be reported as "missing".
|
|
67
|
+
*/
|
|
68
|
+
export declare function commandOnPath(rawCommand: string, args: unknown, rootCanonical: string, env?: NodeJS.ProcessEnv): boolean | null;
|
|
69
|
+
export {};
|