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

31 lines (30 loc) • 1.42 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/. export const PERSONA_FALLBACK_NOTICE_CODE = "persona-prompt-composed"; export const PERSONA_FALLBACK_BEGIN = "<AKM_PERSONA>"; export const PERSONA_FALLBACK_END = "</AKM_PERSONA>"; function withTrailingNewline(value) { return value.endsWith("\n") ? value : `${value}\n`; } /** Preserve a persona when a target has no native system/persona channel. */ export function composePersonaFallbackPrompt(persona, command, adapter) { if (typeof persona !== "string" || typeof command !== "string") { throw new TypeError("persona fallback content must be strings"); } if (typeof adapter !== "string" || adapter.length === 0) { throw new TypeError("persona fallback adapter must be a non-empty string"); } const notice = Object.freeze({ code: PERSONA_FALLBACK_NOTICE_CODE, severity: "info", adapter, field: "persona", message: "The selected engine has no native persona channel; AKM composed the persona into the prompt.", }); const notices = Object.freeze([notice]); return Object.freeze({ prompt: `${PERSONA_FALLBACK_BEGIN}\n${withTrailingNewline(persona)}${PERSONA_FALLBACK_END}\n\n${command}`, notices, }); }