Skip to main content

/build-installers Command

System Prompt

⚠️ EXECUTION DIRECTIVE: When the user invokes this command, you MUST:

  1. IMMEDIATELY execute - no questions, no explanations first
  2. ALWAYS show full output from script/tool execution
  3. ALWAYS provide summary after execution completes

DO NOT:

  • Say "I don't need to take action" - you ALWAYS execute when invoked
  • Ask for confirmation unless requires_confirmation: true in frontmatter
  • Skip execution even if it seems redundant - run it anyway

The user invoking the command IS the confirmation.


Purpose

Generate production-ready native installer scripts that download, verify, and install binaries across Unix/Linux/macOS and Windows platforms.

Usage

# Generate all installers
/build-installers --product coditect --cdn https://cdn.example.com

# Generate Unix installer only
/build-installers --product myapp --cdn https://cdn.example.com --platforms unix

# Custom output directory
/build-installers --product myapp --cdn https://cdn.example.com --output dist/installers/

# Embed specific version
/build-installers --product myapp --cdn https://cdn.example.com --version 1.2.0

# Use minimal template (no colors, simple output)
/build-installers --product myapp --cdn https://cdn.example.com --template minimal

Action Policy

Generated Files

FilePlatformUsage
install.shUnix/Linux/macOScurl -fsSL https://example.com/install.sh | bash
install.ps1Windowsirm https://example.com/install.ps1 | iex

Installer Features

Unix install.sh:

  • Platform detection (darwin/linux, x64/arm64, glibc/musl)
  • Manifest fetching from CDN
  • Binary download with curl/wget fallback
  • SHA256 checksum verification
  • Installation to ~/.local/bin (XDG compliant)
  • PATH configuration (bash/zsh/fish profiles)
  • Colored output with NO_COLOR support
  • Version selection (stable/latest/specific)

Windows install.ps1:

  • Architecture detection (AMD64/ARM64)
  • Manifest fetching with Invoke-RestMethod
  • Binary download with progress
  • SHA256 verification (Get-FileHash)
  • Installation to %LOCALAPPDATA%\product\bin
  • PATH environment variable update
  • Administrator elevation handling

Template Variables

VariableDescriptionExample
{{PRODUCT_NAME}}Product identifiercoditect
{{CDN_BASE}}CDN root URLhttps://cdn.example.com
{{VERSION}}Embedded version1.2.0
{{INSTALL_DIR}}Default install path~/.local/bin
{{CONFIG_DIR}}Config directory~/.config/product

Agent Delegation

This command delegates to native-installer-builder for:

  • Platform detection algorithm implementation
  • Checksum verification patterns
  • Shell scripting best practices
  • Error handling and user messaging

Output

Success Output

╭─────────────────────────────────────────────╮
│ Installers Generated Successfully │
├─────────────────────────────────────────────┤
│ Product: coditect │
│ CDN: https://cdn.example.com │
│ Version: 1.2.0 │
├─────────────────────────────────────────────┤
│ Generated: │
│ ✓ installers/install.sh (4.2 KB) │
│ ✓ installers/install.ps1 (3.8 KB) │
├─────────────────────────────────────────────┤
│ Usage: │
│ Unix: curl -fsSL .../install.sh | bash │
│ Windows: irm .../install.ps1 | iex │
╰─────────────────────────────────────────────╯

Validation Output

╭─────────────────────────────────────────────╮
│ Installer Validation │
├─────────────────────────────────────────────┤
│ install.sh: │
│ ✓ Shebang present │
│ ✓ set -e enabled │
│ ✓ Platform detection valid │
│ ✓ Checksum verification present │
│ ✓ ShellCheck passed │
├─────────────────────────────────────────────┤
│ install.ps1: │
│ ✓ Requires statement present │
│ ✓ ErrorActionPreference set │
│ ✓ Hash verification present │
│ ✓ PSScriptAnalyzer passed │
╰─────────────────────────────────────────────╯

Generated Script Structure

install.sh Structure

#!/bin/bash
# Product installer - generated by CODITECT

set -euo pipefail

# Configuration
CDN_BASE="https://cdn.example.com"
PRODUCT_NAME="coditect"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"

# Functions
detect_platform() # Detect OS and architecture
fetch_manifest() # Get release manifest from CDN
download_binary() # Download with progress
verify_checksum() # SHA256 verification
install_binary() # Install to target directory
configure_path() # Update shell profile
main() # Orchestrate installation

install.ps1 Structure

#Requires -Version 5.1
# Product installer - generated by CODITECT

param([string]$Version = "stable")

# Configuration
$CDN_BASE = "https://cdn.example.com"
$PRODUCT_NAME = "coditect"
$INSTALL_DIR = "$env:LOCALAPPDATA\$PRODUCT_NAME\bin"

# Functions
Get-PlatformKey # Detect architecture
Get-ReleaseManifest # Fetch manifest
Install-Binary # Download and verify
Add-ToPath # Update PATH
Install-Product # Orchestrate installation

Error Handling

Common Errors

Missing required argument:

ERROR: --product is required
FIX: Specify product name
/build-installers --product myapp --cdn https://cdn.example.com

Invalid CDN URL:

ERROR: Invalid CDN URL format
FIX: Provide full URL with protocol
--cdn https://storage.googleapis.com/mybucket

Examples


Clear Examples

Example 1: Full Installer Generation

Input:

/build-installers --product myapp --cdn https://cdn.example.com

Expected Output:

╭─────────────────────────────────────────────╮
│ Installers Generated Successfully │
├─────────────────────────────────────────────┤
│ Product: myapp │
│ CDN: https://cdn.example.com │
│ Version: latest │
├─────────────────────────────────────────────┤
│ Generated: │
│ ✓ installers/install.sh (4.2 KB) │
│ ✓ installers/install.ps1 (3.8 KB) │
╰─────────────────────────────────────────────╯

✅ COMMAND COMPLETE: /build-installers

Example 2: Unix-Only with Version

Input:

/build-installers --product myapp --cdn https://cdn.example.com --platforms unix --version 2.1.0

Expected Output:

╭─────────────────────────────────────────────╮
│ Installers Generated Successfully │
├─────────────────────────────────────────────┤
│ Product: myapp │
│ Version: 2.1.0 │
│ Platform: unix │
├─────────────────────────────────────────────┤
│ Generated: │
│ ✓ installers/install.sh (4.2 KB) │
╰─────────────────────────────────────────────╯

Recovery Steps

If this command fails:

  1. "--product is required" error

    • Cause: Missing product name
    • Fix: Add --product <name> to command
  2. "Invalid CDN URL format" error

    • Cause: URL missing protocol or malformed
    • Fix: Use full URL with https:// prefix
    • Example: --cdn https://storage.googleapis.com/mybucket
  3. Files not created

    • Cause: Output directory doesn't exist or no write permission
    • Fix: Create output directory first or use --output with valid path
  4. ShellCheck/PSScriptAnalyzer warnings

    • Cause: Generated scripts have minor issues
    • Fix: Review warnings in validation output, usually safe to ignore

Context Requirements

Before using this command, verify:

  • CDN URL is accessible and configured
  • Product name matches CDN bucket structure
  • Manifest file exists at CDN: {CDN_BASE}/manifest.json
  • Binary files exist at CDN for target platforms

Platform Requirements:

PlatformBinary NamingExample
darwin-x64{product}-darwin-x64myapp-darwin-x64
darwin-arm64{product}-darwin-arm64myapp-darwin-arm64
linux-x64{product}-linux-x64myapp-linux-x64
windows-x64{product}-windows-x64.exemyapp-windows-x64.exe

Standard Installer Generation

User: /build-installers --product coditect --cdn https://storage.googleapis.com/coditect-dist

Agent: I'll generate native installers for coditect.

[Creates install.sh with:]
- Platform detection for darwin-x64, darwin-arm64, linux-x64, linux-arm64, linux-x64-musl
- Manifest fetching from GCS
- SHA256 verification
- PATH configuration

[Creates install.ps1 with:]
- Windows x64 support
- PowerShell 5.1+ compatibility
- User PATH update

Generated:
- installers/install.sh
- installers/install.ps1