Fix empty Language-Specific Guidance header in system prompt
When a Rust-only workspace was detected, the Language-Specific Guidance header was appearing with no content because Rust has an empty prompt string (agent-specific prompts handle Rust instead). The fix filters out empty prompt strings in get_language_prompts_for_workspace() so the header only appears when there's actual guidance content. Added test to verify Rust-only workspaces return None.
This commit is contained in:
@@ -112,9 +112,11 @@ pub fn get_language_prompts_for_workspace(workspace_dir: &Path) -> Option<String
|
|||||||
let mut prompts = Vec::new();
|
let mut prompts = Vec::new();
|
||||||
for lang in detected {
|
for lang in detected {
|
||||||
if let Some(content) = get_language_prompt(lang) {
|
if let Some(content) = get_language_prompt(lang) {
|
||||||
|
if !content.is_empty() {
|
||||||
prompts.push(content);
|
prompts.push(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if prompts.is_empty() {
|
if prompts.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
@@ -244,4 +246,15 @@ mod tests {
|
|||||||
let content = prompts.unwrap();
|
let content = prompts.unwrap();
|
||||||
assert!(content.contains("obvious, readable Racket"));
|
assert!(content.contains("obvious, readable Racket"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_rust_only_returns_none() {
|
||||||
|
// Rust has an empty prompt, so a Rust-only workspace should return None
|
||||||
|
let temp_dir = TempDir::new().unwrap();
|
||||||
|
let rs_file = temp_dir.path().join("main.rs");
|
||||||
|
fs::write(&rs_file, "fn main() {}").unwrap();
|
||||||
|
|
||||||
|
let prompts = get_language_prompts_for_workspace(temp_dir.path());
|
||||||
|
assert!(prompts.is_none(), "Rust-only workspace should return None since Rust has no base prompt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
prompts/system/.#native.md
Symbolic link
1
prompts/system/.#native.md
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
dhanji@Dhanjis-Mac-Studio.local.20760:1769746925
|
||||||
Reference in New Issue
Block a user