feat: add npx-style zero-install runner

Add run.sh that downloads and caches skillshare binary for execution
without requiring global installation. The binary is cached in
~/.cache/skillshare/ and auto-updates every 24 hours.

Update skillshare skill to use runner function for zero-install support.
This commit is contained in:
Willie Hung
2026-01-16 20:25:31 +08:00
parent fd2c69dbc5
commit cf14445c7e
3 changed files with 192 additions and 3 deletions
+27 -2
View File
@@ -47,8 +47,33 @@ skillshare pull claude && skillshare sync # Pull from Claude → sync to all
| 🔍 Diagnostics | `doctor` checks git, broken links, duplicates |
| 🤖 AI-native | Built-in skill lets your AI manage everything |
## AI-Native Execution
The built-in [`skillshare` skill](https://github.com/runkids/skillshare/tree/main/skills/skillshare) enables your AI CLI to manage skills directly — **no manual installation required**.
```text
┌─────────────────────────────────────────────────────────────┐
│ User: "sync my skills to all targets" │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ AI reads skillshare skill │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ skillshare sync │
│ ✓ Synced 5 skills to claude, codex, cursor │
└─────────────────────────────────────────────────────────────┘
```
> [!TIP]
> **Let your AI manage skills.** Just say: *"Pull my new skill from Claude and sync to all targets."*
> The skill automatically downloads the binary on first use — just say:
> - *"Show my skillshare status"*
> - *"Sync my skills to all targets"*
> - *"Pull skills from Claude and sync everywhere"*
> - *"Install the pdf skill from anthropics/skills"*
## Installation
@@ -58,7 +83,7 @@ skillshare pull claude && skillshare sync # Pull from Claude → sync to all
curl -fsSL https://raw.githubusercontent.com/runkids/skillshare/main/install.sh | sh
```
Works on macOS and Linux. Automatically detects your system and installs the latest version.
Installs to `/usr/local/bin/`. Works on macOS and Linux.
### Homebrew (macOS)
Executable
+135
View File
@@ -0,0 +1,135 @@
#!/bin/sh
# skillshare runner - npx-style execution without installation
# Usage: curl -fsSL https://raw.githubusercontent.com/runkids/skillshare/main/run.sh | sh -s -- [command] [args]
# Or: sh run.sh [command] [args]
set -e
REPO="runkids/skillshare"
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/skillshare"
BIN_DIR="$CACHE_DIR/bin"
BINARY="$BIN_DIR/skillshare"
VERSION_FILE="$CACHE_DIR/.version"
MAX_AGE=86400 # Check for updates every 24 hours
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'
info() { printf "${CYAN}[skillshare]${NC} %s\n" "$1" >&2; }
success() { printf "${GREEN}[skillshare]${NC} %s\n" "$1" >&2; }
warn() { printf "${YELLOW}[skillshare]${NC} %s\n" "$1" >&2; }
error() { printf "${RED}[skillshare]${NC} %s\n" "$1" >&2; exit 1; }
# Detect OS
detect_os() {
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$OS" in
darwin) OS="darwin" ;;
linux) OS="linux" ;;
mingw*|msys*|cygwin*) error "Windows is not supported via this script. Please download from GitHub releases." ;;
*) error "Unsupported OS: $OS" ;;
esac
}
# Detect architecture
detect_arch() {
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64) ARCH="amd64" ;;
arm64|aarch64) ARCH="arm64" ;;
*) error "Unsupported architecture: $ARCH" ;;
esac
}
# Get file modification time in seconds since epoch (cross-platform)
get_file_age() {
if [ "$(uname -s)" = "Darwin" ]; then
stat -f %m "$1" 2>/dev/null || echo 0
else
stat -c %Y "$1" 2>/dev/null || echo 0
fi
}
# Check if we need to update (version file older than MAX_AGE)
needs_update() {
[ ! -f "$VERSION_FILE" ] && return 0
[ ! -x "$BINARY" ] && return 0
file_time=$(get_file_age "$VERSION_FILE")
current_time=$(date +%s)
age=$((current_time - file_time))
[ "$age" -ge "$MAX_AGE" ]
}
# Get latest version from GitHub API
get_latest_version() {
LATEST=$(curl -sL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)
if [ -z "$LATEST" ]; then
error "Failed to get latest version. Check your internet connection."
fi
VERSION=${LATEST#v}
}
# Download and install to cache
download_binary() {
detect_os
detect_arch
get_latest_version
URL="https://github.com/${REPO}/releases/download/${LATEST}/skillshare_${VERSION}_${OS}_${ARCH}.tar.gz"
info "Downloading skillshare ${VERSION} for ${OS}/${ARCH}..."
mkdir -p "$BIN_DIR"
TMP_DIR=$(mktemp -d)
trap "rm -rf $TMP_DIR" EXIT
if ! curl -sL "$URL" | tar xz -C "$TMP_DIR" 2>/dev/null; then
error "Failed to download. URL: $URL"
fi
if [ ! -f "$TMP_DIR/skillshare" ]; then
error "Binary not found in archive"
fi
mv "$TMP_DIR/skillshare" "$BINARY"
chmod +x "$BINARY"
echo "$VERSION" > "$VERSION_FILE"
success "Cached skillshare ${VERSION} at ${BIN_DIR}"
}
# Main logic
main() {
# 1. Check if skillshare is already in PATH
if command -v skillshare >/dev/null 2>&1; then
exec skillshare "$@"
fi
# 2. Check cached binary
if [ -x "$BINARY" ]; then
if ! needs_update; then
exec "$BINARY" "$@"
fi
# Try to update, but fall back to cached version on failure
if download_binary 2>/dev/null; then
exec "$BINARY" "$@"
else
warn "Update check failed, using cached version"
touch "$VERSION_FILE" # Reset timer
exec "$BINARY" "$@"
fi
fi
# 3. First run - download binary
download_binary
exec "$BINARY" "$@"
}
main "$@"
+30 -1
View File
@@ -1,6 +1,6 @@
---
name: skillshare
version: 0.4.0
version: 0.5.0
description: Manage and sync skills across AI CLI tools. Use when asked to "sync my skills", "pull skills", "show skillshare status", "list my skills", "install a skill", "create a new skill", "backup skills", or manage skill targets.
argument-hint: "[command] [target] [--dry-run]"
---
@@ -9,6 +9,35 @@ argument-hint: "[command] [target] [--dry-run]"
Manage and sync skills across multiple AI CLI tools from a single source of truth.
## Zero-Install Execution
**IMPORTANT:** Before running any `skillshare` command, use this runner function to ensure skillshare is available (downloads to cache if not installed):
```bash
skillshare_run() {
if command -v skillshare >/dev/null 2>&1; then
skillshare "$@"
elif [ -x "${XDG_CACHE_HOME:-$HOME/.cache}/skillshare/bin/skillshare" ]; then
"${XDG_CACHE_HOME:-$HOME/.cache}/skillshare/bin/skillshare" "$@"
else
curl -fsSL https://raw.githubusercontent.com/runkids/skillshare/main/run.sh | sh -s -- "$@"
fi
}
```
Use `skillshare_run` instead of `skillshare` for all commands. Example:
```bash
skillshare_run status
skillshare_run sync --dry-run
```
Or run directly without defining the function:
```bash
curl -fsSL https://raw.githubusercontent.com/runkids/skillshare/main/run.sh | sh -s -- status
```
## When to Use This Skill
Activate when the user: