Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

zeta2 cli: Include section ranges in new full output format (#39203)

Agus Zubiagadf43a2d3b1aa
diff --git a/Cargo.lock b/Cargo.lock
index 2e493c9afda..6f2089b31e2 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 b06431baf65..f5b23d653bd 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 42477d9d06c..df70119b7fc 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<Path>, Range<usize>)>,
diff --git a/crates/zeta_cli/src/main.rs b/crates/zeta_cli/src/main.rs
index ebe59fc7a37..b13771a66f6 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,
}))?),
}
})