Skip to main content

sqlite_graphrag/output/
mod.rs

1//! Single point of terminal I/O for the CLI (stdout JSON, stderr human).
2//!
3//! All user-visible output must go through this module; direct `println!` in
4//! other modules is forbidden.
5//!
6//! Split by responsibility (GAP-SG-146), roughly in order of how structured
7//! the output is:
8//!
9//! * `envelope` — complete JSON payloads, and the single point where the
10//!   agent-native reshaping surface is applied
11//! * `error_envelope` — failure payloads, with a serializer-free fallback
12//! * `stream` — NDJSON, one record per line, under the GAP-SG-215 stream
13//!   contract: per-record knobs only, and the `agent_surface` record on the
14//!   trailer rather than on every line
15//! * `passthrough` — plain text and verbatim bytes, no JSON at all
16//! * `human` — stderr diagnostics via `tracing`
17//! * `sink` — the one place bytes actually reach stdout
18//! * [`format`] — `--format` value enums
19//! * `responses` — the serializable payload types themselves
20//!
21//! Every public item is re-exported here, so `crate::output::emit_json` and
22//! friends keep working unchanged; callers never name a submodule.
23
24mod envelope;
25mod error_envelope;
26mod format;
27mod human;
28mod passthrough;
29mod responses;
30mod sink;
31mod stream;
32
33#[cfg(test)]
34mod tests;
35
36pub use envelope::{emit_json, emit_json_compact};
37pub use error_envelope::{emit_error_json, emit_error_json_with_suggestion};
38pub use format::{JsonOutputFormat, OutputFormat};
39pub use human::{emit_error, emit_error_i18n, emit_progress, emit_progress_i18n};
40pub use passthrough::{emit_raw, emit_text};
41pub use responses::{RecallItem, RecallResponse, RememberResponse};
42pub use stream::{emit_json_line, emit_stream_record, emit_stream_trailer};