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,11 @@
|
|
|
1
|
+
import { type ExecFileException } from 'node:child_process';
|
|
2
|
+
export interface BrowserOpener {
|
|
3
|
+
open(filePath: string): Promise<boolean>;
|
|
4
|
+
}
|
|
5
|
+
type ExecFileFn = (file: string, args: string[], callback: (error: ExecFileException | null) => void) => void;
|
|
6
|
+
export declare function createOpener(deps: {
|
|
7
|
+
platform: string;
|
|
8
|
+
execFile: ExecFileFn;
|
|
9
|
+
}): BrowserOpener;
|
|
10
|
+
export declare function defaultOpener(): BrowserOpener;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { execFile as nodeExecFile } from 'node:child_process';
|
|
2
|
+
export function createOpener(deps) {
|
|
3
|
+
return {
|
|
4
|
+
open(filePath) {
|
|
5
|
+
let cmd;
|
|
6
|
+
let args;
|
|
7
|
+
switch (deps.platform) {
|
|
8
|
+
case 'darwin':
|
|
9
|
+
cmd = 'open';
|
|
10
|
+
args = [filePath];
|
|
11
|
+
break;
|
|
12
|
+
case 'linux':
|
|
13
|
+
cmd = 'xdg-open';
|
|
14
|
+
args = [filePath];
|
|
15
|
+
break;
|
|
16
|
+
case 'win32':
|
|
17
|
+
cmd = 'cmd.exe';
|
|
18
|
+
args = ['/c', 'start', '', filePath];
|
|
19
|
+
break;
|
|
20
|
+
default:
|
|
21
|
+
return Promise.resolve(false);
|
|
22
|
+
}
|
|
23
|
+
return new Promise((resolve) => {
|
|
24
|
+
deps.execFile(cmd, args, (error) => {
|
|
25
|
+
resolve(!error);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function defaultOpener() {
|
|
32
|
+
return createOpener({
|
|
33
|
+
platform: process.platform,
|
|
34
|
+
execFile: (file, args, callback) => {
|
|
35
|
+
nodeExecFile(file, args, callback);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ScanResult } from './report.js';
|
|
2
|
+
/**
|
|
3
|
+
* Exact duplicate detection for primary component content (skills, commands,
|
|
4
|
+
* agents) across the enabled, unambiguous effective instances of ONE project
|
|
5
|
+
* context. "Exact" means byte-identical after normalizing line endings
|
|
6
|
+
* (CRLF→LF) and trailing end-of-file whitespace — nothing else. This is never
|
|
7
|
+
* a semantic-similarity claim, and a duplicate is not proof that either
|
|
8
|
+
* plugin is defective.
|
|
9
|
+
*/
|
|
10
|
+
export interface OverlapEntry {
|
|
11
|
+
pluginId: string;
|
|
12
|
+
type: string;
|
|
13
|
+
relPath: string;
|
|
14
|
+
}
|
|
15
|
+
export interface OverlapGroup {
|
|
16
|
+
hash: string;
|
|
17
|
+
entries: OverlapEntry[];
|
|
18
|
+
}
|
|
19
|
+
export declare function findOverlaps(plugins: {
|
|
20
|
+
pluginId: string;
|
|
21
|
+
scan: ScanResult;
|
|
22
|
+
}[]): OverlapGroup[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { compareBytes } from './report.js';
|
|
2
|
+
export function findOverlaps(plugins) {
|
|
3
|
+
const byHash = new Map();
|
|
4
|
+
for (const { pluginId, scan } of plugins) {
|
|
5
|
+
for (const component of scan.components) {
|
|
6
|
+
if (component.hash === null)
|
|
7
|
+
continue;
|
|
8
|
+
const entries = byHash.get(component.hash) ?? [];
|
|
9
|
+
entries.push({ pluginId, type: component.type, relPath: component.relPath });
|
|
10
|
+
byHash.set(component.hash, entries);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const groups = [];
|
|
14
|
+
for (const [hash, entries] of byHash.entries()) {
|
|
15
|
+
const distinctPlugins = new Set(entries.map((e) => e.pluginId));
|
|
16
|
+
if (distinctPlugins.size < 2)
|
|
17
|
+
continue; // within-plugin repetition is not cross-plugin overlap
|
|
18
|
+
entries.sort((a, b) => compareBytes(a.pluginId, b.pluginId) || compareBytes(a.relPath, b.relPath));
|
|
19
|
+
groups.push({ hash, entries });
|
|
20
|
+
}
|
|
21
|
+
groups.sort((a, b) => compareBytes(a.hash, b.hash));
|
|
22
|
+
return groups;
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonicalize a path for identity comparisons: realpath when the target
|
|
3
|
+
* exists (resolves macOS /tmp → /private/tmp aliasing and other symlinks),
|
|
4
|
+
* plain resolve+normalize when it does not (a stale projectPath from Claude
|
|
5
|
+
* must never throw — it simply won't match anything that exists).
|
|
6
|
+
*/
|
|
7
|
+
export declare function canonicalize(path: string): string;
|
|
8
|
+
/** True when childCanonical is rootCanonical or lies underneath it. */
|
|
9
|
+
export declare function isWithin(rootCanonical: string, childCanonical: string): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { realpathSync } from 'node:fs';
|
|
2
|
+
import { resolve, sep } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Canonicalize a path for identity comparisons: realpath when the target
|
|
5
|
+
* exists (resolves macOS /tmp → /private/tmp aliasing and other symlinks),
|
|
6
|
+
* plain resolve+normalize when it does not (a stale projectPath from Claude
|
|
7
|
+
* must never throw — it simply won't match anything that exists).
|
|
8
|
+
*/
|
|
9
|
+
export function canonicalize(path) {
|
|
10
|
+
try {
|
|
11
|
+
return realpathSync(path);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return resolve(path);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** True when childCanonical is rootCanonical or lies underneath it. */
|
|
18
|
+
export function isWithin(rootCanonical, childCanonical) {
|
|
19
|
+
if (childCanonical === rootCanonical)
|
|
20
|
+
return true;
|
|
21
|
+
const root = rootCanonical.endsWith(sep) ? rootCanonical : rootCanonical + sep;
|
|
22
|
+
return childCanonical.startsWith(root);
|
|
23
|
+
}
|
|
@@ -0,0 +1,353 @@
|
|
|
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
|
+
}
|
|
8
|
+
/**
|
|
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.
|
|
12
|
+
*/
|
|
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');
|
|
16
|
+
}
|
|
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');
|
|
20
|
+
}
|
|
21
|
+
export function renderJson(report) {
|
|
22
|
+
return `${JSON.stringify(report, null, 2)}\n`;
|
|
23
|
+
}
|
|
24
|
+
function findingsByCategory(findings, ...categories) {
|
|
25
|
+
return findings.filter((f) => categories.includes(f.category));
|
|
26
|
+
}
|
|
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.`)));
|
|
39
|
+
}
|
|
40
|
+
else if (coverageGaps > 0) {
|
|
41
|
+
lines.push(t.yellow(`Doctor could not fully verify ${coverageGaps} item${coverageGaps === 1 ? '' : 's'}.`));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
lines.push(t.green('No broken plugins found.'));
|
|
45
|
+
}
|
|
46
|
+
lines.push('');
|
|
47
|
+
const current = report.contexts.find((c) => c.isCurrent) ?? report.contexts[0];
|
|
48
|
+
const multiContext = report.contexts.length > 1;
|
|
49
|
+
const globalActionable = findingsByCategory(report.findings.items, 'confirmed_problem', 'review');
|
|
50
|
+
const globalCoverage = findingsByCategory(report.findings.items, 'coverage');
|
|
51
|
+
if (multiContext) {
|
|
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);
|
|
56
|
+
}
|
|
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);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (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);
|
|
88
|
+
}
|
|
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
|
+
}
|
|
115
|
+
lines.push('');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
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));
|
|
125
|
+
}
|
|
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
|
+
}
|
|
155
|
+
lines.push('');
|
|
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
|
+
}
|
|
193
|
+
}
|
|
194
|
+
lines.push('');
|
|
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
|
+
}
|
|
235
|
+
}
|
|
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
|
+
}
|
|
259
|
+
}
|
|
260
|
+
lines.push('');
|
|
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;
|
|
353
|
+
}
|