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
45 lines (44 loc) • 1.74 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/.
/**
* Setup wizard step: choose where akm stores its stash (skills, commands,
* and other assets).
*/
import * as p from "../../cli/clack.js";
import { primaryBundlePath } from "../../core/config/config.js";
import { assertSafeStashDir, getDefaultStashDir } from "../../core/paths.js";
import { prompt } from "../prompt.js";
export async function stepStashDir(current, options) {
const currentPrimary = primaryBundlePath(current);
const defaultDir = options?.preferredDir ?? currentPrimary ?? getDefaultStashDir();
if (options?.nonInteractive) {
return defaultDir;
}
const choice = await prompt(() => p.select({
message: "Where should akm store skills, commands, and other assets?",
options: [
{ value: "default", label: defaultDir, hint: currentPrimary ? "current" : "default" },
{ value: "custom", label: "Enter a custom path..." },
],
}));
if (choice === "default")
return defaultDir;
const customPath = await prompt(() => p.text({
message: "Enter the bundle directory path:",
placeholder: defaultDir,
validate: (v) => {
if (!v?.trim())
return "Path cannot be empty";
try {
assertSafeStashDir(v.trim());
}
catch (err) {
if (err instanceof Error)
return err.message;
return "Refused: unsafe bundle directory";
}
},
}));
return customPath.trim();
}