Skill: ckchzh/sensor (version 2.0.0)

--- name: "Sensor" description: "Read and manage IoT sensor data from the terminal. Use when polling readings, checking device connectivity, converting units, analyzing telemetry trends." version: "2.0.0" author: "BytesAgain" homepage: https://bytesagain.com source: https://github.com/bytesagain/ai-skills tags: ["sensor", "tool", "terminal", "cli", "utility"] --- # Sensor A terminal-first utility toolkit for managing sensor data. Log readings, check device status, analyze telemetry, generate reports, and export data — all with timestamped logging and full export support. ## Why Sensor? - Works entirely offline — your data never leaves your machine - Simple command-line interface, no GUI needed - Export to JSON, CSV, or plain text anytime - Automatic history and activity logging - Each command maintains its own dedicated log file ## Commands | Command | Description | |---------|-------------| | `sensor run <input>` | Run a sensor task (or view recent runs with no args) | | `sensor check <input>` | Check sensor readings or device connectivity | | `sensor convert <input>` | Convert between units or data formats | | `sensor analyze <input>` | Analyze telemetry trends and patterns | | `sensor generate <input>` | Generate sensor configurations or test data | | `sensor preview <input>` | Preview a sensor operation before executing | | `sensor batch <input>` | Batch-process multiple sensor readings | | `sensor compare <input>` | Compare sensor readings across devices or time periods | | `sensor export <input>` | Log an export operation (or view recent exports) | | `sensor config <input>` | Store or review sensor configuration settings | | `sensor status <input>` | Log a device status update (or view recent status entries) | | `sensor report <input>` | Generate or log a sensor data report | | `sensor stats` | Show summary statistics across all categories | | `sensor export <fmt>` | Export all data (formats: json, csv, txt) | | `sensor search <term>` | Search across all logged entries | | `sensor recent` | Show the 20 most recent activity log entries | | `sensor status` | Health check — version, data dir, entry count, disk usage | | `sensor help` | Show full usage information | | `sensor version` | Show version (v2.0.0) | Each action command works in two modes: - **With arguments:** saves the input with a timestamp to `<command>.log` and logs to history - **Without arguments:** displays the 20 most recent entries for that command ## Data Storage All data is stored locally in `~/.local/share/sensor/`. Each command writes to its own dedicated log file (e.g., `run.log`, `check.log`, `analyze.log`). A unified `history.log` tracks all activity with timestamps. Data never leaves your machine. Directory structure: ``` ~/.local/share/sensor/ ├── run.log ├── check.log ├── convert.log ├── analyze.log ├── generate.log ├── preview.log ├── batch.log ├── compare.log ├── export.log ├── config.log ├── status.log ├── report.log └── history.log ``` ## Requirements - Bash (with `set -euo pipefail`) - Standard Unix utilities: `date`, `wc`, `du`, `tail`, `grep`, `sed`, `cat` - No external dependencies or network access required ## When to Use 1. **Logging IoT sensor readings from the field** — use `run` and `check` to record temperature, humidity, pressure, or other sensor readings with automatic timestamps 2. **Analyzing telemetry trends across devices** — use `analyze` and `compare` to identify patterns in sensor data and spot anomalies between devices or time periods 3. **Converting sensor data between units** — use `convert` to log unit conversions (Celsius to Fahrenheit, PSI to bar, etc.) and keep a record of transformations 4. **Generating periodic sensor reports** — use `report`, `stats`, and `export` to compile sensor data into JSON, CSV, or text formats for dashboards or stakeholder reviews 5. **Batch-processing multi-device sensor data** — use `batch` and `config` to handle bulk sensor operations and maintain device configuration records ## Examples ```bash # Log a temperature reading sensor run "Sensor-A3: 23.5°C at warehouse zone B" # Check device connectivity status sensor check "Gateway-01: online, 12 sensors connected, latency 45ms" # Analyze a telemetry trend sensor analyze "Temperature drift: +0.3°C/hour over last 6 hours in cold storage" # Export all sensor data as CSV for analysis sensor export csv # Search for all entries related to a specific sensor sensor search "Sensor-A3" ``` ## Configuration Set the `SENSOR_DIR` environment variable to change the data directory. Default: `~/.local/share/sensor/` ## Output All commands output results to stdout. Redirect to a file with `> output.txt` if needed. The `export` command writes directly to `~/.local/share/sensor/export.<fmt>`. --- Powered by BytesAgain | bytesagain.com | [REDACTED_SECRET]

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

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

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

_help() {
    echo "Sensor v2.0.0 — utility toolkit"
    echo ""
    echo "Usage: sensor <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 "  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 "=== Sensor 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 "=== Sensor 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 "=== Sensor 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: sensor 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
    run)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent run entries:"
            tail -20 "$DATA_DIR/run.log" 2>/dev/null || echo "  No entries yet. Use: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: sensor 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 "  [Sensor] 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: $1 — run 'sensor help'"
        exit 1
        ;;
esac

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