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

Function parseHooksFromFrontmatter

src/tools/AgentTool/loadAgentsDir.ts:424–440  ·  view source on GitHub ↗

* Parse hooks from frontmatter using the HooksSchema * @param frontmatter The frontmatter object containing potential hooks * @param agentType The agent type for logging purposes * @returns Parsed hooks settings or undefined if invalid/missing

(
  frontmatter: Record<string, unknown>,
  agentType: string,
)

Source from the content-addressed store, hash-verified

422 * @returns Parsed hooks settings or undefined if invalid/missing
423 */
424function parseHooksFromFrontmatter(
425 frontmatter: Record<string, unknown>,
426 agentType: string,
427): HooksSettings | undefined {
428 if (!frontmatter.hooks) {
429 return undefined
430 }
431
432 const result = HooksSchema().safeParse(frontmatter.hooks)
433 if (!result.success) {
434 logForDebugging(
435 `Invalid hooks in agent '${agentType}': ${result.error.message}`,
436 )
437 return undefined
438 }
439 return result.data
440}
441
442/**
443 * Parses agent definition from JSON data

Callers 1

parseAgentFromMarkdownFunction · 0.70

Calls 1

logForDebuggingFunction · 0.85

Tested by

no test coverage detected