Skip to content
API reference

commands/slash

Import
import * as api from "@fungi.computer/parakeet/slash";
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”
Signature
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”
Signature
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”
Signature
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”
Signature
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”
Signature
type SlashWordItem = Readonly<{
word: WhistleSlashWord;
label: string;
matches: readonly number[];
insert: string;
}>;

One argument word offered after the alias.


SlashCompletiontype alias

Section titled “SlashCompletion”
Signature
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”
Signature
type FuzzyMatch = Readonly<{
tier: number;
spread: number;
indices: number[];
}>;

How well one candidate matched a query; lower tiers and spreads rank first.

Signature
function keyLabel(binding, mac?): string;

Human key labels from Whistle bindings, with the platform’s modifier name.

Parameter Type
binding string
mac boolean

string


slashRegistry()function

Section titled “slashRegistry()”
Signature
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.

Parameter Type
snapshot WhistleSnapshot

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()”
Signature
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.

Parameter Type
snapshot WhistleSnapshot

readonly Readonly<{ commandId: string; command: WhistleCommandKey; keys: string; title: string; order: number; }>[]


parseSlashDraft()function

Section titled “parseSlashDraft()”
Signature
function parseSlashDraft(registry, draft): SlashParse;

Parse one draft against the registry; only a leading / names a command.

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

SlashParse


fuzzyMatch()function

Section titled “fuzzyMatch()”
Signature
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.

Parameter Type
candidate string
query string

| Readonly<{ tier: number; spread: number; indices: number[]; }> | undefined


completeSlash()function

Section titled “completeSlash()”
Signature
function completeSlash(registry, draft, options?): SlashCompletion;

Rank completions for one draft; renderers draw exactly these rows.

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; }>

SlashCompletion