MCPcopy Create free account
hub / github.com/WJX20/claude-code / getPluginInstallationFromV2

Function getPluginInstallationFromV2

src/services/plugins/pluginOperations.ts:258–299  ·  view source on GitHub ↗
(pluginId: string)

Source from the content-addressed store, hash-verified

256 * Priority order: local (matching project) > project (matching project) > user > first available
257 */
258export function getPluginInstallationFromV2(pluginId: string): {
259 scope: PluginScope
260 projectPath?: string
261} {
262 const installedData = loadInstalledPluginsV2()
263 const installations = installedData.plugins[pluginId]
264
265 if (!installations || installations.length === 0) {
266 return { scope: 'user' }
267 }
268
269 const currentProjectPath = getOriginalCwd()
270
271 // Find installations by priority: local > project > user > managed
272 const localInstall = installations.find(
273 inst => inst.scope === 'local' && inst.projectPath === currentProjectPath,
274 )
275 if (localInstall) {
276 return { scope: localInstall.scope, projectPath: localInstall.projectPath }
277 }
278
279 const projectInstall = installations.find(
280 inst => inst.scope === 'project' && inst.projectPath === currentProjectPath,
281 )
282 if (projectInstall) {
283 return {
284 scope: projectInstall.scope,
285 projectPath: projectInstall.projectPath,
286 }
287 }
288
289 const userInstall = installations.find(inst => inst.scope === 'user')
290 if (userInstall) {
291 return { scope: userInstall.scope }
292 }
293
294 // Fall back to first installation (could be managed)
295 return {
296 scope: installations[0]!.scope,
297 projectPath: installations[0]!.projectPath,
298 }
299}
300
301// ============================================================================
302// Core Operations

Callers 3

loadInstalledPluginsFunction · 0.85
ManagePluginsFunction · 0.85
uninstallPluginOpFunction · 0.85

Calls 2

loadInstalledPluginsV2Function · 0.85
getOriginalCwdFunction · 0.85

Tested by

no test coverage detected