feat(plugins): add compatible bundle support

This commit is contained in:
Peter Steinberger
2026-03-15 16:08:30 -07:00
parent aa1454d1a8
commit dd40741e18
30 changed files with 2696 additions and 73 deletions

View File

@@ -13,6 +13,7 @@ import {
resolveOpenClawMetadata,
resolveHookInvocationPolicy,
} from "./frontmatter.js";
import { resolvePluginHookDirs } from "./plugin-hooks.js";
import type {
Hook,
HookEligibilityContext,
@@ -242,6 +243,10 @@ function loadHookEntries(
const extraDirs = extraDirsRaw
.map((d) => (typeof d === "string" ? d.trim() : ""))
.filter(Boolean);
const pluginHookDirs = resolvePluginHookDirs({
workspaceDir,
config: opts?.config,
});
const bundledHooks = bundledHooksDir
? loadHooksFromDir({
@@ -256,6 +261,13 @@ function loadHookEntries(
source: "openclaw-workspace", // Extra dirs treated as workspace
});
});
const pluginHooks = pluginHookDirs.flatMap(({ dir, pluginId }) =>
loadHooksFromDir({
dir,
source: "openclaw-plugin",
pluginId,
}),
);
const managedHooks = loadHooksFromDir({
dir: managedHooksDir,
source: "openclaw-managed",
@@ -266,13 +278,16 @@ function loadHookEntries(
});
const merged = new Map<string, Hook>();
// Precedence: extra < bundled < managed < workspace (workspace wins)
// Precedence: extra < bundled < plugin < managed < workspace (workspace wins)
for (const hook of extraHooks) {
merged.set(hook.name, hook);
}
for (const hook of bundledHooks) {
merged.set(hook.name, hook);
}
for (const hook of pluginHooks) {
merged.set(hook.name, hook);
}
for (const hook of managedHooks) {
merged.set(hook.name, hook);
}