claudepluginhub 0.11.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.
@@ -1,147 +1,353 @@
1
- import { BOLD, CYAN, DIM, RED, RESET, YELLOW } from '../output.js';
1
+ import { makeTheme, shouldColorize } from './color.js';
2
+ import { formatApproxTokens } from './estimate.js';
3
+ import { wrapText, terminalWidth } from './wrap.js';
4
+ /** Strip ANSI escape sequences to measure visible character width. */
5
+ function stripAnsi(s) {
6
+ return s.replace(/\x1b\[[0-9;]*m/g, '');
7
+ }
2
8
  /**
3
- * Renderers over one shared DoctorReport. JSON mode emits exactly one JSON
4
- * document (no ANSI, no banners); human mode uses the CLI's existing color
5
- * palette. Capability inventory renders as per-plugin facts; the findings
6
- * list stays reserved for actionable conditions.
9
+ * Wrap plain text then apply `t.dim()` to each resulting line independently.
10
+ * Prevents ANSI dim codes from leaking across physical lines when wrapText
11
+ * splits a long styled string.
7
12
  */
8
- export function renderJson(report) {
9
- return `${JSON.stringify(report, null, 2)}\n`;
13
+ function wrapDim(text, t, width, indent, firstIndent) {
14
+ const wrapped = wrapText(text, width, indent, firstIndent);
15
+ return wrapped.split('\n').map((line) => t.dim(line)).join('\n');
10
16
  }
11
- function formatTokens(n) {
12
- return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
17
+ function wrapBoldHeading(text, t, width) {
18
+ const wrapped = wrapText(text, width, 2, 0);
19
+ return wrapped.split('\n').map((line) => t.bold(line)).join('\n');
13
20
  }
14
- const SEVERITY_TAG = {
15
- error: `${RED}${BOLD}ERROR${RESET}`,
16
- warning: `${YELLOW}WARN ${RESET}`,
17
- info: `${DIM}INFO ${RESET}`,
18
- };
19
- function pluginChips(entry) {
20
- const chips = [];
21
- if (entry.components) {
22
- for (const [type, summary] of Object.entries(entry.components)) {
23
- if (summary.count > 0)
24
- chips.push(`${type} ${summary.count}`);
25
- }
26
- }
27
- if (entry.capabilities) {
28
- const caps = entry.capabilities;
29
- if (caps.hooks.total > 0)
30
- chips.push(`hooks ${caps.hooks.total}`);
31
- if (caps.mcp.total > 0)
32
- chips.push(`mcp ${caps.mcp.total}`);
33
- if (caps.lsp.total > 0)
34
- chips.push(`lsp ${caps.lsp.total}`);
35
- if (caps.monitors.total > 0)
36
- chips.push(`monitors ${caps.monitors.total}`);
37
- if (caps.binCount > 0)
38
- chips.push(`bin ${caps.binCount}`);
39
- }
40
- return chips.length > 0 ? ` ${DIM}[${chips.join(' · ')}]${RESET}` : '';
21
+ export function renderJson(report) {
22
+ return `${JSON.stringify(report, null, 2)}\n`;
41
23
  }
42
- function pluginLine(entry) {
43
- const state = entry.selection === 'disabled'
44
- ? `${DIM}disabled${RESET}`
45
- : entry.selection === 'ambiguous'
46
- ? `${YELLOW}ambiguous${RESET}`
47
- : 'active';
48
- const tokens = entry.estAlwaysOnTokens !== null ? ` ${DIM}~${formatTokens(entry.estAlwaysOnTokens)} tok${RESET}` : '';
49
- const native = entry.nativeErrors.length > 0 ? ` ${RED}load-error${RESET}` : '';
50
- return ` ${BOLD}${entry.id}${RESET} ${DIM}v${entry.version} (${entry.scope})${RESET} ${state}${native}${tokens}${pluginChips(entry)}`;
24
+ function findingsByCategory(findings, ...categories) {
25
+ return findings.filter((f) => categories.includes(f.category));
51
26
  }
52
- function findingBlock(finding) {
53
- const lines = [`${SEVERITY_TAG[finding.severity]} ${BOLD}${finding.title}${RESET}`];
54
- lines.push(` ${finding.message}`);
55
- if (finding.pluginIds.items.length > 0) {
56
- const more = finding.pluginIds.omitted > 0 ? ` (+${finding.pluginIds.omitted} more)` : '';
57
- lines.push(` ${DIM}plugins: ${finding.pluginIds.items.join(', ')}${more}${RESET}`);
58
- }
59
- if (finding.remediation) {
60
- lines.push(` ${DIM}fix: ${finding.remediation}${RESET}`);
27
+ export function renderHuman(report, flags) {
28
+ const color = shouldColorize();
29
+ const t = makeTheme(color);
30
+ const width = terminalWidth();
31
+ const lines = [];
32
+ lines.push('');
33
+ lines.push(`${t.cyan(t.bold('ClaudePluginHub Doctor'))}`);
34
+ lines.push('');
35
+ const { confirmedProblems, reviewItems, coverageGaps } = report.summary;
36
+ const actionableCount = confirmedProblems + reviewItems;
37
+ if (actionableCount > 0) {
38
+ lines.push(t.red(t.bold(`${actionableCount} issue${actionableCount === 1 ? '' : 's'} need${actionableCount === 1 ? 's' : ''} attention.`)));
61
39
  }
62
- return lines;
63
- }
64
- function contextSummaryLine(context) {
65
- const incomplete = context.summary.estimateComplete ? '' : ' (incomplete — lower bound)';
66
- const est = context.summary.estimatedAlwaysOnTokens !== null
67
- ? ` · est. always-on ${CYAN}~${formatTokens(context.summary.estimatedAlwaysOnTokens)} tokens${RESET}${incomplete}`
68
- : '';
69
- return `${DIM}Active: ${context.summary.activePlugins} · Disabled: ${context.summary.disabledRecords} · Ambiguous: ${context.summary.ambiguousPlugins}${est}${RESET}`;
70
- }
71
- function pluginLines(context) {
72
- const lines = context.plugins.items.map(pluginLine);
73
- if (context.plugins.omitted > 0) {
74
- lines.push(` ${DIM}… +${context.plugins.omitted} more plugin record(s) not shown${RESET}`);
40
+ else if (coverageGaps > 0) {
41
+ lines.push(t.yellow(`Doctor could not fully verify ${coverageGaps} item${coverageGaps === 1 ? '' : 's'}.`));
75
42
  }
76
- return lines;
77
- }
78
- function findingLines(findings) {
79
- const lines = findings.items.flatMap(findingBlock);
80
- if (findings.omitted > 0) {
81
- lines.push(`${DIM}… +${findings.omitted} more finding(s) not shown${RESET}`);
43
+ else {
44
+ lines.push(t.green('No broken plugins found.'));
82
45
  }
83
- return lines;
84
- }
85
- export function renderHuman(report) {
86
- const lines = [];
87
- lines.push('');
88
- lines.push(`${CYAN}${BOLD}ClaudePluginHub Doctor${RESET}`);
89
46
  lines.push('');
90
- lines.push(`Claude Code ${report.claude.version ?? '(version unknown)'}`);
91
47
  const current = report.contexts.find((c) => c.isCurrent) ?? report.contexts[0];
92
48
  const multiContext = report.contexts.length > 1;
93
- if (current && !multiContext) {
94
- lines.push(`Project: ${current.label}`);
95
- lines.push(contextSummaryLine(current));
96
- }
97
- const { errors, warnings, notes } = report.summary;
98
- lines.push('');
99
- lines.push(`${errors > 0 ? RED : ''}${errors} error${errors === 1 ? '' : 's'}${errors > 0 ? RESET : ''} · ` +
100
- `${warnings > 0 ? YELLOW : ''}${warnings} warning${warnings === 1 ? '' : 's'}${warnings > 0 ? RESET : ''} · ` +
101
- `${notes} note${notes === 1 ? '' : 's'}`);
49
+ const globalActionable = findingsByCategory(report.findings.items, 'confirmed_problem', 'review');
50
+ const globalCoverage = findingsByCategory(report.findings.items, 'coverage');
102
51
  if (multiContext) {
103
- // Global (installation-level) findings once, then one section per project.
104
- if (report.findings.items.length > 0) {
105
- lines.push('');
106
- lines.push(...findingLines(report.findings));
52
+ // Show global findings under an "Installation-wide" heading
53
+ if (globalActionable.length > 0) {
54
+ lines.push(t.bold('Installation-wide'));
55
+ renderFindingsList(globalActionable, t, width, lines);
107
56
  }
108
- for (const context of report.contexts) {
109
- lines.push('');
110
- lines.push(`${BOLD}— ${context.key} · ${context.label}${context.isCurrent ? ' (current)' : ''}${RESET}`);
111
- lines.push(contextSummaryLine(context));
112
- lines.push(...pluginLines(context));
113
- lines.push(...findingLines(context.findings));
57
+ // Show each context's actionable findings under its own heading
58
+ for (const ctx of report.contexts) {
59
+ const ctxActionable = findingsByCategory(ctx.findings.items, 'confirmed_problem', 'review');
60
+ if (ctxActionable.length > 0) {
61
+ lines.push(wrapBoldHeading(`— ${ctx.key} · ${ctx.label}${ctx.isCurrent ? ' (current)' : ''}`, t, width));
62
+ renderFindingsList(ctxActionable, t, width, lines);
63
+ }
64
+ }
65
+ }
66
+ else {
67
+ const allActionable = [
68
+ ...globalActionable,
69
+ ...report.contexts.flatMap((c) => findingsByCategory(c.findings.items, 'confirmed_problem', 'review')),
70
+ ];
71
+ renderFindingsList(allActionable, t, width, lines);
72
+ }
73
+ if (multiContext) {
74
+ for (const ctx of report.contexts) {
75
+ const headingPlain = `— ${ctx.key} · ${ctx.label}${ctx.isCurrent ? ' (current)' : ''}`;
76
+ const headingWrapped = wrapText(headingPlain, width, 0, 0);
77
+ lines.push(headingWrapped.split('\n').map((l) => t.bold(l)).join('\n'));
78
+ renderContextFootprint(ctx, t, width, lines);
114
79
  }
115
80
  }
116
81
  else if (current) {
117
- if (current.plugins.items.length > 0) {
118
- lines.push('');
119
- lines.push(...pluginLines(current));
82
+ renderContextFootprint(current, t, width, lines);
83
+ }
84
+ if (multiContext) {
85
+ if (globalCoverage.length > 0) {
86
+ lines.push(t.bold('Installation-wide'));
87
+ renderCoverageList(globalCoverage, t, width, lines);
120
88
  }
121
- if (report.findings.items.length + current.findings.items.length > 0) {
89
+ for (const ctx of report.contexts) {
90
+ const ctxCoverage = findingsByCategory(ctx.findings.items, 'coverage');
91
+ if (ctxCoverage.length > 0) {
92
+ lines.push(wrapBoldHeading(`— ${ctx.key} · ${ctx.label}${ctx.isCurrent ? ' (current)' : ''}`, t, width));
93
+ renderCoverageList(ctxCoverage, t, width, lines);
94
+ }
95
+ }
96
+ }
97
+ else {
98
+ const allCoverage = [
99
+ ...globalCoverage,
100
+ ...report.contexts.flatMap((c) => findingsByCategory(c.findings.items, 'coverage')),
101
+ ];
102
+ renderCoverageList(allCoverage, t, width, lines);
103
+ }
104
+ if (flags.strict) {
105
+ const allMaintenance = [
106
+ ...findingsByCategory(report.findings.items, 'maintenance'),
107
+ ...report.contexts.flatMap((c) => findingsByCategory(c.findings.items, 'maintenance')),
108
+ ];
109
+ const hiddenStrictWarnings = allMaintenance.filter((f) => f.severity === 'warning');
110
+ if (hiddenStrictWarnings.length > 0 && !flags.verbose) {
111
+ lines.push(t.yellow(`${hiddenStrictWarnings.length} maintenance warning${hiddenStrictWarnings.length === 1 ? '' : 's'} (would pass without --strict).`));
112
+ for (const finding of hiddenStrictWarnings) {
113
+ lines.push(` ${t.dim(finding.title)}: ${wrapText(finding.message, width - 2, 2)}`);
114
+ }
122
115
  lines.push('');
123
- lines.push(...findingLines(report.findings));
124
- lines.push(...findingLines(current.findings));
125
116
  }
126
117
  }
127
- if (report.unknownScopeRecords.total > 0) {
128
- lines.push('');
129
- lines.push(`${DIM}${report.unknownScopeRecords.total} record(s) with unrecognized scope were preserved but not analyzed.${RESET}`);
118
+ if (flags.verbose) {
119
+ renderVerbose(report, [], t, width, lines);
120
+ }
121
+ const totalFindingsOmitted = report.findings.omitted +
122
+ report.contexts.reduce((sum, c) => sum + c.findings.omitted, 0);
123
+ if (totalFindingsOmitted > 0) {
124
+ lines.push(wrapDim(`${totalFindingsOmitted} additional finding(s) not shown (report capped).`, t, width, 0, 0));
130
125
  }
131
126
  if (report.contextsOmitted > 0) {
127
+ lines.push(wrapDim(`${report.contextsOmitted} additional project context(s) beyond the limit were not analyzed.`, t, width, 0, 0));
128
+ }
129
+ if (report.summary.otherProjectRecordsIgnored > 0) {
130
+ lines.push(wrapDim(report.options.allProjects
131
+ ? `${report.summary.otherProjectRecordsIgnored} record(s) could not be attributed to an analyzable project.`
132
+ : `${report.summary.otherProjectRecordsIgnored} record(s) belonging to other projects were ignored — use --all-projects to analyze them.`, t, width, 0, 0));
133
+ }
134
+ lines.push(wrapDim('~ values are heuristic estimates; `claude plugin details` is authoritative.', t, width, 0, 0));
135
+ lines.push('');
136
+ return lines.join('\n');
137
+ }
138
+ function renderFindingsList(findings, t, width, lines) {
139
+ for (const finding of findings) {
140
+ lines.push(` ${t.bold(finding.title)}`);
141
+ lines.push(wrapText(finding.message, width, 4, 2));
142
+ if (finding.remediation) {
143
+ lines.push(wrapText(`${t.dim('fix:')} ${finding.remediation}`, width, 8, 2));
144
+ }
145
+ lines.push('');
146
+ }
147
+ }
148
+ function renderCoverageList(findings, t, width, lines) {
149
+ for (const finding of findings) {
150
+ lines.push(` ${t.yellow(finding.title)}`);
151
+ lines.push(wrapText(finding.message, width, 4, 2));
152
+ if (finding.remediation) {
153
+ lines.push(wrapText(`${t.dim('fix:')} ${finding.remediation}`, width, 8, 2));
154
+ }
132
155
  lines.push('');
133
- lines.push(`${DIM}${report.contextsOmitted} additional project(s) exceeded the context limit and were not analyzed.${RESET}`);
156
+ }
157
+ }
158
+ function renderContextFootprint(context, t, width, lines) {
159
+ const { summary, contributors } = context;
160
+ if (summary.estimatedAlwaysOnTokens === null && summary.activePlugins === 0)
161
+ return;
162
+ const tokenStr = summary.estimatedAlwaysOnTokens !== null
163
+ ? formatApproxTokens(summary.estimatedAlwaysOnTokens)
164
+ : '—';
165
+ const pluginWord = summary.activePlugins === 1 ? 'plugin' : 'plugins';
166
+ const footprintPlain = `Always-on context: ${tokenStr} tokens across ${summary.activePlugins} ${pluginWord}${!summary.estimateComplete ? ' (incomplete — lower bound)' : ''}`;
167
+ const footprintWrapped = wrapText(footprintPlain, width, 2, 0);
168
+ lines.push(footprintWrapped.split('\n').map((line) => {
169
+ // Style token count and incomplete note within each physical line
170
+ return line
171
+ .replace(new RegExp(`${tokenStr.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} tokens`), t.cyan(`${tokenStr} tokens`))
172
+ .replace('(incomplete — lower bound)', t.dim('(incomplete — lower bound)'));
173
+ }).join('\n'));
174
+ if (contributors && contributors.top.length > 0) {
175
+ for (const c of contributors.top) {
176
+ const contribPlain = `${c.id} ${formatApproxTokens(c.tokens)} tok`;
177
+ const contribWrapped = wrapText(contribPlain, width, 4, 2);
178
+ lines.push(contribWrapped.split('\n').map((line) => {
179
+ const tokSuffix = `${formatApproxTokens(c.tokens)} tok`;
180
+ const idx = line.indexOf(tokSuffix);
181
+ if (idx >= 0) {
182
+ return line.slice(0, idx) + t.dim(tokSuffix) + line.slice(idx + tokSuffix.length);
183
+ }
184
+ return line;
185
+ }).join('\n'));
186
+ }
187
+ if (contributors.remainingCount > 0) {
188
+ lines.push(` ${t.dim(`+${contributors.remainingCount} more with ${formatApproxTokens(contributors.remainingTokens)} tok combined`)}`);
189
+ }
190
+ else if (contributors.top.every((c) => c.tokens === 0) && summary.activePlugins > 0) {
191
+ lines.push(` ${t.dim('(No plugins contribute measurable always-on context.)')}`);
192
+ }
134
193
  }
135
194
  lines.push('');
136
- lines.push(`${DIM}~ values are heuristic estimates (≈4 characters/token); \`claude plugin details\` is authoritative.${RESET}`);
137
- if (report.summary.otherProjectRecordsIgnored > 0) {
138
- lines.push(report.options.allProjects
139
- ? `${DIM}${report.summary.otherProjectRecordsIgnored} record(s) could not be attributed to an analyzable project and were ignored.${RESET}`
140
- : `${DIM}${report.summary.otherProjectRecordsIgnored} record(s) belonging to other projects were ignored — use --all-projects to analyze them.${RESET}`);
195
+ }
196
+ function renderVerbose(report, _allFindings, t, width, lines) {
197
+ const multiContext = report.contexts.length > 1;
198
+ const globalMaintenance = findingsByCategory(report.findings.items, 'maintenance');
199
+ const hasAnyMaintenance = globalMaintenance.length > 0 ||
200
+ report.contexts.some((c) => findingsByCategory(c.findings.items, 'maintenance').length > 0);
201
+ if (hasAnyMaintenance) {
202
+ lines.push(t.bold('Maintenance'));
203
+ if (multiContext) {
204
+ if (globalMaintenance.length > 0) {
205
+ lines.push(` ${t.dim('Installation-wide')}`);
206
+ for (const finding of globalMaintenance) {
207
+ lines.push(` ${finding.title}`);
208
+ lines.push(wrapText(finding.message, width, 6, 4));
209
+ lines.push('');
210
+ }
211
+ }
212
+ for (const ctx of report.contexts) {
213
+ const ctxMaintenance = findingsByCategory(ctx.findings.items, 'maintenance');
214
+ if (ctxMaintenance.length > 0) {
215
+ lines.push(wrapDim(`— ${ctx.key} · ${ctx.label}${ctx.isCurrent ? ' (current)' : ''}`, t, width, 4, 2));
216
+ for (const finding of ctxMaintenance) {
217
+ lines.push(` ${finding.title}`);
218
+ lines.push(wrapText(finding.message, width, 6, 4));
219
+ lines.push('');
220
+ }
221
+ }
222
+ }
223
+ }
224
+ else {
225
+ const allMaintenance = [
226
+ ...globalMaintenance,
227
+ ...report.contexts.flatMap((c) => findingsByCategory(c.findings.items, 'maintenance')),
228
+ ];
229
+ for (const finding of allMaintenance) {
230
+ lines.push(` ${finding.title}`);
231
+ lines.push(wrapText(finding.message, width, 4, 2));
232
+ lines.push('');
233
+ }
234
+ }
141
235
  }
142
- if (report.scan.truncated) {
143
- lines.push(`${DIM}Some scans hit resource limits — see scan_incomplete findings.${RESET}`);
236
+ lines.push(t.bold('Plugins'));
237
+ for (const context of report.contexts) {
238
+ if (report.contexts.length > 1) {
239
+ lines.push(wrapDim(`— ${context.key} · ${context.label}${context.isCurrent ? ' (current)' : ''}`, t, width, 4, 2));
240
+ }
241
+ for (const ep of context.effectivePlugins.items) {
242
+ for (const line of effectivePluginLines(ep, t, width)) {
243
+ lines.push(line);
244
+ }
245
+ }
246
+ if (context.effectivePlugins.omitted > 0) {
247
+ lines.push(` ${t.dim(`… +${context.effectivePlugins.omitted} more`)}`);
248
+ }
249
+ if (context.plugins.omitted > 0) {
250
+ lines.push(` ${t.dim(`… +${context.plugins.omitted} more inventory record(s)`)}`);
251
+ }
252
+ const disabled = context.plugins.items.filter((p) => p.selection === 'disabled');
253
+ if (disabled.length > 0) {
254
+ lines.push(` ${t.dim('Disabled:')}`);
255
+ for (const d of disabled) {
256
+ lines.push(wrapDim(`${d.id} v${d.version} (${d.scope})`, t, width, 6, 4));
257
+ }
258
+ }
144
259
  }
145
260
  lines.push('');
146
- return lines.join('\n');
261
+ const claudeVer = report.claude.version ?? '(version unknown)';
262
+ const optionParts = [`scope ${report.options.scope}`];
263
+ if (report.options.allProjects)
264
+ optionParts.push('all projects');
265
+ if (report.options.strict)
266
+ optionParts.push('strict');
267
+ lines.push(wrapDim(`Claude Code ${claudeVer} · ${optionParts.join(' · ')}`, t, width, 0, 0));
268
+ lines.push('');
269
+ }
270
+ const COMPONENT_DISPLAY_ORDER = ['commands', 'skills', 'agents', 'outputStyles', 'themes'];
271
+ function packChips(chips, indent, width) {
272
+ if (chips.length === 0)
273
+ return [];
274
+ const pfx = ' '.repeat(indent);
275
+ const lines = [];
276
+ let current = pfx + '[';
277
+ for (let i = 0; i < chips.length; i++) {
278
+ const sep = i === 0 ? '' : ' · ';
279
+ const suffix = i === chips.length - 1 ? ']' : '';
280
+ const addition = sep + chips[i] + suffix;
281
+ if (current.length + addition.length <= width) {
282
+ current += addition;
283
+ }
284
+ else if (current === pfx + '[' || current === pfx) {
285
+ current += addition;
286
+ }
287
+ else {
288
+ lines.push(current);
289
+ current = pfx + chips[i] + suffix;
290
+ }
291
+ }
292
+ if (current.length > 0)
293
+ lines.push(current);
294
+ return lines;
295
+ }
296
+ function effectivePluginLines(ep, t, width) {
297
+ let state;
298
+ if (ep.selection === 'ambiguous') {
299
+ state = t.yellow('ambiguous');
300
+ }
301
+ else if (ep.reason === 'scan_equivalent') {
302
+ state = `active ${t.dim('(equivalent records)')}`;
303
+ }
304
+ else {
305
+ state = 'active';
306
+ }
307
+ const tokens = ep.estAlwaysOnTokens !== null ? ` ${t.dim(formatApproxTokens(ep.estAlwaysOnTokens) + ' tok')}` : '';
308
+ const chips = [];
309
+ if (ep.components) {
310
+ for (const type of COMPONENT_DISPLAY_ORDER) {
311
+ const summary = ep.components[type];
312
+ if (summary && summary.count > 0)
313
+ chips.push(`${type} ${summary.count}`);
314
+ }
315
+ }
316
+ const chipStr = chips.length > 0 ? ` ${t.dim(`[${chips.join(' · ')}]`)}` : '';
317
+ const ver = ep.versions.items.length === 1 ? ep.versions.items[0] : ep.versions.items.join('/');
318
+ const scope = ep.scopes.items.length === 1 ? ep.scopes.items[0] : ep.scopes.items.join('/');
319
+ // Try single line
320
+ const full = ` ${t.bold(ep.id)} ${t.dim(`v${ver} (${scope})`)} ${state}${tokens}${chipStr}`;
321
+ if (stripAnsi(full).length <= width)
322
+ return [full];
323
+ // Two-line layout: ID + state + tokens on first line, version/chips on second
324
+ const line1 = ` ${t.bold(ep.id)} ${state}${tokens}`;
325
+ const line2 = ` ${t.dim(`v${ver} (${scope})`)}${chipStr}`;
326
+ const result = [];
327
+ if (stripAnsi(line1).length > width) {
328
+ const idWrapped = wrapText(ep.id, width, 4, 2);
329
+ for (const idLine of idWrapped.split('\n')) {
330
+ result.push(t.bold(idLine));
331
+ }
332
+ result.push(` ${state}${tokens}`);
333
+ }
334
+ else {
335
+ result.push(line1);
336
+ }
337
+ if (stripAnsi(line2).length > width) {
338
+ const verPlain = `v${ver} (${scope})`;
339
+ const verWrapped = wrapText(verPlain, width, 6, 4);
340
+ for (const vLine of verWrapped.split('\n')) {
341
+ result.push(t.dim(vLine));
342
+ }
343
+ if (chips.length > 0) {
344
+ for (const chipLine of packChips(chips, 4, width)) {
345
+ result.push(t.dim(chipLine));
346
+ }
347
+ }
348
+ }
349
+ else {
350
+ result.push(line2);
351
+ }
352
+ return result;
147
353
  }
@@ -10,12 +10,16 @@
10
10
  */
11
11
  export declare const DOCTOR_SCHEMA_VERSION = 1;
12
12
  export type Severity = 'error' | 'warning' | 'info';
13
+ export type FindingCategory = 'confirmed_problem' | 'review' | 'coverage' | 'maintenance';
13
14
  export type ScopeFilter = 'user' | 'project' | 'local' | 'all';
14
15
  export type KnownScope = 'user' | 'project' | 'local' | 'managed';
15
16
  export type RecordScope = KnownScope | 'unknown';
17
+ export type SelectionReason = 'single' | 'shared_install' | 'scan_equivalent' | 'unresolved';
16
18
  export interface DoctorFlags {
17
19
  json: boolean;
18
20
  strict: boolean;
21
+ verbose: boolean;
22
+ open: boolean;
19
23
  scope: ScopeFilter;
20
24
  allProjects: boolean;
21
25
  }
@@ -62,6 +66,7 @@ export interface EffectiveInstance {
62
66
  contextKey: string;
63
67
  id: string;
64
68
  selection: Selection;
69
+ reason: SelectionReason;
65
70
  /** The selected record; null when ambiguous. */
66
71
  record: InstallationRecord | null;
67
72
  contenders: InstallationRecord[];
@@ -177,6 +182,7 @@ export interface CappedList<T> {
177
182
  export interface Finding {
178
183
  code: string;
179
184
  severity: Severity;
185
+ category: FindingCategory;
180
186
  title: string;
181
187
  message: string;
182
188
  pluginIds: CappedList<string>;
@@ -235,22 +241,49 @@ export interface PluginEntry {
235
241
  }[];
236
242
  inventoryIncomplete: boolean;
237
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
+ }
238
269
  export interface ContextReport {
239
270
  key: string;
240
271
  label: string;
241
272
  isCurrent: boolean;
242
273
  plugins: CappedList<PluginEntry>;
274
+ effectivePlugins: CappedList<EffectivePluginEntry>;
275
+ contributors: ContextContributors | null;
243
276
  findings: CappedList<Finding>;
244
277
  summary: {
245
- /** Unambiguous ('sole') effective instances only — ambiguous plugins are
246
- * excluded from context totals and counted separately. */
247
278
  activePlugins: number;
248
279
  ambiguousPlugins: number;
249
280
  disabledRecords: number;
250
281
  estimatedAlwaysOnTokens: number | null;
251
- /** False when any counted plugin's scan was incomplete, unestimable, or
252
- * unreachable — the token total is then a lower bound, not a full sum. */
253
282
  estimateComplete: boolean;
283
+ confirmedProblems: number;
284
+ reviewItems: number;
285
+ coverageGaps: number;
286
+ maintenanceNotes: number;
254
287
  };
255
288
  }
256
289
  export interface DoctorReport {
@@ -276,6 +309,10 @@ export interface DoctorReport {
276
309
  errors: number;
277
310
  warnings: number;
278
311
  notes: number;
312
+ confirmedProblems: number;
313
+ reviewItems: number;
314
+ coverageGaps: number;
315
+ maintenanceNotes: number;
279
316
  otherProjectRecordsIgnored: number;
280
317
  };
281
318
  scan: {
@@ -293,6 +330,8 @@ export declare const MAX_EVIDENCE_STRING = 200;
293
330
  export declare const MAX_MESSAGE_CHARS = 500;
294
331
  export declare const MAX_CONTEXTS = 50;
295
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;
296
335
  export declare const MAX_UNKNOWN_SCOPE_RECORDS = 50;
297
336
  export declare const MAX_CAPABILITY_ITEMS = 25;
298
337
  export declare function cappedList<T>(items: T[], cap: number): CappedList<T>;
@@ -20,6 +20,8 @@ export const MAX_EVIDENCE_STRING = 200;
20
20
  export const MAX_MESSAGE_CHARS = 500;
21
21
  export const MAX_CONTEXTS = 50;
22
22
  export const MAX_PLUGINS_PER_CONTEXT = 200;
23
+ export const MAX_EFFECTIVE_PLUGINS_PER_CONTEXT = 200;
24
+ export const MAX_TOP_CONTRIBUTORS = 3;
23
25
  export const MAX_UNKNOWN_SCOPE_RECORDS = 50;
24
26
  export const MAX_CAPABILITY_ITEMS = 25;
25
27
  export function cappedList(items, cap) {