mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-07-23 19:51:05 -04:00
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
This commit is contained in:
56
sources/session/TurnContext.cpp
Normal file
56
sources/session/TurnContext.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
// 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
|
||||
Reference in New Issue
Block a user