from __future__ import annotations from collections import Counter TRACK_NAMES = [ "Backyard AI", "An Adventure in Thousand Token Wood", ] TRACK_METADATA = { "Backyard AI": { "emoji": "🌿", "description": "Practical AI tools, builders, workflows, and useful product experiences.", }, "An Adventure in Thousand Token Wood": { "emoji": "🌲", "description": "Playful, creative, learning, and exploratory Spaces with room to wander.", }, } BACKYARD_HINTS = { "agent", "llama", "llm", "gguf", "model", "api", "trace", "dataset", "resume", "career", "job", "productivity", "safety", "scam", "risk", "legal", "verify", "builder", "workshop", } WOOD_HINTS = { "game", "quiz", "puzzle", "memory", "story", "creative", "writing", "image", "music", "learn", "learning", "education", "study", "language", "translate", "multilingual", "demo", "prototype", "experiment", "play", } BACKYARD_ZONES = {"Builder Workshop", "Safety Shield", "Career Camp"} WOOD_ZONES = {"Game Grove", "Learning Library", "Creative Studio", "Language Village", "Experiment Lab"} def _normalize(text: str) -> str: return " ".join((text or "").lower().split()) def infer_track(title: str, summary: str, tags: list[str], zone: str, readme: str = "") -> str: text = " ".join([title, summary, " ".join(tags or []), readme]).lower() tokens = set(_normalize(text).split()) backyard_score = 0 wood_score = 0 backyard_score += 4 if zone in BACKYARD_ZONES else 0 wood_score += 4 if zone in WOOD_ZONES else 0 for hint in BACKYARD_HINTS: if hint in text or hint in tokens: backyard_score += 1 for hint in WOOD_HINTS: if hint in text or hint in tokens: wood_score += 1 if backyard_score > wood_score: return "Backyard AI" if wood_score > backyard_score: return "An Adventure in Thousand Token Wood" # Default toward the exploratory track if there is no clear signal. if zone in {"Game Grove", "Creative Studio", "Learning Library"}: return "An Adventure in Thousand Token Wood" return "Backyard AI" def get_track_metadata(track: str) -> dict: return TRACK_METADATA.get(track, TRACK_METADATA[TRACK_NAMES[0]]) def count_tracks(spaces) -> Counter: return Counter(getattr(space, "track", "") or "Unassigned" for space in spaces)