claudepluginhub 0.16.1 → 0.17.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.
Files changed (55) hide show
  1. package/README.md +34 -1
  2. package/dist/args.js +0 -6
  3. package/dist/collection-install.d.ts +4 -23
  4. package/dist/collection-install.js +9 -45
  5. package/dist/component-install.js +7 -29
  6. package/dist/detect.d.ts +0 -2
  7. package/dist/detect.js +3 -7
  8. package/dist/doctor/claude-source.d.ts +4 -6
  9. package/dist/doctor/claude-source.js +1 -2
  10. package/dist/doctor/color.d.ts +0 -1
  11. package/dist/doctor/color.js +0 -1
  12. package/dist/doctor/equivalence.d.ts +1 -1
  13. package/dist/doctor/equivalence.js +68 -149
  14. package/dist/doctor/estimate.js +12 -61
  15. package/dist/doctor/html-report.d.ts +1 -6
  16. package/dist/doctor/html-report.js +43 -116
  17. package/dist/doctor/inventory.d.ts +10 -24
  18. package/dist/doctor/inventory.js +29 -63
  19. package/dist/doctor/overlap.d.ts +3 -6
  20. package/dist/doctor/render.js +20 -38
  21. package/dist/doctor/report.d.ts +7 -16
  22. package/dist/doctor/report.js +3 -6
  23. package/dist/doctor/rules.d.ts +6 -16
  24. package/dist/doctor/rules.js +13 -26
  25. package/dist/doctor/run.d.ts +1 -1
  26. package/dist/doctor/run.js +5 -6
  27. package/dist/doctor/sanitize.d.ts +0 -8
  28. package/dist/doctor/sanitize.js +1 -6
  29. package/dist/doctor/select.d.ts +10 -25
  30. package/dist/doctor/select.js +2 -3
  31. package/dist/download.d.ts +1 -6
  32. package/dist/download.js +4 -14
  33. package/dist/fetch.d.ts +2 -8
  34. package/dist/fetch.js +6 -21
  35. package/dist/github-install.js +1 -12
  36. package/dist/index.js +14 -22
  37. package/dist/install.js +1 -2
  38. package/dist/mcp/server.d.ts +25 -0
  39. package/dist/mcp/server.js +103 -0
  40. package/dist/mcp/tools.d.ts +73 -0
  41. package/dist/mcp/tools.js +231 -0
  42. package/dist/output.d.ts +0 -5
  43. package/dist/output.js +0 -12
  44. package/dist/prompts.d.ts +3 -10
  45. package/dist/prompts.js +5 -20
  46. package/dist/recommend.d.ts +51 -66
  47. package/dist/recommend.js +59 -132
  48. package/dist/remove.d.ts +1 -1
  49. package/dist/remove.js +5 -10
  50. package/dist/update.js +1 -5
  51. package/dist/validation.d.ts +0 -5
  52. package/dist/validation.js +3 -10
  53. package/dist/wrapper.d.ts +0 -1
  54. package/dist/wrapper.js +1 -8
  55. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { compareBytes } from './report.js';
1
+ import { compareBytes, SCOPE_RANK } from './report.js';
2
2
  function cmp(a, b) {
3
3
  const sa = a ?? '';
4
4
  const sb = b ?? '';
@@ -7,24 +7,23 @@ function cmp(a, b) {
7
7
  function cmpBool(a, b) {
8
8
  return (a ? 1 : 0) - (b ? 1 : 0);
9
9
  }
10
- function cmpNum(a, b) {
11
- return a - b;
12
- }
13
10
  function sortedStrings(arr) {
14
11
  return [...arr].sort(compareBytes);
15
12
  }
16
- function cappedListEqual(a, b) {
17
- if (a.total !== b.total || a.omitted !== b.omitted)
18
- return false;
19
- const sa = sortedStrings(a.items);
20
- const sb = sortedStrings(b.items);
21
- if (sa.length !== sb.length)
13
+ function sameStrings(a, b) {
14
+ return sortedStrings(a).join('\0') === sortedStrings(b).join('\0');
15
+ }
16
+ function sameSorted(a, b, compare, equal) {
17
+ if (a.length !== b.length)
22
18
  return false;
23
- for (let i = 0; i < sa.length; i++) {
24
- if (sa[i] !== sb[i])
25
- return false;
26
- }
27
- return true;
19
+ const sa = [...a].sort(compare);
20
+ const sb = [...b].sort(compare);
21
+ return sa.every((x, i) => equal(x, sb[i]));
22
+ }
23
+ function cappedListEqual(a, b) {
24
+ return (a.total === b.total &&
25
+ a.omitted === b.omitted &&
26
+ sameSorted(a.items, b.items, compareBytes, (x, y) => x === y));
28
27
  }
29
28
  function commandEqual(a, b) {
30
29
  if (a === null && b === null)
@@ -51,34 +50,24 @@ function manifestEqual(a, b) {
51
50
  a.parseError === b.parseError &&
52
51
  a.name === b.name &&
53
52
  a.nameInvalid === b.nameInvalid &&
54
- sortedStrings(a.invalidFields).join('\0') === sortedStrings(b.invalidFields).join('\0') &&
55
- sortedStrings(a.declaredMissing).join('\0') === sortedStrings(b.declaredMissing).join('\0') &&
53
+ sameStrings(a.invalidFields, b.invalidFields) &&
54
+ sameStrings(a.declaredMissing, b.declaredMissing) &&
56
55
  canonicalDeps(a.dependencies) === canonicalDeps(b.dependencies));
57
56
  }
58
57
  function cmpComponent(a, b) {
59
58
  return cmp(a.type, b.type) || compareBytes(a.relPath, b.relPath);
60
59
  }
61
- function componentsEqual(a, b) {
62
- if (a.length !== b.length)
63
- return false;
64
- const sa = [...a].sort(cmpComponent);
65
- const sb = [...b].sort(cmpComponent);
66
- for (let i = 0; i < sa.length; i++) {
67
- const x = sa[i];
68
- const y = sb[i];
69
- if (x.type !== y.type ||
70
- x.relPath !== y.relPath ||
71
- x.name !== y.name ||
72
- x.description !== y.description ||
73
- x.estimable !== y.estimable ||
74
- x.disableModelInvocation !== y.disableModelInvocation ||
75
- x.listingChars !== y.listingChars ||
76
- x.listingComplete !== y.listingComplete ||
77
- x.bodyChars !== y.bodyChars ||
78
- x.hash !== y.hash)
79
- return false;
80
- }
81
- return true;
60
+ function componentEqual(x, y) {
61
+ return (x.type === y.type &&
62
+ x.relPath === y.relPath &&
63
+ x.name === y.name &&
64
+ x.description === y.description &&
65
+ x.estimable === y.estimable &&
66
+ x.disableModelInvocation === y.disableModelInvocation &&
67
+ x.listingChars === y.listingChars &&
68
+ x.listingComplete === y.listingComplete &&
69
+ x.bodyChars === y.bodyChars &&
70
+ x.hash === y.hash);
82
71
  }
83
72
  function cmpHook(a, b) {
84
73
  return (cmp(a.event, b.event) ||
@@ -90,66 +79,33 @@ function cmpHook(a, b) {
90
79
  cmp(a.command?.executable, b.command?.executable) ||
91
80
  cmp(a.targetOrigin, b.targetOrigin));
92
81
  }
93
- function hooksEqual(a, b) {
94
- if (a.length !== b.length)
95
- return false;
96
- const sa = [...a].sort(cmpHook);
97
- const sb = [...b].sort(cmpHook);
98
- for (let i = 0; i < sa.length; i++) {
99
- const x = sa[i];
100
- const y = sb[i];
101
- if (x.event !== y.event ||
102
- x.type !== y.type ||
103
- x.broad !== y.broad ||
104
- x.conditional !== y.conditional ||
105
- x.toolMatched !== y.toolMatched ||
106
- x.targetOrigin !== y.targetOrigin ||
107
- !commandEqual(x.command, y.command))
108
- return false;
109
- }
110
- return true;
111
- }
112
- function cmpMcp(a, b) {
113
- return cmp(a.name, b.name);
114
- }
115
- function mcpEqual(a, b) {
116
- if (a.length !== b.length)
117
- return false;
118
- const sa = [...a].sort(cmpMcp);
119
- const sb = [...b].sort(cmpMcp);
120
- for (let i = 0; i < sa.length; i++) {
121
- const x = sa[i];
122
- const y = sb[i];
123
- if (x.name !== y.name ||
124
- x.kind !== y.kind ||
125
- x.commandFound !== y.commandFound ||
126
- x.targetOrigin !== y.targetOrigin ||
127
- !commandEqual(x.command, y.command) ||
128
- !cappedListEqual(x.envKeys, y.envKeys) ||
129
- !cappedListEqual(x.headerKeys, y.headerKeys))
130
- return false;
131
- }
132
- return true;
82
+ function hookEqual(x, y) {
83
+ return (x.event === y.event &&
84
+ x.type === y.type &&
85
+ x.broad === y.broad &&
86
+ x.conditional === y.conditional &&
87
+ x.toolMatched === y.toolMatched &&
88
+ x.targetOrigin === y.targetOrigin &&
89
+ commandEqual(x.command, y.command));
133
90
  }
134
- function cmpLsp(a, b) {
91
+ function cmpByName(a, b) {
135
92
  return cmp(a.name, b.name);
136
93
  }
137
- function lspEqual(a, b) {
138
- if (a.length !== b.length)
139
- return false;
140
- const sa = [...a].sort(cmpLsp);
141
- const sb = [...b].sort(cmpLsp);
142
- for (let i = 0; i < sa.length; i++) {
143
- const x = sa[i];
144
- const y = sb[i];
145
- if (x.name !== y.name ||
146
- x.commandFound !== y.commandFound ||
147
- !commandEqual(x.command, y.command) ||
148
- !cappedListEqual(x.extensions, y.extensions) ||
149
- !cappedListEqual(x.languages, y.languages))
150
- return false;
151
- }
152
- return true;
94
+ function mcpEqual(x, y) {
95
+ return (x.name === y.name &&
96
+ x.kind === y.kind &&
97
+ x.commandFound === y.commandFound &&
98
+ x.targetOrigin === y.targetOrigin &&
99
+ commandEqual(x.command, y.command) &&
100
+ cappedListEqual(x.envKeys, y.envKeys) &&
101
+ cappedListEqual(x.headerKeys, y.headerKeys));
102
+ }
103
+ function lspEqual(x, y) {
104
+ return (x.name === y.name &&
105
+ x.commandFound === y.commandFound &&
106
+ commandEqual(x.command, y.command) &&
107
+ cappedListEqual(x.extensions, y.extensions) &&
108
+ cappedListEqual(x.languages, y.languages));
153
109
  }
154
110
  function cmpMonitor(a, b) {
155
111
  return (cmp(a.name, b.name) ||
@@ -157,29 +113,8 @@ function cmpMonitor(a, b) {
157
113
  cmp(a.command?.form, b.command?.form) ||
158
114
  cmp(a.command?.executable, b.command?.executable));
159
115
  }
160
- function monitorsEqual(a, b) {
161
- if (a.length !== b.length)
162
- return false;
163
- const sa = [...a].sort(cmpMonitor);
164
- const sb = [...b].sort(cmpMonitor);
165
- for (let i = 0; i < sa.length; i++) {
166
- const x = sa[i];
167
- const y = sb[i];
168
- if (x.name !== y.name || x.when !== y.when || !commandEqual(x.command, y.command))
169
- return false;
170
- }
171
- return true;
172
- }
173
- function binEqual(a, b) {
174
- if (a.length !== b.length)
175
- return false;
176
- const sa = [...a].sort((x, y) => compareBytes(x.relPath, y.relPath));
177
- const sb = [...b].sort((x, y) => compareBytes(x.relPath, y.relPath));
178
- for (let i = 0; i < sa.length; i++) {
179
- if (sa[i].relPath !== sb[i].relPath || sa[i].executable !== sb[i].executable)
180
- return false;
181
- }
182
- return true;
116
+ function monitorEqual(x, y) {
117
+ return x.name === y.name && x.when === y.when && commandEqual(x.command, y.command);
183
118
  }
184
119
  export function scanEquivalent(aRecord, aScan, bRecord, bScan) {
185
120
  if (aScan.pathIssue !== null || bScan.pathIssue !== null)
@@ -190,47 +125,32 @@ export function scanEquivalent(aRecord, aScan, bRecord, bScan) {
190
125
  return false;
191
126
  if (!manifestEqual(aScan.manifest, bScan.manifest))
192
127
  return false;
193
- if (!componentsEqual(aScan.components, bScan.components))
194
- return false;
195
- if (!hooksEqual(aScan.hooks, bScan.hooks))
196
- return false;
197
- if (!mcpEqual(aScan.mcp, bScan.mcp))
198
- return false;
199
- if (!lspEqual(aScan.lsp, bScan.lsp))
200
- return false;
201
- if (!monitorsEqual(aScan.monitors, bScan.monitors))
202
- return false;
203
- if (!binEqual(aScan.bin, bScan.bin))
128
+ if (!sameSorted(aScan.components, bScan.components, cmpComponent, componentEqual))
204
129
  return false;
205
- if (sortedStrings(aScan.themeFiles).join('\0') !== sortedStrings(bScan.themeFiles).join('\0'))
130
+ if (!sameSorted(aScan.hooks, bScan.hooks, cmpHook, hookEqual))
206
131
  return false;
207
- // Two installations with different workflow scripts register different slash
208
- // commands — never collapse them into one "equivalent" row.
209
- if (sortedStrings(aScan.workflowFiles).join('\0') !== sortedStrings(bScan.workflowFiles).join('\0'))
132
+ if (!sameSorted(aScan.mcp, bScan.mcp, cmpByName, mcpEqual))
210
133
  return false;
211
- if (sortedStrings(aScan.parseErrors).join('\0') !== sortedStrings(bScan.parseErrors).join('\0'))
134
+ if (!sameSorted(aScan.lsp, bScan.lsp, cmpByName, lspEqual))
212
135
  return false;
213
- if (sortedStrings(aScan.symlinksSkipped).join('\0') !== sortedStrings(bScan.symlinksSkipped).join('\0'))
136
+ if (!sameSorted(aScan.monitors, bScan.monitors, cmpMonitor, monitorEqual))
214
137
  return false;
215
- if (sortedStrings(aScan.limitsHit).join('\0') !== sortedStrings(bScan.limitsHit).join('\0'))
138
+ if (!sameSorted(aScan.bin, bScan.bin, (x, y) => compareBytes(x.relPath, y.relPath), (x, y) => x.relPath === y.relPath && x.executable === y.executable))
216
139
  return false;
217
- // filesScanned and bytesRead are operational counters that do not affect
218
- // findings, estimates, or any diagnostic result — deliberately excluded.
219
- return true;
140
+ // Different workflow scripts register different slash commands, so they count.
141
+ // filesScanned/bytesRead are operational counters and deliberately excluded.
142
+ return (sameStrings(aScan.themeFiles, bScan.themeFiles) &&
143
+ sameStrings(aScan.workflowFiles, bScan.workflowFiles) &&
144
+ sameStrings(aScan.parseErrors, bScan.parseErrors) &&
145
+ sameStrings(aScan.symlinksSkipped, bScan.symlinksSkipped) &&
146
+ sameStrings(aScan.limitsHit, bScan.limitsHit));
220
147
  }
221
- const SCOPE_RANK_VALUES = {
222
- user: 0,
223
- project: 1,
224
- local: 2,
225
- managed: 3,
226
- unknown: 4,
227
- };
228
148
  function cmpRecord(a, b) {
229
- return (cmpNum(SCOPE_RANK_VALUES[a.scope] ?? 99, SCOPE_RANK_VALUES[b.scope] ?? 99) ||
149
+ return (SCOPE_RANK[a.scope] - SCOPE_RANK[b.scope] ||
230
150
  compareBytes(a.installPath, b.installPath) ||
231
151
  compareBytes(a.version, b.version));
232
152
  }
233
- /** Build the composite key used by `ruleDuplicateRecord` for grouping. */
153
+ /** Grouping key shared with `ruleDuplicateRecord`. */
234
154
  export function duplicateRecordKey(record) {
235
155
  return [record.id, record.rawScope, record.projectPathCanonical ?? '', record.version].join('\0');
236
156
  }
@@ -246,7 +166,6 @@ export function resolveEquivalences(base, scanFor) {
246
166
  const allEquiv = scanned.every((s, i) => i === 0 || scanEquivalent(first.record, first.scan, s.record, s.scan));
247
167
  if (!allEquiv)
248
168
  return instance;
249
- // Add composite keys for the specific record groups that were resolved
250
169
  for (const r of contenders) {
251
170
  scanEquivalentKeys.add(duplicateRecordKey(r));
252
171
  }
@@ -1,64 +1,17 @@
1
1
  import { compareBytes } from './report.js';
2
2
  /**
3
- * THE context-estimate heuristic — centralized here, documented once.
4
- *
5
- * Listing tokens ≈ ceil(listingChars / 4.5) + 5 per model-visible component.
6
- * Invocation tokens ≈ ceil(bodyChars / 4.25), where bodyChars EXCLUDES frontmatter.
7
- *
8
- * The two ratios model different serialized content:
9
- * - LISTING (4.5 chars/tok) — structured key/value listing with JSON separators;
10
- * the +5 per-component overhead covers serialization framing.
11
- * - INVOCATION (4.25 chars/tok) — raw Markdown body injected as-is; the lower
12
- * ratio accounts for short-token-dense content in commands and structured
13
- * Markdown that tokenizes less efficiently than prose.
14
- *
15
- * Calibrated against `claude plugin details` output (Claude values are supplied
16
- * benchmark data, not commands executed in the implementation environment):
17
- *
18
- * Always-on listing:
19
- * pr-review-toolkit (7 components): formula → ~1.5k, Claude → ~1,404
20
- * commit-commands (3 commands): formula → ~75, Claude → ~76
21
- * code-review (1 command): formula → ~14, Claude → ~19
22
- * frontend-design (1 skill): formula → ~54, Claude → ~54
23
- *
24
- * Invocation body (all pr-review-toolkit agents + commands):
25
- * silent-failure-hunter: 1,483 vs Claude ~1,400 (+6%)
26
- * review-pr: 1,138 vs Claude ~1,100 (+3%)
27
- * type-design-analyzer: 1,029 vs Claude ~990 (+4%)
28
- * comment-analyzer: 1,026 vs Claude ~990 (+4%)
29
- * pr-test-analyzer: 938 vs Claude ~900 (+4%)
30
- * code-simplifier: 683 vs Claude ~660 (+3%)
31
- * code-reviewer: 611 vs Claude ~590 (+4%)
32
- * Invocation body (other plugins):
33
- * code-review cmd: 1,688 vs Claude ~1,900 (-11%)
34
- * frontend-design skill: 1,874 vs Claude ~1,700 (+10%)
35
- * clean_gone: 397 vs Claude ~450 (-12%)
36
- * commit-push-pr: 143 vs Claude ~160 (-11%)
37
- * commit: 121 vs Claude ~140 (-14%)
38
- * Worst-case error: ~14%. No claim of tokenizer parity.
39
- *
40
- * - Always-on = the plugin's listing text: each model-visible skill/command/
41
- * agent's frontmatter listing fields (name + description; skills and legacy
42
- * commands also include when_to_use, capped at 1,536 combined chars), plus
43
- * per-component overhead. Skills and commands with
44
- * `disable-model-invocation: true` are excluded (not listed for model
45
- * selection); agents ignore this field. Hooks/MCP/LSP are NOT estimated.
46
- * - On-invoke = a component's body (EXCLUDING frontmatter), paid when it fires.
47
- *
48
- * All values are estimates: render with `~`, `<`, or `0` prefix and say so.
49
- * Components whose frontmatter the bounded reader could not understand are
50
- * excluded and the plugin is flagged `estimated: false` (unestimated ≠ invalid).
51
- * `claude plugin details` is the authoritative source; Doctor never parses
52
- * its human output.
53
- *
54
- * Limitations:
55
- * - Plugin skills are managed through `/plugin`, not `skillOverrides`.
56
- * Configurable listing caps or token budgets may make Doctor differ from
57
- * Claude's effective post-budget context.
58
- * - Skills and commands without a frontmatter description may use a
59
- * first-body-paragraph fallback that the bounded parser cannot determine;
60
- * such components mark the listing estimate incomplete rather than silently
61
- * undercounting.
3
+ * Context-estimate heuristic, calibrated against `claude plugin details` (which
4
+ * stays authoritative — no tokenizer parity is claimed; render values with `~`/`<`).
5
+ * - Always-on: ceil(listingChars / 4.5) + 5 per model-visible skill/command/agent.
6
+ * Listing = name + description; skills/commands add when_to_use, with
7
+ * description + when_to_use capped at 1,536 chars. `disable-model-invocation:
8
+ * true` excludes skills and commands, not agents. Hooks/MCP/LSP are not estimated.
9
+ * - On-invoke: ceil(bodyChars / 4.25), frontmatter excluded. The lower ratio
10
+ * reflects raw Markdown tokenizing less efficiently than the listing.
11
+ * A component the bounded frontmatter reader cannot understand, or a skill/command
12
+ * without a description (its first-paragraph fallback is not parsed), makes the
13
+ * plugin `estimated: false` rather than silently undercounting. Configurable
14
+ * listing caps/budgets may make Claude's effective context differ.
62
15
  */
63
16
  const LISTING_CHARS_PER_TOKEN = 4.5;
64
17
  const INVOCATION_CHARS_PER_TOKEN = 4.25;
@@ -86,8 +39,6 @@ export function formatApproxTokens(n) {
86
39
  export function estimatePlugin(scan) {
87
40
  const relevant = scan.components.filter((c) => c.type === 'skill' || c.type === 'command' || c.type === 'agent');
88
41
  const estimable = relevant.filter((c) => c.estimable);
89
- // disable-model-invocation applies to skills and commands only.
90
- // An agent carrying the field still contributes its normal listing.
91
42
  const modelVisible = estimable.filter((c) => !(c.disableModelInvocation && (c.type === 'skill' || c.type === 'command')));
92
43
  const alwaysOnTokens = modelVisible.reduce((sum, c) => sum + estimateListingTokens(c.listingChars), 0);
93
44
  const largestOnInvoke = estimable
@@ -1,9 +1,4 @@
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
- */
1
+ /** Self-contained report for `doctor --open`: inlined CSS, no scripts, no external resources. */
7
2
  import type { DoctorReport } from './report.js';
8
3
  export declare function escapeHtml(s: string): string;
9
4
  export declare function renderHtml(report: DoctorReport): string;
@@ -1,13 +1,5 @@
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
- */
1
+ /** Self-contained report for `doctor --open`: inlined CSS, no scripts, no external resources. */
7
2
  import { formatApproxTokens } from './estimate.js';
8
- // ---------------------------------------------------------------------------
9
- // Escaping
10
- // ---------------------------------------------------------------------------
11
3
  export function escapeHtml(s) {
12
4
  return s
13
5
  .replace(/&/g, '&amp;')
@@ -16,13 +8,16 @@ export function escapeHtml(s) {
16
8
  .replace(/"/g, '&quot;')
17
9
  .replace(/'/g, '&#39;');
18
10
  }
19
- // ---------------------------------------------------------------------------
20
- // Helpers
21
- // ---------------------------------------------------------------------------
22
11
  function severityBadge(s) {
23
12
  const cls = s === 'error' ? 'badge-error' : s === 'warning' ? 'badge-warning' : 'badge-info';
24
13
  const label = s === 'error' ? 'ERROR' : s === 'warning' ? 'WARN' : 'INFO';
25
- return `<span class="badge ${escapeHtml(cls)}">${label}</span>`;
14
+ return `<span class="badge ${cls}">${label}</span>`;
15
+ }
16
+ function contextName(ctx) {
17
+ return `${escapeHtml(ctx.key)} &middot; ${escapeHtml(ctx.label)}`;
18
+ }
19
+ function currentBadge(ctx) {
20
+ return ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : '';
26
21
  }
27
22
  function cappedNote(list) {
28
23
  return list.omitted > 0 ? `<span class="dim"> (+${list.omitted} more)</span>` : '';
@@ -88,10 +83,7 @@ function renderEffectivePlugin(ep) {
88
83
  </details>`;
89
84
  }
90
85
  function renderContextFootprint(ctx, multiContext) {
91
- const heading = multiContext
92
- ? `${escapeHtml(ctx.key)} &middot; ${escapeHtml(ctx.label)}`
93
- : escapeHtml(ctx.label);
94
- const label = heading + (ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : '');
86
+ const label = (multiContext ? contextName(ctx) : escapeHtml(ctx.label)) + currentBadge(ctx);
95
87
  const totalTok = ctx.summary.estimatedAlwaysOnTokens != null
96
88
  ? formatApproxTokens(ctx.summary.estimatedAlwaysOnTokens) + ' tok always-on'
97
89
  : 'estimate unavailable';
@@ -128,9 +120,7 @@ function renderOmissions(report) {
128
120
  parts.push(`<p class="dim">${report.contextsOmitted} additional project context(s) were not analyzed.</p>`);
129
121
  }
130
122
  for (const ctx of report.contexts) {
131
- const ctxName = multiContext
132
- ? `${escapeHtml(ctx.key)} &middot; ${escapeHtml(ctx.label)}`
133
- : escapeHtml(ctx.label);
123
+ const ctxName = multiContext ? contextName(ctx) : escapeHtml(ctx.label);
134
124
  if (ctx.effectivePlugins.omitted > 0) {
135
125
  parts.push(`<p class="dim">${ctx.effectivePlugins.omitted} additional plugin(s) in ${ctxName} not shown.</p>`);
136
126
  }
@@ -140,9 +130,6 @@ function renderOmissions(report) {
140
130
  }
141
131
  return parts.length > 0 ? `<div class="omissions">${parts.join('\n')}</div>` : '';
142
132
  }
143
- // ---------------------------------------------------------------------------
144
- // Verdict
145
- // ---------------------------------------------------------------------------
146
133
  function renderVerdict(report) {
147
134
  const { confirmedProblems, reviewItems, coverageGaps } = report.summary;
148
135
  const actionableCount = confirmedProblems + reviewItems;
@@ -160,9 +147,6 @@ function renderVerdict(report) {
160
147
  }
161
148
  return `<div class="verdict verdict-pass">No broken plugins found.</div>`;
162
149
  }
163
- // ---------------------------------------------------------------------------
164
- // CSS
165
- // ---------------------------------------------------------------------------
166
150
  const CSS = `
167
151
  :root {
168
152
  --bg: #fff; --fg: #1a1a1a; --muted: #666; --border: #e0e0e0;
@@ -235,9 +219,30 @@ details.plugin-detail > summary:hover { color: var(--blue); }
235
219
  .bar-label { max-width: 8rem; }
236
220
  }
237
221
  `;
238
- // ---------------------------------------------------------------------------
239
- // Main renderer
240
- // ---------------------------------------------------------------------------
222
+ function isIssue(f) {
223
+ return f.category === 'confirmed_problem' || f.category === 'review';
224
+ }
225
+ /** Findings matching `pick`, grouped per context (with h3 headings) when there are several. */
226
+ function groupedFindings(report, pick) {
227
+ const global = report.findings.items.filter(pick);
228
+ if (report.contexts.length <= 1) {
229
+ const all = [...global, ...report.contexts.flatMap((c) => c.findings.items.filter(pick))];
230
+ return { body: all.map(renderFinding).join('\n'), count: all.length };
231
+ }
232
+ const parts = [];
233
+ let count = global.length;
234
+ if (global.length > 0) {
235
+ parts.push(`<h3>Installation-wide</h3>\n${global.map(renderFinding).join('\n')}`);
236
+ }
237
+ for (const ctx of report.contexts) {
238
+ const items = ctx.findings.items.filter(pick);
239
+ count += items.length;
240
+ if (items.length > 0) {
241
+ parts.push(`<h3>${contextName(ctx)}${currentBadge(ctx)}</h3>\n${items.map(renderFinding).join('\n')}`);
242
+ }
243
+ }
244
+ return { body: parts.join('\n'), count };
245
+ }
241
246
  export function renderHtml(report) {
242
247
  const version = report.claude.version ? `v${escapeHtml(report.claude.version)}` : 'unknown';
243
248
  const scopeLabel = escapeHtml(report.options.scope);
@@ -248,73 +253,21 @@ export function renderHtml(report) {
248
253
  ]
249
254
  .filter(Boolean)
250
255
  .join(' | ');
251
- // --- Issues (confirmed_problem + review) --------------------------------
252
- const globalIssues = report.findings.items.filter((f) => f.category === 'confirmed_problem' || f.category === 'review');
253
- const globalCoverage = report.findings.items.filter((f) => f.category === 'coverage');
254
256
  const multiContext = report.contexts.length > 1;
255
- let issuesHtml = '';
256
- if (multiContext) {
257
- const parts = [];
258
- if (globalIssues.length > 0) {
259
- parts.push(`<h3>Installation-wide</h3>\n${globalIssues.map(renderFinding).join('\n')}`);
260
- }
261
- for (const ctx of report.contexts) {
262
- const ctxIssues = ctx.findings.items.filter((f) => f.category === 'confirmed_problem' || f.category === 'review');
263
- if (ctxIssues.length > 0) {
264
- parts.push(`<h3>${escapeHtml(ctx.key)} &middot; ${escapeHtml(ctx.label)}${ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : ''}</h3>\n${ctxIssues.map(renderFinding).join('\n')}`);
265
- }
266
- }
267
- if (parts.length > 0) {
268
- issuesHtml = `<h2>Issues</h2>\n${parts.join('\n')}`;
269
- }
270
- }
271
- else {
272
- const allIssues = [
273
- ...globalIssues,
274
- ...report.contexts.flatMap((c) => c.findings.items.filter((f) => f.category === 'confirmed_problem' || f.category === 'review')),
275
- ];
276
- issuesHtml = allIssues.length > 0
277
- ? `<h2>Issues</h2>\n${allIssues.map(renderFinding).join('\n')}`
278
- : '';
279
- }
280
- // --- Context footprint ---------------------------------------------------
257
+ const issues = groupedFindings(report, isIssue);
258
+ const issuesHtml = issues.count > 0 ? `<h2>Issues</h2>\n${issues.body}` : '';
281
259
  const sorted = [...report.contexts].sort((a, b) => a.isCurrent === b.isCurrent ? 0 : a.isCurrent ? -1 : 1);
282
260
  const contextHtml = sorted.length > 0
283
261
  ? `<h2>Context Footprint</h2>\n${sorted.map((c) => renderContextFootprint(c, multiContext)).join('\n')}`
284
262
  : '';
285
- // --- Coverage notes ------------------------------------------------------
286
- let coverageHtml = '';
287
- if (multiContext) {
288
- const parts = [];
289
- if (globalCoverage.length > 0) {
290
- parts.push(`<h3>Installation-wide</h3>\n${globalCoverage.map(renderFinding).join('\n')}`);
291
- }
292
- for (const ctx of report.contexts) {
293
- const ctxCoverage = ctx.findings.items.filter((f) => f.category === 'coverage');
294
- if (ctxCoverage.length > 0) {
295
- parts.push(`<h3>${escapeHtml(ctx.key)} &middot; ${escapeHtml(ctx.label)}${ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : ''}</h3>\n${ctxCoverage.map(renderFinding).join('\n')}`);
296
- }
297
- }
298
- if (parts.length > 0) {
299
- coverageHtml = `<h2>Coverage Notes</h2>\n${parts.join('\n')}`;
300
- }
301
- }
302
- else {
303
- const allCoverage = [
304
- ...globalCoverage,
305
- ...report.contexts.flatMap((c) => c.findings.items.filter((f) => f.category === 'coverage')),
306
- ];
307
- coverageHtml = allCoverage.length > 0
308
- ? `<h2>Coverage Notes</h2>\n${allCoverage.map(renderFinding).join('\n')}`
309
- : '';
310
- }
311
- // --- Per-plugin details --------------------------------------------------
263
+ const coverage = groupedFindings(report, (f) => f.category === 'coverage');
264
+ const coverageHtml = coverage.count > 0 ? `<h2>Coverage Notes</h2>\n${coverage.body}` : '';
312
265
  let pluginDetailsHtml = '';
313
266
  if (multiContext) {
314
267
  const parts = [];
315
268
  for (const ctx of report.contexts) {
316
269
  if (ctx.effectivePlugins.items.length > 0) {
317
- parts.push(`<h3>${escapeHtml(ctx.key)} &middot; ${escapeHtml(ctx.label)}${ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : ''}</h3>\n${ctx.effectivePlugins.items.map(renderEffectivePlugin).join('\n')}`);
270
+ parts.push(`<h3>${contextName(ctx)}${currentBadge(ctx)}</h3>\n${ctx.effectivePlugins.items.map(renderEffectivePlugin).join('\n')}`);
318
271
  }
319
272
  }
320
273
  if (parts.length > 0) {
@@ -327,36 +280,10 @@ export function renderHtml(report) {
327
280
  ? `<h2>Plugin Details</h2>\n${effectivePlugins.map(renderEffectivePlugin).join('\n')}`
328
281
  : '';
329
282
  }
330
- // --- Maintenance (collapsed) ---------------------------------------------
331
- const globalMaintenance = report.findings.items.filter((f) => f.category === 'maintenance');
332
- let maintenanceHtml = '';
333
- if (multiContext) {
334
- const parts = [];
335
- if (globalMaintenance.length > 0) {
336
- parts.push(`<h3>Installation-wide</h3>\n${globalMaintenance.map(renderFinding).join('\n')}`);
337
- }
338
- for (const ctx of report.contexts) {
339
- const ctxMaintenance = ctx.findings.items.filter((f) => f.category === 'maintenance');
340
- if (ctxMaintenance.length > 0) {
341
- parts.push(`<h3>${escapeHtml(ctx.key)} &middot; ${escapeHtml(ctx.label)}${ctx.isCurrent ? ' <span class="badge badge-info">current</span>' : ''}</h3>\n${ctxMaintenance.map(renderFinding).join('\n')}`);
342
- }
343
- }
344
- if (parts.length > 0) {
345
- const totalMaintenance = globalMaintenance.length +
346
- report.contexts.reduce((sum, c) => sum + c.findings.items.filter((f) => f.category === 'maintenance').length, 0);
347
- maintenanceHtml = `<h2>Maintenance</h2>\n<details><summary>${totalMaintenance} maintenance note${totalMaintenance !== 1 ? 's' : ''}</summary>\n${parts.join('\n')}\n</details>`;
348
- }
349
- }
350
- else {
351
- const allMaintenance = [
352
- ...globalMaintenance,
353
- ...report.contexts.flatMap((c) => c.findings.items.filter((f) => f.category === 'maintenance')),
354
- ];
355
- maintenanceHtml =
356
- allMaintenance.length > 0
357
- ? `<h2>Maintenance</h2>\n<details><summary>${allMaintenance.length} maintenance note${allMaintenance.length !== 1 ? 's' : ''}</summary>\n${allMaintenance.map(renderFinding).join('\n')}\n</details>`
358
- : '';
359
- }
283
+ const maintenance = groupedFindings(report, (f) => f.category === 'maintenance');
284
+ const maintenanceHtml = maintenance.count > 0
285
+ ? `<h2>Maintenance</h2>\n<details><summary>${maintenance.count} maintenance note${maintenance.count !== 1 ? 's' : ''}</summary>\n${maintenance.body}\n</details>`
286
+ : '';
360
287
  return `<!DOCTYPE html>
361
288
  <html lang="en">
362
289
  <head>