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

71 lines (70 loc) • 3.59 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/. const text = (value) => (value === undefined || value === null ? "-" : String(value)); const yesNo = (value) => (value === undefined ? "-" : value ? "yes" : "no"); /** Left-aligned columns, two spaces apart, the header first. */ function table(headers, cells) { const widths = headers.map((header, i) => Math.max(header.length, ...cells.map((row) => row[i]?.length ?? 0))); const line = (row) => row .map((cell, i) => cell.padEnd(widths[i] ?? cell.length)) .join(" ") .trimEnd(); return [line(headers), ...cells.map(line)]; } /** The reachability column: answered, or why not. */ function reachable(row) { return row.reachable === true ? "yes" : `no${row.error ? ` (${text(row.error)})` : ""}`; } /** The work column: where it runs, or that it does not. */ function runsOn(row) { if (row.kind === null || row.kind === undefined) return "off"; return row.kind === "local" ? "built-in embedder" : `${text(row.kind)} ${text(row.target)}`; } /** `triage judgment → connection second (qwen3-8b)`: a part of the work that runs elsewhere, and where. */ function override(entry) { const where = entry.target === null || entry.target === undefined ? "off" : `${text(entry.kind)} ${text(entry.target)}`; return `${text(entry.name)} → ${where}${entry.model ? ` (${text(entry.model)})` : ""}`; } /** What to look at in a work row: what resolves elsewhere, or what is wrong. */ function notes(row) { const elsewhere = Array.isArray(row.overrides) ? row.overrides.map(override) : []; return [...elsewhere, ...(row.problem ? [text(row.problem)] : [])].join("; "); } const CONNECTION_COLUMNS = [ { header: "NAME", cell: (row) => text(row.name) }, { header: "DEFAULT", cell: (row) => (row.default ? "yes" : "") }, { header: "ENDPOINT", cell: (row) => text(row.endpoint) }, { header: "KEY", cell: (row) => text(row.key) }, { header: "REACHABLE", cell: reachable, field: "reachable" }, ]; const HARNESS_COLUMNS = [ { header: "NAME", cell: (row) => text(row.name) }, { header: "DEFAULT", cell: (row) => (row.default ? "yes" : "") }, { header: "PLATFORM", cell: (row) => text(row.platform) }, { header: "INSTALLED", cell: (row) => yesNo(row.installed) }, { header: "MODEL CALLS", cell: (row) => (row.modelWork === false ? "off" : ""), field: "modelWork" }, { header: "VERSION", cell: (row) => text(row.version), field: "version" }, ]; const WORK_COLUMNS = [ { header: "WORK", cell: (row) => text(row.process) }, { header: "RUNS ON", cell: runsOn }, { header: "MODEL", cell: (row) => text(row.model) }, { header: "NOTES", cell: notes }, ]; function section(title, columns, rows) { if (rows.length === 0) return []; const shown = columns.filter((column) => column.field === undefined || rows.some((row) => row[column.field] !== undefined)); const body = table(shown.map((column) => column.header), rows.map((row) => shown.map((column) => column.cell(row)))); return [`${title}:`, ...body.map((line) => ` ${line}`)]; } export function renderTargetsTable(rows) { const of = (type) => rows.filter((row) => row?.type === type); return [ ...section("connections", CONNECTION_COLUMNS, of("connection")), ...section("harnesses", HARNESS_COLUMNS, of("harness")), ...section("work", WORK_COLUMNS, of("process")), ]; }