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
33 lines (32 loc) • 1.29 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/.
/**
* Render entries worst-first (by `severityRank`, ties keep original order),
* each as a glyph-prefixed headline with its optional indented detail lines.
*/
export function renderStatusEntries(entries) {
const ordered = entries
.map((entry, index) => ({ entry, index }))
.sort((a, b) => a.entry.severityRank - b.entry.severityRank || a.index - b.index)
.map(({ entry }) => entry);
const lines = [];
for (const entry of ordered) {
lines.push(`${entry.glyph} ${entry.headline}`);
for (const detail of entry.detailLines ?? []) {
lines.push(` ${detail}`);
}
}
return lines;
}
/**
* Render a status→count map as `"2 fail, 1 warn, 5 pass"`, in `order` (worst
* first) with zero counts omitted. Shared by any section header that wants a
* one-line "what's in here" summary before the per-row detail.
*/
export function summarizeCounts(counts, order) {
return order
.filter((status) => (counts[status] ?? 0) > 0)
.map((status) => `${counts[status]} ${status}`)
.join(", ");
}