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

24 lines (23 loc) • 1.26 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/. /** The `state.db` columns that hold a bundle id: the ones whose rows an akm migration or a rename carries. */ export const BUNDLE_ID_COLUMNS = Object.freeze([ { table: "proposals", column: "bundle_id" }, { table: "improve_runs", column: "bundle_id" }, { table: "improve_ledger", column: "bundle_id" }, ]); /** Whether a stored `bundle_id` is a directory (it holds a path separator or a drive colon), never a bundle id: a bundle name holds none of them. */ export function isPathKey(value) { return /[/\\:]/.test(value); } /** * Re-file every `state.db` row of bundle `oldId` under `newId` (`akm bundle rename`). A ledger row `newId` already * holds for the same key (left by a bundle of that name that was dropped from config) gives way to the renamed * bundle's: the rows being carried are the ones in use. */ export function renameStateBundleId(db, oldId, newId) { for (const { table, column } of BUNDLE_ID_COLUMNS) { db.prepare(`UPDATE OR REPLACE ${table} SET ${column} = ? WHERE ${column} = ?`).run(newId, oldId); } }