Skip to content

feat: add pactflow-ai / pact-ruby-standalone via extensions framework#8

Merged
YOU54F merged 1 commit intomainfrom
feat/extensions
Oct 25, 2025
Merged

feat: add pactflow-ai / pact-ruby-standalone via extensions framework#8
YOU54F merged 1 commit intomainfrom
feat/extensions

Conversation

@YOU54F
Copy link
Copy Markdown
Member

@YOU54F YOU54F commented Oct 25, 2025

feat: Add comprehensive extension system for Pact CLI

🎯 Summary

This PR introduces a powerful extension system to the Pact CLI that enables seamless installation, management, and execution of additional tools and legacy binaries. The system supports both modern Rust-based extensions (like PactFlow AI) and traditional Ruby-based tools (pact-standalone), with intelligent version tracking and cross-platform compatibility.

✨ Key Features

Extension Management

  • Install: Download and install extensions from remote sources
  • List: Display available extensions with installed/latest version comparison
  • Update: Update extensions to latest versions
  • Uninstall: Remove extensions and clean up associated files
  • Version Tracking: Show both installed and latest available versions

Command Integration

  • Seamless Execution: Extensions work as first-class CLI commands
  • PactFlow Integration: pact pactflow ai maps to pactflow-ai binary
  • External Subcommands: Support for pact extension <name> syntax
  • Dynamic Discovery: Automatically detects available pactflow commands from external crate

Platform Support

  • Cross-Platform: macOS (Intel/Apple Silicon), Linux (x64/ARM64), Windows (x64/ARM64)
  • Smart Binary Management: Handles platform-specific executables and archives
  • Permissions: Automatic executable permissions on Unix systems

🔧 Implementation Details

Core Components

ExtensionManager - Central management class handling:

  • Configuration persistence in ~/.pact/extensions/config.json
  • Platform detection and URL generation
  • Binary downloading with HTTP client (reqwest)
  • Archive extraction (tar.gz/zip)
  • Symlink creation for legacy tools

Extension Types:

  • PactflowAi - Modern Rust binaries from download.pactflow.io
  • PactRubyStandalone - Legacy Ruby tools from GitHub releases
  • External - User-installed binaries

CLI Integration:

  • New pact extension subcommand with full management capabilities
  • Enhanced pact pactflow command supporting external extensions
  • Async operation support using Tokio runtime

Technical Highlights

  1. Dynamic Command Resolution: Inspects external crate subcommands to avoid hardcoding known commands
  2. Version Intelligence:
    • PactFlow AI: Uses binary --version output parsing
    • Ruby Legacy: Records GitHub release tag during installation
    • Latest versions fetched from APIs in real-time
  3. Robust File Management: Handles directories vs files, symlinks, and cleanup properly
  4. Error Handling: Comprehensive error messages with helpful suggestions

Code Structure

src/cli/extension.rs          # Core extension management
├── ExtensionManager          # Main management logic
├── PlatformInfo             # Cross-platform support  
├── ExtensionConfig          # Configuration structures
└── CLI integration          # Subcommand handling

src/bin.rs                   # Enhanced main binary 
├── Extension command routing
├── PactFlow extension intercept
└── Dynamic command discovery

src/cli.rs                   # Updated CLI builder
├── Extension subcommand
├── PactFlow with extensions
└── External subcommand support

🧪 Testing

Verified Functionality

  • ✅ Extension installation (pactflow-ai, pact-ruby-standalone)
  • ✅ Version comparison and display
  • ✅ Command execution (pact pactflow ai --help)
  • ✅ Legacy tool symlink creation
  • ✅ Configuration persistence
  • ✅ Uninstallation and cleanup
  • ✅ Cross-platform URL generation
  • ✅ Error handling and user feedback

Example Usage

# Install extensions
pact extension install pactflow-ai
pact extension install pact-ruby-standalone

# List with version info
pact extension list
# Output:
# Name                 Type       Installed       Latest          Status    
# pactflow-ai          PactFlow AI 1.11.4         1.11.4          ✅ Installed
# pact-broker-legacy   Ruby Legacy v2.5.5         v2.5.5          ✅ Installed

# Use PactFlow AI seamlessly  
pact pactflow ai --help  # Maps to pactflow-ai binary

# Use legacy tools
pact extension pact-broker-legacy can-i-deploy --pacticipant my-app

📦 Dependencies Added

  • reqwest = "0.12.0" - HTTP client for downloading binaries
  • serde = "1.0" - Configuration serialization
  • serde_json = "1.0" - JSON handling for config files
  • home = "0.5.5" - Cross-platform home directory detection

🔄 Migration & Compatibility

  • Backward Compatible: No breaking changes to existing CLI functionality
  • Additive: All new features are opt-in via the extension subcommand
  • Storage: Extensions stored in ~/.pact/extensions/ (configurable via PACT_CLI_EXTENSIONS_HOME)
  • Integration: Works alongside existing pact-broker-cli, pact-plugin-cli, etc.

🎉 User Impact

This extension system bridges the gap between modern Pact tooling and legacy workflows, enabling users to:

  1. Adopt New Tools: Seamlessly use PactFlow AI without complex installation
  2. Maintain Legacy Support: Keep using Ruby-based tools with consistent interface
  3. Unified Experience: Single CLI for all Pact operations regardless of underlying technology
  4. Future-Proof: Easy adoption path for new Pact innovations

The system provides a foundation for the Pact CLI ecosystem to evolve while maintaining compatibility and ease of use.

```bash
# Install extensions
pact extension install pactflow-ai
pact extension install pact-ruby-standalone

# List with version info
pact extension list
# Output:
# Name                 Type       Installed       Latest          Status
# pactflow-ai          PactFlow AI 1.11.4         1.11.4          ✅ Installed
# pact-broker-legacy   Ruby Legacy v2.5.5         v2.5.5          ✅ Installed

# Use PactFlow AI seamlessly
pact pactflow ai --help  # Maps to pactflow-ai binary

# Use legacy tools
pact extension pact-broker-legacy can-i-deploy --pacticipant my-app
```
@YOU54F YOU54F merged commit 9a38529 into main Oct 25, 2025
17 checks passed
@mefellows
Copy link
Copy Markdown
Member

wow! Yousaf, I'll set aside some time next week to go through all of your CLI magic ✨

@YOU54F YOU54F deleted the feat/extensions branch November 8, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants