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

38 lines (37 loc) • 1.9 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/. // ── Failure helpers ────────────────────────────────────────────────────────── /** * Base failure envelope shared by all agent command failures. * Each command returns its own typed failure shape — this helper builds the * common fields so per-command wrappers only need to add their own fields. */ export function baseFailureFields(result, fallbackReason = "non_zero_exit") { const reason = result.reason ?? fallbackReason; return { schemaVersion: 1, ok: false, reason, error: result.error ?? `agent failure (${reason})`, exitCode: result.exitCode, ...(result.stdout ? { stdout: result.stdout } : {}), ...(result.stderr ? { stderr: result.stderr } : {}), }; } // ── ENOENT hint ────────────────────────────────────────────────────────────── /** * Return `true` when a failed agent result looks like the binary was not found * on PATH. Used to surface a better error message pointing the user at * `akm setup`. */ export function isEnoentFailure(result) { return (result.reason === "spawn_failed" && (!!result.error?.includes("ENOENT") || !!result.error?.toLowerCase().includes("not found"))); } /** * Build an actionable error message for a spawn-ENOENT failure. */ export function enoentHintMessage(binName) { return `The agent binary '${binName}' was not found on PATH. Run \`akm setup\` to configure an agent CLI, or install ${binName} and retry.`; }