buildSystemPromptWithContext function
Build a system prompt with context.
Implementation
String buildSystemPromptWithContext({
required String basePrompt,
String? memoryContent,
String? projectInfo,
List<String>? activeTools,
bool planMode = false,
}) {
final buffer = StringBuffer(basePrompt);
if (memoryContent != null && memoryContent.isNotEmpty) {
buffer.writeln('\n\n<memory>\n$memoryContent\n</memory>');
}
if (projectInfo != null && projectInfo.isNotEmpty) {
buffer.writeln('\n\n<project_info>\n$projectInfo\n</project_info>');
}
if (activeTools != null && activeTools.isNotEmpty) {
buffer.writeln('\n\nAvailable tools: ${activeTools.join(", ")}');
}
if (planMode) {
buffer.writeln(
'\n\nYou are currently in PLAN MODE. '
'Analyze the request and create a detailed plan. '
'Do not execute any changes yet — only plan.',
);
}
return buffer.toString();
}