| Crates.io | claude-parser |
| lib.rs | claude-parser |
| version | 1.0.5 |
| created_at | 2025-06-30 16:43:30.654713+00 |
| updated_at | 2025-07-02 20:43:38.814963+00 |
| description | Claude Code CLI stream-JSON parser for ruv-swarm multi-agent orchestration |
| homepage | https://github.com/ruvnet/ruv-FANN/tree/main/ruv-swarm |
| repository | https://github.com/ruvnet/ruv-FANN |
| max_upload_size | |
| id | 1732089 |
| size | 86,762 |
A high-performance stream-JSON parser for Claude Code CLI output, designed for benchmarking and training data collection.
Stream Event Parsing: Supports all Claude event types:
message_start, message_stopcontent_block_start, content_block_delta, content_block_stoptool_use, function_resultthinkingerrorusagePerformance Metrics Extraction:
Error Handling: Robust error recovery with detailed tracking of error types and recovery strategies
Export Functionality: Export parsed data for training in JSON or JSONL format
use claude_parser::ClaudeStreamParser;
use tokio::fs::File;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create parser
let mut parser = ClaudeStreamParser::new();
// Parse stream from file
let file = File::open("claude_output.jsonl").await?;
let metrics = parser.parse_stream(file).await?;
// Access performance metrics
println!("Total duration: {:?}", metrics.total_duration);
println!("Tool invocations: {}", metrics.tool_invocations.len());
println!("Total tokens: {}", metrics.token_usage.total_tokens);
// Export training data
let export = parser.export_training_data();
export.to_json_file("training_data.json").await?;
Ok(())
}
This parser is designed to work with the RUV-SWARM benchmarking system for:
Licensed under MIT OR Apache-2.0