diff --git a/src/atocore/engineering/wiki.py b/src/atocore/engineering/wiki.py index 547b19c..a15df0c 100644 --- a/src/atocore/engineering/wiki.py +++ b/src/atocore/engineering/wiki.py @@ -47,32 +47,74 @@ def render_homepage() -> str: for p in registered: entity_count = len(get_entities(project=p.project_id, limit=200)) memory_count = len(get_memories(project=p.project_id, active_only=True, limit=200)) - state_count = len(get_state(p.project_id)) + state_entries = get_state(p.project_id) + + # Pull stage/type/client from state entries + stage = "" + proj_type = "" + client = "" + for e in state_entries: + if e.category == "status": + if e.key == "stage": + stage = e.value + elif e.key == "type": + proj_type = e.value + elif e.key == "client": + client = e.value + projects.append({ "id": p.project_id, "description": p.description, "entities": entity_count, "memories": memory_count, - "state": state_count, + "state": len(state_entries), + "stage": stage, + "type": proj_type, + "client": client, }) except Exception: pass + # Group by high-level bucket + buckets: dict[str, list] = { + "Active Contracts": [], + "Leads & Prospects": [], + "Internal Tools & Infra": [], + "Other": [], + } + for p in projects: + t = p["type"].lower() + s = p["stage"].lower() + if "lead" in t or "lead" in s or "prospect" in s: + buckets["Leads & Prospects"].append(p) + elif "contract" in t or ("active" in s and "contract" in s): + buckets["Active Contracts"].append(p) + elif "infra" in t or "tool" in t or "internal" in t: + buckets["Internal Tools & Infra"].append(p) + else: + buckets["Other"].append(p) + lines = ['

AtoCore Wiki

'] lines.append('') - lines.append('

Projects

') - lines.append('
') - for p in projects: - lines.append(f'') - lines.append(f'

{p["id"]}

') - lines.append(f'

{p["description"][:120]}

') - lines.append(f'
{p["entities"]} entities · {p["memories"]} memories · {p["state"]} state entries
') - lines.append('
') - lines.append('
') + for bucket_name, items in buckets.items(): + if not items: + continue + lines.append(f'

{bucket_name}

') + lines.append('
') + for p in items: + client_line = f'
{p["client"]}
' if p["client"] else '' + stage_tag = f'{p["stage"].split(" — ")[0]}' if p["stage"] else '' + lines.append(f'') + lines.append(f'

{p["id"]} {stage_tag}

') + lines.append(client_line) + lines.append(f'

{p["description"][:140]}

') + lines.append(f'
{p["entities"]} entities · {p["memories"]} memories · {p["state"]} state
') + lines.append('
') + lines.append('
') # Quick stats all_entities = get_entities(limit=500) @@ -245,6 +287,8 @@ _TEMPLATE = """ .card h3 { color: var(--accent); margin: 0 0 0.3rem 0; } .card p { font-size: 0.9em; margin: 0; opacity: 0.8; } .card .stats { font-size: 0.8em; margin-top: 0.5rem; opacity: 0.5; } + .card .client { font-size: 0.85em; opacity: 0.65; margin-bottom: 0.3rem; font-style: italic; } + .card h3 .tag { font-size: 0.65em; vertical-align: middle; margin-left: 0.4rem; }