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

68 lines (67 loc) • 3.3 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/. /** * Single registration point for every akm agent harness (#562, #1095). * * `HARNESS_REGISTRY` is the ONE source of truth. Each harness is a * self-contained folder (`./<id>/index.ts`) exporting its descriptor; the * config schema's platform enum, the built-in agent profiles, command * builders, setup choices and the docs table all derive from the array below. * * Adding a harness: create `./<id>/index.ts`, add its class here. Removing: * delete both. This module must stay free of runtime `core/config` imports * (config derives `VALID_HARNESS_IDS` from here). */ import { AiderHarness } from "./aider/index.js"; import { AmazonqHarness } from "./amazonq/index.js"; import { ClaudeHarness } from "./claude/index.js"; import { CodexHarness } from "./codex/index.js"; import { CopilotHarness } from "./copilot/index.js"; import { GeminiHarness } from "./gemini/index.js"; import { OpencodeHarness } from "./opencode/index.js"; import { OpenhandsHarness } from "./openhands/index.js"; import { PiHarness } from "./pi/index.js"; /** * The registered harnesses, with each entry keeping its literal `id` so that * `VALID_HARNESS_IDS` can stay a literal tuple (`HarnessId`, `z.enum(...)` and * the `platform` union all need the literal types). */ // Order is significant: VALID_HARNESS_IDS derives from this array and feeds the // committed JSON-schema enum order. The original [opencode, claude] prefix is // preserved so the pre-unification portion of the generated schema enum does not // reorder; the seven P2 harness adapters are appended after it, which extends the // enum additively (schemas/akm-config.json is regenerated in lockstep). const REGISTERED = [ new OpencodeHarness(), new ClaudeHarness(), new CodexHarness(), new CopilotHarness(), new PiHarness(), new GeminiHarness(), new AiderHarness(), new AmazonqHarness(), new OpenhandsHarness(), ]; /** The single registration point. */ export const HARNESS_REGISTRY = Object.freeze([...REGISTERED]); /** Lookup by the one supported harness id. */ export const HARNESS_BY_ID = new Map(HARNESS_REGISTRY.map((h) => [h.id, h])); /** * Canonical, ordered list of valid harness / platform ids. The Zod * `AgentPlatformSchema` enum, the harness platform union, and * setup's `DetectedHarness` union all derive from this so they cannot drift. */ export const VALID_HARNESS_IDS = Object.freeze(REGISTERED.map((h) => h.id)); /** The platforms a `harnesses` entry may name: every harness in the registry. */ export const HARNESS_CONFIG_PLATFORMS = VALID_HARNESS_IDS; /** Harnesses that expose readable native session logs. */ export const SESSION_LOG_HARNESSES = HARNESS_REGISTRY.filter((h) => h.sessionLogProvider !== undefined); /** Harness ids that can run a named native agent, so a harness may name a default `agent`. */ export const HARNESS_NATIVE_AGENT_IDS = new Set(HARNESS_REGISTRY.filter((h) => h.nativeAgent).map((h) => h.id)); /** * Resolve an exact harness id to its descriptor, or `undefined` if unknown. */ export function getHarness(id) { return HARNESS_BY_ID.get(id); }