aethershell 0.3.1

The world's first multi-agent shell with typed functional pipelines and multi-modal AI
Documentation
#!/usr/bin/env ae
# TUI Dashboard Demo - Showcasing Export, Search, and Statistics Features
#
# This demo script showcases the new TUI dashboard features including:
# - Conversation export (markdown and JSON)
# - Message search and filtering
# - Real-time statistics
# - Agent performance metrics
# - Context window management
#
# Usage: ae demos/tui_dashboard_demo.ae

print("=== AetherShell TUI Dashboard Demo ===\n")

# Section 1: Statistics and Analytics
print("1. Conversation Statistics\n")
print("   The TUI now tracks comprehensive conversation metrics:")
print("   - Total messages (user, assistant, system)")
print("   - Character counts and averages")
print("   - Media attachments")
print("   - Active agents")
print("   - Token estimation with visual progress bar\n")

# Section 2: Export Capabilities
print("2. Export Your Conversations\n")
print("   Keyboard Shortcuts:")
print("   - Ctrl+E: Export to Markdown (human-readable)")
print("   - Ctrl+J: Export to JSON (machine-readable)\n")

print("   Markdown Export Format:")
print("   ┌─────────────────────────────────────┐")
print("   │ # AetherShell Conversation Export   │")
print("   │                                     │")
print("   │ **Exported:** 2024-01-15 10:30:00  │")
print("   │ **Model:** gpt-4o-mini              │")
print("   │ **Total Messages:** 15              │")
print("   │                                     │")
print("   │ ## Conversation                     │")
print("   │                                     │")
print("   │ 👤 **User** (10:25:32)             │")
print("   │ How do pipelines work?              │")
print("   │                                     │")
print("   │ 🤖 **Assistant** (10:25:35)        │")
print("   │ Pipelines use the | operator...     │")
print("   └─────────────────────────────────────┘\n")

print("   JSON Export Structure:")
print("   {")
print("     \"exported_at\": \"2024-01-15T10:30:00Z\",")
print("     \"model\": \"gpt-4o-mini\",")
print("     \"total_messages\": 15,")
print("     \"messages\": [...]")
print("   }\n")

# Section 3: Search and Filter
print("3. Search Your Conversations\n")
print("   Backend Functions Available:")
print("   - search_messages(\"query\") - Case-insensitive content search")
print("   - filter_by_role(role) - Filter by User/Assistant/System\n")

print("   Example Search Results:")
print("   Query: \"pipeline\"")
print("   Found 3 matches:")
print("   [2] 👤 How do pipelines work in AetherShell?")
print("   [4] 🤖 Pipelines use the | operator to chain commands...")
print("   [7] 👤 Can I use pipelines with functions?\n")

# Section 4: Agent Metrics
print("4. Agent Performance Monitoring\n")
print("   Press 'm' in Agent Swarm mode to view metrics:\n")

print("   Agent Metrics:")
print("   ┌─────────────────────────────────────────────────┐")
print("   │ Name: CodeAgent                                 │")
print("   │ Status: 🟢 Working                             │")
print("   │ Uptime: 5m 32s                                  │")
print("   │ Idle Time: 1m 15s                               │")
print("   │ Tools: 12                                       │")
print("   ├─────────────────────────────────────────────────┤")
print("   │ Name: ResearchAgent                             │")
print("   │ Status: 🟡 Waiting                             │")
print("   │ Uptime: 3m 18s                                  │")
print("   │ Idle Time: 45s                                  │")
print("   │ Tools: 8                                        │")
print("   └─────────────────────────────────────────────────┘\n")

# Section 5: Settings and Customization
print("5. Customizable Display Settings\n")
print("   Toggle keyboard shortcuts:")
print("   - 1: Auto-scroll (automatically scroll to latest messages)")
print("   - 2: Timestamps (show/hide message timestamps)")
print("   - 3: Media Preview (enable/disable inline media)\n")

# Section 6: Context Window
print("6. Context Window Management\n")
print("   The TUI tracks your conversation context:")
print("   - Visual indicator shows context window size")
print("   - Token estimation (4 chars ≈ 1 token)")
print("   - Progress bar: Current usage vs. 4096 token limit")
print("   - Get last N messages with get_context_window(N)\n")

print("   Example:")
print("   ┌─────────────────────────────────────┐")
print("   │ Context Window: Last 10 messages    │")
print("   │ ████████████░░░░░░░░ 2500/4096     │")
print("   │ 61% of context used                 │")
print("   └─────────────────────────────────────┘\n")

# Section 7: Complete Keyboard Shortcuts
print("7. Complete Keyboard Shortcuts Reference\n")

print("   Chat Mode:")
print("   ┌──────────┬───────────────────────────┐")
print("   │ Key      │ Action                    │")
print("   ├──────────┼───────────────────────────┤")
print("   │ Ctrl+E   │ Export to Markdown        │")
print("   │ Ctrl+J   │ Export to JSON            │")
print("   │ Ctrl+L   │ Clear Conversation        │")
print("   │ Ctrl+F   │ Search (coming soon)      │")
print("   │ 1        │ Toggle Auto-Scroll        │")
print("   │ 2        │ Toggle Timestamps         │")
print("   │ 3        │ Toggle Media Preview      │")
print("   │ Tab      │ Switch Tabs               │")
print("   │ i        │ Enter Input Mode          │")
print("   │ Esc      │ Exit Input Mode           │")
print("   │ q        │ Quit                      │")
print("   └──────────┴───────────────────────────┘\n")

print("   Agent Swarm Mode:")
print("   ┌──────────┬───────────────────────────┐")
print("   │ Key      │ Action                    │")
print("   ├──────────┼───────────────────────────┤")
print("   │ n        │ New Agent                 │")
print("   │ d        │ Delete Agent              │")
print("   │ m        │ View Metrics              │")
print("   │ c        │ Chat with Agent           │")
print("   │ r        │ Restart Agent             │")
print("   │ Ctrl+P   │ Pause/Resume              │")
print("   └──────────┴───────────────────────────┘\n")

# Section 8: Live Demo Instructions
print("8. Try It Yourself!\n")
print("   To see these features in action:")
print("   1. Launch TUI mode:  ae tui")
print("   2. Start chatting in Chat mode")
print("   3. Watch statistics update in real-time (right sidebar)")
print("   4. Press Ctrl+E to export your conversation")
print("   5. Switch to Agent Swarm mode with Tab")
print("   6. Create an agent with 'n'")
print("   7. Press 'm' to view agent metrics")
print("   8. Toggle settings with 1, 2, 3\n")

# Section 9: Testing
print("9. Comprehensive Testing\n")
print("   All features are fully tested:")
print("   - 16 unit tests (export, search, stats, context, settings)")
print("   - 7 integration tests (workflows, app integration)")
print("   - 100% pass rate ✅")
print("   - Test runtime: <0.05s\n")

print("   Run tests:")
print("   cargo test --test tui_dashboard")
print("   cargo test --test tui_dashboard_integration\n")

# Section 10: Architecture
print("10. Technical Architecture\n")
print("    Core Modules:")
print("    - src/tui/app.rs: 13 new methods, 2 new structs (770 lines)")
print("    - src/tui/dashboard.rs: 5 render functions (233 lines)")
print("    - src/tui/events.rs: Enhanced event handlers (279 lines)")
print("    - src/tui/ui.rs: Integrated dashboard (635 lines)\n")

print("    Data Structures:")
print("    struct ConversationStats {")
print("        total_messages: usize,")
print("        user_messages: usize,")
print("        assistant_messages: usize,")
print("        system_messages: usize,")
print("        total_characters: usize,")
print("        avg_message_length: usize,")
print("        total_media_attachments: usize,")
print("        active_agents: usize,")
print("    }\n")

print("    struct AgentMetrics {")
print("        name: String,")
print("        status: AgentStatus,")
print("        uptime_seconds: i64,")
print("        idle_seconds: i64,")
print("        tool_count: usize,")
print("    }\n")

# Conclusion
print("=== End of TUI Dashboard Demo ===\n")
print("For more information, see:")
print("- docs/TUI_DASHBOARD_FEATURES.md - Complete feature documentation")
print("- docs/TUI_GUIDE.md - Full TUI guide")
print("- tests/tui_dashboard*.rs - Test suite\n")

print("Ready to explore AetherShell's powerful TUI features! 🚀")