Skip to content
BaruchEricPublic

About

CLI to drive Raycast — fire deeplinks, read on-disk state, manage script commands, and author extensions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

rayc

A dependency-free, agent-native CLI that drives Raycast from the terminal — fire deeplinks, read on-disk state, scaffold Script Commands, and wrap the official ray extension CLI, with stable exit codes and --json/--print output.

TL;DR

  • What: a single-binary CLI wrapper around Raycast's deeplink scheme and on-disk state, plus a thin passthrough to Raycast's own ray extension tooling.
  • How: builds raycast://… URLs and fires them via macOS open; reads extension manifests and prefs straight off disk; never touches Raycast's encrypted stores.
  • Stack: Bun + TypeScript, zero runtime dependencies (Node stdlib + Bun APIs only). macOS only.
  • Agent-friendly: every trigger action has a --print dry run, list commands emit --json, and exit codes are stable (0/1/2) — see AGENTS.md.
  • Run: bun install && bun link, then rayc doctor.

Overview

rayc gives you terminal (and script/agent) access to Raycast across four pillars:

Pillar Commands
Trigger actions open, link, ai, run, shortcut
Read data (unencrypted only) list extensions, list scripts, list prefs
Script Commands script new, script list, script install
Extension authoring ext new, ext dev/build/lint/publish/migrate, ray-install
Diagnostics doctor, help, version

Deeplink paths use the schema <author-or-owner>/<extension>/<command> (exactly 3 segments); built-in commands use raycast as the author. The reliable workflow is discover → preview → fire: enumerate exact deeplinks with rayc list extensions --json, preview with --print, then fire.

Two honest constraints are baked in:

  • Encrypted stores are off-limits. Raycast's clipboard history, snippets, and activity log live in OpenPGP-encrypted SQLite (raycast-enc.sqlite, …). No external tool can read them, and rayc never pretends to — it only surfaces what is genuinely in the clear.
  • open exits 0 on handoff, not on success. macOS open returns 0 the moment it hands a URL to Raycast, even for a bogus slug (a silent no-op). Validate slugs against list extensions or eyeball with --print first.

Tech stack

  • Runtime: Bun — the rayc shebang is #!/usr/bin/env bun; process spawning uses Bun.spawnSync.
  • Language: TypeScript 5, strict mode, ESNext modules, moduleResolution: bundler, .ts imports allowed.
  • Dependencies: none at runtime. Everything imports from the Node stdlib (node:fs, node:os, node:path) plus Bun globals. Dev deps are only typescript and @types/bun.
  • Platform: macOS only — it shells out to open, defaults, and Raycast's ~/.config/raycast / ~/Library/Application Support/com.raycast.macos paths.

Getting started

Install

cd dev-tools/rayc
bun install
bun link            # puts `rayc` on PATH via ~/.bun/bin
rayc doctor         # sanity-check Raycast, bun, ray, config dirs, and what's readable

To ship a standalone binary instead of the linked source entry:

bun run build       # bun build src/index.ts --compile --outfile dist/rayc
./dist/rayc doctor

Run

# Discover, then fire (the safe loop)
rayc list extensions --json                          # exact deeplinks for installed extensions
rayc open gebeto/translate/quick-translate --arg text="hola" --print   # preview the URL
rayc open gebeto/translate/quick-translate --arg text="hola"           # actually fire it

rayc link "raycast://confetti"                       # raw deeplink escape hatch
rayc run confetti                                    # fire a saved shortcut
rayc shortcut add cliphist "raycast://extensions/raycast/clipboard-history/clipboard-history"

rayc list prefs                                      # preferences, secrets redacted aggressively
rayc script new deploy --lang bash --mode compact    # scaffold a Script Command with @raycast.* header
rayc ext new                                         # scaffold an extension (bun create raycast-extension)

Trigger-action flags: --print (dry run — build/print the URL, fire nothing), --background (launchType=background), --fallback TEXT, --context JSON (must be valid JSON or exit 2), and repeatable --arg k=v. Boolean flags stand alone; every other flag takes a value (--flag value or --flag=value).

Env vars

  • RAYC_AI_COMMAND — override the built-in Raycast AI command slug used by rayc ai (the default raycast/raycast-ai-chat/ai-chat is version-dependent and unverified; --command <author/ext/cmd> overrides it inline). rayc ai is experimental and requires Raycast Pro.

No other environment configuration is required.

Scripts

Script Command What it does
typecheck tsc --noEmit Type-check the source without emitting.
build bun build src/index.ts --compile --outfile dist/rayc Compile a standalone single-file binary to dist/rayc.

There is no test suite, lint step, or bundler config beyond these two scripts.

Architecture

Single small entry point with a flat command dispatch table; each command is its own module, and shared logic lives in three lib files.

src/
  index.ts            # arg[0] → handler dispatch table, --help/--version, exit-code plumbing
  commands/
    open.ts           # open / link / ai / run / shortcut (trigger actions + shortcuts.json CRUD)
    list.ts           # list extensions | scripts | prefs (reads on-disk state, --json/--filter)
    script.ts         # script new | list | install (scaffold + manage Script Commands)
    ext.ts            # ext new|dev|build|lint|publish|migrate + ray-install (wraps `ray`)
    doctor.ts         # environment + readability diagnostics
  lib/
    args.ts           # dependency-free flag parser (booleans stand alone; others take values; `--` ends flags)
    deeplink.ts       # buildCommandDeeplink() assembles URLs; fire() runs `open <url>`
    raycast.ts        # Raycast paths, scanExtensions()/scanScripts(), run()/which(), secret redaction

Key behaviors:

  • Deeplinks are built by buildCommandDeeplink (validates the 3-segment path, URL-encodes each segment, appends launchType/arguments/context/fallbackText) and fired by fire via open.
  • On-disk reads are pure filesystem scans: extension manifests under ~/.config/raycast/extensions, Script Command @raycast.* header metadata, and defaults read com.raycast.macos for prefs — the last passed through redactSecrets (masks token/secret/password/api-key patterns and any 32+ char opaque blob).
  • ext * maps verbs to the official ray CLI and runs it in-place, requiring a directory whose package.json depends on @raycast/api; it prefers a global ray, falling back to npx ray.

Files rayc writes: ~/.config/rayc/shortcuts.json (named-shortcut map) and ~/.config/raycast/scripts/ (managed Script Commands — register that directory once in Raycast → Settings → Extensions → Script Commands → Add Directories).

Exit codes (stable — branch on them): 0 success/handoff, 1 runtime error, 2 usage error.

Status

Version 0.1.0, macOS only, MIT © Eric Baruch. All five command pillars are implemented and functional. Known rough edges, both documented in-tool: rayc ai is experimental (needs Raycast Pro; the AI slug is unverified), and open returning 0 is a handoff, not proof the command ran. There is no automated test suite. See AGENTS.md for the full agent-facing contract.

License

MIT © Eric Baruch

About

CLI to drive Raycast — fire deeplinks, read on-disk state, manage script commands, and author extensions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages