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:
Dhanji R. Prasanna
2026-02-05 14:00:52 +11:00
parent 9443f9333b
commit 6cb70f26fa
2 changed files with 15 additions and 1 deletions

View File

@@ -112,7 +112,9 @@ pub fn get_language_prompts_for_workspace(workspace_dir: &Path) -> Option<String
let mut prompts = Vec::new();
for lang in detected {
if let Some(content) = get_language_prompt(lang) {
prompts.push(content);
if !content.is_empty() {
prompts.push(content);
}
}
}
@@ -244,4 +246,15 @@ mod tests {
let content = prompts.unwrap();
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
View File

@@ -0,0 +1 @@
dhanji@Dhanjis-Mac-Studio.local.20760:1769746925