Skill Atlas
Portfolio-level review for route overlap, stale ownership, shared resources, and no-route opportunities.
Top Issues
- {blocker_items or '
- No blocking portfolio issues detected. '}
Catalog
| Name | Path | Owner | Maturity | Review |
|---|
#!/usr/bin/env python3 import argparse import csv import html import json import re from collections import Counter, defaultdict from datetime import date, datetime from io import StringIO from pathlib import Path from typing import Any try: import yaml except ImportError: # pragma: no cover yaml = None ROOT = Path(__file__).resolve().parent.parent IGNORE_PARTS = { ".git", "__pycache__", "dist", ".previews", "node_modules", ".venv", "venv", } STOPWORDS = { "a", "an", "and", "the", "to", "for", "from", "with", "into", "skill", "skills", "agent", "reusable", "use", "when", "create", "turn", } CADENCE_DAYS = { "monthly": 31, "quarterly": 100, "semiannual": 200, "annual": 370, "per-release": 120, } def parse_frontmatter(path: Path) -> tuple[dict[str, Any], str]: text = path.read_text(encoding="utf-8", errors="replace") lines = text.splitlines() if not lines or lines[0].strip() != "---": return {}, text try: end_index = lines[1:].index("---") + 1 except ValueError: return {}, text frontmatter_text = "\n".join(lines[1:end_index]) body = "\n".join(lines[end_index + 1 :]).lstrip() if yaml is not None: payload = yaml.safe_load(frontmatter_text) or {} return payload if isinstance(payload, dict) else {}, body payload = {} for line in frontmatter_text.splitlines(): if ":" in line: key, value = line.split(":", 1) payload[key.strip()] = value.strip().strip('"') return payload, body def load_json(path: Path) -> dict[str, Any]: if not path.exists(): return {} try: payload = json.loads(path.read_text(encoding="utf-8")) except json.JSONDecodeError: return {} return payload if isinstance(payload, dict) else {} def should_skip(path: Path, root: Path) -> bool: try: rel = path.relative_to(root) except ValueError: return True if any(part in IGNORE_PARTS for part in rel.parts): return True return len(rel.parts) >= 2 and rel.parts[0] == "tests" and rel.parts[1].startswith("tmp") def find_skill_dirs(workspace_root: Path) -> list[Path]: workspace_root = workspace_root.resolve() skill_dirs = [] for skill_md in sorted(workspace_root.rglob("SKILL.md")): if should_skip(skill_md, workspace_root): continue skill_dirs.append(skill_md.parent) return skill_dirs def tokens(text: str) -> set[str]: raw = re.findall(r"[a-zA-Z0-9_\-\u4e00-\u9fff]{2,}", text.casefold()) return {item for item in raw if item not in STOPWORDS} def jaccard(left: set[str], right: set[str]) -> float: if not left or not right: return 0.0 return len(left & right) / len(left | right) def safe_rel(root: Path, path: Path) -> str: try: return str(path.resolve().relative_to(root.resolve())) except ValueError: return str(path.resolve()) def display_path(path: Path) -> str: try: return str(path.resolve().relative_to(ROOT.resolve())) except ValueError: return str(path.resolve()) def resource_names(skill_dir: Path) -> list[str]: names = [] for folder in ("scripts", "references", "assets", "templates"): target = skill_dir / folder if not target.exists(): continue for path in sorted(target.rglob("*")): rel = path.relative_to(skill_dir) if any(part in IGNORE_PARTS for part in rel.parts): continue if path.suffix in {".pyc", ".pyo"}: continue if path.is_file() and not path.is_symlink(): names.append(f"{folder}/{path.name}") return names def collect_skill(workspace_root: Path, skill_dir: Path) -> dict[str, Any]: frontmatter, _ = parse_frontmatter(skill_dir / "SKILL.md") manifest = load_json(skill_dir / "manifest.json") name = str(frontmatter.get("name") or manifest.get("name") or skill_dir.name) description = str(frontmatter.get("description") or "") targets = manifest.get("target_platforms", []) return { "name": name, "path": safe_rel(workspace_root, skill_dir), "description": description, "owner": str(manifest.get("owner", "")), "version": str(manifest.get("version", "")), "status": str(manifest.get("status", "")), "maturity": str(manifest.get("maturity_tier", manifest.get("skill_archetype", ""))), "updated_at": str(manifest.get("updated_at", "")), "review_cadence": str(manifest.get("review_cadence", "")), "targets": [str(item) for item in targets] if isinstance(targets, list) else [], "resources": resource_names(skill_dir), "token_set": sorted(tokens(description)), } def route_overlap(skills: list[dict[str, Any]], threshold: float) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: rows = [] collisions = [] for i, left in enumerate(skills): for right in skills[i + 1 :]: score = round(jaccard(set(left["token_set"]), set(right["token_set"])), 3) status = "collision" if score >= threshold else "clear" row = { "skill_a": left["name"], "skill_b": right["name"], "path_a": left["path"], "path_b": right["path"], "score": score, "status": status, } rows.append(row) if status == "collision": collisions.append(row) duplicate_names = [ {"name": name, "paths": [item["path"] for item in skills if item["name"] == name]} for name, count in Counter(item["name"] for item in skills).items() if count > 1 ] for item in duplicate_names: collisions.append( { "skill_a": item["name"], "skill_b": item["name"], "path_a": item["paths"][0], "path_b": item["paths"][1], "score": 1.0, "status": "duplicate-name", } ) return rows, collisions def dependency_graph(skills: list[dict[str, Any]]) -> dict[str, Any]: by_resource: dict[str, list[str]] = defaultdict(list) for skill in skills: for resource in skill.get("resources", []): by_resource[resource].append(skill["name"]) shared = [ {"resource": resource, "skills": sorted(names)} for resource, names in sorted(by_resource.items()) if len(set(names)) > 1 ] return { "nodes": [{"name": item["name"], "path": item["path"]} for item in skills], "shared_resources": shared, } def parse_date(value: str) -> date | None: if not value: return None try: return datetime.strptime(value[:10], "%Y-%m-%d").date() except ValueError: return None def stale_skills(skills: list[dict[str, Any]], today: date) -> list[dict[str, Any]]: stale = [] for skill in skills: updated = parse_date(skill.get("updated_at", "")) cadence = skill.get("review_cadence") or "" allowed_days = CADENCE_DAYS.get(cadence, 120) if not updated: stale.append({"name": skill["name"], "path": skill["path"], "reason": "missing updated_at"}) continue age = (today - updated).days if age > allowed_days: stale.append( { "name": skill["name"], "path": skill["path"], "reason": f"review overdue by cadence {cadence or 'unspecified'}", "age_days": age, "allowed_days": allowed_days, } ) return stale def owner_review_gaps(skills: list[dict[str, Any]]) -> list[dict[str, Any]]: gaps = [] for skill in skills: missing = [] if not skill.get("owner"): missing.append("owner") if not skill.get("review_cadence"): missing.append("review_cadence") if not skill.get("maturity"): missing.append("maturity") if missing: gaps.append({"name": skill["name"], "path": skill["path"], "missing": missing}) return gaps def no_route_opportunities(workspace_root: Path) -> list[dict[str, Any]]: opportunities = [] for path in sorted(workspace_root.rglob("failure-cases.md")): if should_skip(path, workspace_root): continue text = path.read_text(encoding="utf-8", errors="replace") for line in text.splitlines(): stripped = line.strip() if not stripped.startswith("-"): continue lowered = stripped.casefold() if "no_route" in lowered or "no route" in lowered or "missed" in lowered or "under-trigger" in lowered: opportunities.append({"source": safe_rel(workspace_root, path), "note": stripped.lstrip("- ").strip()}) return opportunities[:50] def write_csv(path: Path, rows: list[dict[str, Any]]) -> None: path.parent.mkdir(parents=True, exist_ok=True) fields = ["skill_a", "skill_b", "path_a", "path_b", "score", "status"] buffer = StringIO() writer = csv.DictWriter(buffer, fieldnames=fields, lineterminator="\n") writer.writeheader() for row in rows: writer.writerow({field: row.get(field, "") for field in fields}) path.write_text(buffer.getvalue(), encoding="utf-8") def render_html(payload: dict[str, Any]) -> str: summary = payload["summary"] rows = [] for skill in payload["catalog"]["skills"][:80]: rows.append( "
Portfolio-level review for route overlap, stale ownership, shared resources, and no-route opportunities.
| Name | Path | Owner | Maturity | Review |
|---|