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
53 lines (52 loc) • 3.41 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/.
/**
* One notice per process for each deprecated config key that still works in 0.10 and goes in 0.11, like the
* `extends` notice. The config is read exactly as before; a notice is not printed for akm's own runs
* (the scheduler, a task, improve, audit) or with `--help`, and `--quiet` silences it (it goes through `warnOnce`).
*/
import { getParsedInvocation } from "../../cli/invocation.js";
import { warnOnce } from "../warn.js";
import { isPlainObject } from "./deep-merge.js";
const INTERNAL_SOURCES = new Set(["task", "improve", "audit"]);
/**
* True for akm's own invocations (the scheduler, a task, improve or audit), `--help` and `--scheduled`: no
* deprecation notice. `hasFlag` answers for the invocation's own arguments (before any `--`).
*/
export function deprecationNoticesSuppressed(hasFlag, env = process.env) {
return (INTERNAL_SOURCES.has(env.AKM_EVENT_SOURCE ?? "") || hasFlag("--help") || hasFlag("-h") || hasFlag("--scheduled"));
}
export function warnDeprecatedConfigKeys(raw, sourcePath) {
if (deprecationNoticesSuppressed((flag) => getParsedInvocation().hasFlag(flag)))
return;
const where = sourcePath ? ` (${sourcePath})` : "";
const improve = isPlainObject(raw.improve) ? raw.improve : {};
if (improve.strategies !== undefined || improve.qualityGate !== undefined) {
warnOnce("config:improve-learning-keys-deprecated", `\`improve.strategies\` and \`improve.qualityGate\` are Deprecated and are removed in 0.11: use \`experimental.learning.strategies\` and \`experimental.learning.qualityGate\`${where}. See STABILITY.md.`);
}
// Still deletes state rows in 0.10; 0.11 drops the key and nothing replaces it.
if (isPlainObject(improve.stateGc) && improve.stateGc.collect !== undefined) {
warnOnce("config:state-gc-collect-deprecated", `\`improve.stateGc.collect\` is Deprecated and is removed in 0.11, with no replacement${where}. See STABILITY.md.`);
}
const experimental = isPlainObject(raw.experimental) ? raw.experimental : {};
const learning = isPlainObject(experimental.learning) ? experimental.learning : {};
for (const [base, strategies] of [
["improve.strategies", improve.strategies],
["experimental.learning.strategies", learning.strategies],
]) {
if (!isPlainObject(strategies))
continue;
for (const [name, strategy] of Object.entries(strategies)) {
if (!isPlainObject(strategy))
continue;
if (strategy.limit !== undefined) {
warnOnce("config:strategy-limit-deprecated", `\`${base}.${name}.limit\` is Deprecated and is removed in 0.11: use \`--limit\` or \`processes.reflect.limit\`${where}. See STABILITY.md.`);
}
const processes = isPlainObject(strategy.processes) ? strategy.processes : {};
if (isPlainObject(processes.consolidate) && processes.consolidate.limit !== undefined) {
warnOnce("config:consolidate-limit-deprecated", `\`${base}.${name}.processes.consolidate.limit\` is Deprecated and is removed in 0.11; \`--limit\` and \`processes.reflect.limit\` stay${where}. See STABILITY.md.`);
}
}
}
}