middleware()
Define middleware that wraps command execution with pre/post logic.
Import from maltty.
Signature
The TEnv type parameter declares environment requirements (e.g., which properties middleware adds to ctx).
Root vs command middleware
Root middleware runs for every command. Register on cli():
Command middleware runs only for a specific command:
Root middleware wraps command middleware, which wraps the handler (onion model).
decorateContext()
Add a typed, immutable property to a context instance at runtime. Used by middleware authors to extend ctx with custom properties.
Returns the same ctx reference. The property is non-writable and non-configurable after assignment. Pair with module augmentation on the Context interface for compile-time visibility.