#!/usr/bin/env python3 """ ideas - Idea incubator Capture, develop, and track ideas over time. """ import json import sys import random from datetime import datetime from pathlib import Path WORKSPACE = Path("/home/wdjones/.openclaw/workspace") IDEAS_FILE = WORKSPACE / "data" / "ideas.json" STAGES = ['seed', 'growing', 'ready', 'planted', 'archived'] STAGE_EMOJI = {'seed': 'š±', 'growing': 'šæ', 'ready': 'š»', 'planted': 'š³', 'archived': 'š¦'} def load_ideas() -> list: """Load ideas.""" IDEAS_FILE.parent.mkdir(parents=True, exist_ok=True) if IDEAS_FILE.exists(): with open(IDEAS_FILE) as f: return json.load(f) return [] def save_ideas(ideas: list): """Save ideas.""" with open(IDEAS_FILE, 'w') as f: json.dump(ideas, f, indent=2) def add_idea(title: str, description: str = None, tags: list = None): """Add a new idea.""" ideas = load_ideas() idea = { 'id': len(ideas) + 1, 'title': title, 'description': description, 'tags': tags or [], 'stage': 'seed', 'notes': [], 'created': datetime.now().isoformat(), 'updated': datetime.now().isoformat(), } ideas.append(idea) save_ideas(ideas) print(f"š± Idea #{idea['id']}: {title}") def add_note(idea_id: int, note: str): """Add a development note to an idea.""" ideas = load_ideas() for idea in ideas: if idea['id'] == idea_id: idea['notes'].append({ 'text': note, 'date': datetime.now().isoformat(), }) idea['updated'] = datetime.now().isoformat() save_ideas(ideas) print(f"š Note added to idea #{idea_id}") return print(f"Idea not found: #{idea_id}") def advance(idea_id: int): """Advance an idea to the next stage.""" ideas = load_ideas() for idea in ideas: if idea['id'] == idea_id: current = idea['stage'] idx = STAGES.index(current) if idx < len(STAGES) - 2: # Don't auto-advance to archived idea['stage'] = STAGES[idx + 1] idea['updated'] = datetime.now().isoformat() save_ideas(ideas) emoji = STAGE_EMOJI[idea['stage']] print(f"{emoji} Idea #{idea_id} advanced to: {idea['stage']}") else: print("Idea already at final stage") return print(f"Idea not found: #{idea_id}") def archive(idea_id: int): """Archive an idea.""" ideas = load_ideas() for idea in ideas: if idea['id'] == idea_id: idea['stage'] = 'archived' idea['updated'] = datetime.now().isoformat() save_ideas(ideas) print(f"š¦ Idea #{idea_id} archived") return print(f"Idea not found: #{idea_id}") def show_idea(idea_id: int): """Show idea details.""" ideas = load_ideas() for idea in ideas: if idea['id'] == idea_id: emoji = STAGE_EMOJI[idea['stage']] print(f"\n{emoji} Idea #{idea['id']}: {idea['title']}") print("=" * 50) print(f"Stage: {idea['stage']}") print(f"Created: {idea['created'][:10]}") if idea.get('description'): print(f"\n{idea['description']}") if idea.get('tags'): print(f"\nTags: {' '.join('#' + t for t in idea['tags'])}") if idea['notes']: print(f"\nš Development Notes ({len(idea['notes'])})") for note in idea['notes'][-5:]: print(f" [{note['date'][:10]}] {note['text']}") print() return print(f"Idea not found: #{idea_id}") def list_ideas(stage: str = None): """List ideas.""" ideas = load_ideas() if stage: ideas = [i for i in ideas if i['stage'] == stage] else: ideas = [i for i in ideas if i['stage'] != 'archived'] if not ideas: print("No ideas yet. Add with: ideas add