claudepluginhub 0.16.1 → 0.18.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 +36 -2
  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 +29 -16
  24. package/dist/doctor/rules.js +86 -26
  25. package/dist/doctor/run.d.ts +1 -1
  26. package/dist/doctor/run.js +13 -8
  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,23 +1,16 @@
1
1
  import type { ScanResult } from './report.js';
2
2
  /**
3
- * Bounded, deterministic, read-only inventory of one plugin install root.
3
+ * Bounded, deterministic, read-only inventory of one plugin install root — limited
4
+ * structural checks, not validation (`claude plugin validate` is authoritative).
4
5
  *
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.
6
+ * Every plugin file is untrusted: size-checked before reading, JSON parsed in
7
+ * try/catch, frontmatter read by a bounded line scanner (not a YAML parser —
8
+ * files it cannot understand become "unestimated", never "invalid"). Nothing
9
+ * from a plugin is ever executed or imported.
9
10
  *
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.
11
+ * Symlinks are followed only when their realpath stays inside the canonical
12
+ * root, with a visited set against cycles; escaping or unresolvable links are
13
+ * reported and mark the scan incomplete. Scans are memoized by canonical root.
21
14
  */
22
15
  export interface ScanLimits {
23
16
  /** Distinct plugin roots scanned per run. */
@@ -33,15 +26,8 @@ export interface ScanLimits {
33
26
  /** Directory depth below the plugin root. */
34
27
  maxDepth: number;
35
28
  }
36
- export declare const DEFAULT_LIMITS: ScanLimits;
37
- /** Documented tool-matched hook events (hooks reference). */
29
+ /** Documented tool-matched hook events. */
38
30
  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
31
  export interface Scanner {
46
32
  scan(installPath: string): ScanResult;
47
33
  stats(): {
@@ -4,7 +4,8 @@ import { createHash } from 'node:crypto';
4
4
  import { isWithin, canonicalize } from './paths.js';
5
5
  import { boundName, sanitizeCommand, sanitizeUrlOrigin } from './sanitize.js';
6
6
  import { VALID_NAME_RE } from '../validation.js';
7
- export const DEFAULT_LIMITS = {
7
+ import { compareBytes } from './report.js';
8
+ const DEFAULT_LIMITS = {
8
9
  maxPlugins: 200,
9
10
  maxFilesPerPlugin: 2000,
10
11
  maxFileBytes: 512 * 1024,
@@ -12,7 +13,7 @@ export const DEFAULT_LIMITS = {
12
13
  maxTotalBytes: 128 * 1024 * 1024,
13
14
  maxDepth: 12,
14
15
  };
15
- /** Documented tool-matched hook events (hooks reference). */
16
+ /** Documented tool-matched hook events. */
16
17
  export const TOOL_MATCHED_EVENTS = new Set([
17
18
  'PreToolUse',
18
19
  'PostToolUse',
@@ -23,16 +24,14 @@ export const TOOL_MATCHED_EVENTS = new Set([
23
24
  const FRONTMATTER_MAX_LINES = 100;
24
25
  const FRONTMATTER_MAX_BYTES = 16 * 1024;
25
26
  const MAX_KEYS = 50;
26
- /** Default cap on combined description + when_to_use listing text (chars).
27
- * Configurable listing caps/budgets may cause Doctor to differ from Claude's
28
- * effective post-budget context. */
27
+ /** Default cap on combined description + when_to_use listing chars. */
29
28
  const LISTING_DESC_CAP = 1536;
30
29
  /**
31
- * Aggregate cap on hook/MCP/LSP/monitor facts per plugin. Parse helpers stop
32
- * producing at MAX_FACTS_PER_TYPE + 1 so the scanner can DETECT the overflow
33
- * and flag it ('max-facts' → scan_incomplete) instead of capping silently.
30
+ * Per-plugin cap on hook/MCP/LSP/monitor facts. Parse helpers stop at
31
+ * MAX_FACTS_PER_TYPE + 1 so overflow is detected and flagged ('max-facts'),
32
+ * never capped silently.
34
33
  */
35
- export const MAX_FACTS_PER_TYPE = 100;
34
+ const MAX_FACTS_PER_TYPE = 100;
36
35
  export function createScanner(overrides) {
37
36
  const limits = { ...DEFAULT_LIMITS, ...overrides };
38
37
  const memo = new Map();
@@ -99,10 +98,7 @@ export function createScanner(overrides) {
99
98
  totalBytesRead += size;
100
99
  return content;
101
100
  }
102
- /**
103
- * Deterministic bounded walk. Calls visit(relPath, absPath, size) for every
104
- * regular file reached. Returns false when a budget aborted the walk.
105
- */
101
+ /** Deterministic bounded walk calling visit() for every regular file reached. */
106
102
  function walk(rootCanonical, startRel, state, visit) {
107
103
  const visitedDirs = new Set();
108
104
  function recurse(dirAbs, dirRel, depth) {
@@ -409,11 +405,8 @@ function readBlockScalar(lines, startIndex, limit, indicator, chomping) {
409
405
  const leadingSpaces = line.match(/^( *)/)?.[1].length ?? 0;
410
406
  if (indent === -1) {
411
407
  indent = leadingSpaces;
412
- if (indent === 0) {
413
- if (/^---\s*$/.test(line))
414
- break;
408
+ if (indent === 0)
415
409
  break;
416
- }
417
410
  }
418
411
  if (leadingSpaces < indent)
419
412
  break;
@@ -761,7 +754,7 @@ function boundedKeys(value) {
761
754
  if (!value || typeof value !== 'object' || Array.isArray(value)) {
762
755
  return { items: [], total: 0, omitted: 0 };
763
756
  }
764
- const keys = Object.keys(value).filter((k) => typeof k === 'string');
757
+ const keys = Object.keys(value);
765
758
  const items = keys.slice(0, MAX_KEYS).map(boundName).sort();
766
759
  return { items, total: keys.length, omitted: keys.length - items.length };
767
760
  }
@@ -920,14 +913,12 @@ function parseMonitorEntries(raw) {
920
913
  return facts;
921
914
  }
922
915
  function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
923
- // --- manifest -------------------------------------------------------------
924
916
  const manifestRel = '.claude-plugin/plugin.json';
925
917
  const manifestAbs = join(rootCanonical, manifestRel);
926
918
  let manifest = {};
927
- let manifestExists = false;
919
+ let manifestExists = true;
928
920
  try {
929
921
  lstatSync(manifestAbs);
930
- manifestExists = true;
931
922
  }
932
923
  catch {
933
924
  manifestExists = false;
@@ -955,6 +946,11 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
955
946
  }
956
947
  }
957
948
  }
949
+ const experimental = manifest.experimental && typeof manifest.experimental === 'object' && !Array.isArray(manifest.experimental)
950
+ ? manifest.experimental
951
+ : {};
952
+ // themes/monitors may also be declared under `experimental`; the top-level field wins.
953
+ const topOrExperimental = (field) => manifest[field] !== undefined ? manifest[field] : experimental[field];
958
954
  if (result.manifest.inspected && !result.manifest.parseError) {
959
955
  const name = manifest.name;
960
956
  if (typeof name === 'string' && VALID_NAME_RE.test(name)) {
@@ -965,21 +961,16 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
965
961
  if (typeof name === 'string')
966
962
  result.manifest.name = null;
967
963
  }
968
- const experimental = manifest.experimental && typeof manifest.experimental === 'object' && !Array.isArray(manifest.experimental)
969
- ? manifest.experimental
970
- : {};
971
- const themesValue = manifest.themes !== undefined ? manifest.themes : experimental.themes;
972
- const monitorsValue = manifest.monitors !== undefined ? manifest.monitors : experimental.monitors;
973
964
  const checks = [
974
965
  ['commands', manifest.commands, isPathOrArray],
975
966
  ['agents', manifest.agents, isPathOrArray],
976
967
  ['skills', manifest.skills, isPathOrArray],
977
968
  ['outputStyles', manifest.outputStyles, isPathOrArray],
978
- ['themes', themesValue, isPathOrArray],
969
+ ['themes', topOrExperimental('themes'), isPathOrArray],
979
970
  ['hooks', manifest.hooks, isPathArrayOrObject],
980
971
  ['mcpServers', manifest.mcpServers, isPathArrayOrObject],
981
972
  ['lspServers', manifest.lspServers, isPathArrayOrObject],
982
- ['monitors', monitorsValue, isPathArrayOrObject],
973
+ ['monitors', topOrExperimental('monitors'), isPathArrayOrObject],
983
974
  // Top-level only — `workflows` is NOT an `experimental.*` field.
984
975
  ['workflows', manifest.workflows, isPathOrArray],
985
976
  ['dependencies', manifest.dependencies, (v) => Array.isArray(v)],
@@ -987,7 +978,7 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
987
978
  for (const [field, value, valid] of checks) {
988
979
  if (value !== undefined && !valid(value)) {
989
980
  result.manifest.invalidFields.push(field);
990
- // invalid declarations are ignored below — defaults apply
981
+ // Invalid declarations are dropped so the defaults apply below.
991
982
  if (field === 'themes')
992
983
  delete experimental.themes;
993
984
  delete manifest[field];
@@ -999,17 +990,11 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
999
990
  }
1000
991
  result.manifest.dependencies = parseDependencies(manifest.dependencies);
1001
992
  }
1002
- else if (result.manifest.parseError) {
1003
- manifest = {};
1004
- }
1005
- const experimental = manifest.experimental && typeof manifest.experimental === 'object' && !Array.isArray(manifest.experimental)
1006
- ? manifest.experimental
1007
- : {};
1008
- // --- component path resolution (docs: skills ADD, others REPLACE) ---------
993
+ // Declared paths: skills ADD to the default dir, every other type REPLACES it.
1009
994
  const commandsRoots = boundPaths(stringPaths(manifest.commands), state);
1010
995
  const agentsRoots = boundPaths(stringPaths(manifest.agents), state);
1011
996
  const outputStylesRoots = boundPaths(stringPaths(manifest.outputStyles), state);
1012
- const themesRoots = boundPaths(stringPaths(manifest.themes !== undefined ? manifest.themes : experimental.themes), state);
997
+ const themesRoots = boundPaths(stringPaths(topOrExperimental('themes')), state);
1013
998
  // A declared "." / "./" means the root SKILL.md (handled below as the
1014
999
  // documented special case) — it must not become a whole-tree walk root.
1015
1000
  const explicitRootSkill = declaresRootPath(manifest.skills);
@@ -1024,7 +1009,7 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1024
1009
  ...boundPaths(stringPaths(manifest.hooks), state),
1025
1010
  ...boundPaths(stringPaths(manifest.mcpServers), state),
1026
1011
  ...boundPaths(stringPaths(manifest.lspServers), state),
1027
- ...boundPaths(stringPaths(manifest.monitors !== undefined ? manifest.monitors : experimental.monitors), state),
1012
+ ...boundPaths(stringPaths(topOrExperimental('monitors')), state),
1028
1013
  ...boundPaths(stringPaths(manifest.workflows), state),
1029
1014
  ];
1030
1015
  for (const rel of [...new Set(declared)].sort()) {
@@ -1071,7 +1056,6 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1071
1056
  result.components.push(buildComponent('skill', 'SKILL.md', direct.content));
1072
1057
  }
1073
1058
  }
1074
- // --- themes ----------------------------------------------------------------
1075
1059
  for (const root of themesRoots.length > 0 ? [...new Set(themesRoots)].sort() : ['themes']) {
1076
1060
  walk(rootCanonical, root, state, (relPath, absPath, size) => {
1077
1061
  if (!relPath.endsWith('.json'))
@@ -1088,7 +1072,6 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1088
1072
  }
1089
1073
  });
1090
1074
  }
1091
- // --- JSON config helpers -----------------------------------------------------
1092
1075
  const readJsonConfig = (rel) => {
1093
1076
  const direct = openDirect(rel);
1094
1077
  if (direct.content === null)
@@ -1128,7 +1111,6 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1128
1111
  target.push(fact);
1129
1112
  }
1130
1113
  };
1131
- // --- hooks -------------------------------------------------------------------
1132
1114
  {
1133
1115
  const { files, inline } = configSources(manifest.hooks, 'hooks/hooks.json');
1134
1116
  for (const rel of files) {
@@ -1139,7 +1121,6 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1139
1121
  for (const cfg of inline)
1140
1122
  pushFacts(result.hooks, parseHooksConfig(cfg));
1141
1123
  }
1142
- // --- MCP servers ---------------------------------------------------------------
1143
1124
  {
1144
1125
  const { files, inline } = configSources(manifest.mcpServers, '.mcp.json');
1145
1126
  for (const rel of files) {
@@ -1150,7 +1131,6 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1150
1131
  for (const cfg of inline)
1151
1132
  pushFacts(result.mcp, parseMcpConfig({ mcpServers: cfg }, rootCanonical));
1152
1133
  }
1153
- // --- LSP servers -----------------------------------------------------------------
1154
1134
  {
1155
1135
  const { files, inline } = configSources(manifest.lspServers, '.lsp.json');
1156
1136
  for (const rel of files) {
@@ -1169,10 +1149,8 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1169
1149
  state.limitsHit.add('max-keys');
1170
1150
  state.incomplete = true;
1171
1151
  }
1172
- // --- monitors ----------------------------------------------------------------------
1173
1152
  {
1174
- const monitorsValue = manifest.monitors !== undefined ? manifest.monitors : experimental.monitors;
1175
- const { files, inline } = configSources(monitorsValue, 'monitors/monitors.json');
1153
+ const { files, inline } = configSources(topOrExperimental('monitors'), 'monitors/monitors.json');
1176
1154
  for (const rel of files) {
1177
1155
  const parsed = readJsonConfig(rel);
1178
1156
  if (parsed !== undefined)
@@ -1181,14 +1159,8 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1181
1159
  if (inline.length > 0)
1182
1160
  pushFacts(result.monitors, parseMonitorEntries(inline));
1183
1161
  }
1184
- // --- workflows/ (spec: top-level manifest field, REPLACES the default dir) --
1185
- // Mirrors the measured loader behaviour, which is narrower than every other
1186
- // component scan here:
1187
- // - `.js` ONLY, matched case-sensitively (`W.JS` is silently not loaded)
1188
- // - direct children only — `workflows/sub/w.js` never loads
1189
- // Files are LISTED, never read and never executed. The invocation name lives
1190
- // in the script's `export const meta`, which needs a JS parser the CLI does
1191
- // not ship, so no name is claimed here.
1162
+ // Workflows mirror the loader, which is narrower than other scans: `.js` only,
1163
+ // case-sensitive (`W.JS` never loads), direct children only. Listed, never read.
1192
1164
  const workflowsRoots = boundPaths(stringPaths(manifest.workflows), state);
1193
1165
  for (const root of workflowsRoots.length > 0 ? [...new Set(workflowsRoots)].sort() : ['workflows']) {
1194
1166
  const dirReal = containedReal(rootCanonical, root, state);
@@ -1206,7 +1178,6 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1206
1178
  state.incomplete = true;
1207
1179
  }
1208
1180
  for (const entry of entries.slice(0, MAX_KEYS)) {
1209
- // Case-SENSITIVE: the loader does not lowercase, so `W.JS` is not a workflow.
1210
1181
  if (!entry.endsWith('.js'))
1211
1182
  continue;
1212
1183
  const abs = join(dirReal, entry);
@@ -1217,10 +1188,7 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1217
1188
  catch {
1218
1189
  continue;
1219
1190
  }
1220
- // Same containment rule as bin/ below: `statSync` alone FOLLOWS symlinks,
1221
- // so an entry resolving outside the plugin root would be listed as a
1222
- // legitimate workflow of this plugin and the report would not be marked
1223
- // incomplete — the one signal that tells the reader the scan was bounded.
1191
+ // statSync alone follows symlinks; an escaping entry must be reported, not listed.
1224
1192
  if (info.isSymbolicLink()) {
1225
1193
  try {
1226
1194
  const real = realpathSync(abs);
@@ -1243,9 +1211,7 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1243
1211
  result.workflowFiles.push(`${root}/${entry}`);
1244
1212
  }
1245
1213
  }
1246
- // --- bin/ (spec: on PATH while the plugin is enabled; tree-only, no manifest) --------
1247
- // The directory itself goes through the contained-realpath helper: a bin/
1248
- // that is a symlink pointing outside the root must not be listed at all.
1214
+ // bin/ has no manifest field; the directory itself must resolve inside the root.
1249
1215
  const binReal = containedReal(rootCanonical, 'bin', state);
1250
1216
  if (binReal !== null) {
1251
1217
  let entries = [];
@@ -1303,6 +1269,6 @@ function scanPlugin(rootCanonical, state, result, read, walk, openDirect) {
1303
1269
  seenComponents.add(key);
1304
1270
  return true;
1305
1271
  });
1306
- result.components.sort((a, b) => (a.relPath < b.relPath ? -1 : a.relPath > b.relPath ? 1 : 0));
1272
+ result.components.sort((a, b) => compareBytes(a.relPath, b.relPath));
1307
1273
  result.themeFiles.sort();
1308
1274
  }
@@ -1,11 +1,8 @@
1
1
  import type { ScanResult } from './report.js';
2
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.
3
+ * Exact duplicates of skill/command/agent content across one context's sole
4
+ * instances: byte-identical after CRLF→LF and trailing-whitespace normalization
5
+ * (see hashComponentContent) — never a semantic-similarity claim.
9
6
  */
10
7
  export interface OverlapEntry {
11
8
  pluginId: string;
@@ -1,15 +1,10 @@
1
1
  import { makeTheme, shouldColorize } from './color.js';
2
2
  import { formatApproxTokens } from './estimate.js';
3
3
  import { wrapText, terminalWidth } from './wrap.js';
4
- /** Strip ANSI escape sequences to measure visible character width. */
5
4
  function stripAnsi(s) {
6
5
  return s.replace(/\x1b\[[0-9;]*m/g, '');
7
6
  }
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
- */
7
+ /** Style per wrapped line so ANSI codes never span physical lines. */
13
8
  function wrapDim(text, t, width, indent, firstIndent) {
14
9
  const wrapped = wrapText(text, width, indent, firstIndent);
15
10
  return wrapped.split('\n').map((line) => t.dim(line)).join('\n');
@@ -21,6 +16,9 @@ function wrapBoldHeading(text, t, width) {
21
16
  export function renderJson(report) {
22
17
  return `${JSON.stringify(report, null, 2)}\n`;
23
18
  }
19
+ function contextHeading(ctx) {
20
+ return `— ${ctx.key} · ${ctx.label}${ctx.isCurrent ? ' (current)' : ''}`;
21
+ }
24
22
  function findingsByCategory(findings, ...categories) {
25
23
  return findings.filter((f) => categories.includes(f.category));
26
24
  }
@@ -30,7 +28,7 @@ export function renderHuman(report, flags) {
30
28
  const width = terminalWidth();
31
29
  const lines = [];
32
30
  lines.push('');
33
- lines.push(`${t.cyan(t.bold('ClaudePluginHub Doctor'))}`);
31
+ lines.push(t.cyan(t.bold('ClaudePluginHub Doctor')));
34
32
  lines.push('');
35
33
  const { confirmedProblems, reviewItems, coverageGaps } = report.summary;
36
34
  const actionableCount = confirmedProblems + reviewItems;
@@ -49,16 +47,14 @@ export function renderHuman(report, flags) {
49
47
  const globalActionable = findingsByCategory(report.findings.items, 'confirmed_problem', 'review');
50
48
  const globalCoverage = findingsByCategory(report.findings.items, 'coverage');
51
49
  if (multiContext) {
52
- // Show global findings under an "Installation-wide" heading
53
50
  if (globalActionable.length > 0) {
54
51
  lines.push(t.bold('Installation-wide'));
55
52
  renderFindingsList(globalActionable, t, width, lines);
56
53
  }
57
- // Show each context's actionable findings under its own heading
58
54
  for (const ctx of report.contexts) {
59
55
  const ctxActionable = findingsByCategory(ctx.findings.items, 'confirmed_problem', 'review');
60
56
  if (ctxActionable.length > 0) {
61
- lines.push(wrapBoldHeading(`— ${ctx.key} · ${ctx.label}${ctx.isCurrent ? ' (current)' : ''}`, t, width));
57
+ lines.push(wrapBoldHeading(contextHeading(ctx), t, width));
62
58
  renderFindingsList(ctxActionable, t, width, lines);
63
59
  }
64
60
  }
@@ -72,9 +68,7 @@ export function renderHuman(report, flags) {
72
68
  }
73
69
  if (multiContext) {
74
70
  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'));
71
+ lines.push(wrapText(contextHeading(ctx), width, 0, 0).split('\n').map((l) => t.bold(l)).join('\n'));
78
72
  renderContextFootprint(ctx, t, width, lines);
79
73
  }
80
74
  }
@@ -84,13 +78,13 @@ export function renderHuman(report, flags) {
84
78
  if (multiContext) {
85
79
  if (globalCoverage.length > 0) {
86
80
  lines.push(t.bold('Installation-wide'));
87
- renderCoverageList(globalCoverage, t, width, lines);
81
+ renderFindingsList(globalCoverage, t, width, lines, t.yellow);
88
82
  }
89
83
  for (const ctx of report.contexts) {
90
84
  const ctxCoverage = findingsByCategory(ctx.findings.items, 'coverage');
91
85
  if (ctxCoverage.length > 0) {
92
- lines.push(wrapBoldHeading(`— ${ctx.key} · ${ctx.label}${ctx.isCurrent ? ' (current)' : ''}`, t, width));
93
- renderCoverageList(ctxCoverage, t, width, lines);
86
+ lines.push(wrapBoldHeading(contextHeading(ctx), t, width));
87
+ renderFindingsList(ctxCoverage, t, width, lines, t.yellow);
94
88
  }
95
89
  }
96
90
  }
@@ -99,7 +93,7 @@ export function renderHuman(report, flags) {
99
93
  ...globalCoverage,
100
94
  ...report.contexts.flatMap((c) => findingsByCategory(c.findings.items, 'coverage')),
101
95
  ];
102
- renderCoverageList(allCoverage, t, width, lines);
96
+ renderFindingsList(allCoverage, t, width, lines, t.yellow);
103
97
  }
104
98
  if (flags.strict) {
105
99
  const allMaintenance = [
@@ -116,7 +110,7 @@ export function renderHuman(report, flags) {
116
110
  }
117
111
  }
118
112
  if (flags.verbose) {
119
- renderVerbose(report, [], t, width, lines);
113
+ renderVerbose(report, t, width, lines);
120
114
  }
121
115
  const totalFindingsOmitted = report.findings.omitted +
122
116
  report.contexts.reduce((sum, c) => sum + c.findings.omitted, 0);
@@ -135,19 +129,9 @@ export function renderHuman(report, flags) {
135
129
  lines.push('');
136
130
  return lines.join('\n');
137
131
  }
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) {
132
+ function renderFindingsList(findings, t, width, lines, styleTitle = t.bold) {
149
133
  for (const finding of findings) {
150
- lines.push(` ${t.yellow(finding.title)}`);
134
+ lines.push(` ${styleTitle(finding.title)}`);
151
135
  lines.push(wrapText(finding.message, width, 4, 2));
152
136
  if (finding.remediation) {
153
137
  lines.push(wrapText(`${t.dim('fix:')} ${finding.remediation}`, width, 8, 2));
@@ -166,7 +150,6 @@ function renderContextFootprint(context, t, width, lines) {
166
150
  const footprintPlain = `Always-on context: ${tokenStr} tokens across ${summary.activePlugins} ${pluginWord}${!summary.estimateComplete ? ' (incomplete — lower bound)' : ''}`;
167
151
  const footprintWrapped = wrapText(footprintPlain, width, 2, 0);
168
152
  lines.push(footprintWrapped.split('\n').map((line) => {
169
- // Style token count and incomplete note within each physical line
170
153
  return line
171
154
  .replace(new RegExp(`${tokenStr.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} tokens`), t.cyan(`${tokenStr} tokens`))
172
155
  .replace('(incomplete — lower bound)', t.dim('(incomplete — lower bound)'));
@@ -193,7 +176,7 @@ function renderContextFootprint(context, t, width, lines) {
193
176
  }
194
177
  lines.push('');
195
178
  }
196
- function renderVerbose(report, _allFindings, t, width, lines) {
179
+ function renderVerbose(report, t, width, lines) {
197
180
  const multiContext = report.contexts.length > 1;
198
181
  const globalMaintenance = findingsByCategory(report.findings.items, 'maintenance');
199
182
  const hasAnyMaintenance = globalMaintenance.length > 0 ||
@@ -212,7 +195,7 @@ function renderVerbose(report, _allFindings, t, width, lines) {
212
195
  for (const ctx of report.contexts) {
213
196
  const ctxMaintenance = findingsByCategory(ctx.findings.items, 'maintenance');
214
197
  if (ctxMaintenance.length > 0) {
215
- lines.push(wrapDim(`— ${ctx.key} · ${ctx.label}${ctx.isCurrent ? ' (current)' : ''}`, t, width, 4, 2));
198
+ lines.push(wrapDim(contextHeading(ctx), t, width, 4, 2));
216
199
  for (const finding of ctxMaintenance) {
217
200
  lines.push(` ${finding.title}`);
218
201
  lines.push(wrapText(finding.message, width, 6, 4));
@@ -236,7 +219,7 @@ function renderVerbose(report, _allFindings, t, width, lines) {
236
219
  lines.push(t.bold('Plugins'));
237
220
  for (const context of report.contexts) {
238
221
  if (report.contexts.length > 1) {
239
- lines.push(wrapDim(`— ${context.key} · ${context.label}${context.isCurrent ? ' (current)' : ''}`, t, width, 4, 2));
222
+ lines.push(wrapDim(contextHeading(context), t, width, 4, 2));
240
223
  }
241
224
  for (const ep of context.effectivePlugins.items) {
242
225
  for (const line of effectivePluginLines(ep, t, width)) {
@@ -314,13 +297,12 @@ function effectivePluginLines(ep, t, width) {
314
297
  }
315
298
  }
316
299
  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
300
+ const ver = ep.versions.items.join('/');
301
+ const scope = ep.scopes.items.join('/');
320
302
  const full = ` ${t.bold(ep.id)} ${t.dim(`v${ver} (${scope})`)} ${state}${tokens}${chipStr}`;
321
303
  if (stripAnsi(full).length <= width)
322
304
  return [full];
323
- // Two-line layout: ID + state + tokens on first line, version/chips on second
305
+ // Two-line layout: id + state + tokens, then version/scope + chips.
324
306
  const line1 = ` ${t.bold(ep.id)} ${state}${tokens}`;
325
307
  const line2 = ` ${t.dim(`v${ver} (${scope})`)}${chipStr}`;
326
308
  const result = [];
@@ -24,11 +24,9 @@ export interface DoctorFlags {
24
24
  allProjects: boolean;
25
25
  }
26
26
  /**
27
- * Sanitized native error from a record's optional `errors` field.
28
- * Observed shape (spike 2026-07-18, Claude Code 2.1.212): array of
29
- * human-readable strings; a record can stay enabled:true with an unsatisfied
30
- * dependency. Object-with-`code` elements are tolerated as an alternate/future
31
- * shape. Raw messages are never stored.
27
+ * Sanitized native error from a record's optional `errors` field (observed as
28
+ * an array of strings; `{code}` objects tolerated). A record can stay
29
+ * enabled:true with an unsatisfied dependency. Raw messages are never stored.
32
30
  */
33
31
  export interface NativePluginError {
34
32
  /** 'dependency-missing', a validated code token, or 'unknown'. */
@@ -231,15 +229,9 @@ export interface PluginCapabilities {
231
229
  }>;
232
230
  binCount: number;
233
231
  /**
234
- * Count of `workflows/` scripts found (default dir or the manifest's
235
- * replaces-default path; `.js`, direct children only).
236
- *
237
- * A COUNT, not a per-item list, deliberately: the invocation name a workflow
238
- * registers lives in its `export const meta = {…}`, and extracting that
239
- * requires a JS parser the CLI does not ship. Emitting file basenames as if
240
- * they were command names would be a fabricated claim — the runtime uses
241
- * `meta.name`, which frequently differs from the filename. Report what we can
242
- * actually see.
232
+ * A count, not names: a workflow's invocation name is `meta.name` inside the
233
+ * script (needs a JS parser the CLI does not ship) and often differs from the
234
+ * filename, so listing basenames would be a fabricated claim.
243
235
  */
244
236
  workflowCount: number;
245
237
  }
@@ -346,8 +338,6 @@ export declare const MAX_FINDINGS = 500;
346
338
  export declare const MAX_PATHS_PER_TYPE = 50;
347
339
  export declare const MAX_PLUGIN_IDS_PER_FINDING = 20;
348
340
  export declare const MAX_EVIDENCE_ITEMS = 10;
349
- export declare const MAX_EVIDENCE_STRING = 200;
350
- export declare const MAX_MESSAGE_CHARS = 500;
351
341
  export declare const MAX_CONTEXTS = 50;
352
342
  export declare const MAX_PLUGINS_PER_CONTEXT = 200;
353
343
  export declare const MAX_EFFECTIVE_PLUGINS_PER_CONTEXT = 200;
@@ -362,6 +352,7 @@ export declare function cappedList<T>(items: T[], cap: number): CappedList<T>;
362
352
  export declare function recapList<T>(list: CappedList<T>, cap: number): CappedList<T>;
363
353
  export declare function boundEvidenceString(value: string): string;
364
354
  export declare function boundMessage(value: string): string;
355
+ export declare const SCOPE_RANK: Record<RecordScope, number>;
365
356
  export declare function compareBytes(a: string, b: string): number;
366
357
  export declare function compareFindings(a: Finding, b: Finding): number;
367
358
  export declare function comparePluginEntries(a: Pick<PluginEntry, 'id' | 'scope' | 'version'>, b: Pick<PluginEntry, 'id' | 'scope' | 'version'>): number;
@@ -9,15 +9,12 @@
9
9
  * command strings — see sanitize.ts.
10
10
  */
11
11
  export const DOCTOR_SCHEMA_VERSION = 1;
12
- // ---------------------------------------------------------------------------
13
- // Bounds & ordering
14
- // ---------------------------------------------------------------------------
15
12
  export const MAX_FINDINGS = 500;
16
13
  export const MAX_PATHS_PER_TYPE = 50;
17
14
  export const MAX_PLUGIN_IDS_PER_FINDING = 20;
18
15
  export const MAX_EVIDENCE_ITEMS = 10;
19
- export const MAX_EVIDENCE_STRING = 200;
20
- export const MAX_MESSAGE_CHARS = 500;
16
+ const MAX_EVIDENCE_STRING = 200;
17
+ const MAX_MESSAGE_CHARS = 500;
21
18
  export const MAX_CONTEXTS = 50;
22
19
  export const MAX_PLUGINS_PER_CONTEXT = 200;
23
20
  export const MAX_EFFECTIVE_PLUGINS_PER_CONTEXT = 200;
@@ -47,7 +44,7 @@ export function boundMessage(value) {
47
44
  return boundString(value, MAX_MESSAGE_CHARS);
48
45
  }
49
46
  const SEVERITY_RANK = { error: 0, warning: 1, info: 2 };
50
- const SCOPE_RANK = {
47
+ export const SCOPE_RANK = {
51
48
  user: 0,
52
49
  project: 1,
53
50
  local: 2,