style: run oxfmt

This commit is contained in:
Peter Steinberger
2026-01-17 07:59:53 +00:00
parent 5986175268
commit 7cebe7a506
34 changed files with 127 additions and 148 deletions

View File

@@ -97,9 +97,8 @@ describe("hooks install (e2e)", () => {
expect(installResult.ok).toBe(true);
if (!installResult.ok) return;
const { clearInternalHooks, createInternalHookEvent, triggerInternalHook } = await import(
"./internal-hooks.js"
);
const { clearInternalHooks, createInternalHookEvent, triggerInternalHook } =
await import("./internal-hooks.js");
const { loadInternalHooks } = await import("./loader.js");
clearInternalHooks();

View File

@@ -62,7 +62,7 @@ describe("installHooksFromArchive", () => {
"---",
"name: zip-hook",
"description: Zip hook",
"metadata: {\"clawdbot\":{\"events\":[\"command:new\"]}}",
'metadata: {"clawdbot":{"events":["command:new"]}}',
"---",
"",
"# Zip Hook",
@@ -82,9 +82,7 @@ describe("installHooksFromArchive", () => {
expect(result.hookPackId).toBe("zip-hooks");
expect(result.hooks).toContain("zip-hook");
expect(result.targetDir).toBe(path.join(stateDir, "hooks", "zip-hooks"));
expect(
fs.existsSync(path.join(result.targetDir, "hooks", "zip-hook", "HOOK.md")),
).toBe(true);
expect(fs.existsSync(path.join(result.targetDir, "hooks", "zip-hook", "HOOK.md"))).toBe(true);
});
it("installs hook packs from tar archives", async () => {
@@ -109,7 +107,7 @@ describe("installHooksFromArchive", () => {
"---",
"name: tar-hook",
"description: Tar hook",
"metadata: {\"clawdbot\":{\"events\":[\"command:new\"]}}",
'metadata: {"clawdbot":{"events":["command:new"]}}',
"---",
"",
"# Tar Hook",
@@ -148,7 +146,7 @@ describe("installHooksFromPath", () => {
"---",
"name: my-hook",
"description: My hook",
"metadata: {\"clawdbot\":{\"events\":[\"command:new\"]}}",
'metadata: {"clawdbot":{"events":["command:new"]}}',
"---",
"",
"# My Hook",

View File

@@ -134,7 +134,9 @@ async function installHookPackageFromDir(params: {
};
}
const hooksDir = params.hooksDir ? resolveUserPath(params.hooksDir) : path.join(CONFIG_DIR, "hooks");
const hooksDir = params.hooksDir
? resolveUserPath(params.hooksDir)
: path.join(CONFIG_DIR, "hooks");
await fs.mkdir(hooksDir, { recursive: true });
const targetDir = resolveHookInstallDir(hookPackId, hooksDir);
@@ -232,7 +234,9 @@ async function installHookFromDir(params: {
};
}
const hooksDir = params.hooksDir ? resolveUserPath(params.hooksDir) : path.join(CONFIG_DIR, "hooks");
const hooksDir = params.hooksDir
? resolveUserPath(params.hooksDir)
: path.join(CONFIG_DIR, "hooks");
await fs.mkdir(hooksDir, { recursive: true });
const targetDir = resolveHookInstallDir(hookName, hooksDir);

View File

@@ -79,9 +79,7 @@ export async function loadInternalHooks(
// Register for all events listed in metadata
const events = entry.clawdbot?.events ?? [];
if (events.length === 0) {
console.warn(
`Hook warning: Hook '${entry.hook.name}' has no events defined in metadata`,
);
console.warn(`Hook warning: Hook '${entry.hook.name}' has no events defined in metadata`);
continue;
}
@@ -126,9 +124,7 @@ export async function loadInternalHooks(
const handler = mod[exportName];
if (typeof handler !== "function") {
console.error(
`Hook error: Handler '${exportName}' from ${modulePath} is not a function`,
);
console.error(`Hook error: Handler '${exportName}' from ${modulePath} is not a function`);
continue;
}

View File

@@ -48,7 +48,11 @@ function resolvePackageHooks(manifest: HookPackageManifest): string[] {
return raw.map((entry) => (typeof entry === "string" ? entry.trim() : "")).filter(Boolean);
}
function loadHookFromDir(params: { hookDir: string; source: string; nameHint?: string }): Hook | null {
function loadHookFromDir(params: {
hookDir: string;
source: string;
nameHint?: string;
}): Hook | null {
const hookMdPath = path.join(params.hookDir, "HOOK.md");
if (!fs.existsSync(hookMdPath)) return null;