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
23 lines (22 loc) • 1.02 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/.
import { spawnSync } from "node:child_process";
import { UsageError } from "../../core/errors.js";
export function scriptExecutable(interpreter) {
if (interpreter === "bun" || interpreter === "bun-standalone")
return process.execPath;
if (interpreter === "kotlin")
return "kotlin";
return interpreter;
}
export function gitIdentity(unit, root) {
if (unit.isolation !== "worktree")
return {};
const result = spawnSync("git", ["-C", root, "rev-parse", "HEAD"], { encoding: "utf8" });
const oid = result.status === 0 ? result.stdout.trim() : "";
if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(oid)) {
throw new UsageError(`Worktree-isolated workflow root ${root} has no immutable Git HEAD OID.`, "WORKFLOW_SOURCE_INVALID");
}
return { gitCommitOid: oid };
}