4 KiB
HEX Custom Commands
This workspace configures literal custom voice commands for HEX. Run
bun run check after editing hex.config.ts. HEX reloads valid changes and
keeps the previous registry if evaluation or validation fails.
Config and dependencies execute as the current user with normal filesystem, network, environment, and subprocess access. This host is supervised, not sandboxed. Add only trusted packages and review commands before enabling them.
.hex-sdk is managed by HEX and provides the local @hex/commands package. Do
not edit it or replace it with an npm dependency. HEX refreshes the managed SDK
from the running app bundle on startup while preserving user-owned workspace
files and third-party dependencies.
- Import
defineHexConfigfrom@hex/commandsand userunwith the providedhexcapabilities for ordinary commands. - Import Effect APIs,
Hex, anddefineHexConfigfrom@hex/commands/effect. - Command keys are stable IDs. Phrases must not overlap a command whose context can coexist at the same specificity, or any protected native phrase.
dictationdeclaratively replaces the native streaming protocol.startphrases match only at the beginning while listening;stop,send, andcancelmatch only at the end while voice dictation is active. These are not handlers and are unavailable as ordinary commands.- Keep at least one phrase in every dictation control. Invalid or overlapping protocol changes are rejected together with command changes, preserving the last valid native snapshot.
whenaccepts exactly one ofapplicationorbrowserHost.- Without a
capturesschema, a phrase may end in one{name}placeholder, e.g."search amazon for {query}". It requires at least one spoken word before the placeholder and one or more words after the prefix; the normalized remainder arrives ascaptures.namein the handler (and on the EffectHexservice). Capture phrases requirerun; they cannot use a nativeaction. A capture phrase conflicts with any coexisting phrase that shares its literal prefix. - Import
digit,letter,choice,union, ortextto define typed captures.digit()accepts zero through nine;digit({ min, max })restricts that range. Digit captures may appear multiple times anywhere in every alias and arrive as numbers.choice(["left", "right"] as const)returns those exact strings;choice({ left: ["left", "back"], right: ["right", "forward"] } as const)normalizes spoken aliases to its canonical keys. Choice aliases are one word.letter()accepts literal, common spoken, and NATO alphabet names and returns the canonical lowercase"a" | ... | "z"letter.union(letter(), digit(), choice(["home", "end"] as const))composes bounded one-token captures and infers the union of their canonical values. Union members must not overlap;text()is not allowed in a union.text()arrives as a string and must be trailing. Every alias must bind every declared capture exactly once. Schema-bearing commands requirerun. - Capabilities are
openUrl,openApplication,openPath,press, andtypeText. openUrlopens absolute web URLs and app deep links such asslack://channel?team=T_EXAMPLE&id=C_EXAMPLEusing an installed macOS handler.openApplicationtakes an app name or path, not a deep link. UseopenPathfor files; file, inline-script, and data URLs are unsupported.- Structured native action descriptors are available for fixed single actions, but handlers are the clearest default and compose multiple capabilities.
- Effect
runaccepts an Effect value or a function that returns an Effect. - Context contains
application,browserHost,browserUrl, andwindowTitlewhen available. transformationsregisters named string functions. Selected transformations run after a mode's corrections and optional OpenCode rewrite. Return only the final transformed string; failures preserve the previous pipeline output.
See .agents/skills/personal-commands/SKILL.md for examples.