"""App/Product context knowledge loader."""
import json
from pathlib import Path
from typing import Any
from ..config import KNOWLEDGE_DIR
def get_app_context() -> dict[str, Any]:
"""Load app/product context from knowledge files.
Returns:
Dictionary containing app context information including:
- product_name: Name of the product/service
- description: Brief description
- value_propositions: Key value props
- target_audiences: Target market segments
- competitors: Known competitors
- unique_selling_points: What makes this different
If no context file exists, returns a template structure.
"""
context_file = KNOWLEDGE_DIR / "app_context.json"
if context_file.exists():
with open(context_file, "r", encoding="utf-8") as f:
return json.load(f)
# Return template structure if no file exists
return {
"product_name": "",
"description": "",
"value_propositions": [],
"target_audiences": [],
"competitors": [],
"unique_selling_points": [],
"industry": "",
"website_url": "",
"brand_voice": "",
"_note": "This is a template. Create data/knowledge/app_context.json with your actual data.",
}
def save_app_context(context: dict[str, Any]) -> None:
"""Save app context to the knowledge file.
Args:
context: The app context dictionary to save.
"""
KNOWLEDGE_DIR.mkdir(parents=True, exist_ok=True)
context_file = KNOWLEDGE_DIR / "app_context.json"
with open(context_file, "w", encoding="utf-8") as f:
json.dump(context, f, indent=2)