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

Function loadPluginSettings

src/utils/plugins/pluginLoader.ts:1807–1849  ·  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

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

Callers 1

createPluginFromPathFunction · 0.85

Calls 6

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

Tested by

no test coverage detected