1
0

feat: Implement direct typing for the Terminal skill with a new default delay for text injection.

This commit is contained in:
2026-02-28 17:05:14 +01:00
parent ee50b9464a
commit 8ec0629e1a
3 changed files with 8 additions and 34 deletions

View File

@@ -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
}
}