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
45 lines (44 loc) • 2.32 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/.
import { IMPROVE_ENGINE_PROCESSES } from "../../core/config/engine-semantics.js";
import { ConfigError } from "../../core/errors.js";
import { executionDefaultsOf } from "../../execution/source.js";
import { buildExecution, currentLayer, resolveExecution, shippedAlias } from "../../integrations/agent/execution.js";
/**
* Resolve improve-owned model work: `improve.connection` / `improve.harness`
* -> index.<pass> -> `improve.processes.<name>` -> the call's own settings ->
* the run's selection, nearest wins, over the default by name. A strategy adds no layer: it says which
* processes run, never where. `null` when no connection or harness is
* configured for it.
*/
export function resolveImproveExecution(options) {
const processKey = options.process ?? options.processName;
const processes = options.config.improve?.processes;
try {
const prepared = resolveExecution({
content: `improve ${options.processName} execution selection`,
config: options.config,
layers: [
shippedAlias(options.alias),
{ id: "improve", kind: "invocation-defaults", values: executionDefaultsOf(options.config.improve) },
{ id: "index", kind: "invocation-defaults", values: executionDefaultsOf(options.index) },
{
id: `improve.processes.${processKey}`,
kind: "invocation-defaults",
values: executionDefaultsOf(IMPROVE_ENGINE_PROCESSES.includes(processKey) ? processes?.[processKey] : undefined),
},
currentLayer(executionDefaultsOf(options.current)),
{ id: "run", kind: "current", values: executionDefaultsOf(options.run) },
],
modelWork: true,
});
const lowered = buildExecution(prepared.request, prepared.runner);
return Object.freeze({ runner: lowered.runner, notices: lowered.notices });
}
catch (error) {
if (error instanceof ConfigError && error.code === "LLM_NOT_CONFIGURED")
return null;
throw error;
}
}