Files
microdao-daarion/scripts/seed_city_rooms.py
Apple 0039be5dc0 feat(rooms): Add city-lobby with DAARWIZZ + fix API proxy
- Created city-lobby room as main public chat with DAARWIZZ
- Fixed /api/city/rooms proxy to use correct backend path (/api/v1/city/rooms)
- Updated district rooms with zone keys (leadership, system, engineering, etc.)
- Set MicroDAO lobbies as primary rooms
- Created seed_city_rooms.py script
- Created TASK_PHASE_CITY_ROOMS_AND_PUBLIC_CHAT_v1.md

Total: 35 rooms, 31 public, 10 districts
2025-12-01 08:47:37 -08:00

198 lines
7.6 KiB
Python

#!/usr/bin/env python3
"""
Seed City Rooms for DAARION.city
Creates:
1. City Lobby with DAARWIZZ (main public chat)
2. Updates district rooms with district_key
3. Creates MicroDAO default lobbies if missing
Usage:
python scripts/seed_city_rooms.py --dry-run # Preview changes
python scripts/seed_city_rooms.py # Apply changes
"""
import argparse
import asyncio
import os
import sys
from pathlib import Path
# Add project root to path
PROJECT_ROOT = Path(__file__).parent.parent
sys.path.insert(0, str(PROJECT_ROOT))
# Database connection
DATABASE_URL = os.getenv(
"DATABASE_URL",
"postgresql://postgres:postgres@144.76.224.179:5432/daarion"
)
# District mapping from agents_city_mapping.yaml
DISTRICTS = [
{"key": "leadership", "name": "Leadership Hall", "slug": "leadership-hall", "color": "#F59E0B", "icon": "crown"},
{"key": "system", "name": "System Control Center", "slug": "system-control", "color": "#6366F1", "icon": "cpu"},
{"key": "engineering", "name": "Engineering Lab", "slug": "engineering-lab", "color": "#10B981", "icon": "code"},
{"key": "marketing", "name": "Marketing Hub", "slug": "marketing-hub", "color": "#EC4899", "icon": "megaphone"},
{"key": "finance", "name": "Finance Office", "slug": "finance-office", "color": "#14B8A6", "icon": "banknotes"},
{"key": "web3", "name": "Web3 District", "slug": "web3-district", "color": "#8B5CF6", "icon": "cube"},
{"key": "security", "name": "Security Bunker", "slug": "security-bunker", "color": "#EF4444", "icon": "shield"},
{"key": "vision", "name": "Vision Studio", "slug": "vision-studio", "color": "#22D3EE", "icon": "eye"},
{"key": "rnd", "name": "R&D Laboratory", "slug": "rnd-lab", "color": "#A855F7", "icon": "beaker"},
{"key": "memory", "name": "Memory Vault", "slug": "memory-vault", "color": "#06B6D4", "icon": "database"},
]
# MicroDAO lobbies
MICRODAOS = [
{"slug": "daarion", "name": "DAARION DAO", "lobby_slug": "daarion-lobby"},
{"slug": "energy-union", "name": "Energy Union", "lobby_slug": "energy-union-lobby"},
{"slug": "greenfood", "name": "GreenFood DAO", "lobby_slug": "greenfood-lobby"},
{"slug": "soul", "name": "Soul Retreat Hub", "lobby_slug": "soul-lobby"},
]
async def seed_rooms(dry_run: bool = True):
"""Seed city rooms."""
import asyncpg
print("=" * 60)
print("🏙️ DAARION City Rooms Seed")
print("=" * 60)
if dry_run:
print("\n🔍 DRY RUN - No changes will be made\n")
conn = await asyncpg.connect(DATABASE_URL)
try:
# 1. Create City Lobby with DAARWIZZ
print("\n📍 Step 1: City Lobby with DAARWIZZ")
print("-" * 40)
existing_lobby = await conn.fetchrow(
"SELECT id, slug FROM city_rooms WHERE slug = 'city-lobby'"
)
if existing_lobby:
print(f" ✅ City Lobby already exists: {existing_lobby['id']}")
else:
print(" 📝 Creating City Lobby...")
if not dry_run:
await conn.execute("""
INSERT INTO city_rooms (
id, slug, name, description, room_type, visibility,
is_default, is_public, sort_order, owner_type, space_scope
) VALUES (
'room_city_lobby',
'city-lobby',
'DAARION City Lobby',
'Головний публічний чат з DAARWIZZ. Ласкаво просимо до DAARION!',
'city',
'public-city',
true,
true,
1,
'city',
'city'
)
""")
print(" ✅ City Lobby created!")
else:
print(" Would create: city-lobby (DAARION City Lobby)")
# 2. Update district rooms with district_key (using zone field)
print("\n📍 Step 2: Update District Rooms")
print("-" * 40)
for district in DISTRICTS:
existing = await conn.fetchrow(
"SELECT id, slug, zone FROM city_rooms WHERE slug = $1",
district["slug"]
)
if existing:
if existing["zone"] != district["key"]:
print(f" 📝 Updating {district['slug']} with zone={district['key']}")
if not dry_run:
await conn.execute("""
UPDATE city_rooms
SET zone = $1, room_type = 'district', color = $2, icon = $3
WHERE slug = $4
""", district["key"], district["color"], district["icon"], district["slug"])
else:
print(f"{district['slug']} already has zone={district['key']}")
else:
print(f" 📝 Creating district room: {district['slug']}")
if not dry_run:
await conn.execute("""
INSERT INTO city_rooms (
id, slug, name, room_type, visibility, zone,
is_public, sort_order, owner_type, space_scope, color, icon
) VALUES (
$1, $2, $3, 'district', 'public-city', $4,
true, 50, 'city', 'city', $5, $6
)
""", f"room_district_{district['key']}", district["slug"],
district["name"], district["key"], district["color"], district["icon"])
# 3. Verify MicroDAO lobbies
print("\n📍 Step 3: Verify MicroDAO Lobbies")
print("-" * 40)
for dao in MICRODAOS:
existing = await conn.fetchrow(
"SELECT id, slug, room_role FROM city_rooms WHERE slug = $1",
dao["lobby_slug"]
)
if existing:
if existing["room_role"] != "primary":
print(f" 📝 Setting {dao['lobby_slug']} as primary room")
if not dry_run:
await conn.execute("""
UPDATE city_rooms SET room_role = 'primary' WHERE slug = $1
""", dao["lobby_slug"])
else:
print(f"{dao['lobby_slug']} is primary room")
else:
print(f" ⚠️ Missing: {dao['lobby_slug']} - will need manual creation")
# 4. Summary
print("\n📊 Summary")
print("-" * 40)
total = await conn.fetchval("SELECT COUNT(*) FROM city_rooms")
public = await conn.fetchval("SELECT COUNT(*) FROM city_rooms WHERE is_public = true")
districts = await conn.fetchval("SELECT COUNT(*) FROM city_rooms WHERE room_type = 'district'")
print(f" Total rooms: {total}")
print(f" Public rooms: {public}")
print(f" District rooms: {districts}")
if dry_run:
print("\n🔍 DRY RUN complete - no changes were made")
else:
print("\n✅ Seed complete!")
finally:
await conn.close()
def main():
parser = argparse.ArgumentParser(
description="Seed City Rooms for DAARION.city"
)
parser.add_argument(
"--dry-run",
action="store_true",
help="Preview changes without applying them"
)
args = parser.parse_args()
asyncio.run(seed_rooms(dry_run=args.dry_run))
if __name__ == "__main__":
main()