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

45 lines (44 loc) • 2.07 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/. import { SHIPPED_ALIAS } from "../core/config/model-aliases.js"; import { ConfigError } from "../core/errors.js"; import { executionDefaultsOf } from "../execution/source.js"; import { buildExecution, resolveExecution, shippedAlias } from "../integrations/agent/execution.js"; const NO_LOWERING_NOTICES = Object.freeze([]); /** * Resolve standalone index passes from the index section only (the index-wide * settings, then the pass's own). Improve strategies own improve-triggered calls * and are intentionally not consulted. No runner when the pass is off or no * connection or harness is configured. */ export function resolveIndexPassExecution(passName, config) { const pass = config.index?.[passName]; if (pass?.enabled === false) return Object.freeze({ runner: undefined, notices: NO_LOWERING_NOTICES }); try { // Under the model-work tool policy: confined where the harness can be, unrestricted (with a notice) elsewhere. const prepared = resolveExecution({ content: "", config, layers: [ shippedAlias(SHIPPED_ALIAS.index), { id: "index", kind: "invocation-defaults", values: executionDefaultsOf(config.index), }, { id: `index.${passName}`, kind: "invocation-defaults", values: executionDefaultsOf(pass) }, ], 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 Object.freeze({ runner: undefined, notices: NO_LOWERING_NOTICES }); } throw error; } }