Console architecture
Two entries:
@jolly-pixel/console: the headlessCommandConsole. No DOM, no Lit.@jolly-pixel/console/element: the Litjolly-consoledialog.
The element imports the root, never the reverse. No instance is exported: each editor page creates one and passes it down.
Map
| Folder | Holds |
|---|---|
registry/ | Registry, NamespaceEntry, definitions, validation, ConsoleFeature |
input/ | tokenize, classify, coerce |
execution/ | bindArguments, variables, InputHistory, RevertStack, Scrollback, built-ins |
search/ | Suggestion, score, search, complete, browse, typo |
script/ | scanScript, VariableScript, ScriptDraft, highlightLine |
element/ | the three elements, KeyboardController, SuggestionController |
One keystroke
- An exact variable name wins over search.
completemay awaitautocomplete(). Each request is numbered; a late one is dropped.- Every result is a
Suggestionthat already holds the line and caret it leaves. - The list lives in the prompt shadow root so ARIA IDREFs resolve (ADR-0007).
Submitting a line
submit()never throws. Errors become error entries.- A returned promise keeps the echo pending until it settles.
ctx.signalaborts when the command is replaced or unregistered.
Reverting
RevertStackkeeps applied changes only.InputHistorycannot: it keeps no-op lines./revertpops newest first and skips a change whose address no longer resolves (ADR-0009).- A variable revert writes the previous value through
set, so mirrors need nothing more. - A mirrored command's revert stays in
ConsoleServerunder arevertId.
Scripts
parsediffs against the snapshot, so only edited lines are written.- Rollback and
/revertrestore whatget()returned just before each write. scanScriptfeeds both the parser andhighlightLine.- The editor is a transparent
textareaover a coloredpre, in one grid cell and one scroller. Nothing to sync, and native undo still works.
See ADR-0010.
Registration
- The last registration wins, for commands, variables and namespaces (ADR-0003).
- Namespaces are flat entries keyed by dotted address; parents with no registration of their own are derived (ADR-0011).
- A handle only removes the entry it created.
- Replacing or unregistering a command aborts its signal.
- Every change emits
registry-changed. registerConsoleFeaturesunregisters what it registered if a feature throws.
Scope
CommandConsolekeeps the scope as an address;scopewalks up to the nearest registered namespace.- The prompt reads through
scoped, aScopedRegistrythat tries<scope>.<name>first.registry, the mirror and the server always use full addresses (ADR-0012).
In an editor
The host owns the instance. A new command is a feature module plus one line in the editor's feature list.
API: CommandConsole, features, grammar, jolly-console, ADRs.