Skip to content

Add Script Commands - #38

Open
amanmprojects wants to merge 1 commit into
typecraft-dev:mainfrom
amanmprojects:feat/script-commands
Open

amanmprojects wants to merge 1 commit into
typecraft-dev:mainfrom
amanmprojects:feat/script-commands

Conversation

@amanmprojects

@amanmprojects amanmprojects commented Oct 25, 2026 •

Copy link
Copy Markdown

Adds Raycast Script Commands (SPEC §9.9, ref 03 §5), part of Phase 2. Nothing is added to the shell's dependencies: scanning and running use bash, and the rest is QML/JS.

What it does

An executable script with @raycast.* header comments in ~/.config/oma-cast/script-commands becomes a root-search command. It gets frecency ranking, aliases, favourites and the disable action like any other command. Extra folders go in config.json as "scriptCommandDirectories": ["~/bin/raycast"].

  • Modes
    • compact: a running toast with Cancel on Ctrl+T, then the last line of output
    • silent: closes the launcher and shows the last line in the OSD
    • fullOutput: a view that streams the output; ↵ copies it, Ctrl+R runs the script again, Stop is in the action panel
    • inline: the first line is the row's subtitle, refreshed every refreshTime (at least 10 s)
  • Arguments: up to three (text, password, dropdown) as pills. Dropdowns step with ↑/↓ (the same stepOption as Quicklinks #8) and start on their first option. Passwords show as dots. percentEncoded is applied.
  • Header: the regex and keys from ref 03 §5. packageName defaults to the Title-Cased folder name, and currentDirectoryPath resolves against the script's folder. needsConfirmation uses the existing alert.
  • Built-ins:
    • Search Script Commands lists scripts by package, plus an "Invalid Scripts" section showing why a header was rejected.
    • Create Script Command takes title and mode pills, writes a template and opens it with omarchy-launch-editor.
    • Reload Script Commands rescans. oma-cast also rescans on every open.
  • Row actions: Edit Script (Ctrl+E) and Copy Path (Ctrl+Shift+C).
  • RPC: scriptCommands.getScripts|reload|runScript|cancelScript|getRun, named after Raycast's namespace.

Scripts run as bash -lc 'cd "$1"; shift; exec "$@"' with the script path and arguments as argv elements, so argument text never goes through a shell. LC_ALL is unset, as ref 03 §5 describes.

Design choices ([I]/[D] in comments)

  • Leaving a fullOutput view stops its script, since nothing else shows that output.
  • Background inline runs time out after 30 s.
  • Output kept per run is capped at 512 KB.
  • Icon URLs aren't fetched. An emoji becomes the row glyph, and an image path is resolved relative to the script.

Not included

ANSI colours in the output view (they're stripped), iconDark, and a settings page for the folders.

Testing

  • node --test tests/*.test.js: 121 pass. New tests in tests/script-commands.test.js cover header parsing, arguments, output handling, the template, and Search Script Commands sections and actions. One test also runs the real scan, run and create bash scripts against a temp folder.
  • omarchy plugin validate plugin passes. tests/smoke.sh passes (worst toggle 83 ms).
  • On Omarchy 4.5.0rc1 / Quickshell 0.3.2, with test scripts covering every mode:
    • checked through RPC: discovery, broken-header reporting, argument errors, confirmation, Create (including "already exists") and inline refresh
    • checked by screenshot: the pills, the list view and the streaming output view
  • Not checked by hand: the compact toast spinner and the new key bindings.

The code, tests and this description were written with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

Executable scripts with @raycast.* headers in ~/.config/oma-cast/script-commands
(plus config.json scriptCommandDirectories) become root-search commands, per
SPEC §9.9 and ref 03 §5.

- Modes: compact (running toast with Cancel, then the last line), silent (HUD),
  fullOutput (streamed output view: copy, run again, stop) and inline
  (first line as the subtitle, refreshed on refreshTime >= 10 s).
- Up to three text/password/dropdown arguments as pills; needsConfirmation
  uses the alert.
- Search / Create / Reload Script Commands built-ins; invalid headers are
  listed with the reason.
- RPC: scriptCommands.getScripts|reload|runScript|cancelScript|getRun.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant