fix: Add active project name and path to system prompt

This commit is contained in:
Petr Mironychev
2025-11-12 19:29:33 +01:00
parent 1cd19aa5d1
commit a26d475806
2 changed files with 8 additions and 2 deletions

View File

@ -99,13 +99,19 @@ void ClientInterface::sendMessage(
QString systemPrompt = chatAssistantSettings.systemPrompt(); QString systemPrompt = chatAssistantSettings.systemPrompt();
auto project = LLMCore::RulesLoader::getActiveProject(); auto project = LLMCore::RulesLoader::getActiveProject();
if (project) { if (project) {
systemPrompt += QString("\n# Active project name: %1").arg(project->displayName());
systemPrompt += QString("\n# Active Project path: %1").arg(project->projectDirectory().toUrlishString());
QString projectRules QString projectRules
= LLMCore::RulesLoader::loadRulesForProject(project, LLMCore::RulesContext::Chat); = LLMCore::RulesLoader::loadRulesForProject(project, LLMCore::RulesContext::Chat);
if (!projectRules.isEmpty()) { if (!projectRules.isEmpty()) {
systemPrompt += "\n# Project Rules\n\n" + projectRules; systemPrompt += QString("\n# Project Rules\n\n") + projectRules;
} }
} else {
systemPrompt += QString("\n# No active project in IDE");
} }
if (!linkedFiles.isEmpty()) { if (!linkedFiles.isEmpty()) {

View File

@ -86,7 +86,7 @@ QFuture<QString> ListProjectFilesTool::executeAsync(const QJsonObject &input)
return QtConcurrent::run([this]() -> QString { return QtConcurrent::run([this]() -> QString {
QList<ProjectExplorer::Project *> projects = ProjectExplorer::ProjectManager::projects(); QList<ProjectExplorer::Project *> projects = ProjectExplorer::ProjectManager::projects();
if (projects.isEmpty()) { if (projects.isEmpty()) {
QString error = "Error: No projects found"; QString error = "No projects found";
throw ToolRuntimeError(error); throw ToolRuntimeError(error);
} }