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
package/README.md
CHANGED
|
@@ -19,6 +19,9 @@ npx claudepluginhub https://claudepluginhub.com/api/user-plugins/<userId>/<slug>
|
|
|
19
19
|
|
|
20
20
|
# Recommend plugins for the current project
|
|
21
21
|
npx claudepluginhub recommend
|
|
22
|
+
|
|
23
|
+
# Diagnose your Claude Code plugin setup (local, read-only, offline)
|
|
24
|
+
npx claudepluginhub doctor
|
|
22
25
|
```
|
|
23
26
|
|
|
24
27
|
## Identifier types
|
|
@@ -51,6 +54,7 @@ npx claudepluginhub update [identifier] Update (u/ collections only)
|
|
|
51
54
|
npx claudepluginhub list List (u/ collections only)
|
|
52
55
|
npx claudepluginhub remove <identifier> Remove
|
|
53
56
|
npx claudepluginhub recommend Recommend plugins for the current project
|
|
57
|
+
npx claudepluginhub doctor Diagnose the Claude Code plugin setup (read-only)
|
|
54
58
|
```
|
|
55
59
|
|
|
56
60
|
## Recommend
|
|
@@ -71,6 +75,77 @@ exist (e.g. `next.config.*`, `tailwind.config.*`). **Privacy:** only dependency
|
|
|
71
75
|
names and allowlisted config-filename prefixes are sent — never file contents,
|
|
72
76
|
never arbitrary filenames.
|
|
73
77
|
|
|
78
|
+
## Doctor
|
|
79
|
+
|
|
80
|
+
`npx claudepluginhub doctor` diagnoses the effective Claude Code plugin setup
|
|
81
|
+
for the current project — completely locally. It reads `claude plugin list
|
|
82
|
+
--json` (the only installed-plugin source of truth) plus files inside each
|
|
83
|
+
plugin's install directory, and reports concrete findings: native load errors,
|
|
84
|
+
broken install paths or manifests, duplicate/ambiguous installations, exact
|
|
85
|
+
duplicate skill/command/agent content across enabled plugins, broad
|
|
86
|
+
unconditional command hooks, missing MCP/LSP prerequisites, missing declared
|
|
87
|
+
dependencies, LSP extension conflicts, non-executable `bin/` files, and
|
|
88
|
+
heuristic context-size estimates. No account or network needed.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npx claudepluginhub doctor # verdict-first report for the current project
|
|
92
|
+
npx claudepluginhub doctor --open # detailed HTML report opened in your browser
|
|
93
|
+
npx claudepluginhub doctor --verbose # include maintenance details and full inventory
|
|
94
|
+
npx claudepluginhub doctor --json # machine-readable (schemaVersion 1)
|
|
95
|
+
npx claudepluginhub doctor --strict # warnings also fail (CI)
|
|
96
|
+
npx claudepluginhub doctor --scope user # restrict to one scope (user|project|local|all)
|
|
97
|
+
npx claudepluginhub doctor --all-projects # analyze other projects' records too, per project
|
|
98
|
+
npx claudepluginhub doctor --help # full reference
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Default output** leads with a verdict ("No broken plugins found" or "N
|
|
102
|
+
issues need attention"), followed by actionable findings, top context
|
|
103
|
+
contributors, and coverage notes. Maintenance details (disabled stale caches,
|
|
104
|
+
redundant records) are hidden by default — use `--verbose` to see them. Use
|
|
105
|
+
`--open` to generate a detailed self-contained HTML report and open it in your
|
|
106
|
+
browser (writes a temporary file — the only non-read-only action, opt-in).
|
|
107
|
+
|
|
108
|
+
**Default scope behavior.** Doctor diagnoses the current directory: user-scope
|
|
109
|
+
(and managed) plugins plus project/local plugins whose recorded project path
|
|
110
|
+
matches the current directory after resolving symlinks (macOS `/private/...`
|
|
111
|
+
aliases included). Records belonging to other projects are counted but not
|
|
112
|
+
analyzed unless `--all-projects` is passed — and then each project is analyzed
|
|
113
|
+
as its own context; plugins that merely coexist in different projects are
|
|
114
|
+
never reported as conflicting. Disabled plugins are inventoried but never
|
|
115
|
+
count toward active context totals, overlap, or runtime-risk findings. When
|
|
116
|
+
several enabled records exist for one plugin and their scans are equivalent
|
|
117
|
+
for Doctor's checks, they are treated as one effective plugin; otherwise
|
|
118
|
+
Doctor reports the ambiguity instead of guessing.
|
|
119
|
+
|
|
120
|
+
**Severities and exit codes.** `ERROR` = breaks or blocks plugin loading;
|
|
121
|
+
`WARN` = likely problem or notable risk signal; `INFO` = context. Exit `0` =
|
|
122
|
+
no errors (with `--strict`: no warnings either); exit `1` = completed with
|
|
123
|
+
errors (or warnings under `--strict`); exit `2` = Doctor could not run (bad
|
|
124
|
+
arguments, Claude CLI missing, or unusable `claude plugin list --json`
|
|
125
|
+
output). Manifest/component checks are limited structural checks — for
|
|
126
|
+
authoritative validation run `claude plugin validate <plugin install path>`.
|
|
127
|
+
|
|
128
|
+
**Context estimates** are heuristics (≈4 characters/token, always marked
|
|
129
|
+
`~`): always-on ≈ each skill/command/agent's name + description (the plugin's
|
|
130
|
+
listing text); on-invoke ≈ the component body. `claude plugin details` is the
|
|
131
|
+
authoritative source.
|
|
132
|
+
|
|
133
|
+
**Privacy.** Doctor is read-only and offline: it executes nothing (no plugin
|
|
134
|
+
code, hooks, MCP/LSP servers, or binaries), modifies nothing, and sends
|
|
135
|
+
nothing anywhere. Reports contain no absolute paths, file contents, or
|
|
136
|
+
environment/header values; URLs are reduced to their origin and commands to an
|
|
137
|
+
executable name, so `--json` output is safe to share.
|
|
138
|
+
|
|
139
|
+
```jsonc
|
|
140
|
+
// npx claudepluginhub doctor --json | jq '.summary'
|
|
141
|
+
{
|
|
142
|
+
"errors": 0,
|
|
143
|
+
"warnings": 1,
|
|
144
|
+
"notes": 2,
|
|
145
|
+
"otherProjectRecordsIgnored": 3
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
74
149
|
## Examples
|
|
75
150
|
|
|
76
151
|
```bash
|
|
@@ -84,10 +159,14 @@ npx claudepluginhub vercel/next.js --plugin cache-components
|
|
|
84
159
|
|--------|-------------|
|
|
85
160
|
| `--plugin <name>` | Install a specific plugin from a marketplace repo |
|
|
86
161
|
| `--yes, -y` | Skip prompts (install all, project scope) |
|
|
87
|
-
| `--scope <scope>` | Set scope: `user`, `project` (default), `local` |
|
|
162
|
+
| `--scope <scope>` | Set scope: `user`, `project` (default), `local` — `doctor` also accepts `all` (its default) |
|
|
88
163
|
| `--limit <n>` | `recommend` only: picks per detected stack (1-50, default 4) |
|
|
89
|
-
| `--json` | `recommend`
|
|
90
|
-
|
|
|
164
|
+
| `--json` | `recommend` / `doctor`: raw JSON output |
|
|
165
|
+
| `--strict` | `doctor` only: warnings also fail the run (exit 1) |
|
|
166
|
+
| `--verbose` | `doctor` only: show maintenance details and full plugin inventory |
|
|
167
|
+
| `--open` | `doctor` only: generate a detailed HTML report and open in browser |
|
|
168
|
+
| `--all-projects` | `doctor` only: analyze other projects' records, each per project |
|
|
169
|
+
| `-h, --help` | Show help (`doctor --help` for the doctor reference) |
|
|
91
170
|
|
|
92
171
|
## Lifecycle differences
|
|
93
172
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DoctorFlags } from './report.js';
|
|
2
|
+
export type ParsedDoctorArgs = {
|
|
3
|
+
kind: 'help';
|
|
4
|
+
} | {
|
|
5
|
+
kind: 'run';
|
|
6
|
+
flags: DoctorFlags;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'error';
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const DOCTOR_HELP = "ClaudePluginHub Doctor \u2014 diagnose the Claude Code plugin setup for this project.\n\nUsage: npx claudepluginhub doctor [options]\n\nReads `claude plugin list --json` plus files inside each plugin's install\ndirectory. Local-first and read-only: no plugin code is executed, nothing is\nmodified, and nothing is sent anywhere \u2014 no account or network needed.\n\nOptions:\n --json Machine-readable report (schemaVersion 1) on stdout;\n operational errors go to stderr\n --strict Warnings also fail the run (exit 1) \u2014 for CI use\n --verbose Show maintenance findings, full plugin inventory, and\n technical details hidden from the default output\n --open Generate a detailed HTML report and open it in the browser;\n writes a temporary file (explicit opt-in \u2014 the default\n command is read-only)\n --scope <scope> Restrict to one scope: user | project | local | all\n (default: all)\n --all-projects Also analyze project/local records belonging to other\n projects, each within its own project context\n -h, --help Show this help (runs nothing, scans nothing)\n\nDefault behavior:\n Diagnoses the effective setup for the current directory: user-scope (and\n managed) plugins, plus project/local plugins whose project path matches the\n current directory after resolving symlinks. Records belonging to other\n projects are counted but not analyzed unless --all-projects is passed.\n Disabled plugins are inventoried but never contribute to active context\n totals, overlap findings, or runtime-risk analysis. When several enabled\n records exist for one plugin and Claude's choice between them is not\n publicly determinable, Doctor reports the ambiguity instead of guessing.\n\nSeverities and exit codes:\n ERROR breaks or blocks plugin loading exit 1\n WARN likely problem or notable risk signal exit 1 only with --strict\n INFO context and low-stakes observations never fails the run\n exit 2 = Doctor could not run (bad arguments, Claude CLI missing, or\n unusable `claude plugin list --json` output).\n\nPrivacy:\n The report contains no absolute paths, file contents, or environment/header\n values. URLs are reduced to their origin; commands to an executable name.\n Context estimates are heuristics (~4 characters per token, marked with ~);\n `claude plugin details` is the authoritative source.\n\nExamples:\n npx claudepluginhub doctor\n npx claudepluginhub doctor --open\n npx claudepluginhub doctor --verbose\n npx claudepluginhub doctor --json | jq '.summary'\n npx claudepluginhub doctor --strict --scope project\n";
|
|
12
|
+
export declare function parseDoctorFlags(argv: string[]): ParsedDoctorArgs;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const VALID_SCOPES = ['user', 'project', 'local', 'all'];
|
|
2
|
+
export const DOCTOR_HELP = `ClaudePluginHub Doctor — diagnose the Claude Code plugin setup for this project.
|
|
3
|
+
|
|
4
|
+
Usage: npx claudepluginhub doctor [options]
|
|
5
|
+
|
|
6
|
+
Reads \`claude plugin list --json\` plus files inside each plugin's install
|
|
7
|
+
directory. Local-first and read-only: no plugin code is executed, nothing is
|
|
8
|
+
modified, and nothing is sent anywhere — no account or network needed.
|
|
9
|
+
|
|
10
|
+
Options:
|
|
11
|
+
--json Machine-readable report (schemaVersion 1) on stdout;
|
|
12
|
+
operational errors go to stderr
|
|
13
|
+
--strict Warnings also fail the run (exit 1) — for CI use
|
|
14
|
+
--verbose Show maintenance findings, full plugin inventory, and
|
|
15
|
+
technical details hidden from the default output
|
|
16
|
+
--open Generate a detailed HTML report and open it in the browser;
|
|
17
|
+
writes a temporary file (explicit opt-in — the default
|
|
18
|
+
command is read-only)
|
|
19
|
+
--scope <scope> Restrict to one scope: user | project | local | all
|
|
20
|
+
(default: all)
|
|
21
|
+
--all-projects Also analyze project/local records belonging to other
|
|
22
|
+
projects, each within its own project context
|
|
23
|
+
-h, --help Show this help (runs nothing, scans nothing)
|
|
24
|
+
|
|
25
|
+
Default behavior:
|
|
26
|
+
Diagnoses the effective setup for the current directory: user-scope (and
|
|
27
|
+
managed) plugins, plus project/local plugins whose project path matches the
|
|
28
|
+
current directory after resolving symlinks. Records belonging to other
|
|
29
|
+
projects are counted but not analyzed unless --all-projects is passed.
|
|
30
|
+
Disabled plugins are inventoried but never contribute to active context
|
|
31
|
+
totals, overlap findings, or runtime-risk analysis. When several enabled
|
|
32
|
+
records exist for one plugin and Claude's choice between them is not
|
|
33
|
+
publicly determinable, Doctor reports the ambiguity instead of guessing.
|
|
34
|
+
|
|
35
|
+
Severities and exit codes:
|
|
36
|
+
ERROR breaks or blocks plugin loading exit 1
|
|
37
|
+
WARN likely problem or notable risk signal exit 1 only with --strict
|
|
38
|
+
INFO context and low-stakes observations never fails the run
|
|
39
|
+
exit 2 = Doctor could not run (bad arguments, Claude CLI missing, or
|
|
40
|
+
unusable \`claude plugin list --json\` output).
|
|
41
|
+
|
|
42
|
+
Privacy:
|
|
43
|
+
The report contains no absolute paths, file contents, or environment/header
|
|
44
|
+
values. URLs are reduced to their origin; commands to an executable name.
|
|
45
|
+
Context estimates are heuristics (~4 characters per token, marked with ~);
|
|
46
|
+
\`claude plugin details\` is the authoritative source.
|
|
47
|
+
|
|
48
|
+
Examples:
|
|
49
|
+
npx claudepluginhub doctor
|
|
50
|
+
npx claudepluginhub doctor --open
|
|
51
|
+
npx claudepluginhub doctor --verbose
|
|
52
|
+
npx claudepluginhub doctor --json | jq '.summary'
|
|
53
|
+
npx claudepluginhub doctor --strict --scope project
|
|
54
|
+
`;
|
|
55
|
+
export function parseDoctorFlags(argv) {
|
|
56
|
+
if (argv.includes('--help') || argv.includes('-h'))
|
|
57
|
+
return { kind: 'help' };
|
|
58
|
+
let json = false;
|
|
59
|
+
let strict = false;
|
|
60
|
+
let verbose = false;
|
|
61
|
+
let open = false;
|
|
62
|
+
let allProjects = false;
|
|
63
|
+
let scope = null;
|
|
64
|
+
const seen = new Set();
|
|
65
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
66
|
+
const arg = argv[i];
|
|
67
|
+
if (arg === '--json' || arg === '--strict' || arg === '--all-projects' || arg === '--verbose' || arg === '--open') {
|
|
68
|
+
if (seen.has(arg))
|
|
69
|
+
return { kind: 'error', message: `Duplicate flag: ${arg}` };
|
|
70
|
+
seen.add(arg);
|
|
71
|
+
if (arg === '--json')
|
|
72
|
+
json = true;
|
|
73
|
+
else if (arg === '--strict')
|
|
74
|
+
strict = true;
|
|
75
|
+
else if (arg === '--verbose')
|
|
76
|
+
verbose = true;
|
|
77
|
+
else if (arg === '--open')
|
|
78
|
+
open = true;
|
|
79
|
+
else
|
|
80
|
+
allProjects = true;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (arg === '--scope') {
|
|
84
|
+
if (seen.has(arg))
|
|
85
|
+
return { kind: 'error', message: 'Duplicate flag: --scope' };
|
|
86
|
+
seen.add(arg);
|
|
87
|
+
const value = argv[i + 1];
|
|
88
|
+
if (!value || value.startsWith('-')) {
|
|
89
|
+
return { kind: 'error', message: 'Missing value for --scope. Must be: user, project, local, or all' };
|
|
90
|
+
}
|
|
91
|
+
if (!VALID_SCOPES.includes(value)) {
|
|
92
|
+
return { kind: 'error', message: `Invalid scope "${value}". Must be: user, project, local, or all` };
|
|
93
|
+
}
|
|
94
|
+
scope = value;
|
|
95
|
+
i += 1;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
return { kind: 'error', message: `Unknown argument for doctor: ${arg}` };
|
|
99
|
+
}
|
|
100
|
+
if (open && json) {
|
|
101
|
+
return { kind: 'error', message: '--open and --json are incompatible' };
|
|
102
|
+
}
|
|
103
|
+
const resolvedScope = scope ?? 'all';
|
|
104
|
+
if (allProjects && resolvedScope === 'user') {
|
|
105
|
+
return {
|
|
106
|
+
kind: 'error',
|
|
107
|
+
message: '--all-projects only widens project-bound scopes and cannot be combined with --scope user',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return { kind: 'run', flags: { json, strict, verbose, open, scope: resolvedScope, allProjects } };
|
|
111
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { InstallationRecord } from './report.js';
|
|
2
|
+
/**
|
|
3
|
+
* Probe layer over the Claude CLI. `claude plugin list --json` is the ONLY
|
|
4
|
+
* installed-plugin source of truth; its exact shape is undocumented, so
|
|
5
|
+
* records are validated individually — a malformed element is dropped (and
|
|
6
|
+
* counted) without failing the run, while a top-level failure (claude not
|
|
7
|
+
* spawnable, non-zero exit, output not a JSON array) is an operational
|
|
8
|
+
* failure the caller maps to exit 2.
|
|
9
|
+
*/
|
|
10
|
+
export interface ClaudeExecResult {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
stdout: string;
|
|
13
|
+
stderr: string;
|
|
14
|
+
}
|
|
15
|
+
export type ClaudeExec = (args: string[]) => ClaudeExecResult;
|
|
16
|
+
export interface ProbeSuccess {
|
|
17
|
+
ok: true;
|
|
18
|
+
claudeVersion: string | null;
|
|
19
|
+
records: InstallationRecord[];
|
|
20
|
+
droppedRecords: number;
|
|
21
|
+
}
|
|
22
|
+
export interface ProbeFailure {
|
|
23
|
+
ok: false;
|
|
24
|
+
reason: string;
|
|
25
|
+
}
|
|
26
|
+
export type ProbeResult = ProbeSuccess | ProbeFailure;
|
|
27
|
+
export declare function probeClaude(exec?: ClaudeExec): ProbeResult;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { boundEvidenceString } from './report.js';
|
|
3
|
+
import { canonicalize } from './paths.js';
|
|
4
|
+
import { sanitizeNativeErrors } from './sanitize.js';
|
|
5
|
+
const KNOWN_SCOPES = new Set(['user', 'project', 'local', 'managed']);
|
|
6
|
+
function defaultExec(args) {
|
|
7
|
+
try {
|
|
8
|
+
const stdout = execFileSync('claude', args, {
|
|
9
|
+
encoding: 'utf-8',
|
|
10
|
+
timeout: 60_000,
|
|
11
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
12
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
13
|
+
});
|
|
14
|
+
return { ok: true, stdout, stderr: '' };
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
const error = err;
|
|
18
|
+
return {
|
|
19
|
+
ok: false,
|
|
20
|
+
stdout: error.stdout ?? '',
|
|
21
|
+
stderr: error.stderr ?? error.message ?? 'Unknown error',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function parseVersion(output) {
|
|
26
|
+
const match = output.trim().match(/^(\d+\.\d+\.\d+\S*)/);
|
|
27
|
+
return match ? match[1] : null;
|
|
28
|
+
}
|
|
29
|
+
function splitId(id) {
|
|
30
|
+
const at = id.lastIndexOf('@');
|
|
31
|
+
if (at <= 0)
|
|
32
|
+
return { name: id, marketplace: '' };
|
|
33
|
+
return { name: id.slice(0, at), marketplace: id.slice(at + 1) };
|
|
34
|
+
}
|
|
35
|
+
function parseRecord(element) {
|
|
36
|
+
if (!element || typeof element !== 'object' || Array.isArray(element))
|
|
37
|
+
return null;
|
|
38
|
+
const raw = element;
|
|
39
|
+
if (typeof raw.id !== 'string' || raw.id.length === 0)
|
|
40
|
+
return null;
|
|
41
|
+
if (typeof raw.scope !== 'string' || raw.scope.length === 0)
|
|
42
|
+
return null;
|
|
43
|
+
if (typeof raw.enabled !== 'boolean')
|
|
44
|
+
return null;
|
|
45
|
+
if (typeof raw.installPath !== 'string' || raw.installPath.length === 0)
|
|
46
|
+
return null;
|
|
47
|
+
if (raw.version !== undefined && typeof raw.version !== 'string')
|
|
48
|
+
return null;
|
|
49
|
+
if (raw.projectPath !== undefined && typeof raw.projectPath !== 'string')
|
|
50
|
+
return null;
|
|
51
|
+
// Bound externally sourced identifiers — id/version/scope strings come
|
|
52
|
+
// from another program's output and must not inflate the report.
|
|
53
|
+
const id = boundEvidenceString(raw.id);
|
|
54
|
+
const { name, marketplace } = splitId(id);
|
|
55
|
+
const rawScope = boundEvidenceString(raw.scope);
|
|
56
|
+
const scope = KNOWN_SCOPES.has(rawScope) ? rawScope : 'unknown';
|
|
57
|
+
return {
|
|
58
|
+
id,
|
|
59
|
+
name,
|
|
60
|
+
marketplace,
|
|
61
|
+
version: boundEvidenceString(raw.version ?? 'unknown'),
|
|
62
|
+
scope,
|
|
63
|
+
rawScope,
|
|
64
|
+
enabled: raw.enabled,
|
|
65
|
+
installPath: raw.installPath,
|
|
66
|
+
installPathCanonical: canonicalize(raw.installPath),
|
|
67
|
+
projectPathCanonical: typeof raw.projectPath === 'string' ? canonicalize(raw.projectPath) : null,
|
|
68
|
+
errors: sanitizeNativeErrors(raw.errors),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export function probeClaude(exec = defaultExec) {
|
|
72
|
+
const versionResult = exec(['--version']);
|
|
73
|
+
if (!versionResult.ok) {
|
|
74
|
+
return {
|
|
75
|
+
ok: false,
|
|
76
|
+
reason: 'Claude CLI not found or not runnable. Doctor needs `claude plugin list --json` for its inventory. ' +
|
|
77
|
+
'Install Claude Code first: https://code.claude.com/docs',
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const claudeVersion = parseVersion(versionResult.stdout);
|
|
81
|
+
const listResult = exec(['plugin', 'list', '--json']);
|
|
82
|
+
if (!listResult.ok) {
|
|
83
|
+
const detail = listResult.stderr.trim().slice(0, 200);
|
|
84
|
+
return {
|
|
85
|
+
ok: false,
|
|
86
|
+
reason: `\`claude plugin list --json\` failed${detail ? `: ${detail}` : ''}. This Claude version may be too old for Doctor.`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
let parsed;
|
|
90
|
+
try {
|
|
91
|
+
parsed = JSON.parse(listResult.stdout);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return {
|
|
95
|
+
ok: false,
|
|
96
|
+
reason: '`claude plugin list --json` did not return valid JSON. This Claude version may be too old for Doctor.',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (!Array.isArray(parsed)) {
|
|
100
|
+
return {
|
|
101
|
+
ok: false,
|
|
102
|
+
reason: '`claude plugin list --json` did not return a JSON array. This Claude version may be too old for Doctor.',
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const records = [];
|
|
106
|
+
let droppedRecords = 0;
|
|
107
|
+
for (const element of parsed) {
|
|
108
|
+
const record = parseRecord(element);
|
|
109
|
+
if (record)
|
|
110
|
+
records.push(record);
|
|
111
|
+
else
|
|
112
|
+
droppedRecords += 1;
|
|
113
|
+
}
|
|
114
|
+
return { ok: true, claudeVersion, records, droppedRecords };
|
|
115
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Zero-dependency ANSI color utilities for CLI output. */
|
|
2
|
+
export declare function shouldColorize(): boolean;
|
|
3
|
+
export interface Theme {
|
|
4
|
+
bold(s: string): string;
|
|
5
|
+
dim(s: string): string;
|
|
6
|
+
red(s: string): string;
|
|
7
|
+
green(s: string): string;
|
|
8
|
+
yellow(s: string): string;
|
|
9
|
+
cyan(s: string): string;
|
|
10
|
+
}
|
|
11
|
+
export declare function makeTheme(color: boolean): Theme;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Zero-dependency ANSI color utilities for CLI output. */
|
|
2
|
+
export function shouldColorize() {
|
|
3
|
+
if ('NO_COLOR' in process.env)
|
|
4
|
+
return false;
|
|
5
|
+
if (process.env.FORCE_COLOR !== undefined)
|
|
6
|
+
return true;
|
|
7
|
+
return process.stdout.isTTY === true;
|
|
8
|
+
}
|
|
9
|
+
const identity = (s) => s;
|
|
10
|
+
const wrap = (open, close) => (s) => `${open}${s}${close}`;
|
|
11
|
+
export function makeTheme(color) {
|
|
12
|
+
if (!color) {
|
|
13
|
+
return { bold: identity, dim: identity, red: identity, green: identity, yellow: identity, cyan: identity };
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
bold: wrap('\x1b[1m', '\x1b[22m'),
|
|
17
|
+
dim: wrap('\x1b[2m', '\x1b[22m'),
|
|
18
|
+
red: wrap('\x1b[31m', '\x1b[39m'),
|
|
19
|
+
green: wrap('\x1b[32m', '\x1b[39m'),
|
|
20
|
+
yellow: wrap('\x1b[33m', '\x1b[39m'),
|
|
21
|
+
cyan: wrap('\x1b[36m', '\x1b[39m'),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InstallationRecord, ScanResult } from './report.js';
|
|
2
|
+
import type { SelectionOutput } from './select.js';
|
|
3
|
+
export declare function scanEquivalent(aRecord: InstallationRecord, aScan: ScanResult, bRecord: InstallationRecord, bScan: ScanResult): boolean;
|
|
4
|
+
/** Build the composite key used by `ruleDuplicateRecord` for grouping. */
|
|
5
|
+
export declare function duplicateRecordKey(record: InstallationRecord): string;
|
|
6
|
+
export declare function resolveEquivalences(base: SelectionOutput, scanFor: (record: InstallationRecord) => ScanResult): {
|
|
7
|
+
resolved: SelectionOutput;
|
|
8
|
+
scanEquivalentKeys: Set<string>;
|
|
9
|
+
};
|