akm docs

Programmatic API (akm-cli/api)

akm-cli is a CLI package. The one supported programmatic entry point is akm-cli/api, which exists so the akm plugins (OpenCode, Claude Code, ...) can do their automatic recall in-process instead of starting an akm process per prompt. Everything else in the package stays CLI-only: deep imports of akm-cli/dist/* are not an API, and the CLI is still the way to run every other command.

import { curate } from "akm-cli/api";

const text = await curate("deploy to prod", { limit: 4, type: "skill", format: "text" });

curate(query, options?)

function curate(
  query: string,
  options?: {
    limit?: number; type?: string; source?: string;
    filters?: { user?: string; agent?: string; run?: string; channel?: string };
    belief?: "all" | "current" | "historical";
    format?: "text" | "json";
  },
): Promise<string>;

Loading it

package.json exports maps akm-cli/api to dist/api.js under Bun and to dist/api-node.mjs under Node (which registers the loader hook for the package's embedded .md/.xml assets before loading dist/api.js), with dist/api.d.ts for types. akm-cli/package.json and akm-cli/dist/* are also exported, so a plugin can locate the akm bin with require.resolve("akm-cli/package.json") and published plugin versions that deep-import akm-cli/dist/commands/read/*.js keep working.

Stability

Evolving (see STABILITY.md): the export list only grows, and curate()'s parameters and result keep the contract above; the text it returns is the CLI's agent-shaped output and changes whenever that does. tests/contracts/api-surface.test.ts pins the export list.