feat: Add edit file tool (#249)

* feat: Add edit file tool
* feat: Add icons for action buttons
This commit is contained in:
Petr Mironychev
2025-11-03 08:56:52 +01:00
committed by GitHub
parent e7110810f8
commit 9b90aaa06e
39 changed files with 3732 additions and 344 deletions

View File

@ -19,6 +19,8 @@
#pragma once
#include "FileSearchUtils.hpp"
#include <context/IgnoreManager.hpp>
#include <llmcore/BaseTool.hpp>
#include <QFuture>
@ -42,38 +44,7 @@ public:
QFuture<QString> executeAsync(const QJsonObject &input) override;
private:
enum class MatchType { ExactName, PathMatch, PartialName };
struct FileMatch
{
QString absolutePath;
QString relativePath;
QString projectName;
QString content;
MatchType matchType;
bool contentRead = false;
QString error;
bool operator<(const FileMatch &other) const
{
return static_cast<int>(matchType) < static_cast<int>(other.matchType);
}
};
FileMatch findBestMatch(const QString &query, const QString &filePattern, int maxResults);
void searchInFileSystem(
const QString &dirPath,
const QString &query,
const QString &projectName,
const QString &projectDir,
ProjectExplorer::Project *project,
QList<FileMatch> &matches,
int maxResults,
int &currentDepth,
int maxDepth = 5);
bool matchesFilePattern(const QString &fileName, const QString &pattern) const;
QString readFileContent(const QString &filePath) const;
QString formatResult(const FileMatch &match, bool readContent) const;
QString formatResult(const FileSearchUtils::FileMatch &match, bool readContent) const;
Context::IgnoreManager *m_ignoreManager;
};