MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / loadPluginSettings

Function loadPluginSettings

src/utils/plugins/pluginLoader.ts:1808–1850  ·  view source on GitHub ↗

* Load plugin settings from settings.json file or manifest.settings. * settings.json takes priority over manifest.settings when both exist. * Only allowlisted keys are included in the result.

(
  pluginPath: string,
  manifest: PluginManifest,
)

Source from the content-addressed store, hash-verified

1806 * Only allowlisted keys are included in the result.
1807 */
1808async function loadPluginSettings(
1809 pluginPath: string,
1810 manifest: PluginManifest,
1811): Promise<Record<string, unknown> | undefined> {
1812 // Try loading settings.json from the plugin directory
1813 const settingsJsonPath = join(pluginPath, 'settings.json')
1814 try {
1815 const content = await readFile(settingsJsonPath, { encoding: 'utf-8' })
1816 const parsed = jsonParse(content)
1817 if (isRecord(parsed)) {
1818 const filtered = parsePluginSettings(parsed)
1819 if (filtered) {
1820 logForDebugging(
1821 `Loaded settings from settings.json for plugin ${manifest.name}`,
1822 )
1823 return filtered
1824 }
1825 }
1826 } catch (e: unknown) {
1827 // Missing/inaccessible is expected - settings.json is optional
1828 if (!isFsInaccessible(e)) {
1829 logForDebugging(
1830 `Failed to parse settings.json for plugin ${manifest.name}: ${e}`,
1831 { level: 'warn' },
1832 )
1833 }
1834 }
1835
1836 // Fall back to manifest.settings
1837 if (manifest.settings) {
1838 const filtered = parsePluginSettings(
1839 manifest.settings as Record<string, unknown>,
1840 )
1841 if (filtered) {
1842 logForDebugging(
1843 `Loaded settings from manifest for plugin ${manifest.name}`,
1844 )
1845 return filtered
1846 }
1847 }
1848
1849 return undefined
1850}
1851
1852/**
1853 * Merge two HooksSettings objects

Callers 1

createPluginFromPathFunction · 0.85

Calls 6

readFileFunction · 0.85
jsonParseFunction · 0.85
parsePluginSettingsFunction · 0.85
isFsInaccessibleFunction · 0.85
isRecordFunction · 0.70
logForDebuggingFunction · 0.50

Tested by

no test coverage detected