* 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, )
| 422 | * @returns Parsed hooks settings or undefined if invalid/missing |
| 423 | */ |
| 424 | function 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 |
no test coverage detected