Files
qelectrotech-source-mirror/sources/ui/aiassistantsetup.h
T
ispyisail ddc645174f Connect an AI assistant: say when Python is missing
The configuration names "python" or "python3", or the Python the Windows
installer can add. When none of those can run, the assistant fails with
an error far from the cause, so the dialog now says so in bold, with what
to do: tick "Python pour l'assistant IA" in the installer or install
Python (Windows), or install Python 3 from the system's packages.

Windows 10 and 11 put a python.exe in WindowsApps that only opens the
Microsoft Store, so a PATH search alone reports Python where there is
none. A result there is reported as possibly that shortcut. Backslashes
are converted explicitly, not with QDir::fromNativeSeparators(), which
leaves them alone off Windows and so could not be tested here.

tst_aiassistantsetup: 17 cases (8 new: the bundled Python is taken
without looking on PATH; none, python.org, the Store shortcut with either
separator, and a Linux folder named WindowsApps). Each of the 4 new rules
was removed in turn and the test failed. ctest 32/32. In the GUI, the
same install layout shows the warning with no python3 on PATH and no
warning with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 15:17:16 +13:00

81 lines
2.3 KiB
C++

/*
Copyright 2006-2026 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AIASSISTANTSETUP_H
#define AIASSISTANTSETUP_H
#include <QString>
#include <QStringList>
#include <functional>
/**
@brief What an AI assistant needs to start QElectroTech's MCP server
(misc/qet-mcp), and the configuration text each assistant expects.
No widgets and no application object, so it can be tested alone. It
reads the file system and nothing else: it writes nothing and starts
nothing. AiAssistantDialog shows its result.
*/
namespace AiAssistantSetup
{
/// The assistants a configuration can be written for.
enum class Client {
ClaudeDesktop,
ClaudeCode,
VsCode,
Cursor,
GeminiCli,
CodexCli,
LmStudio
};
QList<Client> clients();
/// Whether the Python the configuration names can actually run.
enum class PythonStatus {
Found,
Missing,
/// Only Windows' "python.exe" shortcut in WindowsApps, which opens
/// the Microsoft Store when Python is not installed.
StoreShortcut
};
/// Where the pieces are. An empty server means none was found.
struct Paths {
QString server; ///< qet_mcp.py
QString python; ///< the Python to run it with
QString qet_binary; ///< this QElectroTech
PythonStatus python_status = PythonStatus::Missing;
};
/// Finds a program on PATH; QStandardPaths::findExecutable() by default.
using ExecutableFinder = std::function<QString(const QString &)>;
Paths detect(const QString &application_dir,
const QString &application_file,
bool windows,
const ExecutableFinder &find_executable = ExecutableFinder());
QString configuration(Client client,
const Paths &paths,
const QString &workspace,
bool allow_edit);
}
#endif // AIASSISTANTSETUP_H