Skip to content

trevor-the-developer/warp-terminal-clone-bootstrap

Repository files navigation

πŸš€ Wurp Terminal Bootstrap

A comprehensive modular bootstrap system that generates complete AI-powered terminal applications built with .NET 9. Features a clean, maintainable architecture with numbered modules for easy development and extension.

Latest Updates:

  • βœ… Centralized binary search paths using new utility functions
  • βœ… Reduced code duplication in shell scripts
  • βœ… Updated to .NET 9 for compatibility with Freelance-AI project
  • βœ… Fixed modular system warnings - no more "modules directory not found" messages
  • βœ… Added comprehensive test suite with 17 automated tests
  • βœ… Full integration testing for generated projects

⚑ Quick Start

# Create project in current directory
./wurp-terminal-bootstrap.sh

# Create project in specific location
./wurp-terminal-bootstrap.sh -p ~/workspace -n my-terminal

# Debug mode to see module loading
./wurp-terminal-bootstrap.sh --debug -p ~/test -n debug-project

# Show help
./wurp-terminal-bootstrap.sh -h

🎯 Command Options

Option Description Example
-p, --path Base directory for project -p ~/Projects
-n, --name Project folder name -n my-terminal
-d, --debug Enable debug mode (shows module loading) --debug
-h, --help Show help message -h

πŸ—οΈ Modular Architecture

This bootstrap uses a numbered module system for clean, maintainable code:

lib/
β”œβ”€β”€ wurp-terminal-bootstrap-functions.sh  # Smart coordinator with fallbacks
└── modules/
    β”œβ”€β”€ 00-core.sh                        # Core utilities (config, colors, validation)
    β”œβ”€β”€ 10-project.sh                     # Project structure creation
    └── 20-files.sh                       # File generation (C#, configs, docs)

🧩 Module Benefits

  • 00-core.sh (270 lines) - Pure utilities, no dependencies, binary search functions
  • 10-project.sh (100 lines) - Directory structure only
  • 20-files.sh (400 lines) - All C# and config file generation
  • Smart loading - Modules load in order with graceful fallbacks
  • Debug mode - See exactly what's loading with --debug
  • Centralized utilities - Common binary search paths prevent duplication

πŸ“ What It Creates

The bootstrap script generates a complete project structure:

your-project/
β”œβ”€β”€ Program.cs                          # Main terminal application entry point
β”œβ”€β”€ WurpTerminal.csproj                 # .NET 9 project file
β”œβ”€β”€ wurp-config.json                   # Centralised configuration
β”œβ”€β”€ Core/                               # Modular C# architecture
β”‚   β”œβ”€β”€ WurpTerminalService.cs          # Main terminal service
β”‚   β”œβ”€β”€ AIIntegration.cs                # AI command handling
β”‚   └── ThemeManager.cs                 # Theme management
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ wurp-terminal                   # Main launcher script
β”‚   └── lib/
β”‚       └── wurp-terminal-functions.sh # Generated function library
β”œβ”€β”€ .gitignore                          # Git ignore file
β”œβ”€β”€ .editorconfig                       # Editor configuration
└── README.md                          # Project documentation

πŸš€ Generated Terminal Features

The created terminal includes:

  • πŸ€– Enhanced AI Integration - Full FreelanceAI API integration with smart routing
  • πŸ“Š Real-time Metrics - Provider selection, cost tracking, and performance monitoring
  • πŸ“œ Command History - Persistent command history with search
  • 🎨 Multiple Themes - Default, dark, and wurp themes with colors
  • 🐚 Shell Integration - Works seamlessly with bash/zsh
  • ⚑ System Commands - Execute any system command with output
  • πŸ”§ Built-in Commands - help, clear, history, themes, AI commands
  • πŸ’» Cross-platform - Runs on Linux, macOS, Windows with .NET 8
  • πŸ”„ Automatic Failover - Seamless switching between AI providers
  • πŸ’° Cost Optimisation - Budget tracking and intelligent provider selection

πŸ› οΈ After Bootstrap

Navigate to your project and use the generated build system:

cd your-project

# Check dependencies (dotnet, jq, curl)
./scripts/wurp-terminal check

# Build the application
./scripts/wurp-terminal build

# Build and publish optimised binary
./scripts/wurp-terminal publish

# Full installation (build, publish, create symlinks)
./scripts/wurp-terminal install

# Show installation status
./scripts/wurp-terminal status

# Run the terminal directly
./scripts/wurp-terminal run

# Or use the installed binary
wurp-terminal

πŸ€– Generated Terminal Commands

Once installed, use these commands in your AI-powered terminal:

AI Commands

ai explain "docker ps"        # Explain what a command does
ai suggest "deploy app"       # Get command suggestions for tasks
ai debug "permission denied"  # Get debugging help for errors
ai code "REST API controller" # Generate code with smart routing
ai review "my-code.cs"        # Code review with AI assistance
ai optimise "slow query"      # Performance optimisation suggestions
ai test "async methods"       # Testing strategies and examples

FreelanceAI Integration

./scripts/wurp-terminal ai-status  # Check FreelanceAI provider status and costs
./scripts/wurp-terminal check       # Verify dependencies and AI services

Theme Commands

theme                         # Show current theme and available options
theme dark                    # Switch to dark theme
theme wurp                    # Switch to wurp theme (cyan prompt)
theme default                 # Switch to default theme

Built-in Commands

help                          # Show comprehensive help
history                       # Show recent command history
clear                         # Clear screen
exit / quit                   # Exit terminal gracefully

System Integration

# All system commands work normally
ls -la                        # File listing
git status                    # Git commands
npm install                   # Package managers
docker ps                     # Container management

πŸ“‹ Requirements

Requirement Purpose Installation
.NET 9 SDK Build and run C# application
jq JSON configuration processing sudo apt install jq or brew install jq
curl AI service health checks sudo apt install curl or brew install curl
bash/zsh Shell compatibility Usually pre-installed

πŸ”§ Development Workflow

Adding New Features

# Modify C# file generation
nano lib/modules/20-files.sh

# Change project structure
nano lib/modules/10-project.sh

# Update core utilities (includes binary search functions)
nano lib/modules/00-core.sh

# Add new utility functions to core module
# - get_binary_search_paths() for .NET path management
# - find_binary() for locating compiled applications
# - check_binary_exists() for quick validation
# - get_binary_relative_path() for display purposes

# Test changes with debug mode
DEBUG=true ./wurp-terminal-bootstrap.sh -p ~/test -n dev-test

Future Module Extensions

# Ready for additional modules:
lib/modules/30-build.sh        # Enhanced build operations
lib/modules/40-integration.sh  # Shell and desktop integration
lib/modules/50-services.sh     # AI service management
lib/modules/60-management.sh   # Advanced project management

πŸ§ͺ Testing & Debugging

Comprehensive Test Suite

We provide a complete test script that validates all aspects of generated projects:

# Test the current project
./test-wurp-terminal.sh

# Test a specific project
./test-wurp-terminal.sh /path/to/your-project

# Test the example project we just created
./test-wurp-terminal.sh ~/workspace/my-terminal

Test Coverage (17 Automated Tests)

The test script performs comprehensive validation:

πŸ”§ Build & Functionality Tests

  1. Help Command - Validates script help system
  2. Dependency Check - Ensures all required tools are available
  3. Build Application - Tests .NET 9 compilation
  4. Publish Application - Validates optimized binary creation
  5. Status Check - Verifies installation status reporting

πŸš€ Terminal Functionality Tests

  1. Version Command - Tests terminal version display
  2. Terminal Help - Validates built-in help system
  3. AI Explain Command - Tests AI command explanation feature
  4. AI Suggest Command - Tests AI task suggestion feature
  5. AI Debug Command - Tests AI debugging assistance
  6. Theme List Command - Tests theme management listing
  7. Theme Change Command - Tests theme switching functionality

πŸ“ Structure & Configuration Tests

  1. Project Structure Validation - Ensures all required files and directories exist
  2. Configuration File Validation - Validates JSON configuration syntax
  3. Executable Permissions - Checks script execution permissions
  4. Published Binary Verification - Uses centralized search paths to confirm binary creation
  5. Symlink Verification - Tests global installation symlinks

Test Output Example

πŸš€ Wurp Terminal Clone - Test Suite
==================================

ℹ️  Testing project: /home/user/workspace/my-terminal

πŸ” Running Wurp Terminal Tests...

πŸ§ͺ Test 1: Help command
βœ… PASSED: Help command
πŸ§ͺ Test 2: Dependency check
βœ… PASSED: Dependency check
...
πŸ§ͺ Test 17: Symlink verification
βœ… PASSED: Symlink verification

═══════════════════════════════════════
πŸ“Š Test Results Summary
═══════════════════════════════════════

ℹ️  Tests Run: 17
βœ… Tests Passed: 17
βœ… All tests passed successfully! πŸŽ‰

✨ Wurp Terminal Clone is working correctly!

Debug Mode

# See detailed module loading and execution
./wurp-terminal-bootstrap.sh --debug -p ~/debug -n test-project

Verify Installation

# Check generated project works
cd your-project
./scripts/wurp-terminal check    # Verify dependencies
./scripts/wurp-terminal build    # Test build process
./scripts/wurp-terminal status   # Show installation status

# Run full test suite
/path/to/bootstrap/test-wurp-terminal.sh ./

πŸ“š Project Structure Details

Component Purpose Technology
Program.cs Application entry point with async/await
Core/*.cs Modular service architecture Clean Architecture pattern
wurp-config.json Centralised configuration JSON with jq processing
scripts/wurp-terminal Build and deployment automation Bash with error handling
Function library Reusable build and utility functions Modular bash functions

🎯 Example Usage Scenarios

Basic Project Creation

# Simple project in current directory
./wurp-terminal-bootstrap.sh

# Custom location and name
./wurp-terminal-bootstrap.sh -p ~/workspace -n ai-terminal
cd ~/workspace/ai-terminal
./scripts/wurp-terminal install

Development Workflow

# Create development version with debug
./wurp-terminal-bootstrap.sh --debug -p ~/dev -n terminal-dev
cd ~/dev/terminal-dev

# Iterative development
./scripts/wurp-terminal build    # Quick build for testing
./scripts/wurp-terminal publish  # Optimised build
./scripts/wurp-terminal install  # Full installation

Production Deployment

# Create production version
./wurp-terminal-bootstrap.sh -p /opt -n company-terminal
cd /opt/company-terminal
./scripts/wurp-terminal install

# Verify installation
./scripts/wurp-terminal status
company-terminal --help

🌟 Why This Architecture Rocks

🧠 Maintainable Code

  • Single responsibility - Each module has one clear purpose
  • Easy debugging - Know exactly where to look for issues
  • Clean extensions - Add features without touching existing code

πŸš€ Developer Experience

  • Fast iterations - Modify only what you need
  • Debug mode - See exactly what's happening
  • Module isolation - Test components independently

πŸ“ˆ Scalable Design

  • Numbered modules - Clear dependency ordering
  • Graceful fallbacks - Works with or without modules
  • Future-ready - Easy to add new capabilities

πŸ”§ Code Quality & Maintainability

🎯 DRY Principle Implementation

Recent improvements focus on eliminating code duplication and improving maintainability:

Centralized Binary Search Functions

  • get_binary_search_paths() - Standardized .NET binary location paths
  • find_binary() - Unified binary location logic
  • check_binary_exists() - Quick existence validation
  • get_binary_relative_path() - Consistent path display

Before vs After Duplication Reduction

# BEFORE: Duplicated in 5+ functions across multiple files
local search_paths=(
    "bin/Release/net9.0/linux-x64/publish/$binary_name"
    "bin/Release/net9.0/publish/$binary_name"
    "bin/Release/net9.0/linux-x64/$binary_name"
    "bin/Release/net9.0/linux-x64/publish/$binary_name.dll"
    "bin/Release/net9.0/publish/$binary_name.dll"
)

# AFTER: Centralized in core module, reused everywhere
local actual_binary
if actual_binary=$(find_binary); then
    # Use the binary
fi

πŸ“Š Improvements Achieved

  • ⬇️ 60% Code Reduction - Eliminated ~15 lines per function
  • 🎯 Consistency - All functions use identical search logic
  • 🧹 Maintainability - Change paths in one place only
  • πŸ”„ Reusability - Functions exported across modules
  • πŸ›‘οΈ Error Handling - Improved error reporting
  • βœ… Compatibility - Maintained legacy and modular modes

πŸ“Š Current State

Complete: 65% βœ…

  • Core architecture βœ…
  • Centralized utility functions for common tasks βœ…
  • Reduced code duplication across scripts βœ…
  • File generation βœ…
  • Project structure βœ…
  • Basic build system βœ…

Remaining: 40% 🚧

  • Enhanced build operations
  • Shell/desktop integration
  • Service management
  • Advanced project management

Built with ❀️ using .NET 9, C# 12, and Modular Bash Architecture

Transform your terminal experience with AI-powered assistance and modern development practices.

About

Bootstrap scripts to get a developer started with the warp-terminal-clone repo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages