mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-11-22 02:22:44 -05:00
Feat: Add Claude tools support to plugin (#231)
* feat: Add settings for handle using tools in chat * feat: Add Claude tools support * fix: Add ai ignore to read project files list tool * fix: Add ai ignore to read project file by name tool * fix: Add ai ignore to read current opened files tool
This commit is contained in:
@ -22,6 +22,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <logger/Logger.hpp>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QtConcurrent>
|
||||
@ -30,6 +31,7 @@ namespace QodeAssist::Tools {
|
||||
|
||||
ReadVisibleFilesTool::ReadVisibleFilesTool(QObject *parent)
|
||||
: BaseTool(parent)
|
||||
, m_ignoreManager(new Context::IgnoreManager(this))
|
||||
{}
|
||||
|
||||
QString ReadVisibleFilesTool::name() const
|
||||
@ -84,6 +86,15 @@ QFuture<QString> ReadVisibleFilesTool::executeAsync(const QJsonObject &input)
|
||||
}
|
||||
|
||||
QString filePath = editor->document()->filePath().toFSPathString();
|
||||
|
||||
auto project = ProjectExplorer::ProjectManager::projectForFile(
|
||||
editor->document()->filePath());
|
||||
if (project && m_ignoreManager->shouldIgnore(filePath, project)) {
|
||||
LOG_MESSAGE(
|
||||
QString("Ignoring visible file due to .qodeassistignore: %1").arg(filePath));
|
||||
continue;
|
||||
}
|
||||
|
||||
QByteArray contentBytes = editor->document()->contents();
|
||||
QString fileContent = QString::fromUtf8(contentBytes);
|
||||
|
||||
@ -98,6 +109,11 @@ QFuture<QString> ReadVisibleFilesTool::executeAsync(const QJsonObject &input)
|
||||
results.append(fileResult);
|
||||
}
|
||||
|
||||
if (results.isEmpty()) {
|
||||
QString error = "Error: All visible files are excluded by .qodeassistignore";
|
||||
throw std::runtime_error(error.toStdString());
|
||||
}
|
||||
|
||||
return results.join("\n\n" + QString(80, '=') + "\n\n");
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user