import { kody } from 'kody:runtime' import { KODY_ID, OFFICIAL_PACKAGE_ID, PUBLIC_URL, tokenSetupUrl } from './helpers.ts' /** * After a community fork, call this first. * Returns owner-specific webhook + local config steps for your Raycast copy. * * @returns Adapt playbook (webhooks, config path, extension, publish) * * @example * import adapt from 'kody:@kody/raycast/adapt' * await adapt() */ export default async function adapt() { const listed = await kody.packageList({}) const packageId = listed.packages.find(pkg => pkg.kody_id === KODY_ID)?.package_id ?? OFFICIAL_PACKAGE_ID return { purpose: 'Point this forked Raycast package at minted webhooks on the owner account, write local launcher config, then add stored execute commands.', packageId, kodyId: KODY_ID, configPath: '~/.config/kody/raycast.json', extensionPath: 'extension/', ownerSettings: { webhooks: { required: ['list-commands', 'run'], optional: [ 'upsert-command', 'delete-command', 'list-packages', 'get-package', 'invoke', 'root', ], storage: 'local-file-or-raycast-preferences', note: 'Never paste minted webhook URLs into chat or commits.', }, optionalPackageApp: { setupExport: './setup-launcher-token', fields: ['apiBaseUrl', 'token'], note: 'Package apps need a Kody browser handoff; prefer webhooks for Raycast.', }, optionalInvocationToken: { setupUrl: tokenSetupUrl(packageId), note: 'Legacy HTTP invocation path for list-packages / get-package / invoke.', }, }, steps: [ { id: 'intent', title: 'Rewrite README ## Intent', detail: 'Describe how this fork will launch commands for the forking user.', }, { id: 'mint-webhooks', title: 'Mint list-commands and run webhooks', detail: 'Use webhookUrlMint (or the package webhooks UI) for list-commands and run on this fork. Do not disable live webhooks afterward.', }, { id: 'apply-webhooks', title: 'Apply webhook URLs to a private GitHub repo (optional)', detail: 'webhookUrlApply each handle to a repo the owner controls (integration of their choice) so a local machine can read config.url via gh api without pasting secrets into chat.', }, { id: 'local-config', title: 'Write ~/.config/kody/raycast.json', detail: 'On the owner machine, write listCommandsWebhookUrl + runWebhookUrl (mode 0600). Prefer file over Raycast preference paste when an agent can write the file.', }, { id: 'extension', title: 'Import extension/', detail: 'From extension/: npm install, then Raycast → Import Extension (or npm run dev). Open Kody Commands.', }, { id: 'commands', title: 'Add stored commands', detail: 'import upsertCommand from "kody:@YOU/raycast/upsert-command"; await upsertCommand({ title, description, icon, code })', }, { id: 'publish', title: 'Publish your fork', detail: 'Publish after README Intent matches this copy.', }, ], share: PUBLIC_URL, } }