← Public packages
@kentcdodds/raycast
Raycast launcher: stored execute commands via webhooks (canonical; do not use raycast-shortcuts).
src/upsert-command.ts
33 lines · 1.2 KB · TypeScriptimport {
toSummary,
upsertCommandRecord,
type UpsertCommandInput,
} from './commands-store.ts'
/**
* Create or replace a Raycast execute command in package storage.
* Agents: call this when Kent 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:@kentcdodds/raycast/upsert-command'
* await upsertCommand({
* title: 'Ping Discord #general',
* description: 'Post a test message',
* icon: 'SpeechBubble',
* code: `import { kody } from 'kody:runtime'
* export default async function main() {
* return await kody.search({ query: 'discord post message' })
* }`,
* })
*/
export default async function upsertCommand(input: UpsertCommandInput) {
const command = await upsertCommandRecord(input)
return { ok: true as const, command: toSummary(command), id: command.id }
}