Core 把 UI 与 AI 交互拆成事件驱动的控制面
core/mod.rs 明确把 engine、events、ops、session、tool_parser、turn 分成独立模块,并在 TUI alt-screen 中禁止直接 print_stdout/print_stderr,要求通过 tracing 和事件通道输出。
终端画面只是一个事件消费者;真正决定模型、工具和会话怎么走的是 Core Engine。这样换成 Web、ACP 或测试宿主时,不必再复制一套 Agent Loop。
自研时应先定义 operation/event 契约,再让 TUI、HTTP 和自动化入口共享同一运行时;禁止 UI 层私自执行工具或改会话。
1 //! Core engine module for `DeepSeek` CLI.
2 //!
3 //! This module provides the event-driven architecture that separates
4 //! the UI from the AI interaction logic:
5 //!
6 //! - `engine`: The main engine that processes operations
7 //! - `events`: Events emitted by the engine to the UI
8 //! - `ops`: Operations submitted by the UI to the engine
9 //! - `session`: Session state management
10 //! - `turn`: Turn context and tracking
11
12 // Engine code runs inside the TUI alt-screen — see `runtime_log` for why
13 // raw stdio prints must not appear here. Use `tracing::*` instead.
14 #![deny(clippy::print_stdout)]
15 #![deny(clippy::print_stderr)]
查看全部 2 处证据
-
契约
crates/tui/src/core/mod.rs:1–15event-driven architecture 与 stdio 输出禁令。 -
实现
crates/tui/src/core/mod.rs:17–33engine/events/ops/session/turn 模块装配。