Skip to content

refactor: replace LoadOptions.verbose with typed load events via OutputSink #166

@emesal

Description

@emesal

Context

LoadOptions.verbose currently gates two eprintln! calls inside Chibi::load_with_options (in chibi-core/src/chibi.rs):

  • [MCP: N tools loaded] on success
  • [MCP: bridge unavailable: {e}] on error

In chibi-cli/src/main.rs, a parallel block also guarded by the same flag prints:

  • [Built-in (N): ...]
  • [Plugins (N): ...] / [No plugins loaded]

These are bypassed for chibi-json (hardcoded verbose: false) and print directly to stderr, bypassing the OutputSink abstraction entirely.

Problem

This refactor moved presentation fields out of chibi-core's config and into clients. LoadOptions.verbose is an awkward remnant: it's a presentation concern that leaked into a load-time option struct, and it causes chibi-core to eprintln! directly rather than emitting typed events.

Two directions to consider:

Option A — Emit load events via OutputSink

load_with_options takes an &dyn OutputSink (or a callback) and emits typed CommandEvent variants for load-time diagnostics:

CommandEvent::McpToolsLoaded { count: usize }
CommandEvent::McpBridgeUnavailable { reason: String }
CommandEvent::BuiltinToolsLoaded { count: usize, names: Vec<String> }
CommandEvent::PluginsLoaded { count: usize, names: Vec<String> }

Clients filter/display as appropriate. verbose is removed from LoadOptions.

Pro: consistent with the rest of the refactor; typed, structured events available to all clients.
Con: OutputSink must exist before Chibi is constructed, which is currently the case in both clients — but worth confirming this is always true.

Option B — Treat as debug/trace output, not user-facing

These messages are developer/diagnostic output, not user-facing events. Suppress them entirely (or route to a proper tracing subscriber like tracing/log) rather than surfacing through OutputSink.

Pro: simpler, less surface area; keeps OutputSink for user-visible events only.
Con: verbose mode loses load-time diagnostics; tracing adds a dep.

Suggested resolution

Option A feels most consistent with the refactor direction. The chibi-cli post-load tool list prints should also move into a typed CommandEvent::LoadSummary { ... } variant emitted by load_with_options itself, rather than being in main.rs.

LoadOptions.verbose would then be removed entirely.

Related

  • Branch: refactor/typed-output-2602
  • This is Task 9 from the presentation layer refactor plan (docs/plans/2026-02-19-presentation-layer-refactor.md)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions