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.72 kB
JavaScript
// 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/.
/**
* Output shape registry.
*
* Separated from `shapes.ts` so per-command shape modules can import
* `registerOutputShape` without creating a circular dependency back into
* the main shapes module.
*/
import { createCommandRegistry } from "../command-registry.js";
const OUTPUT_SHAPE_REGISTRY = createCommandRegistry();
/**
* Register an output shape handler for a command name.
*
* Call this at module load time from a `src/output/shapes/<command>.ts` file.
* Multiple command names may share the same handler — call once per name.
*
* ```ts
* registerOutputShape("my-command", (result, detail) => result);
* ```
*/
export function registerOutputShape(command, handler) {
OUTPUT_SHAPE_REGISTRY.register(command, handler);
}
/**
* Register a batch of {@link OutputShapeEntry} definitions in iteration order.
*
* This is the explicit-assembly entry point used by `shapes.ts`: the built-in
* shape set is registered by iterating a single explicit list exactly once,
* with no reliance on module import order.
*/
export function registerOutputShapes(entries) {
OUTPUT_SHAPE_REGISTRY.registerAll(entries);
}
/**
* Remove a previously-registered output shape. Test-only utility.
*/
export function deregisterOutputShape(command) {
OUTPUT_SHAPE_REGISTRY.deregister(command);
}
/**
* Look up a registered output shape handler by command name.
* Returns `undefined` if not registered.
*/
export function getOutputShapeHandler(command) {
return OUTPUT_SHAPE_REGISTRY.get(command);
}