| 463 | } |
| 464 | |
| 465 | QString ClientInterface::getCurrentFileContext() const |
| 466 | { |
| 467 | auto currentEditor = Core::EditorManager::currentEditor(); |
| 468 | if (!currentEditor) { |
| 469 | LOG_MESSAGE("No active editor found"); |
| 470 | return QString(); |
| 471 | } |
| 472 | |
| 473 | auto textDocument = qobject_cast<TextEditor::TextDocument *>(currentEditor->document()); |
| 474 | if (!textDocument) { |
| 475 | LOG_MESSAGE("Current document is not a text document"); |
| 476 | return QString(); |
| 477 | } |
| 478 | |
| 479 | QString fileInfo = QString("Language: %1\nFile: %2\n\n") |
| 480 | .arg(textDocument->mimeType(), textDocument->filePath().toFSPathString()); |
| 481 | |
| 482 | QString content = textDocument->document()->toPlainText(); |
| 483 | |
| 484 | LOG_MESSAGE(QString("Got context from file: %1").arg(textDocument->filePath().toFSPathString())); |
| 485 | |
| 486 | return QString("Current file context:\n%1\nFile content:\n%2").arg(fileInfo, content); |
| 487 | } |
| 488 | |
| 489 | QString ClientInterface::getSystemPromptWithLinkedFiles( |
| 490 | const QString &basePrompt, const QList<QString> &linkedFiles) const |