make sure user requirements are included
This commit is contained in:
@@ -1728,7 +1728,7 @@ async fn run_autonomous(
|
|||||||
let status_callback: g3_planner::StatusCallback = Box::new(move |msg: &str| {
|
let status_callback: g3_planner::StatusCallback = Box::new(move |msg: &str| {
|
||||||
output_clone.print(msg);
|
output_clone.print(msg);
|
||||||
});
|
});
|
||||||
match g3_planner::get_initial_discovery_messages(&path_str, provider, Some(&status_callback)).await {
|
match g3_planner::get_initial_discovery_messages(&path_str, Some(&requirements), provider, Some(&status_callback)).await {
|
||||||
Ok(messages) => (messages, Some(path_str.to_string())),
|
Ok(messages) => (messages, Some(path_str.to_string())),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
output.print(&format!("⚠️ LLM discovery failed: {}, skipping fast-start", e));
|
output.print(&format!("⚠️ LLM discovery failed: {}, skipping fast-start", e));
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ pub type StatusCallback = Box<dyn Fn(&str) + Send + Sync>;
|
|||||||
///
|
///
|
||||||
/// * `codebase_path` - The path to the codebase to explore
|
/// * `codebase_path` - The path to the codebase to explore
|
||||||
/// * `provider` - An LLM provider to query for exploration commands
|
/// * `provider` - An LLM provider to query for exploration commands
|
||||||
|
/// * `requirements_text` - Optional requirements text to include in the discovery prompt
|
||||||
/// * `status_callback` - Optional callback for status updates
|
/// * `status_callback` - Optional callback for status updates
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
@@ -34,6 +35,7 @@ pub type StatusCallback = Box<dyn Fn(&str) + Send + Sync>;
|
|||||||
/// A `Result<Vec<Message>>` containing Assistant messages with JSON tool call strings.
|
/// A `Result<Vec<Message>>` containing Assistant messages with JSON tool call strings.
|
||||||
pub async fn get_initial_discovery_messages(
|
pub async fn get_initial_discovery_messages(
|
||||||
codebase_path: &str,
|
codebase_path: &str,
|
||||||
|
requirements_text: Option<&str>,
|
||||||
provider: &dyn LLMProvider,
|
provider: &dyn LLMProvider,
|
||||||
status_callback: Option<&StatusCallback>,
|
status_callback: Option<&StatusCallback>,
|
||||||
) -> Result<Vec<Message>> {
|
) -> Result<Vec<Message>> {
|
||||||
@@ -50,10 +52,19 @@ pub async fn get_initial_discovery_messages(
|
|||||||
let codebase_report = explore_codebase(codebase_path);
|
let codebase_report = explore_codebase(codebase_path);
|
||||||
|
|
||||||
// Step 2: Build the prompt with the codebase report appended
|
// Step 2: Build the prompt with the codebase report appended
|
||||||
let user_prompt = format!(
|
let user_prompt = if let Some(requirements) = requirements_text {
|
||||||
"{}\n\n=== CODEBASE REPORT ===\n\n{}",
|
format!(
|
||||||
DISCOVERY_REQUIREMENTS_PROMPT, codebase_report
|
"{}\n\n
|
||||||
);
|
=== REQUIREMENTS ===\n\n{}\n\n
|
||||||
|
=== CODEBASE REPORT ===\n\n{}",
|
||||||
|
DISCOVERY_REQUIREMENTS_PROMPT, requirements, codebase_report
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
format!(
|
||||||
|
"{}\n\n=== CODEBASE REPORT ===\n\n{}",
|
||||||
|
DISCOVERY_REQUIREMENTS_PROMPT, codebase_report
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
// Step 3: Create messages for the LLM
|
// Step 3: Create messages for the LLM
|
||||||
let messages = vec![
|
let messages = vec![
|
||||||
|
|||||||
@@ -19,13 +19,20 @@ pub const DISCOVERY_REQUIREMENTS_PROMPT: &str = r#"**CRITICAL**: DO ABSOLUTELY N
|
|||||||
UNDERSTAND WHICH PARTS OF THE CODE YOU MIGHT BE INTERESTED IN, AND WHAT SEARCH/GREP EXPRESSIONS YOU MIGHT WANT TO USE
|
UNDERSTAND WHICH PARTS OF THE CODE YOU MIGHT BE INTERESTED IN, AND WHAT SEARCH/GREP EXPRESSIONS YOU MIGHT WANT TO USE
|
||||||
TO GET A BETTER UNDERSTANDING OF THE CODEBASE.
|
TO GET A BETTER UNDERSTANDING OF THE CODEBASE.
|
||||||
|
|
||||||
Your task is to analyze the codebase structure provided below and generate shell commands to explore it further.
|
Your task is to analyze the codebase overview provided below and generate shell commands to explore it further - in particular, those
|
||||||
|
you deem most relevant to the requirements given below.
|
||||||
|
|
||||||
Your output MUST include:
|
Your output MUST include:
|
||||||
1. A section with heading {{SUMMARY BASED ON INITIAL INFO}} containing a brief summary of what you understand about the codebase structure (max 10000 tokens).
|
1. retain as much information of that as you consider relevant to the request and your next job (not to be attempted yet)
|
||||||
2. A section with heading {{CODE EXPLORATION COMMANDS}} containing shell commands to explore the codebase further.
|
for planning the main tasks for what you will implement. Ideally that should not be more than 10000 tokens. Write a section
|
||||||
|
that you will later use in your next phase, which is detailed implementation plan. Use the heading {{SUMMARY BASED ON INITIAL
|
||||||
|
INFO}}.
|
||||||
|
2. Based on the initial summary, try plan ahead for what you need for a deep dive into the code. Do pay attention that
|
||||||
|
the information should be sparing.
|
||||||
- Use tools like `ls`, `rg` (ripgrep), `grep`, `sed`, `cat`, `head`, `tail` etc.
|
- Use tools like `ls`, `rg` (ripgrep), `grep`, `sed`, `cat`, `head`, `tail` etc.
|
||||||
- Focus on commands that will help understand the code structure without dumping entire files.
|
- Focus on commands that will help understand the code STRUCTURE without dumping large sections of file.
|
||||||
|
- e.g. for Rust you might try `rg --no-heading --line-number --with-filename --max-filesize 500K -g '*.rs' '^(pub )?(struct|enum|type|union)`
|
||||||
- Mark the beginning and end of the commands with "```".
|
- Mark the beginning and end of the commands with "```".
|
||||||
|
- Carefully consider which commands give you the most relevant information, make it a maximum of 20.
|
||||||
|
|
||||||
DO NOT ADD ANY COMMENTS OR OTHER EXPLANATION IN THE COMMANDS SECTION, JUST INCLUDE THE SHELL COMMANDS."#;
|
DO NOT ADD ANY COMMENTS OR OTHER EXPLANATION IN THE COMMANDS SECTION, JUST INCLUDE THE SHELL COMMANDS."#;
|
||||||
|
|||||||
Reference in New Issue
Block a user