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
32 lines (31 loc) • 1.19 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/.
/**
* Read one value from the selected config file without loading the config.
*
* For the setting read before the config load: CLI usage capture runs before
* config is read.
* It reads only the file itself (no `extends` chain, no schema), and any
* failure, a missing or broken file included, yields `undefined` so the caller
* falls back to its default. It never throws and never warns.
*/
import { getConfigPath } from "../paths.js";
import { parseConfigText, readConfigText } from "./config-io.js";
export function peekConfigValue(keys, env = process.env) {
try {
const text = readConfigText(getConfigPath(env));
if (text === undefined)
return undefined;
let value = parseConfigText(text);
for (const key of keys) {
if (typeof value !== "object" || value === null)
return undefined;
value = value[key];
}
return value;
}
catch {
return undefined;
}
}