1
0

chore: Introduce Qodana static analysis configuration and apply minor code formatting and C# 12 collection expressions.

This commit is contained in:
2026-03-01 20:07:20 +01:00
parent ec575ab5f9
commit 15f9647f8a
24 changed files with 344 additions and 80 deletions

View File

@@ -11,18 +11,18 @@ public static class DiscardCommand
public static async Task ExecuteAsync(bool pipeToStdout, bool verbose)
{
Logger.Verbose = verbose;
var socketPath = DaemonService.GetSocketPath();
try
{
using var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
var endPoint = new UnixDomainSocketEndPoint(socketPath);
await socket.ConnectAsync(endPoint);
// Send ABORT (cmd == 3)
await socket.SendAsync(new byte[] { 3 }, SocketFlags.None);
if (verbose)
{
Console.WriteLine("Sent ABORT command to daemon.");

View File

@@ -34,11 +34,11 @@ public static class HistoryCommand
// Apply grep filter
if (!string.IsNullOrWhiteSpace(grep))
{
entries = entries.Where(e =>
e.RawTranscript.Contains(grep, StringComparison.OrdinalIgnoreCase) ||
entries = entries.Where(e =>
e.RawTranscript.Contains(grep, StringComparison.OrdinalIgnoreCase) ||
e.RefinedText.Contains(grep, StringComparison.OrdinalIgnoreCase))
.ToList();
if (entries.Count == 0)
{
AnsiConsole.MarkupLine($"[yellow]No history entries match '{grep}'.[/]");

View File

@@ -23,7 +23,7 @@ public static class LatencyTestCommand
AnsiConsole.MarkupLine("Generating 1-second silent audio file for testing...");
var testWavPath = Constants.Paths.LatencyTestWavFile;
var pInfo = new ProcessStartInfo
{
FileName = Constants.Commands.AudioFfmpeg,
@@ -43,17 +43,17 @@ public static class LatencyTestCommand
}
var client = new OpenAiCompatibleClient(config.GroqApiKey);
try
{
await AnsiConsole.Status()
.StartAsync("Running latency test...", async ctx =>
.StartAsync("Running latency test...", async ctx =>
{
ctx.Status("Testing STT (Whisper)...");
var sttWatch = Stopwatch.StartNew();
var transcript = await client.TranscribeAsync(testWavPath, config.WhisperLanguage, config.WhisperModel);
sttWatch.Stop();
ctx.Status("Testing LLM (Llama)...");
var systemPrompt = PromptBuilder.BuildPrompt(config);
var llmWatch = Stopwatch.StartNew();
@@ -66,7 +66,7 @@ public static class LatencyTestCommand
var table = new Table();
table.AddColumn("Operation");
table.AddColumn("Latency (ms)");
table.AddRow("STT", sttWatch.ElapsedMilliseconds.ToString());
table.AddRow("LLM", llmWatch.ElapsedMilliseconds.ToString());
table.AddRow("[bold]Total[/]", $"[bold]{total}ms[/]");

View File

@@ -37,7 +37,7 @@ public static class OnboardCommand
new TextPrompt<string>("Together AI API Key:")
.DefaultValue(string.IsNullOrWhiteSpace(config.TogetherApiKey) ? "" : config.TogetherApiKey)
.AllowEmpty());
config.LlmModel = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("Select [green]LLM Model[/]:")
@@ -50,7 +50,7 @@ public static class OnboardCommand
.Title("Select [green]LLM Model[/]:")
.AddChoices(new[] { "openai/gpt-oss-20b", "llama-3.1-8b-instant", "llama-3.3-70b-versatile" })
.UseConverter(c => c == "openai/gpt-oss-20b" ? "openai/gpt-oss-20b (Fastest)" : c == "llama-3.1-8b-instant" ? "llama-3.1-8b-instant (Cheapest)" : "llama-3.3-70b-versatile (More Accurate)"));
if (config.LlmModel.Contains(" ")) config.LlmModel = config.LlmModel.Split(' ')[0];
}
@@ -70,12 +70,12 @@ public static class OnboardCommand
new TextPrompt<string>("Microphone Spoken Language (e.g. en, es, zh):")
.DefaultValue(string.IsNullOrWhiteSpace(config.WhisperLanguage) ? "en" : config.WhisperLanguage)
.AllowEmpty()
.Validate(lang =>
.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();
}));
@@ -94,7 +94,7 @@ public static class OnboardCommand
.UseConverter(c => c == "pw-record" ? "pw-record (Default PipeWire)" : "ffmpeg (Universal PulseAudio)"));
var availableSkills = SkillRegistry.AllSkills.Select(s => s.Name).ToList();
if (availableSkills.Any())
{
config.ActiveSkills = AnsiConsole.Prompt(
@@ -106,7 +106,7 @@ public static class OnboardCommand
}
configManager.SaveConfig(config);
AnsiConsole.MarkupLine("\n[bold green]Configuration saved successfully![/]");
try

View File

@@ -37,7 +37,7 @@ public static class SkillCommand
private static async Task ExecuteListAsync()
{
SkillRegistry.Initialize();
var table = new Table().Border(TableBorder.Rounded);
table.AddColumn("Name");
table.AddColumn("Action");
@@ -68,13 +68,13 @@ public static class SkillCommand
private static async Task ExecuteAddAsync()
{
AnsiConsole.MarkupLine("[bold blue]Add a new Dynamic Skill[/]");
var name = AnsiConsole.Ask<string>("Skill [green]Name[/]:");
var description = AnsiConsole.Ask<string>("Skill [green]Description[/]:");
var hotwordsStr = AnsiConsole.Ask<string>("Comma-separated [green]Hotwords[/] (e.g. 'System my skill, System do skill'):");
var hotwords = hotwordsStr.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
var action = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("What is the [green]Action[/] type?")

View File

@@ -23,7 +23,7 @@ public static class StatsCommand
var totalCount = entries.Count;
var totalDuration = TimeSpan.FromMilliseconds(entries.Sum(e => e.DurationMs));
var avgDuration = TimeSpan.FromMilliseconds(entries.Average(e => e.DurationMs));
var mostActiveDay = entries
.GroupBy(e => e.Timestamp.Date)
.OrderByDescending(g => g.Count())
@@ -42,12 +42,12 @@ public static class StatsCommand
AnsiConsole.MarkupLine($"[dim]Total recordings:[/] {totalCount}");
AnsiConsole.MarkupLine($"[dim]Total duration:[/] {totalDuration.TotalMinutes:F1}m");
AnsiConsole.MarkupLine($"[dim]Average processing latency:[/] {avgDuration.TotalSeconds:F2}s");
if (mostActiveDay != null)
{
AnsiConsole.MarkupLine($"[dim]Most active day:[/] {mostActiveDay.Key:yyyy-MM-dd} ({mostActiveDay.Count()} recordings)");
}
if (topWords.Count > 0)
{
AnsiConsole.MarkupLine($"[dim]Top spoken words (>3 chars):[/] {string.Join(", ", topWords)}");

View File

@@ -11,18 +11,18 @@ public static class StatusCommand
public static async Task ExecuteAsync(bool json, bool verbose)
{
Logger.Verbose = verbose;
var socketPath = DaemonService.GetSocketPath();
try
{
using var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
var endPoint = new UnixDomainSocketEndPoint(socketPath);
await socket.ConnectAsync(endPoint);
var msg = new byte[] { 5, (byte)(json ? 1 : 0) };
await socket.SendAsync(msg, SocketFlags.None);
var responseBuffer = new byte[4096];
int received = await socket.ReceiveAsync(responseBuffer, SocketFlags.None);
if (received > 0)

View File

@@ -17,11 +17,11 @@ public static class StopCommand
using var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
var endPoint = new UnixDomainSocketEndPoint(socketPath);
await socket.ConnectAsync(endPoint);
var msg = new byte[] { 2, (byte)(pipeToStdout ? 1 : 0), (byte)(copyToClipboard ? 1 : 0) };
await socket.SendAsync(msg, SocketFlags.None);
if (verbose) Console.WriteLine("Sent STOP command to daemon.");
var responseBuffer = new byte[4096];
while (true)
{

View File

@@ -11,19 +11,19 @@ public static class ToggleCommand
public static async Task ExecuteAsync(bool pipeToStdout, bool copyToClipboard, bool verbose)
{
Logger.Verbose = verbose;
var socketPath = DaemonService.GetSocketPath();
try
{
using var socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified);
var endPoint = new UnixDomainSocketEndPoint(socketPath);
await socket.ConnectAsync(endPoint);
// Send TOGGLE (cmd == 4), pipeToStdout, copyToClipboard
var msg = new byte[] { 4, (byte)(pipeToStdout ? 1 : 0), (byte)(copyToClipboard ? 1 : 0) };
await socket.SendAsync(msg, SocketFlags.None);
if (verbose)
{
Console.WriteLine("Sent TOGGLE command to daemon.");
@@ -36,7 +36,7 @@ public static class ToggleCommand
{
int received = await socket.ReceiveAsync(responseBuffer, SocketFlags.None);
if (received == 0) break; // socket closed by daemon
if (pipeToStdout)
{
var text = System.Text.Encoding.UTF8.GetString(responseBuffer, 0, received);