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
36 lines (35 loc) • 1.22 kB
JavaScript
// 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/.
const REMEMBER_RE = /\bakm\s+remember\s+(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)')/g;
const FEEDBACK_RE = /\bakm\s+feedback\s+(\S+)(?:\s+--[a-z-]+)*\s+(?:--note|-n)\s+(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)')/g;
export function extractInlineRefMentions(text, ts) {
if (!text || text.length < 10)
return [];
const out = [];
REMEMBER_RE.lastIndex = 0;
for (const m of text.matchAll(REMEMBER_RE)) {
const body = m[1] ?? m[2] ?? "";
if (!body.trim())
continue;
out.push({
kind: "remember",
text: body,
...(ts !== undefined ? { ts } : {}),
});
}
FEEDBACK_RE.lastIndex = 0;
for (const m of text.matchAll(FEEDBACK_RE)) {
const ref = m[1] ?? "";
const note = m[2] ?? m[3] ?? "";
if (!ref)
continue;
out.push({
kind: "feedback",
ref,
text: note,
...(ts !== undefined ? { ts } : {}),
});
}
return out;
}