/** * @fileoverview Generic plugin loader. * * Owns the machinery that's identical for every plugin domain: * * 1. Discover plugins for a domain (via discoverPlugins). * 2. Dynamic-import each discovered entry point. * 3. Hand the imported module to a domain-supplied `registerExports` * callback that performs the actual registration (into the fitness * check registry, the sim scenario registry, the kernel language * registry, etc.). * 4. Roll up per-plugin counts into a PluginLoadResult, catching and * reporting per-plugin failures without aborting the whole batch. * * What we deliberately do NOT own here: the *contents* of registration. * Each domain (fit, sim, lang) knows what shape its plugins export and * which registry to feed; that lives with the tool that owns the * registry. The callback receives a `RegisterCtx` so it can emit * structured warnings without re-deriving plugin metadata. * * This file replaces what used to be a fit-coupled loader in * @opensip-tools/fitness. The fitness loader is now a thin adapter * that supplies a fit-specific registerExports callback and re-exports * loadPlugin / loadAllPlugins with the same public signatures it had * before, so existing callers (fit.ts) don't change. */ import type { DiscoveredPlugin, LoadedPlugin, PluginLayout, PluginLoadResult } from './types.js'; /** * Per-plugin context handed to a domain's `registerExports` callback. * Lets the callback emit structured warnings (with namespace/source * already filled in) without re-deriving plugin metadata. */ export interface RegisterCtx { readonly plugin: DiscoveredPlugin; /** Emit a structured warning about a malformed plugin export. */ readonly warn: (evt: string, msg: string, fields?: Record) => void; /** Emit a structured debug event. */ readonly debug: (evt: string, fields?: Record) => void; } /** * Per-plugin registration counts returned from the callback — a generic * map keyed by whatever artifact kinds the domain registers (e.g. * `{ checks: 3, recipes: 1 }`, `{ scenarios: 2 }`, `{ adapters: 1 }`). * The kernel carries no tool-specific counter names (ADR-0009 M2). */ export type RegisteredCounts = Readonly>; /** * Callback that registers a plugin's exports into the right registries * for its domain. Returns the per-kind counts for that plugin. Kinds a * domain doesn't produce are simply absent from the map. */ export type RegisterExportsFn = (mod: Record, ctx: RegisterCtx) => Promise | RegisteredCounts; /** * Load a single discovered plugin: dynamic-import its entry, run the * domain's `registerExports` callback, and wrap any thrown error so a * single bad plugin doesn't take down the rest of the batch. */ export declare function loadPlugin(plugin: DiscoveredPlugin, registerExports: RegisterExportsFn): Promise; /** * Discover and load every plugin for a domain. Plugins are loaded * sequentially to keep registration order deterministic. * * Without `projectDir`, no plugins are discovered — there is no * user-global fallback, by design. */ export declare function loadAllPlugins(layout: PluginLayout, projectDir: string | undefined, registerExports: RegisterExportsFn): Promise; //# sourceMappingURL=loader.d.ts.map