import { toSummary, upsertCommandRecord, type UpsertCommandInput, } from './commands-store.ts' /** * Create or replace a Raycast execute command in package storage. * Agents: call this when the user asks for a new Raycast command. * * @param input.title - List title in Raycast * @param input.description - Subtitle / help text * @param input.icon - Raycast Icon key (e.g. "Hammer") or emoji * @param input.code - ESM module with `export default async function main(params)` * @param input.id - Stable id (kebab-case); defaults from title * @returns The saved command summary (code omitted) plus id * * @example * import upsertCommand from 'kody:@kody/raycast/upsert-command' * await upsertCommand({ * title: 'List my Kody packages', * description: 'Smoke: list-packages via execute', * icon: 'Box', * code: `import listPackages from 'kody:@kody/raycast/list-packages' * export default async function main() { * return await listPackages() * }`, * }) */ export default async function upsertCommand(input: UpsertCommandInput) { const command = await upsertCommandRecord(input) return { ok: true as const, command: toSummary(command), id: command.id } }