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

57 lines (56 loc) • 2.26 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 { cancel as realCancel, confirm as realConfirm, intro as realIntro, isCancel as realIsCancel, log as realLog, multiselect as realMultiselect, note as realNote, outro as realOutro, select as realSelect, spinner as realSpinner, text as realText, } from "@clack/prompts"; // ── Test seam ──────────────────────────────────────────────────────────────── // Swap-and-restore override. Inert in production; only tests call the setter // (via tests/_helpers/seams.ts `overrideSeam`, never directly). let clackFake; /** TEST-ONLY. Swap the clack prompt surface; pass undefined to restore. */ export function _setClackForTests(fake) { clackFake = fake; } const realFns = { intro: realIntro, outro: realOutro, cancel: realCancel, confirm: realConfirm, select: realSelect, multiselect: realMultiselect, text: realText, spinner: realSpinner, note: realNote, isCancel: realIsCancel, }; /** Delegator with the real export's exact type; reads the fake at call time. */ function bind(name) { return ((...args) => { const impl = (clackFake?.[name] ?? realFns[name]); return impl(...args); }); } function bindLog(name) { return ((...args) => { const impl = (clackFake?.log?.[name] ?? realLog[name]); return impl(...args); }); } export const intro = bind("intro"); export const outro = bind("outro"); export const cancel = bind("cancel"); export const confirm = bind("confirm"); export const select = bind("select"); export const multiselect = bind("multiselect"); export const text = bind("text"); export const spinner = bind("spinner"); export const note = bind("note"); export const isCancel = bind("isCancel"); export const log = { message: bindLog("message"), info: bindLog("info"), success: bindLog("success"), step: bindLog("step"), warn: bindLog("warn"), warning: bindLog("warning"), error: bindLog("error"), };