Back to Directory
project-constellation-mapper

project-constellation-mapper

Discovers local projects and uses a multi-agent swarm to analyze READMEs/package files, generating an emoji-prefixed master markdown overview table.

🌌 Project Constellation Mapper

Core Directive: Discover local projects across directories and use a multi-agent swarm to extract metadata (name, description, stack, URLs) into a master markdown overview table.

🛠️ Execution SOP

Run the following orchestration via the eval tool (Python):

import json
from pathlib import Path

# Adjust search_dirs as needed
search_dirs = [Path.home() / "dev"] 
project_dirs = []

for base in search_dirs:
    if not base.exists(): continue
    for d in base.iterdir():
        if d.is_dir() and not d.name.startswith('.'):
            if (d / "package.json").exists() or (d / "README.md").exists() or (d / ".git").exists():
                project_dirs.append(str(d))

def analyze_project(path_str):
    p = Path(path_str)
    readme = p / "README.md"
    pkg = p / "package.json"
    
    content = ""
    try:
        if readme.exists():
            content += f"README.md:\n{read(str(readme))[:1500]}\n\n"
        if pkg.exists():
            content += f"package.json:\n{read(str(pkg))[:1000]}\n"
    except Exception as e:
        pass

    if not content.strip():
        content = f"Directory: {p.name}"

    prompt = f"Analyze project at '{path_str}'. Determine its name, a highly condensed description (< 15 words), tech stack, and any repo/doc URLs (or write 'Local'). Content:\n{content}"
    schema = {
        "type": "object",
        "properties": {
            "emoji": {"type": "string", "description": "One fitting emoji"},
            "name": {"type": "string"},
            "description": {"type": "string"},
            "stack": {"type": "string"},
            "urls": {"type": "string"}
        },
        "required": ["emoji", "name", "description", "stack", "urls"]
    }
    
    try:
        res = agent(prompt, agent="explore", schema=schema)
        data = res.get("data", res)
        if not isinstance(data, dict): data = res
        data["path"] = path_str
        return data
    except Exception as e:
        return {"emoji": "⚠️", "name": p.name, "description": f"Error: {e}", "stack": "?", "urls": "Local", "path": path_str}

phase("Swarm Analysis")
results = parallel([lambda d=d: analyze_project(d) for d in project_dirs])

phase("Synthesis")
table_lines = ["| Project | Description | Stack | URLs / Path |", "|---|---|---|---|"]

for r in sorted(results, key=lambda x: str(x.get('name', 'Unknown')).lower()):
    emoji = str(r.get('emoji', '📁')).strip()
    name = str(r.get('name', 'Unknown')).strip()
    desc = str(r.get('description', '')).strip().replace('\n', ' ')
    stack = str(r.get('stack', '')).strip()
    urls = str(r.get('urls', '')).strip()
    path = str(r.get('path', ''))
    
    url_str = '*Local*' if urls.lower() in ['local', 'none', 'n/a'] else urls.replace('|', ' ')
    table_lines.append(f"| {emoji} **{name}** | {desc} | {stack} | {url_str}<br/>`{path}` |")

md_content = "# 🌌 Master Project Constellation\n\n" + "\n".join(table_lines) + "\n"
write("PROJECTS_MASTER_TABLE.md", md_content)
log("Table written to PROJECTS_MASTER_TABLE.md")
print(md_content)