π File detail
utils/plugins/addDirPluginSettings.ts
π― Use case
This file lives under βutils/β, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, β¦). On the API surface it exposes getAddDirEnabledPlugins and getAddDirExtraMarketplaces β mainly functions, hooks, or classes. Dependencies touch Node path helpers and schema validation. It composes internal code from bootstrap and settings (relative imports). What the file header says: Reads plugin-related settings (enabledPlugins, extraKnownMarketplaces) from --add-dir directories. These have the LOWEST priority β callers must spread standard settings on top so that user/project/local/flag/policy sources all override.
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
Reads plugin-related settings (enabledPlugins, extraKnownMarketplaces) from --add-dir directories. These have the LOWEST priority β callers must spread standard settings on top so that user/project/local/flag/policy sources all override.
π€ Exports (heuristic)
getAddDirEnabledPluginsgetAddDirExtraMarketplaces
π External import roots
Package roots from from "β¦" (relative paths omitted).
pathzod
π₯οΈ Source preview
/**
* Reads plugin-related settings (enabledPlugins, extraKnownMarketplaces)
* from --add-dir directories.
*
* These have the LOWEST priority β callers must spread standard settings
* on top so that user/project/local/flag/policy sources all override.
*/
import { join } from 'path'
import type { z } from 'zod/v4'
import { getAdditionalDirectoriesForClaudeMd } from '../../bootstrap/state.js'
import { parseSettingsFile } from '../settings/settings.js'
import type {
ExtraKnownMarketplaceSchema,
SettingsJson,
} from '../settings/types.js'
type ExtraKnownMarketplace = z.infer<
ReturnType<typeof ExtraKnownMarketplaceSchema>
>
const SETTINGS_FILES = ['settings.json', 'settings.local.json'] as const
/**
* Returns a merged record of enabledPlugins from all --add-dir directories.
*
* Within each directory, settings.local.json is processed after settings.json
* (local wins within that dir). Across directories, later CLI-order wins on
* conflict.
*
* This has the lowest priority β callers must spread their standard settings
* on top to let user/project/local/flag/policy override.
*/
export function getAddDirEnabledPlugins(): NonNullable<
SettingsJson['enabledPlugins']
> {
const result: NonNullable<SettingsJson['enabledPlugins']> = {}
for (const dir of getAdditionalDirectoriesForClaudeMd()) {
for (const file of SETTINGS_FILES) {
const { settings } = parseSettingsFile(join(dir, '.claude', file))
if (!settings?.enabledPlugins) {
continue
}
Object.assign(result, settings.enabledPlugins)
}
}
return result
}
/**
* Returns a merged record of extraKnownMarketplaces from all --add-dir directories.
*
* Same priority rules as getAddDirEnabledPlugins: settings.local.json wins
* within each dir, and callers spread standard settings on top.
*/
export function getAddDirExtraMarketplaces(): Record<
string,
ExtraKnownMarketplace
> {
const result: Record<string, ExtraKnownMarketplace> = {}
for (const dir of getAdditionalDirectoriesForClaudeMd()) {
for (const file of SETTINGS_FILES) {
const { settings } = parseSettingsFile(join(dir, '.claude', file))
if (!settings?.extraKnownMarketplaces) {
continue
}
Object.assign(result, settings.extraKnownMarketplaces)
}
}
return result
}