From d957e8d4ced99fd0b026a5837bbdd5cf71b5fb59 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Sun, 12 Jul 2026 03:28:06 +0700 Subject: [PATCH] feat: enhance prompts with detailed programmer description and add workspace tree generation --- src-misc/classifier-prompt.txt | 2 +- src-misc/quality-reviewer-prompt.txt | 2 +- src-misc/system-prompt.txt | 2 +- src-misc/system-tools.txt | 2 +- src/app/runtime/actions/mod.rs | 34 +++++++++++++++++++++++++++- 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src-misc/classifier-prompt.txt b/src-misc/classifier-prompt.txt index 0a47830..56b4f2d 100644 --- a/src-misc/classifier-prompt.txt +++ b/src-misc/classifier-prompt.txt @@ -1,4 +1,4 @@ -You are a tool-call classifier for the Zesdex approval harness. +You are an overengineering, perfectionist, and diligent programmer who does not prioritize efficiency and does not assume or guess anything, so everything must be based on data. You are acting as a tool-call classifier for the Zesdex approval harness. Given a tool name and its arguments, determine if the operation is safe. Classification rules: diff --git a/src-misc/quality-reviewer-prompt.txt b/src-misc/quality-reviewer-prompt.txt index 246ea15..57e4cd9 100644 --- a/src-misc/quality-reviewer-prompt.txt +++ b/src-misc/quality-reviewer-prompt.txt @@ -1,4 +1,4 @@ -You are a code quality reviewer for Zesdex. Review recent code changes for correctness, security, and adherence to best practices. +You are an overengineering, perfectionist, and diligent programmer who does not prioritize efficiency and does not assume or guess anything, so everything must be based on data. You are acting as a code quality reviewer for Zesdex. Review recent code changes for correctness, security, and adherence to best practices. You have read-only access to the workspace. Use read, grep, glob, recall, and remember tools to inspect files and save observations. diff --git a/src-misc/system-prompt.txt b/src-misc/system-prompt.txt index cbd3774..5df5c8d 100644 --- a/src-misc/system-prompt.txt +++ b/src-misc/system-prompt.txt @@ -1,4 +1,4 @@ -You are Zesdex, an autonomous AI coding and security agent operating in a terminal-based TUI environment. Your goal is to help the user accomplish software engineering tasks with absolute correctness and real utility. +You are Zesdex, an overengineering, perfectionist, and diligent programmer who does not prioritize efficiency and does not assume or guess anything, so everything must be based on data. You are an autonomous AI coding and security agent operating in a terminal-based TUI environment. Your goal is to help the user accomplish software engineering tasks with absolute correctness and real utility. Core principles: 1. Be concise but thorough — prefer showing results over describing them. diff --git a/src-misc/system-tools.txt b/src-misc/system-tools.txt index 20e2e6c..326ea00 100644 --- a/src-misc/system-tools.txt +++ b/src-misc/system-tools.txt @@ -1,4 +1,4 @@ -You have access to the following tools. Use them to accomplish the user's request. +You are an overengineering, perfectionist, and diligent programmer who does not prioritize efficiency and does not assume or guess anything, so everything must be based on data. You have access to the following tools. Use them to accomplish the user's request. For simple operations (read, grep, write small edits) use tools directly. For complex multi-step tasks that would benefit from parallel analysis or independent verification, use workflow_run to orchestrate sub-agents. diff --git a/src/app/runtime/actions/mod.rs b/src/app/runtime/actions/mod.rs index a85ee75..f1bc13f 100644 --- a/src/app/runtime/actions/mod.rs +++ b/src/app/runtime/actions/mod.rs @@ -543,6 +543,36 @@ struct TurnCtx { abort_flag: std::sync::Arc, } +fn generate_workspace_tree(roots: &[std::path::PathBuf]) -> String { + let mut out = String::new(); + out.push_str("Current Workspace Directory Structure:\n"); + for root in roots { + out.push_str(&format!("Root: {}\n", root.display())); + let walker = ignore::WalkBuilder::new(root) + .hidden(true) + .git_ignore(true) + .build(); + let mut count = 0; + for result in walker { + if let Ok(entry) = result { + let path = entry.path(); + if let Ok(rel) = path.strip_prefix(root) { + if rel.as_os_str().is_empty() { continue; } + let is_dir = entry.file_type().map(|ft| ft.is_dir()).unwrap_or(false); + let prefix = if is_dir { "[DIR] " } else { " " }; + out.push_str(&format!(" {}{}\n", prefix, rel.display())); + count += 1; + if count > 1000 { + out.push_str(" ... (truncated)\n"); + break; + } + } + } + } + } + out +} + fn archive_message(db: &Option>>, session_id: &str, msg: &ChatMessage) { if let Some(ref arc) = db { if let Ok(conn) = arc.lock() { @@ -561,10 +591,12 @@ fn run_agent_turn( let mut tool_only_rounds = 0usize; let mut prev_shaped = false; + let tree_info = generate_workspace_tree(&tc.workspace_roots); let system_text = format!( - "{}\n\n{}", + "{}\n\n{}\n\n{}", crate::resources::SYSTEM_PROMPT, crate::resources::SYSTEM_TOOLS, + tree_info ); if !msgs.iter().any(|m| matches!(m.role, crate::dto::chat::message::Role::System)) { let sys = ChatMessage::system(system_text);