vigiles API reference
    Preparing search index...

    Function loadHook

    • Load a compiled-hook program's default export from file.

      JS module formats (.mjs/.cjs/.js) load via dynamic import directly; a TypeScript hook (.ts/.mts/.cts) loads only under a TS-capable runtime (tsx, or a Node that strips types). When the runtime is the reason, the error says so and points at authoring the hook as .mjs; any other failure is reported as itself.

      import { loadHook, assertHookDenies } from "vigiles";

      const guard = await loadHook(".vigiles/hooks/guard.hook.mjs");
      assertHookDenies(guard, {
      tool_name: "Bash",
      tool_input: { command: "git push --force" },
      });

      Parameters

      • file: string
      • root: string = ...

      Returns Promise<AnyHook>

      when the file can't be imported, or has no default-exported hook program.