Skip to content

example42/sai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

SAI - Software Action Interface

CI Release Go Report Card License: MIT

SAI is a lightweight CLI tool for executing software management actions using provider-based configurations. The core philosophy is "Do everything on every software on every OS" through a unified interface.

πŸš€ Quick Start

Installation

Quick Install (Recommended)

Unix/Linux/macOS:

curl -fsSL https://raw.githubusercontent.com/example42/sai/main/scripts/install.sh | bash

Windows PowerShell:

iwr -useb https://raw.githubusercontent.com/example42/sai/main/scripts/install.ps1 | iex

Package Managers

Homebrew (macOS/Linux):

brew install example42/tap/sai

Scoop (Windows):

scoop bucket add example42 https://github.com/example42/scoop-bucket
scoop install sai

Manual Installation

  1. Download the latest release from GitHub Releases
  2. Extract the archive
  3. Move the binary to a directory in your PATH

First Steps

# Install software (auto-detects best provider)
sai install nginx

# Start a service
sai start nginx

# Check service status
sai status nginx

# View logs
sai logs nginx

# Get help
sai --help

πŸ“– Features

Universal Software Management

  • Install/Uninstall: sai install nginx, sai uninstall nginx
  • Upgrade: sai upgrade nginx
  • Search: sai search nginx
  • Information: sai info nginx, sai version nginx
  • List: sai list (all installed software)

Service Management

  • Control: sai start nginx, sai stop nginx, sai restart nginx
  • Boot Management: sai enable nginx, sai disable nginx
  • Status: sai status nginx
  • Configuration: sai config nginx

System Monitoring

  • Logs: sai logs nginx or sai logs (system logs)
  • Performance: sai cpu nginx, sai memory nginx, sai io nginx
  • Health: sai check nginx

Advanced Operations

  • Batch Operations: sai apply actions.yaml
  • System Statistics: sai stats
  • Repository Management: sai saidata

πŸ”§ Core Concepts

Provider-Based Architecture

SAI uses a dynamic provider system where all provider logic is defined in YAML files rather than hardcoded implementations:

  • Zero-Code Provider Addition: Add new providers by creating YAML files
  • Runtime Flexibility: Modify provider behavior without recompiling
  • Community Contributions: Non-Go developers can contribute providers
  • Cross-Platform: Automatic provider detection and prioritization

Intelligent Defaults

When software-specific configuration (saidata) isn't available, SAI generates intelligent defaults:

  • Package Names: Uses software name as default
  • Service Names: Uses software name as default service
  • Configuration Paths: Generates standard paths like /etc/{software}/
  • Safety Validation: Verifies resources exist before execution

Hierarchical Configuration

SAI supports OS-specific overrides with automatic environment detection:

software/ap/apache/
β”œβ”€β”€ default.yaml              # Base configuration
β”œβ”€β”€ ubuntu/22.04.yaml         # Ubuntu 22.04 specific
β”œβ”€β”€ centos/8.yaml             # CentOS 8 specific
└── macos/13.yaml             # macOS 13 specific

πŸ“‹ Usage Examples

Software Management

# Install with automatic provider detection
sai install docker

# Install with specific provider
sai install docker --provider apt

# Install with confirmation bypass
sai install docker --yes

# Dry run (show what would be executed)
sai install docker --dry-run

# Search across all providers
sai search docker

# Get detailed information
sai info docker

# Check versions across providers
sai version docker

# Upgrade to latest version
sai upgrade docker

# Uninstall software
sai uninstall docker

Service Management

# Start service
sai start apache

# Stop service
sai stop apache

# Restart service
sai restart apache

# Enable at boot
sai enable apache

# Disable at boot
sai disable apache

# Check status
sai status apache

# View configuration files
sai config apache

# Check if service is working
sai check apache

Monitoring and Troubleshooting

# View service logs
sai logs nginx

# View system logs
sai logs

# Monitor CPU usage
sai cpu nginx

# Monitor memory usage
sai memory nginx

# Monitor I/O statistics
sai io nginx

# System-wide monitoring
sai cpu
sai memory
sai io

Batch Operations

Create an actions.yaml file:

version: "0.1"
actions:
  - action: install
    software: nginx
    provider: apt
  - action: start
    software: nginx
  - action: enable
    software: nginx

Execute batch operations:

sai apply actions.yaml

Global Options

# Use custom configuration
sai install nginx --config /path/to/config.yaml

# Verbose output
sai install nginx --verbose

# Quiet mode
sai install nginx --quiet

# JSON output
sai list --json

# Force specific provider
sai install nginx --provider docker

# Auto-confirm all prompts
sai install nginx --yes

# Show commands without executing
sai install nginx --dry-run

πŸ—οΈ Building from Source

Prerequisites

  • Go 1.21 or later
  • Git

Build Commands

# Clone repository
git clone https://github.com/example42/sai.git
cd sai

# Build for current platform
make build

# Build for all platforms
make build-all

# Build optimized release binaries
make build-release

# Create distribution packages
make package

# Generate checksums
make checksums

# Install locally
make install

# Run tests
make test

# Run linter
make lint

# Clean build artifacts
make clean

Development

# Build with race detection
make build-dev

# Run with verbose output
make run -- --verbose

# Install development dependencies
make deps

# Verify build environment
make verify-env

πŸ“ Project Structure

β”œβ”€β”€ cmd/sai/                   # Main application entry point
β”œβ”€β”€ internal/                  # Private application code
β”‚   β”œβ”€β”€ cli/                   # CLI command implementations
β”‚   β”œβ”€β”€ action/                # Action management and orchestration
β”‚   β”œβ”€β”€ provider/              # Provider loading and management
β”‚   β”œβ”€β”€ saidata/               # Software data management
β”‚   β”œβ”€β”€ template/              # Template engine and functions
β”‚   β”œβ”€β”€ executor/              # Command execution
β”‚   β”œβ”€β”€ config/                # Configuration management
β”‚   β”œβ”€β”€ logger/                # Structured logging
β”‚   └── ...                    # Other internal packages
β”œβ”€β”€ docs/                      # Documentation and examples
β”‚   β”œβ”€β”€ saidata_samples/       # Example software configurations
β”‚   └── *.md                   # Documentation files
β”œβ”€β”€ providers/                 # Provider implementation files
β”‚   β”œβ”€β”€ specialized/           # Specialized operational providers
β”‚   └── *.yaml                 # Standard provider definitions
β”œβ”€β”€ schemas/                   # JSON Schema validation files
β”œβ”€β”€ scripts/                   # Installation and utility scripts
β”œβ”€β”€ .github/workflows/         # CI/CD workflows
β”œβ”€β”€ Makefile                   # Build configuration
β”œβ”€β”€ Dockerfile                 # Container build configuration
β”œβ”€β”€ .goreleaser.yml           # Release automation configuration
└── go.mod                     # Go module definition

πŸ”Œ Supported Providers

Package Managers

  • apt (Debian/Ubuntu)
  • brew (macOS/Linux)
  • dnf (Fedora/RHEL)
  • yum (CentOS/RHEL)
  • pacman (Arch Linux)
  • zypper (openSUSE)
  • apk (Alpine Linux)
  • pkg (FreeBSD)
  • choco (Windows)
  • winget (Windows)
  • scoop (Windows)

Container Platforms

  • docker (Docker containers)
  • helm (Kubernetes packages)

Language Package Managers

  • npm (Node.js)
  • pip (Python)
  • gem (Ruby)
  • cargo (Rust)
  • go (Go modules)
  • maven (Java)
  • gradle (Java/Kotlin)
  • composer (PHP)
  • nuget (.NET)

Specialized Providers

  • Security: Vulnerability scanning, SBOM generation
  • Debugging: GDB integration, performance profiling
  • Operations: Backup/restore, network analysis
  • Monitoring: Resource usage, performance metrics

🌍 Platform Support

SAI works on:

  • Linux (all major distributions)
  • macOS (Intel and Apple Silicon)
  • Windows (x64 and ARM64)

Automatic environment detection includes:

  • Platform identification (linux, darwin, windows)
  • OS distribution detection (ubuntu, centos, fedora, etc.)
  • Version resolution (22.04, 8, 13.0, etc.)
  • Architecture detection (amd64, arm64)

βš™οΈ Configuration

Configuration File

SAI looks for configuration files in:

  1. --config flag path
  2. ./sai.yaml
  3. ~/.config/sai/config.yaml
  4. /etc/sai/config.yaml

Example configuration:

saidata_repository: "https://github.com/example42/saidata.git"
default_provider: ""
provider_priority:
  apt: 100
  brew: 90
  docker: 80
timeout: 300s
log_level: "info"

confirmations:
  install: true
  uninstall: true
  system_changes: true
  info_commands: false

output:
  provider_color: "blue"
  command_style: "bold"
  success_color: "green"
  error_color: "red"
  show_commands: true
  show_exit_codes: true

repository:
  git_url: "https://github.com/example42/saidata.git"
  local_path: "~/.cache/sai/saidata"
  update_interval: "24h"
  offline_mode: false

Environment Variables

  • SAI_CONFIG: Configuration file path
  • SAI_PROVIDER: Default provider
  • SAI_VERBOSE: Enable verbose output
  • SAI_DRY_RUN: Enable dry-run mode
  • SAI_YES: Auto-confirm prompts
  • SAI_QUIET: Enable quiet mode

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Contribution Steps

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Run make test lint
  6. Submit a pull request

Adding Providers

Create a new provider by adding a YAML file to the providers/ directory:

version: "1.0"
provider:
  name: "my-provider"
  type: "package_manager"
  platforms: ["linux", "darwin"]
  executable: "my-package-manager"
actions:
  install:
    description: "Install software package"
    template: "my-package-manager install {{sai_package}}"
    validation:
      command: "my-package-manager list | grep {{sai_package}}"

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Cobra for CLI framework
  • Viper for configuration management
  • All contributors and community members

πŸ“ž Support


SAI CLI - Do everything on every software on every OS πŸš€

About

WIP

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages