Skip to content

mission control for agent skills

Add release packaging and installers

Alvin Unreal9a1d291fddc1
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..0aff2e5
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,35 @@
+name: Release
+
+on:
+ push:
+ tags:
+ - "v*"
+
+permissions:
+ contents: write
+
+jobs:
+ goreleaser:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: go.mod
+
+ - name: Run tests
+ run: go test ./...
+
+ - name: Run GoReleaser
+ uses: goreleaser/goreleaser-action@v6
+ with:
+ distribution: goreleaser
+ version: latest
+ args: release --clean
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
+ SCOOP_BUCKET_GITHUB_TOKEN: ${{ secrets.SCOOP_BUCKET_GITHUB_TOKEN }}
diff --git a/.github/workflows/winget.yml b/.github/workflows/winget.yml
new file mode 100644
index 0000000..77570d9
--- /dev/null
+++ b/.github/workflows/winget.yml
@@ -0,0 +1,20 @@
+name: Publish to WinGet
+
+on:
+ release:
+ types: [released]
+
+permissions:
+ contents: read
+
+jobs:
+ publish:
+ runs-on: windows-latest
+ steps:
+ - name: Submit manifest PR to winget-pkgs
+ uses: vedantmgoyal9/winget-releaser@v2
+ with:
+ identifier: alvinunreal.lazyskills
+ installers-regex: 'lazyskills_Windows_.*\.zip'
+ max-versions-to-keep: 5
+ token: ${{ secrets.WINGET_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 5198f59..d76b090 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,8 @@
# Local asset scratch / dump folder — not for the repo
lfs/
+
+# Release/build output
+dist/
+/lazyskills
+/lazyskills.exe
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
new file mode 100644
index 0000000..f381f93
--- /dev/null
+++ b/.goreleaser.yaml
@@ -0,0 +1,124 @@
+version: 2
+
+project_name: lazyskills
+
+before:
+ hooks:
+ - go mod tidy
+
+builds:
+ - id: lazyskills
+ main: ./cmd/lazyskills
+ binary: lazyskills
+ env:
+ - CGO_ENABLED=0
+ goos:
+ - darwin
+ - linux
+ - windows
+ goarch:
+ - amd64
+ - arm64
+ ldflags:
+ - -s -w
+ - -X main.version={{.Version}}
+ - -X main.commit={{.Commit}}
+ - -X main.date={{.Date}}
+
+archives:
+ - id: default
+ ids:
+ - lazyskills
+ formats:
+ - tar.gz
+ format_overrides:
+ - goos: windows
+ formats:
+ - zip
+ name_template: >-
+ {{ .ProjectName }}_
+ {{- title .Os }}_
+ {{- if eq .Arch "amd64" }}x86_64
+ {{- else if eq .Arch "arm64" }}arm64
+ {{- else }}{{ .Arch }}{{ end }}
+ files:
+ - LICENSE
+ - README.md
+
+checksum:
+ name_template: checksums.txt
+
+nfpms:
+ - id: linux-packages
+ ids:
+ - lazyskills
+ package_name: lazyskills
+ vendor: alvinunreal
+ homepage: https://github.com/alvinunreal/lazyskills
+ maintainer: Alvin <[email protected]>
+ description: Mission control for agent skills to stay lazy.
+ license: MIT
+ formats:
+ - deb
+ - rpm
+ bindir: /usr/bin
+ contents:
+ - src: LICENSE
+ dst: /usr/share/doc/lazyskills/LICENSE
+ - src: README.md
+ dst: /usr/share/doc/lazyskills/README.md
+
+snapshot:
+ version_template: "{{ incpatch .Version }}-next"
+
+changelog:
+ sort: asc
+ filters:
+ exclude:
+ - "^docs:"
+ - "^test:"
+ - "^chore:"
+ - "merge conflict"
+ - Merge pull request
+ - Merge remote-tracking branch
+ - Merge branch
+
+release:
+ github:
+ owner: alvinunreal
+ name: lazyskills
+ draft: false
+ prerelease: auto
+ mode: replace
+ footer: |
+ ## Installation
+
+ ```bash
+ brew install --cask alvinunreal/tap/lazyskills
+ ```
+
+ ```bash
+ curl -fsSL https://raw.githubusercontent.com/alvinunreal/lazyskills/main/scripts/install.sh | sh
+ ```
+
+homebrew_casks:
+ - name: lazyskills
+ repository:
+ owner: alvinunreal
+ name: homebrew-tap
+ token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
+ directory: Casks
+ homepage: https://github.com/alvinunreal/lazyskills
+ description: Mission control for agent skills to stay lazy.
+ license: MIT
+
+scoops:
+ - name: lazyskills
+ repository:
+ owner: alvinunreal
+ name: scoop-bucket
+ token: "{{ .Env.SCOOP_BUCKET_GITHUB_TOKEN }}"
+ directory: bucket
+ homepage: https://github.com/alvinunreal/lazyskills
+ description: Mission control for agent skills to stay lazy.
+ license: MIT
diff --git a/README.md b/README.md
index 468fbff..37592e3 100644
--- a/README.md
+++ b/README.md
@@ -36,10 +36,97 @@ It is designed to complement the official `skills` CLI, not replace it.
✅ Source/repo-aware selection for grouped workflows
✅ Structured command execution with confirmation, captured output, and rescan after successful mutations
-## 🛠️ Install / build
+## 🛠️ Installation
+
+### Homebrew
```bash
-go build ./cmd/lazyskills
+brew install --cask alvinunreal/tap/lazyskills
+```
+
+### macOS / Linux install script
+
+```bash
+curl -fsSL https://raw.githubusercontent.com/alvinunreal/lazyskills/main/scripts/install.sh | sh
+```
+
+The script installs to `/usr/local/bin` by default and verifies the release checksum. To install somewhere else:
+
+```bash
+curl -fsSL https://raw.githubusercontent.com/alvinunreal/lazyskills/main/scripts/install.sh | sh -s -- -b ~/.local/bin
+```
+
+### Windows PowerShell
+
+```powershell
+iwr https://raw.githubusercontent.com/alvinunreal/lazyskills/main/scripts/install.ps1 -useb | iex
+```
+
+The PowerShell installer installs to `%LOCALAPPDATA%\Programs\lazyskills\bin` and adds it to your user PATH.
+
+### Windows Scoop
+
+```powershell
+scoop bucket add alvinunreal https://github.com/alvinunreal/scoop-bucket
+scoop install lazyskills
+```
+
+### Windows WinGet
+
+```powershell
+winget install alvinunreal.lazyskills
+```
+
+WinGet availability may lag behind GitHub Releases because new versions are submitted to `microsoft/winget-pkgs` as pull requests.
+
+### Go
+
+```bash
+go install github.com/alvinunreal/lazyskills/cmd/lazyskills@latest
+```
+
+### Nix experimental
+
+Run directly from GitHub:
+
+```bash
+nix run github:alvinunreal/lazyskills
+```
+
+Or from a local checkout:
+
+```bash
+nix run
+```
+
+### Manual download
+
+Download a binary archive from [GitHub Releases](https://github.com/alvinunreal/lazyskills/releases), verify it with `checksums.txt`, and place `lazyskills` on your PATH.
+
+### Linux packages
+
+LazySkills publishes `.deb` and `.rpm` packages for Linux amd64 and arm64 releases.
+
+Debian / Ubuntu:
+
+```bash
+curl -LO https://github.com/alvinunreal/lazyskills/releases/download/v0.1.0/lazyskills_0.1.0_linux_amd64.deb
+sudo apt install ./lazyskills_0.1.0_linux_amd64.deb
+```
+
+Fedora / RHEL / openSUSE:
+
+```bash
+curl -LO https://github.com/alvinunreal/lazyskills/releases/download/v0.1.0/lazyskills_0.1.0_linux_amd64.rpm
+sudo dnf install ./lazyskills_0.1.0_linux_amd64.rpm
+```
+
+Use the `arm64` package instead on ARM Linux machines.
+
+### Build from source
+
+```bash
+go build -o lazyskills ./cmd/lazyskills
```
Then run:
@@ -55,6 +142,12 @@ Or scan as JSON:
./lazyskills scan --json --cwd /path/to/project
```
+Check the installed version:
+
+```bash
+lazyskills version
+```
+
## ⌨️ Usage
```bash
@@ -114,3 +207,29 @@ The registry is manually ported for now. A generated parity check is a planned f
go test ./...
go build ./cmd/lazyskills
```
+
+## 🚢 Releases
+
+LazySkills uses [GoReleaser](https://goreleaser.com/) to publish cross-platform binaries, checksums, GitHub Releases, and the Homebrew formula.
+
+Release a new version by pushing a SemVer tag:
+
+```bash
+git tag v0.1.0
+git push origin v0.1.0
+```
+
+The release workflow builds:
+
+- macOS Intel and Apple Silicon
+- Linux amd64 and arm64
+- Windows amd64 and arm64
+- Linux `.deb` and `.rpm` packages
+
+Nix users can run LazySkills with `nix run github:alvinunreal/lazyskills` once the flake dependency hash is finalized.
+
+Homebrew publishing requires the repository secret `HOMEBREW_TAP_GITHUB_TOKEN` with permission to push to `alvinunreal/homebrew-tap`.
+
+Scoop publishing requires the repository secret `SCOOP_BUCKET_GITHUB_TOKEN` with permission to push to `alvinunreal/scoop-bucket`.
+
+WinGet publishing requires the repository secret `WINGET_TOKEN`, a classic GitHub token with `public_repo` scope. The first WinGet submission may need to be created manually before automated updates are accepted.
diff --git a/cmd/lazyskills/main.go b/cmd/lazyskills/main.go
index 4550387..009c1c1 100644
--- a/cmd/lazyskills/main.go
+++ b/cmd/lazyskills/main.go
@@ -6,8 +6,14 @@ import (
"fmt"
"os"
- "lazyskills/internal/scan"
- "lazyskills/internal/tui"
+ "github.com/alvinunreal/lazyskills/internal/scan"
+ "github.com/alvinunreal/lazyskills/internal/tui"
+)
+
+var (
+ version = "dev"
+ commit = "none"
+ date = "unknown"
)
func main() {
@@ -18,6 +24,10 @@ func main() {
}
func run(args []string) error {
+ if len(args) > 0 && (args[0] == "version" || args[0] == "--version" || args[0] == "-v") {
+ fmt.Fprintf(os.Stdout, "lazyskills %s\ncommit: %s\nbuilt: %s\n", version, commit, date)
+ return nil
+ }
if len(args) == 0 {
cwd, err := os.Getwd()
if err != nil {
@@ -33,7 +43,7 @@ func run(args []string) error {
return err
}
if fs.NArg() > 0 {
- return fmt.Errorf("usage: lazyskills [--cwd <path>] | lazyskills scan --json [--cwd <path>]")
+ return fmt.Errorf("usage: lazyskills [--cwd <path>] | lazyskills scan --json [--cwd <path>] | lazyskills version")
}
if *cwd == "" {
var err error
diff --git a/go.mod b/go.mod
index 43c7e05..4fbbe04 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module lazyskills
+module github.com/alvinunreal/lazyskills
go 1.26.3
diff --git a/internal/actions/actions.go b/internal/actions/actions.go
index 8059e8b..84d5fca 100644
--- a/internal/actions/actions.go
+++ b/internal/actions/actions.go
@@ -7,8 +7,8 @@ import (
"path/filepath"
"strings"
- "lazyskills/internal/compat"
- "lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/compat"
+ "github.com/alvinunreal/lazyskills/internal/model"
)
type CommandPreview struct {
diff --git a/internal/actions/actions_test.go b/internal/actions/actions_test.go
index 7aa95f7..bc9affe 100644
--- a/internal/actions/actions_test.go
+++ b/internal/actions/actions_test.go
@@ -5,7 +5,7 @@ import (
"strings"
"testing"
- "lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/model"
)
func init() {
diff --git a/internal/agents/agents.go b/internal/agents/agents.go
index 154852b..5489709 100644
--- a/internal/agents/agents.go
+++ b/internal/agents/agents.go
@@ -5,7 +5,7 @@ import (
"path/filepath"
"sort"
- "lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/model"
)
type Agent struct {
diff --git a/internal/compat/compat.go b/internal/compat/compat.go
index 211b72e..c33e963 100644
--- a/internal/compat/compat.go
+++ b/internal/compat/compat.go
@@ -4,7 +4,7 @@ import (
"regexp"
"strings"
- "lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/model"
)
var unsafeNameChars = regexp.MustCompile(`[^a-z0-9._]+`)
diff --git a/internal/compat/compat_test.go b/internal/compat/compat_test.go
index eaf8a85..5393b5a 100644
--- a/internal/compat/compat_test.go
+++ b/internal/compat/compat_test.go
@@ -3,7 +3,7 @@ package compat
import (
"testing"
- "lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/model"
)
func TestSanitizeLockDisplayKeepsRawSeparate(t *testing.T) {
diff --git a/internal/display/display.go b/internal/display/display.go
index 47539d1..bb50b94 100644
--- a/internal/display/display.go
+++ b/internal/display/display.go
@@ -4,8 +4,8 @@ import (
"fmt"
"strings"
- "lazyskills/internal/compat"
- "lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/compat"
+ "github.com/alvinunreal/lazyskills/internal/model"
)
type SkillView struct {
diff --git a/internal/display/display_test.go b/internal/display/display_test.go
index 5e815d5..25ca93c 100644
--- a/internal/display/display_test.go
+++ b/internal/display/display_test.go
@@ -6,7 +6,7 @@ import (
"strings"
"testing"
- "lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/model"
)
func TestSkillViewSanitizesRenderedFields(t *testing.T) {
diff --git a/internal/frontmatter/frontmatter.go b/internal/frontmatter/frontmatter.go
index 46fe31e..c68543b 100644
--- a/internal/frontmatter/frontmatter.go
+++ b/internal/frontmatter/frontmatter.go
@@ -5,7 +5,7 @@ import (
"os"
"regexp"
- "lazyskills/internal/compat"
+ "github.com/alvinunreal/lazyskills/internal/compat"
"gopkg.in/yaml.v3"
)
diff --git a/internal/locks/locks.go b/internal/locks/locks.go
index 6e6f752..1558a6f 100644
--- a/internal/locks/locks.go
+++ b/internal/locks/locks.go
@@ -5,7 +5,7 @@ import (
"os"
"path/filepath"
- "lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/model"
)
func ProjectLockPath(cwd string) string {
diff --git a/internal/runner/runner.go b/internal/runner/runner.go
index 8dc82da..e4564bc 100644
--- a/internal/runner/runner.go
+++ b/internal/runner/runner.go
@@ -8,7 +8,7 @@ import (
"strings"
"time"
- "lazyskills/internal/compat"
+ "github.com/alvinunreal/lazyskills/internal/compat"
)
const MaxOutputBytes = 32 * 1024
diff --git a/internal/scan/scan.go b/internal/scan/scan.go
index 0030e97..b45a5b6 100644
--- a/internal/scan/scan.go
+++ b/internal/scan/scan.go
@@ -9,11 +9,11 @@ import (
"sort"
"strings"
- "lazyskills/internal/agents"
- "lazyskills/internal/compat"
- "lazyskills/internal/frontmatter"
- "lazyskills/internal/locks"
- "lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/agents"
+ "github.com/alvinunreal/lazyskills/internal/compat"
+ "github.com/alvinunreal/lazyskills/internal/frontmatter"
+ "github.com/alvinunreal/lazyskills/internal/locks"
+ "github.com/alvinunreal/lazyskills/internal/model"
)
var LookPath = exec.LookPath
diff --git a/internal/scan/scan_test.go b/internal/scan/scan_test.go
index 43e683c..47ed9a8 100644
--- a/internal/scan/scan_test.go
+++ b/internal/scan/scan_test.go
@@ -6,7 +6,7 @@ import (
"path/filepath"
"testing"
- "lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/model"
)
func writeSkill(t *testing.T, dir, name, desc string) {
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 1866d91..b470514 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -14,14 +14,14 @@ import (
"github.com/charmbracelet/lipgloss"
"github.com/muesli/reflow/wordwrap"
- "lazyskills/internal/actions"
- "lazyskills/internal/agents"
- "lazyskills/internal/compat"
- "lazyskills/internal/display"
- "lazyskills/internal/frontmatter"
- "lazyskills/internal/model"
- "lazyskills/internal/runner"
- "lazyskills/internal/scan"
+ "github.com/alvinunreal/lazyskills/internal/actions"
+ "github.com/alvinunreal/lazyskills/internal/agents"
+ "github.com/alvinunreal/lazyskills/internal/compat"
+ "github.com/alvinunreal/lazyskills/internal/display"
+ "github.com/alvinunreal/lazyskills/internal/frontmatter"
+ "github.com/alvinunreal/lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/runner"
+ "github.com/alvinunreal/lazyskills/internal/scan"
)
type scopeFilter int
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index aa75563..f3b40c3 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -12,11 +12,11 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
- "lazyskills/internal/actions"
- "lazyskills/internal/compat"
- "lazyskills/internal/display"
- "lazyskills/internal/model"
- "lazyskills/internal/runner"
+ "github.com/alvinunreal/lazyskills/internal/actions"
+ "github.com/alvinunreal/lazyskills/internal/compat"
+ "github.com/alvinunreal/lazyskills/internal/display"
+ "github.com/alvinunreal/lazyskills/internal/model"
+ "github.com/alvinunreal/lazyskills/internal/runner"
)
func TestFilteredSkillsUsesSanitizedSearch(t *testing.T) {
diff --git a/scripts/install.ps1 b/scripts/install.ps1
new file mode 100644
index 0000000..d889f19
--- /dev/null
+++ b/scripts/install.ps1
@@ -0,0 +1,64 @@
+param(
+ [string]$Version = "latest",
+ [string]$BinDir = "$env:LOCALAPPDATA\Programs\lazyskills\bin",
+ [switch]$NoPathUpdate
+)
+
+$ErrorActionPreference = "Stop"
+
+$Owner = "alvinunreal"
+$Repo = "lazyskills"
+$Binary = "lazyskills.exe"
+
+$arch = switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) {
+ "X64" { "x86_64"; break }
+ "Arm64" { "arm64"; break }
+ default { throw "Unsupported architecture: $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)" }
+}
+
+$archive = "${Repo}_Windows_${arch}.zip"
+$baseUrl = "https://github.com/${Owner}/${Repo}/releases"
+if ($Version -eq "latest") {
+ $downloadUrl = "${baseUrl}/latest/download/${archive}"
+ $checksumUrl = "${baseUrl}/latest/download/checksums.txt"
+} else {
+ $downloadUrl = "${baseUrl}/download/${Version}/${archive}"
+ $checksumUrl = "${baseUrl}/download/${Version}/checksums.txt"
+}
+
+$tmp = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().ToString())
+New-Item -ItemType Directory -Path $tmp | Out-Null
+
+try {
+ $archivePath = Join-Path $tmp $archive
+ $checksumsPath = Join-Path $tmp "checksums.txt"
+
+ Write-Host "Downloading ${archive}..."
+ Invoke-WebRequest -Uri $downloadUrl -OutFile $archivePath
+ Invoke-WebRequest -Uri $checksumUrl -OutFile $checksumsPath
+
+ Write-Host "Verifying checksum..."
+ $expectedLine = Get-Content $checksumsPath | Where-Object { $_ -match [regex]::Escape($archive) } | Select-Object -First 1
+ if (-not $expectedLine) { throw "Checksum for ${archive} not found" }
+ $expected = ($expectedLine -split "\s+")[0].ToLowerInvariant()
+ $actual = (Get-FileHash -Algorithm SHA256 $archivePath).Hash.ToLowerInvariant()
+ if ($expected -ne $actual) { throw "Checksum mismatch for ${archive}" }
+
+ Expand-Archive -Path $archivePath -DestinationPath $tmp -Force
+
+ New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
+ Copy-Item -Path (Join-Path $tmp $Binary) -Destination (Join-Path $BinDir $Binary) -Force
+
+ if (-not $NoPathUpdate) {
+ $userPath = [Environment]::GetEnvironmentVariable("Path", "User")
+ $paths = @($userPath -split ";" | Where-Object { $_ })
+ if ($paths -notcontains $BinDir) {
+ [Environment]::SetEnvironmentVariable("Path", (($paths + $BinDir) -join ";"), "User")
+ Write-Host "Added ${BinDir} to your user PATH. Restart your terminal to use lazyskills everywhere."
+ }
+ }
+
+ & (Join-Path $BinDir $Binary) version
+} finally {
+ Remove-Item -Path $tmp -Recurse -Force -ErrorAction SilentlyContinue
+}
diff --git a/scripts/install.sh b/scripts/install.sh
new file mode 100755
index 0000000..92faf62
--- /dev/null
+++ b/scripts/install.sh
@@ -0,0 +1,122 @@
+#!/usr/bin/env sh
+set -eu
+
+OWNER="alvinunreal"
+REPO="lazyskills"
+BINARY="lazyskills"
+DEFAULT_BINDIR="/usr/local/bin"
+
+usage() {
+ cat <<EOF
+Install lazyskills from GitHub Releases.
+
+Usage:
+ install.sh [-b <bindir>] [-v <version>]
+
+Options:
+ -b <bindir> Install directory. Default: ${DEFAULT_BINDIR}
+ -v <version> Release version, for example v0.1.0. Default: latest.
+ -h Show this help.
+
+Examples:
+ curl -fsSL https://raw.githubusercontent.com/${OWNER}/${REPO}/main/scripts/install.sh | sh
+ curl -fsSL https://raw.githubusercontent.com/${OWNER}/${REPO}/main/scripts/install.sh | sh -s -- -b ~/.local/bin
+EOF
+}
+
+BINDIR="${BINDIR:-$DEFAULT_BINDIR}"
+VERSION="${VERSION:-latest}"
+
+while getopts "b:v:h" opt; do
+ case "$opt" in
+ b) BINDIR="$OPTARG" ;;
+ v) VERSION="$OPTARG" ;;
+ h) usage; exit 0 ;;
+ *) usage; exit 1 ;;
+ esac
+done
+
+need() {
+ if ! command -v "$1" >/dev/null 2>&1; then
+ echo "error: $1 is required" >&2
+ exit 1
+ fi
+}
+
+need curl
+need tar
+
+OS="$(uname -s)"
+ARCH="$(uname -m)"
+
+case "$OS" in
+ Darwin) GOOS="Darwin" ;;
+ Linux) GOOS="Linux" ;;
+ *) echo "error: unsupported OS: $OS" >&2; exit 1 ;;
+esac
+
+case "$ARCH" in
+ x86_64|amd64) GOARCH="x86_64" ;;
+ arm64|aarch64) GOARCH="arm64" ;;
+ *) echo "error: unsupported architecture: $ARCH" >&2; exit 1 ;;
+esac
+
+ARCHIVE="${REPO}_${GOOS}_${GOARCH}.tar.gz"
+BASE_URL="https://github.com/${OWNER}/${REPO}/releases"
+if [ "$VERSION" = "latest" ]; then
+ DOWNLOAD_URL="${BASE_URL}/latest/download/${ARCHIVE}"
+ CHECKSUM_URL="${BASE_URL}/latest/download/checksums.txt"
+else
+ DOWNLOAD_URL="${BASE_URL}/download/${VERSION}/${ARCHIVE}"
+ CHECKSUM_URL="${BASE_URL}/download/${VERSION}/checksums.txt"
+fi
+
+TMPDIR="$(mktemp -d)"
+cleanup() { rm -rf "$TMPDIR"; }
+trap cleanup EXIT INT TERM
+
+echo "Downloading ${ARCHIVE}..."
+curl -fsSL "$DOWNLOAD_URL" -o "$TMPDIR/$ARCHIVE"
+curl -fsSL "$CHECKSUM_URL" -o "$TMPDIR/checksums.txt"
+
+echo "Verifying checksum..."
+if command -v sha256sum >/dev/null 2>&1; then
+ (cd "$TMPDIR" && grep " ${ARCHIVE}$" checksums.txt | sha256sum -c -)
+elif command -v shasum >/dev/null 2>&1; then
+ (cd "$TMPDIR" && grep " ${ARCHIVE}$" checksums.txt | shasum -a 256 -c -)
+else
+ echo "warning: sha256sum or shasum not found; skipping checksum verification" >&2
+fi
+
+tar -xzf "$TMPDIR/$ARCHIVE" -C "$TMPDIR" "$BINARY"
+
+if [ ! -d "$BINDIR" ]; then
+ echo "Creating ${BINDIR}..."
+ if mkdir -p "$BINDIR" 2>/dev/null; then
+ :
+ elif command -v sudo >/dev/null 2>&1; then
+ sudo mkdir -p "$BINDIR"
+ else
+ echo "error: cannot create ${BINDIR}; choose another directory with -b" >&2
+ exit 1
+ fi
+fi
+
+TARGET="${BINDIR}/${BINARY}"
+echo "Installing to ${TARGET}..."
+if mv "$TMPDIR/$BINARY" "$TARGET" 2>/dev/null; then
+ chmod 755 "$TARGET"
+elif command -v sudo >/dev/null 2>&1; then
+ sudo mv "$TMPDIR/$BINARY" "$TARGET"
+ sudo chmod 755 "$TARGET"
+else
+ echo "error: cannot write to ${BINDIR}; choose another directory with -b" >&2
+ exit 1
+fi
+
+echo "Installed: $($TARGET version | tr '\n' ' ' | sed 's/ $//')"
+
+case ":$PATH:" in
+ *":$BINDIR:"*) ;;
+ *) echo "Note: ${BINDIR} is not on your PATH." ;;
+esac