added openrouter ai generated tasks

This commit is contained in:
masongga
2026-05-23 23:20:41 -06:00
parent 5f0bbaf3cf
commit c5b20e094e
15 changed files with 1213 additions and 87 deletions

25
lib/ai-task-fallback.ts Normal file
View File

@@ -0,0 +1,25 @@
import type { AiTaskContext } from "@/lib/ai-task-context";
import { buildJournalAwareFallbackLabels } from "@/lib/ai-journal-hints";
import {
habitCatalog,
matchesFocusTopics,
matchesQuizAnswers,
} from "@/lib/habit-catalog";
import { sanitizePlausibleAiTaskLabels } from "@/lib/ai-habit-utils";
export function buildFallbackAiTaskLabels(context: AiTaskContext): string[] {
const labels = new Set<string>(buildJournalAwareFallbackLabels(context));
for (const entry of habitCatalog) {
const fromFocus = matchesFocusTopics(entry, context.preferences);
const fromQuiz = context.dailyQuiz
? matchesQuizAnswers(entry, context.dailyQuiz)
: false;
if (fromFocus || fromQuiz) {
labels.add(entry.label);
}
}
return sanitizePlausibleAiTaskLabels(Array.from(labels));
}