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.35 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 fs from "node:fs";
import { stalePathRoots } from "../asset/stale-path.js";
import { bundleLintSkip } from "./bundle-skip.js";
import { readMovedRefs } from "./moved-refs.js";
/** The root of each configured bundle by its id, for the checks that look a qualified ref up in the bundle it names. */
function bundleRootsOf(sources) {
return new Map(sources.flatMap(({ registryId, path }) => (registryId ? [[registryId, path === undefined ? [] : [path]]] : [])));
}
/**
* The scope of the configured bundle at `root` among the configured `sources` (none for a file outside every bundle).
* `readMoves` is how the caller reads the recorded moves.
*/
export function lintScope(root, cfg, sources, readMoves) {
return {
stashRoot: root,
extraStashRoots: sources
.map((source) => source.path)
// asset-io: bundle-root root probe
.filter((p) => p !== undefined && p !== root && fs.existsSync(p)),
bundleRoots: bundleRootsOf(sources),
moves: readMovedRefs(readMoves),
stalePathRoots: stalePathRoots(cfg, root),
bundleSkip: bundleLintSkip(cfg, root),
};
}