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

35 lines (34 loc) • 1.4 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 user's `models.json` (retired): `<configDir>/models.json`, an alias to * model table per engine. It is read, in memory, as part of the conversion of * the `engines` form ({@link convertEngineConfig}); `akm migrate apply` moves it * out of the config directory once its aliases are folded into the config. */ import fs from "node:fs"; import path from "node:path"; import { getConfigDir } from "../paths.js"; import { copyToConfigBackups } from "./config-io.js"; function modelsFilePath() { return path.join(getConfigDir(), "models.json"); } /** The user's `models.json`, parsed; absent or unreadable is no overlay. */ export function readModelsFile() { try { return JSON.parse(fs.readFileSync(modelsFilePath(), "utf8")); } catch { return undefined; } } export function modelsFileExists() { return fs.existsSync(modelsFilePath()); } /** Move `models.json` to `<cacheDir>/config-backups/models.json.<timestamp>` and return where it went. */ export function retireModelsFile(now = new Date()) { const target = copyToConfigBackups(modelsFilePath(), (stamp) => `models.json.${stamp}`, now); fs.rmSync(modelsFilePath()); return target; }