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.06 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/.
import { getMeta, setMeta } from "../storage/repositories/index-meta-repository.js";
const KEY = "onMissRefs";
export function readIndexOnMissRefs(db) {
try {
return new Set(JSON.parse(getMeta(db, KEY) ?? "[]"));
}
catch {
return new Set();
}
}
function write(db, refs) {
setMeta(db, KEY, JSON.stringify([...refs]));
}
export function addIndexOnMissRefs(db, refs) {
if (refs.length === 0)
return;
write(db, new Set([...readIndexOnMissRefs(db), ...refs]));
}
/** A scan has seen these refs: they are no longer waiting for one. */
export function clearIndexOnMissRefs(db, scanned) {
const marked = readIndexOnMissRefs(db);
if (marked.size === 0)
return;
const rest = new Set([...marked].filter((ref) => !scanned.has(ref)));
if (rest.size !== marked.size)
write(db, rest);
}