Add some debug output and simplify overyl complex code
This commit is contained in:
parent
fd289edded
commit
bc0ae50be5
|
|
@ -22,6 +22,7 @@
|
|||
#include <QStandardPaths>
|
||||
#endif
|
||||
|
||||
|
||||
#include "mcp/KomMcpServer.hpp"
|
||||
#include "mcp/KompanionQtServer.hpp"
|
||||
#include "mcp/RegisterTools.hpp"
|
||||
|
|
|
|||
|
|
@ -18,11 +18,10 @@
|
|||
#include <QtCore/QStandardPaths>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
#include <QDebug>
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
namespace {
|
||||
const QString kSchemaResource = QStringLiteral(":/kompanion/ToolSchemas.json");
|
||||
|
||||
QString normaliseToolName(const QString &defaultNamespace, const QString &rawName)
|
||||
{
|
||||
if (rawName.contains('.')) {
|
||||
|
|
@ -103,31 +102,13 @@ KompanionQtServer::KompanionQtServer(const QString &backend, KomMcpServer *logic
|
|||
QList<QMcpTool> KompanionQtServer::loadToolsFromSchema() const
|
||||
{
|
||||
QList<QMcpTool> tools;
|
||||
const QStringList candidates = {
|
||||
kSchemaResource,
|
||||
QStringLiteral(":/ToolSchemas.json"),
|
||||
QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
QStringLiteral("kompanion/mcp/ToolSchemas.json")),
|
||||
QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||
QStringLiteral("kompanion/mcp/ToolSchemas.json"))
|
||||
};
|
||||
|
||||
QFile schemaFile;
|
||||
for (const QString &candidate : candidates) {
|
||||
if (candidate.isEmpty())
|
||||
continue;
|
||||
schemaFile.setFileName(candidate);
|
||||
if (schemaFile.open(QIODevice::ReadOnly)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!schemaFile.isOpen()) {
|
||||
qWarning() << "[KompanionQtServer] Failed to open tool schema (resource or installed copy):" << candidates;
|
||||
QFile kSchemaResource(":/kompanion/ToolSchemas.json");
|
||||
if (!kSchemaResource.open(QIODevice::ReadOnly)) {
|
||||
qWarning() << "[KompanionQtServer] Failed to open tool schema";
|
||||
return tools;
|
||||
}
|
||||
|
||||
const auto doc = QJsonDocument::fromJson(schemaFile.readAll());
|
||||
const auto doc = QJsonDocument::fromJson(kSchemaResource.readAll());
|
||||
if (!doc.isObject()) {
|
||||
qWarning() << "[KompanionQtServer] Tool schema resource is not a JSON object";
|
||||
return tools;
|
||||
|
|
@ -143,7 +124,9 @@ if (!schemaFile.isOpen()) {
|
|||
|
||||
for (auto it = toolDefs.constBegin(); it != toolDefs.constEnd(); ++it) {
|
||||
const QString fullName = normaliseToolName(defaultNamespace, it.key());
|
||||
|
||||
if (!m_logic->hasTool(fullName.toStdString())) {
|
||||
qDebug() << "skipping " << fullName << " that does not fit";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue