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

64 lines (63 loc) • 3.05 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/. /** * What runs where, in words, once setup has chosen: model calls, agent work and * embeddings. The words are read off the table `akm info` and `akm health` * print (`../commands/targets.ts`), so the summary says what those say and what * a call does. */ import { targetRows } from "../commands/targets.js"; import { getHarness } from "../integrations/harnesses/index.js"; /** Whether akm can run this platform's program with its tools limited to reading and searching for model calls. */ export function runsReadOnly(platform) { return getHarness(platform)?.confinable === true; } /** What setup says, wherever it names a harness that takes akm's model calls and cannot be restricted. */ export function unrestrictedModelWorkNote(name) { return `Model work on ${name} cannot be restricted: it can edit files and run commands.`; } function modelSuffix(row) { return row.model ? ` (${row.model})` : ""; } /** Model calls or agent work: where the row says it runs, or what is wrong with the config that stops it. */ function describeWork(row, rows, modelWork) { if (row.problem) return row.problem; if (row.kind === "connection") { return `${modelWork ? "connection" : "akm's own runtime over connection"} "${row.target}"${modelSuffix(row)}`; } if (row.kind === "harness") { const platform = rows.find((r) => r.type === "harness" && r.name === row.target); const restriction = modelWork && platform?.type === "harness" ? runsReadOnly(platform.platform) ? ", limited to reading and searching" : `. ${unrestrictedModelWorkNote(`"${row.target}"`)}` : ""; return `harness "${row.target}"${modelSuffix(row)}${restriction}`; } const declined = modelWork ? rows.find((r) => r.type === "harness" && r.modelWork === false) : undefined; return declined ? `off: no connection is configured, and harness "${declined.name}" is set not to take model calls. Add a connection with \`akm setup --endpoint URL\`.` : "off: no connection or harness is configured"; } function describeEmbeddings(row) { if (row.kind === "local") return `akm's built-in local embedder${modelSuffix(row)}`; if (row.kind === "connection") return `${row.model ?? "a model"} on connection "${row.target}"`; if (row.kind === "endpoint") return `${row.model ?? "a model"} at ${row.target}`; return "off"; } export function describeRuns(config) { const rows = targetRows({ config }); const work = (name) => rows.find((r) => r.type === "process" && r.process === name); return { modelCalls: describeWork(work("improve"), rows, true), agentWork: describeWork(work("agents"), rows, false), embeddings: describeEmbeddings(work("embedding")), }; }