Skill: xueyetianya/codepal (version 2.0.1)

--- name: CodePal description: "Analyze codebases quickly with AI-powered intelligence and insights. Use when understanding unfamiliar repos, checking quality, or generating summaries." version: "2.0.0" author: "BytesAgain" homepage: https://bytesagain.com source: https://github.com/bytesagain/ai-skills tags: ["code","developer","analysis","todo","loc","dependencies","programming","devtools"] categories: ["Developer Tools", "Productivity"] --- # CodePal A full-featured devtools toolkit for checking, validating, generating, formatting, linting, explaining, converting, diffing, previewing, and fixing code — with built-in logging, search, statistics, and data export. ## Commands | Command | Description | |---------|-------------| | `check <input>` | Check code and log the result; without args shows recent check entries | | `validate <input>` | Validate code input; without args shows recent validate entries | | `generate <input>` | Generate code from a description; without args shows recent entries | | `format <input>` | Format code; without args shows recent format entries | | `lint <input>` | Lint code for potential issues; without args shows recent lint entries | | `explain <input>` | Explain a code snippet or concept; without args shows recent entries | | `convert <input>` | Convert code between languages or formats; without args shows recent entries | | `template <input>` | Create or apply code templates; without args shows recent entries | | `diff <input>` | Log code differences; without args shows recent diff entries | | `preview <input>` | Preview code output; without args shows recent preview entries | | `fix <input>` | Record a code fix; without args shows recent fix entries | | `report <input>` | Generate a code report; without args shows recent report entries | | `stats` | Show summary statistics across all log categories | | `export <fmt>` | Export all data (json, csv, or txt) | | `search <term>` | Search across all logged entries for a keyword | | `recent` | Show the 20 most recent entries from the activity log | | `status` | Health check — version, data dir, total entries, disk usage, last activity | | `help` | Show all available commands | | `version` | Print version (v2.0.0) | ## Usage ```bash codepal <command> [args] ``` Each command with arguments logs the input with a timestamp to a category-specific log file. Running a command with no arguments shows the most recent entries for that category. ## Data Storage - **Default location**: `~/.local/share/codepal` - **Log files**: Each command has its own log file (e.g., `check.log`, `lint.log`, `generate.log`) - **History**: All actions are also recorded in `history.log` with timestamps - **Export formats**: JSON (structured array of objects), CSV (type/time/value columns), plain text (grouped by category) ## Requirements - Bash 4+ (strict mode: `set -euo pipefail`) - No external dependencies or API keys required - Standard Unix tools (`date`, `wc`, `grep`, `du`, `head`, `tail`) ## When to Use 1. **Code review tracking** — Use `check`, `lint`, and `validate` to log issues discovered during code review sessions, then `search` to find them later 2. **Learning unfamiliar codebases** — Use `explain` to document your understanding of code patterns, then `report` to create summaries 3. **Code generation and templating** — Use `generate` to log code generation prompts and `template` to track template usage 4. **Diffing and debugging** — Use `diff` to record code changes and `fix` to document bug fixes, creating an audit trail 5. **Team metrics and reporting** — Use `stats` for activity summaries, `export json` to feed into dashboards, and `recent` for quick status checks ## Examples ```bash # Check a function codepal check "validateEmail() is missing null check" # Generate a code snippet description codepal generate "React hook for debounced search" # Lint a file codepal lint "server.js:42 — unused variable 'config'" # Explain a concept codepal explain "JavaScript closure in event handler" # Record a diff codepal diff "Refactored auth middleware to use async/await" # Fix a bug codepal fix "Off-by-one error in pagination logic" # View aggregate statistics codepal stats # Export all logged data as CSV codepal export csv # Search for entries about authentication codepal search "auth" # Show recent activity codepal recent # Health check codepal status ``` ## Output - Command results print to stdout - Entries are timestamped (`YYYY-MM-DD HH:MM`) and persisted to `~/.local/share/codepal/<category>.log` - Export files are written to `~/.local/share/codepal/export.<fmt>` with a byte count confirmation --- Powered by BytesAgain | bytesagain.com | [REDACTED_SECRET]

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

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

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

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

_help() {
    echo "Codepal v2.0.0 — devtools toolkit"
    echo ""
    echo "Usage: codepal <command> [args]"
    echo ""
    echo "Commands:"
    echo "  check              Check"
    echo "  validate           Validate"
    echo "  generate           Generate"
    echo "  format             Format"
    echo "  lint               Lint"
    echo "  explain            Explain"
    echo "  convert            Convert"
    echo "  template           Template"
    echo "  diff               Diff"
    echo "  preview            Preview"
    echo "  fix                Fix"
    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 "=== Codepal 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 "=== Codepal 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 "=== Codepal 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: codepal 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
    check)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent check entries:"
            tail -20 "$DATA_DIR/check.log" 2>/dev/null || echo "  No entries yet. Use: codepal 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 "  [Codepal] check: $input"
            echo "  Saved. Total check entries: $total"
            _log "check" "$input"
        fi
        ;;
    validate)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent validate entries:"
            tail -20 "$DATA_DIR/validate.log" 2>/dev/null || echo "  No entries yet. Use: codepal validate <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/validate.log"
            local total=$(wc -l < "$DATA_DIR/validate.log")
            echo "  [Codepal] validate: $input"
            echo "  Saved. Total validate entries: $total"
            _log "validate" "$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: codepal 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 "  [Codepal] generate: $input"
            echo "  Saved. Total generate entries: $total"
            _log "generate" "$input"
        fi
        ;;
    format)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent format entries:"
            tail -20 "$DATA_DIR/format.log" 2>/dev/null || echo "  No entries yet. Use: codepal format <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/format.log"
            local total=$(wc -l < "$DATA_DIR/format.log")
            echo "  [Codepal] format: $input"
            echo "  Saved. Total format entries: $total"
            _log "format" "$input"
        fi
        ;;
    lint)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent lint entries:"
            tail -20 "$DATA_DIR/lint.log" 2>/dev/null || echo "  No entries yet. Use: codepal lint <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/lint.log"
            local total=$(wc -l < "$DATA_DIR/lint.log")
            echo "  [Codepal] lint: $input"
            echo "  Saved. Total lint entries: $total"
            _log "lint" "$input"
        fi
        ;;
    explain)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent explain entries:"
            tail -20 "$DATA_DIR/explain.log" 2>/dev/null || echo "  No entries yet. Use: codepal explain <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/explain.log"
            local total=$(wc -l < "$DATA_DIR/explain.log")
            echo "  [Codepal] explain: $input"
            echo "  Saved. Total explain entries: $total"
            _log "explain" "$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: codepal 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 "  [Codepal] convert: $input"
            echo "  Saved. Total convert entries: $total"
            _log "convert" "$input"
        fi
        ;;
    template)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent template entries:"
            tail -20 "$DATA_DIR/template.log" 2>/dev/null || echo "  No entries yet. Use: codepal template <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/template.log"
            local total=$(wc -l < "$DATA_DIR/template.log")
            echo "  [Codepal] template: $input"
            echo "  Saved. Total template entries: $total"
            _log "template" "$input"
        fi
        ;;
    diff)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent diff entries:"
            tail -20 "$DATA_DIR/diff.log" 2>/dev/null || echo "  No entries yet. Use: codepal diff <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/diff.log"
            local total=$(wc -l < "$DATA_DIR/diff.log")
            echo "  [Codepal] diff: $input"
            echo "  Saved. Total diff entries: $total"
            _log "diff" "$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: codepal 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 "  [Codepal] preview: $input"
            echo "  Saved. Total preview entries: $total"
            _log "preview" "$input"
        fi
        ;;
    fix)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent fix entries:"
            tail -20 "$DATA_DIR/fix.log" 2>/dev/null || echo "  No entries yet. Use: codepal fix <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/fix.log"
            local total=$(wc -l < "$DATA_DIR/fix.log")
            echo "  [Codepal] fix: $input"
            echo "  Saved. Total fix entries: $total"
            _log "fix" "$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: codepal 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 "  [Codepal] 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 'codepal help' for available commands."
        exit 1
        ;;
esac

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