MCPcopy Create free account
hub / github.com/Noumena-Network/code / addInstalledPlugin

Function addInstalledPlugin

src/utils/plugins/installedPluginsManager.ts:884–922  ·  view source on GitHub ↗
(
  pluginId: string,
  metadata: InstalledPlugin,
  scope: PersistableScope = 'user',
  projectPath?: string,
)

Source from the content-addressed store, hash-verified

882 * @param projectPath - Project path (for project/local scopes)
883 */
884export function addInstalledPlugin(
885 pluginId: string,
886 metadata: InstalledPlugin,
887 scope: PersistableScope = 'user',
888 projectPath?: string,
889): void {
890 const v2Data = loadInstalledPluginsFromDisk()
891 const v2Entry: PluginInstallationEntry = {
892 scope,
893 installPath: metadata.installPath,
894 version: metadata.version,
895 installedAt: metadata.installedAt,
896 lastUpdated: metadata.lastUpdated,
897 gitCommitSha: metadata.gitCommitSha,
898 ...(projectPath && { projectPath }),
899 }
900
901 // Get or create array for this plugin (preserves other scope installations)
902 const installations = v2Data.plugins[pluginId] || []
903
904 // Find existing entry for this scope+projectPath
905 const existingIndex = installations.findIndex(
906 entry => entry.scope === scope && entry.projectPath === projectPath,
907 )
908
909 const isUpdate = existingIndex >= 0
910 if (isUpdate) {
911 installations[existingIndex] = v2Entry
912 } else {
913 installations.push(v2Entry)
914 }
915
916 v2Data.plugins[pluginId] = installations
917 saveInstalledPluginsV2(v2Data)
918
919 logForDebugging(
920 `${isUpdate ? 'Updated' : 'Added'} installed plugin: ${pluginId} (scope: ${scope})`,
921 )
922}
923
924/**
925 * Remove a plugin from the installed plugins registry

Callers 2

cacheAndRegisterPluginFunction · 0.85

Calls 3

saveInstalledPluginsV2Function · 0.85
logForDebuggingFunction · 0.50

Tested by

no test coverage detected