Architecture
Package boundaries
Section titled “Package boundaries”| Package | Purpose |
|---|---|
Repl.Core | Dependency-free authoring/runtime core: routing, parsing, binding, output pipeline, CoreReplApp, IReplMap, Results.* |
Repl.Defaults | DI-enabled facade (ReplApp), lifecycle orchestration, default composition profiles (UseDefaultInteractive, UseCliProfile, UseEmbeddedConsoleProfile) |
Repl | Meta-package — bundles Core + Defaults + Protocol. Start here. |
Repl.Protocol | Machine-readable contracts: help schemas, error contracts, minimal MCP manifest types |
Repl.WebSocket | WebSocket transport for hosted sessions (ReplWebSocketSession over StreamedReplHost) |
Repl.Telnet | Telnet session protocol (framing, NAWS and terminal-type negotiation) over a WebSocket, a Stream or an IDuplexPipe |
Repl.Remote | Remote administration of a running process: wire contracts, named-pipe listener, console and one-shot clients |
Repl.Remote.Defaults | Connects Repl.Remote to a ReplApp through ReplAppRemoteBackend |
Repl.Spectre | Spectre.Console integration: rich prompts, renderables, IAnsiConsole DI injection |
Repl.Mcp | MCP server: UseMcpServer(), tool/resource/prompt mapping, MCP Apps, transport factory |
Repl.Testing | In-memory multi-session test harness: ReplTestHost, ReplSessionHandle, typed results/events |
Layering
Section titled “Layering”Repl.Core has no dependencies outside the .NET BCL. Integration packages depend on Core but not on each other, so you pick what you need. The remote pair is the one exception: Repl.Remote depends on nothing in Repl, and Repl.Remote.Defaults connects it to Repl.Defaults.
Execution pipeline
Section titled “Execution pipeline”- Parse — route matched, parameters bound and validated against constraints
- Middleware — the ordered pipeline registered with
app.Use(...)(auth, logging, tracing, etc.) - Dispatch — handler invoked via DI
- Output — return value passed to the output transformer for the active channel
- Render — formatter (text/JSON/YAML/XML/Spectre) writes to the channel’s output stream
Pipelines & Integration lists the twelve stages behind these phases, including the help and completion short-circuit and the exit code.
Channel model
Section titled “Channel model”A channel is the transport through which a session runs. The same command graph is executed on all channels. Each channel implementation adapts input/output to its transport protocol.
Custom transports use StreamedReplHost: it writes to a TextWriter, receives text through EnqueueInput, and runs a session with RunSessionAsync. The built-in Repl.WebSocket and Repl.Telnet packages are examples — SSH, named pipes, TCP sockets, or gRPC streams fit the same model.
Key abstractions
Section titled “Key abstractions”| Type | Role |
|---|---|
IReplMap | Registration interface — Map(...), Context(...), AutomationHidden(), AsResource() |
IReplApp | Runtime interface — Run(args) |
IReplInteractionChannel | Prompt/progress channel injected into handlers — namespace Repl.Interaction |
ITerminalInfo | Session metadata (window size, ANSI capabilities) — namespace Repl.Interaction |
IReplIoContext | Active I/O context (Output, Error, IsHostedSession, …) |
Results | Semantic return helpers — Results.Success(msg), Results.Error(code, msg), Results.Cancelled(msg) |
Result-flow paging
Section titled “Result-flow paging”First-class paging contracts (IReplPageSource<T>, ReplPage<T>) sit in the Output phase above, at stage 10 (Result Processing) of the full pipeline. The integrated terminal pager, the JSON page envelope ($type: "page"), and the MCP _replCursor/_replPageSize inputs are all driven from this layer — the same handler code works across all output formats.
→ Result-Flow Paging · Cursor Patterns
Source
Section titled “Source”Full architecture documentation (with diagrams): docs/architecture.md in the source repository.