feat: Implement new commands for recording control, configuration management, latency testing, and status display, updating program entry and project references.
This commit is contained in:
74
Commands/OnboardCommand.cs
Normal file
74
Commands/OnboardCommand.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Spectre.Console;
|
||||
using Toak.Configuration;
|
||||
using Toak.Core.Skills;
|
||||
|
||||
namespace Toak.Commands;
|
||||
|
||||
public static class OnboardCommand
|
||||
{
|
||||
public static async Task ExecuteAsync(bool verbose)
|
||||
{
|
||||
Toak.Core.Logger.Verbose = verbose;
|
||||
var config = ConfigManager.LoadConfig();
|
||||
|
||||
AnsiConsole.Write(new FigletText("Toak").Color(Color.Green));
|
||||
AnsiConsole.MarkupLine("[grey]Welcome to the Toak configuration wizard.[/]");
|
||||
AnsiConsole.WriteLine();
|
||||
|
||||
config.GroqApiKey = AnsiConsole.Prompt(
|
||||
new TextPrompt<string>("Groq API Key:")
|
||||
.DefaultValue(string.IsNullOrWhiteSpace(config.GroqApiKey) ? "" : config.GroqApiKey)
|
||||
.AllowEmpty());
|
||||
|
||||
config.LlmModel = AnsiConsole.Prompt(
|
||||
new SelectionPrompt<string>()
|
||||
.Title("Select [green]LLM Model[/]:")
|
||||
.AddChoices(new[] { "openai/gpt-oss-20b", "llama-3.1-8b-instant" })
|
||||
.UseConverter(c => c == "openai/gpt-oss-20b" ? "openai/gpt-oss-20b (Fastest)" : "llama-3.1-8b-instant (Cheapest)"));
|
||||
|
||||
if (config.LlmModel.Contains(" ")) config.LlmModel = config.LlmModel.Split(' ')[0];
|
||||
|
||||
config.WhisperModel = AnsiConsole.Prompt(
|
||||
new SelectionPrompt<string>()
|
||||
.Title("Select [green]Whisper Model[/]:")
|
||||
.AddChoices(new[] { "whisper-large-v3", "whisper-large-v3-turbo" })
|
||||
.UseConverter(c => c == "whisper-large-v3" ? "whisper-large-v3 (Accurate)" : "whisper-large-v3-turbo (Fast)"));
|
||||
|
||||
config.WhisperLanguage = AnsiConsole.Prompt(
|
||||
new TextPrompt<string>("Microphone Spoken Language (e.g. en, es, zh):")
|
||||
.DefaultValue(string.IsNullOrWhiteSpace(config.WhisperLanguage) ? "en" : config.WhisperLanguage)
|
||||
.AllowEmpty()
|
||||
.Validate(lang =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(lang)) return ValidationResult.Success();
|
||||
if (lang.Contains(",") || lang.Contains(" "))
|
||||
return ValidationResult.Error("[red]Please provide only one language code (e.g., 'en' not 'en, es')[/]");
|
||||
|
||||
return ValidationResult.Success();
|
||||
}));
|
||||
|
||||
config.TypingBackend = AnsiConsole.Prompt(
|
||||
new SelectionPrompt<string>()
|
||||
.Title("Select [green]Typing Backend[/]:")
|
||||
.AddChoices(new[] { "wtype", "xdotool" }));
|
||||
|
||||
var availableSkills = SkillRegistry.AllSkills.Select(s => s.Name).ToList();
|
||||
|
||||
if (availableSkills.Any())
|
||||
{
|
||||
config.ActiveSkills = AnsiConsole.Prompt(
|
||||
new MultiSelectionPrompt<string>()
|
||||
.Title("Select [green]Active Skills[/]:")
|
||||
.NotRequired()
|
||||
.InstructionsText("[grey](Press [blue]<space>[/] to toggle a skill, [green]<enter>[/] to accept)[/]")
|
||||
.AddChoices(availableSkills));
|
||||
}
|
||||
|
||||
ConfigManager.SaveConfig(config);
|
||||
|
||||
AnsiConsole.MarkupLine("\n[bold green]Configuration saved successfully![/]");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user