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

33 lines (32 loc) • 1.22 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/. /** * Return a Node-style system error code from an error or one of its causes. * The bounded walk handles wrappers without trusting or parsing error text. */ export function systemErrorCode(error) { let current = error; for (let depth = 0; depth < 8; depth += 1) { if (!current || typeof current !== "object") return undefined; const candidate = current; if (typeof candidate.code === "string") return candidate.code; current = candidate.cause; } return undefined; } /** Read-only telemetry writes are expected to disappear without diagnostics. */ export function isReadOnlyFilesystemError(error) { let current = error; for (let depth = 0; depth < 8; depth += 1) { if (!current || typeof current !== "object") return false; const candidate = current; if (candidate.code === "EROFS" || candidate.code === "EACCES") return true; current = candidate.cause; } return false; }