Expand description
The slash-command parser/dispatcher — DOC-50 §5 Slice 7, §6 Q4 (“mixed routing”).
Why: DOC-50 §6 Q4 resolves slash-command handling as a split: a small,
fixed set of client-side built-ins (/help, /clear, /quit//exit)
that never reach a product’s crate::engine::TuiEngine, and every
other slash command (domain commands like /model, /workstream, plus
any command this crate has never heard of) forwarded verbatim to
TuiEngine::handle_input — “the client does NOT interpret domain
commands” (thin-client axiom, DOC-39 §2.1 C-1/C-2). This module is where
that split is decided. It replaces tagent’s monolithic
try_handle_slash/SLASH_COMMANDS (crates/trusty-agents/src/repl/*.rs,
crates/trusty-agents/src/repl/tui/helpers.rs:156-181), which mixed
generic commands with tagent-specific ones and carried no routing
metadata at all.
What: three pieces.
route— pure, engine-free: given a submitted line, decideRoute::BuiltInorRoute::Forward. Only needs the fixedbuilt_in_commandstable, socrate::app::ReplApp::submit_line(which has no engine handle — seecrate::app::reduce’s module doc comment) can call it directly and apply a built-in’s effect inline (Route::BuiltIn(BuiltIn::Clear)reusescrate::app::ReplApp::clear_scrollback, the same effectReplEvent::ClearScrollbackproduces).resolve_forward/compose_selection— the picker half (DOC-50 §3.2/Q6): a bare/name(no args)Route::Forwardline whose name matchesTuiEngine::picker(name)opens an inline picker instead of reachinghandle_input; confirming a picker item resubmits"{dispatch_command} {selected.id}". These DO need engine access, so they’re free functions a product’s async event-loop wiring calls (rather than living inside the synccrate::app::reduce::applyreducer, which cannot reach aTuiEngine— see that module’s doc comment).dispatch_forward— composes the two into the actual integration point: given aRoute::Forwardline staged incrate::app::ReplApp::pending_submit, either opens a picker or callsengine.handle_input.
§Spec References
SPEC-TTUI-05~draft— Slice 7 deliverable (§5, Slice 7) and Q4 (mixed routing), Q6 (inline pickers).
Enums§
- BuiltIn
- The effect of a recognized built-in command — applied directly by
crate::app::ReplApp::submit_line, never round-tripped throughTuiEngine. - Forward
- What the caller should do with a
Route::Forwardline. - Route
- Where a submitted line should route (DOC-50 §6 Q4).
Functions§
- built_
in_ commands - The fixed, client-side built-in command table (DOC-50 §6 Q4) — never
forwarded to
TuiEngine::handle_input. - compose_
selection - Compose the line to resubmit when the user confirms
selectedfromrequest(DOC-50 §3.2PickerRequestcontract:"{dispatch_command} {selected.id}"). - dispatch_
forward - The
Route::Forwardhalf of the dispatch pipeline: resolve a picker or callengine.handle_input. - render_
help - Render
/help’s output: the built-ins plus every engine-supplied command, one line each, then the key bindings. - resolve_
forward - Resolve a
Route::Forwardline againstengine: does it open a picker, or does it genuinely needhandle_input? - route
- Classify one submitted line per DOC-50 §6 Q4’s mixed-routing model.