feat: Improved workspace instructions support

This commit is contained in:
2026-07-17 14:52:35 -06:00
parent 8c885d9a77
commit a45e66c634
13 changed files with 364 additions and 81 deletions
+33
View File
@@ -32,6 +32,7 @@ use crate::utils::{
list_file_names, now, render_prompt, temp_file,
};
use super::instructions;
use super::memory::{
DEFAULT_MEMORY_CAP_WITH_TOOLS, DEFAULT_MEMORY_CAP_WITHOUT_TOOLS, MemoryStore, WorkspaceMemory,
};
@@ -797,6 +798,20 @@ impl RequestContext {
self.session.as_ref(),
)?;
if app.workspace_instructions.unwrap_or(true)
&& let Ok(cwd) = env::current_dir()
{
let file_names = app
.workspace_instructions_files
.clone()
.unwrap_or_else(instructions::default_workspace_instructions_files);
if let Some(found) = instructions::discover_workspace_instructions(&cwd, &file_names) {
let separator = if role.is_empty_prompt() { "" } else { "\n\n" };
role.append_to_prompt(separator);
role.append_to_prompt(&instructions::build_instructions_section(&found));
}
}
if should_inject_skill_instructions(app, &policy) {
let config = self.skill_instructions_config();
@@ -1470,6 +1485,24 @@ impl RequestContext {
"memory_cap_without_tools",
super::format_option_value(&app.memory_cap_without_tools),
),
(
"workspace_instructions",
super::format_option_value(&app.workspace_instructions),
),
(
"workspace_instructions_file",
env::current_dir()
.ok()
.and_then(|cwd| {
let file_names = app
.workspace_instructions_files
.clone()
.unwrap_or_else(instructions::default_workspace_instructions_files);
instructions::discover_workspace_instructions(&cwd, &file_names)
})
.map(|i| i.path.display().to_string())
.unwrap_or_else(|| "null".into()),
),
(
"rag_reranker_model",
super::format_option_value(&rag_reranker_model),