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
33 lines (32 loc) • 1.37 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/.
/**
* Backend selection for the OS-native scheduler.
*
* • Linux → crontab
* • macOS → launchd (per-user LaunchAgent)
* • Windows → schtasks.exe / Task Scheduler
*
* Each backend implements {@link SchedulerBackend}; selection is a one-line
* platform check. Tests inject a fake `platform` to exercise non-host
* code paths.
*/
import { backendNameForPlatform } from "../../core/platform.js";
import { CRON_BACKEND } from "./cron.js";
import { LAUNCHD_BACKEND } from "./launchd.js";
import { SCHTASKS_BACKEND } from "./schtasks.js";
// Tests inject a fake `SchedulerBackend` directly via the `deps.backend` parameter
// the `akm task` mutation entries accept (the backend carries its own
// `name`), so no module-level override binding is needed. `selectBackend`'s
// `options.platform` steers the platform.
export function selectBackend(options = {}) {
switch (backendNameForPlatform(options.platform)) {
case "schtasks":
return SCHTASKS_BACKEND(options.schtasks);
case "launchd":
return LAUNCHD_BACKEND(options.launchd);
default:
return CRON_BACKEND(options.cron);
}
}