Skip to main content

Overview

SuperCmd uses compiled Swift binaries for macOS-specific features that require low-level system access. These native modules run as separate processes and communicate with the main Electron process via stdout/stdin or IPC.
All native modules live in src/native/ and are compiled to standalone executables during the build process. They are unpacked from the asar archive for execution.

Architecture

Native modules follow a consistent architecture:
1

Compilation

Swift source files are compiled to native binaries using swiftc
2

Distribution

Binaries are placed in dist/native/ and unpacked from app.asar
3

Execution

Main process spawns binaries as child processes
4

Communication

JSON messages are exchanged via stdout/stdin

Binary Resolution

SuperCmd resolves native binary paths with asar awareness:

Snippet Expander

Purpose

Monitors keyboard input and detects snippet keywords in real-time.

Implementation

Features

  • Tracks a sliding window of typed characters
  • Matches longest keywords first
  • Supports custom delimiter characters
  • Ignores modifier key combinations (Cmd, Ctrl, Alt)

Hotkey Hold Monitor

Purpose

Monitors a specific key combination and emits events when pressed and released.

Implementation

Features

Precise Modifier Detection

Tracks exact modifier key states (Cmd, Ctrl, Alt, Shift, Fn)

Release Reasons

Distinguishes between key-up, modifier-up, and flags-changed events

Low Latency

Direct event tap at kernel level for minimal delay

Process Termination

Exits automatically when key is released

Speech Recognizer

Purpose

Real-time speech-to-text using Apple’s Speech framework.

Implementation

Integration

Window Management

Window Adjustment

Native Swift module for precise window positioning:

Color Picker

Native color picker using NSColorPanel:

Permissions Management

Native modules require various macOS permissions:

Building Native Modules

Native modules are compiled during the build process:

Build Configuration

In package.json:

Error Handling

Native modules use consistent error reporting:

Best Practices

  • Always clean up child processes on app quit
  • Implement restart logic for crashed processes
  • Use stdout buffering for reliable message parsing
  • Set appropriate timeouts for long-running operations
  • Request permissions gracefully with user prompts
  • Provide clear error messages when permissions are denied
  • Check permission status before spawning processes
  • Guide users to System Settings when needed
  • Spawn processes only when needed
  • Reuse long-running processes when possible
  • Use event taps at appropriate levels (HID vs Session)
  • Minimize JSON parsing overhead

See Also

Extension Runtime

Learn about extension execution

Electron Architecture

Understand the main/renderer process model

Raycast API

API compatibility reference