ralph_workflow/json_parser/mod.rs
1//! JSON Stream Parsing Module
2//!
3//! Functions for parsing NDJSON (newline-delimited JSON)
4//! streams from Claude, Codex, Gemini, and `OpenCode` CLI tools.
5//!
6//! This module uses serde for JSON parsing, which is ~100x faster
7//! than spawning jq for each event.
8//!
9//! # Module Structure
10//!
11//! - [`types`] - Shared types and event structures
12//! - [`stream_classifier`] - Algorithmic detection of partial vs complete events
13//! - [`claude`] - Claude CLI output parser (with streaming support)
14//! - [`codex`] - `OpenAI` Codex CLI output parser (with streaming support)
15//! - [`gemini`] - Google Gemini CLI output parser (with streaming support)
16//! - [`opencode`] - `OpenCode` CLI output parser (with streaming support)
17//! - [`health`] - Parser health monitoring and graceful degradation
18//!
19//! # Streaming Support
20//!
21//! All parsers now support delta streaming for real-time content display:
22//! - **Claude**: Full streaming with `DeltaAccumulator` for text and thinking deltas
23//! - **Gemini**: Streaming with delta flag support for message content
24//! - **Codex**: Streaming for `agent_message` and reasoning item types
25//! - **`OpenCode`**: Streaming for text events
26//!
27//! In verbose mode, parsers show full accumulated content. In normal mode,
28//! they show real-time deltas for immediate feedback.
29//!
30//! ## Verbosity Levels
31//!
32//! The parsers respect the configured verbosity level:
33//! - **Quiet (0)**: Minimal output, aggressive truncation
34//! - **Normal (1)**: Balanced output with moderate truncation, shows real-time deltas
35//! - **Verbose (2)**: Default - shows more detail including tool inputs and full accumulated text
36//! - **Full (3)**: No truncation, show all content
37//! - **Debug (4)**: Maximum verbosity, includes raw JSON output
38
39pub mod claude;
40#[cfg(test)]
41mod claude_tests;
42pub mod codex;
43#[cfg(test)]
44mod codex_tests;
45pub mod deduplication;
46pub mod delta_display;
47mod event_queue;
48pub mod gemini;
49#[cfg(test)]
50mod gemini_tests;
51pub mod health;
52mod incremental_parser;
53pub mod opencode;
54#[cfg(test)]
55mod opencode_tests;
56pub mod printer;
57mod stream_classifier;
58pub mod streaming_state;
59pub mod terminal;
60pub mod types;
61
62pub use claude::ClaudeParser;
63pub use codex::CodexParser;
64pub use gemini::GeminiParser;
65pub use opencode::OpenCodeParser;
66
67#[cfg(test)]
68mod tests;