Files
QodeAssist/sources/session/TurnContext.cpp
Petr Mironychev af85efb554 refactor: Decoupling chat architecture (#367)
* refactor: Migrate tests to Qt Creator plugin framework and update llmqore transports

* refactor: Move conversation history into IDE-free session library

* refactor: Extract turn context assembly behind injected ports

* build: Add RunQodeAssistTests target for the plugin test suite

* refactor: Route the chat through a Session and ChatBackend seam
2026-07-19 22:45:04 +02:00

57 lines
2.0 KiB
C++

// Copyright (C) 2026 Petr Mironychev
// SPDX-License-Identifier: GPL-3.0-or-later
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
#include "session/TurnContext.hpp"
namespace QodeAssist::Session {
QString renderSystemPrompt(const TurnContext &context)
{
QString prompt = context.basePrompt;
if (context.rolePrompt)
prompt += "\n\n" + *context.rolePrompt;
if (context.project.available) {
prompt += QString("\n# Active project: %1").arg(context.project.displayName);
prompt += QString(
"\n# Project source root: %1"
"\n# All new source files, headers, QML and CMake edits MUST be "
"created or modified under this directory. Use absolute paths "
"rooted here, or project-relative paths.")
.arg(context.project.sourceRoot);
if (context.project.buildDirectory) {
prompt += QString(
"\n# Build output directory (compiler artifacts only — do NOT "
"create or edit source files here): %1")
.arg(*context.project.buildDirectory);
}
if (!context.projectRules.isEmpty())
prompt += QString("\n# Project Rules\n\n") + context.projectRules;
} else {
prompt += QString("\n# No active project in IDE");
}
if (!context.alwaysOnSkills.isEmpty())
prompt += QString("\n\n") + context.alwaysOnSkills;
if (!context.skillsCatalog.isEmpty())
prompt += QString("\n\n") + context.skillsCatalog;
for (const InvokedSkill &skill : context.invokedSkills)
prompt += QString("\n\n# Invoked Skill: %1\n\n%2").arg(skill.name, skill.body);
if (!context.linkedFilePaths.isEmpty()) {
prompt += "\n\nLinked files for reference:\n";
for (const LinkedFile &file : context.linkedFiles)
prompt += QString("\nFile: %1\nContent:\n%2\n").arg(file.fileName, file.content);
}
return prompt;
}
} // namespace QodeAssist::Session