()
| 159 | * when any enabled plugin references it. |
| 160 | */ |
| 161 | export function getDeclaredMarketplaces(): Record<string, DeclaredMarketplace> { |
| 162 | const implicit: Record<string, DeclaredMarketplace> = {} |
| 163 | |
| 164 | // Only the official marketplace can be implicitly declared — it's the one |
| 165 | // built-in source we know. Other marketplaces have no default source to inject. |
| 166 | // Explicitly-disabled entries (value: false) don't count. |
| 167 | const enabledPlugins = { |
| 168 | ...getAddDirEnabledPlugins(), |
| 169 | ...(getInitialSettings().enabledPlugins ?? {}), |
| 170 | } |
| 171 | for (const [pluginId, value] of Object.entries(enabledPlugins)) { |
| 172 | if ( |
| 173 | value && |
| 174 | parsePluginIdentifier(pluginId).marketplace === OFFICIAL_MARKETPLACE_NAME |
| 175 | ) { |
| 176 | implicit[OFFICIAL_MARKETPLACE_NAME] = { |
| 177 | source: OFFICIAL_MARKETPLACE_SOURCE, |
| 178 | sourceIsFallback: true, |
| 179 | } |
| 180 | break |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | // Lowest precedence: implicit < --add-dir < merged settings. |
| 185 | // An explicit extraKnownMarketplaces entry for claude-plugins-official |
| 186 | // in --add-dir or settings wins. |
| 187 | return { |
| 188 | ...implicit, |
| 189 | ...getAddDirExtraMarketplaces(), |
| 190 | ...(getInitialSettings().extraKnownMarketplaces ?? {}), |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * Find which editable settings source declared a marketplace. |
no test coverage detected