MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / loadPluginHooks

Function loadPluginHooks

source code/utils/plugins/pluginLoader.ts:1226–1244  ·  view source on GitHub ↗

* Loads and validates plugin hooks configuration from a JSON file. * IMPORTANT: Only call this when the hooks file is expected to exist. * * @param hooksConfigPath - Full path to the hooks.json file * @param pluginName - Plugin name for error messages * @returns Validated HooksSettings * @thro

(
  hooksConfigPath: string,
  pluginName: string,
)

Source from the content-addressed store, hash-verified

1224 * @throws Error if file doesn't exist or is invalid
1225 */
1226async function loadPluginHooks(
1227 hooksConfigPath: string,
1228 pluginName: string,
1229): Promise<HooksSettings> {
1230 if (!(await pathExists(hooksConfigPath))) {
1231 throw new Error(
1232 `Hooks file not found at ${hooksConfigPath} for plugin ${pluginName}. If the manifest declares hooks, the file must exist.`,
1233 )
1234 }
1235
1236 const content = await readFile(hooksConfigPath, { encoding: 'utf-8' })
1237 const rawHooksConfig = jsonParse(content)
1238
1239 // The hooks.json file has a wrapper structure with description and hooks
1240 // Use PluginHooksSchema to validate and extract the hooks property
1241 const validatedPluginHooks = PluginHooksSchema().parse(rawHooksConfig)
1242
1243 return validatedPluginHooks.hooks as HooksSettings
1244}
1245
1246/**
1247 * Validate a list of plugin component relative paths by checking existence in parallel.

Callers 6

processSessionStartHooksFunction · 0.85
processSetupHooksFunction · 0.85
createPluginFromPathFunction · 0.85
refreshActivePluginsFunction · 0.85
setupPluginHookHotReloadFunction · 0.85
useManagePluginsFunction · 0.85

Calls 3

pathExistsFunction · 0.85
readFileFunction · 0.85
jsonParseFunction · 0.85

Tested by

no test coverage detected