From 1f182021fb342b9c6b8a265114cb25b3ee35efa9 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Sat, 11 Jul 2026 22:16:47 +0700 Subject: [PATCH] feat: enhance system prompt handling and input key actions --- src-misc/system-prompt.txt | 2 +- src/app/runtime/actions/mod.rs | 9 +++++++++ src/controller/input.rs | 12 ++++++++++-- src/resources.rs | 3 +++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src-misc/system-prompt.txt b/src-misc/system-prompt.txt index b605154..a87fc64 100644 --- a/src-misc/system-prompt.txt +++ b/src-misc/system-prompt.txt @@ -8,7 +8,7 @@ Core principles: 5. For simple tasks, handle them directly with read/grep/write/edit. 6. For complex tasks (multi-file changes, parallel analysis, independent verification), use workflow_run to orchestrate sub-agents. 7. Every write or edit must have a clear reason — include it in the reason parameter. -8. When you're uncertain about requirements, ask clarifying questions before acting. +8. For greetings or conversation that doesn't require code changes, respond naturally WITHOUT calling any tools. 9. After making changes, verify they work by running builds or tests. 10. Respect the agent mode: Auto (full autonomy), Normal (review risky ops), Plan (no mutations), Yolo (full autonomy + no classifier). diff --git a/src/app/runtime/actions/mod.rs b/src/app/runtime/actions/mod.rs index 4a4c65b..73d3b5b 100644 --- a/src/app/runtime/actions/mod.rs +++ b/src/app/runtime/actions/mod.rs @@ -521,6 +521,15 @@ fn run_agent_turn( let mut msgs = messages.to_vec(); let mut edits_this_turn = 0u32; + let system_text = format!( + "{}\n\n{}", + crate::resources::SYSTEM_PROMPT, + crate::resources::SYSTEM_TOOLS, + ); + if !msgs.iter().any(|m| matches!(m.role, crate::dto::chat::message::Role::System)) { + msgs.insert(0, ChatMessage::system(system_text)); + } + for _step in 0..MAX_AGENT_STEPS { let response = tc .client diff --git a/src/controller/input.rs b/src/controller/input.rs index ebac232..1b63e5a 100644 --- a/src/controller/input.rs +++ b/src/controller/input.rs @@ -38,10 +38,18 @@ pub fn handle_key(key: KeyEvent, state: &mut AppStateRest) -> Vec { vec![Action::CursorRight] } KeyCode::Up => { - vec![Action::HistoryUp] + if key.modifiers.contains(KeyModifiers::CONTROL) { + vec![Action::HistoryUp] + } else { + vec![Action::ScrollUp] + } } KeyCode::Down => { - vec![Action::HistoryDown] + if key.modifiers.contains(KeyModifiers::CONTROL) { + vec![Action::HistoryDown] + } else { + vec![Action::ScrollDown] + } } KeyCode::PageUp => { vec![Action::ScrollUp] diff --git a/src/resources.rs b/src/resources.rs index 81c0810..8aef568 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -1,3 +1,6 @@ +pub const SYSTEM_PROMPT: &str = include_str!("../src-misc/system-prompt.txt"); +pub const SYSTEM_TOOLS: &str = include_str!("../src-misc/system-tools.txt"); + pub const BANNER: &str = r" ███████╗███████╗███████╗██████╗ ███████╗██╗ ██╗ ╚══███╔╝██╔════╝██╔════╝██╔══██╗██╔════╝╚██╗██╔╝