vtcode_core/prompts/
render.rs1use crate::config::VTCodeConfig;
4use crate::prompts::context::PromptContext;
5use crate::prompts::temporal::generate_temporal_date_context;
6
7pub fn render_environment_addenda(
9 vtcode_config: Option<&VTCodeConfig>,
10 prompt_context: Option<&PromptContext>,
11) -> Option<String> {
12 let mut lines = Vec::new();
13
14 if let Some(ctx) = prompt_context
15 && !ctx.languages.is_empty()
16 {
17 lines.push(format!("- Languages: {}.", ctx.languages.join(", ")));
21 }
22
23 if let Some(cfg) = vtcode_config {
24 if let Some(interaction_line) = render_interaction_addendum(cfg) {
25 lines.push(interaction_line);
26 }
27
28 if cfg.mcp.enabled {
29 lines.push(
30 "- Sources: prefer MCP (including Agent Plugin servers) before external fetches when available."
31 .to_string(),
32 );
33 }
34
35 if cfg.agent.include_temporal_context {
41 let date_context = generate_temporal_date_context(cfg.agent.temporal_context_use_utc);
42 let trimmed = date_context.trim();
43 let line = if let Some(rest) = trimmed.strip_prefix("Current date (UTC):") {
44 format!("- Date (UTC): {}", rest.trim())
45 } else {
46 trimmed.replacen("Current date:", "- Date:", 1).to_string()
47 };
48 lines.push(line);
49 }
50
51 if cfg.agent.include_working_directory
52 && let Some(ctx) = prompt_context
53 && let Some(cwd) = &ctx.current_directory
54 {
55 lines.push(format!("- Working directory: {}", cwd.display()));
56 }
57 }
58
59 if lines.is_empty() {
60 None
61 } else {
62 Some(format!("## Environment\n{}", lines.join("\n")))
63 }
64}
65
66fn render_interaction_addendum(cfg: &VTCodeConfig) -> Option<String> {
68 match cfg.chat.ask_questions.enabled {
69 true => None,
70 false => Some(
71 "- Interaction: no `request_user_input`; make reasonable assumptions unless Planning workflow needs follow-up."
72 .to_string(),
73 ),
74 }
75}