diff --git a/Core/Constants.cs b/Core/Constants.cs index e63c267..cf0b9ca 100644 --- a/Core/Constants.cs +++ b/Core/Constants.cs @@ -45,5 +45,6 @@ public static class Constants { public const string LlmModel = "openai/gpt-oss-20b"; public const string WhisperModel = "whisper-large-v3-turbo"; + public const int DefaultTypeDelayMs = 2; } } diff --git a/Core/Skills/SkillRegistry.cs b/Core/Skills/SkillRegistry.cs index c5102f9..ed1293f 100644 --- a/Core/Skills/SkillRegistry.cs +++ b/Core/Skills/SkillRegistry.cs @@ -69,10 +69,9 @@ public static class SkillRegistry new SkillDefinition { Name = "Terminal", - Description = "Executes the spoken command in your shell.", + Description = "Translates the spoken command into a bash command and types it.", Hotwords = new[] { "System terminal", "System run", "System execute" }, - Action = "script", - ScriptPath = "~/.config/toak/skills/terminal_action.sh", + Action = "type", SystemPrompt = @"You are a Linux terminal expert. Translate the user's request into a single, valid bash command. Output ONLY the raw command, no formatting, no markdown." @@ -124,32 +123,6 @@ Text: {transcript}" File.WriteAllText(filename, json); } - // Create the default terminal wrapper script if it doesn't exist - string scriptPath = Path.Combine(SkillsDirectory, "terminal_action.sh"); - if (!File.Exists(scriptPath)) - { - string scriptContent = "#!/bin/bash\n" + - "export TOAK_PROPOSED_CMD=\"$1\"\n" + - "x-terminal-emulator -e bash -c 'echo -e \"\\033[1;32mToak Terminal Skill\\033[0m\"; " + - "echo \"Proposed command:\"; echo; " + - "echo -e \" \\033[33m$TOAK_PROPOSED_CMD\\033[0m\"; echo; " + - "read -p \"Execute command? [Y/n] \" resp; " + - "if [[ $resp =~ ^[Yy]$ ]] || [[ -z $resp ]]; then " + - "echo; echo -e \"\\033[1;36m>> Executing...\\033[0m\"; eval \"$TOAK_PROPOSED_CMD\"; " + - "else echo; echo \"Aborted.\"; fi; " + - "echo; echo \"Process finished. Press Enter to exit.\"; read;'\n"; - - File.WriteAllText(scriptPath, scriptContent); - - // Try to make it executable - try { - System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo { - FileName = "chmod", - Arguments = $"+x \"{scriptPath}\"", - CreateNoWindow = true, - UseShellExecute = false - })?.WaitForExit(); - } catch { } - } + // No longer generating terminal_action.sh as Terminal skill now uses "type" action } } diff --git a/IO/TextInjector.cs b/IO/TextInjector.cs index d414424..adb0aa4 100644 --- a/IO/TextInjector.cs +++ b/IO/TextInjector.cs @@ -29,7 +29,7 @@ public class TextInjector : ITextInjector pInfo = new ProcessStartInfo { FileName = Toak.Core.Constants.Commands.TypeWayland, - Arguments = $"\"{text.Replace("\"", "\\\"")}\"", + Arguments = $"-d {Toak.Core.Constants.Defaults.DefaultTypeDelayMs} \"{text.Replace("\"", "\\\"")}\"", UseShellExecute = false, CreateNoWindow = true }; @@ -51,7 +51,7 @@ public class TextInjector : ITextInjector pInfo = new ProcessStartInfo { FileName = Toak.Core.Constants.Commands.TypeX11, - Arguments = $"type --clearmodifiers --delay 0 \"{text.Replace("\"", "\\\"")}\"", + Arguments = $"type --clearmodifiers --delay {Toak.Core.Constants.Defaults.DefaultTypeDelayMs} \"{text.Replace("\"", "\\\"")}\"", UseShellExecute = false, CreateNoWindow = true }; @@ -79,7 +79,7 @@ public class TextInjector : ITextInjector pInfo = new ProcessStartInfo { FileName = Toak.Core.Constants.Commands.TypeWayland, - Arguments = "-", + Arguments = $"-d {Toak.Core.Constants.Defaults.DefaultTypeDelayMs} -", UseShellExecute = false, CreateNoWindow = true, RedirectStandardInput = true @@ -110,7 +110,7 @@ public class TextInjector : ITextInjector pInfo = new ProcessStartInfo { FileName = Toak.Core.Constants.Commands.TypeX11, - Arguments = "type --clearmodifiers --delay 0 --file -", + Arguments = $"type --clearmodifiers --delay {Toak.Core.Constants.Defaults.DefaultTypeDelayMs} --file -", UseShellExecute = false, CreateNoWindow = true, RedirectStandardInput = true