claudepluginhub 0.12.1 → 0.13.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/dist/collection-install.d.ts +33 -0
- package/dist/collection-install.js +46 -3
- package/dist/index.js +5 -2
- package/dist/prompts.d.ts +13 -0
- package/dist/prompts.js +85 -1
- package/dist/recommend.d.ts +9 -0
- package/dist/recommend.js +168 -4
- package/package.json +1 -1
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
import type { Scope } from './prompts.js';
|
|
2
|
+
import type { MarketplaceJSON } from './fetch.js';
|
|
3
|
+
/**
|
|
4
|
+
* Structured outcome of one plugin install attempt, discriminated on `ok` so
|
|
5
|
+
* a failure always carries its `stage` and `error`. `stage` names the step
|
|
6
|
+
* that failed so callers can classify failures without parsing `error` text
|
|
7
|
+
* (the recommend flow maps stages to its allowlisted failureClass enum —
|
|
8
|
+
* never the raw error string).
|
|
9
|
+
*/
|
|
10
|
+
export type PluginInstallResult = {
|
|
11
|
+
name: string;
|
|
12
|
+
ok: true;
|
|
13
|
+
} | {
|
|
14
|
+
name: string;
|
|
15
|
+
ok: false;
|
|
16
|
+
stage: 'validate' | 'marketplace_add' | 'install';
|
|
17
|
+
/** Native command output or a validation message — display only, never sent anywhere. */
|
|
18
|
+
error: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Install a single plugin from a fetched marketplace manifest: validate the
|
|
22
|
+
* marketplace name, find the EXPECTED plugin by name (never a blind
|
|
23
|
+
* `plugins[0]`), register the marketplace, install. Prompt-free and
|
|
24
|
+
* exit-free — always returns a structured result, so interactive callers
|
|
25
|
+
* (collection/wrapper installs, the recommend flow) own their own output and
|
|
26
|
+
* exit semantics.
|
|
27
|
+
*
|
|
28
|
+
* `skipMarketplaceAdd` lets multi-plugin callers that registered the shared
|
|
29
|
+
* marketplace once up-front (runNativeManifestInstall) reuse the entry-lookup
|
|
30
|
+
* + install steps without re-adding per plugin.
|
|
31
|
+
*/
|
|
32
|
+
export declare function installPluginFromManifest(manifest: MarketplaceJSON, pluginName: string, registerUrl: string, scope: Scope, opts?: {
|
|
33
|
+
skipMarketplaceAdd?: boolean;
|
|
34
|
+
}): PluginInstallResult;
|
|
2
35
|
export declare function runCollectionInstall(url: string, yes: boolean, scopeOverride: Scope | null): Promise<void>;
|
|
3
36
|
/**
|
|
4
37
|
* Install a single plugin via its ClaudePluginHub wrapper marketplace
|
|
@@ -15,6 +15,48 @@ function isInstallableMarketplaceName(name) {
|
|
|
15
15
|
!name.includes('..') &&
|
|
16
16
|
name !== '.');
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Install a single plugin from a fetched marketplace manifest: validate the
|
|
20
|
+
* marketplace name, find the EXPECTED plugin by name (never a blind
|
|
21
|
+
* `plugins[0]`), register the marketplace, install. Prompt-free and
|
|
22
|
+
* exit-free — always returns a structured result, so interactive callers
|
|
23
|
+
* (collection/wrapper installs, the recommend flow) own their own output and
|
|
24
|
+
* exit semantics.
|
|
25
|
+
*
|
|
26
|
+
* `skipMarketplaceAdd` lets multi-plugin callers that registered the shared
|
|
27
|
+
* marketplace once up-front (runNativeManifestInstall) reuse the entry-lookup
|
|
28
|
+
* + install steps without re-adding per plugin.
|
|
29
|
+
*/
|
|
30
|
+
export function installPluginFromManifest(manifest, pluginName, registerUrl, scope, opts = {}) {
|
|
31
|
+
if (!isInstallableMarketplaceName(manifest.name)) {
|
|
32
|
+
return {
|
|
33
|
+
name: pluginName,
|
|
34
|
+
ok: false,
|
|
35
|
+
stage: 'validate',
|
|
36
|
+
error: `marketplace name "${manifest.name}" is not accepted by Claude Code`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const entry = manifest.plugins.find((p) => p.name === pluginName);
|
|
40
|
+
if (!entry) {
|
|
41
|
+
return {
|
|
42
|
+
name: pluginName,
|
|
43
|
+
ok: false,
|
|
44
|
+
stage: 'validate',
|
|
45
|
+
error: `plugin "${pluginName}" not found in the manifest`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (!opts.skipMarketplaceAdd) {
|
|
49
|
+
const addResult = claudeMarketplaceAdd(registerUrl, scope);
|
|
50
|
+
if (!addResult.ok) {
|
|
51
|
+
return { name: pluginName, ok: false, stage: 'marketplace_add', error: addResult.output };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const installResult = claudePluginInstall(entry.name, manifest.name, scope);
|
|
55
|
+
if (!installResult.ok) {
|
|
56
|
+
return { name: pluginName, ok: false, stage: 'install', error: installResult.output };
|
|
57
|
+
}
|
|
58
|
+
return { name: pluginName, ok: true };
|
|
59
|
+
}
|
|
18
60
|
/**
|
|
19
61
|
* Install from a hosted marketplace manifest by delegating to Claude Code's
|
|
20
62
|
* native plugin system: `claude plugin marketplace add <url>` once, then
|
|
@@ -94,16 +136,17 @@ async function runNativeManifestInstall(url, yes, scopeOverride, kind) {
|
|
|
94
136
|
process.exit(1);
|
|
95
137
|
}
|
|
96
138
|
printSuccess(`Marketplace "${manifest.name}" added`);
|
|
97
|
-
// Install each selected plugin
|
|
139
|
+
// Install each selected plugin via the shared prompt-free operation (the
|
|
140
|
+
// marketplace was registered once above, so each call skips the add step).
|
|
98
141
|
let failures = 0;
|
|
99
142
|
for (const plugin of selectedPlugins) {
|
|
100
143
|
printStep(`Installing ${plugin.name}...`);
|
|
101
|
-
const result =
|
|
144
|
+
const result = installPluginFromManifest(manifest, plugin.name, registerUrl.toString(), scope, { skipMarketplaceAdd: true });
|
|
102
145
|
if (result.ok) {
|
|
103
146
|
printSuccess(plugin.name);
|
|
104
147
|
}
|
|
105
148
|
else {
|
|
106
|
-
printFail(plugin.name, result.
|
|
149
|
+
printFail(plugin.name, result.error);
|
|
107
150
|
failures++;
|
|
108
151
|
}
|
|
109
152
|
}
|
package/dist/index.js
CHANGED
|
@@ -56,9 +56,12 @@ Notes:
|
|
|
56
56
|
|
|
57
57
|
Recommend (reads local manifest dependency names + config filenames only —
|
|
58
58
|
never file contents):
|
|
59
|
-
recommend Top plugins grouped by each detected stack
|
|
59
|
+
recommend Top plugins grouped by each detected stack;
|
|
60
|
+
in a terminal, optionally select up to 5 to
|
|
61
|
+
install via Claude Code (anonymous outcomes of
|
|
62
|
+
attempted installs are reported)
|
|
60
63
|
recommend --limit 6 Results per stack (1-50, default 4)
|
|
61
|
-
recommend --json Raw JSON output
|
|
64
|
+
recommend --json Raw JSON output (never interactive)
|
|
62
65
|
|
|
63
66
|
Options:
|
|
64
67
|
--plugin <name> Install a specific plugin from a marketplace repo
|
package/dist/prompts.d.ts
CHANGED
|
@@ -5,5 +5,18 @@ export interface SelectableItem {
|
|
|
5
5
|
selected: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare function checkboxPrompt(title: string, items: SelectableItem[]): Promise<number[] | null>;
|
|
8
|
+
/**
|
|
9
|
+
* Recommendation-specific multi-select. Differs from `checkboxPrompt` (which
|
|
10
|
+
* existing collection/component selectors keep unchanged) in three deliberate
|
|
11
|
+
* ways:
|
|
12
|
+
* - NO select-all: the 'a' key is ignored — recommendations are opt-in per
|
|
13
|
+
* item, never bulk-installed.
|
|
14
|
+
* - Hard selection cap: toggling ON past `maxSelected` is rejected with
|
|
15
|
+
* immediate hint feedback; toggling OFF always works.
|
|
16
|
+
* - Non-TTY fallback returns [] (select nothing) — recommend must never
|
|
17
|
+
* auto-install in a non-interactive run, unlike checkboxPrompt's
|
|
18
|
+
* all-selected fallback.
|
|
19
|
+
*/
|
|
20
|
+
export declare function recommendPrompt(title: string, items: SelectableItem[], maxSelected: number): Promise<number[] | null>;
|
|
8
21
|
export declare function confirmPrompt(message: string): Promise<boolean>;
|
|
9
22
|
export declare function scopePrompt(defaultScope?: Scope): Promise<Scope | null>;
|
package/dist/prompts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RESET, BOLD, DIM, GREEN, CYAN, INVERSE, HIDE_CURSOR, SHOW_CURSOR, moveUp, } from './output.js';
|
|
1
|
+
import { RESET, BOLD, DIM, GREEN, CYAN, INVERSE, HIDE_CURSOR, SHOW_CURSOR, CLEAR_LINE, moveUp, } from './output.js';
|
|
2
2
|
function isInteractive() {
|
|
3
3
|
return !!process.stdin.isTTY;
|
|
4
4
|
}
|
|
@@ -82,6 +82,90 @@ export async function checkboxPrompt(title, items) {
|
|
|
82
82
|
write(SHOW_CURSOR);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
function renderRecommendSelect(title, items, cursor, maxSelected, atCap) {
|
|
86
|
+
// Every line starts with CLEAR_LINE: the cap hint changes width between
|
|
87
|
+
// renders ("(max 5)" vs "(max 5 reached)"), so overwriting in place would
|
|
88
|
+
// otherwise leave residue from the longer variant.
|
|
89
|
+
const lines = [`${CLEAR_LINE}${BOLD}${title}${RESET}`];
|
|
90
|
+
const capHint = atCap ? `(max ${maxSelected} reached)` : `(max ${maxSelected})`;
|
|
91
|
+
lines.push(`${CLEAR_LINE}${DIM} Space=toggle Enter=confirm Ctrl+C=skip ${capHint}${RESET}`);
|
|
92
|
+
for (let i = 0; i < items.length; i++) {
|
|
93
|
+
const item = items[i];
|
|
94
|
+
const marker = item.selected ? `${GREEN}[x]${RESET}` : `[ ]`;
|
|
95
|
+
const prefix = i === cursor ? `${INVERSE}>` : ' ';
|
|
96
|
+
const label = i === cursor ? `${BOLD}${item.label}${RESET}` : item.label;
|
|
97
|
+
const desc = item.description ? ` ${DIM}${item.description}${RESET}` : '';
|
|
98
|
+
const suffix = i === cursor ? RESET : '';
|
|
99
|
+
lines.push(`${CLEAR_LINE}${prefix} ${marker} ${label}${desc}${suffix}`);
|
|
100
|
+
}
|
|
101
|
+
return lines.join('\n');
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Recommendation-specific multi-select. Differs from `checkboxPrompt` (which
|
|
105
|
+
* existing collection/component selectors keep unchanged) in three deliberate
|
|
106
|
+
* ways:
|
|
107
|
+
* - NO select-all: the 'a' key is ignored — recommendations are opt-in per
|
|
108
|
+
* item, never bulk-installed.
|
|
109
|
+
* - Hard selection cap: toggling ON past `maxSelected` is rejected with
|
|
110
|
+
* immediate hint feedback; toggling OFF always works.
|
|
111
|
+
* - Non-TTY fallback returns [] (select nothing) — recommend must never
|
|
112
|
+
* auto-install in a non-interactive run, unlike checkboxPrompt's
|
|
113
|
+
* all-selected fallback.
|
|
114
|
+
*/
|
|
115
|
+
export async function recommendPrompt(title, items, maxSelected) {
|
|
116
|
+
if (!isInteractive()) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
const wasRaw = process.stdin.isRaw;
|
|
120
|
+
process.stdin.setRawMode(true);
|
|
121
|
+
process.stdin.resume();
|
|
122
|
+
write(HIDE_CURSOR);
|
|
123
|
+
let cursor = 0;
|
|
124
|
+
const totalLines = items.length + 2; // title + hint + items
|
|
125
|
+
const selectedCount = () => items.filter((item) => item.selected).length;
|
|
126
|
+
write(renderRecommendSelect(title, items, cursor, maxSelected, false));
|
|
127
|
+
try {
|
|
128
|
+
while (true) {
|
|
129
|
+
const key = await readKey();
|
|
130
|
+
const str = key.toString();
|
|
131
|
+
// Ctrl+C — skip installing, not an error
|
|
132
|
+
if (str === '\x03') {
|
|
133
|
+
write('\n' + SHOW_CURSOR);
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
// Enter
|
|
137
|
+
if (str === '\r' || str === '\n') {
|
|
138
|
+
write('\n' + SHOW_CURSOR);
|
|
139
|
+
return items
|
|
140
|
+
.map((item, i) => (item.selected ? i : -1))
|
|
141
|
+
.filter((i) => i !== -1);
|
|
142
|
+
}
|
|
143
|
+
// Space - toggle (ON only below the cap; OFF always allowed)
|
|
144
|
+
if (str === ' ') {
|
|
145
|
+
if (items[cursor].selected || selectedCount() < maxSelected) {
|
|
146
|
+
items[cursor].selected = !items[cursor].selected;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// NOTE: no 'a' (select-all) handler by design.
|
|
150
|
+
// Arrow up or 'k'
|
|
151
|
+
if (str === '\x1b[A' || str === 'k') {
|
|
152
|
+
cursor = cursor > 0 ? cursor - 1 : items.length - 1;
|
|
153
|
+
}
|
|
154
|
+
// Arrow down or 'j'
|
|
155
|
+
if (str === '\x1b[B' || str === 'j') {
|
|
156
|
+
cursor = cursor < items.length - 1 ? cursor + 1 : 0;
|
|
157
|
+
}
|
|
158
|
+
// Re-render
|
|
159
|
+
write(moveUp(totalLines - 1) + '\r');
|
|
160
|
+
write(renderRecommendSelect(title, items, cursor, maxSelected, selectedCount() >= maxSelected));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
process.stdin.setRawMode(wasRaw ?? false);
|
|
165
|
+
process.stdin.pause();
|
|
166
|
+
write(SHOW_CURSOR);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
85
169
|
export async function confirmPrompt(message) {
|
|
86
170
|
if (!isInteractive())
|
|
87
171
|
return true;
|
package/dist/recommend.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hard cap on plugins selectable in one interactive recommend run. Deliberate
|
|
3
|
+
* selection-safety bound: the selector has no select-all and every item starts
|
|
4
|
+
* unchecked, so a run can never bulk-install a 20-item recommendation list.
|
|
5
|
+
* Coupled surfaces when raising: the server's MAX_OUTCOMES cap
|
|
6
|
+
* (/api/recommend/outcome — must deploy FIRST, or over-cap outcome reports
|
|
7
|
+
* silently schema-reject) and the "up to 5" literal in index.ts help text.
|
|
8
|
+
*/
|
|
9
|
+
export declare const RECOMMEND_MAX_SELECTIONS = 5;
|
|
1
10
|
export interface RecommendFlags {
|
|
2
11
|
limit: number;
|
|
3
12
|
json: boolean;
|
package/dist/recommend.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { BASE_URL } from './fetch.js';
|
|
4
|
-
import {
|
|
3
|
+
import { BASE_URL, fetchMarketplace } from './fetch.js';
|
|
4
|
+
import { checkClaudeCli } from './native.js';
|
|
5
|
+
import { installPluginFromManifest } from './collection-install.js';
|
|
6
|
+
import { recommendPrompt, scopePrompt, confirmPrompt } from './prompts.js';
|
|
7
|
+
import { print, printBanner, printStep, printSuccess, printFail, printError, BOLD, DIM, RESET, CYAN, YELLOW, } from './output.js';
|
|
5
8
|
/**
|
|
6
9
|
* `npx claudepluginhub recommend` — instant plugin recommendations for the
|
|
7
10
|
* current project. Reads local manifest dependency NAMES and telltale config
|
|
@@ -20,6 +23,15 @@ const MAX_DEP_LENGTH = 128;
|
|
|
20
23
|
*/
|
|
21
24
|
const DEFAULT_LIMIT = 4;
|
|
22
25
|
const MAX_LIMIT = 50;
|
|
26
|
+
/**
|
|
27
|
+
* Hard cap on plugins selectable in one interactive recommend run. Deliberate
|
|
28
|
+
* selection-safety bound: the selector has no select-all and every item starts
|
|
29
|
+
* unchecked, so a run can never bulk-install a 20-item recommendation list.
|
|
30
|
+
* Coupled surfaces when raising: the server's MAX_OUTCOMES cap
|
|
31
|
+
* (/api/recommend/outcome — must deploy FIRST, or over-cap outcome reports
|
|
32
|
+
* silently schema-reject) and the "up to 5" literal in index.ts help text.
|
|
33
|
+
*/
|
|
34
|
+
export const RECOMMEND_MAX_SELECTIONS = 5;
|
|
23
35
|
/**
|
|
24
36
|
* Telltale filename prefixes. Privacy allowlist: when a cwd entry matches a
|
|
25
37
|
* prefix, the PREFIX ITSELF is sent — never the raw basename — so only
|
|
@@ -397,7 +409,159 @@ export async function runRecommend(argv) {
|
|
|
397
409
|
});
|
|
398
410
|
print('');
|
|
399
411
|
});
|
|
400
|
-
//
|
|
401
|
-
//
|
|
412
|
+
// Interactive install (TTY only). The footer prints AFTER the flow so the
|
|
413
|
+
// last line is always the refine link, whatever path was taken.
|
|
414
|
+
await runInteractiveInstall(body);
|
|
415
|
+
}
|
|
416
|
+
/** Always the last output: the picker page link (not /for/[stack] — low-coverage stacks 404 there). */
|
|
417
|
+
function printFooter() {
|
|
402
418
|
print(`${DIM}Refine stacks: ${BASE_URL}/tools/for-your-project${RESET}`);
|
|
403
419
|
}
|
|
420
|
+
const STAGE_TO_FAILURE_CLASS = {
|
|
421
|
+
validate: 'manifest_invalid',
|
|
422
|
+
marketplace_add: 'marketplace_add_failed',
|
|
423
|
+
install: 'install_failed',
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* Optional interactive tail of `recommend`: select up to
|
|
427
|
+
* RECOMMEND_MAX_SELECTIONS recommended plugins, pick one scope, confirm, and
|
|
428
|
+
* install each through the shared wrapper-marketplace path (identical to
|
|
429
|
+
* `p/<slug>`). Skipped entirely for non-TTY runs (both streams checked —
|
|
430
|
+
* stdin alone misses `recommend | cat`) and when nothing is natively
|
|
431
|
+
* installable. Exits 1 when any selected install failed.
|
|
432
|
+
*/
|
|
433
|
+
async function runInteractiveInstall(body) {
|
|
434
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
435
|
+
printFooter();
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
// Maintainer-override items are manual-only and never selectable — their
|
|
439
|
+
// override command is already printed above and is NEVER executed here.
|
|
440
|
+
const installable = body.sections.flatMap((section) => section.results
|
|
441
|
+
.filter((item) => !item.install.maintainerOverride && item.install.claude !== null)
|
|
442
|
+
.map((item) => ({ item, stack: section.stack })));
|
|
443
|
+
if (installable.length === 0) {
|
|
444
|
+
printFooter();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
// Prerequisite check BEFORE asking the user to make any decisions. Not an
|
|
448
|
+
// error exit: the recommendations already printed successfully and the
|
|
449
|
+
// install tail is optional — checkClaudeCli() prints the actionable hint,
|
|
450
|
+
// then the run ends cleanly with the footer like every other skip path.
|
|
451
|
+
// (Exit 1 stays reserved for attempted installs that failed, below.)
|
|
452
|
+
if (!checkClaudeCli()) {
|
|
453
|
+
print('');
|
|
454
|
+
printFooter();
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
print('');
|
|
458
|
+
const chosen = await recommendPrompt('Install plugins:', installable.map(({ item, stack }) => ({
|
|
459
|
+
label: `${item.name} (${formatStackLabel(stack)})`,
|
|
460
|
+
selected: false,
|
|
461
|
+
})), RECOMMEND_MAX_SELECTIONS);
|
|
462
|
+
if (chosen === null || chosen.length === 0) {
|
|
463
|
+
print('');
|
|
464
|
+
printFooter();
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const selected = chosen.map((i) => installable[i]);
|
|
468
|
+
print('');
|
|
469
|
+
const scope = await scopePrompt('project');
|
|
470
|
+
if (scope === null) {
|
|
471
|
+
print('');
|
|
472
|
+
printFooter();
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
// Final confirmation with the exact names, count, and scope. Declining
|
|
476
|
+
// exits cleanly with zero mutations. The reporting disclosure prints BEFORE
|
|
477
|
+
// this prompt — confirming is what leads to the outcome report, so the user
|
|
478
|
+
// must see it while declining still prevents the send.
|
|
479
|
+
print('');
|
|
480
|
+
print(`${BOLD}Selected:${RESET} ${selected.map(({ item }) => item.name).join(', ')}`);
|
|
481
|
+
print(`${DIM}Anonymous install outcomes are reported to claudepluginhub.com.${RESET}`);
|
|
482
|
+
const confirmed = await confirmPrompt(`Install ${selected.length} plugin${selected.length === 1 ? '' : 's'} with ${scope} scope?`);
|
|
483
|
+
if (!confirmed) {
|
|
484
|
+
print('');
|
|
485
|
+
printFooter();
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
print('');
|
|
489
|
+
const outcomes = [];
|
|
490
|
+
for (const { item } of selected) {
|
|
491
|
+
printStep(`Installing ${item.name}...`);
|
|
492
|
+
const manifestUrl = `${BASE_URL}/api/plugins/${item.slug}/marketplace.json`;
|
|
493
|
+
const manifest = await fetchMarketplace(manifestUrl);
|
|
494
|
+
if (!manifest) {
|
|
495
|
+
printFail(item.name);
|
|
496
|
+
outcomes.push({ slug: item.slug, status: 'failed', failureClass: 'fetch_failed' });
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
// Wrapper manifests name their single plugin after the slug; the shared
|
|
500
|
+
// installer verifies that by name instead of trusting plugins[0].
|
|
501
|
+
const result = installPluginFromManifest(manifest, item.slug, manifestUrl, scope);
|
|
502
|
+
if (result.ok) {
|
|
503
|
+
printSuccess(item.name);
|
|
504
|
+
outcomes.push({ slug: item.slug, status: 'installed' });
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
printFail(item.name, result.error);
|
|
508
|
+
outcomes.push({
|
|
509
|
+
slug: item.slug,
|
|
510
|
+
status: 'failed',
|
|
511
|
+
failureClass: STAGE_TO_FAILURE_CLASS[result.stage],
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
const installed = outcomes.filter((o) => o.status === 'installed').length;
|
|
516
|
+
const failed = outcomes.length - installed;
|
|
517
|
+
print('');
|
|
518
|
+
print(`${BOLD}${installed} installed, ${failed} failed.${RESET}`);
|
|
519
|
+
await reportOutcomes(body.outcomeProof, outcomes);
|
|
520
|
+
print('');
|
|
521
|
+
print(`${DIM}Manage: claude plugin list | claude plugin uninstall <name>${RESET}`);
|
|
522
|
+
print('');
|
|
523
|
+
// Repeats the pre-confirm disclosure adjacent to the actual send, and
|
|
524
|
+
// deliberately prints even when reportOutcomes skipped it (no proof from an
|
|
525
|
+
// older server, POST failure): over-disclosing beats a privacy notice
|
|
526
|
+
// that's absent on runs where the report DID go out.
|
|
527
|
+
print(`${DIM}Anonymous install outcomes are reported to claudepluginhub.com.${RESET}`);
|
|
528
|
+
printFooter();
|
|
529
|
+
if (failed > 0) {
|
|
530
|
+
process.exit(1);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Fail-soft outcome report: echo the server's signed proof back with only
|
|
535
|
+
* {pluginId, status, failureClass} per ATTEMPTED plugin — never dependency
|
|
536
|
+
* names, paths, plugin inventories, command output, or raw error text. Any
|
|
537
|
+
* failure here is invisible and never changes the local install result; runs
|
|
538
|
+
* where nothing was selected never reach this call.
|
|
539
|
+
*/
|
|
540
|
+
async function reportOutcomes(proof, outcomes) {
|
|
541
|
+
if (!proof || outcomes.length === 0)
|
|
542
|
+
return;
|
|
543
|
+
const bySlug = new Map(proof.items.map((p) => [p.slug, p.pluginId]));
|
|
544
|
+
const payload = outcomes.flatMap((o) => {
|
|
545
|
+
const pluginId = bySlug.get(o.slug);
|
|
546
|
+
if (!pluginId)
|
|
547
|
+
return [];
|
|
548
|
+
return [
|
|
549
|
+
o.status === 'failed'
|
|
550
|
+
? { pluginId, status: o.status, failureClass: o.failureClass }
|
|
551
|
+
: { pluginId, status: o.status },
|
|
552
|
+
];
|
|
553
|
+
});
|
|
554
|
+
if (payload.length === 0)
|
|
555
|
+
return;
|
|
556
|
+
try {
|
|
557
|
+
await fetch(`${BASE_URL}/api/recommend/outcome`, {
|
|
558
|
+
method: 'POST',
|
|
559
|
+
headers: { 'content-type': 'application/json' },
|
|
560
|
+
body: JSON.stringify({ proof, outcomes: payload }),
|
|
561
|
+
signal: AbortSignal.timeout(5_000),
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
catch {
|
|
565
|
+
// Silent by contract: outcome telemetry must never affect the user's run.
|
|
566
|
+
}
|
|
567
|
+
}
|