Skill: bytesagain3/score (version 2.0.2)

--- name: score version: "2.0.0" author: BytesAgain homepage: https://bytesagain.com source: https://github.com/bytesagain/ai-skills license: MIT-0 tags: [score, tool, utility] description: "Track game scores, brackets, and player statistics. Use when recording results, scoring rounds, ranking leaderboards, reviewing game history, computing stats." --- # Score Gaming toolkit for tracking scores, rankings, challenges, leaderboards, and rewards from the command line. Log entries, review history, export data, and search across all records. ## Overview Score is a versatile CLI tool for game and competition tracking. Each command logs or retrieves entries with timestamps. Pass arguments to record new data, or run a command with no arguments to view recent entries. Built-in utilities provide statistics, data export, search, and health checks. ## Commands | Command | Description | |---------|-------------| | `score roll [input]` | Log a roll entry, or view recent rolls | | `score score [input]` | Log a score entry, or view recent scores | | `score rank [input]` | Log a rank entry, or view recent rankings | | `score history [input]` | Log a history note, or view recent history | | `score stats [input]` | Log a stats note, or view recent stats entries | | `score challenge [input]` | Log a challenge, or view recent challenges | | `score create [input]` | Log a creation event, or view recent creates | | `score join [input]` | Log a join event, or view recent joins | | `score track [input]` | Log a tracking entry, or view recent tracks | | `score leaderboard [input]` | Log a leaderboard entry, or view recent standings | | `score reward [input]` | Log a reward, or view recent rewards | | `score reset [input]` | Log a reset event, or view recent resets | | `score stats` | Show summary statistics across all log files | | `score export <fmt>` | Export all data (json, csv, or txt) | | `score search <term>` | Search all entries for a term | | `score recent` | Show last 20 lines of activity history | | `score status` | Health check (version, entries, disk usage, last activity) | | `score help` | Show usage help | | `score version` | Show version (v2.0.0) | ## Data Storage - **Location:** `~/.local/share/score/` - **Per-command logs:** Each command (roll, score, rank, etc.) writes to its own `<command>.log` file - **History:** `history.log` — timestamped action log recording every operation - **Export:** `export.<fmt>` — generated export files (json, csv, txt) - Format: `YYYY-MM-DD HH:MM|value` per line in each log file - All data is plain text. No database or cloud service. ## Requirements - bash (with `set -euo pipefail`) - Standard Unix utilities (`date`, `wc`, `du`, `tail`, `grep`, `cat`, `head`) - No external dependencies or API keys ## When to Use 1. **Tracking game scores** — Use `score score "Player1 25pts"` to log scores during a game night or tournament 2. **Running leaderboards** — Use `score leaderboard "Player1 #1"` to maintain standings, then `score export csv` for spreadsheets 3. **Dice rolling & randomness** — Log dice results with `score roll "d20: 17"` for tabletop RPG sessions 4. **Challenge tracking** — Create and track challenges between players with `score challenge "speed run level 3"` 5. **Data analysis & export** — Use `score stats` for summary counts, `score search` to find specific entries, and `score export json` for programmatic analysis ## Examples ```bash # Log a dice roll score roll "d20: natural 17" # Output: [Score] roll: d20: natural 17 # Saved. Total roll entries: 1 # Record a game score score score "Alice 2500pts round-3" # Output: [Score] score: Alice 2500pts round-3 # Saved. Total score entries: 1 # Update the leaderboard score leaderboard "Alice #1, Bob #2, Charlie #3" ``` ```bash # View recent rolls (no argument = read mode) score roll # Check overall statistics score stats # Output: history: 5 entries # roll: 3 entries # Total: 8 entries # Data size: 4.0K # Search across all entries score search "Alice" ``` ```bash # Export everything as JSON score export json # Output: Exported to ~/.local/share/score/export.json (245 bytes) # Export as CSV for spreadsheets score export csv # Check system health score status # Output: Version: v2.0.0, Data dir, Entries count, Disk usage, Last activity # View recent activity score recent ``` ## How It Works Each domain command (roll, score, rank, challenge, etc.) has dual behavior: - **With arguments:** Appends a timestamped entry to `<command>.log` and logs the action to `history.log` - **Without arguments:** Displays the last 20 entries from that command's log file The `stats` utility aggregates entry counts across all log files. The `export` command converts all logs into JSON, CSV, or plain text format. The `search` command performs case-insensitive grep across every log file. ## Tips - Each command is its own namespace — you can track dozens of game types simultaneously - Use `recent` for a quick dashboard of the last 20 actions - Pipe `export json` output to `jq` for advanced analysis - Override data directory: `export SCORE_DIR=...` (set in your environment before sourcing) --- Powered by BytesAgain | bytesagain.com | [REDACTED_SECRET]

path: scripts/script.sh
content: #!/usr/bin/env bash
# Score — gaming tool
# Powered by BytesAgain | bytesagain.com | [REDACTED_SECRET]
set -euo pipefail

DATA_DIR="${HOME}/.local/share/score"
mkdir -p "$DATA_DIR"

_log() { echo "$(date '+%m-%d %H:%M') $1: $2" >> "$DATA_DIR/history.log"; }
_version() { echo "score v2.0.0"; }

_help() {
    echo "Score v2.0.0 — gaming toolkit"
    echo ""
    echo "Usage: score <command> [args]"
    echo ""
    echo "Commands:"
    echo "  roll               Roll"
    echo "  score              Score"
    echo "  rank               Rank"
    echo "  history            History"
    echo "  stats              Stats"
    echo "  challenge          Challenge"
    echo "  create             Create"
    echo "  join               Join"
    echo "  track              Track"
    echo "  leaderboard        Leaderboard"
    echo "  reward             Reward"
    echo "  reset              Reset"
    echo "  stats              Summary statistics"
    echo "  export <fmt>       Export (json|csv|txt)"
    echo "  search <term>      Search entries"
    echo "  recent             Recent activity"
    echo "  status             Health check"
    echo "  help               Show this help"
    echo "  version            Show version"
    echo ""
    echo "Data: $DATA_DIR"
}

_stats() {
    echo "=== Score Stats ==="
    local total=0
    for f in "$DATA_DIR"/*.log; do
        [ -f "$f" ] || continue
        local name=$(basename "$f" .log)
        local c=$(wc -l < "$f")
        total=$((total + c))
        echo "  $name: $c entries"
    done
    echo "  ---"
    echo "  Total: $total entries"
    echo "  Data size: $(du -sh "$DATA_DIR" 2>/dev/null | cut -f1)"
}

_export() {
    local fmt="${1:-json}"
    local out="$DATA_DIR/export.$fmt"
    case "$fmt" in
        json)
            echo "[" > "$out"
            local first=1
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                local name=$(basename "$f" .log)
                while IFS='|' read -r ts val; do
                    [ $first -eq 1 ] && first=0 || echo "," >> "$out"
                    printf '  {"type":"%s","time":"%s","value":"%s"}' "$name" "$ts" "$val" >> "$out"
                done < "$f"
            done
            echo "\n]" >> "$out"
            ;;
        csv)
            echo "type,time,value" > "$out"
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                local name=$(basename "$f" .log)
                while IFS='|' read -r ts val; do echo "$name,$ts,$val" >> "$out"; done < "$f"
            done
            ;;
        txt)
            echo "=== Score Export ===" > "$out"
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                echo "--- $(basename "$f" .log) ---" >> "$out"
                cat "$f" >> "$out"
            done
            ;;
        *) echo "Formats: json, csv, txt"; return 1 ;;
    esac
    echo "Exported to $out ($(wc -c < "$out") bytes)"
}

_status() {
    echo "=== Score Status ==="
    echo "  Version: v2.0.0"
    echo "  Data dir: $DATA_DIR"
    echo "  Entries: $(cat "$DATA_DIR"/*.log 2>/dev/null | wc -l) total"
    echo "  Disk: $(du -sh "$DATA_DIR" 2>/dev/null | cut -f1)"
    echo "  Last: $(tail -1 "$DATA_DIR/history.log" 2>/dev/null || echo never)"
    echo "  Status: OK"
}

_search() {
    local term="${1:?Usage: score search <term>}"
    echo "Searching for: $term"
    for f in "$DATA_DIR"/*.log; do
        [ -f "$f" ] || continue
        local m=$(grep -i "$term" "$f" 2>/dev/null || true)
        if [ -n "$m" ]; then
            echo "  --- $(basename "$f" .log) ---"
            echo "$m" | sed 's/^/    /'
        fi
    done
}

_recent() {
    echo "=== Recent Activity ==="
    tail -20 "$DATA_DIR/history.log" 2>/dev/null | sed 's/^/  /' || echo "  No activity yet."
}

case "${1:-help}" in
    roll)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent roll entries:"
            tail -20 "$DATA_DIR/roll.log" 2>/dev/null || echo "  No entries yet. Use: score roll <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/roll.log"
            local total=$(wc -l < "$DATA_DIR/roll.log")
            echo "  [Score] roll: $input"
            echo "  Saved. Total roll entries: $total"
            _log "roll" "$input"
        fi
        ;;
    score)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent score entries:"
            tail -20 "$DATA_DIR/score.log" 2>/dev/null || echo "  No entries yet. Use: score score <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/score.log"
            local total=$(wc -l < "$DATA_DIR/score.log")
            echo "  [Score] score: $input"
            echo "  Saved. Total score entries: $total"
            _log "score" "$input"
        fi
        ;;
    rank)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent rank entries:"
            tail -20 "$DATA_DIR/rank.log" 2>/dev/null || echo "  No entries yet. Use: score rank <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/rank.log"
            local total=$(wc -l < "$DATA_DIR/rank.log")
            echo "  [Score] rank: $input"
            echo "  Saved. Total rank entries: $total"
            _log "rank" "$input"
        fi
        ;;
    history)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent history entries:"
            tail -20 "$DATA_DIR/history.log" 2>/dev/null || echo "  No entries yet. Use: score history <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/history.log"
            local total=$(wc -l < "$DATA_DIR/history.log")
            echo "  [Score] history: $input"
            echo "  Saved. Total history entries: $total"
            _log "history" "$input"
        fi
        ;;
    stats)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent stats entries:"
            tail -20 "$DATA_DIR/stats.log" 2>/dev/null || echo "  No entries yet. Use: score stats <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/stats.log"
            local total=$(wc -l < "$DATA_DIR/stats.log")
            echo "  [Score] stats: $input"
            echo "  Saved. Total stats entries: $total"
            _log "stats" "$input"
        fi
        ;;
    challenge)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent challenge entries:"
            tail -20 "$DATA_DIR/challenge.log" 2>/dev/null || echo "  No entries yet. Use: score challenge <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/challenge.log"
            local total=$(wc -l < "$DATA_DIR/challenge.log")
            echo "  [Score] challenge: $input"
            echo "  Saved. Total challenge entries: $total"
            _log "challenge" "$input"
        fi
        ;;
    create)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent create entries:"
            tail -20 "$DATA_DIR/create.log" 2>/dev/null || echo "  No entries yet. Use: score create <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/create.log"
            local total=$(wc -l < "$DATA_DIR/create.log")
            echo "  [Score] create: $input"
            echo "  Saved. Total create entries: $total"
            _log "create" "$input"
        fi
        ;;
    join)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent join entries:"
            tail -20 "$DATA_DIR/join.log" 2>/dev/null || echo "  No entries yet. Use: score join <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/join.log"
            local total=$(wc -l < "$DATA_DIR/join.log")
            echo "  [Score] join: $input"
            echo "  Saved. Total join entries: $total"
            _log "join" "$input"
        fi
        ;;
    track)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent track entries:"
            tail -20 "$DATA_DIR/track.log" 2>/dev/null || echo "  No entries yet. Use: score track <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/track.log"
            local total=$(wc -l < "$DATA_DIR/track.log")
            echo "  [Score] track: $input"
            echo "  Saved. Total track entries: $total"
            _log "track" "$input"
        fi
        ;;
    leaderboard)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent leaderboard entries:"
            tail -20 "$DATA_DIR/leaderboard.log" 2>/dev/null || echo "  No entries yet. Use: score leaderboard <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/leaderboard.log"
            local total=$(wc -l < "$DATA_DIR/leaderboard.log")
            echo "  [Score] leaderboard: $input"
            echo "  Saved. Total leaderboard entries: $total"
            _log "leaderboard" "$input"
        fi
        ;;
    reward)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent reward entries:"
            tail -20 "$DATA_DIR/reward.log" 2>/dev/null || echo "  No entries yet. Use: score reward <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/reward.log"
            local total=$(wc -l < "$DATA_DIR/reward.log")
            echo "  [Score] reward: $input"
            echo "  Saved. Total reward entries: $total"
            _log "reward" "$input"
        fi
        ;;
    reset)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent reset entries:"
            tail -20 "$DATA_DIR/reset.log" 2>/dev/null || echo "  No entries yet. Use: score reset <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/reset.log"
            local total=$(wc -l < "$DATA_DIR/reset.log")
            echo "  [Score] reset: $input"
            echo "  Saved. Total reset entries: $total"
            _log "reset" "$input"
        fi
        ;;
    stats) _stats ;;
    export) shift; _export "$@" ;;
    search) shift; _search "$@" ;;
    recent) _recent ;;
    status) _status ;;
    help|--help|-h) _help ;;
    version|--version|-v) _version ;;
    *)
        echo "Unknown: $1 — run 'score help'"
        exit 1
        ;;
esac

Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)