agent2: Support directories in @file mentions (#36416)
Release Notes: - N/A
This commit is contained in:
parent
821e97a392
commit
7bcea7dc2c
5 changed files with 325 additions and 168 deletions
|
@ -146,6 +146,7 @@ impl UserMessage {
|
|||
They are up-to-date and don't need to be re-read.\n\n";
|
||||
|
||||
const OPEN_FILES_TAG: &str = "<files>";
|
||||
const OPEN_DIRECTORIES_TAG: &str = "<directories>";
|
||||
const OPEN_SYMBOLS_TAG: &str = "<symbols>";
|
||||
const OPEN_THREADS_TAG: &str = "<threads>";
|
||||
const OPEN_FETCH_TAG: &str = "<fetched_urls>";
|
||||
|
@ -153,6 +154,7 @@ impl UserMessage {
|
|||
"<rules>\nThe user has specified the following rules that should be applied:\n";
|
||||
|
||||
let mut file_context = OPEN_FILES_TAG.to_string();
|
||||
let mut directory_context = OPEN_DIRECTORIES_TAG.to_string();
|
||||
let mut symbol_context = OPEN_SYMBOLS_TAG.to_string();
|
||||
let mut thread_context = OPEN_THREADS_TAG.to_string();
|
||||
let mut fetch_context = OPEN_FETCH_TAG.to_string();
|
||||
|
@ -168,7 +170,7 @@ impl UserMessage {
|
|||
}
|
||||
UserMessageContent::Mention { uri, content } => {
|
||||
match uri {
|
||||
MentionUri::File { abs_path, .. } => {
|
||||
MentionUri::File { abs_path } => {
|
||||
write!(
|
||||
&mut symbol_context,
|
||||
"\n{}",
|
||||
|
@ -179,6 +181,9 @@ impl UserMessage {
|
|||
)
|
||||
.ok();
|
||||
}
|
||||
MentionUri::Directory { .. } => {
|
||||
write!(&mut directory_context, "\n{}\n", content).ok();
|
||||
}
|
||||
MentionUri::Symbol {
|
||||
path, line_range, ..
|
||||
}
|
||||
|
@ -233,6 +238,13 @@ impl UserMessage {
|
|||
.push(language_model::MessageContent::Text(file_context));
|
||||
}
|
||||
|
||||
if directory_context.len() > OPEN_DIRECTORIES_TAG.len() {
|
||||
directory_context.push_str("</directories>\n");
|
||||
message
|
||||
.content
|
||||
.push(language_model::MessageContent::Text(directory_context));
|
||||
}
|
||||
|
||||
if symbol_context.len() > OPEN_SYMBOLS_TAG.len() {
|
||||
symbol_context.push_str("</symbols>\n");
|
||||
message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue