added security checks for journal text box for AI

This commit is contained in:
masongga
2026-05-23 23:55:25 -06:00
parent bffe0f941c
commit 25fb5499c1
9 changed files with 395 additions and 70 deletions

View File

@@ -15,20 +15,24 @@ export function getGenerationSlotCount(
}
export function buildGenerationUserPrompt(
context: AiTaskContext,
_context: AiTaskContext,
options?: AiTaskGenerationOptions,
) {
const maxCount = options?.maxCount ?? MAX_DAILY_AI_TASKS;
const excludeLabels = options?.excludeLabels ?? [];
if (excludeLabels.length === 0) {
return `Generate today's personalized habit task labels as a JSON array of up to ${maxCount} strings.`;
}
const baseRequest =
excludeLabels.length === 0
? `Generate today's personalized habit task labels as a JSON array of up to ${maxCount} strings.`
: [
`Generate exactly ${maxCount} NEW habit task labels as a JSON array of strings.`,
"Do not repeat or rephrase any of these existing tasks the user already has:",
...excludeLabels.map((label) => `- ${label}`),
"Use different wording only for genuinely different activities.",
].join("\n");
return [
`Generate exactly ${maxCount} NEW habit task labels as a JSON array of strings.`,
"Do not repeat or rephrase any of these existing tasks the user already has:",
...excludeLabels.map((label) => `- ${label}`),
"Use different wording only for genuinely different activities.",
].join("\n");
baseRequest,
"Output contract: respond with ONLY a JSON array of strings. Do not include explanations, markdown, or any other text.",
].join("\n\n");
}