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

29 lines (28 loc) • 1.52 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/. /** Marker emitted by output redaction. It must never become durable asset content. */ export const REDACTED_CONTENT_MARKER = "[REDACTED]"; /** Reflect prompt section that contains run diagnostics, not proposed asset content. */ export const REFLECT_AVOID_PATTERNS_HEADING = "Avoid These Patterns"; const REFLECT_AVOID_PATTERNS_RE = /^##[ \t]+Avoid These Patterns[ \t]*$/i; export function containsRedactedContent(content) { return content.includes(REDACTED_CONTENT_MARKER); } export function containsReflectPromptScaffolding(content) { return content.split(/\r?\n/).some((line) => REFLECT_AVOID_PATTERNS_RE.test(line)); } /** * Return a secret-free rejection reason when generated content is unsafe to * persist. `redactedContent` is the same body after applying the dispatch * lease's sensitive-value inventory; comparing it avoids exposing the value. */ export function generatedContentRejection(content, redactedContent) { if (containsRedactedContent(content)) { return `Agent proposal content contains ${REDACTED_CONTENT_MARKER}; refusing to persist already-redacted text.`; } if (redactedContent !== content) { return "Agent proposal content echoed a configured credential; refusing to persist either the secret or a redacted replacement."; } return undefined; }