Document persistence architecture and report-skill parity

This commit is contained in:
Jacob Dubin
2026-05-17 00:41:09 -05:00
parent a8a153e910
commit 5d57095ce5
8 changed files with 320 additions and 4 deletions

View File

@@ -30,6 +30,14 @@ public sealed class JiboExperienceCatalog
public IReadOnlyList<string> WeatherTodayHighLowReplies { get; init; } = [];
public IReadOnlyList<string> WeatherTomorrowHighLowReplies { get; init; } = [];
public IReadOnlyList<string> WeatherServiceDownReplies { get; init; } = [];
public IReadOnlyList<string> CalendarNothingTodayReplies { get; init; } = [];
public IReadOnlyList<string> CalendarNothingReplies { get; init; } = [];
public IReadOnlyList<string> CalendarOutroReplies { get; init; } = [];
public IReadOnlyList<string> CommuteNowReplies { get; init; } = [];
public IReadOnlyList<string> CommuteServiceDownReplies { get; init; } = [];
public IReadOnlyList<string> NewsIntroReplies { get; init; } = [];
public IReadOnlyList<string> NewsCategoryIntroReplies { get; init; } = [];
public IReadOnlyList<string> NewsOutroReplies { get; init; } = [];
public IReadOnlyList<string> WeatherReplies { get; init; } = [];
public IReadOnlyList<string> CalendarReplies { get; init; } = [];
public IReadOnlyList<string> CommuteReplies { get; init; } = [];

View File

@@ -292,17 +292,50 @@ internal static class PersonalReportOrchestrator
if (toggles.CalendarEnabled)
{
reportSections.Add(randomizer.Choose(catalog.CalendarReplies));
reportSections.Add(
RenderReportSkillTemplate(
ChooseReportSkillTemplate(
catalog.CalendarNothingTodayReplies,
catalog.CalendarNothingReplies,
"Looking at your calendar, I don't see anything scheduled today."),
userName));
reportSections.Add(
RenderReportSkillTemplate(
ChooseReportSkillTemplate(
catalog.CalendarOutroReplies,
[],
"And that's it."),
userName));
}
if (toggles.CommuteEnabled)
{
reportSections.Add(randomizer.Choose(catalog.CommuteReplies));
reportSections.Add(
RenderReportSkillTemplate(
ChooseReportSkillTemplate(
catalog.CommuteServiceDownReplies,
catalog.CommuteNowReplies,
"Sorry, commute information isn't available right now."),
userName));
}
if (toggles.NewsEnabled)
{
reportSections.Add(
RenderReportSkillTemplate(
ChooseReportSkillTemplate(
catalog.NewsIntroReplies,
catalog.NewsCategoryIntroReplies,
"Here's today's news, from the associated press."),
userName));
reportSections.Add(randomizer.Choose(catalog.NewsBriefings));
reportSections.Add(
RenderReportSkillTemplate(
ChooseReportSkillTemplate(
catalog.NewsOutroReplies,
[],
"And that's what's new in the news."),
userName));
}
reportSections.Add(
@@ -697,4 +730,33 @@ internal static class PersonalReportOrchestrator
.Replace(" ", " ", StringComparison.Ordinal)
.Trim();
}
private static string ChooseReportSkillTemplate(
IReadOnlyList<string> primaryTemplates,
IReadOnlyList<string> secondaryTemplates,
string fallback)
{
var primary = primaryTemplates.FirstOrDefault(static template => !string.IsNullOrWhiteSpace(template));
if (!string.IsNullOrWhiteSpace(primary))
{
return primary!;
}
var secondary = secondaryTemplates.FirstOrDefault(static template => !string.IsNullOrWhiteSpace(template));
if (!string.IsNullOrWhiteSpace(secondary))
{
return secondary!;
}
return fallback;
}
private static string RenderReportSkillTemplate(string template, string userName)
{
return template
.Replace("${speaker}", userName, StringComparison.OrdinalIgnoreCase)
.Replace("${speaker}'s", $"{userName}'s", StringComparison.OrdinalIgnoreCase)
.Replace(" ", " ", StringComparison.Ordinal)
.Trim();
}
}

View File

@@ -154,6 +154,46 @@ public static class LegacyMimCatalogImporter
return LegacyMimBucket.WeatherServiceDown;
}
if (fileName.StartsWith("CalendarNothingToday", StringComparison.OrdinalIgnoreCase))
{
return LegacyMimBucket.CalendarNothingToday;
}
if (fileName.StartsWith("CalendarNothing", StringComparison.OrdinalIgnoreCase))
{
return LegacyMimBucket.CalendarNothing;
}
if (fileName.StartsWith("CalendarOutro", StringComparison.OrdinalIgnoreCase))
{
return LegacyMimBucket.CalendarOutro;
}
if (fileName.StartsWith("CommuteNow", StringComparison.OrdinalIgnoreCase))
{
return LegacyMimBucket.CommuteNow;
}
if (fileName.StartsWith("CommuteServiceDown", StringComparison.OrdinalIgnoreCase))
{
return LegacyMimBucket.CommuteServiceDown;
}
if (fileName.StartsWith("NewsIntroCategory", StringComparison.OrdinalIgnoreCase))
{
return LegacyMimBucket.NewsCategoryIntro;
}
if (fileName.StartsWith("NewsIntro", StringComparison.OrdinalIgnoreCase))
{
return LegacyMimBucket.NewsIntro;
}
if (fileName.StartsWith("NewsOutro", StringComparison.OrdinalIgnoreCase))
{
return LegacyMimBucket.NewsOutro;
}
if (fileName.StartsWith("Weather", StringComparison.OrdinalIgnoreCase) ||
string.Equals(fileName, "WetNowDryLater", StringComparison.OrdinalIgnoreCase))
{
@@ -266,6 +306,14 @@ public static class LegacyMimCatalogImporter
WeatherTodayHighLowReplies = Merge(baseCatalog.WeatherTodayHighLowReplies, importedCatalog.WeatherTodayHighLowReplies),
WeatherTomorrowHighLowReplies = Merge(baseCatalog.WeatherTomorrowHighLowReplies, importedCatalog.WeatherTomorrowHighLowReplies),
WeatherServiceDownReplies = Merge(baseCatalog.WeatherServiceDownReplies, importedCatalog.WeatherServiceDownReplies),
CalendarNothingTodayReplies = Merge(baseCatalog.CalendarNothingTodayReplies, importedCatalog.CalendarNothingTodayReplies),
CalendarNothingReplies = Merge(baseCatalog.CalendarNothingReplies, importedCatalog.CalendarNothingReplies),
CalendarOutroReplies = Merge(baseCatalog.CalendarOutroReplies, importedCatalog.CalendarOutroReplies),
CommuteNowReplies = Merge(baseCatalog.CommuteNowReplies, importedCatalog.CommuteNowReplies),
CommuteServiceDownReplies = Merge(baseCatalog.CommuteServiceDownReplies, importedCatalog.CommuteServiceDownReplies),
NewsIntroReplies = Merge(baseCatalog.NewsIntroReplies, importedCatalog.NewsIntroReplies),
NewsCategoryIntroReplies = Merge(baseCatalog.NewsCategoryIntroReplies, importedCatalog.NewsCategoryIntroReplies),
NewsOutroReplies = Merge(baseCatalog.NewsOutroReplies, importedCatalog.NewsOutroReplies),
WeatherReplies = Merge(baseCatalog.WeatherReplies, importedCatalog.WeatherReplies),
CalendarReplies = Merge(baseCatalog.CalendarReplies, importedCatalog.CalendarReplies),
CommuteReplies = Merge(baseCatalog.CommuteReplies, importedCatalog.CommuteReplies),
@@ -347,6 +395,14 @@ public static class LegacyMimCatalogImporter
WeatherTodayHighLow,
WeatherTomorrowHighLow,
WeatherServiceDown,
CalendarNothingToday,
CalendarNothing,
CalendarOutro,
CommuteNow,
CommuteServiceDown,
NewsIntro,
NewsCategoryIntro,
NewsOutro,
ReportSkillTemplate
}
@@ -365,6 +421,14 @@ public static class LegacyMimCatalogImporter
private readonly List<string> _weatherTodayHighLowReplies = [];
private readonly List<string> _weatherTomorrowHighLowReplies = [];
private readonly List<string> _weatherServiceDownReplies = [];
private readonly List<string> _calendarNothingTodayReplies = [];
private readonly List<string> _calendarNothingReplies = [];
private readonly List<string> _calendarOutroReplies = [];
private readonly List<string> _commuteNowReplies = [];
private readonly List<string> _commuteServiceDownReplies = [];
private readonly List<string> _newsIntroReplies = [];
private readonly List<string> _newsCategoryIntroReplies = [];
private readonly List<string> _newsOutroReplies = [];
public void Add(LegacyMimBucket bucket, string? condition, string text)
{
@@ -438,6 +502,30 @@ public static class LegacyMimCatalogImporter
case LegacyMimBucket.WeatherServiceDown:
AddDistinct(_weatherServiceDownReplies, text);
return;
case LegacyMimBucket.CalendarNothingToday:
AddDistinct(_calendarNothingTodayReplies, text);
return;
case LegacyMimBucket.CalendarNothing:
AddDistinct(_calendarNothingReplies, text);
return;
case LegacyMimBucket.CalendarOutro:
AddDistinct(_calendarOutroReplies, text);
return;
case LegacyMimBucket.CommuteNow:
AddDistinct(_commuteNowReplies, text);
return;
case LegacyMimBucket.CommuteServiceDown:
AddDistinct(_commuteServiceDownReplies, text);
return;
case LegacyMimBucket.NewsIntro:
AddDistinct(_newsIntroReplies, text);
return;
case LegacyMimBucket.NewsCategoryIntro:
AddDistinct(_newsCategoryIntroReplies, text);
return;
case LegacyMimBucket.NewsOutro:
AddDistinct(_newsOutroReplies, text);
return;
case LegacyMimBucket.ReportSkillTemplate:
AddDistinct(_reportSkillTemplates, text);
return;
@@ -463,6 +551,15 @@ public static class LegacyMimCatalogImporter
WeatherTodayHighLowReplies = [.. _weatherTodayHighLowReplies],
WeatherTomorrowHighLowReplies = [.. _weatherTomorrowHighLowReplies],
WeatherServiceDownReplies = [.. _weatherServiceDownReplies]
,
CalendarNothingTodayReplies = [.. _calendarNothingTodayReplies],
CalendarNothingReplies = [.. _calendarNothingReplies],
CalendarOutroReplies = [.. _calendarOutroReplies],
CommuteNowReplies = [.. _commuteNowReplies],
CommuteServiceDownReplies = [.. _commuteServiceDownReplies],
NewsIntroReplies = [.. _newsIntroReplies],
NewsCategoryIntroReplies = [.. _newsCategoryIntroReplies],
NewsOutroReplies = [.. _newsOutroReplies]
};
}