Skip to content

Add Script Commands - #74

Open
nchudleigh wants to merge 2 commits into
typecraft-dev:mainfrom
nchudleigh:feat/script-commands
Open

nchudleigh wants to merge 2 commits into
typecraft-dev:mainfrom
nchudleigh:feat/script-commands

Conversation

@nchudleigh

Copy link
Copy Markdown

Executable scripts in ~/.config/omacast/script-commands/ now show up in root search, using Raycast's Script Commands headers (SPEC §9.9). For example, a "Switch Display" script with a dropdown of monitor inputs:

# @raycast.schemaVersion 1
# @raycast.title Switch Display
# @raycast.mode silent
# @raycast.argument1 { "type": "dropdown", "placeholder": "Input", "data": [{"title": "Mac mini", "value": "x0091"}, {"title": "MacBook Pro", "value": "x00d0"}] }

What works

  • core/ScriptCommands.js parses the headers: any comment style, keys in any case, argument1..3, currentDirectoryPath, needsConfirmation, and the package name defaulting to the folder name.
  • services/ScriptCommandSource.qml scans the folder each time the launcher opens. It keeps files that are executable, 1 byte to 2 MB, and have no .template. in the name, and reads only the first 60 lines.
  • services/ScriptRunner.qml runs the file under bash -lc from its folder, with $1..$3 and stdin closed.
  • Arguments use the existing pills. Dropdowns are new: ←/→ (or a click) cycles the options and typing is ignored. Password values show as dots.
  • silent closes the launcher and shows a HUD with the last output line. compact shows "Running…", then a toast, or a HUD if the launcher has closed. A failed run shows the last line of stderr.

Not in this PR

  • fullOutput and inline scripts run as compact. The output view and inline refresh can follow.
  • Emoji icons only; image-file icons get a terminal glyph.
  • No folder setting, and no Create or Reload commands.

Privacy (please check): script arguments are the one place user text reaches an argv, because $1..$3 is the Script Commands interface. This is noted in SPEC §9.9 and in the README's Privacy section.

Testing

  • node --test tests/*.test.js: 146 pass. tests/script-commands.test.js adds parser, argv, cycling and outcome tests, plus tests that run the real scan and runner shell snippets.
  • omarchy plugin validate . passes.
  • Tried on the live shell:
    • the script appears as a "Script Command" row;
    • ↵ with an empty dropdown focuses the pill, and → shows "‹ Alpha ›";
    • leaving out a required argument gives "Type a pick first";
    • a run shows its last line in the HUD, from the script's folder.

🤖 Generated with Claude Code

nchudleigh and others added 2 commits November 3, 2026 21:50
Executables in ~/.config/omacast/script-commands with Raycast's
@raycast.* headers become root-search commands (SPEC §9.9). Text,
password and dropdown arguments are pills; silent shows a HUD with the
last output line, compact a toast. fullOutput and inline run as compact
for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wait for both the exit and the end of output before reading the last
line, with stderr merged into stdout as Raycast reads it. Let the
runner's cd resolve currentDirectoryPath, and clear argument pills after
a compact run so a second ↵ starts fresh.

Co-Authored-By: Claude Opus 5.5 <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