Added an analyzer which keeps line breaks LF on every system (#1193)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-11 19:30:00 +01:00
1 parent b1c1f13993
commit 65d50de033
96 files changed
+741 -393

No files matched your search

@@ -89,11 +89,11 @@ public sealed class CountMailsTool(SettingsManager settingsManager, MailboxRetri
internal static ToolFunctionDefinition DescribeMailboxes(ToolFunctionDefinition function, IReadOnlyList<DataSourceMailbox> mailboxes)
{
var description = new StringBuilder(DESCRIPTION);
description.AppendLine();
description.AppendLine();
description.AppendLine($"The mailboxes you may count, by the ID to pass in {MailToolArguments.MAILBOX_IDS_ARGUMENT}:");
description.AppendLineLF();
description.AppendLineLF();
description.AppendLineLF($"The mailboxes you may count, by the ID to pass in {MailToolArguments.MAILBOX_IDS_ARGUMENT}:");
foreach (var mailbox in mailboxes)
description.AppendLine($"- id={mailbox.Id}, name='{mailbox.Name}'");
description.AppendLineLF($"- id={mailbox.Id}, name='{mailbox.Name}'");
return function with
{
@@ -54,9 +54,9 @@ internal static class MailToolResults
if (!string.IsNullOrWhiteSpace(text))
{
builder.AppendLine();
builder.AppendLine("---");
builder.AppendLine();
builder.AppendLineLF();
builder.AppendLineLF("---");
builder.AppendLineLF();
builder.Append(text);
}
@@ -65,7 +65,7 @@ internal static class MailToolResults
void AppendField(string label, string? value)
{
if (!string.IsNullOrWhiteSpace(value))
builder.AppendLine($"- **{label}:** {value}");
builder.AppendLineLF($"- **{label}:** {value}");
}
}
@@ -135,11 +135,11 @@ public sealed class SearchMailsTool(SettingsManager settingsManager, MailboxRetr
internal static ToolFunctionDefinition DescribeMailboxes(ToolFunctionDefinition function, IReadOnlyList<DataSourceMailbox> mailboxes)
{
var description = new StringBuilder(DESCRIPTION);
description.AppendLine();
description.AppendLine();
description.AppendLine($"The mailboxes you may search, by the ID to pass in {MailToolArguments.MAILBOX_IDS_ARGUMENT}:");
description.AppendLineLF();
description.AppendLineLF();
description.AppendLineLF($"The mailboxes you may search, by the ID to pass in {MailToolArguments.MAILBOX_IDS_ARGUMENT}:");
foreach (var mailbox in mailboxes)
description.AppendLine($"- id={mailbox.Id}, name='{mailbox.Name}'");
description.AppendLineLF($"- id={mailbox.Id}, name='{mailbox.Name}'");
return function with
{
@@ -286,21 +286,21 @@ public sealed class SemanticSearchTool(SettingsManager settingsManager, DataSour
internal static ToolFunctionDefinition DescribeDataSources(ToolFunctionDefinition function, IReadOnlyList<(IDataSource DataSource, string Description)> dataSources, IReadOnlyList<IDataSource>? unreachableDataSources = null)
{
var description = new StringBuilder(DESCRIPTION);
description.AppendLine();
description.AppendLine();
description.AppendLine($"The data sources you may search, by the ID to pass in {DATA_SOURCE_IDS_ARGUMENT}:");
description.AppendLineLF();
description.AppendLineLF();
description.AppendLineLF($"The data sources you may search, by the ID to pass in {DATA_SOURCE_IDS_ARGUMENT}:");
foreach (var (dataSource, dataSourceDescription) in dataSources)
{
description.Append($"- id={dataSource.Id}, name='{dataSource.Name}', type={GetKind(dataSource)}");
if (!string.IsNullOrWhiteSpace(dataSourceDescription))
description.Append($", description='{dataSourceDescription.Trim().Shorten(MAX_DESCRIPTION_CHARACTERS)}'");
description.AppendLine();
description.AppendLineLF();
}
if (unreachableDataSources is { Count: > 0 })
{
description.AppendLine();
description.AppendLineLF();
UnreachableDataSources.AppendTo(description, unreachableDataSources);
}
@@ -50,7 +50,7 @@ public static class ToolSelectionRules
public static string BuildToolPolicyPrompt(IEnumerable<ToolDefinition> definitions)
{
var policySections = GetInstructedTools(definitions)
.Select(x => $"## Tool `{x.Function.Name}`{Environment.NewLine}{x.SystemPromptInstructions.Trim()}")
.Select(x => $"## Tool `{x.Function.Name}`\n{x.SystemPromptInstructions.Trim()}")
.Distinct(StringComparer.Ordinal)
.ToList();
if (policySections.Count == 0)
@@ -60,7 +60,7 @@ public static class ToolSelectionRules
# Tool usage instructions:
You have multiple tools available. Each tool has a different purpose and usage policy. Choose wisely and if you are not sure, always ask the user for clarification. You must follow the usage policy of each tool to ensure accurate and reliable results. Here are the usage policies for each tool:
{string.Join(Environment.NewLine+Environment.NewLine, policySections)}
{string.Join("\n\n", policySections)}
""";
return toolPolicyPrompt;
@@ -159,7 +159,7 @@ public sealed partial class ToolSettingsService
// dictionary rather than this tool's entry. A comment says the same thing without
// overwriting anything:
//
lua.AppendLine($"-- The whole table is locked unless you set CONFIG[\"SETTINGS\"][\"{MINIMUM_CONFIDENCE}.AllowUserOverride\"] = true");
lua.AppendLineLF($"-- The whole table is locked unless you set CONFIG[\"SETTINGS\"][\"{MINIMUM_CONFIDENCE}.AllowUserOverride\"] = true");
}
return new(LuaCode: lua.ToString());
@@ -177,9 +177,9 @@ public sealed partial class ToolSettingsService
var table = $"CONFIG[\"SETTINGS\"][\"{settingName}\"]";
if (lua.Length > 0)
lua.AppendLine();
lua.AppendLine($"{table} = {table} or {{}}");
lua.AppendLineLF();
lua.AppendLineLF($"{table} = {table} or {{}}");
foreach (var (key, value) in values)
lua.AppendLine($"{table}[\"{LuaTools.EscapeLuaString(key)}\"] = \"{LuaTools.EscapeLuaString(value)}\"");
lua.AppendLineLF($"{table}[\"{LuaTools.EscapeLuaString(key)}\"] = \"{LuaTools.EscapeLuaString(value)}\"");
}
}