mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-13 16:07:22 +00:00
Fixed line endings in the reflection folder and tests on Windows (#1192)
This commit is contained in:
1 parent
6f187f1bd8
commit
b1c1f13993
7 files changed
+157
-22
No files matched your search
@@ -2,6 +2,8 @@ using System.Text;
|
||||
|
||||
using AIStudio.Chat;
|
||||
|
||||
using SharedTools;
|
||||
|
||||
namespace AIStudio.Assistants.BeyondFactsLab;
|
||||
|
||||
/// <summary>
|
||||
@@ -12,7 +14,7 @@ namespace AIStudio.Assistants.BeyondFactsLab;
|
||||
/// No model takes part. The person confirmed every work state word for word, so the folder repeats them word for word
|
||||
/// instead of having a model rewrite them. A step without a confirmed work state is named, not filled. Personal
|
||||
/// disclosures stay out unless the person includes them, and so does the conversation of a step which may contain
|
||||
/// some: the folder is meant to be passed on.
|
||||
/// some: the folder is meant to be passed on. Every line ends with LF, on every system.
|
||||
/// </remarks>
|
||||
public static class BflReflectionFolder
|
||||
{
|
||||
@@ -33,7 +35,7 @@ public static class BflReflectionFolder
|
||||
public static string Build(BflReflectionFolderInput input)
|
||||
{
|
||||
var text = new StringBuilder();
|
||||
text.Append("# ").Append(Markdown.EscapeInlineText(BflResultKind.REFLECTION_FOLDER.Title)).Append(": ").AppendLine(Markdown.EscapeInlineText(input.ProjectName));
|
||||
text.Append("# ").Append(Markdown.EscapeInlineText(BflResultKind.REFLECTION_FOLDER.Title)).Append(": ").AppendLineLF(Markdown.EscapeInlineText(input.ProjectName));
|
||||
|
||||
foreach (var step in BflStep.All)
|
||||
AppendStep(text, step, input);
|
||||
@@ -78,15 +80,15 @@ public static class BflReflectionFolder
|
||||
/// <param name="input">What the folder is put together from.</param>
|
||||
private static void AppendStep(StringBuilder text, BflStep step, BflReflectionFolderInput input)
|
||||
{
|
||||
text.AppendLine().Append("## ").AppendLine(Markdown.EscapeInlineText(step.Title)).AppendLine();
|
||||
text.AppendLineLF().Append("## ").AppendLineLF(Markdown.EscapeInlineText(step.Title)).AppendLineLF();
|
||||
if (input.WorkStates.GetValueOrDefault(step)?.Confirmed is not { } confirmed)
|
||||
{
|
||||
text.Append('_').Append(Markdown.EscapeInlineText(TB("No confirmed work state."))).AppendLine("_");
|
||||
text.Append('_').Append(Markdown.EscapeInlineText(TB("No confirmed work state."))).AppendLineLF("_");
|
||||
return;
|
||||
}
|
||||
|
||||
var confirmedAt = confirmed.ConfirmedAtUtc.ToLocalTime().ToString("d", input.Culture);
|
||||
text.Append('_').Append(Markdown.EscapeInlineText(string.Format(input.Culture, TB("Version {0}, confirmed on {1}."), confirmed.Revision, confirmedAt))).AppendLine("_");
|
||||
text.Append('_').Append(Markdown.EscapeInlineText(string.Format(input.Culture, TB("Version {0}, confirmed on {1}."), confirmed.Revision, confirmedAt))).AppendLineLF("_");
|
||||
var notice = BflStaleness.Of(step, input.WorkStates, input.Forms) switch
|
||||
{
|
||||
BflWorkStateStatus.OUTDATED => TB("An earlier step changed after this confirmation."),
|
||||
@@ -95,14 +97,14 @@ public static class BflReflectionFolder
|
||||
};
|
||||
|
||||
if (notice.Length > 0)
|
||||
text.AppendLine().Append('_').Append(Markdown.EscapeInlineText(notice)).AppendLine("_");
|
||||
text.AppendLineLF().Append('_').Append(Markdown.EscapeInlineText(notice)).AppendLineLF("_");
|
||||
|
||||
foreach (var section in BflWorkStateSections.ForStep(step))
|
||||
{
|
||||
if (section.Key is OPEN_POINTS_KEY || section.IsPersonalDisclosure && !input.IncludePersonalDisclosures || !confirmed.Sections.TryGetValue(section.Key, out var sectionText) || string.IsNullOrWhiteSpace(sectionText))
|
||||
continue;
|
||||
|
||||
text.AppendLine().Append("### ").AppendLine(Markdown.EscapeInlineText(section.Title)).AppendLine().AppendLine(sectionText.Trim());
|
||||
text.AppendLineLF().Append("### ").AppendLineLF(Markdown.EscapeInlineText(section.Title)).AppendLineLF().AppendLineLF(WithLineBreaks(sectionText));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +115,7 @@ public static class BflReflectionFolder
|
||||
/// <param name="input">What the folder is put together from.</param>
|
||||
private static void AppendOpenPoints(StringBuilder text, BflReflectionFolderInput input)
|
||||
{
|
||||
text.AppendLine().Append("## ").AppendLine(Markdown.EscapeInlineText(TB("Open questions"))).AppendLine();
|
||||
text.AppendLineLF().Append("## ").AppendLineLF(Markdown.EscapeInlineText(TB("Open questions"))).AppendLineLF();
|
||||
var any = false;
|
||||
foreach (var step in BflStep.All)
|
||||
{
|
||||
@@ -121,11 +123,11 @@ public static class BflReflectionFolder
|
||||
continue;
|
||||
|
||||
any = true;
|
||||
text.Append("### ").AppendLine(Markdown.EscapeInlineText(step.Title)).AppendLine().AppendLine(openPoints.Trim()).AppendLine();
|
||||
text.Append("### ").AppendLineLF(Markdown.EscapeInlineText(step.Title)).AppendLineLF().AppendLineLF(WithLineBreaks(openPoints)).AppendLineLF();
|
||||
}
|
||||
|
||||
if (!any)
|
||||
text.Append('_').Append(Markdown.EscapeInlineText(TB("No confirmed work state names open questions."))).AppendLine("_");
|
||||
text.Append('_').Append(Markdown.EscapeInlineText(TB("No confirmed work state names open questions."))).AppendLineLF("_");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -135,15 +137,15 @@ public static class BflReflectionFolder
|
||||
/// <param name="input">What the folder is put together from.</param>
|
||||
private static void AppendMaterials(StringBuilder text, BflReflectionFolderInput input)
|
||||
{
|
||||
text.AppendLine().Append("## ").AppendLine(Markdown.EscapeInlineText(TB("Material"))).AppendLine();
|
||||
text.AppendLineLF().Append("## ").AppendLineLF(Markdown.EscapeInlineText(TB("Material"))).AppendLineLF();
|
||||
if (input.Materials.Count is 0)
|
||||
{
|
||||
text.Append('_').Append(Markdown.EscapeInlineText(TB("No material was added."))).AppendLine("_");
|
||||
text.Append('_').Append(Markdown.EscapeInlineText(TB("No material was added."))).AppendLineLF("_");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var material in input.Materials.OrderBy(material => material.AddedAtUtc))
|
||||
text.Append("- ").Append(Markdown.EscapeInlineText(material.Name)).Append(" (").Append(Markdown.EscapeInlineText(KindName(material.Kind))).AppendLine(")");
|
||||
text.Append("- ").Append(Markdown.EscapeInlineText(material.Name)).Append(" (").Append(Markdown.EscapeInlineText(KindName(material.Kind))).AppendLineLF(")");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -153,27 +155,36 @@ public static class BflReflectionFolder
|
||||
/// <param name="input">What the folder is put together from.</param>
|
||||
private static void AppendConversations(StringBuilder text, BflReflectionFolderInput input)
|
||||
{
|
||||
text.AppendLine().Append("## ").AppendLine(Markdown.EscapeInlineText(TB("Appendix: the conversations"))).AppendLine();
|
||||
text.AppendLineLF().Append("## ").AppendLineLF(Markdown.EscapeInlineText(TB("Appendix: the conversations"))).AppendLineLF();
|
||||
foreach (var step in BflStep.All)
|
||||
{
|
||||
if (!input.Conversations.TryGetValue(step, out var messages) || messages.Count is 0)
|
||||
continue;
|
||||
|
||||
text.Append("### ").AppendLine(Markdown.EscapeInlineText(step.Title)).AppendLine();
|
||||
text.Append("### ").AppendLineLF(Markdown.EscapeInlineText(step.Title)).AppendLineLF();
|
||||
if (!input.IncludePersonalDisclosures && MayHoldPersonalDisclosures(step))
|
||||
{
|
||||
text.Append('_').Append(Markdown.EscapeInlineText(TB("Left out, as it may contain personal disclosures."))).AppendLine("_").AppendLine();
|
||||
text.Append('_').Append(Markdown.EscapeInlineText(TB("Left out, as it may contain personal disclosures."))).AppendLineLF("_").AppendLineLF();
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var message in messages)
|
||||
{
|
||||
var speaker = message.IsFromPerson ? TA("You") : TB("Lab");
|
||||
text.Append("**").Append(Markdown.EscapeInlineText(speaker)).AppendLine(":**").AppendLine().AppendLine(message.Text).AppendLine();
|
||||
text.Append("**").Append(Markdown.EscapeInlineText(speaker)).AppendLineLF(":**").AppendLineLF().AppendLineLF(WithLineBreaks(message.Text)).AppendLineLF();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a text which the person or a model wrote, trimmed and with LF line breaks.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A model may answer with CR LF; without this, the folder would mix two kinds of line breaks.
|
||||
/// </remarks>
|
||||
/// <param name="text">The text.</param>
|
||||
private static string WithLineBreaks(string text) => text.Trim().ReplaceLineEndings("\n");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of a kind of material.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user