MCPcopy Index your code
hub / github.com/codeaashu/claude-code / installPluginOp

Function installPluginOp

src/services/plugins/pluginOperations.ts:321–418  ·  view source on GitHub ↗
(
  plugin: string,
  scope: InstallableScope = 'user',
)

Source from the content-addressed store, hash-verified

319 * @returns Result indicating success/failure
320 */
321export async function installPluginOp(
322 plugin: string,
323 scope: InstallableScope = 'user',
324): Promise<PluginOperationResult> {
325 assertInstallableScope(scope)
326
327 const { name: pluginName, marketplace: marketplaceName } =
328 parsePluginIdentifier(plugin)
329
330 // ── Search materialized marketplaces for the plugin ──
331 let foundPlugin: PluginMarketplaceEntry | undefined
332 let foundMarketplace: string | undefined
333 let marketplaceInstallLocation: string | undefined
334
335 if (marketplaceName) {
336 const pluginInfo = await getPluginById(plugin)
337 if (pluginInfo) {
338 foundPlugin = pluginInfo.entry
339 foundMarketplace = marketplaceName
340 marketplaceInstallLocation = pluginInfo.marketplaceInstallLocation
341 }
342 } else {
343 const marketplaces = await loadKnownMarketplacesConfig()
344 for (const [mktName, mktConfig] of Object.entries(marketplaces)) {
345 try {
346 const marketplace = await getMarketplace(mktName)
347 const pluginEntry = marketplace.plugins.find(p => p.name === pluginName)
348 if (pluginEntry) {
349 foundPlugin = pluginEntry
350 foundMarketplace = mktName
351 marketplaceInstallLocation = mktConfig.installLocation
352 break
353 }
354 } catch (error) {
355 logError(toError(error))
356 continue
357 }
358 }
359 }
360
361 if (!foundPlugin || !foundMarketplace) {
362 const location = marketplaceName
363 ? `marketplace "${marketplaceName}"`
364 : 'any configured marketplace'
365 return {
366 success: false,
367 message: `Plugin "${pluginName}" not found in ${location}`,
368 }
369 }
370
371 const entry = foundPlugin
372 const pluginId = `${entry.name}@${foundMarketplace}`
373
374 const result = await installResolvedPlugin({
375 pluginId,
376 entry,
377 scope,
378 marketplaceInstallLocation,

Callers 1

installPluginFunction · 0.85

Calls 9

assertInstallableScopeFunction · 0.85
parsePluginIdentifierFunction · 0.85
getPluginByIdFunction · 0.85
toErrorFunction · 0.85
installResolvedPluginFunction · 0.85
formatResolutionErrorFunction · 0.85
entriesMethod · 0.80
logErrorFunction · 0.50

Tested by

no test coverage detected