UNPKG

akm-cli

Version:

akm (Agent Knowledge Manager) — a portable, local-first capability library for AI agents. Discover, load, share, and improve reusable skills, scripts, workflows, and knowledge across any shell-capable coding agent, including Claude Code, OpenCode, and Cur

49 lines (48 loc) • 1.75 kB
// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. /** * Plain-text formatter registry. * * Separated from `text.ts` so per-command formatter modules can import * `registerTextFormatter` without creating a circular dependency back into * the main text module. */ import { createCommandRegistry } from "../command-registry.js"; const TEXT_FORMATTER_REGISTRY = createCommandRegistry(); /** * Register a plain-text formatter for a command name. * * Call this at module load time from a `src/output/text/<command>.ts` file. * Multiple command names may share the same handler — call once per name. * * ```ts * registerTextFormatter("my-command", (r) => `done: ${r.ref}`); * ``` */ export function registerTextFormatter(command, handler) { TEXT_FORMATTER_REGISTRY.register(command, handler); } /** * Register a batch of {@link TextFormatterEntry} definitions in iteration order. * * This is the explicit-assembly entry point used by `text.ts`: the built-in * formatter set is registered by iterating a single explicit list exactly once, * with no reliance on module import order. */ export function registerTextFormatters(entries) { TEXT_FORMATTER_REGISTRY.registerAll(entries); } /** * Remove a previously-registered text formatter. Test-only utility. */ export function deregisterTextFormatter(command) { TEXT_FORMATTER_REGISTRY.deregister(command); } /** * Look up a registered text formatter by command name. * Returns `undefined` if not registered. */ export function getTextFormatterHandler(command) { return TEXT_FORMATTER_REGISTRY.get(command); }