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

56 lines (55 loc) • 2.83 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/. import { curateShapes } from "./shapes/curate.js"; import { envListShapes } from "./shapes/env-list.js"; import { eventsShapes } from "./shapes/events.js"; import { migrateShapes } from "./shapes/migrate.js"; import { passthroughShapes } from "./shapes/passthrough.js"; import { proposalAcceptShapes } from "./shapes/proposal/accept.js"; import { proposalDiffShapes } from "./shapes/proposal/diff.js"; import { proposalListShapes } from "./shapes/proposal/list.js"; import { proposalProducerShapes } from "./shapes/proposal/producer.js"; import { proposalRejectShapes } from "./shapes/proposal/reject.js"; import { proposalReopenShapes } from "./shapes/proposal/reopen.js"; import { proposalShowShapes } from "./shapes/proposal/show.js"; import { getOutputShapeHandler, registerOutputShapes } from "./shapes/registry.js"; import { searchShapes } from "./shapes/search.js"; import { secretListShapes } from "./shapes/secret-list.js"; import { showShapes } from "./shapes/show.js"; // ── Explicit built-in shape assembly ────────────────────────────────────────── // Each entry below is a pure exported `OutputShapeEntry[]` from a per-command // module. The set is registered ONCE, deterministically, with no reliance on // import order. Removing a module from this list removes its registration — // and because each name is referenced statically, a deleted export fails to // compile instead of silently disappearing at runtime. const BUILT_IN_OUTPUT_SHAPES = [ ...searchShapes, ...curateShapes, ...showShapes, ...eventsShapes, ...proposalListShapes, ...proposalShowShapes, ...proposalAcceptShapes, ...proposalRejectShapes, ...proposalReopenShapes, ...proposalDiffShapes, ...proposalProducerShapes, ...envListShapes, ...secretListShapes, ...migrateShapes, // Passthrough commands are registered last so an explicit dedicated handler // above always wins over the identity-stamp fallback for the same name. ...passthroughShapes, ]; registerOutputShapes(BUILT_IN_OUTPUT_SHAPES); export function shapeForCommand(command, result, detail, shape = "human") { const handler = getOutputShapeHandler(command); if (handler) { return handler(result, detail, shape); } // Output-shape registry is exhaustive: no silent JSON.stringify // fallback. A missing case here is a registration bug — fail loudly so // the caller (or its tests) sees the missing command name. throw new Error(`output shape not registered for command: ${command}`); }