/** * Graph language-adapter registry — per-RunScope. * * Each `RunScope` owns its own adapter registry (Item 1 / D7). The * graph tool's `contributeScope` hook constructs a fresh registry per CLI * invocation and attaches it to `scope.graph.adapters`. * * Built on the kernel's unified `Registry` with * `duplicatePolicy: 'overwrite'` — re-registering an adapter with the * same `id` overwrites the incumbent. That's intentional: a host * application can swap an adapter in tests, and the file's prior * incarnation documented this contract explicitly. * * Public API: * - `GraphAdapterRegistry` — the registry class. * - `createAdapterRegistry()` — factory used by `contributeScope`. * - `currentAdapterRegistry()` — reads the scope-bound instance. * - `pickAdapter()` — thin helper that routes through * the scope-bound instance to select the adapter for the run. * * Future PRs may auto-detect the right adapter from project files; * for now `pickAdapter()` returns the only registered adapter so the * orchestrator behaves identically to today. */ import { type Registerable } from '@opensip-tools/core'; import type { GraphLanguageAdapter } from './types.js'; interface RegisterableAdapter extends Registerable { readonly id: string; readonly name: string; readonly adapter: GraphLanguageAdapter; } /** * Per-RunScope adapter registry. Wraps the kernel `Registry` with * the graph-specific `register` / `pick` surface. */ export declare class GraphAdapterRegistry { private readonly inner; /** * Register an adapter by its `id`. Re-registering an adapter with * the same `id` overwrites; that's intentional so a host application * can swap an adapter in tests. */ register(adapter: GraphLanguageAdapter): void; /** * Pick the adapter for the current run. * * - Zero registered adapters → fail with a configuration error. * - One registered adapter → return it. * - Multiple adapters → choose by file-extension dominance in * `cwd` when supplied; fall back to a deterministic preference order * (TypeScript first, then Python, then alphabetical). * * The dominance heuristic is intentionally simple: count files for * each adapter's `fileExtensions` (recursive, ignoring common * non-source dirs), pick whichever has the most matches. Ties prefer * TypeScript so the legacy TS-only behavior is preserved when a repo * has both. A real `--language` CLI flag is the right long-term * answer; until it lands, this heuristic is the best the registry can * do without inspecting tool config. */ pick(cwd?: string): GraphLanguageAdapter; clear(): void; get size(): number; getAll(): readonly RegisterableAdapter[]; getById(id: string): RegisterableAdapter | undefined; /** * Emit an actionable warning when no installed adapter matched any * source file under `cwd`. Names the registered adapters and points at * the per-language packages so a Go/Java (or any unsupported-language) * repo gets "install @opensip-tools/graph-" instead of a silent * empty result. Audit 2026-05-29 (#4 fix 3). */ private warnNoMatchingAdapter; private pickByFileDominance; private countFilesPerAdapter; private resolveTie; } /** Factory used by the graph tool's `contributeScope` hook. */ export declare function createAdapterRegistry(): GraphAdapterRegistry; /** * Stash the list of adapters discovered at CLI startup so the graph * tool's `contributeScope` can register them into each new scope's adapter * registry. Called once at bootstrap; idempotent. */ export declare function setDiscoveredAdapters(adapters: readonly GraphLanguageAdapter[]): void; /** Read the list set by `setDiscoveredAdapters`. Defaults to empty. */ export declare function getDiscoveredAdapters(): readonly GraphLanguageAdapter[]; /** * Read the current scope's graph adapter registry. Throws when no * scope is active or when the graph subscope is missing — both * indicate the caller is running outside the CLI's pre-action-hook (or * the test fixture forgot to construct + enter a scope). * * @throws {Error} When called outside `runWithScope(...)`, or when the * active scope has no graph subscope. */ export declare function currentAdapterRegistry(): GraphAdapterRegistry; /** Pick the adapter for the current run. See `GraphAdapterRegistry.pick`. */ export declare function pickAdapter(cwd?: string): GraphLanguageAdapter; export {}; //# sourceMappingURL=registry.d.ts.map