Skill: ckchzh/calctool (version 2.0.1)

--- name: CalcTool description: "Perform basic, scientific, and financial calculations from the terminal. Use when computing interest, converting units, or solving quick math." version: "2.0.0" author: "BytesAgain" homepage: https://bytesagain.com source: https://github.com/bytesagain/ai-skills tags: ["calculator","math","arithmetic","scientific","convert","finance","utility"] categories: ["Utility", "Productivity"] --- # CalcTool Utility toolkit — run, check, convert, analyze, generate, preview, batch, compare, and manage data entries. Each command logs input with timestamps for full traceability and review. ## Commands | Command | Description | |---------|-------------| | `calctool run <input>` | Log a run entry (no args = view recent runs) | | `calctool check <input>` | Log a check entry (no args = view recent checks) | | `calctool convert <input>` | Log a convert entry (no args = view recent converts) | | `calctool analyze <input>` | Log an analyze entry (no args = view recent analyses) | | `calctool generate <input>` | Log a generate entry (no args = view recent generates) | | `calctool preview <input>` | Log a preview entry (no args = view recent previews) | | `calctool batch <input>` | Log a batch entry (no args = view recent batches) | | `calctool compare <input>` | Log a compare entry (no args = view recent compares) | | `calctool export <input>` | Log an export entry (no args = view recent exports) | | `calctool config <input>` | Log a config entry (no args = view recent configs) | | `calctool status <input>` | Log a status entry (no args = view recent statuses) | | `calctool report <input>` | Log a report entry (no args = view recent reports) | | `calctool stats` | Summary statistics — entry counts per category, total, data size | | `calctool search <term>` | Search across all log entries | | `calctool recent` | Show last 20 history entries | | `calctool help` | Show usage info | | `calctool version` | Show version string | > **Note:** The `export` and `status` commands in the case dispatch also have utility variants (`_export <fmt>` and `_status`) that provide structured export (json/csv/txt) and health check output respectively. However, the primary case match routes to the logging version. ## Data Storage All data is stored locally in `~/.local/share/calctool/`. Each command writes to its own `.log` file (e.g., `run.log`, `check.log`, `analyze.log`). A unified `history.log` records every action with timestamps. No external services or databases required. **Log format:** `YYYY-MM-DD HH:MM|<value>` **Export formats:** JSON, CSV, or plain text (via the `_export` helper function). ## Requirements - **bash** (version 4+ recommended) - Standard POSIX utilities: `date`, `wc`, `du`, `grep`, `tail`, `head`, `cat` - No external dependencies, no network access needed - Works on Linux, macOS, and WSL ## When to Use 1. **Logging calculation results** — Record computations, conversions, or analysis results with `run`, `convert`, or `analyze` for future reference 2. **Batch processing and comparison** — Log batch operations with `batch` and side-by-side comparisons with `compare` 3. **Generating and previewing outputs** — Use `generate` to log generated results and `preview` to log draft outputs before finalizing 4. **Configuration and status tracking** — Record configuration changes with `config` and system states with `status` for audit trails 5. **Reporting and data export** — Create `report` entries for periodic summaries and use `stats` or `search` to review all logged data ## Examples ```bash # Log a calculation run calctool run "2 * (3 + 4) / 5 = 2.8" # Log a unit conversion calctool convert "100 USD to CNY = 725.30" # Log an analysis result calctool analyze "Dataset A: mean=45.2, std=12.1, n=500" # Compare two results calctool compare "Plan A: $12,000/yr vs Plan B: $10,800/yr — B saves 10%" # Generate a report entry calctool report "Q1 2026 summary: 142 entries, 98% accuracy" # Search for specific entries calctool search "USD" # View summary statistics calctool stats # View recent activity calctool recent # Check health status calctool status ``` ## How It Works CalcTool stores all data locally in `~/.local/share/calctool/`. Each command logs activity with timestamps for full traceability. Use `stats` to see a summary of entries per category with total counts and data size. Use `search` to find specific entries across all logs, `recent` to view the latest activity, or the built-in export helper to back up your data in JSON, CSV, or plain text format. --- Powered by BytesAgain | bytesagain.com | [REDACTED_SECRET]

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

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

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

_version() { echo "calctool v2.0.0"; }

_help() {
    echo "Calctool v2.0.0 — utility toolkit"
    echo ""
    echo "Usage: calctool <command> [args]"
    echo ""
    echo "Commands:"
    echo "  run                Run"
    echo "  check              Check"
    echo "  convert            Convert"
    echo "  analyze            Analyze"
    echo "  generate           Generate"
    echo "  preview            Preview"
    echo "  batch              Batch"
    echo "  compare            Compare"
    echo "  export             Export"
    echo "  config             Config"
    echo "  status             Status"
    echo "  report             Report"
    echo "  stats              Summary statistics"
    echo "  export <fmt>       Export (json|csv|txt)"
    echo "  status             Health check"
    echo "  help               Show this help"
    echo "  version            Show version"
    echo ""
    echo "Data: $DATA_DIR"
}

_stats() {
    echo "=== Calctool 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)"
    echo "  Since: $(head -1 "$DATA_DIR/history.log" 2>/dev/null | cut -d'|' -f1 || echo 'N/A')"
}

_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 "" >> "$out"
            echo "]" >> "$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 "=== Calctool Export ===" > "$out"
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                echo "--- $(basename "$f" .log) ---" >> "$out"
                cat "$f" >> "$out"
                echo "" >> "$out"
            done
            ;;
        *) echo "Formats: json, csv, txt"; return 1 ;;
    esac
    echo "Exported to $out ($(wc -c < "$out") bytes)"
}

_status() {
    echo "=== Calctool 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)"
    local last=$(tail -1 "$DATA_DIR/history.log" 2>/dev/null || echo "never")
    echo "  Last activity: $last"
    echo "  Status: OK"
}

_search() {
    local term="${1:?Usage: calctool search <term>}"
    echo "Searching for: $term"
    local found=0
    for f in "$DATA_DIR"/*.log; do
        [ -f "$f" ] || continue
        local matches=$(grep -i "$term" "$f" 2>/dev/null || true)
        if [ -n "$matches" ]; then
            echo "  --- $(basename "$f" .log) ---"
            echo "$matches" | while read -r line; do
                echo "    $line"
                found=$((found + 1))
            done
        fi
    done
    [ $found -eq 0 ] && echo "  No matches found."
}

_recent() {
    echo "=== Recent Activity ==="
    if [ -f "$DATA_DIR/history.log" ]; then
        tail -20 "$DATA_DIR/history.log" | while IFS='' read -r line; do
            echo "  $line"
        done
    else
        echo "  No activity yet."
    fi
}

# Main dispatch
case "${1:-help}" in
    run)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent run entries:"
            tail -20 "$DATA_DIR/run.log" 2>/dev/null || echo "  No entries yet. Use: calctool run <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/run.log"
            local total=$(wc -l < "$DATA_DIR/run.log")
            echo "  [Calctool] run: $input"
            echo "  Saved. Total run entries: $total"
            _log "run" "$input"
        fi
        ;;
    check)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent check entries:"
            tail -20 "$DATA_DIR/check.log" 2>/dev/null || echo "  No entries yet. Use: calctool check <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/check.log"
            local total=$(wc -l < "$DATA_DIR/check.log")
            echo "  [Calctool] check: $input"
            echo "  Saved. Total check entries: $total"
            _log "check" "$input"
        fi
        ;;
    convert)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent convert entries:"
            tail -20 "$DATA_DIR/convert.log" 2>/dev/null || echo "  No entries yet. Use: calctool convert <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/convert.log"
            local total=$(wc -l < "$DATA_DIR/convert.log")
            echo "  [Calctool] convert: $input"
            echo "  Saved. Total convert entries: $total"
            _log "convert" "$input"
        fi
        ;;
    analyze)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent analyze entries:"
            tail -20 "$DATA_DIR/analyze.log" 2>/dev/null || echo "  No entries yet. Use: calctool analyze <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/analyze.log"
            local total=$(wc -l < "$DATA_DIR/analyze.log")
            echo "  [Calctool] analyze: $input"
            echo "  Saved. Total analyze entries: $total"
            _log "analyze" "$input"
        fi
        ;;
    generate)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent generate entries:"
            tail -20 "$DATA_DIR/generate.log" 2>/dev/null || echo "  No entries yet. Use: calctool generate <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/generate.log"
            local total=$(wc -l < "$DATA_DIR/generate.log")
            echo "  [Calctool] generate: $input"
            echo "  Saved. Total generate entries: $total"
            _log "generate" "$input"
        fi
        ;;
    preview)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent preview entries:"
            tail -20 "$DATA_DIR/preview.log" 2>/dev/null || echo "  No entries yet. Use: calctool preview <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/preview.log"
            local total=$(wc -l < "$DATA_DIR/preview.log")
            echo "  [Calctool] preview: $input"
            echo "  Saved. Total preview entries: $total"
            _log "preview" "$input"
        fi
        ;;
    batch)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent batch entries:"
            tail -20 "$DATA_DIR/batch.log" 2>/dev/null || echo "  No entries yet. Use: calctool batch <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/batch.log"
            local total=$(wc -l < "$DATA_DIR/batch.log")
            echo "  [Calctool] batch: $input"
            echo "  Saved. Total batch entries: $total"
            _log "batch" "$input"
        fi
        ;;
    compare)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent compare entries:"
            tail -20 "$DATA_DIR/compare.log" 2>/dev/null || echo "  No entries yet. Use: calctool compare <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/compare.log"
            local total=$(wc -l < "$DATA_DIR/compare.log")
            echo "  [Calctool] compare: $input"
            echo "  Saved. Total compare entries: $total"
            _log "compare" "$input"
        fi
        ;;
    export)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent export entries:"
            tail -20 "$DATA_DIR/export.log" 2>/dev/null || echo "  No entries yet. Use: calctool export <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/export.log"
            local total=$(wc -l < "$DATA_DIR/export.log")
            echo "  [Calctool] export: $input"
            echo "  Saved. Total export entries: $total"
            _log "export" "$input"
        fi
        ;;
    config)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent config entries:"
            tail -20 "$DATA_DIR/config.log" 2>/dev/null || echo "  No entries yet. Use: calctool config <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/config.log"
            local total=$(wc -l < "$DATA_DIR/config.log")
            echo "  [Calctool] config: $input"
            echo "  Saved. Total config entries: $total"
            _log "config" "$input"
        fi
        ;;
    status)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent status entries:"
            tail -20 "$DATA_DIR/status.log" 2>/dev/null || echo "  No entries yet. Use: calctool status <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/status.log"
            local total=$(wc -l < "$DATA_DIR/status.log")
            echo "  [Calctool] status: $input"
            echo "  Saved. Total status entries: $total"
            _log "status" "$input"
        fi
        ;;
    report)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent report entries:"
            tail -20 "$DATA_DIR/report.log" 2>/dev/null || echo "  No entries yet. Use: calctool report <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/report.log"
            local total=$(wc -l < "$DATA_DIR/report.log")
            echo "  [Calctool] report: $input"
            echo "  Saved. Total report entries: $total"
            _log "report" "$input"
        fi
        ;;
    stats) _stats ;;
    export) shift; _export "$@" ;;
    search) shift; _search "$@" ;;
    recent) _recent ;;
    status) _status ;;
    help|--help|-h) _help ;;
    version|--version|-v) _version ;;
    *)
        echo "Unknown command: $1"
        echo "Run 'calctool help' for available commands."
        exit 1
        ;;
esac

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