commands/slash
Import
Section titled “Import”import * as api from "@fungi.computer/parakeet/slash";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| type alias | SlashCommand | One slash command as every Parakeet renderer lists it. |
| type alias | KeyBindingRow | One key binding as help and hint surfaces list it. |
| type alias | SlashParse | How one composer draft maps to a command. |
| type alias | SlashCommandItem | One command offered while the alias is being typed. |
| type alias | SlashWordItem | One argument word offered after the alias. |
| type alias | SlashCompletion | What a composer shows for the current draft. |
| type alias | FuzzyMatch | How well one candidate matched a query; lower tiers and spreads rank first. |
| function | keyLabel() | Human key labels from Whistle bindings, with the platform’s modifier name. |
| function | slashRegistry() | Every slash alias in the live graph, with the keys bound to its command. |
| function | keyBindings() | Every bound key in the live graph, grouped by command. |
| function | parseSlashDraft() | Parse one draft against the registry; only a leading / names a command. |
| function | fuzzyMatch() | Fuzzy match: a prefix beats a word start beats a substring beats an in-order subsequence; tighter subsequences rank first. |
| function | completeSlash() | Rank completions for one draft; renderers draw exactly these rows. |
SlashCommandtype alias
Section titled “SlashCommand”type SlashCommand = Readonly<{ alias: string; commandId: string; command: WhistleCommandKey; consumesDraft?: boolean; title: string; description?: string; category: string; order: number; grammar?: WhistleSlashArguments; keys: readonly string[]; availability: WhistleAvailability;}>;One slash command as every Parakeet renderer lists it.
KeyBindingRowtype alias
Section titled “KeyBindingRow”type KeyBindingRow = Readonly<{ commandId: string; command: WhistleCommandKey; keys: string; title: string; order: number;}>;One key binding as help and hint surfaces list it.
SlashParsetype alias
Section titled “SlashParse”type SlashParse = | Readonly<{ kind: "prompt"; }> | Readonly<{ kind: "command"; command: SlashCommand; arguments?: WhistleJsonObject; requestIdField?: string; }> | Readonly<{ kind: "invalid"; message: string; }>;How one composer draft maps to a command.
SlashCommandItemtype alias
Section titled “SlashCommandItem”type SlashCommandItem = Readonly<{ command: SlashCommand; label: string; matches: readonly number[]; insert: string;}>;One command offered while the alias is being typed.
SlashWordItemtype alias
Section titled “SlashWordItem”type SlashWordItem = Readonly<{ word: WhistleSlashWord; label: string; matches: readonly number[]; insert: string;}>;One argument word offered after the alias.
SlashCompletiontype alias
Section titled “SlashCompletion”type SlashCompletion = | Readonly<{ kind: "none"; }> | Readonly<{ kind: "commands"; query: string; items: readonly SlashCommandItem[]; }> | Readonly<{ kind: "arguments"; command: SlashCommand; query: string; hint: string; items: readonly SlashWordItem[]; }>;What a composer shows for the current draft.
FuzzyMatchtype alias
Section titled “FuzzyMatch”type FuzzyMatch = Readonly<{ tier: number; spread: number; indices: number[];}>;How well one candidate matched a query; lower tiers and spreads rank first.
keyLabel()function
Section titled “keyLabel()”function keyLabel(binding, mac?): string;Human key labels from Whistle bindings, with the platform’s modifier name.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
binding |
string |
mac |
boolean |
Returns
Section titled “Returns”string
slashRegistry()function
Section titled “slashRegistry()”function slashRegistry(snapshot): readonly Readonly<{ alias: string; commandId: string; command: WhistleCommandKey; consumesDraft?: boolean; title: string; description?: string; category: string; order: number; grammar?: { hint: string; words?: readonly object[]; text?: { field: string; arguments: { [key: string]: | string | number | boolean | readonly string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | ... 4 more ... | null)[] | { ...; } | null)[] | { ...; } | null)[] | { ...; } | ...[] | { [key: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | ... 4 more ... | null)[] | { ...; } | null)[] | { ...; } | null)[] | { ...; } | ...; } | null; }; requestIdField?: string; }; }; keys: readonly string[]; availability: WhistleAvailability;}>[];Every slash alias in the live graph, with the keys bound to its command.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
snapshot |
WhistleSnapshot |
Returns
Section titled “Returns”readonly Readonly<{ alias: string; commandId: string; command:
WhistleCommandKey; consumesDraft?: boolean; title: string;
description?: string; category: string; order: number; grammar?:
{ hint: string; words?: readonly object[]; text?: { field:
string; arguments: { [key: string]: | string | number |
boolean | readonly string | number | boolean | readonly (string | number
| boolean | readonly (string | number | boolean | readonly (string |
number | boolean | readonly (string | number | boolean | readonly (string
| number | boolean | readonly (string | … 4 more … | null)[] | {
…; } | null)[] | { …; } | null)[] | { …; } | …[] | {
[key: string]: string | number | boolean | readonly (string | number
| boolean | readonly (string | number | boolean | readonly (string |
number | boolean | readonly (string | number | boolean | readonly (string
| number | boolean | readonly (string | … 4 more … | null)[] | {
…; } | null)[] | { …; } | null)[] | { …; } | …; } |
null; }; requestIdField?: string; }; }; keys: readonly string[];
availability: WhistleAvailability; }>[]
keyBindings()function
Section titled “keyBindings()”function keyBindings(snapshot): readonly Readonly<{ commandId: string; command: WhistleCommandKey; keys: string; title: string; order: number;}>[];Every bound key in the live graph, grouped by command.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
snapshot |
WhistleSnapshot |
Returns
Section titled “Returns”readonly Readonly<{ commandId: string; command: WhistleCommandKey;
keys: string; title: string; order: number; }>[]
parseSlashDraft()function
Section titled “parseSlashDraft()”function parseSlashDraft(registry, draft): SlashParse;Parse one draft against the registry; only a leading / names a command.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
registry |
readonly Readonly<{ alias: string; commandId: string; command: WhistleCommandKey; consumesDraft?: boolean; title: string; description?: string; category: string; order: number; grammar?: { hint: string; words?: readonly object[]; text?: { field: string; arguments: { [key: string]: | string | number | boolean | readonly string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | … 4 more … | null)[] | { …; } | null)[] | { …; } | null)[] | { …; } | …[] | { [key: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | … 4 more … | null)[] | { …; } | null)[] | { …; } | null)[] | { …; } | …; } | null; }; requestIdField?: string; }; }; keys: readonly string[]; availability: WhistleAvailability; }>[] |
draft |
string |
Returns
Section titled “Returns”fuzzyMatch()function
Section titled “fuzzyMatch()”function fuzzyMatch( candidate, query,): | Readonly<{ tier: number; spread: number; indices: number[]; }> | undefined;Fuzzy match: a prefix beats a word start beats a substring beats an in-order subsequence; tighter subsequences rank first.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
candidate |
string |
query |
string |
Returns
Section titled “Returns”| Readonly<{ tier: number; spread: number; indices: number[];
}> | undefined
completeSlash()function
Section titled “completeSlash()”function completeSlash(registry, draft, options?): SlashCompletion;Rank completions for one draft; renderers draw exactly these rows.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
registry |
readonly Readonly<{ alias: string; commandId: string; command: WhistleCommandKey; consumesDraft?: boolean; title: string; description?: string; category: string; order: number; grammar?: { hint: string; words?: readonly object[]; text?: { field: string; arguments: { [key: string]: | string | number | boolean | readonly string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | … 4 more … | null)[] | { …; } | null)[] | { …; } | null)[] | { …; } | …[] | { [key: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | … 4 more … | null)[] | { …; } | null)[] | { …; } | null)[] | { …; } | …; } | null; }; requestIdField?: string; }; }; keys: readonly string[]; availability: WhistleAvailability; }>[] |
draft |
string |
options |
Readonly<{ idleCategory?: string; }> |