|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +// Demo script showcasing the enhanced tool display system |
| 4 | +// This demonstrates the beautiful, interactive tool call rendering |
| 5 | + |
| 6 | +// Since we can't import the TypeScript files directly in Node.js, |
| 7 | +// let's create a simple test that shows what the enhanced display would look like |
| 8 | + |
| 9 | +console.log('\n🎨 Enhanced Tool Display Demo - Pink Pixel Style\n'); |
| 10 | + |
| 11 | +// Demo 1: File listing result |
| 12 | +console.log('📁 Demo 1: File Listing Tool Call'); |
| 13 | +const fileListMessage = { |
| 14 | + role: MessageRole.Tool, |
| 15 | + toolName: 'list_files', |
| 16 | + content: JSON.stringify([ |
| 17 | + { name: 'package.json', size: '1.8KB', modified: '2024-02-01' }, |
| 18 | + { name: 'README.md', size: '15.2KB', modified: '2024-02-01' }, |
| 19 | + { name: 'src', size: '-', modified: '2024-01-30', type: 'directory' }, |
| 20 | + { name: 'dist', size: '-', modified: '2024-02-01', type: 'directory' }, |
| 21 | + ]) |
| 22 | +}; |
| 23 | + |
| 24 | +toolDisplay.displayCall(fileListMessage, { |
| 25 | + showTimings: false, |
| 26 | + enableInteractive: false, |
| 27 | + maxTableRows: 10 |
| 28 | +}); |
| 29 | + |
| 30 | +// Demo 2: API response |
| 31 | +setTimeout(() => { |
| 32 | + console.log('\n🌐 Demo 2: API Response Tool Call'); |
| 33 | + const apiMessage = { |
| 34 | + role: MessageRole.Tool, |
| 35 | + toolName: 'fetch_weather', |
| 36 | + content: JSON.stringify({ |
| 37 | + location: 'San Francisco, CA', |
| 38 | + temperature: '22°C', |
| 39 | + condition: 'Partly Cloudy', |
| 40 | + humidity: '65%', |
| 41 | + wind_speed: '12 mph', |
| 42 | + forecast: [ |
| 43 | + { day: 'Today', high: '24°C', low: '18°C', condition: 'Partly Cloudy' }, |
| 44 | + { day: 'Tomorrow', high: '26°C', low: '19°C', condition: 'Sunny' }, |
| 45 | + { day: 'Friday', high: '23°C', low: '17°C', condition: 'Cloudy' } |
| 46 | + ] |
| 47 | + }) |
| 48 | + }; |
| 49 | + |
| 50 | + toolDisplay.displayCall(apiMessage, { |
| 51 | + showTimings: false, |
| 52 | + enableInteractive: false, |
| 53 | + maxTableRows: 5 |
| 54 | + }); |
| 55 | +}, 1500); |
| 56 | + |
| 57 | +// Demo 3: Search results |
| 58 | +setTimeout(() => { |
| 59 | + console.log('\n🔍 Demo 3: Search Results Tool Call'); |
| 60 | + const searchMessage = { |
| 61 | + role: MessageRole.Tool, |
| 62 | + toolName: 'search_codebase', |
| 63 | + content: JSON.stringify([ |
| 64 | + 'src/components/Button.tsx', |
| 65 | + 'src/components/Modal.tsx', |
| 66 | + 'src/ui/theme.ts', |
| 67 | + 'src/utils/helpers.js', |
| 68 | + 'tests/components/Button.test.tsx' |
| 69 | + ]) |
| 70 | + }; |
| 71 | + |
| 72 | + toolDisplay.displayCall(searchMessage, { |
| 73 | + showTimings: false, |
| 74 | + enableInteractive: false, |
| 75 | + maxJsonLines: 15 |
| 76 | + }); |
| 77 | +}, 3000); |
| 78 | + |
| 79 | +// Demo 4: Error handling |
| 80 | +setTimeout(() => { |
| 81 | + console.log('\n❌ Demo 4: Error Tool Call'); |
| 82 | + const errorMessage = { |
| 83 | + role: MessageRole.Tool, |
| 84 | + toolName: 'compile_code', |
| 85 | + content: JSON.stringify({ |
| 86 | + success: false, |
| 87 | + error: 'Type error in src/index.ts:42', |
| 88 | + details: 'Property "name" does not exist on type "User"', |
| 89 | + suggestions: [ |
| 90 | + 'Check if the property name is correct', |
| 91 | + 'Ensure the interface is imported', |
| 92 | + 'Add the missing property to the interface' |
| 93 | + ] |
| 94 | + }) |
| 95 | + }; |
| 96 | + |
| 97 | + toolDisplay.displayCall(errorMessage, { |
| 98 | + showTimings: false, |
| 99 | + enableInteractive: false |
| 100 | + }); |
| 101 | +}, 4500); |
| 102 | + |
| 103 | +// Demo 5: Simple text result |
| 104 | +setTimeout(() => { |
| 105 | + console.log('\n📝 Demo 5: Text Result Tool Call'); |
| 106 | + const textMessage = { |
| 107 | + role: MessageRole.Tool, |
| 108 | + toolName: 'generate_summary', |
| 109 | + content: 'This project implements a CLI chatbot with MCP support. It features beautiful terminal UI with gradients, interactive components, and sophisticated tool call display. The system supports multiple AI providers and can be extended with custom tools.' |
| 110 | + }; |
| 111 | + |
| 112 | + toolDisplay.displayCall(textMessage, { |
| 113 | + showTimings: false, |
| 114 | + enableInteractive: false |
| 115 | + }); |
| 116 | + |
| 117 | + console.log('\n✨ Demo Complete! The enhanced tool display system provides:'); |
| 118 | + console.log(' • Beautiful gradient headers with status badges'); |
| 119 | + console.log(' • Boxed parameter and result sections'); |
| 120 | + console.log(' • Intelligent formatting (tables, lists, JSON)'); |
| 121 | + console.log(' • Syntax highlighting for JSON content'); |
| 122 | + console.log(' • Interactive features (copy, expand/collapse)'); |
| 123 | + console.log(' • Pink Pixel branded styling throughout'); |
| 124 | + console.log('\nSet BIBBLE_ENHANCED_TOOLS=true to enable in chat! 🚀\n'); |
| 125 | +}, 6000); |
0 commit comments