from __future__ import annotations from typing import Any, List, Optional def _clean_bullets(value: Any) -> List[str]: if not value: return [] if isinstance(value, str): parts = [line.strip() for line in value.splitlines()] return [p for p in parts if p and not p.startswith("#")] if isinstance(value, list): out: List[str] = [] for item in value: if isinstance(item, str): s = item.strip() if s and not s.startswith("#"): out.append(s) return out return [] def compile_surveyor_attributes_overlay(attributes: Any) -> str: """Compile surveyor attributes (plain bullet lines) into a prompt overlay.""" items = _clean_bullets(attributes) if not items: return "" lines: List[str] = [] lines.append("Surveyor attributes (follow these):") for item in items: lines.append(f"- {item}") return "\n".join(lines).strip() def compile_question_bank_overlay(question_bank_text: Optional[str]) -> str: if not isinstance(question_bank_text, str): return "" raw = [line.strip() for line in question_bank_text.splitlines()] items = [line for line in raw if line and not line.startswith("#")] if not items: return "" lines: List[str] = [] lines.append("Question bank (targets to cover):") for idx, item in enumerate(items, start=1): lines.append(f"- q{idx:02d}: {item}") return "\n".join(lines).strip()