feat: Add execution command tool (#273)

This commit is contained in:
Petr Mironychev
2025-11-23 12:52:20 +01:00
committed by GitHub
parent a15f64a234
commit 07de415346
7 changed files with 321 additions and 1 deletions

View File

@ -108,6 +108,8 @@ const char CA_ALLOW_FILE_SYSTEM_WRITE[] = "QodeAssist.caAllowFileSystemWrite";
const char CA_ALLOW_ACCESS_OUTSIDE_PROJECT[] = "QodeAssist.caAllowAccessOutsideProject";
const char CA_ENABLE_EDIT_FILE_TOOL[] = "QodeAssist.caEnableEditFileTool";
const char CA_ENABLE_BUILD_PROJECT_TOOL[] = "QodeAssist.caEnableBuildProjectTool";
const char CA_ENABLE_TERMINAL_COMMAND_TOOL[] = "QodeAssist.caEnableTerminalCommandTool";
const char CA_ALLOWED_TERMINAL_COMMANDS[] = "QodeAssist.caAllowedTerminalCommands";
const char QODE_ASSIST_GENERAL_OPTIONS_ID[] = "QodeAssist.GeneralOptions";
const char QODE_ASSIST_GENERAL_SETTINGS_PAGE_ID[] = "QodeAssist.1GeneralSettingsPageId";

View File

@ -89,6 +89,22 @@ ToolsSettings::ToolsSettings()
"project. This feature is under testing and may have unexpected behavior."));
enableBuildProjectTool.setDefaultValue(false);
enableTerminalCommandTool.setSettingsKey(Constants::CA_ENABLE_TERMINAL_COMMAND_TOOL);
enableTerminalCommandTool.setLabelText(Tr::tr("Enable Terminal Command Tool (Experimental)"));
enableTerminalCommandTool.setToolTip(
Tr::tr("Enable the experimental execute_terminal_command tool that allows AI to execute "
"terminal commands from the allowed list. This feature is under testing and may have "
"unexpected behavior."));
enableTerminalCommandTool.setDefaultValue(false);
allowedTerminalCommands.setSettingsKey(Constants::CA_ALLOWED_TERMINAL_COMMANDS);
allowedTerminalCommands.setLabelText(Tr::tr("Allowed Terminal Commands"));
allowedTerminalCommands.setToolTip(
Tr::tr("Comma-separated list of terminal commands that AI is allowed to execute. "
"Example: git, ls, cat, grep, cmake"));
allowedTerminalCommands.setDisplayStyle(Utils::StringAspect::LineEditDisplay);
allowedTerminalCommands.setDefaultValue("git, ls, cat, grep");
resetToDefaults.m_buttonText = Tr::tr("Reset Page to Defaults");
readSettings();
@ -113,7 +129,12 @@ ToolsSettings::ToolsSettings()
Space{8},
Group{
title(Tr::tr("Experimental Features")),
Column{enableEditFileTool, enableBuildProjectTool, autoApplyFileEdits}},
Column{
enableEditFileTool,
enableBuildProjectTool,
enableTerminalCommandTool,
allowedTerminalCommands,
autoApplyFileEdits}},
Stretch{1}};
});
}
@ -144,6 +165,8 @@ void ToolsSettings::resetSettingsToDefaults()
resetAspect(autoApplyFileEdits);
resetAspect(enableEditFileTool);
resetAspect(enableBuildProjectTool);
resetAspect(enableTerminalCommandTool);
resetAspect(allowedTerminalCommands);
writeSettings();
}
}

View File

@ -40,6 +40,8 @@ public:
// Experimental features
Utils::BoolAspect enableEditFileTool{this};
Utils::BoolAspect enableBuildProjectTool{this};
Utils::BoolAspect enableTerminalCommandTool{this};
Utils::StringAspect allowedTerminalCommands{this};
Utils::BoolAspect autoApplyFileEdits{this};
private: