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

26 lines (25 loc) • 1.31 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. A dispatch redacts its reply before anything reads it, so content * that echoed a credential reaches here carrying the marker. */ export function generatedContentRejection(content) { if (containsRedactedContent(content)) { return `Agent proposal content contains ${REDACTED_CONTENT_MARKER}; refusing to persist already-redacted text.`; } return undefined; }