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
81 lines (80 loc) • 3.9 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/.
function planGlyph(status) {
switch (status) {
case "current":
return "✓";
case "ready":
return "⚠";
default: // "blocked"
return "✗";
}
}
export function formatMigratePlain(result) {
if (!result || typeof result !== "object")
return null;
const plan = result;
if (typeof plan.status !== "string")
return null;
const lines = [`${planGlyph(plan.status)} ${plan.status}`];
if (plan.configFile?.credentials?.length) {
lines.push(` credentials.json: ${plan.configFile.credentials.length} key(s) (${plan.configFile.credentials.join(", ")})`);
}
if (plan.taskFiles) {
const tasks = plan.taskFiles;
lines.push(` task files: ${tasks.changed} change, ${tasks.skipped} current, ${tasks.blocked} blocked`);
for (const file of tasks.files ?? [])
if (file.status === "changed")
lines.push(` ${file.filePath}`);
}
if (plan.assetEngineKeys) {
lines.push(` asset engine keys: ${plan.assetEngineKeys.changed} change, ${plan.assetEngineKeys.skipped} skipped`);
}
if (plan.assetContentRefs) {
const refs = plan.assetContentRefs;
lines.push(` asset content refs: ${refs.refs} in ${refs.changed} file(s) change, ${refs.skipped} skipped, ${refs.shadowed?.length ?? 0} shadowed`);
}
if (plan.bundlePolicy)
lines.push(` bundle policy: ${plan.bundlePolicy.changed} change(s)`);
if (plan.proposalRecords && plan.proposalRecords.changed > 0)
lines.push(` ${plan.proposalRecords.message}`);
if (plan.indexRows && plan.indexRows.changed > 0)
lines.push(` ${plan.indexRows.message}`);
if (plan.blockers?.length) {
lines.push("", "blockers:", ...plan.blockers.map((blocker) => ` - ${blocker}`));
}
if (plan.configFile?.notes?.length) {
lines.push("", "config notes:", ...plan.configFile.notes.map((note) => ` - ${note}`));
}
if (plan.assetEngineKeys?.notes?.length) {
lines.push("", "engine name notes:", ...plan.assetEngineKeys.notes.map((note) => ` - ${note}`));
}
if (plan.bundlePolicy?.notes?.length) {
lines.push("", "bundle policy notes:", ...plan.bundlePolicy.notes.map((note) => ` - ${note}`));
}
const v5Notes = plan.taskFilesV5?.flatMap((file) => (file.notes ?? []).map((note) => ` - ${file.filePath}: ${note}`));
if (v5Notes?.length)
lines.push("", "version 5 notes (change by hand):", ...v5Notes);
const v5Guidance = plan.taskFilesV5?.flatMap((file) => file.guidance ? [` - ${file.filePath}: ${file.guidance}`] : []);
if (v5Guidance?.length)
lines.push("", "how to fix:", ...v5Guidance);
if (plan.workflowFiles)
lines.push("", `workflow files: ${plan.workflowFiles.message}`);
if (plan.assetContentRefs?.shadowed?.length) {
lines.push("", "shadowed refs (another file holds the old spelling as its ref; not rewritten, resolve them by hand):", ...plan.assetContentRefs.shadowed.map((ref) => ` - ${ref.bundleId}: ${ref.from} (now ${ref.to})`));
}
if (plan.assetContentRefs?.reconcile?.length) {
lines.push("", "git reconcile:", ...plan.assetContentRefs.reconcile.map((note) => ` - ${note}`));
}
if (plan.backupPath) {
lines.push("", `backup: ${plan.backupPath}`);
}
if (plan.applied !== undefined)
lines.push(`applied: ${plan.applied}`);
return lines.join("\n");
}
export const migrateFormatters = [
{ command: "migrate-status", handler: (r) => formatMigratePlain(r) },
{ command: "migrate-apply", handler: (r) => formatMigratePlain(r) },
];