diff --git a/src/hooks/types.ts b/src/hooks/types.ts index 6675a432630..4bd8fcbd62f 100644 --- a/src/hooks/types.ts +++ b/src/hooks/types.ts @@ -37,6 +37,7 @@ export type Hook = { description: string; source: "openclaw-bundled" | "openclaw-managed" | "openclaw-workspace" | "openclaw-plugin"; pluginId?: string; + frontmatter?: ParsedHookFrontmatter; filePath: string; // Path to HOOK.md baseDir: string; // Directory containing hook handlerPath: string; // Path to handler module (handler.ts/js) diff --git a/src/hooks/workspace.ts b/src/hooks/workspace.ts index af5db5c8f2c..c0e80b2dbbb 100644 --- a/src/hooks/workspace.ts +++ b/src/hooks/workspace.ts @@ -14,14 +14,7 @@ import { resolveHookInvocationPolicy, } from "./frontmatter.js"; import { resolvePluginHookDirs } from "./plugin-hooks.js"; -import type { - Hook, - HookEligibilityContext, - HookEntry, - HookSnapshot, - HookSource, - ParsedHookFrontmatter, -} from "./types.js"; +import type { Hook, HookEligibilityContext, HookEntry, HookSnapshot, HookSource } from "./types.js"; type HookPackageManifest = { name?: string; @@ -135,6 +128,7 @@ function loadHookFromDir(params: { description, source: params.source, pluginId: params.pluginId, + frontmatter, filePath: safeHookMdPath, baseDir, handlerPath, @@ -220,15 +214,7 @@ export function loadHookEntriesFromDir(params: { pluginId: params.pluginId, }); return hooks.map((hook) => { - let frontmatter: ParsedHookFrontmatter = {}; - const raw = readBoundaryFileUtf8({ - absolutePath: hook.filePath, - rootPath: path.dirname(hook.filePath), - boundaryLabel: "hook directory", - }); - if (raw !== null) { - frontmatter = parseFrontmatter(raw); - } + const frontmatter = hook.frontmatter ?? {}; const entry: HookEntry = { hook: { ...hook, @@ -311,15 +297,7 @@ function loadHookEntries( } return Array.from(merged.values()).map((hook) => { - let frontmatter: ParsedHookFrontmatter = {}; - const raw = readBoundaryFileUtf8({ - absolutePath: hook.filePath, - rootPath: hook.baseDir, - boundaryLabel: "hook directory", - }); - if (raw !== null) { - frontmatter = parseFrontmatter(raw); - } + const frontmatter = hook.frontmatter ?? {}; return { hook, frontmatter,