From df43a2d3b1aa6971ae25a584fee66cea4748f06d Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Tue, 30 Sep 2025 11:30:13 -0300 Subject: [PATCH] zeta2 cli: Include section ranges in new full output format (#39203) Release Notes: - N/A --------- Co-authored-by: Oleksiy Syvokon --- Cargo.lock | 1 + crates/cloud_zeta2_prompt/Cargo.toml | 1 + crates/cloud_zeta2_prompt/src/cloud_zeta2_prompt.rs | 3 ++- crates/zeta_cli/src/main.rs | 8 +++++--- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e493c9afda2dff62ae49048a12a3e1d106b35df..6f2089b31e2910b9915f90fc1edadc2144c3daf8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3217,6 +3217,7 @@ dependencies = [ "indoc", "ordered-float 2.10.1", "rustc-hash 2.1.1", + "serde", "strum 0.27.1", "workspace-hack", ] diff --git a/crates/cloud_zeta2_prompt/Cargo.toml b/crates/cloud_zeta2_prompt/Cargo.toml index b06431baf652c67459280ffec64d45ca072420ef..f5b23d653bd84faed6ce1fca02f6c7436a0badc8 100644 --- a/crates/cloud_zeta2_prompt/Cargo.toml +++ b/crates/cloud_zeta2_prompt/Cargo.toml @@ -17,5 +17,6 @@ cloud_llm_client.workspace = true indoc.workspace = true ordered-float.workspace = true rustc-hash.workspace = true +serde.workspace = true strum.workspace = true workspace-hack.workspace = true diff --git a/crates/cloud_zeta2_prompt/src/cloud_zeta2_prompt.rs b/crates/cloud_zeta2_prompt/src/cloud_zeta2_prompt.rs index 42477d9d06cd945d1018cccdfe1ffd6cbf1000cd..df70119b7fc91cc570e605fd5cebb9164d54f215 100644 --- a/crates/cloud_zeta2_prompt/src/cloud_zeta2_prompt.rs +++ b/crates/cloud_zeta2_prompt/src/cloud_zeta2_prompt.rs @@ -5,6 +5,7 @@ use cloud_llm_client::predict_edits_v3::{self, Event, PromptFormat, ReferencedDe use indoc::indoc; use ordered_float::OrderedFloat; use rustc_hash::{FxHashMap, FxHashSet}; +use serde::Serialize; use std::fmt::Write; use std::sync::Arc; use std::{cmp::Reverse, collections::BinaryHeap, ops::Range, path::Path}; @@ -75,7 +76,7 @@ pub enum DeclarationStyle { Declaration, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize)] pub struct SectionLabels { pub excerpt_index: usize, pub section_ranges: Vec<(Arc, Range)>, diff --git a/crates/zeta_cli/src/main.rs b/crates/zeta_cli/src/main.rs index ebe59fc7a374202ee5611965d82a1971abb30354..b13771a66f6dba266b0a6c5bc0e1a64d0f481aa8 100644 --- a/crates/zeta_cli/src/main.rs +++ b/crates/zeta_cli/src/main.rs @@ -122,7 +122,7 @@ enum OutputFormat { #[default] Prompt, Request, - Both, + Full, } #[derive(Debug, Clone)] @@ -299,15 +299,17 @@ async fn get_context( .await?; let planned_prompt = cloud_zeta2_prompt::PlannedPrompt::populate(&request)?; - let prompt_string = planned_prompt.to_prompt_string()?.0; + let (prompt_string, section_labels) = planned_prompt.to_prompt_string()?; + match zeta2_args.output_format { OutputFormat::Prompt => anyhow::Ok(prompt_string), OutputFormat::Request => { anyhow::Ok(serde_json::to_string_pretty(&request)?) } - OutputFormat::Both => anyhow::Ok(serde_json::to_string_pretty(&json!({ + OutputFormat::Full => anyhow::Ok(serde_json::to_string_pretty(&json!({ "request": request, "prompt": prompt_string, + "section_labels": section_labels, }))?), } })