From 7c9794f8d4d05074b96bb525d19db4ee1f6b3e95 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Tue, 11 Aug 2026 21:53:57 +0900 Subject: Complete runtime diagnostics and verification coverage --- src/Agent.App/Agent.App.csproj | 3 +++ src/Agent.App/Program.cs | 28 ++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src/Agent.App') diff --git a/src/Agent.App/Agent.App.csproj b/src/Agent.App/Agent.App.csproj index 4059624..17b7bc9 100644 --- a/src/Agent.App/Agent.App.csproj +++ b/src/Agent.App/Agent.App.csproj @@ -10,6 +10,9 @@ + + + diff --git a/src/Agent.App/Program.cs b/src/Agent.App/Program.cs index 6f3485f..3d2d2db 100644 --- a/src/Agent.App/Program.cs +++ b/src/Agent.App/Program.cs @@ -110,7 +110,7 @@ internal static class Program } catch (Exception ex) when (ex is CommandLineException or ConfigurationException or LocaleException or IOException or UnauthorizedAccessException) { - Console.Error.WriteLine($"agent-mcp: {ex.Message}"); + Console.Error.WriteLine($"agent-mcp: {FormatStartupError(args, ex)}"); return 2; } catch (Exception ex) when (ex is not (OutOfMemoryException or StackOverflowException or AccessViolationException)) @@ -120,6 +120,30 @@ internal static class Program } } + internal static string FormatStartupError(string[] args, Exception error) + { + string language = "en"; + for (int i = 0; i + 1 < args.Length; i++) + if (args[i] == "--lang") language = args[i + 1]; + try + { + string directory = Path.Combine(AppContext.BaseDirectory, "config", "locales"); + LocaleCatalog locale = LocaleCatalog.Load(directory, language, "en"); + string key = error switch + { + CommandLineException => "cli.invalid", + ConfigurationException => "config.invalid", + LocaleException => "locale.invalid", + _ => "app.io_error" + }; + return locale.Format(key, new Dictionary { ["message"] = error.Message }); + } + catch + { + return error.Message; + } + } + private static InternalToolDispatcher CreateToolDispatcher(AgentConfiguration configuration, string baseDirectory, string logDirectory, SessionStore? sessionStore = null) { string stateDirectory = Path.Combine(baseDirectory, "state"); @@ -155,7 +179,7 @@ internal static class Program } } - private static AgentRuntimeSettings CreateRuntimeSettings(AgentConfiguration configuration, string userPrompt, string language, + internal static AgentRuntimeSettings CreateRuntimeSettings(AgentConfiguration configuration, string userPrompt, string language, IReadOnlyList skills, LocaleCatalog locale) => new( userPrompt, language, -- cgit v1.2.3