# TSA Agent Knowledge Base # Markdown documentation for RAG and agent context """ Knowledge base containing TSA documentation for agent context: - tsa_algorithms.md: Core TSA algorithms (Z-curve, OIS, pooling) - effect_models.md: Fixed vs random effects, measures - alpha_spending.md: O'Brien-Fleming, Pocock spending functions - tsa_file_format.md: Internal TSA file format and code reference """ from pathlib import Path KNOWLEDGE_DIR = Path(__file__).parent def get_knowledge_path(topic: str) -> Path: """Get path to a knowledge file by topic name.""" topic_map = { "algorithms": "tsa_algorithms.md", "tsa_algorithms": "tsa_algorithms.md", "effect_models": "effect_models.md", "models": "effect_models.md", "alpha_spending": "alpha_spending.md", "spending": "alpha_spending.md", "boundaries": "alpha_spending.md", "file_format": "tsa_file_format.md", "tsa_file_format": "tsa_file_format.md", "codes": "tsa_file_format.md", "format": "tsa_file_format.md", } filename = topic_map.get(topic.lower(), f"{topic}.md") return KNOWLEDGE_DIR / filename def load_knowledge(topic: str) -> str: """Load knowledge content by topic.""" path = get_knowledge_path(topic) if path.exists(): return path.read_text() return f"Knowledge topic '{topic}' not found." def list_topics() -> list[str]: """List available knowledge topics.""" return [p.stem for p in KNOWLEDGE_DIR.glob("*.md")]