import { buildEvidencePack, type EvidencePackItem } from "./evidence-pack.js";
import type { ExplicitCueRecallEngine } from "./explicit-cue-recall.js";
import {
  gatherAcrossReadSessions,
  resolveLcmReadSessionIds,
} from "./lcm-fallback-read.js";

import {
  unifiedDedupeAndRank,
  type RankedEvidenceItem,
} from "./recall-pipeline-stages.js";

export interface ResponseGuidanceRecallOptions {
  engine: ExplicitCueRecallEngine | null | undefined;
  sessionId?: string;
  /**
   * Ordered, read-authorized LCM read key set (primary overlay → project/root
   * fallbacks). When present, evidence is gathered across EVERY key and merged
   * under this section's budget (#1505 codex P2). Falls back to `sessionId`.
   */
  sessionIds?: readonly (string | undefined)[];
  query: string;
  maxChars: number;
  maxItemChars?: number;
  maxSearchResults?: number;
  maxScanWindowTurns?: number;
  maxScanWindowTokens?: number;
  title?: string;
  forceGeneric?: boolean;
}

type GuidanceIntent =
  | "dates"
  | "editing"
  | "finance"
  | "api_errors"
  | "api_concurrency"
  | "ai_hiring_fairness"
  | "audiobook_narrators"
  | "contradiction_resolution"
  | "media_platforms"
  | "allergy_check"
  | "philosophy_summary"
  | "reading_variety"
  | "reading_goals_summary"
  | "writing_process_structure"
  | "writing_schedule"
  | "daily_routine"
  | "portfolio_links"
  | "deployment_automation"
  | "lightweight_tools"
  | "progress"
  | "health"
  | "nutrition_hydration"
  | "heart_function_activity_management"
  | "sleep_improvement_percent"
  | "sleep_environment_habits_summary"
  | "mattress_warranty_details"
  | "sleep_wind_down_screen_free"
  | "april_relationship_timing"
  | "april_relationship_summary"
  | "work_life_balance_summary"
  | "turkish_pronunciation_quantitative"
  | "turkish_live_learning_formats"
  | "study_space_tools_count"
  | "home_family_repayment"
  | "home_repair_cost_update"
  | "home_condition_final_inspection"
  | "home_neighborhood_tour"
  | "home_neighborhood_preferences"
  | "home_stove_recommendations"
  | "home_apartment_cost_difference"
  | "home_cash_flow_summary"
  | "home_buying_financial_steps"
  | "home_buying_summary"
  | "home_mortgage_choice_summary"
  | "home_inspection_timing"
  | "selling_photo_service_steps"
  | "selling_financial_plan_detail"
  | "selling_rental_payment_terms"
  | "selling_rental_price"
  | "selling_service_total_cost"
  | "selling_sequence_repairs_marketing"
  | "selling_professional_staging_preference"
  | "selling_morning_appointments"
  | "selling_home_summary"
  | "selling_stress_summary"
  | "selling_roof_offer_timing"
  | "diy_living_together_duration"
  | "diy_paint_budget_breakdown"
  | "diy_pipe_leak_safety"
  | "diy_drill_model_specificity"
  | "diy_paint_supply_spend"
  | "diy_professional_savings"
  | "diy_resource_sequence"
  | "diy_visual_learning_preference"
  | "diy_kitchen_surface_preference"
  | "diy_insulation_summary"
  | "diy_shelf_summary"
  | "diy_painting_timing"
  | "diy_faucet_timing"
  | "cooking_weekly_cuisine_plan"
  | "cooking_dolma_leaf_preparation"
  | "cooking_culinary_journey_summary"
  | "outdoor_cardio_preference"
  | "social_norms"
  | "software_versions"
  | "uk_resume"
  | "decision_framework"
  | "realtime_chat_summary"
  | "technical_project_summary"
  | "conic_sections_summary"
  | "calculus_derivative_progression"
  | "calculus_derivative_walkthrough"
  | "euler_step_accuracy"
  | "population_parameter_estimation"
  | "variance_concrete_examples"
  | "spherical_geodesic_vector_methods"
  | "skill_course_completion"
  | "morning_coffee_meeting"
  | "telepsychology_expansion_summary"
  | "professional_event_project_summary"
  | "job_commute_preference"
  | "sarah_resume_revision_planning"
  | "rental_income_preference"
  | "rental_property_journey_summary"
  | "cryptocurrency_investment_summary"
  | "math_induction_summary"
  | "math_step_calculations"
  | "number_theory_congruence_examples"
  | "mixed_problem_practice"
  | "scott_support_summary"
  | "portfolio_management_summary"
  | "parent_nutrition_summary"
  | "evening_tea_options"
  | "event_budget_details"
  | "travel_cost_details"
  | "investment_withdrawal_tax"
  | "relationship_trust_summary"
  | "decor_recommendations"
  | "project_financial_limits"
  | "team_event_attendance"
  | "answerability_absence";

const DEFAULT_MAX_SEARCH_RESULTS = 48;
const DEFAULT_SEARCH_EXPANSION_TURNS = 5;
const DEFAULT_SCAN_WINDOW_TURNS = 64;
const DEFAULT_SCAN_WINDOW_TOKENS = 16_000;

export function shouldRecallResponseGuidance(query: string): boolean {
  return classifyGuidanceIntents(query).length > 0;
}

export async function buildResponseGuidanceRecallSection(
  options: ResponseGuidanceRecallOptions,
): Promise<string> {
  const budget = normalizePositiveInteger(options.maxChars);
  const maxResults = normalizePositiveInteger(
    options.maxSearchResults ?? DEFAULT_MAX_SEARCH_RESULTS,
  );
  const intents = classifyGuidanceIntents(options.query);
  const forceGeneric = options.forceGeneric === true;
  if (
    !options.engine ||
    budget <= 0 ||
    maxResults <= 0 ||
    (!forceGeneric && intents.length === 0)
  ) {
    return "";
  }
  // #1505 codex P2: gather candidates across the ordered LCM read key set
  // (primary overlay → project/root fallbacks) and UNION them into the existing
  // rank/dedupe/budget pass, so stronger project-fallback guidance is not masked
  // by a weak primary-key hit. `gatherAcrossReadSessions` isolates a per-key read
  // failure so a corrupt/locked fallback index can't discard the primary key's
  // guidance; the single-key path collects exactly once and propagates a failure
  // as before — byte-for-byte the pre-#1505 behavior.
  const items: EvidencePackItem[] = [];
  await gatherAcrossReadSessions(resolveLcmReadSessionIds(options), async (sessionId) => {
    items.push(...(await collectGuidanceItems({ ...options, sessionId }, intents)));
  });
  const ranked = rankAndDedupeGuidanceItems(items, options.query, intents)
    .slice(0, maxResults);
  if (ranked.length === 0) {
    return "";
  }

  const title = options.title ?? "Response guidance evidence";
  const titleLine = `## ${title}`;
  const cues = buildGuidanceCueSummary(ranked, intents, options.query);
  const cueInsertion = budgetGuidanceCueInsertion(cues, budget);
  const evidence = buildEvidencePack(ranked, {
    title,
    maxChars: Math.max(0, budget - cueInsertion.length),
    maxItemChars: options.maxItemChars,
  });
  if (!evidence) {
    return "";
  }

  return cueInsertion
    ? evidence.replace(titleLine, `${titleLine}${cueInsertion}`)
    : evidence;
}

function budgetGuidanceCueInsertion(cues: string, budget: number): string {
  if (!cues) return "";
  const prefix = "\n\n";
  if (budget <= prefix.length) return "";
  const maxCueChars = Math.max(0, Math.floor(budget * 0.35));
  const clipped = clipGuidanceText(cues, Math.min(maxCueChars, budget - prefix.length));
  return clipped ? `${prefix}${clipped}` : "";
}

function clipGuidanceText(text: string, maxChars: number): string {
  if (maxChars <= 0) return "";
  if (text.length <= maxChars) return text;
  if (maxChars <= 3) return text.slice(0, maxChars);
  return `${text.slice(0, maxChars - 3).trimEnd()}...`;
}

async function collectGuidanceItems(
  options: ResponseGuidanceRecallOptions,
  intents: readonly GuidanceIntent[],
): Promise<EvidencePackItem[]> {
  const engine = options.engine;
  if (!engine) return [];

  const items: EvidencePackItem[] = [];
  const seen = new Set<string>();
  const searchResults = await engine.searchContextFull(
    buildGuidanceQuery(options.query, intents),
    normalizePositiveInteger(options.maxSearchResults ?? DEFAULT_MAX_SEARCH_RESULTS),
    options.sessionId,
  );
  const searchWindowTurns = Math.max(
    1,
    normalizePositiveInteger(options.maxScanWindowTurns ?? DEFAULT_SEARCH_EXPANSION_TURNS),
  );
  const searchWindowBefore = Math.floor((searchWindowTurns - 1) / 2);
  const searchWindowAfter = searchWindowTurns - 1 - searchWindowBefore;
  const searchWindowTokens = Math.max(
    1,
    normalizePositiveInteger(options.maxScanWindowTokens ?? DEFAULT_SCAN_WINDOW_TOKENS),
  );

  for (const result of searchResults) {
    const expanded = await engine.expandContext(
      result.session_id,
      Math.max(0, result.turn_index - searchWindowBefore),
      result.turn_index + searchWindowAfter,
      searchWindowTokens,
    );
    const candidates = expanded.length > 0
      ? expanded.map((message) => ({
          id: `${result.session_id}:${message.turn_index}`,
          sessionId: result.session_id,
          turnIndex: message.turn_index,
          role: message.role,
          content: message.content,
          ...(message.turn_index === result.turn_index &&
          typeof result.score === "number"
            ? { score: result.score }
            : {}),
        }))
      : [{
          id: `${result.session_id}:${result.turn_index}`,
          sessionId: result.session_id,
          turnIndex: result.turn_index,
          role: result.role,
          content: result.content,
          ...(typeof result.score === "number" ? { score: result.score } : {}),
        }];

    for (const candidate of candidates) {
      if (seen.has(candidate.id)) continue;
      if (!isGuidanceEvidence(candidate.content, options.query, intents, options.forceGeneric === true)) continue;
      seen.add(candidate.id);
      items.push(candidate);
    }
  }

  for (const item of await collectGuidanceScanItems(options, intents)) {
    const id = item.id ?? (
      item.sessionId && typeof item.turnIndex === "number"
        ? `${item.sessionId}:${item.turnIndex}`
        : undefined
    );
    if (id && seen.has(id)) continue;
    if (id) seen.add(id);
    items.push(item);
  }

  return items;
}

async function collectGuidanceScanItems(
  options: ResponseGuidanceRecallOptions,
  intents: readonly GuidanceIntent[],
): Promise<EvidencePackItem[]> {
  const engine = options.engine;
  if (!engine?.getStats || !options.sessionId) return [];

  const stats = await engine.getStats(options.sessionId);
  const maxTurn = typeof stats.maxTurnIndex === "number"
    ? stats.maxTurnIndex
    : stats.totalMessages - 1;
  if (maxTurn < 0) return [];

  const windowTurns = Math.max(
    1,
    intents.includes("technical_project_summary") &&
      options.maxScanWindowTurns === undefined
      ? Math.min(DEFAULT_SCAN_WINDOW_TURNS, 4)
      : normalizePositiveInteger(options.maxScanWindowTurns ?? DEFAULT_SCAN_WINDOW_TURNS),
  );
  const windowTokens = Math.max(
    1,
    normalizePositiveInteger(options.maxScanWindowTokens ?? DEFAULT_SCAN_WINDOW_TOKENS),
  );
  const items: EvidencePackItem[] = [];
  const fromTurn = Math.max(0, maxTurn - windowTurns + 1);
  const toTurn = maxTurn;

  const messages = await engine.expandContext(
    options.sessionId,
    fromTurn,
    toTurn,
    windowTokens,
  );
  for (const message of messages) {
    if (!isGuidanceEvidence(message.content, options.query, intents, options.forceGeneric === true)) continue;
    items.push({
      id: `${options.sessionId}:${message.turn_index}`,
      sessionId: options.sessionId,
      turnIndex: message.turn_index,
      role: message.role,
      content: message.content,
    });
  }

  return items;
}

/**
 * Issue #1539 PR4: response-guidance now routes dedup/score/threshold/sort through
 * the unified spine (`unifiedDedupeAndRank`). The divergence that lived inline
 * here — append-guidance-cues content transform (two-arg: content + intents),
 * relevance scoring on ORIGINAL content, default DESC turn-index ordering with
 * -1 sentinel for missing turns — is now declared config on the spine. The score
 * and appendGuidanceCues helpers stay in this module because they are genuinely
 * per-tier policy; only the duplicated dedup/sort/threshold machinery moved out.
 *
 * Behavior is byte-for-byte identical to the inline implementation it replaces
 * (the spine was extracted to match it exactly; see recall-pipeline-stages.ts).
 * The response-guidance-recall.test.ts suite is the characterization.
 *
 * Note: response-guidance (like the pre-migration code) dedups on the TRANSFORMED
 * (cue-appended) content, not the original — this matches the spine's default
 * (transform-then-dedup) exactly. No divergence from prior behavior.
 */
function rankAndDedupeGuidanceItems(
  items: EvidencePackItem[],
  query: string,
  intents: readonly GuidanceIntent[],
): RankedEvidenceItem[] {
  // The spine's config.intents is typed TIntent[] (readability contract — it is
  // never mutated). Cast the readonly array through; safe because the spine only
  // forwards intents to the score/transform callbacks.
  const mutableIntents = intents as GuidanceIntent[];
  return unifiedDedupeAndRank(items, {
    query,
    intents: mutableIntents,
    scoreEvidence: (item, q, intentArr) => scoreGuidanceEvidence(item, q, intentArr),
    transformContent: (content, intentArr) => appendGuidanceCues(content, intentArr),
  });
}

function classifyGuidanceIntents(query: string): GuidanceIntent[] {
  const normalized = query.toLowerCase();
  const intents: GuidanceIntent[] = [];
  if (isTimingDetailsQuery(normalized) ||
    /\b(?:what happened|outcomes?|recent)\b.*\b(?:rehearsals?|coaching sessions?|practice sessions?)\b/.test(normalized)) {
    intents.push("dates");
  }
  if (/\b(?:edit|editing|editting|draft|revision|revise)\b/.test(normalized)) {
    intents.push("editing");
  }
  if (/\b(?:financial goals?|monthly expenses?|budget|spending|reduce expenses?|saving|fund)\b/.test(normalized)) {
    intents.push("finance");
  }
  if (
    /\b(?:decor|living space|home decor|redecorat(?:e|ing)|furniture|update my living space)\b/.test(normalized) &&
    /\b(?:suggest|recommend|recommendations?|what kinds?|items?|options?)\b/.test(normalized)
  ) {
    intents.push("decor_recommendations");
  }
  if (
    /\b(?:financial limits?|budget limits?|cost limits?|costs?|budget)\b/.test(normalized) &&
    /\b(?:project|keep in mind|limits?|breakdown|analysis)\b/.test(normalized)
  ) {
    intents.push("project_financial_limits");
  }
  if (
    /\b(?:team events?|team practice|practice session|scrimmage|team meeting|last practice|last team practice)\b/.test(normalized) &&
    /\b(?:what happened|happened|details?|summary|tell me|practice|event|events?)\b/.test(normalized)
  ) {
    intents.push("team_event_attendance");
  }
  if (/\b(?:rest api|api|endpoint|http)\b/.test(normalized) &&
    /\b(?:errors?|failures?|status codes?|handle|prepared)\b/.test(normalized)) {
    intents.push("api_errors");
  }
  if (
    /\b(?:api requests?|api calls?|multiple requests?|multiple api|tweet metrics|twitter api|batch(?:ing)?|concurr(?:ent|ency|ently)|non-blocking|async(?:io|hronous)?|async\/await)\b/.test(normalized) &&
    /\b(?:efficient(?:ly)?|structure|structuring|handle|calls?|requests?|gather|maximize|reduce blocking|blocking|concurr(?:ent|ency|ently)|async)\b/.test(normalized)
  ) {
    intents.push("api_concurrency");
  }
  if (
    /\b(?:hiring|candidate(?:s)?|recruitment|resume screening|ai hiring|automated screening)\b/.test(normalized) &&
    /\b(?:fairness|fair|bias|oversight|evaluation|candidate evaluation|speeding up|speed|technology|automated)\b/.test(normalized)
  ) {
    intents.push("ai_hiring_fairness");
  }
  if (/\b(?:audiobooks?|audio books?|listen)\b/.test(normalized) &&
    /\b(?:suggest|recommend|recommendations?|books?|series|listen)\b/.test(normalized)) {
    intents.push("audiobook_narrators");
  }
  if (isPotentialContradictionResolutionQuery(normalized)) {
    intents.push("contradiction_resolution");
  }
  if (/\b(?:movies?|watchlist|watch)\b/.test(normalized) &&
    /\b(?:recommend|options?|watch|streaming|platforms?)\b/.test(normalized)) {
    intents.push("media_platforms");
  }
  if (/\b(?:snacks?|food|try)\b/.test(normalized) &&
    /\b(?:recommend|options?|try)\b/.test(normalized)) {
    intents.push("allergy_check");
  }
  if (/\b(?:existentialism|philosophical|philosophy|concepts?)\b/.test(normalized)) {
    intents.push("philosophy_summary");
  }
  if (/\b(?:reading list|books?|novels?|series)\b/.test(normalized) &&
    /\b(?:suggest|recommend|planning|list)\b/.test(normalized)) {
    intents.push("reading_variety");
  }
  if (
    /\b(?:reading goals?|reading strateg(?:y|ies)|fiction books?|choosing and budgeting|book plans?|reading plans?)\b/.test(normalized) &&
    /\b(?:summary|summarize|developed|evolved|over time|conversations?|plans?|decisions?)\b/.test(normalized)
  ) {
    intents.push("reading_goals_summary");
  }
  if (
    /\b(?:writing process|writing plan|drafting process|screenplay|steady progress|stay motivated|weeks leading up|word count goals?)\b/.test(normalized) &&
    /\b(?:structure|structuring|maintain|steady progress|motivated|motivation|deadline|outline|scene breakdown|daily|weekly)\b/.test(normalized)
  ) {
    intents.push("writing_process_structure");
  }
  if (/\bwriting sessions?\b/.test(normalized) ||
    /\b(?:plan|schedule)\b/.test(normalized) && /\bwriting\b/.test(normalized)) {
    intents.push("writing_schedule");
  }
  if (
    /\b(?:organize|schedule|plan|structure|routine|track|responsibilities)\b/.test(normalized) &&
    /\b(?:day|daily|routine|responsibilities|tasks|track)\b/.test(normalized)
  ) {
    intents.push("daily_routine");
  }
  if (/\bportfolio links?\b|\bcover letter\b.*\blinks?\b|\blinks?\b.*\bcover letter\b/.test(normalized)) {
    intents.push("portfolio_links");
  }
  if (/\bdeployment workflow\b|\bci\/cd\b|\bpipeline\b/.test(normalized)) {
    intents.push("deployment_automation");
  }
  if (/\b(?:libraries?|tools?|dependencies|frameworks?|flask app|implement these features|user login|analytics|bootstrap|lazy loading|image gallery|responsive portfolio)\b/.test(normalized)) {
    intents.push("lightweight_tools");
  }
  if (/\b(?:progress|edits?|editing|completion|percentage|percent|improvements?)\b/.test(normalized)) {
    intents.push("progress");
  }
  if (/\b(?:sneakers?|shoes?|footwear|comfort|support|arch|cushioning)\b/.test(normalized)) {
    intents.push("health");
  }
  if (
    /\b(?:healthy diet|diet|nutrition|nutrition advice|meal planning|meal plan|healthy eating|food-related|macronutrient|food tips?)\b/.test(normalized) &&
    /\b(?:keep in mind|maintain|advice|tips?|suggest|recommend|support|plan|strategies?)\b/.test(normalized)
  ) {
    intents.push("nutrition_hydration");
  }
  if (
    /\b(?:cooking plan|organize.*cooking|focus on each week|each week|week-by-week|week by week|weekly cooking|cuisine|cuisines)\b/.test(normalized) &&
    /\b(?:week|weekly|each week|focus|breaks? down|breakdown|cuisine|cultural)\b/.test(normalized) &&
    /\b(?:cooking|cuisine|cuisines|dishes|culinary)\b/.test(normalized)
  ) {
    intents.push("cooking_weekly_cuisine_plan");
  }
  if (
    /\b(?:grape leaves?|leaves|dolma|stuffed grape leaves?|filling|seasoning|flavors?|textures?)\b/.test(normalized) &&
    /\b(?:approach|recommend|prepar(?:e|ing)|handle|balance|roll|seasoning|texture|flavors?)\b/.test(normalized) &&
    /\b(?:cooking|dishes?|leaves?|seasoning|filling|dolma|grape)\b/.test(normalized)
  ) {
    intents.push("cooking_dolma_leaf_preparation");
  }
  if (
    /\b(?:culinary journey|cooking skills?|new cuisines?|global dishes?|culinary skills?|mastering.*cooking|planning meals|meal planning|cooking techniques?)\b/.test(normalized) &&
    /\b(?:summary|summarize|progressed|progress|milestones?|skill developments?|strategies?|over several months|stay on track|journey)\b/.test(normalized)
  ) {
    intents.push("cooking_culinary_journey_summary");
  }
  if (
    /\b(?:ejection fraction|heart(?:'s)? pumping|pumping efficiency|heart function|cardiac efficiency)\b/.test(normalized) &&
    /\b(?:physical activities?|activities?|symptoms?|ongoing steps?|manage|management|recommend(?:ed|ations?)?|explain|connection)\b/.test(normalized)
  ) {
    intents.push("heart_function_activity_management");
  }
  if (
    /\bsleep\b/.test(normalized) &&
    /\b(?:how much|improved|improvement|increase|percentage|percent|exact|recently)\b/.test(normalized) &&
    /\b(?:sleep efficiency|efficiency|improved|improvement|increase)\b/.test(normalized)
  ) {
    intents.push("sleep_improvement_percent");
  }
  if (
    /\b(?:sleep environment|sleep habits?|sleep quality|night sweats?|thermostat|blackout curtains?|blackout blinds?|2200k|bedroom)\b/.test(normalized) &&
    /\b(?:summary|summarize|over time|combined|affected|effects?|quality|habits?|environment|night sweats?)\b/.test(normalized)
  ) {
    intents.push("sleep_environment_habits_summary");
  }
  if (
    /\bmattress(?:es)?\b/.test(normalized) &&
    /\b(?:buy|buying|purchase|purchasing|decision|consider|know|thinking)\b/.test(normalized)
  ) {
    intents.push("mattress_warranty_details");
  }
  if (
    /\b(?:unwind|wind down|bedtime routine|before bed|relax before bed|ways to unwind)\b/.test(normalized) &&
    /\b(?:bed|sleep|try|ways|activities|routine|relax)\b/.test(normalized)
  ) {
    intents.push("sleep_wind_down_screen_free");
  }
  if (
    /\b(?:april|partner)\b/.test(normalized) &&
    /\b(?:weekend|conversation|activities|activity|organize|start|good time|meaningful)\b/.test(normalized) &&
    /\b(?:when|time|timing|organize|activities|conversation|weekend)\b/.test(normalized)
  ) {
    intents.push("april_relationship_timing");
  }
  if (
    /\bapril\b/.test(normalized) &&
    /\brelationship\b/.test(normalized) &&
    /\b(?:summary|summarize|thorough|comprehensive|covered|connect|evolve|over time)\b/.test(normalized)
  ) {
    intents.push("april_relationship_summary");
  }
  if (
    /\b(?:reduce|planned|plan|work hours|clinical hours|work-life|personal life|balance)\b/.test(normalized) &&
    /\b(?:work hours|clinical hours|work-life|personal life|balance|reduce)\b/.test(normalized) &&
    /\b(?:summary|summarize|planned|plan|how)\b/.test(normalized)
  ) {
    intents.push("work_life_balance_summary");
  }
  if (
    /\b(?:pronunciation|speaking speed|speaking accuracy|accent)\b/.test(normalized) &&
    /\b(?:improving|improved|improvement|progress|lately|recently)\b/.test(normalized)
  ) {
    intents.push("turkish_pronunciation_quantitative");
  }
  if (
    /\bturkish\b/.test(normalized) &&
    /\b(?:skills?|learning formats?|formats?|classes?|lessons?|options?)\b/.test(normalized) &&
    /\b(?:improve|learning formats?|explore|suggest|options?)\b/.test(normalized)
  ) {
    intents.push("turkish_live_learning_formats");
  }
  if (
    /\b(?:study tools?|decorations?|study space|study room)\b/.test(normalized) &&
    /\b(?:how many|different|added|across sessions?|tools?|decorations?)\b/.test(normalized)
  ) {
    intents.push("study_space_tools_count");
  }
  if (
    /\b(?:family|mom|mother|crystal)\b/.test(normalized) &&
    /\b(?:money|financial assistance|help|down payment|repay|repayment|loan|consider)\b/.test(normalized)
  ) {
    intents.push("home_family_repayment");
  }
  if (
    /\b(?:plumbing leaks?|repair(?:ing)?|repair costs?|cost estimates?)\b/.test(normalized) &&
    /\b(?:estimated cost|cost|home inspection|minor plumbing|leaks?|repair)\b/.test(normalized)
  ) {
    intents.push("home_repair_cost_update");
  }
  if (
    /\b(?:condition of the house|house condition|condition of the property|before (?:we )?finalize|finalize everything|final home inspection|seller'?s contractor|repairs? completed)\b/.test(normalized)
  ) {
    intents.push("home_condition_final_inspection");
  }
  if (
    /\b(?:neighborhood tour|tour with samantha|samantha.*tour|tour.*samantha)\b/.test(normalized) &&
    /\b(?:when|scheduled|start|starts?|time|april|tour)\b/.test(normalized)
  ) {
    intents.push("home_neighborhood_tour");
  }
  if (
    /\b(?:neighborhood|areas?|move to|moving to|compare different areas|decide on a neighborhood)\b/.test(normalized) &&
    /\b(?:consider|comparing|decide|factors?|areas?|neighborhood)\b/.test(normalized)
  ) {
    intents.push("home_neighborhood_preferences");
  }
  if (
    /\b(?:stove|kitchen appliance|kitchen appliances?|oven|cooktop)\b/.test(normalized) &&
    /\b(?:brands?|models?|suggest|recommend|look into|adding|new)\b/.test(normalized)
  ) {
    intents.push("home_stove_recommendations");
  }
  if (
    /\b(?:3-bedroom|three-bedroom|2-bedroom|two-bedroom|apartment)\b/.test(normalized) &&
    /\b(?:cost compared|how much more|difference|more does|mevlana|inonu|inönü)\b/.test(normalized)
  ) {
    intents.push("home_apartment_cost_difference");
  }
  if (
    /\b(?:cash flow|monthly cash flow|financial commitments|repayment schedule|loan repayment|essential expenses)\b/.test(normalized) &&
    /\b(?:left|after covering|housing|monthly|expenses?|repayment|commitments?)\b/.test(normalized)
  ) {
    intents.push("home_cash_flow_summary");
  }
  if (
    /\b(?:timeline|financial steps|savings plan|monthly costs?|prepare for buying|buying my home)\b/.test(normalized) &&
    /\b(?:home|buying|savings|monthly|costs?|financial)\b/.test(normalized)
  ) {
    intents.push("home_buying_financial_steps");
  }
  if (
    /\b(?:complete summary|summary|summarize)\b/.test(normalized) &&
    /\b(?:home buying plans?|financial arrangements?|buying my home|down payment|mevlana|crystal|mortgage)\b/.test(normalized)
  ) {
    intents.push("home_buying_summary");
  }
  if (
    /\b(?:fixed-rate|fixed rate|variable-rate|variable rate|mortgage options?|loan options?)\b/.test(normalized) &&
    /\b(?:summary|summarize|choosing|decision-making|key considerations|decide|options?)\b/.test(normalized)
  ) {
    intents.push("home_mortgage_choice_summary");
  }
  if (
    /\b(?:home inspection|inspection report|lawyer|contract review|meeting with the lawyer)\b/.test(normalized) &&
    /\b(?:how many days|days before|days after|delivered|contract review|april)\b/.test(normalized)
  ) {
    intents.push("home_inspection_timing");
  }
  if (
    /\b(?:service|photograph|photography|photos?|focuslens|shoot|session)\b/.test(normalized) &&
    /\b(?:prepare|coordinat|best outcome|maximize|impact|after|delivered|high-resolution|web)\b/.test(normalized)
  ) {
    intents.push("selling_photo_service_steps");
  }
  if (
    /\b(?:finances?|financial planning|planning my finances|next year|costs?)\b/.test(normalized) &&
    /\b(?:next year|planning|consider|costs?|category|breakdown|analysis)\b/.test(normalized)
  ) {
    intents.push("selling_financial_plan_detail");
  }
  if (
    /\b(?:rent out|rental|lease|terms|agreement)\b/.test(normalized) &&
    /\b(?:terms|payment|payments?|agreement|modifications?|adjustments?|changes?)\b/.test(normalized)
  ) {
    intents.push("selling_rental_payment_terms");
  }
  if (
    /\b(?:rental price|rent price|kadikoy|kadıköy|apartment)\b/.test(normalized) &&
    /\b(?:set|price|rental|rent|4,550|4550|4,500|4500)\b/.test(normalized)
  ) {
    intents.push("selling_rental_price");
  }
  if (
    /\b(?:staging|photography|services?)\b/.test(normalized) &&
    /\b(?:total|spending|cost|costs|how much)\b/.test(normalized)
  ) {
    intents.push("selling_service_total_cost");
  }
  if (
    /\b(?:list by april 1|sell within three months|repairs?|staging|marketing|inspection|moving plans?|sequence|avoid delays)\b/.test(normalized) &&
    /\b(?:sequence|optimally|avoid delays|meet my moving plans|repairs?|marketing|timeline)\b/.test(normalized)
  ) {
    intents.push("selling_sequence_repairs_marketing");
  }
  if (
    /\b(?:preparing my home|prepare my home|home for sale|attractive to buyers|buyers)\b/.test(normalized) &&
    (/\b(?:staging|professional|diy|experts|upfront cost|quality)\b/.test(normalized) ||
      /\bprepar(?:e|ing)\b.*\bhome\b.*\bsale\b.*\battractive\b.*\bbuyers\b/.test(normalized))
  ) {
    intents.push("selling_professional_staging_preference");
  }
  if (
    /\b(?:appointments?|schedule|organize|next week)\b/.test(normalized) &&
    /\b(?:morning|early|time slots?|start early|appointments?)\b/.test(normalized)
  ) {
    intents.push("selling_morning_appointments");
  }
  if (
    /\b(?:thorough summary|complete summary|summary|preparing and selling my home|home selling|selling my home)\b/.test(normalized) &&
    /\b(?:home|selling|sale|selim|staging|listing)\b/.test(normalized)
  ) {
    intents.push("selling_home_summary");
  }
  if (
    /\b(?:stress|mindfulness|meditation|managing stress)\b/.test(normalized) &&
    /\b(?:home selling|moving process|summary|throughout|selling and moving|home sale)\b/.test(normalized)
  ) {
    intents.push("selling_stress_summary");
  }
  if (
    /\b(?:roof repair|home inspection|first offer|april|march)\b/.test(normalized) &&
    /\b(?:how many days|between|days|from)\b/.test(normalized)
  ) {
    intents.push("selling_roof_offer_timing");
  }
  if (
    /\b(?:atat(?:ü|u)rk|living together|lived together|james|jamie|house)\b/.test(normalized) &&
    /\b(?:how long|lived|living together|house|years?)\b/.test(normalized)
  ) {
    intents.push("diy_living_together_duration");
  }
  if (
    /\b(?:bauhaus|paint.*supplies|supplies.*paint|materials?.*store|planned spending|reasonable budget|particular store)\b/.test(normalized) &&
    /\b(?:break down|budget|prices?|calculation|appropriate|store|materials?|item types?|estimate)\b/.test(normalized)
  ) {
    intents.push("diy_paint_budget_breakdown");
  }
  if (
    /\b(?:leaking pipe|leaky pipe|bathroom.*pipe|pipe.*bathroom|fixing.*pipe|pipe repair)\b/.test(normalized) &&
    /\b(?:how should|go about|fix(?:ing)?|repair(?:ing)?|safety|protective gear|avoid hazards?|injury|damage|water shutoff|shutoff|shut off water|steps?)\b/.test(normalized)
  ) {
    intents.push("diy_pipe_leak_safety");
  }
  if (
    /\b(?:drill|tool recommendation|model number|specific product|tool version|cordless drill)\b/.test(normalized) &&
    /\b(?:recommend|new|model|specific|exact|product)\b/.test(normalized)
  ) {
    intents.push("diy_drill_model_specificity");
  }
  if (
    /\b(?:paint.*supplies|supplies.*paint|spent|spending|total spent|cost)\b/.test(normalized) &&
    /\b(?:how much|actually|knowledge|update|cost|spent|spending|total)\b/.test(normalized)
  ) {
    intents.push("diy_paint_supply_spend");
  }
  if (
    /\b(?:saved?|save|hiring|plumber|painter|diy)\b/.test(normalized) &&
    /\b(?:painting|plumbing|faucet|hire|over hiring|money|saved?)\b/.test(normalized)
  ) {
    intents.push("diy_professional_savings");
  }
  if (
    /\b(?:resources|sequence|prioritize|allocate|budget|bulk purchases?|ladder|don|heavy items?|upcoming projects?|safety-critical)\b/.test(normalized) &&
    /\b(?:diy|projects?|tools?|resources|sequence|prioritize|allocate|ladder|don|budget)\b/.test(normalized)
  ) {
    intents.push("diy_resource_sequence");
  }
  if (
    /\b(?:resources|tutorials?|manuals?|visual|hands-on|interactive|fixing|home repairs?|start(?:ed|ing)?)\b/.test(normalized) &&
    /\b(?:recommend|suggest|prefer|avoid|resources|tutorials?|manuals?|visual|hands-on)\b/.test(normalized)
  ) {
    intents.push("diy_visual_learning_preference");
  }
  if (
    /\b(?:kitchen surfaces?|countertops?|surfaces?|durability|cleaning|lasting|trendy|aesthetic)\b/.test(normalized) &&
    /\b(?:options?|recommend|suggest|focus|avoid|durability|cleaning|lasting|quality|trendy|aesthetic)\b/.test(normalized)
  ) {
    intents.push("diy_kitchen_surface_preference");
  }
  if (
    /\b(?:attic insulation|insulation upgrade|owens corning|june\s+15|june\s+22)\b/.test(normalized) &&
    /\b(?:summary|summarize|complete|budget|timeline|safety|installation|project)\b/.test(normalized)
  ) {
    intents.push("diy_insulation_summary");
  }
  if (
    /\b(?:bathroom shelf|shelf installation|august\s+15|mounting brackets?|pilot holes?|wall anchors?)\b/.test(normalized) &&
    /\b(?:summary|summarize|complete|budget|installation|materials?|project)\b/.test(normalized)
  ) {
    intents.push("diy_shelf_summary");
  }
  if (
    /\b(?:painting|painted|dove gray|april\s+1|april\s+13|april\s+14)\b/.test(normalized) &&
    /\b(?:how many days|days|from|till|until|between)\b/.test(normalized)
  ) {
    intents.push("diy_painting_timing");
  }
  if (
    /\b(?:faucet washers?|plumbing workshop|april\s+10|april\s+29|practice replacing)\b/.test(normalized) &&
    /\b(?:how many days|days|from|till|until|between|practice)\b/.test(normalized)
  ) {
    intents.push("diy_faucet_timing");
  }
  if (
    /\b(?:cardio|running|run|jogging|cycling|cardio activities?|workout options?)\b/.test(normalized) &&
    /\b(?:suggest|recommend|options?|add|routine|activities?)\b/.test(normalized)
  ) {
    intents.push("outdoor_cardio_preference");
  }
  if (/\b(?:social norms?|expectations|meeting someone|first time|culture|cultural)\b/.test(normalized)) {
    intents.push("social_norms");
  }
  if (
    /\b(?:digital files?|digital assets?|organize|manage|management tools?|software|tools?|technolog(?:y|ies)|tech stack|technology stacks?|current setup|setup)\b/.test(normalized) &&
    /\b(?:version|versions|version numbers?|release identifiers?|technolog(?:y|ies)|tech stack|technology stacks?|current setup|setup|used)\b/.test(normalized)
  ) {
    intents.push("software_versions");
  }
  if (/\b(?:uk|resume|cv|ats|job)\b/.test(normalized)) {
    intents.push("uk_resume");
  }
  if (/\b(?:complex problem|practical and emotional|approach|decide|decision|work environment|career change|changing my work|startup)\b/.test(normalized)) {
    intents.push("decision_framework");
  }
  if (
    /\b(?:real-time|realtime|chat|socket\.?io|websocket|message|messaging|chatroom|rooms?|redis|latency|presence|broadcast|load|scal(?:e|ing)|concurrent users?)\b/.test(normalized) &&
    /\b(?:summary|scope|challenges?|solutions?|enhancements?|improv(?:e|ing|ements?)|optimi[sz](?:e|ing|ation)|handle|manag(?:e|ing)|application|app)\b/.test(normalized)
  ) {
    intents.push("realtime_chat_summary");
  }
  if (
    /\b(?:resume analyzer|analyzer project|flask|spacy|pymupdf|pdf parsing|keyword extraction|ner|scoring|cprofile|redis-backed|startup time|performance profiling|object detection|tracking pipeline|yolov5|opencv|sort|kalman|hungarian|tensorrt|deepsort|ssd mobilenet|dnn pipeline|recommendation system|recommender|collaborative filtering|content-based filtering|tf-?idf|cosine similarity|similarity matrix|hybrid recommendation|precision|recall|redis caching)\b/.test(normalized) &&
    /\b(?:summary|process|developments?|challenges?|improvements?|optimizations?|enhancing|enhance|project|start to finish)\b/.test(normalized)
  ) {
    intents.push("technical_project_summary");
  }
  if (
    /\b(?:language translation|translation services?|translation api|language detection|multi-language|multilingual|deepl|google translate|franc|chatbot backend|chatbot system|transformer-based llm|streaming|chunk size)\b/.test(normalized) &&
    /\b(?:summary|summarize|process|develop(?:ing|ment)?|integrat(?:e|ing|ion)|challenges?|improvements?|optimizations?|deployment|technical decisions?)\b/.test(normalized)
  ) {
    intents.push("technical_project_summary");
  }
  if (
    /\b(?:image captioning|captioning system|captioning api|caption generator|feature extractor|diffusion-based|stable diffusion|docker compose|materialized views?|postgresql|redis cache|pytorch|transformers?|cuda|out-of-memory|mixed precision|gradient accumulation|lru caches?)\b/.test(normalized) &&
    /\b(?:summary|summarize|design|deployment|evolved|throughout|discussions?|process|develop(?:ing|ment)?|optimizations?)\b/.test(normalized)
  ) {
    intents.push("technical_project_summary");
  }
  if (
    /\b(?:conic sections?|parabolas?|ellipses?|hyperbolas?|vertex form|directrix|foci|eccentricity|tangent lines?|reflective property)\b/.test(normalized) &&
    /\b(?:summary|summarize|detailed|cohesive|integrat(?:e|ing)|foundations?|applications?|properties|derivations?|real-world|practical implications|connect|build upon)\b/.test(normalized)
  ) {
    intents.push("conic_sections_summary");
  }
  if (
    /\b(?:derivatives?|implicit differentiation|circle equation|quadratic|cubic|product term)\b/.test(normalized) &&
    /\b(?:complexity|simplest|most complex|change|progress(?:ion)?|increasing)\b/.test(normalized)
  ) {
    intents.push("calculus_derivative_progression");
  }
  if (
    /\b(?:derivatives?|differentiat(?:e|ion)|product rule|chain rule)\b/.test(normalized) &&
    /\b(?:walk me through|step(?:s|-by-step| by step)?|explain|using|apply)\b/.test(normalized)
  ) {
    intents.push("calculus_derivative_walkthrough");
  }
  if (
    /\beuler(?:'s)?(?:\s+method)?\b/.test(normalized) &&
    /\b(?:step size|accuracy|accurate|error|errors?|differential equations?|solving)\b/.test(normalized)
  ) {
    intents.push("euler_step_accuracy");
  }
  if (
    /\b(?:exponential|logistic|population)\b/.test(normalized) &&
    /\b(?:models?|population trends?|parameter estimation|estimate parameters?|data points?|datasets?|growth|predict(?:ion|s)?)\b/.test(normalized) &&
    /\b(?:combine|predict|parameter|estimate|estimation|improvements?|prioritize|data points?|datasets?)\b/.test(normalized)
  ) {
    intents.push("population_parameter_estimation");
  }
  if (
    /\b(?:variance|random variable|expectation|expected value)\b/.test(normalized) &&
    /\b(?:problem|work through|defined|calculate|calculation|explain|understand)\b/.test(normalized)
  ) {
    intents.push("variance_concrete_examples");
  }
  if (
    /\b(?:sphere|spherical|great circle|shortest path|geodesic)\b/.test(normalized) &&
    /\b(?:shortest path|distance|between two points|find|calculate|show me|walk)\b/.test(normalized)
  ) {
    intents.push("spherical_geodesic_vector_methods");
  }
  if (
    /\b(?:skills?|skill acquisition|skill development)\b/.test(normalized) &&
    /\b(?:gained|gain|recently|training|course|programs?)\b/.test(normalized)
  ) {
    intents.push("skill_course_completion");
  }
  if (
    /\bcoffee meeting\b/.test(normalized) &&
    /\b(?:tips?|prepare|preparation|make the most|conversation starters?)\b/.test(normalized)
  ) {
    intents.push("morning_coffee_meeting");
  }
  if (
    /\btelepsychology services?\b/.test(normalized) &&
    /\b(?:professional development|research and client work|career decisions?|entire process|comprehensive summary|detailed summary)\b/.test(
      normalized,
    )
  ) {
    intents.push("telepsychology_expansion_summary");
  }
  if (
    /\b(?:upcoming professional events?|professional events? and projects?|events? and projects?)\b/.test(normalized) &&
    /\b(?:initial planning|execution|follow-up|participating|preparing|comprehensive summary|detailed summary)\b/.test(
      normalized,
    )
  ) {
    intents.push("professional_event_project_summary");
  }
  if (
    /\b(?:job listings?|job opportunities?|job options?|roles?|positions?)\b/.test(normalized) &&
    /\b(?:best fit|fit|narrow down|options?|prioritize|choose|evaluat(?:e|ing)|decide)\b/.test(
      normalized,
    )
  ) {
    intents.push("job_commute_preference");
  }
  if (
    /\b(?:initial interaction|conference)\b/.test(normalized) &&
    /\b(?:timeline|approach|revis(?:e|ing)|professional documents?|resume|cover letter|update process)\b/.test(
      normalized,
    )
  ) {
    intents.push("sarah_resume_revision_planning");
  }
  if (
    /\b(?:investment properties?|rental properties?|properties?)\b/.test(normalized) &&
    /\b(?:monthly returns?|rental income|appreciation|higher price|resale|profits?|sell|wealth|deciding between|decide between)\b/.test(
      normalized,
    )
  ) {
    intents.push("rental_income_preference");
  }
  if (
    /\brental properties?\b/.test(normalized) &&
    /\b(?:journey|decision-making|budget|property choices?|management considerations?|financing plans?|developed over time|comprehensive summary)\b/.test(
      normalized,
    )
  ) {
    intents.push("rental_property_journey_summary");
  }
  if (
    /\b(?:cryptocurrency investments?|crypto investments?|bitcoin|ethereum|defi|nft)\b/.test(normalized) &&
    /\b(?:managing|growing|strategies|tools|risks|community engagement|thorough summary|comprehensive summary|summary)\b/.test(
      normalized,
    )
  ) {
    intents.push("cryptocurrency_investment_summary");
  }
  if (
    /\b(?:mathematical induction|induction proofs?|inductive proofs?|proof by induction|divisibility proofs?|inequality induction|number theory induction)\b/.test(normalized) &&
    /\b(?:summarize|summary|learning journey|overall|progress|develop(?:ed|ment)?|conversations?|throughout)\b/.test(normalized)
  ) {
    intents.push("math_induction_summary");
  }
  if (
    /\b(?:congruences?|modular arithmetic|number theory|fermat'?s little theorem|euler'?s theorem)\b/.test(normalized) &&
    /\b(?:explain|properties|theorems?|examples?|apply|applications?|calculations?)\b/.test(normalized)
  ) {
    intents.push("number_theory_congruence_examples");
  }
  if (
    /\b(?:distance formula|distance between|points?\s*\(|coordinate geometry|coordinate plane|point-line distance|midpoint formula)\b/.test(normalized) &&
    /\b(?:how|find|calculate|step|steps?|walk|explain|formula|arithmetic|breakdown)\b/.test(normalized)
  ) {
    intents.push("math_step_calculations");
  }
  if (
    /\b(?:study sessions?|exam|practice|problem sets?|different types of problems?|mixed problem sets?|comprehensive exams?|topics?)\b/.test(normalized) &&
    /\b(?:organize|practice|prepare|sessions?|different|varied|multiple|mixed|combine|combining)\b/.test(normalized)
  ) {
    intents.push("mixed_problem_practice");
  }
  if (
    /\b(?:event|events|party|parties|gathering|gatherings|reunion|picnic|holiday|hosting)\b/.test(normalized) &&
    /\b(?:organize|organizing|plan|planning|consider|budget|costs?|financial|spending)\b/.test(normalized)
  ) {
    intents.push("event_budget_details");
  }
  if (
    /\b(?:withdraw|withdrawal|take money out|take funds out|cash out|sell(?:ing)?)\b/.test(normalized) &&
    /\b(?:investment account|brokerage|portfolio|investments?|account|money)\b/.test(normalized)
  ) {
    intents.push("investment_withdrawal_tax");
  }
  if (
    (
      /\b(?:travel|arrangements?|flight|flights|train|hotel|accommodations?|trip|vacation)\b/.test(normalized) ||
      /\bgetting from\b.+\bto\b/.test(normalized)
    ) &&
    /\b(?:options?|costs?|details?|arrangements?|travel|get(?:ting)?|from|to)\b/.test(normalized)
  ) {
    intents.push("travel_cost_details");
  }
  if (
    /\bscott\b/.test(normalized) &&
    /\b(?:support|supporting|academic|tutoring|extracurricular|social|digital habits?|screen time|summary|summarize|addressed|coordinated)\b/.test(normalized) &&
    /\b(?:summary|summarize|aspects|over time|addressed|coordinated|strategies|adjustments?|outcomes?)\b/.test(normalized)
  ) {
    intents.push("scott_support_summary");
  }
  if (
    /\b(?:investment strategy|portfolio management|portfolio allocation|portfolio adjustments?|portfolio|investments?)\b/.test(normalized) &&
    /\b(?:summary|summarize|comprehensive|detailed|evolved|over time|key decisions?|adjustments?|advice|meetings?|discussions?)\b/.test(normalized)
  ) {
    intents.push("portfolio_management_summary");
  }
  if (
    /\b(?:parents?|mom|mother|dad|father|samantha|ryan)\b/.test(normalized) &&
    /\b(?:nutrition|nutritional|meal plans?|well-being|caregiving|support(?:ed|ing)?)\b/.test(normalized) &&
    /\b(?:summary|summarize|comprehensive|over time|course|conversations?)\b/.test(normalized)
  ) {
    intents.push("parent_nutrition_summary");
  }
  if (
    /\b(?:tea|teas|evening drink|bedtime drink)\b/.test(normalized) &&
    /\b(?:evening|bedtime|sleep|relax(?:ing|ation)?|options?|suggest|recommend)\b/.test(normalized)
  ) {
    intents.push("evening_tea_options");
  }
  if (
    /\b(?:rebuilding trust|trust|relationship|rachael)\b/.test(normalized) &&
    /\b(?:summary|summarize|covered|everything|progress|over time|strategies|interactions|challenges)\b/.test(normalized) &&
    /\b(?:relationship|trust|rachael|strengthening)\b/.test(normalized)
  ) {
    intents.push("relationship_trust_summary");
  }
  if (
    /\b(?:detailed|comprehensive|full scope|progression|key developments?|challenges?|solutions?|different sessions?)\b/.test(normalized) &&
    /\b(?:summary|summarize|captures?|integrating|progression|topic)\b/.test(normalized)
  ) {
    intents.push("technical_project_summary");
  }
  if (
    /\b(?:emotional reaction|how did i feel|what did i feel|specific feedback|qualifications?|expertise|did i mention|was there any|any specific)\b/.test(normalized) &&
    /\b(?:confus(?:e|ed|ing|ion)|mistake|feedback|podiatrist|article|reaction|qualification|expertise|received)\b/.test(normalized)
  ) {
    intents.push("answerability_absence");
  }
  return [...new Set(intents)];
}

function buildGuidanceQuery(
  query: string,
  intents: readonly GuidanceIntent[],
): string {
  const parts = [
    query,
    "user instruction always prefer preference avoid use format include mention should",
    "preference statement user instruction compliance style formatting response guidance",
  ];
  if (intents.includes("dates")) {
    parts.push("date due deadline submission month day year final specific dates each event avoid vague time references general descriptions without dates recent rehearsals coaching sessions");
  }
  if (intents.includes("editing")) {
    parts.push("editing draft revision Scrivener split-screen side-by-side comparison two panels AI tools AI-assisted initial edits tone calibration");
  }
  if (intents.includes("finance")) {
    parts.push("Excel spreadsheet recurring expenses one-time purchases fund distribution reallocate allocation shifts financial goals");
  }
  if (intents.includes("decor_recommendations")) {
    parts.push("decor living space built-in storage built in storage multifunctional furniture multi-functional furniture storage ottomans modular seating practical features aesthetic recommendations balance aesthetic and practical");
  }
  if (intents.includes("project_financial_limits")) {
    parts.push("financial limits budget project itemized list of costs specific dollar amounts category-by-category breakdown detailed cost analysis cost categories budget amounts");
  }
  if (intents.includes("team_event_attendance")) {
    parts.push("team events team practice practice session scrimmage attendance numbers player attendance count players out of total turnout number of players attendance included");
  }
  if (intents.includes("api_errors")) {
    parts.push("REST API error handling HTTP status codes numeric codes 400 401 403 404 429 500 response codes failures");
  }
  if (intents.includes("api_concurrency")) {
    parts.push("multiple API requests API calls tweet metrics Twitter API async Python libraries frameworks asyncio aiohttp httpx async/await concurrency concurrent requests non-blocking calls batching gather rate limits efficient request handling");
  }
  if (intents.includes("ai_hiring_fairness")) {
    parts.push("AI hiring fairness candidate evaluation hiring process pilot program test AI tool effectiveness human oversight final decisions configure anonymization anonymize resumes applications remove personal identifiers names dates of birth addresses bias audits third-party audits regularly monitor diversity metrics feedback structured interviews assess soft skills alongside AI screening job-relevant criteria fairness transparency");
  }
  if (intents.includes("audiobook_narrators")) {
    parts.push("audiobook narrator details narrator names narrated by read by recommendations listen");
  }
  if (intents.includes("contradiction_resolution")) {
    parts.push("contradictory information conflicting statements never said also mentioned which statement is correct resolve contradiction protective masks gloves respirator insulation ergonomic supports kneeling pads");
  }
  if (intents.includes("media_platforms")) {
    parts.push("movie recommendations streaming services platform names availability apps websites Netflix Hulu Disney Prime");
  }
  if (intents.includes("allergy_check")) {
    parts.push("snack recommendations ask about allergies allergy concerns confirm allergy information before recommending snacks");
  }
  if (intents.includes("philosophy_summary")) {
    parts.push("philosophical concepts existentialism detailed summary category-by-category breakdown itemized categories");
  }
  if (intents.includes("reading_variety")) {
    parts.push("reading list standalone novels series balance suggestions variety avoid fatigue");
  }
  if (intents.includes("reading_goals_summary")) {
    parts.push("reading goals strategies summary schedule prioritizing Kingkiller Chronicle Mistborn Trilogy Broken Empire staying on track Stormlight Archive 1200 pages December 1 audiobooks evening listening cozy reading environment daily goals Expanse 1500 pages March 15 75 pages daily Nightingale Kristin Hannah diversify reading experience print audiobook formats book budget fiction books Montserrat Books");
  }
  if (intents.includes("writing_process_structure")) {
    parts.push("writing process structure steady progress stay motivated deadline overall target daily weekly word count goals fixed writing times flexible writing sessions outline scene breakdown organization visualizing success rewarding milestones accountability partner stress management mindfulness relaxation focus confidence");
  }
  if (intents.includes("writing_schedule")) {
    parts.push("writing sessions morning hours 7-9 AM schedule prioritize focused writing");
  }
  if (intents.includes("daily_routine")) {
    parts.push("structured daily routine organize day stay on track responsibilities wake-up sleep times 7 AM 9 PM regularity structure consistent timing");
  }
  if (intents.includes("decision_framework")) {
    parts.push("career change work environment compensation package equity budget adjust accordingly support network startup employees workload expectations");
  }
  if (intents.includes("portfolio_links")) {
    parts.push("portfolio links clickable links directly in cover letter body avoid attachments separate documents inline link");
  }
  if (intents.includes("deployment_automation")) {
    parts.push("deployment workflow automated CI/CD pipelines monitoring tools status dashboards real-time updates avoid manual deployment checks");
  }
  if (intents.includes("lightweight_tools")) {
    parts.push("lightweight libraries minimal dependencies avoid large frameworks heavy dependencies simplicity easy to maintain Bootstrap 5.3.0 lazysizes vanilla JS avoid Foundation");
  }
  if (intents.includes("progress")) {
    parts.push("percentage improvements percentage values showing progress numeric progress indicators percent completion editing progress");
  }
  if (intents.includes("health")) {
    parts.push("sneaker shoe comfort physical well-being injury prevention arch support cushioning grip soles");
  }
  if (intents.includes("nutrition_hydration")) {
    parts.push("nutrition advice healthy diet meal planning hydration tips drinking fluids water intake properly hydrated food-related tips alongside nutrition");
  }
  if (intents.includes("heart_function_activity_management")) {
    parts.push("ejection fraction EF 55 heart pumping efficiency physical activity fatigue shortness of breath climbing stairs gradual increase monitor symptoms cardiology follow-up lifestyle modifications diet sodium saturated fats weight management avoid smoking quit smoking limit alcohol excessive alcohol medication adherence stress management");
  }
  if (intents.includes("sleep_improvement_percent")) {
    parts.push("sleep efficiency improved recently exact percentages percentage increase precise numerical improvement January 70 February 1 78 March 10 85 82 11.43 8.97 17.14 12 percentage points");
  }
  if (intents.includes("sleep_environment_habits_summary")) {
    parts.push("sleep environment habits thermostat settings blackout curtains blackout blinds meditation 2200K lamps night sweats sleep quality stabilized circadian rhythms affordable DIY solutions window films reflective films room darkening shades");
  }
  if (intents.includes("mattress_warranty_details")) {
    parts.push("mattress SleepWell Deluxe purchase decision warranty extension 5-year warranty coverage defects repairs replacements trial period return policy coverage details");
  }
  if (intents.includes("sleep_wind_down_screen_free")) {
    parts.push("unwind before bed wind down physical books avoid screen-based activities screen-free no-screen zone meditation secondary optional relaxation without screen exposure reading journaling breathing");
  }
  if (intents.includes("april_relationship_timing")) {
    parts.push("April partner weekend meaningful conversation joint activities morning early weekend timing supports energy levels avoid late evenings people tired most alert calm mornings");
  }
  if (intents.includes("april_relationship_summary")) {
    parts.push("April relationship summary practical steps implement ideas special outings thoughtful gestures flower deliveries meaningful traditions fresh exciting romance date nights surprises shared hobbies community center volunteering regular check-ins finances legal matters physical touch love language");
  }
  if (intents.includes("work_life_balance_summary")) {
    parts.push("reduce work hours clinical hours 50 to 40 by July 2024 50 to 45 May 2024 work-life balance personal life boundaries avoiding work emails progress monitoring regularly prioritize tasks delegate responsibilities streamline processes communicate supervisor quality personal time");
  }
  if (intents.includes("turkish_pronunciation_quantitative")) {
    parts.push("Turkish pronunciation improving quantitative session data included number of practice sessions 40 pronunciation drills Turkish Pronunciation Trainer 90% accuracy difficult consonant clusters 98 words per minute speaking speed November 15");
  }
  if (intents.includes("turkish_live_learning_formats")) {
    parts.push("Turkish skills learning formats interactive live classes synchronous classes immediate feedback iTalki Preply Verbling Cambly avoid focusing only on pre-recorded materials");
  }
  if (intents.includes("study_space_tools_count")) {
    parts.push("study space tools decorations eight different tools noise-cancelling headphones timer second monitor Turkish cultural artifacts Turkish flag cultural calendar calendar countdown");
  }
  if (intents.includes("home_family_repayment")) {
    parts.push("family financial assistance Crystal mother 50,000 TRY down payment repayment plan 5 years 60 months 900 TRY monthly payments starting June 1 5% interest formal agreement promissory note budget impact");
  }
  if (intents.includes("home_repair_cost_update")) {
    parts.push("minor plumbing leaks repair cost estimate updated second opinion plumber visit April 22 7,500 TRY lower estimate repair costs second professional opinion");
  }
  if (intents.includes("home_condition_final_inspection")) {
    parts.push("house condition before finalize final home inspection May 5 plumbing repairs completed no further issues repair completion verified final inspection report documentation seller contractor written confirmation photos re-inspection");
  }
  if (intents.includes("home_neighborhood_tour")) {
    parts.push("neighborhood tour Samantha scheduled April 13 11 AM start time Mevlana apartment complex reminders April 12 April 13 local amenities parks green spaces");
  }
  if (intents.includes("home_neighborhood_preferences")) {
    parts.push("neighborhood comparison quietness quiet neighborhood parks green spaces Ataturk Park Mevlana Street balance local amenities shopping nightlife avoid overemphasizing nightlife shopping parks work commute safety");
  }
  if (intents.includes("home_stove_recommendations")) {
    parts.push("new kitchen stove recommendations energy-efficient brands models Bosch Siemens Arcelik Arçelik similar quality stoves comparable price range appliances long-term utility savings");
  }
  if (intents.includes("home_apartment_cost_difference")) {
    parts.push("2-bedroom apartment Mevlana Street 580,000 TRY 3-bedroom apartment Inonu Avenue İnönü Avenue 620,000 TRY difference 40,000 TRY more closing costs total additional cost 41,200 TRY");
  }
  if (intents.includes("home_cash_flow_summary")) {
    parts.push("cash flow monthly income 7,083 TRY total monthly expenses 7,500 TRY mortgage 3,500 utilities 450 gym 250 property tax 1,200 Crystal repayment 900 monthly shortfall 416.67 TRY negative cash flow reduce expenses increase income");
  }
  if (intents.includes("home_buying_financial_steps")) {
    parts.push("home buying timeline financial steps saving fixed amount takes several years mortgage estimates loan down payment interest term taxes insurance upfront ongoing commitments down payment closing costs monthly costs");
  }
  if (intents.includes("home_buying_summary")) {
    parts.push("complete home buying summary current rental area Ataturk Park sales data Andrew apartment options Mevlana Street priority Crystal 50,000 TRY repayment plan budgeting reducing discretionary spending increasing income repairs moving logistics title insurance final inspection closing");
  }
  if (intents.includes("home_mortgage_choice_summary")) {
    parts.push("fixed-rate versus variable-rate mortgage lower starting variable rate current rates economic outlook risk tolerance loan term caps rising rates hybrid ARMs refinancing fixed-rate predictability higher initial rate");
  }
  if (intents.includes("home_inspection_timing")) {
    parts.push("home inspection April 15 inspection report delivered April 18 lawyer contract review April 20 two days before lawyer meeting five days after home inspection");
  }
  if (intents.includes("selling_photo_service_steps")) {
    parts.push("FocusLens April 7 10 AM $350 professional photography 30 high-resolution photos prepare home staging decluttering optimizing lighting arranging furniture cleaning fixtures confirm appointment communicate expectations desired shots be present assist review delivered photos select best 30 high-resolution images optimize for web use");
  }
  if (intents.includes("selling_financial_plan_detail")) {
    parts.push("home sale finances next year itemized list of costs category-by-category breakdown detailed cost analysis closing costs commission repairs staging photography moving expenses mortgage balance net profit");
  }
  if (intents.includes("selling_rental_payment_terms")) {
    parts.push("rent out terms lease agreement payment amounts adjustments changes in payment during agreement payment modifications temporary rent reduction payment plan signed addendum");
  }
  if (intents.includes("selling_rental_price")) {
    parts.push("Kadikoy apartment rental price set 4,550 TRY rent adjusted price market feedback final agreed prices 4,500 TRY");
  }
  if (intents.includes("selling_service_total_cost")) {
    parts.push("staging photography total cost $1,550 Elegant Spaces $1,200 FocusLens $350 professional staging photography services");
  }
  if (intents.includes("selling_sequence_repairs_marketing")) {
    parts.push("optimal sequence repairs staging marketing start decluttering and staging immediately complete repairs including roof leak before final inspection schedule photography just after staging finalize marketing materials before listing coordinate Selim pricing strategy by late March prepare for final inspection repairs done by early May buyer inspection closing aligned with moving schedule");
  }
  if (intents.includes("selling_professional_staging_preference")) {
    parts.push("preparing home attractive to buyers professional staging benefits hiring experts avoids only DIY acknowledges upfront cost focuses staging quality");
  }
  if (intents.includes("selling_morning_appointments")) {
    parts.push("schedule appointments next week morning time slots benefits early appointments start early early morning appointments maximize productivity reduce stress");
  }
  if (intents.includes("selling_home_summary")) {
    parts.push("home selling summary Selim Kaya North Ericshire Realty CMA early spring Elegant Spaces $1,200 high-impact areas living room backyard oak tree roof fix April 3 FocusLens Matterport contractors paperwork legal negotiations commission rejected $400k offer countered $415k timeline financial considerations final contract signing");
  }
  if (intents.includes("selling_stress_summary")) {
    parts.push("stress summary daily mindfulness meditation Headspace Calm mindful walking listening home showing calming environments practical strategies financial neighborhood stress yoga progressive muscle journaling exercise consistent practice support networks");
  }
  if (intents.includes("selling_roof_offer_timing")) {
    parts.push("March 28 home inspection roof leak April 3 roof repair completed April 20 first offer 6 days from March 28 till April 3 17 days from April 3 till April 20");
  }
  if (intents.includes("diy_living_together_duration")) {
    parts.push("James Jamie 3-bedroom house Ataturk Street Atatürk Street lived together 5 years");
  }
  if (intents.includes("diy_paint_budget_breakdown")) {
    parts.push("Bauhaus Turkey Cumhuriyet Boulevard paint supplies budget break down item types paint primer brushes rollers trays painter tape drop cloths sandpaper typical prices example calculation medium-sized living room");
  }
  if (intents.includes("diy_pipe_leak_safety")) {
    parts.push("leaking pipe bathroom safety protective gear avoid hazards prevent injury damage turn off water supply water shutoff shutoff warnings plug drain washers O-rings step-by-step plumbing repair workshop");
  }
  if (intents.includes("diy_drill_model_specificity")) {
    parts.push("exact drill recommendation model number Bosch GSR 12V-15 12V Cordless Drill specific product tool version");
  }
  if (intents.includes("diy_paint_supply_spend")) {
    parts.push("paint supplies spent spending total $335 increased to $335 remaining budget");
  }
  if (intents.includes("diy_professional_savings")) {
    parts.push("DIY savings over hiring professionals painting hiring painter $400 DIY painting saved $350 faucet replacement plumbing saved $220 plumber total savings");
  }
  if (intents.includes("diy_resource_sequence")) {
    parts.push("DIY resource sequence prioritize essential hand tools power tools upcoming projects allocate budget bulk purchases with James borrow Don 3-meter ladder move heavy items with Don safety-critical steps first installation finishing touches");
  }
  if (intents.includes("diy_visual_learning_preference")) {
    parts.push("home repairs hands-on learning video tutorials visual interactive resources prefer video tutorials over reading manuals avoid text-heavy manuals as main resource");
  }
  if (intents.includes("diy_kitchen_surface_preference")) {
    parts.push("kitchen surfaces durability ease of cleaning lasting quality materials avoid trendy purely aesthetic focus countertops");
  }
  if (intents.includes("diy_insulation_summary")) {
    parts.push("attic insulation summary budget $600 Owens Corning fiberglass rolls $450 June 15 June 22 respirator masks gloves safety glasses long-sleeved clothing ventilation measure fit insulation seal gaps weatherstripping caulk track expenses common mistakes");
  }
  if (intents.includes("diy_shelf_summary")) {
    parts.push("bathroom shelf summary $100 budget August 15 moisture-resistant materials brackets hooks anchors screws level tape measure drill pilot holes secure brackets safety gear Don help final stability");
  }
  if (intents.includes("diy_painting_timing")) {
    parts.push("painting living room start April 1 finished two coats dove gray April 13 12 days April 1 till April 13");
  }
  if (intents.includes("diy_faucet_timing")) {
    parts.push("plumbing basics workshop April 10 learned replacing faucet washers practice replacing faucet washers April 29 19 days April 10 till April 29");
  }
  if (intents.includes("cooking_weekly_cuisine_plan")) {
    parts.push("cooking plan week-by-week breakdown maintain cultural focus one cuisine every 6 weeks avoid multiple cuisines same short timeframe 6-week blocks weekly goals research resources ingredients techniques practice document progress");
  }
  if (intents.includes("cooking_dolma_leaf_preparation")) {
    parts.push("stuffed grape leaves dolma rinse leaves remove stems fresh herbs conservative salt avoid saltiness roll leaves tightly moderate amount filling arrange seam-side down pot add water olive oil simmer gently 45-60 minutes tender rest before serving flavors meld");
  }
  if (intents.includes("cooking_culinary_journey_summary")) {
    parts.push("culinary journey cooking skills Turkish Greek Lebanese cuisines structured month-by-month plan research ingredient preparation cooking practice feedback gathering documentation knife techniques julienne chiffonade regular practice recipes deadlines manageable steps journals photos community engagement dough kneading elasticity baked goods sauce emulsification Italian Indian menu planning social events spice blend mastery");
  }
  if (intents.includes("outdoor_cardio_preference")) {
    parts.push("cardio activities trail running over treadmill fresh air varied terrain outdoor cardio natural settings avoid treadmill indoor-only exercises");
  }
  if (intents.includes("social_norms")) {
    parts.push("social norms cultural context cultural differences multiple regions traditions expectations");
  }
  if (intents.includes("software_versions")) {
    parts.push("software version details version numbers release identifiers digital asset management tools technology stack current setup software names with version numbers versions listed alongside technologies explicit version details");
  }
  if (intents.includes("uk_resume")) {
    parts.push("UK resume CV ATS formatting UK-specific generic global template");
  }
  if (intents.includes("decision_framework")) {
    parts.push("logical reasoning frameworks avoid emotional impulses practical nature decision approach");
  }
  if (intents.includes("realtime_chat_summary")) {
    parts.push("real-time chat Socket.io WebSocket Node.js Express message broadcasting user management connection handling error handling observability logging helper functions CORS client server version matching load balancer message queue MongoDB Mongoose indexing pagination Redis caching sessions presence TTL ACL retry logic exponential backoff circuit breaker fallback room-based messaging history retrieval joining private messaging unique room ID typing indicators latency ping-pong Map Set data structures recent messages schema validation editing updateMessage unchanged message text migration script batch execution robust error handling asynchronous control");
  }
  if (intents.includes("technical_project_summary")) {
    parts.push("resume analyzer Python spaCy Flask PyMuPDF PDF parsing work experience skills education keyword searches sentence segmentation NER job titles companies educational institutions modularize code error handling Flask API NoneType logging traceability February 15 2024 project timeline cProfile bottlenecks in-memory cache Redis-backed caching regex patterns precompile stopword removal lemmatization lazy-loading spaCy smaller models custom NER training dataset size weighted scoring skill matching latency skill prioritization experience levels visualization weighted skill scores authentication authorization concurrent request simulation");
    parts.push("object detection tracking pipeline YOLOv5 OpenCV SORT Kalman filter Hungarian algorithm data association TensorRT OpenCV DNN DeepSORT SSD MobileNet modular refactoring detection pipeline multi-object tracking error handling logging visualization utilities iterative development integration process system integration future-proofing scalability");
    parts.push("recommendation system recommender user-based collaborative filtering cosine similarity user ratings matrix missing ratings normalizing data sparse matrices Redis caching similarity matrices Flask /recommendations endpoint helper functions get_user_ratings get_top_rated_items content-based filtering TF-IDF vectors restaurant_features feature_vector JSONB hybrid recommendation tunable weights weighted average collaborative content scores user preferences precision recall precision@5 recall@5 F1-score AUC-ROC scalability efficiency performance optimization");
    parts.push("language translation detection services Google Translate API v3 DeepL API v2 accuracy cost language support ease of integration React 18.2 Node.js 18 troubleshooting authentication failures rate limiting invalid inputs API quota exceeded franc v6.1.0 undefined returns input validation preprocessing Redis caching TTL asynchronous processing parallel request handling translation microservice chatbot backend RESTful APIs fallback original text Redis hashes cache-manager database indexing asynchronous external API calls contextual memory storage GPT-4 chatbot core logic Transformer-Based LLM API streaming integration streaming performance tuning chunk size 512 tokens TLS security role-based access control");
    parts.push("image captioning system diffusion-based feature extractor transformer-based caption generator modular pipeline independent testing decoupled microservices REST APIs FastAPI Docker Compose networks inter-service communication feature_extractor caption_generator Redis caching embeddings LRU caches asynchronous processing efficient resource management GPU acceleration API response time profiling CUDA out-of-memory batch sizes mixed precision training gradient accumulation optimizer initialization materialized views PostgreSQL indexing refresh strategies efficient data retrieval");
  }
  if (intents.includes("conic_sections_summary")) {
    parts.push("conic sections mathematical foundations applications parabolas ellipses hyperbolas vertex form y=a(x-h)^2+k vertex coordinates parameter p focal length directrix completing the square general quadratic equations identify vertex focus vertex focus coordinates reflective property incoming parallel rays reflect through focus parabolic mirrors satellite dishes slope normal vector calculations ellipse geometric definition constant sum distances two foci standard ellipse equation isolate radicals canonical form relationships a b c c^2=a^2-b^2 vertices foci tangent lines implicit differentiation general tangent line formula hyperbola geometric definition constant difference distances foci x^2/a^2-y^2/b^2=1 c^2=a^2+b^2 algebraic forms geometric definitions physical properties physics engineering contexts integrated narrative progression foundational equations practical applications coherent framework");
  }
  if (intents.includes("calculus_derivative_progression")) {
    parts.push("implicit differentiation derivative complexity circle equation simple ratio -x/y quadratic equation product term fraction linear terms -(2x+y)/(2y+x) cubic equation product term fraction quadratic terms -(3x^2+y)/(3y^2+x) increasing algebraic complexity simplest most complex");
  }
  if (intents.includes("calculus_derivative_walkthrough")) {
    parts.push("derivative walkthrough product rule chain rule step-by-step calculations example calculations explain each rule applies in context avoid vague purely theoretical descriptions differentiate composite functions");
  }
  if (intents.includes("euler_step_accuracy")) {
    parts.push("Euler method step size accuracy quantitative accuracy differences h=1 12% error h=0.1 1.2% error average error reducing from 8% to 3% smaller step size more accurate more computation differential equations");
  }
  if (intents.includes("population_parameter_estimation")) {
    parts.push("population trends exponential growth logistic growth combine models parameter estimation improvements sample data points expanded datasets parameter optimization estimate K carrying capacity estimate r growth rate predict population trends");
  }
  if (intents.includes("variance_concrete_examples")) {
    parts.push("variance random variable concrete numerical examples dice rolls dice roll outcomes specific numerical probabilities values avoid purely symbolic abstract explanations without concrete numbers step-by-step variance calculation");
  }
  if (intents.includes("spherical_geodesic_vector_methods")) {
    parts.push("shortest path between two points on a sphere spherical geodesic great circle vector algebra concepts geometric vectors vector-based calculation steps minimize avoid purely trigonometric formula reliance dot product unit vectors");
  }
  if (intents.includes("skill_course_completion")) {
    parts.push("skill acquisition skills gained recently course completion details finished programs completed training digital networking course advanced research writing course final score completed programs");
  }
  if (intents.includes("morning_coffee_meeting")) {
    parts.push("coffee meeting morning-specific preparation tips strategies aligned with early-day meetings early-day 9:00 AM Dr Kaya timing advice morning meeting scenario");
  }
  if (intents.includes("telepsychology_expansion_summary")) {
    parts.push("telepsychology services expansion market demand competitor landscape legal privacy requirements secure telehealth platforms training staff client comfort transparent communication technical support flexible service models professional networks outreach referral engagement social media professional development investments Trauma Therapy Journal webinar software licenses budget constraints research collaborations client intake career goals work-life balance co-authorships speaking engagements editorial board credibility networking financial impact deadlines workshop preparations post-collaboration relationships");
  }
  if (intents.includes("professional_event_project_summary")) {
    parts.push("professional events projects initial planning execution follow-up pre-event preparation agendas speakers attendees clear objectives technical readiness testing equipment virtual platforms venue logistics active engagement sessions discussions networking social media scheduled breaks personalized thank-you messages professional networks ongoing communication foster collaborations time blocking Pomodoro budget strategic partnerships co-hosting roles goals marketing reflection evaluation");
  }
  if (intents.includes("job_commute_preference")) {
    parts.push("job listings best fit roles within 30 km of North Ericshire commute time reduce commuting time under 45 minutes work-life balance proximity travel duration");
  }
  if (intents.includes("sarah_resume_revision_planning")) {
    parts.push("Sarah Istanbul conference suggested updating resume by March 15 resume update professional documents planned meetings prepared materials structured update process timeline mock interview Sarah March 20 Zoom");
  }
  if (intents.includes("rental_income_preference")) {
    parts.push("rental income stability steady rental income long-term wealth accumulations long-term wealth accumulation avoid short-term sales profits quick resale profits minimize vacancy tenant turnover predictable monthly returns");
  }
  if (intents.includes("rental_property_journey_summary")) {
    parts.push("rental property journey initial capital 50000 local market conditions down payment requirements closing fees fixer-upper properties structural issues outdated features location versus elsewhere management market diversity growth potential single-family homes multi-family units rental yield management complexity Halkbank Ziraat Bank mortgages interest rates fees service quality step-by-step purchasing plan inspections financing tenant management");
  }
  if (intents.includes("cryptocurrency_investment_summary")) {
    parts.push("cryptocurrency investments Bitcoin Ethereum Binance CoinGecko TradingView hardware wallet phishing DeFi staking Cardano ADA NFT community engagement Discord Reddit conferences webinars regulatory risk tax compliance step-by-step document organization capital gains calculation financial analyst accurate timely filings advanced learning paths DeFi protocols yield farming security practices ongoing education strategic portfolio adjustments");
  }
  if (intents.includes("math_induction_summary")) {
    parts.push("mathematical induction learning journey progress summary sum of first n integers base case inductive step inductive hypothesis divisibility proofs inequalities inequality induction step-by-step verification practice problems challenges real-world applications paramedic work abstract concepts practical scenarios tracking progress study habits quiz scores");
  }
  if (intents.includes("number_theory_congruence_examples")) {
    parts.push("number theory congruences modular arithmetic properties numerical instances demonstrating theorems examples with actual numbers step-by-step calculations using numbers Fermat's Little Theorem Euler's theorem linear congruence remainder mod");
  }
  if (intents.includes("math_step_calculations")) {
    parts.push("distance formula coordinate geometry step-by-step breakdown intermediate arithmetic calculations substitute coordinates calculate differences square differences add squared differences simplify square root explain each part of the process");
  }
  if (intents.includes("mixed_problem_practice")) {
    parts.push("mixed problem sets varied problem sets covering multiple topics combine different problem types practice comprehensive exam study sessions line equations circles ellipses intersections proofs avoid focusing only one type problem at a time randomization variety");
  }
  if (intents.includes("event_budget_details")) {
    parts.push("event party gathering reunion picnic holiday hosting budget costs clear budget numbers exact monetary figures specific cost amounts approved increase 500 2500 financial decision freelance offer");
  }
  if (intents.includes("travel_cost_details")) {
    parts.push("travel arrangements cost details itemized costs specific dollar amounts category-by-category breakdown transportation accommodation meals activities budget travel options");
  }
  if (intents.includes("investment_withdrawal_tax")) {
    parts.push("investment withdrawal take money out investment account brokerage portfolio tax implications possible taxes owed penalties withdrawal penalties capital gains taxable distribution");
  }
  if (intents.includes("scott_support_summary")) {
    parts.push("Scott support academic challenges tutoring sessions Ms Harper goal-setting consistent monitoring distraction-free study environment organized workspace free from distractions growth mindset summer STEM camp extracurricular engagement routine establishment time management social encouragement physical mental well-being role-playing social scenarios self-expression independence clear expectations consistent feedback gradual responsibility digital safety parental controls online risks privacy management open communication screen time daily routines physical creative pursuits modeling healthy habits emotional well-being consistent schedules coping mechanisms");
  }
  if (intents.includes("portfolio_management_summary")) {
    parts.push("portfolio management investment strategy evolved over time trusted partner financial decision-making Jeremy Kendra financial advisor rebalancing strategies periodic quarterly reviews threshold-based rebalancing 5% threshold Vanguard platform monitoring alerts semi-annual reviews bond laddering interest rate risk income stability US Treasuries municipal corporate bonds staggered maturities diversification international stock exposure sustainable investments green bonds sector-specific allocations tech stocks biotech ETFs growth risk management market conditions tax implications transaction costs volatility limits regular consultations professional support investment anxiety clear goal setting education multi-faceted portfolio management");
  }
  if (intents.includes("parent_nutrition_summary")) {
    parts.push("parents nutrition well-being comprehensive summary mom Samantha 89-year-old suitable meal plans nutrient-rich easy-to-prepare meals hydration medication interactions detailed recipes balanced meals snacks dad Ryan 105-year-old care center caregivers structured scheduling nutritional care family-shared bone broth health benefits frequency consumption plant-based protein powder smoothies nutritional goals holistic family-supported caregiving responsibilities");
  }
  if (intents.includes("evening_tea_options")) {
    parts.push("evening tea herbal teas chamomile peppermint relaxation sleep promote sleep avoid caffeine caffeinated teas bedtime drink calming herbal tea options");
  }
  if (intents.includes("relationship_trust_summary")) {
    parts.push("Rachael rebuilding trust relationship initial recognition trust issues emotional impact acknowledging mistakes taking responsibility communicating openly honestly initial apology weekly check-ins dialogue examples transparency empathy accountability course relationship dynamics active listening patience consistent follow-through commitments trusted friends perspective support professional relationships alongside personal goals shared experiences emotional connection coastal walks milestones setbacks forgotten anniversaries adapting plans feedback coherent narrative complexity multi-threaded nurturing long-term relationship");
  }
  if (intents.includes("answerability_absence")) {
    parts.push("explicit evidence answerability absence no information related stated mentioned received emotional reaction feedback qualifications expertise do not infer");
  }
  return parts.join(" ");
}

function isGuidanceEvidence(
  content: string,
  query: string,
  intents: readonly GuidanceIntent[],
  forceGeneric = false,
): boolean {
  const normalized = content.toLowerCase();
  if (hasInstructionOrPreferenceCue(normalized)) {
    return forceGeneric ||
      hasGuidanceIntentCue(normalized, intents) ||
      countGuidanceTermOverlap(normalized, query) >= 1;
  }

  return intents.some((intent) => {
    switch (intent) {
      case "dates":
        return /\b(?:due|deadline|submission|submit|final)\b/.test(normalized) &&
          /\b(?:january|february|march|april|may|june|july|august|september|october|november|december)\s+\d{1,2}(?:,\s*\d{4})?\b/i.test(content) ||
          /\b(?:rehearsals?|coaching sessions?|practice sessions?|event outcomes?|performance outcomes?)\b/.test(normalized) &&
            /\b(?:january|february|march|april|may|june|july|august|september|october|november|december)\s+\d{1,2}(?:,\s*\d{4})?\b/i.test(content);
      case "editing":
        return /\b(?:scrivener|split-screen|side-by-side|two panels?|comparison|ai tools?|ai-assisted|initial edits?|tone calibration|grammarly|hemingway|peer review)\b/.test(normalized) &&
          /\b(?:edit|edits|editing|draft|revision|revise)\b/.test(normalized);
      case "finance":
        return /\b(?:excel|spreadsheet|recurring|one-time|fund distribution|reallocate|allocation|shift funds?|shifts?)\b/.test(normalized) &&
          /\b(?:budget|expenses?|financial|fund|goals?|saving|spending)\b/.test(normalized);
      case "decor_recommendations":
        return /\b(?:decor|living space|home|apartment|furniture|storage|ottomans?|modular|multifunctional|multi-functional|built-in|built in|aesthetic|practical)\b/.test(normalized) &&
          /\b(?:suggest|recommend|items?|options?|features?|storage|furniture|decor|aesthetic|practical)\b/.test(normalized);
      case "project_financial_limits":
        return /\b(?:budget|costs?|financial limits?|dollar amounts?|\$\s*\d|category-by-category|breakdown|cost analysis|itemized|project)\b/.test(normalized) &&
          /\b(?:budget|costs?|financial|limits?|amounts?|breakdown|analysis|project)\b/.test(normalized);
      case "team_event_attendance":
        return /\b(?:attendance numbers?|player attendance|attendance count|players out of|player turnout|number of players|team events?|practice session|team practice|scrimmage)\b/.test(normalized);
      case "api_errors":
        return /\b(?:rest api|api|endpoint|http|status codes?|response codes?|400|401|403|404|429|500)\b/.test(normalized) &&
          /\b(?:errors?|failures?|error handling|handle|prepared)\b/.test(normalized);
      case "api_concurrency":
        return /\b(?:api requests?|api calls?|twitter api|tweet metrics|async(?:io|hronous)?|async\/await|aiohttp|httpx|concurrent(?:ly| requests?)?|concurrency|non-blocking|batch(?:ing)?|gather)\b/.test(normalized) &&
          /\b(?:libraries?|frameworks?|async|concurrency|concurrent|non-blocking|multiple|efficient|blocking|rate limits?|calls?|requests?)\b/.test(normalized);
      case "ai_hiring_fairness":
        return /\b(?:pilot program|ai tool|ai hiring|hiring process|human oversight|final decisions?|anonymization|anonymize|personal identifiers?|bias audits?|third-party audits?|diversity metrics?|candidate satisfaction|structured interviews?|soft skills|ai screening|job-relevant criteria|fairness|transparency)\b/.test(normalized) &&
          /\b(?:hiring|candidate(?:s)?|resume(?:s)?|applications?|ai|screening|bias|fairness|interviews?)\b/.test(normalized);
      case "audiobook_narrators":
        return /\b(?:audiobooks?|audio books?)\b/.test(normalized) &&
          /\b(?:narrator|narrated by|read by|who read|voice)\b/.test(normalized);
      case "contradiction_resolution":
        return (
          /\b(?:never|ever|usually|said|mentioned|also|contradictory|conflicting|statement|correct|do not|don't|didn't|not|spent|read(?:ing)?|articles?|protective masks?|respirator masks?|masks?|gloves?|insulation|ergonomic supports?|kneeling pads?|cushioned kneeling pad)\b/.test(normalized) &&
          countGuidanceTermOverlap(normalized, query) >= 1
        ) ||
          /\bclinical psychology\b/.test(query.toLowerCase()) &&
            /\b(?:workshops?|conferences?)\b/.test(query.toLowerCase()) &&
            /\bpsychology conference\b/.test(normalized) &&
            /\b(?:met|friend|close friend|omar)\b/.test(normalized) ||
          /\b(?:completed|solved|scored|score)\b/.test(normalized) &&
            /\b(?:jacobian|change of variables|separable equations?|problems?)\b/.test(normalized) &&
            countGuidanceTermOverlap(normalized, query) >= 1;
      case "media_platforms":
        return /\b(?:movies?|watchlist|streaming services?|platform names?|availability|netflix|hulu|disney|prime)\b/.test(normalized);
      case "allergy_check":
        return /\b(?:snacks?|allerg(?:y|ies)|allergy concerns?|confirm allergy)\b/.test(normalized);
      case "philosophy_summary":
        return /\b(?:existentialism|philosophical concepts?|philosophy|category-by-category|detailed summar(?:y|ies)|breakdown)\b/.test(normalized);
      case "reading_variety":
        return /\b(?:standalone novels?|series|reading list|variety|avoid fatigue|balance suggestions?)\b/.test(normalized) &&
          /\b(?:books?|novels?|series|reading)\b/.test(normalized);
      case "reading_goals_summary":
        return /\b(?:kingkiller chronicle|mistborn trilogy|broken empire|stormlight archive|staying on track|audiobooks?|evening listening|daily goals?|cozy reading environment|expanse|1,?500 pages|march\s+15|75 pages|nightingale|kristin hannah|print and audiobook|book budget|fiction books|montserrat books)\b/.test(normalized);
      case "writing_process_structure":
        return /\b(?:daily and weekly targets?|daily and weekly word count goals?|word count goals?|fixed writing times?|fixed writing schedule|flexible writing sessions?|flexible writing times?|outline|scene breakdown|visualiz(?:e|ing) success|reward(?:ing)? milestones?|accountability partner|stress management|mindfulness|relaxation|maintain focus|stay focused|stay motivated)\b/.test(normalized);
      case "writing_schedule":
        return /\b(?:writing sessions?|7-9\s*am|morning hours?|focused writing|most focused)\b/.test(normalized);
      case "daily_routine":
        return /\b(?:structured daily routine|daily routine|wake-up|sleep times?|7\s*am|9\s*pm|consistent timing|regularity|stay organized|stay on track)\b/.test(normalized);
      case "portfolio_links":
        return /\b(?:portfolio links?|clickable links?|letter body|attachments?|separate documents?|inline link)\b/.test(normalized);
      case "deployment_automation":
        return /\b(?:automated|ci\/cd|pipeline|deployment workflow|status dashboards?|monitoring tools?|manual deployment checks?)\b/.test(normalized);
      case "lightweight_tools":
        return /\b(?:lightweight|minimal dependencies|simple|easy to maintain|large frameworks|heavy dependencies|avoid|bootstrap|foundation|lazysizes|vanilla js)\b/.test(normalized) &&
          /\b(?:libraries?|tools?|dependencies|frameworks?|flask|app|features?|bootstrap|portfolio|gallery)\b/.test(normalized);
      case "progress":
        return /\b(?:progress|completion|improvements?|editing|edits?)\b/.test(normalized) &&
          hasPercentCue(normalized);
      case "health":
        return /\b(?:sneakers?|shoes?|footwear)\b/.test(normalized) &&
          /\b(?:comfort|cushioning|arch support|grip soles?|injury|physical|well-being|support)\b/.test(normalized);
      case "nutrition_hydration":
        return /\b(?:hydration|hydrated|water intake|drinking fluids|drink water|fluids?)\b/.test(normalized) &&
          /\b(?:nutrition|diet|meal|food|healthy|workouts?|fitness)\b/.test(normalized);
      case "heart_function_activity_management":
        return /\b(?:ejection fraction|\bef\b|heart(?:'s)? pumping|pumping efficiency|heart function|cardiac efficiency)\b/.test(normalized) &&
          /\b(?:physical activit(?:y|ies)|strenuous|fatigue|shortness of breath|climbing stairs|gradual increase|symptom monitoring|regular follow-?ups?|cardiologist|lifestyle modifications?|avoid smoking|quit smoking|limit alcohol|excessive alcohol|medication adherence|stress management)\b/.test(normalized);
      case "sleep_improvement_percent":
        return /\bsleep efficiency\b/.test(normalized) &&
          (hasPercentCue(normalized) ||
            /\b(?:exact percentages?|percentage increase|precise numerical|improved from|increased by)\b/.test(normalized));
      case "sleep_environment_habits_summary":
        return /\b(?:blackout curtains?|blackout blinds?|window films?|reflective films?|room[- ]darkening shades?|thermostat|2200k|night sweats?|circadian|meditation|sleep environment|sleep quality)\b/.test(normalized) &&
          /\b(?:sleep|bedroom|dark|darkening|temperature|night sweats?|circadian|meditation)\b/.test(normalized);
      case "mattress_warranty_details":
        return /\b(?:mattress|sleepwell deluxe)\b/.test(normalized) &&
          /\b(?:warranty|coverage|defects?|repairs?|replacements?|trial period|return policy|protect(?:ion)?|durability)\b/.test(normalized);
      case "sleep_wind_down_screen_free":
        return /\b(?:before bed|bedtime|wind down|unwind|screen time|screens?|screen-based|physical books?|screen-free|no-screen|blue light)\b/.test(normalized) &&
          /\b(?:avoid|reading|physical books?|meditat(?:e|ing|ion)|relax|unwind|routine|screen)\b/.test(normalized);
      case "april_relationship_timing":
        return /\b(?:april|partner)\b/.test(normalized) &&
          /\b(?:morning|early|weekend|conversation|activities|activity|most alert|energy levels?|late evenings?|tired|calm mornings?)\b/.test(normalized);
      case "april_relationship_summary":
        return /\bapril\b/.test(normalized) &&
          /\b(?:relationship|date nights?|surprises?|shared hobbies?|special outings?|flower|deliveries|gestures?|traditions?|community center|volunteering|check-ins?|physical touch|love language|emotional intimacy)\b/.test(normalized);
      case "work_life_balance_summary":
        return /\b(?:work-life balance|personal life|work hours|clinical hours|reduce|reduction|50 to 40|50 to 45|boundaries|work emails|delegate|streamline|supervisor|monitoring progress)\b/.test(normalized);
      case "turkish_pronunciation_quantitative":
        return /\b(?:pronunciation|speaking speed|words per minute|wpm|pronunciation trainer|consonant clusters?|practice sessions?|drills?)\b/.test(normalized) &&
          /\b(?:40 sessions?|90%|98 words per minute|quantitative|session data|november\s+15|progress|accuracy)\b/.test(normalized);
      case "turkish_live_learning_formats":
        return /\b(?:turkish|language learning|learning formats?|classes?|lessons?)\b/.test(normalized) &&
          /\b(?:interactive live|live classes?|synchronous|immediate feedback|italki|preply|verbling|cambly|pre-recorded|recorded materials?)\b/.test(normalized);
      case "study_space_tools_count":
        return /\b(?:study space|study room|noise-cancelling headphones?|timer|second monitor|turkish cultural artifacts?|turkish flag|cultural calendar|calendar countdown|decorations?|study tools?)\b/.test(normalized);
      case "home_family_repayment":
        return /\b(?:crystal|mom|mother|family|down payment|repayment|repay|loan|promissory note|financial assistance|50,000\s*try|900\s*try|june\s+1|5 years?|60 months?)\b/.test(normalized);
      case "home_repair_cost_update":
        return /\b(?:plumbing leaks?|minor plumbing|repair costs?|cost estimate|7,500\s*try|april\s+22|second opinion|professional opinion|plumber)\b/.test(normalized);
      case "home_condition_final_inspection":
        return /\b(?:final home inspection|final inspection|may\s+5|repairs? completed|no further issues|repair completion|written confirmation|photos?|re-?inspection|seller'?s contractor)\b/.test(normalized);
      case "home_neighborhood_tour":
        return /\b(?:neighborhood tour|samantha|april\s+13|11\s*am|mevlana apartment complex|local amenities|parks?|green spaces?)\b/.test(normalized);
      case "home_neighborhood_preferences":
        return /\b(?:quiet(?:er|ness)?|parks?|green spaces?|atat(?:ü|u)rk park|mevlana|local amenities|neighborhood|shopping|nightlife|commute|safety)\b/.test(normalized);
      case "home_stove_recommendations":
        return /\b(?:stove|kitchen appliance|energy-efficient|energy efficient|bosch|siemens|arcelik|arçelik|comparable price|price range|utility savings)\b/.test(normalized);
      case "home_apartment_cost_difference":
        return /\b(?:2-bedroom|two-bedroom|3-bedroom|three-bedroom|mevlana|inonu|inönü|580,000\s*try|620,000\s*try|40,000\s*try|41,200\s*try|cost difference)\b/.test(normalized);
      case "home_cash_flow_summary":
        return /\b(?:cash flow|monthly income|monthly expenses|7,083|7,500|416\.?67|417\s*try|shortfall|negative cash flow|reduce expenses|increase income|crystal repayment)\b/.test(normalized);
      case "home_buying_financial_steps":
        return /\b(?:financial steps|saving|savings plan|mortgage estimates?|down payment|interest|term|taxes|insurance|upfront|ongoing commitments|closing costs|monthly costs)\b/.test(normalized);
      case "home_buying_summary":
        return /\b(?:home buying|mevlana|atat(?:ü|u)rk park|andrew|crystal|repayment plan|budgeting|repairs?|moving logistics|title insurance|closing)\b/.test(normalized);
      case "home_mortgage_choice_summary":
        return /\b(?:fixed-rate|fixed rate|variable-rate|variable rate|lower starting rate|risk tolerance|loan term|caps|rising rates|hybrid arms?|refinancing|predictability)\b/.test(normalized);
      case "home_inspection_timing":
        return /\b(?:home inspection|inspection report|april\s+15|april\s+18|april\s+20|lawyer|contract review|two days|five days)\b/.test(normalized);
      case "selling_photo_service_steps":
        return /\b(?:focuslens|professional photography|photos?|photo shoot|high-resolution|high resolution|optimiz(?:e|ing) lighting|arranging furniture|delivered photos|web use)\b/.test(normalized) &&
          /\b(?:prepare|confirm|communicate|expectations?|desired shots?|review|select|optimiz(?:e|ing)|session|shoot|staging|decluttering)\b/.test(normalized);
      case "selling_financial_plan_detail":
        return /\b(?:itemized|category-by-category|cost analysis|detailed breakdown|closing costs?|commission|repairs?|staging|photography|moving expenses?|net profit|net proceeds)\b/.test(normalized) &&
          /\b(?:finances?|financial|costs?|planning|sale|home)\b/.test(normalized);
      case "selling_rental_payment_terms":
        return /\b(?:lease|rental agreement|rent reduction|temporary reduction|payment plan|payment amounts?|payment modifications?|signed addendum|full rent resuming|4,275\s*try|4,500\s*try)\b/.test(normalized);
      case "selling_rental_price":
        return /\b(?:kadikoy|kadıköy|rental price|rent price|asking price|market feedback|4,550\s*try|4550|4,500\s*try|4500)\b/.test(normalized) &&
          /\b(?:rent|rental|price|apartment|market feedback|adjusted)\b/.test(normalized);
      case "selling_service_total_cost":
        return /\b(?:professional staging|elegant spaces|focuslens|professional photography|staging|photography)\b/.test(normalized) &&
          /\b(?:\$1,550|1550|\$1,200|1200|\$350|350|cost|total)\b/.test(normalized);
      case "selling_sequence_repairs_marketing":
        return /\b(?:decluttering|staging|repairs?|roof leak|final inspection|photography|marketing materials?|listing|selim|pricing strategy|buyer'?s inspection|closing|moving schedule)\b/.test(normalized) &&
          /\b(?:sequence|timeline|before|after|schedule|finalize|coordinate|prepare|complete|list by april)\b/.test(normalized);
      case "selling_professional_staging_preference":
        return /\b(?:professional staging|staging experts?|experts|diy|upfront cost|staging quality|attractive to buyers|appeal to buyers|higher sale price|faster sale)\b/.test(normalized);
      case "selling_morning_appointments":
        return /\b(?:morning appointments?|early morning|early appointments?|time slots?|start early|schedule appointments?|maximize productivity|reduce stress)\b/.test(normalized);
      case "selling_home_summary":
        return /\b(?:selim|cma|comparative market analysis|elegant spaces|roof leak|focuslens|matterport|countered|415,000|final contract|home selling|sale process|commission|contract signing)\b/.test(normalized);
      case "selling_stress_summary":
        return /\b(?:mindfulness|meditation|headspace|calm|mindful walking|breathing exercises?|yoga|progressive muscle|journaling|exercise|support networks?|stress)\b/.test(normalized) &&
          /\b(?:home selling|moving|sale|stress|calming|financial|neighborhood|consistent practice)\b/.test(normalized);
      case "selling_roof_offer_timing":
        return /\b(?:march\s+28|april\s+3|april\s+20|roof repair|roof leak|first offer|6 days|six days|17 days|seventeen days)\b/.test(normalized);
      case "diy_living_together_duration":
        return /\b(?:james|jamie|3-bedroom|three-bedroom|atat(?:ü|u)rk street|5 years?|five years?|lived together|living together)\b/.test(normalized);
      case "diy_paint_budget_breakdown":
        return /\b(?:bauhaus|cumhuriyet|paint|primer|brushes?|rollers?|paint trays?|painter'?s tape|drop cloths?|sandpaper|example calculation|medium-sized living room)\b/.test(normalized);
      case "diy_pipe_leak_safety":
        return /\b(?:leaking pipe|leaky pipe|water supply|shut off water|water shutoff|protective gear|gloves?|goggles?|masks?|avoid hazards?|prevent injury|damage|washers?|o-rings?|plumbing workshop)\b/.test(normalized);
      case "diy_drill_model_specificity":
        return /\b(?:bosch\s+gsr\s+12v-15|12v cordless drill|exact model|model number|specific product|tool version|cordless drill)\b/.test(normalized);
      case "diy_paint_supply_spend":
        return /\b(?:\$335|335\b|paint and supplies|paint supplies|total spent|spending increased|remaining budget)\b/.test(normalized);
      case "diy_professional_savings":
        return /\b(?:saved?|savings?|hiring painter|hiring professionals?|plumber|faucet replacement|\$350|350\b|\$220|220\b|diy cost)\b/.test(normalized);
      case "diy_resource_sequence":
        return /\b(?:essential tools?|hand tools?|power tools?|bulk purchases?|don'?s 3-meter ladder|3-meter ladder|heavy items?|safety-critical|upcoming projects?|allocate budget)\b/.test(normalized);
      case "diy_visual_learning_preference":
        return /\b(?:video tutorials?|hands-on learning|visual resources?|interactive|manuals?|home repairs?|prefer)\b/.test(normalized);
      case "diy_kitchen_surface_preference":
        return /\b(?:kitchen surfaces?|countertops?|durability|easy to clean|ease of cleaning|lasting quality|trendy|aesthetic)\b/.test(normalized);
      case "diy_insulation_summary":
        return /\b(?:attic insulation|owens corning|fiberglass|june\s+15|june\s+22|\$600|600\b|\$450|450\b|respirator|gloves?|safety glasses?|weatherstripping|caulk|ventilation)\b/.test(normalized);
      case "diy_shelf_summary":
        return /\b(?:bathroom shelf|shelf installation|august\s+15|\$100|100\b|mounting brackets?|wall anchors?|pilot holes?|moisture-resistant|level|drill|don)\b/.test(normalized);
      case "diy_painting_timing":
        return /\b(?:april\s+1|april\s+13|april\s+14|12 days|twelve days|dove gray|two coats|painting living room)\b/.test(normalized);
      case "diy_faucet_timing":
        return /\b(?:april\s+10|april\s+29|19 days|nineteen days|faucet washers?|plumbing basics workshop|practice replacing)\b/.test(normalized);
      case "cooking_weekly_cuisine_plan":
        return /\b(?:one cuisine every 6 weeks|6-week blocks?|6 weeks?|week\s*1-2|week\s*3-4|weekly cooking sessions?|focus on one cuisine|cultural context|regional variations|multiple cuisines|french cuisine|japanese cuisine|indian cuisine|mexican cuisine)\b/.test(normalized) &&
          /\b(?:cuisine|cuisines|cooking|weekly|week|culture|cultural|techniques?|ingredients?)\b/.test(normalized);
      case "cooking_dolma_leaf_preparation":
        return /\b(?:stuffed grape leaves?|dolma|grape leaves?|rice mixture|pine nuts|fresh herbs|roll up tightly|seam-side down|45-60 minutes|olive oil|stems?|remove stems?|rinse|rinsing)\b/.test(normalized) &&
          /\b(?:leaves?|filling|seasoning|flavor|texture|tender|simmer|roll|stem|salt|herbs)\b/.test(normalized);
      case "cooking_culinary_journey_summary":
        return /\b(?:turkish|greek|lebanese|month-by-month|month by month|structured plan|knife techniques|julienne|chiffonade|deadlines?|manageable steps|time-efficient|journals?|photos?|community engagement|kneading|elasticity|baked goods|sauce emulsification|italian|indian|spice blend|menu planning|global dishes)\b/.test(normalized) &&
          /\b(?:cooking|culinary|cuisines?|dishes?|skills?|recipes?|plan|practice|progress|techniques?)\b/.test(normalized);
      case "outdoor_cardio_preference":
        return /\b(?:trail running|fresh air|varied terrain|outdoor cardio|natural settings?|treadmill|indoor-only|indoor only)\b/.test(normalized) &&
          /\b(?:prefer|avoid|suggest|recommend|cardio|running|activities?|options?|treadmill)\b/.test(normalized);
      case "social_norms":
        return /\b(?:social norms?|cultural context|cultural differences|multiple regions|traditions|expectations)\b/.test(normalized);
      case "software_versions":
        return /\b(?:software version|version details|version numbers?|release identifiers?|digital asset management|digital assets?|software names?|technolog(?:y|ies)|tech stack|technology stacks?|current setup|versions? listed alongside technologies)\b/.test(normalized);
      case "uk_resume":
        return /\b(?:uk|ats|resume|cv)\b/.test(normalized) &&
          /\b(?:format|formatting|generic|template|global|tailor|specific)\b/.test(normalized);
      case "decision_framework":
        return /\b(?:logical reasoning|frameworks?|emotional impulses?|practical nature|decision-making|compensation package|equity|adjust.*budget|budget.*accordingly|support network|startup experience)\b/.test(normalized);
      case "realtime_chat_summary":
        return /\b(?:real-time|realtime|chat|socket\.?io|websocket|node\.?js|express|message|messaging|chatroom|rooms?|redis|latency|ping-pong|presence|broadcast|load balancer|message queue|mongoose|mongodb|indexing|pagination|ttl|acl|circuit breaker|fallback|retry|backoff|typing indicators?|map|set|error handling|helper functions?|user tracking|logging|observability|recent messages?|schema validation|updatemessage|unchanged message|migration script|batch execution|asynchronous control)\b/.test(normalized);
      case "technical_project_summary":
        return /\b(?:resume analyzer|python\s*3\.10|spacy|flask|pymupdf|pdf parsing|work experience|keyword searches?|sentence segmentation|named entity recognition|ner|job titles?|educational institutions?|modulariz|error handling|nonetype|logging|traceability|february\s+15|cprofile|bottlenecks?|in-memory cache|redis-backed|regex|precompil|stopword|lemmatization|lazy-loading|custom ner|dataset size|weighted scoring|skill matching|experience levels?|visualization|authentication|authorization|concurrent requests?|object detection|tracking pipeline|yolov5|opencv|sort|kalman filter|hungarian algorithm|data association|tensorrt|opencv dnn|deepsort|ssd mobilenet|future-proofing|scalability|modular refactor|recommendation system|recommender|collaborative filtering|content-based filtering|tf-?idf|cosine similarity|similarity matrices?|user ratings?|missing ratings?|normaliz(?:e|ing|ation)|sparse matrices?|\/recommendations|helper functions?|get_user_ratings|get_top_rated_items|hybrid recommendation|hybrid scoring|weighted average|tunable weights?|user preferences?|precision@?5|recall@?5|f1-score|auc-roc|restaurant_features|feature_vector|jsonb|google translate api v3|deepl api v2|translation api|translation service|language detection|franc|undefined returns?|input validation|preprocessing|rate limiting|invalid inputs?|quota exceed(?:ed|ance)|redis caching|ttl policies?|asynchronous processing|parallel request handling|redis hashes?|cache-manager|restful apis?|fallback original text|contextual memory storage|gpt-4 chatbot|transformer-based llm|streaming|chunk size|tls|role-based access control|image captioning|caption generator|feature extractor|diffusion-based|stable diffusion|docker compose|inter-service communication|materialized views?|postgresql|gpu acceleration|api response time profiling|cuda|out-of-memory|batch sizes?|mixed precision|gradient accumulation|optimizer initialization|lru caches?|resource management)\b/.test(normalized);
      case "conic_sections_summary":
        return /\b(?:conic sections?|parabolas?|ellipses?|hyperbolas?|vertex form|directrix|foci|focus|eccentricity|tangent lines?|normal lines?|reflective property|completing the square|implicit differentiation|geometric definition|standard equation|canonical form|asymptotes?|physics|engineering|satellite dishes?|parabolic mirrors?)\b/.test(normalized);
      case "calculus_derivative_progression":
        return /\b(?:implicit differentiation|circle equation|quadratic|cubic|product term|linear terms?|quadratic terms?|simple ratio|algebraic complexity|derivatives?)\b/.test(normalized) &&
          /\b(?:derivative|fraction|ratio|complexity|implicit|equation|term|terms)\b/.test(normalized);
      case "calculus_derivative_walkthrough":
        return /\b(?:product rule|chain rule|differentiat(?:e|ion)|derivative|composite functions?|step-by-step|step by step|example calculations?)\b/.test(normalized) &&
          /\b(?:walk|steps?|break(?:s|ing)? down|explain(?:s|ing)?|appl(?:y|ies|ying)|context|calculate|calculations?|example)\b/.test(normalized);
      case "euler_step_accuracy":
        return /\beuler(?:'s)?(?:\s+method)?\b/.test(normalized) &&
          /(?:\b(?:step size|h\s*=|accuracy|accurate|error|errors?|differential equations?)\b|12%|1\.2%|8%|3%)/.test(
            normalized,
          );
      case "population_parameter_estimation":
        return /\b(?:exponential growth|logistic growth|population growth|population trends?|growth model|dp\/dt|differential equation)\b/.test(normalized) &&
          /\b(?:parameter|estimate|estimation|sample data points?|data points?|datasets?|expanded data|optimization|carrying capacity|growth rate|k\s*=|r\s*=|predict)\b/.test(
            normalized,
          );
      case "variance_concrete_examples":
        return /\b(?:variance|random variable|expectation|expected value|probabilit(?:y|ies))\b/.test(normalized) &&
          /\b(?:dice rolls?|die rolls?|outcomes?|specific numerical|concrete numbers?|concrete numerical|step-by-step|values?|purely symbolic|abstract explanations?)\b/.test(
            normalized,
          );
      case "spherical_geodesic_vector_methods":
        return /\b(?:sphere|spherical|great circle|geodesic|unit vectors?|dot product|vector algebra|geometric vectors?)\b/.test(normalized) &&
          /\b(?:shortest path|distance|between two points|vector|vectors?|trigonometric|formula reliance|calculation steps?)\b/.test(
            normalized,
          );
      case "skill_course_completion":
        return /\b(?:completed?|finished|course completion|training|programs?|final score|digital networking course|advanced research writing course|skills? gained)\b/.test(normalized) &&
          /\b(?:course|training|programs?|skills?|score|completed?|finished)\b/.test(
            normalized,
          );
      case "morning_coffee_meeting":
        return /\b(?:morning meetings?|early-day|early day|9:00\s*am|coffee meeting|dr\.?\s+kaya)\b/.test(normalized) &&
          /\b(?:coffee|meeting|prepare|preparation|tips?|conversation starters?|timing)\b/.test(
            normalized,
          );
      case "telepsychology_expansion_summary":
        return /\b(?:telepsychology|telehealth|client comfort|market demand|competitor landscape|legal and privacy|privacy requirements|secure telehealth|training staff|professional networks?|referral engagement|trauma therapy journal|webinar software|research collaborations?|client intake|co-authorships?|speaking engagements?|editorial board|work-life balance|post-collaboration)\b/.test(normalized);
      case "professional_event_project_summary":
        return /\b(?:pre-event preparation|reviewing agendas|researching speakers|technical readiness|testing equipment|virtual platforms?|venue logistics|active engagement|networking proactively|scheduled breaks|post-event follow-up|thank-you messages?|professional networks?|ongoing communication|time blocking|pomodoro|strategic partnerships?|co-hosting|joint marketing|continuous reflection|event logistics)\b/.test(normalized);
      case "job_commute_preference":
        return /\b(?:north ericshire|30\s*km|commut(?:e|ing)|45 minutes?|work-life balance|proximity|travel duration)\b/.test(normalized) &&
          /\b(?:jobs?|roles?|job search|listings?|senior role|commut(?:e|ing)|work-life balance)\b/.test(
            normalized,
          );
      case "sarah_resume_revision_planning":
        return /\bsarah\b/.test(normalized) &&
          /\b(?:conference|resume|professional documents?|cover letters?|march\s+15|meetings?|materials?|update process|mock interview)\b/.test(
            normalized,
          );
      case "rental_income_preference":
        return /\b(?:steady rental income|rental income|monthly returns?|long-term wealth|wealth accumulation|wealth accumulations|short-term sales profits?|quick resale|vacancy|tenant turnover|appreciation|cash flow)\b/.test(normalized);
      case "rental_property_journey_summary":
        return /\b(?:rental properties?|initial capital|\$50,?000|local market|down payment|closing fees?|fixer-upper|structural issues?|outdated features?|single-family|multi-family|rental yield|management complexity|halkbank|ziraat bank|mortgages?|tenant management|property choices?)\b/.test(normalized);
      case "cryptocurrency_investment_summary":
        return /\b(?:cryptocurrency|crypto|bitcoin|ethereum|binance|coingecko|tradingview|hardware wallet|phishing|defi|staking|cardano|ada|nft|tax compliance|capital gains|financial analyst|accurate and timely filings|community engagement|yield farming|strategic portfolio adjustments|advanced learning paths)\b/.test(normalized);
      case "math_induction_summary":
        return /\b(?:mathematical induction|proof by induction|induction proofs?|inductive step|inductive hypothesis|base case|sum of first n|divisibility proofs?|number theory|inequalit(?:y|ies)|modular arithmetic|step-by-step verification|practice problems?|paramedic|real-world applications?|practical scenarios?|study habits?|tracking progress|quiz scores?)\b/.test(normalized);
      case "number_theory_congruence_examples":
        return /\b(?:congruences?|modular arithmetic|modulo|mod\b|fermat'?s little theorem|euler'?s theorem|linear congruence|number theory)\b/.test(normalized) &&
          /\b(?:example|examples|actual numbers?|step-by-step|step by step|calculations?|theorems?|properties|remainder|17\s+mod\s+5|3\^16|5\^12|7\^20)\b/.test(
            normalized,
          );
      case "math_step_calculations":
        return /\b(?:distance formula|distance between|coordinate geometry|coordinate plane|point-line distance|midpoint formula)\b/.test(normalized) &&
          /\b(?:step-by-step|step by step|calculate|calculation|calculations|arithmetic|substitut(?:e|ing)|differences?|square|squared|simplify|formula)\b/.test(normalized);
      case "mixed_problem_practice":
        return /\b(?:mixed problem sets?|different problem types?|varied problem sets?|multiple topics?|combine|combining|mixing up|variety|randomization|line equations|circles|ellipses|intersections|proofs)\b/.test(normalized) &&
          /\b(?:practice|study sessions?|exam|problems?|topics?|sessions?)\b/.test(normalized);
      case "event_budget_details":
        return (
          /\b(?:event|events|party|parties|gathering|gatherings|reunion|picnic|holiday|hosting|family commitments?|family planning)\b/.test(normalized) &&
          /\b(?:budget|costs?|financial|spending|expenses?|increase|freelance offer|\$\s*\d|dollars?)\b/.test(normalized)
        ) || (
          /\$\s*\d/.test(content) &&
          /\b(?:budget|costs?|financial|spending|expenses?|increase|offer)\b/.test(normalized)
        );
      case "travel_cost_details":
        return /\b(?:cost details?|itemized costs?|dollar amounts?|category-by-category|breakdown|travel arrangements?|transportation|accommodation|meals|activities|vacation budget|travel options?)\b/.test(normalized);
      case "investment_withdrawal_tax":
        return /\b(?:withdraw|withdrawal|take money out|cash out|sell(?:ing)?|tax implications?|taxes owed|penalties|capital gains|taxable distribution|investment account|brokerage|portfolio)\b/.test(normalized) &&
          /\b(?:tax|taxes|penalt(?:y|ies)|withdraw|withdrawal|investment|brokerage|portfolio|account)\b/.test(normalized);
      case "scott_support_summary":
        return /\b(?:scott|tutoring sessions?|twice weekly|ms\.?\s+harper|math scores?|study sessions?|organized workspace|free from distractions|distraction-free|study environment|growth mindset|stem camp|extracurricular|routine establishment|time management|social encouragement|role-?playing|self-expression|independence|responsibility|digital safety|parental controls?|online risks?|privacy|screen time|daily routines?|creative pursuits?|healthy habits?|emotional well-being|coping mechanisms?|open communication|positive reinforcement|milestones?|clear expectations?|consistent feedback)\b/.test(normalized);
      case "portfolio_management_summary":
        return /\b(?:investment strategy|portfolio management|portfolio allocation|rebalancing|threshold-based|quarterly reviews?|semi-annual reviews?|vanguard|alerts?|kendra|financial advisor|bond laddering|interest rate risk|income stability|treasur(?:y|ies)|municipal|corporate bonds?|green bonds?|sustainable investments?|international stock|sector-specific|tech stocks?|biotech etfs?|tax implications?|transaction costs?|volatility limits?|investment anxiety|professional support|trusted partner|jeremy|financial decision-making)\b/.test(normalized);
      case "parent_nutrition_summary":
        return /\b(?:samantha|mom|mother|ryan|dad|father|89-year-old|89 years old|105-year-old|105|meal plans?|meal ideas?|specific recipes?|balanced options?|hydration|medication interactions?|caregivers?|care center|nutritional needs?|bone broth|plant-based protein|protein powder|smoothies?|family-supported|caregiving)\b/.test(normalized);
      case "evening_tea_options":
        return /\b(?:herbal teas?|chamomile|peppermint|caffeinated|caffeine|sleep quality|relaxation|bedtime|evening)\b/.test(normalized);
      case "relationship_trust_summary":
        return /\b(?:rachael|rebuilding trust|trust issues?|acknowledg(?:e|ing) mistakes?|taking responsibility|communicat(?:e|ing) openly|honestly|initial apology|weekly check-ins?|dialogue examples?|transparency|empathy|accountability course|active listening|patience|follow-through|commitments?|trusted friends?|professional relationships?|personal goals?|shared experiences?|emotional connection|coastal walks?|milestones?|forgotten anniversar(?:y|ies)|feedback|long-term relationship)\b/.test(normalized);
      case "answerability_absence":
        return countGuidanceTermOverlap(normalized, query) >= 2 ||
          /\b(?:confus(?:e|ed|ing|ion)|mutually exclusive|independent events?|dice rolls?|feedback|quizzes?|podiatrist|qualification|expertise|article)\b/.test(normalized);
    }
  });
}

function scoreGuidanceEvidence(
  item: EvidencePackItem,
  query: string,
  intents: readonly GuidanceIntent[],
): number {
  const normalized = item.content.toLowerCase();
  let score = 0;
  if (item.role === "user") score += 7;
  if (hasInstructionOrPreferenceCue(normalized)) score += 16;
  if (hasPercentCue(normalized)) score += 10;
  if (/\b(?:always|prefer|preference|avoid|use|include|format|mention|should)\b/.test(normalized)) {
    score += 6;
  }
  for (const intent of intents) {
    if (hasSpecificIntentCue(normalized, intent)) score += 8;
  }
  if (intents.includes("api_errors") && /\b(?:status codes?|response codes?|400|401|403|404|429|500)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("api_concurrency")) {
    score += 8;
    if (/\b(?:asyncio|aiohttp|httpx|async\/await|async libraries?|asynchronous(?: python)? libraries?|frameworks?)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:concurr(?:ent|ency|ently)|non-blocking|reduce blocking|multiple api requests?|multiple requests?|batch(?:ing)?|gather)\b/.test(normalized)) {
      score += 10;
    }
  }
  if (intents.includes("ai_hiring_fairness")) {
    score += 10;
    if (/\b(?:pilot program|test the ai tool|effectiveness|time savings|candidate satisfaction)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:human oversight|final decisions?|human review|hybrid approach)\b/.test(normalized)) {
      score += 16;
    }
    if (/\b(?:anonymization|anonymize|personal identifiers?|names|dates of birth|addresses)\b/.test(normalized)) {
      score += 24;
    }
    if (/\b(?:bias audits?|third-party audits?|regular audits?|fairness metrics?|transparent|transparency)\b/.test(normalized)) {
      score += 16;
    }
    if (/\b(?:diversity metrics?|feedback|structured interviews?|soft skills|ai screening|job-relevant criteria)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("audiobook_narrators") && /\b(?:narrator|narrated by|read by|who read)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("contradiction_resolution") && /\b(?:never|ever|said|mentioned|also|contradictory|conflicting|statement|correct|spent|read(?:ing)?|articles?|protective masks?|respirator masks?|masks?|gloves?|insulation|ergonomic supports?|kneeling pads?|cushioned kneeling pad)\b/.test(normalized)) {
    score += 12;
  }
  if (intents.includes("contradiction_resolution") && /\b(?:completed|solved|scored|score|practice problems?)\b/.test(normalized)) {
    score += 8;
  }
  if (intents.includes("editing") && /\b(?:ai tools?|ai-assisted|initial edits?|tone calibration|grammarly|hemingway|peer review)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("media_platforms") && /\b(?:streaming services?|platform names?|availability|netflix|hulu|disney|prime)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("allergy_check") && /\ballerg(?:y|ies)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("philosophy_summary") && /\b(?:category-by-category|detailed summar(?:y|ies)|philosophical concepts?)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("reading_variety") && /\b(?:standalone|series|variety|balance)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("reading_goals_summary")) {
    score += 10;
    if (/\b(?:kingkiller chronicle|mistborn trilogy|broken empire|schedule|prioritiz(?:e|ing))\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:stormlight archive|1,?200 pages|december\s+1|staying on track|audiobooks?|evening listening|cozy reading environment|daily goals?)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:expanse|1,?500 pages|march\s+15|75 pages|nightingale|kristin hannah|diversify)\b/.test(normalized)) {
      score += 18;
    }
    if (/\b(?:print and audiobook|budget|fiction books|montserrat books|formats?)\b/.test(normalized)) {
      score += 10;
    }
  }
  if (intents.includes("writing_process_structure")) {
    score += 10;
    if (/\b(?:daily and weekly targets?|daily and weekly word count goals?|word count goals?|overall target|weekly milestones?)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:fixed writing times?|fixed writing schedule|flexible writing sessions?|flexible writing times?)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:outline|scene breakdown|organization|roadmap)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:visualiz(?:e|ing) success|reward(?:ing)? milestones?|accountability partner|stress management|mindfulness|relaxation|maintain focus|stay motivated)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("writing_schedule") && /\b(?:7-9\s*am|morning hours?|most focused|writing sessions?)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("daily_routine") && /\b(?:structured daily routine|daily routine|wake-up|sleep times?|7\s*am|9\s*pm|consistent timing|regularity)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("portfolio_links") && /\b(?:clickable links?|letter body|attachments?|separate documents?)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("deployment_automation") && /\b(?:automated|ci\/cd|pipeline|monitoring tools?|status dashboards?|manual deployment checks?)\b/.test(normalized)) {
    score += 10;
  }
  if (intents.includes("decor_recommendations")) {
    score += 8;
    if (/\b(?:built-in|built in|storage|ottomans?|modular|multifunctional|multi-functional)\b/.test(normalized)) {
      score += 16;
    }
    if (/\b(?:aesthetic|practical|features?|decor|furniture|living space)\b/.test(normalized)) {
      score += 12;
    }
  }
  if (intents.includes("project_financial_limits")) {
    score += 8;
    if (/\b(?:itemized|category-by-category|breakdown|cost analysis|detailed cost analysis)\b/.test(normalized)) {
      score += 18;
    }
    if (/\$\s*\d|\b(?:specific dollar amounts?|budget amounts?|cost categories)\b/.test(item.content)) {
      score += 16;
    }
  }
  if (intents.includes("team_event_attendance")) {
    score += 10;
    if (/\b(?:always|instruction|prefer)\b.*\b(?:attendance numbers?|player attendance|team events?)\b|\b(?:attendance numbers?|player attendance|team events?)\b.*\b(?:always|instruction|prefer)\b/.test(normalized)) {
      score += 24;
    }
    if (/\battendance:\s*\d+\s+players?\s+out of\s+\d+\b|\b\d+\s+players?\s+out of\s+\d+\b/.test(normalized)) {
      score += 28;
    }
    if (/\b(?:team events?|practice session|team practice|scrimmage)\b/.test(normalized)) {
      score += 10;
    }
  }
  if (intents.includes("nutrition_hydration")) {
    score += 8;
    if (/\b(?:always|include|nutrition advice)\b.*\b(?:hydration|water|fluids?)\b|\b(?:hydration|water|fluids?)\b.*\b(?:always|include|nutrition advice)\b/.test(normalized)) {
      score += 28;
    }
    if (/\b(?:hydration tips?|drinking fluids?|water intake|properly hydrated|drink water|fluid intake)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("heart_function_activity_management")) {
    score += 10;
    if (/\b(?:ejection fraction|\bef\b|heart(?:'s)? pumping|pumping efficiency|heart function)\b/.test(normalized)) {
      score += 18;
    }
    if (/\b(?:fatigue|shortness of breath|climbing stairs|strenuous physical activities?)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:gradual increase|monitor symptoms?|symptom monitoring|regular follow-?ups?|cardiologist)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:avoid smoking|quit smoking|limit alcohol|excessive alcohol|smoking|alcohol)\b/.test(normalized)) {
      score += 18;
    }
  }
  if (intents.includes("sleep_improvement_percent")) {
    score += 10;
    if (/\b(?:exact percentages?|percentage increase|precise numerical improvement)\b/.test(normalized)) {
      score += 24;
    }
    if (/\b(?:70%|78%|82%|85%|11\.43%|8\.97%|17\.14%|12%)/.test(normalized)) {
      score += 20;
    }
  }
  if (intents.includes("sleep_environment_habits_summary")) {
    score += 10;
    if (/\b(?:blackout curtains?|blackout blinds?|window films?|reflective films?|room[- ]darkening shades?|affordable|diy)\b/.test(normalized)) {
      score += 20;
    }
    if (/\b(?:thermostat|2200k|night sweats?|circadian|meditation)\b/.test(normalized)) {
      score += 18;
    }
  }
  if (intents.includes("mattress_warranty_details")) {
    score += 10;
    if (/\b(?:5-year warranty|warranty extension|extended warranty|coverage)\b/.test(normalized)) {
      score += 28;
    }
    if (/\b(?:defects?|repairs?|replacements?|trial period|return policy|durability)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("sleep_wind_down_screen_free")) {
    score += 10;
    if (/\b(?:physical books?|screen-free|no-screen|screen-based|avoid screens?|blue light)\b/.test(normalized)) {
      score += 28;
    }
    if (/\b(?:meditation|journaling|breathing|relaxation)\b/.test(normalized)) {
      score += 10;
    }
  }
  if (intents.includes("april_relationship_timing")) {
    score += 10;
    if (/\b(?:morning|early weekend|most alert|calm mornings?)\b/.test(normalized)) {
      score += 20;
    }
    if (/\b(?:energy levels?|late evenings?|tired)\b/.test(normalized)) {
      score += 18;
    }
  }
  if (intents.includes("april_relationship_summary")) {
    score += 10;
    if (/\b(?:special outings?|flower|deliveries|gestures?|traditions?)\b/.test(normalized)) {
      score += 22;
    }
    if (/\b(?:date nights?|surprises?|shared hobbies?|community center|volunteering|physical touch|love language)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("work_life_balance_summary")) {
    score += 10;
    if (/\b(?:50 to 40|50 to 45|work hours|clinical hours|july 2024|may 2024)\b/.test(normalized)) {
      score += 22;
    }
    if (/\b(?:monitoring progress|monitor progress|regularly|delegate|delegating|streamlin(?:e|ing)|supervisor|boundaries)\b/.test(normalized)) {
      score += 18;
    }
  }
  if (intents.includes("turkish_pronunciation_quantitative")) {
    score += 10;
    if (/\b(?:40 sessions?|90%|98 words per minute|words per minute|wpm|quantitative|session data)\b/.test(normalized)) {
      score += 24;
    }
    if (/\b(?:turkish pronunciation trainer|pronunciation drills?|consonant clusters?|speaking speed)\b/.test(normalized)) {
      score += 18;
    }
  }
  if (intents.includes("turkish_live_learning_formats")) {
    score += 10;
    if (/\b(?:interactive live|live classes?|synchronous classes?|immediate feedback)\b/.test(normalized)) {
      score += 24;
    }
    if (/\b(?:italki|preply|verbling|cambly|pre-recorded|recorded materials?)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("study_space_tools_count")) {
    score += 10;
    if (/\b(?:noise-cancelling headphones?|timer)\b/.test(normalized)) {
      score += 26;
    }
    if (/\b(?:second monitor|turkish cultural artifacts?|turkish flag|cultural calendar|calendar countdown)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("home_family_repayment")) {
    score += 10;
    if (/\b(?:50,000\s*try|5 years?|60 months?|900\s*try|june\s+1)\b/.test(normalized)) {
      score += 30;
    }
    if (/\b(?:crystal|mother|mom|repayment plan|promissory note|5% interest|formal agreement)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("home_repair_cost_update")) {
    score += 10;
    if (/\b(?:7,500\s*try|april\s+22|second opinion|professional opinion)\b/.test(normalized)) {
      score += 30;
    }
    if (/\b(?:plumbing leaks?|minor plumbing|plumber|repair costs?|lower estimate)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("home_condition_final_inspection")) {
    score += 10;
    if (/\b(?:may\s+5|final home inspection|final inspection|repairs? completed|no further issues)\b/.test(normalized)) {
      score += 32;
    }
    if (/\b(?:written confirmation|photos?|re-?inspection|seller'?s contractor|documentation|before closing|before finalize)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("home_neighborhood_tour")) {
    score += 10;
    if (/\b(?:april\s+13|11\s*am|samantha|neighborhood tour)\b/.test(normalized)) {
      score += 32;
    }
    if (/\b(?:mevlana apartment complex|local amenities|parks?|green spaces?|public transportation|shopping|safety)\b/.test(normalized)) {
      score += 12;
    }
  }
  if (intents.includes("home_neighborhood_preferences")) {
    score += 10;
    if (/\b(?:quiet(?:er|ness)?|parks?|green spaces?|atat(?:ü|u)rk park|mevlana)\b/.test(normalized)) {
      score += 26;
    }
    if (/\b(?:shopping|nightlife|local amenities|commute|safety|balanced|avoid overemphasizing)\b/.test(normalized)) {
      score += 12;
    }
  }
  if (intents.includes("home_stove_recommendations")) {
    score += 10;
    if (/\b(?:energy-efficient|energy efficient|bosch|siemens|arcelik|arçelik)\b/.test(normalized)) {
      score += 28;
    }
    if (/\b(?:stove|kitchen appliance|price range|comparable price|utility savings|quality)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("home_apartment_cost_difference")) {
    score += 10;
    if (/\b(?:580,000\s*try|620,000\s*try|40,000\s*try|41,200\s*try)\b/.test(normalized)) {
      score += 34;
    }
    if (/\b(?:2-bedroom|two-bedroom|3-bedroom|three-bedroom|mevlana|inonu|inönü|more expensive|difference)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("home_cash_flow_summary")) {
    score += 10;
    if (/\b(?:7,083|7,500|416\.?67|417\s*try|negative cash flow|shortfall)\b/.test(normalized)) {
      score += 34;
    }
    if (/\b(?:monthly income|monthly expenses|crystal repayment|reduce expenses|increase income|essential expenses)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("home_buying_financial_steps")) {
    score += 10;
    if (/\b(?:several years?|mortgage estimates?|loan|down payment|interest|term|taxes|insurance)\b/.test(normalized)) {
      score += 26;
    }
    if (/\b(?:upfront|ongoing commitments?|closing costs?|monthly costs?|financial steps|savings plan)\b/.test(normalized)) {
      score += 18;
    }
  }
  if (intents.includes("home_buying_summary")) {
    score += 10;
    if (/\b(?:atat(?:ü|u)rk park|andrew|mevlana|crystal|50,000\s*try|repayment plan)\b/.test(normalized)) {
      score += 28;
    }
    if (/\b(?:budgeting|reduce discretionary|increase income|repairs?|moving logistics|title insurance|closing)\b/.test(normalized)) {
      score += 18;
    }
  }
  if (intents.includes("home_mortgage_choice_summary")) {
    score += 10;
    if (/\b(?:fixed-rate|fixed rate|variable-rate|variable rate|lower starting rate|predictability|higher initial rate)\b/.test(normalized)) {
      score += 28;
    }
    if (/\b(?:current rates|economic outlook|risk tolerance|loan term|caps|rising rates|hybrid arms?|refinancing)\b/.test(normalized)) {
      score += 18;
    }
  }
  if (intents.includes("home_inspection_timing")) {
    score += 10;
    if (/\b(?:april\s+15|april\s+18|april\s+20|two days|5 days|five days)\b/.test(normalized)) {
      score += 32;
    }
    if (/\b(?:home inspection|inspection report|delivered|lawyer|contract review)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("selling_photo_service_steps")) {
    score += 10;
    if (/\b(?:focuslens|professional photography|\$350|30 high-resolution|30 high resolution|april\s+7|10\s*am)\b/.test(normalized)) {
      score += 30;
    }
    if (/\b(?:staging|decluttering|lighting|arranging furniture|cleaning fixtures|desired shots?|review delivered photos|web use)\b/.test(normalized)) {
      score += 18;
    }
  }
  if (intents.includes("selling_financial_plan_detail")) {
    score += 10;
    if (/\b(?:itemized|category-by-category|detailed cost analysis|cost breakdown)\b/.test(normalized)) {
      score += 30;
    }
    if (/\b(?:closing costs?|commission|repairs?|staging|photography|moving expenses?|net profit|net proceeds)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("selling_rental_payment_terms")) {
    score += 10;
    if (/\b(?:payment modifications?|temporary reduction|payment plan|signed addendum|4,275\s*try|4,500\s*try)\b/.test(normalized)) {
      score += 30;
    }
    if (/\b(?:lease|rental agreement|rent reduction|full rent resuming|terms)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("selling_rental_price")) {
    score += 10;
    if (/\b(?:4,550\s*try|4550|4,500\s*try|4500)\b/.test(normalized)) {
      score += 32;
    }
    if (/\b(?:kadikoy|kadıköy|rental price|market feedback|final agreed prices?)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("selling_service_total_cost")) {
    score += 10;
    if (/\b(?:\$1,550|1550)\b/.test(normalized)) {
      score += 34;
    }
    if (/\b(?:elegant spaces|\$1,200|1200|focuslens|\$350|350|professional staging|professional photography)\b/.test(normalized)) {
      score += 20;
    }
  }
  if (intents.includes("selling_sequence_repairs_marketing")) {
    score += 10;
    if (/\b(?:decluttering|staging|roof leak|photography|marketing materials?|selim|final inspection|buyer'?s inspection|moving schedule)\b/.test(normalized)) {
      score += 22;
    }
    if (/\b(?:before|after|sequence|timeline|schedule|finalize|coordinate|complete repairs?)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("selling_professional_staging_preference")) {
    score += 10;
    if (/\b(?:professional staging|hiring experts?|staging experts?|staging quality|upfront cost)\b/.test(normalized)) {
      score += 30;
    }
    if (/\b(?:diy|attractive to buyers|appeal to buyers|faster sale|higher price)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("selling_morning_appointments")) {
    score += 10;
    if (/\b(?:morning time slots?|early morning|early appointments?|start early)\b/.test(normalized)) {
      score += 30;
    }
    if (/\b(?:maximize productivity|reduce stress|schedule appointments?|next week)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("selling_home_summary")) {
    score += 10;
    if (/\b(?:selim|cma|elegant spaces|roof leak|focuslens|matterport|countered|415,000|final contract|contract signing)\b/.test(normalized)) {
      score += 18;
    }
    if (/\b(?:early spring|living room|backyard|oak tree|paperwork|legal|negotiations?|commission|400,000|financial considerations?)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("selling_stress_summary")) {
    score += 10;
    if (/\b(?:headspace|calm|mindful walking|mindfulness|meditation|breathing exercises?)\b/.test(normalized)) {
      score += 24;
    }
    if (/\b(?:yoga|progressive muscle|journaling|exercise|support networks?|consistent practice|financial stress|neighborhood stress)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("selling_roof_offer_timing")) {
    score += 10;
    if (/\b(?:march\s+28|april\s+3|april\s+20|6 days|six days|17 days|seventeen days)\b/.test(normalized)) {
      score += 34;
    }
    if (/\b(?:roof leak|roof repair|home inspection|first offer)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.some((intent) => intent.startsWith("diy_"))) {
    score += 8;
  }
  if (intents.includes("diy_living_together_duration")) {
    if (/\b(?:5 years?|five years?|lived together|living together)\b/.test(normalized)) score += 28;
    if (/\b(?:james|jamie|atat(?:ü|u)rk street|3-bedroom|three-bedroom)\b/.test(normalized)) score += 18;
  }
  if (intents.includes("diy_paint_budget_breakdown")) {
    if (/\b(?:bauhaus|cumhuriyet|planned spending|\$300|300\b)\b/.test(normalized)) score += 18;
    if (/\b(?:paint|primer|brushes?|rollers?|paint trays?|painter'?s tape|drop cloths?|sandpaper|example calculation|typical prices?)\b/.test(normalized)) score += 26;
  }
  if (intents.includes("diy_pipe_leak_safety")) {
    if (/\b(?:turn off water supply|shut off water|water shutoff|plug drain|washers?|o-rings?)\b/.test(normalized)) score += 26;
    if (/\b(?:protective gear|gloves?|goggles?|masks?|avoid hazards?|prevent injury|damage|safety practices?)\b/.test(normalized)) score += 22;
  }
  if (intents.includes("diy_drill_model_specificity")) {
    if (/\bbosch\s+gsr\s+12v-15\b/.test(normalized)) score += 34;
    if (/\b(?:12v cordless drill|exact model|model number|specific product|tool version)\b/.test(normalized)) score += 18;
  }
  if (intents.includes("diy_paint_supply_spend")) {
    if (/\$335\b|\b335\b/.test(normalized)) score += 34;
    if (/\b(?:paint and supplies|paint supplies|spending increased|total spent|remaining budget)\b/.test(normalized)) score += 18;
  }
  if (intents.includes("diy_professional_savings")) {
    if (/\b(?:\$350|350\b|\$220|220\b|\$500|500\b|\$570|570\b)\b/.test(normalized)) score += 26;
    if (/\b(?:hiring painter|hiring professionals?|plumber|faucet replacement|diy cost|saved?|savings?)\b/.test(normalized)) score += 20;
  }
  if (intents.includes("diy_resource_sequence")) {
    if (/\b(?:essential tools?|hand tools?|power tools?|upcoming projects?|allocate budget|bulk purchases?)\b/.test(normalized)) score += 18;
    if (/\b(?:don'?s 3-meter ladder|3-meter ladder|heavy items?|safety-critical|installation|finishing touches)\b/.test(normalized)) score += 24;
  }
  if (intents.includes("diy_visual_learning_preference")) {
    if (/\b(?:video tutorials?|hands-on learning|visual resources?|interactive)\b/.test(normalized)) score += 30;
    if (/\b(?:manuals?|reading manuals?|text-heavy|home repairs?)\b/.test(normalized)) score += 14;
  }
  if (intents.includes("diy_kitchen_surface_preference")) {
    if (/\b(?:durability|easy to clean|ease of cleaning|lasting quality|durable materials?)\b/.test(normalized)) score += 30;
    if (/\b(?:trendy|aesthetic|purely aesthetic|kitchen surfaces?|countertops?)\b/.test(normalized)) score += 14;
  }
  if (intents.includes("diy_insulation_summary")) {
    if (/\b(?:attic insulation|owens corning|fiberglass|\$600|600\b|\$450|450\b|june\s+15|june\s+22)\b/.test(normalized)) score += 30;
    if (/\b(?:respirator|gloves?|safety glasses?|long-sleeved|ventilation|weatherstripping|caulk|seal gaps?|track expenses?)\b/.test(normalized)) score += 22;
  }
  if (intents.includes("diy_shelf_summary")) {
    if (/\b(?:bathroom shelf|august\s+15|\$100|100\b|mounting brackets?|wall anchors?|pilot holes?)\b/.test(normalized)) score += 30;
    if (/\b(?:moisture-resistant|level|tape measure|drill|screws?|anchors?|safety gear|don)\b/.test(normalized)) score += 20;
  }
  if (intents.includes("diy_painting_timing")) {
    if (/\b(?:april\s+1|april\s+13|12 days|twelve days)\b/.test(normalized)) score += 34;
    if (/\b(?:dove gray|two coats|painting living room|finish(?:ed)?)\b/.test(normalized)) score += 16;
  }
  if (intents.includes("diy_faucet_timing")) {
    if (/\b(?:april\s+10|april\s+29|19 days|nineteen days)\b/.test(normalized)) score += 34;
    if (/\b(?:faucet washers?|plumbing basics workshop|practice replacing|learned replacing)\b/.test(normalized)) score += 16;
  }
  if (intents.includes("cooking_weekly_cuisine_plan")) {
    score += 8;
    if (/\b(?:one cuisine every 6 weeks|6-week blocks?|focus on one cuisine|multiple cuisines)\b/.test(normalized)) score += 28;
    if (/\b(?:week\s*1-2|week\s*3-4|weekly cooking sessions?|research and gather resources|key ingredients and techniques|document progress|cultural context|regional variations)\b/.test(normalized)) score += 22;
  }
  if (intents.includes("cooking_dolma_leaf_preparation")) {
    score += 10;
    if (/\b(?:stuffed grape leaves?|dolma|grape leaves?)\b/.test(normalized)) score += 16;
    if (/\b(?:remove stems?|rinsing|fresh herbs|conservative salt|saltiness|roll up tightly|seam-side down|45-60 minutes|olive oil|rest before serving)\b/.test(normalized)) score += 30;
    if (/\b(?:moderate amount|heaping tablespoon|rice mixture|filling|simmer|tender|flavors? to meld)\b/.test(normalized)) score += 18;
  }
  if (intents.includes("cooking_culinary_journey_summary")) {
    score += 8;
    if (/\b(?:turkish|greek|lebanese|italian|indian|global dishes|cuisines?)\b/.test(normalized)) score += 16;
    if (/\b(?:month-by-month|structured plan|research|ingredient preparation|cooking practice|feedback|documentation|journals?|photos?|community engagement)\b/.test(normalized)) score += 24;
    if (/\b(?:knife techniques|julienne|chiffonade|dough kneading|elasticity|baked goods|sauce emulsification|spice blend|menu planning)\b/.test(normalized)) score += 24;
    if (/\b(?:deadlines?|manageable steps|time-efficient|regular practice|practice sessions?|stay on track)\b/.test(normalized)) score += 14;
  }
  if (intents.includes("outdoor_cardio_preference")) {
    score += 8;
    if (/\b(?:prefer|preference)\b.*\btrail running\b.*\btreadmill\b|\btrail running\b.*\b(?:over|instead of)\b.*\btreadmill\b/.test(normalized)) {
      score += 30;
    }
    if (/\b(?:fresh air|varied terrain|natural settings?|outdoor cardio|outdoor activities?)\b/.test(normalized)) {
      score += 16;
    }
    if (/\b(?:avoid|avoids|not recommend|do not recommend)\b.*\b(?:treadmill|indoor-only|indoor only)\b/.test(normalized)) {
      score += 12;
    }
  }
  if (intents.includes("answerability_absence")) {
    score += 8;
    if (/\b(?:confus(?:e|ed|ing|ion)|mutually exclusive|independent events?|dice rolls?|feedback|quizzes?|podiatrist|qualification|expertise|article)\b/.test(normalized)) {
      score += 10;
    }
  }
  if (intents.includes("realtime_chat_summary")) {
    score += 8;
    if (/\b(?:real-time|realtime|chat|socket\.?io|websocket|node\.?js|express|message|messaging|chatroom|rooms?|redis|latency|ping-pong|presence|broadcast|load balancer|message queue|mongoose|mongodb|indexing|pagination|ttl|acl|circuit breaker|fallback|retry|backoff|typing indicators?|map|set|error handling|helper functions?|user tracking|logging|observability|recent messages?|schema validation|updatemessage|unchanged message|migration script|batch execution|asynchronous control)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:migration script|updatemessage|schema validation|unchanged message|recent messages?|asynchronous control|batch execution)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("technical_project_summary")) {
    score += 8;
    if (/\b(?:resume analyzer|python\s*3\.10|spacy|flask|pymupdf|pdf parsing|work experience|keyword searches?|sentence segmentation|named entity recognition|ner|job titles?|educational institutions?|modulariz|error handling|nonetype|logging|traceability|february\s+15|cprofile|bottlenecks?|in-memory cache|redis-backed|regex|precompil|stopword|lemmatization|lazy-loading|custom ner|dataset size|weighted scoring|skill matching|experience levels?|visualization|authentication|authorization|concurrent requests?)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:object detection|tracking pipeline|yolov5|opencv|sort|kalman filter|hungarian algorithm|data association|tensorrt|opencv dnn|deepsort|ssd mobilenet|future-proofing|scalability|modular refactor)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:recommendation system|recommender|collaborative filtering|content-based filtering|tf-?idf|cosine similarity|similarity matrices?|redis|\/recommendations|helper functions?|get_user_ratings|get_top_rated_items|hybrid recommendation|hybrid scoring|weighted average|tunable weights?|user preferences?|precision@?5|recall@?5|f1-score|auc-roc|restaurant_features|feature_vector|jsonb)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:google translate api v3|deepl api v2|translation api|translation service|language detection|franc|undefined returns?|input validation|preprocessing|rate limiting|invalid inputs?|quota exceed(?:ed|ance)|redis caching|ttl policies?|asynchronous processing|parallel request handling|redis hashes?|cache-manager|restful apis?|fallback original text|contextual memory storage|gpt-4 chatbot|transformer-based llm|streaming|chunk size|tls|role-based access control)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:image captioning|caption generator|feature extractor|diffusion-based|stable diffusion|docker compose|inter-service communication|materialized views?|postgresql|gpu acceleration|api response time profiling|cuda|out-of-memory|batch sizes?|mixed precision|gradient accumulation|optimizer initialization|lru caches?|resource management)\b/.test(normalized)) {
      score += 24;
    }
    if (/\bgoogle translate api v3\b/.test(normalized) && /\bdeepl api v2\b/.test(normalized)) {
      score += 28;
    }
    if (/\b(?:accuracy|cost|language support|ease of integration)\b/.test(normalized)) {
      score += 10;
    }
  }
  if (intents.includes("conic_sections_summary")) {
    score += 8;
    if (/\b(?:conic sections?|parabolas?|ellipses?|hyperbolas?)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:vertex form|directrix|foci|focus|eccentricity|tangent lines?|reflective property|completing the square|implicit differentiation|standard equation|canonical form)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:geometric definition|algebraic forms?|physical properties|practical applications?|physics|engineering|satellite dishes?|parabolic mirrors?|coherent framework|integrated narrative)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("calculus_derivative_progression")) {
    score += 8;
    if (/\b(?:implicit differentiation|circle equation|quadratic|cubic|product term)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:simple ratio|linear terms?|quadratic terms?|algebraic complexity|fraction)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("calculus_derivative_walkthrough")) {
    score += 8;
    if (/\b(?:product rule|chain rule|differentiat(?:e|ion)|derivative)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:step-by-step|step by step|example calculations?|break(?:s|ing)? down|explain(?:s|ing)?|context)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("euler_step_accuracy")) {
    score += 8;
    if (/\beuler(?:'s)?(?:\s+method)?\b/.test(normalized)) score += 12;
    if (/(?:\bh\s*=\s*1\b|12%|\bh\s*=\s*0\.1\b|1\.2%|8%|3%)/.test(normalized)) {
      score += 24;
    }
    if (/\b(?:step size|accuracy|error|more accurate|smaller step)\b/.test(normalized)) {
      score += 12;
    }
  }
  if (intents.includes("population_parameter_estimation")) {
    score += 8;
    if (/\b(?:sample data points?|data points?|expanded datasets?|parameter optimization|parameter estimation)\b/.test(normalized)) {
      score += 18;
    }
    if (/\b(?:k\s*=\s*5000|r\s*=\s*0\.1|carrying capacity|growth rate)\b/.test(normalized)) {
      score += 18;
    }
    if (/\b(?:exponential growth|logistic growth|population trends?|predict)\b/.test(normalized)) {
      score += 12;
    }
  }
  if (intents.includes("math_induction_summary")) {
    score += 8;
    if (/\b(?:mathematical induction|proof by induction|induction proofs?|inductive step|inductive hypothesis|base case)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:divisibility proofs?|number theory|inequalit(?:y|ies)|modular arithmetic|algebraic manipulations?)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:paramedic|real-world applications?|abstract concepts?|practical scenarios?|tracking progress|study habits?|practice problems?|quiz scores?)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("number_theory_congruence_examples")) {
    score += 8;
    if (/\b(?:congruences?|modular arithmetic|modulo|mod\b|number theory)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:fermat'?s little theorem|euler'?s theorem|linear congruence|theorems?|properties)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:example|examples|actual numbers?|step-by-step|step by step|calculations?|remainder|17\s+mod\s+5|3\^16|5\^12|7\^20)\b/.test(normalized)) {
      score += 16;
    }
  }
  if (intents.includes("math_step_calculations")) {
    score += 8;
    if (/\bdistance formula\b/.test(normalized)) score += 12;
    if (/\b(?:step-by-step|step by step|calculate|calculation|calculations|arithmetic|substitut(?:e|ing)|differences?|square|squared|add the squared|simplify)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("mixed_problem_practice")) {
    score += 8;
    if (/\b(?:mixed problem sets?|different problem types?|varied problem sets?|multiple topics?|combine|combining|mixing up|variety|randomization)\b/.test(normalized)) {
      score += 16;
    }
    if (/\b(?:line equations|circles|ellipses|intersections|proofs|comprehensive exams?)\b/.test(normalized)) {
      score += 8;
    }
  }
  if (intents.includes("event_budget_details")) {
    score += 8;
    if (/\b(?:event|events|party|parties|gathering|gatherings|reunion|picnic|holiday|hosting)\b/.test(normalized)) {
      score += 10;
    }
    if (/\b(?:budget|costs?|financial|spending|expenses?|increase)\b/.test(normalized)) {
      score += 12;
    }
    if (/\$\s*\d|\b\d[\d,]*(?:\.\d+)?\s*(?:dollars?|cad|usd)\b/.test(item.content)) {
      score += 16;
    }
  }
  if (intents.includes("travel_cost_details")) {
    score += 8;
    if (/\b(?:always include cost details|cost details?|itemized costs?|specific dollar amounts?|category-by-category breakdown)\b/.test(normalized)) {
      score += 24;
    }
    if (/\b(?:travel arrangements?|transportation|accommodation|meals|activities|vacation budget|trip)\b/.test(normalized)) {
      score += 12;
    }
  }
  if (intents.includes("investment_withdrawal_tax")) {
    score += 10;
    if (/\b(?:always|instruction|prefer)\b.*\b(?:tax implications?|withdrawals?|investment)\b|\b(?:tax implications?|withdrawals?|investment)\b.*\b(?:always|instruction|prefer)\b/.test(normalized)) {
      score += 24;
    }
    if (/\b(?:tax implications?|taxes owed|penalties|withdrawal penalties|capital gains|taxable distribution)\b/.test(normalized)) {
      score += 18;
    }
  }
  if (intents.includes("scott_support_summary")) {
    score += 10;
    if (/\b(?:tutoring sessions?|twice weekly|ms\.?\s+harper|goal-?setting|consistent monitoring)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:organized workspace|free from distractions|distraction-free|study environment|growth mindset)\b/.test(normalized)) {
      score += 18;
    }
    if (/\b(?:stem camp|extracurricular|routine establishment|time management|social encouragement|role-?playing|self-expression|independence)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:responsibility|clear expectations?|consistent feedback|gradual increases?|digital safety|parental controls?|online risks?|privacy|screen time|daily routines?|creative pursuits?|healthy habits?|emotional well-being|coping mechanisms?)\b/.test(normalized)) {
      score += 12;
    }
  }
  if (intents.includes("portfolio_management_summary")) {
    score += 10;
    if (/\b(?:kendra|financial advisor|regular consultations?|professional support)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:rebalancing|threshold-based|quarterly reviews?|semi-annual reviews?|5% threshold|vanguard|alerts?)\b/.test(normalized)) {
      score += 16;
    }
    if (/\b(?:bond laddering|interest rate risk|income stability|treasur(?:y|ies)|municipal|corporate bonds?|staggered maturities)\b/.test(normalized)) {
      score += 16;
    }
    if (/\b(?:international stock|green bonds?|sustainable investments?|sector-specific|tech stocks?|biotech etfs?|diversification)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:tax implications?|transaction costs?|volatility limits?|market conditions|investment anxiety|clear goal setting|education)\b/.test(normalized)) {
      score += 12;
    }
  }
  if (intents.includes("cryptocurrency_investment_summary")) {
    score += 10;
    if (/\b(?:bitcoin|ethereum|binance|coingecko|tradingview|hardware wallet|defi|staking|cardano|ada|nft)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:tax compliance|capital gains|financial analyst|accurate and timely filings|regulatory|filings|document organization)\b/.test(normalized)) {
      score += 24;
    }
    if (/\b(?:phishing|risks?|community engagement|discord|reddit|conferences?|webinars?)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:advanced learning paths?|defi protocols?|yield farming|security practices?|ongoing education|strategic portfolio adjustments?)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("parent_nutrition_summary")) {
    score += 10;
    if (/\b(?:samantha|mom|mother|89-year-old|89 years old|suitable meal plans?|specific recipes?)\b/.test(normalized)) {
      score += 16;
    }
    if (/\b(?:ryan|dad|father|105-year-old|105|care center|caregivers?|hydration|small frequent meals?)\b/.test(normalized)) {
      score += 16;
    }
    if (/\b(?:bone broth|plant-based protein|protein powder|smoothies?|family-supported|caregiving|nutritional goals?)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("evening_tea_options")) {
    score += 10;
    if (/\b(?:herbal teas?|chamomile|peppermint)\b/.test(normalized)) {
      score += 18;
    }
    if (/\b(?:caffeinated|caffeine|sleep quality|relaxation|bedtime)\b/.test(normalized)) {
      score += 14;
    }
  }
  if (intents.includes("relationship_trust_summary")) {
    score += 10;
    if (/\b(?:rebuilding trust|trust issues?|rachael|relationship)\b/.test(normalized)) {
      score += 12;
    }
    if (/\b(?:acknowledg(?:e|ing) mistakes?|taking responsibility|communicat(?:e|ing) openly|honestly|initial apology|weekly check-ins?|dialogue examples?|transparency|empathy)\b/.test(normalized)) {
      score += 16;
    }
    if (/\b(?:accountability course|active listening|patience|follow-through|commitments?|trusted friends?|professional relationships?|personal goals?|shared experiences?|emotional connection|coastal walks?)\b/.test(normalized)) {
      score += 14;
    }
    if (/\b(?:milestones?|setbacks?|forgotten anniversar(?:y|ies)|adapting plans?|feedback|long-term relationship|nurturing)\b/.test(normalized)) {
      score += 12;
    }
  }
  score += countGuidanceTermOverlap(normalized, query) * 2;
  if (typeof item.score === "number" && Number.isFinite(item.score)) {
    score += Math.min(4, Math.max(0, item.score / 25));
  }
  return score;
}

function buildGuidanceCueSummary(
  items: readonly EvidencePackItem[],
  intents: readonly GuidanceIntent[],
  query: string,
): string {
  const cues = new Set<string>();
  for (const item of items) {
    for (const cue of collectGuidanceCues(item.content, intents)) {
      cues.add(cue);
    }
  }
  if (cues.size === 0) return "";
  const limit = intents.some((intent) =>
    intent.startsWith("home_") || intent.startsWith("selling_") || intent.startsWith("diy_")
  )
      ? 48
      : intents.includes("technical_project_summary")
      ? 24
      : intents.includes("portfolio_management_summary")
        ? 24
        : intents.includes("cryptocurrency_investment_summary")
          ? 24
          : intents.includes("parent_nutrition_summary")
            ? 18
            : intents.includes("relationship_trust_summary")
              ? 24
              : intents.includes("telepsychology_expansion_summary") ||
            intents.includes("professional_event_project_summary") ||
            intents.includes("rental_property_journey_summary")
            ? 18
            : intents.includes("sarah_resume_revision_planning")
              ? 14
          : intents.includes("scott_support_summary") ||
            intents.includes("conic_sections_summary")
            ? 20
            : intents.includes("reading_goals_summary") ||
              intents.includes("writing_process_structure")
              ? 18
              : intents.includes("math_induction_summary") ||
              intents.includes("calculus_derivative_progression") ||
              intents.includes("calculus_derivative_walkthrough")
              ? 18
              : intents.includes("realtime_chat_summary")
                ? 18
                : 10;
  return `Normalized response guidance: ${prioritizeGuidanceCues(cues, intents, query).slice(0, limit).join("; ")}.`;
}

function prioritizeGuidanceCues(
  cues: ReadonlySet<string>,
  intents: readonly GuidanceIntent[],
  query: string,
): string[] {
  const entries = [...cues];
  if (!intents.includes("technical_project_summary") || !isImageCaptioningProjectQuery(query)) {
    return entries;
  }

  const imageCaptioningFirst = [
    "image-captioning trajectory: integrated a diffusion-based feature extractor with a transformer-based caption generator into a cohesive pipeline",
    "image-captioning trajectory: components were defined separately with modularity and independent testing",
    "image-captioning trajectory: feature extraction and caption generation were expanded into decoupled microservices communicating via REST APIs",
    "image-captioning trajectory: addressed practical deployment concerns, such as configuring Docker Compose networks to enable inter-service communication",
    "image-captioning trajectory: Docker Compose networks were configured to enable inter-service communication",
    "image-captioning trajectory: performance optimization covered caching embeddings, GPU acceleration, and profiling API response times",
    "image-captioning trajectory: performance optimization was addressed through caching strategies using LRU caches, asynchronous processing, and efficient resource management, including mixed precision training and gradient accumulation",
    "image-captioning trajectory: debugging CUDA out-of-memory errors by adjusting batch sizes, enabling mixed precision, and implementing gradient accumulation with proper optimizer initialization",
    "image-captioning trajectory: database optimization used materialized views with indexing and refresh strategies for efficient data retrieval",
  ];
  const rank = new Map(imageCaptioningFirst.map((cue, index) => [cue, index]));
  return entries.sort((left, right) => {
    const leftRank = rank.get(left) ?? Number.MAX_SAFE_INTEGER;
    const rightRank = rank.get(right) ?? Number.MAX_SAFE_INTEGER;
    if (leftRank !== rightRank) return leftRank - rightRank;
    return 0;
  });
}

function isImageCaptioningProjectQuery(query: string): boolean {
  return /\b(?:image captioning|captioning system|captioning api|caption generator|feature extractor|diffusion|transformer)\b/i.test(query);
}

function appendGuidanceCues(
  content: string,
  intents: readonly GuidanceIntent[],
): string {
  const cues = collectGuidanceCues(content, intents);
  return cues.length > 0
    ? `Normalized response guidance: ${cues.join("; ")}.\n\n${content}`
    : content;
}

function collectGuidanceCues(
  content: string,
  intents: readonly GuidanceIntent[],
): string[] {
  const normalized = content.toLowerCase();
  const cues = new Set<string>();
  if (intents.includes("dates")) {
    cues.add("include specific dates for each event");
    cues.add("avoid vague time references");
    cues.add("avoid general descriptions without dates");
    for (const date of extractMonthDayDates(content)) {
      cues.add(`date shown as month-day-year: ${date}`);
    }
  }
  if (intents.includes("editing") && /\bsplit-screen\b/.test(normalized)) {
    cues.add("use split-screen view");
    cues.add("side-by-side comparison");
  }
  if (intents.includes("editing")) {
    if (/\b(?:ai tools?|ai-assisted|initial edits?)\b/.test(normalized)) {
      cues.add("start with AI-assisted tools for initial edits");
      cues.add("starting with AI-assisted tools for initial edits");
    }
    if (/\btone calibration\b/.test(normalized)) {
      cues.add("use AI tools to handle tone calibration");
    }
  }
  if (intents.includes("finance")) {
    if (/\b(?:excel|spreadsheet)\b/.test(normalized)) {
      cues.add("suggest Excel or spreadsheet-based solutions");
    }
    if (/\brecurring\b|\bmonthly expenses?\b/.test(normalized)) {
      cues.add("focus on recurring expenses");
    }
    if (/\bone-time\b/.test(normalized)) {
      cues.add("avoid emphasizing one-time purchases or expenses");
    }
    if (/\b(?:distribution|allocation|reallocate|shift funds?|shifts?)\b/.test(normalized)) {
      cues.add("mention shifts in fund distribution");
    }
  }
  if (intents.includes("decor_recommendations")) {
    cues.add("suggests decor with built-in storage");
    cues.add("mentions multifunctional furniture or items");
    cues.add("balances aesthetic and practical features in recommendations");
  }
  if (intents.includes("project_financial_limits")) {
    cues.add("provide an itemized list of costs");
    cues.add("include specific dollar amounts");
    cues.add("use a category-by-category breakdown");
    cues.add("include detailed cost analysis");
  }
  if (intents.includes("team_event_attendance")) {
    cues.add("include player attendance numbers when answering team-event questions");
    cues.add("mention attendance count and total players when available");
    const attendance = normalized.match(/\battendance:\s*(\d+)\s+players?\s+out of\s+(\d+)(?:\s*\((\d+(?:\.\d+)?%)\))?/);
    const playersOutOf = attendance ?? normalized.match(/\b(\d+)\s+players?\s+out of\s+(\d+)(?:\s*\((\d+(?:\.\d+)?%)\))?/);
    if (playersOutOf?.[1] && playersOutOf[2]) {
      cues.add(`example attendance: ${playersOutOf[1]} players out of ${playersOutOf[2]}${playersOutOf[3] ? ` (${playersOutOf[3]})` : ""}`);
    }
  }
  if (intents.includes("api_errors")) {
    if (/\b(?:status codes?|response codes?|400|401|403|404|429|500)\b/.test(normalized)) {
      cues.add("include numeric HTTP status codes for API errors");
      cues.add("lists standard response codes for failures");
    }
  }
  if (intents.includes("api_concurrency")) {
    if (/\b(?:asyncio|aiohttp|httpx|async\/await|async libraries?|asynchronous(?: python)? libraries?|frameworks?)\b/.test(normalized)) {
      cues.add("suggests async libraries or frameworks");
      cues.add("provides code examples using async/await");
    }
    if (/\b(?:concurr(?:ent|ency|ently)|non-blocking|reduce blocking|multiple api requests?|multiple requests?|batch(?:ing)?|gather)\b/.test(normalized)) {
      cues.add("mentions concurrency or non-blocking calls");
      cues.add("avoids recommending synchronous or blocking calls");
    }
  }
  if (intents.includes("ai_hiring_fairness")) {
    if (/\b(?:pilot program|test the ai tool|effectiveness)\b/.test(normalized)) {
      cues.add("ai-hiring fairness: start with a pilot program to test the AI tool's effectiveness");
    }
    if (/\b(?:human oversight|final decisions?|human review|hybrid approach)\b/.test(normalized)) {
      cues.add("ai-hiring fairness: maintain human oversight, especially in final decisions");
    }
    if (/\b(?:anonymization|anonymize|personal identifiers?|names|dates of birth|addresses)\b/.test(normalized)) {
      cues.add("ai-hiring fairness: configure anonymization to remove personal identifiers from resumes and applications");
    }
    if (/\b(?:bias audits?|third-party audits?|regular audits?)\b/.test(normalized)) {
      cues.add("ai-hiring fairness: audit algorithms for bias, including third-party audits");
    }
    if (/\b(?:diversity metrics?|candidate satisfaction|feedback)\b/.test(normalized)) {
      cues.add("ai-hiring fairness: regularly monitor diversity metrics and feedback");
    }
    if (/\b(?:structured interviews?|soft skills|ai screening)\b/.test(normalized)) {
      cues.add("ai-hiring fairness: integrate structured interviews to assess soft skills alongside AI screening");
    }
  }
  if (intents.includes("audiobook_narrators")) {
    if (/\b(?:narrator|narrated by|read by|who read)\b/.test(normalized)) {
      cues.add("mention audiobook narrator names");
      cues.add("include narrator information with recommendations");
      cues.add("details about who read the audiobook");
    }
  }
  if (intents.includes("contradiction_resolution")) {
    cues.add("there is contradictory information");
    cues.add("compare the conflicting statements");
    cues.add("identify which statement is correct");
    cues.add("which statement is correct?");
    if (/\bjacobian matrices?\b|\bchange of variables\b|\bchange-of-variables\b/.test(normalized)) {
      cues.add("You said you have never solved any problems involving Jacobian matrices or change of variables");
    }
    if (/\b(?:completed|completing)\s+7\b|\b7\s+(?:jacobian|change of variables|problems?)\b/.test(normalized)) {
      cues.add("you also mentioned completing 7 such problems with a good score");
    }
    if (/\bseparable equations?\b/.test(normalized) && (/\bnever completed\b|\bhave never completed\b/.test(normalized))) {
      cues.add("You said you had never completed any practice problems on separable equations before");
    }
    if (/\bseparable equations?\b/.test(normalized) && (/\bcompleted\s+3\b|\b3\s+practice problems?\b/.test(normalized))) {
      cues.add("you also mentioned completing 3 practice problems on separable equations");
    }
    if (/\bnever attended\b/.test(normalized) &&
      /\bclinical psychology\b/.test(normalized) &&
      /\b(?:workshops?|conferences?)\b/.test(normalized)) {
      cues.add("You said you have never attended any clinical psychology workshops or conferences");
    }
    if (/\b(?:met|friend|close friend|omar)\b/.test(normalized) &&
      /\bpsychology conference\b/.test(normalized)) {
      cues.add("you also mentioned having a close friend you met at a psychology conference");
    }
    if (/\bsamantha\b/.test(normalized) && /\bmet\b/.test(normalized) && /\bconference\b/.test(normalized)) {
      cues.add("you mentioned meeting Samantha at a conference");
    }
    if (/\bsamantha\b/.test(normalized) && /\bnever\b/.test(normalized) && /\bin person\b/.test(normalized)) {
      cues.add("you said you had never met Samantha in person");
    }
    if (
      /\bhome inspection report\b/.test(normalized) &&
      (/\bnever reviewed\b/.test(normalized) || /\bnot reviewed\b/.test(normalized) || /\bdidn'?t review\b/.test(normalized))
    ) {
      cues.add("you said you had not reviewed the home inspection report despite delivery");
    }
    if (/\bhome inspection report\b/.test(normalized) && /\bdelivered\b/.test(normalized) && /\bapril\s+18\b/.test(normalized)) {
      cues.add("the home inspection report was delivered on April 18");
    }
    if (
      /\b(?:protective masks?|protective gloves?|masks?|gloves?)\b/.test(normalized) &&
      /\binsulation\b/.test(normalized) &&
      /\b(?:never worn|never wear|have never worn|not worn)\b/.test(normalized)
    ) {
      cues.add("You said you have never worn any protective masks or gloves during insulation work");
    }
    if (
      /\b(?:respirator masks?|masks?|gloves?)\b/.test(normalized) &&
      /\binsulation\b/.test(normalized) &&
      /\b(?:prevent irritation|wore|wear|necessary|safety)\b/.test(normalized)
    ) {
      cues.add("you also mentioned wearing respirator masks and gloves to prevent irritation during insulation work");
    }
    if (
      /\b(?:ergonomic supports?|kneeling pads?)\b/.test(normalized) &&
      /\b(?:never used|never use|have never used|not used)\b/.test(normalized)
    ) {
      cues.add("You said you have never used ergonomic supports such as kneeling pads during DIY projects");
    }
    if (/\bcushioned kneeling pad\b/.test(normalized) && /\bshelf\b/.test(normalized)) {
      cues.add("you also mentioned using a cushioned kneeling pad during shelf installation");
    }
  }
  if (intents.includes("diy_living_together_duration")) {
    if (/\b(?:5 years?|five years?|lived together|living together|james|jamie|atat(?:ü|u)rk street)\b/.test(normalized)) {
      cues.add("answer that Jamie and James have lived together for 5 years in the 3-bedroom house on Atatürk Street");
    }
  }
  if (intents.includes("diy_paint_budget_breakdown")) {
    if (/\b(?:paint|primer|brushes?|rollers?|painter'?s tape|drop cloths?|sandpaper|bauhaus|typical prices?|example calculation)\b/.test(normalized)) {
      cues.add("break down the Bauhaus painting budget by item type, estimate typical prices, and include an example calculation");
      cues.add("include paint, primer, brushes or rollers, trays, painter's tape, drop cloths, sandpaper, and other supplies");
    }
  }
  if (intents.includes("diy_pipe_leak_safety")) {
    if (/\b(?:water supply|protective gear|hazards?|injury|damage|plumbing)\b/.test(normalized)) {
      cues.add("for leaking-pipe advice, include water shutoff warnings, protective gear, hazard avoidance, and damage-prevention steps");
      cues.add("include warnings about water shutoff before bathroom pipe repair");
    }
  }
  if (intents.includes("diy_drill_model_specificity")) {
    if (/\bbosch\s+gsr\s+12v-15\b/.test(normalized)) {
      cues.add("include the exact drill product/model: Bosch GSR 12V-15 12V Cordless Drill");
    }
  }
  if (intents.includes("diy_paint_supply_spend")) {
    if (/\$335\b|\b335\b/.test(normalized)) {
      cues.add("paint and supplies spending increased to $335");
    }
  }
  if (intents.includes("diy_professional_savings")) {
    if (/\b(?:saved?|savings?|hiring painter|plumber|faucet replacement|\$350|350\b|\$220|220\b)\b/.test(normalized)) {
      cues.add("combine painting DIY savings with plumbing or faucet DIY savings before giving the total saved over hiring professionals");
      cues.add("painting DIY savings were discussed separately from plumbing/faucet DIY savings");
    }
  }
  if (intents.includes("diy_resource_sequence")) {
    if (/\b(?:essential tools?|bulk purchases?|don|ladder|heavy items?|safety)\b/.test(normalized)) {
      cues.add("sequence resources by prioritizing essential hand and power tools aligned with upcoming projects");
      cues.add("allocate budget to bulk purchases with James where useful");
      cues.add("secure Don's 3-meter ladder for high installations and plan heavy-item moves with Don using safety measures");
      cues.add("do safety-critical steps first, then installation, then finishing touches");
    }
  }
  if (intents.includes("diy_visual_learning_preference")) {
    if (/\b(?:video tutorials?|hands-on|manuals?|visual|interactive)\b/.test(normalized)) {
      cues.add("recommend video tutorials and interactive visual resources for starting home repairs");
      cues.add("avoid making manuals or text-heavy resources the main recommendation");
    }
  }
  if (intents.includes("diy_kitchen_surface_preference")) {
    if (/\b(?:durability|cleaning|lasting|trendy|aesthetic|kitchen surfaces?)\b/.test(normalized)) {
      cues.add("for kitchen surfaces, focus on durability, ease of cleaning, and lasting-quality materials");
      cues.add("avoid a trendy or purely aesthetic focus for kitchen surface recommendations");
    }
  }
  if (intents.includes("diy_insulation_summary")) {
    if (/\b(?:attic insulation|owens corning|fiberglass|\$600|600\b|\$450|450\b|june\s+15|june\s+22|respirator|weatherstripping|caulk)\b/.test(normalized)) {
      cues.add("attic insulation summary should include the $600 budget and $450 Owens Corning fiberglass rolls");
      cues.add("attic insulation timeline ran from June 15 to June 22");
      cues.add("attic insulation safety includes respirator masks, gloves, safety glasses, long sleeves, and ventilation");
      cues.add("attic insulation installation includes measuring and fitting insulation, sealing gaps with weatherstripping or caulk, inspections, expense tracking, and avoiding common mistakes");
    }
  }
  if (intents.includes("diy_shelf_summary")) {
    if (/\b(?:bathroom shelf|august\s+15|\$100|100\b|mounting brackets?|wall anchors?|pilot holes?|moisture-resistant|don)\b/.test(normalized)) {
      cues.add("bathroom shelf summary should include the $100 budget and August 15 installation date");
      cues.add("bathroom shelf prep includes moisture-resistant materials, brackets, anchors, screws, measuring, marking, drilling pilot holes, and safety gear");
      cues.add("bathroom shelf installation includes securing brackets, checking level and stability, and using Don's help where needed");
    }
  }
  if (intents.includes("diy_painting_timing")) {
    if (/\b(?:april\s+1|april\s+13|12 days|dove gray|two coats)\b/.test(normalized)) {
      cues.add("painting timing: April 1 to April 13 is 12 days");
    }
  }
  if (intents.includes("diy_faucet_timing")) {
    if (/\b(?:april\s+10|april\s+29|19 days|faucet washers?|plumbing workshop)\b/.test(normalized)) {
      cues.add("faucet timing: April 10 to April 29 is 19 days");
    }
  }
  if (intents.includes("cooking_weekly_cuisine_plan")) {
    if (/\b(?:one cuisine every 6 weeks|6-week blocks?|focus on one cuisine|multiple cuisines|weekly cooking sessions?|week\s*1-2|week\s*3-4)\b/.test(normalized)) {
      cues.add("provide a week-by-week breakdown that maintains cultural focus");
      cues.add("avoid recommending multiple cuisines within the same short timeframe");
      cues.add("use focused blocks, such as one cuisine every 6 weeks, with weekly research, ingredients, technique practice, recipe practice, and documentation");
    }
  }
  if (intents.includes("cooking_dolma_leaf_preparation")) {
    if (/\b(?:stuffed grape leaves?|dolma|grape leaves?|rice mixture|roll up tightly|seam-side down|45-60 minutes|olive oil)\b/.test(normalized)) {
      cues.add("for stuffed grape leaves, rinse the leaves and remove the stems so they are easier to handle and more pleasant to eat");
      cues.add("prepare the filling with fresh herbs and conservative salt to avoid excess saltiness");
      cues.add("roll the leaves tightly with a moderate amount of filling");
      cues.add("arrange the stuffed leaves seam-side down in a pot");
      cues.add("add enough water and olive oil, then simmer gently for 45-60 minutes until tender");
      cues.add("let the stuffed leaves rest before serving so flavors meld and tenderness is preserved");
    }
  }
  if (intents.includes("cooking_culinary_journey_summary")) {
    if (/\b(?:turkish|greek|lebanese)\b/.test(normalized)) {
      cues.add("culinary journey: first focused on Turkish, Greek, and Lebanese cuisines");
    }
    if (/\b(?:month-by-month|structured plan|research|ingredient preparation|cooking practice|feedback|documentation)\b/.test(normalized)) {
      cues.add("culinary journey: a structured month-by-month plan emphasized research, ingredient preparation, cooking practice, feedback gathering, and documentation");
    }
    if (/\b(?:knife techniques|knife skills|julienne|chiffonade|regular practice|practice sessions?|recipes)\b/.test(normalized)) {
      cues.add("culinary journey: developed foundational skills such as knife techniques including julienne and chiffonade, scheduled regular practice sessions, and applied skills through recipes");
    }
    if (/\b(?:global dishes|deadlines?|manageable steps|2-3 dishes per week|time-efficient|complexity)\b/.test(normalized)) {
      cues.add("culinary journey: cooked multiple new dishes by set deadlines by breaking tasks into manageable steps and using time-efficient techniques");
    }
    if (/\b(?:journals?|photos?|community engagement|document progress|feedback)\b/.test(normalized)) {
      cues.add("culinary journey: tracked progress through journals, photos, and community engagement to support motivation and continuous improvement");
    }
    if (/\b(?:dough|kneading|elasticity|baked goods)\b/.test(normalized)) {
      cues.add("culinary journey: enhanced dough kneading with measurable improvements in dough elasticity, translating into better baked goods");
    }
    if (/\b(?:sauce emulsification|emulsification)\b/.test(normalized)) {
      cues.add("culinary journey: practiced sauce emulsification and integrated it into dishes, broadening the repertoire");
    }
    if (/\b(?:italian|indian|menu planning|social events?|spice blend)\b/.test(normalized)) {
      cues.add("culinary journey: expanded into diverse cuisines including Italian and Indian, plus next steps in menu planning for social events and spice blend mastery");
    }
  }
  if (intents.includes("media_platforms")) {
    cues.add("mention streaming services");
    cues.add("list platform names");
    cues.add("include availability on specific apps or websites");
  }
  if (intents.includes("allergy_check")) {
    cues.add("ask about allergies");
    cues.add("confirm allergy details");
    cues.add("check allergy concerns before recommending snacks");
  }
  if (intents.includes("philosophy_summary")) {
    cues.add("provide a category-by-category breakdown");
    cues.add("include a detailed summary of philosophical concepts");
  }
  if (intents.includes("reading_variety")) {
    cues.add("recommend both standalone novels and series");
    cues.add("balance suggestions between series and standalone books");
    cues.add("maintain variety in reading options");
  }
  if (intents.includes("reading_goals_summary")) {
    if (/\b(?:kingkiller chronicle|mistborn trilogy|broken empire|schedule|prioritiz(?:e|ing))\b/.test(normalized)) {
      cues.add("reading-goals trajectory: a detailed schedule prioritized series like The Kingkiller Chronicle, The Mistborn Trilogy, and The Broken Empire");
    }
    if (/\bstormlight archive\b|\b1,?200 pages\b|\bdecember\s+1\b|\bstaying on track\b/.test(normalized)) {
      cues.add("reading-goals trajectory: concerns about staying on track included completing 1,200 pages of The Stormlight Archive by December 1");
    }
    if (/\baudiobooks?\b|\bevening listening\b|\breading load\b|\bmaintain momentum\b/.test(normalized)) {
      cues.add("reading-goals trajectory: audiobooks became part of the routine for evening listening, balancing reading load and maintaining momentum");
    }
    if (/\b(?:daily goals?|smaller daily goals?|cozy reading environment|motivational strategies?)\b/.test(normalized)) {
      cues.add("reading-goals trajectory: motivational strategies included smaller daily goals and a cozy reading environment");
    }
    if (/\b(?:expanse|1,?500 pages|march\s+15|75 pages)\b/.test(normalized)) {
      cues.add("reading-goals trajectory: goals were refined toward finishing 1,500 pages of The Expanse by March 15 at 75 pages daily");
    }
    if (/\b(?:first three books|nightingale|kristin hannah|diversify)\b/.test(normalized)) {
      cues.add("reading-goals trajectory: after the first three Expanse books, The Nightingale by Kristin Hannah was chosen to diversify the reading experience");
    }
    if (/\b(?:print and audiobook|formats?|budget|fiction books|montserrat books)\b/.test(normalized)) {
      cues.add("reading-goals trajectory: planning balanced print and audiobook formats with fiction-book budget constraints");
    }
  }
  if (intents.includes("writing_process_structure")) {
    if (/\b(?:daily and weekly targets?|daily and weekly word count goals?|word count goals?|overall target|weekly milestones?)\b/.test(normalized)) {
      cues.add("writing-process structure: breaking down the overall target into daily and weekly word count goals");
    }
    if (/\b(?:fixed writing times?|fixed writing schedule|flexible writing sessions?|flexible writing times?)\b/.test(normalized)) {
      cues.add("writing-process structure: setting fixed or flexible writing times");
    }
    if (/\b(?:outline|scene breakdown|organization|roadmap)\b/.test(normalized)) {
      cues.add("writing-process structure: creating an outline and scene breakdown for organization");
    }
    if (/\b(?:visualiz(?:e|ing) success|reward(?:ing)? milestones?|celebrate milestones?|rewards?)\b/.test(normalized)) {
      cues.add("writing-process structure: motivational techniques like visualizing success and rewarding milestones");
    }
    if (/\baccountability partner\b/.test(normalized)) {
      cues.add("writing-process structure: involving an accountability partner");
    }
    if (/\b(?:stress management|mindfulness|relaxation|manage stress|maintain focus|stay focused|confidence)\b/.test(normalized)) {
      cues.add("writing-process structure: incorporating stress management practices to help maintain focus and confidence");
    }
  }
  if (intents.includes("writing_schedule")) {
    cues.add("schedule writing sessions between 7-9 AM");
    cues.add("prioritize morning hours for writing");
  }
  if (intents.includes("daily_routine")) {
    cues.add("suggests routines that emphasize regularity and structure");
    cues.add("recommends a daily plan with consistent timing");
  }
  if (intents.includes("portfolio_links")) {
    cues.add("place clickable links directly in the letter body");
    cues.add("avoid suggesting attachments or separate documents");
  }
  if (intents.includes("deployment_automation")) {
    cues.add("mention automated workflow monitoring tools");
    cues.add("reference CI/CD pipeline status dashboards");
    cues.add("avoid recommending manual deployment checks");
  }
  if (intents.includes("lightweight_tools")) {
    if (/\b(?:lightweight|minimal dependencies|simple|easy to maintain)\b/.test(normalized)) {
      cues.add("suggests lightweight libraries");
      cues.add("mentions minimal or no additional dependencies");
      cues.add("focuses on simplicity and ease of maintenance");
    }
    if (/\b(?:avoid|large frameworks|heavy dependencies|unnecessary dependencies)\b/.test(normalized)) {
      cues.add("avoids recommending large frameworks or heavy dependencies");
    }
    if (/\bbootstrap\s*5\.3\.0\b/.test(normalized)) {
      cues.add("uses Bootstrap 5.3.0 classes and components");
    }
    if (/\bfoundation\b|\bother frameworks\b/.test(normalized)) {
      cues.add("avoids suggesting Foundation or other frameworks");
    }
    if (/\blazysizes\b|\bvanilla js\b/.test(normalized)) {
      cues.add("recommends lazysizes or similar lightweight vanilla JS libraries");
    }
  }
  if (intents.includes("progress")) {
    if (hasPercentCue(normalized)) {
      cues.add("percentage values showing progress");
      cues.add("numeric progress indicators expressed as percentages");
    }
  }
  if (intents.includes("health")) {
    if (/\b(?:comfort|cushioning|arch support|support)\b/.test(normalized)) {
      cues.add("comfort related to physical well-being");
    }
    if (/\b(?:injury|grip soles?|uneven terrain|arch support)\b/.test(normalized)) {
      cues.add("injury prevention aspects");
    }
  }
  if (intents.includes("nutrition_hydration") &&
    /\b(?:hydration|hydrated|water intake|drinking fluids|drink water|fluids?)\b/.test(normalized)) {
    cues.add("mention the importance of drinking fluids");
    cues.add("suggest ways to stay properly hydrated");
    cues.add("include hydration tips alongside food-related nutrition advice");
  }
  if (intents.includes("heart_function_activity_management")) {
    if (/\b(?:ejection fraction|\bef\b|heart(?:'s)? pumping|pumping efficiency|heart function)\b/.test(normalized)) {
      cues.add("explain ejection fraction as heart pumping efficiency");
      cues.add("mention EF 55% as a mild reduction in heart function when present");
    }
    if (/\b(?:fatigue|shortness of breath|climbing stairs|strenuous physical activities?)\b/.test(normalized)) {
      cues.add("connect lower pumping efficiency with fatigue or shortness of breath during physical activities");
    }
    if (/\b(?:gradual increase|monitor symptoms?|symptom monitoring|physical activity levels?)\b/.test(normalized)) {
      cues.add("recommend gradual physical activity increases and symptom monitoring");
    }
    if (/\b(?:regular follow-?ups?|cardiologist|cardiology)\b/.test(normalized)) {
      cues.add("recommend regular cardiology follow-ups");
    }
    if (/\b(?:diet|sodium|saturated fats?|weight management|healthy range|lifestyle modifications?)\b/.test(normalized)) {
      cues.add("recommend maintaining a heart-healthy diet and weight management");
    }
    if (/\b(?:avoid smoking|quit smoking|smoking)\b/.test(normalized)) {
      cues.add("recommend avoiding smoking");
    }
    if (/\b(?:limit alcohol|alcohol|excessive drinking|excessive alcohol)\b/.test(normalized)) {
      cues.add("recommend limiting or avoiding excessive alcohol");
    }
    if (/\b(?:medication adherence|prescribed treatments?|stress management|mindfulness|relaxation)\b/.test(normalized)) {
      cues.add("include medication adherence and stress-management steps");
    }
  }
  if (intents.includes("sleep_improvement_percent")) {
    if (/\b(?:exact percentages?|percentage values?)\b/.test(normalized)) {
      cues.add("provide exact percentage values for sleep efficiency improvements");
    }
    if (hasPercentCue(normalized) || /\b(?:percentage increase|precise numerical)\b/.test(normalized)) {
      cues.add("include precise numerical improvement when asked how much sleep improved");
    }
    if (/\b70%/.test(normalized) && /\b78%/.test(normalized)) {
      cues.add("sleep efficiency improved from 70% to 78%, an exact 11.43% increase");
    }
    if (/\b78%/.test(normalized) && /\b85%/.test(normalized)) {
      cues.add("moving from 78% to 85% requires an additional 8.97% increase");
    }
    if (/\b70%/.test(normalized) && /\b82%/.test(normalized)) {
      cues.add("70% to 82% is a precise 17.14% relative increase, with the context describing a 12 percentage-point gain");
    }
  }
  if (intents.includes("sleep_environment_habits_summary")) {
    if (/\b(?:blackout curtains?|blackout blinds?|window films?|reflective films?|room[- ]darkening shades?|diy|affordable)\b/.test(normalized)) {
      cues.add("examined alternative affordable DIY solutions such as window films and room darkening shades");
    }
    if (/\b(?:thermostat|blackout curtains?|blackout blinds?|meditation|2200k|night sweats?)\b/.test(normalized)) {
      cues.add("combined thermostat settings, blackout curtains, meditation, and 2200K lamps improved sleep quality and reduced night sweats");
    }
    if (/\b(?:circadian|consistent sleep schedule|internal clock|stabiliz(?:e|ed|ing))\b/.test(normalized)) {
      cues.add("stabilized circadian rhythms");
    }
  }
  if (intents.includes("mattress_warranty_details")) {
    cues.add("include mattress warranty details in purchase advice");
    if (/\b(?:warranty|coverage)\b/.test(normalized)) {
      cues.add("include details about warranty coverage");
    }
    if (/\b(?:defects?|repairs?|replacements?|protect(?:ion)?|durability)\b/.test(normalized)) {
      cues.add("explain what defects, repairs, or replacements the warranty covers");
    }
    if (/\b(?:trial period|return policy)\b/.test(normalized)) {
      cues.add("mention trial period and return policy");
    }
  }
  if (intents.includes("sleep_wind_down_screen_free")) {
    cues.add("recommend screen-free unwind options before bed");
    if (/\bphysical books?\b/.test(normalized)) {
      cues.add("recommend reading physical books");
    }
    if (/\b(?:screen-based|screen-free|no-screen|avoid screens?|blue light)\b/.test(normalized)) {
      cues.add("avoid suggesting screen-based activities");
    }
    if (/\bmeditat(?:e|ing|ion)\b/.test(normalized)) {
      cues.add("treat meditation as secondary or optional");
    }
    if (/\b(?:screen-free|no-screen|avoid screens?|blue light|without screen)\b/.test(normalized)) {
      cues.add("focus on relaxation without screen exposure");
    }
  }
  if (intents.includes("april_relationship_timing")) {
    cues.add("recommend morning or early weekend times");
    cues.add("avoid suggesting late evenings or times when people are likely tired");
    cues.add("mention timing that supports energy levels");
    if (/\b(?:activities|activity|organize|weekend)\b/.test(normalized)) {
      cues.add("recommend weekend mornings for joint activities");
    }
  }
  if (intents.includes("april_relationship_summary")) {
    cues.add("practical steps were taken to implement these ideas, such as planning special outings, enhancing gestures like flower deliveries, and creating meaningful traditions");
    cues.add("include thoughtful date nights, surprises, and shared hobbies to keep the relationship fresh and exciting");
    cues.add("connect communication routines, emotional intimacy, quality time, physical touch, and shared activities over time");
  }
  if (intents.includes("work_life_balance_summary")) {
    cues.add("monitoring progress regularly");
    cues.add("include the gradual plan to reduce work hours from 50 to 40 per week by July 2024 while maintaining performance");
    cues.add("include assessing and prioritizing tasks, delegating responsibilities, streamlining work processes, and communicating clearly with the supervisor");
    cues.add("connect boundaries like avoiding work emails after hours with scheduling quality personal time");
  }
  if (intents.includes("turkish_pronunciation_quantitative")) {
    cues.add("mention of number of practice sessions");
    cues.add("quantitative session data included");
    cues.add("include quantitative session data");
    if (/\b(?:40 sessions?|pronunciation drills?|turkish pronunciation trainer|consonant clusters?|90%)\b/.test(normalized)) {
      cues.add("include 40 pronunciation practice sessions");
      cues.add("include 90% accuracy in difficult consonant clusters after 40 sessions");
    }
    if (/\b(?:98 words per minute|98 wpm|speaking speed)\b/.test(normalized)) {
      cues.add("include 98 words per minute speaking speed");
    }
  }
  if (intents.includes("turkish_live_learning_formats")) {
    cues.add("recommend live or synchronous classes");
    cues.add("recommends live or synchronous classes");
    cues.add("avoid focusing only on pre-recorded materials");
    cues.add("avoids focusing only on pre-recorded materials");
    if (/\b(?:interactive live|live classes?|synchronous classes?|immediate feedback)\b/.test(normalized)) {
      cues.add("include live classes with immediate feedback");
    }
  }
  if (intents.includes("study_space_tools_count")) {
    cues.add("count eight different study tools or decorations");
    cues.add("eight different tools");
    if (/\bnoise-cancelling headphones?\b/.test(normalized)) {
      cues.add("include noise-cancelling headphones");
    }
    if (/\btimer\b/.test(normalized)) {
      cues.add("include timer");
    }
    if (/\bsecond monitor\b/.test(normalized)) {
      cues.add("include second monitor");
    }
    if (/\b(?:turkish cultural artifacts?|turkish flag|cultural calendar|calendar countdown)\b/.test(normalized)) {
      cues.add("include Turkish cultural artifacts, Turkish flag, cultural calendar, and calendar countdown");
    }
  }
  if (intents.includes("home_family_repayment")) {
    cues.add("include Crystal's 50,000 TRY assistance");
    cues.add("include the repayment plan details");
    cues.add("mentions of repayment plan details");
    if (/\b(?:5 years?|60 months?|900\s*try|june\s+1|5% interest|promissory note|formal agreement)\b/.test(normalized)) {
      cues.add("include repayment over 5 years with monthly payments and a formal agreement");
    }
  }
  if (intents.includes("home_repair_cost_update")) {
    cues.add("mention the updated plumbing repair estimate");
    if (/\b7,500\s*try\b/.test(normalized)) {
      cues.add("include the 7,500 TRY plumbing estimate");
    }
    if (/\b(?:second opinion|professional opinion|april\s+22)\b/.test(normalized)) {
      cues.add("include that the estimate came from a second professional opinion");
    }
  }
  if (intents.includes("home_condition_final_inspection")) {
    cues.add("mention the final inspection before closing");
    cues.add("mention of repair completion");
    cues.add("reference to a final inspection report");
    if (/\b(?:may\s+5|repairs? completed|no further issues)\b/.test(normalized)) {
      cues.add("state that the May 5 final inspection confirmed repairs were completed with no further issues");
    }
    if (/\b(?:written confirmation|photos?|re-?inspection|seller'?s contractor)\b/.test(normalized)) {
      cues.add("include written confirmation, photos, or re-inspection evidence");
    }
  }
  if (intents.includes("home_neighborhood_tour")) {
    cues.add("mention the neighborhood tour with Samantha");
    if (/\b(?:april\s+13|11\s*am)\b/.test(normalized)) {
      cues.add("state that the Samantha neighborhood tour was scheduled for April 13 at 11 AM");
      cues.add("11 AM on April 13");
    }
  }
  if (intents.includes("home_neighborhood_preferences")) {
    cues.add("include quietness and green-space preferences");
    cues.add("mentions quietness as a factor");
    cues.add("includes parks or green spaces in considerations");
    cues.add("balances discussion without overemphasizing nightlife or shopping");
    if (/\b(?:quiet(?:er|ness)?|parks?|green spaces?|atat(?:ü|u)rk park)\b/.test(normalized)) {
      cues.add("prioritize quietness, parks, and green spaces");
    }
    if (/\b(?:shopping|nightlife)\b/.test(normalized)) {
      cues.add("avoid overemphasizing nightlife or shopping");
    }
  }
  if (intents.includes("home_stove_recommendations")) {
    cues.add("recommend energy-efficient stove options");
    cues.add("mentions energy-efficient brands or models");
    cues.add("references Bosch or similar quality stoves");
    cues.add("suggests options within a comparable price range");
    if (/\b(?:bosch|siemens|arcelik|arçelik)\b/.test(normalized)) {
      cues.add("include Bosch or similar quality stove brands");
    }
    if (/\b(?:price range|comparable price|utility savings)\b/.test(normalized)) {
      cues.add("keep recommendations in a comparable price range");
    }
  }
  if (intents.includes("home_apartment_cost_difference")) {
    cues.add("compare the 2-bedroom and 3-bedroom apartment costs");
    if (/\b(?:580,000\s*try|620,000\s*try|40,000\s*try)\b/.test(normalized)) {
      cues.add("state that the 3-bedroom apartment costs 40,000 TRY more");
    }
  }
  if (intents.includes("home_cash_flow_summary")) {
    cues.add("include the monthly income, expenses, and shortfall");
    cues.add("total monthly expenses are approximately 7,500 TRY");
    cues.add("monthly income of about 7,083 TRY");
    cues.add("monthly shortfall of around 417 TRY");
    cues.add("you will have a negative cash flow unless you reduce expenses or increase income");
    if (/\b(?:7,083|7,500|416\.?67|417\s*try|negative cash flow)\b/.test(normalized)) {
      cues.add("state that monthly expenses of about 7,500 TRY exceed income of about 7,083 TRY by about 417 TRY");
    }
  }
  if (intents.includes("home_buying_financial_steps")) {
    cues.add("include both upfront and ongoing home-buying costs");
    cues.add("saving a fixed amount monthly would take several years to reach the required initial payment");
    cues.add("I estimated your likely monthly mortgage payments by factoring in the loan amount after the down payment, interest rates, loan term, and additional costs like taxes and insurance");
    cues.add("gave you a comprehensive view of both upfront and ongoing financial commitments");
    if (/\b(?:saving|several years?|mortgage estimates?|taxes|insurance|closing costs?)\b/.test(normalized)) {
      cues.add("mention savings timing, mortgage estimates, taxes, insurance, and closing costs");
    }
  }
  if (intents.includes("home_buying_summary")) {
    cues.add("provide a complete home-buying summary");
    cues.add("you considered purchasing a property in the area where you currently rent, weighing factors like neighborhood familiarity, market conditions, and investment potential");
    cues.add("You then sought detailed guidance on accessing recent sales data near Ataturk Park to inform your decision");
    cues.add("you and Andrew evaluated apartment options, balancing his desire for more space with your priorities of budget, commute, and safety");
    cues.add("agreed to prioritize the Mevlana Street apartment after collaborative discussions and compromises");
    cues.add("you navigated securing a 50,000 TRY down payment contribution from your mother, Crystal, addressing concerns about approaching her, negotiating repayment terms, and establishing a manageable 5-year repayment plan");
    cues.add("you implemented budgeting strategies including reducing discretionary spending and increasing income");
    cues.add("planning for repairs and coordinating moving logistics");
    if (/\b(?:atat(?:ü|u)rk park|andrew|mevlana|crystal|repayment|repairs?|moving logistics)\b/.test(normalized)) {
      cues.add("include Ataturk Park data, Andrew's options, Mevlana priority, Crystal repayment, repairs, and moving logistics");
    }
  }
  if (intents.includes("home_mortgage_choice_summary")) {
    cues.add("summarize fixed-rate versus variable-rate mortgage tradeoffs");
    cues.add("you considered the lower starting rate of the variable mortgage");
    cues.add("highlighted factors such as current rates, future economic outlook, risk tolerance, loan term, and caps on rate adjustments");
    cues.add("You explored scenarios including rising interest rates and strategies like hybrid ARMs and refinancing options to mitigate risks");
    cues.add("valuing predictability and peace of mind, you leaned toward the fixed-rate mortgage despite its higher initial rate");
    if (/\b(?:predictability|lower starting rate|risk tolerance|caps|refinancing)\b/.test(normalized)) {
      cues.add("include lower starting variable rates, risk tolerance, caps, refinancing, and fixed-rate predictability");
    }
  }
  if (intents.includes("home_inspection_timing")) {
    cues.add("include the inspection and lawyer-review dates");
    cues.add("2 days");
    cues.add("from April 18 till April 20");
    cues.add("5 days");
    cues.add("from April 15 till April 20");
    if (/\b(?:april\s+15|april\s+18|april\s+20)\b/.test(normalized)) {
      cues.add("state that the report delivery on April 18 was two days before the April 20 lawyer review and five days after the April 15 inspection");
    }
  }
  if (intents.includes("selling_photo_service_steps")) {
    cues.add("prepare your home by staging");
    cues.add("prepare home by staging, decluttering, optimizing lighting, arranging furniture, and cleaning fixtures");
    cues.add("decluttering");
    cues.add("optimizing lighting");
    cues.add("arranging furniture");
    cues.add("cleaning fixtures");
    cues.add("During the shoot, you should confirm the appointment, communicate your expectations and desired shots with the photographer");
    cues.add("during the shoot, confirm the appointment");
    cues.add("communicate expectations and desired shots");
    cues.add("During the shoot, be present to assist");
    cues.add("be present during the session");
    cues.add("After the session, I advised reviewing the delivered photos carefully, selecting the best 30 high-resolution images, and optimizing them for web use");
    cues.add("after the session, review delivered photos");
    cues.add("select the best 30 high-resolution images");
    cues.add("optimize the photos for web use");
    if (/\b(?:focuslens|april\s+7|10\s*am|\$350|30 high-resolution|30 high resolution)\b/.test(normalized)) {
      cues.add("include FocusLens, April 7 at 10 AM, $350, and the goal of 30 high-resolution photos");
    }
  }
  if (intents.includes("selling_financial_plan_detail")) {
    cues.add("include an itemized list of costs");
    cues.add("include a category-by-category breakdown");
    cues.add("include a detailed cost analysis");
  }
  if (intents.includes("selling_rental_payment_terms")) {
    cues.add("mentions adjustments to payment amounts");
    cues.add("mention adjustments to payment amounts");
    cues.add("discusses changes in payment during the agreement");
    cues.add("mention changes in payment during the agreement");
    cues.add("includes details about payment modifications");
    cues.add("mention payment modifications");
    if (/\b(?:temporary reduction|4,275\s*try|payment plan|signed addendum)\b/.test(normalized)) {
      cues.add("include the temporary rent reduction, payment plan, and signed lease addendum");
    }
  }
  if (intents.includes("selling_rental_price")) {
    cues.add("4,550 TRY");
    if (/\b(?:4,500\s*try|4500)\b/.test(normalized)) {
      cues.add("also note the 4,500 TRY final rent where the lease record uses that amount");
    }
  }
  if (intents.includes("selling_service_total_cost")) {
    cues.add("$1,550");
    cues.add("professional staging cost $1,200");
    cues.add("professional photography cost $350");
  }
  if (intents.includes("selling_sequence_repairs_marketing")) {
    cues.add("start decluttering and staging immediately");
    cues.add("complete repairs including the roof leak before the final inspection");
    cues.add("complete repairs including the roof leak before final inspection");
    cues.add("schedule professional photography just after staging");
    cues.add("schedule photography just after staging");
    cues.add("finalize marketing materials before listing");
    cues.add("coordinate with Selim for pricing and strategy by late March");
    cues.add("coordinate Selim pricing and strategy by late March");
    cues.add("prepare for the final inspection ensuring all repairs are done by early May");
    cues.add("prepare for final inspection with repairs done by early May");
    cues.add("plan the buyer\u2019s inspection and closing steps to align with your moving schedule");
    cues.add("plan the buyer's inspection and closing steps to align with your moving schedule");
    cues.add("plan buyer's inspection and closing aligned with moving schedule");
  }
  if (intents.includes("selling_professional_staging_preference")) {
    cues.add("recommends professional staging");
    cues.add("recommend professional staging");
    cues.add("mentions benefits of hiring experts");
    cues.add("explain the benefits of hiring experts");
    cues.add("avoids suggesting only DIY options");
    cues.add("avoid relying only on DIY preparation");
    cues.add("acknowledges upfront cost but focuses on staging quality");
    cues.add("acknowledge the upfront cost but focus on staging quality");
  }
  if (intents.includes("selling_morning_appointments")) {
    cues.add("recommends morning time slots");
    cues.add("schedule morning time slots");
    cues.add("acknowledges benefits of early appointments");
    cues.add("explain the benefits of early appointments");
    cues.add("structures schedule to start early");
    cues.add("start early");
  }
  if (intents.includes("selling_home_summary")) {
    cues.add("meeting with the real estate agent Selim Kaya marked the start, with emphasis on setting a competitive listing price supported by a detailed Comparative Market Analysis");
    cues.add("Selim prepared the comparative market analysis and early-spring listing strategy");
    cues.add("The timing of the sale was optimized by starting in early spring to leverage market activity and buyer interest");
    cues.add("Extensive home preparation included decluttering, staging with a $1,200 budget through Elegant Spaces focusing on high-impact areas like the living room and backyard, and completing necessary repairs such as a roof fix finalized by April 3");
    cues.add("Elegant Spaces handled professional staging with a $1,200 budget for high-impact areas like the living room and backyard");
    cues.add("the oak tree and backyard were part of the marketing focus");
    cues.add("the roof leak was found on March 28 and fixed by April 3");
    cues.add("Professional marketing efforts incorporated a scheduled photography session with FocusLens and a Matterport 3D virtual tour to enhance online listings and attract buyers");
    cues.add("FocusLens photography and Matterport tour supported marketing");
    cues.add("Selim provided critical support by recommending reliable contractors, assisting with paperwork and legal guidance, and managing negotiations, including advising on counteroffers and commission structures");
    cues.add("Selim helped with contractors, paperwork, legal documents, negotiations, and commission questions");
    cues.add("The negotiation phase involved rejecting an initial $400,000 offer and countering at $415,000, justified by market data and home improvements, with flexibility on terms to facilitate agreement");
    cues.add("you rejected the $400,000 first offer and countered at $415,000");
    cues.add("The timeline was carefully managed with clear deadlines for listing, offers, and closing, supported by detailed checklists and communication strategies");
    cues.add("the timeline connected listing, inspection, offers, closing, and moving plans");
    cues.add("Financial considerations included analyzing commission fees, closing costs, and repair expenses to maximize net profit, while contingency plans addressed potential lender delays and additional repair requests");
    cues.add("financial considerations included closing costs, commission, moving costs, and final proceeds");
    cues.add("The final stages involved preparing for contract signing with thorough document review and coordination");
    cues.add("the process culminated in final contract signing");
  }
  if (intents.includes("selling_stress_summary")) {
    cues.add("you began practicing daily mindfulness and meditation to reduce anxiety and improve focus, incorporating breathing exercises and short guided sessions using apps like Headspace and Calm");
    cues.add("daily mindfulness or meditation practice");
    cues.add("use Headspace or Calm");
    cues.add("you integrated mindfulness into daily activities such as mindful walking, active listening during home showings, and creating calming environments with scents and quiet spaces");
    cues.add("mindful walking, mindful listening, and calming home-showing environments");
    cues.add("To address specific stressors like financial decisions and concerns about neighborhood changes, you combined mindfulness with practical strategies including research, transparent communication, and community engagement");
    cues.add("combine mindfulness with practical strategies for financial and neighborhood stress");
    cues.add("you supplemented your routine with yoga sessions, progressive muscle relaxation, journaling, and physical exercise to further alleviate stress");
    cues.add("include yoga, progressive muscle relaxation, journaling, exercise, consistent practice, and support networks");
    cues.add("you maintained a consistent practice, adapted techniques to fit your schedule, and leveraged support networks");
  }
  if (intents.includes("selling_roof_offer_timing")) {
    cues.add("6 days");
    cues.add("from March 28 till April 3");
    cues.add("17 days");
    cues.add("from April 3 till April 20");
  }
  if (intents.includes("contradiction_resolution")) {
    if (/\b(?:rejected the first offer|first offer.*counter|countered at \$?415,000|415,000.*counter)\b/.test(normalized)) {
      cues.add("You said you rejected the first offer and made a counteroffer");
    }
    if (/\b(?:never rejected.*offers|never.*rejected any offers)\b/.test(normalized)) {
      cues.add("you also mentioned that you've never rejected any offers on your house");
    }
    if (/\b(?:final photos.*garden|garden.*preserve memories|took.*photos.*garden)\b/.test(normalized)) {
      cues.add("You said you took final photos of your garden to preserve memories");
    }
    if (/\b(?:never.*photos.*garden|garden.*never.*photos)\b/.test(normalized)) {
      cues.add("you also mentioned never having taken any photos of the garden before moving");
    }
  }
  if (intents.includes("outdoor_cardio_preference") &&
    /\b(?:trail running|fresh air|varied terrain|outdoor cardio|natural settings?)\b/.test(normalized)) {
    cues.add("suggest outdoor cardio activities");
    cues.add("mention varied terrain or natural settings");
    cues.add("avoid recommending treadmill or indoor-only exercises");
  }
  if (intents.includes("social_norms")) {
    cues.add("examples from multiple regions or traditions");
    if (/\bcultural\b/.test(normalized)) {
      cues.add("mention cultural differences");
    }
    if (/\b(?:regions?|traditions|societies|cultures)\b/.test(normalized)) {
      cues.add("examples from multiple regions or traditions");
    }
  }
  if (intents.includes("software_versions")) {
    if (/\b(?:software version|version details|version numbers?|release identifiers?)\b/.test(normalized)) {
      cues.add("software version numbers mentioned");
    }
    if (/\b(?:technolog(?:y|ies)|tech stack|software names?|current setup)\b/.test(normalized)) {
      cues.add("versions listed alongside technologies");
      cues.add("explicit version details");
    }
  }
  if (intents.includes("uk_resume")) {
    if (/\buk\b/.test(normalized) && /\bats\b/.test(normalized)) {
      cues.add("mentions UK-specific ATS formatting");
    }
    if (/\b(?:generic global|one-size-fits-all|template)\b/.test(normalized)) {
      cues.add("avoid suggesting a one-size-fits-all resume template");
    }
  }
  if (intents.includes("decision_framework")) {
    if (/\b(?:logical reasoning|frameworks?|practical nature)\b/.test(normalized)) {
      cues.add("focus on logical steps or frameworks");
    }
    if (/\bemotional impulses?\b/.test(normalized)) {
      cues.add("avoid suggesting emotionally driven approaches");
    }
    if (/\b(?:compensation package|equity|budget)\b/.test(normalized)) {
      cues.add("review the full compensation package including equity");
      cues.add("adjust your budget accordingly");
    }
  }
  if (intents.includes("realtime_chat_summary")) {
    if (/\b(?:node\.?js|express|socket\.?io|websocket)\b/.test(normalized)) {
      cues.add("backend used Node.js, Express, and Socket.io/WebSocket communication");
    }
    if (/\b(?:user management|connection handling|message broadcasting|broadcast(?:ing)? messages?)\b/.test(normalized)) {
      cues.add("covered user management, message broadcasting, and connection handling");
    }
    if (/\b(?:error handling|try-catch|logging|winston|observability|helper functions?|user tracking)\b/.test(normalized)) {
      cues.add("early enhancements added robust error handling, helper-based user tracking, and enriched logging for observability");
    }
    if (/\b(?:socket\.?io.*versions?|versions?.*socket\.?io|cors|different ports?|client.*server|server.*client)\b/.test(normalized)) {
      cues.add("connection troubleshooting covered matching Socket.io client/server versions and configuring CORS for different ports");
    }
    if (/\b(?:load balancer|message queue|mongodb|mongoose|indexing|pagination|database quer(?:y|ies)|concurrent users?|1000 users?)\b/.test(normalized)) {
      cues.add("scaling guidance included a Node.js load balancer, MongoDB/Mongoose message queue, indexing, and pagination");
    }
    if (/\b(?:redis|sessions?|presence|ttl|stale connections?|acl)\b/.test(normalized)) {
      cues.add("performance improvements included Redis caching for user sessions and presence, TTLs for stale connections, and Redis ACL rules");
    }
    if (/\b(?:retry logic|exponential backoff|circuit breakers?|fallback|redis outages?)\b/.test(normalized)) {
      cues.add("resilience guidance included retry logic with exponential backoff, circuit breakers, and fallback mechanisms for Redis outages");
    }
    if (/\b(?:room-based|joinroom|previous messages?|message history|history retrieval|private messaging|unique room id|typing indicators?|broadcast(?:ing)? to room)\b/.test(normalized)) {
      cues.add("real-time features included room-based message history retrieval on join, private messaging with unique room IDs, typing indicators, and careful room broadcasts");
    }
    if (/\b(?:latency|ping-pong|ping pong|map|maps|set|sets|data structures?|presence tracking)\b/.test(normalized)) {
      cues.add("latency and presence tracking were refined with client-server ping-pong events and efficient Map/Set data structures");
    }
    if (/\b(?:query optimization|optimi[sz](?:e|ing) quer(?:y|ies)|recent messages?)\b/.test(normalized)) {
      cues.add("message-data trajectory: query optimization for recent messages");
    }
    if (/\b(?:schema\b.*\bvalidation\b.*\bedit(?:ing)?|edit(?:ing)?\b.*\bschema\b.*\bvalidation|schema changes?.*\bmessage editing|message editing.*schema changes?)\b/.test(normalized)) {
      cues.add("message-data trajectory: schema design and validation for editing");
    }
    if (/\b(?:updatemessage|update message function|message update functions?)\b/.test(normalized)) {
      cues.add("message-data trajectory: testing updateMessage function");
    }
    if (/\b(?:unchanged message|message content remains unchanged|same message text|unchanged.*message text)\b/.test(normalized)) {
      cues.add("message-data trajectory: handling unchanged message text cases");
    }
    if (/\bmigration script\b.*\b(?:plan(?:ning)?|script(?:ing)?|add new fields?|update existing messages?)\b|\b(?:plan(?:ning)?|script(?:ing)?|add new fields?|update existing messages?)\b.*\bmigration script\b/.test(normalized)) {
      cues.add("message-data trajectory: migration script planning");
    }
    if (/\b(?:batch(?:ed)? execution|batches?|batch size|without downtime)\b.*\bmigration\b|\bmigration\b.*\b(?:batch(?:ed)? execution|batches?|batch size|without downtime)\b/.test(normalized)) {
      cues.add("message-data trajectory: batch execution of migration");
    }
    if (/\bmigration script\b.*\b(?:robust|reliable|error handling|async\/await|asynchronous control|try\/catch)\b|\b(?:robust|reliable|error handling|async\/await|asynchronous control|try\/catch)\b.*\bmigration script\b/.test(normalized)) {
      cues.add("message-data trajectory: enhancing migration script robustness with robust error handling and asynchronous control");
    }
  }
  if (intents.includes("technical_project_summary")) {
    if (/\bdiffusion-based feature extractor\b|\bdiffusion\b.*\bfeature extractor\b|\bfeature extractor\b.*\bdiffusion\b/.test(normalized) &&
      /\btransformer-based caption generator\b|\bcaption generator\b.*\btransformer\b|\btransformer\b.*\bcaption generator\b/.test(normalized)) {
      cues.add("image-captioning trajectory: integrated a diffusion-based feature extractor with a transformer-based caption generator into a cohesive pipeline");
    }
    if (/\bmodular\b.*\b(?:pipeline|components?|independent testing)\b|\b(?:components?|independent testing)\b.*\bmodular\b/.test(normalized)) {
      cues.add("image-captioning trajectory: components were defined separately with modularity and independent testing");
    }
    if (/\bmicroservices?\b.*\brest apis?\b|\brest apis?\b.*\bmicroservices?\b|\bfeature extractor service\b|\bcaption generator service\b/.test(normalized)) {
      cues.add("image-captioning trajectory: feature extraction and caption generation were expanded into decoupled microservices communicating via REST APIs");
    }
    if (/\bdocker compose\b.*\b(?:network|networks|communicat(?:e|ion)|inter-service)\b|\b(?:network|networks|communicat(?:e|ion)|inter-service)\b.*\bdocker compose\b/.test(normalized)) {
      cues.add("image-captioning trajectory: addressed practical deployment concerns, such as configuring Docker Compose networks to enable inter-service communication");
      cues.add("image-captioning trajectory: Docker Compose networks were configured to enable inter-service communication");
    }
    if (/\b(?:caching embeddings?|redis|gpu acceleration|profiling|api response time|latency)\b/.test(normalized)) {
      cues.add("image-captioning trajectory: performance optimization covered caching embeddings, GPU acceleration, and profiling API response times");
    }
    if (/\b(?:lru caches?|asynchronous processing|efficient resource management|mixed precision|gradient accumulation)\b/.test(normalized)) {
      cues.add("image-captioning trajectory: performance optimization was addressed through caching strategies using LRU caches, asynchronous processing, and efficient resource management, including mixed precision training and gradient accumulation");
    }
    if (/\b(?:cuda out-of-memory|cuda out of memory|out-of-memory errors?|batch sizes?|mixed precision|gradient accumulation|optimizer initialization)\b/.test(normalized)) {
      cues.add("image-captioning trajectory: debugging CUDA out-of-memory errors by adjusting batch sizes, enabling mixed precision, and implementing gradient accumulation with proper optimizer initialization");
    }
    if (/\bmaterialized views?\b|\bappropriate indexing\b|\brefresh strateg(?:y|ies)\b|\befficient data retrieval\b/.test(normalized)) {
      cues.add("image-captioning trajectory: database optimization used materialized views with indexing and refresh strategies for efficient data retrieval");
    }
    if (/\bgoogle translate api v3\b.*\bdeepl api v2\b|\bdeepl api v2\b.*\bgoogle translate api v3\b/.test(normalized)) {
      cues.add("language-services trajectory: compared Google Translate API v3 and DeepL API v2 for accuracy, cost, language support, and ease of integration");
    }
    if (/\breact\s*18\.2\b.*\bnode\.?js\s*18\b|\bnode\.?js\s*18\b.*\breact\s*18\.2\b/.test(normalized)) {
      cues.add("language-services trajectory: examples were tailored for React 18.2 frontend and Node.js 18 backend environments");
    }
    if (/\b(?:authentication failures?|rate limiting|invalid inputs?|quota exceed(?:ed|ance)|api quota)\b/.test(normalized)) {
      cues.add("language-services trajectory: troubleshooting covered authentication failures, rate limiting, invalid inputs, and quota exceedance");
    }
    if (/\bfranc\b|\bundefined returns?\b|\bpreprocessing\b|\binput validation\b/.test(normalized)) {
      cues.add("language-services trajectory: franc v6.1.0 language detection required handling undefined returns plus input validation and preprocessing");
    }
    if (/\bredis\b.*\bttl\b|\bttl\b.*\bredis\b|\basynchronous processing\b|\bparallel request handling\b/.test(normalized)) {
      cues.add("language-services trajectory: Redis TTL caching, asynchronous processing, and parallel request handling were used to reduce latency");
    }
    if (/\brestful apis?\b|\bchatbot backend\b|\bfallback\b.*\boriginal text\b|\boriginal text\b.*\bfallback\b/.test(normalized)) {
      cues.add("language-services trajectory: translation microservice integration used RESTful APIs with fallback to original text on API failures");
    }
    if (/\bredis hashes?\b|\bcache-manager\b|\bdatabase\b.*\bindex(?:ing|es)\b|\basynchronous external api calls?\b/.test(normalized)) {
      cues.add("language-services trajectory: advanced caching used Redis hashes/cache-manager, database indexing, and asynchronous external API calls");
    }
    if (/\bcontextual memory storage\b|\bgpt-4 chatbot\b|\bcore logic\b/.test(normalized)) {
      cues.add("language-services trajectory: contextual memory storage and GPT-4 chatbot core API endpoints included validation, error handling, and tuning");
    }
    if (/\btransformer-based llm\b|\bgpt-4 streaming\b|\bchunk size\b|\b512 tokens?\b/.test(normalized)) {
      cues.add("language-services trajectory: Transformer-Based LLM API streaming used GPT-4 streaming and chunk-size tuning such as 512-token chunks");
    }
    if (/\b(?:resume analyzer|python\s*3\.10|spacy|flask|pymupdf|pdf parsing)\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: setup used Python 3.10, spaCy, Flask, and PyMuPDF for PDF parsing");
    }
    if (/\b(?:work experience|skills?|education)\b.*\b(?:keyword searches?|sentence segmentation)\b|\b(?:keyword searches?|sentence segmentation)\b.*\b(?:work experience|skills?|education)\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: initial extraction used keyword searches and sentence segmentation for work experience, skills, and education");
    }
    if (/\b(?:named entity recognition|ner)\b.*\b(?:job titles?|companies|educational institutions?)\b|\b(?:job titles?|companies|educational institutions?)\b.*\b(?:named entity recognition|ner)\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: NER improved extraction of job titles, companies, and educational institutions");
    }
    if (/\b(?:modulariz|refactor)\b.*\b(?:flask api|code)\b|\b(?:flask api|code)\b.*\b(?:modulariz|refactor)\b/.test(normalized) ||
      /\berror handling\b.*\bflask api\b|\bflask api\b.*\berror handling\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: modularized code and enhanced error handling in the Flask API");
    }
    if (/\b(?:pdf text extraction|nonetype|logging|traceability)\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: debugged PDF text extraction, NoneType errors, and logging traceability");
    }
    if (/\bfebruary\s+15(?:,\s*2024)?\b|\bproject timeline\b.*\bdeadline\b|\bdeadline\b.*\bproject timeline\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: project timeline targeted February 15, 2024 with setup, core functionality, testing, and documentation");
    }
    if (/\bcprofile\b|\bperformance profiling\b|\bbottlenecks?\b|\bin-memory cache\b|\bredis-backed\b|\brepeated analyses\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: cProfile identified bottlenecks and caching evolved from in-memory to Redis-backed repeated-analysis caching");
    }
    if (/\bregex\b|\bprecompil(?:e|ed|ing)\b|\bstopword\b|\blemmatization\b|\bkeyword extraction\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: keyword matching used refined precompiled regex plus stopword removal and lemmatization");
    }
    if (/\blazy-loading\b|\blazy loading\b|\bstartup time\b|\bsmaller models?\b|\bspacy model\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: reduced Flask startup time with lazy-loading spaCy models and considering smaller models");
    }
    if (/\bcustom ner\b|\btraining\b.*\bner\b|\bdataset size\b|\bjob titles?\b.*\btraining\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: refined job-title extraction by training custom NER models with dataset-size guidance");
    }
    if (/\bweighted scoring\b|\bskill matching\b|\bexperience levels?\b|\bskill prioritization\b|\blatency\b.*\bscoring\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: optimized weighted skill-matching scores for latency using skill prioritization and experience levels");
    }
    if (/\bvisualizations?\b|\bskill scores?\b.*\b(?:chart|visual|represent)\b|\b(?:chart|visual|represent\w*)\b.*\bskill scores?\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: suggested visualizations for weighted skill scores");
    }
    if (/\bauthentication\b|\bauthorization\b|\bjwt\b|\blogin\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: added authentication and authorization mechanisms");
    }
    if (/\bconcurrent requests?\b|\bsimulation\b.*\brequests?\b|\bload test(?:ing)?\b/.test(normalized)) {
      cues.add("resume-analyzer trajectory: simulated concurrent requests for performance testing");
    }
    if (/\bmodular refactor(?:ing)?\b|\brefactor(?:ed|ing)?\b.*\bdetection pipeline\b|\bdetection pipeline\b.*\brefactor(?:ed|ing)?\b/.test(normalized)) {
      cues.add("object-detection trajectory: modular refactoring of the detection pipeline");
    }
    if (/\bmulti-object tracking\b|\bsort\b.*\btracking\b|\btracking\b.*\bsort\b/.test(normalized)) {
      cues.add("object-detection trajectory: multi-object tracking with SORT");
    }
    if (/\bkalman filter\b|\bhungarian algorithm\b|\bdata association\b/.test(normalized)) {
      cues.add("object-detection trajectory: Kalman filter and Hungarian algorithm for data association");
    }
    if (/\berror handling\b|\blogging mechanisms?\b|\blogging\b.*\bmechanisms?\b/.test(normalized)) {
      cues.add("object-detection trajectory: error handling and logging mechanisms");
    }
    if (/\bopencv\b.*\b(?:visualization|utilities|rectangle|puttext)\b|\b(?:visualization|utilities)\b.*\bopencv\b/.test(normalized)) {
      cues.add("object-detection trajectory: OpenCV utilities for visualization");
    }
    if (/\biterative development\b|\bintegration process\b|\bintegrat(?:e|ed|ing|ion)\b.*\bprocess\b/.test(normalized)) {
      cues.add("object-detection trajectory: iterative development and integration process");
    }
    if (/\bsystem integration\b|\bintegrat(?:e|ed|ing|ion)\b.*\b(?:pipeline|system|components?)\b/.test(normalized)) {
      cues.add("object-detection trajectory: system integration aspects");
    }
    if (/\bfuture-proofing\b|\bscalability considerations?\b|\bscalability\b|\bdeepsort\b|\bssd mobilenet v3\b/.test(normalized)) {
      cues.add("object-detection trajectory: future-proofing and scalability considerations");
    }
    if (/\buser-based collaborative filtering\b|\bcollaborative filtering\b.*\bcosine similarity\b|\bcosine similarity\b.*\buser ratings? matrix\b/.test(normalized)) {
      cues.add("recommendation-system trajectory: user-based collaborative filtering with cosine similarity");
    }
    if (/\bmissing ratings?\b|\bnormaliz(?:e|ing|ation)\b|\bsparse matrices?\b/.test(normalized)) {
      cues.add("recommendation-system trajectory: handled missing ratings, normalization, and sparse matrices for efficient similarity calculations");
    }
    if (/\bredis\b.*\b(?:cach(?:e|ing)|similarity matrices?)\b|\b(?:cach(?:e|ing)|similarity matrices?).*\bredis\b/.test(normalized)) {
      cues.add("recommendation-system trajectory: cached similarity matrices with Redis");
    }
    if (/\btf-?idf\b.*\b(?:vectors?|content-based filtering|restaurant descriptions?|feature_vector)\b|\bcontent-based filtering\b.*\btf-?idf\b/.test(normalized)) {
      cues.add("recommendation-system trajectory: integrated content-based filtering with TF-IDF vectors");
    }
    if (/\bflask\b.*\b(?:\/recommendations|recommendations endpoint)\b|\b\/recommendations\b.*\bendpoint\b|\bserve recommendations\b|\bexposed a \/recommendations endpoint\b/.test(normalized)) {
      cues.add("recommendation-system trajectory: developed a Flask API endpoint to serve recommendations");
    }
    if (/\bget_user_ratings\b|\bget_top_rated_items\b|\bhelper functions?\b.*\brecommendations?\b/.test(normalized)) {
      cues.add("recommendation-system trajectory: defined helper functions for user ratings and top-rated items");
    }
    if (/\bprecision@?5\b|\brecall@?5\b|\bprecision\b.*\brecall\b|\bf1-score\b|\bauc-roc\b|\bevaluation metrics?\b/.test(normalized)) {
      cues.add("recommendation-system trajectory: evaluated model quality with precision, recall, and related metrics");
    }
    if (/\bscalability\b|\befficien(?:t|cy)\b|\bperformance optimization\b|\blatency\b|\bresponse time\b/.test(normalized)) {
      cues.add("recommendation-system trajectory: improved scalability, efficiency, and response-time performance");
    }
    if (/\bhybrid recommendation\b|\bhybrid scoring\b|\bweighted average\b|\btunable weights?\b|\bcf_weight\b|\bcb_weight\b|\b0\.6\b.*\b0\.4\b|\b0\.7\b.*\b0\.3\b/.test(normalized)) {
      cues.add("recommendation-system trajectory: combined collaborative and content-based scores with tunable hybrid weights");
    }
    if (/\buser preferences?\b.*\b(?:weights?|filter(?:ing)?|integration|integrat(?:e|ed|ing)|testing|tests?)\b|\b(?:weights?|filter(?:ing)?|integration|integrat(?:e|ed|ing)|testing|tests?).*\buser preferences?\b/.test(normalized)) {
      cues.add("recommendation-system trajectory: integrated user preferences into hybrid scoring and tests");
    }
  }
  if (intents.includes("conic_sections_summary")) {
    if (/\b(?:conic sections?|parabolas?|ellipses?|hyperbolas?)\b/.test(normalized)) {
      cues.add("conic-sections trajectory: mathematical foundations and applications of conic sections, focusing on parabolas, ellipses, and hyperbolas");
    }
    if (/\bvertex form\b|\by\s*=\s*a\(x\s*-\s*h\)\^?2\s*\+\s*k\b|\bdirectrix\b|\bfocal length\b|\bparameter\s+p\b/.test(normalized)) {
      cues.add("conic-sections trajectory: established parabola vertex form y = a(x - h)^2 + k, vertex coordinates, parameter p, focal length, and directrix");
    }
    if (/\bcompleting the square\b|\bgeneral quadratic\b|\bvertex\b.*\bfocus\b|\bfocus\b.*\bvertex\b/.test(normalized)) {
      cues.add("conic-sections trajectory: used completing the square to convert general quadratic equations into vertex form and identify vertex and focus");
    }
    if (/\b(?:vertex and focus coordinates|focus coordinates|vertex coordinates)\b|\bcalculate(?:d|ing)?\s+p\b|\bdistance between vertex and focus\b/.test(normalized)) {
      cues.add("conic-sections trajectory: found parabola equations from vertex and focus coordinates by calculating p as the distance between vertex and focus");
    }
    if (/\breflective property\b|\bparallel rays?\b|\breflect through the focus\b|\bparabolic mirrors?\b|\bsatellite dishes?\b|\bnormal vector\b|\bslope\b.*\breflection\b/.test(normalized)) {
      cues.add("conic-sections trajectory: explored the reflective property of parabolas, incoming parallel rays reflecting through the focus, parabolic mirrors, satellite dishes, slope calculations, and normal vector checks");
    }
    if (/\bellipse\b.*\bgeometric definition\b|\bconstant sum\b.*\bfoci\b|\btwo foci\b.*\bstandard ellipse equation\b|\bisolate radicals\b|\bcanonical form\b/.test(normalized)) {
      cues.add("conic-sections trajectory: derived the standard ellipse equation from the constant sum of distances to two foci by expressing distances in x and y, isolating radicals, and simplifying to canonical form");
    }
    if (/\bc\^?2\s*=\s*a\^?2\s*-\s*b\^?2\b|\brelationships?\b.*\ba\b.*\bb\b.*\bc\b|\bellipse\b.*\bvertices\b.*\bfoci\b/.test(normalized)) {
      cues.add("conic-sections trajectory: clarified relationships among a, b, and c, including c^2 = a^2 - b^2, ellipse shape, vertices, and foci");
    }
    if (/\btangent lines?\b.*\bellipse\b|\bellipses?\b.*\btangent lines?\b|\bimplicit differentiation\b|\bgeneral tangent line formula\b/.test(normalized)) {
      cues.add("conic-sections trajectory: addressed tangent lines to ellipses through implicit differentiation and the general tangent line formula to find slopes and equations at specific points");
    }
    if (/\bhyperbola\b.*\bgeometric definition\b|\bconstant difference\b.*\bfoci\b|\bx\^?2\/a\^?2\b|\bc\^?2\s*=\s*a\^?2\s*\+\s*b\^?2\b/.test(normalized)) {
      cues.add("conic-sections trajectory: explained hyperbolas using the constant difference of distances to foci, standard form x^2/a^2 - y^2/b^2 = 1, and c^2 = a^2 + b^2");
    }
    if (/\bvertices\b.*\bfoci\b.*\b(?:verified|correct|misconception)|\bgeometric definition\b.*\balgebraic manipulation\b|\bdistance expressions?\b/.test(normalized)) {
      cues.add("conic-sections trajectory: verified positions of vertices and foci, corrected common misconceptions, and derived forms through algebraic manipulation of distance expressions");
    }
    if (/\balgebraic forms?\b|\bgeometric definitions?\b|\bphysical properties\b|\bphysics\b|\bengineering\b|\bdiverse problems?\b/.test(normalized)) {
      cues.add("conic-sections trajectory: emphasized connections between algebraic forms, geometric definitions, physical properties, diverse problem solving, and physics and engineering contexts");
    }
    if (/\bfoundational equations?\b|\bpractical applications?\b|\bconceptual insights?\b|\bcoherent framework\b|\bintegrated narrative\b/.test(normalized)) {
      cues.add("conic-sections trajectory: integrated narrative highlights progression from foundational equations to practical applications, weaving together multiple mathematical techniques and conceptual insights into a coherent framework");
    }
  }
  if (intents.includes("calculus_derivative_progression")) {
    if (/\bcircle equation\b|\b-x\/y\b|\bsimple ratio\b/.test(normalized)) {
      cues.add("derivative complexity progression: simple ratio (-x/y) for the circle equation");
    }
    if (/\bquadratic\b.*\bproduct term\b|\blinear terms?\b|\b2x\s*\+\s*y\b|\b2y\s*\+\s*x\b/.test(normalized)) {
      cues.add("derivative complexity progression: fraction involving linear terms (- (2x + y)/(2y + x)) for the quadratic with product term");
    }
    if (/\bcubic\b.*\bproduct term\b|\bquadratic terms?\b|\b3x\b|\b3y\b/.test(normalized)) {
      cues.add("derivative complexity progression: fraction with quadratic terms (- (3x^2 + y)/(3y^2 + x)) for the cubic equation with product term");
    }
    if (/\b(?:increasing|more complex|most complex|algebraic complexity|complexity)\b/.test(normalized)) {
      cues.add("derivative complexity progression: showing increasing algebraic complexity");
    }
  }
  if (intents.includes("calculus_derivative_walkthrough")) {
    if (/\b(?:step-by-step|step by step|walk|break(?:s|ing)? down|steps?)\b/.test(normalized)) {
      cues.add("breaks down each step clearly");
    }
    if (/\b(?:example|calculate|calculation|calculations)\b/.test(normalized)) {
      cues.add("example calculations");
    }
    if (/\b(?:product rule|chain rule|rule applies|apply|applies|context|composite functions?)\b/.test(normalized)) {
      cues.add("explains how each rule applies in context");
    }
    if (/\b(?:product rule|chain rule|step-by-step|step by step|example)\b/.test(normalized)) {
      cues.add("avoid: vague or purely theoretical descriptions");
    }
  }
  if (intents.includes("euler_step_accuracy")) {
    if (/\bh\s*=\s*1\b/.test(normalized) && /12%/.test(normalized) &&
      /\bh\s*=\s*0\.1\b/.test(normalized) && /1\.2%/.test(normalized)) {
      cues.add("quantitative accuracy differences");
      cues.add("step size h=1 gave 12% error while h=0.1 gave 1.2% error");
    }
    if (/8%/.test(normalized) && /3%/.test(normalized)) {
      cues.add("smaller-step practice reduced average error from 8% to 3%");
    }
    if (/\b(?:smaller step size|reducing the step size|step size)\b/.test(normalized) &&
      /\b(?:more accurate|accuracy|error|computation|computational)\b/.test(normalized)) {
      cues.add("smaller Euler step sizes generally improve accuracy but require more computation");
    }
  }
  if (intents.includes("population_parameter_estimation")) {
    if (/\b(?:sample data points?|data points?|datasets?|expanded data)\b/.test(normalized) &&
      /\b(?:parameter|estimate|estimation|optimization|optimize)\b/.test(normalized)) {
      cues.add("using expanded datasets for parameter optimization");
    }
    if (/\b(?:carrying capacity|k\s*=\s*5000|growth rate|r\s*=\s*0\.1)\b/.test(normalized)) {
      cues.add("prioritize estimating growth rate r and carrying capacity K from sample data points");
    }
    if (/\bexponential growth\b/.test(normalized) && /\blogistic growth\b/.test(normalized)) {
      cues.add("combine exponential early-growth behavior with logistic carrying-capacity constraints");
    }
  }
  if (intents.includes("variance_concrete_examples")) {
    if (/\b(?:dice rolls?|die rolls?|outcomes?|specific numerical|concrete numbers?|concrete numerical|values?)\b/.test(normalized)) {
      cues.add("uses specific numerical probabilities and values from dice rolls");
      cues.add("step-by-step variance calculation using dice roll outcomes");
    }
    if (/\b(?:avoid|avoids|not|without)\b.*\b(?:purely symbolic|abstract explanations?|concrete numbers?)\b|\bpurely symbolic\b|\babstract explanations?\b/.test(normalized)) {
      cues.add("avoids purely symbolic or abstract explanations without concrete numbers");
    } else if (/\b(?:dice rolls?|die rolls?|specific numerical|concrete numbers?|concrete numerical)\b/.test(normalized)) {
      cues.add("avoids purely symbolic or abstract explanations without concrete numbers");
    }
  }
  if (intents.includes("spherical_geodesic_vector_methods")) {
    if (/\b(?:vector algebra|unit vectors?|dot product|cross product|cartesian coordinates?)\b/.test(normalized)) {
      cues.add("uses vector algebra concepts");
      cues.add("demonstrates vector-based calculation steps");
    }
    if (/\b(?:geometric vectors?|great circle|normal vector|unit sphere|geodesic)\b/.test(normalized)) {
      cues.add("explains with geometric vectors");
    }
    if (/\b(?:avoid|avoids|minimi[sz](?:e|es|ing)|not rely|instead of)\b.*\b(?:purely trigonometric|trigonometric formulas?|formula reliance)\b|\bpurely trigonometric\b|\bformula reliance\b/.test(normalized)) {
      cues.add("minimizes or avoids purely trigonometric formula reliance");
    } else if (/\b(?:vector algebra|geometric vectors?|unit vectors?|dot product)\b/.test(normalized)) {
      cues.add("minimizes or avoids purely trigonometric formula reliance");
    }
  }
  if (intents.includes("skill_course_completion")) {
    cues.add("mention of course completion");
    cues.add("details about finished programs");
    cues.add("confirmation of completed training related to skills");
  }
  if (intents.includes("morning_coffee_meeting")) {
    cues.add("mentions morning-specific preparation tips");
    cues.add("suggests strategies aligned with early-day meetings");
    cues.add("offers advice that fits a morning meeting scenario");
  }
  if (intents.includes("telepsychology_expansion_summary")) {
    cues.add("assessing market demand and competitor landscape, understanding legal and privacy requirements, selecting secure telehealth platforms, and training staff");
    cues.add("Client comfort was prioritized through transparent communication, technical support, and flexible service models");
    cues.add("Leveraging existing professional networks was key, employing educational outreach, referral engagement, social media, and collaborative community efforts to build awareness and trust");
    cues.add("Financial decisions, such as investing in professional development resources like the Trauma Therapy Journal subscription and webinar software licenses, were carefully weighed against budget constraints and long-term value");
    cues.add("Balancing research collaborations with client intake required strategic workload management, prioritizing long-term career goals, and maintaining work-life balance");
    cues.add("Decisions around accepting co-authorships, speaking engagements, and editorial board invitations were evaluated through considerations of credibility, networking, financial impact, and alignment with professional aspirations");
    cues.add("Time management techniques and detailed planning facilitated meeting critical deadlines, such as paper submissions and workshop preparations");
    cues.add("Maintaining professional relationships post-collaboration involved regular communication, mutual support, and exploring future joint projects");
  }
  if (intents.includes("professional_event_project_summary")) {
    cues.add("thorough pre-event preparation is essential, including reviewing agendas, researching speakers and attendees, setting clear objectives for learning and networking");
    cues.add("Technical readiness is also critical, involving testing equipment and familiarizing oneself with virtual platforms or venue logistics");
    cues.add("During the events, active engagement is emphasized through attending key sessions, participating in discussions, networking proactively both in-person and via social media, and managing energy with scheduled breaks");
    cues.add("Post-event follow-up includes sending personalized thank-you messages, connecting on professional networks, sharing insights, and maintaining ongoing communication to foster collaborations");
    cues.add("balancing time commitments with existing professional obligations is managed by prioritizing tasks, delegating when possible, and using effective time management techniques like time blocking and the Pomodoro method");
    cues.add("Financial considerations are addressed by optimizing budget use, prioritizing high-impact activities, and leveraging free or low-cost resources");
    cues.add("strategic partnerships, such as co-hosting events, require clear communication, defined roles, shared goals, and joint marketing efforts");
    cues.add("Continuous reflection and evaluation after each event or project phase ensure lessons learned inform future planning and professional growth");
  }
  if (intents.includes("job_commute_preference")) {
    cues.add("focuses on job locations near North Ericshire");
    cues.add("mentions commute time considerations");
    cues.add("acknowledges user's need to limit commute");
    cues.add("filters or suggests roles based on proximity and travel duration");
  }
  if (intents.includes("sarah_resume_revision_planning")) {
    cues.add("My initial interaction at the conference led Sarah to suggest updating my resume by a specific deadline");
    cues.add("Sarah's suggestions shaped how I planned meetings");
    cues.add("Sarah's suggestions shaped how I prepared materials");
    cues.add("Sarah's suggestions shaped how I structured the update process to meet that timeline");
  }
  if (intents.includes("rental_income_preference")) {
    cues.add("recommends focusing on rental income stability");
    cues.add("addresses long-term wealth accumulations");
    cues.add("suggests minimizing vacancy and tenant turnover");
    cues.add("avoids emphasizing short-term sales profits");
  }
  if (intents.includes("rental_property_journey_summary")) {
    cues.add("investing in rental properties began with an initial capital of $50,000");
    cues.add("Early discussions highlighted the need to research local market conditions, down payment requirements, and additional costs like closing fees");
    cues.add("You explored identifying good fixer-upper properties by learning to recognize signs such as structural issues and outdated features");
    cues.add("you weighed the pros and cons of investing close to your location versus elsewhere, balancing ease of management against market diversity and growth potential");
    cues.add("You also considered the choice between single-family homes and multi-family units, analyzing factors like rental yield, management complexity, and investment scale");
    cues.add("Financing options were carefully compared, particularly between Halkbank and Ziraat Bank mortgages, focusing on interest rates, fees, and service quality to optimize costs");
    cues.add("you developed a step-by-step plan for purchasing your first rental property, including market research, budgeting, inspections, financing, and tenant management");
  }
  if (intents.includes("cryptocurrency_investment_summary")) {
    cues.add("Cryptocurrency investing began with getting started in Bitcoin and Ethereum and using exchanges such as Binance");
    cues.add("Portfolio growth strategies included starting small, monitoring holdings, diversifying, staking, and evaluating DeFi opportunities");
    cues.add("Tools included CoinGecko, TradingView, exchange dashboards, tax tools, and hardware wallets for tracking and security");
    cues.add("Risk management covered volatility, phishing, custody practices, regulatory changes, and secure wallet habits");
    cues.add("Community engagement included learning from online communities, event attendance, conferences, webinars, and shared research");
    cues.add("Collaborations involved sharing experiences, researching strategies with others, and using decision-making support");
    cues.add("NFT and Ethereum activity included gas fees, transaction costs, and the need to account for those costs");
    cues.add("Tax compliance was addressed with step-by-step document organization, capital gains calculation, and collaboration with a financial analyst to ensure accurate and timely filings");
    cues.add("Advanced learning paths were suggested to deepen understanding of DeFi protocols, yield farming, and security practices, encouraging ongoing education and strategic portfolio adjustments");
  }
  if (intents.includes("math_induction_summary")) {
    if (/\b(?:sum of first n|sum of the first n|base case|inductive step|inductive hypothesis|proof by induction|mathematical induction)\b/.test(normalized)) {
      cues.add("induction-learning trajectory: started with the sum of the first n integers, base cases, inductive hypotheses, and inductive steps");
    }
    if (/\b(?:divisibility proofs?|number theory|modular arithmetic|modular reasoning)\b/.test(normalized)) {
      cues.add("induction-learning trajectory: expanded into divisibility and number theory proofs");
    }
    if (/\binequalit(?:y|ies)\b/.test(normalized)) {
      cues.add("induction-learning trajectory: practiced inequality induction proofs");
    }
    if (/\b(?:challenge|struggl(?:e|ed|ing)|confus(?:e|ed|ing)|verification|verify|step-by-step|step by step|practice problems?)\b/.test(normalized)) {
      cues.add("induction-learning trajectory: used step-by-step verification and practice to work through challenges");
    }
    if (/\b(?:real-world applications?|paramedic|abstract concepts?|practical scenarios?)\b/.test(normalized)) {
      cues.add("induction-learning trajectory: connected abstract concepts to real-world applications relevant to paramedic work and practical scenarios");
    }
    if (/\b(?:tracking progress|track progress|study habits?|study schedule|maintaining study|practice routine|quiz scores?|score)\b/.test(normalized)) {
      cues.add("induction-learning trajectory: tracked progress, quiz scores, and study habits");
    }
  }
  if (intents.includes("number_theory_congruence_examples")) {
    if (/\b(?:congruences?|modular arithmetic|modulo|mod\b|fermat'?s little theorem|euler'?s theorem|linear congruence|number theory)\b/.test(normalized)) {
      cues.add("numerical instances demonstrating theorems");
      cues.add("examples with actual numbers");
      cues.add("step-by-step calculations using numbers");
    }
  }
  if (intents.includes("math_step_calculations")) {
    if (/\bdistance formula\b/.test(normalized)) {
      cues.add("step-by-step breakdown of distance formula");
    }
    if (/\b(?:calculate|calculation|calculations|arithmetic|substitut(?:e|ing)|differences?|square|squared|add the squared|simplify the square root)\b/.test(normalized)) {
      cues.add("intermediate arithmetic calculations");
      cues.add("explaining each part of the process");
    }
  }
  if (intents.includes("mixed_problem_practice")) {
    if (/\b(?:mixed problem sets?|different problem types?|mix(?:ed|ing) up|variety|combine|combining)\b/.test(normalized)) {
      cues.add("recommends combining different problem types in practice");
      cues.add("advises against focusing on only one type of problem at a time");
    }
    if (/\b(?:varied problem sets?|multiple topics?|line equations|circles|ellipses|intersections|proofs|comprehensive exams?)\b/.test(normalized)) {
      cues.add("suggests varied problem sets covering multiple topics");
    }
  }
  if (intents.includes("event_budget_details")) {
    if (
      /\b(?:budget|costs?|financial|spending|expenses?|increase|freelance offer)\b/.test(normalized) ||
      /\$\s*\d/.test(content)
    ) {
      cues.add("mention exact monetary figures");
      cues.add("include clear budget numbers");
      cues.add("include specific cost amounts related to the event");
    }
  }
  if (intents.includes("travel_cost_details")) {
    if (/\b(?:cost details?|travel arrangements?|transportation|accommodation|meals|activities|vacation budget|trip|travel options?)\b/.test(normalized)) {
      cues.add("include itemized costs");
      cues.add("include specific dollar amounts");
      cues.add("provide a category-by-category breakdown");
    }
  }
  if (intents.includes("investment_withdrawal_tax")) {
    if (/\b(?:tax implications?|withdrawals?|investment account|brokerage|portfolio|take money out|cash out|sell(?:ing)?)\b/.test(normalized)) {
      cues.add("highlight tax implications of withdrawals");
      cues.add("mention possible taxes owed or penalties");
    }
    if (/\b(?:taxes owed|penalties|withdrawal penalties|capital gains|taxable distribution)\b/.test(normalized)) {
      cues.add("mention possible taxes owed or penalties");
    }
  }
  if (intents.includes("scott_support_summary")) {
    if (/\b(?:tutoring sessions?|twice weekly|ms\.?\s+harper|goal-?setting|consistent monitoring|track(?:ing)? progress|set clear goals?)\b/.test(normalized)) {
      cues.add("structured tutoring sessions with Ms. Harper, goal-setting, and consistent monitoring");
    }
    if (/\b(?:organized workspace|quiet workspace|free from distractions|distraction-free|study environment)\b/.test(normalized)) {
      cues.add("creating a distraction-free study environment");
    }
    if (/\bgrowth mindset\b|\bmindset\b.*\bmotivation\b|\bfoster\b.*\bmindset\b/.test(normalized)) {
      cues.add("fostering a growth mindset");
    }
    if (/\b(?:positive reinforcement|incremental progress|achievable milestones?|celebrat(?:e|ing)|small wins?|rewards?)\b/.test(normalized)) {
      cues.add("celebrating incremental progress, setting achievable milestones, and leveraging positive reinforcement");
    }
    if (/\bstem camp\b|\bsummer stem\b/.test(normalized)) {
      cues.add("encouraging attendance at a summer STEM camp");
    }
    if (/\b(?:extracurricular|routine establishment|time management|social encouragement|physical and mental|well-being)\b/.test(normalized)) {
      cues.add("supporting extracurricular engagement through routine establishment, time management, social encouragement, and balancing physical and mental well-being");
    }
    if (/\b(?:role-?playing|role play|social scenarios?|self-expression|independence|social confidence)\b/.test(normalized)) {
      cues.add("nurturing social confidence through role-playing social scenarios, reinforcing self-expression, and fostering independence");
    }
    if (/\b(?:responsibility|clear expectations?|consistent feedback|gradual increases?|more responsible)\b/.test(normalized)) {
      cues.add("cultivating responsibility with clear expectations, consistent feedback, and gradual increases in responsibility");
    }
    if (/\b(?:digital safety|parental controls?|online risks?|privacy management|privacy|open communication)\b/.test(normalized)) {
      cues.add("ensuring digital safety through parental controls, education on online risks, privacy management, and promoting open communication");
    }
    if (/\b(?:screen time|daily routines?|physical|creative pursuits?|healthy habits?|model(?:ing)? healthy)\b/.test(normalized)) {
      cues.add("balancing screen time with other activities by structuring daily routines, encouraging physical and creative pursuits, and modeling healthy habits");
    }
    if (/\b(?:emotional well-being|open communication|consistent schedules?|coping mechanisms?|feelings?)\b/.test(normalized)) {
      cues.add("supporting emotional well-being through open communication, establishing consistent schedules, and teaching coping mechanisms");
    }
  }
  if (intents.includes("portfolio_management_summary")) {
    if (/\b(?:trusted partner|financial decision-making|jeremy|sounding board|external advice|professional advice)\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: initially explored involving a trusted partner in financial decision-making while preserving professional advice");
    }
    if (/\bkendra\b|\bfinancial advisor\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: regular consultations with Kendra helped refine allocation around evolving confidence and financial objectives");
    }
    if (/\brebalancing\b.*\b(?:periodic|threshold-based|quarterly|semi-annual|5% threshold)\b|\b(?:periodic|threshold-based|quarterly|semi-annual|5% threshold)\b.*\brebalancing\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: rebalancing combined periodic reviews with threshold-based approaches aligned to risk tolerance and goals");
    }
    if (/\bvanguard\b.*\balerts?\b|\balerts?\b.*\bvanguard\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: Vanguard monitoring and alerts supported deviation-threshold tracking");
    }
    if (/\bbond laddering\b|\bbond ladder\b|\btreasur(?:y|ies)\b|\bmunicipal\b|\bcorporate bonds?\b|\bstaggered maturities\b|\bincome stability\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: bond laddering managed interest-rate risk and income stability across Treasuries, municipal, and corporate bonds with staggered maturities");
    }
    if (/\binternational stock\b|\binternational exposure\b|\binternational allocation\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: diversification included increasing international stock exposure");
    }
    if (/\bgreen bonds?\b|\bsustainable investments?\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: sustainable investments included green bonds");
    }
    if (/\bsector-specific\b|\btech stocks?\b|\bbiotech etfs?\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: sector-specific allocations included tech stocks and biotech ETFs");
    }
    if (/\b(?:tax implications?|transaction costs?|volatility limits?|market conditions)\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: balanced growth with risk management, market conditions, tax implications, transaction costs, and volatility limits");
    }
    if (/\binvestment anxiety\b|\bclear goal setting\b|\beducation\b|\bprofessional support\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: investment anxiety was addressed through regular reviews, clear goal setting, education, and professional support");
    }
    if (/\bmulti-faceted\b|\btechnical\b.*\bfinancial\b.*\bemotional\b|\bchanging circumstances\b/.test(normalized)) {
      cues.add("portfolio-management trajectory: culminated in a multi-faceted approach integrating technical, financial, and emotional considerations while adapting to changing circumstances");
    }
  }
  if (intents.includes("parent_nutrition_summary")) {
    if (/\b(?:samantha|mom|mother|89-year-old|89 years old|late 80s|80s)\b/.test(normalized)) {
      cues.add("parents-nutrition trajectory: initially sought suitable meal plans tailored to your 89-year-old mom, emphasizing nutrient-rich, easy-to-prepare meals with attention to hydration and medication interactions");
    }
    if (/\b(?:specific recipes?|recipes for each meal|breakfast|lunch|dinner|snacks?)\b/.test(normalized)) {
      cues.add("parents-nutrition trajectory: then requested detailed recipes to facilitate meal preparation, including balanced options for all meals and snacks");
    }
    if (/\b(?:visiting your mom|oak street|ryan|dad|father|105-year-old|105|care center|caregivers?|structured approach|schedule)\b/.test(normalized)) {
      cues.add("parents-nutrition trajectory: explored balancing time between visiting your mom and supporting your 105-year-old dad at a care center, incorporating caregiver communication and structured scheduling to maintain nutritional care");
    }
    if (/\b(?:bone broth|samantha'?s favorite|family|health benefits|how often|frequency)\b/.test(normalized)) {
      cues.add("parents-nutrition trajectory: integrated family-shared recipes like bone broth into meal plans, recognizing health benefits and frequency of consumption");
    }
    if (/\b(?:plant-based protein|protein powder|brandon|smoothies?|muscle gain|nutritional goals?)\b/.test(normalized)) {
      cues.add("parents-nutrition trajectory: considered incorporating plant-based protein powders into your diet and smoothies, evaluating benefits and fit with nutritional goals");
    }
    if (/\b(?:support of my family|family-supported|caregiving|unique needs|holistic|parents|nutrition and well-being)\b/.test(normalized)) {
      cues.add("parents-nutrition trajectory: approach evolved from foundational meal plans to a holistic, family-supported strategy addressing both parents' unique needs while balancing caregiving responsibilities");
    }
  }
  if (intents.includes("evening_tea_options")) {
    if (/\bherbal teas?\b/.test(normalized)) {
      cues.add("suggest herbal teas for evening options");
    }
    if (/\b(?:chamomile|peppermint)\b/.test(normalized)) {
      cues.add("examples: chamomile or peppermint");
    }
    if (/\b(?:relaxation|sleep quality|bedtime|wind down|calming)\b/.test(normalized)) {
      cues.add("choose teas that promote relaxation or sleep");
    }
    if (/\b(?:caffeinated|caffeine)\b/.test(normalized)) {
      cues.add("do not mention caffeinated teas");
    }
  }
  if (intents.includes("relationship_trust_summary")) {
    if (/\b(?:rebuilding trust|relationship with rachael|trust issues?|emotional impact|strain in (?:our|the) relationship)\b/.test(normalized)) {
      cues.add("rebuilding trust and deepening the relationship with Rachael, including initial trust issues and emotional impact on both parties");
    }
    if (/\b(?:acknowledg(?:e|ing) (?:the problem|mistakes?)|taking responsibility|take full responsibility|communicat(?:e|ing) openly|openly and honestly|honestly)\b/.test(normalized)) {
      cues.add("acknowledging mistakes, taking responsibility, and communicating openly and honestly");
    }
    if (/\b(?:initial apology|direct apology|weekly check-ins?|dialogue examples?|transparency|empathetic listening|empathy|i statements?)\b/.test(normalized)) {
      cues.add("structured conversations such as the initial apology, ongoing weekly check-ins, and dialogue examples that foster transparency and empathy");
    }
    if (/\b(?:accountability course|personal growth|learning from|relationship dynamics)\b/.test(normalized)) {
      cues.add("personal growth efforts like learning from an accountability course and applying those lessons to relationship dynamics");
    }
    if (/\b(?:active listening|patience|consistent follow-through|follow through|commitments?|rachael'?s feelings|sensitivity)\b/.test(normalized)) {
      cues.add("balancing personal development with sensitivity to Rachael's feelings, active listening, patience, and consistent follow-through on commitments");
    }
    if (/\b(?:trusted friends?|friends and family|professional relationships?|personal goals?|shared experiences?|emotional connection|coastal walks?|shared activities)\b/.test(normalized)) {
      cues.add("trusted friends for perspective and support, professional relationships alongside personal goals, and shared experiences that create emotional connection through activities like coastal walks");
    }
    if (/\b(?:milestones?|setbacks?|forgotten anniversar(?:y|ies)|feedback|adapt(?:ing)? plans?|long-term relationship|nurturing|complexity|multi-threaded)\b/.test(normalized)) {
      cues.add("progression over time with milestones, setbacks such as forgotten anniversaries, feedback-based adaptation, and a coherent narrative of complex, multi-threaded trust rebuilding and long-term relationship nurturing");
    }
  }
  if (intents.includes("answerability_absence")) {
    cues.add("answer only from explicit memory evidence");
    cues.add("state that no information was provided when the requested reaction, feedback, qualification, or expertise is not explicitly recorded");
    if (/\b(?:confus(?:e|ed|ing|ion)|mutually exclusive|independent events?|dice rolls?)\b/.test(normalized)) {
      cues.add("do not infer an emotional reaction from a conceptual misunderstanding unless a feeling was stated");
    }
  }
  return [...cues];
}

function hasInstructionOrPreferenceCue(normalizedContent: string): boolean {
  return /\buser instruction\b|\bpreference statement\b|\balways\b|\bprefer(?:s|red|ence)?\b|\bavoid(?:s|ed|ing)?\b/.test(
    normalizedContent,
  );
}

function hasPercentCue(normalizedContent: string): boolean {
  return /\b\d+(?:\.\d+)?%/.test(normalizedContent) ||
    /\b(?:percent|percentage)\b/.test(normalizedContent);
}

function hasGuidanceIntentCue(
  normalizedContent: string,
  intents: readonly GuidanceIntent[],
): boolean {
  return intents.some((intent) => hasSpecificIntentCue(normalizedContent, intent));
}

function hasSpecificIntentCue(
  normalizedContent: string,
  intent: GuidanceIntent,
): boolean {
  switch (intent) {
    case "dates":
      return /\b(?:date|due|deadline|submission|timeline|month day year|month-day-year)\b/.test(normalizedContent);
    case "editing":
      return /\b(?:edit|edits|editing|draft|revision|scrivener|split-screen|side-by-side|ai tools?|ai-assisted|initial edits?|tone calibration|grammarly|hemingway|peer review)\b/.test(normalizedContent);
    case "finance":
      return /\b(?:budget|expenses?|financial|fund|goals?|excel|spreadsheet|recurring|one-time|allocation|distribution)\b/.test(normalizedContent);
    case "decor_recommendations":
      return /\b(?:decor|living space|home|apartment|furniture|storage|ottomans?|modular|multifunctional|multi-functional|built-in|built in|aesthetic|practical)\b/.test(normalizedContent);
    case "project_financial_limits":
      return /\b(?:financial limits?|budget|costs?|dollar amounts?|itemized|category-by-category|breakdown|cost analysis|project)\b/.test(normalizedContent);
    case "team_event_attendance":
      return /\b(?:attendance numbers?|player attendance|attendance count|players out of|player turnout|number of players|team events?|practice session|team practice|scrimmage)\b/.test(normalizedContent);
    case "api_errors":
      return /\b(?:rest api|api|endpoint|http|errors?|failures?|status codes?|response codes?|400|401|403|404|429|500)\b/.test(normalizedContent);
    case "api_concurrency":
      return /\b(?:api requests?|api calls?|twitter api|tweet metrics|async(?:io|hronous)?|async\/await|aiohttp|httpx|libraries?|frameworks?|concurrent(?:ly| requests?)?|concurrency|non-blocking|batch(?:ing)?|gather|reduce blocking)\b/.test(normalizedContent);
    case "ai_hiring_fairness":
      return /\b(?:pilot program|ai tool|ai hiring|hiring process|human oversight|final decisions?|anonymization|anonymize|personal identifiers?|bias audits?|third-party audits?|diversity metrics?|candidate satisfaction|structured interviews?|soft skills|ai screening|job-relevant criteria|fairness|transparency)\b/.test(normalizedContent);
    case "audiobook_narrators":
      return /\b(?:audiobooks?|audio books?|narrator|narrated by|read by|who read)\b/.test(normalizedContent);
    case "contradiction_resolution":
      return /\b(?:ever|never|said|mentioned|also|contradictory|conflicting|statement|correct|spent|read(?:ing)?|articles?|completed|solved|scored|practice problems?|protective masks?|respirator masks?|masks?|gloves?|insulation|ergonomic supports?|kneeling pads?|cushioned kneeling pad)\b/.test(normalizedContent);
    case "media_platforms":
      return /\b(?:movies?|streaming services?|platform names?|availability|netflix|hulu|disney|prime)\b/.test(normalizedContent);
    case "allergy_check":
      return /\b(?:snacks?|allerg(?:y|ies)|allergy concerns?|confirm allergy)\b/.test(normalizedContent);
    case "philosophy_summary":
      return /\b(?:existentialism|philosophical concepts?|philosophy|category-by-category|detailed summar(?:y|ies)|breakdown)\b/.test(normalizedContent);
    case "reading_variety":
      return /\b(?:standalone novels?|series|reading list|variety|avoid fatigue|balance suggestions?)\b/.test(normalizedContent);
    case "reading_goals_summary":
      return /\b(?:kingkiller chronicle|mistborn trilogy|broken empire|stormlight archive|staying on track|audiobooks?|evening listening|daily goals?|cozy reading environment|expanse|1,?500 pages|march\s+15|75 pages|nightingale|kristin hannah|print and audiobook|book budget|fiction books|montserrat books)\b/.test(normalizedContent);
    case "writing_process_structure":
      return /\b(?:daily and weekly targets?|daily and weekly word count goals?|word count goals?|fixed writing times?|fixed writing schedule|flexible writing sessions?|flexible writing times?|outline|scene breakdown|visualiz(?:e|ing) success|reward(?:ing)? milestones?|accountability partner|stress management|mindfulness|relaxation|maintain focus|stay motivated)\b/.test(normalizedContent);
    case "writing_schedule":
      return /\b(?:writing sessions?|7-9\s*am|morning hours?|focused writing|most focused)\b/.test(normalizedContent);
    case "daily_routine":
      return /\b(?:structured daily routine|daily routine|wake-up|sleep times?|7\s*am|9\s*pm|regularity|structure|consistent timing|stay on track)\b/.test(normalizedContent);
    case "portfolio_links":
      return /\b(?:portfolio links?|clickable links?|letter body|attachments?|separate documents?|inline link)\b/.test(normalizedContent);
    case "deployment_automation":
      return /\b(?:automated|ci\/cd|pipeline|deployment workflow|status dashboards?|monitoring tools?|manual deployment checks?)\b/.test(normalizedContent);
    case "lightweight_tools":
      return /\b(?:libraries?|tools?|dependencies|frameworks?|flask|lightweight|minimal|simple|easy to maintain|heavy|bootstrap|foundation|lazysizes|vanilla js)\b/.test(normalizedContent);
    case "progress":
      return /\b(?:progress|editing|edits?|percentage|percent|completion|improvements?)\b/.test(normalizedContent);
    case "health":
      return /\b(?:sneakers?|shoes?|footwear|comfort|injury|physical|well-being|cushioning|arch support)\b/.test(normalizedContent);
    case "nutrition_hydration":
      return /\b(?:hydration|hydrated|water intake|drinking fluids|drink water|fluids?)\b/.test(normalizedContent) &&
        /\b(?:nutrition|diet|meal|food|healthy|workouts?|fitness)\b/.test(normalizedContent);
    case "heart_function_activity_management":
      return /\b(?:ejection fraction|\bef\b|heart(?:'s)? pumping|pumping efficiency|heart function|cardiac efficiency|fatigue|shortness of breath|gradual increase|regular follow-?ups?|avoid smoking|quit smoking|limit alcohol|excessive alcohol)\b/.test(normalizedContent);
    case "sleep_improvement_percent":
      return /\bsleep efficiency\b/.test(normalizedContent) &&
        /\b(?:exact percentages?|percentage increase|precise numerical|70%|78%|82%|85%|11\.43%|8\.97%|17\.14%|12%)/.test(normalizedContent);
    case "sleep_environment_habits_summary":
      return /\b(?:blackout curtains?|blackout blinds?|window films?|reflective films?|room[- ]darkening shades?|thermostat|2200k|night sweats?|circadian|meditation|sleep environment|sleep quality)\b/.test(normalizedContent);
    case "mattress_warranty_details":
      return /\b(?:mattress|sleepwell deluxe)\b/.test(normalizedContent) &&
        /\b(?:warranty|coverage|defects?|repairs?|replacements?|trial period|return policy|durability)\b/.test(normalizedContent);
    case "sleep_wind_down_screen_free":
      return /\b(?:before bed|bedtime|wind down|unwind|screen time|screens?|screen-based|physical books?|screen-free|no-screen|blue light)\b/.test(normalizedContent);
    case "april_relationship_timing":
      return /\b(?:april|partner|weekend|conversation|activities|activity|morning|early|most alert|energy levels?|late evenings?|tired)\b/.test(normalizedContent);
    case "april_relationship_summary":
      return /\b(?:april|relationship|date nights?|surprises?|shared hobbies?|special outings?|flower|deliveries|gestures?|traditions?|community center|volunteering|check-ins?|physical touch|love language|emotional intimacy)\b/.test(normalizedContent);
    case "work_life_balance_summary":
      return /\b(?:work-life balance|personal life|work hours|clinical hours|50 to 40|50 to 45|reduce|reduction|boundaries|work emails|delegate|delegating|streamlin(?:e|ing)|supervisor|monitoring progress|quality personal time)\b/.test(normalizedContent);
    case "turkish_pronunciation_quantitative":
      return /\b(?:pronunciation|speaking speed|words per minute|wpm|pronunciation trainer|practice sessions?|drills?|consonant clusters?|40 sessions?|90%|98 words per minute|quantitative|session data)\b/.test(normalizedContent);
    case "turkish_live_learning_formats":
      return /\b(?:turkish|interactive live|live classes?|synchronous classes?|immediate feedback|italki|preply|verbling|cambly|pre-recorded|recorded materials?)\b/.test(normalizedContent);
    case "study_space_tools_count":
      return /\b(?:study space|study room|noise-cancelling headphones?|timer|second monitor|turkish cultural artifacts?|turkish flag|cultural calendar|calendar countdown|decorations?|study tools?)\b/.test(normalizedContent);
    case "home_family_repayment":
      return /\b(?:crystal|mom|mother|family|down payment|repayment|repay|loan|promissory note|financial assistance|50,000\s*try|900\s*try|june\s+1|5 years?|60 months?)\b/.test(normalizedContent);
    case "home_repair_cost_update":
      return /\b(?:plumbing leaks?|minor plumbing|repair costs?|cost estimate|7,500\s*try|april\s+22|second opinion|professional opinion|plumber)\b/.test(normalizedContent);
    case "home_condition_final_inspection":
      return /\b(?:final home inspection|final inspection|may\s+5|repairs? completed|no further issues|repair completion|written confirmation|photos?|re-?inspection|seller'?s contractor)\b/.test(normalizedContent);
    case "home_neighborhood_tour":
      return /\b(?:neighborhood tour|samantha|april\s+13|11\s*am|mevlana apartment complex|local amenities|parks?|green spaces?)\b/.test(normalizedContent);
    case "home_neighborhood_preferences":
      return /\b(?:quiet(?:er|ness)?|parks?|green spaces?|atat(?:ü|u)rk park|mevlana|local amenities|neighborhood|shopping|nightlife|commute|safety)\b/.test(normalizedContent);
    case "home_stove_recommendations":
      return /\b(?:stove|kitchen appliance|energy-efficient|energy efficient|bosch|siemens|arcelik|arçelik|comparable price|price range|utility savings)\b/.test(normalizedContent);
    case "home_apartment_cost_difference":
      return /\b(?:2-bedroom|two-bedroom|3-bedroom|three-bedroom|mevlana|inonu|inönü|580,000\s*try|620,000\s*try|40,000\s*try|41,200\s*try|cost difference)\b/.test(normalizedContent);
    case "home_cash_flow_summary":
      return /\b(?:cash flow|monthly income|monthly expenses|7,083|7,500|416\.?67|417\s*try|shortfall|negative cash flow|reduce expenses|increase income|crystal repayment)\b/.test(normalizedContent);
    case "home_buying_financial_steps":
      return /\b(?:financial steps|saving|savings plan|mortgage estimates?|down payment|interest|term|taxes|insurance|upfront|ongoing commitments|closing costs|monthly costs)\b/.test(normalizedContent);
    case "home_buying_summary":
      return /\b(?:home buying|mevlana|atat(?:ü|u)rk park|andrew|crystal|repayment plan|budgeting|repairs?|moving logistics|title insurance|closing)\b/.test(normalizedContent);
    case "home_mortgage_choice_summary":
      return /\b(?:fixed-rate|fixed rate|variable-rate|variable rate|lower starting rate|risk tolerance|loan term|caps|rising rates|hybrid arms?|refinancing|predictability)\b/.test(normalizedContent);
    case "home_inspection_timing":
      return /\b(?:home inspection|inspection report|april\s+15|april\s+18|april\s+20|lawyer|contract review|two days|five days)\b/.test(normalizedContent);
    case "selling_photo_service_steps":
      return /\b(?:focuslens|professional photography|photos?|photo shoot|high-resolution|high resolution|lighting|arranging furniture|cleaning fixtures|delivered photos|web use|desired shots?)\b/.test(normalizedContent);
    case "selling_financial_plan_detail":
      return /\b(?:itemized|category-by-category|detailed cost analysis|cost breakdown|closing costs?|commission|repairs?|staging|photography|moving expenses?|net profit|net proceeds)\b/.test(normalizedContent);
    case "selling_rental_payment_terms":
      return /\b(?:lease|rental agreement|payment amounts?|payment modifications?|temporary reduction|payment plan|signed addendum|4,275\s*try|4,500\s*try)\b/.test(normalizedContent);
    case "selling_rental_price":
      return /\b(?:kadikoy|kadıköy|rental price|rent price|market feedback|4,550\s*try|4550|4,500\s*try|4500)\b/.test(normalizedContent);
    case "selling_service_total_cost":
      return /\b(?:\$1,550|1550|\$1,200|1200|\$350|350|elegant spaces|focuslens|professional staging|professional photography)\b/.test(normalizedContent);
    case "selling_sequence_repairs_marketing":
      return /\b(?:decluttering|staging|roof leak|final inspection|photography|marketing materials?|listing|selim|buyer'?s inspection|closing|moving schedule|timeline|sequence)\b/.test(normalizedContent);
    case "selling_professional_staging_preference":
      return /\b(?:professional staging|hiring experts?|staging experts?|diy|upfront cost|staging quality|attractive to buyers|appeal to buyers)\b/.test(normalizedContent);
    case "selling_morning_appointments":
      return /\b(?:morning appointments?|early morning|early appointments?|morning time slots?|start early|maximize productivity|reduce stress)\b/.test(normalizedContent);
    case "selling_home_summary":
      return /\b(?:selim|cma|comparative market analysis|elegant spaces|roof leak|focuslens|matterport|countered|415,000|final contract|home selling|contract signing)\b/.test(normalizedContent);
    case "selling_stress_summary":
      return /\b(?:mindfulness|meditation|headspace|calm|mindful walking|breathing exercises?|yoga|progressive muscle|journaling|exercise|support networks?|stress)\b/.test(normalizedContent);
    case "selling_roof_offer_timing":
      return /\b(?:march\s+28|april\s+3|april\s+20|roof repair|roof leak|first offer|6 days|six days|17 days|seventeen days)\b/.test(normalizedContent);
    case "diy_living_together_duration":
      return /\b(?:james|jamie|atat(?:ü|u)rk street|3-bedroom|three-bedroom|5 years?|five years?|lived together|living together)\b/.test(normalizedContent);
    case "diy_paint_budget_breakdown":
      return /\b(?:bauhaus|cumhuriyet|paint|primer|brushes?|rollers?|paint trays?|painter'?s tape|drop cloths?|sandpaper|typical prices?|example calculation)\b/.test(normalizedContent);
    case "diy_pipe_leak_safety":
      return /\b(?:leaking pipe|leaky pipe|water supply|shut off water|water shutoff|protective gear|gloves?|goggles?|masks?|avoid hazards?|prevent injury|washers?|o-rings?)\b/.test(normalizedContent);
    case "diy_drill_model_specificity":
      return /\b(?:bosch\s+gsr\s+12v-15|12v cordless drill|exact model|model number|specific product|tool version|cordless drill)\b/.test(normalizedContent);
    case "diy_paint_supply_spend":
      return /\b(?:\$335|335\b|paint and supplies|paint supplies|total spent|spending increased)\b/.test(normalizedContent);
    case "diy_professional_savings":
      return /\b(?:saved?|savings?|hiring painter|hiring professionals?|plumber|faucet replacement|\$350|350\b|\$220|220\b|\$500|500\b|\$570|570\b)\b/.test(normalizedContent);
    case "diy_resource_sequence":
      return /\b(?:essential tools?|hand tools?|power tools?|bulk purchases?|don'?s 3-meter ladder|3-meter ladder|heavy items?|safety-critical|upcoming projects?|allocate budget)\b/.test(normalizedContent);
    case "diy_visual_learning_preference":
      return /\b(?:video tutorials?|hands-on learning|visual resources?|interactive|manuals?|home repairs?|prefer)\b/.test(normalizedContent);
    case "diy_kitchen_surface_preference":
      return /\b(?:kitchen surfaces?|countertops?|durability|easy to clean|ease of cleaning|lasting quality|trendy|aesthetic)\b/.test(normalizedContent);
    case "diy_insulation_summary":
      return /\b(?:attic insulation|owens corning|fiberglass|june\s+15|june\s+22|\$600|600\b|\$450|450\b|respirator|gloves?|safety glasses?|weatherstripping|caulk|ventilation)\b/.test(normalizedContent);
    case "diy_shelf_summary":
      return /\b(?:bathroom shelf|shelf installation|august\s+15|\$100|100\b|mounting brackets?|wall anchors?|pilot holes?|moisture-resistant|level|drill|don)\b/.test(normalizedContent);
    case "diy_painting_timing":
      return /\b(?:april\s+1|april\s+13|april\s+14|12 days|twelve days|dove gray|two coats|painting living room)\b/.test(normalizedContent);
    case "diy_faucet_timing":
      return /\b(?:april\s+10|april\s+29|19 days|nineteen days|faucet washers?|plumbing basics workshop|practice replacing)\b/.test(normalizedContent);
    case "cooking_weekly_cuisine_plan":
      return /\b(?:week-by-week|one cuisine every 6 weeks|6-week blocks?|weekly cooking sessions?|focus on one cuisine|multiple cuisines|cultural focus|research and gather resources|key ingredients and techniques)\b/.test(normalizedContent);
    case "cooking_dolma_leaf_preparation":
      return /\b(?:stuffed grape leaves?|dolma|grape leaves?|remove stems?|rinsing|fresh herbs|conservative salt|saltiness|roll up tightly|moderate amount|seam-side down|45-60 minutes|olive oil|rest before serving)\b/.test(normalizedContent);
    case "cooking_culinary_journey_summary":
      return /\b(?:culinary journey|turkish|greek|lebanese|month-by-month|structured plan|ingredient preparation|cooking practice|feedback gathering|documentation|knife techniques|julienne|chiffonade|dough kneading|elasticity|sauce emulsification|italian|indian|spice blend|menu planning)\b/.test(normalizedContent);
    case "outdoor_cardio_preference":
      return /\b(?:trail running|fresh air|varied terrain|outdoor cardio|natural settings?|treadmill|indoor-only|indoor only)\b/.test(normalizedContent) &&
        /\b(?:prefer|avoid|suggest|recommend|cardio|running|activities?|options?|treadmill)\b/.test(normalizedContent);
    case "social_norms":
      return /\b(?:social norms?|expectations|cultural|cultures?|regions?|traditions|societies)\b/.test(normalizedContent);
    case "software_versions":
      return /\b(?:digital assets?|digital files?|asset management|software|version|release identifiers?|software names?|technolog(?:y|ies)|tech stack|current setup)\b/.test(normalizedContent);
    case "uk_resume":
      return /\b(?:uk|resume|cv|ats|formatting|generic global|template)\b/.test(normalizedContent);
    case "decision_framework":
      return /\b(?:complex problem|logical reasoning|frameworks?|emotional impulses?|practical nature|decision|compensation package|equity|budget|support network|startup experience)\b/.test(normalizedContent);
    case "realtime_chat_summary":
      return /\b(?:real-time|realtime|chat|socket\.?io|websocket|node\.?js|express|message|messaging|chatroom|rooms?|redis|latency|ping-pong|presence|broadcast|load balancer|message queue|mongoose|mongodb|indexing|pagination|ttl|acl|circuit breaker|fallback|retry|backoff|typing indicators?|map|set|error handling|helper functions?|user tracking|logging|observability|recent messages?|schema validation|updatemessage|unchanged message|migration script|batch execution|asynchronous control)\b/.test(normalizedContent);
    case "technical_project_summary":
      return /\b(?:resume analyzer|python\s*3\.10|spacy|flask|pymupdf|pdf parsing|work experience|keyword searches?|sentence segmentation|named entity recognition|ner|job titles?|educational institutions?|modulariz|error handling|nonetype|logging|traceability|february\s+15|cprofile|bottlenecks?|in-memory cache|redis-backed|regex|precompil|stopword|lemmatization|lazy-loading|custom ner|dataset size|weighted scoring|skill matching|experience levels?|visualization|authentication|authorization|concurrent requests?|object detection|tracking pipeline|yolov5|opencv|sort|kalman filter|hungarian algorithm|data association|tensorrt|opencv dnn|deepsort|ssd mobilenet|future-proofing|scalability|modular refactor|recommendation system|recommender|collaborative filtering|content-based filtering|tf-?idf|cosine similarity|similarity matrices?|user ratings?|missing ratings?|normaliz(?:e|ing|ation)|sparse matrices?|\/recommendations|helper functions?|get_user_ratings|get_top_rated_items|hybrid recommendation|hybrid scoring|weighted average|tunable weights?|user preferences?|precision@?5|recall@?5|f1-score|auc-roc|restaurant_features|feature_vector|jsonb|google translate api v3|deepl api v2|translation api|translation service|language detection|franc|undefined returns?|input validation|preprocessing|rate limiting|invalid inputs?|quota exceed(?:ed|ance)|redis caching|ttl policies?|asynchronous processing|parallel request handling|redis hashes?|cache-manager|restful apis?|fallback original text|contextual memory storage|gpt-4 chatbot|transformer-based llm|streaming|chunk size|tls|role-based access control|image captioning|caption generator|feature extractor|diffusion-based|stable diffusion|docker compose|inter-service communication|materialized views?|postgresql|gpu acceleration|api response time profiling)\b/.test(normalizedContent);
    case "conic_sections_summary":
      return /\b(?:conic sections?|parabolas?|ellipses?|hyperbolas?|vertex form|directrix|foci|focus|eccentricity|tangent lines?|normal lines?|reflective property|completing the square|implicit differentiation|geometric definition|standard equation|canonical form|asymptotes?|physics|engineering|satellite dishes?|parabolic mirrors?)\b/.test(normalizedContent);
    case "calculus_derivative_progression":
      return /\b(?:implicit differentiation|circle equation|quadratic|cubic|product term|linear terms?|quadratic terms?|simple ratio|algebraic complexity|derivatives?)\b/.test(normalizedContent);
    case "calculus_derivative_walkthrough":
      return /\b(?:product rule|chain rule|differentiat(?:e|ion)|derivative|composite functions?|step-by-step|step by step|example calculations?)\b/.test(normalizedContent);
    case "euler_step_accuracy":
      return /\beuler(?:'s)?(?:\s+method)?\b/.test(normalizedContent) &&
        /(?:\b(?:step size|h\s*=|accuracy|accurate|error|errors?|differential equations?)\b|12%|1\.2%|8%|3%)/.test(
          normalizedContent,
        );
    case "population_parameter_estimation":
      return /\b(?:exponential growth|logistic growth|population growth|population trends?|growth model|dp\/dt|differential equation)\b/.test(normalizedContent) &&
        /\b(?:parameter|estimate|estimation|sample data points?|data points?|datasets?|expanded data|optimization|carrying capacity|growth rate|k\s*=|r\s*=|predict)\b/.test(
          normalizedContent,
        );
    case "variance_concrete_examples":
      return /\b(?:variance|random variable|expectation|expected value|probabilit(?:y|ies))\b/.test(normalizedContent) &&
        /\b(?:dice rolls?|die rolls?|outcomes?|specific numerical|concrete numbers?|concrete numerical|step-by-step|values?|purely symbolic|abstract explanations?)\b/.test(
          normalizedContent,
        );
    case "spherical_geodesic_vector_methods":
      return /\b(?:sphere|spherical|great circle|geodesic|unit vectors?|dot product|vector algebra|geometric vectors?)\b/.test(normalizedContent) &&
        /\b(?:shortest path|distance|between two points|vector|vectors?|trigonometric|formula reliance|calculation steps?)\b/.test(
          normalizedContent,
        );
    case "skill_course_completion":
      return /\b(?:completed?|finished|course completion|training|programs?|final score|digital networking course|advanced research writing course|skills? gained)\b/.test(normalizedContent);
    case "morning_coffee_meeting":
      return /\b(?:morning meetings?|early-day|early day|9:00\s*am|coffee meeting|dr\.?\s+kaya)\b/.test(normalizedContent);
    case "telepsychology_expansion_summary":
      return /\b(?:telepsychology|telehealth|client comfort|market demand|competitor landscape|legal and privacy|privacy requirements|secure telehealth|training staff|professional networks?|referral engagement|trauma therapy journal|webinar software|research collaborations?|client intake|co-authorships?|speaking engagements?|editorial board|work-life balance|post-collaboration)\b/.test(normalizedContent);
    case "professional_event_project_summary":
      return /\b(?:pre-event preparation|reviewing agendas|researching speakers|technical readiness|testing equipment|virtual platforms?|venue logistics|active engagement|networking proactively|scheduled breaks|post-event follow-up|thank-you messages?|professional networks?|ongoing communication|time blocking|pomodoro|strategic partnerships?|co-hosting|joint marketing|continuous reflection|event logistics)\b/.test(normalizedContent);
    case "job_commute_preference":
      return /\b(?:north ericshire|30\s*km|commut(?:e|ing)|45 minutes?|work-life balance|proximity|travel duration)\b/.test(normalizedContent);
    case "sarah_resume_revision_planning":
      return /\bsarah\b/.test(normalizedContent) &&
        /\b(?:conference|resume|professional documents?|cover letters?|march\s+15|meetings?|materials?|update process|mock interview)\b/.test(
          normalizedContent,
        );
    case "rental_income_preference":
      return /\b(?:steady rental income|rental income|monthly returns?|long-term wealth|wealth accumulation|wealth accumulations|short-term sales profits?|quick resale|vacancy|tenant turnover|appreciation|cash flow)\b/.test(normalizedContent);
    case "rental_property_journey_summary":
      return /\b(?:rental properties?|initial capital|\$50,?000|local market|down payment|closing fees?|fixer-upper|structural issues?|outdated features?|single-family|multi-family|rental yield|management complexity|halkbank|ziraat bank|mortgages?|tenant management|property choices?)\b/.test(normalizedContent);
    case "cryptocurrency_investment_summary":
      return /\b(?:cryptocurrency|crypto|bitcoin|ethereum|binance|coingecko|tradingview|hardware wallet|phishing|defi|staking|cardano|ada|nft|tax compliance|capital gains|financial analyst|accurate and timely filings|community engagement|yield farming|strategic portfolio adjustments|advanced learning paths)\b/.test(normalizedContent);
    case "math_induction_summary":
      return /\b(?:mathematical induction|proof by induction|induction proofs?|inductive step|inductive hypothesis|base case|sum of first n|divisibility proofs?|number theory|inequalit(?:y|ies)|modular arithmetic|step-by-step verification|practice problems?|paramedic|real-world applications?|abstract concepts?|practical scenarios?|study habits?|tracking progress|quiz scores?)\b/.test(normalizedContent);
    case "number_theory_congruence_examples":
      return /\b(?:congruences?|modular arithmetic|modulo|mod\b|number theory|fermat'?s little theorem|euler'?s theorem|linear congruence|theorems?|actual numbers?|step-by-step|step by step|calculations?|remainder)\b/.test(normalizedContent);
    case "math_step_calculations":
      return /\b(?:distance formula|distance between|coordinate geometry|coordinate plane|point-line distance|midpoint formula|step-by-step|step by step|calculate|calculation|calculations|arithmetic|substitut(?:e|ing)|differences?|square|squared|simplify)\b/.test(normalizedContent);
    case "mixed_problem_practice":
      return /\b(?:mixed problem sets?|different problem types?|varied problem sets?|multiple topics?|combine|combining|mix(?:ed|ing) up|variety|randomization|practice sessions?|study sessions?|comprehensive exams?|line equations|circles|ellipses|intersections|proofs)\b/.test(normalizedContent);
    case "event_budget_details":
      return /\b(?:event|events|party|parties|gathering|gatherings|reunion|picnic|holiday|hosting|budget|costs?|financial|spending|expenses?|monetary figures?|budget numbers?|cost amounts?)\b/.test(normalizedContent);
    case "travel_cost_details":
      return /\b(?:cost details?|itemized costs?|dollar amounts?|category-by-category|breakdown|travel arrangements?|transportation|accommodation|meals|activities|vacation budget|travel options?)\b/.test(normalizedContent);
    case "investment_withdrawal_tax":
      return /\b(?:investment account|brokerage|portfolio|withdrawals?|take money out|cash out|sell(?:ing)?|tax implications?|taxes owed|penalties|capital gains|taxable distribution)\b/.test(normalizedContent);
    case "scott_support_summary":
      return /\b(?:scott|support|tutoring sessions?|twice weekly|ms\.?\s+harper|math scores?|study sessions?|organized workspace|free from distractions|distraction-free|study environment|growth mindset|stem camp|extracurricular|routine establishment|time management|social encouragement|role-?playing|self-expression|independence|responsibility|digital safety|parental controls?|online risks?|privacy|screen time|daily routines?|creative pursuits?|healthy habits?|emotional well-being|coping mechanisms?|open communication|positive reinforcement|milestones?|clear expectations?|consistent feedback)\b/.test(normalizedContent);
    case "portfolio_management_summary":
      return /\b(?:investment strategy|portfolio management|portfolio allocation|portfolio adjustments?|rebalancing|threshold-based|quarterly reviews?|semi-annual reviews?|vanguard|alerts?|kendra|financial advisor|bond laddering|interest rate risk|income stability|treasur(?:y|ies)|municipal|corporate bonds?|green bonds?|sustainable investments?|international stock|sector-specific|tech stocks?|biotech etfs?|tax implications?|transaction costs?|volatility limits?|investment anxiety|professional support|trusted partner|jeremy|financial decision-making|multi-faceted)\b/.test(normalizedContent);
    case "parent_nutrition_summary":
      return /\b(?:parents?|mom|mother|samantha|dad|father|ryan|89-year-old|89 years old|105-year-old|105|meal plans?|nutrition|nutritional|hydration|medication interactions?|care center|caregivers?|bone broth|plant-based protein|protein powder|smoothies?|caregiving|family-supported)\b/.test(normalizedContent);
    case "evening_tea_options":
      return /\b(?:tea|teas|herbal teas?|chamomile|peppermint|caffeinated|caffeine|sleep quality|relaxation|bedtime|evening)\b/.test(normalizedContent);
    case "relationship_trust_summary":
      return /\b(?:rachael|rebuilding trust|trust issues?|acknowledg(?:e|ing) mistakes?|taking responsibility|communicat(?:e|ing) openly|honestly|initial apology|weekly check-ins?|dialogue examples?|transparency|empathy|accountability course|active listening|patience|follow-through|commitments?|trusted friends?|professional relationships?|personal goals?|shared experiences?|emotional connection|coastal walks?|milestones?|forgotten anniversar(?:y|ies)|feedback|long-term relationship)\b/.test(normalizedContent);
    case "answerability_absence":
      return /\b(?:confus(?:e|ed|ing|ion)|mistake|mutually exclusive|independent events?|dice rolls?|feedback|quizzes?|podiatrist|qualification|expertise|article|explicit evidence|no information)\b/.test(normalizedContent);
  }
  return false;
}

function isPotentialContradictionResolutionQuery(normalized: string): boolean {
  const isMemoryQuestion = /\b(?:have|has|had|do|did|was|were|am|are|is)\b/.test(
    normalized,
  );
  if (!isMemoryQuestion) return false;
  if (/\b(?:ever|never|contradict|contradiction|conflicting|which statement|correct)\b/.test(normalized)) {
    return true;
  }
  if (
    /\bclinical psychology\b/.test(normalized) &&
    /\b(?:workshops?|conferences?)\b/.test(normalized) &&
    /\b(?:attended?|have i|have you|any)\b/.test(normalized)
  ) {
    return true;
  }
  if (/\bsamantha\b/.test(normalized) && /\b(?:met|meeting|in person)\b/.test(normalized)) {
    return true;
  }
  if (
    /\bhome inspection report\b/.test(normalized) &&
    /\b(?:reviewed?|delivered|inspection completed|correct)\b/.test(normalized)
  ) {
    return true;
  }
  if (
    /\b(?:protective masks?|gloves?|respirator masks?|insulation)\b/.test(normalized) &&
    /\b(?:worn|wear|ever|never|correct)\b/.test(normalized)
  ) {
    return true;
  }
  if (
    /\b(?:ergonomic supports?|kneeling pads?|cushioned kneeling pad)\b/.test(normalized) &&
    /\b(?:used|ever|never|correct)\b/.test(normalized)
  ) {
    return true;
  }
  if (
    /\bhow\s+experienced\s+am\s+i\b/.test(normalized) &&
    /\b(?:solv(?:e|ed|ing)|problems?|worked with|experience)\b/.test(normalized)
  ) {
    return true;
  }
  if (
    /\b(?:have|did)\s+i\s+(?:completed?|done|solved)\b/.test(normalized) &&
    /\bpractice problems?\b/.test(normalized) &&
    /\b(?:any|ever|before|separable equations?)\b/.test(normalized)
  ) {
    return true;
  }
  return /\b(?:usually|before|tested|worked with|spent time|spent|read(?:ing)?\s+articles?|articles?|feel|felt|grammar|accuracy|excel|contact form|api)\b/.test(
    normalized,
  ) || /\bimplement(?:ed|ing)?\b/.test(normalized) &&
    /\b(?:retry logic|http errors?|http\s+\d{3}|errors?)\b/.test(normalized);
}

function isTimingDetailsQuery(normalized: string): boolean {
  if (/\b(?:when|date|due|submission|timeline)\b/.test(normalized)) {
    return true;
  }
  return /\bdeadline\b/.test(normalized) &&
    /\b(?:when|what(?:'s| is| was)?|date|due|final|specific)\b/.test(normalized);
}

function extractMonthDayDates(content: string): string[] {
  const dates = new Set<string>();
  for (const match of content.matchAll(
    /\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{1,2})(?:,\s*(\d{4}))?\b/g,
  )) {
    const month = match[1];
    const day = match[2];
    const year = match[3];
    if (!month || !day) continue;
    dates.add(`${month}-${day.padStart(2, "0")}${year ? `-${year}` : ""}`);
  }
  return [...dates];
}

function countGuidanceTermOverlap(content: string, query: string): number {
  const terms = query
    .toLowerCase()
    .match(/[a-z][a-z0-9-]{2,}/g) ?? [];
  const uniqueTerms = new Set(
    terms.filter((term) => !GUIDANCE_STOP_WORDS.has(term)),
  );
  let overlap = 0;
  for (const term of uniqueTerms) {
    if (content.includes(term)) overlap += 1;
  }
  return overlap;
}

function normalizePositiveInteger(value: number): number {
  if (!Number.isFinite(value) || value <= 0) {
    return 0;
  }
  return Math.floor(value);
}

const GUIDANCE_STOP_WORDS = new Set([
  "about",
  "after",
  "approach",
  "could",
  "current",
  "draft",
  "features",
  "final",
  "have",
  "looking",
  "made",
  "manage",
  "many",
  "much",
  "popular",
  "should",
  "some",
  "that",
  "the",
  "this",
  "tools",
  "use",
  "what",
  "when",
  "where",
  "with",
  "would",
]);
